[
  {
    "path": ".clang-format",
    "content": "BasedOnStyle: Microsoft\nIndentWidth: 4\nUseTab: Never\n\nLanguage: Cpp\nStandard: Cpp11\nSortIncludes: false\nAlignAfterOpenBracket: Align\nAlignEscapedNewlines: Left\nAlignOperands: true\nAlignTrailingComments: true\n# AllowShortBlocksOnASingleLine: Empty\nAllowShortCaseLabelsOnASingleLine: true\nAllowShortFunctionsOnASingleLine: InlineOnly\nAllowShortIfStatementsOnASingleLine: Never\nAllowShortLambdasOnASingleLine: All\nAlwaysBreakAfterReturnType: None\nBreakConstructorInitializers: BeforeComma\nBreakInheritanceList: BeforeComma\nCpp11BracedListStyle: true\nPointerAlignment: Right\nSpaceBeforeAssignmentOperators: true\nSpaceBeforeCtorInitializerColon: true\nSpaceBeforeInheritanceColon: true\nSpaceBeforeParens: ControlStatements\nSpaceBeforeRangeBasedForLoopColon: true\n# SpaceBeforeSquareBrackets: false\n# SpaceInEmptyBlock: false\nSpaceInEmptyParentheses: false\nSpacesInAngles: false\nSpacesInCStyleCastParentheses: false\n# SpacesInConditionalStatement: false\nSpacesInParentheses: false\nSpacesInSquareBrackets: false\n"
  },
  {
    "path": ".editorconfig",
    "content": "root = true\n\n[*]\nend_of_line = CRLF\nindent_style = space\nindent_size = 4\ninsert_final_newline = true\ntrim_trailing_whitespace = true\n\n[ffmpeg/**]\nend_of_line = LF\nindent_style = space\nindent_size = 4\n\n[libbluray/**]\nend_of_line = LF\nindent_style = space\nindent_size = 4\n"
  },
  {
    "path": ".github/FUNDING.yml",
    "content": "# These are supported funding model platforms\n\ngithub: Nevcairiel # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]\npatreon: # Replace with a single Patreon username\nopen_collective: # Replace with a single Open Collective username\nko_fi: # Replace with a single Ko-fi username\ntidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel\ncommunity_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry\nliberapay: # Replace with a single Liberapay username\nissuehunt: # Replace with a single IssueHunt username\notechie: # Replace with a single Otechie username\nlfx_crowdfunding: # Replace with a single LFX Crowdfunding project-name e.g., cloud-foundry\ncustom: # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']\n"
  },
  {
    "path": ".gitignore",
    "content": "\n*.user\n*.suo\n*.sdf\n*.opensdf\n*.aps\n*.db\n*.opendb\n\n/ipch\n/bin_*\n/common/includes/version_rev.h\n/.vs\n"
  },
  {
    "path": ".gitmodules",
    "content": "[submodule \"ffmpeg\"]\n\tpath = ffmpeg\n\turl = https://gitea.1f0.de/LAV/FFmpeg.git\n[submodule \"libbluray\"]\n\tpath = libbluray\n\turl = https://gitea.1f0.de/LAV/libbluray.git\n[submodule \"qsdecoder\"]\n\tpath = qsdecoder\n\turl = https://gitea.1f0.de/LAV/qsdecoder.git\n"
  },
  {
    "path": "CHANGELOG.txt",
    "content": "LAV DirectShow Filters Changelog\n===================================\n0.81.0 - 2026/01/12\nLAV Splitter\n- NEW: Support for APV (Advanced Professional Video) video streams\n- Fixed: VVC in MP4 without CTTS did not play properly\n- Fixed: AV1 streams with invalid metadata did not get handled correctly\n\nLAV Video\n- NEW: Support for decoding APV (Advanced Professional Video)\n- Changed: Re-designed pixel format mapping to be based on a heuristic rather then hard-coded, improving support for rarely-used formats\n- Fixed: Deinterlacing of 4:2:2 videos was broken in 0.80\n\nLAV Audio\n- Fixed: Bitstreaming TrueHD from Blu-rays with seamless branching could result in out-of-sync audio, or a noticeable gap\n\n0.80.0 - 2025/06/20\nLAV Splitter\n- NEW: Introduced the IURLSourceFilterLAV interface to allow opening URLs with custom user agent and referrer\n- NEW: Added support for WebP images\n- Changed: Increased the length of the advanced subtitle selection field, so its no longer cut off after 255 characters\n- Changed: Improved buffering behavior on badly interleaved video files\n- Fixed: Audio streams with an unknown/unsupported codec are no longer selected for playback, as long as others are present\n- Fixed: Improved accuracy of reported FPS from AviSynth scripts\n\nLAV Video\n- NEW: D3D11 support for HEVC 4:2:2 and 4:4:4 hardware decoding\n- NEW: Dolby Vision extension metadata is exported for renderers to use\n- Changed: Added additional media types to support more video streams\n- Changed: Updated dav1d for significant AV1 decoding improvements\n- Fixed: Improved handling of H.264 4:4:4 files encoded by certain versions of x264\n- Fixed: VP9 DXVA2/D3D11 decoding could result in artifacts on some clips\n- Fixed: Decoding ProRes reports more accurate color details\n\nLAV Audio\n- Changed: Added support for additional ADPCM audio codecs\n\n0.79.2 - 2024/04/08\nLAV Splitter\n- Fixed: Buffering media from a high latency source was slower then expected (since 0.79)\n\nLAV Audio\n- Fixed: Bitstream AC3 audio could fallback to PCM on streams that start with a corrupt audio frame (since 0.78)\n- Fixed: Resolved a memory leak when bitstreaming AC3\n\n0.79.1 - 2024/03/28\nLAV Video\n- Fixed: Resolved a glitch when playing HEVC video\n\n0.79.0 - 2024/03/25\nLAV Splitter\n- NEW: Support for demuxing VVC video\n- Changed: Updated language lists to support all relevant language codes\n- Changed: Improved resilience of streaming HLS\n- Changed: Tweaked frame rate detection logic\n\nLAV Video:\n- NEW: Support for decoding VVC video\n\n0.78.0 - 2023/10/25\nLAV Splitter\n- NEW: Added identification of DTS:X in DTS HD-HRA streams\n- NEW: Support for various stream flags in Matroska containers (Hearing Impaired, and more)\n- Changed: Text-based subtitle selection now uses case-insensitive matches (ASCII characters only)\n- Fixed: Many stream titles in MP4 files weren't being read properly\n\nLAV Video\n- NEW: Support for decoding SMC video\n- Fixed: HLG video streams could have their HLG flag overriden in some circumstances\n\nLAV Audio\n- Fixed: TrueHD bitstreaming of Atmos tracks could cause output timestamps to be off, confusing some audio renderers\n\n0.77.2 - 2023/03/08\nLAV Splitter\n- NEW: Added identification for spatial/immersive audio extensions (Atmos, DTS:X)\n- Changed: More reasonable rounding for odd aspect ratios, avoiding issues with some video pipelines\n- Fixed: Improved compatibility with some FTP servers\n\nLAV Audio\n- Fixed: Restored the default channel layouts for 5.1 and 7.1 to the correct layout (accidentally changed in 0.77, causing some playback issues)\n- Fixed: Some TrueHD files would not decode correctly\n- Fixed: Clipping protection did not engage when using Integer output\n\n0.77.1 - 2022/11/15\nLAV Splitter\n- Fixed: More MP4 keyframe information fixes\n\n0.77.0 - 2022/11/10\nLAV Splitter\n- Fixed: Improved handling of multichannel PCM channel assignments\n- Fixed: MP4 Keyframe information could be wrong\n\nLAV Audio\n- NEW: Support for audio with more then 8 channel, including automatic downmixing if required\n\n0.76.1 - 2022/02/28\nLAV Splitter\n- Changed: When requesting a HTTP URL, the URL itself is send as a referrer to increase compatibility\n- Fixed: The priority of \"Default\" subtitle tracks in MKV files was wrong when a forced track was present\n\nLAV Video\n- Changed: Improved color reporting for DVD menus/subtitles\n- Fixed: D3D11 surface clearing did not work properly on Intel GPUs\n\n0.76.0 - 2022/01/22\nLAV Splitter\n- NEW: Added an option to re-evaluate subtitle stream selection when the audio language changes\n- NEW: Improved advanced subtitle selection syntax with negated flags (positive and negative flags can now be combined for more flexible selection)\n- Changed: Improved variant/stream selection in DASH and HLS streams\n- Changed: Video streams with the highest bitrate are preferred (if equal resolution)\n\nLAV Video\n- NEW: Support for passing DoVi metadata to video renderers\n- NEW: BobWeaver (BWDIF) software deinterlacer (a blend of YADIF and Weston, focusing on their individual strengths)\n- NEW: Support for FIC screen capture video\n- Changed: D3D11 video surfaces are flushed to black before decoding, avoiding green artifacts\n- Changed: D3D11 devices are created up to feature level 12.1\n\nLAV Audio\n- Fixed: TrueHD bitstreaming could result in A/V sync issues or drop-outs\n- Removed: Support for the external DTS decoder (dtsdecoderdll.dll) has been removed\n\n0.75.1 - 2021/06/21\nLAV Splitter\n- Changed: AV1 files with no extradata will now generate a format header with stream information for decoders to use\n- Fixed: Improved stream selection when multiple \"default\" video tracks are present\n\nLAV Video\n- Changed: Updated dav1d for significant improvements in AV1 10-bit decoding performance\n- Changed: AV1 hardware decoding will more reliably engage when provided with additional stream information from the demuxer\n\nLAV Audio\n- Fixed: Opus decoding had audible artifacts in some files in 0.75\n\n0.75.0 - 2021/03/30\nLAV Splitter\n- NEW: Support for DASH streaming\n- NEW: WebVTT support in Matroska/WebM\n- Changed: Improved Font support from Matroska files\n- Fixed: Large queue size limits could result in the wrong limit being applied\n- Fixed: Resolved a memory leak in Matroska demuxing\n- Fixed: Avoid selecting a stream with only a single video frame in MP4 files, which is often a cover art\n- Fixed: Seeking in Matroska files with only audio cue points did not function\n- Fixed: Seeking to the beginning of certain HLS streams did not work properly\n- Fixed: Duration information in Matroska files is more reliable\n\nLAV Video\n- NEW: AV1 DXVA2/D3D11 hardware decoding support\n- NEW: ProRes 4444 XQ support\n- Faster: Updated dav1d decoder and improved thread configuration for significantly improved AV1 decoding speed\n- Fixed: Added a workaround for VP9 hardware decoding on AMD video cards\n- Fixed: H.264 streams exceeding the Level 5.1 DPB limit will no longer be hardware decoded\n- Fixed: Improved handling of missing reference frames in H.264 streams with hardware decoding\n- Fixed: HEVC streams encoding 8-bit video in a Main10 profile can be properly hardware decoded\n- Deprecated: NVIDIA CUVID and Intel QuickSync have been deprecated for future removal/replacement\n\nLAV Audio\n- Fixed: Resolved an issue with glitching TrueHD bitstreaming on seamless-branching titles\n- Fixed: Resolved a compatibility issue with some playback applications\n- Deprecated: Support for the binary DTS decoder (dtsdecoderdll.dll) has been deprecated for future removal\n\n0.74.1 - 2019/03/19\nLAV Video\n- Fixed: VP9 video could produce wrong timestamps, resulting in a black screen or other playback disruptions\n- Fixed: Decoding VP9 from a non-keyframe (ie. after a seek, or badly cut file) would not always recover properly once a keyframe was encountered\n\n0.74.0 - 2019/03/16\nLAV Splitter\n- Changed: Using GnuTLS for HTTPS and other TLS protocols, improving performance and compatibility with a lot of web streaming services (ie. YouTube Live Streams through youtube-dl, and more)\n- Fixed: Keyframes in MP4 files were being reported with a slightly offset timestamp, resulting in slow keyframe seeking\n- Fixed: Subtitles that stretch over chapter boundaries could be lost in Ordered Chapter MKV files\n- Fixed: Fonts embedded in MKVs without a proper mimetype were not being imported (now it checks the file extensions for .ttf/.otf as well)\n\nLAV Video\n- NEW: Initial support for parsing HDR10+ (SMPTE ST 2094-40) metadata, and passing it to the video renderer\n- NEW: Using the dav1d AV1 decoder for significantly improved AV1 decoding performance\n- Changed: Re-enabled experimental hardware acceleration for H.264 MVC 3D decoding on Intel GPUs, disabled by default\n- Changed: Updated Intel MediaSDK dispatchers to the latest Media SDK, fixing compatibility with newer runtimes in the Intel DCH drivers\n- Changed: Improved support for additional UtVideo subtypes\n\nLAV Audio\n- Changed: Added an option to disable the PCM fallback when bitstreaming is requested\n- Fixed: Further improvements to TrueHD Bitstreaming, resolving glitching on more new titles (particularly seamless branching titles)\n- Fixed: Automatic fallback from bitstreaming to PCM could crash in some situations\n\n0.73.1 - 2018/10/11\nLAV Video\n- Fixed: Container-provided color information will only overwrite video bitstream color information if its set and valid\n\nLAV Audio\n- Fixed: Certain multi-channel AAC streams did not decode in 0.73\n\n0.73.0 - 2018/10/05\nLAV Splitter\n- Changed: Export the description of cover art and attachments for use by players\n- Fixed: Properly marked the packet allocator as providing read-only packets, to avoid crashes with in-place transform filters\n\nLAV Video\n- NEW: Support for AV1 decoding using libaom\n- Changed: Enabled VP9 hardware acceleration by default\n- Fixed: The aspect ratio of certain WMV/VC-1 files was not being properly respected in the WMV9 MFT decoder\n\n0.72.0 - 2018/06/19\nLAV Video\n- Changed: Enabled CineformHD decoding by default, since the decoder has much improved\n- Fixed: Decoding Matroska files with Linked Segments which used old x264 4:4:4 encodes could result in corruption\n\nLAV Audio\n- NEW: Blu-ray Dolby Digital Plus 7.1 decoding and bitstreaming support\n- NEW: LAV Audio will fallback to audio decoding if bitstreaming is not supported by the audio renderer/hardware\n- Fixed: DTS-HD HRA bitstreaming did not work properly with many A/V receivers\n- Fixed: TrueHD bitstreaming could result in drop-outs on high bitrate TrueHD+Atmos streams\n\n0.71.0 - 2018/02/15\nGeneral\n- LAV Filters now requires Windows Vista or newer, Windows XP is no longer supported\n\nLAV Splitter\n- NEW: Preliminary support for UHD Blu-ray parsing\n\nLAV Video\n- NEW: D3D11 hardware accelerated decoding (native mode with madVR, Copy-Back otherwise)\n- Fixed: HDR metadata was not properly communicated to madVR in DXVA2-Native mode\n- Fixed: Anamorphic WMV9/VC-1 videos were not being played back with the correct aspect ratio in all cases\n- Fixed: Changing certain settings while playback was paused could result in a deadlock\n- Fixed: Playing severely corrupted HEVC streams with hardware decoding could result in playback failing entirely, instead of skipping over the corruption\n\nLAV Audio\n- NEW: Basic support for AAC 960 streams (common in DVB radio streams)\n\n0.70.2 - 2017/07/06\nLAV Video\n- Fixed: DXVA2 decoding could fail in 0.70 after a dynamic media type change\n\n0.70.1 - 2017/07/01\nLAV Video\n- NEW: DXVA2-CopyBack uses D3D9Ex to allow headless operation\n- Changed: Increased the maximum number of decode threads to 32\n- Changed: Rebalanced the \"Auto\" thread strategy to use the exact number of available CPU cores, instead of 1.5x the cores\n- Fixed: Certain H264 streams could crash in 0.70 due to lack of buffer padding\n\n0.70.0 - 2017/06/15\nGeneral\n- Official LAV Filters builds require a SSE2 capable CPU\n\nLAV Splitter\n- Fixed: Certain MP4/MOV files didn't play or seek correctly in recent versions of LAV Splitter\n- Fixed: HEVC in MP4 without PTS timestamp is being signaled appropriately\n- Fixed: Closing RTSP streams did not properly call the TEARDOWN function\n\nLAV Video\n- NEW: CUVID support for VP9 8/10-bit and HEVC 10/12-bit decoding\n- NEW: DXVA2 support for VP9 10-bit decoding\n- Changed: Simplified the internal dataflow to reduce overhead and improve performance\n- Changed: Enabled P010 output to EVR on Windows 10 Creators Update\n- Fixed: Y416 output was incorrect (required by madVR 0.91.8 and newer)\n- Fixed: Parsing H.264 MVC SEI NALs could fail in some cases\n- Fixed: CUVID decoding could deinterlace progressive streams under certain circumstances, degrading the quality\n\nLAV Audio\n- Fixed: LATM AAC streams with Program Config Elements (PCE) (common in DVB-T2 broadcast) played with audible distortions\n- Fixed: Very short PCM audio streams didn't play properly\n\n0.69.0 - 2016/12/11\nLAV Splitter\n- NEW: Support for extracting HDR metadata from YouTube HDR VP9 streams\n- Fixed: Reading MKV files could crash when encountering tags for unknown or disabled streams\n\nLAV Video\n- NEW: Support for 10-bit UtVideo\n- NEW: MagicYUV decoding support\n- NEW: Experimental support for CineformHD decoding\n- Fixed: Converting 12-bit 4:4:4 YCbCr to RGB32 would result in a garbled image\n- Fixed: Decoding certain H.264 streams could drop a few frames at the start of playback\n\nLAV Audio\n- NEW: DTS Express (LBR) decoding support\n\n0.68.1 - 2016/05/05\nLAV Splitter\n- NEW: Support for reading metadata tags from MKV files (including the \"3d-plane\" MVC 3D tag from MakeMKV 1.9.10 and newer)\n- Fixed: Improved handling of QuickTime codecs in MKV files\n- Fixed: S302M audio streams with non-pcm content did not work anymore (requires an external decoder)\n\nLAV Video\n- Changed: Flags for BT.2020 are exported in DXVA2_ExtendedFormat (previously only reported to madVR, since the Windows SDK did not specify them)\n- Changed: Prevent connections to the \"AVI Decompressor\" filter which could result in a broken image or crashes otherwise\n- Fixed: Some progressive files could report the wrong FPS when software deinterlacing was turned on\n- Fixed: MPEG-2 streams using \"intra refresh\" did not decode properly\n\nLAV Audio\n- Fixed: Decoding MPEG Audio streams from the Microsoft MPEG-1 Splitter could result in playback starting with an audible glitch\n\n0.68.0 - 2016/03/08\nLAV Splitter\n- NEW: H.264 MVC 3D demuxing from MKV 3D, Blu-ray discs and Blu-ray SSIF files\n- Fixed: The bitdepth of DTS-HD MA streams is reported properly in the stream information\n\nLAV Video\n- NEW: H.264 MVC 3D decoding (requires madVR 0.90 or newer)\n- NEW: HEVC HDR streams export the HDR metadata to the video renderer (requires madVR 0.89.18 or newer)\n- NEW: VP9 DXVA2 Hardware Acceleration\n- NEW: Weston Three Field Deinterlacing filter (w3fdif)\n- NEW: Ability to choose which GPU is used for DXVA2-CopyBack decoding\n- Changed: Removed the CUVID HQ processing option, it is now automatically used when appropriate\n- Fixed: CUVID would crash when playing certain HEVC files\n- Fixed: Some pixel format conversions were much slower than expected\n- Fixed: Pixel Format changes mid-stream were not re-negotiated with the renderer in all cases\n- Fixed: Changes in the framerate due to software deinterlacing are properly reflected in the media type\n\nLAV Audio\n- Fixed: Increased PCM buffering to avoid stuttering with TrueHD on some audio devices\n\n0.67.0 - 2015/11/15\nLAV Splitter\n- NEW: Support for HTTPS URLs\n- NEW: Automatic selection of the highest quality variant in HLS streams\n- Changed: Reverted back to the old ASF demuxer\n- Changed: Backported ASF seeking improvements to the old ASF demuxer\n- Fixed: ASS in AVI did not work in recent versions\n- Fixed: RTP/RTSP did not work properly in 0.66\n\nLAV Video\n- NEW: Improved DVD subtitle and menu drawing with madVR (support for madVRs subtitle repositioning and lower latency)\n- Changed: HEVC and 4K HWAccel is enabled by default\n- Changed: Enabled DXVA2-CB Direct Mode with YV12 output on 8-bit sources\n- Fixed: DVD menus could show a black screen instead of the menu in some situations\n\nLAV Audio\n- Fixed: Improved clipping behavior in badly mastered DTS-HD tracks\n\n0.66.0 - 2015/09/22\nLAV Splitter\n- NEW: Added options to increase the queue size for increased buffering\n- Changed: Switched ASF/WMV demuxing to a new demuxer from Libav\n- Fixed: Improved seeking with MPEG-TS files which contain teletext streams\n\nLAV Video\n- NEW: Support for DXVA2-Native decoding of HEVC 10-bit with EVR on supported GPUs\n- Changed: 4K Video Decoding on AMD graphics card is now enabled (needs recent drivers to work properly)\n- Changed: DXVA2-CB decoding uses less memory on NVIDIA graphics cards\n- Fixed: H264 DXVA2 decoding failed when no SPS/PPS was available in the media type\n- Fixed: Conversion of RGB48 to RGB32/24 did not properly use dithering\n- Fixed: Improved handling of a few DVD menu quirks\n- Fixed: Decoding 10-bit video with EVR could result in a black screen\n\nLAV Audio\n- Changed: 5.1 audio favors the \"Side\" 5.1 layout, which conforms to modern surround standards\n\n0.65.0 - 2015/04/21\nLAV Splitter\n- NEW: Support for MKV subtitle Cues to show subtitles immediately after a seek\n- NEW: Attachments and embedded cover art images are exported through the IDSMResourceBag interface\n- Fixed: Improved demuxing of HEVC in MPEG-TS and increased the reliability of the SPS/PPS/VPS extraction\n- Fixed: Demuxing Blu-rays/MPEG-TS where the first stream was not a video stream could result in broken timestamps\n- Fixed: Seeking in MKVs which are currently being written is more reliable\n\nLAV Video\n- Fixed: Improved HEVC DXVA2 decoding on a few samples\n- Fixed: Playback of VFR MPEG-4 in AVI had wrong timestamps in 0.64\n- Fixed: Improved handling of DVD subtitles without timestamps\n\nLAV Audio:\n- NEW: Native DTS-HD decoding using libdcadec\n- Changed: 5.1 audio prefers the speaker mask with side channels, to match recent specifications\n\n0.64.0 - 2015/02/13\nGeneral\n- NEW: Individual LAV Filters can now be blacklisted through the registry by creating a key with the executable name in HKCU\\Software\\LAV\\<Filter>\\Blacklist\n\nLAV Splitter\n- NEW: Support for RTMP using rtmpdump-style parameter syntax\n- NEW: Support for Opus-in-TS\n- Fixed: The language reported for audio/subtitle streams on some Blu-rays could be wrong\n\nLAV Video\n- NEW: HEVC Main10 decoding in DXVA2 Copy-Back mode\n- Faster: DXVA2 Copy-Back in direct output mode uses up to 50% less CPU and performance is improved accordingly\n- Fixed: H.264 streams with only DTS timestamps would play out of sync with DXVA2\n- Fixed: DXVA2 could crash on some MPEG-2 streams\n- Fixed: Improved compatibility with a few HEVC streams when using DXVA2\n\n0.63.0 - 2014/10/03\nLAV Splitter\n- NEW: Support for playing AES encrypted HLS streams\n- NEW: Advanced Subtitle selection allows selecting subtitles by a string match on the stream title\n- NEW: Support for rtspu, rtspm, rtspt and rtsph URLs to force the RTSP transport protocol\n- NEW: Animated GIF image support\n- Fixed: Improved timestamp handling of badly muxed/corrupted H.264 streams\n- Fixed: 4K ProRes streams in MKV didn't play reliably\n- Fixed: Some HEVC streams in MKV/MP4 didn't play properly\n- Fixed: VobSubs in MP4 didn't properly export their color palette\n- Fixed: Streaming MP3s through the Microsoft URL filter could result in the last audio frame to be partially repeated\n- Fixed: The duration of MP3 files would be wrong if it contained long IDv3 tags\n- Fixed: TrueHD streams with an Dolby Atmos sub-stream were not demuxed properly\n\nLAV Video\n- NEW: Experimental support for CUVID and DXVA2 HEVC acceleration\n- Faster: HEVC decoding is up to 100% faster\n- Fixed: DVD subtitle rendering could crash in 64-bit builds\n\nLAV Audio\n- Fixed: TrueHD streams with an Dolby Atmos sub-stream did not decode\n\n0.62.0 - 2014/06/12\nLAV Splitter\n- Fixed: The filtered Forced Subtitles stream did not properly send all related subtitle data in some cases\n\nLAV Video\n- NEW: Implemented a WMV9 MFT decoder to replace the old DMO decoder for VC-1/WMV3 on Windows 7 and above\n- NEW: Support for VP7 video\n- Fixed: Multi-threaded video decoding could result in a handle leak on some systems\n- Fixed: Video processing was slow on Windows XP due to inefficient memcpy use\n- Fixed: DVD subtitles could overlap on some discs\n\nLAV Audio\n- Fixed: Dynamic format switching to an audio stream with a different sample rate did not work in some cases\n\n0.61.2 - 2014/04/08\nGeneral\n- Installer: The installer does now backup DirectShow registry settings before overwriting them, allowing uninstall to restore them\n\nLAV Splitter\n- NEW: Support for ProRes in MKV\n- Fixed: Opening AviSynth scripts with LAV Splitter which used DirectShowSource to load LAV Splitter again caused a deadlock\n- Fixed: Audio-only AviSynth scripts did not show a duration.\n- Fixed: Cue Sheets with directives with empty parameters could cause a crash\n\nLAV Video\n- Fixed: AVC1 video streams without SPS/PPS in the configuration record did not decode properly\n- Fixed: Decoding H.264 streams with a resolution change using the DXVA2 Copy-Back decoder could crash\n- Fixed: YUV->RGB conversion produced the wrong output for the last line of odd-height 4:2:2 or 4:4:4 files\n\nLAV Audio\n- Changed: LAV Audio offers more alternate output configurations to the audio renderer if the audio renderer refuses our preferred format.\n- Fixed: Decoding AC3 audio with corrupted audio frames could cause unnecessary format changes to occur and disrupt playback\n- Fixed: Decoding DTS audio on a CPU without SSE2 support could crash on some streams\n\n0.61.1 - 2014/03/07\nLAV Splitter\n- NEW: Support for opening \"icyx://\" stream URLs\n- Fixed: Opening of some Blu-ray discs would take several minutes and could hang the player.\n\nLAV Video\n- Fixed: Aggressive Deinterlacing is no longer applied to soft-telecined content, which caused severe playback issues.\n\n0.61.0 - 2014/03/04\nLAV Splitter\n- NEW: Support for \"demuxing\" AviSynth scripts (requires AviSynth, 2.6 recommended)\n- NEW: Support for reading ICY stream metadata from ShoutCast streams\n- Fixed: The duration of DVB MPEG-TS files is being detected more reliably\n- Fixed: The ITrackInfo interface was not available in the last few versions\n- Fixed: The duration of certain Ogg Vorbis streams was wrong\n- Changed: DTS-HD audio tracks are now exposed using the official DTS-HD media type, in addition to the old DTS type\n- Workaround: Block WMP/WMC from always overwriting the initial track selection\n\nLAV Video\n- NEW: Support for Duck TrueMotion 1/2\n- NEW: Support for BT.2020 in YCbCr -> RGB conversions\n- Fixed: Format conversion could cause out of memory errors when converting high-resolution videos\n- Fixed: The decoder could crash if DXVA2 decoding failed and the software decoder is unavailable\n- Fixed: Reduced binary bloat caused by the YCbCr -> RGB converter, reducing binary size to nearly half\n- Fixed: Playback of RV30/RV40 was not smooth in 0.60\n- Fixed: Video corruption when using DXVA2 on Intel GPUs when decoding certain VC-1 or MPEG-2 clips\n- Fixed: Decoding WMV3 Complex profile automatically falls back to software, since hardware decoding is unsupported.\n- Faster: DXVA2 Copy-Back decoding on Intel GPUs is significantly faster\n- Changed: If the wmv9dmo decoder is unavailable, the FFmpeg decoder is automatically used instead\n- Changed: Updated QuickSync decoder to the latest version, fixes a few timestamp issues.\n- Changed: Relaxed the resolution checks for H.264 decoding on AMD GPUs, allowing files with 2K resolutions to be decoded (ie. 2048x1280, etc.)\n\nLAV Audio\n- NEW: Support for ATRAC3+\n- Fixed: Decoding AC3 audio could produce glitches in playback due to too aggressive error checking.\n\n0.60.1 - 2014/01/14\nLAV Splitter\n- Fixed a crash when opening MPEG-2 files with Stereo3D Metadata\n- Improved the format of the chapter names created from embedded cue sheets\n- Fixed an incompatibility in the IPropertyBag metadata interface with a few players\n\n0.60.0 - 2014/01/12\nLAV Splitter\n- Improved playback of a few Blu-ray discs, avoids a hiccup at clip change\n- Support for reading embedded Cue Sheets from audio files as chapters\n- Added support for reporting the stream bitrate through IBitrateInfo (for MPC-HC et al.)\n- Additional metadata from the source file is exported through IPropertyBag (including \"ROTATION\" for video orientation information)\n- Fixed demuxing of MKV files with huge SSA/ASS format blocks (> 1MB)\n- Fixed playback of certain MPEG4 ASP streams in MKV to be smooth\n\nLAV Video\n- Added support for VC-1/WMV3 DXVA2 decoding on recent Intel GPUs (Ivy Bridge/Haswell, needs recent drivers)\n- Fixed a crash when stopping playback or seeking on AMD when using DXVA2 Native\n- Fixed playback of WMVA videos in software mode\n- Fixed a few issues with output of odd-height videos when converting to various pixel formats\n- Fixed a few corner cases when reporting the video range to madVR\n- Fixed a crash when playing raw video files with unaligned width (non mod16)\n\nLAV Audio\n- The version of the DTS DLL decoder is now checked, and versions before 1.1.0.0 are blocked (since they do not work)\n- Fixed an issue with DTS parsing which could result in occasional audio stutter\n- Improved support for Opus audio pre-skip\n\n0.59.1 - 2013/11/04\nLAV Splitter\n- Fixed a regression when demuxing AAC audio from MP4/MOV files\n\n0.59.0 - 2013/11/03\nLAV Splitter\n- Support for demuxing H.265/HEVC and VP9\n- Improvements for H.264 in AVI or as raw video streams\n- Improved stream detection in files which start with a few seconds audio before the video\n- Improved timestamp handling when demuxing seamless branching Blu-rays, fixes a few hicups/freezes mid-stream\n\nLAV Video\n- Support for decoding H.265/HEVC and VP9\n- Accept H.264 from the MainConcept demuxer\n- Added support for DV Video from Canopus cameras\n\nLAV Audio\n- Fixed playback issues on a few DTS and DTS-HD tracks\n\n0.58.2 - 2013/07/26\nLAV Splitter\n- Fixed demuxing of WavPack from MKV\n\nLAV Video\n- Fixed a crash when YADIF was being used on a single- or dual-core CPU\n\nLAV Audio\n- Fixed decoding of DTS streams with a frame size change mid-stream\n\n0.58.1 - 2013/07/09\nLAV Splitter\n- Improved UDP network streaming\n- Added a new option to configure the stream analysis duration of network streams\n- Reduced subtitle delay on certain Blu-ray titles\n- Improved detection of DTS-in-WAV\n- Improved I/O behaviour for sequential reading from optical media\n\nLAV Video\n- Fixed dynamic reconnection on parameter changes (Aspect Ratio, etc) with VMR-9\n- Support for Apple Intermediate Codec (ICOD)\n- dxva2: added a check for AMD UVD/UVD+ GPUs to ensure the H.264 Level 4.1 DPB restrictions are met\n\nLAV Audio\n- Fixed a regression decoding certain Ogg Vorbis streams\n\n0.58.0 - 2013/06/23\nGeneral\n- LAV Filters now includes a manifest file to control DLL loading\n- Fixed the shortcuts to the configuration dialogs created by the installer in the start menu\n\nLAV Splitter\n- Handle the \"Default\" flag in MKV files with multiple video streams\n- Fixed a regression in VC-1 demuxing which caused some streams to fail decoding with the WMV9 DMO decoder\n- Improved transition between ordered chapters in certain (badly formed) MKV files\n- Improved handling of AVC1 in AVI files\n- Improved accuracy of IAMStreamSelect::get_CurrentMarker\n- Several potential crash fixes and stability improvements\n\nLAV Video\n- YADIF deinterlacing is now multi-threaded, significant performance improvement on multi-core CPUs\n- Improved detection of progressive streams to ensure deinterlacing is disabled, especially when \"Aggressive Deinterlacing\" is used\n- Restored Fraps constant frame rate output by proper handling of repeated frames\n- Support for the new UtVideo sub-types, and fixed a regression in UtVideo decoding\n- cuvid: fix double-rate deinterlacing on certain streams without timing information\n- Updated the Intel QuickSync Decoder to 0.44\n\n0.57.0 - 2013/05/20\nLAV Splitter\n- Added a Popup Menu to the Tray Icon which allows Stream, Edition and Chapter switching\n- Improved stream selection in files with multiple video streams\n- Improved performance when opening MKVs with linked segments\n- Fixed playback of MKVs with Segment Linking and Vorbis Audio\n\nLAV Video\n- Enabled Hardware/GPU Deinterlacing when using the QuickSync decoder\n- Support for JPEG2000 DCinema streams\n- Support for RGB48 output, and high-quality dithering of RGB48 to RGB32\n- Fixed a crash with DXVA2 Native on AMD GPUs in certain situations\n- Improved detection of H.264 RGB streams, improves support with EVR\n- Adjusted performance tuning for consistent performance in both playback and transcoding (in 0.56, transcoding could be slow)\n\nLAV Audio\n- Use the FLAC channel mask from metadata, fixes playback of FLAC files with non-standard channel layouts\n\n0.56.2 - 2013/04/19\nLAV Splitter\n- Emit the EC_LENGTH_CHANGED event when the edition is changed, to help players update their playback duration\n\nLAV Video\n- dxva2: fixed corruption/dropped frames after seeking in interlaced MPEG-2/VC-1 streams\n- dxva2: fixed corruption after seeking in interlaced H.264 on AMD GPUs\n- dxva2: fixed decoding of H.264 on AMD UVD/UVD+ GPUs (HD 2xxx/3xxx Series)\n- dxva2: disabled wmv3 decoding on AMD UVD/UVD+ GPUs (until it can be fixed)\n- Fixed colorspace used for YUV Fraps to always be BT.709\n- Added support for MPEG-4 Video with the BLZ0 FourCC (used in older Blizzard games)\n\n0.56.1 - 2013/04/13\nLAV Splitter\n- Fixed various crashes with ordered chapter MKVs\n- Fixed a crash when playing an MKV with a disabled subtitle track\n- Fixed switching between video streams with different codecs (ie. H264 -> MPEG2)\n\nLAV Video\n- Fixed a crash on close with DXVA2 Native\n- Re-tuned YADIF for smooth playback instead of benchmarking\n\n0.56.0 - 2013/04/10\nGeneral\n- Major ffmpeg update, the DLLs have had their version number increased\n\nLAV Splitter\n- Support for Matroska Ordered Chaptes / Segment Linking\n- Improved support for parsing language tags from OGM files\n- Small performance improvements by avoiding copying the stream data in memory needlessly\n- Improved duration calculation for MP3 files\n\nLAV Video\n- Performance improvements for single-threaded decoders and YADIF (up to 20% in some situations)\n\n0.55.3 - 2013/02/10\nLAV Splitter\n- Improved handling of Annex B H.264 in many containers\n- Improved support for external source filters without seeking ability (live sources)\n- Fixed duration in some MP4/MOV files\n- Fixed stream program assignment for some MPEG-TS files (resulted in some streams not visible)\n\nLAV Video\n- Added support for TSCC2\n- Fixed a crash when playing certain H.264 files with QuickSync or CUVID\n\n0.55.2 - 2013/01/25\nLAV Splitter\n- Improved support for MP4-style H.264 in AVI\n- Further improvements for AAC in MPEG-TS\n- Small improvements to handling Blu-rays with odd stream configurations\n- Improved handling of Ogg Vorbis streams\n\nLAV Video\n- Basic support for playing DVDs in different playback rates\n- Fixed DXVA2 resource cleanup which may have caused a crash in some situations with DXVA2-Native\n- Fixed A/V Sync when using the WMV9 DMO decoder (especially noticeable after seeking)\n\nLAV Audio\n- Improved AC3 decoding quality (thanks to madshi for the patch in ffmpeg)\n\n0.55.1 - 2013/01/11\nGeneral\n- Clicking the Tray Icon with a Property Page already active brings it back to the front\n\nLAV Splitter\n- Added an option to disable quality-based audio stream selection (selects the first stream matching the language preferences)\n- Removed Bitrate from audio quality criteria, because its too unreliable at this point.\n\nLAV Video\n- Fixed YADIF deinterlacing (broken after a ffmpeg update on 0.55)\n\nLAV Audio\n- Switched to Triangular Dithering for 16-bit Integer conversions\n\n0.55.0 - 2013/01/09\nGeneral\n- All Filters now have an optional tray icon which can open the property sheet when clicked (disabled by default)\n\nLAV Splitter\n- Improved FPS detection for interlaced H.264 streams in Matroska\n- Fixed H.264 in Ogg and PMP\n- Fixed seeking in RMVB files with AAC audio\n- Improved support for AAC in MPEG-TS (especially in ISDB-T)\n- Fixed Key-Frame seeking for AVI and added support for MP4\n\nLAV Video\n- Improved handling of raw RGB video with LAV Splitter (Video was upside-down in some cases)\n- Improved support for the Overlay Mixer renderer\n- Fixed decoding of non-mod16 video with CUVID\n- Fixed DXVA2 decoding of H.264 MBAFF content with >= 16px cropping\n- Support for fade in/out animations in DVD subtitles\n- Fixed DVD menu overlays showing too early on some discs\n- Fixed forced DVD subtitles being stuck on the screen until the next subtitle line\n- Improved playback of MPEG-1 in MKV with Haali Splitter\n\nLAV Audio\n- Fixed 6.1 to 7.1 upmixing when the standard channel layout option is turned off\n- Dithering when converting audio to 16-bit Integer\n- Fallback to DTS \"Core\" bitstreaming if DTS-HD fails\n\n0.54.1 - 2012/11/27\nLAV Splitter\n- Improved seeking in MP4 files created by Windows Live Movie Maker\n\nLAV Video\n- Improved H.264 DXVA on recent Intel GPUs (Sandy/Ivy Bridge and newer Atoms)\n  - Fixed corruption with high number of reference frames ( > 11 )\n  - Fixed corruption in MBAFF interlaced content\n- Fixed an issue that caused DVD menus/subtitles to stop working in DXVA2 Native mode in some situations\n\n0.54.0 - 2012/11/24\nLAV Splitter\n- Subtitle selection in \"Default\" mode now properly takes the \"Default Track\" flag into account\n- Fixed an issue that could cause graph flush events to be send out of sync\n\nLAV Video\n- The DXVA2 Native decoder can now properly detect hardware support for video resolutions\n  - Allows 4K DXVA2 decoding on NVIDIA\n- New options to control which resolutions are being handled by the hardware decoder (SD, HD and 4K/UHD)\n- Added support for DVD menu overlays and DVD subtitles with DXVA2 Native\n- Improved DXVA2 Native support with madVR\n- Fixed a freeze when playing corrupted H.264 streams in DXVA2 Native\n- Fixed a few rare DVD menu issues when using the QuickSync decoder\n\n0.53.2 - 2012/11/11\nLAV Video\n- Fixed DVD menu still frames with DXVA2 Copy Back\n- Fixed Live TV playback with QuickSync\n\n0.53.1 - 2012/11/10\nLAV Video\n- Fixed initial media type when YADIF is active\n- Fixed an image corruption issue with DVD playback\n- Improved handling of DVD menus on some discs\n- Reduced decode latency with CUVID/DXVA2-CB on DVDs for smoother playback in some situations\n- Added an option to toggle HW decoding for DVDs\n\n0.53.0 - 2012/11/05\nLAV Splitter\n- Added support for reading image files (tiff, png, jpeg, tga, bmp)\n- Support for MPEG-4 ASP in MPEG-TS\n- Support for reading metadata using the IAMMediaContent interface\n- Fixed Aspect Ratio on some wmv/asf files\n\nLAV Video\n- Fixed a crash in the WMV9 DMO decoder on Windows 8\n- DVD improvements\n  - Subtitles are properly cleared from the screen, and won't be shown forever on some discs\n  - Improved subtitle/menu positioning on some PAL discs\n  - Improved handling of still frame DVD menus\n  - Fixed a deadlock that caused the player to freeze in some DVD menus\n  - Improved quality of blending subtitles/menus\n- QuickSync improvements\n  - Support using QuickSync in Fullscreen Exclusive mode (ie. in WMC)\n  - Improved fallback to software decoding if QuickSync is not available\n  - Support for DVD decoding\n- Added support for Avid DV\n- Properly indicate progressive video when YADIF deinterlacing is activated\n\nLAV Audio\n- Added proper DirectShow types and config options for AMR-NB, Nellymoser and various (AD)PCM variants\n\n0.52.0 - 2012/10/20\nLAV Splitter\n- Improved IO performance on network sources\n- Added an option to configure the maximum memory usage of the frame queues\n- Support ALAC in MKV\n- Support SRT subtitles in AVI\n- Improved raw video support in combination with LAV Video\n\nLAV Video\n- Support for DVD Video decoding\n- Slight GPU memory usage reduction with DXVA2 Native\n- Fixed video corruption after seeks with VP3/Theora\n- Fixed decoding of \"old\" H.264 4:4:4 lossless files\n- More strict handling of output pixel formats, only enabled formats are allowed for output\n- QuickSync: Improved compatibility with new driver series\n- Improved support for VC-1 with the SageTV MpegDemux\n\nLAV Audio\n- Fixed a few issues with audio mixing\n  - Some channels would occasionally be mixed twice, causing incorrect audio levels\n  - Downmixing 8ch to stereo could crash on some systems\n  - Increased maximum LFE coefficient to 3.0 and fixed scale to be consistent with surround/center coefficients\n  - Added downmixing to Mono\n  - Clipping protection is no longer reset on seeks\n- Added support for Opus\n- Fixed excessive memory allocations when decoding MPEG4-ALS\n\n0.51.3 - 2012/07/19\nLAV Splitter\n- Further improved H264 media type creation\n\nLAV Audio\n- Fixed an issue with the initial media types causing graph building failures in some situations\n- Fixed a bug with DVBViewer which caused a delay on channel changes\n\n0.51.2 - 2012/07/15\nLAV Splitter\n- Improved H264 media type creation with some files\n- Fixed reading of QuickTime/AppleText chapters in MOV/MP4\n\nLAV Video\n- Reduced latency of H264 software decoding (improves Live TV playback)\n- Fixed chroma handling of the YCgCo to RGB conversion\n- Fixed timestamp handling of MPEG2 (regression introduced in 0.51)\n\nLAV Audio\n- Re-Mix audio as a fallback when the audio chain refuses a new channel configuration\n- Fixed an error that caused 16-bit FLAC to show as 24-bit on the status panel\n\n0.51.1 - 2012/07/10\nLAV Video\n- Improved compatibility between DXVA and certain DVB players\n\n0.51.0 - 2012/07/09\nLAV Splitter\n- Increased IO responsiveness on high-latency network connections\n- Improved timestamp handling for MPEG-PS (.mpg/.vob/.evo)\n- Improved support for H264 streams in SSIF MPEG-TS files\n- Added an option to control the priority of audio streams for the hearing/visually impaired\n- Added new flags to the advanced subtitle selection\n  - \"h\" for hearing impaired\n  - \"n\" for normal streams (no flags)\n  - \"!\" NOT operator for inverting the meaning of the flags\n\nLAV Video\n- Improved DXVA2 Native to software fallback in some situations\n- Support for YCgCo to RGB conversion\n- Added a new smart Stream Aspect Ratio mode\n  - Will only use Stream AR when the container does not provide a realiable AR\n\nLAV Audio\n- Improved decoding performance of MP4 ALS and a few other formats\n- Fixed playback of COOK with the MPC-HC RM Splitter\n- Auto A/V Sync is now automatically disabled on pure-audio files to avoid potential conflicts\n- Audio Down-Mixing support\n\n0.50.5 - 2012/05/12\nLAV Video\n- Fixed a crash in DXVA2-Native decoding (introduced in 0.50.4)\n\n0.50.4 - 2012/05/12\nLAV Video\n- Fixed seeking with QuickSync running in madVR Exclusive Mode\n\n0.50.3 - 2012/05/11\nLAV Splitter\n- Fixed playback of raw PCM in AVI streams\n- Fixed a rare misdetection of MPEG-2 as VC-1\n\nLAV Video\n- QuickSync: Fixed playback of some H.264 streams that would run out of sync on newer drivers\n- Fixed a memory leak when playing H.264 RGB (and some other formats)\n- Improved behaviour for H.264 and MPEG-2 on Live TV channel changes\n\nLAV Audio\n- Added support for Speex (via libspeex)\n- Improved support for AMR-NB/WB (using OpenCore decoder)\n\n0.50.2 - 2012/04/26\nLAV Splitter\n- Improved support for Playback Rates other then 1.0x\n- Improved demuxing performance by implementing a custom Sample Allocator to avoid one extra memory copy\n\nLAV Video\n- Fixed a rare crash when using YV12 output on non-mod16 video\n- Fixed excessive memory consumption with Haali Splitter and DXVA2-CB\n- Fixed a deadlock on dynamic format changes with DXVA2 Native\n- Added support for YV24 output\n\nLAV Audio\n- Improved support for Playback Rates other then 1.0x\n- Support for ALAC and ALS with the MPC-HC MP4 splitter\n- Improved A/V Sync on dynamic format changes\n- Improved Auto A/V Sync Correction algorithm (lower threshold, faster reaction)\n- Fixed audio pitch when bitstreaming 44.1KHz AC3/DTS\n\n0.50.1 - 2012/03/29\nLAV Splitter\n- Fixed Stream Detection on some Blu-rays with short Logo clips before the main movie\n- Fixed a crash when processing invalid/broken PGS subtitles\n\nLAV Video\n- Fixed a crash on dynamic format changes (stream change, Blu-ray clip change)\n\n0.50 - 2012/03/27\nLAV Splitter\n- Improved support for H264 Elementary Streams\n- Fixed a regression with seeking in MPEG-TS files recorded by some HD-PVR devices\n\nLAV Video\n- New Worker Thread design for Decoding/Deinterlacing\n  - WMV9+YADIF is up to 40% faster\n- Improved DXVA2 for MPEG-2 interlaced\n- Improved H264 DXVA2 on AMD with certain streams\n- Improved CUVID support for 4K streams on supported hardware (GT520, GTX680, other VP5 hardware)\n\nLAV Audio\n- Added support for RealAudio Lossless (RALF)\n\n0.49 - 2012/03/10\nLAV Splitter\n- Improved MKV demuxing performance from slow sources (network streaming, etc)\n- Improved stream detection on Blu-rays\n- Improved support for RealAudio (COOK, SIPR, etc) in MKV\n- Support for streaming from HTTP URLs\n\nLAV Audio\n- Improved support for DTS files with Little-Endian or 14B encodings\n\nLAV Video\n- New VC1/WMV3 decoder based on the Microsoft DMO Decoder (new default)\n- Updated Intel QuickSync decoder (0.29, r44)\n- Fixed decoding of some MBAFF H264 streams with DXVA2\n- Improved Stream Aspect Ratio logic in the CUVID decoder for H264 streams\n- Fixed Deinterlacing when DXVA2 Native is active in certain situations\n\n0.48 - 2012/02/24\nLAV Splitter\n- Improved Video/Audio stream detection in some MPEG-TS files\n\nLAV Video\n- Fixed a potential crash with native DXVA2 when the software fallback was used\n\n0.47 - 2012/02/20\nLAV Audio\n- Fixed seeking in COOK audio with the MPC-HC RealMedia splitter\n\nLAV Video\n- New DXVA2 \"native\" decoder (see release notes)\n- Updated Intel QuickSync decoder and tweaked configuration (0.28, r41)\n- Overall performance improvements\n- Multi-threaded decoding for Fraps\n- Fixed a regression that resulted in only single-threaded playback on certain H264 files\n- Fixed a crash in the CUVID decoder introduced in 0.46 under certain circumstances\n\n0.46 - 2012/02/12\nLAV Splitter\n- Experimental support for streaming protocols (RTSP, RTP, MMS)\n- Support for IBufferInfo (Buffer Status in MPC-HC \"Statistics\" pane)\n- Added a memory limit to avoid too high memory use from the frame queues\n- Fixed playback of files with Subtitles in WMP/WMC in some cases\n\nLAV Audio\n- Improved playback of files with bad audio frame interleaving\n- Improved support of COOK, ATRAC and SIPR (RealAudio codecs)\n\nLAV Video\n- Updated and improved Intel QuickSync decoder (0.26, r38)\n- Fixed DXVA2 software fallback on some lossless H264 clips\n- Improved Fraps decoding with EVR\n- Improved playback of MPEG4 in MP4\n- Multi-threaded decoding for Lagarith\n- Fixed playback of Theora with the MPC-HC Ogg Splitter\n- Dithering Enhancements:\n  - New \"Random Dithering\" option (new default)\n  - Improved \"Ordered Dithering\" in the RGB converter\n- Support for decoding v210/v410 raw formats\n- Support for Snow and FFV1\n\n0.45 - 2012/01/28\nLAV Splitter\n- Improved playback of concatenated H.264 MOV/MP4 files\n- Adjusted FLAC MediaType to avoid ReClock stealing the connection\n- Improved playback of MPEG-TS with timestamp discontinuities\n\nLAV Audio\n- Fixed playback of very short PCM samples\n- Improved COOK decoding without LAV Splitter\n\nLAV Video\n- New DXVA2 \"copy back\" decoder (see release notes)\n- Updated Intel QuickSync decoder (r29)\n- Multi-threaded decoding for RV30/40, UtVideo and DNxHD\n- Support for the \"FCC\" color matrix\n- Improved Dirac support\n- CUVID support for MPEG-4 ASP (experimental)\n- Support for Intel Indeo 4, MS Video 1, 8BPS, LOCO, ZMBV, VCR1, AASC\n\n0.44 - 2012/01/07\nLAV Splitter\n- Fixed a seeking regression in the mkv demuxer introduced in 0.43\n- Fixed a bug that caused stream descriptions to vanish after the file finished playing\n- Improved playback of WMVA video with commercial decoders\n- Added support for the new OpenType MIME type produced by mkvtoolnix > 5.2.0\n\nLAV Audio\n- Fixed LATM AAC playback with some source filters\n\nLAV Video\n- Added Intel QuickSync hardware decoder\n- Added support for YADIF with hardware decoding\n- Added support for Dirac decoding\n- Added support for DNxHD decoding\n- Added support for v210/v410 output\n- Improved dynamic reconnection with post-processing filters\n- Fixed a seeking related corruption issue with MPEG4-ASP\n\n0.43 - 2011/12/21\nLAV Splitter\n- Improved MKV seeking and demuxing performance\n- Improved buffering for smoother playback (especially at start/after seeks)\n- Fixed a few audio media type issues\n- Fixed a minor resource handle leak\n\nLAV Audio\n- Updated to new ffmpeg audio decoding API\n- Disabled Float Audio output on Windows XP by default\n\nLAV Video\n- Fixed handling of soft-telecined MPEG2/H264 broadcasts in CUVID mode\n- Improved support for 4:2:2 10-bit streams\n- Fixed a crash related to unaligned memory buffers on Windows  XP\n- Added support for decoding AMV streams\n\n0.42 - 2011/11/30\nLAV Splitter\n- Fixed a timestamping bug in the new MKV demuxer\n- Further enhancements to explorer thumbnail generation\n\n0.41 - 2011/11/29\nLAV Splitter\n- New MKV Demuxer (see release notes for details)\n- Fixed a bug with the Vorbis Media Type\n- Disabled Subtitles when generating Thumbnails in Explorer\n\nLAV Video\n- Fixed a overflow in 10 -> 8 bit dithering and NV12 output\n\n0.40 - 2011/11/21\nLAV Splitter\n- Improved demuxing of raw PCM streams\n- Fixed VC-1 in MP4 with the MS WMVideo Decoder\n- Improved playback of files with TrueHD audio streams\n- Added support for a requested stop time from the player\n- Improved playback of Blu-ray rips created by EasyBD\n- Added support for RGB24 raw video in AVI\n\nLAV Audio\n- Improved decoding of formats with extremely large audio frames\n\nLAV Video\n- Added YADIF software deinterlacing\n- Rewritten Interlaced options\n  - Added new \"Aggressive\" deinterlacing mode\n  - Moved many interlaced related options to global level\n- Fixed an issue with stream compatibility detection in the CUVID decoder, causing a software fallback when not required\n\n0.39 - 2011/11/07\nLAV Splitter\n- Fixed a bug that caused MPEG-2 and VC-1 parsers to produce wrong timestamps after a seek\n- Fixed playback of raw .h264 files\n\nLAV Video\n- NV12 is now the preferred YUV 4:2:0 output format\n- Fixed handling of the \"As Input\" RGB output setting\n- Improved VP6 cropping\n- Don't report completely progressive movies as interlaced to the renderer\n- Fixed playback of some broken MPEG-2 MKV muxes\n- RGB will now by default be offered as Bottom-Up instead of Top-Down for improved compatibility\n\n0.38 - 2011/11/01\nLAV Splitter\n- New subtitle selection options (see release notes or readme)\n- Improved handling of languages with more then one ISO 639-2 code (f.ex. German, French, etc)\n- Improved seeking to the start of the file\n- Added support for VobSubs in MP4\n- Added support for MKV nested chapters\n- Improved playback of RV40 in MKV\n- Improved support of H264 in WTV\n\nLAV Audio\n- Fixed a crash with raw audio and SPDIF processing\n- Improved support for COOK\n- Improved DTS-in-WAV detection\n\nLAV Video\n- Fixed a issue that caused MPC-HCs EVR-CP to produce wrong colors when using CUVID decoding\n- Support Multi-Threading and CUVID decoding for MPEG-1\n- Improve decoder flushing\n- Fixed a potential freeze on load and dynamic type changes\n- Fixed a freeze on seeking with certain VP8 files\n- Added support for UtVideo\n- Added support for H264 4:2:2\n\n0.37 - 2011/10/06\nLAV Splitter\n- Improved handling of failures on the output pins\n- Improved VC-1 in EVO timestamps\n\nLAV Audio\n- Added support for dynamic channel count changes in AAC\n- Implemented support for sample format conversions\n- Implemented Audio Delay options\n- Disabled the WMA codecs by default\n- Improved Bitstreaming data flow\n\nLAV Video\n- Fixed cropping of VP6 video\n- New SSE2 YUV420 -> YUV422 converter\n- Performance enhancements in the CUVID decoder on some systems\n- Fixed playback with the XP Overlay Mixer\n- Fixed a crash when decoding RGB video (Fraps, etc)\n\n0.36 - 2011/09/29\nLAV Splitter\n- Improved support for ADTS AAC\n- Fixed MPEG-2 timestamps in VOB\n- Fixed MPEG-2 frame rate reporting for telecined/interlaced\n\nLAV Video\n- Integrated NVIDIA CUVID Hardware decoder\n- Performance enhancements in 10bit decoding\n- Support for Flash Screen Video (FSV1)\n- Support for Apple ProRes\n- Improved MPEG-2 playback\n- Improved A/V sync with VC-1 and MPEG4-ASP\n\n0.35 - 2011/09/07\nLAV Splitter\n- Fixed a crash in IAMStreamSelect::Info handling with certain applications\n- Improve duration calculation for MPEG files\n\nLAV Audio\n- Fix playback of DTS streams which change the channel mid-playback\n\nLAV Video\n- Fixed a crash with 10-bit decoding and benchmarking tools\n- Fixed a H264 NALU parsing issue with certain streams\n\n0.34 - 2011/09/04\nLAV Splitter\n- Improve playback of VC-1 in EVO\n- Support for SSA subtitles in AVI\n- Support for H264 in VFW mode in MKV\n\nLAV Video\n- New optimized pixel format converters (faster and more accurate)\n- New YUV->RGB converter\n- Support for PNG video\n\n0.33 - 2011/08/22\nLAV Splitter\n- Improved compatibility with the MS WMVideo decoder\n- Fixed the mediatype for raw PCM streams\n\nLAV Audio\n- Added support for Vorbis streams demuxed by Haali and MPC-HC Splitters\n\nLAV Video\n- VC-1 decoding is now disabled by default\n- Fixed behaviour of the Stream AR option\n- The maximum number of decoding threads is now 16\n- Free decoding buffers when the input pin disconnects to avoid big memory leaks\n\n0.32 - 2011/08/19\nGeneral\n- The installer will now add shortcuts to the start menu to open the filter configurations\n- The ffmpeg DLLs have been renamed to carry a \"lav\" suffix to avoid collisions with other components\n\nLAV Splitter\n- Improved detection of AAC LATM tracks (previously mis-detected as mp1/mp2)\n- Fixed playback of badly interleaved AVI files\n- Smarter default stream selection for RealMedia files\n- Improved stream language handling for Blu-rays\n- Fixed a crash issue with the Forced Subtitle pin on Blu-rays\n\nLAV Audio\n- DTS decoding failures are now handled more gracefully\n- Fixed Media Types for Stereo 44.1kHz Audio\n\nLAV Video\n- First official version - refer to release notes for details\n\n0.31 - 2011/07/28\nLAV Splitter\n- Improved audio codec selection priorities\n- Improved VC-1 playback when using the madVR internal decoder\n- Improved playback of MPEG-TS files with a timestamp wrap right at the beginning of a file\n- Reduced amount of data required for file probing, resulting in faster startup time\n- Fixed demuxing/timestamping of RealMedia files\n\nLAV Audio\n- Fixed a bug in the DTS parser which caused occasional hiccups on DTS-HD content\n- Added the ability to detect DTS-in-WAV\n\n0.30 - 2011/07/15\nLAV Splitter\n- Improved VC-1 playback with ffdshow DXVA\n- Added support for outputting MPEG-4 Timed Text subtitles (only pure text supported)\n- Better support for MLP audio\n- I/O performance enhancements\n- Added an option to toggle how LAV Splitter handles audio stream switching\n- Added a hard-limit on queue sizes to avoid excessive memory usage when transcoding\n- Added an experimental interface for the Player to control graph rebuilding\n\nLAV Audio\n- Further improvements to the DTS-HD parsing\n- Better support for MLP audio\n- Added more E-AC3 subtypes\n\n0.29 - 2011/06/09\nLAV Splitter\n- The language code is now always shown in the stream changer (as a hint to easily know what to put into the preferred languages fields)\n- Enabled ITrackInfo\n- Improved H264 in MPEG-TS playback (including an option to try to fix broken HD-PVR recordings)\n- Added a programmatic configuration interface for players to configure LAV Splitter\n\nLAV Audio\n- Added support for decoding encrypted DVD audio\n- Fix decoding of some DTS-HD streams with the ArcSoft decoder\n- Added a programmatic configuration interface for players to configure LAV Audio\n\n0.28 - 2011/05/27\nLAV Splitter\n- Improved PGS filtering, forced subtitles should be cleared off the screen properly more often.\n- Improved playback of H264 in MPEG-TS with certain files (mostly from camcorders, but some Blu-rays as well)\n- Fixed 16-bit LPCM on DVDs\n- Fixed the Media Types for uncompressed video\n\nLAV Audio\n- Added the ability to decode DTS Express when using the ArcSoft DTS Decoder\n- Fixed missing audio after seeks with Ogg Vorbis\n\n0.27 - 2011/05/24\nGeneral\n- Added debug versions which generate log files on your desktop\n\nLAV Splitter\n- Fixed a memory leak when switching streams\n- Increased probe buffer size (which results in files to be properly detected in more cases)\n- Fixed playback of MPEG-TS files with a odd program configuration\n\nLAV Audio\n- Improvements to the DTS decoder interface\n  - Support for 1.1.0.0\n  - Try to reverse any channel upmixing done by the decoder, outputting the audio as close to the original source as possible.\n- New Channel Mapping functionality\n  - Output only \"standard\" channel layouts (Mono, Stereo, 5.1, 6.1, 7.1), filling non-existent channels with silence. Required by some HDMI receivers with \"odd\" source layouts. (default)\n  - Convert Mono to Stereo (simply double the audio channel)\n  - Convert 6.1 to 7.1 (Back Center gets doubled into both back channels)\n\n0.26 - 2011/05/15\nGeneral\n- The VC2010 runtime is no longer required to be installed\n\nLAV Splitter\n- Further VC-1 in MKV improvements\n- Added a separate \"mpegvideo\" (m2v files) option to the Format section\n- Added a flag for secondary audio streams\n- Changed the default DTS media type (better compatibility)\n\nLAV Audio\n- Added the ability to use the ArcSoft DTS decoder directly through LAV Audio\n- Added an automatic algorithm to keep A/V sync stable\n- Improved Bitstreaming with splitters other then LAV Splitter\n- Improved timestamp generation when bitstreaming\n- Fixed LPCM 24-bit Media Types\n\n0.25 - 2011/05/06\nLAV Splitter\n- Added the ability to filter Blu-ray PGS subtitles, so only frames flagged as \"forced\" are delivered\n  - Either through a new \"Forced Subtitles\" stream (default)\n  - Or, filtering for every PGS stream (configurable)\n- Improved support for H264 in AVI\n- Improved timings for TrueHD in MKV\n- m2ts files directly openend inside a Blu-ray structure should now properly display stream languages\n- Alot of fixes and enhancements for format compatibility (especially MPEG-TS)\n- Support using the ArcSoft HD Audio Decoder for E-AC3\n\nLAV Audio\n- Audio bitstreaming (pass-through) for HDMI and S/PDIF\n  - Support for AC3, E-AC3, TrueHD, DTS and DTS-HD\n- Use the float decoders for mp1/mp2\n- Added official support for WMAv1, WMAv2 and WMA Pro\n- Fixed an issue that caused sync issues with FLAC audio, and FLAC is once again enabled by default\n\n0.24 - 2011/04/25\nGeneral\n- Big ffmpeg update! Libraries have been renamed (version increase)\n\nLAV Splitter\n- Obviously wrong frame rates will no longer be reported to the decoder\n- Improved mpeg2 playback\n- Improved dynamic media type changes\n- Fix the first few frames of ASS/SSA subtitles in Matroska\n- Fix an issue with the display of some codec names\n- Add proper subtypes for little-endian PCM\n- Fix subtypes for QT PCM\n\nLAV Audio\n- Support processing of 64-bit double output from the decoders\n- PCM data will be buffered before its send to the renderer/post processor\n\n0.23 - 2011/04/21\nGeneral\n- There is now an installer available in addition to the trusted old .zip files!\n\nLAV Splitter\n- Added support for using the \"File Source (Async)\" (and others) together with LAV Splitter\n  - This is the new default mode for improved compatibility!\n  - Check release notes for additional informations.\n- Added configuration which input formats will be demuxed\n- Improved VC-1 in MKV playback\n\nLAV Audio\n- Fixed playback of lossless formats with huge sample sizes\n- Improved A/V sync with TrueHD (and possibly others)\n- FLAC decoding is now disabled by default, because the decoder is not 100% working\n\n0.22 - 2011/04/11\nLAV Splitter\n- Added support for MKV embedded fonts\n- Improved VC-1 and H264 parsing\n- Fixed choppy XVID playback in MKV\n- Fixed a seeking issues that caused incompatibilitys with certain decoders (eg. a crash in ffdshow libmpeg2)\n- No longer report incomplete lists of keyframes via IKeyFrameInfo, as it would break seeking in certain players.\n- Allow opening all .mpls files if the user directly specifys to open one, even if it contains loops or duplicate titles.\n- Improved playback of MPEG-TS with multiple programs\n- Added new debugging option (Generate missing timestamps)\n\n0.21 - 2011/04/07\nLAV Splitter\n- Improve MPEG-TS program handling in some special circumstances\n- Filter out misdetected audio streams (unsupported DTS Express on BluRays)\n- Increase the priority of DTS-HD over normal DTS\n- Use the official AVI MEDIASUBTYPE instead of a custom one\n- Added options to completly disable stream parsing\n- Added a new VC-1 parser which will take over when VC-1 timestamp adjustments are turned off\n\n0.20 - 2011/04/05\nLAV Splitter\n- Added first BluRay support (see Release Notes or README for more details)\n\nLAV Audio\n- Removed static jitter check which caused corruptions in some audio streams\n- Improved error resilience - broken streams should now play in many more cases\n\n0.19 - 2011/03/19\nGeneral\n- Version Information has been added to the filter .ax files, as well as shown on the property pages.\n\nLAV Splitter\n- Redesigned stream name generations\n  - Codec profiles are now shown (if known - supported are H264, VC1, MPEG2 and DTS)\n  - Audio bit-depth is no longer shown for lossy codecs, as it doesn't apply there\n  - Improved logic that parses the stream flags\n  - Names for the subtitle codecs have been added\n  - If the language is \"Undetermined\", it'll no longer be shown\n- Size of the packet queue has been increased (solves subtitle issues, as well as improves playback stability)\n- Redesigned the way the splitter registers for formats in the registry for better compatibility\n- Changed the stream change handling for better compatibility with certain players (Media Portal, and others)\n- Improved handling of unknown streams (no codec information present)\n- Added a new option that controls if substreams should be exposed in the stream selector (Only AC3 in TrueHD supported)\n\nLAV Audio\n- Added a new configuration panel which allows to configure which formats the decoder should handle\n\n0.18 - 2011/03/09\nLAV Splitter\n- Improved compatibility when decoding VC-1 with the ArcSoft and Cyberlink Decoders\n- Increased the splitters merit\n- Fixed an issue that caused the splitter to deadlock when changing streams with madVR\n\nLAV Audio Decoder\n- Fixed a bug that caused sample durations to be calculated wrong, causing playback glitches\n\n0.17 - 2011/02/27\nLAV Splitter\n- Fixed seeking before starting playback\n\n0.16 - 2011/02/27\nLAV Audio Decoder\n- Fixed missing audio after seeks\n\n0.15 - 2011/02/27\nLAV Splitter\n- Fixed automatic selection of forced subtitle stream if the \"Only Forced Subs\" mode is active.\n- Fixed a bug in file handling that caused file sizes above 4GB to overflow, causing invalid durations to be reported in some files.\n- Improved performance on file opening\n\nLAV Audio Decoder\n- Enabled the ffmpeg codec parsers, which should improve compatibility with other DirectShow splitters.\n- Added a audio channel activity display to the status property page (for debugging channel assignments)\n\n0.14 - 2011/02/10\nGeneral\n- The project and filters have been renamed slightly for consistency\n\nLAV Splitter\n- The settings have been moved to a different place in the Registry. You will need to re-apply them.\n- Improved MPEG-TS duration calculations.\n- The settings will now always be properly saved and loaded.\n- Disabled the limit of 20 Streams per file.\n- Fixed two separate issues that caused files to not start playing.\n\nLAV Audio Decoder\n- Property Page for Configuration and Status has been added\n- Dynamic Range Compression is now off by default, but configurable.\n- Media Type creation has been improved, fixes filter connection issues.\n- Processing of UINT8 Samples has been fixed.\n- Fixed a crash with some Audio codecs.\n- Fixed Channel Order for 7.1 Streams\n- Increased the decoders Merit\n- Added support for decoding QT PCM\n\n0.13 - 2011/01/29\nLAVFSplitter\n- Added support for demuxing BluRay LPCM tracks into the MPC-HC format\n- Added a new LAVFSplitter specific media type to all audio streams\nLAVCAudio\n- First version of LAVCAudio implemented\n\n0.12 - 2011/01/21\n- Fixed a crash issue with certain configurations and files with subtitles\n- Revisited file duration logic, now tries to prefer the duration of the video stream. This fixes MPEG-TS duration issues.\n- Updated ffmpeg (a lot of issues resolved)\n\n0.11 - 2010/11/06\n- Smart stream pre-selection based on language, flags and quality\n- Properties page for configuration (languages, stream selection logic)\n- Added support for AAC LATM (single stream)\n- Changed the \"No Subtitles\" pin to a more \"friendly\" Media Type\n- Fixed a crash with certain AAC tracks\n\n0.10 - 2010/10/26\n- Added more MOV/MP4 byte markers\n- Added support for multichannel PCM tracks\n- Added support for DVD LPCM tracks\n- Added support for usign the ArcSoft HD decoder for DTS and TrueHD tracks\n- Send the proper media type for TrueHD instead of trying to connect with AC-3\n- Improved H264 frame rate detection\n- Improved FLAC support\n- Fix loading of files with unicode characters in their names\n- Fixed timestamping issues that caused certain videos to play too fast\n- Fixed M-JPEG media type\n- Fixed corruption with MPEG-4 ASP (DivX/Xvid) when using the Xvid decoder\n\n0.9 - 2010/09/12\n- Added support for distinguishing hearing impaired subtitles in mpeg-ts streams\n- Added BluRay LPCM support\n- MP1/MP2 audio media type fixes\n- Honor the original FourCC of the file in media type generation\n- Added support for using the Cyberlink VC-1 decoder\n- Fixed an issue with some H264/AVC1 files that caused video to not play at all\n- Fixed unicode in chapter names\n- Fixed getting the current chapter\n\n0.8 - 2010/08/30\n- Alot of internal changes to enhance performance and maintainability\n- Fixed a potential deadlock on seeking\n- Fixed playing files without a video stream\n- Fixed an issue that caused some players to hang on playback start\n- Improved language detection\n\n0.7 - 2010/08/23\n- Further improvements to aspect ratio detection\n- Restore old FPS detection\n- Adjusted flushing to fix subtitle delays\n- Reverted a timing change that broke TrueHD\n\n0.6 - 2010/08/22\n- Added support for E-AC3\n- Fixed MPEG2 Media Types\n- Added support for RealVideo in MKV\n- Set proper aspect ratio in media type\n- Fixed memory leaks in packet handling code\n- Unicode support for stream names\n- Threading changes for more fluid playback at startup\n- Changed Flushing behaviour that solves a conflict with the MS DTV-DVD Decoder\n- Better support for Vorbis audio\n- Registers for the OGG Container Format\n\n0.5 - 2010/08/18\n- Fixed duration of MPEG-TS files\n- Added support for DVB subtitles\n- Fixed switching of Audio and Subtitle Streams\n- Added a \"No Subtitles\" Stream\n\n0.4 - 2010/08/16\n- Improved SSA Subtitle support\n- Fixed freeze-on-stop issue\n\n0.3 - 2010/08/15\n- Added Chapter support\n- Improved stream descriptions\n- 64-bit support\n\n0.2 - 2010/08/14\n- Fixed overflow in timestamp calculation causing AVIs to play too fast\n\n0.1 - 2010/08/14\n- Initial Release\n"
  },
  {
    "path": "COPYING",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 2, June 1991\n\n Copyright (C) 1989, 1991 Free Software Foundation, Inc.,\n 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The licenses for most software are designed to take away your\nfreedom to share and change it.  By contrast, the GNU General Public\nLicense is intended to guarantee your freedom to share and change free\nsoftware--to make sure the software is free for all its users.  This\nGeneral Public License applies to most of the Free Software\nFoundation's software and to any other program whose authors commit to\nusing it.  (Some other Free Software Foundation software is covered by\nthe GNU Lesser General Public License instead.)  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthis service if you wish), that you receive source code or can get it\nif you want it, that you can change the software or use pieces of it\nin new free programs; and that you know you can do these things.\n\n  To protect your rights, we need to make restrictions that forbid\nanyone to deny you these rights or to ask you to surrender the rights.\nThese restrictions translate to certain responsibilities for you if you\ndistribute copies of the software, or if you modify it.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must give the recipients all the rights that\nyou have.  You must make sure that they, too, receive or can get the\nsource code.  And you must show them these terms so they know their\nrights.\n\n  We protect your rights with two steps: (1) copyright the software, and\n(2) offer you this license which gives you legal permission to copy,\ndistribute and/or modify the software.\n\n  Also, for each author's protection and ours, we want to make certain\nthat everyone understands that there is no warranty for this free\nsoftware.  If the software is modified by someone else and passed on, we\nwant its recipients to know that what they have is not the original, so\nthat any problems introduced by others will not reflect on the original\nauthors' reputations.\n\n  Finally, any free program is threatened constantly by software\npatents.  We wish to avoid the danger that redistributors of a free\nprogram will individually obtain patent licenses, in effect making the\nprogram proprietary.  To prevent this, we have made it clear that any\npatent must be licensed for everyone's free use or not licensed at all.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                    GNU GENERAL PUBLIC LICENSE\n   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION\n\n  0. This License applies to any program or other work which contains\na notice placed by the copyright holder saying it may be distributed\nunder the terms of this General Public License.  The \"Program\", below,\nrefers to any such program or work, and a \"work based on the Program\"\nmeans either the Program or any derivative work under copyright law:\nthat is to say, a work containing the Program or a portion of it,\neither verbatim or with modifications and/or translated into another\nlanguage.  (Hereinafter, translation is included without limitation in\nthe term \"modification\".)  Each licensee is addressed as \"you\".\n\nActivities other than copying, distribution and modification are not\ncovered by this License; they are outside its scope.  The act of\nrunning the Program is not restricted, and the output from the Program\nis covered only if its contents constitute a work based on the\nProgram (independent of having been made by running the Program).\nWhether that is true depends on what the Program does.\n\n  1. You may copy and distribute verbatim copies of the Program's\nsource code as you receive it, in any medium, provided that you\nconspicuously and appropriately publish on each copy an appropriate\ncopyright notice and disclaimer of warranty; keep intact all the\nnotices that refer to this License and to the absence of any warranty;\nand give any other recipients of the Program a copy of this License\nalong with the Program.\n\nYou may charge a fee for the physical act of transferring a copy, and\nyou may at your option offer warranty protection in exchange for a fee.\n\n  2. You may modify your copy or copies of the Program or any portion\nof it, thus forming a work based on the Program, and copy and\ndistribute such modifications or work under the terms of Section 1\nabove, provided that you also meet all of these conditions:\n\n    a) You must cause the modified files to carry prominent notices\n    stating that you changed the files and the date of any change.\n\n    b) You must cause any work that you distribute or publish, that in\n    whole or in part contains or is derived from the Program or any\n    part thereof, to be licensed as a whole at no charge to all third\n    parties under the terms of this License.\n\n    c) If the modified program normally reads commands interactively\n    when run, you must cause it, when started running for such\n    interactive use in the most ordinary way, to print or display an\n    announcement including an appropriate copyright notice and a\n    notice that there is no warranty (or else, saying that you provide\n    a warranty) and that users may redistribute the program under\n    these conditions, and telling the user how to view a copy of this\n    License.  (Exception: if the Program itself is interactive but\n    does not normally print such an announcement, your work based on\n    the Program is not required to print an announcement.)\n\nThese requirements apply to the modified work as a whole.  If\nidentifiable sections of that work are not derived from the Program,\nand can be reasonably considered independent and separate works in\nthemselves, then this License, and its terms, do not apply to those\nsections when you distribute them as separate works.  But when you\ndistribute the same sections as part of a whole which is a work based\non the Program, the distribution of the whole must be on the terms of\nthis License, whose permissions for other licensees extend to the\nentire whole, and thus to each and every part regardless of who wrote it.\n\nThus, it is not the intent of this section to claim rights or contest\nyour rights to work written entirely by you; rather, the intent is to\nexercise the right to control the distribution of derivative or\ncollective works based on the Program.\n\nIn addition, mere aggregation of another work not based on the Program\nwith the Program (or with a work based on the Program) on a volume of\na storage or distribution medium does not bring the other work under\nthe scope of this License.\n\n  3. You may copy and distribute the Program (or a work based on it,\nunder Section 2) in object code or executable form under the terms of\nSections 1 and 2 above provided that you also do one of the following:\n\n    a) Accompany it with the complete corresponding machine-readable\n    source code, which must be distributed under the terms of Sections\n    1 and 2 above on a medium customarily used for software interchange; or,\n\n    b) Accompany it with a written offer, valid for at least three\n    years, to give any third party, for a charge no more than your\n    cost of physically performing source distribution, a complete\n    machine-readable copy of the corresponding source code, to be\n    distributed under the terms of Sections 1 and 2 above on a medium\n    customarily used for software interchange; or,\n\n    c) Accompany it with the information you received as to the offer\n    to distribute corresponding source code.  (This alternative is\n    allowed only for noncommercial distribution and only if you\n    received the program in object code or executable form with such\n    an offer, in accord with Subsection b above.)\n\nThe source code for a work means the preferred form of the work for\nmaking modifications to it.  For an executable work, complete source\ncode means all the source code for all modules it contains, plus any\nassociated interface definition files, plus the scripts used to\ncontrol compilation and installation of the executable.  However, as a\nspecial exception, the source code distributed need not include\nanything that is normally distributed (in either source or binary\nform) with the major components (compiler, kernel, and so on) of the\noperating system on which the executable runs, unless that component\nitself accompanies the executable.\n\nIf distribution of executable or object code is made by offering\naccess to copy from a designated place, then offering equivalent\naccess to copy the source code from the same place counts as\ndistribution of the source code, even though third parties are not\ncompelled to copy the source along with the object code.\n\n  4. You may not copy, modify, sublicense, or distribute the Program\nexcept as expressly provided under this License.  Any attempt\notherwise to copy, modify, sublicense or distribute the Program is\nvoid, and will automatically terminate your rights under this License.\nHowever, parties who have received copies, or rights, from you under\nthis License will not have their licenses terminated so long as such\nparties remain in full compliance.\n\n  5. You are not required to accept this License, since you have not\nsigned it.  However, nothing else grants you permission to modify or\ndistribute the Program or its derivative works.  These actions are\nprohibited by law if you do not accept this License.  Therefore, by\nmodifying or distributing the Program (or any work based on the\nProgram), you indicate your acceptance of this License to do so, and\nall its terms and conditions for copying, distributing or modifying\nthe Program or works based on it.\n\n  6. Each time you redistribute the Program (or any work based on the\nProgram), the recipient automatically receives a license from the\noriginal licensor to copy, distribute or modify the Program subject to\nthese terms and conditions.  You may not impose any further\nrestrictions on the recipients' exercise of the rights granted herein.\nYou are not responsible for enforcing compliance by third parties to\nthis License.\n\n  7. If, as a consequence of a court judgment or allegation of patent\ninfringement or for any other reason (not limited to patent issues),\nconditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot\ndistribute so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you\nmay not distribute the Program at all.  For example, if a patent\nlicense would not permit royalty-free redistribution of the Program by\nall those who receive copies directly or indirectly through you, then\nthe only way you could satisfy both it and this License would be to\nrefrain entirely from distribution of the Program.\n\nIf any portion of this section is held invalid or unenforceable under\nany particular circumstance, the balance of the section is intended to\napply and the section as a whole is intended to apply in other\ncircumstances.\n\nIt is not the purpose of this section to induce you to infringe any\npatents or other property right claims or to contest validity of any\nsuch claims; this section has the sole purpose of protecting the\nintegrity of the free software distribution system, which is\nimplemented by public license practices.  Many people have made\ngenerous contributions to the wide range of software distributed\nthrough that system in reliance on consistent application of that\nsystem; it is up to the author/donor to decide if he or she is willing\nto distribute software through any other system and a licensee cannot\nimpose that choice.\n\nThis section is intended to make thoroughly clear what is believed to\nbe a consequence of the rest of this License.\n\n  8. If the distribution and/or use of the Program is restricted in\ncertain countries either by patents or by copyrighted interfaces, the\noriginal copyright holder who places the Program under this License\nmay add an explicit geographical distribution limitation excluding\nthose countries, so that distribution is permitted only in or among\ncountries not thus excluded.  In such case, this License incorporates\nthe limitation as if written in the body of this License.\n\n  9. The Free Software Foundation may publish revised and/or new versions\nof the General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\nEach version is given a distinguishing version number.  If the Program\nspecifies a version number of this License which applies to it and \"any\nlater version\", you have the option of following the terms and conditions\neither of that version or of any later version published by the Free\nSoftware Foundation.  If the Program does not specify a version number of\nthis License, you may choose any version ever published by the Free Software\nFoundation.\n\n  10. If you wish to incorporate parts of the Program into other free\nprograms whose distribution conditions are different, write to the author\nto ask for permission.  For software which is copyrighted by the Free\nSoftware Foundation, write to the Free Software Foundation; we sometimes\nmake exceptions for this.  Our decision will be guided by the two goals\nof preserving the free status of all derivatives of our free software and\nof promoting the sharing and reuse of software generally.\n\n                            NO WARRANTY\n\n  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY\nFOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN\nOTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES\nPROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED\nOR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF\nMERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS\nTO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE\nPROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,\nREPAIR OR CORRECTION.\n\n  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR\nREDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,\nINCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING\nOUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED\nTO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY\nYOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER\nPROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE\nPOSSIBILITY OF SUCH DAMAGES.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nconvey the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software; you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation; either version 2 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License along\n    with this program; if not, write to the Free Software Foundation, Inc.,\n    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n\nAlso add information on how to contact you by electronic and paper mail.\n\nIf the program is interactive, make it output a short notice like this\nwhen it starts in an interactive mode:\n\n    Gnomovision version 69, Copyright (C) year name of author\n    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, the commands you use may\nbe called something other than `show w' and `show c'; they could even be\nmouse-clicks or menu items--whatever suits your program.\n\nYou should also get your employer (if you work as a programmer) or your\nschool, if any, to sign a \"copyright disclaimer\" for the program, if\nnecessary.  Here is a sample; alter the names:\n\n  Yoyodyne, Inc., hereby disclaims all copyright interest in the program\n  `Gnomovision' (which makes passes at compilers) written by James Hacker.\n\n  <signature of Ty Coon>, 1 April 1989\n  Ty Coon, President of Vice\n\nThis General Public License does not permit incorporating your program into\nproprietary programs.  If your program is a subroutine library, you may\nconsider it more useful to permit linking proprietary applications with the\nlibrary.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.\n"
  },
  {
    "path": "LAVFilters.iss",
    "content": "; LAV Filters Inno Setup script\n\n#include <idp.iss>\n\n; Include version info\n#define ISPP_INCLUDED\n#include \"common\\includes\\version.h\"\n\n#if LAV_VERSION_BUILD > 0\n    #define LAV_VERSION_STRING str(LAV_VERSION_MAJOR) + \".\" + str(LAV_VERSION_MINOR) + \".\" + str(LAV_VERSION_REVISION) + \"-\" + str(LAV_VERSION_BUILD)\n#else\n    #if LAV_VERSION_REVISION > 0\n        #define LAV_VERSION_STRING str(LAV_VERSION_MAJOR) + \".\" + str(LAV_VERSION_MINOR) + \".\" + str(LAV_VERSION_REVISION)\n    #else\n        #define LAV_VERSION_STRING str(LAV_VERSION_MAJOR) + \".\" + str(LAV_VERSION_MINOR)\n    #endif\n#endif\n\n[Setup]\nAllowCancelDuringInstall  = no\nAllowNoIcons              = yes\nAllowUNCPath              = no\nAppId                     = lavfilters\nAppName                   = LAV Filters\nAppPublisher              = Hendrik Leppkes\nAppPublisherURL           = https://1f0.de/\nAppVerName                = LAV Filters {#=LAV_VERSION_STRING}\nAppVersion                = {#=LAV_VERSION_STRING}\nVersionInfoVersion        = {#=LAV_VERSION_MAJOR}.{#=LAV_VERSION_MINOR}.{#=LAV_VERSION_REVISION}.{#=LAV_VERSION_BUILD}\nVersionInfoCompany        = 1f0.de\nVersionInfoCopyright      = GPLv2\nOutputBaseFilename        = LAVFilters-{#=LAV_VERSION_STRING}\nOutputDir                 = .\nCompression               = lzma2/ultra64\nSolidCompression          = yes\nMinVersion                = 0,6.0\nPrivilegesRequired        = admin\nCreateAppDir              = yes\nDefaultDirName            = {pf}\\LAV Filters\nDefaultGroupName          = LAV Filters\nDisableStartupPrompt      = yes\nUninstallable             = yes\nDisableDirPage            = auto\nDisableProgramGroupPage   = auto\nUsePreviousTasks          = yes\n#ifexist \"..\\LAVSignInfo.txt\"\nSignTool                  = LAVSignTool\nSignedUninstaller         = yes\n#endif\n\n[Messages]\nWelcomeLabel1=[name/ver]\nWelcomeLabel2=This will install [name] on your computer.%n%nIt is recommended that you close all other applications before continuing.\nWinVersionTooLowError=This software only works on Windows XP SP3 and newer.\n\n[Types]\nName: default; Description: Default\nName: full;    Description: Full\nName: custom;  Description: Custom; Flags: iscustom\n\n[Components]\nName: lavsplitter32; Description: LAV Splitter (x86); Types: default full custom;\nName: lavsplitter64; Description: LAV Splitter (x64); Types: default full custom; Check: IsWin64;\nName: lavaudio32;    Description: LAV Audio (x86);    Types: default full custom;\nName: lavaudio64;    Description: LAV Audio (x64);    Types: default full custom; Check: IsWin64;\nName: lavvideo32;    Description: LAV Video (x86);    Types: default full custom;\nName: lavvideo64;    Description: LAV Video (x64);    Types: default full custom; Check: IsWin64;\nName: mvc3d;         Description: H.264 MVC 3D Decoder (extra download); Types: full; ExtraDiskSpaceRequired: 41242624;\n\n[Tasks]\nName: icons;          Description: \"Create Start Menu Shortcuts\";\nName: reset_settings; Description: \"Reset Settings\"; Flags: checkedonce unchecked; Check: SettingsExistCheck()\n\n[Files]\nSource: bin_Win32\\avcodec-lav-62.dll;  DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter32 lavaudio32 lavvideo32\nSource: bin_Win32\\avfilter-lav-11.dll;  DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavvideo32\nSource: bin_Win32\\avformat-lav-62.dll; DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter32 lavaudio32\nSource: bin_Win32\\avutil-lav-60.dll;   DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter32 lavaudio32 lavvideo32\nSource: bin_Win32\\swresample-lav-6.dll;DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter32 lavaudio32 lavvideo32\nSource: bin_Win32\\swscale-lav-9.dll;   DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavvideo32\nSource: bin_Win32\\libbluray.dll;       DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter32\nSource: bin_Win32\\LAVAudio.ax;         DestDir: {app}\\x86; Flags: 32bit regserver ignoreversion restartreplace uninsrestartdelete; Components: lavaudio32\nSource: bin_Win32\\LAVSplitter.ax;      DestDir: {app}\\x86; Flags: 32bit regserver ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter32\nSource: bin_Win32\\LAVVideo.ax;         DestDir: {app}\\x86; Flags: 32bit regserver ignoreversion restartreplace uninsrestartdelete; Components: lavvideo32\nSource: bin_Win32\\LAVFilters.Dependencies.manifest; DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter32 lavaudio32 lavvideo32\nSource: bin_Win32\\IntelQuickSyncDecoder.dll; DestDir: {app}\\x86; Flags: 32bit ignoreversion restartreplace uninsrestartdelete; Components: lavvideo32\n\nSource: bin_x64\\avcodec-lav-62.dll;    DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter64 lavaudio64 lavvideo64\nSource: bin_x64\\avfilter-lav-11.dll;    DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavvideo64\nSource: bin_x64\\avformat-lav-62.dll;   DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter64 lavaudio64\nSource: bin_x64\\avutil-lav-60.dll;     DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter64 lavaudio64 lavvideo64\nSource: bin_x64\\swresample-lav-6.dll;  DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter64 lavaudio64 lavvideo64\nSource: bin_x64\\swscale-lav-9.dll;     DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavvideo64\nSource: bin_x64\\libbluray.dll;         DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter64\nSource: bin_x64\\LAVAudio.ax;           DestDir: {app}\\x64; Flags: 64bit regserver ignoreversion restartreplace uninsrestartdelete; Components: lavaudio64\nSource: bin_x64\\LAVSplitter.ax;        DestDir: {app}\\x64; Flags: 64bit regserver ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter64\nSource: bin_x64\\LAVVideo.ax;           DestDir: {app}\\x64; Flags: 64bit regserver ignoreversion restartreplace uninsrestartdelete; Components: lavvideo64\nSource: bin_x64\\LAVFilters.Dependencies.manifest; DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavsplitter64 lavaudio64 lavvideo64\nSource: bin_x64\\IntelQuickSyncDecoder.dll; DestDir: {app}\\x64; Flags: 64bit ignoreversion restartreplace uninsrestartdelete; Components: lavvideo64\n\nSource: COPYING;                       DestDir: {app};     Flags: ignoreversion restartreplace uninsrestartdelete\nSource: README.md;                     DestDir: {app};     Flags: ignoreversion restartreplace uninsrestartdelete\nSource: CHANGELOG.txt;                 DestDir: {app};     Flags: ignoreversion restartreplace uninsrestartdelete\n\nSource: thirdparty\\contrib\\7za.exe;    DestDir: {tmp};     Flags: dontcopy\n\n[UninstallDelete]\nType: files; Name: {app}\\x86\\libmfxsw32.dll\nType: files; Name: {app}\\x64\\libmfxsw64.dll\n\n[Icons]\nName: {group}\\LAV Splitter Configuration;        Filename: rundll32.exe; Parameters: \"\"\"{app}\\x86\\LAVSplitter.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x86; IconFilename: {app}\\x86\\LAVSplitter.ax; IconIndex: 0; Tasks: icons; Components: lavsplitter32\nName: {group}\\LAV Splitter Configuration;        Filename: rundll32.exe; Parameters: \"\"\"{app}\\x64\\LAVSplitter.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x64; IconFilename: {app}\\x64\\LAVSplitter.ax; IconIndex: 0; Tasks: icons; Components: lavsplitter64 AND NOT lavsplitter32\nName: {group}\\LAV Audio Configuration;           Filename: rundll32.exe; Parameters: \"\"\"{app}\\x86\\LAVAudio.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x86; IconFilename: {app}\\x86\\LAVAudio.ax; IconIndex: 0; Tasks: icons; Components: lavaudio32\nName: {group}\\LAV Audio Configuration;           Filename: rundll32.exe; Parameters: \"\"\"{app}\\x64\\LAVAudio.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x64; IconFilename: {app}\\x64\\LAVAudio.ax; IconIndex: 0; Tasks: icons; Components: lavaudio64 AND NOT lavaudio32\nName: {group}\\LAV Video Configuration;           Filename: rundll32.exe; Parameters: \"\"\"{app}\\x86\\LAVVideo.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x86; IconFilename: {app}\\x86\\LAVVideo.ax; IconIndex: 0; Tasks: icons; Components: lavvideo32\nName: {group}\\LAV Video Configuration;           Filename: rundll32.exe; Parameters: \"\"\"{app}\\x64\\LAVVideo.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x64; IconFilename: {app}\\x64\\LAVVideo.ax; IconIndex: 0; Tasks: icons; Components: lavvideo64 AND NOT lavvideo32\nName: {group}\\Visit LAV Filters Home Page;       Filename: \"https://1f0.de/\"; Tasks: icons\nName: {group}\\Visit LAV Filters on Doom9;        Filename: \"https://forum.doom9.org/showthread.php?t=156191\"; Tasks: icons\nName: {group}\\Uninstall LAV Filters;             Filename: {uninstallexe}; Tasks: icons\n\n[Registry]\nRoot: HKCU; Subkey: Software\\LAV;                  Flags: uninsdeletekeyifempty\nRoot: HKCU; Subkey: Software\\LAV\\Audio;            Flags: uninsdeletekey; Components: lavaudio32 lavaudio64\nRoot: HKCU; Subkey: Software\\LAV\\Splitter;         Flags: uninsdeletekey; Components: lavsplitter32 lavsplitter64\nRoot: HKCU; Subkey: Software\\LAV\\Splitter\\Formats; Flags: uninsdeletekey; Components: lavsplitter32 lavsplitter64\nRoot: HKCU; Subkey: Software\\LAV\\Video;            Flags: uninsdeletekey; Components: lavvideo32 lavvideo64\nRoot: HKCU; Subkey: Software\\LAV\\Video\\Formats;    Flags: uninsdeletekey; Components: lavvideo32 lavvideo64\nRoot: HKCU; Subkey: Software\\LAV\\Video\\Output;     Flags: uninsdeletekey; Components: lavvideo32 lavvideo64\n\n[Run]\nDescription: \"Open LAV Splitter Configuration\"; Filename: rundll32.exe; Parameters: \"\"\"{app}\\x86\\LAVSplitter.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x86; Components: lavsplitter32; Flags: postinstall nowait unchecked\nDescription: \"Open LAV Splitter Configuration\"; Filename: rundll32.exe; Parameters: \"\"\"{app}\\x64\\LAVSplitter.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x64; Components: lavsplitter64 AND NOT lavsplitter32; Flags: postinstall nowait unchecked\nDescription: \"Open LAV Audio Configuration\";    Filename: rundll32.exe; Parameters: \"\"\"{app}\\x86\\LAVAudio.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x86; Components: lavaudio32; Flags: postinstall nowait unchecked\nDescription: \"Open LAV Audio Configuration\";    Filename: rundll32.exe; Parameters: \"\"\"{app}\\x64\\LAVAudio.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x64; Components: lavaudio64 AND NOT lavaudio32; Flags: postinstall nowait unchecked\nDescription: \"Open LAV Video Configuration\";    Filename: rundll32.exe; Parameters: \"\"\"{app}\\x86\\LAVVideo.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x86; Components: lavvideo32; Flags: postinstall nowait unchecked\nDescription: \"Open LAV Video Configuration\";    Filename: rundll32.exe; Parameters: \"\"\"{app}\\x64\\LAVVideo.ax\"\",OpenConfiguration\"; WorkingDir: {app}\\x64; Components: lavvideo64 AND NOT lavvideo32; Flags: postinstall nowait unchecked\n\n[Code]\ntype\n  Format = record\n             id: String;\n             name: String;\n             default: Boolean;\n             subtype: String;\n             asyncSource: Boolean;\n             protocol: Boolean;\n             extensions: Array of String;\n             chkbytes: Array of String;\n           end;\n\nconst\n  NumFormatsMinusOne = 22;\n  LavGUID = '{B98D13E7-55DB-4385-A33D-09FD1BA26338}';\n  StreamGUID = '{E436EB83-524F-11CE-9F53-0020AF0BA770}';\n  LavSplitterFormatsReg = 'Software\\LAV\\Splitter\\Formats';\n\nvar\n  SplitterPage: TInputOptionWizardPage;\n  SplitterFormats: Array [0..NumFormatsMinusOne] of Format;\n\nfunction IsProcessorFeaturePresent(Feature: Integer): Boolean;\nexternal 'IsProcessorFeaturePresent@kernel32.dll stdcall';\n\nfunction Is_SSE2_Supported(): Boolean;\nbegin\n  // PF_XMMI64_INSTRUCTIONS_AVAILABLE\n  Result := IsProcessorFeaturePresent(10);\nend;\n\nfunction SettingsExistCheck(): Boolean;\nbegin\n  if RegKeyExists(HKCU, 'Software\\LAV') then\n    Result := True\n  else\n    Result := False;\nend;\n\nfunction IsUpdate(): Boolean;\nvar\n  sPrevPath: String;\nbegin\n  sPrevPath := WizardForm.PrevAppDir;\n  Result := (sPrevPath <> '');\nend;\n\nprocedure FR(var f: Format; const id, desc: String; const default: Boolean; const extensions: Array of String);\nbegin\n  f.id         := id;\n  f.name       := desc;\n  f.default    := default;\n  f.extensions := extensions;\n  f.subtype    := '';\n  f.chkbytes   := [''];\n  f.protocol   := False;\nend;\n\nprocedure FP(var f: Format; const id, desc: String; const default: Boolean; const extensions: Array of String);\nbegin\n  FR(f, id, desc, default, extensions);\n  f.protocol := True;\nend;\n\nprocedure FS(var f: Format; const subtype: String; const chkbytes : Array of String; UseAsync: Boolean);\nbegin\n  f.subtype     := subtype;\n  f.chkbytes    := chkbytes;\n  f.asyncSource := UseAsync;\nend;\n\nprocedure InitFormats();\nbegin\n  FR(SplitterFormats[0], 'matroska', 'Matroska/WebM', True, ['mkv','mka', 'mks', 'mk3d', 'webm', '']);\n  FS(SplitterFormats[0], '{1AC0BEBD-4D2B-45ad-BCEB-F2C41C5E3788}', ['0,4,,1A45DFA3', ''], True);\n  FR(SplitterFormats[1], 'avi', 'AVI', True, ['avi','divx', 'vp6', 'amv', '']);\n  FS(SplitterFormats[1], '{e436eb88-524f-11ce-9f53-0020af0ba770}', ['0,4,,52494646,8,4,,41564920', '0,4,,52494646,8,4,,41564958', '0,4,,52494646,8,4,,414D5620', ''], True);\n  FR(SplitterFormats[2], 'mp4', 'MP4/MOV', True, ['mp4', 'mov', '3gp', '3ga', 'm4v', 'qt', '']);\n  FS(SplitterFormats[2], '{08E22ADA-B715-45ed-9D20-7B87750301D4}', ['4,4,,66747970', '4,4,,6d6f6f76', '4,4,,6d646174', '4,4,,736b6970', '4,4,,75647461',\n                                                                    '4,12,ffffffff00000000ffffffff,77696465000000006d646174', '4,12,ffffffff00000000ffffffff,776964650000000066726565',\n                                                                    '4,12,ffffffff00000000ffffffff,6672656500000000636D6F76', '4,12,ffffffff00000000ffffffff,66726565000000006D766864',\n                                                                    '4,14,ffffffff000000000000ffffffff,706E6F7400000000000050494354', ''], True);\n  FR(SplitterFormats[3], 'mpegts', 'MPEG-TS', True, ['ts', 'm2ts', 'mts', 'tp', 'ssif', '']);\n  FS(SplitterFormats[3], '{e06d8023-db46-11cf-b4d1-00805f6cbbea}', ['0,1,,47,188,1,,47,376,1,,47', '4,1,,47,196,1,,47,388,1,,47', '0,4,,54467263,1660,1,,47', ''], True);\n  FR(SplitterFormats[4], 'mpeg', 'MPEG-PS/VOB/EVO', True, ['mpg', 'mpeg', 'vob', 'evo', '']);\n  FS(SplitterFormats[4], '{e06d8022-db46-11cf-b4d1-00805f6cbbea}', ['0,5,FFFFFFFFC0,000001BA40', ''], True);\n  FR(SplitterFormats[5], 'bluray', 'Blu-ray', True, ['bdmv', 'mpls', '']);\n  FS(SplitterFormats[5], '{20884BC2-629F-45EA-B1C5-FA4FFA438250}', ['0,4,,494E4458', '0,4,,4D4F424A', '0,4,,4D504C53', ''], False);\n  FR(SplitterFormats[6], 'flv', 'FLV', True, ['flv', '']);\n  FS(SplitterFormats[6], '{F2FAC0F1-3852-4670-AAC0-9051D400AC54}', ['0,4,,464C5601', ''], True);\n  FR(SplitterFormats[7], 'ogg', 'Ogg/OGM', True, ['ogg', 'ogv', 'ogm', '']);\n  FS(SplitterFormats[7], '{D2855FA9-61A7-4db0-B979-71F297C17A04}', ['0,4,,4F676753', ''], True);\n  FR(SplitterFormats[8], 'rm', 'RealMedia (rm/rmvb)', True, ['rm', 'rmvb', '']);\n  FR(SplitterFormats[9], 'wtv', 'Windows Television (wtv)', False, ['wtv', '']);\n  FR(SplitterFormats[10], 'asf', 'WMV / ASF / DVR-MS', True, ['wmv', 'asf', 'dvr-ms', '']);\n  FR(SplitterFormats[11], 'mxf', 'MXF (Material Exchange Format)', True, ['mxf', '']);\n  FR(SplitterFormats[12], 'bink', 'Bink', True, ['bik', '']);\n\n  FR(SplitterFormats[13], 'avisynth', 'AviSynth scripts', True, ['avs', '']);\n\n  FP(SplitterFormats[14], 'rtmp', 'RTMP Streaming Protocol', False, ['rtmp', 'rtmpt', '']);\n  FP(SplitterFormats[15], 'rtsp', 'RTSP Streaming Protocol', True, ['rtsp', 'rtspu', 'rtspm', 'rtspt', 'rtsph', '']);\n  FP(SplitterFormats[16], 'rtp', 'RTP Streaming Protocol', True, ['rtp', '']);\n  FP(SplitterFormats[17], 'mms', 'MMS Streaming Protocol', True, ['mms', 'mmsh', 'mmst', '']);\n\n  FR(SplitterFormats[18], 'dts', 'DTS Audio', True, ['dts', 'dtshd', '']);\n  FR(SplitterFormats[19], 'ac3', 'AC3 Audio', True, ['ac3', 'eac3', '']);\n  FR(SplitterFormats[20], 'aac', 'AAC Audio', True, ['aac', '']);\n  FR(SplitterFormats[21], 'mp3', 'MP3 Audio', True, ['mp3', '']);\n  FR(SplitterFormats[22], 'flac', 'FLAC Audio', True, ['flac', '']);\nend;\n\nprocedure RegWriteStringWithBackup(const RootKey: Integer; const SubKeyName, ValueName, Data: String);\nvar\n  OldValue: String;\nbegin\n  if RegQueryStringValue(RootKey, SubKeyName, ValueName, OldValue) then begin\n    if CompareText(OldValue, Data) <> 0 then begin\n      RegWriteStringValue(RootKey, SubKeyName, ValueName + '.LAV', OldValue);\n    end\n  end;\n  RegWriteStringValue(RootKey, SubKeyName, ValueName, Data);\nend;\n\nfunction RegRestoreBackup(const RootKey: Integer; const SubKeyName, ValueName, CheckValue: String; const DeleteMode: Integer) : Boolean;\nvar\n  CurrentValue: String;\n  BackupValue: String;\nbegin\n  Result := False;\n  if RegQueryStringValue(RootKey, SubKeyName, ValueName, CurrentValue) then begin\n    if CompareText(CurrentValue, CheckValue) = 0 then begin\n      if RegQueryStringValue(RootKey, SubKeyName, ValueName + '.LAV', BackupValue) then begin\n        RegWriteStringValue(RootKey, SubKeyName, ValueName, BackupValue);\n        Result := True;\n      end else begin\n        if DeleteMode = 1 then begin\n          RegDeleteValue(RootKey, SubKeyName, ValueName);\n          RegDeleteKeyIfEmpty(RootKey, SubKeyName);\n        end else if DeleteMode = 2 then\n          RegDeleteKeyIncludingSubkeys(RootKey, SubKeyName);\n      end\n    end\n  end;\n  RegDeleteValue(RootKey, SubKeyName, ValueName + '.LAV');\nend;\n\nprocedure RegisterSourceFormatGUIDs(f: Format);\nvar\n  i: Integer;\n  source: String;\nbegin\n  i := 0;\n  if Length(f.subtype) > 0 then\n    begin\n      if f.asyncSource then\n        source := '{e436ebb5-524f-11ce-9f53-0020af0ba770}'\n      else\n        source := LavGUID;\n      if IsComponentSelected('lavsplitter32') then\n        RegWriteStringWithBackup(HKCR32, 'Media Type\\' + StreamGUID + '\\' + f.subtype, 'Source Filter', source);\n      if IsComponentSelected('lavsplitter64') then\n        RegWriteStringWithBackup(HKCR64, 'Media Type\\' + StreamGUID + '\\' + f.subtype, 'Source Filter', source);\n    end;\n\n  while Length(f.chkbytes[i]) > 0 do\n    begin\n      if IsComponentSelected('lavsplitter32') then\n        RegWriteStringValue(HKCR32, 'Media Type\\' + StreamGUID + '\\' + f.subtype, IntToStr(i), f.chkbytes[i]);\n      if IsComponentSelected('lavsplitter64') then\n        RegWriteStringValue(HKCR64, 'Media Type\\' + StreamGUID + '\\' + f.subtype, IntToStr(i), f.chkbytes[i]);\n\n      i := i+1;\n    end;\nend;\n\nprocedure UnregisterSourceFormatGUIDs(f: Format);\nvar\n  SourceGuid: String;\n  DelMode: Integer;\nbegin\n  if Length(f.subtype) > 0 then\n  begin\n    if f.asyncSource then begin\n      SourceGuid := '{e436ebb5-524f-11ce-9f53-0020af0ba770}';\n      DelMode := 0;\n    end else begin\n      SourceGuid := LavGUID;\n      DelMode := 2;\n    end;\n    RegRestoreBackup(HKCR32, 'Media Type\\' + StreamGUID + '\\' + f.subtype, 'Source Filter', SourceGuid, DelMode);\n    if IsWin64 then\n      RegRestoreBackup(HKCR64, 'Media Type\\' + StreamGUID + '\\' + f.subtype, 'Source Filter', SourceGuid, DelMode);\n  end;\nend;\n\nprocedure RegisterSourceFormatExtensions(f: Format);\nvar\n  i: Integer;\nbegin\n  i := 0;\n  while Length(f.extensions[i]) > 0 do\n    begin\n      if f.protocol then begin\n        RegWriteStringWithBackup(HKCR, f.extensions[i], 'Source Filter', LavGUID);\n      end else begin\n        if IsComponentSelected('lavsplitter32') then begin\n          RegWriteStringWithBackup(HKCR32, 'Media Type\\Extensions\\.' + f.extensions[i], 'Source Filter', LavGUID);\n          RegWriteStringWithBackup(HKCR32, 'Media Type\\Extensions\\.' + f.extensions[i], 'Media Type', StreamGUID);\n          if Length(f.subtype) > 0 then\n            RegWriteStringWithBackup(HKCR32, 'Media Type\\Extensions\\.' + f.extensions[i], 'SubType', f.subtype);\n        end;\n        if IsComponentSelected('lavsplitter64') then begin\n          RegWriteStringWithBackup(HKCR64, 'Media Type\\Extensions\\.' + f.extensions[i], 'Source Filter', LavGUID);\n          RegWriteStringWithBackup(HKCR64, 'Media Type\\Extensions\\.' + f.extensions[i], 'Media Type', StreamGUID);\n          if Length(f.subtype) > 0 then\n            RegWriteStringWithBackup(HKCR64, 'Media Type\\Extensions\\.' + f.extensions[i], 'SubType', f.subtype);\n        end\n      end;\n\n      i := i+1;\n    end;\nend;\n\nprocedure UnregisterSourceFormatExtensions(f: Format);\nvar\n  source: String;\n  i: Integer;\nbegin\n  i := 0;\n  while Length(f.extensions[i]) > 0 do\n    begin\n      if f.protocol then\n        RegRestoreBackup(HKCR, f.extensions[i], 'Source Filter', LavGUID, 1)\n      else begin\n        RegRestoreBackup(HKCR32, 'Media Type\\Extensions\\.' + f.extensions[i], 'Source Filter', LavGUID, 2);\n        RegRestoreBackup(HKCR32, 'Media Type\\Extensions\\.' + f.extensions[i], 'Media Type', StreamGUID, 0);\n        if Length(f.subtype) > 0 then\n          RegRestoreBackup(HKCR32, 'Media Type\\Extensions\\.' + f.extensions[i], 'SubType', f.subtype, 0);\n        if IsWin64 then begin\n          RegRestoreBackup(HKCR64, 'Media Type\\Extensions\\.' + f.extensions[i], 'Source Filter', LavGUID, 2);\n          RegRestoreBackup(HKCR64, 'Media Type\\Extensions\\.' + f.extensions[i], 'Media Type', StreamGUID, 0);\n          if Length(f.subtype) > 0 then\n            RegRestoreBackup(HKCR64, 'Media Type\\Extensions\\.' + f.extensions[i], 'SubType', f.subtype, 0)\n        end\n      end;\n\n      i := i+1;\n    end;\nend;\n\nfunction GetDefaultFormatSetting(f: Format): Boolean;\nvar\n  value: Cardinal;\nbegin\n  if RegQueryDWordValue(HKCU, LavSplitterFormatsReg, f.id, value) then begin\n    Result := value > 0;\n  end else begin\n    Result := f.default;\n  end\nend;\n\nprocedure ResetSettings();\nbegin\n  RegDeleteKeyIncludingSubkeys(HKCU, 'Software\\LAV');\nend;\n\nprocedure DoUnzip(source: String; targetdir: String);\nvar\n    unzipTool: String;\n    ReturnCode: Integer;\nbegin\n    // source contains tmp constant, so resolve it to path name\n    source := ExpandConstant(source);\n\n    unzipTool := ExpandConstant('{tmp}\\7za.exe');\n\n    if not FileExists(unzipTool)\n    then MsgBox('UnzipTool not found: ' + unzipTool, mbError, MB_OK)\n    else if not FileExists(source)\n    then MsgBox('File was not found while trying to unzip: ' + source, mbError, MB_OK)\n    else begin\n         if Exec(unzipTool, ' x \"' + source + '\" -o\"' + targetdir + '\" -y',\n                 '', SW_HIDE, ewWaitUntilTerminated, ReturnCode) = false\n         then begin\n             MsgBox('Unzip failed:' + source, mbError, MB_OK)\n         end;\n    end;\nend;\n\nprocedure CurStepChanged(CurStep: TSetupStep);\nvar\n  i: Integer;\n  targetPath : String;\nbegin\n  if (CurStep = ssPostInstall) then begin\n    if IsTaskSelected('reset_settings') then\n      ResetSettings();\n\n    if IsComponentSelected('lavsplitter32') or IsComponentSelected('lavsplitter64') then\n      begin\n        for i := 0 to NumFormatsMinusOne do\n          begin\n            if SplitterPage.Values[i] then begin\n              RegisterSourceFormatGUIDs(SplitterFormats[i]);\n              RegisterSourceFormatExtensions(SplitterFormats[i]);\n            end else begin\n              UnregisterSourceFormatGUIDs(SplitterFormats[i]);\n              UnregisterSourceFormatExtensions(SplitterFormats[i]);\n            end;\n            RegWriteDWordValue(HKCU, LavSplitterFormatsReg, SplitterFormats[i].id, Ord(SplitterPage.Values[i]));\n          end;\n      end;\n\n      if IsComponentSelected('mvc3d') then\n      begin\n        ExtractTemporaryFile('7za.exe');\n        targetPath := ExpandConstant('{tmp}\\');\n        if IsComponentSelected('lavvideo32') then\n          DoUnzip(targetPath + 'libmfxsw32-v3.7z', ExpandConstant('{app}\\x86'));\n        if IsComponentSelected('lavvideo64') then\n          DoUnzip(targetPath + 'libmfxsw64-v3.7z', ExpandConstant('{app}\\x64'));\n      end;\n  end;\nend;\n\nprocedure CurPageChanged(CurPageID: Integer);\nbegin\n    if CurPageID = wpReady then\n    begin\n      // User can navigate to 'Ready to install' page several times, so we\n      // need to clear file list to ensure that only needed files are added.\n      idpClearFiles;\n\n      if IsComponentSelected('mvc3d') then\n      begin\n        if IsComponentSelected('lavvideo32') then\n          idpAddFile('https://files.1f0.de/lavf/plugins/libmfxsw32-v3.7z', ExpandConstant('{tmp}\\libmfxsw32-v3.7z'));\n        if IsComponentSelected('lavvideo64') then\n          idpAddFile('https://files.1f0.de/lavf/plugins/libmfxsw64-v3.7z', ExpandConstant('{tmp}\\libmfxsw64-v3.7z'));\n      end;\n  end;\nend;\n\nprocedure CurUninstallStepChanged(CurUninstallStep: TUninstallStep);\nvar\n  i: Integer;\nbegin\n  if (CurUninstallStep = usUninstall) then begin\n    for i := 0 to NumFormatsMinusOne do\n      begin\n        UnregisterSourceFormatGUIDs(SplitterFormats[i]);\n        UnregisterSourceFormatExtensions(SplitterFormats[i]);\n      end;\n  end;\nend;\n\nfunction ShouldSkipPage(PageID: Integer): Boolean;\nbegin\n  Result := False;\n  if PageID = SplitterPage.ID then begin\n    if not (IsComponentSelected('lavsplitter32') or IsComponentSelected('lavsplitter64')) then\n      Result := True;\n  end;\nend;\n\nfunction InitializeSetup(): Boolean;\nbegin\n  InitFormats;\n  Result := True;\n\n  if not Is_SSE2_Supported() then begin\n    SuppressibleMsgBox('LAV Filters requires a CPU with SSE2 instruction support.'#10'Your CPU does not have these capabilities.', mbCriticalError, MB_OK, MB_OK);\n    Result := False;\n  end;\nend;\n\nfunction InitializeUninstall(): Boolean;\nbegin\n  InitFormats;\n  Result := True;\nend;\n\nprocedure InitializeWizard();\nvar\n  i: Integer;\nbegin\n  SplitterPage := CreateInputOptionPage(wpSelectTasks,\n    'LAV Splitter Formats',\n    'Select which formats LAV Splitter should be setup to handle',\n    'Select for which formats LAV Splitter should be setup to be the Source Filter.'#10'Note: These are only the file formats for LAV Splitter, audio and video codecs are configured separately.',\n    False, False);\n\n  for i := 0 to NumFormatsMinusOne do\n    begin\n      SplitterPage.Add(SplitterFormats[i].name);\n      SplitterPage.Values[i] := GetDefaultFormatSetting(SplitterFormats[i]);\n    end;\n\n  // Adjust tasks page\n  WizardForm.SelectTasksLabel.Hide;\n  WizardForm.TasksList.Top    := 0;\n  WizardForm.TasksList.Height := PageFromID(wpSelectTasks).SurfaceHeight;\n\n  idpDownloadAfter(wpReady);\nend;\n"
  },
  {
    "path": "LAVFilters.sln",
    "content": "﻿\nMicrosoft Visual Studio Solution File, Format Version 12.00\n# Visual Studio Version 17\nVisualStudioVersion = 17.2.32630.192\nMinimumVisualStudioVersion = 16.0.30011.22\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"LAVSplitter\", \"demuxer\\LAVSplitter\\LAVSplitter.vcxproj\", \"{F475F86F-3F7F-4B1D-82A6-078339F599FD}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86} = {0A058024-41F4-4509-97D2-803A1806CE86}\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80} = {E2012DB5-33CB-44A7-B521-04287F6D0D80}\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} = {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"baseclasses\", \"common\\baseclasses\\baseclasses.vcxproj\", \"{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"DSUtilLite\", \"common\\DSUtilLite\\DSUtilLite.vcxproj\", \"{0A058024-41F4-4509-97D2-803A1806CE86}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} = {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"Demuxers\", \"demuxer\\Demuxers\\Demuxers.vcxproj\", \"{E2012DB5-33CB-44A7-B521-04287F6D0D80}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86} = {0A058024-41F4-4509-97D2-803A1806CE86}\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062} = {E1DA1B95-71F1-4C21-A271-121176925062}\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} = {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"LAVAudio\", \"decoder\\LAVAudio\\LAVAudio.vcxproj\", \"{12154C64-9136-4C21-92FA-665008C6FD27}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86} = {0A058024-41F4-4509-97D2-803A1806CE86}\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} = {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"libbluray\", \"libbluray\\libbluray.vcxproj\", \"{E1DA1B95-71F1-4C21-A271-121176925062}\"\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"LAVVideo\", \"decoder\\LAVVideo\\LAVVideo.vcxproj\", \"{D29ADED3-086B-46A8-9455-97EFF6B14775}\"\n\tProjectSection(ProjectDependencies) = postProject\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86} = {0A058024-41F4-4509-97D2-803A1806CE86}\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA} = {E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}\n\tEndProjectSection\nEndProject\nProject(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = \"IntelQuickSyncDecoder\", \"qsdecoder\\IntelQuickSyncDecoder.vcxproj\", \"{83F0170E-6AB3-467B-98D5-E061BD2BF00D}\"\nEndProject\nGlobal\n\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\n\t\tDebug|Win32 = Debug|Win32\n\t\tDebug|x64 = Debug|x64\n\t\tRelease|Win32 = Release|Win32\n\t\tRelease|x64 = Release|x64\n\tEndGlobalSection\n\tGlobalSection(ProjectConfigurationPlatforms) = postSolution\n\t\t{F475F86F-3F7F-4B1D-82A6-078339F599FD}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{F475F86F-3F7F-4B1D-82A6-078339F599FD}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{F475F86F-3F7F-4B1D-82A6-078339F599FD}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{F475F86F-3F7F-4B1D-82A6-078339F599FD}.Debug|x64.Build.0 = Debug|x64\n\t\t{F475F86F-3F7F-4B1D-82A6-078339F599FD}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{F475F86F-3F7F-4B1D-82A6-078339F599FD}.Release|Win32.Build.0 = Release|Win32\n\t\t{F475F86F-3F7F-4B1D-82A6-078339F599FD}.Release|x64.ActiveCfg = Release|x64\n\t\t{F475F86F-3F7F-4B1D-82A6-078339F599FD}.Release|x64.Build.0 = Release|x64\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Debug|x64.Build.0 = Debug|x64\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release|Win32.Build.0 = Release|Win32\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release|x64.ActiveCfg = Release|x64\n\t\t{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}.Release|x64.Build.0 = Release|x64\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86}.Debug|x64.Build.0 = Debug|x64\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86}.Release|Win32.Build.0 = Release|Win32\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86}.Release|x64.ActiveCfg = Release|x64\n\t\t{0A058024-41F4-4509-97D2-803A1806CE86}.Release|x64.Build.0 = Release|x64\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80}.Debug|x64.Build.0 = Debug|x64\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80}.Release|Win32.Build.0 = Release|Win32\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80}.Release|x64.ActiveCfg = Release|x64\n\t\t{E2012DB5-33CB-44A7-B521-04287F6D0D80}.Release|x64.Build.0 = Release|x64\n\t\t{12154C64-9136-4C21-92FA-665008C6FD27}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{12154C64-9136-4C21-92FA-665008C6FD27}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{12154C64-9136-4C21-92FA-665008C6FD27}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{12154C64-9136-4C21-92FA-665008C6FD27}.Debug|x64.Build.0 = Debug|x64\n\t\t{12154C64-9136-4C21-92FA-665008C6FD27}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{12154C64-9136-4C21-92FA-665008C6FD27}.Release|Win32.Build.0 = Release|Win32\n\t\t{12154C64-9136-4C21-92FA-665008C6FD27}.Release|x64.ActiveCfg = Release|x64\n\t\t{12154C64-9136-4C21-92FA-665008C6FD27}.Release|x64.Build.0 = Release|x64\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062}.Debug|x64.Build.0 = Debug|x64\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062}.Release|Win32.Build.0 = Release|Win32\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062}.Release|x64.ActiveCfg = Release|x64\n\t\t{E1DA1B95-71F1-4C21-A271-121176925062}.Release|x64.Build.0 = Release|x64\n\t\t{D29ADED3-086B-46A8-9455-97EFF6B14775}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{D29ADED3-086B-46A8-9455-97EFF6B14775}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{D29ADED3-086B-46A8-9455-97EFF6B14775}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{D29ADED3-086B-46A8-9455-97EFF6B14775}.Debug|x64.Build.0 = Debug|x64\n\t\t{D29ADED3-086B-46A8-9455-97EFF6B14775}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{D29ADED3-086B-46A8-9455-97EFF6B14775}.Release|Win32.Build.0 = Release|Win32\n\t\t{D29ADED3-086B-46A8-9455-97EFF6B14775}.Release|x64.ActiveCfg = Release|x64\n\t\t{D29ADED3-086B-46A8-9455-97EFF6B14775}.Release|x64.Build.0 = Release|x64\n\t\t{83F0170E-6AB3-467B-98D5-E061BD2BF00D}.Debug|Win32.ActiveCfg = Debug|Win32\n\t\t{83F0170E-6AB3-467B-98D5-E061BD2BF00D}.Debug|Win32.Build.0 = Debug|Win32\n\t\t{83F0170E-6AB3-467B-98D5-E061BD2BF00D}.Debug|x64.ActiveCfg = Debug|x64\n\t\t{83F0170E-6AB3-467B-98D5-E061BD2BF00D}.Debug|x64.Build.0 = Debug|x64\n\t\t{83F0170E-6AB3-467B-98D5-E061BD2BF00D}.Release|Win32.ActiveCfg = Release|Win32\n\t\t{83F0170E-6AB3-467B-98D5-E061BD2BF00D}.Release|Win32.Build.0 = Release|Win32\n\t\t{83F0170E-6AB3-467B-98D5-E061BD2BF00D}.Release|x64.ActiveCfg = Release|x64\n\t\t{83F0170E-6AB3-467B-98D5-E061BD2BF00D}.Release|x64.Build.0 = Release|x64\n\tEndGlobalSection\n\tGlobalSection(SolutionProperties) = preSolution\n\t\tHideSolutionNode = FALSE\n\tEndGlobalSection\n\tGlobalSection(ExtensibilityGlobals) = postSolution\n\t\tSolutionGuid = {F5B92918-449E-4214-B227-464B757DB420}\n\tEndGlobalSection\nEndGlobal\n"
  },
  {
    "path": "README.md",
    "content": "LAV Filters - ffmpeg based DirectShow Splitter and Decoders\n=============================\n\nLAV Filters are a set of DirectShow filters based on the libavformat and libavcodec libraries\nfrom the ffmpeg project, which will allow you to play virtually any format in a DirectShow player.\n\nThe filters are still under development, so not every feature is finished, or every format supported.\n\nInstall\n-----------------------------\n- Unpack\n- Register (install_*.bat files)\n\tRegistering requires administrative rights, and an elevated shell (\"Run as Administrator\")\n\nUsing it\n-----------------------------\nBy default, the splitter will register for all media formats that have been\ntested and found working at least partially.\nThis currently includes (but is not limited to)\n\tMKV/WebM, AVI, MP4/MOV, TS/M2TS/MPG, FLV, OGG, BluRay (.bdmv and .mpls)\n\nHowever, some other splitters register in a \"bad\" way and force all players\nto use them. The Haali Media Splitter is one of those, and to give priority\nto the LAVFSplitter you have to either uninstall Haali or rename its .ax file\nat least temporarily.\n\nThe Audio and Video Decoder will register with relatively high merit, which should make\nit the preferred decoder by default. Most players offer a way to choose the preferred\ndecoder however.\n\nAutomatic Stream Selection\n-----------------------------\nLAV Splitter offers different ways to pre-select streams when opening a file.\nThe selection of video streams is not configurable, and LAV Splitter will quite simply\npick the one with the best quality.\n\nAudio stream selection offers some flexibility, specifically you can configure your preferred languages.\nThe language configuration is straightforward. Just enter a list of 3-letter language codes (ISO 639-2),\nseparated by comma or space.\n\nFor example: `eng ger fre`. This would try to select a stream matching one of these languages,\nin the order you specified them. First, check if an English track is present, and only if not,\ngo to German, and after that, go to French.\n\nIf multiple audio tracks match one language, the choice is based on the quality. The primary attribute here\nis the number of channels, and after that is the codec used. PCM and lossless codecs have a higher priority\nthan lossy codecs.\n\nSubtitle selection offers the most flexibility.\nThere are 4 distinct modes of subtitle selection.\n\n#### No Subtitles\nThis mode is simple, by default subtitles will be off.\n\n#### Only Forced Subtitles\nThis mode will only pre-select subtitles flagged with the \"forced\" flag. It'll also obey the language preferences, of course.\n\n#### Default\nThe default mode will select subtitles matching your language preference. If there is no match, or you didn't configure\nlanguages, no subtitles will be activated. In addition, subtitles flagged \"default\" or \"forced\" will always be used.\n\n#### Advanced\nThe advanced mode lets you write your own combinations of rules with a special syntax. It also allows selecting subtitles\nbased on the audio language of the file.\n\nThe base syntax is simple, it always requires a pair of audio and subtitle language, separated by a colon, for example: `eng:ger`\nIn this example, LAV Splitter would select German subtitles if English audio was found.\n\nInstead of language codes, the advanced mode supports two special cases: `*` and `off`.\nWhen you specify `*` for a language code, it'll match everything. For example `*:eng`  will activate English subtitles, independent\nof the audio language. The reverse is also possible: `eng:*` will activate any subtitles when the audio is English.\n\nThe \"off\" flag is only valid for the subtitle language, and it instructs LAV Splitter to turn the subtitles off.\nSo \"eng:off\" means that when the audio is English, the subtitles will be deactivated.\n\nAdditionally to the syntax above, the following flags can be appended to the subtitle token separated by a pipe symbol (`|`):\n - `d` for default subtitles\n - `f` for forced subtitles\n - `h` for hearing impaired\n - `n` for normal streams (not default, forced, or impaired).\n\nIn addition, you can also check for the absence of flags by preceding the flags with a `!`.\nThe advanced rules can be combined into a complete logic for subtitle selection by just appending them, separated with a comma or a space.\nThe rules will always be parsed from left to right, the first match taking precedence.\n\nFinally, the rules can match the name of a stream, with some limitations. Only single words can be matched, as spaces are a separator for the next token.\nA text match can be added to the end of the token with a `@` sign.\n\nExample: (basic flag usage)\n- `*:*|f`\n  - On any audio language, load any subtitles that are flagged forced.\n\nExample: (basic ruleset)\n- `eng:eng|f eng:ger|f eng:off *:eng *:ger`\n  - If the audio is English, load an English or a German forced subtitle track, otherwise, turn subtitles off.\n  - If the audio is not English, load English or German subtitles.\n\nExample: (flag usage with negation)\n- `jpn:ger|d!f`\n  - In the Japanese language, load German subtitles that have the default-flag but not together with forced-flag.\n  - This is useful when you have files where the default and forced flags are set together.\n\nExample: (advanced ruleset for files with multiple audio and subtitle-tracks)\n- `jpn:ger|d!f  jpn:ger|!f  jpn:ger  ger:ger|f  ger:eng|f  ger:*|f`\n  - On Japanese audio, try to load German full subs (default but not forced), then unforced, and at last any german subs if there are no unforced subs.\n  - On German audio load only forced subs in the following order: German, English, any.\n\nExample: (text match)\n- `*:eng@Forced`\n  - On any audio, select english subtitle streams with \"Forced\" in the stream title.\n\nBlu-ray Support\n-----------------------------\nTo play a BluRay, simply open the index.bdmv file in the BDMV folder on the BluRay disc.\nLAV Splitter will then automatically detect the longest track on the disc (usually the main movie),\nand start playing.\nAlternatively, you can also open a playlist file (*.mpls, located in BDMV/PLAYLIST), and LAV Splitter\nwill then play that specific title.\n\nIn future versions, you'll be able to choose the title from within the player, as well.\n\nCompiling\n-----------------------------\nCompiling is pretty straightforward using VS2022 (included project files).\nOlder versions of Visual Studio are not officially supported, but may still work.\n\nIt does, however, require that you build your own FFmpeg.\nFFmpeg is included as part of the repository in a submodule, pointing to a custom\nfork of FFmpeg with various patches for improved compatibility with LAV and DirectShow.\n\nA script is provided to compile FFmpeg using MSYS2 with MINGW/GCC or MSVC.\n\nThe custom fork of FFmpeg can be found here:\nhttps://gitea.1f0.de/LAV/FFmpeg\n\nlibbluray is compiled with the MSVC project files, however, as with FFmpeg a custom\nversion is used, which is also linked as a Git submodule.\n\nYou can get find the custom version of libbluray here:\nhttps://gitea.1f0.de/LAV/libbluray\n\nFeedback\n-----------------------------\nGitHub Project: https://github.com/Nevcairiel/LAVFilters\nDoom9: https://forum.doom9.org/showthread.php?t=156191\n"
  },
  {
    "path": "build.bat",
    "content": "@ECHO OFF\n\nfor /f \"usebackq tokens=*\" %%i in (`call \"%ProgramFiles(x86)%\\Microsoft Visual Studio\\Installer\\vswhere.exe\" -version \"[16.0,18.0)\" -latest -products * -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath`) do (\n  set VSInstallDir=%%i\n)\n\nset \"VSCMD_START_DIR=%CD%\"\ncall \"%VSInstallDir%\\Common7\\Tools\\VsDevCmd.bat\" -no_logo -arch=x86 > NUL\n\nsh build_ffmpeg.sh x86 || EXIT /B 1\nMSBuild.exe LAVFilters.sln /nologo /m /t:Rebuild /property:Configuration=Release;Platform=Win32\nIF ERRORLEVEL 1 EXIT /B 1\n\nsh build_ffmpeg.sh x64 || EXIT /B 1\nMSBuild.exe LAVFilters.sln /nologo /m /t:Rebuild /property:Configuration=Release;Platform=x64\nIF ERRORLEVEL 1 EXIT /B 1\n\nPAUSE\n"
  },
  {
    "path": "build_ffmpeg.sh",
    "content": "#!/bin/sh\n\narch=x86\narchdir=Win32\nclean_build=true\ncross_prefix=\n\nCV2PDB=../thirdparty/contrib/cv2pdb.exe\n\nfor opt in \"$@\"\ndo\n    case \"$opt\" in\n    x86)\n            ;;\n    x64 | amd64)\n            arch=x86_64\n            archdir=x64\n            cross_prefix=x86_64-w64-mingw32-\n            ;;\n    quick)\n            clean_build=false\n            ;;\n    *)\n            echo \"Unknown Option $opt\"\n            exit 1\n    esac\ndone\n\nmake_dirs() (\n  mkdir -p bin_${archdir}/lib\n  mkdir -p bin_${archdir}d/lib\n)\n\ncopy_libs() (\n  # copy and process .dll/.pdb\n  for file in lib*/*-lav-*.dll; do\n    file_basename=$(basename $file)\n    file_pdb=$(basename $file .dll).pdb\n    ${CV2PDB} -p${file_pdb} ${file} ../bin_${archdir}d/${file_basename}\n    cp ../bin_${archdir}d/${file_basename} ../bin_${archdir}/\n    cp ../bin_${archdir}d/${file_pdb} ../bin_${archdir}/\n  done\n\n  # copy lib files\n  cp -u lib*/*.lib ../bin_${archdir}/lib\n  cp -u lib*/*.lib ../bin_${archdir}d/lib\n)\n\nclean() (\n  make distclean > /dev/null 2>&1\n)\n\nconfigure() (\n  OPTIONS=\"\n    --enable-shared                 \\\n    --disable-static                \\\n    --enable-gpl                    \\\n    --enable-version3               \\\n    --disable-autodetect            \\\n    --enable-w32threads             \\\n    --disable-demuxer=matroska      \\\n    --disable-filters               \\\n    --enable-filter=scale,yadif,w3fdif,bwdif \\\n    --disable-protocol=async,cache,concat,httpproxy,icecast,md5,subfile \\\n    --disable-muxers                \\\n    --enable-muxer=spdif            \\\n    --disable-bsfs                  \\\n    --enable-bsf=extract_extradata  \\\n    --disable-avdevice              \\\n    --disable-encoders              \\\n    --disable-devices               \\\n    --disable-programs              \\\n    --disable-debug                 \\\n    --disable-doc                   \\\n    --enable-avisynth               \\\n    --enable-bzlib                  \\\n    --enable-d3d11va                \\\n    --enable-dxva2                  \\\n    --enable-gnutls                 \\\n    --enable-gmp                    \\\n    --enable-libdav1d               \\\n    --enable-libspeex               \\\n    --enable-libopencore-amrnb      \\\n    --enable-libopencore-amrwb      \\\n    --enable-libxml2                \\\n    --enable-zlib                   \\\n    --build-suffix=-lav             \\\n    --disable-stripping             \\\n    --arch=${arch}\"\n\n  EXTRA_CFLAGS=\"-fno-tree-vectorize -D_WIN32_WINNT=0x0600 -DWINVER=0x0600 -gdwarf-5\"\n  EXTRA_LDFLAGS=\"\"\n  PKG_CONFIG_PREFIX_DIR=\"\"\n  if [ \"${arch}\" == \"x86_64\" ]; then\n    export PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH:../thirdparty/64/lib/pkgconfig/\"\n    OPTIONS=\"${OPTIONS} --enable-cross-compile --cross-prefix=${cross_prefix} --target-os=mingw32 --pkg-config=pkg-config\"\n    EXTRA_CFLAGS=\"${EXTRA_CFLAGS} -I../thirdparty/64/include -fno-omit-frame-pointer\"\n    EXTRA_LDFLAGS=\"${EXTRA_LDFLAGS} -L../thirdparty/64/lib\"\n    PKG_CONFIG_PREFIX_DIR=\"--define-variable=prefix=../thirdparty/64\"\n  else\n    export PKG_CONFIG_PATH=\"$PKG_CONFIG_PATH:../thirdparty/32/lib/pkgconfig/\"\n    OPTIONS=\"${OPTIONS} --cpu=i686\"\n    EXTRA_CFLAGS=\"${EXTRA_CFLAGS} -I../thirdparty/32/include -mmmx -msse -msse2 -mfpmath=sse -mstackrealign\"\n    EXTRA_LDFLAGS=\"${EXTRA_LDFLAGS} -L../thirdparty/32/lib\"\n    PKG_CONFIG_PREFIX_DIR=\"--define-variable=prefix=../thirdparty/32\"\n  fi\n\n  sh configure --extra-ldflags=\"${EXTRA_LDFLAGS}\" --extra-cflags=\"${EXTRA_CFLAGS}\" --pkg-config-flags=\"--static ${PKG_CONFIG_PREFIX_DIR}\" ${OPTIONS}\n)\n\nbuild() (\n  make -j$NUMBER_OF_PROCESSORS\n)\n\nmake_dirs\n\necho\necho Building ffmpeg in GCC ${arch} Release config...\necho\n\ncd ffmpeg\n\nif $clean_build ; then\n    clean\n\n    ## run configure, redirect to file because of a msys bug\n    configure > ffbuild/config.out 2>&1\n    CONFIGRETVAL=$?\n\n    ## show configure output\n    cat ffbuild/config.out\nfi\n\n## Only if configure succeeded, actually build\nif ! $clean_build || [ ${CONFIGRETVAL} -eq 0 ]; then\n  build &&\n  copy_libs || exit 1\nfi\n\ncd ..\n"
  },
  {
    "path": "build_ffmpeg_msvc.sh",
    "content": "#!/bin/sh\n\narch=x86\narchdir=Win32\narchincdir=32\nclean_build=true\ndebug=true\n\nfor opt in \"$@\"\ndo\n    case \"$opt\" in\n    x86)\n            ;;\n    x64 | amd64)\n            arch=x86_64\n            archdir=x64\n            archincdir=64\n            ;;\n    quick)\n            clean_build=false\n            ;;\n    release)\n            debug=false\n            ;;\n    *)\n            echo \"Unknown Option $opt\"\n            exit 1\n    esac\ndone\n\nmake_dirs() (\n  mkdir -p bin_${archdir}d/lib\n  mkdir -p bin_${archdir}/lib\n)\n\ncopy_libs() (\n  if $debug ; then\n      cp -u lib*/*-lav-*.dll ../bin_${archdir}d\n      cp -u lib*/*-lav-*.pdb ../bin_${archdir}d\n      cp -u lib*/*.lib ../bin_${archdir}d/lib\n  else\n      cp -u lib*/*-lav-*.dll ../bin_${archdir}\n      cp -u lib*/*-lav-*.pdb ../bin_${archdir}\n      cp -u lib*/*.lib ../bin_${archdir}/lib\n  fi\n)\n\nclean() (\n  make distclean > /dev/null 2>&1\n)\n\nconfigure() (\n  OPTIONS=\"\n    --enable-shared                 \\\n    --disable-static                \\\n    --enable-gpl                    \\\n    --enable-version3               \\\n    --disable-autodetect            \\\n    --enable-w32threads             \\\n    --disable-demuxer=matroska      \\\n    --disable-filters               \\\n    --enable-filter=scale,yadif,w3fdif,bwdif \\\n    --disable-protocol=async,cache,concat,httpproxy,icecast,md5,subfile \\\n    --disable-muxers                \\\n    --enable-muxer=spdif            \\\n    --disable-bsfs                  \\\n    --enable-bsf=extract_extradata  \\\n    --disable-avdevice              \\\n    --disable-encoders              \\\n    --disable-devices               \\\n    --disable-programs              \\\n    --disable-doc                   \\\n    --enable-avisynth               \\\n    --enable-d3d11va                \\\n    --enable-dxva2                  \\\n    --enable-schannel               \\\n    --enable-zlib                   \\\n    --build-suffix=-lav             \\\n    --arch=${arch}\"\n\n  EXTRA_CFLAGS=\"-D_WIN32_WINNT=0x0600 -DWINVER=0x0600 -Zo -GS- -I../thirdparty/$archincdir/include/\"\n  EXTRA_LDFLAGS=\"\"\n\n  if $debug ; then\n    OPTIONS=\"${OPTIONS} --enable-debug\"\n    EXTRA_CFLAGS=\"${EXTRA_CFLAGS} -MDd\"\n    EXTRA_LDFLAGS=\"${EXTRA_LDFLAGS} -NODEFAULTLIB:libcmt\"\n  else\n    OPTIONS=\"${OPTIONS} --disable-debug\"\n    EXTRA_CFLAGS=\"${EXTRA_CFLAGS} -MD\"\n    EXTRA_LDFLAGS=\"${EXTRA_LDFLAGS} -NODEFAULTLIB:libcmt\"\n  fi\n\n  sh configure --toolchain=msvc --extra-cflags=\"${EXTRA_CFLAGS}\" --extra-ldflags=\"${EXTRA_LDFLAGS}\" ${OPTIONS}\n)\n\nbuild() (\n  make -j$NUMBER_OF_PROCESSORS\n)\n\necho Building ffmpeg in MSVC Debug config...\n\nmake_dirs\n\ncd ffmpeg\n\nif $clean_build ; then\n    clean\n\n    ## run configure, redirect to file because of a msys bug\n    configure > ffbuild/config.out 2>&1\n    CONFIGRETVAL=$?\n\n    ## show configure output\n    cat ffbuild/config.out\nfi\n\n## Only if configure succeeded, actually build\nif ! $clean_build || [ ${CONFIGRETVAL} -eq 0 ]; then\n  build &&\n  copy_libs\nfi\n\ncd ..\n"
  },
  {
    "path": "common/DSUtilLite/BaseDSPropPage.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"BaseDSPropPage.h\"\n\nCBaseDSPropPage::CBaseDSPropPage(LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, int DialogId, int TitleId)\n    : CBasePropertyPage(pName, pUnk, DialogId, TitleId)\n{\n}\n\nHWND CBaseDSPropPage::createHintWindow(HWND parent, int timePop, int timeInit, int timeReshow)\n{\n    HWND hhint =\n        CreateWindowEx(WS_EX_TOPMOST, TOOLTIPS_CLASS, nullptr, WS_POPUP | TTS_NOPREFIX | TTS_ALWAYSTIP, CW_USEDEFAULT,\n                       CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, parent, nullptr, nullptr, nullptr);\n    SetWindowPos(hhint, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE);\n    SendMessage(hhint, TTM_SETDELAYTIME, TTDT_AUTOPOP, MAKELONG(timePop, 0));\n    SendMessage(hhint, TTM_SETDELAYTIME, TTDT_INITIAL, MAKELONG(timeInit, 0));\n    SendMessage(hhint, TTM_SETDELAYTIME, TTDT_RESHOW, MAKELONG(timeReshow, 0));\n    SendMessage(hhint, TTM_SETMAXTIPWIDTH, 0, 470);\n    return hhint;\n}\n\nTOOLINFO CBaseDSPropPage::addHint(int id, const LPWSTR text)\n{\n    if (!m_hHint)\n        m_hHint = createHintWindow(m_Dlg, 15000);\n    TOOLINFO ti;\n    ti.cbSize = sizeof(TOOLINFO);\n    ti.uFlags = TTF_SUBCLASS | TTF_IDISHWND;\n    ti.hwnd = m_Dlg;\n    ti.uId = (LPARAM)GetDlgItem(m_Dlg, id);\n    ti.lpszText = text;\n    SendMessage(m_hHint, TTM_ADDTOOL, 0, (LPARAM)&ti);\n    return ti;\n}\n\nvoid CBaseDSPropPage::ListView_AddCol(HWND hlv, int &ncol, int w, const wchar_t *txt, bool right)\n{\n    LVCOLUMN lvc;\n    lvc.mask = LVCF_FMT | LVCF_WIDTH | LVCF_TEXT | LVCF_SUBITEM;\n    lvc.iSubItem = ncol;\n    lvc.pszText = (LPWSTR)txt;\n    lvc.cx = w;\n    lvc.fmt = right ? LVCFMT_RIGHT : LVCFMT_LEFT;\n    ListView_InsertColumn(hlv, ncol, &lvc);\n    ncol++;\n}\n\nHRESULT CBaseDSPropPage::ShowPropPageDialog(IBaseFilter *pFilter, HWND hwndOwner)\n{\n    CheckPointer(pFilter, E_INVALIDARG);\n    CoInitialize(nullptr);\n\n    // Get PropertyPages interface\n    ISpecifyPropertyPages *pProp = nullptr;\n    HRESULT hr = pFilter->QueryInterface<ISpecifyPropertyPages>(&pProp);\n    if (SUCCEEDED(hr) && pProp)\n    {\n        // Get the filter's name and IUnknown pointer.\n        FILTER_INFO FilterInfo;\n        hr = pFilter->QueryFilterInfo(&FilterInfo);\n        // We don't need the graph, so don't sit on a ref to it\n        if (FilterInfo.pGraph)\n            FilterInfo.pGraph->Release();\n\n        IUnknown *pFilterUnk = nullptr;\n        pFilter->QueryInterface<IUnknown>(&pFilterUnk);\n\n        // Show the page.\n        CAUUID caGUID;\n        pProp->GetPages(&caGUID);\n        pProp->Release();\n        hr = OleCreatePropertyFrame(hwndOwner,          // Parent window\n                                    0, 0,               // Reserved\n                                    FilterInfo.achName, // Caption for the dialog box\n                                    1,                  // Number of objects (just the filter)\n                                    &pFilterUnk,        // Array of object pointers.\n                                    caGUID.cElems,      // Number of property pages\n                                    caGUID.pElems,      // Array of property page CLSIDs\n                                    0,                  // Locale identifier\n                                    0, nullptr          // Reserved\n        );\n\n        // Clean up.\n        pFilterUnk->Release();\n        CoTaskMemFree(caGUID.pElems);\n\n        hr = S_OK;\n    }\n    CoUninitialize();\n    return hr;\n}\n"
  },
  {
    "path": "common/DSUtilLite/BaseDSPropPage.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nclass CBaseDSPropPage : public CBasePropertyPage\n{\n  public:\n    CBaseDSPropPage(LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, int DialogId, int TitleId);\n\n  public:\n    static HRESULT ShowPropPageDialog(IBaseFilter *pFilter, HWND hwndOwner = nullptr);\n\n  protected:\n    // Convenience function to add a new column to a list view control\n    static void ListView_AddCol(HWND hlv, int &ncol, int w, const wchar_t *txt, bool right);\n\n    TOOLINFO addHint(int id, const LPWSTR text);\n\n  private:\n    HWND createHintWindow(HWND parent, int timePop = 1700, int timeInit = 70, int timeReshow = 7);\n\n  private:\n    HWND m_hHint = 0;\n};\n"
  },
  {
    "path": "common/DSUtilLite/BaseTrayIcon.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"DShowUtil.h\"\n#include \"BaseTrayIcon.h\"\n#include \"BaseDSPropPage.h\"\n\n#include <time.h>\n#include <process.h>\n#include <Shlwapi.h>\n\n#define TRAYICON 0x1f0\n#define MSG_TRAYICON WM_USER + 1\n#define MSG_QUIT WM_USER + 2\n\n// The assumed size of the propery page\n#define PROP_WIDTH_OFFSET 400\n#define PROP_HEIGHT_OFFSET 250\n\nstatic const WCHAR *noTrayProcesses[] = {L\"dllhost.exe\", L\"explorer.exe\", L\"ReClockHelper.dll\"};\n\nBOOL CBaseTrayIcon::ProcessBlackList()\n{\n    WCHAR fileName[1024];\n    GetModuleFileName(nullptr, fileName, 1024);\n    WCHAR *processName = PathFindFileName(fileName);\n\n    for (int i = 0; i < countof(noTrayProcesses); i++)\n    {\n        if (_wcsicmp(processName, noTrayProcesses[i]) == 0)\n            return TRUE;\n    }\n    return FALSE;\n}\n\nCBaseTrayIcon::CBaseTrayIcon(IBaseFilter *pFilter, const WCHAR *wszName, int resIcon)\n    : m_pFilter(pFilter)\n    , m_wszName(wszName)\n    , m_resIcon(resIcon)\n{\n    memset(&m_NotifyIconData, 0, sizeof(m_NotifyIconData));\n    m_evSetupFinished.Reset();\n    StartMessageThread();\n}\n\nCBaseTrayIcon::~CBaseTrayIcon(void)\n{\n    m_pFilter = nullptr;\n    if (m_hWnd)\n    {\n        SendMessage(m_hWnd, MSG_QUIT, 0, 0);\n        WaitForSingleObject(m_hThread, INFINITE);\n    }\n    CloseHandle(m_hThread);\n}\n\nHRESULT CBaseTrayIcon::StartMessageThread()\n{\n    m_hThread = (HANDLE)_beginthreadex(nullptr,           /* Security */\n                                       0,                 /* Stack Size */\n                                       InitialThreadProc, /* Thread process */\n                                       (LPVOID)this,      /* Arguments */\n                                       0,                 /* 0 = Start Immediately */\n                                       nullptr            /* Thread Address */\n    );\n    m_evSetupFinished.Wait();\n    return S_OK;\n}\n\nunsigned int WINAPI CBaseTrayIcon::InitialThreadProc(LPVOID pv)\n{\n    HRESULT hrCo = CoInitialize(nullptr);\n\n    CBaseTrayIcon *pTrayIcon = (CBaseTrayIcon *)pv;\n    unsigned int ret = pTrayIcon->TrayMessageThread();\n\n    if (SUCCEEDED(hrCo))\n        CoUninitialize();\n\n    return ret;\n}\n\nDWORD CBaseTrayIcon::TrayMessageThread()\n{\n    HRESULT hr;\n    MSG msg;\n\n    // Create the Window Class if it doesn't exist yet\n    hr = RegisterWindowClass();\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"CBaseTrayIcon::ThreadProc(): Failed to register window class\"));\n    }\n\n    // And the Window we use for messages\n    hr = CreateMessageWindow();\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"CBaseTrayIcon::ThreadProc(): Failed to create message window\"));\n        m_evSetupFinished.Set();\n        UnregisterClass(m_wszClassName, g_hInst);\n        return 1;\n    }\n    ASSERT(m_hWnd);\n\n    CreateTrayIconData();\n    Shell_NotifyIcon(NIM_ADD, &m_NotifyIconData);\n    Shell_NotifyIcon(NIM_SETVERSION, &m_NotifyIconData);\n\n    m_evSetupFinished.Set();\n\n    // Message loop\n    while (GetMessage(&msg, nullptr, 0, 0) > 0)\n    {\n        TranslateMessage(&msg);\n        DispatchMessage(&msg);\n    }\n\n    Shell_NotifyIcon(NIM_DELETE, &m_NotifyIconData);\n    // Free icon resources\n    if (m_NotifyIconData.hIcon)\n    {\n        DestroyIcon(m_NotifyIconData.hIcon);\n        m_NotifyIconData.hIcon = nullptr;\n    }\n\n    // Unregister the window class we used\n    UnregisterClass(m_wszClassName, g_hInst);\n\n    return 0;\n}\n\nHRESULT CBaseTrayIcon::RegisterWindowClass()\n{\n    swprintf_s(m_wszClassName, countof(m_wszClassName), L\"LAVTrayIconClass%d\", GetCurrentThreadId());\n\n    WNDCLASSEX wx = {};\n    wx.cbSize = sizeof(WNDCLASSEX);\n    wx.lpfnWndProc = WindowProc;\n    wx.hInstance = g_hInst;\n    wx.lpszClassName = m_wszClassName;\n    ATOM wndClass = RegisterClassEx(&wx);\n\n    return !wndClass ? E_FAIL : S_OK;\n}\n\nHRESULT CBaseTrayIcon::CreateMessageWindow()\n{\n    m_hWnd = CreateWindowEx(0, m_wszClassName, L\"LAV Tray Message Window\", 0, 0, 0, 0, 0, HWND_MESSAGE, nullptr,\n                            nullptr, nullptr);\n    SetWindowLongPtr(m_hWnd, GWLP_USERDATA, LONG_PTR(this));\n    return m_hWnd == nullptr ? E_FAIL : S_OK;\n}\n\nHRESULT CBaseTrayIcon::CreateTrayIconData()\n{\n    memset(&m_NotifyIconData, 0, sizeof(m_NotifyIconData));\n    m_NotifyIconData.cbSize = sizeof(m_NotifyIconData);\n    m_NotifyIconData.hWnd = m_hWnd;\n    m_NotifyIconData.uID = TRAYICON;\n    m_NotifyIconData.uFlags = NIF_ICON | NIF_TIP | NIF_MESSAGE;\n    m_NotifyIconData.hIcon = (HICON)LoadImage(g_hInst, MAKEINTRESOURCE(m_resIcon), IMAGE_ICON, 16, 16, LR_DEFAULTCOLOR);\n    m_NotifyIconData.uCallbackMessage = MSG_TRAYICON;\n    m_NotifyIconData.uVersion = NOTIFYICON_VERSION;\n    wcscpy_s(m_NotifyIconData.szTip, m_wszName);\n\n    return S_OK;\n}\n\nHRESULT CBaseTrayIcon::OpenPropPage()\n{\n    CheckPointer(m_pFilter, E_UNEXPECTED);\n    m_bPropPageOpen = TRUE;\n    RECT desktopRect;\n    GetWindowRect(GetDesktopWindow(), &desktopRect);\n    SetWindowPos(m_hWnd, 0, (desktopRect.right / 2) - PROP_WIDTH_OFFSET, (desktopRect.bottom / 2) - PROP_HEIGHT_OFFSET,\n                 0, 0, SWP_NOZORDER | SWP_NOSIZE);\n    CBaseDSPropPage::ShowPropPageDialog(m_pFilter, m_hWnd);\n    m_bPropPageOpen = FALSE;\n    return S_OK;\n}\n\nstatic BOOL CALLBACK enumWindowCallback(HWND hwnd, LPARAM lparam)\n{\n    HWND owner = (HWND)lparam;\n    if (owner == GetWindow(hwnd, GW_OWNER))\n    {\n        SetForegroundWindow(hwnd);\n        return FALSE;\n    }\n    return TRUE;\n}\n\nLRESULT CALLBACK CBaseTrayIcon::WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    CBaseTrayIcon *icon = (CBaseTrayIcon *)GetWindowLongPtr(hwnd, GWLP_USERDATA);\n    switch (uMsg)\n    {\n    case WM_DESTROY:\n        Shell_NotifyIcon(NIM_DELETE, &icon->m_NotifyIconData);\n        PostQuitMessage(0);\n        break;\n    case MSG_QUIT: DestroyWindow(hwnd); break;\n    case MSG_TRAYICON: {\n        UINT trayMsg = LOWORD(lParam);\n        if (icon)\n        {\n            switch (trayMsg)\n            {\n            case WM_LBUTTONUP:\n                if (!icon->m_bPropPageOpen)\n                {\n                    icon->OpenPropPage();\n                }\n                else\n                {\n                    EnumThreadWindows(GetCurrentThreadId(), enumWindowCallback, (LPARAM)icon->m_hWnd);\n                }\n                break;\n            case WM_RBUTTONUP:\n            case WM_CONTEXTMENU:\n                if (icon->m_bPropPageOpen)\n                {\n                    break;\n                }\n                HMENU hMenu = icon->GetPopupMenu();\n                if (hMenu)\n                {\n                    POINT p;\n                    GetCursorPos(&p);\n                    SetForegroundWindow(hwnd);\n                    int cmd = TrackPopupMenu(hMenu, TPM_RETURNCMD, p.x, p.y, 0, hwnd, nullptr);\n                    PostMessage(hwnd, WM_NULL, 0, 0);\n                    icon->ProcessMenuCommand(hMenu, cmd);\n                    DestroyMenu(hMenu);\n                }\n                break;\n            }\n        }\n    }\n    break;\n    }\n    return DefWindowProc(hwnd, uMsg, wParam, lParam);\n}\n"
  },
  {
    "path": "common/DSUtilLite/BaseTrayIcon.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <ShellAPI.h>\n\nclass CBaseTrayIcon\n{\n  public:\n    CBaseTrayIcon(IBaseFilter *pFilter, const WCHAR *wszName, int resIcon);\n    virtual ~CBaseTrayIcon(void);\n\n    static BOOL ProcessBlackList();\n\n  protected:\n    virtual HRESULT CreateTrayIconData();\n\n    virtual HMENU GetPopupMenu() { return nullptr; }\n    virtual HRESULT ProcessMenuCommand(HMENU hMenu, int cmd) { return E_NOTIMPL; }\n\n    HRESULT OpenPropPage();\n\n  private:\n    HRESULT StartMessageThread();\n    HRESULT RegisterWindowClass();\n    HRESULT CreateMessageWindow();\n\n    DWORD TrayMessageThread();\n    static unsigned int WINAPI InitialThreadProc(LPVOID pv);\n\n    static LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  protected:\n    IBaseFilter *m_pFilter;\n\n  private:\n    CAMEvent m_evSetupFinished{TRUE};\n\n    HANDLE m_hThread = 0;\n    HWND m_hWnd = 0;\n    BOOL m_bPropPageOpen = FALSE;\n\n    WCHAR m_wszClassName[64];\n    const WCHAR *m_wszName = nullptr;\n    int m_resIcon = 0;\n\n    NOTIFYICONDATA m_NotifyIconData;\n};\n"
  },
  {
    "path": "common/DSUtilLite/ByteParser.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"ByteParser.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4101)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 5033)\nextern \"C\"\n{\n#define AVCODEC_X86_MATHOPS_H\n#include \"libavcodec/get_bits.h\"\n};\n#pragma warning(pop)\n\nCByteParser::CByteParser(const BYTE *pData, size_t length)\n    : m_pData(pData)\n    , m_pEnd(pData + length)\n{\n    m_gbCtx = (GetBitContext *)av_mallocz(sizeof(GetBitContext));\n    init_get_bits8(m_gbCtx, pData, (int)length);\n}\n\nCByteParser::~CByteParser()\n{\n    av_freep(&m_gbCtx);\n}\n\nunsigned int CByteParser::BitRead(unsigned int numBits, bool peek)\n{\n    if (numBits == 0)\n        return 0;\n\n    if (peek)\n        return show_bits_long(m_gbCtx, numBits);\n    else\n        return get_bits_long(m_gbCtx, numBits);\n}\n\nvoid CByteParser::BitSkip(unsigned int numBits)\n{\n    if (numBits == 0)\n        return;\n\n    skip_bits_long(m_gbCtx, numBits);\n}\n\nsize_t CByteParser::RemainingBits() const\n{\n    int bits = get_bits_left(m_gbCtx);\n    if (bits < 0)\n        return 0;\n    return (size_t)bits;\n}\n\nsize_t CByteParser::Pos() const\n{\n    return (size_t)(m_pEnd - m_pData - Remaining());\n}\n\n// Exponential Golomb Coding (with k = 0)\n// As used in H.264/MPEG-4 AVC\n// http://en.wikipedia.org/wiki/Exponential-Golomb_coding\n\nunsigned CByteParser::UExpGolombRead()\n{\n    int n = -1;\n    for (BYTE b = 0; !b && RemainingBits(); n++)\n    {\n        b = get_bits1(m_gbCtx);\n    }\n    if (!RemainingBits())\n        return 0;\n    return ((1 << n) | BitRead(n)) - 1;\n}\n\nint CByteParser::SExpGolombRead()\n{\n    int k = UExpGolombRead() + 1;\n    // Negative numbers are interleaved in the series\n    // unsigned: 0, 1,  2, 3,  4, 5,  6, ...\n    //   signed: 0, 1, -1, 2, -2, 3, -3, ....\n    // So all even numbers are negative (last bit = 0)\n    // Note that we added 1 to the unsigned value already, so the check is inverted\n    if (k & 1)\n        return -(k >> 1);\n    else\n        return (k >> 1);\n}\n\nvoid CByteParser::BitByteAlign()\n{\n    align_get_bits(m_gbCtx);\n}\n"
  },
  {
    "path": "common/DSUtilLite/ByteParser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#pragma once\n\nstruct GetBitContext;\n\n/**\n * Byte Parser Utility Class\n */\nclass CByteParser\n{\n  public:\n    /** Construct a Byte Parser to parse the given BYTE array with the given length */\n    CByteParser(const BYTE *pData, size_t length);\n    virtual ~CByteParser();\n\n    /** Read 1 to 32 Bits from the Byte Array. If peek is set, the data will just be returned, and the buffer not\n     * advanced. */\n    unsigned int BitRead(unsigned int numBits, bool peek = false);\n\n    /** Skip any number of bits from the byte array */\n    void BitSkip(unsigned int numBits);\n\n    /** Read a unsigned number in Exponential Golomb encoding (with k = 0) */\n    unsigned int UExpGolombRead();\n    /** Read a signed number in Exponential Golomb encoding (with k = 0) */\n    int SExpGolombRead();\n\n    /** Pointer to the start of the byte array */\n    const BYTE *Start() const { return m_pData; }\n    /** Pointer to the end of the byte array */\n    const BYTE *End() const { return m_pEnd; }\n\n    /** Overall length (in bytes) of the byte array */\n    size_t Length() const;\n\n    size_t Pos() const;\n\n    /** Number of bytes remaining in the array */\n    size_t Remaining() const { return RemainingBits() >> 3; }\n\n    /** Number of bits remaining */\n    size_t RemainingBits() const;\n\n    void BitByteAlign();\n\n  private:\n    GetBitContext *m_gbCtx = nullptr;\n\n    const BYTE *m_pData = nullptr;\n    const BYTE *m_pEnd = nullptr;\n};\n"
  },
  {
    "path": "common/DSUtilLite/CueSheet.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"CueSheet.h\"\n\n#include <algorithm>\n#include <sstream>\n#include <regex>\n\nusing namespace std;\n\nenum class ParserState\n{\n    GLOBAL,\n    FILE,\n    TRACK\n};\n\ntypedef string::value_type char_t;\n\nstatic char_t up_char(char_t ch)\n{\n    return use_facet<ctype<char_t>>(locale()).toupper(ch);\n}\n\nstatic string toupper(const string &src)\n{\n    string result;\n    transform(src.begin(), src.end(), back_inserter(result), up_char);\n    return result;\n}\n\nstatic void str_replace(string &s, const string &search, const string &replace)\n{\n    for (string::size_type pos = 0;; pos += replace.length())\n    {\n        pos = s.find(search, pos);\n        if (pos == string::npos)\n            break;\n\n        s.erase(pos, search.length());\n        s.insert(pos, replace);\n    }\n}\n\nstatic string GetCueParam(string line, bool firstWord = false)\n{\n    const string delims(\" \\t\\n\\r\\\"'\");\n    string::size_type idx;\n    // Find beginning of the command word\n    idx = line.find_first_not_of(delims);\n    // Find end of the command word\n    idx = line.find_first_of(delims, idx);\n    // Find beginning of param\n    idx = line.find_first_not_of(delims, idx);\n    if (idx == string::npos)\n        return string();\n    string param = line.substr(idx);\n    // trim spaces off the end\n    param = param.substr(0, param.find_last_not_of(delims) + 1);\n    // replace escaped quotes\n    str_replace(param, \"\\\\\\\"\", \"\\\"\");\n\n    if (firstWord)\n    {\n        idx = param.find_first_of(delims);\n        if (idx != string::npos)\n            param = param.substr(0, idx);\n    }\n    return param;\n}\n\nstatic REFERENCE_TIME ParseCueIndex(string line)\n{\n    int index, m, s, f, ret;\n    ret = sscanf_s(line.c_str(), \" INDEX %d %d:%d:%d\", &index, &m, &s, &f);\n    if (ret == 4)\n        return (m * 60i64 + s) * 10000000i64 + (f * 10000000i64 / 75);\n    else\n        return 0;\n}\n\nCCueSheet::CCueSheet()\n{\n}\n\nCCueSheet::~CCueSheet()\n{\n}\n\nHRESULT CCueSheet::Parse(string cueSheet)\n{\n    DbgLog((LOG_TRACE, 10, L\"CCueSheet::Parse(): Parsing Cue Sheet\"));\n    int trackCount = 0;\n    ParserState state(ParserState::GLOBAL);\n    stringstream cueSheetStream(cueSheet);\n    string line;\n    while (getline(cueSheetStream, line))\n    {\n        string word;\n        (stringstream(line)) >> word;\n        word = toupper(word);\n        switch (state)\n        {\n        case ParserState::GLOBAL:\n            if (word == \"PERFORMER\")\n            {\n                m_Performer = GetCueParam(line);\n            }\n            else if (word == \"TITLE\")\n            {\n                m_Title = GetCueParam(line);\n            }\n            else if (word == \"FILE\")\n            {\n                state = ParserState::FILE;\n            }\n            break;\n        case ParserState::FILE:\n        case ParserState::TRACK:\n            if (word == \"FILE\")\n            {\n                DbgLog((LOG_TRACE, 10, L\"CCueSheet::Parse(): Multiple FILE segments not supported.\"));\n                return E_FAIL;\n            }\n            if (word == \"TRACK\")\n            {\n                state = ParserState::TRACK;\n                trackCount++;\n\n                string id = GetCueParam(line, true);\n                Track track{trackCount - 1, id, \"Title \" + id, 0, \"\"};\n                m_Tracks.push_back(track);\n            }\n            else if (state == ParserState::TRACK)\n            {\n                if (word == \"TITLE\")\n                {\n                    m_Tracks.back().Title = GetCueParam(line);\n                }\n                else if (word == \"INDEX\")\n                {\n                    m_Tracks.back().Time = ParseCueIndex(line);\n                }\n                else if (word == \"PERFORMER\")\n                {\n                    m_Tracks.back().Performer = GetCueParam(line);\n                }\n            }\n            break;\n        }\n    }\n\n    return S_OK;\n}\n\nstd::string CCueSheet::FormatTrack(Track &track)\n{\n    string trackFormat = track.Id + \". \";\n    if (!track.Performer.empty())\n        trackFormat += track.Performer + \" - \";\n    trackFormat += track.Title;\n    return trackFormat;\n}\n"
  },
  {
    "path": "common/DSUtilLite/CueSheet.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <string>\n#include <list>\n\nclass CCueSheet\n{\n  public:\n    CCueSheet();\n    ~CCueSheet();\n\n    HRESULT Parse(std::string cueSheet);\n\n  public:\n    struct Track\n    {\n        int index;\n        std::string Id;\n        std::string Title;\n        REFERENCE_TIME Time;\n        std::string Performer;\n    };\n\n    std::string m_Performer;\n    std::string m_Title;\n    std::list<Track> m_Tracks;\n\n    std::string FormatTrack(Track &track);\n};\n"
  },
  {
    "path": "common/DSUtilLite/DSMResourceBag.cpp",
    "content": "#include \"stdafx.h\"\n#include \"DSMResourceBag.h\"\n\n#include <algorithm>\n\nCDSMResource::CDSMResource()\n    : mime(L\"application/octet-stream\")\n{\n}\n\nCDSMResource::CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE *pData, int len, DWORD_PTR tag)\n{\n    this->name = name;\n    this->desc = desc;\n    this->mime = mime;\n    data.resize(len);\n    memcpy(data.data(), pData, data.size());\n    this->tag = tag;\n}\n\nCDSMResource &CDSMResource::operator=(const CDSMResource &r)\n{\n    if (this != &r)\n    {\n        name = r.name;\n        desc = r.desc;\n        mime = r.mime;\n        data = r.data;\n        tag = r.tag;\n    }\n    return *this;\n}\n\nCDSMResourceBag::CDSMResourceBag()\n{\n}\n\nCDSMResourceBag::~CDSMResourceBag()\n{\n    m_resources.clear();\n}\n\nSTDMETHODIMP_(DWORD) CDSMResourceBag::ResGetCount()\n{\n    CAutoLock lock(&m_csResources);\n    return (DWORD)m_resources.size();\n}\n\nSTDMETHODIMP CDSMResourceBag::ResGet(DWORD iIndex, BSTR *ppName, BSTR *ppDesc, BSTR *ppMime, BYTE **ppData,\n                                     DWORD *pDataLen, DWORD_PTR *pTag)\n{\n    CAutoLock lock(&m_csResources);\n\n    if (ppData && !pDataLen)\n        return E_INVALIDARG;\n\n    if (iIndex >= m_resources.size())\n        return E_INVALIDARG;\n\n    CDSMResource &r = m_resources[iIndex];\n\n    if (ppName)\n    {\n        *ppName = SysAllocString(r.name.data());\n        if (*ppName == NULL)\n            return E_OUTOFMEMORY;\n    }\n    if (ppDesc)\n    {\n        *ppDesc = SysAllocString(r.desc.data());\n        if (*ppDesc == NULL)\n            return E_OUTOFMEMORY;\n    }\n    if (ppMime)\n    {\n        *ppMime = SysAllocString(r.mime.data());\n        if (*ppMime == NULL)\n            return E_OUTOFMEMORY;\n    }\n    if (ppData)\n    {\n        *pDataLen = (DWORD)r.data.size();\n        memcpy(*ppData = (BYTE *)CoTaskMemAlloc(*pDataLen), r.data.data(), *pDataLen);\n    }\n    if (pTag)\n    {\n        *pTag = r.tag;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDSMResourceBag::ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, const BYTE *pData,\n                                     DWORD len, DWORD_PTR tag)\n{\n    CAutoLock lock(&m_csResources);\n\n    if (iIndex >= m_resources.size())\n        return E_INVALIDARG;\n\n    CDSMResource &r = m_resources[iIndex];\n\n    if (pName)\n        r.name = pName;\n\n    if (pDesc)\n        r.desc = pDesc;\n\n    if (pMime)\n        r.mime = pMime;\n\n    if (pData || len == 0)\n    {\n        r.data.resize(len);\n        if (pData)\n        {\n            memcpy(r.data.data(), pData, r.data.size());\n        }\n    }\n\n    r.tag = tag;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDSMResourceBag::ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE *pData, DWORD len,\n                                        DWORD_PTR tag)\n{\n    CAutoLock lock(&m_csResources);\n    m_resources.push_back(CDSMResource());\n    return ResSet((DWORD)m_resources.size() - 1, pName, pDesc, pMime, pData, len, tag);\n}\n\nSTDMETHODIMP CDSMResourceBag::ResRemoveAt(DWORD iIndex)\n{\n    CAutoLock lock(&m_csResources);\n\n    if (iIndex >= m_resources.size())\n        return E_INVALIDARG;\n\n    m_resources.erase(m_resources.cbegin() + iIndex);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDSMResourceBag::ResRemoveAll(DWORD_PTR tag)\n{\n    CAutoLock lock(&m_csResources);\n\n    if (tag)\n    {\n        m_resources.erase(\n            std::remove_if(m_resources.begin(), m_resources.end(), [&](const CDSMResource &r) { return r.tag == tag; }),\n            m_resources.end());\n    }\n    else\n    {\n        m_resources.clear();\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "common/DSUtilLite/DSMResourceBag.h",
    "content": "#pragma once\n\n#include \"IDSMResourceBag.h\"\n\n#include <string>\n#include <vector>\n#include <map>\n\nclass CDSMResource\n{\n  public:\n    CDSMResource();\n    CDSMResource(LPCWSTR name, LPCWSTR desc, LPCWSTR mime, BYTE *pData, int len, DWORD_PTR tag = 0);\n\n    CDSMResource &operator=(const CDSMResource &r);\n\n  public:\n    DWORD_PTR tag;\n    std::wstring name, desc, mime;\n    std::vector<BYTE> data;\n};\n\nclass CDSMResourceBag : public IDSMResourceBag\n{\n  public:\n    CDSMResourceBag();\n    virtual ~CDSMResourceBag();\n\n    // IDSMResourceBag\n    STDMETHODIMP_(DWORD) ResGetCount();\n    STDMETHODIMP ResGet(DWORD iIndex, BSTR *ppName, BSTR *ppDesc, BSTR *ppMime, BYTE **ppData, DWORD *pDataLen,\n                        DWORD_PTR *pTag = nullptr);\n    STDMETHODIMP ResSet(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, const BYTE *pData, DWORD len,\n                        DWORD_PTR tag = 0);\n    STDMETHODIMP ResAppend(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE *pData, DWORD len, DWORD_PTR tag = 0);\n    STDMETHODIMP ResRemoveAt(DWORD iIndex);\n    STDMETHODIMP ResRemoveAll(DWORD_PTR tag = 0);\n\n  private:\n    CCritSec m_csResources;\n    std::vector<CDSMResource> m_resources;\n};\n"
  },
  {
    "path": "common/DSUtilLite/DSUtilLite.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{0A058024-41F4-4509-97D2-803A1806CE86}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n    <RootNamespace>DSUtilLite</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <Import Project=\"$(SolutionDir)common\\platform.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Import Project=\"$(SolutionDir)common\\common.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <TargetName>dsutild</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n    <TargetName>dsutil</TargetName>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n    <PreBuildEvent>\n      <Command>\"$(SolutionDir)common\\genversion.bat\"</Command>\n    </PreBuildEvent>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Release'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n    <PreBuildEvent>\n      <Command>\"$(SolutionDir)common\\genversion.bat\"</Command>\n    </PreBuildEvent>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClInclude Include=\"BaseDSPropPage.h\" />\n    <ClInclude Include=\"CueSheet.h\" />\n    <ClInclude Include=\"DSMResourceBag.h\" />\n    <ClInclude Include=\"MediaSampleSideData.h\" />\n    <ClInclude Include=\"PopupMenu.h\" />\n    <ClInclude Include=\"BaseTrayIcon.h\" />\n    <ClInclude Include=\"ByteParser.h\" />\n    <ClInclude Include=\"DeCSS\\CSSauth.h\" />\n    <ClInclude Include=\"DeCSS\\CSSscramble.h\" />\n    <ClInclude Include=\"DeCSS\\DeCSSInputPin.h\" />\n    <ClInclude Include=\"DShowUtil.h\" />\n    <ClInclude Include=\"FloatingAverage.h\" />\n    <ClInclude Include=\"FontInstaller.h\" />\n    <ClInclude Include=\"gpu_memcpy_sse4.h\" />\n    <ClInclude Include=\"growarray.h\" />\n    <ClInclude Include=\"H264Nalu.h\" />\n    <ClInclude Include=\"lavf_log.h\" />\n    <ClInclude Include=\"rand_sse.h\" />\n    <ClInclude Include=\"registry.h\" />\n    <ClInclude Include=\"stdafx.h\" />\n    <ClInclude Include=\"SynchronizedQueue.h\" />\n    <ClInclude Include=\"timer.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"BaseDSPropPage.cpp\" />\n    <ClCompile Include=\"CueSheet.cpp\" />\n    <ClCompile Include=\"DSMResourceBag.cpp\" />\n    <ClCompile Include=\"MediaSampleSideData.cpp\" />\n    <ClCompile Include=\"PopupMenu.cpp\" />\n    <ClCompile Include=\"BaseTrayIcon.cpp\" />\n    <ClCompile Include=\"ByteParser.cpp\" />\n    <ClCompile Include=\"DeCSS\\CSSauth.cpp\" />\n    <ClCompile Include=\"DeCSS\\CSSscramble.cpp\" />\n    <ClCompile Include=\"DeCSS\\DeCSSInputPin.cpp\" />\n    <ClCompile Include=\"DShowUtil.cpp\" />\n    <ClCompile Include=\"filterreg.cpp\" />\n    <ClCompile Include=\"FontInstaller.cpp\" />\n    <ClCompile Include=\"H264Nalu.cpp\" />\n    <ClCompile Include=\"locale.cpp\" />\n    <ClCompile Include=\"registry.cpp\" />\n    <ClCompile Include=\"stdafx.cpp\">\n      <PrecompiledHeader>Create</PrecompiledHeader>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\baseclasses\\baseclasses.vcxproj\">\n      <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>\n    </ProjectReference>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>\n"
  },
  {
    "path": "common/DSUtilLite/DSUtilLite.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\\DeCSS\">\n      <UniqueIdentifier>{a130de5c-2e03-4582-92a8-2675b370e46f}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\DeCSS\">\n      <UniqueIdentifier>{b645319e-a7a0-4188-b5cb-516008bf32c5}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"stdafx.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"H264Nalu.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DShowUtil.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"registry.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"growarray.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"FloatingAverage.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"BaseDSPropPage.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"FontInstaller.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DeCSS\\CSSauth.h\">\n      <Filter>Header Files\\DeCSS</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DeCSS\\CSSscramble.h\">\n      <Filter>Header Files\\DeCSS</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DeCSS\\DeCSSInputPin.h\">\n      <Filter>Header Files\\DeCSS</Filter>\n    </ClInclude>\n    <ClInclude Include=\"ByteParser.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"lavf_log.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"gpu_memcpy_sse4.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"rand_sse.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"SynchronizedQueue.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"BaseTrayIcon.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"PopupMenu.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CueSheet.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"timer.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DSMResourceBag.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"MediaSampleSideData.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"stdafx.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"H264Nalu.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"filterreg.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"locale.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"DShowUtil.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"registry.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"BaseDSPropPage.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"FontInstaller.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"DeCSS\\CSSauth.cpp\">\n      <Filter>Source Files\\DeCSS</Filter>\n    </ClCompile>\n    <ClCompile Include=\"DeCSS\\CSSscramble.cpp\">\n      <Filter>Source Files\\DeCSS</Filter>\n    </ClCompile>\n    <ClCompile Include=\"DeCSS\\DeCSSInputPin.cpp\">\n      <Filter>Source Files\\DeCSS</Filter>\n    </ClCompile>\n    <ClCompile Include=\"ByteParser.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"BaseTrayIcon.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"PopupMenu.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CueSheet.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"DSMResourceBag.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"MediaSampleSideData.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "common/DSUtilLite/DShowUtil.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"DShowUtil.h\"\n\n#include <Shlwapi.h>\n\n#include <dvdmedia.h>\n#include \"moreuuids.h\"\n\n#include \"registry.h\"\n\n#include \"IMediaSideDataFFmpeg.h\"\n\n//\n// Usage: SetThreadName (-1, \"MainThread\");\n//\ntypedef struct tagTHREADNAME_INFO\n{\n    DWORD dwType;     // must be 0x1000\n    LPCSTR szName;    // pointer to name (in user addr space)\n    DWORD dwThreadID; // thread ID (-1=caller thread)\n    DWORD dwFlags;    // reserved for future use, must be zero\n} THREADNAME_INFO;\n\nconst DWORD MS_VC_EXCEPTION = 0x406D1388;\n\nvoid SetThreadName(DWORD dwThreadID, LPCSTR szThreadName)\n{\n    THREADNAME_INFO info;\n    info.dwType = 0x1000;\n    info.szName = szThreadName;\n    info.dwThreadID = dwThreadID;\n    info.dwFlags = 0;\n\n    __try\n    {\n        RaiseException(MS_VC_EXCEPTION, 0, sizeof(info) / sizeof(ULONG_PTR), (ULONG_PTR *)&info);\n    }\n    __except (EXCEPTION_EXECUTE_HANDLER)\n    {\n    }\n}\n\n#ifdef DEBUG\n\n#include <Shlobj.h>\n#include <Shlwapi.h>\n\nextern HANDLE m_hOutput;\nvolatile LONG hOutputCounter = 0;\nextern HRESULT DbgUniqueProcessName(LPCTSTR inName, LPTSTR outName);\nvoid DbgSetLogFile(LPCTSTR szFile)\n{\n    HANDLE hOutput =\n        CreateFile(szFile, GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, nullptr);\n\n    if (INVALID_HANDLE_VALUE == hOutput && GetLastError() == ERROR_SHARING_VIOLATION)\n    {\n        TCHAR uniqueName[MAX_PATH] = {0};\n        if (SUCCEEDED(DbgUniqueProcessName(szFile, uniqueName)))\n        {\n            hOutput = CreateFile(uniqueName, GENERIC_WRITE, FILE_SHARE_READ, nullptr, CREATE_ALWAYS,\n                                 FILE_ATTRIBUTE_NORMAL, nullptr);\n        }\n    }\n\n    if (hOutput != INVALID_HANDLE_VALUE)\n    {\n        if (InterlockedCompareExchangePointer(&m_hOutput, hOutput, INVALID_HANDLE_VALUE) != INVALID_HANDLE_VALUE)\n            CloseHandle(hOutput);\n    }\n\n    InterlockedIncrement(&hOutputCounter);\n}\n\nvoid DbgSetLogFileDesktop(LPCTSTR szFile)\n{\n    TCHAR szLogPath[512];\n    SHGetFolderPath(nullptr, CSIDL_DESKTOPDIRECTORY, nullptr, 0, szLogPath);\n    PathAppend(szLogPath, szFile);\n    DbgSetLogFile(szLogPath);\n}\n\nvoid DbgCloseLogFile()\n{\n    LONG count = InterlockedDecrement(&hOutputCounter);\n    if (count == 0 && m_hOutput != INVALID_HANDLE_VALUE)\n    {\n        FlushFileBuffers(m_hOutput);\n        CloseHandle(m_hOutput);\n        m_hOutput = INVALID_HANDLE_VALUE;\n    }\n}\n#endif\n\nvoid split(const std::string &text, const std::string &separators, std::list<std::string> &words)\n{\n    size_t n = text.length();\n    size_t start, stop;\n\n    start = text.find_first_not_of(separators);\n    while ((start >= 0) && (start < n))\n    {\n        stop = text.find_first_of(separators, start);\n        if ((stop < 0) || (stop > n))\n            stop = n;\n        words.push_back(text.substr(start, stop - start));\n        start = text.find_first_not_of(separators, stop + 1);\n    }\n}\n\nIBaseFilter *FindFilter(const GUID &clsid, IFilterGraph *pFG)\n{\n    IBaseFilter *pFilter = nullptr;\n    IEnumFilters *pEnumFilters = nullptr;\n    if (pFG && SUCCEEDED(pFG->EnumFilters(&pEnumFilters)))\n    {\n        for (IBaseFilter *pBF = nullptr; S_OK == pEnumFilters->Next(1, &pBF, 0);)\n        {\n            GUID clsid2;\n            if (SUCCEEDED(pBF->GetClassID(&clsid2)) && clsid == clsid2)\n            {\n                pFilter = pBF;\n                break;\n            }\n            SafeRelease(&pBF);\n        }\n        SafeRelease(&pEnumFilters);\n    }\n\n    return pFilter;\n}\n\nBOOL FilterInGraph(const GUID &clsid, IFilterGraph *pFG)\n{\n    BOOL bFound = FALSE;\n    IBaseFilter *pFilter = nullptr;\n\n    pFilter = FindFilter(clsid, pFG);\n    bFound = (pFilter != nullptr);\n    SafeRelease(&pFilter);\n\n    return bFound;\n}\n\nBOOL FilterInGraphWithInputSubtype(const GUID &clsid, IFilterGraph *pFG, const GUID &clsidSubtype)\n{\n    BOOL bFound = FALSE;\n    IBaseFilter *pFilter = nullptr;\n\n    pFilter = FindFilter(clsid, pFG);\n\n    if (pFilter)\n    {\n        IEnumPins *pPinEnum = nullptr;\n        pFilter->EnumPins(&pPinEnum);\n        IPin *pPin = nullptr;\n        while ((S_OK == pPinEnum->Next(1, &pPin, nullptr)) && pPin)\n        {\n            PIN_DIRECTION dir;\n            pPin->QueryDirection(&dir);\n            if (dir == PINDIR_INPUT)\n            {\n                AM_MEDIA_TYPE mt;\n                pPin->ConnectionMediaType(&mt);\n\n                if (mt.subtype == clsidSubtype)\n                {\n                    bFound = TRUE;\n                }\n                FreeMediaType(mt);\n            }\n            SafeRelease(&pPin);\n\n            if (bFound)\n                break;\n        }\n\n        SafeRelease(&pPinEnum);\n        SafeRelease(&pFilter);\n    }\n\n    return bFound;\n}\n\nstd::wstring WStringFromGUID(const GUID &guid)\n{\n    WCHAR null[128] = {0}, buff[128];\n    StringFromGUID2(GUID_NULL, null, 127);\n    return std::wstring(StringFromGUID2(guid, buff, 127) > 0 ? buff : null);\n}\n\nint SafeMultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, LPWSTR lpWideCharStr,\n                            int cchWideChar)\n{\n    int len = MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, lpWideCharStr, cchWideChar);\n    if (cchWideChar)\n    {\n        if (len == cchWideChar || (len == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER))\n        {\n            lpWideCharStr[cchWideChar - 1] = 0;\n        }\n        else if (len == 0)\n        {\n            DWORD dwErr = GetLastError();\n            if (dwErr == ERROR_NO_UNICODE_TRANSLATION && CodePage == CP_UTF8)\n            {\n                return SafeMultiByteToWideChar(CP_ACP, dwFlags, lpMultiByteStr, cbMultiByte, lpWideCharStr,\n                                               cchWideChar);\n            }\n            else if (dwErr == ERROR_NO_UNICODE_TRANSLATION && (dwFlags & MB_ERR_INVALID_CHARS))\n            {\n                return SafeMultiByteToWideChar(CP_UTF8, (dwFlags & ~MB_ERR_INVALID_CHARS), lpMultiByteStr, cbMultiByte,\n                                               lpWideCharStr, cchWideChar);\n            }\n            lpWideCharStr[0] = 0;\n        }\n    }\n    return len;\n}\n\nint SafeWideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr,\n                            int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar)\n{\n    int len = WideCharToMultiByte(CodePage, dwFlags, lpWideCharStr, cchWideChar, lpMultiByteStr, cbMultiByte,\n                                  lpDefaultChar, lpUsedDefaultChar);\n    if (cbMultiByte)\n    {\n        if (len == cbMultiByte || (len == 0 && GetLastError() == ERROR_INSUFFICIENT_BUFFER))\n        {\n            lpMultiByteStr[cbMultiByte - 1] = 0;\n        }\n        else if (len == 0)\n        {\n            lpMultiByteStr[0] = 0;\n        }\n    }\n    return len;\n}\n\nLPWSTR CoTaskGetWideCharFromMultiByte(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte)\n{\n    int len = MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, nullptr, 0);\n    if (len)\n    {\n        LPWSTR pszWideString = (LPWSTR)CoTaskMemAlloc(len * sizeof(WCHAR));\n        MultiByteToWideChar(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, pszWideString, len);\n\n        return pszWideString;\n    }\n    else\n    {\n        DWORD dwErr = GetLastError();\n        if (dwErr == ERROR_NO_UNICODE_TRANSLATION && CodePage == CP_UTF8)\n        {\n            return CoTaskGetWideCharFromMultiByte(CP_ACP, dwFlags, lpMultiByteStr, cbMultiByte);\n        }\n        else if (dwErr == ERROR_NO_UNICODE_TRANSLATION && (dwFlags & MB_ERR_INVALID_CHARS))\n        {\n            return CoTaskGetWideCharFromMultiByte(CP_UTF8, (dwFlags & ~MB_ERR_INVALID_CHARS), lpMultiByteStr,\n                                                  cbMultiByte);\n        }\n    }\n    return NULL;\n}\n\nLPSTR CoTaskGetMultiByteFromWideChar(UINT CodePage, DWORD dwFlags, LPCWSTR lpMultiByteStr, int cbMultiByte)\n{\n    int len = WideCharToMultiByte(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, nullptr, 0, nullptr, nullptr);\n    if (len)\n    {\n        LPSTR pszMBString = (LPSTR)CoTaskMemAlloc(len * sizeof(char));\n        WideCharToMultiByte(CodePage, dwFlags, lpMultiByteStr, cbMultiByte, pszMBString, len, nullptr, nullptr);\n\n        return pszMBString;\n    }\n    return NULL;\n}\n\nBSTR ConvertCharToBSTR(const char *sz)\n{\n    bool acp = false;\n    if (!sz || strlen(sz) == 0)\n        return nullptr;\n\n    WCHAR *wide = CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, sz, -1);\n    if (!wide)\n        return nullptr;\n\n    BSTR bstr = SysAllocString(wide);\n    CoTaskMemFree(wide);\n\n    return bstr;\n}\n\nIBaseFilter *GetFilterFromPin(IPin *pPin)\n{\n    CheckPointer(pPin, nullptr);\n\n    PIN_INFO pi;\n    if (pPin && SUCCEEDED(pPin->QueryPinInfo(&pi)))\n    {\n        return pi.pFilter;\n    }\n\n    return nullptr;\n}\n\nHRESULT NukeDownstream(IFilterGraph *pGraph, IPin *pPin)\n{\n    PIN_DIRECTION dir;\n    if (pPin)\n    {\n        IPin *pPinTo = nullptr;\n        if (FAILED(pPin->QueryDirection(&dir)))\n            return E_FAIL;\n        if (dir == PINDIR_OUTPUT)\n        {\n            if (SUCCEEDED(pPin->ConnectedTo(&pPinTo)) && pPinTo)\n            {\n                if (IBaseFilter *pFilter = GetFilterFromPin(pPinTo))\n                {\n                    NukeDownstream(pGraph, pFilter);\n                    pGraph->Disconnect(pPinTo);\n                    pGraph->Disconnect(pPin);\n                    pGraph->RemoveFilter(pFilter);\n                    SafeRelease(&pFilter);\n                }\n                SafeRelease(&pPinTo);\n            }\n        }\n    }\n\n    return S_OK;\n}\n\nHRESULT NukeDownstream(IFilterGraph *pGraph, IBaseFilter *pFilter)\n{\n    IEnumPins *pEnumPins = nullptr;\n    if (pFilter && SUCCEEDED(pFilter->EnumPins(&pEnumPins)))\n    {\n        for (IPin *pPin = nullptr; S_OK == pEnumPins->Next(1, &pPin, 0); pPin = nullptr)\n        {\n            NukeDownstream(pGraph, pPin);\n            SafeRelease(&pPin);\n        }\n        SafeRelease(&pEnumPins);\n    }\n\n    return S_OK;\n}\n\n// pPin - pin of our filter to start searching\n// refiid - guid of the interface to find\n// pUnknown - variable that'll receive the interface\nHRESULT FindIntefaceInGraph(IPin *pPin, REFIID refiid, void **pUnknown)\n{\n    PIN_DIRECTION dir;\n    pPin->QueryDirection(&dir);\n\n    IPin *pOtherPin = nullptr;\n    if (SUCCEEDED(pPin->ConnectedTo(&pOtherPin)) && pOtherPin)\n    {\n        IBaseFilter *pFilter = GetFilterFromPin(pOtherPin);\n        SafeRelease(&pOtherPin);\n\n        HRESULT hrFilter = pFilter->QueryInterface(refiid, pUnknown);\n        if (FAILED(hrFilter))\n        {\n            IEnumPins *pPinEnum = nullptr;\n            pFilter->EnumPins(&pPinEnum);\n\n            HRESULT hrPin = E_FAIL;\n            for (IPin *pOtherPin2 = nullptr; pPinEnum->Next(1, &pOtherPin2, 0) == S_OK; pOtherPin2 = nullptr)\n            {\n                PIN_DIRECTION pinDir;\n                pOtherPin2->QueryDirection(&pinDir);\n                if (dir == pinDir)\n                {\n                    hrPin = FindIntefaceInGraph(pOtherPin2, refiid, pUnknown);\n                }\n                SafeRelease(&pOtherPin2);\n                if (SUCCEEDED(hrPin))\n                    break;\n            }\n            hrFilter = hrPin;\n            SafeRelease(&pPinEnum);\n        }\n        SafeRelease(&pFilter);\n\n        if (SUCCEEDED(hrFilter))\n        {\n            return S_OK;\n        }\n    }\n    return E_NOINTERFACE;\n}\n\n// pPin - pin of our filter to start searching\n// refiid - guid of the interface to find\n// pUnknown - variable that'll receive the interface\nHRESULT FindPinIntefaceInGraph(IPin *pPin, REFIID refiid, void **pUnknown)\n{\n    PIN_DIRECTION dir;\n    pPin->QueryDirection(&dir);\n\n    IPin *pOtherPin = nullptr;\n    if (SUCCEEDED(pPin->ConnectedTo(&pOtherPin)) && pOtherPin)\n    {\n        IBaseFilter *pFilter = nullptr;\n        HRESULT hrFilter = pOtherPin->QueryInterface(refiid, pUnknown);\n\n        if (FAILED(hrFilter))\n        {\n            pFilter = GetFilterFromPin(pOtherPin);\n\n            IEnumPins *pPinEnum = nullptr;\n            pFilter->EnumPins(&pPinEnum);\n\n            HRESULT hrPin = E_FAIL;\n            for (IPin *pOtherPin2 = nullptr; pPinEnum->Next(1, &pOtherPin2, 0) == S_OK; pOtherPin2 = nullptr)\n            {\n                PIN_DIRECTION pinDir;\n                pOtherPin2->QueryDirection(&pinDir);\n                if (dir == pinDir)\n                {\n                    hrPin = FindPinIntefaceInGraph(pOtherPin2, refiid, pUnknown);\n                }\n                SafeRelease(&pOtherPin2);\n                if (SUCCEEDED(hrPin))\n                    break;\n            }\n            hrFilter = hrPin;\n            SafeRelease(&pPinEnum);\n        }\n        SafeRelease(&pFilter);\n        SafeRelease(&pOtherPin);\n\n        if (SUCCEEDED(hrFilter))\n        {\n            return S_OK;\n        }\n    }\n    return E_NOINTERFACE;\n}\n\n// pPin - pin of our filter to start searching\n// guid - guid of the filter to find\n// ppFilter - variable that'll receive a AddRef'd reference to the filter\nHRESULT FindFilterSafe(IPin *pPin, const GUID &guid, IBaseFilter **ppFilter, BOOL bReverse)\n{\n    CheckPointer(ppFilter, E_POINTER);\n    CheckPointer(pPin, E_POINTER);\n    HRESULT hr = S_OK;\n\n    PIN_DIRECTION dir;\n    pPin->QueryDirection(&dir);\n\n    IPin *pOtherPin = nullptr;\n    if (bReverse)\n    {\n        dir = (dir == PINDIR_INPUT) ? PINDIR_OUTPUT : PINDIR_INPUT;\n        pOtherPin = pPin;\n        pPin->AddRef();\n        hr = S_OK;\n    }\n    else\n    {\n        hr = pPin->ConnectedTo(&pOtherPin);\n    }\n    if (SUCCEEDED(hr) && pOtherPin)\n    {\n        IBaseFilter *pFilter = GetFilterFromPin(pOtherPin);\n        SafeRelease(&pOtherPin);\n\n        HRESULT hrFilter = E_NOINTERFACE;\n        CLSID filterGUID;\n        if (SUCCEEDED(pFilter->GetClassID(&filterGUID)))\n        {\n            if (filterGUID == guid)\n            {\n                *ppFilter = pFilter;\n                hrFilter = S_OK;\n            }\n            else\n            {\n                IEnumPins *pPinEnum = nullptr;\n                pFilter->EnumPins(&pPinEnum);\n\n                HRESULT hrPin = E_FAIL;\n                for (IPin *pOtherPin2 = nullptr; pPinEnum->Next(1, &pOtherPin2, 0) == S_OK; pOtherPin2 = nullptr)\n                {\n                    PIN_DIRECTION pinDir;\n                    pOtherPin2->QueryDirection(&pinDir);\n                    if (dir == pinDir)\n                    {\n                        hrPin = FindFilterSafe(pOtherPin2, guid, ppFilter);\n                    }\n                    SafeRelease(&pOtherPin2);\n                    if (SUCCEEDED(hrPin))\n                        break;\n                }\n                hrFilter = hrPin;\n                SafeRelease(&pPinEnum);\n                SafeRelease(&pFilter);\n            }\n        }\n\n        if (SUCCEEDED(hrFilter))\n        {\n            return S_OK;\n        }\n    }\n    return E_NOINTERFACE;\n}\n\n// pPin - pin of our filter to start searching\n// guid - guid of the filter to find\n// ppFilter - variable that'll receive a AddRef'd reference to the filter\nBOOL HasSourceWithType(IPin *pPin, const GUID &mediaType)\n{\n    CheckPointer(pPin, false);\n    BOOL bFound = FALSE;\n\n    PIN_DIRECTION dir;\n    pPin->QueryDirection(&dir);\n\n    IPin *pOtherPin = nullptr;\n    if (SUCCEEDED(pPin->ConnectedTo(&pOtherPin)) && pOtherPin)\n    {\n        IBaseFilter *pFilter = GetFilterFromPin(pOtherPin);\n\n        HRESULT hrFilter = E_NOINTERFACE;\n        IEnumPins *pPinEnum = nullptr;\n        pFilter->EnumPins(&pPinEnum);\n\n        HRESULT hrPin = E_FAIL;\n        for (IPin *pOtherPin2 = nullptr; !bFound && pPinEnum->Next(1, &pOtherPin2, 0) == S_OK; pOtherPin2 = nullptr)\n        {\n            if (pOtherPin2 != pOtherPin)\n            {\n                PIN_DIRECTION pinDir;\n                pOtherPin2->QueryDirection(&pinDir);\n                if (dir != pinDir)\n                {\n                    IEnumMediaTypes *pMediaTypeEnum = nullptr;\n                    if (SUCCEEDED(pOtherPin2->EnumMediaTypes(&pMediaTypeEnum)))\n                    {\n                        for (AM_MEDIA_TYPE *mt = nullptr; pMediaTypeEnum->Next(1, &mt, 0) == S_OK; mt = nullptr)\n                        {\n                            if (mt->majortype == mediaType)\n                            {\n                                bFound = TRUE;\n                            }\n                            DeleteMediaType(mt);\n                        }\n                        SafeRelease(&pMediaTypeEnum);\n                    }\n                }\n                else\n                {\n                    bFound = HasSourceWithType(pOtherPin2, mediaType);\n                }\n            }\n            SafeRelease(&pOtherPin2);\n        }\n        SafeRelease(&pPinEnum);\n        SafeRelease(&pFilter);\n        SafeRelease(&pOtherPin);\n    }\n    return bFound;\n}\n\n// Similar to HasSourceWithType but also checks forward pins for future backwards joins\nBOOL HasSourceWithTypeAdvanced(IPin *pPinInput, IPin *pPinOutput, const GUID &mediaType)\n{\n    // check the input pin backwards first\n    if (pPinInput && HasSourceWithType(pPinInput, mediaType))\n        return true;\n\n    if (pPinOutput == NULL)\n        return false;\n\n    // and check the tree forwards\n    BOOL bFound = FALSE;\n    IPin *pOtherPin = nullptr;\n    if (SUCCEEDED(pPinOutput->ConnectedTo(&pOtherPin)) && pOtherPin)\n    {\n        IBaseFilter *pFilter = GetFilterFromPin(pOtherPin);\n\n        HRESULT hrFilter = E_NOINTERFACE;\n        IEnumPins *pPinEnum = nullptr;\n        pFilter->EnumPins(&pPinEnum);\n\n        // Iterate over pins of the filter..\n        HRESULT hrPin = E_FAIL;\n        for (IPin *pOtherPin2 = nullptr; !bFound && pPinEnum->Next(1, &pOtherPin2, 0) == S_OK; pOtherPin2 = nullptr)\n        {\n            // ignore the pint we're connected to\n            if (pOtherPin2 != pOtherPin)\n            {\n                PIN_DIRECTION pinDir;\n                pOtherPin2->QueryDirection(&pinDir);\n\n                // if its another input, go backwards there\n                if (pinDir == PINDIR_INPUT)\n                {\n                    bFound = HasSourceWithType(pOtherPin2, mediaType);\n                }\n                // if its an output, go forwards\n                else if (pinDir == PINDIR_OUTPUT)\n                {\n                    bFound = HasSourceWithTypeAdvanced(NULL, pOtherPin2, mediaType);\n                }\n            }\n            SafeRelease(&pOtherPin2);\n        }\n        SafeRelease(&pPinEnum);\n        SafeRelease(&pFilter);\n        SafeRelease(&pOtherPin);\n    }\n\n    return bFound;\n}\n\nBOOL FilterInGraphSafe(IPin *pPin, const GUID &guid, BOOL bReverse)\n{\n    IBaseFilter *pFilter = nullptr;\n    HRESULT hr = FindFilterSafe(pPin, guid, &pFilter, bReverse);\n    if (SUCCEEDED(hr) && pFilter)\n    {\n        SafeRelease(&pFilter);\n        return TRUE;\n    }\n    return FALSE;\n}\n\nunsigned int lav_xiphlacing(unsigned char *s, unsigned int v)\n{\n    unsigned int n = 0;\n\n    while (v >= 0xff)\n    {\n        *s++ = 0xff;\n        v -= 0xff;\n        n++;\n    }\n    *s = v;\n    n++;\n    return n;\n}\n\nvoid videoFormatTypeHandler(const AM_MEDIA_TYPE &mt, BITMAPINFOHEADER **pBMI, REFERENCE_TIME *prtAvgTime,\n                            DWORD *pDwAspectX, DWORD *pDwAspectY)\n{\n    videoFormatTypeHandler(mt.pbFormat, &mt.formattype, pBMI, prtAvgTime, pDwAspectX, pDwAspectY);\n}\n\nvoid videoFormatTypeHandler(const BYTE *format, const GUID *formattype, BITMAPINFOHEADER **pBMI,\n                            REFERENCE_TIME *prtAvgTime, DWORD *pDwAspectX, DWORD *pDwAspectY)\n{\n    REFERENCE_TIME rtAvg = 0;\n    BITMAPINFOHEADER *bmi = nullptr;\n    DWORD dwAspectX = 0, dwAspectY = 0;\n\n    if (!format)\n        goto done;\n\n    if (*formattype == FORMAT_VideoInfo)\n    {\n        VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)format;\n        rtAvg = vih->AvgTimePerFrame;\n        bmi = &vih->bmiHeader;\n    }\n    else if (*formattype == FORMAT_VideoInfo2)\n    {\n        VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)format;\n        rtAvg = vih2->AvgTimePerFrame;\n        bmi = &vih2->bmiHeader;\n        dwAspectX = vih2->dwPictAspectRatioX;\n        dwAspectY = vih2->dwPictAspectRatioY;\n    }\n    else if (*formattype == FORMAT_MPEGVideo)\n    {\n        MPEG1VIDEOINFO *mp1vi = (MPEG1VIDEOINFO *)format;\n        rtAvg = mp1vi->hdr.AvgTimePerFrame;\n        bmi = &mp1vi->hdr.bmiHeader;\n    }\n    else if (*formattype == FORMAT_MPEG2Video)\n    {\n        MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)format;\n        rtAvg = mp2vi->hdr.AvgTimePerFrame;\n        bmi = &mp2vi->hdr.bmiHeader;\n        dwAspectX = mp2vi->hdr.dwPictAspectRatioX;\n        dwAspectY = mp2vi->hdr.dwPictAspectRatioY;\n    }\n    else\n    {\n        ASSERT(FALSE);\n    }\n\ndone:\n    if (pBMI)\n    {\n        *pBMI = bmi;\n    }\n    if (prtAvgTime)\n    {\n        *prtAvgTime = rtAvg;\n    }\n    if (pDwAspectX && pDwAspectY)\n    {\n        *pDwAspectX = dwAspectX;\n        *pDwAspectY = dwAspectY;\n    }\n}\n\nvoid audioFormatTypeHandler(const BYTE *format, const GUID *formattype, DWORD *pnSamples, WORD *pnChannels,\n                            WORD *pnBitsPerSample, WORD *pnBlockAlign, DWORD *pnBytesPerSec, DWORD *pnChannelMask)\n{\n    DWORD nSamples = 0;\n    WORD nChannels = 0;\n    WORD nBitsPerSample = 0;\n    WORD nBlockAlign = 0;\n    DWORD nBytesPerSec = 0;\n    DWORD nChannelMask = 0;\n\n    if (!format)\n        goto done;\n\n    if (*formattype == FORMAT_WaveFormatEx)\n    {\n        WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;\n        nSamples = wfex->nSamplesPerSec;\n        nChannels = wfex->nChannels;\n        nBitsPerSample = wfex->wBitsPerSample;\n        nBlockAlign = wfex->nBlockAlign;\n        nBytesPerSec = wfex->nAvgBytesPerSec;\n\n        if (wfex->wFormatTag == WAVE_FORMAT_EXTENSIBLE && wfex->cbSize >= 22)\n        {\n            WAVEFORMATEXTENSIBLE *wfexs = (WAVEFORMATEXTENSIBLE *)wfex;\n            nChannelMask = wfexs->dwChannelMask;\n        }\n    }\n    else if (*formattype == FORMAT_VorbisFormat2)\n    {\n        VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;\n        nSamples = vf2->SamplesPerSec;\n        nChannels = (WORD)vf2->Channels;\n        nBitsPerSample = (WORD)vf2->BitsPerSample;\n    }\n\ndone:\n    if (pnSamples)\n        *pnSamples = nSamples;\n    if (pnChannels)\n        *pnChannels = nChannels;\n    if (pnBitsPerSample)\n        *pnBitsPerSample = nBitsPerSample;\n    if (pnBlockAlign)\n        *pnBlockAlign = nBlockAlign;\n    if (pnBytesPerSec)\n        *pnBytesPerSec = nBytesPerSec;\n    if (pnChannelMask)\n        *pnChannelMask = nChannelMask;\n}\n\nvoid getExtraData(const AM_MEDIA_TYPE &mt, BYTE *extra, size_t *extralen)\n{\n    return getExtraData(mt.pbFormat, &mt.formattype, mt.cbFormat, extra, extralen);\n}\n\nvoid getExtraData(const BYTE *format, const GUID *formattype, const size_t formatlen, BYTE *extra, size_t *extralen)\n{\n    const BYTE *extraposition = nullptr;\n    size_t extralength = 0;\n    if (*formattype == FORMAT_WaveFormatEx)\n    {\n        WAVEFORMATEX *wfex = (WAVEFORMATEX *)format;\n        extraposition = format + sizeof(WAVEFORMATEX);\n        // Protected against over-reads\n        extralength = formatlen - sizeof(WAVEFORMATEX);\n    }\n    else if (*formattype == FORMAT_VorbisFormat2)\n    {\n        VORBISFORMAT2 *vf2 = (VORBISFORMAT2 *)format;\n        BYTE *start = nullptr, *end = nullptr;\n        unsigned offset = 1;\n        if (extra)\n        {\n            *extra = 2;\n            offset += lav_xiphlacing(extra + offset, vf2->HeaderSize[0]);\n            offset += lav_xiphlacing(extra + offset, vf2->HeaderSize[1]);\n            extra += offset;\n        }\n        else\n        {\n            BYTE dummy[100];\n            offset += lav_xiphlacing(dummy, vf2->HeaderSize[0]);\n            offset += lav_xiphlacing(dummy, vf2->HeaderSize[1]);\n        }\n        extralength = vf2->HeaderSize[0] + vf2->HeaderSize[1] + vf2->HeaderSize[2];\n        extralength = min(extralength, formatlen - sizeof(VORBISFORMAT2));\n\n        if (extra && extralength)\n            memcpy(extra, format + sizeof(VORBISFORMAT2), extralength);\n        if (extralen)\n            *extralen = extralength + offset;\n\n        return;\n    }\n    else if (*formattype == FORMAT_VideoInfo)\n    {\n        extraposition = format + sizeof(VIDEOINFOHEADER);\n        extralength = formatlen - sizeof(VIDEOINFOHEADER);\n    }\n    else if (*formattype == FORMAT_VideoInfo2)\n    {\n        extraposition = format + sizeof(VIDEOINFOHEADER2);\n        extralength = formatlen - sizeof(VIDEOINFOHEADER2);\n    }\n    else if (*formattype == FORMAT_MPEGVideo)\n    {\n        MPEG1VIDEOINFO *mp1vi = (MPEG1VIDEOINFO *)format;\n        extraposition = (BYTE *)mp1vi->bSequenceHeader;\n        extralength = min(mp1vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG1VIDEOINFO, bSequenceHeader[0]));\n    }\n    else if (*formattype == FORMAT_MPEG2Video)\n    {\n        MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)format;\n        extraposition = (BYTE *)mp2vi->dwSequenceHeader;\n        extralength = min(mp2vi->cbSequenceHeader, formatlen - FIELD_OFFSET(MPEG2VIDEOINFO, dwSequenceHeader[0]));\n    }\n    else if (*formattype == FORMAT_SubtitleInfo)\n    {\n        SUBTITLEINFO *sub = (SUBTITLEINFO *)format;\n        extraposition = format + sub->dwOffset;\n        extralength = formatlen - sub->dwOffset;\n    }\n\n    if (extra && extralength)\n        memcpy(extra, extraposition, extralength);\n    if (extralen)\n        *extralen = extralength;\n}\n\nvoid CopyMediaSideDataFF(AVPacket *dst, const MediaSideDataFFMpeg **sd)\n{\n    if (!dst)\n        return;\n\n    if (!sd || !*sd)\n    {\n        dst->side_data = nullptr;\n        dst->side_data_elems = 0;\n        return;\n    }\n\n    // add sidedata to the packet\n    for (int i = 0; i < (*sd)->side_data_elems; i++)\n    {\n        uint8_t *ptr = av_packet_new_side_data(dst, (*sd)->side_data[i].type, (*sd)->side_data[i].size);\n        memcpy(ptr, (*sd)->side_data[i].data, (*sd)->side_data[i].size);\n    }\n\n    *sd = nullptr;\n}\n\nBOOL IsWindows7OrNewer()\n{\n    return (g_osInfo.dwMajorVersion == 6 && g_osInfo.dwMinorVersion >= 1) || (g_osInfo.dwMajorVersion > 6);\n}\n\nBOOL IsWindows8OrNewer()\n{\n    return (g_osInfo.dwMajorVersion == 6 && g_osInfo.dwMinorVersion >= 2) || (g_osInfo.dwMajorVersion > 6);\n}\n\nBOOL IsWindows10OrNewer()\n{\n    return (g_osInfo.dwMajorVersion >= 10);\n}\n\nBOOL IsWindows10BuildOrNewer(DWORD dwBuild)\n{\n    return (g_osInfo.dwMajorVersion > 10 || (g_osInfo.dwMajorVersion == 10 && g_osInfo.dwBuildNumber >= dwBuild));\n}\n\nvoid __cdecl debugprintf(LPCWSTR format, ...)\n{\n    WCHAR buf[4096], *p = buf;\n    va_list args;\n    int n;\n\n    va_start(args, format);\n    n = _vsnwprintf_s(p, 4096, 4096 - 3, format, args); // buf-3 is room for CR/LF/NUL\n    va_end(args);\n\n    p += (n < 0) ? (4096 - 3) : n;\n\n    while (p > buf && isspace(p[-1]))\n        *--p = L'\\0';\n\n    *p++ = L'\\r';\n    *p++ = L'\\n';\n    *p = L'\\0';\n\n    OutputDebugString(buf);\n}\n\nBOOL CheckApplicationBlackList(LPCTSTR subkey)\n{\n    HRESULT hr;\n    DWORD dwVal;\n    WCHAR fileName[1024];\n    GetModuleFileName(NULL, fileName, 1024);\n    WCHAR *processName = PathFindFileName(fileName);\n\n    // Check local machine path\n    CRegistry regLM = CRegistry(HKEY_LOCAL_MACHINE, subkey, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        dwVal = regLM.ReadDWORD(processName, hr);\n        return SUCCEEDED(hr) && dwVal;\n    }\n\n    // Check current user path\n    CRegistry regCU = CRegistry(HKEY_CURRENT_USER, subkey, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        dwVal = regCU.ReadDWORD(processName, hr);\n        return SUCCEEDED(hr) && dwVal;\n    }\n\n    return FALSE;\n}\n"
  },
  {
    "path": "common/DSUtilLite/DShowUtil.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#pragma once\n\n#include <list>\n#include <string>\n#include <DShow.h>\n\n#define LCID_NOSUBTITLES -1\n\n// SafeRelease Template, for type safety\ntemplate <class T> void SafeRelease(T **ppT)\n{\n    if (*ppT)\n    {\n        (*ppT)->Release();\n        *ppT = nullptr;\n    }\n}\n\n#ifdef _DEBUG\n#define DBG_TIMING(x, l, y)                                                      \\\n    {                                                                            \\\n        DWORD start = timeGetTime();                                             \\\n        y;                                                                       \\\n        DWORD end = timeGetTime();                                               \\\n        if (end - start > l)                                                     \\\n            DbgLog((LOG_CUSTOM5, 10, L\"TIMING: %S took %u ms\", x, end - start)); \\\n    }\nextern void DbgSetLogFile(LPCTSTR szLogFile);\nextern void DbgSetLogFileDesktop(LPCTSTR szLogFile);\nextern void DbgCloseLogFile();\n#else\n#define DBG_TIMING(x, l, y) y;\n#define DbgSetLogFile(sz)\n#define DbgSetLogFileDesktop(sz)\n#define DbgCloseLogFile()\n#endif\n\n// SAFE_ARRAY_DELETE macro.\n// Deletes an array allocated with new [].\n\n#ifndef SAFE_ARRAY_DELETE\n#define SAFE_ARRAY_DELETE(x) \\\n    if (x)                   \\\n    {                        \\\n        delete[] x;          \\\n        x = nullptr;         \\\n    }\n#endif\n\n// some common macros\n#define SAFE_DELETE(pPtr) \\\n    {                     \\\n        delete pPtr;      \\\n        pPtr = nullptr;   \\\n    }\n#define SAFE_CO_FREE(pPtr)   \\\n    {                        \\\n        CoTaskMemFree(pPtr); \\\n        pPtr = nullptr;      \\\n    }\n#define CHECK_HR(hr) \\\n    if (FAILED(hr))  \\\n    {                \\\n        goto done;   \\\n    }\n#define QI(i) (riid == __uuidof(i)) ? GetInterface((i *)this, ppv):\n#define QI2(i) (riid == IID_##i) ? GetInterface((i *)this, ppv):\n#define countof(array) (sizeof(array) / sizeof(array[0]))\n\n// Gennenric IUnknown creation function\ntemplate <class T> static CUnknown *WINAPI CreateInstance(LPUNKNOWN lpunk, HRESULT *phr)\n{\n    *phr = S_OK;\n    CUnknown *punk = new T(lpunk, phr);\n    if (punk == nullptr)\n    {\n        *phr = E_OUTOFMEMORY;\n    }\n    return punk;\n}\n\nextern void SetThreadName(DWORD dwThreadID, LPCSTR szThreadName);\n\nvoid split(const std::string &text, const std::string &separators, std::list<std::string> &words);\n\n// Filter Registration\nextern void RegisterSourceFilter(const CLSID &clsid, const GUID &subtype2, LPCWSTR chkbytes, ...);\nextern void RegisterSourceFilter(const CLSID &clsid, const GUID &subtype2, std::list<LPCWSTR> chkbytes, ...);\nextern void UnRegisterSourceFilter(const GUID &subtype);\n\nextern void RegisterProtocolSourceFilter(const CLSID &clsid, LPCWSTR protocol);\nextern void UnRegisterProtocolSourceFilter(LPCWSTR protocol);\n\nextern BOOL CheckApplicationBlackList(LPCTSTR subkey);\n\n// Locale\nextern std::string ISO6391ToLanguage(LPCSTR code);\nextern std::string ISO6392ToLanguage(LPCSTR code);\nextern std::string ProbeLangForLanguage(LPCSTR code);\nextern LCID ISO6391ToLcid(LPCSTR code);\nextern LCID ISO6392ToLcid(LPCSTR code);\nextern LCID ProbeLangForLCID(LPCSTR code);\nextern std::string ISO6391To6392(LPCSTR code);\nextern std::string ISO6392To6391(LPCSTR code);\nextern std::string ProbeForISO6392(LPCSTR lang);\n\n// FilterGraphUtils\nextern IBaseFilter *FindFilter(const GUID &clsid, IFilterGraph *pFG);\nextern BOOL FilterInGraph(const GUID &clsid, IFilterGraph *pFG);\nextern BOOL FilterInGraphWithInputSubtype(const GUID &clsid, IFilterGraph *pFG, const GUID &clsidSubtype);\nextern IBaseFilter *GetFilterFromPin(IPin *pPin);\nextern HRESULT NukeDownstream(IFilterGraph *pGraph, IPin *pPin);\nextern HRESULT NukeDownstream(IFilterGraph *pGraph, IBaseFilter *pFilter);\nextern HRESULT FindIntefaceInGraph(IPin *pPin, REFIID refiid, void **pUnknown);\nextern HRESULT FindPinIntefaceInGraph(IPin *pPin, REFIID refiid, void **pUnknown);\nextern HRESULT FindFilterSafe(IPin *pPin, const GUID &guid, IBaseFilter **ppFilter, BOOL bReverse = FALSE);\nextern BOOL FilterInGraphSafe(IPin *pPin, const GUID &guid, BOOL bReverse = FALSE);\nextern BOOL HasSourceWithType(IPin *pPin, const GUID &mediaType);\nextern BOOL HasSourceWithTypeAdvanced(IPin *pPinInput, IPin *pPinOutput, const GUID &mediaType);\n\nstd::wstring WStringFromGUID(const GUID &guid);\nBSTR ConvertCharToBSTR(const char *sz);\n\nint SafeMultiByteToWideChar(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte, LPWSTR lpWideCharStr,\n                            int cchWideChar);\nint SafeWideCharToMultiByte(UINT CodePage, DWORD dwFlags, LPCWSTR lpWideCharStr, int cchWideChar, LPSTR lpMultiByteStr,\n                            int cbMultiByte, LPCSTR lpDefaultChar, LPBOOL lpUsedDefaultChar);\nLPWSTR CoTaskGetWideCharFromMultiByte(UINT CodePage, DWORD dwFlags, LPCSTR lpMultiByteStr, int cbMultiByte);\nLPSTR CoTaskGetMultiByteFromWideChar(UINT CodePage, DWORD dwFlags, LPCWSTR lpMultiByteStr, int cbMultiByte);\n\nunsigned int lav_xiphlacing(unsigned char *s, unsigned int v);\n\nvoid videoFormatTypeHandler(const AM_MEDIA_TYPE &mt, BITMAPINFOHEADER **pBMI = nullptr,\n                            REFERENCE_TIME *prtAvgTime = nullptr, DWORD *pDwAspectX = nullptr,\n                            DWORD *pDwAspectY = nullptr);\nvoid videoFormatTypeHandler(const BYTE *format, const GUID *formattype, BITMAPINFOHEADER **pBMI = nullptr,\n                            REFERENCE_TIME *prtAvgTime = nullptr, DWORD *pDwAspectX = nullptr,\n                            DWORD *pDwAspectY = nullptr);\nvoid audioFormatTypeHandler(const BYTE *format, const GUID *formattype, DWORD *pnSamples, WORD *pnChannels,\n                            WORD *pnBitsPerSample, WORD *pnBlockAlign, DWORD *pnBytesPerSec, DWORD *pnChannelMask);\nvoid getExtraData(const AM_MEDIA_TYPE &mt, BYTE *extra, size_t *extralen);\nvoid getExtraData(const BYTE *format, const GUID *formattype, const size_t formatlen, BYTE *extra, size_t *extralen);\n\nstruct AVPacket;\nstruct MediaSideDataFFMpeg;\nvoid CopyMediaSideDataFF(AVPacket *dst, const MediaSideDataFFMpeg **sd);\n\nBOOL IsWindows7OrNewer();\nBOOL IsWindows8OrNewer();\nBOOL IsWindows10OrNewer();\nBOOL IsWindows10BuildOrNewer(DWORD dwBuild);\nvoid __cdecl debugprintf(LPCWSTR format, ...);\n"
  },
  {
    "path": "common/DSUtilLite/DeCSS/CSSauth.cpp",
    "content": "#include \"stdafx.h\"\n\nstatic void CSSengine(int varient, unsigned char const *input, unsigned char *output);\n\nvoid CSSkey1(int varient, unsigned char const *challenge, unsigned char *key)\n{\n    static unsigned char perm_challenge[] = {1, 3, 0, 7, 5, 2, 9, 6, 4, 8};\n\n    unsigned char scratch[10];\n    int i;\n\n    for (i = 9; i >= 0; --i)\n    {\n        scratch[i] = challenge[perm_challenge[i]];\n    }\n\n    CSSengine(varient, scratch, key);\n}\n\nvoid CSSkey2(int varient, unsigned char const *challenge, unsigned char *key)\n{\n    static unsigned char perm_challenge[] = {6, 1, 9, 3, 8, 5, 7, 4, 0, 2};\n\n    static unsigned char perm_varient[] = {0x0a, 0x08, 0x0e, 0x0c, 0x0b, 0x09, 0x0f, 0x0d, 0x1a, 0x18, 0x1e,\n                                           0x1c, 0x1b, 0x19, 0x1f, 0x1d, 0x02, 0x00, 0x06, 0x04, 0x03, 0x01,\n                                           0x07, 0x05, 0x12, 0x10, 0x16, 0x14, 0x13, 0x11, 0x17, 0x15};\n\n    unsigned char scratch[10];\n    int i;\n\n    for (i = 9; i >= 0; --i)\n    {\n        scratch[i] = challenge[perm_challenge[i]];\n    }\n\n    CSSengine(perm_varient[varient], scratch, key);\n}\n\nvoid CSSbuskey(int varient, unsigned char const *challenge, unsigned char *key)\n{\n    static unsigned char perm_challenge[] = {4, 0, 3, 5, 7, 2, 8, 6, 1, 9};\n    static unsigned char perm_varient[] = {0x12, 0x1a, 0x16, 0x1e, 0x02, 0x0a, 0x06, 0x0e, 0x10, 0x18, 0x14,\n                                           0x1c, 0x00, 0x08, 0x04, 0x0c, 0x13, 0x1b, 0x17, 0x1f, 0x03, 0x0b,\n                                           0x07, 0x0f, 0x11, 0x19, 0x15, 0x1d, 0x01, 0x09, 0x05, 0x0d};\n\n    unsigned char scratch[10];\n    int i;\n\n    for (i = 9; i >= 0; --i)\n    {\n        scratch[i] = challenge[perm_challenge[i]];\n    }\n\n    CSSengine(perm_varient[varient], scratch, key);\n}\n\nstatic void CSSgenbits(unsigned char *output, int len, unsigned char const *s)\n{\n    unsigned long lfsr0, lfsr1;\n    unsigned char b1_combined; /* Save the old value of bit 1 for feedback */\n\n    /* In order to ensure that the LFSR works we need to ensure that the\n     * initial values are non-zero.  Thus when we initialise them from\n     * the seed,  we ensure that a bit is set.\n     */\n    lfsr0 = (s[0] << 17) | (s[1] << 9) | ((s[2] & ~7) << 1) | 8 | (s[2] & 7);\n    lfsr1 = (s[3] << 9) | 0x100 | s[4];\n\n    ++output;\n\n    b1_combined = 0;\n    do\n    {\n        int bit;\n        unsigned char val;\n\n        for (bit = 0, val = 0; bit < 8; ++bit)\n        {\n            unsigned char o_lfsr0, o_lfsr1; /* Actually only 1 bit each */\n            unsigned char combined;\n\n            o_lfsr0 = ((lfsr0 >> 24) ^ (lfsr0 >> 21) ^ (lfsr0 >> 20) ^ (lfsr0 >> 12)) & 1;\n            lfsr0 = (lfsr0 << 1) | o_lfsr0;\n\n            o_lfsr1 = ((lfsr1 >> 16) ^ (lfsr1 >> 2)) & 1;\n            lfsr1 = (lfsr1 << 1) | o_lfsr1;\n\n#define BIT0(x) ((x)&1)\n#define BIT1(x) (((x) >> 1) & 1)\n\n            combined = !o_lfsr1 + b1_combined + !o_lfsr0;\n            b1_combined = BIT1(combined);\n            val |= BIT0(combined) << bit;\n        }\n\n        *--output = val;\n    } while (--len > 0);\n}\n\nunsigned char CSSsecret[];\nunsigned char CSSvarients[];\nunsigned char CSStable0[];\nunsigned char CSStable1[];\nunsigned char CSStable2[];\nunsigned char CSStable3[];\n\nstatic void CSSengine(int varient, unsigned char const *input, unsigned char *output)\n{\n    unsigned char cse, term, index;\n    unsigned char temp1[5];\n    unsigned char temp2[5];\n    unsigned char bits[30];\n\n    int i;\n\n    /* Feed the CSSsecret into the input values such that\n     * we alter the seed to the LFSR's used above,  then\n     * generate the bits to play with.\n     */\n    for (i = 5; --i >= 0;)\n    {\n        temp1[i] = input[5 + i] ^ CSSsecret[i] ^ CSStable2[i];\n    }\n\n    CSSgenbits(&bits[29], sizeof bits, temp1);\n\n    /* This term is used throughout the following to\n     * select one of 32 different variations on the\n     * algorithm.\n     */\n    cse = CSSvarients[varient] ^ CSStable2[varient];\n\n    /* Now the actual blocks doing the encryption.  Each\n     * of these works on 40 bits at a time and are quite\n     * similar.\n     */\n    for (i = 5, term = 0; --i >= 0; term = input[i])\n    {\n        index = bits[25 + i] ^ input[i];\n        index = CSStable1[index] ^ ~CSStable2[index] ^ cse;\n\n        temp1[i] = CSStable2[index] ^ CSStable3[index] ^ term;\n    }\n    temp1[4] ^= temp1[0];\n\n    for (i = 5, term = 0; --i >= 0; term = temp1[i])\n    {\n        index = bits[20 + i] ^ temp1[i];\n        index = CSStable1[index] ^ ~CSStable2[index] ^ cse;\n\n        temp2[i] = CSStable2[index] ^ CSStable3[index] ^ term;\n    }\n    temp2[4] ^= temp2[0];\n\n    for (i = 5, term = 0; --i >= 0; term = temp2[i])\n    {\n        index = bits[15 + i] ^ temp2[i];\n        index = CSStable1[index] ^ ~CSStable2[index] ^ cse;\n        index = CSStable2[index] ^ CSStable3[index] ^ term;\n\n        temp1[i] = CSStable0[index] ^ CSStable2[index];\n    }\n    temp1[4] ^= temp1[0];\n\n    for (i = 5, term = 0; --i >= 0; term = temp1[i])\n    {\n        index = bits[10 + i] ^ temp1[i];\n        index = CSStable1[index] ^ ~CSStable2[index] ^ cse;\n\n        index = CSStable2[index] ^ CSStable3[index] ^ term;\n\n        temp2[i] = CSStable0[index] ^ CSStable2[index];\n    }\n    temp2[4] ^= temp2[0];\n\n    for (i = 5, term = 0; --i >= 0; term = temp2[i])\n    {\n        index = bits[5 + i] ^ temp2[i];\n        index = CSStable1[index] ^ ~CSStable2[index] ^ cse;\n\n        temp1[i] = CSStable2[index] ^ CSStable3[index] ^ term;\n    }\n    temp1[4] ^= temp1[0];\n\n    for (i = 5, term = 0; --i >= 0; term = temp1[i])\n    {\n        index = bits[i] ^ temp1[i];\n        index = CSStable1[index] ^ ~CSStable2[index] ^ cse;\n\n        output[i] = CSStable2[index] ^ CSStable3[index] ^ term;\n    }\n}\n\nstatic unsigned char CSSvarients[] = {0xB7, 0x74, 0x85, 0xD0, 0xCC, 0xDB, 0xCA, 0x73, 0x03, 0xFE, 0x31,\n                                      0x03, 0x52, 0xE0, 0xB7, 0x42, 0x63, 0x16, 0xF2, 0x2A, 0x79, 0x52,\n                                      0xFF, 0x1B, 0x7A, 0x11, 0xCA, 0x1A, 0x9B, 0x40, 0xAD, 0x01};\n\nstatic unsigned char CSSsecret[] = {0x55, 0xD6, 0xC4, 0xC5, 0x28};\n\nstatic unsigned char CSStable0[] = {\n    0xB7, 0xF4, 0x82, 0x57, 0xDA, 0x4D, 0xDB, 0xE2, 0x2F, 0x52, 0x1A, 0xA8, 0x68, 0x5A, 0x8A, 0xFF, 0xFB, 0x0E, 0x6D,\n    0x35, 0xF7, 0x5C, 0x76, 0x12, 0xCE, 0x25, 0x79, 0x29, 0x39, 0x62, 0x08, 0x24, 0xA5, 0x85, 0x7B, 0x56, 0x01, 0x23,\n    0x68, 0xCF, 0x0A, 0xE2, 0x5A, 0xED, 0x3D, 0x59, 0xB0, 0xA9, 0xB0, 0x2C, 0xF2, 0xB8, 0xEF, 0x32, 0xA9, 0x40, 0x80,\n    0x71, 0xAF, 0x1E, 0xDE, 0x8F, 0x58, 0x88, 0xB8, 0x3A, 0xD0, 0xFC, 0xC4, 0x1E, 0xB5, 0xA0, 0xBB, 0x3B, 0x0F, 0x01,\n    0x7E, 0x1F, 0x9F, 0xD9, 0xAA, 0xB8, 0x3D, 0x9D, 0x74, 0x1E, 0x25, 0xDB, 0x37, 0x56, 0x8F, 0x16, 0xBA, 0x49, 0x2B,\n    0xAC, 0xD0, 0xBD, 0x95, 0x20, 0xBE, 0x7A, 0x28, 0xD0, 0x51, 0x64, 0x63, 0x1C, 0x7F, 0x66, 0x10, 0xBB, 0xC4, 0x56,\n    0x1A, 0x04, 0x6E, 0x0A, 0xEC, 0x9C, 0xD6, 0xE8, 0x9A, 0x7A, 0xCF, 0x8C, 0xDB, 0xB1, 0xEF, 0x71, 0xDE, 0x31, 0xFF,\n    0x54, 0x3E, 0x5E, 0x07, 0x69, 0x96, 0xB0, 0xCF, 0xDD, 0x9E, 0x47, 0xC7, 0x96, 0x8F, 0xE4, 0x2B, 0x59, 0xC6, 0xEE,\n    0xB9, 0x86, 0x9A, 0x64, 0x84, 0x72, 0xE2, 0x5B, 0xA2, 0x96, 0x58, 0x99, 0x50, 0x03, 0xF5, 0x38, 0x4D, 0x02, 0x7D,\n    0xE7, 0x7D, 0x75, 0xA7, 0xB8, 0x67, 0x87, 0x84, 0x3F, 0x1D, 0x11, 0xE5, 0xFC, 0x1E, 0xD3, 0x83, 0x16, 0xA5, 0x29,\n    0xF6, 0xC7, 0x15, 0x61, 0x29, 0x1A, 0x43, 0x4F, 0x9B, 0xAF, 0xC5, 0x87, 0x34, 0x6C, 0x0F, 0x3B, 0xA8, 0x1D, 0x45,\n    0x58, 0x25, 0xDC, 0xA8, 0xA3, 0x3B, 0xD1, 0x79, 0x1B, 0x48, 0xF2, 0xE9, 0x93, 0x1F, 0xFC, 0xDB, 0x2A, 0x90, 0xA9,\n    0x8A, 0x3D, 0x39, 0x18, 0xA3, 0x8E, 0x58, 0x6C, 0xE0, 0x12, 0xBB, 0x25, 0xCD, 0x71, 0x22, 0xA2, 0x64, 0xC6, 0xE7,\n    0xFB, 0xAD, 0x94, 0x77, 0x04, 0x9A, 0x39, 0xCF, 0x7C};\n\nstatic unsigned char CSStable1[] = {\n    0x8C, 0x47, 0xB0, 0xE1, 0xEB, 0xFC, 0xEB, 0x56, 0x10, 0xE5, 0x2C, 0x1A, 0x5D, 0xEF, 0xBE, 0x4F, 0x08, 0x75, 0x97,\n    0x4B, 0x0E, 0x25, 0x8E, 0x6E, 0x39, 0x5A, 0x87, 0x53, 0xC4, 0x1F, 0xF4, 0x5C, 0x4E, 0xE6, 0x99, 0x30, 0xE0, 0x42,\n    0x88, 0xAB, 0xE5, 0x85, 0xBC, 0x8F, 0xD8, 0x3C, 0x54, 0xC9, 0x53, 0x47, 0x18, 0xD6, 0x06, 0x5B, 0x41, 0x2C, 0x67,\n    0x1E, 0x41, 0x74, 0x33, 0xE2, 0xB4, 0xE0, 0x23, 0x29, 0x42, 0xEA, 0x55, 0x0F, 0x25, 0xB4, 0x24, 0x2C, 0x99, 0x13,\n    0xEB, 0x0A, 0x0B, 0xC9, 0xF9, 0x63, 0x67, 0x43, 0x2D, 0xC7, 0x7D, 0x07, 0x60, 0x89, 0xD1, 0xCC, 0xE7, 0x94, 0x77,\n    0x74, 0x9B, 0x7E, 0xD7, 0xE6, 0xFF, 0xBB, 0x68, 0x14, 0x1E, 0xA3, 0x25, 0xDE, 0x3A, 0xA3, 0x54, 0x7B, 0x87, 0x9D,\n    0x50, 0xCA, 0x27, 0xC3, 0xA4, 0x50, 0x91, 0x27, 0xD4, 0xB0, 0x82, 0x41, 0x97, 0x79, 0x94, 0x82, 0xAC, 0xC7, 0x8E,\n    0xA5, 0x4E, 0xAA, 0x78, 0x9E, 0xE0, 0x42, 0xBA, 0x28, 0xEA, 0xB7, 0x74, 0xAD, 0x35, 0xDA, 0x92, 0x60, 0x7E, 0xD2,\n    0x0E, 0xB9, 0x24, 0x5E, 0x39, 0x4F, 0x5E, 0x63, 0x09, 0xB5, 0xFA, 0xBF, 0xF1, 0x22, 0x55, 0x1C, 0xE2, 0x25, 0xDB,\n    0xC5, 0xD8, 0x50, 0x03, 0x98, 0xC4, 0xAC, 0x2E, 0x11, 0xB4, 0x38, 0x4D, 0xD0, 0xB9, 0xFC, 0x2D, 0x3C, 0x08, 0x04,\n    0x5A, 0xEF, 0xCE, 0x32, 0xFB, 0x4C, 0x92, 0x1E, 0x4B, 0xFB, 0x1A, 0xD0, 0xE2, 0x3E, 0xDA, 0x6E, 0x7C, 0x4D, 0x56,\n    0xC3, 0x3F, 0x42, 0xB1, 0x3A, 0x23, 0x4D, 0x6E, 0x84, 0x56, 0x68, 0xF4, 0x0E, 0x03, 0x64, 0xD0, 0xA9, 0x92, 0x2F,\n    0x8B, 0xBC, 0x39, 0x9C, 0xAC, 0x09, 0x5E, 0xEE, 0xE5, 0x97, 0xBF, 0xA5, 0xCE, 0xFA, 0x28, 0x2C, 0x6D, 0x4F, 0xEF,\n    0x77, 0xAA, 0x1B, 0x79, 0x8E, 0x97, 0xB4, 0xC3, 0xF4};\n\nstatic unsigned char CSStable2[] = {\n    0xB7, 0x75, 0x81, 0xD5, 0xDC, 0xCA, 0xDE, 0x66, 0x23, 0xDF, 0x15, 0x26, 0x62, 0xD1, 0x83, 0x77, 0xE3, 0x97, 0x76,\n    0xAF, 0xE9, 0xC3, 0x6B, 0x8E, 0xDA, 0xB0, 0x6E, 0xBF, 0x2B, 0xF1, 0x19, 0xB4, 0x95, 0x34, 0x48, 0xE4, 0x37, 0x94,\n    0x5D, 0x7B, 0x36, 0x5F, 0x65, 0x53, 0x07, 0xE2, 0x89, 0x11, 0x98, 0x85, 0xD9, 0x12, 0xC1, 0x9D, 0x84, 0xEC, 0xA4,\n    0xD4, 0x88, 0xB8, 0xFC, 0x2C, 0x79, 0x28, 0xD8, 0xDB, 0xB3, 0x1E, 0xA2, 0xF9, 0xD0, 0x44, 0xD7, 0xD6, 0x60, 0xEF,\n    0x14, 0xF4, 0xF6, 0x31, 0xD2, 0x41, 0x46, 0x67, 0x0A, 0xE1, 0x58, 0x27, 0x43, 0xA3, 0xF8, 0xE0, 0xC8, 0xBA, 0x5A,\n    0x5C, 0x80, 0x6C, 0xC6, 0xF2, 0xE8, 0xAD, 0x7D, 0x04, 0x0D, 0xB9, 0x3C, 0xC2, 0x25, 0xBD, 0x49, 0x63, 0x8C, 0x9F,\n    0x51, 0xCE, 0x20, 0xC5, 0xA1, 0x50, 0x92, 0x2D, 0xDD, 0xBC, 0x8D, 0x4F, 0x9A, 0x71, 0x2F, 0x30, 0x1D, 0x73, 0x39,\n    0x13, 0xFB, 0x1A, 0xCB, 0x24, 0x59, 0xFE, 0x05, 0x96, 0x57, 0x0F, 0x1F, 0xCF, 0x54, 0xBE, 0xF5, 0x06, 0x1B, 0xB2,\n    0x6D, 0xD3, 0x4D, 0x32, 0x56, 0x21, 0x33, 0x0B, 0x52, 0xE7, 0xAB, 0xEB, 0xA6, 0x74, 0x00, 0x4C, 0xB1, 0x7F, 0x82,\n    0x99, 0x87, 0x0E, 0x5E, 0xC0, 0x8F, 0xEE, 0x6F, 0x55, 0xF3, 0x7E, 0x08, 0x90, 0xFA, 0xB6, 0x64, 0x70, 0x47, 0x4A,\n    0x17, 0xA7, 0xB5, 0x40, 0x8A, 0x38, 0xE5, 0x68, 0x3E, 0x8B, 0x69, 0xAA, 0x9B, 0x42, 0xA5, 0x10, 0x01, 0x35, 0xFD,\n    0x61, 0x9E, 0xE6, 0x16, 0x9C, 0x86, 0xED, 0xCD, 0x2E, 0xFF, 0xC4, 0x5B, 0xA0, 0xAE, 0xCC, 0x4B, 0x3B, 0x03, 0xBB,\n    0x1C, 0x2A, 0xAC, 0x0C, 0x3F, 0x93, 0xC7, 0x72, 0x7A, 0x09, 0x22, 0x3D, 0x45, 0x78, 0xA9, 0xA8, 0xEA, 0xC9, 0x6A,\n    0xF7, 0x29, 0x91, 0xF0, 0x02, 0x18, 0x3A, 0x4E, 0x7C};\n\nstatic unsigned char CSStable3[] = {\n    0x73, 0x51, 0x95, 0xE1, 0x12, 0xE4, 0xC0, 0x58, 0xEE, 0xF2, 0x08, 0x1B, 0xA9, 0xFA, 0x98, 0x4C, 0xA7, 0x33,\n    0xE2, 0x1B, 0xA7, 0x6D, 0xF5, 0x30, 0x97, 0x1D, 0xF3, 0x02, 0x60, 0x5A, 0x82, 0x0F, 0x91, 0xD0, 0x9C, 0x10,\n    0x39, 0x7A, 0x83, 0x85, 0x3B, 0xB2, 0xB8, 0xAE, 0x0C, 0x09, 0x52, 0xEA, 0x1C, 0xE1, 0x8D, 0x66, 0x4F, 0xF3,\n    0xDA, 0x92, 0x29, 0xB9, 0xD5, 0xC5, 0x77, 0x47, 0x22, 0x53, 0x14, 0xF7, 0xAF, 0x22, 0x64, 0xDF, 0xC6, 0x72,\n    0x12, 0xF3, 0x75, 0xDA, 0xD7, 0xD7, 0xE5, 0x02, 0x9E, 0xED, 0xDA, 0xDB, 0x4C, 0x47, 0xCE, 0x91, 0x06, 0x06,\n    0x6D, 0x55, 0x8B, 0x19, 0xC9, 0xEF, 0x8C, 0x80, 0x1A, 0x0E, 0xEE, 0x4B, 0xAB, 0xF2, 0x08, 0x5C, 0xE9, 0x37,\n    0x26, 0x5E, 0x9A, 0x90, 0x00, 0xF3, 0x0D, 0xB2, 0xA6, 0xA3, 0xF7, 0x26, 0x17, 0x48, 0x88, 0xC9, 0x0E, 0x2C,\n    0xC9, 0x02, 0xE7, 0x18, 0x05, 0x4B, 0xF3, 0x39, 0xE1, 0x20, 0x02, 0x0D, 0x40, 0xC7, 0xCA, 0xB9, 0x48, 0x30,\n    0x57, 0x67, 0xCC, 0x06, 0xBF, 0xAC, 0x81, 0x08, 0x24, 0x7A, 0xD4, 0x8B, 0x19, 0x8E, 0xAC, 0xB4, 0x5A, 0x0F,\n    0x73, 0x13, 0xAC, 0x9E, 0xDA, 0xB6, 0xB8, 0x96, 0x5B, 0x60, 0x88, 0xE1, 0x81, 0x3F, 0x07, 0x86, 0x37, 0x2D,\n    0x79, 0x14, 0x52, 0xEA, 0x73, 0xDF, 0x3D, 0x09, 0xC8, 0x25, 0x48, 0xD8, 0x75, 0x60, 0x9A, 0x08, 0x27, 0x4A,\n    0x2C, 0xB9, 0xA8, 0x8B, 0x8A, 0x73, 0x62, 0x37, 0x16, 0x02, 0xBD, 0xC1, 0x0E, 0x56, 0x54, 0x3E, 0x14, 0x5F,\n    0x8C, 0x8F, 0x6E, 0x75, 0x1C, 0x07, 0x39, 0x7B, 0x4B, 0xDB, 0xD3, 0x4B, 0x1E, 0xC8, 0x7E, 0xFE, 0x3E, 0x72,\n    0x16, 0x83, 0x7D, 0xEE, 0xF5, 0xCA, 0xC5, 0x18, 0xF9, 0xD8, 0x68, 0xAB, 0x38, 0x85, 0xA8, 0xF0, 0xA1, 0x73,\n    0x9F, 0x5D, 0x19, 0x0B, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x33, 0x72, 0x39, 0x25, 0x67, 0x26,\n    0x6D, 0x71, 0x36, 0x77, 0x3C, 0x20, 0x62, 0x23, 0x68, 0x74, 0xC3, 0x82, 0xC9, 0x15, 0x57, 0x16, 0x5D, 0x81};\n"
  },
  {
    "path": "common/DSUtilLite/DeCSS/CSSauth.h",
    "content": "#pragma once\n\nextern void CSSkey1(int varient, byte const *challenge, byte *key);\nextern void CSSkey2(int varient, byte const *challenge, byte *key);\nextern void CSSbuskey(int varient, byte const *challenge, byte *key);\n"
  },
  {
    "path": "common/DSUtilLite/DeCSS/CSSscramble.cpp",
    "content": "#include \"stdafx.h\"\n\n#ifndef countof\n#define countof(array) (sizeof(array) / sizeof(array[0]))\n#endif\n\nunsigned int CSStab0[11] = {5, 0, 1, 2, 3, 4, 0, 1, 2, 3, 4};\n\nunsigned char CSStab1[256] = {\n    0x33, 0x73, 0x3b, 0x26, 0x63, 0x23, 0x6b, 0x76, 0x3e, 0x7e, 0x36, 0x2b, 0x6e, 0x2e, 0x66, 0x7b, 0xd3, 0x93, 0xdb,\n    0x06, 0x43, 0x03, 0x4b, 0x96, 0xde, 0x9e, 0xd6, 0x0b, 0x4e, 0x0e, 0x46, 0x9b, 0x57, 0x17, 0x5f, 0x82, 0xc7, 0x87,\n    0xcf, 0x12, 0x5a, 0x1a, 0x52, 0x8f, 0xca, 0x8a, 0xc2, 0x1f, 0xd9, 0x99, 0xd1, 0x00, 0x49, 0x09, 0x41, 0x90, 0xd8,\n    0x98, 0xd0, 0x01, 0x48, 0x08, 0x40, 0x91, 0x3d, 0x7d, 0x35, 0x24, 0x6d, 0x2d, 0x65, 0x74, 0x3c, 0x7c, 0x34, 0x25,\n    0x6c, 0x2c, 0x64, 0x75, 0xdd, 0x9d, 0xd5, 0x04, 0x4d, 0x0d, 0x45, 0x94, 0xdc, 0x9c, 0xd4, 0x05, 0x4c, 0x0c, 0x44,\n    0x95, 0x59, 0x19, 0x51, 0x80, 0xc9, 0x89, 0xc1, 0x10, 0x58, 0x18, 0x50, 0x81, 0xc8, 0x88, 0xc0, 0x11, 0xd7, 0x97,\n    0xdf, 0x02, 0x47, 0x07, 0x4f, 0x92, 0xda, 0x9a, 0xd2, 0x0f, 0x4a, 0x0a, 0x42, 0x9f, 0x53, 0x13, 0x5b, 0x86, 0xc3,\n    0x83, 0xcb, 0x16, 0x5e, 0x1e, 0x56, 0x8b, 0xce, 0x8e, 0xc6, 0x1b, 0xb3, 0xf3, 0xbb, 0xa6, 0xe3, 0xa3, 0xeb, 0xf6,\n    0xbe, 0xfe, 0xb6, 0xab, 0xee, 0xae, 0xe6, 0xfb, 0x37, 0x77, 0x3f, 0x22, 0x67, 0x27, 0x6f, 0x72, 0x3a, 0x7a, 0x32,\n    0x2f, 0x6a, 0x2a, 0x62, 0x7f, 0xb9, 0xf9, 0xb1, 0xa0, 0xe9, 0xa9, 0xe1, 0xf0, 0xb8, 0xf8, 0xb0, 0xa1, 0xe8, 0xa8,\n    0xe0, 0xf1, 0x5d, 0x1d, 0x55, 0x84, 0xcd, 0x8d, 0xc5, 0x14, 0x5c, 0x1c, 0x54, 0x85, 0xcc, 0x8c, 0xc4, 0x15, 0xbd,\n    0xfd, 0xb5, 0xa4, 0xed, 0xad, 0xe5, 0xf4, 0xbc, 0xfc, 0xb4, 0xa5, 0xec, 0xac, 0xe4, 0xf5, 0x39, 0x79, 0x31, 0x20,\n    0x69, 0x29, 0x61, 0x70, 0x38, 0x78, 0x30, 0x21, 0x68, 0x28, 0x60, 0x71, 0xb7, 0xf7, 0xbf, 0xa2, 0xe7, 0xa7, 0xef,\n    0xf2, 0xba, 0xfa, 0xb2, 0xaf, 0xea, 0xaa, 0xe2, 0xff};\n\nunsigned char CSStab2[256] = {\n    0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x09, 0x08, 0x0b, 0x0a, 0x0d, 0x0c, 0x0f, 0x0e, 0x12, 0x13, 0x10,\n    0x11, 0x16, 0x17, 0x14, 0x15, 0x1b, 0x1a, 0x19, 0x18, 0x1f, 0x1e, 0x1d, 0x1c, 0x24, 0x25, 0x26, 0x27, 0x20, 0x21,\n    0x22, 0x23, 0x2d, 0x2c, 0x2f, 0x2e, 0x29, 0x28, 0x2b, 0x2a, 0x36, 0x37, 0x34, 0x35, 0x32, 0x33, 0x30, 0x31, 0x3f,\n    0x3e, 0x3d, 0x3c, 0x3b, 0x3a, 0x39, 0x38, 0x49, 0x48, 0x4b, 0x4a, 0x4d, 0x4c, 0x4f, 0x4e, 0x40, 0x41, 0x42, 0x43,\n    0x44, 0x45, 0x46, 0x47, 0x5b, 0x5a, 0x59, 0x58, 0x5f, 0x5e, 0x5d, 0x5c, 0x52, 0x53, 0x50, 0x51, 0x56, 0x57, 0x54,\n    0x55, 0x6d, 0x6c, 0x6f, 0x6e, 0x69, 0x68, 0x6b, 0x6a, 0x64, 0x65, 0x66, 0x67, 0x60, 0x61, 0x62, 0x63, 0x7f, 0x7e,\n    0x7d, 0x7c, 0x7b, 0x7a, 0x79, 0x78, 0x76, 0x77, 0x74, 0x75, 0x72, 0x73, 0x70, 0x71, 0x92, 0x93, 0x90, 0x91, 0x96,\n    0x97, 0x94, 0x95, 0x9b, 0x9a, 0x99, 0x98, 0x9f, 0x9e, 0x9d, 0x9c, 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87,\n    0x89, 0x88, 0x8b, 0x8a, 0x8d, 0x8c, 0x8f, 0x8e, 0xb6, 0xb7, 0xb4, 0xb5, 0xb2, 0xb3, 0xb0, 0xb1, 0xbf, 0xbe, 0xbd,\n    0xbc, 0xbb, 0xba, 0xb9, 0xb8, 0xa4, 0xa5, 0xa6, 0xa7, 0xa0, 0xa1, 0xa2, 0xa3, 0xad, 0xac, 0xaf, 0xae, 0xa9, 0xa8,\n    0xab, 0xaa, 0xdb, 0xda, 0xd9, 0xd8, 0xdf, 0xde, 0xdd, 0xdc, 0xd2, 0xd3, 0xd0, 0xd1, 0xd6, 0xd7, 0xd4, 0xd5, 0xc9,\n    0xc8, 0xcb, 0xca, 0xcd, 0xcc, 0xcf, 0xce, 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xff, 0xfe, 0xfd, 0xfc,\n    0xfb, 0xfa, 0xf9, 0xf8, 0xf6, 0xf7, 0xf4, 0xf5, 0xf2, 0xf3, 0xf0, 0xf1, 0xed, 0xec, 0xef, 0xee, 0xe9, 0xe8, 0xeb,\n    0xea, 0xe4, 0xe5, 0xe6, 0xe7, 0xe0, 0xe1, 0xe2, 0xe3};\n\nunsigned char CSStab3[512] = {\n    0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49,\n    0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6,\n    0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00,\n    0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d,\n    0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb,\n    0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24,\n    0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92,\n    0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff,\n    0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49,\n    0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6,\n    0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00,\n    0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d,\n    0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb,\n    0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24,\n    0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92,\n    0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff,\n    0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49,\n    0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6,\n    0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00,\n    0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d,\n    0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb,\n    0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24,\n    0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92,\n    0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff,\n    0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49,\n    0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6,\n    0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff, 0x00, 0x24, 0x49, 0x6d, 0x92, 0xb6, 0xdb, 0xff};\n\nunsigned char CSStab4[256] = {\n    0x00, 0x80, 0x40, 0xc0, 0x20, 0xa0, 0x60, 0xe0, 0x10, 0x90, 0x50, 0xd0, 0x30, 0xb0, 0x70, 0xf0, 0x08, 0x88, 0x48,\n    0xc8, 0x28, 0xa8, 0x68, 0xe8, 0x18, 0x98, 0x58, 0xd8, 0x38, 0xb8, 0x78, 0xf8, 0x04, 0x84, 0x44, 0xc4, 0x24, 0xa4,\n    0x64, 0xe4, 0x14, 0x94, 0x54, 0xd4, 0x34, 0xb4, 0x74, 0xf4, 0x0c, 0x8c, 0x4c, 0xcc, 0x2c, 0xac, 0x6c, 0xec, 0x1c,\n    0x9c, 0x5c, 0xdc, 0x3c, 0xbc, 0x7c, 0xfc, 0x02, 0x82, 0x42, 0xc2, 0x22, 0xa2, 0x62, 0xe2, 0x12, 0x92, 0x52, 0xd2,\n    0x32, 0xb2, 0x72, 0xf2, 0x0a, 0x8a, 0x4a, 0xca, 0x2a, 0xaa, 0x6a, 0xea, 0x1a, 0x9a, 0x5a, 0xda, 0x3a, 0xba, 0x7a,\n    0xfa, 0x06, 0x86, 0x46, 0xc6, 0x26, 0xa6, 0x66, 0xe6, 0x16, 0x96, 0x56, 0xd6, 0x36, 0xb6, 0x76, 0xf6, 0x0e, 0x8e,\n    0x4e, 0xce, 0x2e, 0xae, 0x6e, 0xee, 0x1e, 0x9e, 0x5e, 0xde, 0x3e, 0xbe, 0x7e, 0xfe, 0x01, 0x81, 0x41, 0xc1, 0x21,\n    0xa1, 0x61, 0xe1, 0x11, 0x91, 0x51, 0xd1, 0x31, 0xb1, 0x71, 0xf1, 0x09, 0x89, 0x49, 0xc9, 0x29, 0xa9, 0x69, 0xe9,\n    0x19, 0x99, 0x59, 0xd9, 0x39, 0xb9, 0x79, 0xf9, 0x05, 0x85, 0x45, 0xc5, 0x25, 0xa5, 0x65, 0xe5, 0x15, 0x95, 0x55,\n    0xd5, 0x35, 0xb5, 0x75, 0xf5, 0x0d, 0x8d, 0x4d, 0xcd, 0x2d, 0xad, 0x6d, 0xed, 0x1d, 0x9d, 0x5d, 0xdd, 0x3d, 0xbd,\n    0x7d, 0xfd, 0x03, 0x83, 0x43, 0xc3, 0x23, 0xa3, 0x63, 0xe3, 0x13, 0x93, 0x53, 0xd3, 0x33, 0xb3, 0x73, 0xf3, 0x0b,\n    0x8b, 0x4b, 0xcb, 0x2b, 0xab, 0x6b, 0xeb, 0x1b, 0x9b, 0x5b, 0xdb, 0x3b, 0xbb, 0x7b, 0xfb, 0x07, 0x87, 0x47, 0xc7,\n    0x27, 0xa7, 0x67, 0xe7, 0x17, 0x97, 0x57, 0xd7, 0x37, 0xb7, 0x77, 0xf7, 0x0f, 0x8f, 0x4f, 0xcf, 0x2f, 0xaf, 0x6f,\n    0xef, 0x1f, 0x9f, 0x5f, 0xdf, 0x3f, 0xbf, 0x7f, 0xff};\n\nunsigned char CSStab5[256] = {\n    0xff, 0x7f, 0xbf, 0x3f, 0xdf, 0x5f, 0x9f, 0x1f, 0xef, 0x6f, 0xaf, 0x2f, 0xcf, 0x4f, 0x8f, 0x0f, 0xf7, 0x77, 0xb7,\n    0x37, 0xd7, 0x57, 0x97, 0x17, 0xe7, 0x67, 0xa7, 0x27, 0xc7, 0x47, 0x87, 0x07, 0xfb, 0x7b, 0xbb, 0x3b, 0xdb, 0x5b,\n    0x9b, 0x1b, 0xeb, 0x6b, 0xab, 0x2b, 0xcb, 0x4b, 0x8b, 0x0b, 0xf3, 0x73, 0xb3, 0x33, 0xd3, 0x53, 0x93, 0x13, 0xe3,\n    0x63, 0xa3, 0x23, 0xc3, 0x43, 0x83, 0x03, 0xfd, 0x7d, 0xbd, 0x3d, 0xdd, 0x5d, 0x9d, 0x1d, 0xed, 0x6d, 0xad, 0x2d,\n    0xcd, 0x4d, 0x8d, 0x0d, 0xf5, 0x75, 0xb5, 0x35, 0xd5, 0x55, 0x95, 0x15, 0xe5, 0x65, 0xa5, 0x25, 0xc5, 0x45, 0x85,\n    0x05, 0xf9, 0x79, 0xb9, 0x39, 0xd9, 0x59, 0x99, 0x19, 0xe9, 0x69, 0xa9, 0x29, 0xc9, 0x49, 0x89, 0x09, 0xf1, 0x71,\n    0xb1, 0x31, 0xd1, 0x51, 0x91, 0x11, 0xe1, 0x61, 0xa1, 0x21, 0xc1, 0x41, 0x81, 0x01, 0xfe, 0x7e, 0xbe, 0x3e, 0xde,\n    0x5e, 0x9e, 0x1e, 0xee, 0x6e, 0xae, 0x2e, 0xce, 0x4e, 0x8e, 0x0e, 0xf6, 0x76, 0xb6, 0x36, 0xd6, 0x56, 0x96, 0x16,\n    0xe6, 0x66, 0xa6, 0x26, 0xc6, 0x46, 0x86, 0x06, 0xfa, 0x7a, 0xba, 0x3a, 0xda, 0x5a, 0x9a, 0x1a, 0xea, 0x6a, 0xaa,\n    0x2a, 0xca, 0x4a, 0x8a, 0x0a, 0xf2, 0x72, 0xb2, 0x32, 0xd2, 0x52, 0x92, 0x12, 0xe2, 0x62, 0xa2, 0x22, 0xc2, 0x42,\n    0x82, 0x02, 0xfc, 0x7c, 0xbc, 0x3c, 0xdc, 0x5c, 0x9c, 0x1c, 0xec, 0x6c, 0xac, 0x2c, 0xcc, 0x4c, 0x8c, 0x0c, 0xf4,\n    0x74, 0xb4, 0x34, 0xd4, 0x54, 0x94, 0x14, 0xe4, 0x64, 0xa4, 0x24, 0xc4, 0x44, 0x84, 0x04, 0xf8, 0x78, 0xb8, 0x38,\n    0xd8, 0x58, 0x98, 0x18, 0xe8, 0x68, 0xa8, 0x28, 0xc8, 0x48, 0x88, 0x08, 0xf0, 0x70, 0xb0, 0x30, 0xd0, 0x50, 0x90,\n    0x10, 0xe0, 0x60, 0xa0, 0x20, 0xc0, 0x40, 0x80, 0x00};\n\nvoid CSSdescramble(unsigned char *sec, unsigned char *tkey)\n{\n    unsigned int t1, t2, t3, t4, t5, t6;\n    unsigned char *end = sec + 0x800;\n\n    t1 = tkey[0] ^ sec[0x54] | 0x100;\n    t2 = tkey[1] ^ sec[0x55];\n    t3 = (*((unsigned int *)(tkey + 2))) ^ (*((unsigned int *)(sec + 0x56)));\n    t4 = t3 & 7;\n    t3 = t3 * 2 + 8 - t4;\n    sec += 0x80;\n    t5 = 0;\n    while (sec != end)\n    {\n        t4 = CSStab2[t2] ^ CSStab3[t1];\n        t2 = t1 >> 1;\n        t1 = ((t1 & 1) << 8) ^ t4;\n        t4 = CSStab5[t4];\n        t6 = (((((((t3 >> 3) ^ t3) >> 1) ^ t3) >> 8) ^ t3) >> 5) & 0xff;\n        t3 = (t3 << 8) | t6;\n        t6 = CSStab4[t6];\n        t5 += t6 + t4;\n        *sec++ = CSStab1[*sec] ^ (t5 & 0xff);\n        t5 >>= 8;\n    }\n}\n\nvoid CSSdisckey(unsigned char *dkey, unsigned char *pkey)\n{\n    unsigned int t1, t2, t3, t4, t5, t6;\n    unsigned char k[5];\n    int i;\n\n    t1 = pkey[0] | 0x100;\n    t2 = pkey[1];\n    t3 = *((unsigned int *)(pkey + 2));\n    t4 = t3 & 7;\n    t3 = t3 * 2 + 8 - t4;\n    t5 = 0;\n    for (i = 0; i < 5; i++)\n    {\n        t4 = CSStab2[t2] ^ CSStab3[t1];\n        t2 = t1 >> 1;\n        t1 = ((t1 & 1) << 8) ^ t4;\n        t4 = CSStab4[t4];\n        t6 = (((((((t3 >> 3) ^ t3) >> 1) ^ t3) >> 8) ^ t3) >> 5) & 0xff;\n        t3 = (t3 << 8) | t6;\n        t6 = CSStab4[t6];\n        t5 += t6 + t4;\n        k[i] = t5 & 0xff;\n        t5 >>= 8;\n    }\n    for (i = 9; i >= 0; i--)\n    {\n        dkey[CSStab0[i + 1]] = k[CSStab0[i + 1]] ^ CSStab1[dkey[CSStab0[i + 1]]] ^ dkey[CSStab0[i]];\n    }\n}\n\nvoid CSStitlekey(unsigned char *tkey, unsigned char *dkey)\n{\n    unsigned int t1, t2, t3, t4, t5, t6;\n    unsigned char k[5];\n    int i;\n\n    t1 = dkey[0] | 0x100;\n    t2 = dkey[1];\n    t3 = *((unsigned int *)(dkey + 2));\n    t4 = t3 & 7;\n    t3 = t3 * 2 + 8 - t4;\n    t5 = 0;\n    for (i = 0; i < 5; i++)\n    {\n        t4 = CSStab2[t2] ^ CSStab3[t1];\n        t2 = t1 >> 1;\n        t1 = ((t1 & 1) << 8) ^ t4;\n        t4 = CSStab4[t4];\n        t6 = (((((((t3 >> 3) ^ t3) >> 1) ^ t3) >> 8) ^ t3) >> 5) & 0xff;\n        t3 = (t3 << 8) | t6;\n        t6 = CSStab5[t6];\n        t5 += t6 + t4;\n        k[i] = t5 & 0xff;\n        t5 >>= 8;\n    }\n    for (i = 9; i >= 0; i--)\n    {\n        tkey[CSStab0[i + 1]] = k[CSStab0[i + 1]] ^ CSStab1[tkey[CSStab0[i + 1]]] ^ tkey[CSStab0[i]];\n    }\n}\n\nunsigned char g_PlayerKeys[][6] = {\n    // from mplayer:\n    {0x01, 0xaf, 0xe3, 0x12, 0x80}, {0x12, 0x11, 0xca, 0x04, 0x3b}, {0x14, 0x0c, 0x9e, 0xd0, 0x09},\n    {0x14, 0x71, 0x35, 0xba, 0xe2}, {0x1a, 0xa4, 0x33, 0x21, 0xa6}, {0x26, 0xec, 0xc4, 0xa7, 0x4e},\n    {0x2c, 0xb2, 0xc1, 0x09, 0xee}, {0x2f, 0x25, 0x9e, 0x96, 0xdd}, {0x33, 0x2f, 0x49, 0x6c, 0xe0},\n    {0x35, 0x5b, 0xc1, 0x31, 0x0f}, {0x36, 0x67, 0xb2, 0xe3, 0x85}, {0x39, 0x3d, 0xf1, 0xf1, 0xbd},\n    {0x3b, 0x31, 0x34, 0x0d, 0x91}, {0x45, 0xed, 0x28, 0xeb, 0xd3}, {0x48, 0xb7, 0x6c, 0xce, 0x69},\n    {0x4b, 0x65, 0x0d, 0xc1, 0xee}, {0x4c, 0xbb, 0xf5, 0x5b, 0x23}, {0x51, 0x67, 0x67, 0xc5, 0xe0},\n    {0x53, 0x94, 0xe1, 0x75, 0xbf}, {0x57, 0x2c, 0x8b, 0x31, 0xae}, {0x63, 0xdb, 0x4c, 0x5b, 0x4a},\n    {0x7b, 0x1e, 0x5e, 0x2b, 0x57}, {0x85, 0xf3, 0x85, 0xa0, 0xe0}, {0xab, 0x1e, 0xe7, 0x7b, 0x72},\n    {0xab, 0x36, 0xe3, 0xeb, 0x76}, {0xb1, 0xb8, 0xf9, 0x38, 0x03}, {0xb8, 0x5d, 0xd8, 0x53, 0xbd},\n    {0xbf, 0x92, 0xc3, 0xb0, 0xe2}, {0xcf, 0x1a, 0xb2, 0xf8, 0x0a}, {0xec, 0xa0, 0xcf, 0xb3, 0xff},\n    {0xfc, 0x95, 0xa9, 0x87, 0x35}\n    // TODO: find more player keys\n};\n\nint g_nPlayerKeys = countof(g_PlayerKeys);\n"
  },
  {
    "path": "common/DSUtilLite/DeCSS/CSSscramble.h",
    "content": "#pragma once\n\nextern void CSSdisckey(unsigned char *dkey, unsigned char *pkey);\nextern void CSStitlekey(unsigned char *tkey, unsigned char *dkey);\nextern void CSSdescramble(unsigned char *sector, unsigned char *tkey);\n\nextern unsigned char g_PlayerKeys[][6];\nextern int g_nPlayerKeys;\n"
  },
  {
    "path": "common/DSUtilLite/DeCSS/DeCSSInputPin.cpp",
    "content": "/*\n *      Copyright (C) 2003-2006 Gabest\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <dvdmedia.h>\n#include <ks.h>\n#include <ksmedia.h>\n\n#include \"DeCSSInputPin.h\"\n#include \"CSSauth.h\"\n#include \"CSSscramble.h\"\n\n#include \"../DShowUtil.h\"\n\n//\n// CDeCSSPinHelper\n//\n\nCDeCSSPinHelper::CDeCSSPinHelper()\n{\n    m_varient = -1;\n    memset(m_Challenge, 0, sizeof(m_Challenge));\n    memset(m_KeyCheck, 0, sizeof(m_KeyCheck));\n    memset(m_DiscKey, 0, sizeof(m_DiscKey));\n    memset(m_TitleKey, 0, sizeof(m_TitleKey));\n}\n\nvoid CDeCSSPinHelper::Decrypt(IMediaSample *pSample)\n{\n    long len = pSample->GetActualDataLength();\n\n    BYTE *p = nullptr;\n    if (SUCCEEDED(pSample->GetPointer(&p)) && len > 0)\n    {\n        if (m_mt.majortype == MEDIATYPE_DVD_ENCRYPTED_PACK && len == 2048 && (p[0x14] & 0x30))\n        {\n            CSSdescramble(p, m_TitleKey);\n            p[0x14] &= ~0x30;\n\n            IMediaSample2 *pMS2 = nullptr;\n            if (SUCCEEDED(pSample->QueryInterface(&pMS2)) && pMS2)\n            {\n                AM_SAMPLE2_PROPERTIES props;\n                memset(&props, 0, sizeof(props));\n                if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE *)&props)) &&\n                    (props.dwTypeSpecificFlags & AM_UseNewCSSKey))\n                {\n                    props.dwTypeSpecificFlags &= ~AM_UseNewCSSKey;\n                    pMS2->SetProperties(sizeof(props), (BYTE *)&props);\n                }\n                pMS2->Release();\n            }\n        }\n    }\n}\n\nvoid CDeCSSPinHelper::StripPacket(BYTE *&p, long &len)\n{\n    GUID majortype = m_mt.majortype;\n    GUID subtype = m_mt.subtype;\n\n    if (majortype == MEDIATYPE_MPEG2_PACK || majortype == MEDIATYPE_DVD_ENCRYPTED_PACK)\n    {\n        if (len > 0 && *(DWORD *)p == 0xba010000)\n        { // MEDIATYPE_*_PACK\n            len -= 14;\n            p += 14;\n            if (int stuffing = (p[-1] & 7))\n            {\n                len -= stuffing;\n                p += stuffing;\n            }\n            majortype = MEDIATYPE_MPEG2_PES;\n        }\n    }\n\n    if (majortype == MEDIATYPE_MPEG2_PES)\n    {\n        if (len > 0 && *(DWORD *)p == 0xbb010000)\n        {\n            len -= 4;\n            p += 4;\n            int hdrlen = ((p[0] << 8) | p[1]) + 2;\n            len -= hdrlen;\n            p += hdrlen;\n        }\n\n        if (len > 4 && ((*(DWORD *)p & 0xf0ffffff) == 0xe0010000 || (*(DWORD *)p & 0xe0ffffff) == 0xc0010000 ||\n                        (*(DWORD *)p & 0xbdffffff) == 0xbd010000))\n        { // PES\n            bool ps1 = (*(DWORD *)p & 0xbdffffff) == 0xbd010000;\n\n            len -= 4;\n            p += 4;\n            size_t expected = ((p[0] << 8) | p[1]);\n            len -= 2;\n            p += 2;\n            BYTE *p0 = p;\n\n            for (int i = 0; i < 16 && *p == 0xff; i++, len--, p++)\n            {\n                ;\n            }\n\n            if ((*p & 0xc0) == 0x80)\n            { // mpeg2\n                len -= 2;\n                p += 2;\n                len -= *p + 1;\n                p += *p + 1;\n            }\n            else\n            { // mpeg1\n                if ((*p & 0xc0) == 0x40)\n                {\n                    len -= 2;\n                    p += 2;\n                }\n\n                if ((*p & 0x30) == 0x30 || (*p & 0x30) == 0x20)\n                {\n                    bool pts = !!(*p & 0x20), dts = !!(*p & 0x10);\n                    if (pts)\n                    {\n                        len -= 5;\n                    }\n                    p += 5;\n                    if (dts)\n                    {\n                        ASSERT((*p & 0xf0) == 0x10);\n                        len -= 5;\n                        p += 5;\n                    }\n                }\n                else\n                {\n                    len--;\n                    p++;\n                }\n            }\n\n            if (ps1)\n            {\n                len--;\n                p++;\n                if (subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)\n                {\n                    len -= 6;\n                    p += 6;\n                }\n                else if (subtype == MEDIASUBTYPE_DOLBY_AC3 || subtype == FOURCCMap(0x2000) ||\n                         subtype == MEDIASUBTYPE_DTS || subtype == FOURCCMap(0x2001))\n                {\n                    len -= 3;\n                    p += 3;\n                }\n            }\n\n            if (expected > 0)\n            {\n                expected -= (p - p0);\n                len = min((long)expected, len);\n            }\n        }\n\n        if (len < 0)\n        {\n            ASSERT(0);\n            len = 0;\n        }\n    }\n}\n\n// IKsPropertySet\n\nSTDMETHODIMP CDeCSSPinHelper::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength,\n                                  LPVOID pPropertyData, ULONG DataLength)\n{\n    if (PropSet != AM_KSPROPSETID_CopyProt)\n    {\n        return E_NOTIMPL;\n    }\n\n    switch (Id)\n    {\n    case AM_PROPERTY_COPY_MACROVISION: break;\n    case AM_PROPERTY_DVDCOPY_CHLG_KEY: { // 3. auth: receive drive nonce word, also store and encrypt the buskey made up\n                                         // of the two nonce words\n        AM_DVDCOPY_CHLGKEY *pChlgKey = (AM_DVDCOPY_CHLGKEY *)pPropertyData;\n        for (int i = 0; i < 10; i++)\n        {\n            m_Challenge[i] = pChlgKey->ChlgKey[9 - i];\n        }\n\n        CSSkey2(m_varient, m_Challenge, &m_Key[5]);\n\n        CSSbuskey(m_varient, m_Key, m_KeyCheck);\n    }\n    break;\n    case AM_PROPERTY_DVDCOPY_DISC_KEY: { // 5. receive the disckey\n        AM_DVDCOPY_DISCKEY *pDiscKey =\n            (AM_DVDCOPY_DISCKEY *)pPropertyData; // pDiscKey->DiscKey holds the disckey encrypted with itself and the\n                                                 // 408 disckeys encrypted with the playerkeys\n\n        bool fSuccess = false;\n\n        for (int j = 0; j < g_nPlayerKeys; j++)\n        {\n            for (int k = 1; k < 409; k++)\n            {\n                BYTE DiscKey[6];\n                for (int i = 0; i < 5; i++)\n                {\n                    DiscKey[i] = pDiscKey->DiscKey[k * 5 + i] ^ m_KeyCheck[4 - i];\n                }\n                DiscKey[5] = 0;\n\n                CSSdisckey(DiscKey, g_PlayerKeys[j]);\n\n                BYTE Hash[6];\n                for (int i = 0; i < 5; i++)\n                {\n                    Hash[i] = pDiscKey->DiscKey[i] ^ m_KeyCheck[4 - i];\n                }\n                Hash[5] = 0;\n\n                CSSdisckey(Hash, DiscKey);\n\n                if (!memcmp(Hash, DiscKey, 6))\n                {\n                    memcpy(m_DiscKey, DiscKey, 6);\n                    j = g_nPlayerKeys;\n                    fSuccess = true;\n                    break;\n                }\n            }\n        }\n\n        if (!fSuccess)\n        {\n            return E_FAIL;\n        }\n    }\n    break;\n    case AM_PROPERTY_DVDCOPY_DVD_KEY1: { // 2. auth: receive our drive-encrypted nonce word and decrypt it for\n                                         // verification\n        AM_DVDCOPY_BUSKEY *pKey1 = (AM_DVDCOPY_BUSKEY *)pPropertyData;\n        for (int i = 0; i < 5; i++)\n        {\n            m_Key[i] = pKey1->BusKey[4 - i];\n        }\n\n        m_varient = -1;\n\n        for (int i = 31; i >= 0; i--)\n        {\n            CSSkey1(i, m_Challenge, m_KeyCheck);\n\n            if (memcmp(m_KeyCheck, &m_Key[0], 5) == 0)\n            {\n                m_varient = i;\n            }\n        }\n    }\n    break;\n    case AM_PROPERTY_DVDCOPY_REGION: break;\n    case AM_PROPERTY_DVDCOPY_SET_COPY_STATE: break;\n    case AM_PROPERTY_DVDCOPY_TITLE_KEY: { // 6. receive the title key and decrypt it with the disc key\n        AM_DVDCOPY_TITLEKEY *pTitleKey = (AM_DVDCOPY_TITLEKEY *)pPropertyData;\n        for (int i = 0; i < 5; i++)\n        {\n            m_TitleKey[i] = pTitleKey->TitleKey[i] ^ m_KeyCheck[4 - i];\n        }\n        m_TitleKey[5] = 0;\n        CSStitlekey(m_TitleKey, m_DiscKey);\n    }\n    break;\n    default: return E_PROP_ID_UNSUPPORTED;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDeCSSPinHelper::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength,\n                                  LPVOID pPropertyData, ULONG DataLength, ULONG *pBytesReturned)\n{\n    if (PropSet != AM_KSPROPSETID_CopyProt)\n    {\n        return E_NOTIMPL;\n    }\n\n    switch (Id)\n    {\n    case AM_PROPERTY_DVDCOPY_CHLG_KEY: { // 1. auth: send our nonce word\n        AM_DVDCOPY_CHLGKEY *pChlgKey = (AM_DVDCOPY_CHLGKEY *)pPropertyData;\n        for (int i = 0; i < 10; i++)\n        {\n            pChlgKey->ChlgKey[i] = 9 - (m_Challenge[i] = i);\n        }\n        *pBytesReturned = sizeof(AM_DVDCOPY_CHLGKEY);\n    }\n    break;\n    case AM_PROPERTY_DVDCOPY_DEC_KEY2: { // 4. auth: send back the encrypted drive nonce word to finish the\n                                         // authentication\n        AM_DVDCOPY_BUSKEY *pKey2 = (AM_DVDCOPY_BUSKEY *)pPropertyData;\n        for (int i = 0; i < 5; i++)\n        {\n            pKey2->BusKey[4 - i] = m_Key[5 + i];\n        }\n        *pBytesReturned = sizeof(AM_DVDCOPY_BUSKEY);\n    }\n    break;\n    case AM_PROPERTY_DVDCOPY_REGION: {\n        DVD_REGION *pRegion = (DVD_REGION *)pPropertyData;\n        pRegion->RegionData = 0;\n        pRegion->SystemRegion = 0;\n        *pBytesReturned = sizeof(DVD_REGION);\n    }\n    break;\n    case AM_PROPERTY_DVDCOPY_SET_COPY_STATE: {\n        AM_DVDCOPY_SET_COPY_STATE *pState = (AM_DVDCOPY_SET_COPY_STATE *)pPropertyData;\n        pState->DVDCopyState = AM_DVDCOPYSTATE_AUTHENTICATION_REQUIRED;\n        *pBytesReturned = sizeof(AM_DVDCOPY_SET_COPY_STATE);\n    }\n    break;\n    default: return E_PROP_ID_UNSUPPORTED;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDeCSSPinHelper::QuerySupported(REFGUID PropSet, ULONG Id, ULONG *pTypeSupport)\n{\n    if (PropSet != AM_KSPROPSETID_CopyProt)\n    {\n        return E_NOTIMPL;\n    }\n\n    switch (Id)\n    {\n    case AM_PROPERTY_COPY_MACROVISION: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    case AM_PROPERTY_DVDCOPY_CHLG_KEY: *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET; break;\n    case AM_PROPERTY_DVDCOPY_DEC_KEY2: *pTypeSupport = KSPROPERTY_SUPPORT_GET; break;\n    case AM_PROPERTY_DVDCOPY_DISC_KEY: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    case AM_PROPERTY_DVDCOPY_DVD_KEY1: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    case AM_PROPERTY_DVDCOPY_REGION: *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET; break;\n    case AM_PROPERTY_DVDCOPY_SET_COPY_STATE: *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET; break;\n    case AM_PROPERTY_DVDCOPY_TITLE_KEY: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    default: return E_PROP_ID_UNSUPPORTED;\n    }\n\n    return S_OK;\n}\n\n//\n// CDeCSSTransformInputPin\n//\n\nCDeCSSTransformInputPin::CDeCSSTransformInputPin(TCHAR *pObjectName, CTransformFilter *pFilter, HRESULT *phr,\n                                                 LPWSTR pName)\n    : CTransformInputPin(pObjectName, pFilter, phr, pName)\n    , CDeCSSPinHelper()\n{\n}\n\nSTDMETHODIMP CDeCSSTransformInputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    return QI(IKsPropertySet) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\nSTDMETHODIMP CDeCSSTransformInputPin::Receive(IMediaSample *pSample)\n{\n    Decrypt(pSample);\n    return __super::Receive(pSample);\n}\n\nHRESULT CDeCSSTransformInputPin::SetMediaType(const CMediaType *pmt)\n{\n    SetCSSMediaType(pmt);\n    return __super::SetMediaType(pmt);\n}\n"
  },
  {
    "path": "common/DSUtilLite/DeCSS/DeCSSInputPin.h",
    "content": "/*\n *      Copyright (C) 2003-2006 Gabest\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n */\n\n#pragma once\n\nclass CDeCSSPinHelper : public IKsPropertySet\n{\n    int m_varient;\n    BYTE m_Challenge[10], m_KeyCheck[5], m_Key[10];\n    BYTE m_DiscKey[6], m_TitleKey[6];\n\n    CMediaType m_mt;\n\n  public:\n    CDeCSSPinHelper();\n\n    void Decrypt(IMediaSample *pSample);\n    void StripPacket(BYTE *&p, long &len);\n\n    void SetCSSMediaType(const CMediaType *pmt) { m_mt = *pmt; }\n\n    // IKsPropertySet\n    STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData,\n                     ULONG DataLength);\n    STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData,\n                     ULONG DataLength, ULONG *pBytesReturned);\n    STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG *pTypeSupport);\n};\n\nclass CDeCSSTransformInputPin\n    : public CTransformInputPin\n    , public CDeCSSPinHelper\n{\n  public:\n    CDeCSSTransformInputPin(TCHAR *pObjectName, CTransformFilter *pFilter, HRESULT *phr, LPWSTR pName);\n\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // IMemInputPin\n    STDMETHODIMP Receive(IMediaSample *pSample);\n    HRESULT SetMediaType(const CMediaType *pmt);\n};\n"
  },
  {
    "path": "common/DSUtilLite/FloatingAverage.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <assert.h>\n#include \"DShowUtil.h\"\n\ntemplate <class T> class FloatingAverage\n{\n  public:\n    FloatingAverage(unsigned int iNumSamples = 10) { SetNumSamples(iNumSamples); }\n\n    ~FloatingAverage() { free(m_Samples); }\n\n    void SetNumSamples(unsigned int iNumSamples)\n    {\n        if (iNumSamples > m_NumSamplesAlloc)\n        {\n            m_Samples = (T *)realloc(m_Samples, iNumSamples * sizeof(T));\n            m_NumSamplesAlloc = iNumSamples;\n        }\n        if (iNumSamples > m_NumSamples)\n            memset(m_Samples + m_NumSamples, 0, sizeof(T) * (iNumSamples - m_NumSamples));\n        m_NumSamples = iNumSamples;\n    }\n\n    void Sample(T fSample)\n    {\n        m_Samples[m_CurrentSample] = fSample;\n        if (++m_CurrentSample >= m_NumSamples)\n        {\n            m_CurrentSample = 0;\n        }\n    }\n\n    T Average() const\n    {\n        T fAverage = 0;\n        for (unsigned int i = 0; i < m_NumSamples; ++i)\n        {\n            fAverage += m_Samples[i] / m_NumSamples;\n        }\n        return fAverage;\n    }\n\n    T Minimum() const\n    {\n        T min = m_Samples[0];\n        for (unsigned int i = 1; i < m_NumSamples; ++i)\n        {\n            if (m_Samples[i] < min)\n                min = m_Samples[i];\n        }\n        return min;\n    }\n\n    T AbsMinimum() const\n    {\n        T min = m_Samples[0];\n        for (unsigned int i = 1; i < m_NumSamples; ++i)\n        {\n            if (abs(m_Samples[i]) < abs(min))\n                min = m_Samples[i];\n        }\n        return min;\n    }\n\n    T Maximum() const\n    {\n        T max = m_Samples[0];\n        for (unsigned int i = 1; i < m_NumSamples; ++i)\n        {\n            if (m_Samples[i] > max)\n                max = m_Samples[i];\n        }\n        return max;\n    }\n\n    T AbsMaximum() const\n    {\n        T max = m_Samples[0];\n        for (unsigned int i = 1; i < m_NumSamples; ++i)\n        {\n            if (abs(m_Samples[i]) > abs(max))\n                max = m_Samples[i];\n        }\n        return max;\n    }\n\n    void OffsetValues(T value) const\n    {\n        for (unsigned int i = 0; i < m_NumSamples; ++i)\n        {\n            m_Samples[i] += value;\n        }\n    }\n\n    unsigned int CurrentSample() const { return m_CurrentSample; }\n\n  private:\n    T *m_Samples = nullptr;\n    unsigned int m_NumSamples = 0;\n    unsigned int m_NumSamplesAlloc = 0;\n    unsigned int m_CurrentSample = 0;\n};\n"
  },
  {
    "path": "common/DSUtilLite/FontInstaller.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"FontInstaller.h\"\n\nCFontInstaller::CFontInstaller()\n    : pAddFontMemResourceEx(nullptr)\n    , pRemoveFontMemResourceEx(nullptr)\n{\n    if (HMODULE hGdi = GetModuleHandle(_T(\"gdi32.dll\")))\n    {\n        pAddFontMemResourceEx =\n            (HANDLE(WINAPI *)(PVOID, DWORD, PVOID, DWORD *))GetProcAddress(hGdi, \"AddFontMemResourceEx\");\n        pRemoveFontMemResourceEx = (BOOL(WINAPI *)(HANDLE))GetProcAddress(hGdi, \"RemoveFontMemResourceEx\");\n    }\n}\n\nCFontInstaller::~CFontInstaller()\n{\n    UninstallFonts();\n}\n\nbool CFontInstaller::InstallFont(const void *pData, UINT len)\n{\n    return InstallFontMemory(pData, len);\n}\n\nvoid CFontInstaller::UninstallFonts()\n{\n    if (pRemoveFontMemResourceEx)\n    {\n        std::vector<HANDLE>::iterator it;\n        for (it = m_fonts.begin(); it != m_fonts.end(); ++it)\n        {\n            pRemoveFontMemResourceEx(*it);\n        }\n        m_fonts.clear();\n    }\n}\n\nbool CFontInstaller::InstallFontMemory(const void *pData, UINT len)\n{\n    if (!pAddFontMemResourceEx)\n    {\n        return false;\n    }\n\n    DWORD nFonts = 0;\n    HANDLE hFont = pAddFontMemResourceEx((PVOID)pData, len, nullptr, &nFonts);\n    if (hFont && nFonts > 0)\n    {\n        m_fonts.push_back(hFont);\n    }\n    return hFont && nFonts > 0;\n}\n"
  },
  {
    "path": "common/DSUtilLite/FontInstaller.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#pragma once\n\n#include <vector>\n\nclass CFontInstaller\n{\n    HANDLE(WINAPI *pAddFontMemResourceEx)(PVOID, DWORD, PVOID, DWORD *) = nullptr;\n    BOOL(WINAPI *pRemoveFontMemResourceEx)(HANDLE) = nullptr;\n\n    std::vector<HANDLE> m_fonts;\n    bool InstallFontMemory(const void *pData, UINT len);\n\n  public:\n    CFontInstaller();\n    virtual ~CFontInstaller();\n\n    bool InstallFont(const void *pData, UINT len);\n    void UninstallFonts();\n};\n"
  },
  {
    "path": "common/DSUtilLite/H264Nalu.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"H264Nalu.h\"\n\nvoid CH264Nalu::SetBuffer(const BYTE *pBuffer, size_t nSize, int nNALSize)\n{\n    m_pBuffer = pBuffer;\n    m_nSize = nSize;\n    m_nNALSize = nNALSize;\n    m_nCurPos = 0;\n    m_nNextRTP = 0;\n\n    m_nNALStartPos = 0;\n    m_nNALDataPos = 0;\n\n    // In AnnexB, the buffer is not guaranteed to start on a NAL boundary\n    if (nNALSize == 0 && nSize > 0)\n        MoveToNextAnnexBStartcode();\n}\n\nbool CH264Nalu::MoveToNextAnnexBStartcode()\n{\n    if (m_nSize < 4)\n        goto notfound;\n\n    size_t nBuffEnd = m_nSize - 4;\n\n    for (size_t i = m_nCurPos; i <= nBuffEnd; i++)\n    {\n        if ((*((DWORD *)(m_pBuffer + i)) & 0x00FFFFFF) == 0x00010000)\n        {\n            // Found next AnnexB NAL\n            m_nCurPos = i;\n            return true;\n        }\n    }\n\nnotfound:\n    m_nCurPos = m_nSize;\n    return false;\n}\n\nbool CH264Nalu::MoveToNextRTPStartcode()\n{\n    if (m_nNextRTP < m_nSize)\n    {\n        m_nCurPos = m_nNextRTP;\n        return true;\n    }\n\n    m_nCurPos = m_nSize;\n    return false;\n}\n\nbool CH264Nalu::ReadNext()\n{\n    if (m_nCurPos >= m_nSize)\n        return false;\n\n    if ((m_nNALSize != 0) && (m_nCurPos == m_nNextRTP))\n    {\n        if (m_nCurPos + m_nNALSize >= m_nSize)\n            return false;\n        // RTP Nalu type : (XX XX) XX XX NAL..., with XX XX XX XX or XX XX equal to NAL size\n        m_nNALStartPos = m_nCurPos;\n        m_nNALDataPos = m_nCurPos + m_nNALSize;\n\n        // Read Length code from the buffer\n        unsigned nTemp = 0;\n        for (int i = 0; i < m_nNALSize; i++)\n            nTemp = (nTemp << 8) + m_pBuffer[m_nCurPos++];\n\n        m_nNextRTP += nTemp + m_nNALSize;\n        MoveToNextRTPStartcode();\n    }\n    else\n    {\n        // Remove trailing bits\n        while (m_pBuffer[m_nCurPos] == 0x00 && ((*((DWORD *)(m_pBuffer + m_nCurPos)) & 0x00FFFFFF) != 0x00010000))\n            m_nCurPos++;\n\n        // AnnexB Nalu : 00 00 01 NAL...\n        m_nNALStartPos = m_nCurPos;\n        m_nCurPos += 3;\n        m_nNALDataPos = m_nCurPos;\n        MoveToNextAnnexBStartcode();\n    }\n\n    forbidden_bit = (m_pBuffer[m_nNALDataPos] >> 7) & 1;\n    nal_reference_idc = (m_pBuffer[m_nNALDataPos] >> 5) & 3;\n    nal_unit_type = (NALU_TYPE)(m_pBuffer[m_nNALDataPos] & 0x1f);\n\n    return true;\n}\n\nbool CH265Nalu::ReadNext()\n{\n    if (CH264Nalu::ReadNext())\n    {\n        nal_unit_type = (NALU_TYPE)((m_pBuffer[m_nNALDataPos] >> 1) & 0x3F);\n        return true;\n    }\n\n    return false;\n}\n\nCH264NALUnescape::CH264NALUnescape(const BYTE *src, size_t nSize)\n{\n    m_pBuffer = (BYTE *)_aligned_malloc(nSize + 16, 16);\n    memset(m_pBuffer, 0, nSize + 16);\n\n    unsigned si = 0, di = 0;\n    BYTE *dst = m_pBuffer;\n    while (si + 2 < nSize)\n    {\n        // detect and remove escapes\n        if (src[si + 2] > 3)\n        {\n            dst[di++] = src[si++];\n            dst[di++] = src[si++];\n        }\n        else if (src[si] == 0 && src[si + 1] == 0 && src[si + 2] != 0)\n        {\n            if (src[si + 2] == 3)\n            { // escape\n                dst[di++] = 0;\n                dst[di++] = 0;\n                si += 3;\n\n                continue;\n            }\n        }\n\n        dst[di++] = src[si++];\n    }\n\n    while (si < nSize)\n        dst[di++] = src[si++];\n\n    m_nSize = di;\n}\n\nCH264NALUnescape::~CH264NALUnescape()\n{\n    _aligned_free(m_pBuffer);\n}\n"
  },
  {
    "path": "common/DSUtilLite/H264Nalu.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#pragma once\n\ntypedef enum\n{\n    NALU_TYPE_UNKNOWN = 0,\n    NALU_TYPE_SLICE = 1,\n    NALU_TYPE_DPA = 2,\n    NALU_TYPE_DPB = 3,\n    NALU_TYPE_DPC = 4,\n    NALU_TYPE_IDR = 5,\n    NALU_TYPE_SEI = 6,\n    NALU_TYPE_SPS = 7,\n    NALU_TYPE_PPS = 8,\n    NALU_TYPE_AUD = 9,\n    NALU_TYPE_EOSEQ = 10,\n    NALU_TYPE_EOSTREAM = 11,\n    NALU_TYPE_FILL = 12,\n    NALU_TYPE_SPS_SUB = 15,\n} NALU_TYPE;\n\nclass CH264Nalu\n{\n  protected:\n    int forbidden_bit = 0;                       //! should be always FALSE\n    int nal_reference_idc = 0;                   //! NALU_PRIORITY_xxxx\n    NALU_TYPE nal_unit_type = NALU_TYPE_UNKNOWN; //! NALU_TYPE_xxxx\n\n    size_t m_nNALStartPos = 0; //! NALU start (including startcode / size)\n    size_t m_nNALDataPos = 0;  //! Useful part\n\n    const BYTE *m_pBuffer = nullptr;\n    size_t m_nCurPos = 0;\n    size_t m_nNextRTP = 0;\n    size_t m_nSize = 0;\n    int m_nNALSize = 0;\n\n    bool MoveToNextAnnexBStartcode();\n    bool MoveToNextRTPStartcode();\n\n  public:\n    CH264Nalu() { SetBuffer(nullptr, 0, 0); }\n    NALU_TYPE GetType() const { return nal_unit_type; }\n    bool IsRefFrame() const { return (nal_reference_idc != 0); }\n\n    size_t GetDataLength() const { return m_nCurPos - m_nNALDataPos; }\n    const BYTE *GetDataBuffer() { return m_pBuffer + m_nNALDataPos; }\n    size_t GetRoundedDataLength() const\n    {\n        size_t nSize = m_nCurPos - m_nNALDataPos;\n        return nSize + 128 - (nSize % 128);\n    }\n\n    size_t GetLength() const { return m_nCurPos - m_nNALStartPos; }\n    const BYTE *GetNALBuffer() { return m_pBuffer + m_nNALStartPos; }\n    size_t GetNALPos() { return m_nNALStartPos; }\n    bool IsEOF() const { return m_nCurPos >= m_nSize; }\n\n    void SetBuffer(const BYTE *pBuffer, size_t nSize, int nNALSize);\n    bool ReadNext();\n};\n\nclass CH265Nalu : public CH264Nalu\n{\n  public:\n    CH265Nalu()\n        : CH264Nalu(){};\n    bool ReadNext();\n};\n\nclass CH264NALUnescape\n{\n  public:\n    CH264NALUnescape(const BYTE *pBuffer, size_t nSize);\n    ~CH264NALUnescape();\n    const BYTE *GetBuffer() const { return m_pBuffer; }\n    size_t GetSize() const { return m_nSize; }\n\n  private:\n    BYTE *m_pBuffer = nullptr;\n    size_t m_nSize = 0;\n};\n"
  },
  {
    "path": "common/DSUtilLite/MediaSampleSideData.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"MediaSampleSideData.h\"\n\nCMediaSampleSideData::CMediaSampleSideData(LPCTSTR pName, CBaseAllocator *pAllocator, HRESULT *phr, LPBYTE pBuffer,\n                                           LONG length)\n    : CMediaSample(pName, pAllocator, phr, pBuffer, length)\n{\n}\n\nCMediaSampleSideData::~CMediaSampleSideData()\n{\n    ReleaseSideData();\n}\n\nSTDMETHODIMP CMediaSampleSideData::QueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n\n    if (riid == __uuidof(IMediaSideData))\n    {\n        return GetInterface((IMediaSideData *)this, ppv);\n    }\n    else\n    {\n        return __super::QueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP_(ULONG) CMediaSampleSideData::Release()\n{\n    /* Decrement our own private reference count */\n    LONG lRef;\n    if (m_cRef == 1)\n    {\n        lRef = 0;\n        m_cRef = 0;\n    }\n    else\n    {\n        lRef = InterlockedDecrement(&m_cRef);\n    }\n    ASSERT(lRef >= 0);\n\n    /* Did we release our final reference count */\n    if (lRef == 0)\n    {\n        /* Free all resources */\n        if (m_dwFlags & Sample_TypeChanged)\n        {\n            SetMediaType(NULL);\n        }\n        ASSERT(m_pMediaType == NULL);\n        m_dwFlags = 0;\n        m_dwTypeSpecificFlags = 0;\n        m_dwStreamId = AM_STREAM_MEDIA;\n\n        ReleaseSideData();\n\n        /* This may cause us to be deleted */\n        // Our refcount is reliably 0 thus no-one will mess with us\n        m_pAllocator->ReleaseBuffer(this);\n    }\n    return (ULONG)lRef;\n}\n\nvoid CMediaSampleSideData::ReleaseSideData()\n{\n    CAutoLock Lock(&m_csSideData);\n\n    for (auto it = m_SideData.begin(); it != m_SideData.end(); it++)\n    {\n        SideDataEntry *sd = &(it->second);\n        _aligned_free(sd->pData);\n    }\n\n    m_SideData.clear();\n}\n\n// IMediaSideData\nSTDMETHODIMP CMediaSampleSideData::SetSideData(GUID guidType, const BYTE *pData, size_t size)\n{\n    if (!pData || !size)\n        return E_POINTER;\n\n    CAutoLock Lock(&m_csSideData);\n\n    auto it = m_SideData.find(guidType);\n    if (it != m_SideData.end())\n    {\n        SideDataEntry *sd = &(it->second);\n        BYTE *newData = (BYTE *)_aligned_realloc(sd->pData, size, 16);\n        if (newData)\n        {\n            sd->size = size;\n            sd->pData = newData;\n            memcpy(newData, pData, size);\n        }\n        else\n        {\n            return E_OUTOFMEMORY;\n        }\n    }\n    else\n    {\n        SideDataEntry sd;\n        sd.pData = (BYTE *)_aligned_malloc(size, 16);\n        if (sd.pData)\n        {\n            sd.size = size;\n            memcpy(sd.pData, pData, size);\n        }\n        else\n        {\n            return E_OUTOFMEMORY;\n        }\n\n        m_SideData[guidType] = sd;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CMediaSampleSideData::GetSideData(GUID guidType, const BYTE **pData, size_t *pSize)\n{\n    if (!pData || !pSize)\n        return E_POINTER;\n\n    CAutoLock Lock(&m_csSideData);\n\n    auto it = m_SideData.find(guidType);\n    if (it != m_SideData.end())\n    {\n        *pData = it->second.pData;\n        *pSize = it->second.size;\n\n        return S_OK;\n    }\n\n    return E_FAIL;\n}\n"
  },
  {
    "path": "common/DSUtilLite/MediaSampleSideData.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <map>\n\n#include \"amfilter.h\"\n#include \"IMediaSideData.h\"\n\nstruct SideDataGUIDComparer\n{\n    bool operator()(const GUID &Left, const GUID &Right) const\n    {\n        // comparison logic goes here\n        return memcmp(&Left, &Right, sizeof(Right)) < 0;\n    }\n};\n\nclass CMediaSampleSideData\n    : public CMediaSample\n    , public IMediaSideData\n{\n  public:\n    CMediaSampleSideData(LPCTSTR pName, CBaseAllocator *pAllocator, HRESULT *phr, LPBYTE pBuffer, LONG length);\n    virtual ~CMediaSampleSideData();\n\n    STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) Release();\n\n    // IMediaSideData\n    STDMETHODIMP SetSideData(GUID guidType, const BYTE *pData, size_t size);\n    STDMETHODIMP GetSideData(GUID guidType, const BYTE **pData, size_t *pSize);\n\n  private:\n    void ReleaseSideData();\n\n    struct SideDataEntry\n    {\n        BYTE *pData;\n        size_t size;\n    };\n\n    CCritSec m_csSideData;\n    std::map<GUID, SideDataEntry, SideDataGUIDComparer> m_SideData;\n};\n"
  },
  {
    "path": "common/DSUtilLite/PopupMenu.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"PopupMenu.h\"\n\nCPopupMenu::CPopupMenu(void)\n{\n    m_hMenu = CreatePopupMenu();\n}\n\nCPopupMenu::~CPopupMenu(void)\n{\n    if (m_hMenu)\n        DestroyMenu(m_hMenu);\n}\n\nHRESULT CPopupMenu::AddItem(UINT id, LPWSTR caption, BOOL checked, BOOL enabled)\n{\n    if (!m_hMenu)\n        return E_UNEXPECTED;\n    MENUITEMINFO mii;\n    mii.cbSize = sizeof(mii);\n    mii.fMask = MIIM_ID | MIIM_STATE | MIIM_FTYPE | MIIM_STRING;\n    mii.fType = MFT_STRING | MFT_RADIOCHECK;\n    mii.wID = id;\n    mii.fState = (checked ? MFS_CHECKED : 0) | (!enabled ? MFS_DISABLED : 0);\n    mii.dwTypeData = caption;\n    mii.cch = (UINT)wcslen(mii.dwTypeData);\n    InsertMenuItem(m_hMenu, order++, TRUE, &mii);\n    return S_OK;\n}\n\nHRESULT CPopupMenu::AddSeparator()\n{\n    if (!m_hMenu)\n        return E_UNEXPECTED;\n    MENUITEMINFO mii;\n    mii.cbSize = sizeof(mii);\n    mii.fMask = MIIM_TYPE;\n    mii.fType = MFT_SEPARATOR;\n    InsertMenuItem(m_hMenu, order++, TRUE, &mii);\n    return S_OK;\n}\n\nHRESULT CPopupMenu::AddSubmenu(HMENU hSubMenu, LPWSTR caption)\n{\n    if (!m_hMenu)\n        return E_UNEXPECTED;\n    MENUITEMINFO mii;\n    mii.cbSize = sizeof(mii);\n    mii.fMask = MIIM_FTYPE | MIIM_STRING | MIIM_SUBMENU;\n    mii.fType = MFT_STRING;\n    mii.hSubMenu = hSubMenu;\n    mii.dwTypeData = caption;\n    mii.cch = (UINT)wcslen(mii.dwTypeData);\n    InsertMenuItem(m_hMenu, order++, TRUE, &mii);\n    return S_OK;\n}\n\nHMENU CPopupMenu::Finish()\n{\n    HMENU hMenu = m_hMenu;\n    m_hMenu = nullptr;\n    return hMenu;\n}\n"
  },
  {
    "path": "common/DSUtilLite/PopupMenu.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nclass CPopupMenu\n{\n  public:\n    CPopupMenu(void);\n    virtual ~CPopupMenu(void);\n\n    HRESULT AddItem(UINT id, LPWSTR caption, BOOL checked = FALSE, BOOL enabled = TRUE);\n    HRESULT AddSeparator();\n    HRESULT AddSubmenu(HMENU hSubMenu, LPWSTR caption);\n\n    HMENU Finish();\n\n  private:\n    HMENU m_hMenu = 0;\n    int order = 0;\n};\n"
  },
  {
    "path": "common/DSUtilLite/SynchronizedQueue.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <deque>\n\ntemplate <class T> class CSynchronizedQueue : public CCritSec\n{\n  public:\n    CSynchronizedQueue(){};\n\n    void Push(T item)\n    {\n        CAutoLock lock(this);\n\n        m_queue.push_back(item);\n    }\n\n    T Pop(void)\n    {\n        CAutoLock lock(this);\n\n        if (m_queue.empty())\n            return nullptr;\n\n        T item = m_queue.front();\n        m_queue.pop_front();\n\n        return item;\n    }\n\n    bool Empty()\n    {\n        CAutoLock lock(this);\n\n        return m_queue.empty();\n    }\n\n    size_t Size()\n    {\n        CAutoLock lock(this);\n\n        return m_queue.size();\n    }\n\n  private:\n    std::deque<T> m_queue;\n};\n"
  },
  {
    "path": "common/DSUtilLite/filterreg.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"DShowUtil.h\"\n\nstd::wstring CStringFromGUID(const GUID &guid)\n{\n    WCHAR null[128] = {0}, buff[128];\n    StringFromGUID2(GUID_NULL, null, 127);\n    return std::wstring(StringFromGUID2(guid, buff, 127) > 0 ? buff : null);\n}\n\n// filter registration helpers\n\nbool DeleteRegKey(std::wstring szKey, std::wstring szSubkey)\n{\n    bool bOK = false;\n\n    HKEY hKey;\n    LONG ec = ::RegOpenKeyEx(HKEY_CLASSES_ROOT, szKey.c_str(), 0, KEY_ALL_ACCESS, &hKey);\n    if (ec == ERROR_SUCCESS)\n    {\n        if (szSubkey.length() > 0)\n            ec = ::RegDeleteKey(hKey, szSubkey.c_str());\n\n        bOK = (ec == ERROR_SUCCESS);\n\n        ::RegCloseKey(hKey);\n    }\n\n    return bOK;\n}\n\nbool SetRegKeyValue(std::wstring szKey, std::wstring szSubkey, std::wstring szValueName, std::wstring szValue)\n{\n    bool bOK = false;\n\n    if (szSubkey.length() > 0)\n        szKey += _T(\"\\\\\") + szSubkey;\n\n    HKEY hKey;\n    LONG ec =\n        ::RegCreateKeyEx(HKEY_CLASSES_ROOT, szKey.c_str(), 0, 0, REG_OPTION_NON_VOLATILE, KEY_ALL_ACCESS, 0, &hKey, 0);\n    if (ec == ERROR_SUCCESS)\n    {\n        if (szValue.length() > 0)\n        {\n            ec = ::RegSetValueEx(hKey, szValueName.c_str(), 0, REG_SZ,\n                                 reinterpret_cast<BYTE *>(const_cast<LPTSTR>(szValue.c_str())),\n                                 (DWORD)(_tcslen(szValue.c_str()) + 1) * sizeof(TCHAR));\n        }\n\n        bOK = (ec == ERROR_SUCCESS);\n\n        ::RegCloseKey(hKey);\n    }\n\n    return bOK;\n}\n\nbool SetRegKeyValue(std::wstring szKey, std::wstring szSubkey, std::wstring szValue)\n{\n    return SetRegKeyValue(szKey, szSubkey, _T(\"\"), szValue);\n}\n\nvoid RegisterSourceFilter(const CLSID &clsid, const GUID &subtype2, LPCWSTR chkbytes, ...)\n{\n    std::wstring null = CStringFromGUID(GUID_NULL);\n    std::wstring majortype = CStringFromGUID(MEDIATYPE_Stream);\n    std::wstring subtype = CStringFromGUID(subtype2);\n\n    SetRegKeyValue(_T(\"Media Type\\\\\") + majortype, subtype, _T(\"0\"), chkbytes);\n    SetRegKeyValue(_T(\"Media Type\\\\\") + majortype, subtype, _T(\"Source Filter\"), CStringFromGUID(clsid));\n\n    DeleteRegKey(_T(\"Media Type\\\\\") + null, subtype);\n\n    va_list extensions;\n    va_start(extensions, chkbytes);\n    LPCWSTR ext = nullptr;\n    while (ext = va_arg(extensions, LPCWSTR))\n    {\n        DeleteRegKey(_T(\"Media Type\\\\Extensions\"), ext);\n    }\n    va_end(extensions);\n}\n\nvoid RegisterProtocolSourceFilter(const CLSID &clsid, LPCWSTR protocol)\n{\n    SetRegKeyValue(protocol, _T(\"\"), _T(\"Source Filter\"), CStringFromGUID(clsid));\n}\n\nvoid UnRegisterProtocolSourceFilter(LPCWSTR protocol)\n{\n    DeleteRegKey(protocol, _T(\"\"));\n}\n\nvoid RegisterSourceFilter(const CLSID &clsid, const GUID &subtype2, std::list<LPCWSTR> chkbytes, ...)\n{\n    std::wstring null = CStringFromGUID(GUID_NULL);\n    std::wstring majortype = CStringFromGUID(MEDIATYPE_Stream);\n    std::wstring subtype = CStringFromGUID(subtype2);\n\n    int i = 0;\n    std::list<LPCWSTR>::iterator it;\n    for (it = chkbytes.begin(); it != chkbytes.end(); ++it)\n    {\n        WCHAR idx[10] = {0};\n        swprintf_s(idx, _T(\"%d\"), i);\n        SetRegKeyValue(_T(\"Media Type\\\\\") + majortype, subtype, idx, *it);\n        i++;\n    }\n\n    SetRegKeyValue(_T(\"Media Type\\\\\") + majortype, subtype, _T(\"Source Filter\"), CStringFromGUID(clsid));\n\n    DeleteRegKey(_T(\"Media Type\\\\\") + null, subtype);\n\n    va_list extensions;\n    va_start(extensions, chkbytes);\n    LPCWSTR ext = nullptr;\n    while (ext = va_arg(extensions, LPCWSTR))\n    {\n        DeleteRegKey(_T(\"Media Type\\\\Extensions\"), ext);\n    }\n    va_end(extensions);\n}\n\nvoid UnRegisterSourceFilter(const GUID &subtype)\n{\n    DeleteRegKey(_T(\"Media Type\\\\\") + CStringFromGUID(MEDIATYPE_Stream), CStringFromGUID(subtype));\n}\n"
  },
  {
    "path": "common/DSUtilLite/gpu_memcpy_sse4.h",
    "content": "/*\n *      Copyright (C) 2011-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Taken from the QuickSync decoder by Eric Gur\n */\n\n#include <emmintrin.h>\n#include <smmintrin.h>\n\n// gpu_memcpy is a memcpy style function that copied data very fast from a\n// GPU tiled memory (write back)\n// Performance tip: page offset (12 lsb) of both addresses should be different\n//  optimally use a 2K offset between them.\ninline void *gpu_memcpy(void *d, const void *s, size_t size)\n{\n    static const size_t regsInLoop = sizeof(size_t) * 2; // 8 or 16\n\n    if (d == nullptr || s == nullptr)\n        return nullptr;\n\n    // If memory is not aligned, use memcpy\n    bool isAligned = (((size_t)(s) | (size_t)(d)) & 0xF) == 0;\n    if (!isAligned)\n    {\n        return memcpy(d, s, size);\n    }\n\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n#ifdef _M_X64\n    __m128i xmm8, xmm9, xmm10, xmm11, xmm12, xmm13, xmm14, xmm15;\n#endif\n\n    size_t remainder = size & (regsInLoop * sizeof(xmm0) - 1); // Copy 128 or 256 bytes every loop\n    size_t end = 0;\n\n    __m128i *pTrg = (__m128i *)d;\n    __m128i *pTrgEnd = pTrg + ((size - remainder) >> 4);\n    __m128i *pSrc = (__m128i *)s;\n\n    // Make sure source is synced - doesn't hurt if not needed.\n    _mm_sfence();\n\n    while (pTrg < pTrgEnd)\n    {\n        // _mm_stream_load_si128 emits the Streaming SIMD Extensions 4 (SSE4.1) instruction MOVNTDQA\n        // Fastest method for copying GPU RAM. Available since Penryn (45nm Core 2 Duo/Quad)\n        xmm0 = _mm_stream_load_si128(pSrc);\n        xmm1 = _mm_stream_load_si128(pSrc + 1);\n        xmm2 = _mm_stream_load_si128(pSrc + 2);\n        xmm3 = _mm_stream_load_si128(pSrc + 3);\n        xmm4 = _mm_stream_load_si128(pSrc + 4);\n        xmm5 = _mm_stream_load_si128(pSrc + 5);\n        xmm6 = _mm_stream_load_si128(pSrc + 6);\n        xmm7 = _mm_stream_load_si128(pSrc + 7);\n#ifdef _M_X64 // Use all 16 xmm registers\n        xmm8 = _mm_stream_load_si128(pSrc + 8);\n        xmm9 = _mm_stream_load_si128(pSrc + 9);\n        xmm10 = _mm_stream_load_si128(pSrc + 10);\n        xmm11 = _mm_stream_load_si128(pSrc + 11);\n        xmm12 = _mm_stream_load_si128(pSrc + 12);\n        xmm13 = _mm_stream_load_si128(pSrc + 13);\n        xmm14 = _mm_stream_load_si128(pSrc + 14);\n        xmm15 = _mm_stream_load_si128(pSrc + 15);\n#endif\n\n        _ReadWriteBarrier();\n\n        // _mm_store_si128 emit the SSE2 intruction MOVDQA (aligned store)\n        _mm_store_si128(pTrg, xmm0);\n        _mm_store_si128(pTrg + 1, xmm1);\n        _mm_store_si128(pTrg + 2, xmm2);\n        _mm_store_si128(pTrg + 3, xmm3);\n        _mm_store_si128(pTrg + 4, xmm4);\n        _mm_store_si128(pTrg + 5, xmm5);\n        _mm_store_si128(pTrg + 6, xmm6);\n        _mm_store_si128(pTrg + 7, xmm7);\n#ifdef _M_X64 // Use all 16 xmm registers\n        _mm_store_si128(pTrg + 8, xmm8);\n        _mm_store_si128(pTrg + 9, xmm9);\n        _mm_store_si128(pTrg + 10, xmm10);\n        _mm_store_si128(pTrg + 11, xmm11);\n        _mm_store_si128(pTrg + 12, xmm12);\n        _mm_store_si128(pTrg + 13, xmm13);\n        _mm_store_si128(pTrg + 14, xmm14);\n        _mm_store_si128(pTrg + 15, xmm15);\n#endif\n        pSrc += regsInLoop;\n        pTrg += regsInLoop;\n    }\n\n    // Copy in 16 byte steps\n    if (remainder >= 16)\n    {\n        size = remainder;\n        remainder = size & 15;\n        end = size >> 4;\n        for (size_t i = 0; i < end; ++i)\n        {\n            pTrg[i] = _mm_stream_load_si128(pSrc + i);\n        }\n    }\n\n    // Copy last bytes - shouldn't happen as strides are modulu 16\n    if (remainder)\n    {\n        __m128i temp = _mm_stream_load_si128(pSrc + end);\n\n        char *ps = (char *)(&temp);\n        char *pt = (char *)(pTrg + end);\n\n        for (size_t i = 0; i < remainder; ++i)\n        {\n            pt[i] = ps[i];\n        }\n    }\n\n    return d;\n}\n"
  },
  {
    "path": "common/DSUtilLite/growarray.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n// Class template: Re-sizable array.\n\n// To grow or shrink the array, call SetSize().\n// To pre-allocate the array, call Allocate().\n\n// Notes:\n// Copy constructor and assignment operator are private, to avoid throwing exceptions. (One could easily modify this.)\n// It is the caller's responsibility to release the objects in the array. The array's destuctor does not release them.\n// The array does not actually shrink when SetSize is called with a smaller size. Only the reported size changes.\n\n#pragma once\n\n#include <assert.h>\n#include \"DShowUtil.h\"\n\ntemplate <class T> class GrowableArray\n{\n  public:\n    GrowableArray() {}\n\n    virtual ~GrowableArray() { free(m_pArray); }\n\n    // Allocate: Reserves memory for the array, but does not increase the count.\n    HRESULT Allocate(DWORD alloc)\n    {\n        HRESULT hr = S_OK;\n        if (alloc > m_allocated || !m_pArray)\n        {\n            T *pNew = (T *)realloc(m_pArray, sizeof(T) * alloc);\n            if (!pNew)\n            {\n                free(m_pArray);\n                m_pArray = nullptr;\n                m_allocated = 0;\n                return E_OUTOFMEMORY;\n            }\n            m_pArray = pNew;\n            ZeroMemory(m_pArray + m_allocated, (alloc - m_allocated) * sizeof(T));\n            m_allocated = alloc;\n        }\n        return hr;\n    }\n\n    HRESULT Clear()\n    {\n        free(m_pArray);\n        m_pArray = nullptr;\n        m_count = m_allocated = 0;\n        return S_OK;\n    }\n\n    // SetSize: Changes the count, and grows the array if needed.\n    HRESULT SetSize(DWORD count)\n    {\n        HRESULT hr = S_OK;\n        if (count > m_allocated)\n        {\n            hr = Allocate(count);\n        }\n        if (SUCCEEDED(hr))\n        {\n            m_count = count;\n        }\n        return hr;\n    }\n\n    HRESULT Append(GrowableArray<T> *other) { return Append(other->Ptr(), other->GetCount()); }\n\n    HRESULT Append(const T *other, DWORD dwSize)\n    {\n        HRESULT hr = S_OK;\n        DWORD old = GetCount();\n        hr = SetSize(old + dwSize);\n        if (SUCCEEDED(hr))\n            memcpy(m_pArray + old, other, dwSize);\n\n        return S_OK;\n    }\n\n    HRESULT AppendZero(DWORD dwSize)\n    {\n        HRESULT hr = S_OK;\n        DWORD old = GetCount();\n        hr = SetSize(old + dwSize);\n        if (SUCCEEDED(hr))\n            memset(m_pArray + old, 0, dwSize);\n\n        return S_OK;\n    }\n\n    void Consume(DWORD dwSize)\n    {\n        ASSERT(dwSize <= m_count);\n\n        if (dwSize == m_count)\n            Clear();\n        else\n        {\n            memmove(m_pArray, m_pArray + dwSize, m_count - dwSize);\n            m_count -= dwSize;\n        }\n    }\n\n    DWORD GetCount() const { return m_count; }\n    DWORD GetAllocated() const { return m_allocated; }\n\n    // Accessor.\n    T &operator[](DWORD index)\n    {\n        assert(index < m_count);\n        return m_pArray[index];\n    }\n\n    // Const accessor.\n    const T &operator[](DWORD index) const\n    {\n        assert(index < m_count);\n        return m_pArray[index];\n    }\n\n    // Return the underlying array.\n    T *Ptr() { return m_pArray; }\n\n  protected:\n    GrowableArray &operator=(const GrowableArray &r);\n    GrowableArray(const GrowableArray &r);\n\n    T *m_pArray = nullptr;\n    DWORD m_count = 0;     // Nominal count.\n    DWORD m_allocated = 0; // Actual allocation size.\n};\n"
  },
  {
    "path": "common/DSUtilLite/lavf_log.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#define LOG_BUF_LEN 2048\ninline void lavf_log_callback(void *ptr, int level, const char *fmt, va_list vl)\n{\n    static int print_prefix = 1;\n    static int count;\n    static char line[LOG_BUF_LEN] = {0}, prev[LOG_BUF_LEN] = {0};\n\n    if (level > AV_LOG_VERBOSE)\n        return;\n\n    av_log_format_line(ptr, level, fmt, vl, line, sizeof(line), &print_prefix);\n\n    if (print_prefix && !strcmp(line, prev))\n    {\n        count++;\n        return;\n    }\n    if (count > 0)\n    {\n        DbgLog((LOG_CUSTOM1, level, L\"    Last message repeated %d times\", count));\n        count = 0;\n    }\n    size_t len = strnlen_s(line, LOG_BUF_LEN);\n    if (len > 0 && line[len - 1] == '\\n')\n    {\n        line[len - 1] = 0;\n    }\n\n    DbgLog((LOG_CUSTOM1, level, L\"%S\", line));\n    strncpy_s(prev, line, _TRUNCATE);\n}\n"
  },
  {
    "path": "common/DSUtilLite/locale.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"DShowUtil.h\"\n\n#include <string>\n#include <regex>\n#include <algorithm>\n\nstatic struct\n{\n    LPCSTR name, iso6392, iso6391, iso6392_2;\n    LCID lcid;\n} s_isolangs[] = // TODO : fill LCID !!!\n    {\n        // Based on ISO-639-2, sorted by primary language code. Some manual additions of deprecated tags.\n        {\"Afar\", \"aar\", \"aa\"},\n        {\"Abkhazian\", \"abk\", \"ab\"},\n        {\"Achinese\", \"ace\", nullptr},\n        {\"Acoli\", \"ach\", nullptr},\n        {\"Adangme\", \"ada\", nullptr},\n        {\"Adyghe\", \"ady\", nullptr},\n        {\"Afro-Asiatic (Other)\", \"afa\", nullptr},\n        {\"Afrihili\", \"afh\", nullptr},\n        {\"Afrikaans\", \"afr\", \"af\", nullptr, MAKELCID(MAKELANGID(LANG_AFRIKAANS, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Ainu\", \"ain\", nullptr},\n        {\"Akan\", \"aka\", \"ak\"},\n        {\"Akkadian\", \"akk\", nullptr},\n        {\"Albanian\", \"sqi\", \"sq\", \"alb\", MAKELCID(MAKELANGID(LANG_ALBANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Aleut\", \"ale\", nullptr},\n        {\"Algonquian languages\", \"alg\", nullptr},\n        {\"Southern Altai\", \"alt\", nullptr},\n        {\"Amharic\", \"amh\", \"am\"},\n        {\"English, Old (ca.450-1100)\", \"ang\", nullptr},\n        {\"Angika\", \"anp\", nullptr},\n        {\"Apache languages\", \"apa\", nullptr},\n        {\"Arabic\", \"ara\", \"ar\", nullptr, MAKELCID(MAKELANGID(LANG_ARABIC, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Aramaic\", \"arc\", nullptr},\n        {\"Aragonese\", \"arg\", \"an\"},\n        {\"Armenian\", \"arm\", \"hy\", \"hye\", MAKELCID(MAKELANGID(LANG_ARMENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Mapudungun\", \"arn\", nullptr},\n        {\"Arapaho\", \"arp\", nullptr},\n        {\"Artificial (Other)\", \"art\", nullptr},\n        {\"Arawak\", \"arw\", nullptr},\n        {\"Assamese\", \"asm\", \"as\", nullptr, MAKELCID(MAKELANGID(LANG_ASSAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Asturian; Bable\", \"ast\", nullptr},\n        {\"Athapascan languages\", \"ath\", nullptr},\n        {\"Australian languages\", \"aus\", nullptr},\n        {\"Avaric\", \"ava\", \"av\"},\n        {\"Avestan\", \"ave\", \"ae\"},\n        {\"Awadhi\", \"awa\", nullptr},\n        {\"Aymara\", \"aym\", \"ay\"},\n        {\"Azerbaijani\", \"aze\", \"az\", nullptr, MAKELCID(MAKELANGID(LANG_AZERI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Banda\", \"bad\", nullptr},\n        {\"Bamileke languages\", \"bai\", nullptr},\n        {\"Bashkir\", \"bak\", \"ba\", nullptr, MAKELCID(MAKELANGID(LANG_BASHKIR, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Baluchi\", \"bal\", nullptr},\n        {\"Bambara\", \"bam\", \"bm\"},\n        {\"Balinese\", \"ban\", nullptr},\n        {\"Basque\", \"baq\", \"eu\", \"eus\", MAKELCID(MAKELANGID(LANG_BASQUE, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Basa\", \"bas\", nullptr},\n        {\"Baltic (Other)\", \"bat\", nullptr},\n        {\"Beja\", \"bej\", nullptr},\n        {\"Belarusian\", \"bel\", \"be\", nullptr, MAKELCID(MAKELANGID(LANG_BELARUSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Bemba\", \"bem\", nullptr},\n        {\"Bengali\", \"ben\", \"bn\", nullptr, MAKELCID(MAKELANGID(LANG_BENGALI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Berber (Other)\", \"ber\", nullptr},\n        {\"Bhojpuri\", \"bho\", nullptr},\n        {\"Bihari\", \"bih\", \"bh\"},\n        {\"Bikol\", \"bik\", nullptr},\n        {\"Bini\", \"bin\", nullptr},\n        {\"Bislama\", \"bis\", \"bi\"},\n        {\"Siksika\", \"bla\", nullptr},\n        {\"Bantu (Other)\", \"bnt\", nullptr},\n        {\"Bosnian\", \"bos\", \"bs\"},\n        {\"Braj\", \"bra\", nullptr},\n        {\"Breton\", \"bre\", \"br\", nullptr, MAKELCID(MAKELANGID(LANG_BRETON, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Batak (Indonesia)\", \"btk\", nullptr},\n        {\"Buriat\", \"bua\", nullptr},\n        {\"Buginese\", \"bug\", nullptr},\n        {\"Bulgarian\", \"bul\", \"bg\", nullptr, MAKELCID(MAKELANGID(LANG_BULGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Burmese\", \"bur\", \"my\", \"mya\"},\n        {\"Blin\", \"byn\", nullptr},\n        {\"Caddo\", \"cad\", nullptr},\n        {\"Central American Indian (Other)\", \"cai\", nullptr},\n        {\"Carib\", \"car\", nullptr},\n        {\"Catalan\", \"cat\", \"ca\", nullptr, MAKELCID(MAKELANGID(LANG_CATALAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Caucasian (Other)\", \"cau\", nullptr},\n        {\"Cebuano\", \"ceb\", nullptr},\n        {\"Celtic (Other)\", \"cel\", nullptr},\n        {\"Chamorro\", \"cha\", \"ch\"},\n        {\"Chibcha\", \"chb\", nullptr},\n        {\"Chechen\", \"che\", \"ce\"},\n        {\"Chagatai\", \"chg\", nullptr},\n        {\"Chinese\", \"chi\", \"zh\", \"zho\", MAKELCID(MAKELANGID(LANG_CHINESE, SUBLANG_NEUTRAL), SORT_DEFAULT)},\n        {\"Chuukese\", \"chk\", nullptr},\n        {\"Mari\", \"chm\", nullptr},\n        {\"Chinook jargon\", \"chn\", nullptr},\n        {\"Choctaw\", \"cho\", nullptr},\n        {\"Chipewyan\", \"chp\", nullptr},\n        {\"Cherokee\", \"chr\", nullptr},\n        {\"Church Slavic\", \"chu\", \"cu\"},\n        {\"Chuvash\", \"chv\", \"cv\"},\n        {\"Cheyenne\", \"chy\", nullptr},\n        {\"Chamic languages\", \"cmc\", nullptr},\n        {\"Montenegrin\", \"cnr\", nullptr},\n        {\"Coptic\", \"cop\", nullptr},\n        {\"Cornish\", \"cor\", \"kw\"},\n        {\"Corsican\", \"cos\", \"co\", nullptr, MAKELCID(MAKELANGID(LANG_CORSICAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Creoles and pidgins, English-based\", \"cpe\", nullptr},\n        {\"Creoles and pidgins, French-based\", \"cpf\", nullptr},\n        {\"Creoles and pidgins, Portuguese-based\", \"cpp\", nullptr},\n        {\"Cree\", \"cre\", \"cr\"},\n        {\"Crimean Turkish\", \"crh\", nullptr},\n        {\"Creoles and pidgins (Other)\", \"crp\", nullptr},\n        {\"Kashubian\", \"csb\", nullptr},\n        {\"Cushitic (Other)\", \"cus\", nullptr},\n        {\"Czech\", \"cze\", \"cs\", \"ces\", MAKELCID(MAKELANGID(LANG_CZECH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Dakota\", \"dak\", nullptr},\n        {\"Danish\", \"dan\", \"da\", nullptr, MAKELCID(MAKELANGID(LANG_DANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Dargwa\", \"dar\", nullptr},\n        {\"Dayak\", \"day\", nullptr},\n        {\"Delaware\", \"del\", nullptr},\n        {\"Slave (Athapascan)\", \"den\", nullptr},\n        {\"Dogrib\", \"dgr\", nullptr},\n        {\"Dinka\", \"din\", nullptr},\n        {\"Divehi\", \"div\", \"dv\", nullptr, MAKELCID(MAKELANGID(LANG_DIVEHI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Dogri\", \"doi\", nullptr},\n        {\"Dravidian (Other)\", \"dra\", nullptr},\n        {\"Lower Sorbian\", \"dsb\", nullptr},\n        {\"Duala\", \"dua\", nullptr},\n        {\"Dutch, Middle (ca. 1050-1350)\", \"dum\", nullptr},\n        {\"Dutch\", \"dut\", \"nl\", \"nld\", MAKELCID(MAKELANGID(LANG_DUTCH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Dyula\", \"dyu\", nullptr},\n        {\"Dzongkha\", \"dzo\", \"dz\"},\n        {\"Efik\", \"efi\", nullptr},\n        {\"Egyptian (Ancient)\", \"egy\", nullptr},\n        {\"Ekajuk\", \"eka\", nullptr},\n        {\"Elamite\", \"elx\", nullptr},\n        {\"English\", \"eng\", \"en\", nullptr, MAKELCID(MAKELANGID(LANG_ENGLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"English, Middle (1100-1500)\", \"enm\", nullptr},\n        {\"Esperanto\", \"epo\", \"eo\"},\n        {\"Estonian\", \"est\", \"et\", nullptr, MAKELCID(MAKELANGID(LANG_ESTONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Ewe\", \"ewe\", \"ee\"},\n        {\"Ewondo\", \"ewo\", nullptr},\n        {\"Fang\", \"fan\", nullptr},\n        {\"Faroese\", \"fao\", \"fo\", nullptr, MAKELCID(MAKELANGID(LANG_FAEROESE, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Fanti\", \"fat\", nullptr},\n        {\"Fijian\", \"fij\", \"fj\"},\n        {\"Filipino\", \"fil\", nullptr},\n        {\"Finnish\", \"fin\", \"fi\", nullptr, MAKELCID(MAKELANGID(LANG_FINNISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Finno-Ugrian (Other)\", \"fiu\", nullptr},\n        {\"Fon\", \"fon\", nullptr},\n        {\"French\", \"fre\", \"fr\", \"fra\", MAKELCID(MAKELANGID(LANG_FRENCH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"French, Middle (ca.1400-1600)\", \"frm\", nullptr},\n        {\"French, Old (842-ca.1400)\", \"fro\", nullptr},\n        {\"Northern Frisian\", \"frr\", nullptr},\n        {\"Eastern Frisian\", \"frs\", nullptr},\n        {\"Frisian\", \"fry\", \"fy\", nullptr, MAKELCID(MAKELANGID(LANG_FRISIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Fulah\", \"ful\", \"ff\"},\n        {\"Friulian\", \"fur\", nullptr},\n        {\"Ga\", \"gaa\", nullptr},\n        {\"Gayo\", \"gay\", nullptr},\n        {\"Gbaya\", \"gba\", nullptr},\n        {\"Germanic (Other)\", \"gem\", nullptr},\n        {\"Georgian\", \"geo\", \"ka\", \"kat\", MAKELCID(MAKELANGID(LANG_GEORGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"German\", \"ger\", \"de\", \"deu\", MAKELCID(MAKELANGID(LANG_GERMAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Geez\", \"gez\", nullptr},\n        {\"Gilbertese\", \"gil\", nullptr},\n        {\"Gaelic; Scottish Gaelic\", \"gla\", \"gd\"},\n        {\"Irish\", \"gle\", \"ga\", nullptr, MAKELCID(MAKELANGID(LANG_IRISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Galician\", \"glg\", \"gl\", nullptr, MAKELCID(MAKELANGID(LANG_GALICIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Manx\", \"glv\", \"gv\"},\n        {\"German, Middle High (ca.1050-1500)\", \"gmh\", nullptr},\n        {\"German, Old High (ca.750-1050)\", \"goh\", nullptr},\n        {\"Gondi\", \"gon\", nullptr},\n        {\"Gorontalo\", \"gor\", nullptr},\n        {\"Gothic\", \"got\", nullptr},\n        {\"Grebo\", \"grb\", nullptr},\n        {\"Ancient Greek\", \"grc\", nullptr},\n        {\"Greek\", \"gre\", \"el\", \"ell\", MAKELCID(MAKELANGID(LANG_GREEK, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Guarani\", \"grn\", \"gn\"},\n        {\"Swiss German\", \"gsw\", nullptr},\n        {\"Gujarati\", \"guj\", \"gu\", nullptr, MAKELCID(MAKELANGID(LANG_GUJARATI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Gwichin\", \"gwi\", nullptr},\n        {\"Haida\", \"hai\", nullptr},\n        {\"Haitian\", \"hat\", \"ht\"},\n        {\"Hausa\", \"hau\", \"ha\", nullptr, MAKELCID(MAKELANGID(LANG_HAUSA, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Hawaiian\", \"haw\", nullptr},\n        {\"Hebrew\", \"heb\", \"he\", nullptr, MAKELCID(MAKELANGID(LANG_HEBREW, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Herero\", \"her\", \"hz\"},\n        {\"Hiligaynon\", \"hil\", nullptr},\n        {\"Himachali\", \"him\", nullptr},\n        {\"Hindi\", \"hin\", \"hi\", nullptr, MAKELCID(MAKELANGID(LANG_HINDI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Hittite\", \"hit\", nullptr},\n        {\"Hmong\", \"hmn\", nullptr},\n        {\"Hiri Motu\", \"hmo\", \"ho\"},\n        {\"Croatian\", \"hrv\", \"hr\", \"scr\", MAKELCID(MAKELANGID(LANG_CROATIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Upper Sorbian\", \"hsb\", nullptr},\n        {\"Hungarian\", \"hun\", \"hu\", nullptr, MAKELCID(MAKELANGID(LANG_HUNGARIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Hupa\", \"hup\", nullptr},\n        {\"Iban\", \"iba\", nullptr},\n        {\"Igbo\", \"ibo\", \"ig\", nullptr, MAKELCID(MAKELANGID(LANG_IGBO, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Icelandic\", \"ice\", \"is\", \"isl\", MAKELCID(MAKELANGID(LANG_ICELANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Ido\", \"ido\", \"io\"},\n        {\"Sichuan Yi\", \"iii\", \"ii\"},\n        {\"Ijo\", \"ijo\", nullptr},\n        {\"Inuktitut\", \"iku\", \"iu\", nullptr, MAKELCID(MAKELANGID(LANG_INUKTITUT, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Interlingue\", \"ile\", \"ie\"},\n        {\"Iloko\", \"ilo\", nullptr},\n        {\"Interlingua\", \"ina\", \"ia\"},\n        {\"Indic (Other)\", \"inc\", nullptr},\n        {\"Indonesian\", \"ind\", \"id\", nullptr, MAKELCID(MAKELANGID(LANG_INDONESIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Indo-European (Other)\", \"ine\", nullptr},\n        {\"Ingush\", \"inh\", nullptr},\n        {\"Inupiaq\", \"ipk\", \"ik\"},\n        {\"Iranian (Other)\", \"ira\", nullptr},\n        {\"Iroquoian languages\", \"iro\", nullptr},\n        {\"Italian\", \"ita\", \"it\", nullptr, MAKELCID(MAKELANGID(LANG_ITALIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Javanese\", \"jav\", \"jv\"},\n        {\"Lojban\", \"jbo\", nullptr},\n        {\"Japanese\", \"jpn\", \"ja\", nullptr, MAKELCID(MAKELANGID(LANG_JAPANESE, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Judeo-Persian\", \"jpr\", nullptr},\n        {\"Judeo-Arabic\", \"jrb\", nullptr},\n        {\"Kara-Kalpak\", \"kaa\", nullptr},\n        {\"Kabyle\", \"kab\", nullptr},\n        {\"Kachin\", \"kac\", nullptr},\n        {\"Greenlandic; Kalaallisut\", \"kal\", \"kl\", nullptr, MAKELCID(MAKELANGID(LANG_GREENLANDIC, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Kamba\", \"kam\", nullptr},\n        {\"Kannada\", \"kan\", \"kn\", nullptr, MAKELCID(MAKELANGID(LANG_KANNADA, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Karen\", \"kar\", nullptr},\n        {\"Kashmiri\", \"kas\", \"ks\", nullptr, MAKELCID(MAKELANGID(LANG_KASHMIRI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Kanuri\", \"kau\", \"kr\"},\n        {\"Kawi\", \"kaw\", nullptr},\n        {\"Kazakh\", \"kaz\", \"kk\", nullptr, MAKELCID(MAKELANGID(LANG_KAZAK, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Kabardian\", \"kbd\", nullptr},\n        {\"Khasi\", \"kha\", nullptr},\n        {\"Khoisan (Other)\", \"khi\", nullptr},\n        {\"Khmer\", \"khm\", \"km\", nullptr, MAKELCID(MAKELANGID(LANG_KHMER, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Khotanese\", \"kho\", nullptr},\n        {\"Kikuyu; Gikuyu\", \"kik\", \"ki\"},\n        {\"Kinyarwanda\", \"kin\", \"rw\", nullptr, MAKELCID(MAKELANGID(LANG_KINYARWANDA, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Kirghiz\", \"kir\", \"ky\"},\n        {\"Kimbundu\", \"kmb\", nullptr},\n        {\"Konkani\", \"kok\", nullptr, nullptr, MAKELCID(MAKELANGID(LANG_KONKANI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Komi\", \"kom\", \"kv\"},\n        {\"Kongo\", \"kon\", \"kg\"},\n        {\"Korean\", \"kor\", \"ko\", nullptr, MAKELCID(MAKELANGID(LANG_KOREAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Kosraean\", \"kos\", nullptr},\n        {\"Kpelle\", \"kpe\", nullptr},\n        {\"Karachay-Balkar\", \"krc\", nullptr},\n        {\"Karelian\", \"krl\", nullptr},\n        {\"Kru\", \"kro\", nullptr},\n        {\"Kurukh\", \"kru\", nullptr},\n        {\"Kwanyama, Kuanyama\", \"kua\", \"kj\"},\n        {\"Kumyk\", \"kum\", nullptr},\n        {\"Kurdish\", \"kur\", \"ku\"},\n        {\"Kutenai\", \"kut\", nullptr},\n        {\"Ladino\", \"lad\", nullptr},\n        {\"Lahnda\", \"lah\", nullptr},\n        {\"Lamba\", \"lam\", nullptr},\n        {\"Lao\", \"lao\", \"lo\", nullptr, MAKELCID(MAKELANGID(LANG_LAO, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Latin\", \"lat\", \"la\"},\n        {\"Latvian\", \"lav\", \"lv\", nullptr, MAKELCID(MAKELANGID(LANG_LATVIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Lezghian\", \"lez\", nullptr},\n        {\"Limburgan; Limburger; Limburgish\", \"lim\", \"li\"},\n        {\"Lingala\", \"lin\", \"ln\"},\n        {\"Lithuanian\", \"lit\", \"lt\", nullptr, MAKELCID(MAKELANGID(LANG_LITHUANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Mongo\", \"lol\", nullptr},\n        {\"Lozi\", \"loz\", nullptr},\n        {\"Luxembourgish; Letzeburgesch\", \"ltz\", \"lb\", nullptr, MAKELCID(MAKELANGID(LANG_LUXEMBOURGISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Luba-Lulua\", \"lua\", nullptr},\n        {\"Luba-Katanga\", \"lub\", \"lu\"},\n        {\"Ganda\", \"lug\", \"lg\"},\n        {\"Luiseno\", \"lui\", nullptr},\n        {\"Lunda\", \"lun\", nullptr},\n        {\"Luo (Kenya and Tanzania)\", \"luo\", nullptr},\n        {\"Lushai\", \"lus\", nullptr},\n        {\"Macedonian\", \"mac\", \"mk\", \"mkd\", MAKELCID(MAKELANGID(LANG_MACEDONIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Madurese\", \"mad\", nullptr},\n        {\"Magahi\", \"mag\", nullptr},\n        {\"Marshallese\", \"mah\", \"mh\"},\n        {\"Maithili\", \"mai\", nullptr},\n        {\"Makasar\", \"mak\", nullptr},\n        {\"Malayalam\", \"mal\", \"ml\", nullptr, MAKELCID(MAKELANGID(LANG_MALAYALAM, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Mandingo\", \"man\", nullptr},\n        {\"Maori\", \"mao\", \"mi\", \"mri\", MAKELCID(MAKELANGID(LANG_MAORI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Austronesian (Other)\", \"map\", nullptr},\n        {\"Marathi\", \"mar\", \"mr\", nullptr, MAKELCID(MAKELANGID(LANG_MARATHI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Masai\", \"mas\", nullptr},\n        {\"Malay\", \"may\", \"ms\", \"msa\", MAKELCID(MAKELANGID(LANG_MALAY, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Moksha\", \"mdf\", nullptr},\n        {\"Mandar\", \"mdr\", nullptr},\n        {\"Mende\", \"men\", nullptr},\n        {\"Irish, Middle (900-1200)\", \"mga\", nullptr},\n        {\"Micmac\", \"mic\", nullptr},\n        {\"Minangkabau\", \"min\", nullptr},\n        {\"Miscellaneous languages\", \"mis\", nullptr},\n        {\"Mon-Khmer (Other)\", \"mkh\", nullptr},\n        {\"Malagasy\", \"mlg\", \"mg\"},\n        {\"Maltese\", \"mlt\", \"mt\", nullptr, MAKELCID(MAKELANGID(LANG_MALTESE, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Manchu\", \"mnc\", nullptr},\n        {\"Manipuri\", \"mni\", nullptr, nullptr, MAKELCID(MAKELANGID(LANG_MANIPURI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Manobo languages\", \"mno\", nullptr},\n        {\"Mohawk\", \"moh\", nullptr, nullptr, MAKELCID(MAKELANGID(LANG_MOHAWK, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Moldavian\", \"mol\", \"mo\"}, // deprecated\n        {\"Mongolian\", \"mon\", \"mn\", nullptr, MAKELCID(MAKELANGID(LANG_MONGOLIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Mossi\", \"mos\", nullptr},\n        {\"Multiple languages\", \"mul\", nullptr},\n        {\"Munda languages\", \"mun\", nullptr},\n        {\"Creek\", \"mus\", nullptr},\n        {\"Mirandese\", \"mwl\", nullptr},\n        {\"Marwari\", \"mwr\", nullptr},\n        {\"Mayan languages\", \"myn\", nullptr},\n        {\"Erzya\", \"myv\", nullptr},\n        {\"Nahuatl\", \"nah\", nullptr},\n        {\"North American Indian (Other)\", \"nai\", nullptr},\n        {\"Neapolitan\", \"nap\", nullptr},\n        {\"Nauru\", \"nau\", \"na\"},\n        {\"Navaho, Navajo\", \"nav\", \"nv\"},\n        {\"Ndebele, South\", \"nbl\", \"nr\"},\n        {\"Ndebele, North\", \"nde\", \"nd\"},\n        {\"Ndonga\", \"ndo\", \"ng\"},\n        {\"Low German; Low Saxon\", \"nds\", nullptr},\n        {\"Nepali\", \"nep\", \"ne\", nullptr, MAKELCID(MAKELANGID(LANG_NEPALI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Newari\", \"new\", nullptr},\n        {\"Nias\", \"nia\", nullptr},\n        {\"Niger-Kordofanian (Other)\", \"nic\", nullptr},\n        {\"Niuean\", \"niu\", nullptr},\n        {\"Norwegian Nynorsk\", \"nno\", \"nn\"},\n        {\"Norwegian Bokml\", \"nob\", \"nb\"},\n        {\"Nogai\", \"nog\", nullptr},\n        {\"Norse, Old\", \"non\", nullptr},\n        {\"Norwegian\", \"nor\", \"no\", nullptr, MAKELCID(MAKELANGID(LANG_NORWEGIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"N'Ko\", \"nqo\", nullptr},\n        {\"Pedi; Sepedi; Northern Sotho\", \"nso\", nullptr, nullptr, MAKELCID(MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Nubian languages\", \"nub\", nullptr},\n        {\"Classical Newari\", \"nwc\", nullptr},\n        {\"Nyanja; Chichewa; Chewa\", \"nya\", \"ny\"},\n        {\"Nyamwezi\", \"nym\", nullptr},\n        {\"Nyankole\", \"nyn\", nullptr},\n        {\"Nyoro\", \"nyo\", nullptr},\n        {\"Nzima\", \"nzi\", nullptr},\n        {\"Occitan (post 1500}\", \"oci\", \"oc\", nullptr, MAKELCID(MAKELANGID(LANG_OCCITAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Ojibwa\", \"oji\", \"oj\"},\n        {\"Oriya\", \"ori\", \"or\"},\n        {\"Oromo\", \"orm\", \"om\"},\n        {\"Osage\", \"osa\", nullptr},\n        {\"Ossetian; Ossetic\", \"oss\", \"os\"},\n        {\"Turkish, Ottoman (1500-1928)\", \"ota\", nullptr},\n        {\"Otomian languages\", \"oto\", nullptr},\n        {\"Papuan (Other)\", \"paa\", nullptr},\n        {\"Pangasinan\", \"pag\", nullptr},\n        {\"Pahlavi\", \"pal\", nullptr},\n        {\"Pampanga\", \"pam\", nullptr},\n        {\"Panjabi\", \"pan\", \"pa\"},\n        {\"Papiamento\", \"pap\", nullptr},\n        {\"Palauan\", \"pau\", nullptr},\n        {\"Persian, Old (ca.600-400 B.C.)\", \"peo\", nullptr},\n        {\"Persian\", \"per\", \"fa\", \"fas\", MAKELCID(MAKELANGID(LANG_PERSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Philippine (Other)\", \"phi\", nullptr},\n        {\"Phoenician\", \"phn\", nullptr},\n        {\"Pali\", \"pli\", \"pi\"},\n        {\"Portuguese (Brazil)\", \"pob\", \"pb\"}, // deprecated/unofficial\n        {\"Polish\", \"pol\", \"pl\", nullptr, MAKELCID(MAKELANGID(LANG_POLISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Pohnpeian\", \"pon\", nullptr},\n        {\"Portuguese\", \"por\", \"pt\", nullptr, MAKELCID(MAKELANGID(LANG_PORTUGUESE, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Prakrit languages\", \"pra\", nullptr},\n        {\"Provenal, Old (to 1500)\", \"pro\", nullptr},\n        {\"Pushto\", \"pus\", \"ps\"},\n        {\"Quechua\", \"que\", \"qu\", nullptr, MAKELCID(MAKELANGID(LANG_QUECHUA, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Rajasthani\", \"raj\", nullptr},\n        {\"Rapanui\", \"rap\", nullptr},\n        {\"Rarotongan\", \"rar\", nullptr},\n        {\"Romance (Other)\", \"roa\", nullptr},\n        {\"Romansh\", \"roh\", \"rm\"},\n        {\"Romany\", \"rom\", nullptr},\n        {\"Romanian\", \"rum\", \"ro\", \"ron\", MAKELCID(MAKELANGID(LANG_ROMANIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Rundi\", \"run\", \"rn\"},\n        {\"Aromanian\", \"rup\", nullptr},\n        {\"Russian\", \"rus\", \"ru\", nullptr, MAKELCID(MAKELANGID(LANG_RUSSIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Sandawe\", \"sad\", nullptr},\n        {\"Sango\", \"sag\", \"sg\"},\n        {\"Yakut\", \"sah\", nullptr, nullptr, MAKELCID(MAKELANGID(LANG_YAKUT, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"South American Indian (Other)\", \"sai\", nullptr},\n        {\"Salishan languages\", \"sal\", nullptr},\n        {\"Samaritan Aramaic\", \"sam\", nullptr},\n        {\"Sanskrit\", \"san\", \"sa\", nullptr, MAKELCID(MAKELANGID(LANG_SANSKRIT, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Sasak\", \"sas\", nullptr},\n        {\"Santali\", \"sat\", nullptr},\n        {\"Sicilian\", \"scn\", nullptr},\n        {\"Scots\", \"sco\", nullptr},\n        {\"Selkup\", \"sel\", nullptr},\n        {\"Semitic (Other)\", \"sem\", nullptr},\n        {\"Irish, Old (to 900)\", \"sga\", nullptr},\n        {\"Sign languages\", \"sgn\", nullptr},\n        {\"Shan\", \"shn\", nullptr},\n        {\"Sidamo\", \"sid\", nullptr},\n        {\"Sinhalese\", \"sin\", \"si\", nullptr, MAKELCID(MAKELANGID(LANG_SINHALESE, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Siouan languages\", \"sio\", nullptr},\n        {\"Sino-Tibetan (Other)\", \"sit\", nullptr},\n        {\"Slavic (Other)\", \"sla\", nullptr},\n        {\"Slovak\", \"slo\", \"sk\", \"slk\", MAKELCID(MAKELANGID(LANG_SLOVAK, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Slovenian\", \"slv\", \"sl\", nullptr, MAKELCID(MAKELANGID(LANG_SLOVENIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Southern Sami\", \"sma\", nullptr},\n        {\"Northern Sami\", \"sme\", \"se\"},\n        {\"Sami languages (Other)\", \"smi\", nullptr},\n        {\"Lule Sami\", \"smj\", nullptr},\n        {\"Inari Sami\", \"smn\", nullptr},\n        {\"Samoan\", \"smo\", \"sm\"},\n        {\"Skolt Sami\", \"sms\", nullptr},\n        {\"Shona\", \"sna\", \"sn\"},\n        {\"Sindhi\", \"snd\", \"sd\", nullptr, MAKELCID(MAKELANGID(LANG_SINDHI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Soninke\", \"snk\", nullptr},\n        {\"Sogdian\", \"sog\", nullptr},\n        {\"Somali\", \"som\", \"so\"},\n        {\"Songhai\", \"son\", nullptr},\n        {\"Sotho, Southern\", \"sot\", \"st\", nullptr, MAKELCID(MAKELANGID(LANG_SOTHO, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Spanish\", \"spa\", \"es\", \"esp\", MAKELCID(MAKELANGID(LANG_SPANISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Sardinian\", \"srd\", \"sc\"},\n        {\"Sranan Tongo\", \"srn\", nullptr},\n        {\"Serbian\", \"srp\", \"sr\", \"scc\", MAKELCID(MAKELANGID(LANG_SERBIAN_NEUTRAL, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Serer\", \"srr\", nullptr},\n        {\"Nilo-Saharan (Other)\", \"ssa\", nullptr},\n        {\"Swati\", \"ssw\", \"ss\"},\n        {\"Sukuma\", \"suk\", nullptr},\n        {\"Sundanese\", \"sun\", \"su\"},\n        {\"Susu\", \"sus\", nullptr},\n        {\"Sumerian\", \"sux\", nullptr},\n        {\"Swahili\", \"swa\", \"sw\", nullptr, MAKELCID(MAKELANGID(LANG_SWAHILI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Swedish\", \"swe\", \"sv\", nullptr, MAKELCID(MAKELANGID(LANG_SWEDISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Classical Syriac\", \"syc\", nullptr},\n        {\"Syriac\", \"syr\", nullptr, nullptr, MAKELCID(MAKELANGID(LANG_SYRIAC, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Tahitian\", \"tah\", \"ty\"},\n        {\"Tai (Other)\", \"tai\", nullptr},\n        {\"Tamil\", \"tam\", \"ta\", nullptr, MAKELCID(MAKELANGID(LANG_TAMIL, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Tatar\", \"tat\", \"tt\", nullptr, MAKELCID(MAKELANGID(LANG_TATAR, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Telugu\", \"tel\", \"te\", nullptr, MAKELCID(MAKELANGID(LANG_TELUGU, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Timne\", \"tem\", nullptr},\n        {\"Tereno\", \"ter\", nullptr},\n        {\"Tetum\", \"tet\", nullptr},\n        {\"Tajik\", \"tgk\", \"tg\", nullptr, MAKELCID(MAKELANGID(LANG_TAJIK, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Tagalog\", \"tgl\", \"tl\"},\n        {\"Thai\", \"tha\", \"th\", nullptr, MAKELCID(MAKELANGID(LANG_THAI, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Tibetan\", \"tib\", \"bo\", \"bod\", MAKELCID(MAKELANGID(LANG_TIBETAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Tigre\", \"tig\", nullptr},\n        {\"Tigrinya\", \"tir\", \"ti\", nullptr, MAKELCID(MAKELANGID(LANG_TIGRIGNA, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Tiv\", \"tiv\", nullptr},\n        {\"Tokelau\", \"tkl\", nullptr},\n        {\"Klingon\", \"tlh\", nullptr},\n        {\"Tlingit\", \"tli\", nullptr},\n        {\"Tamashek\", \"tmh\", nullptr},\n        {\"Tonga (Nyasa)\", \"tog\", nullptr},\n        {\"Tonga (Tonga Islands)\", \"ton\", \"to\"},\n        {\"Tok Pisin\", \"tpi\", nullptr},\n        {\"Tsimshian\", \"tsi\", nullptr},\n        {\"Tswana\", \"tsn\", \"tn\", nullptr, MAKELCID(MAKELANGID(LANG_TSWANA, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Tsonga\", \"tso\", \"ts\"},\n        {\"Turkmen\", \"tuk\", \"tk\", nullptr, MAKELCID(MAKELANGID(LANG_TURKMEN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Tumbuka\", \"tum\", nullptr},\n        {\"Tupi languages\", \"tup\", nullptr},\n        {\"Turkish\", \"tur\", \"tr\", nullptr, MAKELCID(MAKELANGID(LANG_TURKISH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Altaic (Other)\", \"tut\", nullptr},\n        {\"Tuvalu\", \"tvl\", nullptr},\n        {\"Twi\", \"twi\", \"tw\"},\n        {\"Tuvinian\", \"tyv\", nullptr},\n        {\"Udmurt\", \"udm\", nullptr},\n        {\"Ugaritic\", \"uga\", nullptr},\n        {\"Uighur\", \"uig\", \"ug\", nullptr, MAKELCID(MAKELANGID(LANG_UIGHUR, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Ukrainian\", \"ukr\", \"uk\", nullptr, MAKELCID(MAKELANGID(LANG_UKRAINIAN, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Umbundu\", \"umb\", nullptr},\n        {\"Undetermined\", \"und\", nullptr},\n        {\"Urdu\", \"urd\", \"ur\", nullptr, MAKELCID(MAKELANGID(LANG_URDU, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Uzbek\", \"uzb\", \"uz\", nullptr, MAKELCID(MAKELANGID(LANG_UZBEK, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Vai\", \"vai\", nullptr},\n        {\"Venda\", \"ven\", \"ve\"},\n        {\"Vietnamese\", \"vie\", \"vi\", nullptr, MAKELCID(MAKELANGID(LANG_VIETNAMESE, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Volapk\", \"vol\", \"vo\"},\n        {\"Votic\", \"vot\", nullptr},\n        {\"Wakashan languages\", \"wak\", nullptr},\n        {\"Walamo\", \"wal\", nullptr},\n        {\"Waray\", \"war\", nullptr},\n        {\"Washo\", \"was\", nullptr},\n        {\"Welsh\", \"wel\", \"cy\", \"cym\", MAKELCID(MAKELANGID(LANG_WELSH, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Sorbian languages\", \"wen\", nullptr},\n        {\"Walloon\", \"wln\", \"wa\"},\n        {\"Wolof\", \"wol\", \"wo\", nullptr, MAKELCID(MAKELANGID(LANG_WOLOF, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Kalmyk\", \"xal\", nullptr},\n        {\"Xhosa\", \"xho\", \"xh\", nullptr, MAKELCID(MAKELANGID(LANG_XHOSA, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Yao\", \"yao\", nullptr},\n        {\"Yapese\", \"yap\", nullptr},\n        {\"Yiddish\", \"yid\", \"yi\"},\n        {\"Yoruba\", \"yor\", \"yo\", nullptr, MAKELCID(MAKELANGID(LANG_YORUBA, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Yupik languages\", \"ypk\", nullptr},\n        {\"Zapotec\", \"zap\", nullptr},\n        {\"Blissymbols\", \"zbl\", nullptr},\n        {\"Zenaga\", \"zen\", nullptr},\n        {\"Standard Moroccan Tamazight\", \"zgh\", nullptr},\n        {\"Zhuang; Chuang\", \"zha\", \"za\"},\n        {\"Zande\", \"znd\", nullptr},\n        {\"Zulu\", \"zul\", \"zu\", nullptr, MAKELCID(MAKELANGID(LANG_ZULU, SUBLANG_DEFAULT), SORT_DEFAULT)},\n        {\"Zuni\", \"zun\", nullptr},\n        {\"Zaza\", \"zza\", nullptr},\n        {nullptr, nullptr, nullptr},\n        {\"No subtitles\", \"---\", nullptr, nullptr, (LCID)LCID_NOSUBTITLES},\n};\n\nstd::string ISO6391ToLanguage(LPCSTR code)\n{\n    CHAR tmp[2 + 1];\n    strncpy_s(tmp, code, 2);\n    tmp[2] = 0;\n    _strlwr_s(tmp);\n    for (size_t i = 0, j = countof(s_isolangs); i < j; i++)\n    {\n        if (s_isolangs[i].iso6391 && !strcmp(s_isolangs[i].iso6391, tmp))\n        {\n            std::string ret = std::string(s_isolangs[i].name);\n            size_t i = ret.find(';');\n            if (i != std::string::npos)\n            {\n                ret = ret.substr(0, i);\n            }\n            return ret;\n        }\n    }\n    return std::string();\n}\n\nstd::string ISO6392ToLanguage(LPCSTR code)\n{\n    CHAR tmp[3 + 1];\n    strncpy_s(tmp, code, 3);\n    tmp[3] = 0;\n    _strlwr_s(tmp);\n    for (size_t i = 0, j = countof(s_isolangs); i < j; i++)\n    {\n        if ((s_isolangs[i].iso6392 && !strcmp(s_isolangs[i].iso6392, tmp)) ||\n            (s_isolangs[i].iso6392_2 && !strcmp(s_isolangs[i].iso6392_2, tmp)))\n        {\n            std::string ret = std::string(s_isolangs[i].name);\n            size_t i = ret.find(';');\n            if (i != std::string::npos)\n            {\n                ret = ret.substr(0, i);\n            }\n            return ret;\n        }\n    }\n    return std::string();\n}\n\nstd::string ProbeLangForLanguage(LPCSTR code)\n{\n    if (strlen(code) == 3)\n    {\n        return ISO6392ToLanguage(code);\n    }\n    else if (strlen(code) >= 2)\n    {\n        return ISO6391ToLanguage(code);\n    }\n    return std::string();\n}\n\nstatic std::string ISO6392Check(LPCSTR lang)\n{\n    CHAR tmp[3 + 1];\n    strncpy_s(tmp, lang, 3);\n    tmp[3] = 0;\n    _strlwr_s(tmp);\n    for (size_t i = 0, j = countof(s_isolangs); i < j; i++)\n    {\n        if ((s_isolangs[i].iso6392 && !strcmp(s_isolangs[i].iso6392, tmp)) ||\n            (s_isolangs[i].iso6392_2 && !strcmp(s_isolangs[i].iso6392_2, tmp)))\n        {\n            return std::string(s_isolangs[i].iso6392);\n        }\n    }\n    return std::string(tmp);\n}\n\nstatic std::string LanguageToISO6392(LPCSTR code)\n{\n    for (size_t i = 0, j = countof(s_isolangs); i < j; i++)\n    {\n        if ((s_isolangs[i].name && !_stricmp(s_isolangs[i].name, code)))\n        {\n            return std::string(s_isolangs[i].iso6392);\n        }\n    }\n    return std::string();\n}\n\nstd::string ProbeForISO6392(LPCSTR lang)\n{\n    std::string isoLang;\n    if (strlen(lang) == 2)\n    {\n        isoLang = ISO6391To6392(lang);\n    }\n    else if (strlen(lang) == 3)\n    {\n        isoLang = ISO6392Check(lang);\n    }\n    else if (strlen(lang) > 3)\n    {\n        isoLang = LanguageToISO6392(lang);\n        if (isoLang.empty())\n        {\n            std::regex ogmRegex(\"\\\\[([[:alpha:]]{3})\\\\]\");\n            std::cmatch res;\n            bool found = std::regex_search(lang, res, ogmRegex);\n            if (found && !res[1].str().empty())\n            {\n                isoLang = ISO6392Check(res[1].str().c_str());\n            }\n        }\n    }\n    if (isoLang.empty())\n        isoLang = std::string(lang);\n    return isoLang;\n}\n\nLCID ISO6391ToLcid(LPCSTR code)\n{\n    CHAR tmp[2 + 1];\n    strncpy_s(tmp, code, 2);\n    tmp[2] = 0;\n    _strlwr_s(tmp);\n    for (size_t i = 0, j = countof(s_isolangs); i < j; i++)\n    {\n        if (s_isolangs[i].iso6391 && !strcmp(s_isolangs[i].iso6391, tmp))\n        {\n            return s_isolangs[i].lcid;\n        }\n    }\n    return 0;\n}\n\nLCID ISO6392ToLcid(LPCSTR code)\n{\n    CHAR tmp[3 + 1];\n    strncpy_s(tmp, code, 3);\n    tmp[3] = 0;\n    _strlwr_s(tmp);\n    for (size_t i = 0, j = countof(s_isolangs); i < j; i++)\n    {\n        if ((s_isolangs[i].iso6392 && !strcmp(s_isolangs[i].iso6392, tmp)) ||\n            (s_isolangs[i].iso6392_2 && !strcmp(s_isolangs[i].iso6392_2, tmp)))\n        {\n            return s_isolangs[i].lcid;\n        }\n    }\n    return 0;\n}\n\nstd::string ISO6391To6392(LPCSTR code)\n{\n    CHAR tmp[2 + 1];\n    strncpy_s(tmp, code, 2);\n    tmp[2] = 0;\n    _strlwr_s(tmp);\n    for (size_t i = 0, j = countof(s_isolangs); i < j; i++)\n    {\n        if (s_isolangs[i].iso6391 && !strcmp(s_isolangs[i].iso6391, tmp))\n        {\n            return s_isolangs[i].iso6392;\n        }\n    }\n    return std::string(code);\n}\n\nstd::string ISO6392To6391(LPCSTR code)\n{\n    CHAR tmp[3 + 1];\n    strncpy_s(tmp, code, 3);\n    tmp[3] = 0;\n    _strlwr_s(tmp);\n    for (size_t i = 0, j = countof(s_isolangs); i < j; i++)\n    {\n        if ((s_isolangs[i].iso6392 && !strcmp(s_isolangs[i].iso6392, tmp)) ||\n            (s_isolangs[i].iso6392_2 && !strcmp(s_isolangs[i].iso6392_2, tmp)))\n        {\n            return s_isolangs[i].iso6391;\n        }\n    }\n    return std::string();\n}\n\nLCID ProbeLangForLCID(LPCSTR code)\n{\n    if (strlen(code) == 3)\n    {\n        return ISO6392ToLcid(code);\n    }\n    else if (strlen(code) >= 2)\n    {\n        return ISO6391ToLcid(code);\n    }\n    return 0;\n}\n"
  },
  {
    "path": "common/DSUtilLite/rand_sse.h",
    "content": "// Based on rand_sse at\n// http://software.intel.com/en-us/articles/fast-random-number-generator-on-the-intel-pentiumr-4-processor/\n\n#include <emmintrin.h>\n\n__declspec(align(16)) static __m128i cur_seed;\n\nvoid srand_sse(unsigned int seed)\n{\n    cur_seed = _mm_set_epi32(seed, seed + 1, seed, seed + 1);\n}\n\ninline void rand_sse(int *result)\n{\n    __declspec(align(16)) __m128i cur_seed_split;\n    __declspec(align(16)) __m128i multiplier;\n    __declspec(align(16)) __m128i adder;\n    __declspec(align(16)) __m128i mod_mask;\n    __declspec(align(16)) __m128i sra_mask;\n    __declspec(align(16)) __m128i sseresult;\n    __declspec(align(16)) static const unsigned int mult[4] = {214013, 17405, 214013, 69069};\n    __declspec(align(16)) static const unsigned int gadd[4] = {2531011, 10395331, 13737667, 1};\n    __declspec(align(16)) static const unsigned int mask[4] = {0xFFFFFFFF, 0, 0xFFFFFFFF, 0};\n    __declspec(align(16)) static const unsigned int masklo[4] = {0x00007FFF, 0x00007FFF, 0x00007FFF, 0x00007FFF};\n\n    adder = _mm_load_si128((__m128i *)gadd);\n    multiplier = _mm_load_si128((__m128i *)mult);\n    mod_mask = _mm_load_si128((__m128i *)mask);\n    sra_mask = _mm_load_si128((__m128i *)masklo);\n    cur_seed_split = _mm_shuffle_epi32(cur_seed, _MM_SHUFFLE(2, 3, 0, 1));\n\n    cur_seed = _mm_mul_epu32(cur_seed, multiplier);\n    multiplier = _mm_shuffle_epi32(multiplier, _MM_SHUFFLE(2, 3, 0, 1));\n    cur_seed_split = _mm_mul_epu32(cur_seed_split, multiplier);\n\n    cur_seed = _mm_and_si128(cur_seed, mod_mask);\n    cur_seed_split = _mm_and_si128(cur_seed_split, mod_mask);\n    cur_seed_split = _mm_shuffle_epi32(cur_seed_split, _MM_SHUFFLE(2, 3, 0, 1));\n    cur_seed = _mm_or_si128(cur_seed, cur_seed_split);\n    cur_seed = _mm_add_epi32(cur_seed, adder);\n\n    sseresult = _mm_srai_epi32(cur_seed, 16);\n    sseresult = _mm_and_si128(sseresult, sra_mask);\n    _mm_storeu_si128((__m128i *)result, sseresult);\n\n    return;\n}\n"
  },
  {
    "path": "common/DSUtilLite/registry.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"registry.h\"\n\nbool CreateRegistryKey(HKEY hKeyRoot, LPCTSTR pszSubKey)\n{\n    HKEY hKey;\n    LONG lRet;\n\n    lRet = RegCreateKeyEx(hKeyRoot, pszSubKey, 0, nullptr, REG_OPTION_NON_VOLATILE, KEY_WRITE, nullptr, &hKey, nullptr);\n\n    if (lRet == ERROR_SUCCESS)\n    {\n        RegCloseKey(hKey);\n        hKey = (HKEY) nullptr;\n        return true;\n    }\n\n    SetLastError((DWORD)lRet);\n    return false;\n}\n\nCRegistry::CRegistry()\n{\n}\n\nCRegistry::CRegistry(HKEY hkeyRoot, LPCTSTR pszSubKey, HRESULT &hr, BOOL bReadOnly, BOOL b64Bit)\n{\n    hr = Open(hkeyRoot, pszSubKey, bReadOnly, b64Bit);\n}\n\nCRegistry::~CRegistry()\n{\n    if (m_key)\n        RegCloseKey(*m_key);\n    delete m_key;\n}\n\nHRESULT CRegistry::Open(HKEY hkeyRoot, LPCTSTR pszSubKey, BOOL bReadOnly, BOOL b64Bit)\n{\n    LONG lRet;\n\n    if (m_key != nullptr)\n    {\n        return E_UNEXPECTED;\n    }\n\n    m_key = new HKEY();\n    REGSAM sam = bReadOnly ? KEY_READ : KEY_READ | KEY_WRITE;\n    if (b64Bit)\n        sam |= KEY_WOW64_64KEY;\n    lRet = RegOpenKeyEx(hkeyRoot, pszSubKey, 0, sam, m_key);\n    if (lRet != ERROR_SUCCESS)\n    {\n        delete m_key;\n        m_key = nullptr;\n        return E_FAIL;\n    }\n    return S_OK;\n}\n\nstd::wstring CRegistry::ReadString(LPCTSTR pszKey, HRESULT &hr)\n{\n    LONG lRet;\n    DWORD dwSize;\n    std::wstring result;\n\n    hr = S_OK;\n\n    if (m_key == nullptr)\n    {\n        hr = E_UNEXPECTED;\n        return result;\n    }\n\n    lRet = RegQueryValueEx(*m_key, pszKey, nullptr, nullptr, nullptr, &dwSize);\n\n    if (lRet == ERROR_SUCCESS)\n    {\n        // Alloc Buffer to fit the data\n        WCHAR *buffer = (WCHAR *)CoTaskMemAlloc(dwSize);\n        if (!buffer)\n        {\n            hr = E_OUTOFMEMORY;\n            return result;\n        }\n        memset(buffer, 0, dwSize);\n        lRet = RegQueryValueEx(*m_key, pszKey, nullptr, nullptr, (LPBYTE)buffer, &dwSize);\n        result = std::wstring(buffer);\n        CoTaskMemFree(buffer);\n    }\n\n    if (lRet != ERROR_SUCCESS)\n    {\n        hr = E_FAIL;\n    }\n\n    return result;\n}\n\nHRESULT CRegistry::WriteString(LPCTSTR pszKey, const LPCTSTR pszValue)\n{\n    LONG lRet;\n    HRESULT hr;\n\n    hr = S_OK;\n\n    if (m_key == nullptr)\n    {\n        return E_UNEXPECTED;\n    }\n\n    lRet = RegSetValueEx(*m_key, pszKey, 0, REG_SZ, (const BYTE *)pszValue,\n                         (DWORD)((wcslen(pszValue) + 1) * sizeof(WCHAR)));\n    if (lRet != ERROR_SUCCESS)\n    {\n        return E_FAIL;\n    }\n    return S_OK;\n}\n\nDWORD CRegistry::ReadDWORD(LPCTSTR pszKey, HRESULT &hr)\n{\n    LONG lRet;\n    DWORD dwSize = sizeof(DWORD);\n    DWORD dwVal = 0;\n\n    hr = S_OK;\n\n    if (m_key == nullptr)\n    {\n        hr = E_UNEXPECTED;\n        return 0;\n    }\n\n    lRet = RegQueryValueEx(*m_key, pszKey, 0, nullptr, (LPBYTE)&dwVal, &dwSize);\n\n    if (lRet != ERROR_SUCCESS)\n    {\n        hr = E_FAIL;\n    }\n\n    return dwVal;\n}\n\nHRESULT CRegistry::WriteDWORD(LPCTSTR pszKey, DWORD dwValue)\n{\n    LONG lRet;\n    HRESULT hr;\n\n    hr = S_OK;\n\n    if (m_key == nullptr)\n    {\n        return E_UNEXPECTED;\n    }\n\n    lRet = RegSetValueEx(*m_key, pszKey, 0, REG_DWORD, (const BYTE *)&dwValue, sizeof(dwValue));\n    if (lRet != ERROR_SUCCESS)\n    {\n        return E_FAIL;\n    }\n    return S_OK;\n}\n\nBOOL CRegistry::ReadBOOL(LPCTSTR pszKey, HRESULT &hr)\n{\n    DWORD dwVal = ReadDWORD(pszKey, hr);\n    return dwVal ? TRUE : FALSE;\n}\n\nHRESULT CRegistry::WriteBOOL(LPCTSTR pszKey, BOOL bValue)\n{\n    return WriteDWORD(pszKey, bValue);\n}\n\nBYTE *CRegistry::ReadBinary(LPCTSTR pszKey, DWORD &dwSize, HRESULT &hr)\n{\n    LONG lRet;\n    BYTE *result = nullptr;\n\n    hr = S_OK;\n\n    if (m_key == nullptr)\n    {\n        hr = E_UNEXPECTED;\n        return result;\n    }\n\n    lRet = RegQueryValueEx(*m_key, pszKey, nullptr, nullptr, nullptr, &dwSize);\n\n    if (lRet == ERROR_SUCCESS)\n    {\n        // Alloc Buffer to fit the data\n        result = (BYTE *)CoTaskMemAlloc(dwSize);\n        if (!result)\n        {\n            hr = E_OUTOFMEMORY;\n            return result;\n        }\n        memset(result, 0, dwSize);\n        lRet = RegQueryValueEx(*m_key, pszKey, nullptr, nullptr, (LPBYTE)result, &dwSize);\n    }\n\n    if (lRet != ERROR_SUCCESS)\n    {\n        hr = E_FAIL;\n        CoTaskMemFree(result);\n        result = nullptr;\n    }\n\n    return result;\n}\n\nHRESULT CRegistry::WriteBinary(LPCTSTR pszKey, const BYTE *pbValue, int iLen)\n{\n    LONG lRet;\n    HRESULT hr;\n\n    hr = S_OK;\n\n    if (m_key == nullptr)\n    {\n        return E_UNEXPECTED;\n    }\n\n    lRet = RegSetValueEx(*m_key, pszKey, 0, REG_BINARY, (const BYTE *)pbValue, iLen);\n    if (lRet != ERROR_SUCCESS)\n    {\n        return E_FAIL;\n    }\n    return S_OK;\n}\n\nHRESULT CRegistry::DeleteKey(LPCTSTR pszKey)\n{\n    LONG lRet;\n\n    if (m_key == nullptr)\n    {\n        return E_UNEXPECTED;\n    }\n    lRet = RegDeleteValue(*m_key, pszKey);\n    if (lRet != ERROR_SUCCESS)\n    {\n        return E_FAIL;\n    }\n    return S_OK;\n}\n"
  },
  {
    "path": "common/DSUtilLite/registry.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <string>\n\nbool CreateRegistryKey(HKEY hKeyRoot, LPCTSTR pszSubKey);\n\nclass CRegistry\n{\n  public:\n    CRegistry();\n    CRegistry(HKEY hkeyRoot, LPCTSTR pszSubKey, HRESULT &hr, BOOL bReadOnly = FALSE, BOOL b64Bit = TRUE);\n    ~CRegistry();\n\n    HRESULT Open(HKEY hkeyRoot, LPCTSTR pszSubKey, BOOL bReadOnly = FALSE, BOOL b64Bit = TRUE);\n\n    std::wstring ReadString(LPCTSTR pszKey, HRESULT &hr);\n    HRESULT WriteString(LPCTSTR pszKey, LPCTSTR pszValue);\n\n    DWORD ReadDWORD(LPCTSTR pszKey, HRESULT &hr);\n    HRESULT WriteDWORD(LPCTSTR pszKey, DWORD dwValue);\n\n    BOOL ReadBOOL(LPCTSTR pszKey, HRESULT &hr);\n    HRESULT WriteBOOL(LPCTSTR pszKey, BOOL bValue);\n\n    BYTE *ReadBinary(LPCTSTR pszKey, DWORD &dwSize, HRESULT &hr);\n    HRESULT WriteBinary(LPCTSTR pszKey, const BYTE *pbValue, int iLen);\n\n    HRESULT DeleteKey(LPCTSTR pszKey);\n\n  private:\n    HKEY *m_key = nullptr;\n};\n"
  },
  {
    "path": "common/DSUtilLite/stdafx.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#include \"stdafx.h\"\n"
  },
  {
    "path": "common/DSUtilLite/stdafx.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"common_defines.h\"\n\n#include <Windows.h>\n#include <Objbase.h>\n#include <tchar.h>\n#include <uuids.h>\n\n#include <Commctrl.h>\n\n#include \"streams.h\"\n\n// TODO: reference additional headers your program requires here\n"
  },
  {
    "path": "common/DSUtilLite/timer.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include <intrin.h>\n\n#define START_TIMER \\\n    uint64_t tend;  \\\n    uint64_t tstart = __rdtsc();\n\n#define STOP_TIMER(id)                                                                                              \\\n    tend = __rdtsc();                                                                                               \\\n    {                                                                                                               \\\n        static uint64_t tsum = 0;                                                                                   \\\n        static int tcount = 0;                                                                                      \\\n        static int tskip_count = 0;                                                                                 \\\n        if (tcount < 2 || tend - tstart < 8 * tsum / tcount || tend - tstart < 2000)                                \\\n        {                                                                                                           \\\n            tsum += tend - tstart;                                                                                  \\\n            tcount++;                                                                                               \\\n        }                                                                                                           \\\n        else                                                                                                        \\\n            tskip_count++;                                                                                          \\\n        if (((tcount + tskip_count) & (tcount + tskip_count - 1)) == 0)                                             \\\n        {                                                                                                           \\\n            debugprintf(L\"%I64u decicycles in %S, %d runs, %d skips\", tsum * 10 / tcount, id, tcount, tskip_count); \\\n        }                                                                                                           \\\n    }\n"
  },
  {
    "path": "common/baseclasses/amextra.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: AMExtra.cpp\n//\n// Desc: DirectShow base classes - implements CRenderedInputPin class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>  // DirectShow base class definitions\n#include <mmsystem.h> // Needed for definition of timeGetTime\n#include <limits.h>   // Standard data type limit definitions\n#include <measure.h>  // Used for time critical log functions\n\n#include \"amextra.h\"\n\n#pragma warning(disable : 4355)\n\n//  Implements CRenderedInputPin class\n\nCRenderedInputPin::CRenderedInputPin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                                     __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CBaseInputPin(pObjectName, pFilter, pLock, phr, pName)\n    , m_bAtEndOfStream(FALSE)\n    , m_bCompleteNotified(FALSE)\n{\n}\n#ifdef UNICODE\nCRenderedInputPin::CRenderedInputPin(__in_opt LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                                     __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CBaseInputPin(pObjectName, pFilter, pLock, phr, pName)\n    , m_bAtEndOfStream(FALSE)\n    , m_bCompleteNotified(FALSE)\n{\n}\n#endif\n\n// Flush end of stream condition - caller should do any\n// necessary stream level locking before calling this\n\nSTDMETHODIMP CRenderedInputPin::EndOfStream()\n{\n    HRESULT hr = CheckStreaming();\n\n    //  Do EC_COMPLETE handling for rendered pins\n    if (S_OK == hr && !m_bAtEndOfStream)\n    {\n        m_bAtEndOfStream = TRUE;\n        FILTER_STATE fs;\n        EXECUTE_ASSERT(SUCCEEDED(m_pFilter->GetState(0, &fs)));\n        if (fs == State_Running)\n        {\n            DoCompleteHandling();\n        }\n    }\n    return hr;\n}\n\n// Called to complete the flush\n\nSTDMETHODIMP CRenderedInputPin::EndFlush()\n{\n    CAutoLock lck(m_pLock);\n\n    // Clean up renderer state\n    m_bAtEndOfStream = FALSE;\n    m_bCompleteNotified = FALSE;\n\n    return CBaseInputPin::EndFlush();\n}\n\n// Notify of Run() from filter\n\nHRESULT CRenderedInputPin::Run(REFERENCE_TIME tStart)\n{\n    UNREFERENCED_PARAMETER(tStart);\n    m_bCompleteNotified = FALSE;\n    if (m_bAtEndOfStream)\n    {\n        DoCompleteHandling();\n    }\n    return S_OK;\n}\n\n//  Clear status on going into paused state\n\nHRESULT CRenderedInputPin::Active()\n{\n    m_bAtEndOfStream = FALSE;\n    m_bCompleteNotified = FALSE;\n    return CBaseInputPin::Active();\n}\n\n//  Do stuff to deliver end of stream\n\nvoid CRenderedInputPin::DoCompleteHandling()\n{\n    ASSERT(m_bAtEndOfStream);\n    if (!m_bCompleteNotified)\n    {\n        m_bCompleteNotified = TRUE;\n        m_pFilter->NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)m_pFilter);\n    }\n}\n"
  },
  {
    "path": "common/baseclasses/amextra.h",
    "content": "//------------------------------------------------------------------------------\n// File: AMExtra.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __AMEXTRA__\n#define __AMEXTRA__\n\n// Simple rendered input pin\n//\n// NOTE if your filter queues stuff before rendering then it may not be\n// appropriate to use this class\n//\n// In that case queue the end of stream condition until the last sample\n// is actually rendered and flush the condition appropriately\n\nclass CRenderedInputPin : public CBaseInputPin\n{\n  public:\n    CRenderedInputPin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                      __inout HRESULT *phr, __in_opt LPCWSTR pName);\n#ifdef UNICODE\n    CRenderedInputPin(__in_opt LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                      __inout HRESULT *phr, __in_opt LPCWSTR pName);\n#endif\n\n    // Override methods to track end of stream state\n    STDMETHODIMP EndOfStream();\n    STDMETHODIMP EndFlush();\n\n    HRESULT Active();\n    HRESULT Run(REFERENCE_TIME tStart);\n\n  protected:\n    // Member variables to track state\n    BOOL m_bAtEndOfStream;    // Set by EndOfStream\n    BOOL m_bCompleteNotified; // Set when we notify for EC_COMPLETE\n\n  private:\n    void DoCompleteHandling();\n};\n\n#endif // __AMEXTRA__\n"
  },
  {
    "path": "common/baseclasses/amfilter.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: AMFilter.cpp\n//\n// Desc: DirectShow base classes - implements class hierarchy for streams\n//       architecture.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n//=====================================================================\n//=====================================================================\n// The following classes are declared in this header:\n//\n//\n// CBaseMediaFilter            Basic IMediaFilter support (abstract class)\n// CBaseFilter                 Support for IBaseFilter (incl. IMediaFilter)\n// CEnumPins                   Enumerate input and output pins\n// CEnumMediaTypes             Enumerate the preferred pin formats\n// CBasePin                    Abstract base class for IPin interface\n//    CBaseOutputPin           Adds data provider member functions\n//    CBaseInputPin            Implements IMemInputPin interface\n// CMediaSample                Basic transport unit for IMemInputPin\n// CBaseAllocator              General list guff for most allocators\n//    CMemAllocator            Implements memory buffer allocation\n//\n//=====================================================================\n//=====================================================================\n\n#include <streams.h>\n#include <strsafe.h>\n\n#ifdef DXMPERF\n#include \"dxmperf.h\"\n#endif // DXMPERF\n\n//=====================================================================\n// Helpers\n//=====================================================================\nSTDAPI CreateMemoryAllocator(__deref_out IMemAllocator **ppAllocator)\n{\n    return CoCreateInstance(CLSID_MemoryAllocator, 0, CLSCTX_INPROC_SERVER, IID_IMemAllocator, (void **)ppAllocator);\n}\n\n//  Put this one here rather than in ctlutil.cpp to avoid linking\n//  anything brought in by ctlutil.cpp\nSTDAPI CreatePosPassThru(__in_opt LPUNKNOWN pAgg, BOOL bRenderer, IPin *pPin, __deref_out IUnknown **ppPassThru)\n{\n    *ppPassThru = NULL;\n    IUnknown *pUnkSeek;\n    HRESULT hr = CoCreateInstance(CLSID_SeekingPassThru, pAgg, CLSCTX_INPROC_SERVER, IID_IUnknown, (void **)&pUnkSeek);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    ISeekingPassThru *pPassThru;\n    hr = pUnkSeek->QueryInterface(IID_ISeekingPassThru, (void **)&pPassThru);\n    if (FAILED(hr))\n    {\n        pUnkSeek->Release();\n        return hr;\n    }\n    hr = pPassThru->Init(bRenderer, pPin);\n    pPassThru->Release();\n    if (FAILED(hr))\n    {\n        pUnkSeek->Release();\n        return hr;\n    }\n    *ppPassThru = pUnkSeek;\n    return S_OK;\n}\n\n#define CONNECT_TRACE_LEVEL 3\n\n//=====================================================================\n//=====================================================================\n// Implements CBaseMediaFilter\n//=====================================================================\n//=====================================================================\n\n/* Constructor */\n\nCBaseMediaFilter::CBaseMediaFilter(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __in CCritSec *pLock,\n                                   REFCLSID clsid)\n    : CUnknown(pName, pUnk)\n    , m_pLock(pLock)\n    , m_clsid(clsid)\n    , m_State(State_Stopped)\n    , m_pClock(NULL)\n{\n}\n\n/* Destructor */\n\nCBaseMediaFilter::~CBaseMediaFilter()\n{\n    // must be stopped, but can't call Stop here since\n    // our critsec has been destroyed.\n\n    /* Release any clock we were using */\n\n    if (m_pClock)\n    {\n        m_pClock->Release();\n        m_pClock = NULL;\n    }\n}\n\n/* Override this to say what interfaces we support and where */\n\nSTDMETHODIMP\nCBaseMediaFilter::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_IMediaFilter)\n    {\n        return GetInterface((IMediaFilter *)this, ppv);\n    }\n    else if (riid == IID_IPersist)\n    {\n        return GetInterface((IPersist *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n/* Return the filter's clsid */\nSTDMETHODIMP\nCBaseMediaFilter::GetClassID(__out CLSID *pClsID)\n{\n    CheckPointer(pClsID, E_POINTER);\n    ValidateReadWritePtr(pClsID, sizeof(CLSID));\n    *pClsID = m_clsid;\n    return NOERROR;\n}\n\n/* Override this if your state changes are not done synchronously */\n\nSTDMETHODIMP\nCBaseMediaFilter::GetState(DWORD dwMSecs, __out FILTER_STATE *State)\n{\n    UNREFERENCED_PARAMETER(dwMSecs);\n    CheckPointer(State, E_POINTER);\n    ValidateReadWritePtr(State, sizeof(FILTER_STATE));\n\n    *State = m_State;\n    return S_OK;\n}\n\n/* Set the clock we will use for synchronisation */\n\nSTDMETHODIMP\nCBaseMediaFilter::SetSyncSource(__inout_opt IReferenceClock *pClock)\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    // Ensure the new one does not go away - even if the same as the old\n    if (pClock)\n    {\n        pClock->AddRef();\n    }\n\n    // if we have a clock, release it\n    if (m_pClock)\n    {\n        m_pClock->Release();\n    }\n\n    // Set the new reference clock (might be NULL)\n    // Should we query it to ensure it is a clock?  Consider for a debug build.\n    m_pClock = pClock;\n\n    return NOERROR;\n}\n\n/* Return the clock we are using for synchronisation */\nSTDMETHODIMP\nCBaseMediaFilter::GetSyncSource(__deref_out_opt IReferenceClock **pClock)\n{\n    CheckPointer(pClock, E_POINTER);\n    ValidateReadWritePtr(pClock, sizeof(IReferenceClock *));\n    CAutoLock cObjectLock(m_pLock);\n\n    if (m_pClock)\n    {\n        // returning an interface... addref it...\n        m_pClock->AddRef();\n    }\n    *pClock = (IReferenceClock *)m_pClock;\n    return NOERROR;\n}\n\n/* Put the filter into a stopped state */\n\nSTDMETHODIMP\nCBaseMediaFilter::Stop()\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    m_State = State_Stopped;\n    return S_OK;\n}\n\n/* Put the filter into a paused state */\n\nSTDMETHODIMP\nCBaseMediaFilter::Pause()\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    m_State = State_Paused;\n    return S_OK;\n}\n\n// Put the filter into a running state.\n\n// The time parameter is the offset to be added to the samples'\n// stream time to get the reference time at which they should be presented.\n//\n// you can either add these two and compare it against the reference clock,\n// or you can call CBaseMediaFilter::StreamTime and compare that against\n// the sample timestamp.\n\nSTDMETHODIMP\nCBaseMediaFilter::Run(REFERENCE_TIME tStart)\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    // remember the stream time offset\n    m_tStart = tStart;\n\n    if (m_State == State_Stopped)\n    {\n        HRESULT hr = Pause();\n\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n    }\n    m_State = State_Running;\n    return S_OK;\n}\n\n//\n// return the current stream time - samples with start timestamps of this\n// time or before should be rendered by now\nHRESULT\nCBaseMediaFilter::StreamTime(CRefTime &rtStream)\n{\n    // Caller must lock for synchronization\n    // We can't grab the filter lock because we want to be able to call\n    // this from worker threads without deadlocking\n\n    if (m_pClock == NULL)\n    {\n        return VFW_E_NO_CLOCK;\n    }\n\n    // get the current reference time\n    HRESULT hr = m_pClock->GetTime((REFERENCE_TIME *)&rtStream);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // subtract the stream offset to get stream time\n    rtStream -= m_tStart;\n\n    return S_OK;\n}\n\n//=====================================================================\n//=====================================================================\n// Implements CBaseFilter\n//=====================================================================\n//=====================================================================\n\n/* Override this to say what interfaces we support and where */\n\nSTDMETHODIMP CBaseFilter::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    /* Do we have this interface */\n\n    if (riid == IID_IBaseFilter)\n    {\n        return GetInterface((IBaseFilter *)this, ppv);\n    }\n    else if (riid == IID_IMediaFilter)\n    {\n        return GetInterface((IMediaFilter *)this, ppv);\n    }\n    else if (riid == IID_IPersist)\n    {\n        return GetInterface((IPersist *)this, ppv);\n    }\n    else if (riid == IID_IAMovieSetup)\n    {\n        return GetInterface((IAMovieSetup *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n#ifdef DEBUG\nSTDMETHODIMP_(ULONG) CBaseFilter::NonDelegatingRelease()\n{\n    if (m_cRef == 1)\n    {\n        KASSERT(m_pGraph == NULL);\n    }\n    return CUnknown::NonDelegatingRelease();\n}\n#endif\n\n/* Constructor */\n\nCBaseFilter::CBaseFilter(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __in CCritSec *pLock, REFCLSID clsid)\n    : CUnknown(pName, pUnk)\n    , m_pLock(pLock)\n    , m_clsid(clsid)\n    , m_State(State_Stopped)\n    , m_pClock(NULL)\n    , m_pGraph(NULL)\n    , m_pSink(NULL)\n    , m_pName(NULL)\n    , m_PinVersion(1)\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(pName ? pName : L\"CBaseFilter\", (IBaseFilter *)this);\n#endif // DXMPERF\n\n    ASSERT(pLock != NULL);\n}\n\n/* Passes in a redundant HRESULT argument */\n\nCBaseFilter::CBaseFilter(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk, __in CCritSec *pLock, REFCLSID clsid,\n                         __inout HRESULT *phr)\n    : CUnknown(pName, pUnk)\n    , m_pLock(pLock)\n    , m_clsid(clsid)\n    , m_State(State_Stopped)\n    , m_pClock(NULL)\n    , m_pGraph(NULL)\n    , m_pSink(NULL)\n    , m_pName(NULL)\n    , m_PinVersion(1)\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(pName ? pName : L\"CBaseFilter\", (IBaseFilter *)this);\n#endif // DXMPERF\n\n    ASSERT(pLock != NULL);\n    UNREFERENCED_PARAMETER(phr);\n}\n\n#ifdef UNICODE\nCBaseFilter::CBaseFilter(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk, __in CCritSec *pLock, REFCLSID clsid)\n    : CUnknown(pName, pUnk)\n    , m_pLock(pLock)\n    , m_clsid(clsid)\n    , m_State(State_Stopped)\n    , m_pClock(NULL)\n    , m_pGraph(NULL)\n    , m_pSink(NULL)\n    , m_pName(NULL)\n    , m_PinVersion(1)\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(L\"CBaseFilter\", (IBaseFilter *)this);\n#endif // DXMPERF\n\n    ASSERT(pLock != NULL);\n}\nCBaseFilter::CBaseFilter(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk, __in CCritSec *pLock, REFCLSID clsid,\n                         __inout HRESULT *phr)\n    : CUnknown(pName, pUnk)\n    , m_pLock(pLock)\n    , m_clsid(clsid)\n    , m_State(State_Stopped)\n    , m_pClock(NULL)\n    , m_pGraph(NULL)\n    , m_pSink(NULL)\n    , m_pName(NULL)\n    , m_PinVersion(1)\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(L\"CBaseFilter\", (IBaseFilter *)this);\n#endif // DXMPERF\n\n    ASSERT(pLock != NULL);\n    UNREFERENCED_PARAMETER(phr);\n}\n#endif\n\n/* Destructor */\n\nCBaseFilter::~CBaseFilter()\n{\n#ifdef DXMPERF\n    PERFLOG_DTOR(L\"CBaseFilter\", (IBaseFilter *)this);\n#endif // DXMPERF\n\n    // NOTE we do NOT hold references on the filtergraph for m_pGraph or m_pSink\n    // When we did we had the circular reference problem.  Nothing would go away.\n\n    delete[] m_pName;\n\n    // must be stopped, but can't call Stop here since\n    // our critsec has been destroyed.\n\n    /* Release any clock we were using */\n    if (m_pClock)\n    {\n        m_pClock->Release();\n        m_pClock = NULL;\n    }\n}\n\n/* Return the filter's clsid */\nSTDMETHODIMP\nCBaseFilter::GetClassID(__out CLSID *pClsID)\n{\n    CheckPointer(pClsID, E_POINTER);\n    ValidateReadWritePtr(pClsID, sizeof(CLSID));\n    *pClsID = m_clsid;\n    return NOERROR;\n}\n\n/* Override this if your state changes are not done synchronously */\nSTDMETHODIMP\nCBaseFilter::GetState(DWORD dwMSecs, __out FILTER_STATE *State)\n{\n    UNREFERENCED_PARAMETER(dwMSecs);\n    CheckPointer(State, E_POINTER);\n    ValidateReadWritePtr(State, sizeof(FILTER_STATE));\n\n    *State = m_State;\n    return S_OK;\n}\n\n/* Set the clock we will use for synchronisation */\n\nSTDMETHODIMP\nCBaseFilter::SetSyncSource(__in_opt IReferenceClock *pClock)\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    // Ensure the new one does not go away - even if the same as the old\n    if (pClock)\n    {\n        pClock->AddRef();\n    }\n\n    // if we have a clock, release it\n    if (m_pClock)\n    {\n        m_pClock->Release();\n    }\n\n    // Set the new reference clock (might be NULL)\n    // Should we query it to ensure it is a clock?  Consider for a debug build.\n    m_pClock = pClock;\n\n    return NOERROR;\n}\n\n/* Return the clock we are using for synchronisation */\nSTDMETHODIMP\nCBaseFilter::GetSyncSource(__deref_out_opt IReferenceClock **pClock)\n{\n    CheckPointer(pClock, E_POINTER);\n    ValidateReadWritePtr(pClock, sizeof(IReferenceClock *));\n    CAutoLock cObjectLock(m_pLock);\n\n    if (m_pClock)\n    {\n        // returning an interface... addref it...\n        m_pClock->AddRef();\n    }\n    *pClock = (IReferenceClock *)m_pClock;\n    return NOERROR;\n}\n\n// override CBaseMediaFilter Stop method, to deactivate any pins this\n// filter has.\nSTDMETHODIMP\nCBaseFilter::Stop()\n{\n    CAutoLock cObjectLock(m_pLock);\n    HRESULT hr = NOERROR;\n\n    // notify all pins of the state change\n    if (m_State != State_Stopped)\n    {\n        int cPins = GetPinCount();\n        for (int c = 0; c < cPins; c++)\n        {\n\n            CBasePin *pPin = GetPin(c);\n            if (NULL == pPin)\n            {\n                break;\n            }\n\n            // Disconnected pins are not activated - this saves pins worrying\n            // about this state themselves. We ignore the return code to make\n            // sure everyone is inactivated regardless. The base input pin\n            // class can return an error if it has no allocator but Stop can\n            // be used to resync the graph state after something has gone bad\n\n            if (pPin->IsConnected())\n            {\n                HRESULT hrTmp = pPin->Inactive();\n                if (FAILED(hrTmp) && SUCCEEDED(hr))\n                {\n                    hr = hrTmp;\n                }\n            }\n        }\n    }\n\n#ifdef DXMPERF\n    PERFLOG_STOP(m_pName ? m_pName : L\"CBaseFilter\", (IBaseFilter *)this, m_State);\n#endif // DXMPERF\n\n    m_State = State_Stopped;\n    return hr;\n}\n\n// override CBaseMediaFilter Pause method to activate any pins\n// this filter has (also called from Run)\n\nSTDMETHODIMP\nCBaseFilter::Pause()\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    // notify all pins of the change to active state\n    if (m_State == State_Stopped)\n    {\n        int cPins = GetPinCount();\n        for (int c = 0; c < cPins; c++)\n        {\n\n            CBasePin *pPin = GetPin(c);\n            if (NULL == pPin)\n            {\n                break;\n            }\n\n            // Disconnected pins are not activated - this saves pins\n            // worrying about this state themselves\n\n            if (pPin->IsConnected())\n            {\n                HRESULT hr = pPin->Active();\n                if (FAILED(hr))\n                {\n                    return hr;\n                }\n            }\n        }\n    }\n\n#ifdef DXMPERF\n    PERFLOG_PAUSE(m_pName ? m_pName : L\"CBaseFilter\", (IBaseFilter *)this, m_State);\n#endif // DXMPERF\n\n    m_State = State_Paused;\n    return S_OK;\n}\n\n// Put the filter into a running state.\n\n// The time parameter is the offset to be added to the samples'\n// stream time to get the reference time at which they should be presented.\n//\n// you can either add these two and compare it against the reference clock,\n// or you can call CBaseFilter::StreamTime and compare that against\n// the sample timestamp.\n\nSTDMETHODIMP\nCBaseFilter::Run(REFERENCE_TIME tStart)\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    // remember the stream time offset\n    m_tStart = tStart;\n\n    if (m_State == State_Stopped)\n    {\n        HRESULT hr = Pause();\n\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n    }\n    // notify all pins of the change to active state\n    if (m_State != State_Running)\n    {\n        int cPins = GetPinCount();\n        for (int c = 0; c < cPins; c++)\n        {\n\n            CBasePin *pPin = GetPin(c);\n            if (NULL == pPin)\n            {\n                break;\n            }\n\n            // Disconnected pins are not activated - this saves pins\n            // worrying about this state themselves\n\n            if (pPin->IsConnected())\n            {\n                HRESULT hr = pPin->Run(tStart);\n                if (FAILED(hr))\n                {\n                    return hr;\n                }\n            }\n        }\n    }\n\n#ifdef DXMPERF\n    PERFLOG_RUN(m_pName ? m_pName : L\"CBaseFilter\", (IBaseFilter *)this, tStart, m_State);\n#endif // DXMPERF\n\n    m_State = State_Running;\n    return S_OK;\n}\n\n//\n// return the current stream time - samples with start timestamps of this\n// time or before should be rendered by now\nHRESULT\nCBaseFilter::StreamTime(CRefTime &rtStream)\n{\n    // Caller must lock for synchronization\n    // We can't grab the filter lock because we want to be able to call\n    // this from worker threads without deadlocking\n\n    if (m_pClock == NULL)\n    {\n        return VFW_E_NO_CLOCK;\n    }\n\n    // get the current reference time\n    HRESULT hr = m_pClock->GetTime((REFERENCE_TIME *)&rtStream);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // subtract the stream offset to get stream time\n    rtStream -= m_tStart;\n\n    return S_OK;\n}\n\n/* Create an enumerator for the pins attached to this filter */\n\nSTDMETHODIMP\nCBaseFilter::EnumPins(__deref_out IEnumPins **ppEnum)\n{\n    CheckPointer(ppEnum, E_POINTER);\n    ValidateReadWritePtr(ppEnum, sizeof(IEnumPins *));\n\n    /* Create a new ref counted enumerator */\n\n    *ppEnum = new CEnumPins(this, NULL);\n\n    return *ppEnum == NULL ? E_OUTOFMEMORY : NOERROR;\n}\n\n// default behaviour of FindPin is to assume pins are named\n// by their pin names\nSTDMETHODIMP\nCBaseFilter::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)\n{\n    CheckPointer(ppPin, E_POINTER);\n    ValidateReadWritePtr(ppPin, sizeof(IPin *));\n\n    //  We're going to search the pin list so maintain integrity\n    CAutoLock lck(m_pLock);\n    int iCount = GetPinCount();\n    for (int i = 0; i < iCount; i++)\n    {\n        CBasePin *pPin = GetPin(i);\n        if (NULL == pPin)\n        {\n            break;\n        }\n\n        if (0 == lstrcmpW(pPin->Name(), Id))\n        {\n            //  Found one that matches\n            //\n            //  AddRef() and return it\n            *ppPin = pPin;\n            pPin->AddRef();\n            return S_OK;\n        }\n    }\n    *ppPin = NULL;\n    return VFW_E_NOT_FOUND;\n}\n\n/* Return information about this filter */\n\nSTDMETHODIMP\nCBaseFilter::QueryFilterInfo(__out FILTER_INFO *pInfo)\n{\n    CheckPointer(pInfo, E_POINTER);\n    ValidateReadWritePtr(pInfo, sizeof(FILTER_INFO));\n\n    if (m_pName)\n    {\n        (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);\n    }\n    else\n    {\n        pInfo->achName[0] = L'\\0';\n    }\n    pInfo->pGraph = m_pGraph;\n    if (m_pGraph)\n        m_pGraph->AddRef();\n    return NOERROR;\n}\n\n/* Provide the filter with a filter graph */\n\nSTDMETHODIMP\nCBaseFilter::JoinFilterGraph(__inout_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    // NOTE: we no longer hold references on the graph (m_pGraph, m_pSink)\n\n    m_pGraph = pGraph;\n    if (m_pGraph)\n    {\n        HRESULT hr = m_pGraph->QueryInterface(IID_IMediaEventSink, (void **)&m_pSink);\n        if (FAILED(hr))\n        {\n            ASSERT(m_pSink == NULL);\n        }\n        else\n            m_pSink->Release(); // we do NOT keep a reference on it.\n    }\n    else\n    {\n        // if graph pointer is null, then we should\n        // also release the IMediaEventSink on the same object - we don't\n        // refcount it, so just set it to null\n        m_pSink = NULL;\n    }\n\n    if (m_pName)\n    {\n        delete[] m_pName;\n        m_pName = NULL;\n    }\n\n    if (pName)\n    {\n        size_t namelen;\n        HRESULT hr = StringCchLengthW(pName, STRSAFE_MAX_CCH, &namelen);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n        m_pName = new WCHAR[namelen + 1];\n        if (m_pName)\n        {\n            (void)StringCchCopyW(m_pName, namelen + 1, pName);\n        }\n        else\n        {\n            return E_OUTOFMEMORY;\n        }\n    }\n\n#ifdef DXMPERF\n    PERFLOG_JOINGRAPH(m_pName ? m_pName : L\"CBaseFilter\", (IBaseFilter *)this, pGraph);\n#endif // DXMPERF\n\n    return NOERROR;\n}\n\n// return a Vendor information string. Optional - may return E_NOTIMPL.\n// memory returned should be freed using CoTaskMemFree\n// default implementation returns E_NOTIMPL\nSTDMETHODIMP\nCBaseFilter::QueryVendorInfo(__deref_out LPWSTR *pVendorInfo)\n{\n    UNREFERENCED_PARAMETER(pVendorInfo);\n    return E_NOTIMPL;\n}\n\n// send an event notification to the filter graph if we know about it.\n// returns S_OK if delivered, S_FALSE if the filter graph does not sink\n// events, or an error otherwise.\nHRESULT\nCBaseFilter::NotifyEvent(long EventCode, LONG_PTR EventParam1, LONG_PTR EventParam2)\n{\n    // Snapshot so we don't have to lock up\n    IMediaEventSink *pSink = m_pSink;\n    if (pSink)\n    {\n        if (EC_COMPLETE == EventCode)\n        {\n            EventParam2 = (LONG_PTR)(IBaseFilter *)this;\n        }\n\n        return pSink->Notify(EventCode, EventParam1, EventParam2);\n    }\n    else\n    {\n        return E_NOTIMPL;\n    }\n}\n\n// Request reconnect\n// pPin is the pin to reconnect\n// pmt is the type to reconnect with - can be NULL\n// Calls ReconnectEx on the filter graph\nHRESULT\nCBaseFilter::ReconnectPin(IPin *pPin, __in_opt AM_MEDIA_TYPE const *pmt)\n{\n    IFilterGraph2 *pGraph2;\n    if (m_pGraph != NULL)\n    {\n        HRESULT hr = m_pGraph->QueryInterface(IID_IFilterGraph2, (void **)&pGraph2);\n        if (SUCCEEDED(hr))\n        {\n            hr = pGraph2->ReconnectEx(pPin, pmt);\n            pGraph2->Release();\n            return hr;\n        }\n        else\n        {\n            return m_pGraph->Reconnect(pPin);\n        }\n    }\n    else\n    {\n        return E_NOINTERFACE;\n    }\n}\n\n/* This is the same idea as the media type version does for type enumeration\n   on pins but for the list of pins available. So if the list of pins you\n   provide changes dynamically then either override this virtual function\n   to provide the version number, or more simply call IncrementPinVersion */\n\nLONG CBaseFilter::GetPinVersion()\n{\n    return m_PinVersion;\n}\n\n/* Increment the current pin version cookie */\n\nvoid CBaseFilter::IncrementPinVersion()\n{\n    InterlockedIncrement(&m_PinVersion);\n}\n\n/* register filter */\n\nSTDMETHODIMP CBaseFilter::Register()\n{\n    // get setup data, if it exists\n    //\n    LPAMOVIESETUP_FILTER psetupdata = GetSetupData();\n\n    // check we've got data\n    //\n    if (NULL == psetupdata)\n        return S_FALSE;\n\n    // init is ref counted so call just in case\n    // we're being called cold.\n    //\n    HRESULT hr = CoInitialize((LPVOID)NULL);\n    ASSERT(SUCCEEDED(hr));\n\n    // get hold of IFilterMapper\n    //\n    IFilterMapper *pIFM;\n    hr = CoCreateInstance(CLSID_FilterMapper, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper, (void **)&pIFM);\n    if (SUCCEEDED(hr))\n    {\n        hr = AMovieSetupRegisterFilter(psetupdata, pIFM, TRUE);\n        pIFM->Release();\n    }\n\n    // and clear up\n    //\n    CoFreeUnusedLibraries();\n    CoUninitialize();\n\n    return NOERROR;\n}\n\n/* unregister filter */\n\nSTDMETHODIMP CBaseFilter::Unregister()\n{\n    // get setup data, if it exists\n    //\n    LPAMOVIESETUP_FILTER psetupdata = GetSetupData();\n\n    // check we've got data\n    //\n    if (NULL == psetupdata)\n        return S_FALSE;\n\n    // OLE init is ref counted so call\n    // just in case we're being called cold.\n    //\n    HRESULT hr = CoInitialize((LPVOID)NULL);\n    ASSERT(SUCCEEDED(hr));\n\n    // get hold of IFilterMapper\n    //\n    IFilterMapper *pIFM;\n    hr = CoCreateInstance(CLSID_FilterMapper, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper, (void **)&pIFM);\n    if (SUCCEEDED(hr))\n    {\n        hr = AMovieSetupRegisterFilter(psetupdata, pIFM, FALSE);\n\n        // release interface\n        //\n        pIFM->Release();\n    }\n\n    // clear up\n    //\n    CoFreeUnusedLibraries();\n    CoUninitialize();\n\n    // handle one acceptable \"error\" - that\n    // of filter not being registered!\n    // (couldn't find a suitable #define'd\n    // name for the error!)\n    //\n    if (0x80070002 == hr)\n        return NOERROR;\n    else\n        return hr;\n}\n\n//=====================================================================\n//=====================================================================\n// Implements CEnumPins\n//=====================================================================\n//=====================================================================\n\nCEnumPins::CEnumPins(__in CBaseFilter *pFilter, __in_opt CEnumPins *pEnumPins)\n    : m_Position(0)\n    , m_PinCount(0)\n    , m_pFilter(pFilter)\n    , m_cRef(1)\n    , // Already ref counted\n    m_PinCache(NAME(\"Pin Cache\"))\n{\n\n#ifdef DEBUG\n    m_dwCookie = DbgRegisterObjectCreation(\"CEnumPins\", 0);\n#endif\n\n    /* We must be owned by a filter derived from CBaseFilter */\n\n    ASSERT(pFilter != NULL);\n\n    /* Hold a reference count on our filter */\n    m_pFilter->AddRef();\n\n    /* Are we creating a new enumerator */\n\n    if (pEnumPins == NULL)\n    {\n        m_Version = m_pFilter->GetPinVersion();\n        m_PinCount = m_pFilter->GetPinCount();\n    }\n    else\n    {\n        ASSERT(m_Position <= m_PinCount);\n        m_Position = pEnumPins->m_Position;\n        m_PinCount = pEnumPins->m_PinCount;\n        m_Version = pEnumPins->m_Version;\n        m_PinCache.AddTail(&(pEnumPins->m_PinCache));\n    }\n}\n\n/* Destructor releases the reference count on our filter NOTE since we hold\n   a reference count on the filter who created us we know it is safe to\n   release it, no access can be made to it afterwards though as we have just\n   caused the last reference count to go and the object to be deleted */\n\nCEnumPins::~CEnumPins()\n{\n    m_pFilter->Release();\n\n#ifdef DEBUG\n    DbgRegisterObjectDestruction(m_dwCookie);\n#endif\n}\n\n/* Override this to say what interfaces we support where */\n\nSTDMETHODIMP\nCEnumPins::QueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    /* Do we have this interface */\n\n    if (riid == IID_IEnumPins || riid == IID_IUnknown)\n    {\n        return GetInterface((IEnumPins *)this, ppv);\n    }\n    else\n    {\n        *ppv = NULL;\n        return E_NOINTERFACE;\n    }\n}\n\nSTDMETHODIMP_(ULONG)\nCEnumPins::AddRef()\n{\n    return InterlockedIncrement(&m_cRef);\n}\n\nSTDMETHODIMP_(ULONG)\nCEnumPins::Release()\n{\n    ULONG cRef = InterlockedDecrement(&m_cRef);\n    if (cRef == 0)\n    {\n        delete this;\n    }\n    return cRef;\n}\n\n/* One of an enumerator's basic member functions allows us to create a cloned\n   interface that initially has the same state. Since we are taking a snapshot\n   of an object (current position and all) we must lock access at the start */\n\nSTDMETHODIMP\nCEnumPins::Clone(__deref_out IEnumPins **ppEnum)\n{\n    CheckPointer(ppEnum, E_POINTER);\n    ValidateReadWritePtr(ppEnum, sizeof(IEnumPins *));\n    HRESULT hr = NOERROR;\n\n    /* Check we are still in sync with the filter */\n    if (AreWeOutOfSync() == TRUE)\n    {\n        *ppEnum = NULL;\n        hr = VFW_E_ENUM_OUT_OF_SYNC;\n    }\n    else\n    {\n        *ppEnum = new CEnumPins(m_pFilter, this);\n        if (*ppEnum == NULL)\n        {\n            hr = E_OUTOFMEMORY;\n        }\n    }\n    return hr;\n}\n\n/* Return the next pin after the current position */\n\nSTDMETHODIMP\nCEnumPins::Next(ULONG cPins,                       // place this many pins...\n                __out_ecount(cPins) IPin **ppPins, // ...in this array\n                __out_opt ULONG *pcFetched)        // actual count passed returned here\n{\n    CheckPointer(ppPins, E_POINTER);\n    ValidateReadWritePtr(ppPins, cPins * sizeof(IPin *));\n\n    ASSERT(ppPins);\n\n    if (pcFetched != NULL)\n    {\n        ValidateWritePtr(pcFetched, sizeof(ULONG));\n        *pcFetched = 0; // default unless we succeed\n    }\n    // now check that the parameter is valid\n    else if (cPins > 1)\n    { // pcFetched == NULL\n        return E_INVALIDARG;\n    }\n    ULONG cFetched = 0; // increment as we get each one.\n\n    /* Check we are still in sync with the filter */\n    if (AreWeOutOfSync() == TRUE)\n    {\n        // If we are out of sync, we should refresh the enumerator.\n        // This will reset the position and update the other members, but\n        // will not clear cache of pins we have already returned.\n        Refresh();\n    }\n\n    /* Return each pin interface NOTE GetPin returns CBasePin * not addrefed\n       so we must QI for the IPin (which increments its reference count)\n       If while we are retrieving a pin from the filter an error occurs we\n       assume that our internal state is stale with respect to the filter\n       (for example someone has deleted a pin) so we\n       return VFW_E_ENUM_OUT_OF_SYNC                            */\n\n    while (cFetched < cPins && m_PinCount > m_Position)\n    {\n\n        /* Get the next pin object from the filter */\n\n        CBasePin *pPin = m_pFilter->GetPin(m_Position++);\n        if (pPin == NULL)\n        {\n            // If this happend, and it's not the first time through, then we've got a problem,\n            // since we should really go back and release the iPins, which we have previously\n            // AddRef'ed.\n            ASSERT(cFetched == 0);\n            return VFW_E_ENUM_OUT_OF_SYNC;\n        }\n\n        /* We only want to return this pin, if it is not in our cache */\n        if (0 == m_PinCache.Find(pPin))\n        {\n            /* From the object get an IPin interface */\n\n            *ppPins = pPin;\n            pPin->AddRef();\n\n            cFetched++;\n            ppPins++;\n\n            m_PinCache.AddTail(pPin);\n        }\n    }\n\n    if (pcFetched != NULL)\n    {\n        *pcFetched = cFetched;\n    }\n\n    return (cPins == cFetched ? NOERROR : S_FALSE);\n}\n\n/* Skip over one or more entries in the enumerator */\n\nSTDMETHODIMP\nCEnumPins::Skip(ULONG cPins)\n{\n    /* Check we are still in sync with the filter */\n    if (AreWeOutOfSync() == TRUE)\n    {\n        return VFW_E_ENUM_OUT_OF_SYNC;\n    }\n\n    /* Work out how many pins are left to skip over */\n    /* We could position at the end if we are asked to skip too many... */\n    /* ..which would match the base implementation for CEnumMediaTypes::Skip */\n\n    ULONG PinsLeft = m_PinCount - m_Position;\n    if (cPins > PinsLeft)\n    {\n        return S_FALSE;\n    }\n    m_Position += cPins;\n    return NOERROR;\n}\n\n/* Set the current position back to the start */\n/* Reset has 4 simple steps:\n *\n * Set position to head of list\n * Sync enumerator with object being enumerated\n * Clear the cache of pins already returned\n * return S_OK\n */\n\nSTDMETHODIMP\nCEnumPins::Reset()\n{\n    m_Version = m_pFilter->GetPinVersion();\n    m_PinCount = m_pFilter->GetPinCount();\n\n    m_Position = 0;\n\n    // Clear the cache\n    m_PinCache.RemoveAll();\n\n    return S_OK;\n}\n\n/* Set the current position back to the start */\n/* Refresh has 3 simple steps:\n *\n * Set position to head of list\n * Sync enumerator with object being enumerated\n * return S_OK\n */\n\nSTDMETHODIMP\nCEnumPins::Refresh()\n{\n    m_Version = m_pFilter->GetPinVersion();\n    m_PinCount = m_pFilter->GetPinCount();\n\n    m_Position = 0;\n    return S_OK;\n}\n\n//=====================================================================\n//=====================================================================\n// Implements CEnumMediaTypes\n//=====================================================================\n//=====================================================================\n\nCEnumMediaTypes::CEnumMediaTypes(__in CBasePin *pPin, __in_opt CEnumMediaTypes *pEnumMediaTypes)\n    : m_Position(0)\n    , m_pPin(pPin)\n    , m_cRef(1)\n{\n\n#ifdef DEBUG\n    m_dwCookie = DbgRegisterObjectCreation(\"CEnumMediaTypes\", 0);\n#endif\n\n    /* We must be owned by a pin derived from CBasePin */\n\n    ASSERT(pPin != NULL);\n\n    /* Hold a reference count on our pin */\n    m_pPin->AddRef();\n\n    /* Are we creating a new enumerator */\n\n    if (pEnumMediaTypes == NULL)\n    {\n        m_Version = m_pPin->GetMediaTypeVersion();\n        return;\n    }\n\n    m_Position = pEnumMediaTypes->m_Position;\n    m_Version = pEnumMediaTypes->m_Version;\n}\n\n/* Destructor releases the reference count on our base pin. NOTE since we hold\n   a reference count on the pin who created us we know it is safe to release\n   it, no access can be made to it afterwards though as we might have just\n   caused the last reference count to go and the object to be deleted */\n\nCEnumMediaTypes::~CEnumMediaTypes()\n{\n#ifdef DEBUG\n    DbgRegisterObjectDestruction(m_dwCookie);\n#endif\n    m_pPin->Release();\n}\n\n/* Override this to say what interfaces we support where */\n\nSTDMETHODIMP\nCEnumMediaTypes::QueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    /* Do we have this interface */\n\n    if (riid == IID_IEnumMediaTypes || riid == IID_IUnknown)\n    {\n        return GetInterface((IEnumMediaTypes *)this, ppv);\n    }\n    else\n    {\n        *ppv = NULL;\n        return E_NOINTERFACE;\n    }\n}\n\nSTDMETHODIMP_(ULONG)\nCEnumMediaTypes::AddRef()\n{\n    return InterlockedIncrement(&m_cRef);\n}\n\nSTDMETHODIMP_(ULONG)\nCEnumMediaTypes::Release()\n{\n    ULONG cRef = InterlockedDecrement(&m_cRef);\n    if (cRef == 0)\n    {\n        delete this;\n    }\n    return cRef;\n}\n\n/* One of an enumerator's basic member functions allows us to create a cloned\n   interface that initially has the same state. Since we are taking a snapshot\n   of an object (current position and all) we must lock access at the start */\n\nSTDMETHODIMP\nCEnumMediaTypes::Clone(__deref_out IEnumMediaTypes **ppEnum)\n{\n    CheckPointer(ppEnum, E_POINTER);\n    ValidateReadWritePtr(ppEnum, sizeof(IEnumMediaTypes *));\n    HRESULT hr = NOERROR;\n\n    /* Check we are still in sync with the pin */\n    if (AreWeOutOfSync() == TRUE)\n    {\n        *ppEnum = NULL;\n        hr = VFW_E_ENUM_OUT_OF_SYNC;\n    }\n    else\n    {\n\n        *ppEnum = new CEnumMediaTypes(m_pPin, this);\n\n        if (*ppEnum == NULL)\n        {\n            hr = E_OUTOFMEMORY;\n        }\n    }\n    return hr;\n}\n\n/* Enumerate the next pin(s) after the current position. The client using this\n   interface passes in a pointer to an array of pointers each of which will\n   be filled in with a pointer to a fully initialised media type format\n   Return NOERROR if it all works,\n          S_FALSE if fewer than cMediaTypes were enumerated.\n          VFW_E_ENUM_OUT_OF_SYNC if the enumerator has been broken by\n                                 state changes in the filter\n   The actual count always correctly reflects the number of types in the array.\n*/\n\nSTDMETHODIMP\nCEnumMediaTypes::Next(ULONG cMediaTypes,                                      // place this many types...\n                      __out_ecount(cMediaTypes) AM_MEDIA_TYPE **ppMediaTypes, // ...in this array\n                      __out ULONG *pcFetched)                                 // actual count passed\n{\n    CheckPointer(ppMediaTypes, E_POINTER);\n    ValidateReadWritePtr(ppMediaTypes, cMediaTypes * sizeof(AM_MEDIA_TYPE *));\n    /* Check we are still in sync with the pin */\n    if (AreWeOutOfSync() == TRUE)\n    {\n        return VFW_E_ENUM_OUT_OF_SYNC;\n    }\n\n    if (pcFetched != NULL)\n    {\n        ValidateWritePtr(pcFetched, sizeof(ULONG));\n        *pcFetched = 0; // default unless we succeed\n    }\n    // now check that the parameter is valid\n    else if (cMediaTypes > 1)\n    { // pcFetched == NULL\n        return E_INVALIDARG;\n    }\n    ULONG cFetched = 0; // increment as we get each one.\n\n    /* Return each media type by asking the filter for them in turn - If we\n       have an error code retured to us while we are retrieving a media type\n       we assume that our internal state is stale with respect to the filter\n       (for example the window size changing) so we return\n       VFW_E_ENUM_OUT_OF_SYNC */\n\n    while (cMediaTypes)\n    {\n\n        CMediaType cmt;\n\n        HRESULT hr = m_pPin->GetMediaType(m_Position++, &cmt);\n        if (S_OK != hr)\n        {\n            break;\n        }\n\n        /* We now have a CMediaType object that contains the next media type\n           but when we assign it to the array position we CANNOT just assign\n           the AM_MEDIA_TYPE structure because as soon as the object goes out of\n           scope it will delete the memory we have just copied. The function\n           we use is CreateMediaType which allocates a task memory block */\n\n        /*  Transfer across the format block manually to save an allocate\n            and free on the format block and generally go faster */\n\n        *ppMediaTypes = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));\n        if (*ppMediaTypes == NULL)\n        {\n            break;\n        }\n\n        /*  Do a regular copy */\n        **ppMediaTypes = cmt;\n\n        /*  Make sure the destructor doesn't free these */\n        cmt.pbFormat = NULL;\n        cmt.cbFormat = NULL;\n        cmt.pUnk = NULL;\n\n        ppMediaTypes++;\n        cFetched++;\n        cMediaTypes--;\n    }\n\n    if (pcFetched != NULL)\n    {\n        *pcFetched = cFetched;\n    }\n\n    return (cMediaTypes == 0 ? NOERROR : S_FALSE);\n}\n\n/* Skip over one or more entries in the enumerator */\n\nSTDMETHODIMP\nCEnumMediaTypes::Skip(ULONG cMediaTypes)\n{\n    //  If we're skipping 0 elements we're guaranteed to skip the\n    //  correct number of elements\n    if (cMediaTypes == 0)\n    {\n        return S_OK;\n    }\n\n    /* Check we are still in sync with the pin */\n    if (AreWeOutOfSync() == TRUE)\n    {\n        return VFW_E_ENUM_OUT_OF_SYNC;\n    }\n\n    m_Position += cMediaTypes;\n\n    /*  See if we're over the end */\n    CMediaType cmt;\n    return S_OK == m_pPin->GetMediaType(m_Position - 1, &cmt) ? S_OK : S_FALSE;\n}\n\n/* Set the current position back to the start */\n/* Reset has 3 simple steps:\n *\n * set position to head of list\n * sync enumerator with object being enumerated\n * return S_OK\n */\n\nSTDMETHODIMP\nCEnumMediaTypes::Reset()\n\n{\n    m_Position = 0;\n\n    // Bring the enumerator back into step with the current state.  This\n    // may be a noop but ensures that the enumerator will be valid on the\n    // next call.\n    m_Version = m_pPin->GetMediaTypeVersion();\n    return NOERROR;\n}\n\n//=====================================================================\n//=====================================================================\n// Implements CBasePin\n//=====================================================================\n//=====================================================================\n\n/* NOTE The implementation of this class calls the CUnknown constructor with\n   a NULL outer unknown pointer. This has the effect of making us a self\n   contained class, ie any QueryInterface, AddRef or Release calls will be\n   routed to the class's NonDelegatingUnknown methods. You will typically\n   find that the classes that do this then override one or more of these\n   virtual functions to provide more specialised behaviour. A good example\n   of this is where a class wants to keep the QueryInterface internal but\n   still wants its lifetime controlled by the external object */\n\n/* Constructor */\n\nCBasePin::CBasePin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock, __inout HRESULT *phr,\n                   __in_opt LPCWSTR pName, PIN_DIRECTION dir)\n    : CUnknown(pObjectName, NULL)\n    , m_pFilter(pFilter)\n    , m_pLock(pLock)\n    , m_pName(NULL)\n    , m_Connected(NULL)\n    , m_dir(dir)\n    , m_bRunTimeError(FALSE)\n    , m_pQSink(NULL)\n    , m_TypeVersion(1)\n    , m_tStart()\n    , m_tStop(MAX_TIME)\n    , m_bCanReconnectWhenActive(false)\n    , m_bTryMyTypesFirst(false)\n    , m_dRate(1.0)\n{\n    /*  WARNING - pFilter is often not a properly constituted object at\n        this state (in particular QueryInterface may not work) - this\n        is because its owner is often its containing object and we\n        have been called from the containing object's constructor so\n        the filter's owner has not yet had its CUnknown constructor\n        called\n    */\n#ifdef DXMPERF\n    PERFLOG_CTOR(pName ? pName : L\"CBasePin\", (IPin *)this);\n#endif // DXMPERF\n\n    ASSERT(pFilter != NULL);\n    ASSERT(pLock != NULL);\n\n    if (pName)\n    {\n        size_t cchName;\n        HRESULT hr = StringCchLengthW(pName, STRSAFE_MAX_CCH, &cchName);\n        if (SUCCEEDED(hr))\n        {\n            m_pName = new WCHAR[cchName + 1];\n            if (m_pName)\n            {\n                (void)StringCchCopyW(m_pName, cchName + 1, pName);\n            }\n        }\n    }\n\n#ifdef DEBUG\n    m_cRef = 0;\n#endif\n}\n\n#ifdef UNICODE\nCBasePin::CBasePin(__in_opt LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock, __inout HRESULT *phr,\n                   __in_opt LPCWSTR pName, PIN_DIRECTION dir)\n    : CUnknown(pObjectName, NULL)\n    , m_pFilter(pFilter)\n    , m_pLock(pLock)\n    , m_pName(NULL)\n    , m_Connected(NULL)\n    , m_dir(dir)\n    , m_bRunTimeError(FALSE)\n    , m_pQSink(NULL)\n    , m_TypeVersion(1)\n    , m_tStart()\n    , m_tStop(MAX_TIME)\n    , m_bCanReconnectWhenActive(false)\n    , m_bTryMyTypesFirst(false)\n    , m_dRate(1.0)\n{\n    /*  WARNING - pFilter is often not a properly constituted object at\n        this state (in particular QueryInterface may not work) - this\n        is because its owner is often its containing object and we\n        have been called from the containing object's constructor so\n        the filter's owner has not yet had its CUnknown constructor\n        called\n    */\n#ifdef DXMPERF\n    PERFLOG_CTOR(pName ? pName : L\"CBasePin\", (IPin *)this);\n#endif // DXMPERF\n\n    ASSERT(pFilter != NULL);\n    ASSERT(pLock != NULL);\n\n    if (pName)\n    {\n        size_t cchName;\n        HRESULT hr = StringCchLengthW(pName, STRSAFE_MAX_CCH, &cchName);\n        if (SUCCEEDED(hr))\n        {\n            m_pName = new WCHAR[cchName + 1];\n            if (m_pName)\n            {\n                (void)StringCchCopyW(m_pName, cchName + 1, pName);\n            }\n        }\n    }\n\n#ifdef DEBUG\n    m_cRef = 0;\n#endif\n}\n#endif\n\n/* Destructor since a connected pin holds a reference count on us there is\n   no way that we can be deleted unless we are not currently connected */\n\nCBasePin::~CBasePin()\n{\n#ifdef DXMPERF\n    PERFLOG_DTOR(m_pName ? m_pName : L\"CBasePin\", (IPin *)this);\n#endif // DXMPERF\n\n    //  We don't call disconnect because if the filter is going away\n    //  all the pins must have a reference count of zero so they must\n    //  have been disconnected anyway - (but check the assumption)\n    ASSERT(m_Connected == FALSE);\n\n    delete[] m_pName;\n\n    // check the internal reference count is consistent\n    ASSERT(m_cRef == 0);\n}\n\n/* Override this to say what interfaces we support and where */\n\nSTDMETHODIMP\nCBasePin::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    /* Do we have this interface */\n\n    if (riid == IID_IPin)\n    {\n        return GetInterface((IPin *)this, ppv);\n    }\n    else if (riid == IID_IQualityControl)\n    {\n        return GetInterface((IQualityControl *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n/* Override to increment the owning filter's reference count */\n\nSTDMETHODIMP_(ULONG)\nCBasePin::NonDelegatingAddRef()\n{\n    ASSERT(InterlockedIncrement(&m_cRef) > 0);\n    return m_pFilter->AddRef();\n}\n\n/* Override to decrement the owning filter's reference count */\n\nSTDMETHODIMP_(ULONG)\nCBasePin::NonDelegatingRelease()\n{\n    ASSERT(InterlockedDecrement(&m_cRef) >= 0);\n    return m_pFilter->Release();\n}\n\n/* Displays pin connection information */\n\n#ifdef DEBUG\nvoid CBasePin::DisplayPinInfo(IPin *pReceivePin)\n{\n\n    if (DbgCheckModuleLevel(LOG_TRACE, CONNECT_TRACE_LEVEL))\n    {\n        PIN_INFO ConnectPinInfo;\n        PIN_INFO ReceivePinInfo;\n\n        if (FAILED(QueryPinInfo(&ConnectPinInfo)))\n        {\n            StringCchCopyW(ConnectPinInfo.achName, sizeof(ConnectPinInfo.achName) / sizeof(WCHAR), L\"Bad Pin\");\n        }\n        else\n        {\n            QueryPinInfoReleaseFilter(ConnectPinInfo);\n        }\n\n        if (FAILED(pReceivePin->QueryPinInfo(&ReceivePinInfo)))\n        {\n            StringCchCopyW(ReceivePinInfo.achName, sizeof(ReceivePinInfo.achName) / sizeof(WCHAR), L\"Bad Pin\");\n        }\n        else\n        {\n            QueryPinInfoReleaseFilter(ReceivePinInfo);\n        }\n\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"Trying to connect Pins :\")));\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"    <%ls>\"), ConnectPinInfo.achName));\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"    <%ls>\"), ReceivePinInfo.achName));\n    }\n}\n#endif\n\n/* Displays general information on the pin media type */\n\n#ifdef DEBUG\nvoid CBasePin::DisplayTypeInfo(IPin *pPin, const CMediaType *pmt)\n{\n    UNREFERENCED_PARAMETER(pPin);\n    if (DbgCheckModuleLevel(LOG_TRACE, CONNECT_TRACE_LEVEL))\n    {\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"Trying media type:\")));\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"    major type:  %hs\"), GuidNames[*pmt->Type()]));\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"    sub type  :  %hs\"), GuidNames[*pmt->Subtype()]));\n    }\n}\n#endif\n\n/* Asked to connect to a pin. A pin is always attached to an owning filter\n   object so we always delegate our locking to that object. We first of all\n   retrieve a media type enumerator for the input pin and see if we accept\n   any of the formats that it would ideally like, failing that we retrieve\n   our enumerator and see if it will accept any of our preferred types */\n\nSTDMETHODIMP\nCBasePin::Connect(IPin *pReceivePin,\n                  __in_opt const AM_MEDIA_TYPE *pmt // optional media type\n)\n{\n    CheckPointer(pReceivePin, E_POINTER);\n    ValidateReadPtr(pReceivePin, sizeof(IPin));\n    CAutoLock cObjectLock(m_pLock);\n    DisplayPinInfo(pReceivePin);\n\n    /* See if we are already connected */\n\n    if (m_Connected)\n    {\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"Already connected\")));\n        return VFW_E_ALREADY_CONNECTED;\n    }\n\n    /* See if the filter is active */\n    if (!IsStopped() && !m_bCanReconnectWhenActive)\n    {\n        return VFW_E_NOT_STOPPED;\n    }\n\n    // Find a mutually agreeable media type -\n    // Pass in the template media type. If this is partially specified,\n    // each of the enumerated media types will need to be checked against\n    // it. If it is non-null and fully specified, we will just try to connect\n    // with this.\n\n    const CMediaType *ptype = (CMediaType *)pmt;\n    HRESULT hr = AgreeMediaType(pReceivePin, ptype);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"Failed to agree type\")));\n\n        // Since the procedure is already returning an error code, there\n        // is nothing else this function can do to report the error.\n        EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));\n\n#ifdef DXMPERF\n        PERFLOG_CONNECT((IPin *)this, pReceivePin, hr, pmt);\n#endif // DXMPERF\n\n        return hr;\n    }\n\n    DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"Connection succeeded\")));\n\n#ifdef DXMPERF\n    PERFLOG_CONNECT((IPin *)this, pReceivePin, NOERROR, pmt);\n#endif // DXMPERF\n\n    return NOERROR;\n}\n\n// given a specific media type, attempt a connection (includes\n// checking that the type is acceptable to this pin)\nHRESULT\nCBasePin::AttemptConnection(IPin *pReceivePin,    // connect to this pin\n                            const CMediaType *pmt // using this type\n)\n{\n    // The caller should hold the filter lock becasue this function\n    // uses m_Connected.  The caller should also hold the filter lock\n    // because this function calls SetMediaType(), IsStopped() and\n    // CompleteConnect().\n    ASSERT(CritCheckIn(m_pLock));\n\n    // Check that the connection is valid  -- need to do this for every\n    // connect attempt since BreakConnect will undo it.\n    HRESULT hr = CheckConnect(pReceivePin);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"CheckConnect failed\")));\n\n        // Since the procedure is already returning an error code, there\n        // is nothing else this function can do to report the error.\n        EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));\n\n        return hr;\n    }\n\n    DisplayTypeInfo(pReceivePin, pmt);\n\n    /* Check we will accept this media type */\n\n    hr = CheckMediaType(pmt);\n    if (hr == NOERROR)\n    {\n\n        /*  Make ourselves look connected otherwise ReceiveConnection\n            may not be able to complete the connection\n        */\n        m_Connected = pReceivePin;\n        m_Connected->AddRef();\n        hr = SetMediaType(pmt);\n        if (SUCCEEDED(hr))\n        {\n            /* See if the other pin will accept this type */\n\n            hr = pReceivePin->ReceiveConnection((IPin *)this, pmt);\n            if (SUCCEEDED(hr))\n            {\n                /* Complete the connection */\n\n                hr = CompleteConnect(pReceivePin);\n                if (SUCCEEDED(hr))\n                {\n                    return hr;\n                }\n                else\n                {\n                    DbgLog((LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"Failed to complete connection\")));\n                    pReceivePin->Disconnect();\n                }\n            }\n        }\n    }\n    else\n    {\n        // we cannot use this media type\n\n        // return a specific media type error if there is one\n        // or map a general failure code to something more helpful\n        // (in particular S_FALSE gets changed to an error code)\n        if (SUCCEEDED(hr) || (hr == E_FAIL) || (hr == E_INVALIDARG))\n        {\n            hr = VFW_E_TYPE_NOT_ACCEPTED;\n        }\n    }\n\n    // BreakConnect and release any connection here in case CheckMediaType\n    // failed, or if we set anything up during a call back during\n    // ReceiveConnection.\n\n    // Since the procedure is already returning an error code, there\n    // is nothing else this function can do to report the error.\n    EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));\n\n    /*  If failed then undo our state */\n    if (m_Connected)\n    {\n        m_Connected->Release();\n        m_Connected = NULL;\n    }\n\n    return hr;\n}\n\n/* Given an enumerator we cycle through all the media types it proposes and\n   firstly suggest them to our derived pin class and if that succeeds try\n   them with the pin in a ReceiveConnection call. This means that if our pin\n   proposes a media type we still check in here that we can support it. This\n   is deliberate so that in simple cases the enumerator can hold all of the\n   media types even if some of them are not really currently available */\n\nHRESULT CBasePin::TryMediaTypes(IPin *pReceivePin, __in_opt const CMediaType *pmt, IEnumMediaTypes *pEnum)\n{\n    /* Reset the current enumerator position */\n\n    HRESULT hr = pEnum->Reset();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    CMediaType *pMediaType = NULL;\n    ULONG ulMediaCount = 0;\n\n    // attempt to remember a specific error code if there is one\n    HRESULT hrFailure = S_OK;\n\n    for (;;)\n    {\n\n        /* Retrieve the next media type NOTE each time round the loop the\n           enumerator interface will allocate another AM_MEDIA_TYPE structure\n           If we are successful then we copy it into our output object, if\n           not then we must delete the memory allocated before returning */\n\n        hr = pEnum->Next(1, (AM_MEDIA_TYPE **)&pMediaType, &ulMediaCount);\n        if (hr != S_OK)\n        {\n            if (S_OK == hrFailure)\n            {\n                hrFailure = VFW_E_NO_ACCEPTABLE_TYPES;\n            }\n            return hrFailure;\n        }\n\n        ASSERT(ulMediaCount == 1);\n        ASSERT(pMediaType);\n\n        // check that this matches the partial type (if any)\n\n        if (pMediaType && ((pmt == NULL) || pMediaType->MatchesPartial(pmt)))\n        {\n\n            hr = AttemptConnection(pReceivePin, pMediaType);\n\n            // attempt to remember a specific error code\n            if (FAILED(hr) && SUCCEEDED(hrFailure) && (hr != E_FAIL) && (hr != E_INVALIDARG) &&\n                (hr != VFW_E_TYPE_NOT_ACCEPTED))\n            {\n                hrFailure = hr;\n            }\n        }\n        else\n        {\n            hr = VFW_E_NO_ACCEPTABLE_TYPES;\n        }\n\n        if (pMediaType)\n        {\n            DeleteMediaType(pMediaType);\n            pMediaType = NULL;\n        }\n\n        if (S_OK == hr)\n        {\n            return hr;\n        }\n    }\n}\n\n/* This is called to make the connection, including the taask of finding\n   a media type for the pin connection. pmt is the proposed media type\n   from the Connect call: if this is fully specified, we will try that.\n   Otherwise we enumerate and try all the input pin's types first and\n   if that fails we then enumerate and try all our preferred media types.\n   For each media type we check it against pmt (if non-null and partially\n   specified) as well as checking that both pins will accept it.\n */\n\nHRESULT CBasePin::AgreeMediaType(IPin *pReceivePin, const CMediaType *pmt)\n{\n    ASSERT(pReceivePin);\n    IEnumMediaTypes *pEnumMediaTypes = NULL;\n\n    // if the media type is fully specified then use that\n    if ((pmt != NULL) && (!pmt->IsPartiallySpecified()))\n    {\n\n        // if this media type fails, then we must fail the connection\n        // since if pmt is nonnull we are only allowed to connect\n        // using a type that matches it.\n\n        return AttemptConnection(pReceivePin, pmt);\n    }\n\n    /* Try the other pin's enumerator */\n\n    HRESULT hrFailure = VFW_E_NO_ACCEPTABLE_TYPES;\n\n    for (int i = 0; i < 2; i++)\n    {\n        HRESULT hr;\n        if (i == (int)m_bTryMyTypesFirst)\n        {\n            hr = pReceivePin->EnumMediaTypes(&pEnumMediaTypes);\n        }\n        else\n        {\n            hr = EnumMediaTypes(&pEnumMediaTypes);\n        }\n        if (SUCCEEDED(hr))\n        {\n            ASSERT(pEnumMediaTypes);\n            hr = TryMediaTypes(pReceivePin, pmt, pEnumMediaTypes);\n            pEnumMediaTypes->Release();\n            if (SUCCEEDED(hr))\n            {\n                return NOERROR;\n            }\n            else\n            {\n                // try to remember specific error codes if there are any\n                if ((hr != E_FAIL) && (hr != E_INVALIDARG) && (hr != VFW_E_TYPE_NOT_ACCEPTED))\n                {\n                    hrFailure = hr;\n                }\n            }\n        }\n    }\n\n    return hrFailure;\n}\n\n/* Called when we want to complete a connection to another filter. Failing\n   this will also fail the connection and disconnect the other pin as well */\n\nHRESULT\nCBasePin::CompleteConnect(IPin *pReceivePin)\n{\n    UNREFERENCED_PARAMETER(pReceivePin);\n    return NOERROR;\n}\n\n/* This is called to set the format for a pin connection - CheckMediaType\n   will have been called to check the connection format and if it didn't\n   return an error code then this (virtual) function will be invoked */\n\nHRESULT\nCBasePin::SetMediaType(const CMediaType *pmt)\n{\n    HRESULT hr = m_mt.Set(*pmt);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return NOERROR;\n}\n\n/* This is called during Connect() to provide a virtual method that can do\n   any specific check needed for connection such as QueryInterface. This\n   base class method just checks that the pin directions don't match */\n\nHRESULT\nCBasePin::CheckConnect(IPin *pPin)\n{\n    /* Check that pin directions DONT match */\n\n    PIN_DIRECTION pd;\n    pPin->QueryDirection(&pd);\n\n    ASSERT((pd == PINDIR_OUTPUT) || (pd == PINDIR_INPUT));\n    ASSERT((m_dir == PINDIR_OUTPUT) || (m_dir == PINDIR_INPUT));\n\n    // we should allow for non-input and non-output connections?\n    if (pd == m_dir)\n    {\n        return VFW_E_INVALID_DIRECTION;\n    }\n    return NOERROR;\n}\n\n/* This is called when we realise we can't make a connection to the pin and\n   must undo anything we did in CheckConnect - override to release QIs done */\n\nHRESULT\nCBasePin::BreakConnect()\n{\n    return NOERROR;\n}\n\n/* Called normally by an output pin on an input pin to try and establish a\n   connection.\n*/\n\nSTDMETHODIMP\nCBasePin::ReceiveConnection(IPin *pConnector,        // this is the pin who we will connect to\n                            const AM_MEDIA_TYPE *pmt // this is the media type we will exchange\n)\n{\n    CheckPointer(pConnector, E_POINTER);\n    CheckPointer(pmt, E_POINTER);\n    ValidateReadPtr(pConnector, sizeof(IPin));\n    ValidateReadPtr(pmt, sizeof(AM_MEDIA_TYPE));\n    CAutoLock cObjectLock(m_pLock);\n\n    /* Are we already connected */\n    if (m_Connected)\n    {\n        return VFW_E_ALREADY_CONNECTED;\n    }\n\n    /* See if the filter is active */\n    if (!IsStopped() && !m_bCanReconnectWhenActive)\n    {\n        return VFW_E_NOT_STOPPED;\n    }\n\n    HRESULT hr = CheckConnect(pConnector);\n    if (FAILED(hr))\n    {\n        // Since the procedure is already returning an error code, there\n        // is nothing else this function can do to report the error.\n        EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));\n\n#ifdef DXMPERF\n        PERFLOG_RXCONNECT(pConnector, (IPin *)this, hr, pmt);\n#endif // DXMPERF\n\n        return hr;\n    }\n\n    /* Ask derived class if this media type is ok */\n\n    CMediaType *pcmt = (CMediaType *)pmt;\n    hr = CheckMediaType(pcmt);\n    if (hr != NOERROR)\n    {\n        // no -we don't support this media type\n\n        // Since the procedure is already returning an error code, there\n        // is nothing else this function can do to report the error.\n        EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));\n\n        // return a specific media type error if there is one\n        // or map a general failure code to something more helpful\n        // (in particular S_FALSE gets changed to an error code)\n        if (SUCCEEDED(hr) || (hr == E_FAIL) || (hr == E_INVALIDARG))\n        {\n            hr = VFW_E_TYPE_NOT_ACCEPTED;\n        }\n\n#ifdef DXMPERF\n        PERFLOG_RXCONNECT(pConnector, (IPin *)this, hr, pmt);\n#endif // DXMPERF\n\n        return hr;\n    }\n\n    /* Complete the connection */\n\n    m_Connected = pConnector;\n    m_Connected->AddRef();\n    hr = SetMediaType(pcmt);\n    if (SUCCEEDED(hr))\n    {\n        hr = CompleteConnect(pConnector);\n        if (SUCCEEDED(hr))\n        {\n\n#ifdef DXMPERF\n            PERFLOG_RXCONNECT(pConnector, (IPin *)this, NOERROR, pmt);\n#endif // DXMPERF\n\n            return NOERROR;\n        }\n    }\n\n    DbgLog(\n        (LOG_TRACE, CONNECT_TRACE_LEVEL, TEXT(\"Failed to set the media type or failed to complete the connection.\")));\n    m_Connected->Release();\n    m_Connected = NULL;\n\n    // Since the procedure is already returning an error code, there\n    // is nothing else this function can do to report the error.\n    EXECUTE_ASSERT(SUCCEEDED(BreakConnect()));\n\n#ifdef DXMPERF\n    PERFLOG_RXCONNECT(pConnector, (IPin *)this, hr, pmt);\n#endif // DXMPERF\n\n    return hr;\n}\n\n/* Called when we want to terminate a pin connection */\n\nSTDMETHODIMP\nCBasePin::Disconnect()\n{\n    CAutoLock cObjectLock(m_pLock);\n\n    /* See if the filter is active */\n    if (!IsStopped())\n    {\n        return VFW_E_NOT_STOPPED;\n    }\n\n    return DisconnectInternal();\n}\n\nSTDMETHODIMP\nCBasePin::DisconnectInternal()\n{\n    ASSERT(CritCheckIn(m_pLock));\n\n    if (m_Connected)\n    {\n        HRESULT hr = BreakConnect();\n        if (FAILED(hr))\n        {\n\n#ifdef DXMPERF\n            PERFLOG_DISCONNECT((IPin *)this, m_Connected, hr);\n#endif // DXMPERF\n\n            // There is usually a bug in the program if BreakConnect() fails.\n            DbgBreak(\"WARNING: BreakConnect() failed in CBasePin::Disconnect().\");\n            return hr;\n        }\n\n        m_Connected->Release();\n        m_Connected = NULL;\n\n#ifdef DXMPERF\n        PERFLOG_DISCONNECT((IPin *)this, m_Connected, S_OK);\n#endif // DXMPERF\n\n        return S_OK;\n    }\n    else\n    {\n        // no connection - not an error\n\n#ifdef DXMPERF\n        PERFLOG_DISCONNECT((IPin *)this, m_Connected, S_FALSE);\n#endif // DXMPERF\n\n        return S_FALSE;\n    }\n}\n\n/* Return an AddRef()'d pointer to the connected pin if there is one */\nSTDMETHODIMP\nCBasePin::ConnectedTo(__deref_out IPin **ppPin)\n{\n    CheckPointer(ppPin, E_POINTER);\n    ValidateReadWritePtr(ppPin, sizeof(IPin *));\n    //\n    //  It's pointless to lock here.\n    //  The caller should ensure integrity.\n    //\n\n    IPin *pPin = m_Connected;\n    *ppPin = pPin;\n    if (pPin != NULL)\n    {\n        pPin->AddRef();\n        return S_OK;\n    }\n    else\n    {\n        ASSERT(*ppPin == NULL);\n        return VFW_E_NOT_CONNECTED;\n    }\n}\n\n/* Return the media type of the connection */\nSTDMETHODIMP\nCBasePin::ConnectionMediaType(__out AM_MEDIA_TYPE *pmt)\n{\n    CheckPointer(pmt, E_POINTER);\n    ValidateReadWritePtr(pmt, sizeof(AM_MEDIA_TYPE));\n    CAutoLock cObjectLock(m_pLock);\n\n    /*  Copy constructor of m_mt allocates the memory */\n    if (IsConnected())\n    {\n        CopyMediaType(pmt, &m_mt);\n        return S_OK;\n    }\n    else\n    {\n        ((CMediaType *)pmt)->InitMediaType();\n        return VFW_E_NOT_CONNECTED;\n    }\n}\n\n/* Return information about the filter we are connect to */\n\nSTDMETHODIMP\nCBasePin::QueryPinInfo(__out PIN_INFO *pInfo)\n{\n    CheckPointer(pInfo, E_POINTER);\n    ValidateReadWritePtr(pInfo, sizeof(PIN_INFO));\n\n    pInfo->pFilter = m_pFilter;\n    if (m_pFilter)\n    {\n        m_pFilter->AddRef();\n    }\n\n    if (m_pName)\n    {\n        (void)StringCchCopyW(pInfo->achName, NUMELMS(pInfo->achName), m_pName);\n    }\n    else\n    {\n        pInfo->achName[0] = L'\\0';\n    }\n\n    pInfo->dir = m_dir;\n\n    return NOERROR;\n}\n\nSTDMETHODIMP\nCBasePin::QueryDirection(__out PIN_DIRECTION *pPinDir)\n{\n    CheckPointer(pPinDir, E_POINTER);\n    ValidateReadWritePtr(pPinDir, sizeof(PIN_DIRECTION));\n\n    *pPinDir = m_dir;\n    return NOERROR;\n}\n\n// Default QueryId to return the pin's name\nSTDMETHODIMP\nCBasePin::QueryId(__deref_out LPWSTR *Id)\n{\n    //  We're not going away because someone's got a pointer to us\n    //  so there's no need to lock\n\n    return AMGetWideString(Name(), Id);\n}\n\n/* Does this pin support this media type WARNING this interface function does\n   not lock the main object as it is meant to be asynchronous by nature - if\n   the media types you support depend on some internal state that is updated\n   dynamically then you will need to implement locking in a derived class */\n\nSTDMETHODIMP\nCBasePin::QueryAccept(const AM_MEDIA_TYPE *pmt)\n{\n    CheckPointer(pmt, E_POINTER);\n    ValidateReadPtr(pmt, sizeof(AM_MEDIA_TYPE));\n\n    /* The CheckMediaType method is valid to return error codes if the media\n       type is horrible, an example might be E_INVALIDARG. What we do here\n       is map all the error codes into either S_OK or S_FALSE regardless */\n\n    HRESULT hr = CheckMediaType((CMediaType *)pmt);\n    if (FAILED(hr))\n    {\n        return S_FALSE;\n    }\n    // note that the only defined success codes should be S_OK and S_FALSE...\n    return hr;\n}\n\n/* This can be called to return an enumerator for the pin's list of preferred\n   media types. An input pin is not obliged to have any preferred formats\n   although it can do. For example, the window renderer has a preferred type\n   which describes a video image that matches the current window size. All\n   output pins should expose at least one preferred format otherwise it is\n   possible that neither pin has any types and so no connection is possible */\n\nSTDMETHODIMP\nCBasePin::EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum)\n{\n    CheckPointer(ppEnum, E_POINTER);\n    ValidateReadWritePtr(ppEnum, sizeof(IEnumMediaTypes *));\n\n    /* Create a new ref counted enumerator */\n\n    *ppEnum = new CEnumMediaTypes(this, NULL);\n\n    if (*ppEnum == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    return NOERROR;\n}\n\n/* This is a virtual function that returns a media type corresponding with\n   place iPosition in the list. This base class simply returns an error as\n   we support no media types by default but derived classes should override */\n\nHRESULT CBasePin::GetMediaType(int iPosition, __inout CMediaType *pMediaType)\n{\n    UNREFERENCED_PARAMETER(iPosition);\n    UNREFERENCED_PARAMETER(pMediaType);\n    return E_UNEXPECTED;\n}\n\n/* This is a virtual function that returns the current media type version.\n   The base class initialises the media type enumerators with the value 1\n   By default we always returns that same value. A Derived class may change\n   the list of media types available and after doing so it should increment\n   the version either in a method derived from this, or more simply by just\n   incrementing the m_TypeVersion base pin variable. The type enumerators\n   call this when they want to see if their enumerations are out of date */\n\nLONG CBasePin::GetMediaTypeVersion()\n{\n    return m_TypeVersion;\n}\n\n/* Increment the cookie representing the current media type version */\n\nvoid CBasePin::IncrementTypeVersion()\n{\n    InterlockedIncrement(&m_TypeVersion);\n}\n\n/* Called by IMediaFilter implementation when the state changes from Stopped\n   to either paused or running and in derived classes could do things like\n   commit memory and grab hardware resource (the default is to do nothing) */\n\nHRESULT\nCBasePin::Active(void)\n{\n    return NOERROR;\n}\n\n/* Called by IMediaFilter implementation when the state changes from\n   to either paused to running and in derived classes could do things like\n   commit memory and grab hardware resource (the default is to do nothing) */\n\nHRESULT\nCBasePin::Run(REFERENCE_TIME tStart)\n{\n    UNREFERENCED_PARAMETER(tStart);\n    return NOERROR;\n}\n\n/* Also called by the IMediaFilter implementation when the state changes to\n   Stopped at which point you should decommit allocators and free hardware\n   resources you grabbed in the Active call (default is also to do nothing) */\n\nHRESULT\nCBasePin::Inactive(void)\n{\n    m_bRunTimeError = FALSE;\n    return NOERROR;\n}\n\n// Called when no more data will arrive\nSTDMETHODIMP\nCBasePin::EndOfStream(void)\n{\n    return S_OK;\n}\n\nSTDMETHODIMP\nCBasePin::SetSink(IQualityControl *piqc)\n{\n    CAutoLock cObjectLock(m_pLock);\n    if (piqc)\n        ValidateReadPtr(piqc, sizeof(IQualityControl));\n    m_pQSink = piqc;\n    return NOERROR;\n} // SetSink\n\nSTDMETHODIMP\nCBasePin::Notify(IBaseFilter *pSender, Quality q)\n{\n    UNREFERENCED_PARAMETER(q);\n    UNREFERENCED_PARAMETER(pSender);\n    DbgBreak(\"IQualityControl::Notify not over-ridden from CBasePin.  (IGNORE is OK)\");\n    return E_NOTIMPL;\n} // Notify\n\n// NewSegment notifies of the start/stop/rate applying to the data\n// about to be received. Default implementation records data and\n// returns S_OK.\n// Override this to pass downstream.\nSTDMETHODIMP\nCBasePin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    m_tStart = tStart;\n    m_tStop = tStop;\n    m_dRate = dRate;\n\n    return S_OK;\n}\n\n//=====================================================================\n//=====================================================================\n// Implements CBaseOutputPin\n//=====================================================================\n//=====================================================================\n\nCBaseOutputPin::CBaseOutputPin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                               __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CBasePin(pObjectName, pFilter, pLock, phr, pName, PINDIR_OUTPUT)\n    , m_pAllocator(NULL)\n    , m_pInputPin(NULL)\n{\n    ASSERT(pFilter);\n}\n\n#ifdef UNICODE\nCBaseOutputPin::CBaseOutputPin(__in_opt LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                               __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CBasePin(pObjectName, pFilter, pLock, phr, pName, PINDIR_OUTPUT)\n    , m_pAllocator(NULL)\n    , m_pInputPin(NULL)\n{\n    ASSERT(pFilter);\n}\n#endif\n\n/*   This is called after a media type has been proposed\n\n     Try to complete the connection by agreeing the allocator\n*/\nHRESULT\nCBaseOutputPin::CompleteConnect(IPin *pReceivePin)\n{\n    UNREFERENCED_PARAMETER(pReceivePin);\n    return DecideAllocator(m_pInputPin, &m_pAllocator);\n}\n\n/* This method is called when the output pin is about to try and connect to\n   an input pin. It is at this point that you should try and grab any extra\n   interfaces that you need, in this case IMemInputPin. Because this is\n   only called if we are not currently connected we do NOT need to call\n   BreakConnect. This also makes it easier to derive classes from us as\n   BreakConnect is only called when we actually have to break a connection\n   (or a partly made connection) and not when we are checking a connection */\n\n/* Overriden from CBasePin */\n\nHRESULT\nCBaseOutputPin::CheckConnect(IPin *pPin)\n{\n    HRESULT hr = CBasePin::CheckConnect(pPin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // get an input pin and an allocator interface\n    hr = pPin->QueryInterface(IID_IMemInputPin, (void **)&m_pInputPin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return NOERROR;\n}\n\n/* Overriden from CBasePin */\n\nHRESULT\nCBaseOutputPin::BreakConnect()\n{\n    /* Release any allocator we hold */\n\n    if (m_pAllocator)\n    {\n        // Always decommit the allocator because a downstream filter may or\n        // may not decommit the connection's allocator.  A memory leak could\n        // occur if the allocator is not decommited when a connection is broken.\n        HRESULT hr = m_pAllocator->Decommit();\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        m_pAllocator->Release();\n        m_pAllocator = NULL;\n    }\n\n    /* Release any input pin interface we hold */\n\n    if (m_pInputPin)\n    {\n        m_pInputPin->Release();\n        m_pInputPin = NULL;\n    }\n    return NOERROR;\n}\n\n/* This is called when the input pin didn't give us a valid allocator */\n\nHRESULT\nCBaseOutputPin::InitAllocator(__deref_out IMemAllocator **ppAlloc)\n{\n    return CreateMemoryAllocator(ppAlloc);\n}\n\n/* Decide on an allocator, override this if you want to use your own allocator\n   Override DecideBufferSize to call SetProperties. If the input pin fails\n   the GetAllocator call then this will construct a CMemAllocator and call\n   DecideBufferSize on that, and if that fails then we are completely hosed.\n   If the you succeed the DecideBufferSize call, we will notify the input\n   pin of the selected allocator. NOTE this is called during Connect() which\n   therefore looks after grabbing and locking the object's critical section */\n\n// We query the input pin for its requested properties and pass this to\n// DecideBufferSize to allow it to fulfill requests that it is happy\n// with (eg most people don't care about alignment and are thus happy to\n// use the downstream pin's alignment request).\n\nHRESULT\nCBaseOutputPin::DecideAllocator(IMemInputPin *pPin, __deref_out IMemAllocator **ppAlloc)\n{\n    HRESULT hr = NOERROR;\n    *ppAlloc = NULL;\n\n    // get downstream prop request\n    // the derived class may modify this in DecideBufferSize, but\n    // we assume that he will consistently modify it the same way,\n    // so we only get it once\n    ALLOCATOR_PROPERTIES prop;\n    ZeroMemory(&prop, sizeof(prop));\n\n    // whatever he returns, we assume prop is either all zeros\n    // or he has filled it out.\n    pPin->GetAllocatorRequirements(&prop);\n\n    // if he doesn't care about alignment, then set it to 1\n    if (prop.cbAlign == 0)\n    {\n        prop.cbAlign = 1;\n    }\n\n    /* Try the allocator provided by the input pin */\n\n    hr = pPin->GetAllocator(ppAlloc);\n    if (SUCCEEDED(hr))\n    {\n\n        hr = DecideBufferSize(*ppAlloc, &prop);\n        if (SUCCEEDED(hr))\n        {\n            hr = pPin->NotifyAllocator(*ppAlloc, FALSE);\n            if (SUCCEEDED(hr))\n            {\n                return NOERROR;\n            }\n        }\n    }\n\n    /* If the GetAllocator failed we may not have an interface */\n\n    if (*ppAlloc)\n    {\n        (*ppAlloc)->Release();\n        *ppAlloc = NULL;\n    }\n\n    /* Try the output pin's allocator by the same method */\n\n    hr = InitAllocator(ppAlloc);\n    if (SUCCEEDED(hr))\n    {\n\n        // note - the properties passed here are in the same\n        // structure as above and may have been modified by\n        // the previous call to DecideBufferSize\n        hr = DecideBufferSize(*ppAlloc, &prop);\n        if (SUCCEEDED(hr))\n        {\n            hr = pPin->NotifyAllocator(*ppAlloc, FALSE);\n            if (SUCCEEDED(hr))\n            {\n                return NOERROR;\n            }\n        }\n    }\n\n    /* Likewise we may not have an interface to release */\n\n    if (*ppAlloc)\n    {\n        (*ppAlloc)->Release();\n        *ppAlloc = NULL;\n    }\n    return hr;\n}\n\n/* This returns an empty sample buffer from the allocator WARNING the same\n   dangers and restrictions apply here as described below for Deliver() */\n\nHRESULT\nCBaseOutputPin::GetDeliveryBuffer(__deref_out IMediaSample **ppSample, __in_opt REFERENCE_TIME *pStartTime,\n                                  __in_opt REFERENCE_TIME *pEndTime, DWORD dwFlags)\n{\n    if (m_pAllocator != NULL)\n    {\n        return m_pAllocator->GetBuffer(ppSample, pStartTime, pEndTime, dwFlags);\n    }\n    else\n    {\n        return E_NOINTERFACE;\n    }\n}\n\n/* Deliver a filled-in sample to the connected input pin. NOTE the object must\n   have locked itself before calling us otherwise we may get halfway through\n   executing this method only to find the filter graph has got in and\n   disconnected us from the input pin. If the filter has no worker threads\n   then the lock is best applied on Receive(), otherwise it should be done\n   when the worker thread is ready to deliver. There is a wee snag to worker\n   threads that this shows up. The worker thread must lock the object when\n   it is ready to deliver a sample, but it may have to wait until a state\n   change has completed, but that may never complete because the state change\n   is waiting for the worker thread to complete. The way to handle this is for\n   the state change code to grab the critical section, then set an abort event\n   for the worker thread, then release the critical section and wait for the\n   worker thread to see the event we set and then signal that it has finished\n   (with another event). At which point the state change code can complete */\n\n// note (if you've still got any breath left after reading that) that you\n// need to release the sample yourself after this call. if the connected\n// input pin needs to hold onto the sample beyond the call, it will addref\n// the sample itself.\n\n// of course you must release this one and call GetDeliveryBuffer for the\n// next. You cannot reuse it directly.\n\nHRESULT\nCBaseOutputPin::Deliver(IMediaSample *pSample)\n{\n    if (m_pInputPin == NULL)\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n\n#ifdef DXMPERF\n    PERFLOG_DELIVER(m_pName ? m_pName : L\"CBaseOutputPin\", (IPin *)this, (IPin *)m_pInputPin, pSample, &m_mt);\n#endif // DXMPERF\n\n    return m_pInputPin->Receive(pSample);\n}\n\n// called from elsewhere in our filter to pass EOS downstream to\n// our connected input pin\nHRESULT\nCBaseOutputPin::DeliverEndOfStream(void)\n{\n    // remember this is on IPin not IMemInputPin\n    if (m_Connected == NULL)\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n    return m_Connected->EndOfStream();\n}\n\n/* Commit the allocator's memory, this is called through IMediaFilter\n   which is responsible for locking the object before calling us */\n\nHRESULT\nCBaseOutputPin::Active(void)\n{\n    if (m_pAllocator == NULL)\n    {\n        return VFW_E_NO_ALLOCATOR;\n    }\n    return m_pAllocator->Commit();\n}\n\n/* Free up or unprepare allocator's memory, this is called through\n   IMediaFilter which is responsible for locking the object first */\n\nHRESULT\nCBaseOutputPin::Inactive(void)\n{\n    m_bRunTimeError = FALSE;\n    if (m_pAllocator == NULL)\n    {\n        return VFW_E_NO_ALLOCATOR;\n    }\n    return m_pAllocator->Decommit();\n}\n\n// we have a default handling of EndOfStream which is to return\n// an error, since this should be called on input pins only\nSTDMETHODIMP\nCBaseOutputPin::EndOfStream(void)\n{\n    return E_UNEXPECTED;\n}\n\n// BeginFlush should be called on input pins only\nSTDMETHODIMP\nCBaseOutputPin::BeginFlush(void)\n{\n    return E_UNEXPECTED;\n}\n\n// EndFlush should be called on input pins only\nSTDMETHODIMP\nCBaseOutputPin::EndFlush(void)\n{\n    return E_UNEXPECTED;\n}\n\n// call BeginFlush on the connected input pin\nHRESULT\nCBaseOutputPin::DeliverBeginFlush(void)\n{\n    // remember this is on IPin not IMemInputPin\n    if (m_Connected == NULL)\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n    return m_Connected->BeginFlush();\n}\n\n// call EndFlush on the connected input pin\nHRESULT\nCBaseOutputPin::DeliverEndFlush(void)\n{\n    // remember this is on IPin not IMemInputPin\n    if (m_Connected == NULL)\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n    return m_Connected->EndFlush();\n}\n// deliver NewSegment to connected pin\nHRESULT\nCBaseOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    if (m_Connected == NULL)\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n    return m_Connected->NewSegment(tStart, tStop, dRate);\n}\n\n//=====================================================================\n//=====================================================================\n// Implements CBaseInputPin\n//=====================================================================\n//=====================================================================\n\n/* Constructor creates a default allocator object */\n\nCBaseInputPin::CBaseInputPin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                             __inout HRESULT *phr, __in_opt LPCWSTR pPinName)\n    : CBasePin(pObjectName, pFilter, pLock, phr, pPinName, PINDIR_INPUT)\n    , m_pAllocator(NULL)\n    , m_bReadOnly(FALSE)\n    , m_bFlushing(FALSE)\n{\n    ZeroMemory(&m_SampleProps, sizeof(m_SampleProps));\n}\n\n#ifdef UNICODE\nCBaseInputPin::CBaseInputPin(__in LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                             __inout HRESULT *phr, __in_opt LPCWSTR pPinName)\n    : CBasePin(pObjectName, pFilter, pLock, phr, pPinName, PINDIR_INPUT)\n    , m_pAllocator(NULL)\n    , m_bReadOnly(FALSE)\n    , m_bFlushing(FALSE)\n{\n    ZeroMemory(&m_SampleProps, sizeof(m_SampleProps));\n}\n#endif\n\n/* Destructor releases it's reference count on the default allocator */\n\nCBaseInputPin::~CBaseInputPin()\n{\n    if (m_pAllocator != NULL)\n    {\n        m_pAllocator->Release();\n        m_pAllocator = NULL;\n    }\n}\n\n// override this to publicise our interfaces\nSTDMETHODIMP\nCBaseInputPin::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    /* Do we know about this interface */\n\n    if (riid == IID_IMemInputPin)\n    {\n        return GetInterface((IMemInputPin *)this, ppv);\n    }\n    else\n    {\n        return CBasePin::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n/* Return the allocator interface that this input pin would like the output\n   pin to use. NOTE subsequent calls to GetAllocator should all return an\n   interface onto the SAME object so we create one object at the start\n\n   Note:\n       The allocator is Release()'d on disconnect and replaced on\n       NotifyAllocator().\n\n   Override this to provide your own allocator.\n*/\n\nSTDMETHODIMP\nCBaseInputPin::GetAllocator(__deref_out IMemAllocator **ppAllocator)\n{\n    CheckPointer(ppAllocator, E_POINTER);\n    ValidateReadWritePtr(ppAllocator, sizeof(IMemAllocator *));\n    CAutoLock cObjectLock(m_pLock);\n\n    if (m_pAllocator == NULL)\n    {\n        HRESULT hr = CreateMemoryAllocator(&m_pAllocator);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n    }\n    ASSERT(m_pAllocator != NULL);\n    *ppAllocator = m_pAllocator;\n    m_pAllocator->AddRef();\n    return NOERROR;\n}\n\n/* Tell the input pin which allocator the output pin is actually going to use\n   Override this if you care - NOTE the locking we do both here and also in\n   GetAllocator is unnecessary but derived classes that do something useful\n   will undoubtedly have to lock the object so this might help remind people */\n\nSTDMETHODIMP\nCBaseInputPin::NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly)\n{\n    CheckPointer(pAllocator, E_POINTER);\n    ValidateReadPtr(pAllocator, sizeof(IMemAllocator));\n    CAutoLock cObjectLock(m_pLock);\n\n    IMemAllocator *pOldAllocator = m_pAllocator;\n    pAllocator->AddRef();\n    m_pAllocator = pAllocator;\n\n    if (pOldAllocator != NULL)\n    {\n        pOldAllocator->Release();\n    }\n\n    // the readonly flag indicates whether samples from this allocator should\n    // be regarded as readonly - if true, then inplace transforms will not be\n    // allowed.\n    m_bReadOnly = (BYTE)bReadOnly;\n    return NOERROR;\n}\n\nHRESULT\nCBaseInputPin::BreakConnect()\n{\n    /* We don't need our allocator any more */\n    if (m_pAllocator)\n    {\n        // Always decommit the allocator because a downstream filter may or\n        // may not decommit the connection's allocator.  A memory leak could\n        // occur if the allocator is not decommited when a pin is disconnected.\n        HRESULT hr = m_pAllocator->Decommit();\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        m_pAllocator->Release();\n        m_pAllocator = NULL;\n    }\n\n    return S_OK;\n}\n\n/* Do something with this media sample - this base class checks to see if the\n   format has changed with this media sample and if so checks that the filter\n   will accept it, generating a run time error if not. Once we have raised a\n   run time error we set a flag so that no more samples will be accepted\n\n   It is important that any filter should override this method and implement\n   synchronization so that samples are not processed when the pin is\n   disconnected etc\n*/\n\nSTDMETHODIMP\nCBaseInputPin::Receive(IMediaSample *pSample)\n{\n    CheckPointer(pSample, E_POINTER);\n    ValidateReadPtr(pSample, sizeof(IMediaSample));\n    ASSERT(pSample);\n\n    HRESULT hr = CheckStreaming();\n    if (S_OK != hr)\n    {\n        return hr;\n    }\n\n#ifdef DXMPERF\n    PERFLOG_RECEIVE(m_pName ? m_pName : L\"CBaseInputPin\", (IPin *)m_Connected, (IPin *)this, pSample, &m_mt);\n#endif // DXMPERF\n\n    /* Check for IMediaSample2 */\n    IMediaSample2 *pSample2;\n    if (SUCCEEDED(pSample->QueryInterface(IID_IMediaSample2, (void **)&pSample2)))\n    {\n        hr = pSample2->GetProperties(sizeof(m_SampleProps), (PBYTE)&m_SampleProps);\n        pSample2->Release();\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n    }\n    else\n    {\n        /*  Get the properties the hard way */\n        m_SampleProps.cbData = sizeof(m_SampleProps);\n        m_SampleProps.dwTypeSpecificFlags = 0;\n        m_SampleProps.dwStreamId = AM_STREAM_MEDIA;\n        m_SampleProps.dwSampleFlags = 0;\n        if (S_OK == pSample->IsDiscontinuity())\n        {\n            m_SampleProps.dwSampleFlags |= AM_SAMPLE_DATADISCONTINUITY;\n        }\n        if (S_OK == pSample->IsPreroll())\n        {\n            m_SampleProps.dwSampleFlags |= AM_SAMPLE_PREROLL;\n        }\n        if (S_OK == pSample->IsSyncPoint())\n        {\n            m_SampleProps.dwSampleFlags |= AM_SAMPLE_SPLICEPOINT;\n        }\n        if (SUCCEEDED(pSample->GetTime(&m_SampleProps.tStart, &m_SampleProps.tStop)))\n        {\n            m_SampleProps.dwSampleFlags |= AM_SAMPLE_TIMEVALID | AM_SAMPLE_STOPVALID;\n        }\n        if (S_OK == pSample->GetMediaType(&m_SampleProps.pMediaType))\n        {\n            m_SampleProps.dwSampleFlags |= AM_SAMPLE_TYPECHANGED;\n        }\n        pSample->GetPointer(&m_SampleProps.pbBuffer);\n        m_SampleProps.lActual = pSample->GetActualDataLength();\n        m_SampleProps.cbBuffer = pSample->GetSize();\n    }\n\n    /* Has the format changed in this sample */\n\n    if (!(m_SampleProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED))\n    {\n        return NOERROR;\n    }\n\n    /* Check the derived class accepts this format */\n    /* This shouldn't fail as the source must call QueryAccept first */\n\n    hr = CheckMediaType((CMediaType *)m_SampleProps.pMediaType);\n\n    if (hr == NOERROR)\n    {\n        return NOERROR;\n    }\n\n    /* Raise a runtime error if we fail the media type */\n\n    m_bRunTimeError = TRUE;\n    EndOfStream();\n    m_pFilter->NotifyEvent(EC_ERRORABORT, VFW_E_TYPE_NOT_ACCEPTED, 0);\n    return VFW_E_INVALIDMEDIATYPE;\n}\n\n/*  Receive multiple samples */\nSTDMETHODIMP\nCBaseInputPin::ReceiveMultiple(__in_ecount(nSamples) IMediaSample **pSamples, long nSamples,\n                               __out long *nSamplesProcessed)\n{\n    CheckPointer(pSamples, E_POINTER);\n    ValidateReadPtr(pSamples, nSamples * sizeof(IMediaSample *));\n\n    HRESULT hr = S_OK;\n    *nSamplesProcessed = 0;\n    while (nSamples-- > 0)\n    {\n        hr = Receive(pSamples[*nSamplesProcessed]);\n\n        /*  S_FALSE means don't send any more */\n        if (hr != S_OK)\n        {\n            break;\n        }\n        (*nSamplesProcessed)++;\n    }\n    return hr;\n}\n\n/*  See if Receive() might block */\nSTDMETHODIMP\nCBaseInputPin::ReceiveCanBlock()\n{\n    /*  Ask all the output pins if they block\n        If there are no output pin assume we do block\n    */\n    int cPins = m_pFilter->GetPinCount();\n    int cOutputPins = 0;\n    for (int c = 0; c < cPins; c++)\n    {\n        CBasePin *pPin = m_pFilter->GetPin(c);\n        if (NULL == pPin)\n        {\n            break;\n        }\n        PIN_DIRECTION pd;\n        HRESULT hr = pPin->QueryDirection(&pd);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        if (pd == PINDIR_OUTPUT)\n        {\n\n            IPin *pConnected;\n            hr = pPin->ConnectedTo(&pConnected);\n            if (SUCCEEDED(hr))\n            {\n                ASSERT(pConnected != NULL);\n                cOutputPins++;\n                IMemInputPin *pInputPin;\n                hr = pConnected->QueryInterface(IID_IMemInputPin, (void **)&pInputPin);\n                pConnected->Release();\n                if (SUCCEEDED(hr))\n                {\n                    hr = pInputPin->ReceiveCanBlock();\n                    pInputPin->Release();\n                    if (hr != S_FALSE)\n                    {\n                        return S_OK;\n                    }\n                }\n                else\n                {\n                    /*  There's a transport we don't understand here */\n                    return S_OK;\n                }\n            }\n        }\n    }\n    return cOutputPins == 0 ? S_OK : S_FALSE;\n}\n\n// Default handling for BeginFlush - call at the beginning\n// of your implementation (makes sure that all Receive calls\n// fail). After calling this, you need to free any queued data\n// and then call downstream.\nSTDMETHODIMP\nCBaseInputPin::BeginFlush(void)\n{\n    //  BeginFlush is NOT synchronized with streaming but is part of\n    //  a control action - hence we synchronize with the filter\n    CAutoLock lck(m_pLock);\n\n    // if we are already in mid-flush, this is probably a mistake\n    // though not harmful - try to pick it up for now so I can think about it\n    ASSERT(!m_bFlushing);\n\n    // first thing to do is ensure that no further Receive calls succeed\n    m_bFlushing = TRUE;\n\n    // now discard any data and call downstream - must do that\n    // in derived classes\n    return S_OK;\n}\n\n// default handling for EndFlush - call at end of your implementation\n// - before calling this, ensure that there is no queued data and no thread\n// pushing any more without a further receive, then call downstream,\n// then call this method to clear the m_bFlushing flag and re-enable\n// receives\nSTDMETHODIMP\nCBaseInputPin::EndFlush(void)\n{\n    //  Endlush is NOT synchronized with streaming but is part of\n    //  a control action - hence we synchronize with the filter\n    CAutoLock lck(m_pLock);\n\n    // almost certainly a mistake if we are not in mid-flush\n    ASSERT(m_bFlushing);\n\n    // before calling, sync with pushing thread and ensure\n    // no more data is going downstream, then call EndFlush on\n    // downstream pins.\n\n    // now re-enable Receives\n    m_bFlushing = FALSE;\n\n    // No more errors\n    m_bRunTimeError = FALSE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP\nCBaseInputPin::Notify(IBaseFilter *pSender, Quality q)\n{\n    UNREFERENCED_PARAMETER(q);\n    CheckPointer(pSender, E_POINTER);\n    ValidateReadPtr(pSender, sizeof(IBaseFilter));\n    DbgBreak(\"IQuality::Notify called on an input pin\");\n    return NOERROR;\n} // Notify\n\n/* Free up or unprepare allocator's memory, this is called through\n   IMediaFilter which is responsible for locking the object first */\n\nHRESULT\nCBaseInputPin::Inactive(void)\n{\n    m_bRunTimeError = FALSE;\n    if (m_pAllocator == NULL)\n    {\n        return VFW_E_NO_ALLOCATOR;\n    }\n\n    m_bFlushing = FALSE;\n\n    return m_pAllocator->Decommit();\n}\n\n// what requirements do we have of the allocator - override if you want\n// to support other people's allocators but need a specific alignment\n// or prefix.\nSTDMETHODIMP\nCBaseInputPin::GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps)\n{\n    UNREFERENCED_PARAMETER(pProps);\n    return E_NOTIMPL;\n}\n\n//  Check if it's OK to process data\n//\nHRESULT\nCBaseInputPin::CheckStreaming()\n{\n    //  Shouldn't be able to get any data if we're not connected!\n    ASSERT(IsConnected());\n\n    //  Don't process stuff in Stopped state\n    if (IsStopped())\n    {\n        return VFW_E_WRONG_STATE;\n    }\n    if (m_bFlushing)\n    {\n        return S_FALSE;\n    }\n    if (m_bRunTimeError)\n    {\n        return VFW_E_RUNTIME_ERROR;\n    }\n    return S_OK;\n}\n\n// Pass on the Quality notification q to\n// a. Our QualityControl sink (if we have one) or else\n// b. to our upstream filter\n// and if that doesn't work, throw it away with a bad return code\nHRESULT\nCBaseInputPin::PassNotify(Quality &q)\n{\n    // We pass the message on, which means that we find the quality sink\n    // for our input pin and send it there\n\n    // DbgLog((LOG_TRACE,3,TEXT(\"Passing Quality notification through transform\")));\n    if (m_pQSink != NULL)\n    {\n        return m_pQSink->Notify(m_pFilter, q);\n    }\n    else\n    {\n        // no sink set, so pass it upstream\n        HRESULT hr;\n        IQualityControl *pIQC;\n\n        hr = VFW_E_NOT_FOUND; // default\n        if (m_Connected)\n        {\n            m_Connected->QueryInterface(IID_IQualityControl, (void **)&pIQC);\n\n            if (pIQC != NULL)\n            {\n                hr = pIQC->Notify(m_pFilter, q);\n                pIQC->Release();\n            }\n        }\n        return hr;\n    }\n\n} // PassNotify\n\n//=====================================================================\n//=====================================================================\n// Memory allocation class, implements CMediaSample\n//=====================================================================\n//=====================================================================\n\n/* NOTE The implementation of this class calls the CUnknown constructor with\n   a NULL outer unknown pointer. This has the effect of making us a self\n   contained class, ie any QueryInterface, AddRef or Release calls will be\n   routed to the class's NonDelegatingUnknown methods. You will typically\n   find that the classes that do this then override one or more of these\n   virtual functions to provide more specialised behaviour. A good example\n   of this is where a class wants to keep the QueryInterface internal but\n   still wants it's lifetime controlled by the external object */\n\n/* The last two parameters have default values of NULL and zero */\n\nCMediaSample::CMediaSample(__in_opt LPCTSTR pName, __in_opt CBaseAllocator *pAllocator, __inout_opt HRESULT *phr,\n                           __in_bcount_opt(length) LPBYTE pBuffer,\n                           LONG length)\n    : m_pBuffer(pBuffer)\n    , // Initialise the buffer\n    m_cbBuffer(length)\n    , // And it's length\n    m_lActual(length)\n    , // By default, actual = length\n    m_pMediaType(NULL)\n    , // No media type change\n    m_dwFlags(0)\n    , // Nothing set\n    m_cRef(0)\n    , // 0 ref count\n    m_dwTypeSpecificFlags(0)\n    , // Type specific flags\n    m_dwStreamId(AM_STREAM_MEDIA)\n    ,                        // Stream id\n    m_pAllocator(pAllocator) // Allocator\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(pName ? pName : L\"CMediaSample\", (IMediaSample *)this);\n#endif // DXMPERF\n\n    /* We must have an owner and it must also be derived from class\n       CBaseAllocator BUT we do not hold a reference count on it */\n\n    ASSERT(pAllocator);\n\n    if (length < 0)\n    {\n        *phr = VFW_E_BUFFER_OVERFLOW;\n        m_cbBuffer = 0;\n    }\n}\n\n#ifdef UNICODE\nCMediaSample::CMediaSample(__in_opt LPCSTR pName, __in_opt CBaseAllocator *pAllocator, __inout_opt HRESULT *phr,\n                           __in_bcount_opt(length) LPBYTE pBuffer,\n                           LONG length)\n    : m_pBuffer(pBuffer)\n    , // Initialise the buffer\n    m_cbBuffer(length)\n    , // And it's length\n    m_lActual(length)\n    , // By default, actual = length\n    m_pMediaType(NULL)\n    , // No media type change\n    m_dwFlags(0)\n    , // Nothing set\n    m_cRef(0)\n    , // 0 ref count\n    m_dwTypeSpecificFlags(0)\n    , // Type specific flags\n    m_dwStreamId(AM_STREAM_MEDIA)\n    ,                        // Stream id\n    m_pAllocator(pAllocator) // Allocator\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(L\"CMediaSample\", (IMediaSample *)this);\n#endif // DXMPERF\n\n    /* We must have an owner and it must also be derived from class\n       CBaseAllocator BUT we do not hold a reference count on it */\n\n    ASSERT(pAllocator);\n}\n#endif\n\n/* Destructor deletes the media type memory */\n\nCMediaSample::~CMediaSample()\n{\n#ifdef DXMPERF\n    PERFLOG_DTOR(L\"CMediaSample\", (IMediaSample *)this);\n#endif // DXMPERF\n\n    if (m_pMediaType)\n    {\n        DeleteMediaType(m_pMediaType);\n    }\n}\n\n/* Override this to publicise our interfaces */\n\nSTDMETHODIMP\nCMediaSample::QueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_IMediaSample || riid == IID_IMediaSample2 || riid == IID_IUnknown)\n    {\n        return GetInterface((IMediaSample *)this, ppv);\n    }\n    else\n    {\n        *ppv = NULL;\n        return E_NOINTERFACE;\n    }\n}\n\nSTDMETHODIMP_(ULONG)\nCMediaSample::AddRef()\n{\n    return InterlockedIncrement(&m_cRef);\n}\n\n// --  CMediaSample lifetimes --\n//\n// On final release of this sample buffer it is not deleted but\n// returned to the freelist of the owning memory allocator\n//\n// The allocator may be waiting for the last buffer to be placed on the free\n// list in order to decommit all the memory, so the ReleaseBuffer() call may\n// result in this sample being deleted. We also need to hold a refcount on\n// the allocator to stop that going away until we have finished with this.\n// However, we cannot release the allocator before the ReleaseBuffer, as the\n// release may cause us to be deleted. Similarly we can't do it afterwards.\n//\n// Thus we must leave it to the allocator to hold an addref on our behalf.\n// When he issues us in GetBuffer, he addref's himself. When ReleaseBuffer\n// is called, he releases himself, possibly causing us and him to be deleted.\n\nSTDMETHODIMP_(ULONG)\nCMediaSample::Release()\n{\n    /* Decrement our own private reference count */\n    LONG lRef;\n    if (m_cRef == 1)\n    {\n        lRef = 0;\n        m_cRef = 0;\n    }\n    else\n    {\n        lRef = InterlockedDecrement(&m_cRef);\n    }\n    ASSERT(lRef >= 0);\n\n    DbgLog((LOG_MEMORY, 3, TEXT(\"    Unknown %X ref-- = %d\"), this, m_cRef));\n\n    /* Did we release our final reference count */\n    if (lRef == 0)\n    {\n        /* Free all resources */\n        if (m_dwFlags & Sample_TypeChanged)\n        {\n            SetMediaType(NULL);\n        }\n        ASSERT(m_pMediaType == NULL);\n        m_dwFlags = 0;\n        m_dwTypeSpecificFlags = 0;\n        m_dwStreamId = AM_STREAM_MEDIA;\n\n        /* This may cause us to be deleted */\n        // Our refcount is reliably 0 thus no-one will mess with us\n        m_pAllocator->ReleaseBuffer(this);\n    }\n    return (ULONG)lRef;\n}\n\n// set the buffer pointer and length. Used by allocators that\n// want variable sized pointers or pointers into already-read data.\n// This is only available through a CMediaSample* not an IMediaSample*\n// and so cannot be changed by clients.\nHRESULT\nCMediaSample::SetPointer(__in_bcount(cBytes) BYTE *ptr, LONG cBytes)\n{\n    if (cBytes < 0)\n    {\n        return VFW_E_BUFFER_OVERFLOW;\n    }\n    m_pBuffer = ptr;     // new buffer area (could be null)\n    m_cbBuffer = cBytes; // length of buffer\n    m_lActual = cBytes;  // length of data in buffer (assume full)\n\n    return S_OK;\n}\n\n// get me a read/write pointer to this buffer's memory. I will actually\n// want to use sizeUsed bytes.\nSTDMETHODIMP\nCMediaSample::GetPointer(__deref_out BYTE **ppBuffer)\n{\n    ValidateReadWritePtr(ppBuffer, sizeof(BYTE *));\n\n    // creator must have set pointer either during\n    // constructor or by SetPointer\n    ASSERT(m_pBuffer);\n\n    *ppBuffer = m_pBuffer;\n    return NOERROR;\n}\n\n// return the size in bytes of this buffer\nSTDMETHODIMP_(LONG)\nCMediaSample::GetSize(void)\n{\n    return m_cbBuffer;\n}\n\n// get the stream time at which this sample should start and finish.\nSTDMETHODIMP\nCMediaSample::GetTime(__out REFERENCE_TIME *pTimeStart, // put time here\n                      __out REFERENCE_TIME *pTimeEnd)\n{\n    ValidateReadWritePtr(pTimeStart, sizeof(REFERENCE_TIME));\n    ValidateReadWritePtr(pTimeEnd, sizeof(REFERENCE_TIME));\n\n    if (!(m_dwFlags & Sample_StopValid))\n    {\n        if (!(m_dwFlags & Sample_TimeValid))\n        {\n            return VFW_E_SAMPLE_TIME_NOT_SET;\n        }\n        else\n        {\n            *pTimeStart = m_Start;\n\n            //  Make sure old stuff works\n            *pTimeEnd = m_Start + 1;\n            return VFW_S_NO_STOP_TIME;\n        }\n    }\n\n    *pTimeStart = m_Start;\n    *pTimeEnd = m_End;\n    return NOERROR;\n}\n\n// Set the stream time at which this sample should start and finish.\n// NULL pointers means the time is reset\nSTDMETHODIMP\nCMediaSample::SetTime(__in_opt REFERENCE_TIME *pTimeStart, __in_opt REFERENCE_TIME *pTimeEnd)\n{\n    if (pTimeStart == NULL)\n    {\n        ASSERT(pTimeEnd == NULL);\n        m_dwFlags &= ~(Sample_TimeValid | Sample_StopValid);\n    }\n    else\n    {\n        if (pTimeEnd == NULL)\n        {\n            m_Start = *pTimeStart;\n            m_dwFlags |= Sample_TimeValid;\n            m_dwFlags &= ~Sample_StopValid;\n        }\n        else\n        {\n            ValidateReadPtr(pTimeStart, sizeof(REFERENCE_TIME));\n            ValidateReadPtr(pTimeEnd, sizeof(REFERENCE_TIME));\n            ASSERT(*pTimeEnd >= *pTimeStart);\n\n            m_Start = *pTimeStart;\n            m_End = *pTimeEnd;\n            m_dwFlags |= Sample_TimeValid | Sample_StopValid;\n        }\n    }\n    return NOERROR;\n}\n\n// get the media times (eg bytes) for this sample\nSTDMETHODIMP\nCMediaSample::GetMediaTime(__out LONGLONG *pTimeStart, __out LONGLONG *pTimeEnd)\n{\n    ValidateReadWritePtr(pTimeStart, sizeof(LONGLONG));\n    ValidateReadWritePtr(pTimeEnd, sizeof(LONGLONG));\n\n    if (!(m_dwFlags & Sample_MediaTimeValid))\n    {\n        return VFW_E_MEDIA_TIME_NOT_SET;\n    }\n\n    *pTimeStart = m_MediaStart;\n    *pTimeEnd = (m_MediaStart + m_MediaEnd);\n    return NOERROR;\n}\n\n// Set the media times for this sample\nSTDMETHODIMP\nCMediaSample::SetMediaTime(__in_opt LONGLONG *pTimeStart, __in_opt LONGLONG *pTimeEnd)\n{\n    if (pTimeStart == NULL)\n    {\n        ASSERT(pTimeEnd == NULL);\n        m_dwFlags &= ~Sample_MediaTimeValid;\n    }\n    else\n    {\n        if (NULL == pTimeEnd)\n        {\n            return E_POINTER;\n        }\n        ValidateReadPtr(pTimeStart, sizeof(LONGLONG));\n        ValidateReadPtr(pTimeEnd, sizeof(LONGLONG));\n        ASSERT(*pTimeEnd >= *pTimeStart);\n\n        m_MediaStart = *pTimeStart;\n        m_MediaEnd = (LONG)(*pTimeEnd - *pTimeStart);\n        m_dwFlags |= Sample_MediaTimeValid;\n    }\n    return NOERROR;\n}\n\nSTDMETHODIMP\nCMediaSample::IsSyncPoint(void)\n{\n    if (m_dwFlags & Sample_SyncPoint)\n    {\n        return S_OK;\n    }\n    else\n    {\n        return S_FALSE;\n    }\n}\n\nSTDMETHODIMP\nCMediaSample::SetSyncPoint(BOOL bIsSyncPoint)\n{\n    if (bIsSyncPoint)\n    {\n        m_dwFlags |= Sample_SyncPoint;\n    }\n    else\n    {\n        m_dwFlags &= ~Sample_SyncPoint;\n    }\n    return NOERROR;\n}\n\n// returns S_OK if there is a discontinuity in the data (this same is\n// not a continuation of the previous stream of data\n// - there has been a seek).\nSTDMETHODIMP\nCMediaSample::IsDiscontinuity(void)\n{\n    if (m_dwFlags & Sample_Discontinuity)\n    {\n        return S_OK;\n    }\n    else\n    {\n        return S_FALSE;\n    }\n}\n\n// set the discontinuity property - TRUE if this sample is not a\n// continuation, but a new sample after a seek.\nSTDMETHODIMP\nCMediaSample::SetDiscontinuity(BOOL bDiscont)\n{\n    // should be TRUE or FALSE\n    if (bDiscont)\n    {\n        m_dwFlags |= Sample_Discontinuity;\n    }\n    else\n    {\n        m_dwFlags &= ~Sample_Discontinuity;\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP\nCMediaSample::IsPreroll(void)\n{\n    if (m_dwFlags & Sample_Preroll)\n    {\n        return S_OK;\n    }\n    else\n    {\n        return S_FALSE;\n    }\n}\n\nSTDMETHODIMP\nCMediaSample::SetPreroll(BOOL bIsPreroll)\n{\n    if (bIsPreroll)\n    {\n        m_dwFlags |= Sample_Preroll;\n    }\n    else\n    {\n        m_dwFlags &= ~Sample_Preroll;\n    }\n    return NOERROR;\n}\n\nSTDMETHODIMP_(LONG)\nCMediaSample::GetActualDataLength(void)\n{\n    return m_lActual;\n}\n\nSTDMETHODIMP\nCMediaSample::SetActualDataLength(LONG lActual)\n{\n    if (lActual > m_cbBuffer || lActual < 0)\n    {\n        ASSERT(lActual <= GetSize());\n        return VFW_E_BUFFER_OVERFLOW;\n    }\n    m_lActual = lActual;\n    return NOERROR;\n}\n\n/* These allow for limited format changes in band */\n\nSTDMETHODIMP\nCMediaSample::GetMediaType(__deref_out AM_MEDIA_TYPE **ppMediaType)\n{\n    ValidateReadWritePtr(ppMediaType, sizeof(AM_MEDIA_TYPE *));\n    ASSERT(ppMediaType);\n\n    /* Do we have a new media type for them */\n\n    if (!(m_dwFlags & Sample_TypeChanged))\n    {\n        ASSERT(m_pMediaType == NULL);\n        *ppMediaType = NULL;\n        return S_FALSE;\n    }\n\n    ASSERT(m_pMediaType);\n\n    /* Create a copy of our media type */\n\n    *ppMediaType = CreateMediaType(m_pMediaType);\n    if (*ppMediaType == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n    return NOERROR;\n}\n\n/* Mark this sample as having a different format type */\n\nSTDMETHODIMP\nCMediaSample::SetMediaType(__in_opt AM_MEDIA_TYPE *pMediaType)\n{\n    /* Delete the current media type */\n\n    if (m_pMediaType)\n    {\n        DeleteMediaType(m_pMediaType);\n        m_pMediaType = NULL;\n    }\n\n    /* Mechanism for resetting the format type */\n\n    if (pMediaType == NULL)\n    {\n        m_dwFlags &= ~Sample_TypeChanged;\n        return NOERROR;\n    }\n\n    ASSERT(pMediaType);\n    ValidateReadPtr(pMediaType, sizeof(AM_MEDIA_TYPE));\n\n    /* Take a copy of the media type */\n\n    m_pMediaType = CreateMediaType(pMediaType);\n    if (m_pMediaType == NULL)\n    {\n        m_dwFlags &= ~Sample_TypeChanged;\n        return E_OUTOFMEMORY;\n    }\n\n    m_dwFlags |= Sample_TypeChanged;\n    return NOERROR;\n}\n\n// Set and get properties (IMediaSample2)\nSTDMETHODIMP CMediaSample::GetProperties(DWORD cbProperties, __out_bcount(cbProperties) BYTE *pbProperties)\n{\n    if (0 != cbProperties)\n    {\n        CheckPointer(pbProperties, E_POINTER);\n        //  Return generic stuff up to the length\n        AM_SAMPLE2_PROPERTIES Props;\n        Props.cbData = min(cbProperties, sizeof(Props));\n        Props.dwSampleFlags = m_dwFlags & ~Sample_MediaTimeValid;\n        Props.dwTypeSpecificFlags = m_dwTypeSpecificFlags;\n        Props.pbBuffer = m_pBuffer;\n        Props.cbBuffer = m_cbBuffer;\n        Props.lActual = m_lActual;\n        Props.tStart = m_Start;\n        Props.tStop = m_End;\n        Props.dwStreamId = m_dwStreamId;\n        if (m_dwFlags & AM_SAMPLE_TYPECHANGED)\n        {\n            Props.pMediaType = m_pMediaType;\n        }\n        else\n        {\n            Props.pMediaType = NULL;\n        }\n        CopyMemory(pbProperties, &Props, Props.cbData);\n    }\n    return S_OK;\n}\n\n#define CONTAINS_FIELD(type, field, offset) ((FIELD_OFFSET(type, field) + sizeof(((type *)0)->field)) <= offset)\n\nHRESULT CMediaSample::SetProperties(DWORD cbProperties, __in_bcount(cbProperties) const BYTE *pbProperties)\n{\n\n    /*  Generic properties */\n    AM_MEDIA_TYPE *pMediaType = NULL;\n\n    if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbData, cbProperties))\n    {\n        CheckPointer(pbProperties, E_POINTER);\n        AM_SAMPLE2_PROPERTIES *pProps = (AM_SAMPLE2_PROPERTIES *)pbProperties;\n\n        /*  Don't use more data than is actually there */\n        if (pProps->cbData < cbProperties)\n        {\n            cbProperties = pProps->cbData;\n        }\n        /*  We only handle IMediaSample2 */\n        if (cbProperties > sizeof(*pProps) || pProps->cbData > sizeof(*pProps))\n        {\n            return E_INVALIDARG;\n        }\n        /*  Do checks first, the assignments (for backout) */\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwSampleFlags, cbProperties))\n        {\n            /*  Check the flags */\n            if (pProps->dwSampleFlags & (~Sample_ValidFlags | Sample_MediaTimeValid))\n            {\n                return E_INVALIDARG;\n            }\n            /*  Check a flag isn't being set for a property\n                not being provided\n            */\n            if ((pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID) && !(m_dwFlags & AM_SAMPLE_TIMEVALID) &&\n                !CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStop, cbProperties))\n            {\n                return E_INVALIDARG;\n            }\n        }\n        /*  NB - can't SET the pointer or size */\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pbBuffer, cbProperties))\n        {\n\n            /*  Check pbBuffer */\n            if (pProps->pbBuffer != 0 && pProps->pbBuffer != m_pBuffer)\n            {\n                return E_INVALIDARG;\n            }\n        }\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbBuffer, cbProperties))\n        {\n\n            /*  Check cbBuffer */\n            if (pProps->cbBuffer != 0 && pProps->cbBuffer != m_cbBuffer)\n            {\n                return E_INVALIDARG;\n            }\n        }\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, cbBuffer, cbProperties) &&\n            CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, lActual, cbProperties))\n        {\n\n            /*  Check lActual */\n            if (pProps->cbBuffer < pProps->lActual)\n            {\n                return E_INVALIDARG;\n            }\n        }\n\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pMediaType, cbProperties))\n        {\n\n            /*  Check pMediaType */\n            if (pProps->dwSampleFlags & AM_SAMPLE_TYPECHANGED)\n            {\n                CheckPointer(pProps->pMediaType, E_POINTER);\n                pMediaType = CreateMediaType(pProps->pMediaType);\n                if (pMediaType == NULL)\n                {\n                    return E_OUTOFMEMORY;\n                }\n            }\n        }\n\n        /*  Now do the assignments */\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwStreamId, cbProperties))\n        {\n            m_dwStreamId = pProps->dwStreamId;\n        }\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwSampleFlags, cbProperties))\n        {\n            /*  Set the flags */\n            m_dwFlags = pProps->dwSampleFlags | (m_dwFlags & Sample_MediaTimeValid);\n            m_dwTypeSpecificFlags = pProps->dwTypeSpecificFlags;\n        }\n        else\n        {\n            if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, dwTypeSpecificFlags, cbProperties))\n            {\n                m_dwTypeSpecificFlags = pProps->dwTypeSpecificFlags;\n            }\n        }\n\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, lActual, cbProperties))\n        {\n            /*  Set lActual */\n            m_lActual = pProps->lActual;\n        }\n\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStop, cbProperties))\n        {\n\n            /*  Set the times */\n            m_End = pProps->tStop;\n        }\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, tStart, cbProperties))\n        {\n\n            /*  Set the times */\n            m_Start = pProps->tStart;\n        }\n\n        if (CONTAINS_FIELD(AM_SAMPLE2_PROPERTIES, pMediaType, cbProperties))\n        {\n            /*  Set pMediaType */\n            if (pProps->dwSampleFlags & AM_SAMPLE_TYPECHANGED)\n            {\n                if (m_pMediaType != NULL)\n                {\n                    DeleteMediaType(m_pMediaType);\n                }\n                m_pMediaType = pMediaType;\n            }\n        }\n\n        /*  Fix up the type changed flag to correctly reflect the current state\n            If, for instance the input contained no type change but the\n            output does then if we don't do this we'd lose the\n            output media type.\n        */\n        if (m_pMediaType)\n        {\n            m_dwFlags |= Sample_TypeChanged;\n        }\n        else\n        {\n            m_dwFlags &= ~Sample_TypeChanged;\n        }\n    }\n\n    return S_OK;\n}\n\n//\n// The streaming thread calls IPin::NewSegment(), IPin::EndOfStream(),\n// IMemInputPin::Receive() and IMemInputPin::ReceiveMultiple() on the\n// connected input pin.  The application thread calls Block().  The\n// following class members can only be called by the streaming thread.\n//\n//    Deliver()\n//    DeliverNewSegment()\n//    StartUsingOutputPin()\n//    StopUsingOutputPin()\n//    ChangeOutputFormat()\n//    ChangeMediaType()\n//    DynamicReconnect()\n//\n// The following class members can only be called by the application thread.\n//\n//    Block()\n//    SynchronousBlockOutputPin()\n//    AsynchronousBlockOutputPin()\n//\n\nCDynamicOutputPin::CDynamicOutputPin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                                     __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CBaseOutputPin(pObjectName, pFilter, pLock, phr, pName)\n    , m_hStopEvent(NULL)\n    , m_pGraphConfig(NULL)\n    , m_bPinUsesReadOnlyAllocator(FALSE)\n    , m_BlockState(NOT_BLOCKED)\n    , m_hUnblockOutputPinEvent(NULL)\n    , m_hNotifyCallerPinBlockedEvent(NULL)\n    , m_dwBlockCallerThreadID(0)\n    , m_dwNumOutstandingOutputPinUsers(0)\n{\n    HRESULT hr = Initialize();\n    if (FAILED(hr))\n    {\n        *phr = hr;\n        return;\n    }\n}\n\n#ifdef UNICODE\nCDynamicOutputPin::CDynamicOutputPin(__in_opt LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                                     __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CBaseOutputPin(pObjectName, pFilter, pLock, phr, pName)\n    , m_hStopEvent(NULL)\n    , m_pGraphConfig(NULL)\n    , m_bPinUsesReadOnlyAllocator(FALSE)\n    , m_BlockState(NOT_BLOCKED)\n    , m_hUnblockOutputPinEvent(NULL)\n    , m_hNotifyCallerPinBlockedEvent(NULL)\n    , m_dwBlockCallerThreadID(0)\n    , m_dwNumOutstandingOutputPinUsers(0)\n{\n    HRESULT hr = Initialize();\n    if (FAILED(hr))\n    {\n        *phr = hr;\n        return;\n    }\n}\n#endif\n\nCDynamicOutputPin::~CDynamicOutputPin()\n{\n    if (NULL != m_hUnblockOutputPinEvent)\n    {\n        // This call should not fail because we have access to m_hUnblockOutputPinEvent\n        // and m_hUnblockOutputPinEvent is a valid event.\n        EXECUTE_ASSERT(::CloseHandle(m_hUnblockOutputPinEvent));\n    }\n\n    if (NULL != m_hNotifyCallerPinBlockedEvent)\n    {\n        // This call should not fail because we have access to m_hNotifyCallerPinBlockedEvent\n        // and m_hNotifyCallerPinBlockedEvent is a valid event.\n        EXECUTE_ASSERT(::CloseHandle(m_hNotifyCallerPinBlockedEvent));\n    }\n}\n\nHRESULT CDynamicOutputPin::Initialize(void)\n{\n    m_hUnblockOutputPinEvent = ::CreateEvent(NULL,  // The event will have the default security descriptor.\n                                             TRUE,  // This is a manual reset event.\n                                             TRUE,  // The event is initially signaled.\n                                             NULL); // The event is not named.\n\n    // CreateEvent() returns NULL if an error occurs.\n    if (NULL == m_hUnblockOutputPinEvent)\n    {\n        return AmGetLastErrorToHResult();\n    }\n\n    //  Set flag to say we can reconnect while streaming.\n    SetReconnectWhenActive(true);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDynamicOutputPin::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_IPinFlowControl)\n    {\n        return GetInterface(static_cast<IPinFlowControl *>(this), ppv);\n    }\n    else\n    {\n        return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP CDynamicOutputPin::Disconnect(void)\n{\n    CAutoLock cObjectLock(m_pLock);\n    return DisconnectInternal();\n}\n\nSTDMETHODIMP CDynamicOutputPin::Block(DWORD dwBlockFlags, HANDLE hEvent)\n{\n    const DWORD VALID_FLAGS = AM_PIN_FLOW_CONTROL_BLOCK;\n\n    // Check for illegal flags.\n    if (dwBlockFlags & ~VALID_FLAGS)\n    {\n        return E_INVALIDARG;\n    }\n\n    // Make sure the event is unsignaled.\n    if ((dwBlockFlags & AM_PIN_FLOW_CONTROL_BLOCK) && (NULL != hEvent))\n    {\n        if (!::ResetEvent(hEvent))\n        {\n            return AmGetLastErrorToHResult();\n        }\n    }\n\n    // No flags are set if we are unblocking the output pin.\n    if (0 == dwBlockFlags)\n    {\n\n        // This parameter should be NULL because unblock operations are always synchronous.\n        // There is no need to notify the caller when the event is done.\n        if (NULL != hEvent)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n#ifdef DEBUG\n    AssertValid();\n#endif // DEBUG\n\n    HRESULT hr;\n\n    if (dwBlockFlags & AM_PIN_FLOW_CONTROL_BLOCK)\n    {\n        // IPinFlowControl::Block()'s hEvent parameter is NULL if the block is synchronous.\n        // If hEvent is not NULL, the block is asynchronous.\n        if (NULL == hEvent)\n        {\n            hr = SynchronousBlockOutputPin();\n        }\n        else\n        {\n            hr = AsynchronousBlockOutputPin(hEvent);\n        }\n    }\n    else\n    {\n        hr = UnblockOutputPin();\n    }\n\n#ifdef DEBUG\n    AssertValid();\n#endif // DEBUG\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return S_OK;\n}\n\nHRESULT CDynamicOutputPin::SynchronousBlockOutputPin(void)\n{\n    HANDLE hNotifyCallerPinBlockedEvent = ::CreateEvent(NULL,  // The event will have the default security attributes.\n                                                        FALSE, // This is an automatic reset event.\n                                                        FALSE, // The event is initially unsignaled.\n                                                        NULL); // The event is not named.\n\n    // CreateEvent() returns NULL if an error occurs.\n    if (NULL == hNotifyCallerPinBlockedEvent)\n    {\n        return AmGetLastErrorToHResult();\n    }\n\n    HRESULT hr = AsynchronousBlockOutputPin(hNotifyCallerPinBlockedEvent);\n    if (FAILED(hr))\n    {\n        // This call should not fail because we have access to hNotifyCallerPinBlockedEvent\n        // and hNotifyCallerPinBlockedEvent is a valid event.\n        EXECUTE_ASSERT(::CloseHandle(hNotifyCallerPinBlockedEvent));\n\n        return hr;\n    }\n\n    hr = WaitEvent(hNotifyCallerPinBlockedEvent);\n\n    // This call should not fail because we have access to hNotifyCallerPinBlockedEvent\n    // and hNotifyCallerPinBlockedEvent is a valid event.\n    EXECUTE_ASSERT(::CloseHandle(hNotifyCallerPinBlockedEvent));\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return S_OK;\n}\n\nHRESULT CDynamicOutputPin::AsynchronousBlockOutputPin(HANDLE hNotifyCallerPinBlockedEvent)\n{\n    // This function holds the m_BlockStateLock because it uses\n    // m_dwBlockCallerThreadID, m_BlockState and\n    // m_hNotifyCallerPinBlockedEvent.\n    CAutoLock alBlockStateLock(&m_BlockStateLock);\n\n    if (NOT_BLOCKED != m_BlockState)\n    {\n        if (m_dwBlockCallerThreadID == ::GetCurrentThreadId())\n        {\n            return VFW_E_PIN_ALREADY_BLOCKED_ON_THIS_THREAD;\n        }\n        else\n        {\n            return VFW_E_PIN_ALREADY_BLOCKED;\n        }\n    }\n\n    BOOL fSuccess = ::DuplicateHandle(::GetCurrentProcess(), hNotifyCallerPinBlockedEvent, ::GetCurrentProcess(),\n                                      &m_hNotifyCallerPinBlockedEvent, EVENT_MODIFY_STATE, FALSE, 0);\n    if (!fSuccess)\n    {\n        return AmGetLastErrorToHResult();\n    }\n\n    m_BlockState = PENDING;\n    m_dwBlockCallerThreadID = ::GetCurrentThreadId();\n\n    // The output pin cannot be blocked if the streaming thread is\n    // calling IPin::NewSegment(), IPin::EndOfStream(), IMemInputPin::Receive()\n    // or IMemInputPin::ReceiveMultiple() on the connected input pin.  Also, it\n    // cannot be blocked if the streaming thread is calling DynamicReconnect(),\n    // ChangeMediaType() or ChangeOutputFormat().\n    if (!StreamingThreadUsingOutputPin())\n    {\n\n        // The output pin can be immediately blocked.\n        BlockOutputPin();\n    }\n\n    return S_OK;\n}\n\nvoid CDynamicOutputPin::BlockOutputPin(void)\n{\n    // The caller should always hold the m_BlockStateLock because this function\n    // uses m_BlockState and m_hNotifyCallerPinBlockedEvent.\n    ASSERT(CritCheckIn(&m_BlockStateLock));\n\n    // This function should not be called if the streaming thread is modifying\n    // the connection state or it's passing data downstream.\n    ASSERT(!StreamingThreadUsingOutputPin());\n\n    // This should not fail because we successfully created the event\n    // and we have the security permissions to change it's state.\n    EXECUTE_ASSERT(::ResetEvent(m_hUnblockOutputPinEvent));\n\n    // This event should not fail because AsynchronousBlockOutputPin() successfully\n    // duplicated this handle and we have the appropriate security permissions.\n    EXECUTE_ASSERT(::SetEvent(m_hNotifyCallerPinBlockedEvent));\n    EXECUTE_ASSERT(::CloseHandle(m_hNotifyCallerPinBlockedEvent));\n\n    m_BlockState = BLOCKED;\n    m_hNotifyCallerPinBlockedEvent = NULL;\n}\n\nHRESULT CDynamicOutputPin::UnblockOutputPin(void)\n{\n    // UnblockOutputPin() holds the m_BlockStateLock because it\n    // uses m_BlockState, m_dwBlockCallerThreadID and\n    // m_hNotifyCallerPinBlockedEvent.\n    CAutoLock alBlockStateLock(&m_BlockStateLock);\n\n    if (NOT_BLOCKED == m_BlockState)\n    {\n        return S_FALSE;\n    }\n\n    // This should not fail because we successfully created the event\n    // and we have the security permissions to change it's state.\n    EXECUTE_ASSERT(::SetEvent(m_hUnblockOutputPinEvent));\n\n    // Cancel the block operation if it's still pending.\n    if (NULL != m_hNotifyCallerPinBlockedEvent)\n    {\n        // This event should not fail because AsynchronousBlockOutputPin() successfully\n        // duplicated this handle and we have the appropriate security permissions.\n        EXECUTE_ASSERT(::SetEvent(m_hNotifyCallerPinBlockedEvent));\n        EXECUTE_ASSERT(::CloseHandle(m_hNotifyCallerPinBlockedEvent));\n    }\n\n    m_BlockState = NOT_BLOCKED;\n    m_dwBlockCallerThreadID = 0;\n    m_hNotifyCallerPinBlockedEvent = NULL;\n\n    return S_OK;\n}\n\nHRESULT CDynamicOutputPin::StartUsingOutputPin(void)\n{\n    // The caller should not hold m_BlockStateLock.  If the caller does,\n    // a deadlock could occur.\n    ASSERT(CritCheckOut(&m_BlockStateLock));\n\n    CAutoLock alBlockStateLock(&m_BlockStateLock);\n\n#ifdef DEBUG\n    AssertValid();\n#endif // DEBUG\n\n    // Are we in the middle of a block operation?\n    while (BLOCKED == m_BlockState)\n    {\n        m_BlockStateLock.Unlock();\n\n        // If this ASSERT fires, a deadlock could occur.  The caller should make sure\n        // that this thread never acquires the Block State lock more than once.\n        ASSERT(CritCheckOut(&m_BlockStateLock));\n\n        // WaitForMultipleObjects() returns WAIT_OBJECT_0 if the unblock event\n        // is fired.  It returns WAIT_OBJECT_0 + 1 if the stop event if fired.\n        // See the Windows SDK documentation for more information on\n        // WaitForMultipleObjects().\n        const DWORD UNBLOCK = WAIT_OBJECT_0;\n        const DWORD STOP = WAIT_OBJECT_0 + 1;\n\n        HANDLE ahWaitEvents[] = {m_hUnblockOutputPinEvent, m_hStopEvent};\n        DWORD dwNumWaitEvents = sizeof(ahWaitEvents) / sizeof(HANDLE);\n\n        DWORD dwReturnValue = ::WaitForMultipleObjects(dwNumWaitEvents, ahWaitEvents, FALSE, INFINITE);\n\n        m_BlockStateLock.Lock();\n\n#ifdef DEBUG\n        AssertValid();\n#endif // DEBUG\n\n        switch (dwReturnValue)\n        {\n        case UNBLOCK: break;\n\n        case STOP: return VFW_E_STATE_CHANGED;\n\n        case WAIT_FAILED: return AmGetLastErrorToHResult();\n\n        default:\n            DbgBreak(\"An Unexpected case occured in CDynamicOutputPin::StartUsingOutputPin().\");\n            return E_UNEXPECTED;\n        }\n    }\n\n    m_dwNumOutstandingOutputPinUsers++;\n\n#ifdef DEBUG\n    AssertValid();\n#endif // DEBUG\n\n    return S_OK;\n}\n\nvoid CDynamicOutputPin::StopUsingOutputPin(void)\n{\n    CAutoLock alBlockStateLock(&m_BlockStateLock);\n\n#ifdef DEBUG\n    AssertValid();\n#endif // DEBUG\n\n    m_dwNumOutstandingOutputPinUsers--;\n\n    if ((m_dwNumOutstandingOutputPinUsers == 0) && (NOT_BLOCKED != m_BlockState))\n    {\n        BlockOutputPin();\n    }\n\n#ifdef DEBUG\n    AssertValid();\n#endif // DEBUG\n}\n\nbool CDynamicOutputPin::StreamingThreadUsingOutputPin(void)\n{\n    CAutoLock alBlockStateLock(&m_BlockStateLock);\n\n    return (m_dwNumOutstandingOutputPinUsers > 0);\n}\n\nvoid CDynamicOutputPin::SetConfigInfo(IGraphConfig *pGraphConfig, HANDLE hStopEvent)\n{\n    // This pointer is not addrefed because filters are not allowed to\n    // hold references to the filter graph manager.  See the documentation for\n    // IBaseFilter::JoinFilterGraph() in the Direct Show SDK for more information.\n    m_pGraphConfig = pGraphConfig;\n\n    m_hStopEvent = hStopEvent;\n}\n\nHRESULT CDynamicOutputPin::Active(void)\n{\n    // Make sure the user initialized the object by calling SetConfigInfo().\n    if ((NULL == m_hStopEvent) || (NULL == m_pGraphConfig))\n    {\n        DbgBreak(ERROR\n                 : CDynamicOutputPin::Active() failed because m_pGraphConfig and\n                       m_hStopEvent were not initialized.Call SetConfigInfo() to initialize them.);\n        return E_FAIL;\n    }\n\n    // If this ASSERT fires, the user may have passed an invalid event handle to SetConfigInfo().\n    // The ASSERT can also fire if the event if destroyed and then Active() is called.  An event\n    // handle is invalid if 1) the event does not exist or the user does not have the security\n    // permissions to use the event.\n    EXECUTE_ASSERT(ResetEvent(m_hStopEvent));\n\n    return CBaseOutputPin::Active();\n}\n\nHRESULT CDynamicOutputPin::Inactive(void)\n{\n    // If this ASSERT fires, the user may have passed an invalid event handle to SetConfigInfo().\n    // The ASSERT can also fire if the event if destroyed and then Active() is called.  An event\n    // handle is invalid if 1) the event does not exist or the user does not have the security\n    // permissions to use the event.\n    EXECUTE_ASSERT(SetEvent(m_hStopEvent));\n\n    return CBaseOutputPin::Inactive();\n}\n\nHRESULT CDynamicOutputPin::DeliverBeginFlush(void)\n{\n    // If this ASSERT fires, the user may have passed an invalid event handle to SetConfigInfo().\n    // The ASSERT can also fire if the event if destroyed and then DeliverBeginFlush() is called.\n    // An event handle is invalid if 1) the event does not exist or the user does not have the security\n    // permissions to use the event.\n    EXECUTE_ASSERT(SetEvent(m_hStopEvent));\n\n    return CBaseOutputPin::DeliverBeginFlush();\n}\n\nHRESULT CDynamicOutputPin::DeliverEndFlush(void)\n{\n    // If this ASSERT fires, the user may have passed an invalid event handle to SetConfigInfo().\n    // The ASSERT can also fire if the event if destroyed and then DeliverBeginFlush() is called.\n    // An event handle is invalid if 1) the event does not exist or the user does not have the security\n    // permissions to use the event.\n    EXECUTE_ASSERT(ResetEvent(m_hStopEvent));\n\n    return CBaseOutputPin::DeliverEndFlush();\n}\n\n// ChangeOutputFormat() either dynamicly changes the connection's format type or it dynamicly\n// reconnects the output pin.\nHRESULT CDynamicOutputPin::ChangeOutputFormat(const AM_MEDIA_TYPE *pmt, REFERENCE_TIME tSegmentStart,\n                                              REFERENCE_TIME tSegmentStop, double dSegmentRate)\n{\n    // The caller should call StartUsingOutputPin() before calling this\n    // method.\n    ASSERT(StreamingThreadUsingOutputPin());\n\n    // Callers should always pass a valid media type to ChangeOutputFormat() .\n    ASSERT(NULL != pmt);\n\n    CMediaType cmt(*pmt);\n    HRESULT hr = ChangeMediaType(&cmt);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = DeliverNewSegment(tSegmentStart, tSegmentStop, dSegmentRate);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return S_OK;\n}\n\nHRESULT CDynamicOutputPin::ChangeMediaType(const CMediaType *pmt)\n{\n    // The caller should call StartUsingOutputPin() before calling this\n    // method.\n    ASSERT(StreamingThreadUsingOutputPin());\n\n    // This function assumes the filter graph is running.\n    ASSERT(!IsStopped());\n\n    if (!IsConnected())\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n\n    /*  First check if the downstream pin will accept a dynamic\n        format change\n    */\n    QzCComPtr<IPinConnection> pConnection;\n\n    m_Connected->QueryInterface(IID_IPinConnection, (void **)&pConnection);\n    if (pConnection != NULL)\n    {\n\n        if (S_OK == pConnection->DynamicQueryAccept(pmt))\n        {\n\n            HRESULT hr = ChangeMediaTypeHelper(pmt);\n            if (FAILED(hr))\n            {\n                return hr;\n            }\n\n            return S_OK;\n        }\n    }\n\n    /*  Can't do the dynamic connection */\n    return DynamicReconnect(pmt);\n}\n\nHRESULT CDynamicOutputPin::ChangeMediaTypeHelper(const CMediaType *pmt)\n{\n    // The caller should call StartUsingOutputPin() before calling this\n    // method.\n    ASSERT(StreamingThreadUsingOutputPin());\n\n    HRESULT hr = m_Connected->ReceiveConnection(this, pmt);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = SetMediaType(pmt);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Does this pin use the local memory transport?\n    if (NULL != m_pInputPin)\n    {\n        // This function assumes that m_pInputPin and m_Connected are\n        // two different interfaces to the same object.\n        ASSERT(::IsEqualObject(m_Connected, m_pInputPin));\n\n        ALLOCATOR_PROPERTIES apInputPinRequirements;\n        apInputPinRequirements.cbAlign = 0;\n        apInputPinRequirements.cbBuffer = 0;\n        apInputPinRequirements.cbPrefix = 0;\n        apInputPinRequirements.cBuffers = 0;\n\n        m_pInputPin->GetAllocatorRequirements(&apInputPinRequirements);\n\n        // A zero allignment does not make any sense.\n        if (0 == apInputPinRequirements.cbAlign)\n        {\n            apInputPinRequirements.cbAlign = 1;\n        }\n\n        hr = m_pAllocator->Decommit();\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        hr = DecideBufferSize(m_pAllocator, &apInputPinRequirements);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        hr = m_pAllocator->Commit();\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        hr = m_pInputPin->NotifyAllocator(m_pAllocator, m_bPinUsesReadOnlyAllocator);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n    }\n\n    return S_OK;\n}\n\n// this method has to be called from the thread that is pushing data,\n// and it's the caller's responsibility to make sure that the thread\n// has no outstand samples because they cannot be delivered after a\n// reconnect\n//\nHRESULT CDynamicOutputPin::DynamicReconnect(const CMediaType *pmt)\n{\n    // The caller should call StartUsingOutputPin() before calling this\n    // method.\n    ASSERT(StreamingThreadUsingOutputPin());\n\n    if ((m_pGraphConfig == NULL) || (NULL == m_hStopEvent))\n    {\n        return E_FAIL;\n    }\n\n    HRESULT hr =\n        m_pGraphConfig->Reconnect(this, NULL, pmt, NULL, m_hStopEvent, AM_GRAPH_CONFIG_RECONNECT_CACHE_REMOVED_FILTERS);\n\n    return hr;\n}\n\nHRESULT CDynamicOutputPin::CompleteConnect(IPin *pReceivePin)\n{\n    HRESULT hr = CBaseOutputPin::CompleteConnect(pReceivePin);\n    if (SUCCEEDED(hr))\n    {\n        if (!IsStopped() && m_pAllocator)\n        {\n            hr = m_pAllocator->Commit();\n            ASSERT(hr != VFW_E_ALREADY_COMMITTED);\n        }\n    }\n\n    return hr;\n}\n\n#ifdef DEBUG\nvoid CDynamicOutputPin::AssertValid(void)\n{\n    // Make sure the object was correctly initialized.\n\n    // This ASSERT only fires if the object failed to initialize\n    // and the user ignored the constructor's return code (phr).\n    ASSERT(NULL != m_hUnblockOutputPinEvent);\n\n    // If either of these ASSERTs fire, the user did not correctly call\n    // SetConfigInfo().\n    ASSERT(NULL != m_hStopEvent);\n    ASSERT(NULL != m_pGraphConfig);\n\n    // Make sure the block state is consistent.\n\n    CAutoLock alBlockStateLock(&m_BlockStateLock);\n\n    // BLOCK_STATE variables only have three legal values: PENDING, BLOCKED and NOT_BLOCKED.\n    ASSERT((NOT_BLOCKED == m_BlockState) || (PENDING == m_BlockState) || (BLOCKED == m_BlockState));\n\n    // m_hNotifyCallerPinBlockedEvent is only needed when a block operation cannot complete\n    // immediately.\n    ASSERT(((NULL == m_hNotifyCallerPinBlockedEvent) && (PENDING != m_BlockState)) ||\n           ((NULL != m_hNotifyCallerPinBlockedEvent) && (PENDING == m_BlockState)));\n\n    // m_dwBlockCallerThreadID should always be 0 if the pin is not blocked and\n    // the user is not trying to block the pin.\n    ASSERT((0 == m_dwBlockCallerThreadID) || (NOT_BLOCKED != m_BlockState));\n\n    // If this ASSERT fires, the streaming thread is using the output pin and the\n    // output pin is blocked.\n    ASSERT(((0 != m_dwNumOutstandingOutputPinUsers) && (BLOCKED != m_BlockState)) ||\n           ((0 == m_dwNumOutstandingOutputPinUsers) && (NOT_BLOCKED != m_BlockState)) ||\n           ((0 == m_dwNumOutstandingOutputPinUsers) && (NOT_BLOCKED == m_BlockState)));\n}\n#endif // DEBUG\n\nHRESULT CDynamicOutputPin::WaitEvent(HANDLE hEvent)\n{\n    const DWORD EVENT_SIGNALED = WAIT_OBJECT_0;\n\n    DWORD dwReturnValue = ::WaitForSingleObject(hEvent, INFINITE);\n\n    switch (dwReturnValue)\n    {\n    case EVENT_SIGNALED: return S_OK;\n\n    case WAIT_FAILED: return AmGetLastErrorToHResult();\n\n    default: DbgBreak(\"An Unexpected case occured in CDynamicOutputPin::WaitEvent().\"); return E_UNEXPECTED;\n    }\n}\n\n//=====================================================================\n//=====================================================================\n// Implements CBaseAllocator\n//=====================================================================\n//=====================================================================\n\n/* Constructor overrides the default settings for the free list to request\n   that it be alertable (ie the list can be cast to a handle which can be\n   passed to WaitForSingleObject). Both of the allocator lists also ask for\n   object locking, the all list matches the object default settings but I\n   have included them here just so it is obvious what kind of list it is */\n\nCBaseAllocator::CBaseAllocator(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr, BOOL bEvent,\n                               BOOL fEnableReleaseCallback)\n    : CUnknown(pName, pUnk)\n    , m_lAllocated(0)\n    , m_bChanged(FALSE)\n    , m_bCommitted(FALSE)\n    , m_bDecommitInProgress(FALSE)\n    , m_lSize(0)\n    , m_lCount(0)\n    , m_lAlignment(0)\n    , m_lPrefix(0)\n    , m_hSem(NULL)\n    , m_lWaiting(0)\n    , m_fEnableReleaseCallback(fEnableReleaseCallback)\n    , m_pNotify(NULL)\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(pName ? pName : L\"CBaseAllocator\", (IMemAllocator *)this);\n#endif // DXMPERF\n\n    if (bEvent)\n    {\n        m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);\n        if (m_hSem == NULL)\n        {\n            *phr = E_OUTOFMEMORY;\n            return;\n        }\n    }\n}\n\n#ifdef UNICODE\nCBaseAllocator::CBaseAllocator(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr, BOOL bEvent,\n                               BOOL fEnableReleaseCallback)\n    : CUnknown(pName, pUnk)\n    , m_lAllocated(0)\n    , m_bChanged(FALSE)\n    , m_bCommitted(FALSE)\n    , m_bDecommitInProgress(FALSE)\n    , m_lSize(0)\n    , m_lCount(0)\n    , m_lAlignment(0)\n    , m_lPrefix(0)\n    , m_hSem(NULL)\n    , m_lWaiting(0)\n    , m_fEnableReleaseCallback(fEnableReleaseCallback)\n    , m_pNotify(NULL)\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(L\"CBaseAllocator\", (IMemAllocator *)this);\n#endif // DXMPERF\n\n    if (bEvent)\n    {\n        m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);\n        if (m_hSem == NULL)\n        {\n            *phr = E_OUTOFMEMORY;\n            return;\n        }\n    }\n}\n#endif\n\n/* Destructor */\n\nCBaseAllocator::~CBaseAllocator()\n{\n    // we can't call Decommit here since that would mean a call to a\n    // pure virtual in destructor.\n    // We must assume that the derived class has gone into decommit state in\n    // its destructor.\n#ifdef DXMPERF\n    PERFLOG_DTOR(L\"CBaseAllocator\", (IMemAllocator *)this);\n#endif // DXMPERF\n\n    ASSERT(!m_bCommitted);\n    if (m_hSem != NULL)\n    {\n        EXECUTE_ASSERT(CloseHandle(m_hSem));\n    }\n    if (m_pNotify)\n    {\n        m_pNotify->Release();\n    }\n}\n\n/* Override this to publicise our interfaces */\n\nSTDMETHODIMP\nCBaseAllocator::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    /* Do we know about this interface */\n\n    if (riid == IID_IMemAllocator || riid == IID_IMemAllocatorCallbackTemp && m_fEnableReleaseCallback)\n    {\n        return GetInterface((IMemAllocatorCallbackTemp *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n/* This sets the size and count of the required samples. The memory isn't\n   actually allocated until Commit() is called, if memory has already been\n   allocated then assuming no samples are outstanding the user may call us\n   to change the buffering, the memory will be released in Commit() */\n\nSTDMETHODIMP\nCBaseAllocator::SetProperties(__in ALLOCATOR_PROPERTIES *pRequest, __out ALLOCATOR_PROPERTIES *pActual)\n{\n    CheckPointer(pRequest, E_POINTER);\n    CheckPointer(pActual, E_POINTER);\n    ValidateReadWritePtr(pActual, sizeof(ALLOCATOR_PROPERTIES));\n    CAutoLock cObjectLock(this);\n\n    ZeroMemory(pActual, sizeof(ALLOCATOR_PROPERTIES));\n\n    ASSERT(pRequest->cbBuffer > 0);\n\n    /*  Check the alignment requested */\n    if (pRequest->cbAlign != 1)\n    {\n        DbgLog((LOG_ERROR, 2, TEXT(\"Alignment requested was 0x%x, not 1\"), pRequest->cbAlign));\n        return VFW_E_BADALIGN;\n    }\n\n    /* Can't do this if already committed, there is an argument that says we\n       should not reject the SetProperties call if there are buffers still\n       active. However this is called by the source filter, which is the same\n       person who is holding the samples. Therefore it is not unreasonable\n       for them to free all their samples before changing the requirements */\n\n    if (m_bCommitted)\n    {\n        return VFW_E_ALREADY_COMMITTED;\n    }\n\n    /* Must be no outstanding buffers */\n\n    if (m_lAllocated != m_lFree.GetCount())\n    {\n        return VFW_E_BUFFERS_OUTSTANDING;\n    }\n\n    /* There isn't any real need to check the parameters as they\n       will just be rejected when the user finally calls Commit */\n\n    pActual->cbBuffer = m_lSize = pRequest->cbBuffer;\n    pActual->cBuffers = m_lCount = pRequest->cBuffers;\n    pActual->cbAlign = m_lAlignment = pRequest->cbAlign;\n    pActual->cbPrefix = m_lPrefix = pRequest->cbPrefix;\n\n    m_bChanged = TRUE;\n    return NOERROR;\n}\n\nSTDMETHODIMP\nCBaseAllocator::GetProperties(__out ALLOCATOR_PROPERTIES *pActual)\n{\n    CheckPointer(pActual, E_POINTER);\n    ValidateReadWritePtr(pActual, sizeof(ALLOCATOR_PROPERTIES));\n\n    CAutoLock cObjectLock(this);\n    pActual->cbBuffer = m_lSize;\n    pActual->cBuffers = m_lCount;\n    pActual->cbAlign = m_lAlignment;\n    pActual->cbPrefix = m_lPrefix;\n    return NOERROR;\n}\n\n// get container for a sample. Blocking, synchronous call to get the\n// next free buffer (as represented by an IMediaSample interface).\n// on return, the time etc properties will be invalid, but the buffer\n// pointer and size will be correct.\n\nHRESULT CBaseAllocator::GetBuffer(__deref_out IMediaSample **ppBuffer, __in_opt REFERENCE_TIME *pStartTime,\n                                  __in_opt REFERENCE_TIME *pEndTime, DWORD dwFlags)\n{\n    UNREFERENCED_PARAMETER(pStartTime);\n    UNREFERENCED_PARAMETER(pEndTime);\n    UNREFERENCED_PARAMETER(dwFlags);\n    CMediaSample *pSample;\n\n    *ppBuffer = NULL;\n    for (;;)\n    {\n        { // scope for lock\n            CAutoLock cObjectLock(this);\n\n            /* Check we are committed */\n            if (!m_bCommitted)\n            {\n                return VFW_E_NOT_COMMITTED;\n            }\n            pSample = (CMediaSample *)m_lFree.RemoveHead();\n            if (pSample == NULL)\n            {\n                SetWaiting();\n            }\n        }\n\n        /* If we didn't get a sample then wait for the list to signal */\n\n        if (pSample)\n        {\n            break;\n        }\n        if (dwFlags & AM_GBF_NOWAIT)\n        {\n            return VFW_E_TIMEOUT;\n        }\n        ASSERT(m_hSem != NULL);\n        WaitForSingleObject(m_hSem, INFINITE);\n    }\n\n    /* Addref the buffer up to one. On release\n       back to zero instead of being deleted, it will requeue itself by\n       calling the ReleaseBuffer member function. NOTE the owner of a\n       media sample must always be derived from CBaseAllocator */\n\n    ASSERT(pSample->m_cRef == 0);\n    pSample->m_cRef = 1;\n    *ppBuffer = pSample;\n\n#ifdef DXMPERF\n    PERFLOG_GETBUFFER((IMemAllocator *)this, pSample);\n#endif // DXMPERF\n\n    return NOERROR;\n}\n\n/* Final release of a CMediaSample will call this */\n\nSTDMETHODIMP\nCBaseAllocator::ReleaseBuffer(IMediaSample *pSample)\n{\n    CheckPointer(pSample, E_POINTER);\n    ValidateReadPtr(pSample, sizeof(IMediaSample));\n\n#ifdef DXMPERF\n    PERFLOG_RELBUFFER((IMemAllocator *)this, pSample);\n#endif // DXMPERF\n\n    BOOL bRelease = FALSE;\n    {\n        CAutoLock cal(this);\n\n        /* Put back on the free list */\n\n        m_lFree.Add((CMediaSample *)pSample);\n        if (m_lWaiting != 0)\n        {\n            NotifySample();\n        }\n\n        // if there is a pending Decommit, then we need to complete it by\n        // calling Free() when the last buffer is placed on the free list\n\n        LONG l1 = m_lFree.GetCount();\n        if (m_bDecommitInProgress && (l1 == m_lAllocated))\n        {\n            Free();\n            m_bDecommitInProgress = FALSE;\n            bRelease = TRUE;\n        }\n    }\n\n    if (m_pNotify)\n    {\n\n        ASSERT(m_fEnableReleaseCallback);\n\n        //\n        // Note that this is not synchronized with setting up a notification\n        // method.\n        //\n        m_pNotify->NotifyRelease();\n    }\n\n    /* For each buffer there is one AddRef, made in GetBuffer and released\n       here. This may cause the allocator and all samples to be deleted */\n\n    if (bRelease)\n    {\n        Release();\n    }\n    return NOERROR;\n}\n\nSTDMETHODIMP\nCBaseAllocator::SetNotify(IMemAllocatorNotifyCallbackTemp *pNotify)\n{\n    ASSERT(m_fEnableReleaseCallback);\n    CAutoLock lck(this);\n    if (pNotify)\n    {\n        pNotify->AddRef();\n    }\n    if (m_pNotify)\n    {\n        m_pNotify->Release();\n    }\n    m_pNotify = pNotify;\n    return S_OK;\n}\n\nSTDMETHODIMP\nCBaseAllocator::GetFreeCount(__out LONG *plBuffersFree)\n{\n    ASSERT(m_fEnableReleaseCallback);\n    CAutoLock cObjectLock(this);\n    *plBuffersFree = m_lCount - m_lAllocated + m_lFree.GetCount();\n    return NOERROR;\n}\n\nvoid CBaseAllocator::NotifySample()\n{\n    if (m_lWaiting != 0)\n    {\n        ASSERT(m_hSem != NULL);\n        ReleaseSemaphore(m_hSem, m_lWaiting, 0);\n        m_lWaiting = 0;\n    }\n}\n\nSTDMETHODIMP\nCBaseAllocator::Commit()\n{\n    /* Check we are not decommitted */\n    CAutoLock cObjectLock(this);\n\n    // cannot need to alloc or re-alloc if we are committed\n    if (m_bCommitted)\n    {\n        return NOERROR;\n    }\n\n    // is there a pending decommit ? if so, just cancel it\n    if (m_bDecommitInProgress)\n    {\n        m_bDecommitInProgress = FALSE;\n        m_bCommitted = TRUE;\n\n        // don't call Alloc at this point. He cannot allow SetProperties\n        // between Decommit and the last free, so the buffer size cannot have\n        // changed. And because some of the buffers are not free yet, he\n        // cannot re-alloc anyway.\n        return NOERROR;\n    }\n\n    DbgLog((LOG_MEMORY, 1, TEXT(\"Allocating: %ldx%ld\"), m_lCount, m_lSize));\n\n    // actually need to allocate the samples\n    HRESULT hr = Alloc();\n    if (FAILED(hr))\n    {\n        m_bCommitted = FALSE;\n        return hr;\n    }\n\n    /* Allow GetBuffer calls */\n    m_bCommitted = TRUE;\n\n    AddRef();\n    return NOERROR;\n}\n\nSTDMETHODIMP\nCBaseAllocator::Decommit()\n{\n    BOOL bRelease = FALSE;\n    {\n        /* Check we are not already decommitted */\n        CAutoLock cObjectLock(this);\n        if (m_bCommitted == FALSE)\n        {\n            if (m_bDecommitInProgress == FALSE)\n            {\n                return NOERROR;\n            }\n        }\n\n        /* No more GetBuffer calls will succeed */\n        m_bCommitted = FALSE;\n\n        // are any buffers outstanding?\n        if (m_lFree.GetCount() < m_lAllocated)\n        {\n            // please complete the decommit when last buffer is freed\n            m_bDecommitInProgress = TRUE;\n        }\n        else\n        {\n            m_bDecommitInProgress = FALSE;\n\n            // need to complete the decommit here as there are no\n            // outstanding buffers\n\n            Free();\n            bRelease = TRUE;\n        }\n\n        // Tell anyone waiting that they can go now so we can\n        // reject their call\n#pragma warning(push)\n#ifndef _PREFAST_\n#pragma warning(disable : 4068)\n#endif\n#pragma prefast(                \\\n    suppress                    \\\n    : __WARNING_DEREF_NULL_PTR, \\\n      \"Suppress warning related to Free() invalidating 'this' which is no applicable to CBaseAllocator::Free()\")\n        NotifySample();\n\n#pragma warning(pop)\n    }\n\n    if (bRelease)\n    {\n        Release();\n    }\n    return NOERROR;\n}\n\n/* Base definition of allocation which checks we are ok to go ahead and do\n   the full allocation. We return S_FALSE if the requirements are the same */\n\nHRESULT\nCBaseAllocator::Alloc(void)\n{\n    /* Error if he hasn't set the size yet */\n    if (m_lCount <= 0 || m_lSize <= 0 || m_lAlignment <= 0)\n    {\n        return VFW_E_SIZENOTSET;\n    }\n\n    /* should never get here while buffers outstanding */\n    ASSERT(m_lFree.GetCount() == m_lAllocated);\n\n    /* If the requirements haven't changed then don't reallocate */\n    if (m_bChanged == FALSE)\n    {\n        return S_FALSE;\n    }\n\n    return NOERROR;\n}\n\n/*  Implement CBaseAllocator::CSampleList::Remove(pSample)\n    Removes pSample from the list\n*/\nvoid CBaseAllocator::CSampleList::Remove(__inout CMediaSample *pSample)\n{\n    CMediaSample **pSearch;\n    for (pSearch = &m_List; *pSearch != NULL; pSearch = &(CBaseAllocator::NextSample(*pSearch)))\n    {\n        if (*pSearch == pSample)\n        {\n            *pSearch = CBaseAllocator::NextSample(pSample);\n            CBaseAllocator::NextSample(pSample) = NULL;\n            m_nOnList--;\n            return;\n        }\n    }\n    DbgBreak(\"Couldn't find sample in list\");\n}\n\n//=====================================================================\n//=====================================================================\n// Implements CMemAllocator\n//=====================================================================\n//=====================================================================\n\n/* This goes in the factory template table to create new instances */\nCUnknown *CMemAllocator::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)\n{\n    CUnknown *pUnkRet = new CMemAllocator(NAME(\"CMemAllocator\"), pUnk, phr);\n    return pUnkRet;\n}\n\nCMemAllocator::CMemAllocator(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)\n    : CBaseAllocator(pName, pUnk, phr, TRUE, TRUE)\n    , m_pBuffer(NULL)\n{\n}\n\n#ifdef UNICODE\nCMemAllocator::CMemAllocator(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)\n    : CBaseAllocator(pName, pUnk, phr, TRUE, TRUE)\n    , m_pBuffer(NULL)\n{\n}\n#endif\n\n/* This sets the size and count of the required samples. The memory isn't\n   actually allocated until Commit() is called, if memory has already been\n   allocated then assuming no samples are outstanding the user may call us\n   to change the buffering, the memory will be released in Commit() */\nSTDMETHODIMP\nCMemAllocator::SetProperties(__in ALLOCATOR_PROPERTIES *pRequest, __out ALLOCATOR_PROPERTIES *pActual)\n{\n    CheckPointer(pActual, E_POINTER);\n    ValidateReadWritePtr(pActual, sizeof(ALLOCATOR_PROPERTIES));\n    CAutoLock cObjectLock(this);\n\n    ZeroMemory(pActual, sizeof(ALLOCATOR_PROPERTIES));\n\n    ASSERT(pRequest->cbBuffer > 0);\n\n    SYSTEM_INFO SysInfo;\n    GetSystemInfo(&SysInfo);\n\n    /*  Check the alignment request is a power of 2 */\n    if ((-pRequest->cbAlign & pRequest->cbAlign) != pRequest->cbAlign)\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"Alignment requested 0x%x not a power of 2!\"), pRequest->cbAlign));\n    }\n    /*  Check the alignment requested */\n    if (pRequest->cbAlign == 0 || (SysInfo.dwAllocationGranularity & (pRequest->cbAlign - 1)) != 0)\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"Invalid alignment 0x%x requested - granularity = 0x%x\"), pRequest->cbAlign,\n                SysInfo.dwAllocationGranularity));\n        return VFW_E_BADALIGN;\n    }\n\n    /* Can't do this if already committed, there is an argument that says we\n       should not reject the SetProperties call if there are buffers still\n       active. However this is called by the source filter, which is the same\n       person who is holding the samples. Therefore it is not unreasonable\n       for them to free all their samples before changing the requirements */\n\n    if (m_bCommitted == TRUE)\n    {\n        return VFW_E_ALREADY_COMMITTED;\n    }\n\n    /* Must be no outstanding buffers */\n\n    if (m_lFree.GetCount() < m_lAllocated)\n    {\n        return VFW_E_BUFFERS_OUTSTANDING;\n    }\n\n    /* There isn't any real need to check the parameters as they\n       will just be rejected when the user finally calls Commit */\n\n    // round length up to alignment - remember that prefix is included in\n    // the alignment\n    LONG lSize = pRequest->cbBuffer + pRequest->cbPrefix;\n    LONG lRemainder = lSize % pRequest->cbAlign;\n    if (lRemainder != 0)\n    {\n        lSize = lSize - lRemainder + pRequest->cbAlign;\n    }\n    pActual->cbBuffer = m_lSize = (lSize - pRequest->cbPrefix);\n\n    pActual->cBuffers = m_lCount = pRequest->cBuffers;\n    pActual->cbAlign = m_lAlignment = pRequest->cbAlign;\n    pActual->cbPrefix = m_lPrefix = pRequest->cbPrefix;\n\n    m_bChanged = TRUE;\n    return NOERROR;\n}\n\n// override this to allocate our resources when Commit is called.\n//\n// note that our resources may be already allocated when this is called,\n// since we don't free them on Decommit. We will only be called when in\n// decommit state with all buffers free.\n//\n// object locked by caller\nHRESULT\nCMemAllocator::Alloc(void)\n{\n    CAutoLock lck(this);\n\n    /* Check he has called SetProperties */\n    HRESULT hr = CBaseAllocator::Alloc();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    /* If the requirements haven't changed then don't reallocate */\n    if (hr == S_FALSE)\n    {\n        ASSERT(m_pBuffer);\n        return NOERROR;\n    }\n    ASSERT(hr == S_OK); // we use this fact in the loop below\n\n    /* Free the old resources */\n    if (m_pBuffer)\n    {\n        ReallyFree();\n    }\n\n    /* Make sure we've got reasonable values */\n    if (m_lSize < 0 || m_lPrefix < 0 || m_lCount < 0)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    /* Compute the aligned size */\n    LONG lAlignedSize = m_lSize + m_lPrefix;\n\n    /*  Check overflow */\n    if (lAlignedSize < m_lSize)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    if (m_lAlignment > 1)\n    {\n        LONG lRemainder = lAlignedSize % m_lAlignment;\n        if (lRemainder != 0)\n        {\n            LONG lNewSize = lAlignedSize + m_lAlignment - lRemainder;\n            if (lNewSize < lAlignedSize)\n            {\n                return E_OUTOFMEMORY;\n            }\n            lAlignedSize = lNewSize;\n        }\n    }\n\n    /* Create the contiguous memory block for the samples\n       making sure it's properly aligned (64K should be enough!)\n    */\n    ASSERT(lAlignedSize % m_lAlignment == 0);\n\n    LONGLONG lToAllocate = m_lCount * (LONGLONG)lAlignedSize;\n\n    /*  Check overflow */\n    if (lToAllocate > MAXLONG)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    m_pBuffer = (PBYTE)VirtualAlloc(NULL, (LONG)lToAllocate, MEM_COMMIT, PAGE_READWRITE);\n\n    if (m_pBuffer == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    LPBYTE pNext = m_pBuffer;\n    CMediaSample *pSample;\n\n    ASSERT(m_lAllocated == 0);\n\n    // Create the new samples - we have allocated m_lSize bytes for each sample\n    // plus m_lPrefix bytes per sample as a prefix. We set the pointer to\n    // the memory after the prefix - so that GetPointer() will return a pointer\n    // to m_lSize bytes.\n    for (; m_lAllocated < m_lCount; m_lAllocated++, pNext += lAlignedSize)\n    {\n\n        pSample = new CMediaSample(NAME(\"Default memory media sample\"), this, &hr,\n                                   pNext + m_lPrefix, // GetPointer() value\n                                   m_lSize);          // not including prefix\n\n        ASSERT(SUCCEEDED(hr));\n        if (pSample == NULL)\n        {\n            return E_OUTOFMEMORY;\n        }\n\n        // This CANNOT fail\n        m_lFree.Add(pSample);\n    }\n\n    m_bChanged = FALSE;\n    return NOERROR;\n}\n\n// override this to free up any resources we have allocated.\n// called from the base class on Decommit when all buffers have been\n// returned to the free list.\n//\n// caller has already locked the object.\n\n// in our case, we keep the memory until we are deleted, so\n// we do nothing here. The memory is deleted in the destructor by\n// calling ReallyFree()\nvoid CMemAllocator::Free(void)\n{\n    return;\n}\n\n// called from the destructor (and from Alloc if changing size/count) to\n// actually free up the memory\nvoid CMemAllocator::ReallyFree(void)\n{\n    /* Should never be deleting this unless all buffers are freed */\n\n    ASSERT(m_lAllocated == m_lFree.GetCount());\n\n    /* Free up all the CMediaSamples */\n\n    CMediaSample *pSample;\n    for (;;)\n    {\n        pSample = m_lFree.RemoveHead();\n        if (pSample != NULL)\n        {\n            delete pSample;\n        }\n        else\n        {\n            break;\n        }\n    }\n\n    m_lAllocated = 0;\n\n    // free the block of buffer memory\n    if (m_pBuffer)\n    {\n        EXECUTE_ASSERT(VirtualFree(m_pBuffer, 0, MEM_RELEASE));\n        m_pBuffer = NULL;\n    }\n}\n\n/* Destructor frees our memory resources */\n\nCMemAllocator::~CMemAllocator()\n{\n    Decommit();\n    ReallyFree();\n}\n\n// ------------------------------------------------------------------------\n// filter registration through IFilterMapper. used if IFilterMapper is\n// not found (Quartz 1.0 install)\n\nSTDAPI\nAMovieSetupRegisterFilter(const AMOVIESETUP_FILTER *const psetupdata, IFilterMapper *pIFM, BOOL bRegister)\n{\n    DbgLog((LOG_TRACE, 3, TEXT(\"= AMovieSetupRegisterFilter\")));\n\n    // check we've got data\n    //\n    if (NULL == psetupdata)\n        return S_FALSE;\n\n    // unregister filter\n    // (as pins are subkeys of filter's CLSID key\n    // they do not need to be removed separately).\n    //\n    DbgLog((LOG_TRACE, 3, TEXT(\"= = unregister filter\")));\n    HRESULT hr = pIFM->UnregisterFilter(*(psetupdata->clsID));\n\n    if (bRegister)\n    {\n        // register filter\n        //\n        DbgLog((LOG_TRACE, 3, TEXT(\"= = register filter\")));\n        hr = pIFM->RegisterFilter(*(psetupdata->clsID), psetupdata->strName, psetupdata->dwMerit);\n        if (SUCCEEDED(hr))\n        {\n            // all its pins\n            //\n            DbgLog((LOG_TRACE, 3, TEXT(\"= = register filter pins\")));\n            for (UINT m1 = 0; m1 < psetupdata->nPins; m1++)\n            {\n                hr = pIFM->RegisterPin(\n                    *(psetupdata->clsID), psetupdata->lpPin[m1].strName, psetupdata->lpPin[m1].bRendered,\n                    psetupdata->lpPin[m1].bOutput, psetupdata->lpPin[m1].bZero, psetupdata->lpPin[m1].bMany,\n                    *(psetupdata->lpPin[m1].clsConnectsToFilter), psetupdata->lpPin[m1].strConnectsToPin);\n\n                if (SUCCEEDED(hr))\n                {\n                    // and each pin's media types\n                    //\n                    DbgLog((LOG_TRACE, 3, TEXT(\"= = register filter pin types\")));\n                    for (UINT m2 = 0; m2 < psetupdata->lpPin[m1].nMediaTypes; m2++)\n                    {\n                        hr = pIFM->RegisterPinType(*(psetupdata->clsID), psetupdata->lpPin[m1].strName,\n                                                   *(psetupdata->lpPin[m1].lpMediaType[m2].clsMajorType),\n                                                   *(psetupdata->lpPin[m1].lpMediaType[m2].clsMinorType));\n                        if (FAILED(hr))\n                            break;\n                    }\n                    if (FAILED(hr))\n                        break;\n                }\n                if (FAILED(hr))\n                    break;\n            }\n        }\n    }\n\n    // handle one acceptable \"error\" - that\n    // of filter not being registered!\n    // (couldn't find a suitable #define'd\n    // name for the error!)\n    //\n    if (0x80070002 == hr)\n        return NOERROR;\n    else\n        return hr;\n}\n\n//  Remove warnings about unreferenced inline functions\n#pragma warning(disable : 4514)\n"
  },
  {
    "path": "common/baseclasses/amfilter.h",
    "content": "//------------------------------------------------------------------------------\n// File: AMFilter.h\n//\n// Desc: DirectShow base classes - efines class hierarchy for streams\n//       architecture.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __FILTER__\n#define __FILTER__\n\n/* The following classes are declared in this header: */\n\nclass CBaseMediaFilter; // IMediaFilter support\nclass CBaseFilter;      // IBaseFilter,IMediaFilter support\nclass CBasePin;         // Abstract base class for IPin interface\nclass CEnumPins;        // Enumerate input and output pins\nclass CEnumMediaTypes;  // Enumerate the pin's preferred formats\nclass CBaseOutputPin;   // Adds data provider member functions\nclass CBaseInputPin;    // Implements IMemInputPin interface\nclass CMediaSample;     // Basic transport unit for IMemInputPin\nclass CBaseAllocator;   // General list guff for most allocators\nclass CMemAllocator;    // Implements memory buffer allocation\n\n//=====================================================================\n//=====================================================================\n//\n// QueryFilterInfo and QueryPinInfo AddRef the interface pointers\n// they return.  You can use the macro below to release the interface.\n//\n//=====================================================================\n//=====================================================================\n\n#define QueryFilterInfoReleaseGraph(fi) \\\n    if ((fi).pGraph)                    \\\n        (fi).pGraph->Release();\n\n#define QueryPinInfoReleaseFilter(pi) \\\n    if ((pi).pFilter)                 \\\n        (pi).pFilter->Release();\n\n//=====================================================================\n//=====================================================================\n// Defines CBaseMediaFilter\n//\n// Abstract base class implementing IMediaFilter.\n//\n// Typically you will derive your filter from CBaseFilter rather than\n// this,  unless you are implementing an object such as a plug-in\n// distributor that needs to support IMediaFilter but not IBaseFilter.\n//\n// Note that IMediaFilter is derived from IPersist to allow query of\n// class id.\n//=====================================================================\n//=====================================================================\n\nclass AM_NOVTABLE CBaseMediaFilter\n    : public CUnknown\n    , public IMediaFilter\n{\n\n  protected:\n    FILTER_STATE m_State;      // current state: running, paused\n    IReferenceClock *m_pClock; // this filter's reference clock\n    // note: all filters in a filter graph use the same clock\n\n    // offset from stream time to reference time\n    CRefTime m_tStart;\n\n    CLSID m_clsid;     // This filters clsid\n                       // used for serialization\n    CCritSec *m_pLock; // Object we use for locking\n\n  public:\n    CBaseMediaFilter(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __in CCritSec *pLock, REFCLSID clsid);\n\n    virtual ~CBaseMediaFilter();\n\n    DECLARE_IUNKNOWN\n\n    // override this to say what interfaces we support where\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    //\n    // --- IPersist method ---\n    //\n\n    STDMETHODIMP GetClassID(__out CLSID *pClsID);\n\n    // --- IMediaFilter methods ---\n\n    STDMETHODIMP GetState(DWORD dwMSecs, __out FILTER_STATE *State);\n\n    STDMETHODIMP SetSyncSource(__inout_opt IReferenceClock *pClock);\n\n    STDMETHODIMP GetSyncSource(__deref_out_opt IReferenceClock **pClock);\n\n    // default implementation of Stop and Pause just record the\n    // state. Override to activate or de-activate your filter.\n    // Note that Run when called from Stopped state will call Pause\n    // to ensure activation, so if you are a source or transform\n    // you will probably not need to override Run.\n    STDMETHODIMP Stop();\n    STDMETHODIMP Pause();\n\n    // the start parameter is the difference to be added to the\n    // sample's stream time to get the reference time for\n    // its presentation\n    STDMETHODIMP Run(REFERENCE_TIME tStart);\n\n    // --- helper methods ---\n\n    // return the current stream time - ie find out what\n    // stream time should be appearing now\n    virtual HRESULT StreamTime(CRefTime &rtStream);\n\n    // Is the filter currently active? (running or paused)\n    BOOL IsActive()\n    {\n        CAutoLock cObjectLock(m_pLock);\n        return ((m_State == State_Paused) || (m_State == State_Running));\n    };\n};\n\n//=====================================================================\n//=====================================================================\n// Defines CBaseFilter\n//\n// An abstract class providing basic IBaseFilter support for pin\n// enumeration and filter information reading.\n//\n// We cannot derive from CBaseMediaFilter since methods in IMediaFilter\n// are also in IBaseFilter and would be ambiguous. Since much of the code\n// assumes that they derive from a class that has m_State and other state\n// directly available, we duplicate code from CBaseMediaFilter rather than\n// having a member variable.\n//\n// Derive your filter from this, or from a derived object such as\n// CTransformFilter.\n//=====================================================================\n//=====================================================================\n\nclass AM_NOVTABLE CBaseFilter\n    : public CUnknown\n    , // Handles an IUnknown\n      public IBaseFilter\n    ,                     // The Filter Interface\n      public IAMovieSetup // For un/registration\n{\n\n    friend class CBasePin;\n\n  protected:\n    FILTER_STATE m_State;      // current state: running, paused\n    IReferenceClock *m_pClock; // this graph's ref clock\n    CRefTime m_tStart;         // offset from stream time to reference time\n    CLSID m_clsid;             // This filters clsid\n                               // used for serialization\n    CCritSec *m_pLock;         // Object we use for locking\n\n    WCHAR *m_pName;           // Full filter name\n    IFilterGraph *m_pGraph;   // Graph we belong to\n    IMediaEventSink *m_pSink; // Called with notify events\n    LONG m_PinVersion;        // Current pin version\n\n  public:\n    CBaseFilter(__in_opt LPCTSTR pName,     // Object description\n                __inout_opt LPUNKNOWN pUnk, // IUnknown of delegating object\n                __in CCritSec *pLock,       // Object who maintains lock\n                REFCLSID clsid);            // The clsid to be used to serialize this filter\n\n    CBaseFilter(__in_opt LPCTSTR pName,  // Object description\n                __in_opt LPUNKNOWN pUnk, // IUnknown of delegating object\n                __in CCritSec *pLock,    // Object who maintains lock\n                REFCLSID clsid,          // The clsid to be used to serialize this filter\n                __inout HRESULT *phr);   // General OLE return code\n#ifdef UNICODE\n    CBaseFilter(__in_opt LPCSTR pName,   // Object description\n                __in_opt LPUNKNOWN pUnk, // IUnknown of delegating object\n                __in CCritSec *pLock,    // Object who maintains lock\n                REFCLSID clsid);         // The clsid to be used to serialize this filter\n\n    CBaseFilter(__in_opt LPCSTR pName,   // Object description\n                __in_opt LPUNKNOWN pUnk, // IUnknown of delegating object\n                __in CCritSec *pLock,    // Object who maintains lock\n                REFCLSID clsid,          // The clsid to be used to serialize this filter\n                __inout HRESULT *phr);   // General OLE return code\n#endif\n    ~CBaseFilter();\n\n    DECLARE_IUNKNOWN\n\n    // override this to say what interfaces we support where\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n#ifdef DEBUG\n    STDMETHODIMP_(ULONG) NonDelegatingRelease();\n#endif\n\n    //\n    // --- IPersist method ---\n    //\n\n    STDMETHODIMP GetClassID(__out CLSID *pClsID);\n\n    // --- IMediaFilter methods ---\n\n    STDMETHODIMP GetState(DWORD dwMSecs, __out FILTER_STATE *State);\n\n    STDMETHODIMP SetSyncSource(__in_opt IReferenceClock *pClock);\n\n    STDMETHODIMP GetSyncSource(__deref_out_opt IReferenceClock **pClock);\n\n    // override Stop and Pause so we can activate the pins.\n    // Note that Run will call Pause first if activation needed.\n    // Override these if you want to activate your filter rather than\n    // your pins.\n    STDMETHODIMP Stop();\n    STDMETHODIMP Pause();\n\n    // the start parameter is the difference to be added to the\n    // sample's stream time to get the reference time for\n    // its presentation\n    STDMETHODIMP Run(REFERENCE_TIME tStart);\n\n    // --- helper methods ---\n\n    // return the current stream time - ie find out what\n    // stream time should be appearing now\n    virtual HRESULT StreamTime(CRefTime &rtStream);\n\n    // Is the filter currently active?\n    BOOL IsActive()\n    {\n        CAutoLock cObjectLock(m_pLock);\n        return ((m_State == State_Paused) || (m_State == State_Running));\n    };\n\n    // Is this filter stopped (without locking)\n    BOOL IsStopped() { return (m_State == State_Stopped); };\n\n    //\n    // --- IBaseFilter methods ---\n    //\n\n    // pin enumerator\n    STDMETHODIMP EnumPins(__deref_out IEnumPins **ppEnum);\n\n    // default behaviour of FindPin assumes pin ids are their names\n    STDMETHODIMP FindPin(LPCWSTR Id, __deref_out IPin **ppPin);\n\n    STDMETHODIMP QueryFilterInfo(__out FILTER_INFO *pInfo);\n\n    STDMETHODIMP JoinFilterGraph(__inout_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName);\n\n    // return a Vendor information string. Optional - may return E_NOTIMPL.\n    // memory returned should be freed using CoTaskMemFree\n    // default implementation returns E_NOTIMPL\n    STDMETHODIMP QueryVendorInfo(__deref_out LPWSTR *pVendorInfo);\n\n    // --- helper methods ---\n\n    // send an event notification to the filter graph if we know about it.\n    // returns S_OK if delivered, S_FALSE if the filter graph does not sink\n    // events, or an error otherwise.\n    HRESULT NotifyEvent(long EventCode, LONG_PTR EventParam1, LONG_PTR EventParam2);\n\n    // return the filter graph we belong to\n    __out_opt IFilterGraph *GetFilterGraph() { return m_pGraph; }\n\n    // Request reconnect\n    // pPin is the pin to reconnect\n    // pmt is the type to reconnect with - can be NULL\n    // Calls ReconnectEx on the filter graph\n    HRESULT ReconnectPin(IPin *pPin, __in_opt AM_MEDIA_TYPE const *pmt);\n\n    // find out the current pin version (used by enumerators)\n    virtual LONG GetPinVersion();\n    void IncrementPinVersion();\n\n    // you need to supply these to access the pins from the enumerator\n    // and for default Stop and Pause/Run activation.\n    virtual int GetPinCount() PURE;\n    virtual CBasePin *GetPin(int n) PURE;\n\n    // --- IAMovieSetup methods ---\n\n    STDMETHODIMP Register();   // ask filter to register itself\n    STDMETHODIMP Unregister(); // and unregister itself\n\n    // --- setup helper methods ---\n    // (override to return filters setup data)\n\n    virtual __out_opt LPAMOVIESETUP_FILTER GetSetupData() { return NULL; }\n};\n\n//=====================================================================\n//=====================================================================\n// Defines CBasePin\n//\n// Abstract class that supports the basics of IPin\n//=====================================================================\n//=====================================================================\n\nclass AM_NOVTABLE CBasePin\n    : public CUnknown\n    , public IPin\n    , public IQualityControl\n{\n\n  protected:\n    WCHAR *m_pName;                 // This pin's name\n    IPin *m_Connected;              // Pin we have connected to\n    PIN_DIRECTION m_dir;            // Direction of this pin\n    CCritSec *m_pLock;              // Object we use for locking\n    bool m_bRunTimeError;           // Run time error generated\n    bool m_bCanReconnectWhenActive; // OK to reconnect when active\n    bool m_bTryMyTypesFirst;        // When connecting enumerate\n                                    // this pin's types first\n    CBaseFilter *m_pFilter;         // Filter we were created by\n    IQualityControl *m_pQSink;      // Target for Quality messages\n    LONG m_TypeVersion;             // Holds current type version\n    CMediaType m_mt;                // Media type of connection\n\n    CRefTime m_tStart; // time from NewSegment call\n    CRefTime m_tStop;  // time from NewSegment\n    double m_dRate;    // rate from NewSegment\n\n#ifdef DEBUG\n    LONG m_cRef; // Ref count tracing\n#endif\n\n    // displays pin connection information\n\n#ifdef DEBUG\n    void DisplayPinInfo(IPin *pReceivePin);\n    void DisplayTypeInfo(IPin *pPin, const CMediaType *pmt);\n#else\n    void DisplayPinInfo(IPin *pReceivePin){};\n    void DisplayTypeInfo(IPin *pPin, const CMediaType *pmt){};\n#endif\n\n    // used to agree a media type for a pin connection\n\n    // given a specific media type, attempt a connection (includes\n    // checking that the type is acceptable to this pin)\n    HRESULT\n    AttemptConnection(IPin *pReceivePin,    // connect to this pin\n                      const CMediaType *pmt // using this type\n    );\n\n    // try all the media types in this enumerator - for each that\n    // we accept, try to connect using ReceiveConnection.\n    HRESULT TryMediaTypes(IPin *pReceivePin,              // connect to this pin\n                          __in_opt const CMediaType *pmt, // proposed type from Connect\n                          IEnumMediaTypes *pEnum);        // try this enumerator\n\n    // establish a connection with a suitable mediatype. Needs to\n    // propose a media type if the pmt pointer is null or partially\n    // specified - use TryMediaTypes on both our and then the other pin's\n    // enumerator until we find one that works.\n    HRESULT AgreeMediaType(IPin *pReceivePin,      // connect to this pin\n                           const CMediaType *pmt); // proposed type from Connect\n\n  public:\n    CBasePin(__in_opt LPCTSTR pObjectName, // Object description\n             __in CBaseFilter *pFilter,    // Owning filter who knows about pins\n             __in CCritSec *pLock,         // Object who implements the lock\n             __inout HRESULT *phr,         // General OLE return code\n             __in_opt LPCWSTR pName,       // Pin name for us\n             PIN_DIRECTION dir);           // Either PINDIR_INPUT or PINDIR_OUTPUT\n#ifdef UNICODE\n    CBasePin(__in_opt LPCSTR pObjectName, // Object description\n             __in CBaseFilter *pFilter,   // Owning filter who knows about pins\n             __in CCritSec *pLock,        // Object who implements the lock\n             __inout HRESULT *phr,        // General OLE return code\n             __in_opt LPCWSTR pName,      // Pin name for us\n             PIN_DIRECTION dir);          // Either PINDIR_INPUT or PINDIR_OUTPUT\n#endif\n    virtual ~CBasePin();\n\n    DECLARE_IUNKNOWN\n\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) NonDelegatingRelease();\n    STDMETHODIMP_(ULONG) NonDelegatingAddRef();\n\n    // --- IPin methods ---\n\n    // take lead role in establishing a connection. Media type pointer\n    // may be null, or may point to partially-specified mediatype\n    // (subtype or format type may be GUID_NULL).\n    STDMETHODIMP Connect(IPin *pReceivePin,\n                         __in_opt const AM_MEDIA_TYPE *pmt // optional media type\n    );\n\n    // (passive) accept a connection from another pin\n    STDMETHODIMP ReceiveConnection(IPin *pConnector,        // this is the initiating connecting pin\n                                   const AM_MEDIA_TYPE *pmt // this is the media type we will exchange\n    );\n\n    STDMETHODIMP Disconnect();\n\n    STDMETHODIMP ConnectedTo(__deref_out IPin **pPin);\n\n    STDMETHODIMP ConnectionMediaType(__out AM_MEDIA_TYPE *pmt);\n\n    STDMETHODIMP QueryPinInfo(__out PIN_INFO *pInfo);\n\n    STDMETHODIMP QueryDirection(__out PIN_DIRECTION *pPinDir);\n\n    STDMETHODIMP QueryId(__deref_out LPWSTR *Id);\n\n    // does the pin support this media type\n    STDMETHODIMP QueryAccept(const AM_MEDIA_TYPE *pmt);\n\n    // return an enumerator for this pins preferred media types\n    STDMETHODIMP EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum);\n\n    // return an array of IPin* - the pins that this pin internally connects to\n    // All pins put in the array must be AddReffed (but no others)\n    // Errors: \"Can't say\" - FAIL, not enough slots - return S_FALSE\n    // Default: return E_NOTIMPL\n    // The filter graph will interpret NOT_IMPL as any input pin connects to\n    // all visible output pins and vice versa.\n    // apPin can be NULL if nPin==0 (not otherwise).\n    STDMETHODIMP QueryInternalConnections(__out_ecount_part(*nPin, *nPin) IPin **apPin, // array of IPin*\n                                          __inout ULONG *nPin                           // on input, the number of slots\n                                                                                        // on output  the number of pins\n    )\n    {\n        return E_NOTIMPL;\n    }\n\n    // Called when no more data will be sent\n    STDMETHODIMP EndOfStream(void);\n\n    // Begin/EndFlush still PURE\n\n    // NewSegment notifies of the start/stop/rate applying to the data\n    // about to be received. Default implementation records data and\n    // returns S_OK.\n    // Override this to pass downstream.\n    STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n\n    //================================================================================\n    // IQualityControl methods\n    //================================================================================\n\n    STDMETHODIMP Notify(IBaseFilter *pSender, Quality q);\n\n    STDMETHODIMP SetSink(IQualityControl *piqc);\n\n    // --- helper methods ---\n\n    // Returns true if the pin is connected. false otherwise.\n    BOOL IsConnected(void) { return (m_Connected != NULL); };\n    // Return the pin this is connected to (if any)\n    IPin *GetConnected() { return m_Connected; };\n\n    // Check if our filter is currently stopped\n    BOOL IsStopped() { return (m_pFilter->m_State == State_Stopped); };\n\n    // find out the current type version (used by enumerators)\n    virtual LONG GetMediaTypeVersion();\n    void IncrementTypeVersion();\n\n    // switch the pin to active (paused or running) mode\n    // not an error to call this if already active\n    virtual HRESULT Active(void);\n\n    // switch the pin to inactive state - may already be inactive\n    virtual HRESULT Inactive(void);\n\n    // Notify of Run() from filter\n    virtual HRESULT Run(REFERENCE_TIME tStart);\n\n    // check if the pin can support this specific proposed type and format\n    virtual HRESULT CheckMediaType(const CMediaType *) PURE;\n\n    // set the connection to use this format (previously agreed)\n    virtual HRESULT SetMediaType(const CMediaType *);\n\n    // check that the connection is ok before verifying it\n    // can be overridden eg to check what interfaces will be supported.\n    virtual HRESULT CheckConnect(IPin *);\n\n    // Set and release resources required for a connection\n    virtual HRESULT BreakConnect();\n    virtual HRESULT CompleteConnect(IPin *pReceivePin);\n\n    // returns the preferred formats for a pin\n    virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType);\n\n    // access to NewSegment values\n    REFERENCE_TIME CurrentStopTime() { return m_tStop; }\n    REFERENCE_TIME CurrentStartTime() { return m_tStart; }\n    double CurrentRate() { return m_dRate; }\n\n    //  Access name\n    LPWSTR Name() { return m_pName; };\n\n    //  Can reconnectwhen active?\n    void SetReconnectWhenActive(bool bCanReconnect) { m_bCanReconnectWhenActive = bCanReconnect; }\n\n    bool CanReconnectWhenActive() { return m_bCanReconnectWhenActive; }\n\n  protected:\n    STDMETHODIMP DisconnectInternal();\n};\n\n//=====================================================================\n//=====================================================================\n// Defines CEnumPins\n//\n// Pin enumerator class that works by calling CBaseFilter. This interface\n// is provided by CBaseFilter::EnumPins and calls GetPinCount() and\n// GetPin() to enumerate existing pins. Needs to be a separate object so\n// that it can be cloned (creating an existing object at the same\n// position in the enumeration)\n//\n//=====================================================================\n//=====================================================================\n\nclass CEnumPins : public IEnumPins // The interface we support\n{\n    int m_Position;         // Current ordinal position\n    int m_PinCount;         // Number of pins available\n    CBaseFilter *m_pFilter; // The filter who owns us\n    LONG m_Version;         // Pin version information\n    LONG m_cRef;\n\n    typedef CGenericList<CBasePin> CPinList;\n\n    CPinList m_PinCache; // These pointers have not been AddRef'ed and\n                         // so they should not be dereferenced.  They are\n                         // merely kept to ID which pins have been enumerated.\n\n#ifdef DEBUG\n    DWORD m_dwCookie;\n#endif\n\n    /* If while we are retrieving a pin for example from the filter an error\n       occurs we assume that our internal state is stale with respect to the\n       filter (someone may have deleted all the pins). We can check before\n       starting whether or not the operation is likely to fail by asking the\n       filter what it's current version number is. If the filter has not\n       overriden the GetPinVersion method then this will always match */\n\n    BOOL AreWeOutOfSync() { return (m_pFilter->GetPinVersion() == m_Version ? FALSE : TRUE); };\n\n    /* This method performs the same operations as Reset, except is does not clear\n       the cache of pins already enumerated. */\n\n    STDMETHODIMP Refresh();\n\n  public:\n    CEnumPins(__in CBaseFilter *pFilter, __in_opt CEnumPins *pEnumPins);\n\n    virtual ~CEnumPins();\n\n    // IUnknown\n    STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) AddRef();\n    STDMETHODIMP_(ULONG) Release();\n\n    // IEnumPins\n    STDMETHODIMP Next(ULONG cPins,                       // place this many pins...\n                      __out_ecount(cPins) IPin **ppPins, // ...in this array of IPin*\n                      __out_opt ULONG *pcFetched         // actual count passed returned here\n    );\n\n    STDMETHODIMP Skip(ULONG cPins);\n    STDMETHODIMP Reset();\n    STDMETHODIMP Clone(__deref_out IEnumPins **ppEnum);\n};\n\n//=====================================================================\n//=====================================================================\n// Defines CEnumMediaTypes\n//\n// Enumerates the preferred formats for input and output pins\n//=====================================================================\n//=====================================================================\n\nclass CEnumMediaTypes : public IEnumMediaTypes // The interface we support\n{\n    int m_Position;   // Current ordinal position\n    CBasePin *m_pPin; // The pin who owns us\n    LONG m_Version;   // Media type version value\n    LONG m_cRef;\n#ifdef DEBUG\n    DWORD m_dwCookie;\n#endif\n\n    /* The media types a filter supports can be quite dynamic so we add to\n       the general IEnumXXXX interface the ability to be signaled when they\n       change via an event handle the connected filter supplies. Until the\n       Reset method is called after the state changes all further calls to\n       the enumerator (except Reset) will return E_UNEXPECTED error code */\n\n    BOOL AreWeOutOfSync() { return (m_pPin->GetMediaTypeVersion() == m_Version ? FALSE : TRUE); };\n\n  public:\n    CEnumMediaTypes(__in CBasePin *pPin, __in_opt CEnumMediaTypes *pEnumMediaTypes);\n\n    virtual ~CEnumMediaTypes();\n\n    // IUnknown\n    STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) AddRef();\n    STDMETHODIMP_(ULONG) Release();\n\n    // IEnumMediaTypes\n    STDMETHODIMP Next(ULONG cMediaTypes,                                      // place this many pins...\n                      __out_ecount(cMediaTypes) AM_MEDIA_TYPE **ppMediaTypes, // ...in this array\n                      __out_opt ULONG *pcFetched                              // actual count passed\n    );\n\n    STDMETHODIMP Skip(ULONG cMediaTypes);\n    STDMETHODIMP Reset();\n    STDMETHODIMP Clone(__deref_out IEnumMediaTypes **ppEnum);\n};\n\n//=====================================================================\n//=====================================================================\n// Defines CBaseOutputPin\n//\n// class derived from CBasePin that can pass buffers to a connected pin\n// that supports IMemInputPin. Supports IPin.\n//\n// Derive your output pin from this.\n//\n//=====================================================================\n//=====================================================================\n\nclass AM_NOVTABLE CBaseOutputPin : public CBasePin\n{\n\n  protected:\n    IMemAllocator *m_pAllocator;\n    IMemInputPin *m_pInputPin; // interface on the downstreaminput pin\n                               // set up in CheckConnect when we connect.\n\n  public:\n    CBaseOutputPin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock, __inout HRESULT *phr,\n                   __in_opt LPCWSTR pName);\n#ifdef UNICODE\n    CBaseOutputPin(__in_opt LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock, __inout HRESULT *phr,\n                   __in_opt LPCWSTR pName);\n#endif\n    // override CompleteConnect() so we can negotiate an allocator\n    virtual HRESULT CompleteConnect(IPin *pReceivePin);\n\n    // negotiate the allocator and its buffer size/count and other properties\n    // Calls DecideBufferSize to set properties\n    virtual HRESULT DecideAllocator(IMemInputPin *pPin, __deref_out IMemAllocator **pAlloc);\n\n    // override this to set the buffer size and count. Return an error\n    // if the size/count is not to your liking.\n    // The allocator properties passed in are those requested by the\n    // input pin - use eg the alignment and prefix members if you have\n    // no preference on these.\n    virtual HRESULT DecideBufferSize(IMemAllocator *pAlloc, __inout ALLOCATOR_PROPERTIES *ppropInputRequest) PURE;\n\n    // returns an empty sample buffer from the allocator\n    virtual HRESULT GetDeliveryBuffer(__deref_out IMediaSample **ppSample, __in_opt REFERENCE_TIME *pStartTime,\n                                      __in_opt REFERENCE_TIME *pEndTime, DWORD dwFlags);\n\n    // deliver a filled-in sample to the connected input pin\n    // note - you need to release it after calling this. The receiving\n    // pin will addref the sample if it needs to hold it beyond the\n    // call.\n    virtual HRESULT Deliver(IMediaSample *);\n\n    // override this to control the connection\n    virtual HRESULT InitAllocator(__deref_out IMemAllocator **ppAlloc);\n    HRESULT CheckConnect(IPin *pPin);\n    HRESULT BreakConnect();\n\n    // override to call Commit and Decommit\n    HRESULT Active(void);\n    HRESULT Inactive(void);\n\n    // we have a default handling of EndOfStream which is to return\n    // an error, since this should be called on input pins only\n    STDMETHODIMP EndOfStream(void);\n\n    // called from elsewhere in our filter to pass EOS downstream to\n    // our connected input pin\n    virtual HRESULT DeliverEndOfStream(void);\n\n    // same for Begin/EndFlush - we handle Begin/EndFlush since it\n    // is an error on an output pin, and we have Deliver methods to\n    // call the methods on the connected pin\n    STDMETHODIMP BeginFlush(void);\n    STDMETHODIMP EndFlush(void);\n    virtual HRESULT DeliverBeginFlush(void);\n    virtual HRESULT DeliverEndFlush(void);\n\n    // deliver NewSegment to connected pin - you will need to\n    // override this if you queue any data in your output pin.\n    virtual HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n\n    //================================================================================\n    // IQualityControl methods\n    //================================================================================\n\n    // All inherited from CBasePin and not overridden here.\n    // STDMETHODIMP Notify(IBaseFilter * pSender, Quality q);\n    // STDMETHODIMP SetSink(IQualityControl * piqc);\n};\n\n//=====================================================================\n//=====================================================================\n// Defines CBaseInputPin\n//\n// derive your standard input pin from this.\n// you need to supply GetMediaType and CheckConnect etc (see CBasePin),\n// and you need to supply Receive to do something more useful.\n//\n//=====================================================================\n//=====================================================================\n\nclass AM_NOVTABLE CBaseInputPin\n    : public CBasePin\n    , public IMemInputPin\n{\n\n  protected:\n    IMemAllocator *m_pAllocator; // Default memory allocator\n\n    // allocator is read-only, so received samples\n    // cannot be modified (probably only relevant to in-place\n    // transforms\n    BYTE m_bReadOnly;\n\n    // in flushing state (between BeginFlush and EndFlush)\n    // if TRUE, all Receives are returned with S_FALSE\n    BYTE m_bFlushing;\n\n    // Sample properties - initalized in Receive\n    AM_SAMPLE2_PROPERTIES m_SampleProps;\n\n  public:\n    CBaseInputPin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock, __inout HRESULT *phr,\n                  __in_opt LPCWSTR pName);\n#ifdef UNICODE\n    CBaseInputPin(__in_opt LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock, __inout HRESULT *phr,\n                  __in_opt LPCWSTR pName);\n#endif\n    virtual ~CBaseInputPin();\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    // return the allocator interface that this input pin\n    // would like the output pin to use\n    STDMETHODIMP GetAllocator(__deref_out IMemAllocator **ppAllocator);\n\n    // tell the input pin which allocator the output pin is actually\n    // going to use.\n    STDMETHODIMP NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly);\n\n    // do something with this media sample\n    STDMETHODIMP Receive(IMediaSample *pSample);\n\n    // do something with these media samples\n    STDMETHODIMP ReceiveMultiple(__in_ecount(nSamples) IMediaSample **pSamples, long nSamples,\n                                 __out long *nSamplesProcessed);\n\n    // See if Receive() blocks\n    STDMETHODIMP ReceiveCanBlock();\n\n    // Default handling for BeginFlush - call at the beginning\n    // of your implementation (makes sure that all Receive calls\n    // fail). After calling this, you need to free any queued data\n    // and then call downstream.\n    STDMETHODIMP BeginFlush(void);\n\n    // default handling for EndFlush - call at end of your implementation\n    // - before calling this, ensure that there is no queued data and no thread\n    // pushing any more without a further receive, then call downstream,\n    // then call this method to clear the m_bFlushing flag and re-enable\n    // receives\n    STDMETHODIMP EndFlush(void);\n\n    // this method is optional (can return E_NOTIMPL).\n    // default implementation returns E_NOTIMPL. Override if you have\n    // specific alignment or prefix needs, but could use an upstream\n    // allocator\n    STDMETHODIMP GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps);\n\n    // Release the pin's allocator.\n    HRESULT BreakConnect();\n\n    // helper method to check the read-only flag\n    BOOL IsReadOnly() { return m_bReadOnly; };\n\n    // helper method to see if we are flushing\n    BOOL IsFlushing() { return m_bFlushing; };\n\n    //  Override this for checking whether it's OK to process samples\n    //  Also call this from EndOfStream.\n    virtual HRESULT CheckStreaming();\n\n    // Pass a Quality notification on to the appropriate sink\n    HRESULT PassNotify(Quality &q);\n\n    //================================================================================\n    // IQualityControl methods (from CBasePin)\n    //================================================================================\n\n    STDMETHODIMP Notify(IBaseFilter *pSender, Quality q);\n\n    // no need to override:\n    // STDMETHODIMP SetSink(IQualityControl * piqc);\n\n    // switch the pin to inactive state - may already be inactive\n    virtual HRESULT Inactive(void);\n\n    // Return sample properties pointer\n    AM_SAMPLE2_PROPERTIES *SampleProps()\n    {\n        ASSERT(m_SampleProps.cbData != 0);\n        return &m_SampleProps;\n    }\n};\n\n///////////////////////////////////////////////////////////////////////////\n// CDynamicOutputPin\n//\n\nclass CDynamicOutputPin\n    : public CBaseOutputPin\n    , public IPinFlowControl\n{\n  public:\n#ifdef UNICODE\n    CDynamicOutputPin(__in_opt LPCSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                      __inout HRESULT *phr, __in_opt LPCWSTR pName);\n#endif\n\n    CDynamicOutputPin(__in_opt LPCTSTR pObjectName, __in CBaseFilter *pFilter, __in CCritSec *pLock,\n                      __inout HRESULT *phr, __in_opt LPCWSTR pName);\n\n    ~CDynamicOutputPin();\n\n    // IUnknown Methods\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    // IPin Methods\n    STDMETHODIMP Disconnect(void);\n\n    // IPinFlowControl Methods\n    STDMETHODIMP Block(DWORD dwBlockFlags, HANDLE hEvent);\n\n    //  Set graph config info\n    void SetConfigInfo(IGraphConfig *pGraphConfig, HANDLE hStopEvent);\n\n#ifdef DEBUG\n    virtual HRESULT Deliver(IMediaSample *pSample);\n    virtual HRESULT DeliverEndOfStream(void);\n    virtual HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n#endif // DEBUG\n\n    HRESULT DeliverBeginFlush(void);\n    HRESULT DeliverEndFlush(void);\n\n    HRESULT Inactive(void);\n    HRESULT Active(void);\n    virtual HRESULT CompleteConnect(IPin *pReceivePin);\n\n    virtual HRESULT StartUsingOutputPin(void);\n    virtual void StopUsingOutputPin(void);\n    virtual bool StreamingThreadUsingOutputPin(void);\n\n    HRESULT ChangeOutputFormat(const AM_MEDIA_TYPE *pmt, REFERENCE_TIME tSegmentStart, REFERENCE_TIME tSegmentStop,\n                               double dSegmentRate);\n    HRESULT ChangeMediaType(const CMediaType *pmt);\n    HRESULT DynamicReconnect(const CMediaType *pmt);\n\n  protected:\n    HRESULT SynchronousBlockOutputPin(void);\n    HRESULT AsynchronousBlockOutputPin(HANDLE hNotifyCallerPinBlockedEvent);\n    HRESULT UnblockOutputPin(void);\n\n    void BlockOutputPin(void);\n    void ResetBlockState(void);\n\n    static HRESULT WaitEvent(HANDLE hEvent);\n\n    enum BLOCK_STATE\n    {\n        NOT_BLOCKED,\n        PENDING,\n        BLOCKED\n    };\n\n    // This lock should be held when the following class members are\n    // being used: m_hNotifyCallerPinBlockedEvent, m_BlockState,\n    // m_dwBlockCallerThreadID and m_dwNumOutstandingOutputPinUsers.\n    CCritSec m_BlockStateLock;\n\n    // This event should be signaled when the output pin is\n    // not blocked.  This is a manual reset event.  For more\n    // information on events, see the documentation for\n    // CreateEvent() in the Windows SDK.\n    HANDLE m_hUnblockOutputPinEvent;\n\n    // This event will be signaled when block operation succeedes or\n    // when the user cancels the block operation.  The block operation\n    // can be canceled by calling IPinFlowControl2::Block( 0, NULL )\n    // while the block operation is pending.\n    HANDLE m_hNotifyCallerPinBlockedEvent;\n\n    // The state of the current block operation.\n    BLOCK_STATE m_BlockState;\n\n    // The ID of the thread which last called IPinFlowControl::Block().\n    // For more information on thread IDs, see the documentation for\n    // GetCurrentThreadID() in the Windows SDK.\n    DWORD m_dwBlockCallerThreadID;\n\n    // The number of times StartUsingOutputPin() has been sucessfully\n    // called and a corresponding call to StopUsingOutputPin() has not\n    // been made.  When this variable is greater than 0, the streaming\n    // thread is calling IPin::NewSegment(), IPin::EndOfStream(),\n    // IMemInputPin::Receive() or IMemInputPin::ReceiveMultiple().  The\n    // streaming thread could also be calling: DynamicReconnect(),\n    // ChangeMediaType() or ChangeOutputFormat().  The output pin cannot\n    // be blocked while the output pin is being used.\n    DWORD m_dwNumOutstandingOutputPinUsers;\n\n    // This event should be set when the IMediaFilter::Stop() is called.\n    // This is a manual reset event.  It is also set when the output pin\n    // delivers a flush to the connected input pin.\n    HANDLE m_hStopEvent;\n    IGraphConfig *m_pGraphConfig;\n\n    // TRUE if the output pin's allocator's samples are read only.\n    // Otherwise FALSE.  For more information, see the documentation\n    // for IMemInputPin::NotifyAllocator().\n    BOOL m_bPinUsesReadOnlyAllocator;\n\n  private:\n    HRESULT Initialize(void);\n    HRESULT ChangeMediaTypeHelper(const CMediaType *pmt);\n\n#ifdef DEBUG\n    void AssertValid(void);\n#endif // DEBUG\n};\n\nclass CAutoUsingOutputPin\n{\n  public:\n    CAutoUsingOutputPin(__in CDynamicOutputPin *pOutputPin, __inout HRESULT *phr);\n    ~CAutoUsingOutputPin();\n\n  private:\n    CDynamicOutputPin *m_pOutputPin;\n};\n\ninline CAutoUsingOutputPin::CAutoUsingOutputPin(__in CDynamicOutputPin *pOutputPin, __inout HRESULT *phr)\n    : m_pOutputPin(NULL)\n{\n    // The caller should always pass in valid pointers.\n    ASSERT(NULL != pOutputPin);\n    ASSERT(NULL != phr);\n\n    // Make sure the user initialized phr.\n    ASSERT(S_OK == *phr);\n\n    HRESULT hr = pOutputPin->StartUsingOutputPin();\n    if (FAILED(hr))\n    {\n        *phr = hr;\n        return;\n    }\n\n    m_pOutputPin = pOutputPin;\n}\n\ninline CAutoUsingOutputPin::~CAutoUsingOutputPin()\n{\n    if (NULL != m_pOutputPin)\n    {\n        m_pOutputPin->StopUsingOutputPin();\n    }\n}\n\n#ifdef DEBUG\n\ninline HRESULT CDynamicOutputPin::Deliver(IMediaSample *pSample)\n{\n    // The caller should call StartUsingOutputPin() before calling this\n    // method.\n    ASSERT(StreamingThreadUsingOutputPin());\n\n    return CBaseOutputPin::Deliver(pSample);\n}\n\ninline HRESULT CDynamicOutputPin::DeliverEndOfStream(void)\n{\n    // The caller should call StartUsingOutputPin() before calling this\n    // method.\n    ASSERT(StreamingThreadUsingOutputPin());\n\n    return CBaseOutputPin::DeliverEndOfStream();\n}\n\ninline HRESULT CDynamicOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    // The caller should call StartUsingOutputPin() before calling this\n    // method.\n    ASSERT(StreamingThreadUsingOutputPin());\n\n    return CBaseOutputPin::DeliverNewSegment(tStart, tStop, dRate);\n}\n\n#endif // DEBUG\n\n//=====================================================================\n//=====================================================================\n// Memory allocators\n//\n// the shared memory transport between pins requires the input pin\n// to provide a memory allocator that can provide sample objects. A\n// sample object supports the IMediaSample interface.\n//\n// CBaseAllocator handles the management of free and busy samples. It\n// allocates CMediaSample objects. CBaseAllocator is an abstract class:\n// in particular it has no method of initializing the list of free\n// samples. CMemAllocator is derived from CBaseAllocator and initializes\n// the list of samples using memory from the standard IMalloc interface.\n//\n// If you want your buffers to live in some special area of memory,\n// derive your allocator object from CBaseAllocator. If you derive your\n// IMemInputPin interface object from CBaseMemInputPin, you will get\n// CMemAllocator-based allocation etc for free and will just need to\n// supply the Receive handling, and media type / format negotiation.\n//=====================================================================\n//=====================================================================\n\n//=====================================================================\n//=====================================================================\n// Defines CMediaSample\n//\n// an object of this class supports IMediaSample and represents a buffer\n// for media data with some associated properties. Releasing it returns\n// it to a freelist managed by a CBaseAllocator derived object.\n//=====================================================================\n//=====================================================================\n\nclass CMediaSample : public IMediaSample2 // The interface we support\n{\n\n  protected:\n    friend class CBaseAllocator;\n\n    /*  Values for dwFlags - these are used for backward compatiblity\n        only now - use AM_SAMPLE_xxx\n    */\n    enum\n    {\n        Sample_SyncPoint = 0x01,         /* Is this a sync point */\n        Sample_Preroll = 0x02,           /* Is this a preroll sample */\n        Sample_Discontinuity = 0x04,     /* Set if start of new segment */\n        Sample_TypeChanged = 0x08,       /* Has the type changed */\n        Sample_TimeValid = 0x10,         /* Set if time is valid */\n        Sample_MediaTimeValid = 0x20,    /* Is the media time valid */\n        Sample_TimeDiscontinuity = 0x40, /* Time discontinuity */\n        Sample_StopValid = 0x100,        /* Stop time valid */\n        Sample_ValidFlags = 0x1FF\n    };\n\n    /* Properties, the media sample class can be a container for a format\n       change in which case we take a copy of a type through the SetMediaType\n       interface function and then return it when GetMediaType is called. As\n       we do no internal processing on it we leave it as a pointer */\n\n    DWORD m_dwFlags;                                 /* Flags for this sample */\n                                                     /* Type specific flags are packed\n                                                        into the top word\n                                                     */\n    DWORD m_dwTypeSpecificFlags;                     /* Media type specific flags */\n    __field_ecount_opt(m_cbBuffer) LPBYTE m_pBuffer; /* Pointer to the complete buffer */\n    LONG m_lActual;                                  /* Length of data in this sample */\n    LONG m_cbBuffer;                                 /* Size of the buffer */\n    CBaseAllocator *m_pAllocator;                    /* The allocator who owns us */\n    CMediaSample *m_pNext;                           /* Chaining in free list */\n    REFERENCE_TIME m_Start;                          /* Start sample time */\n    REFERENCE_TIME m_End;                            /* End sample time */\n    LONGLONG m_MediaStart;                           /* Real media start position */\n    LONG m_MediaEnd;                                 /* A difference to get the end */\n    AM_MEDIA_TYPE *m_pMediaType;                     /* Media type change data */\n    DWORD m_dwStreamId;                              /* Stream id */\n  public:\n    LONG m_cRef; /* Reference count */\n\n  public:\n    CMediaSample(__in_opt LPCTSTR pName, __in_opt CBaseAllocator *pAllocator, __inout_opt HRESULT *phr,\n                 __in_bcount_opt(length) LPBYTE pBuffer = NULL, LONG length = 0);\n#ifdef UNICODE\n    CMediaSample(__in_opt LPCSTR pName, __in_opt CBaseAllocator *pAllocator, __inout_opt HRESULT *phr,\n                 __in_bcount_opt(length) LPBYTE pBuffer = NULL, LONG length = 0);\n#endif\n\n    virtual ~CMediaSample();\n\n    /* Note the media sample does not delegate to its owner */\n\n    STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) AddRef();\n    STDMETHODIMP_(ULONG) Release();\n\n    // set the buffer pointer and length. Used by allocators that\n    // want variable sized pointers or pointers into already-read data.\n    // This is only available through a CMediaSample* not an IMediaSample*\n    // and so cannot be changed by clients.\n    HRESULT SetPointer(__in_bcount(cBytes) BYTE *ptr, LONG cBytes);\n\n    // Get me a read/write pointer to this buffer's memory.\n    STDMETHODIMP GetPointer(__deref_out BYTE **ppBuffer);\n\n    STDMETHODIMP_(LONG) GetSize(void);\n\n    // get the stream time at which this sample should start and finish.\n    STDMETHODIMP GetTime(__out REFERENCE_TIME *pTimeStart, // put time here\n                         __out REFERENCE_TIME *pTimeEnd);\n\n    // Set the stream time at which this sample should start and finish.\n    STDMETHODIMP SetTime(__in_opt REFERENCE_TIME *pTimeStart, // put time here\n                         __in_opt REFERENCE_TIME *pTimeEnd);\n    STDMETHODIMP IsSyncPoint(void);\n    STDMETHODIMP SetSyncPoint(BOOL bIsSyncPoint);\n    STDMETHODIMP IsPreroll(void);\n    STDMETHODIMP SetPreroll(BOOL bIsPreroll);\n\n    STDMETHODIMP_(LONG) GetActualDataLength(void);\n    STDMETHODIMP SetActualDataLength(LONG lActual);\n\n    // these allow for limited format changes in band\n\n    STDMETHODIMP GetMediaType(__deref_out AM_MEDIA_TYPE **ppMediaType);\n    STDMETHODIMP SetMediaType(__in_opt AM_MEDIA_TYPE *pMediaType);\n\n    // returns S_OK if there is a discontinuity in the data (this same is\n    // not a continuation of the previous stream of data\n    // - there has been a seek).\n    STDMETHODIMP IsDiscontinuity(void);\n    // set the discontinuity property - TRUE if this sample is not a\n    // continuation, but a new sample after a seek.\n    STDMETHODIMP SetDiscontinuity(BOOL bDiscontinuity);\n\n    // get the media times for this sample\n    STDMETHODIMP GetMediaTime(__out LONGLONG *pTimeStart, __out LONGLONG *pTimeEnd);\n\n    // Set the media times for this sample\n    STDMETHODIMP SetMediaTime(__in_opt LONGLONG *pTimeStart, __in_opt LONGLONG *pTimeEnd);\n\n    // Set and get properties (IMediaSample2)\n    STDMETHODIMP GetProperties(DWORD cbProperties, __out_bcount(cbProperties) BYTE *pbProperties);\n\n    STDMETHODIMP SetProperties(DWORD cbProperties, __in_bcount(cbProperties) const BYTE *pbProperties);\n};\n\n//=====================================================================\n//=====================================================================\n// Defines CBaseAllocator\n//\n// Abstract base class that manages a list of media samples\n//\n// This class provides support for getting buffers from the free list,\n// including handling of commit and (asynchronous) decommit.\n//\n// Derive from this class and override the Alloc and Free functions to\n// allocate your CMediaSample (or derived) objects and add them to the\n// free list, preparing them as necessary.\n//=====================================================================\n//=====================================================================\n\nclass AM_NOVTABLE CBaseAllocator\n    : public CUnknown\n    , // A non delegating IUnknown\n      public IMemAllocatorCallbackTemp\n    ,                 // The interface we support\n      public CCritSec // Provides object locking\n{\n    class CSampleList;\n    friend class CSampleList;\n\n    /*  Trick to get at protected member in CMediaSample */\n    static CMediaSample *&NextSample(__in CMediaSample *pSample) { return pSample->m_pNext; };\n\n    /*  Mini list class for the free list */\n    class CSampleList\n    {\n      public:\n        CSampleList()\n            : m_List(NULL)\n            , m_nOnList(0){};\n#ifdef DEBUG\n        ~CSampleList() { ASSERT(m_nOnList == 0); };\n#endif\n        CMediaSample *Head() const { return m_List; };\n        CMediaSample *Next(__in CMediaSample *pSample) const { return CBaseAllocator::NextSample(pSample); };\n        int GetCount() const { return m_nOnList; };\n        void Add(__inout CMediaSample *pSample)\n        {\n            ASSERT(pSample != NULL);\n            CBaseAllocator::NextSample(pSample) = m_List;\n            m_List = pSample;\n            m_nOnList++;\n        };\n        CMediaSample *RemoveHead()\n        {\n            CMediaSample *pSample = m_List;\n            if (pSample != NULL)\n            {\n                m_List = CBaseAllocator::NextSample(m_List);\n                m_nOnList--;\n            }\n            return pSample;\n        };\n        void Remove(__inout CMediaSample *pSample);\n\n      public:\n        CMediaSample *m_List;\n        int m_nOnList;\n    };\n\n  protected:\n    CSampleList m_lFree; // Free list\n\n    /*  Note to overriders of CBaseAllocator.\n\n        We use a lazy signalling mechanism for waiting for samples.\n        This means we don't call the OS if no waits occur.\n\n        In order to implement this:\n\n        1. When a new sample is added to m_lFree call NotifySample() which\n           calls ReleaseSemaphore on m_hSem with a count of m_lWaiting and\n           sets m_lWaiting to 0.\n           This must all be done holding the allocator's critical section.\n\n        2. When waiting for a sample call SetWaiting() which increments\n           m_lWaiting BEFORE leaving the allocator's critical section.\n\n        3. Actually wait by calling WaitForSingleObject(m_hSem, INFINITE)\n           having left the allocator's critical section.  The effect of\n           this is to remove 1 from the semaphore's count.  You MUST call\n           this once having incremented m_lWaiting.\n\n        The following are then true when the critical section is not held :\n            (let nWaiting = number about to wait or waiting)\n\n            (1) if (m_lFree.GetCount() != 0) then (m_lWaiting == 0)\n            (2) m_lWaiting + Semaphore count == nWaiting\n\n        We would deadlock if\n           nWaiting != 0 &&\n           m_lFree.GetCount() != 0 &&\n           Semaphore count == 0\n\n           But from (1) if m_lFree.GetCount() != 0 then m_lWaiting == 0 so\n           from (2) Semaphore count == nWaiting (which is non-0) so the\n           deadlock can't happen.\n    */\n\n    HANDLE m_hSem;     // For signalling\n    long m_lWaiting;   // Waiting for a free element\n    long m_lCount;     // how many buffers we have agreed to provide\n    long m_lAllocated; // how many buffers are currently allocated\n    long m_lSize;      // agreed size of each buffer\n    long m_lAlignment; // agreed alignment\n    long m_lPrefix;    // agreed prefix (preceeds GetPointer() value)\n    BOOL m_bChanged;   // Have the buffer requirements changed\n\n    // if true, we are decommitted and can't allocate memory\n    BOOL m_bCommitted;\n    // if true, the decommit has happened, but we haven't called Free yet\n    // as there are still outstanding buffers\n    BOOL m_bDecommitInProgress;\n\n    //  Notification interface\n    IMemAllocatorNotifyCallbackTemp *m_pNotify;\n\n    BOOL m_fEnableReleaseCallback;\n\n    // called to decommit the memory when the last buffer is freed\n    // pure virtual - need to override this\n    virtual void Free(void) PURE;\n\n    // override to allocate the memory when commit called\n    virtual HRESULT Alloc(void);\n\n  public:\n    CBaseAllocator(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, __inout HRESULT *, BOOL bEvent = TRUE,\n                   BOOL fEnableReleaseCallback = FALSE);\n#ifdef UNICODE\n    CBaseAllocator(__in_opt LPCSTR, __inout_opt LPUNKNOWN, __inout HRESULT *, BOOL bEvent = TRUE,\n                   BOOL fEnableReleaseCallback = FALSE);\n#endif\n    virtual ~CBaseAllocator();\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    STDMETHODIMP SetProperties(__in ALLOCATOR_PROPERTIES *pRequest, __out ALLOCATOR_PROPERTIES *pActual);\n\n    // return the properties actually being used on this allocator\n    STDMETHODIMP GetProperties(__out ALLOCATOR_PROPERTIES *pProps);\n\n    // override Commit to allocate memory. We handle the GetBuffer\n    // state changes\n    STDMETHODIMP Commit();\n\n    // override this to handle the memory freeing. We handle any outstanding\n    // GetBuffer calls\n    STDMETHODIMP Decommit();\n\n    // get container for a sample. Blocking, synchronous call to get the\n    // next free buffer (as represented by an IMediaSample interface).\n    // on return, the time etc properties will be invalid, but the buffer\n    // pointer and size will be correct. The two time parameters are\n    // optional and either may be NULL, they may alternatively be set to\n    // the start and end times the sample will have attached to it\n    // bPrevFramesSkipped is not used (used only by the video renderer's\n    // allocator where it affects quality management in direct draw).\n\n    STDMETHODIMP GetBuffer(__deref_out IMediaSample **ppBuffer, __in_opt REFERENCE_TIME *pStartTime,\n                           __in_opt REFERENCE_TIME *pEndTime, DWORD dwFlags);\n\n    // final release of a CMediaSample will call this\n    STDMETHODIMP ReleaseBuffer(IMediaSample *pBuffer);\n    // obsolete:: virtual void PutOnFreeList(CMediaSample * pSample);\n\n    STDMETHODIMP SetNotify(IMemAllocatorNotifyCallbackTemp *pNotify);\n\n    STDMETHODIMP GetFreeCount(__out LONG *plBuffersFree);\n\n    // Notify that a sample is available\n    void NotifySample();\n\n    // Notify that we're waiting for a sample\n    void SetWaiting() { m_lWaiting++; };\n};\n\n//=====================================================================\n//=====================================================================\n// Defines CMemAllocator\n//\n// this is an allocator based on CBaseAllocator that allocates sample\n// buffers in main memory (from 'new'). You must call SetProperties\n// before calling Commit.\n//\n// we don't free the memory when going into Decommit state. The simplest\n// way to implement this without complicating CBaseAllocator is to\n// have a Free() function, called to go into decommit state, that does\n// nothing and a ReallyFree function called from our destructor that\n// actually frees the memory.\n//=====================================================================\n//=====================================================================\n\n//  Make me one from quartz.dll\nSTDAPI CreateMemoryAllocator(__deref_out IMemAllocator **ppAllocator);\n\nclass CMemAllocator : public CBaseAllocator\n{\n\n  protected:\n    LPBYTE m_pBuffer; // combined memory for all buffers\n\n    // override to free the memory when decommit completes\n    // - we actually do nothing, and save the memory until deletion.\n    void Free(void);\n\n    // called from the destructor (and from Alloc if changing size/count) to\n    // actually free up the memory\n    void ReallyFree(void);\n\n    // overriden to allocate the memory when commit called\n    HRESULT Alloc(void);\n\n  public:\n    /* This goes in the factory template table to create new instances */\n    static CUnknown *CreateInstance(__inout_opt LPUNKNOWN, __inout HRESULT *);\n\n    STDMETHODIMP SetProperties(__in ALLOCATOR_PROPERTIES *pRequest, __out ALLOCATOR_PROPERTIES *pActual);\n\n    CMemAllocator(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, __inout HRESULT *);\n#ifdef UNICODE\n    CMemAllocator(__in_opt LPCSTR, __inout_opt LPUNKNOWN, __inout HRESULT *);\n#endif\n    ~CMemAllocator();\n};\n\n// helper used by IAMovieSetup implementation\nSTDAPI\nAMovieSetupRegisterFilter(const AMOVIESETUP_FILTER *const psetupdata, IFilterMapper *pIFM, BOOL bRegister);\n\n///////////////////////////////////////////////////////////////////////////\n// ------------------------------------------------------------------------\n// ------------------------------------------------------------------------\n// ------------------------------------------------------------------------\n// ------------------------------------------------------------------------\n///////////////////////////////////////////////////////////////////////////\n\n#endif /* __FILTER__ */\n"
  },
  {
    "path": "common/baseclasses/amvideo.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: AMVideo.cpp\n//\n// Desc: DirectShow base classes - implements helper functions for\n//       bitmap formats.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <limits.h>\n\n// These are bit field masks for true colour devices\n\nconst DWORD bits555[] = {0x007C00, 0x0003E0, 0x00001F};\nconst DWORD bits565[] = {0x00F800, 0x0007E0, 0x00001F};\nconst DWORD bits888[] = {0xFF0000, 0x00FF00, 0x0000FF};\n\n// This maps bitmap subtypes into a bits per pixel value and also a\n// name. unicode and ansi versions are stored because we have to\n// return a pointer to a static string.\n// clang-format off\nconst struct {\n    const GUID *pSubtype;\n    WORD BitCount;\n    CHAR *pName;\n    WCHAR *wszName;\n} BitCountMap[] =  { &MEDIASUBTYPE_RGB1,        1,   \"RGB Monochrome\",     L\"RGB Monochrome\",   \n                     &MEDIASUBTYPE_RGB4,        4,   \"RGB VGA\",            L\"RGB VGA\",          \n                     &MEDIASUBTYPE_RGB8,        8,   \"RGB 8\",              L\"RGB 8\",            \n                     &MEDIASUBTYPE_RGB565,      16,  \"RGB 565 (16 bit)\",   L\"RGB 565 (16 bit)\", \n                     &MEDIASUBTYPE_RGB555,      16,  \"RGB 555 (16 bit)\",   L\"RGB 555 (16 bit)\", \n                     &MEDIASUBTYPE_RGB24,       24,  \"RGB 24\",             L\"RGB 24\",           \n                     &MEDIASUBTYPE_RGB32,       32,  \"RGB 32\",             L\"RGB 32\",\n                     &MEDIASUBTYPE_ARGB32,      32,  \"ARGB 32\",            L\"ARGB 32\",\n                     &MEDIASUBTYPE_Overlay,     0,   \"Overlay\",            L\"Overlay\",          \n                     &GUID_NULL,                0,   \"UNKNOWN\",            L\"UNKNOWN\"           \n};\n// clang-format on\n\n// Return the size of the bitmap as defined by this header\n\nSTDAPI_(DWORD) GetBitmapSize(const BITMAPINFOHEADER *pHeader)\n{\n    return DIBSIZE(*pHeader);\n}\n\n// This is called if the header has a 16 bit colour depth and needs to work\n// out the detailed type from the bit fields (either RGB 565 or RGB 555)\n\nSTDAPI_(const GUID) GetTrueColorType(const BITMAPINFOHEADER *pbmiHeader)\n{\n    BITMAPINFO *pbmInfo = (BITMAPINFO *)pbmiHeader;\n    ASSERT(pbmiHeader->biBitCount == 16);\n\n    // If its BI_RGB then it's RGB 555 by default\n\n    if (pbmiHeader->biCompression == BI_RGB)\n    {\n        return MEDIASUBTYPE_RGB555;\n    }\n\n    // Compare the bit fields with RGB 555\n\n    DWORD *pMask = (DWORD *)pbmInfo->bmiColors;\n    if (pMask[0] == bits555[0])\n    {\n        if (pMask[1] == bits555[1])\n        {\n            if (pMask[2] == bits555[2])\n            {\n                return MEDIASUBTYPE_RGB555;\n            }\n        }\n    }\n\n    // Compare the bit fields with RGB 565\n\n    pMask = (DWORD *)pbmInfo->bmiColors;\n    if (pMask[0] == bits565[0])\n    {\n        if (pMask[1] == bits565[1])\n        {\n            if (pMask[2] == bits565[2])\n            {\n                return MEDIASUBTYPE_RGB565;\n            }\n        }\n    }\n    return GUID_NULL;\n}\n\n// Given a BITMAPINFOHEADER structure this returns the GUID sub type that is\n// used to describe it in format negotiations. For example a video codec fills\n// in the format block with a VIDEOINFO structure, it also fills in the major\n// type with MEDIATYPE_VIDEO and the subtype with a GUID that matches the bit\n// count, for example if it is an eight bit image then MEDIASUBTYPE_RGB8\n\nSTDAPI_(const GUID) GetBitmapSubtype(const BITMAPINFOHEADER *pbmiHeader)\n{\n    ASSERT(pbmiHeader);\n\n    // If it's not RGB then create a GUID from the compression type\n\n    if (pbmiHeader->biCompression != BI_RGB)\n    {\n        if (pbmiHeader->biCompression != BI_BITFIELDS)\n        {\n            FOURCCMap FourCCMap(pbmiHeader->biCompression);\n            return (const GUID)FourCCMap;\n        }\n    }\n\n    // Map the RGB DIB bit depth to a image GUID\n\n    switch (pbmiHeader->biBitCount)\n    {\n    case 1: return MEDIASUBTYPE_RGB1;\n    case 4: return MEDIASUBTYPE_RGB4;\n    case 8: return MEDIASUBTYPE_RGB8;\n    case 16: return GetTrueColorType(pbmiHeader);\n    case 24: return MEDIASUBTYPE_RGB24;\n    case 32: return MEDIASUBTYPE_RGB32;\n    }\n    return GUID_NULL;\n}\n\n// Given a video bitmap subtype we return the number of bits per pixel it uses\n// We return a WORD bit count as thats what the BITMAPINFOHEADER uses. If the\n// GUID subtype is not found in the table we return an invalid USHRT_MAX\n\nSTDAPI_(WORD) GetBitCount(const GUID *pSubtype)\n{\n    ASSERT(pSubtype);\n    const GUID *pMediaSubtype;\n    INT iPosition = 0;\n\n    // Scan the mapping list seeing if the source GUID matches any known\n    // bitmap subtypes, the list is terminated by a GUID_NULL entry\n\n    while (TRUE)\n    {\n        pMediaSubtype = BitCountMap[iPosition].pSubtype;\n        if (IsEqualGUID(*pMediaSubtype, GUID_NULL))\n        {\n            return USHRT_MAX;\n        }\n        if (IsEqualGUID(*pMediaSubtype, *pSubtype))\n        {\n            return BitCountMap[iPosition].BitCount;\n        }\n        iPosition++;\n    }\n}\n\n// Given a bitmap subtype we return a description name that can be used for\n// debug purposes. In a retail build this function still returns the names\n// If the subtype isn't found in the lookup table we return string UNKNOWN\n\nint LocateSubtype(const GUID *pSubtype)\n{\n    ASSERT(pSubtype);\n    const GUID *pMediaSubtype;\n    INT iPosition = 0;\n\n    // Scan the mapping list seeing if the source GUID matches any known\n    // bitmap subtypes, the list is terminated by a GUID_NULL entry\n\n    while (TRUE)\n    {\n        pMediaSubtype = BitCountMap[iPosition].pSubtype;\n        if (IsEqualGUID(*pMediaSubtype, *pSubtype) || IsEqualGUID(*pMediaSubtype, GUID_NULL))\n        {\n            break;\n        }\n\n        iPosition++;\n    }\n\n    return iPosition;\n}\n\nSTDAPI_(WCHAR *) GetSubtypeNameW(const GUID *pSubtype)\n{\n    return BitCountMap[LocateSubtype(pSubtype)].wszName;\n}\n\nSTDAPI_(CHAR *) GetSubtypeNameA(const GUID *pSubtype)\n{\n    return BitCountMap[LocateSubtype(pSubtype)].pName;\n}\n\n#ifndef GetSubtypeName\n#error wxutil.h should have defined GetSubtypeName\n#endif\n#undef GetSubtypeName\n\n// this is here for people that linked to it directly; most people\n// would use the header file that picks the A or W version.\nSTDAPI_(CHAR *) GetSubtypeName(const GUID *pSubtype)\n{\n    return GetSubtypeNameA(pSubtype);\n}\n\n// The mechanism for describing a bitmap format is with the BITMAPINFOHEADER\n// This is really messy to deal with because it invariably has fields that\n// follow it holding bit fields, palettes and the rest. This function gives\n// the number of bytes required to hold a VIDEOINFO that represents it. This\n// count includes the prefix information (like the rcSource rectangle) the\n// BITMAPINFOHEADER field, and any other colour information on the end.\n//\n// WARNING If you want to copy a BITMAPINFOHEADER into a VIDEOINFO always make\n// sure that you use the HEADER macro because the BITMAPINFOHEADER field isn't\n// right at the start of the VIDEOINFO (there are a number of other fields),\n//\n//     CopyMemory(HEADER(pVideoInfo),pbmi,sizeof(BITMAPINFOHEADER));\n//\n\nSTDAPI_(LONG) GetBitmapFormatSize(const BITMAPINFOHEADER *pHeader)\n{\n    // Everyone has this to start with this\n    LONG Size = SIZE_PREHEADER + pHeader->biSize;\n\n    ASSERT(pHeader->biSize >= sizeof(BITMAPINFOHEADER));\n\n    // Does this format use a palette, if the number of colours actually used\n    // is zero then it is set to the maximum that are allowed for that colour\n    // depth (an example is 256 for eight bits). Truecolour formats may also\n    // pass a palette with them in which case the used count is non zero\n\n    // This would scare me.\n    ASSERT(pHeader->biBitCount <= iPALETTE || pHeader->biClrUsed == 0);\n\n    if (pHeader->biBitCount <= iPALETTE || pHeader->biClrUsed)\n    {\n        LONG Entries = (DWORD)1 << pHeader->biBitCount;\n        if (pHeader->biClrUsed)\n        {\n            Entries = pHeader->biClrUsed;\n        }\n        Size += Entries * sizeof(RGBQUAD);\n    }\n\n    // Truecolour formats may have a BI_BITFIELDS specifier for compression\n    // type which means that room for three DWORDs should be allocated that\n    // specify where in each pixel the RGB colour components may be found\n\n    if (pHeader->biCompression == BI_BITFIELDS)\n    {\n        Size += SIZE_MASKS;\n    }\n\n    // A BITMAPINFO for a palettised image may also contain a palette map that\n    // provides the information to map from a source palette to a destination\n    // palette during a BitBlt for example, because this information is only\n    // ever processed during drawing you don't normally store the palette map\n    // nor have any way of knowing if it is present in the data structure\n\n    return Size;\n}\n\n// Returns TRUE if the VIDEOINFO contains a palette\n\nSTDAPI_(BOOL) ContainsPalette(const VIDEOINFOHEADER *pVideoInfo)\n{\n    if (PALETTISED(pVideoInfo) == FALSE)\n    {\n        if (pVideoInfo->bmiHeader.biClrUsed == 0)\n        {\n            return FALSE;\n        }\n    }\n    return TRUE;\n}\n\n// Return a pointer to the first entry in a palette\n\nSTDAPI_(const RGBQUAD *) GetBitmapPalette(const VIDEOINFOHEADER *pVideoInfo)\n{\n    if (pVideoInfo->bmiHeader.biCompression == BI_BITFIELDS)\n    {\n        return TRUECOLOR(pVideoInfo)->bmiColors;\n    }\n    return COLORS(pVideoInfo);\n}\n"
  },
  {
    "path": "common/baseclasses/arithutil.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: ArithUtil.cpp\n//\n// Desc: DirectShow base classes - implements helper classes for building\n//       multimedia filters.\n//\n// Copyright (c) 1992-2004 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n\n//\n//  Declare function from largeint.h we need so that PPC can build\n//\n\n//\n// Enlarged integer divide - 64-bits / 32-bits > 32-bits\n//\n\n#ifndef _X86_\n\n#define LLtoU64(x) (*(unsigned __int64 *)(void *)(&(x)))\n\n__inline ULONG WINAPI EnlargedUnsignedDivide(IN ULARGE_INTEGER Dividend, IN ULONG Divisor, IN PULONG Remainder)\n{\n    // return remainder if necessary\n    if (Remainder != NULL)\n        *Remainder = (ULONG)(LLtoU64(Dividend) % Divisor);\n    return (ULONG)(LLtoU64(Dividend) / Divisor);\n}\n\n#else\n__inline ULONG WINAPI EnlargedUnsignedDivide(IN ULARGE_INTEGER Dividend, IN ULONG Divisor, IN PULONG Remainder)\n{\n    ULONG ulResult;\n    _asm {\n        mov eax,Dividend.LowPart\n        mov edx,Dividend.HighPart\n        mov ecx,Remainder\n        div Divisor\n        or  ecx,ecx\n        jz  short label\n        mov [ecx],edx\nlabel:\n        mov ulResult,eax\n    }\n    return ulResult;\n}\n#endif\n\n/*  Arithmetic functions to help with time format conversions\n */\n\n#ifdef _M_ALPHA\n// work around bug in version 12.00.8385 of the alpha compiler where\n// UInt32x32To64 sign-extends its arguments (?)\n#undef UInt32x32To64\n#define UInt32x32To64(a, b) (((ULONGLONG)((ULONG)(a)) & 0xffffffff) * ((ULONGLONG)((ULONG)(b)) & 0xffffffff))\n#endif\n\n/*   Compute (a * b + d) / c */\nLONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG d)\n{\n    /*  Compute the absolute values to avoid signed arithmetic problems */\n    ULARGE_INTEGER ua, ub;\n    DWORDLONG uc;\n\n    ua.QuadPart = (DWORDLONG)(a >= 0 ? a : -a);\n    ub.QuadPart = (DWORDLONG)(b >= 0 ? b : -b);\n    uc = (DWORDLONG)(c >= 0 ? c : -c);\n    BOOL bSign = (a < 0) ^ (b < 0);\n\n    /*  Do long multiplication */\n    ULARGE_INTEGER p[2];\n    p[0].QuadPart = UInt32x32To64(ua.LowPart, ub.LowPart);\n\n    /*  This next computation cannot overflow into p[1].HighPart because\n        the max number we can compute here is:\n\n                 (2 ** 32 - 1) * (2 ** 32 - 1) +  // ua.LowPart * ub.LowPart\n    (2 ** 32) *  (2 ** 31) * (2 ** 32 - 1) * 2    // x.LowPart * y.HighPart * 2\n\n    == 2 ** 96 - 2 ** 64 + (2 ** 64 - 2 ** 33 + 1)\n    == 2 ** 96 - 2 ** 33 + 1\n    < 2 ** 96\n    */\n\n    ULARGE_INTEGER x;\n    x.QuadPart = UInt32x32To64(ua.LowPart, ub.HighPart) + UInt32x32To64(ua.HighPart, ub.LowPart) + p[0].HighPart;\n    p[0].HighPart = x.LowPart;\n    p[1].QuadPart = UInt32x32To64(ua.HighPart, ub.HighPart) + x.HighPart;\n\n    if (d != 0)\n    {\n        ULARGE_INTEGER ud[2];\n        if (bSign)\n        {\n            ud[0].QuadPart = (DWORDLONG)(-d);\n            if (d > 0)\n            {\n                /*  -d < 0 */\n                ud[1].QuadPart = (DWORDLONG)(LONGLONG)-1;\n            }\n            else\n            {\n                ud[1].QuadPart = (DWORDLONG)0;\n            }\n        }\n        else\n        {\n            ud[0].QuadPart = (DWORDLONG)d;\n            if (d < 0)\n            {\n                ud[1].QuadPart = (DWORDLONG)(LONGLONG)-1;\n            }\n            else\n            {\n                ud[1].QuadPart = (DWORDLONG)0;\n            }\n        }\n        /*  Now do extended addition */\n        ULARGE_INTEGER uliTotal;\n\n        /*  Add ls DWORDs */\n        uliTotal.QuadPart = (DWORDLONG)ud[0].LowPart + p[0].LowPart;\n        p[0].LowPart = uliTotal.LowPart;\n\n        /*  Propagate carry */\n        uliTotal.LowPart = uliTotal.HighPart;\n        uliTotal.HighPart = 0;\n\n        /*  Add 2nd most ls DWORDs */\n        uliTotal.QuadPart += (DWORDLONG)ud[0].HighPart + p[0].HighPart;\n        p[0].HighPart = uliTotal.LowPart;\n\n        /*  Propagate carry */\n        uliTotal.LowPart = uliTotal.HighPart;\n        uliTotal.HighPart = 0;\n\n        /*  Add MS DWORDLONGs - no carry expected */\n        p[1].QuadPart += ud[1].QuadPart + uliTotal.QuadPart;\n\n        /*  Now see if we got a sign change from the addition */\n        if ((LONG)p[1].HighPart < 0)\n        {\n            bSign = !bSign;\n\n            /*  Negate the current value (ugh!) */\n            p[0].QuadPart = ~p[0].QuadPart;\n            p[1].QuadPart = ~p[1].QuadPart;\n            p[0].QuadPart += 1;\n            p[1].QuadPart += (p[0].QuadPart == 0);\n        }\n    }\n\n    /*  Now for the division */\n    if (c < 0)\n    {\n        bSign = !bSign;\n    }\n\n    /*  This will catch c == 0 and overflow */\n    if (uc <= p[1].QuadPart)\n    {\n        return bSign ? (LONGLONG)0x8000000000000000 : (LONGLONG)0x7FFFFFFFFFFFFFFF;\n    }\n\n    DWORDLONG ullResult;\n\n    /*  Do the division */\n    /*  If the dividend is a DWORD_LONG use the compiler */\n    if (p[1].QuadPart == 0)\n    {\n        ullResult = p[0].QuadPart / uc;\n        return bSign ? -(LONGLONG)ullResult : (LONGLONG)ullResult;\n    }\n\n    /*  If the divisor is a DWORD then its simpler */\n    ULARGE_INTEGER ulic;\n    ulic.QuadPart = uc;\n    if (ulic.HighPart == 0)\n    {\n        ULARGE_INTEGER uliDividend;\n        ULARGE_INTEGER uliResult;\n        DWORD dwDivisor = (DWORD)uc;\n        // ASSERT(p[1].HighPart == 0 && p[1].LowPart < dwDivisor);\n        uliDividend.HighPart = p[1].LowPart;\n        uliDividend.LowPart = p[0].HighPart;\n#ifndef USE_LARGEINT\n        uliResult.HighPart = (DWORD)(uliDividend.QuadPart / dwDivisor);\n        p[0].HighPart = (DWORD)(uliDividend.QuadPart % dwDivisor);\n        uliResult.LowPart = 0;\n        uliResult.QuadPart = p[0].QuadPart / dwDivisor + uliResult.QuadPart;\n#else\n        /*  NOTE - this routine will take exceptions if\n            the result does not fit in a DWORD\n        */\n        if (uliDividend.QuadPart >= (DWORDLONG)dwDivisor)\n        {\n            uliResult.HighPart = EnlargedUnsignedDivide(uliDividend, dwDivisor, &p[0].HighPart);\n        }\n        else\n        {\n            uliResult.HighPart = 0;\n        }\n        uliResult.LowPart = EnlargedUnsignedDivide(p[0], dwDivisor, NULL);\n#endif\n        return bSign ? -(LONGLONG)uliResult.QuadPart : (LONGLONG)uliResult.QuadPart;\n    }\n\n    ullResult = 0;\n\n    /*  OK - do long division */\n    for (int i = 0; i < 64; i++)\n    {\n        ullResult <<= 1;\n\n        /*  Shift 128 bit p left 1 */\n        p[1].QuadPart <<= 1;\n        if ((p[0].HighPart & 0x80000000) != 0)\n        {\n            p[1].LowPart++;\n        }\n        p[0].QuadPart <<= 1;\n\n        /*  Compare */\n        if (uc <= p[1].QuadPart)\n        {\n            p[1].QuadPart -= uc;\n            ullResult += 1;\n        }\n    }\n\n    return bSign ? -(LONGLONG)ullResult : (LONGLONG)ullResult;\n}\n\nLONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG d)\n{\n    ULARGE_INTEGER ua;\n    DWORD ub;\n    DWORD uc;\n\n    /*  Compute the absolute values to avoid signed arithmetic problems */\n    ua.QuadPart = (DWORDLONG)(a >= 0 ? a : -a);\n    ub = (DWORD)(b >= 0 ? b : -b);\n    uc = (DWORD)(c >= 0 ? c : -c);\n    BOOL bSign = (a < 0) ^ (b < 0);\n\n    /*  Do long multiplication */\n    ULARGE_INTEGER p0;\n    DWORD p1;\n    p0.QuadPart = UInt32x32To64(ua.LowPart, ub);\n\n    if (ua.HighPart != 0)\n    {\n        ULARGE_INTEGER x;\n        x.QuadPart = UInt32x32To64(ua.HighPart, ub) + p0.HighPart;\n        p0.HighPart = x.LowPart;\n        p1 = x.HighPart;\n    }\n    else\n    {\n        p1 = 0;\n    }\n\n    if (d != 0)\n    {\n        ULARGE_INTEGER ud0;\n        DWORD ud1;\n\n        if (bSign)\n        {\n            //\n            //  Cast d to LONGLONG first otherwise -0x80000000 sign extends\n            //  incorrectly\n            //\n            ud0.QuadPart = (DWORDLONG)(-(LONGLONG)d);\n            if (d > 0)\n            {\n                /*  -d < 0 */\n                ud1 = (DWORD)-1;\n            }\n            else\n            {\n                ud1 = (DWORD)0;\n            }\n        }\n        else\n        {\n            ud0.QuadPart = (DWORDLONG)d;\n            if (d < 0)\n            {\n                ud1 = (DWORD)-1;\n            }\n            else\n            {\n                ud1 = (DWORD)0;\n            }\n        }\n        /*  Now do extended addition */\n        ULARGE_INTEGER uliTotal;\n\n        /*  Add ls DWORDs */\n        uliTotal.QuadPart = (DWORDLONG)ud0.LowPart + p0.LowPart;\n        p0.LowPart = uliTotal.LowPart;\n\n        /*  Propagate carry */\n        uliTotal.LowPart = uliTotal.HighPart;\n        uliTotal.HighPart = 0;\n\n        /*  Add 2nd most ls DWORDs */\n        uliTotal.QuadPart += (DWORDLONG)ud0.HighPart + p0.HighPart;\n        p0.HighPart = uliTotal.LowPart;\n\n        /*  Add MS DWORDLONGs - no carry expected */\n        p1 += ud1 + uliTotal.HighPart;\n\n        /*  Now see if we got a sign change from the addition */\n        if ((LONG)p1 < 0)\n        {\n            bSign = !bSign;\n\n            /*  Negate the current value (ugh!) */\n            p0.QuadPart = ~p0.QuadPart;\n            p1 = ~p1;\n            p0.QuadPart += 1;\n            p1 += (p0.QuadPart == 0);\n        }\n    }\n\n    /*  Now for the division */\n    if (c < 0)\n    {\n        bSign = !bSign;\n    }\n\n    /*  This will catch c == 0 and overflow */\n    if (uc <= p1)\n    {\n        return bSign ? (LONGLONG)0x8000000000000000 : (LONGLONG)0x7FFFFFFFFFFFFFFF;\n    }\n\n    /*  Do the division */\n\n    /*  If the divisor is a DWORD then its simpler */\n    ULARGE_INTEGER uliDividend;\n    ULARGE_INTEGER uliResult;\n    DWORD dwDivisor = uc;\n    uliDividend.HighPart = p1;\n    uliDividend.LowPart = p0.HighPart;\n    /*  NOTE - this routine will take exceptions if\n        the result does not fit in a DWORD\n    */\n    if (uliDividend.QuadPart >= (DWORDLONG)dwDivisor)\n    {\n        uliResult.HighPart = EnlargedUnsignedDivide(uliDividend, dwDivisor, &p0.HighPart);\n    }\n    else\n    {\n        uliResult.HighPart = 0;\n    }\n    uliResult.LowPart = EnlargedUnsignedDivide(p0, dwDivisor, NULL);\n    return bSign ? -(LONGLONG)uliResult.QuadPart : (LONGLONG)uliResult.QuadPart;\n}\n"
  },
  {
    "path": "common/baseclasses/baseclasses.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{E8A3F6FA-AE1C-4C8E-A0B6-9C8480324EAA}</ProjectGuid>\n    <RootNamespace>BaseClasses</RootNamespace>\n    <Keyword>Win32Proj</Keyword>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <Import Project=\"$(SolutionDir)common\\platform.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <CharacterSet>Unicode</CharacterSet>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <CharacterSet>Unicode</CharacterSet>\n    <UseDebugLibraries>true</UseDebugLibraries>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Import Project=\"$(SolutionDir)common\\common.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup>\n    <TargetName Condition=\"'$(Configuration)'=='Debug'\">strmbasd</TargetName>\n    <TargetName Condition=\"'$(Configuration)'=='Release'\">strmbase</TargetName>\n  </PropertyGroup>\n  <ItemDefinitionGroup>\n    <ClCompile>\n      <PrecompiledHeader>NotUsing</PrecompiledHeader>\n    </ClCompile>\n    <Lib>\n      <AdditionalDependencies>strmiids.lib;%(AdditionalDependencies)</AdditionalDependencies>\n    </Lib>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Release'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"amextra.cpp\" />\n    <ClCompile Include=\"amfilter.cpp\" />\n    <ClCompile Include=\"amvideo.cpp\" />\n    <ClCompile Include=\"arithutil.cpp\" />\n    <ClCompile Include=\"combase.cpp\" />\n    <ClCompile Include=\"cprop.cpp\" />\n    <ClCompile Include=\"ctlutil.cpp\" />\n    <ClCompile Include=\"ddmm.cpp\" />\n    <ClCompile Include=\"dllentry.cpp\" />\n    <ClCompile Include=\"dllsetup.cpp\" />\n    <ClCompile Include=\"mtype.cpp\" />\n    <ClCompile Include=\"outputq.cpp\" />\n    <ClCompile Include=\"perflog.cpp\" />\n    <ClCompile Include=\"pstream.cpp\" />\n    <ClCompile Include=\"pullpin.cpp\" />\n    <ClCompile Include=\"refclock.cpp\" />\n    <ClCompile Include=\"renbase.cpp\" />\n    <ClCompile Include=\"schedule.cpp\" />\n    <ClCompile Include=\"seekpt.cpp\" />\n    <ClCompile Include=\"source.cpp\" />\n    <ClCompile Include=\"strmctl.cpp\" />\n    <ClCompile Include=\"sysclock.cpp\" />\n    <ClCompile Include=\"transfrm.cpp\" />\n    <ClCompile Include=\"transip.cpp\" />\n    <ClCompile Include=\"videoctl.cpp\" />\n    <ClCompile Include=\"vtrans.cpp\" />\n    <ClCompile Include=\"winctrl.cpp\" />\n    <ClCompile Include=\"winutil.cpp\" />\n    <ClCompile Include=\"wxdebug.cpp\" />\n    <ClCompile Include=\"wxlist.cpp\" />\n    <ClCompile Include=\"wxutil.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"amextra.h\" />\n    <ClInclude Include=\"amfilter.h\" />\n    <ClInclude Include=\"cache.h\" />\n    <ClInclude Include=\"combase.h\" />\n    <ClInclude Include=\"cprop.h\" />\n    <ClInclude Include=\"ctlutil.h\" />\n    <ClInclude Include=\"ddmm.h\" />\n    <ClInclude Include=\"dllsetup.h\" />\n    <ClInclude Include=\"dxmperf.h\" />\n    <ClInclude Include=\"fourcc.h\" />\n    <ClInclude Include=\"measure.h\" />\n    <ClInclude Include=\"msgthrd.h\" />\n    <ClInclude Include=\"mtype.h\" />\n    <ClInclude Include=\"outputq.h\" />\n    <ClInclude Include=\"perflog.h\" />\n    <ClInclude Include=\"perfstruct.h\" />\n    <ClInclude Include=\"pstream.h\" />\n    <ClInclude Include=\"pullpin.h\" />\n    <ClInclude Include=\"refclock.h\" />\n    <ClInclude Include=\"reftime.h\" />\n    <ClInclude Include=\"renbase.h\" />\n    <ClInclude Include=\"schedule.h\" />\n    <ClInclude Include=\"seekpt.h\" />\n    <ClInclude Include=\"source.h\" />\n    <ClInclude Include=\"streams.h\" />\n    <ClInclude Include=\"strmctl.h\" />\n    <ClInclude Include=\"sysclock.h\" />\n    <ClInclude Include=\"transfrm.h\" />\n    <ClInclude Include=\"transip.h\" />\n    <ClInclude Include=\"videoctl.h\" />\n    <ClInclude Include=\"vtrans.h\" />\n    <ClInclude Include=\"winctrl.h\" />\n    <ClInclude Include=\"winutil.h\" />\n    <ClInclude Include=\"wxdebug.h\" />\n    <ClInclude Include=\"wxlist.h\" />\n    <ClInclude Include=\"wxutil.h\" />\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>\n"
  },
  {
    "path": "common/baseclasses/baseclasses.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"amextra.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"amfilter.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"amvideo.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"arithutil.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"combase.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"cprop.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"ctlutil.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"ddmm.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dllentry.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dllsetup.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"mtype.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"outputq.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"perflog.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pstream.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pullpin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"refclock.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"renbase.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"schedule.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"seekpt.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"source.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"strmctl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"sysclock.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"transfrm.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"transip.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"videoctl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"vtrans.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"winctrl.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"winutil.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"wxdebug.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"wxlist.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"wxutil.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"amextra.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"amfilter.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"cache.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"combase.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"cprop.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"ctlutil.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"ddmm.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"dllsetup.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"dxmperf.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"fourcc.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"measure.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"msgthrd.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"mtype.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"outputq.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"perflog.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"perfstruct.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"pstream.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"pullpin.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"refclock.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"reftime.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"renbase.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"schedule.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"seekpt.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"source.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"streams.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"strmctl.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"sysclock.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"transfrm.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"transip.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"videoctl.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"vtrans.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"winctrl.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"winutil.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"wxdebug.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"wxlist.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"wxutil.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "common/baseclasses/cache.h",
    "content": "//------------------------------------------------------------------------------\n// File: Cache.h\n//\n// Desc: DirectShow base classes - efines a non-MFC generic cache class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n/* This class implements a simple cache. A cache object is instantiated\n   with the number of items it is to hold. An item is a pointer to an\n   object derived from CBaseObject (helps reduce memory leaks). The cache\n   can then have objects added to it and removed from it. The cache size\n   is fixed at construction time and may therefore run out or be flooded.\n   If it runs out it returns a NULL pointer, if it fills up it also returns\n   a NULL pointer instead of a pointer to the object just inserted */\n\n/* Making these classes inherit from CBaseObject does nothing for their\n   functionality but it allows us to check there are no memory leaks */\n\n/* WARNING Be very careful when using this class, what it lets you do is\n   store and retrieve objects so that you can minimise object creation\n   which in turns improves efficiency. However the object you store is\n   exactly the same as the object you get back which means that it short\n   circuits the constructor initialisation phase. This means any class\n   variables the object has (eg pointers) are highly likely to be invalid.\n   Therefore ensure you reinitialise the object before using it again */\n\n#ifndef __CACHE__\n#define __CACHE__\n\nclass CCache : CBaseObject\n{\n\n    /* Make copy constructor and assignment operator inaccessible */\n\n    CCache(const CCache &refCache);\n    CCache &operator=(const CCache &refCache);\n\n  private:\n    /* These are initialised in the constructor. The first variable points to\n       an array of pointers, each of which points to a CBaseObject derived\n       object. The m_iCacheSize is the static fixed size for the cache and the\n       m_iUsed defines the number of places filled with objects at any time.\n       We fill the array of pointers from the start (ie m_ppObjects[0] first)\n       and then only add and remove objects from the end position, so in this\n       respect the array of object pointers should be treated as a stack */\n\n    CBaseObject **m_ppObjects;\n    const INT m_iCacheSize;\n    INT m_iUsed;\n\n  public:\n    CCache(__in_opt LPCTSTR pName, INT iItems);\n    virtual ~CCache();\n\n    /* Add an item to the cache */\n    CBaseObject *AddToCache(__in CBaseObject *pObject);\n\n    /* Remove an item from the cache */\n    CBaseObject *RemoveFromCache();\n\n    /* Delete all the objects held in the cache */\n    void RemoveAll(void);\n\n    /* Return the cache size which is set during construction */\n    INT GetCacheSize(void) const { return m_iCacheSize; };\n};\n\n#endif /* __CACHE__ */\n"
  },
  {
    "path": "common/baseclasses/checkbmi.h",
    "content": "//  Copyright (c) 1992 - 1997  Microsoft Corporation.  All Rights Reserved.\n\n#ifndef _CHECKBMI_H_\n#define _CHECKBMI_H_\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n//  Helper\n__inline BOOL MultiplyCheckOverflow(DWORD a, DWORD b, __deref_out_range(==, a * b) DWORD *pab) {\n    *pab = a * b;\n    if ((a == 0) || (((*pab) / a) == b)) {\n        return TRUE;\n    }\n    return FALSE;\n}\n\n\n//  Checks if the fields in a BITMAPINFOHEADER won't generate\n//  overlows and buffer overruns\n//  This is not a complete check and does not guarantee code using this structure will be secure\n//  from attack\n//  Bugs this is guarding against:\n//        1.  Total structure size calculation overflowing\n//        2.  biClrUsed > 256 for 8-bit palettized content\n//        3.  Total bitmap size in bytes overflowing\n//        4.  biSize < size of the base structure leading to accessessing random memory\n//        5.  Total structure size exceeding know size of data\n//\n\n__success(return != 0) __inline BOOL ValidateBitmapInfoHeader(\n    const BITMAPINFOHEADER *pbmi,   // pointer to structure to check\n    __out_range(>=, sizeof(BITMAPINFOHEADER)) DWORD cbSize     // size of memory block containing structure\n)\n{\n    DWORD dwWidthInBytes;\n    DWORD dwBpp;\n    DWORD dwWidthInBits;\n    DWORD dwHeight;\n    DWORD dwSizeImage;\n    DWORD dwClrUsed;\n\n    // Reject bad parameters - do the size check first to avoid reading bad memory\n    if (cbSize < sizeof(BITMAPINFOHEADER) ||\n        pbmi->biSize < sizeof(BITMAPINFOHEADER) ||\n        pbmi->biSize > 4096) {\n        return FALSE;\n    }\n\n    //  Reject 0 size\n    if (pbmi->biWidth == 0 || pbmi->biHeight == 0) {\n        return FALSE;\n    }\n\n    // Use bpp of 200 for validating against further overflows if not set for compressed format\n    dwBpp = 200;\n\n    if (pbmi->biBitCount > dwBpp) {\n        return FALSE;\n    }\n\n    // Strictly speaking abs can overflow so cast explicitly to DWORD\n    dwHeight = (DWORD)abs(pbmi->biHeight);\n\n    if (!MultiplyCheckOverflow(dwBpp, (DWORD)pbmi->biWidth, &dwWidthInBits)) {\n        return FALSE;\n    }\n\n    //  Compute correct width in bytes - rounding up to 4 bytes\n    dwWidthInBytes = (dwWidthInBits / 8 + 3) & ~3;\n\n    if (!MultiplyCheckOverflow(dwWidthInBytes, dwHeight, &dwSizeImage)) {\n        return FALSE;\n    }\n\n    // Fail if total size is 0 - this catches indivual quantities being 0\n    // Also don't allow huge values > 1GB which might cause arithmetic\n    // errors for users\n    if (dwSizeImage > 0x40000000 ||\n        pbmi->biSizeImage > 0x40000000) {\n        return FALSE;\n    }\n\n    //  Fail if biClrUsed looks bad\n    if (pbmi->biClrUsed > 256) {\n        return FALSE;\n    }\n\n    if (pbmi->biClrUsed == 0 && pbmi->biBitCount <= 8 && pbmi->biBitCount > 0) {\n        dwClrUsed = (1 << pbmi->biBitCount);\n    } else {\n        dwClrUsed = pbmi->biClrUsed;\n    }\n\n    //  Check total size\n    if (cbSize < pbmi->biSize + dwClrUsed * sizeof(RGBQUAD) +\n                 (pbmi->biCompression == BI_BITFIELDS ? 3 * sizeof(DWORD) : 0)) {\n        return FALSE;\n    }\n\n    //  If it is RGB validate biSizeImage - lots of code assumes the size is correct\n    if (pbmi->biCompression == BI_RGB || pbmi->biCompression == BI_BITFIELDS) {\n        if (pbmi->biSizeImage != 0) {\n            DWORD dwBits = (DWORD)pbmi->biWidth * (DWORD)pbmi->biBitCount;\n            DWORD dwWidthInBytes = ((DWORD)((dwBits+31) & (~31)) / 8);\n            DWORD dwTotalSize = (DWORD)abs(pbmi->biHeight) * dwWidthInBytes;\n            if (dwTotalSize > pbmi->biSizeImage) {\n                return FALSE;\n            }\n        }\n    }\n    return TRUE;\n}\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // _CHECKBMI_H_\n"
  },
  {
    "path": "common/baseclasses/combase.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: ComBase.cpp\n//\n// Desc: DirectShow base classes - implements class hierarchy for creating\n//       COM objects.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#pragma warning(disable : 4514) // Disable warnings re unused inline functions\n\n/* Define the static member variable */\n\nLONG CBaseObject::m_cObjects = 0;\n\n/* Constructor */\n\nCBaseObject::CBaseObject(__in_opt LPCTSTR pName)\n{\n    /* Increment the number of active objects */\n    InterlockedIncrement(&m_cObjects);\n\n#ifdef DEBUG\n\n#ifdef UNICODE\n    m_dwCookie = DbgRegisterObjectCreation(0, pName);\n#else\n    m_dwCookie = DbgRegisterObjectCreation(pName, 0);\n#endif\n\n#endif\n}\n\n#ifdef UNICODE\nCBaseObject::CBaseObject(const char *pName)\n{\n    /* Increment the number of active objects */\n    InterlockedIncrement(&m_cObjects);\n\n#ifdef DEBUG\n    m_dwCookie = DbgRegisterObjectCreation(pName, 0);\n#endif\n}\n#endif\n\nHINSTANCE hlibOLEAut32;\n\n/* Destructor */\n\nCBaseObject::~CBaseObject()\n{\n    /* Decrement the number of objects active */\n    if (InterlockedDecrement(&m_cObjects) == 0)\n    {\n        if (hlibOLEAut32)\n        {\n            FreeLibrary(hlibOLEAut32);\n\n            hlibOLEAut32 = 0;\n        }\n    };\n\n#ifdef DEBUG\n    DbgRegisterObjectDestruction(m_dwCookie);\n#endif\n}\n\nstatic const TCHAR szOle32Aut[] = TEXT(\"OleAut32.dll\");\n\nHINSTANCE LoadOLEAut32()\n{\n    if (hlibOLEAut32 == 0)\n    {\n\n        hlibOLEAut32 = LoadLibrary(szOle32Aut);\n    }\n\n    return hlibOLEAut32;\n}\n\n/* Constructor */\n\n// We know we use \"this\" in the initialization list, we also know we don't modify *phr.\n#pragma warning(disable : 4355 4100)\nCUnknown::CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk)\n    : CBaseObject(pName)\n    /* Start the object with a reference count of zero - when the      */\n    /* object is queried for it's first interface this may be          */\n    /* incremented depending on whether or not this object is          */\n    /* currently being aggregated upon                                 */\n    , m_cRef(0)\n    /* Set our pointer to our IUnknown interface.                      */\n    /* If we have an outer, use its, otherwise use ours.               */\n    /* This pointer effectivly points to the owner of                  */\n    /* this object and can be accessed by the GetOwner() method.       */\n    , m_pUnknown(pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>(static_cast<PNDUNKNOWN>(this)))\n/* Why the double cast?  Well, the inner cast is a type-safe cast */\n/* to pointer to a type from which we inherit.  The second is     */\n/* type-unsafe but works because INonDelegatingUnknown \"behaves   */\n/* like\" IUnknown. (Only the names on the methods change.)        */\n{\n    // Everything we need to do has been done in the initializer list\n}\n\n// This does the same as above except it has a useless HRESULT argument\n// use the previous constructor, this is just left for compatibility...\nCUnknown::CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr)\n    : CBaseObject(pName)\n    , m_cRef(0)\n    , m_pUnknown(pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>(static_cast<PNDUNKNOWN>(this)))\n{\n}\n\n#ifdef UNICODE\nCUnknown::CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk)\n    : CBaseObject(pName)\n    , m_cRef(0)\n    , m_pUnknown(pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>(static_cast<PNDUNKNOWN>(this)))\n{\n}\n\nCUnknown::CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr)\n    : CBaseObject(pName)\n    , m_cRef(0)\n    , m_pUnknown(pUnk != 0 ? pUnk : reinterpret_cast<LPUNKNOWN>(static_cast<PNDUNKNOWN>(this)))\n{\n}\n\n#endif\n\n#pragma warning(default : 4355 4100)\n\n/* QueryInterface */\n\nSTDMETHODIMP CUnknown::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n\n    /* We know only about IUnknown */\n\n    if (riid == IID_IUnknown)\n    {\n        GetInterface((LPUNKNOWN)(PNDUNKNOWN)this, ppv);\n        return NOERROR;\n    }\n    else\n    {\n        *ppv = NULL;\n        return E_NOINTERFACE;\n    }\n}\n\n/* We have to ensure that we DON'T use a max macro, since these will typically   */\n/* lead to one of the parameters being evaluated twice.  Since we are worried    */\n/* about concurrency, we can't afford to access the m_cRef twice since we can't  */\n/* afford to run the risk that its value having changed between accesses.        */\n\ntemplate <class T> inline static T ourmax(const T &a, const T &b)\n{\n    return a > b ? a : b;\n}\n\n/* AddRef */\n\nSTDMETHODIMP_(ULONG) CUnknown::NonDelegatingAddRef()\n{\n    LONG lRef = InterlockedIncrement(&m_cRef);\n    ASSERT(lRef > 0);\n    DbgLog((LOG_MEMORY, 3, TEXT(\"    Obj %d ref++ = %d\"), m_dwCookie, m_cRef));\n    return ourmax(ULONG(m_cRef), 1ul);\n}\n\n/* Release */\n\nSTDMETHODIMP_(ULONG) CUnknown::NonDelegatingRelease()\n{\n    /* If the reference count drops to zero delete ourselves */\n\n    LONG lRef = InterlockedDecrement(&m_cRef);\n    ASSERT(lRef >= 0);\n\n    DbgLog((LOG_MEMORY, 3, TEXT(\"    Object %d ref-- = %d\"), m_dwCookie, m_cRef));\n    if (lRef == 0)\n    {\n\n        // COM rules say we must protect against re-entrancy.\n        // If we are an aggregator and we hold our own interfaces\n        // on the aggregatee, the QI for these interfaces will\n        // addref ourselves. So after doing the QI we must release\n        // a ref count on ourselves. Then, before releasing the\n        // private interface, we must addref ourselves. When we do\n        // this from the destructor here it will result in the ref\n        // count going to 1 and then back to 0 causing us to\n        // re-enter the destructor. Hence we add an extra refcount here\n        // once we know we will delete the object.\n        // for an example aggregator see filgraph\\distrib.cpp.\n\n        m_cRef++;\n\n        delete this;\n        return ULONG(0);\n    }\n    else\n    {\n        //  Don't touch m_cRef again even in this leg as the object\n        //  may have just been released on another thread too\n        return ourmax(ULONG(lRef), 1ul);\n    }\n}\n\n/* Return an interface pointer to a requesting client\n   performing a thread safe AddRef as necessary */\n\nSTDAPI GetInterface(LPUNKNOWN pUnk, __out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n    *ppv = pUnk;\n    pUnk->AddRef();\n    return NOERROR;\n}\n\n/* Compares two interfaces and returns TRUE if they are on the same object */\n\nBOOL WINAPI IsEqualObject(IUnknown *pFirst, IUnknown *pSecond)\n{\n    /*  Different objects can't have the same interface pointer for\n        any interface\n    */\n    if (pFirst == pSecond)\n    {\n        return TRUE;\n    }\n    /*  OK - do it the hard way - check if they have the same\n        IUnknown pointers - a single object can only have one of these\n    */\n    LPUNKNOWN pUnknown1; // Retrieve the IUnknown interface\n    LPUNKNOWN pUnknown2; // Retrieve the other IUnknown interface\n    HRESULT hr;          // General OLE return code\n\n    ASSERT(pFirst);\n    ASSERT(pSecond);\n\n    /* See if the IUnknown pointers match */\n\n    hr = pFirst->QueryInterface(IID_IUnknown, (void **)&pUnknown1);\n    if (FAILED(hr))\n    {\n        return FALSE;\n    }\n    ASSERT(pUnknown1);\n\n    /* Release the extra interface we hold */\n\n    pUnknown1->Release();\n\n    hr = pSecond->QueryInterface(IID_IUnknown, (void **)&pUnknown2);\n    if (FAILED(hr))\n    {\n        return FALSE;\n    }\n    ASSERT(pUnknown2);\n\n    /* Release the extra interface we hold */\n\n    pUnknown2->Release();\n    return (pUnknown1 == pUnknown2);\n}\n"
  },
  {
    "path": "common/baseclasses/combase.h",
    "content": "//------------------------------------------------------------------------------\n// File: ComBase.h\n//\n// Desc: DirectShow base classes - defines a class hierarchy for creating\n//       COM objects.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n/*\n\na. Derive your COM object from CUnknown\n\nb. Make a static CreateInstance function that takes an LPUNKNOWN, an HRESULT *\n   and a TCHAR *. The LPUNKNOWN defines the object to delegate IUnknown calls\n   to. The HRESULT * allows error codes to be passed around constructors and\n   the TCHAR * is a descriptive name that can be printed on the debugger.\n\n   It is important that constructors only change the HRESULT * if they have\n   to set an ERROR code, if it was successful then leave it alone or you may\n   overwrite an error code from an object previously created.\n\n   When you call a constructor the descriptive name should be in static store\n   as we do not copy the string. To stop large amounts of memory being used\n   in retail builds by all these static strings use the NAME macro,\n\n   CMyFilter = new CImplFilter(NAME(\"My filter\"),pUnknown,phr);\n   if (FAILED(hr)) {\n       return hr;\n   }\n\n   In retail builds NAME(_x_) compiles to NULL, the base CBaseObject class\n   knows not to do anything with objects that don't have a name.\n\nc. Have a constructor for your object that passes the LPUNKNOWN, HRESULT * and\n   TCHAR * to the CUnknown constructor. You can set the HRESULT if you have an\n   error, or just simply pass it through to the constructor.\n\n   The object creation will fail in the class factory if the HRESULT indicates\n   an error (ie FAILED(HRESULT) == TRUE)\n\nd. Create a FactoryTemplate with your object's class id and CreateInstance\n   function.\n\nThen (for each interface) either\n\nMultiple inheritance\n\n1. Also derive it from ISomeInterface\n2. Include DECLARE_IUNKNOWN in your class definition to declare\n   implementations of QueryInterface, AddRef and Release that\n   call the outer unknown\n3. Override NonDelegatingQueryInterface to expose ISomeInterface by\n   code something like\n\n     if (riid == IID_ISomeInterface) {\n         return GetInterface((ISomeInterface *) this, ppv);\n     } else {\n         return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n     }\n\n4. Declare and implement the member functions of ISomeInterface.\n\nor: Nested interfaces\n\n1. Declare a class derived from CUnknown\n2. Include DECLARE_IUNKNOWN in your class definition\n3. Override NonDelegatingQueryInterface to expose ISomeInterface by\n   code something like\n\n     if (riid == IID_ISomeInterface) {\n         return GetInterface((ISomeInterface *) this, ppv);\n     } else {\n         return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n     }\n\n4. Implement the member functions of ISomeInterface. Use GetOwner() to\n   access the COM object class.\n\nAnd in your COM object class:\n\n5. Make the nested class a friend of the COM object class, and declare\n   an instance of the nested class as a member of the COM object class.\n\n   NOTE that because you must always pass the outer unknown and an hResult\n   to the CUnknown constructor you cannot use a default constructor, in\n   other words you will have to make the member variable a pointer to the\n   class and make a NEW call in your constructor to actually create it.\n\n6. override the NonDelegatingQueryInterface with code like this:\n\n     if (riid == IID_ISomeInterface) {\n         return m_pImplFilter->\n            NonDelegatingQueryInterface(IID_ISomeInterface, ppv);\n     } else {\n         return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n     }\n\nYou can have mixed classes which support some interfaces via multiple\ninheritance and some via nested classes\n\n*/\n\n#ifndef __COMBASE__\n#define __COMBASE__\n\n// Filter Setup data structures no defined in axextend.idl\n\ntypedef REGPINTYPES AMOVIESETUP_MEDIATYPE, *PAMOVIESETUP_MEDIATYPE, *FAR LPAMOVIESETUP_MEDIATYPE;\n\ntypedef REGFILTERPINS AMOVIESETUP_PIN, *PAMOVIESETUP_PIN, *FAR LPAMOVIESETUP_PIN;\n\ntypedef struct _AMOVIESETUP_FILTER\n{\n    const CLSID *clsID;\n    const WCHAR *strName;\n    DWORD dwMerit;\n    UINT nPins;\n    const AMOVIESETUP_PIN *lpPin;\n    const CLSID filterCategory;\n} AMOVIESETUP_FILTER, *PAMOVIESETUP_FILTER, *FAR LPAMOVIESETUP_FILTER;\n\n/* The DLLENTRY module initialises the module handle on loading */\n\nextern HINSTANCE g_hInst;\n\n/* On DLL load remember which platform we are running on */\n\nextern DWORD g_amPlatform;\nextern OSVERSIONINFO g_osInfo; // Filled in by GetVersionEx\n\n/* Version of IUnknown that is renamed to allow a class to support both\n   non delegating and delegating IUnknowns in the same COM object */\n\n#ifndef INONDELEGATINGUNKNOWN_DEFINED\nDECLARE_INTERFACE(INonDelegatingUnknown)\n{\n    STDMETHOD(NonDelegatingQueryInterface)(THIS_ REFIID, LPVOID *) PURE;\n    STDMETHOD_(ULONG, NonDelegatingAddRef)(THIS) PURE;\n    STDMETHOD_(ULONG, NonDelegatingRelease)(THIS) PURE;\n};\n#define INONDELEGATINGUNKNOWN_DEFINED\n#endif\n\ntypedef INonDelegatingUnknown *PNDUNKNOWN;\n\n/* This is the base object class that supports active object counting. As\n   part of the debug facilities we trace every time a C++ object is created\n   or destroyed. The name of the object has to be passed up through the class\n   derivation list during construction as you cannot call virtual functions\n   in the constructor. The downside of all this is that every single object\n   constructor has to take an object name parameter that describes it */\n\nclass CBaseObject\n{\n\n  private:\n    // Disable the copy constructor and assignment by default so you will get\n    //   compiler errors instead of unexpected behaviour if you pass objects\n    //   by value or assign objects.\n    CBaseObject(const CBaseObject &objectSrc);    // no implementation\n    void operator=(const CBaseObject &objectSrc); // no implementation\n\n  private:\n    static LONG m_cObjects; /* Total number of objects active */\n\n  protected:\n#ifdef DEBUG\n    DWORD m_dwCookie; /* Cookie identifying this object */\n#endif\n\n  public:\n    /* These increment and decrement the number of active objects */\n\n    CBaseObject(__in_opt LPCTSTR pName);\n#ifdef UNICODE\n    CBaseObject(__in_opt LPCSTR pName);\n#endif\n    ~CBaseObject();\n\n    /* Call this to find if there are any CUnknown derived objects active */\n\n    static LONG ObjectsActive() { return m_cObjects; };\n};\n\n/* An object that supports one or more COM interfaces will be based on\n   this class. It supports counting of total objects for DLLCanUnloadNow\n   support, and an implementation of the core non delegating IUnknown */\n\nclass AM_NOVTABLE CUnknown\n    : public INonDelegatingUnknown\n    , public CBaseObject\n{\n  private:\n    const LPUNKNOWN m_pUnknown; /* Owner of this object */\n\n  protected:              /* So we can override NonDelegatingRelease() */\n    volatile LONG m_cRef; /* Number of reference counts */\n\n  public:\n    CUnknown(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk);\n    virtual ~CUnknown(){};\n\n    // This is redundant, just use the other constructor\n    //   as we never touch the HRESULT in this anyway\n    CUnknown(__in_opt LPCTSTR Name, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr);\n#ifdef UNICODE\n    CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk);\n    CUnknown(__in_opt LPCSTR pName, __in_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr);\n#endif\n\n    /* Return the owner of this object */\n\n    LPUNKNOWN GetOwner() const { return m_pUnknown; };\n\n    /* Called from the class factory to create a new instance, it is\n       pure virtual so it must be overriden in your derived class */\n\n    /* static CUnknown *CreateInstance(LPUNKNOWN, HRESULT *) */\n\n    /* Non delegating unknown implementation */\n\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID, __deref_out void **);\n    STDMETHODIMP_(ULONG) NonDelegatingAddRef();\n    STDMETHODIMP_(ULONG) NonDelegatingRelease();\n};\n\n/* Return an interface pointer to a requesting client\n   performing a thread safe AddRef as necessary */\n\nSTDAPI GetInterface(LPUNKNOWN pUnk, __out void **ppv);\n\n/* A function that can create a new COM object */\n\ntypedef CUnknown *(CALLBACK *LPFNNewCOMObject)(__in_opt LPUNKNOWN pUnkOuter, __inout_opt HRESULT *phr);\n\n/*  A function (can be NULL) which is called from the DLL entrypoint\n    routine for each factory template:\n\n    bLoading - TRUE on DLL load, FALSE on DLL unload\n    rclsid   - the m_ClsID of the entry\n*/\ntypedef void(CALLBACK *LPFNInitRoutine)(BOOL bLoading, const CLSID *rclsid);\n\n/* Create one of these per object class in an array so that\n   the default class factory code can create new instances */\n\nclass CFactoryTemplate\n{\n\n  public:\n    const WCHAR *m_Name;\n    const CLSID *m_ClsID;\n    LPFNNewCOMObject m_lpfnNew;\n    LPFNInitRoutine m_lpfnInit;\n    const AMOVIESETUP_FILTER *m_pAMovieSetup_Filter;\n\n    BOOL IsClassID(REFCLSID rclsid) const { return (IsEqualCLSID(*m_ClsID, rclsid)); };\n\n    CUnknown *CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout_opt HRESULT *phr) const\n    {\n        CheckPointer(phr, NULL);\n        return m_lpfnNew(pUnk, phr);\n    };\n};\n\n/* You must override the (pure virtual) NonDelegatingQueryInterface to return\n   interface pointers (using GetInterface) to the interfaces your derived\n   class supports (the default implementation only supports IUnknown) */\n\n#define DECLARE_IUNKNOWN                                             \\\n    STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv) \\\n    {                                                                \\\n        return GetOwner()->QueryInterface(riid, ppv);                \\\n    };                                                               \\\n    STDMETHODIMP_(ULONG) AddRef() { return GetOwner()->AddRef(); };  \\\n    STDMETHODIMP_(ULONG) Release() { return GetOwner()->Release(); };\n\nHINSTANCE LoadOLEAut32();\n\n#endif /* __COMBASE__ */\n"
  },
  {
    "path": "common/baseclasses/cprop.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: CProp.cpp\n//\n// Desc: DirectShow base classes - implements CBasePropertyPage class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n\n// Constructor for the base property page class. As described in the header\n// file we must be initialised with dialog and title resource identifiers.\n// The class supports IPropertyPage and overrides AddRef and Release calls\n// to keep track of the reference counts. When the last count is released\n// we call SetPageSite(NULL) and SetObjects(0,NULL) to release interfaces\n// previously obtained by the property page when it had SetObjects called\n\nCBasePropertyPage::CBasePropertyPage(__in_opt LPCTSTR pName,     // Debug only name\n                                     __inout_opt LPUNKNOWN pUnk, // COM Delegator\n                                     int DialogId,               // Resource ID\n                                     int TitleId)\n    : // To get tital\n    CUnknown(pName, pUnk)\n    , m_DialogId(DialogId)\n    , m_TitleId(TitleId)\n    , m_hwnd(NULL)\n    , m_Dlg(NULL)\n    , m_pPageSite(NULL)\n    , m_bObjectSet(FALSE)\n    , m_bDirty(FALSE)\n{\n}\n\n#ifdef UNICODE\nCBasePropertyPage::CBasePropertyPage(__in_opt LPCSTR pName,      // Debug only name\n                                     __inout_opt LPUNKNOWN pUnk, // COM Delegator\n                                     int DialogId,               // Resource ID\n                                     int TitleId)\n    : // To get tital\n    CUnknown(pName, pUnk)\n    , m_DialogId(DialogId)\n    , m_TitleId(TitleId)\n    , m_hwnd(NULL)\n    , m_Dlg(NULL)\n    , m_pPageSite(NULL)\n    , m_bObjectSet(FALSE)\n    , m_bDirty(FALSE)\n{\n}\n#endif\n\n// Increment our reference count\n\nSTDMETHODIMP_(ULONG) CBasePropertyPage::NonDelegatingAddRef()\n{\n    LONG lRef = InterlockedIncrement(&m_cRef);\n    ASSERT(lRef > 0);\n    return max(ULONG(m_cRef), 1ul);\n}\n\n// Release a reference count and protect against reentrancy\n\nSTDMETHODIMP_(ULONG) CBasePropertyPage::NonDelegatingRelease()\n{\n    // If the reference count drops to zero delete ourselves\n\n    LONG lRef = InterlockedDecrement(&m_cRef);\n    if (lRef == 0)\n    {\n        m_cRef++;\n        SetPageSite(NULL);\n        SetObjects(0, NULL);\n        delete this;\n        return ULONG(0);\n    }\n    else\n    {\n        //  Don't touch m_cRef again here!\n        return max(ULONG(lRef), 1ul);\n    }\n}\n\n// Expose our IPropertyPage interface\n\nSTDMETHODIMP\nCBasePropertyPage::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_IPropertyPage)\n    {\n        return GetInterface((IPropertyPage *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n// Get the page info so that the page site can size itself\n\nSTDMETHODIMP CBasePropertyPage::GetPageInfo(__out LPPROPPAGEINFO pPageInfo)\n{\n    CheckPointer(pPageInfo, E_POINTER);\n    WCHAR wszTitle[STR_MAX_LENGTH];\n    WideStringFromResource(wszTitle, m_TitleId);\n\n    // Allocate dynamic memory for the property page title\n\n    LPOLESTR pszTitle;\n    HRESULT hr = AMGetWideString(wszTitle, &pszTitle);\n    if (FAILED(hr))\n    {\n        NOTE(\"No caption memory\");\n        return hr;\n    }\n\n    pPageInfo->cb = sizeof(PROPPAGEINFO);\n    pPageInfo->pszTitle = pszTitle;\n    pPageInfo->pszDocString = NULL;\n    pPageInfo->pszHelpFile = NULL;\n    pPageInfo->dwHelpContext = 0;\n\n    // Set defaults in case GetDialogSize fails\n    pPageInfo->size.cx = 340;\n    pPageInfo->size.cy = 150;\n\n    GetDialogSize(m_DialogId, DialogProc, 0L, &pPageInfo->size);\n    return NOERROR;\n}\n\n// Handles the messages for our property window\n\nINT_PTR CALLBACK CBasePropertyPage::DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    CBasePropertyPage *pPropertyPage;\n\n    switch (uMsg)\n    {\n\n    case WM_INITDIALOG:\n\n        _SetWindowLongPtr(hwnd, DWLP_USER, lParam);\n\n        // This pointer may be NULL when calculating size\n\n        pPropertyPage = (CBasePropertyPage *)lParam;\n        if (pPropertyPage == NULL)\n        {\n            return (LRESULT)1;\n        }\n        pPropertyPage->m_Dlg = hwnd;\n    }\n\n    // This pointer may be NULL when calculating size\n\n    pPropertyPage = _GetWindowLongPtr<CBasePropertyPage *>(hwnd, DWLP_USER);\n    if (pPropertyPage == NULL)\n    {\n        return (LRESULT)1;\n    }\n    return pPropertyPage->OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n\n// Tells us the object that should be informed of the property changes\n\nSTDMETHODIMP CBasePropertyPage::SetObjects(ULONG cObjects, __in_ecount_opt(cObjects) LPUNKNOWN *ppUnk)\n{\n    if (cObjects == 1)\n    {\n\n        if ((ppUnk == NULL) || (*ppUnk == NULL))\n        {\n            return E_POINTER;\n        }\n\n        // Set a flag to say that we have set the Object\n        m_bObjectSet = TRUE;\n        return OnConnect(*ppUnk);\n    }\n    else if (cObjects == 0)\n    {\n\n        // Set a flag to say that we have not set the Object for the page\n        m_bObjectSet = FALSE;\n        return OnDisconnect();\n    }\n\n    DbgBreak(\"No support for more than one object\");\n    return E_UNEXPECTED;\n}\n\n// Create the window we will use to edit properties\n\nSTDMETHODIMP CBasePropertyPage::Activate(HWND hwndParent, LPCRECT pRect, BOOL fModal)\n{\n    CheckPointer(pRect, E_POINTER);\n\n    // Return failure if SetObject has not been called.\n    if (m_bObjectSet == FALSE)\n    {\n        return E_UNEXPECTED;\n    }\n\n    if (m_hwnd)\n    {\n        return E_UNEXPECTED;\n    }\n\n    m_hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(m_DialogId), hwndParent, DialogProc, (LPARAM)this);\n    if (m_hwnd == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    OnActivate();\n    Move(pRect);\n    return Show(SW_SHOWNORMAL);\n}\n\n// Set the position of the property page\n\nSTDMETHODIMP CBasePropertyPage::Move(LPCRECT pRect)\n{\n    CheckPointer(pRect, E_POINTER);\n\n    if (m_hwnd == NULL)\n    {\n        return E_UNEXPECTED;\n    }\n\n    MoveWindow(m_hwnd,        // Property page handle\n               pRect->left,   // x coordinate\n               pRect->top,    // y coordinate\n               WIDTH(pRect),  // Overall window width\n               HEIGHT(pRect), // And likewise height\n               TRUE);         // Should we repaint it\n\n    return NOERROR;\n}\n\n// Display the property dialog\n\nSTDMETHODIMP CBasePropertyPage::Show(UINT nCmdShow)\n{\n    // Have we been activated yet\n\n    if (m_hwnd == NULL)\n    {\n        return E_UNEXPECTED;\n    }\n\n    // Ignore wrong show flags\n\n    if ((nCmdShow != SW_SHOW) && (nCmdShow != SW_SHOWNORMAL) && (nCmdShow != SW_HIDE))\n    {\n        return E_INVALIDARG;\n    }\n\n    ShowWindow(m_hwnd, nCmdShow);\n    InvalidateRect(m_hwnd, NULL, TRUE);\n    return NOERROR;\n}\n\n// Destroy the property page dialog\n\nSTDMETHODIMP CBasePropertyPage::Deactivate(void)\n{\n    if (m_hwnd == NULL)\n    {\n        return E_UNEXPECTED;\n    }\n\n    // Remove WS_EX_CONTROLPARENT before DestroyWindow call\n\n    DWORD dwStyle = GetWindowLong(m_hwnd, GWL_EXSTYLE);\n    dwStyle = dwStyle & (~WS_EX_CONTROLPARENT);\n\n    //  Set m_hwnd to be NULL temporarily so the message handler\n    //  for WM_STYLECHANGING doesn't add the WS_EX_CONTROLPARENT\n    //  style back in\n    HWND hwnd = m_hwnd;\n    m_hwnd = NULL;\n    SetWindowLong(hwnd, GWL_EXSTYLE, dwStyle);\n    m_hwnd = hwnd;\n\n    OnDeactivate();\n\n    // Destroy the dialog window\n\n    DestroyWindow(m_hwnd);\n    m_hwnd = NULL;\n    return NOERROR;\n}\n\n// Tells the application property page site\n\nSTDMETHODIMP CBasePropertyPage::SetPageSite(__in_opt LPPROPERTYPAGESITE pPageSite)\n{\n    if (pPageSite)\n    {\n\n        if (m_pPageSite)\n        {\n            return E_UNEXPECTED;\n        }\n\n        m_pPageSite = pPageSite;\n        m_pPageSite->AddRef();\n    }\n    else\n    {\n\n        if (m_pPageSite == NULL)\n        {\n            return E_UNEXPECTED;\n        }\n\n        m_pPageSite->Release();\n        m_pPageSite = NULL;\n    }\n    return NOERROR;\n}\n\n// Apply any changes so far made\n\nSTDMETHODIMP CBasePropertyPage::Apply()\n{\n    // In ActiveMovie 1.0 we used to check whether we had been activated or\n    // not. This is too constrictive. Apply should be allowed as long as\n    // SetObject was called to set an object. So we will no longer check to\n    // see if we have been activated (ie., m_hWnd != NULL), but instead\n    // make sure that m_bObjectSet is TRUE (ie., SetObject has been called).\n\n    if (m_bObjectSet == FALSE)\n    {\n        return E_UNEXPECTED;\n    }\n\n    // Must have had a site set\n\n    if (m_pPageSite == NULL)\n    {\n        return E_UNEXPECTED;\n    }\n\n    // Has anything changed\n\n    if (m_bDirty == FALSE)\n    {\n        return NOERROR;\n    }\n\n    // Commit derived class changes\n\n    HRESULT hr = OnApplyChanges();\n    if (SUCCEEDED(hr))\n    {\n        m_bDirty = FALSE;\n    }\n    return hr;\n}\n\n// Base class definition for message handling\n\nINT_PTR CBasePropertyPage::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    // we would like the TAB key to move around the tab stops in our property\n    // page, but for some reason OleCreatePropertyFrame clears the CONTROLPARENT\n    // style behind our back, so we need to switch it back on now behind its\n    // back.  Otherwise the tab key will be useless in every page.\n    //\n\n    CBasePropertyPage *pPropertyPage;\n    {\n        pPropertyPage = _GetWindowLongPtr<CBasePropertyPage *>(hwnd, DWLP_USER);\n\n        if (pPropertyPage->m_hwnd == NULL)\n        {\n            return 0;\n        }\n        switch (uMsg)\n        {\n        case WM_STYLECHANGING:\n            if (wParam == GWL_EXSTYLE)\n            {\n                LPSTYLESTRUCT lpss = (LPSTYLESTRUCT)lParam;\n                lpss->styleNew |= WS_EX_CONTROLPARENT;\n                return 0;\n            }\n        }\n    }\n\n    return DefWindowProc(hwnd, uMsg, wParam, lParam);\n}\n"
  },
  {
    "path": "common/baseclasses/cprop.h",
    "content": "//------------------------------------------------------------------------------\n// File: CProp.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __CPROP__\n#define __CPROP__\n\n// Base property page class. Filters typically expose custom properties by\n// implementing special control interfaces, examples are IDirectDrawVideo\n// and IQualProp on renderers. This allows property pages to be built that\n// use the given interface. Applications such as the ActiveMovie OCX query\n// filters for the property pages they support and expose them to the user\n//\n// This class provides all the framework for a property page. A property\n// page is a COM object that supports IPropertyPage. We should be created\n// with a resource ID for the dialog which we will load when required. We\n// should also be given in the constructor a resource ID for a title string\n// we will load from the DLLs STRINGTABLE. The property page titles must be\n// stored in resource files so that they can be easily internationalised\n//\n// We have a number of virtual methods (not PURE) that may be overriden in\n// derived classes to query for interfaces and so on. These functions have\n// simple implementations here that just return NOERROR. Derived classes\n// will almost definately have to override the message handler method called\n// OnReceiveMessage. We have a static dialog procedure that calls the method\n// so that derived classes don't have to fiddle around with the this pointer\n\nclass AM_NOVTABLE CBasePropertyPage\n    : public IPropertyPage\n    , public CUnknown\n{\n  protected:\n    LPPROPERTYPAGESITE m_pPageSite; // Details for our property site\n    HWND m_hwnd;                    // Window handle for the page\n    HWND m_Dlg;                     // Actual dialog window handle\n    BOOL m_bDirty;                  // Has anything been changed\n    int m_TitleId;                  // Resource identifier for title\n    int m_DialogId;                 // Dialog resource identifier\n\n    static INT_PTR CALLBACK DialogProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    BOOL m_bObjectSet; // SetObject has been called or not.\n  public:\n    CBasePropertyPage(__in_opt LPCTSTR pName,     // Debug only name\n                      __inout_opt LPUNKNOWN pUnk, // COM Delegator\n                      int DialogId,               // Resource ID\n                      int TitleId);               // To get tital\n\n#ifdef UNICODE\n    CBasePropertyPage(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN pUnk, int DialogId, int TitleId);\n#endif\n    virtual ~CBasePropertyPage(){};\n    DECLARE_IUNKNOWN\n\n    // Override these virtual methods\n\n    virtual HRESULT OnConnect(IUnknown *pUnknown) { return NOERROR; };\n    virtual HRESULT OnDisconnect() { return NOERROR; };\n    virtual HRESULT OnActivate() { return NOERROR; };\n    virtual HRESULT OnDeactivate() { return NOERROR; };\n    virtual HRESULT OnApplyChanges() { return NOERROR; };\n    virtual INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n    // These implement an IPropertyPage interface\n\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) NonDelegatingRelease();\n    STDMETHODIMP_(ULONG) NonDelegatingAddRef();\n    STDMETHODIMP SetPageSite(__in_opt LPPROPERTYPAGESITE pPageSite);\n    STDMETHODIMP Activate(HWND hwndParent, LPCRECT prect, BOOL fModal);\n    STDMETHODIMP Deactivate(void);\n    STDMETHODIMP GetPageInfo(__out LPPROPPAGEINFO pPageInfo);\n    STDMETHODIMP SetObjects(ULONG cObjects, __in_ecount_opt(cObjects) LPUNKNOWN *ppUnk);\n    STDMETHODIMP Show(UINT nCmdShow);\n    STDMETHODIMP Move(LPCRECT prect);\n    STDMETHODIMP IsPageDirty(void) { return m_bDirty ? S_OK : S_FALSE; }\n    STDMETHODIMP Apply(void);\n    STDMETHODIMP Help(LPCWSTR lpszHelpDir) { return E_NOTIMPL; }\n    STDMETHODIMP TranslateAccelerator(__inout LPMSG lpMsg) { return E_NOTIMPL; }\n};\n\n#endif // __CPROP__\n"
  },
  {
    "path": "common/baseclasses/ctlutil.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: CtlUtil.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// Base classes implementing IDispatch parsing for the basic control dual\n// interfaces. Derive from these and implement just the custom method and\n// property methods. We also implement CPosPassThru that can be used by\n// renderers and transforms to pass by IMediaPosition and IMediaSeeking\n\n#include <streams.h>\n#include <limits.h>\n#include \"seekpt.h\"\n\n// 'bool' non standard reserved word\n#pragma warning(disable : 4237)\n\n// --- CBaseDispatch implementation ----------\nCBaseDispatch::~CBaseDispatch()\n{\n    if (m_pti)\n    {\n        m_pti->Release();\n    }\n}\n\n// return 1 if we support GetTypeInfo\n\nSTDMETHODIMP\nCBaseDispatch::GetTypeInfoCount(__out UINT *pctinfo)\n{\n    CheckPointer(pctinfo, E_POINTER);\n    ValidateReadWritePtr(pctinfo, sizeof(UINT *));\n    *pctinfo = 1;\n    return S_OK;\n}\n\ntypedef HRESULT(STDAPICALLTYPE *LPLOADTYPELIB)(const OLECHAR FAR *szFile, __deref_out ITypeLib FAR *FAR *pptlib);\n\ntypedef HRESULT(STDAPICALLTYPE *LPLOADREGTYPELIB)(REFGUID rguid, WORD wVerMajor, WORD wVerMinor, LCID lcid,\n                                                  __deref_out ITypeLib FAR *FAR *pptlib);\n\n// attempt to find our type library\n\nSTDMETHODIMP\nCBaseDispatch::GetTypeInfo(REFIID riid, UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo)\n{\n    CheckPointer(pptinfo, E_POINTER);\n    ValidateReadWritePtr(pptinfo, sizeof(ITypeInfo *));\n    HRESULT hr;\n\n    *pptinfo = NULL;\n\n    // we only support one type element\n    if (0 != itinfo)\n    {\n        return TYPE_E_ELEMENTNOTFOUND;\n    }\n\n    if (NULL == pptinfo)\n    {\n        return E_POINTER;\n    }\n\n    // always look for neutral\n    if (NULL == m_pti)\n    {\n\n        LPLOADTYPELIB lpfnLoadTypeLib;\n        LPLOADREGTYPELIB lpfnLoadRegTypeLib;\n        ITypeLib *ptlib;\n        HINSTANCE hInst;\n\n        static const char szTypeLib[] = \"LoadTypeLib\";\n        static const char szRegTypeLib[] = \"LoadRegTypeLib\";\n        static const WCHAR szControl[] = L\"control.tlb\";\n\n        //\n        // Try to get the Ole32Aut.dll module handle.\n        //\n\n        hInst = LoadOLEAut32();\n        if (hInst == NULL)\n        {\n            DWORD dwError = GetLastError();\n            return AmHresultFromWin32(dwError);\n        }\n        lpfnLoadRegTypeLib = (LPLOADREGTYPELIB)GetProcAddress(hInst, szRegTypeLib);\n        if (lpfnLoadRegTypeLib == NULL)\n        {\n            DWORD dwError = GetLastError();\n            return AmHresultFromWin32(dwError);\n        }\n\n        hr = (*lpfnLoadRegTypeLib)(LIBID_QuartzTypeLib, 1, 0, // version 1.0\n                                   lcid, &ptlib);\n\n        if (FAILED(hr))\n        {\n\n            // attempt to load directly - this will fill the\n            // registry in if it finds it\n\n            lpfnLoadTypeLib = (LPLOADTYPELIB)GetProcAddress(hInst, szTypeLib);\n            if (lpfnLoadTypeLib == NULL)\n            {\n                DWORD dwError = GetLastError();\n                return AmHresultFromWin32(dwError);\n            }\n\n            hr = (*lpfnLoadTypeLib)(szControl, &ptlib);\n            if (FAILED(hr))\n            {\n                return hr;\n            }\n        }\n\n        hr = ptlib->GetTypeInfoOfGuid(riid, &m_pti);\n\n        ptlib->Release();\n\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n    }\n\n    *pptinfo = m_pti;\n    m_pti->AddRef();\n    return S_OK;\n}\n\nSTDMETHODIMP\nCBaseDispatch::GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                             __out_ecount(cNames) DISPID *rgdispid)\n{\n    // although the IDispatch riid is dead, we use this to pass from\n    // the interface implementation class to us the iid we are talking about.\n\n    ITypeInfo *pti;\n    HRESULT hr = GetTypeInfo(riid, 0, lcid, &pti);\n\n    if (SUCCEEDED(hr))\n    {\n        hr = pti->GetIDsOfNames(rgszNames, cNames, rgdispid);\n\n        pti->Release();\n    }\n    return hr;\n}\n\n// --- CMediaControl implementation ---------\n\nCMediaControl::CMediaControl(const TCHAR *name, LPUNKNOWN pUnk)\n    : CUnknown(name, pUnk)\n{\n}\n\n// expose our interfaces IMediaControl and IUnknown\n\nSTDMETHODIMP\nCMediaControl::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n    if (riid == IID_IMediaControl)\n    {\n        return GetInterface((IMediaControl *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n// return 1 if we support GetTypeInfo\n\nSTDMETHODIMP\nCMediaControl::GetTypeInfoCount(__out UINT *pctinfo)\n{\n    return m_basedisp.GetTypeInfoCount(pctinfo);\n}\n\n// attempt to find our type library\n\nSTDMETHODIMP\nCMediaControl::GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo)\n{\n    return m_basedisp.GetTypeInfo(IID_IMediaControl, itinfo, lcid, pptinfo);\n}\n\nSTDMETHODIMP\nCMediaControl::GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                             __out_ecount(cNames) DISPID *rgdispid)\n{\n    return m_basedisp.GetIDsOfNames(IID_IMediaControl, rgszNames, cNames, lcid, rgdispid);\n}\n\nSTDMETHODIMP\nCMediaControl::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                      __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr)\n{\n    // this parameter is a dead leftover from an earlier interface\n    if (IID_NULL != riid)\n    {\n        return DISP_E_UNKNOWNINTERFACE;\n    }\n\n    ITypeInfo *pti;\n    HRESULT hr = GetTypeInfo(0, lcid, &pti);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pti->Invoke((IMediaControl *)this, dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);\n\n    pti->Release();\n    return hr;\n}\n\n// --- CMediaEvent implementation ----------\n\nCMediaEvent::CMediaEvent(__in_opt LPCTSTR name, __in_opt LPUNKNOWN pUnk)\n    : CUnknown(name, pUnk)\n{\n}\n\n// expose our interfaces IMediaEvent and IUnknown\n\nSTDMETHODIMP\nCMediaEvent::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n    if (riid == IID_IMediaEvent || riid == IID_IMediaEventEx)\n    {\n        return GetInterface((IMediaEventEx *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n// return 1 if we support GetTypeInfo\n\nSTDMETHODIMP\nCMediaEvent::GetTypeInfoCount(__out UINT *pctinfo)\n{\n    return m_basedisp.GetTypeInfoCount(pctinfo);\n}\n\n// attempt to find our type library\n\nSTDMETHODIMP\nCMediaEvent::GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo)\n{\n    return m_basedisp.GetTypeInfo(IID_IMediaEvent, itinfo, lcid, pptinfo);\n}\n\nSTDMETHODIMP\nCMediaEvent::GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                           __out_ecount(cNames) DISPID *rgdispid)\n{\n    return m_basedisp.GetIDsOfNames(IID_IMediaEvent, rgszNames, cNames, lcid, rgdispid);\n}\n\nSTDMETHODIMP\nCMediaEvent::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                    __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr)\n{\n    // this parameter is a dead leftover from an earlier interface\n    if (IID_NULL != riid)\n    {\n        return DISP_E_UNKNOWNINTERFACE;\n    }\n\n    ITypeInfo *pti;\n    HRESULT hr = GetTypeInfo(0, lcid, &pti);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pti->Invoke((IMediaEvent *)this, dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);\n\n    pti->Release();\n    return hr;\n}\n\n// --- CMediaPosition implementation ----------\n\nCMediaPosition::CMediaPosition(__in_opt LPCTSTR name, __in_opt LPUNKNOWN pUnk)\n    : CUnknown(name, pUnk)\n{\n}\n\nCMediaPosition::CMediaPosition(__in_opt LPCTSTR name, __in_opt LPUNKNOWN pUnk, __inout HRESULT *phr)\n    : CUnknown(name, pUnk)\n{\n    UNREFERENCED_PARAMETER(phr);\n}\n\n// expose our interfaces IMediaPosition and IUnknown\n\nSTDMETHODIMP\nCMediaPosition::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n    if (riid == IID_IMediaPosition)\n    {\n        return GetInterface((IMediaPosition *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n// return 1 if we support GetTypeInfo\n\nSTDMETHODIMP\nCMediaPosition::GetTypeInfoCount(__out UINT *pctinfo)\n{\n    return m_basedisp.GetTypeInfoCount(pctinfo);\n}\n\n// attempt to find our type library\n\nSTDMETHODIMP\nCMediaPosition::GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo)\n{\n    return m_basedisp.GetTypeInfo(IID_IMediaPosition, itinfo, lcid, pptinfo);\n}\n\nSTDMETHODIMP\nCMediaPosition::GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                              __out_ecount(cNames) DISPID *rgdispid)\n{\n    return m_basedisp.GetIDsOfNames(IID_IMediaPosition, rgszNames, cNames, lcid, rgdispid);\n}\n\nSTDMETHODIMP\nCMediaPosition::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                       __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr)\n{\n    // this parameter is a dead leftover from an earlier interface\n    if (IID_NULL != riid)\n    {\n        return DISP_E_UNKNOWNINTERFACE;\n    }\n\n    ITypeInfo *pti;\n    HRESULT hr = GetTypeInfo(0, lcid, &pti);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pti->Invoke((IMediaPosition *)this, dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);\n\n    pti->Release();\n    return hr;\n}\n\n// --- IMediaPosition and IMediaSeeking pass through class ----------\n\nCPosPassThru::CPosPassThru(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk, __inout HRESULT *phr, IPin *pPin)\n    : CMediaPosition(pName, pUnk)\n    , m_pPin(pPin)\n{\n    if (pPin == NULL)\n    {\n        *phr = E_POINTER;\n        return;\n    }\n}\n\n// Expose our IMediaSeeking and IMediaPosition interfaces\n\nSTDMETHODIMP\nCPosPassThru::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n    *ppv = NULL;\n\n    if (riid == IID_IMediaSeeking)\n    {\n        return GetInterface(static_cast<IMediaSeeking *>(this), ppv);\n    }\n    return CMediaPosition::NonDelegatingQueryInterface(riid, ppv);\n}\n\n// Return the IMediaPosition interface from our peer\n\nHRESULT\nCPosPassThru::GetPeer(IMediaPosition **ppMP)\n{\n    *ppMP = NULL;\n\n    IPin *pConnected;\n    HRESULT hr = m_pPin->ConnectedTo(&pConnected);\n    if (FAILED(hr))\n    {\n        return E_NOTIMPL;\n    }\n    IMediaPosition *pMP;\n    hr = pConnected->QueryInterface(IID_IMediaPosition, (void **)&pMP);\n    pConnected->Release();\n    if (FAILED(hr))\n    {\n        return E_NOTIMPL;\n    }\n\n    *ppMP = pMP;\n    return S_OK;\n}\n\n// Return the IMediaSeeking interface from our peer\n\nHRESULT\nCPosPassThru::GetPeerSeeking(__deref_out IMediaSeeking **ppMS)\n{\n    *ppMS = NULL;\n\n    IPin *pConnected;\n    HRESULT hr = m_pPin->ConnectedTo(&pConnected);\n    if (FAILED(hr))\n    {\n        return E_NOTIMPL;\n    }\n    IMediaSeeking *pMS;\n    hr = pConnected->QueryInterface(IID_IMediaSeeking, (void **)&pMS);\n    pConnected->Release();\n    if (FAILED(hr))\n    {\n        return E_NOTIMPL;\n    }\n\n    *ppMS = pMS;\n    return S_OK;\n}\n\n// --- IMediaSeeking methods ----------\n\nSTDMETHODIMP\nCPosPassThru::GetCapabilities(__out DWORD *pCaps)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->GetCapabilities(pCaps);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::CheckCapabilities(__inout DWORD *pCaps)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->CheckCapabilities(pCaps);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::IsFormatSupported(const GUID *pFormat)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->IsFormatSupported(pFormat);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::QueryPreferredFormat(__out GUID *pFormat)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->QueryPreferredFormat(pFormat);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::SetTimeFormat(const GUID *pFormat)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->SetTimeFormat(pFormat);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::GetTimeFormat(__out GUID *pFormat)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->GetTimeFormat(pFormat);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::IsUsingTimeFormat(const GUID *pFormat)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->IsUsingTimeFormat(pFormat);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::ConvertTimeFormat(__out LONGLONG *pTarget, __in_opt const GUID *pTargetFormat, LONGLONG Source,\n                                __in_opt const GUID *pSourceFormat)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->ConvertTimeFormat(pTarget, pTargetFormat, Source, pSourceFormat);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::SetPositions(__inout_opt LONGLONG *pCurrent, DWORD CurrentFlags, __inout_opt LONGLONG *pStop,\n                           DWORD StopFlags)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->SetPositions(pCurrent, CurrentFlags, pStop, StopFlags);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::GetPositions(__out_opt LONGLONG *pCurrent, __out_opt LONGLONG *pStop)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->GetPositions(pCurrent, pStop);\n    pMS->Release();\n    return hr;\n}\n\nHRESULT\nCPosPassThru::GetSeekingLongLong(HRESULT (__stdcall IMediaSeeking::*pMethod)(__out LONGLONG *), LONGLONG *pll)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (SUCCEEDED(hr))\n    {\n        hr = (pMS->*pMethod)(pll);\n        pMS->Release();\n    }\n    return hr;\n}\n\n// If we don't have a current position then ask upstream\n\nSTDMETHODIMP\nCPosPassThru::GetCurrentPosition(__out LONGLONG *pCurrent)\n{\n    // Can we report the current position\n    HRESULT hr = GetMediaTime(pCurrent, NULL);\n    if (SUCCEEDED(hr))\n        hr = NOERROR;\n    else\n        hr = GetSeekingLongLong(&IMediaSeeking::GetCurrentPosition, pCurrent);\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::GetStopPosition(__out LONGLONG *pStop)\n{\n    return GetSeekingLongLong(&IMediaSeeking::GetStopPosition, pStop);\n    ;\n}\n\nSTDMETHODIMP\nCPosPassThru::GetDuration(__out LONGLONG *pDuration)\n{\n    return GetSeekingLongLong(&IMediaSeeking::GetDuration, pDuration);\n    ;\n}\n\nSTDMETHODIMP\nCPosPassThru::GetPreroll(__out LONGLONG *pllPreroll)\n{\n    return GetSeekingLongLong(&IMediaSeeking::GetPreroll, pllPreroll);\n    ;\n}\n\nSTDMETHODIMP\nCPosPassThru::GetAvailable(__out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMS->GetAvailable(pEarliest, pLatest);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::GetRate(__out double *pdRate)\n{\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMS->GetRate(pdRate);\n    pMS->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::SetRate(double dRate)\n{\n    if (0.0 == dRate)\n    {\n        return E_INVALIDARG;\n    }\n\n    IMediaSeeking *pMS;\n    HRESULT hr = GetPeerSeeking(&pMS);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMS->SetRate(dRate);\n    pMS->Release();\n    return hr;\n}\n\n// --- IMediaPosition methods ----------\n\nSTDMETHODIMP\nCPosPassThru::get_Duration(__out REFTIME *plength)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pMP->get_Duration(plength);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::get_CurrentPosition(__out REFTIME *pllTime)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->get_CurrentPosition(pllTime);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::put_CurrentPosition(REFTIME llTime)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->put_CurrentPosition(llTime);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::get_StopTime(__out REFTIME *pllTime)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->get_StopTime(pllTime);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::put_StopTime(REFTIME llTime)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->put_StopTime(llTime);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::get_PrerollTime(__out REFTIME *pllTime)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->get_PrerollTime(pllTime);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::put_PrerollTime(REFTIME llTime)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->put_PrerollTime(llTime);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::get_Rate(__out double *pdRate)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->get_Rate(pdRate);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::put_Rate(double dRate)\n{\n    if (0.0 == dRate)\n    {\n        return E_INVALIDARG;\n    }\n\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->put_Rate(dRate);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::CanSeekForward(__out LONG *pCanSeekForward)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->CanSeekForward(pCanSeekForward);\n    pMP->Release();\n    return hr;\n}\n\nSTDMETHODIMP\nCPosPassThru::CanSeekBackward(__out LONG *pCanSeekBackward)\n{\n    IMediaPosition *pMP;\n    HRESULT hr = GetPeer(&pMP);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    hr = pMP->CanSeekBackward(pCanSeekBackward);\n    pMP->Release();\n    return hr;\n}\n\n// --- Implements the CRendererPosPassThru class ----------\n\n// Media times (eg current frame, field, sample etc) are passed through the\n// filtergraph in media samples. When a renderer gets a sample with media\n// times in it, it will call one of the RegisterMediaTime methods we expose\n// (one takes an IMediaSample, the other takes the media times direct). We\n// store the media times internally and return them in GetCurrentPosition.\n\nCRendererPosPassThru::CRendererPosPassThru(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk, __inout HRESULT *phr,\n                                           IPin *pPin)\n    : CPosPassThru(pName, pUnk, phr, pPin)\n    , m_StartMedia(0)\n    , m_EndMedia(0)\n    , m_bReset(TRUE)\n{\n}\n\n// Sets the media times the object should report\n\nHRESULT\nCRendererPosPassThru::RegisterMediaTime(IMediaSample *pMediaSample)\n{\n    ASSERT(pMediaSample);\n    LONGLONG StartMedia;\n    LONGLONG EndMedia;\n\n    CAutoLock cAutoLock(&m_PositionLock);\n\n    // Get the media times from the sample\n\n    HRESULT hr = pMediaSample->GetTime(&StartMedia, &EndMedia);\n    if (FAILED(hr))\n    {\n        ASSERT(hr == VFW_E_SAMPLE_TIME_NOT_SET);\n        return hr;\n    }\n\n    m_StartMedia = StartMedia;\n    m_EndMedia = EndMedia;\n    m_bReset = FALSE;\n    return NOERROR;\n}\n\n// Sets the media times the object should report\n\nHRESULT\nCRendererPosPassThru::RegisterMediaTime(LONGLONG StartTime, LONGLONG EndTime)\n{\n    CAutoLock cAutoLock(&m_PositionLock);\n    m_StartMedia = StartTime;\n    m_EndMedia = EndTime;\n    m_bReset = FALSE;\n    return NOERROR;\n}\n\n// Return the current media times registered in the object\n\nHRESULT\nCRendererPosPassThru::GetMediaTime(__out LONGLONG *pStartTime, __out_opt LONGLONG *pEndTime)\n{\n    ASSERT(pStartTime);\n\n    CAutoLock cAutoLock(&m_PositionLock);\n    if (m_bReset == TRUE)\n    {\n        return E_FAIL;\n    }\n\n    // We don't have to return the end time\n\n    HRESULT hr = ConvertTimeFormat(pStartTime, 0, m_StartMedia, &TIME_FORMAT_MEDIA_TIME);\n    if (pEndTime && SUCCEEDED(hr))\n    {\n        hr = ConvertTimeFormat(pEndTime, 0, m_EndMedia, &TIME_FORMAT_MEDIA_TIME);\n    }\n    return hr;\n}\n\n// Resets the media times we hold\n\nHRESULT\nCRendererPosPassThru::ResetMediaTime()\n{\n    CAutoLock cAutoLock(&m_PositionLock);\n    m_StartMedia = 0;\n    m_EndMedia = 0;\n    m_bReset = TRUE;\n    return NOERROR;\n}\n\n// Intended to be called by the owing filter during EOS processing so\n// that the media times can be adjusted to the stop time.  This ensures\n// that the GetCurrentPosition will actully get to the stop position.\nHRESULT\nCRendererPosPassThru::EOS()\n{\n    HRESULT hr;\n\n    if (m_bReset == TRUE)\n        hr = E_FAIL;\n    else\n    {\n        LONGLONG llStop;\n        if\n            SUCCEEDED(hr = GetStopPosition(&llStop))\n            {\n                CAutoLock cAutoLock(&m_PositionLock);\n                m_StartMedia = m_EndMedia = llStop;\n            }\n    }\n    return hr;\n}\n\n// -- CSourceSeeking implementation ------------\n\nCSourceSeeking::CSourceSeeking(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk, __inout HRESULT *phr,\n                               __in CCritSec *pLock)\n    : CUnknown(pName, pUnk)\n    , m_pLock(pLock)\n    , m_rtStart((long)0)\n{\n    m_rtStop = _I64_MAX / 2;\n    m_rtDuration = m_rtStop;\n    m_dRateSeeking = 1.0;\n\n    m_dwSeekingCaps = AM_SEEKING_CanSeekForwards | AM_SEEKING_CanSeekBackwards | AM_SEEKING_CanSeekAbsolute |\n                      AM_SEEKING_CanGetStopPos | AM_SEEKING_CanGetDuration;\n}\n\nHRESULT CSourceSeeking::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_IMediaSeeking)\n    {\n        CheckPointer(ppv, E_POINTER);\n        return GetInterface(static_cast<IMediaSeeking *>(this), ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\nHRESULT CSourceSeeking::IsFormatSupported(const GUID *pFormat)\n{\n    CheckPointer(pFormat, E_POINTER);\n    // only seeking in time (REFERENCE_TIME units) is supported\n    return *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;\n}\n\nHRESULT CSourceSeeking::QueryPreferredFormat(__out GUID *pFormat)\n{\n    CheckPointer(pFormat, E_POINTER);\n    *pFormat = TIME_FORMAT_MEDIA_TIME;\n    return S_OK;\n}\n\nHRESULT CSourceSeeking::SetTimeFormat(const GUID *pFormat)\n{\n    CheckPointer(pFormat, E_POINTER);\n\n    // nothing to set; just check that it's TIME_FORMAT_TIME\n    return *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : E_INVALIDARG;\n}\n\nHRESULT CSourceSeeking::IsUsingTimeFormat(const GUID *pFormat)\n{\n    CheckPointer(pFormat, E_POINTER);\n    return *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;\n}\n\nHRESULT CSourceSeeking::GetTimeFormat(__out GUID *pFormat)\n{\n    CheckPointer(pFormat, E_POINTER);\n    *pFormat = TIME_FORMAT_MEDIA_TIME;\n    return S_OK;\n}\n\nHRESULT CSourceSeeking::GetDuration(__out LONGLONG *pDuration)\n{\n    CheckPointer(pDuration, E_POINTER);\n    CAutoLock lock(m_pLock);\n    *pDuration = m_rtDuration;\n    return S_OK;\n}\n\nHRESULT CSourceSeeking::GetStopPosition(__out LONGLONG *pStop)\n{\n    CheckPointer(pStop, E_POINTER);\n    CAutoLock lock(m_pLock);\n    *pStop = m_rtStop;\n    return S_OK;\n}\n\nHRESULT CSourceSeeking::GetCurrentPosition(__out LONGLONG *pCurrent)\n{\n    // GetCurrentPosition is typically supported only in renderers and\n    // not in source filters.\n    return E_NOTIMPL;\n}\n\nHRESULT CSourceSeeking::GetCapabilities(__out DWORD *pCapabilities)\n{\n    CheckPointer(pCapabilities, E_POINTER);\n    *pCapabilities = m_dwSeekingCaps;\n    return S_OK;\n}\n\nHRESULT CSourceSeeking::CheckCapabilities(__inout DWORD *pCapabilities)\n{\n    CheckPointer(pCapabilities, E_POINTER);\n\n    // make sure all requested capabilities are in our mask\n    return (~m_dwSeekingCaps & *pCapabilities) ? S_FALSE : S_OK;\n}\n\nHRESULT CSourceSeeking::ConvertTimeFormat(__out LONGLONG *pTarget, __in_opt const GUID *pTargetFormat, LONGLONG Source,\n                                          __in_opt const GUID *pSourceFormat)\n{\n    CheckPointer(pTarget, E_POINTER);\n    // format guids can be null to indicate current format\n\n    // since we only support TIME_FORMAT_MEDIA_TIME, we don't really\n    // offer any conversions.\n    if (pTargetFormat == 0 || *pTargetFormat == TIME_FORMAT_MEDIA_TIME)\n    {\n        if (pSourceFormat == 0 || *pSourceFormat == TIME_FORMAT_MEDIA_TIME)\n        {\n            *pTarget = Source;\n            return S_OK;\n        }\n    }\n\n    return E_INVALIDARG;\n}\n\nHRESULT CSourceSeeking::SetPositions(__inout_opt LONGLONG *pCurrent, DWORD CurrentFlags, __inout_opt LONGLONG *pStop,\n                                     DWORD StopFlags)\n{\n    DWORD StopPosBits = StopFlags & AM_SEEKING_PositioningBitsMask;\n    DWORD StartPosBits = CurrentFlags & AM_SEEKING_PositioningBitsMask;\n\n    if (StopFlags)\n    {\n        CheckPointer(pStop, E_POINTER);\n\n        // accept only relative, incremental, or absolute positioning\n        if (StopPosBits != StopFlags)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    if (CurrentFlags)\n    {\n        CheckPointer(pCurrent, E_POINTER);\n        if (StartPosBits != AM_SEEKING_AbsolutePositioning && StartPosBits != AM_SEEKING_RelativePositioning)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    // scope for autolock\n    {\n        CAutoLock lock(m_pLock);\n\n        // set start position\n        if (StartPosBits == AM_SEEKING_AbsolutePositioning)\n        {\n            m_rtStart = *pCurrent;\n        }\n        else if (StartPosBits == AM_SEEKING_RelativePositioning)\n        {\n            m_rtStart += *pCurrent;\n        }\n\n        // set stop position\n        if (StopPosBits == AM_SEEKING_AbsolutePositioning)\n        {\n            m_rtStop = *pStop;\n        }\n        else if (StopPosBits == AM_SEEKING_IncrementalPositioning)\n        {\n            m_rtStop = m_rtStart + *pStop;\n        }\n        else if (StopPosBits == AM_SEEKING_RelativePositioning)\n        {\n            m_rtStop = m_rtStop + *pStop;\n        }\n    }\n\n    HRESULT hr = S_OK;\n    if (SUCCEEDED(hr) && StopPosBits)\n    {\n        hr = ChangeStop();\n    }\n    if (StartPosBits)\n    {\n        hr = ChangeStart();\n    }\n\n    return hr;\n}\n\nHRESULT CSourceSeeking::GetPositions(__out_opt LONGLONG *pCurrent, __out_opt LONGLONG *pStop)\n{\n    if (pCurrent)\n    {\n        *pCurrent = m_rtStart;\n    }\n    if (pStop)\n    {\n        *pStop = m_rtStop;\n    }\n\n    return S_OK;\n    ;\n}\n\nHRESULT CSourceSeeking::GetAvailable(__out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest)\n{\n    if (pEarliest)\n    {\n        *pEarliest = 0;\n    }\n    if (pLatest)\n    {\n        CAutoLock lock(m_pLock);\n        *pLatest = m_rtDuration;\n    }\n    return S_OK;\n}\n\nHRESULT CSourceSeeking::SetRate(double dRate)\n{\n    {\n        CAutoLock lock(m_pLock);\n        m_dRateSeeking = dRate;\n    }\n    return ChangeRate();\n}\n\nHRESULT CSourceSeeking::GetRate(__out double *pdRate)\n{\n    CheckPointer(pdRate, E_POINTER);\n    CAutoLock lock(m_pLock);\n    *pdRate = m_dRateSeeking;\n    return S_OK;\n}\n\nHRESULT CSourceSeeking::GetPreroll(__out LONGLONG *pPreroll)\n{\n    CheckPointer(pPreroll, E_POINTER);\n    *pPreroll = 0;\n    return S_OK;\n}\n\n// --- CSourcePosition implementation ----------\n\nCSourcePosition::CSourcePosition(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN pUnk, __inout HRESULT *phr,\n                                 __in CCritSec *pLock)\n    : CMediaPosition(pName, pUnk)\n    , m_pLock(pLock)\n    , m_Start(CRefTime((LONGLONG)0))\n{\n    m_Stop = _I64_MAX;\n    m_Rate = 1.0;\n}\n\nSTDMETHODIMP\nCSourcePosition::get_Duration(__out REFTIME *plength)\n{\n    CheckPointer(plength, E_POINTER);\n    ValidateReadWritePtr(plength, sizeof(REFTIME));\n    CAutoLock lock(m_pLock);\n\n    *plength = m_Duration;\n    return S_OK;\n}\n\nSTDMETHODIMP\nCSourcePosition::put_CurrentPosition(REFTIME llTime)\n{\n    m_pLock->Lock();\n    m_Start = llTime;\n    m_pLock->Unlock();\n\n    return ChangeStart();\n}\n\nSTDMETHODIMP\nCSourcePosition::get_StopTime(__out REFTIME *pllTime)\n{\n    CheckPointer(pllTime, E_POINTER);\n    ValidateReadWritePtr(pllTime, sizeof(REFTIME));\n    CAutoLock lock(m_pLock);\n\n    *pllTime = m_Stop;\n    return S_OK;\n}\n\nSTDMETHODIMP\nCSourcePosition::put_StopTime(REFTIME llTime)\n{\n    m_pLock->Lock();\n    m_Stop = llTime;\n    m_pLock->Unlock();\n\n    return ChangeStop();\n}\n\nSTDMETHODIMP\nCSourcePosition::get_PrerollTime(__out REFTIME *pllTime)\n{\n    CheckPointer(pllTime, E_POINTER);\n    ValidateReadWritePtr(pllTime, sizeof(REFTIME));\n    return E_NOTIMPL;\n}\n\nSTDMETHODIMP\nCSourcePosition::put_PrerollTime(REFTIME llTime)\n{\n    return E_NOTIMPL;\n}\n\nSTDMETHODIMP\nCSourcePosition::get_Rate(__out double *pdRate)\n{\n    CheckPointer(pdRate, E_POINTER);\n    ValidateReadWritePtr(pdRate, sizeof(double));\n    CAutoLock lock(m_pLock);\n\n    *pdRate = m_Rate;\n    return S_OK;\n}\n\nSTDMETHODIMP\nCSourcePosition::put_Rate(double dRate)\n{\n    m_pLock->Lock();\n    m_Rate = dRate;\n    m_pLock->Unlock();\n\n    return ChangeRate();\n}\n\n// By default we can seek forwards\n\nSTDMETHODIMP\nCSourcePosition::CanSeekForward(__out LONG *pCanSeekForward)\n{\n    CheckPointer(pCanSeekForward, E_POINTER);\n    *pCanSeekForward = OATRUE;\n    return S_OK;\n}\n\n// By default we can seek backwards\n\nSTDMETHODIMP\nCSourcePosition::CanSeekBackward(__out LONG *pCanSeekBackward)\n{\n    CheckPointer(pCanSeekBackward, E_POINTER);\n    *pCanSeekBackward = OATRUE;\n    return S_OK;\n}\n\n// --- Implementation of CBasicAudio class ----------\n\nCBasicAudio::CBasicAudio(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN punk)\n    : CUnknown(pName, punk)\n{\n}\n\n// overriden to publicise our interfaces\n\nSTDMETHODIMP\nCBasicAudio::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n    if (riid == IID_IBasicAudio)\n    {\n        return GetInterface((IBasicAudio *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP\nCBasicAudio::GetTypeInfoCount(__out UINT *pctinfo)\n{\n    return m_basedisp.GetTypeInfoCount(pctinfo);\n}\n\nSTDMETHODIMP\nCBasicAudio::GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo)\n{\n    return m_basedisp.GetTypeInfo(IID_IBasicAudio, itinfo, lcid, pptinfo);\n}\n\nSTDMETHODIMP\nCBasicAudio::GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                           __out_ecount(cNames) DISPID *rgdispid)\n{\n    return m_basedisp.GetIDsOfNames(IID_IBasicAudio, rgszNames, cNames, lcid, rgdispid);\n}\n\nSTDMETHODIMP\nCBasicAudio::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                    __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr)\n{\n    // this parameter is a dead leftover from an earlier interface\n    if (IID_NULL != riid)\n    {\n        return DISP_E_UNKNOWNINTERFACE;\n    }\n\n    ITypeInfo *pti;\n    HRESULT hr = GetTypeInfo(0, lcid, &pti);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pti->Invoke((IBasicAudio *)this, dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);\n\n    pti->Release();\n    return hr;\n}\n\n// --- IVideoWindow implementation ----------\n\nCBaseVideoWindow::CBaseVideoWindow(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN punk)\n    : CUnknown(pName, punk)\n{\n}\n\n// overriden to publicise our interfaces\n\nSTDMETHODIMP\nCBaseVideoWindow::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n    if (riid == IID_IVideoWindow)\n    {\n        return GetInterface((IVideoWindow *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP\nCBaseVideoWindow::GetTypeInfoCount(__out UINT *pctinfo)\n{\n    return m_basedisp.GetTypeInfoCount(pctinfo);\n}\n\nSTDMETHODIMP\nCBaseVideoWindow::GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo)\n{\n    return m_basedisp.GetTypeInfo(IID_IVideoWindow, itinfo, lcid, pptinfo);\n}\n\nSTDMETHODIMP\nCBaseVideoWindow::GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                                __out_ecount(cNames) DISPID *rgdispid)\n{\n    return m_basedisp.GetIDsOfNames(IID_IVideoWindow, rgszNames, cNames, lcid, rgdispid);\n}\n\nSTDMETHODIMP\nCBaseVideoWindow::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                         __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr)\n{\n    // this parameter is a dead leftover from an earlier interface\n    if (IID_NULL != riid)\n    {\n        return DISP_E_UNKNOWNINTERFACE;\n    }\n\n    ITypeInfo *pti;\n    HRESULT hr = GetTypeInfo(0, lcid, &pti);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pti->Invoke((IVideoWindow *)this, dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);\n\n    pti->Release();\n    return hr;\n}\n\n// --- IBasicVideo implementation ----------\n\nCBaseBasicVideo::CBaseBasicVideo(__in_opt LPCTSTR pName, __in_opt LPUNKNOWN punk)\n    : CUnknown(pName, punk)\n{\n}\n\n// overriden to publicise our interfaces\n\nSTDMETHODIMP\nCBaseBasicVideo::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n    if (riid == IID_IBasicVideo || riid == IID_IBasicVideo2)\n    {\n        return GetInterface(static_cast<IBasicVideo2 *>(this), ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP\nCBaseBasicVideo::GetTypeInfoCount(__out UINT *pctinfo)\n{\n    return m_basedisp.GetTypeInfoCount(pctinfo);\n}\n\nSTDMETHODIMP\nCBaseBasicVideo::GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo)\n{\n    return m_basedisp.GetTypeInfo(IID_IBasicVideo, itinfo, lcid, pptinfo);\n}\n\nSTDMETHODIMP\nCBaseBasicVideo::GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                               __out_ecount(cNames) DISPID *rgdispid)\n{\n    return m_basedisp.GetIDsOfNames(IID_IBasicVideo, rgszNames, cNames, lcid, rgdispid);\n}\n\nSTDMETHODIMP\nCBaseBasicVideo::Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                        __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr)\n{\n    // this parameter is a dead leftover from an earlier interface\n    if (IID_NULL != riid)\n    {\n        return DISP_E_UNKNOWNINTERFACE;\n    }\n\n    ITypeInfo *pti;\n    HRESULT hr = GetTypeInfo(0, lcid, &pti);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = pti->Invoke((IBasicVideo *)this, dispidMember, wFlags, pdispparams, pvarResult, pexcepinfo, puArgErr);\n\n    pti->Release();\n    return hr;\n}\n\n// --- Implementation of Deferred Commands ----------\n\nCDispParams::CDispParams(UINT nArgs, __in_ecount(nArgs) VARIANT *pArgs, __inout_opt HRESULT *phr)\n{\n    cNamedArgs = 0;\n    rgdispidNamedArgs = NULL;\n    cArgs = nArgs;\n\n    if (cArgs)\n    {\n        rgvarg = new VARIANT[cArgs];\n        if (NULL == rgvarg)\n        {\n            cArgs = 0;\n            if (phr)\n            {\n                *phr = E_OUTOFMEMORY;\n            }\n            return;\n        }\n\n        for (UINT i = 0; i < cArgs; i++)\n        {\n\n            //  Why aren't we using VariantCopy?\n\n            VARIANT *pDest = &rgvarg[i];\n            VARIANT *pSrc = &pArgs[i];\n\n            pDest->vt = pSrc->vt;\n            switch (pDest->vt)\n            {\n\n            case VT_I4: pDest->lVal = pSrc->lVal; break;\n\n            case VT_UI1: pDest->bVal = pSrc->bVal; break;\n\n            case VT_I2: pDest->iVal = pSrc->iVal; break;\n\n            case VT_R4: pDest->fltVal = pSrc->fltVal; break;\n\n            case VT_R8: pDest->dblVal = pSrc->dblVal; break;\n\n            case VT_BOOL: pDest->boolVal = pSrc->boolVal; break;\n\n            case VT_ERROR: pDest->scode = pSrc->scode; break;\n\n            case VT_CY: pDest->cyVal = pSrc->cyVal; break;\n\n            case VT_DATE: pDest->date = pSrc->date; break;\n\n            case VT_BSTR:\n                if ((PVOID)pSrc->bstrVal == NULL)\n                {\n                    pDest->bstrVal = NULL;\n                }\n                else\n                {\n\n                    // a BSTR is a WORD followed by a UNICODE string.\n                    // the pointer points just after the WORD\n\n                    WORD len = *(WORD *)(pSrc->bstrVal - (sizeof(WORD) / sizeof(OLECHAR)));\n                    OLECHAR *pch = new OLECHAR[len + (sizeof(WORD) / sizeof(OLECHAR))];\n                    if (pch)\n                    {\n                        WORD *pui = (WORD *)pch;\n                        *pui = len;\n                        pDest->bstrVal = pch + (sizeof(WORD) / sizeof(OLECHAR));\n                        CopyMemory(pDest->bstrVal, pSrc->bstrVal, len * sizeof(OLECHAR));\n                    }\n                    else\n                    {\n                        cArgs = i;\n                        if (phr)\n                        {\n                            *phr = E_OUTOFMEMORY;\n                        }\n                    }\n                }\n                break;\n\n            case VT_UNKNOWN:\n                pDest->punkVal = pSrc->punkVal;\n                pDest->punkVal->AddRef();\n                break;\n\n            case VT_DISPATCH:\n                pDest->pdispVal = pSrc->pdispVal;\n                pDest->pdispVal->AddRef();\n                break;\n\n            default:\n                // a type we haven't got round to adding yet!\n                ASSERT(0);\n                break;\n            }\n        }\n    }\n    else\n    {\n        rgvarg = NULL;\n    }\n}\n\nCDispParams::~CDispParams()\n{\n    for (UINT i = 0; i < cArgs; i++)\n    {\n        switch (rgvarg[i].vt)\n        {\n        case VT_BSTR:\n            //  Explicitly cast BSTR to PVOID to tell code scanning tools we really mean to test the pointer\n            if ((PVOID)rgvarg[i].bstrVal != NULL)\n            {\n                OLECHAR *pch = rgvarg[i].bstrVal - (sizeof(WORD) / sizeof(OLECHAR));\n                delete pch;\n            }\n            break;\n\n        case VT_UNKNOWN: rgvarg[i].punkVal->Release(); break;\n\n        case VT_DISPATCH: rgvarg[i].pdispVal->Release(); break;\n        }\n    }\n    delete[] rgvarg;\n}\n\n// lifetime is controlled by refcounts (see defer.h)\n\nCDeferredCommand::CDeferredCommand(__inout CCmdQueue *pQ, __in_opt LPUNKNOWN pUnk, __inout HRESULT *phr,\n                                   __in LPUNKNOWN pUnkExecutor, REFTIME time, __in GUID *iid, long dispidMethod,\n                                   short wFlags, long nArgs, __in_ecount(nArgs) VARIANT *pDispParams,\n                                   __out VARIANT *pvarResult, __out short *puArgErr, BOOL bStream)\n    : CUnknown(NAME(\"DeferredCommand\"), pUnk)\n    , m_pQueue(pQ)\n    , m_pUnk(pUnkExecutor)\n    , m_iid(iid)\n    , m_dispidMethod(dispidMethod)\n    , m_wFlags(wFlags)\n    , m_DispParams(nArgs, pDispParams, phr)\n    , m_pvarResult(pvarResult)\n    , m_bStream(bStream)\n    , m_hrResult(E_ABORT)\n\n{\n    // convert REFTIME to REFERENCE_TIME\n    COARefTime convertor(time);\n    m_time = convertor;\n\n    // no check of time validity - it's ok to queue a command that's\n    // already late\n\n    // check iid is supportable on pUnk by QueryInterface for it\n    IUnknown *pInterface;\n    HRESULT hr = m_pUnk->QueryInterface(GetIID(), (void **)&pInterface);\n    if (FAILED(hr))\n    {\n        *phr = hr;\n        return;\n    }\n    pInterface->Release();\n\n    // !!! check dispidMethod and param/return types using typelib\n    ITypeInfo *pti;\n    hr = m_Dispatch.GetTypeInfo(*iid, 0, 0, &pti);\n    if (FAILED(hr))\n    {\n        *phr = hr;\n        return;\n    }\n    // !!! some sort of ITypeInfo validity check here\n    pti->Release();\n\n    // Fix up the dispid for put and get\n    if (wFlags == DISPATCH_PROPERTYPUT)\n    {\n        m_DispParams.cNamedArgs = 1;\n        m_DispId = DISPID_PROPERTYPUT;\n        m_DispParams.rgdispidNamedArgs = &m_DispId;\n    }\n\n    // all checks ok - add to queue\n    hr = pQ->Insert(this);\n    if (FAILED(hr))\n    {\n        *phr = hr;\n    }\n}\n\n// refcounts are held by caller of InvokeAt... and by list. So if\n// we get here, we can't be on the list\n\n#if 0\nCDeferredCommand::~CDeferredCommand()\n{\n    // this assert is invalid since if the queue is deleted while we are\n    // still on the queue, we will have been removed by the queue and this\n    // m_pQueue will not have been modified.\n    // ASSERT(m_pQueue == NULL);\n\n    // we don't hold a ref count on pUnk, which is the object that should\n    // execute the command.\n    // This is because there would otherwise be a circular refcount problem\n    // since pUnk probably owns the CmdQueue object that has a refcount\n    // on us.\n    // The lifetime of pUnk is guaranteed by it being part of, or lifetime\n    // controlled by, our parent object. As long as we are on the list, pUnk\n    // must be valid. Once we are off the list, we do not use pUnk.\n\n}\n#endif\n\n// overriden to publicise our interfaces\n\nSTDMETHODIMP\nCDeferredCommand::NonDelegatingQueryInterface(REFIID riid, __out void **ppv)\n{\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n    if (riid == IID_IDeferredCommand)\n    {\n        return GetInterface((IDeferredCommand *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n// remove from q. this will reduce the refcount by one (since the q\n// holds a count) but can't make us go away since he must have a\n// refcount in order to call this method.\n\nSTDMETHODIMP\nCDeferredCommand::Cancel()\n{\n    if (m_pQueue == NULL)\n    {\n        return VFW_E_ALREADY_CANCELLED;\n    }\n\n    HRESULT hr = m_pQueue->Remove(this);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    m_pQueue = NULL;\n    return S_OK;\n}\n\nSTDMETHODIMP\nCDeferredCommand::Confidence(__out LONG *pConfidence)\n{\n    return E_NOTIMPL;\n}\n\nSTDMETHODIMP\nCDeferredCommand::GetHResult(__out HRESULT *phrResult)\n{\n    CheckPointer(phrResult, E_POINTER);\n    ValidateReadWritePtr(phrResult, sizeof(HRESULT));\n\n    if (m_pQueue != NULL)\n    {\n        return E_ABORT;\n    }\n    *phrResult = m_hrResult;\n    return S_OK;\n}\n\n// set the time to be a new time (checking that it is valid) and\n// then requeue\n\nSTDMETHODIMP\nCDeferredCommand::Postpone(REFTIME newtime)\n{\n\n    // check that this time is not past\n    // convert REFTIME to REFERENCE_TIME\n    COARefTime convertor(newtime);\n\n    // check that the time has not passed\n    if (m_pQueue->CheckTime(convertor, IsStreamTime()))\n    {\n        return VFW_E_TIME_ALREADY_PASSED;\n    }\n\n    // extract from list\n    HRESULT hr = m_pQueue->Remove(this);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // change time\n    m_time = convertor;\n\n    // requeue\n    hr = m_pQueue->Insert(this);\n\n    return hr;\n}\n\nHRESULT\nCDeferredCommand::Invoke()\n{\n    // check that we are still outstanding\n    if (m_pQueue == NULL)\n    {\n        return VFW_E_ALREADY_CANCELLED;\n    }\n\n    // get the type info\n    ITypeInfo *pti;\n    HRESULT hr = m_Dispatch.GetTypeInfo(GetIID(), 0, 0, &pti);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // qi for the expected interface and then invoke it. Note that we have to\n    // treat the returned interface as IUnknown since we don't know its type.\n    IUnknown *pInterface;\n\n    hr = m_pUnk->QueryInterface(GetIID(), (void **)&pInterface);\n    if (FAILED(hr))\n    {\n        pti->Release();\n        return hr;\n    }\n\n    EXCEPINFO expinfo;\n    UINT uArgErr;\n    m_hrResult = pti->Invoke(pInterface, GetMethod(), GetFlags(), GetParams(), GetResult(), &expinfo, &uArgErr);\n\n    // release the interface we QI'd for\n    pInterface->Release();\n    pti->Release();\n\n    // remove from list whether or not successful\n    // or we loop indefinitely\n    hr = m_pQueue->Remove(this);\n    m_pQueue = NULL;\n    return hr;\n}\n\n// --- CCmdQueue methods ----------\n\nCCmdQueue::CCmdQueue(__inout_opt HRESULT *phr)\n    : m_listPresentation(NAME(\"Presentation time command list\"))\n    , m_listStream(NAME(\"Stream time command list\"))\n    , m_evDue(TRUE, phr)\n    , // manual reset\n    m_dwAdvise(0)\n    , m_pClock(NULL)\n    , m_bRunning(FALSE)\n{\n}\n\nCCmdQueue::~CCmdQueue()\n{\n    // empty all our lists\n\n    // we hold a refcount on each, so traverse and Release each\n    // entry then RemoveAll to empty the list\n    POSITION pos = m_listPresentation.GetHeadPosition();\n\n    while (pos)\n    {\n        CDeferredCommand *pCmd = m_listPresentation.GetNext(pos);\n        pCmd->Release();\n    }\n    m_listPresentation.RemoveAll();\n\n    pos = m_listStream.GetHeadPosition();\n\n    while (pos)\n    {\n        CDeferredCommand *pCmd = m_listStream.GetNext(pos);\n        pCmd->Release();\n    }\n    m_listStream.RemoveAll();\n\n    if (m_pClock)\n    {\n        if (m_dwAdvise)\n        {\n            m_pClock->Unadvise(m_dwAdvise);\n            m_dwAdvise = 0;\n        }\n        m_pClock->Release();\n    }\n}\n\n// returns a new CDeferredCommand object that will be initialised with\n// the parameters and will be added to the queue during construction.\n// returns S_OK if successfully created otherwise an error and\n// no object has been queued.\n\nHRESULT\nCCmdQueue::New(__out CDeferredCommand **ppCmd,\n               __in LPUNKNOWN pUnk, // this object will execute command\n               REFTIME time, __in GUID *iid, long dispidMethod, short wFlags, long cArgs,\n               __in_ecount(cArgs) VARIANT *pDispParams, __out VARIANT *pvarResult, __out short *puArgErr, BOOL bStream)\n{\n    CAutoLock lock(&m_Lock);\n\n    HRESULT hr = S_OK;\n    *ppCmd = NULL;\n\n    CDeferredCommand *pCmd;\n    pCmd = new CDeferredCommand(this,\n                                NULL, // not aggregated\n                                &hr,\n                                pUnk, // this guy will execute\n                                time, iid, dispidMethod, wFlags, cArgs, pDispParams, pvarResult, puArgErr, bStream);\n\n    if (pCmd == NULL)\n    {\n        hr = E_OUTOFMEMORY;\n    }\n    else\n    {\n        *ppCmd = pCmd;\n    }\n    return hr;\n}\n\nHRESULT\nCCmdQueue::Insert(__in CDeferredCommand *pCmd)\n{\n    CAutoLock lock(&m_Lock);\n\n    // addref the item\n    pCmd->AddRef();\n\n    CGenericList<CDeferredCommand> *pList;\n    if (pCmd->IsStreamTime())\n    {\n        pList = &m_listStream;\n    }\n    else\n    {\n        pList = &m_listPresentation;\n    }\n    POSITION pos = pList->GetHeadPosition();\n\n    // seek past all items that are before us\n    while (pos && (pList->GetValid(pos)->GetTime() <= pCmd->GetTime()))\n    {\n\n        pList->GetNext(pos);\n    }\n\n    // now at end of list or in front of items that come later\n    if (!pos)\n    {\n        pList->AddTail(pCmd);\n    }\n    else\n    {\n        pList->AddBefore(pos, pCmd);\n    }\n\n    SetTimeAdvise();\n    return S_OK;\n}\n\nHRESULT\nCCmdQueue::Remove(__in CDeferredCommand *pCmd)\n{\n    CAutoLock lock(&m_Lock);\n    HRESULT hr = S_OK;\n\n    CGenericList<CDeferredCommand> *pList;\n    if (pCmd->IsStreamTime())\n    {\n        pList = &m_listStream;\n    }\n    else\n    {\n        pList = &m_listPresentation;\n    }\n    POSITION pos = pList->GetHeadPosition();\n\n    // traverse the list\n    while (pos && (pList->GetValid(pos) != pCmd))\n    {\n        pList->GetNext(pos);\n    }\n\n    // did we drop off the end?\n    if (!pos)\n    {\n        hr = VFW_E_NOT_FOUND;\n    }\n    else\n    {\n\n        // found it - now take off list\n        pList->Remove(pos);\n\n        // Insert did an AddRef, so release it\n        pCmd->Release();\n\n        // check that timer request is still for earliest time\n        SetTimeAdvise();\n    }\n    return hr;\n}\n\n// set the clock used for timing\n\nHRESULT\nCCmdQueue::SetSyncSource(__in_opt IReferenceClock *pClock)\n{\n    CAutoLock lock(&m_Lock);\n\n    // addref the new clock first in case they are the same\n    if (pClock)\n    {\n        pClock->AddRef();\n    }\n\n    // kill any advise on the old clock\n    if (m_pClock)\n    {\n        if (m_dwAdvise)\n        {\n            m_pClock->Unadvise(m_dwAdvise);\n            m_dwAdvise = 0;\n        }\n        m_pClock->Release();\n    }\n    m_pClock = pClock;\n\n    // set up a new advise\n    SetTimeAdvise();\n    return S_OK;\n}\n\n// set up a timer event with the reference clock\n\nvoid CCmdQueue::SetTimeAdvise(void)\n{\n    // make sure we have a clock to use\n    if (!m_pClock)\n    {\n        return;\n    }\n\n    // reset the event whenever we are requesting a new signal\n    m_evDue.Reset();\n\n    // time 0 is earliest\n    CRefTime current;\n\n    // find the earliest presentation time\n    POSITION pos = m_listPresentation.GetHeadPosition();\n    if (pos != NULL)\n    {\n        current = m_listPresentation.GetValid(pos)->GetTime();\n    }\n\n    // if we're running, check the stream times too\n    if (m_bRunning)\n    {\n\n        CRefTime t;\n        pos = m_listStream.GetHeadPosition();\n        if (NULL != pos)\n        {\n            t = m_listStream.GetValid(pos)->GetTime();\n\n            // add on stream time offset to get presentation time\n            t += m_StreamTimeOffset;\n\n            // is this earlier?\n            if ((current == TimeZero) || (t < current))\n            {\n                current = t;\n            }\n        }\n    }\n\n    // need to change?\n    if ((current > TimeZero) && (current != m_tCurrentAdvise))\n    {\n        if (m_dwAdvise)\n        {\n            m_pClock->Unadvise(m_dwAdvise);\n            // reset the event whenever we are requesting a new signal\n            m_evDue.Reset();\n        }\n\n        // ask for time advice - the first two params are either\n        // stream time offset and stream time or\n        // presentation time and 0. we always use the latter\n        HRESULT hr = m_pClock->AdviseTime((REFERENCE_TIME)current, TimeZero, (HEVENT)HANDLE(m_evDue), &m_dwAdvise);\n\n        ASSERT(SUCCEEDED(hr));\n        m_tCurrentAdvise = current;\n    }\n}\n\n// switch to run mode. Streamtime to Presentation time mapping known.\n\nHRESULT\nCCmdQueue::Run(REFERENCE_TIME tStreamTimeOffset)\n{\n    CAutoLock lock(&m_Lock);\n\n    m_StreamTimeOffset = tStreamTimeOffset;\n    m_bRunning = TRUE;\n\n    // ensure advise is accurate\n    SetTimeAdvise();\n    return S_OK;\n}\n\n// switch to Stopped or Paused mode. Time mapping not known.\n\nHRESULT\nCCmdQueue::EndRun()\n{\n    CAutoLock lock(&m_Lock);\n\n    m_bRunning = FALSE;\n\n    // check timer setting - stream times\n    SetTimeAdvise();\n    return S_OK;\n}\n\n// return a pointer to the next due command. Blocks for msTimeout\n// milliseconds until there is a due command.\n// Stream-time commands will only become due between Run and Endrun calls.\n// The command remains queued until invoked or cancelled.\n// Returns E_ABORT if timeout occurs, otherwise S_OK (or other error).\n//\n// returns an AddRef'd object\n\nHRESULT\nCCmdQueue::GetDueCommand(__out CDeferredCommand **ppCmd, long msTimeout)\n{\n    // loop until we timeout or find a due command\n    for (;;)\n    {\n\n        {\n            CAutoLock lock(&m_Lock);\n\n            // find the earliest command\n            CDeferredCommand *pCmd = NULL;\n\n            // check the presentation time and the\n            // stream time list to find the earliest\n\n            POSITION pos = m_listPresentation.GetHeadPosition();\n\n            if (NULL != pos)\n            {\n                pCmd = m_listPresentation.GetValid(pos);\n            }\n\n            if (m_bRunning)\n            {\n                pos = m_listStream.GetHeadPosition();\n                if (NULL != pos)\n                {\n                    CDeferredCommand *pStrm = m_listStream.GetValid(pos);\n\n                    CRefTime t = pStrm->GetTime() + m_StreamTimeOffset;\n                    if (!pCmd || (t < pCmd->GetTime()))\n                    {\n                        pCmd = pStrm;\n                    }\n                }\n            }\n\n            //\tif we have found one, is it due?\n            if (pCmd)\n            {\n                if (CheckTime(pCmd->GetTime(), pCmd->IsStreamTime()))\n                {\n\n                    // yes it's due - addref it\n                    pCmd->AddRef();\n                    *ppCmd = pCmd;\n                    return S_OK;\n                }\n            }\n        }\n\n        // block until the advise is signalled\n        if (WaitForSingleObject(m_evDue, msTimeout) != WAIT_OBJECT_0)\n        {\n            return E_ABORT;\n        }\n    }\n}\n\n// return a pointer to a command that will be due for a given time.\n// Pass in a stream time here. The stream time offset will be passed\n// in via the Run method.\n// Commands remain queued until invoked or cancelled.\n// This method will not block. It will report E_ABORT if there are no\n// commands due yet.\n//\n// returns an AddRef'd object\n\nHRESULT\nCCmdQueue::GetCommandDueFor(REFERENCE_TIME rtStream, __out CDeferredCommand **ppCmd)\n{\n    CAutoLock lock(&m_Lock);\n\n    CRefTime tStream(rtStream);\n\n    // find the earliest stream and presentation time commands\n    CDeferredCommand *pStream = NULL;\n    POSITION pos = m_listStream.GetHeadPosition();\n    if (NULL != pos)\n    {\n        pStream = m_listStream.GetValid(pos);\n    }\n    CDeferredCommand *pPresent = NULL;\n    pos = m_listPresentation.GetHeadPosition();\n    if (NULL != pos)\n    {\n        pPresent = m_listPresentation.GetValid(pos);\n    }\n\n    // is there a presentation time that has passed already\n    if (pPresent && CheckTime(pPresent->GetTime(), FALSE))\n    {\n        pPresent->AddRef();\n        *ppCmd = pPresent;\n        return S_OK;\n    }\n\n    // is there a stream time command due before this stream time\n    if (pStream && (pStream->GetTime() <= tStream))\n    {\n        pStream->AddRef();\n        *ppCmd = pStream;\n        return S_OK;\n    }\n\n    // if we are running, we can map presentation times to\n    // stream time. In this case, is there a presentation time command\n    // that will be due before this stream time is presented?\n    if (m_bRunning && pPresent)\n    {\n\n        // this stream time will appear at...\n        tStream += m_StreamTimeOffset;\n\n        // due before that?\n        if (pPresent->GetTime() <= tStream)\n        {\n            *ppCmd = pPresent;\n            return S_OK;\n        }\n    }\n\n    // no commands due yet\n    return VFW_E_NOT_FOUND;\n}\n"
  },
  {
    "path": "common/baseclasses/ctlutil.h",
    "content": "//------------------------------------------------------------------------------\n// File: CtlUtil.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// Base classes implementing IDispatch parsing for the basic control dual\n// interfaces. Derive from these and implement just the custom method and\n// property methods. We also implement CPosPassThru that can be used by\n// renderers and transforms to pass by IMediaPosition and IMediaSeeking\n\n#ifndef __CTLUTIL__\n#define __CTLUTIL__\n\n// OLE Automation has different ideas of TRUE and FALSE\n\n#define OATRUE (-1)\n#define OAFALSE (0)\n\n// It's possible that we could replace this class with CreateStdDispatch\n\nclass CBaseDispatch\n{\n    ITypeInfo *m_pti;\n\n  public:\n    CBaseDispatch()\n        : m_pti(NULL)\n    {\n    }\n    ~CBaseDispatch();\n\n    /* IDispatch methods */\n    STDMETHODIMP GetTypeInfoCount(__out UINT *pctinfo);\n\n    STDMETHODIMP GetTypeInfo(REFIID riid, UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo);\n\n    STDMETHODIMP GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                               __out_ecount(cNames) DISPID *rgdispid);\n};\n\nclass AM_NOVTABLE CMediaControl\n    : public IMediaControl\n    , public CUnknown\n{\n    CBaseDispatch m_basedisp;\n\n  public:\n    CMediaControl(const TCHAR *, LPUNKNOWN);\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    /* IDispatch methods */\n    STDMETHODIMP GetTypeInfoCount(__out UINT *pctinfo);\n\n    STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo);\n\n    STDMETHODIMP GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                               __out_ecount(cNames) DISPID *rgdispid);\n\n    STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                        __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr);\n};\n\nclass AM_NOVTABLE CMediaEvent\n    : public IMediaEventEx\n    , public CUnknown\n{\n    CBaseDispatch m_basedisp;\n\n  public:\n    CMediaEvent(__in_opt LPCTSTR, __in_opt LPUNKNOWN);\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    /* IDispatch methods */\n    STDMETHODIMP GetTypeInfoCount(__out UINT *pctinfo);\n\n    STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo);\n\n    STDMETHODIMP GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                               __out_ecount(cNames) DISPID *rgdispid);\n\n    STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                        __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr);\n};\n\nclass AM_NOVTABLE CMediaPosition\n    : public IMediaPosition\n    , public CUnknown\n{\n    CBaseDispatch m_basedisp;\n\n  public:\n    CMediaPosition(__in_opt LPCTSTR, __in_opt LPUNKNOWN);\n    CMediaPosition(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT *phr);\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    /* IDispatch methods */\n    STDMETHODIMP GetTypeInfoCount(__out UINT *pctinfo);\n\n    STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo);\n\n    STDMETHODIMP GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                               __out_ecount(cNames) DISPID *rgdispid);\n\n    STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                        __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr);\n};\n\n// OA-compatibility means that we must use double as the RefTime value,\n// and REFERENCE_TIME (essentially a LONGLONG) within filters.\n// this class converts between the two\n\nclass COARefTime : public CRefTime\n{\n  public:\n    COARefTime(){};\n\n    COARefTime(CRefTime t)\n        : CRefTime(t){};\n\n    COARefTime(REFERENCE_TIME t)\n        : CRefTime(t){};\n\n    COARefTime(double d) { m_time = (LONGLONG)(d * 10000000); };\n\n    operator double() { return double(m_time) / 10000000; };\n\n    operator REFERENCE_TIME() { return m_time; };\n\n    COARefTime &operator=(const double &rd)\n    {\n        m_time = (LONGLONG)(rd * 10000000);\n        return *this;\n    }\n\n    COARefTime &operator=(const REFERENCE_TIME &rt)\n    {\n        m_time = rt;\n        return *this;\n    }\n\n    inline BOOL operator==(const COARefTime &rt) { return m_time == rt.m_time; };\n\n    inline BOOL operator!=(const COARefTime &rt) { return m_time != rt.m_time; };\n\n    inline BOOL operator<(const COARefTime &rt) { return m_time < rt.m_time; };\n\n    inline BOOL operator>(const COARefTime &rt) { return m_time > rt.m_time; };\n\n    inline BOOL operator>=(const COARefTime &rt) { return m_time >= rt.m_time; };\n\n    inline BOOL operator<=(const COARefTime &rt) { return m_time <= rt.m_time; };\n\n    inline COARefTime operator+(const COARefTime &rt) { return COARefTime(m_time + rt.m_time); };\n\n    inline COARefTime operator-(const COARefTime &rt) { return COARefTime(m_time - rt.m_time); };\n\n    inline COARefTime operator*(LONG l) { return COARefTime(m_time * l); };\n\n    inline COARefTime operator/(LONG l) { return COARefTime(m_time / l); };\n\n  private:\n    //  Prevent bugs from constructing from LONG (which gets\n    //  converted to double and then multiplied by 10000000\n    COARefTime(LONG);\n    LONG operator=(LONG);\n};\n\n// A utility class that handles IMediaPosition and IMediaSeeking on behalf\n// of single-input pin renderers, or transform filters.\n//\n// Renderers will expose this from the filter; transform filters will\n// expose it from the output pin and not the renderer.\n//\n// Create one of these, giving it your IPin* for your input pin, and delegate\n// all IMediaPosition methods to it. It will query the input pin for\n// IMediaPosition and respond appropriately.\n//\n// Call ForceRefresh if the pin connection changes.\n//\n// This class no longer caches the upstream IMediaPosition or IMediaSeeking\n// it acquires it on each method call. This means ForceRefresh is not needed.\n// The method is kept for source compatibility and to minimise the changes\n// if we need to put it back later for performance reasons.\n\nclass CPosPassThru\n    : public IMediaSeeking\n    , public CMediaPosition\n{\n    IPin *m_pPin;\n\n    HRESULT GetPeer(__deref_out IMediaPosition **ppMP);\n    HRESULT GetPeerSeeking(__deref_out IMediaSeeking **ppMS);\n\n  public:\n    CPosPassThru(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT *, IPin *);\n    DECLARE_IUNKNOWN\n\n    HRESULT ForceRefresh() { return S_OK; };\n\n    // override to return an accurate current position\n    virtual HRESULT GetMediaTime(__out LONGLONG *pStartTime, __out_opt LONGLONG *pEndTime) { return E_FAIL; }\n\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    // IMediaSeeking methods\n    STDMETHODIMP GetCapabilities(__out DWORD *pCapabilities);\n    STDMETHODIMP CheckCapabilities(__inout DWORD *pCapabilities);\n    STDMETHODIMP SetTimeFormat(const GUID *pFormat);\n    STDMETHODIMP GetTimeFormat(__out GUID *pFormat);\n    STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);\n    STDMETHODIMP IsFormatSupported(const GUID *pFormat);\n    STDMETHODIMP QueryPreferredFormat(__out GUID *pFormat);\n    STDMETHODIMP ConvertTimeFormat(__out LONGLONG *pTarget, __in_opt const GUID *pTargetFormat, LONGLONG Source,\n                                   __in_opt const GUID *pSourceFormat);\n    STDMETHODIMP SetPositions(__inout_opt LONGLONG *pCurrent, DWORD CurrentFlags, __inout_opt LONGLONG *pStop,\n                              DWORD StopFlags);\n\n    STDMETHODIMP GetPositions(__out_opt LONGLONG *pCurrent, __out_opt LONGLONG *pStop);\n    STDMETHODIMP GetCurrentPosition(__out LONGLONG *pCurrent);\n    STDMETHODIMP GetStopPosition(__out LONGLONG *pStop);\n    STDMETHODIMP SetRate(double dRate);\n    STDMETHODIMP GetRate(__out double *pdRate);\n    STDMETHODIMP GetDuration(__out LONGLONG *pDuration);\n    STDMETHODIMP GetAvailable(__out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest);\n    STDMETHODIMP GetPreroll(__out LONGLONG *pllPreroll);\n\n    // IMediaPosition properties\n    STDMETHODIMP get_Duration(__out REFTIME *plength);\n    STDMETHODIMP put_CurrentPosition(REFTIME llTime);\n    STDMETHODIMP get_StopTime(__out REFTIME *pllTime);\n    STDMETHODIMP put_StopTime(REFTIME llTime);\n    STDMETHODIMP get_PrerollTime(__out REFTIME *pllTime);\n    STDMETHODIMP put_PrerollTime(REFTIME llTime);\n    STDMETHODIMP get_Rate(__out double *pdRate);\n    STDMETHODIMP put_Rate(double dRate);\n    STDMETHODIMP get_CurrentPosition(__out REFTIME *pllTime);\n    STDMETHODIMP CanSeekForward(__out LONG *pCanSeekForward);\n    STDMETHODIMP CanSeekBackward(__out LONG *pCanSeekBackward);\n\n  private:\n    HRESULT GetSeekingLongLong(HRESULT (__stdcall IMediaSeeking::*pMethod)(LONGLONG *), __out LONGLONG *pll);\n};\n\n// Adds the ability to return a current position\n\nclass CRendererPosPassThru : public CPosPassThru\n{\n    CCritSec m_PositionLock; // Locks access to our position\n    LONGLONG m_StartMedia;   // Start media time last seen\n    LONGLONG m_EndMedia;     // And likewise the end media\n    BOOL m_bReset;           // Have media times been set\n\n  public:\n    // Used to help with passing media times through graph\n\n    CRendererPosPassThru(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT *, IPin *);\n    HRESULT RegisterMediaTime(IMediaSample *pMediaSample);\n    HRESULT RegisterMediaTime(LONGLONG StartTime, LONGLONG EndTime);\n    HRESULT GetMediaTime(__out LONGLONG *pStartTime, __out_opt LONGLONG *pEndTime);\n    HRESULT ResetMediaTime();\n    HRESULT EOS();\n};\n\nSTDAPI CreatePosPassThru(__in_opt LPUNKNOWN pAgg, BOOL bRenderer, IPin *pPin, __deref_out IUnknown **ppPassThru);\n\n// A class that handles the IDispatch part of IBasicAudio and leaves the\n// properties and methods themselves pure virtual.\n\nclass AM_NOVTABLE CBasicAudio\n    : public IBasicAudio\n    , public CUnknown\n{\n    CBaseDispatch m_basedisp;\n\n  public:\n    CBasicAudio(__in_opt LPCTSTR, __in_opt LPUNKNOWN);\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    /* IDispatch methods */\n    STDMETHODIMP GetTypeInfoCount(__out UINT *pctinfo);\n\n    STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo);\n\n    STDMETHODIMP GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                               __out_ecount(cNames) DISPID *rgdispid);\n\n    STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                        __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr);\n};\n\n// A class that handles the IDispatch part of IBasicVideo and leaves the\n// properties and methods themselves pure virtual.\n\nclass AM_NOVTABLE CBaseBasicVideo\n    : public IBasicVideo2\n    , public CUnknown\n{\n    CBaseDispatch m_basedisp;\n\n  public:\n    CBaseBasicVideo(__in_opt LPCTSTR, __in_opt LPUNKNOWN);\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    /* IDispatch methods */\n    STDMETHODIMP GetTypeInfoCount(__out UINT *pctinfo);\n\n    STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo);\n\n    STDMETHODIMP GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                               __out_ecount(cNames) DISPID *rgdispid);\n\n    STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                        __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr);\n\n    STDMETHODIMP GetPreferredAspectRatio(__out long *plAspectX, __out long *plAspectY) { return E_NOTIMPL; }\n};\n\n// A class that handles the IDispatch part of IVideoWindow and leaves the\n// properties and methods themselves pure virtual.\n\nclass AM_NOVTABLE CBaseVideoWindow\n    : public IVideoWindow\n    , public CUnknown\n{\n    CBaseDispatch m_basedisp;\n\n  public:\n    CBaseVideoWindow(__in_opt LPCTSTR, __in_opt LPUNKNOWN);\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    /* IDispatch methods */\n    STDMETHODIMP GetTypeInfoCount(__out UINT *pctinfo);\n\n    STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, __deref_out ITypeInfo **pptinfo);\n\n    STDMETHODIMP GetIDsOfNames(REFIID riid, __in_ecount(cNames) LPOLESTR *rgszNames, UINT cNames, LCID lcid,\n                               __out_ecount(cNames) DISPID *rgdispid);\n\n    STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, __in DISPPARAMS *pdispparams,\n                        __out_opt VARIANT *pvarResult, __out_opt EXCEPINFO *pexcepinfo, __out_opt UINT *puArgErr);\n};\n\n// abstract class to help source filters with their implementation\n// of IMediaPosition. Derive from this and set the duration (and stop\n// position). Also override NotifyChange to do something when the properties\n// change.\n\nclass AM_NOVTABLE CSourcePosition : public CMediaPosition\n{\n\n  public:\n    CSourcePosition(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT *, __in CCritSec *);\n\n    // IMediaPosition methods\n    STDMETHODIMP get_Duration(__out REFTIME *plength);\n    STDMETHODIMP put_CurrentPosition(REFTIME llTime);\n    STDMETHODIMP get_StopTime(__out REFTIME *pllTime);\n    STDMETHODIMP put_StopTime(REFTIME llTime);\n    STDMETHODIMP get_PrerollTime(__out REFTIME *pllTime);\n    STDMETHODIMP put_PrerollTime(REFTIME llTime);\n    STDMETHODIMP get_Rate(__out double *pdRate);\n    STDMETHODIMP put_Rate(double dRate);\n    STDMETHODIMP CanSeekForward(__out LONG *pCanSeekForward);\n    STDMETHODIMP CanSeekBackward(__out LONG *pCanSeekBackward);\n\n    // override if you can return the data you are actually working on\n    STDMETHODIMP get_CurrentPosition(__out REFTIME *pllTime) { return E_NOTIMPL; };\n\n  protected:\n    // we call this to notify changes. Override to handle them\n    virtual HRESULT ChangeStart() PURE;\n    virtual HRESULT ChangeStop() PURE;\n    virtual HRESULT ChangeRate() PURE;\n\n    COARefTime m_Duration;\n    COARefTime m_Start;\n    COARefTime m_Stop;\n    double m_Rate;\n\n    CCritSec *m_pLock;\n};\n\nclass AM_NOVTABLE CSourceSeeking\n    : public IMediaSeeking\n    , public CUnknown\n{\n\n  public:\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    // IMediaSeeking methods\n\n    STDMETHODIMP IsFormatSupported(const GUID *pFormat);\n    STDMETHODIMP QueryPreferredFormat(__out GUID *pFormat);\n    STDMETHODIMP SetTimeFormat(const GUID *pFormat);\n    STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);\n    STDMETHODIMP GetTimeFormat(__out GUID *pFormat);\n    STDMETHODIMP GetDuration(__out LONGLONG *pDuration);\n    STDMETHODIMP GetStopPosition(__out LONGLONG *pStop);\n    STDMETHODIMP GetCurrentPosition(__out LONGLONG *pCurrent);\n    STDMETHODIMP GetCapabilities(__out DWORD *pCapabilities);\n    STDMETHODIMP CheckCapabilities(__inout DWORD *pCapabilities);\n    STDMETHODIMP ConvertTimeFormat(__out LONGLONG *pTarget, __in_opt const GUID *pTargetFormat, LONGLONG Source,\n                                   __in_opt const GUID *pSourceFormat);\n\n    STDMETHODIMP SetPositions(__inout_opt LONGLONG *pCurrent, DWORD CurrentFlags, __inout_opt LONGLONG *pStop,\n                              DWORD StopFlags);\n\n    STDMETHODIMP GetPositions(__out_opt LONGLONG *pCurrent, __out_opt LONGLONG *pStop);\n\n    STDMETHODIMP GetAvailable(__out_opt LONGLONG *pEarliest, __out_opt LONGLONG *pLatest);\n    STDMETHODIMP SetRate(double dRate);\n    STDMETHODIMP GetRate(__out double *pdRate);\n    STDMETHODIMP GetPreroll(__out LONGLONG *pPreroll);\n\n  protected:\n    // ctor\n    CSourceSeeking(__in_opt LPCTSTR, __in_opt LPUNKNOWN, __inout HRESULT *, __in CCritSec *);\n\n    // we call this to notify changes. Override to handle them\n    virtual HRESULT ChangeStart() PURE;\n    virtual HRESULT ChangeStop() PURE;\n    virtual HRESULT ChangeRate() PURE;\n\n    CRefTime m_rtDuration; // length of stream\n    CRefTime m_rtStart;    // source will start here\n    CRefTime m_rtStop;     // source will stop here\n    double m_dRateSeeking;\n\n    // seeking capabilities\n    DWORD m_dwSeekingCaps;\n\n    CCritSec *m_pLock;\n};\n\n// Base classes supporting Deferred commands.\n\n// Deferred commands are queued by calls to methods on the IQueueCommand\n// interface, exposed by the filtergraph and by some filters. A successful\n// call to one of these methods will return an IDeferredCommand interface\n// representing the queued command.\n//\n// A CDeferredCommand object represents a single deferred command, and exposes\n// the IDeferredCommand interface as well as other methods permitting time\n// checks and actual execution. It contains a reference to the CCommandQueue\n// object on which it is queued.\n//\n// CCommandQueue is a base class providing a queue of CDeferredCommand\n// objects, and methods to add, remove, check status and invoke the queued\n// commands. A CCommandQueue object would be part of an object that\n// implemented IQueueCommand.\n\nclass CCmdQueue;\n\n// take a copy of the params and store them. Release any allocated\n// memory in destructor\n\nclass CDispParams : public DISPPARAMS\n{\n  public:\n    CDispParams(UINT nArgs, __in_ecount(nArgs) VARIANT *pArgs, __inout_opt HRESULT *phr = NULL);\n    ~CDispParams();\n};\n\n// CDeferredCommand lifetime is controlled by refcounts. Caller of\n// InvokeAt.. gets a refcounted interface pointer, and the CCmdQueue\n// object also holds a refcount on us. Calling Cancel or Invoke takes\n// us off the CCmdQueue and thus reduces the refcount by 1. Once taken\n// off the queue we cannot be put back on the queue.\n\nclass CDeferredCommand\n    : public CUnknown\n    , public IDeferredCommand\n{\n  public:\n    CDeferredCommand(__inout CCmdQueue *pQ,\n                     __in_opt LPUNKNOWN pUnk, // aggregation outer unk\n                     __inout HRESULT *phr,\n                     __in LPUNKNOWN pUnkExecutor, // object that will execute this cmd\n                     REFTIME time, __in GUID *iid, long dispidMethod, short wFlags, long cArgs,\n                     __in_ecount(cArgs) VARIANT *pDispParams, __out VARIANT *pvarResult, __out short *puArgErr,\n                     BOOL bStream);\n\n    DECLARE_IUNKNOWN\n\n    // override this to publicise our interfaces\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __out void **ppv);\n\n    // IDeferredCommand methods\n    STDMETHODIMP Cancel();\n    STDMETHODIMP Confidence(__out LONG *pConfidence);\n    STDMETHODIMP Postpone(REFTIME newtime);\n    STDMETHODIMP GetHResult(__out HRESULT *phrResult);\n\n    // other public methods\n\n    HRESULT Invoke();\n\n    // access methods\n\n    // returns TRUE if streamtime, FALSE if presentation time\n    BOOL IsStreamTime() { return m_bStream; };\n\n    CRefTime GetTime() { return m_time; };\n\n    REFIID GetIID() { return *m_iid; };\n\n    long GetMethod() { return m_dispidMethod; };\n\n    short GetFlags() { return m_wFlags; };\n\n    DISPPARAMS *GetParams() { return &m_DispParams; };\n\n    VARIANT *GetResult() { return m_pvarResult; };\n\n  protected:\n    CCmdQueue *m_pQueue;\n\n    // pUnk for the interface that we will execute the command on\n    LPUNKNOWN m_pUnk;\n\n    // stored command data\n    REFERENCE_TIME m_time;\n    GUID *m_iid;\n    long m_dispidMethod;\n    short m_wFlags;\n    VARIANT *m_pvarResult;\n    BOOL m_bStream;\n    CDispParams m_DispParams;\n    DISPID m_DispId; //  For get and put\n\n    // we use this for ITypeInfo access\n    CBaseDispatch m_Dispatch;\n\n    // save retval here\n    HRESULT m_hrResult;\n};\n\n// a list of CDeferredCommand objects. this is a base class providing\n// the basics of access to the list. If you want to use CDeferredCommand\n// objects then your queue needs to be derived from this class.\n\nclass AM_NOVTABLE CCmdQueue\n{\n  public:\n    CCmdQueue(__inout_opt HRESULT *phr = NULL);\n    virtual ~CCmdQueue();\n\n    // returns a new CDeferredCommand object that will be initialised with\n    // the parameters and will be added to the queue during construction.\n    // returns S_OK if successfully created otherwise an error and\n    // no object has been queued.\n    virtual HRESULT New(__out CDeferredCommand **ppCmd, __in LPUNKNOWN pUnk, REFTIME time, __in GUID *iid,\n                        long dispidMethod, short wFlags, long cArgs, __in_ecount(cArgs) VARIANT *pDispParams,\n                        __out VARIANT *pvarResult, __out short *puArgErr, BOOL bStream);\n\n    // called by the CDeferredCommand object to add and remove itself\n    // from the queue\n    virtual HRESULT Insert(__in CDeferredCommand *pCmd);\n    virtual HRESULT Remove(__in CDeferredCommand *pCmd);\n\n    // Command-Due Checking\n    //\n    // There are two schemes of synchronisation: coarse and accurate. In\n    // coarse mode, you wait till the time arrives and then execute the cmd.\n    // In accurate mode, you wait until you are processing the sample that\n    // will appear at the time, and then execute the command. It's up to the\n    // filter which one it will implement. The filtergraph will always\n    // implement coarse mode for commands queued at the filtergraph.\n    //\n    // If you want coarse sync, you probably want to wait until there is a\n    // command due, and then execute it. You can do this by calling\n    // GetDueCommand. If you have several things to wait for, get the\n    // event handle from GetDueHandle() and when this is signalled then call\n    // GetDueCommand. Stream time will only advance between calls to Run and\n    // EndRun. Note that to avoid an extra thread there is no guarantee that\n    // if the handle is set there will be a command ready. Each time the\n    // event is signalled, call GetDueCommand (probably with a 0 timeout);\n    // This may return E_ABORT.\n    //\n    // If you want accurate sync, you must call GetCommandDueFor, passing\n    // as a parameter the stream time of the samples you are about to process.\n    // This will return:\n    //   -- a stream-time command due at or before that stream time\n    //   -- a presentation-time command due at or before the\n    //      time that stream time will be presented (only between Run\n    //      and EndRun calls, since outside of this, the mapping from\n    //      stream time to presentation time is not known.\n    //   -- any presentation-time command due now.\n    // This means that if you want accurate synchronisation on samples that\n    // might be processed during Paused mode, you need to use\n    // stream-time commands.\n    //\n    // In all cases, commands remain queued until Invoked or Cancelled. The\n    // setting and resetting of the event handle is managed entirely by this\n    // queue object.\n\n    // set the clock used for timing\n    virtual HRESULT SetSyncSource(__in_opt IReferenceClock *);\n\n    // switch to run mode. Streamtime to Presentation time mapping known.\n    virtual HRESULT Run(REFERENCE_TIME tStreamTimeOffset);\n\n    // switch to Stopped or Paused mode. Time mapping not known.\n    virtual HRESULT EndRun();\n\n    // return a pointer to the next due command. Blocks for msTimeout\n    // milliseconds until there is a due command.\n    // Stream-time commands will only become due between Run and Endrun calls.\n    // The command remains queued until invoked or cancelled.\n    // Returns E_ABORT if timeout occurs, otherwise S_OK (or other error).\n    // Returns an AddRef-ed object\n    virtual HRESULT GetDueCommand(__out CDeferredCommand **ppCmd, long msTimeout);\n\n    // return the event handle that will be signalled whenever\n    // there are deferred commands due for execution (when GetDueCommand\n    // will not block).\n    HANDLE GetDueHandle() { return HANDLE(m_evDue); };\n\n    // return a pointer to a command that will be due for a given time.\n    // Pass in a stream time here. The stream time offset will be passed\n    // in via the Run method.\n    // Commands remain queued until invoked or cancelled.\n    // This method will not block. It will report VFW_E_NOT_FOUND if there\n    // are no commands due yet.\n    // Returns an AddRef-ed object\n    virtual HRESULT GetCommandDueFor(REFERENCE_TIME tStream, __out CDeferredCommand **ppCmd);\n\n    // check if a given time is due (TRUE if it is due yet)\n    BOOL CheckTime(CRefTime time, BOOL bStream)\n    {\n\n        // if no clock, nothing is due!\n        if (!m_pClock)\n        {\n            return FALSE;\n        }\n\n        // stream time\n        if (bStream)\n        {\n\n            // not valid if not running\n            if (!m_bRunning)\n            {\n                return FALSE;\n            }\n            // add on known stream time offset to get presentation time\n            time += m_StreamTimeOffset;\n        }\n\n        CRefTime Now;\n        m_pClock->GetTime((REFERENCE_TIME *)&Now);\n        return (time <= Now);\n    };\n\n  protected:\n    // protect access to lists etc\n    CCritSec m_Lock;\n\n    // commands queued in presentation time are stored here\n    CGenericList<CDeferredCommand> m_listPresentation;\n\n    // commands queued in stream time are stored here\n    CGenericList<CDeferredCommand> m_listStream;\n\n    // set when any commands are due\n    CAMEvent m_evDue;\n\n    // creates an advise for the earliest time required, if any\n    void SetTimeAdvise(void);\n\n    // advise id from reference clock (0 if no outstanding advise)\n    DWORD_PTR m_dwAdvise;\n\n    // advise time is for this presentation time\n    CRefTime m_tCurrentAdvise;\n\n    // the reference clock we are using (addrefed)\n    IReferenceClock *m_pClock;\n\n    // true when running\n    BOOL m_bRunning;\n\n    // contains stream time offset when m_bRunning is true\n    CRefTime m_StreamTimeOffset;\n};\n\n#endif // __CTLUTIL__\n"
  },
  {
    "path": "common/baseclasses/ddmm.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: DDMM.cpp\n//\n// Desc: DirectShow base classes - implements routines for using DirectDraw\n//       on a multimonitor system.\n//\n// Copyright (c) 1995-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <ddraw.h>\n#include \"ddmm.h\"\n\n/*\n * FindDeviceCallback\n */\ntypedef struct\n{\n    LPSTR szDevice;\n    GUID *lpGUID;\n    GUID GUID;\n    BOOL fFound;\n} FindDeviceData;\n\nBOOL CALLBACK FindDeviceCallback(__in_opt GUID *lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam)\n{\n    FindDeviceData *p = (FindDeviceData *)lParam;\n\n    if (lstrcmpiA(p->szDevice, szDevice) == 0)\n    {\n        if (lpGUID)\n        {\n            p->GUID = *lpGUID;\n            p->lpGUID = &p->GUID;\n        }\n        else\n        {\n            p->lpGUID = NULL;\n        }\n        p->fFound = TRUE;\n        return FALSE;\n    }\n    return TRUE;\n}\n\nBOOL CALLBACK FindDeviceCallbackEx(__in_opt GUID *lpGUID, __in LPSTR szName, __in LPSTR szDevice, __in LPVOID lParam,\n                                   HMONITOR hMonitor)\n{\n    FindDeviceData *p = (FindDeviceData *)lParam;\n\n    if (lstrcmpiA(p->szDevice, szDevice) == 0)\n    {\n        if (lpGUID)\n        {\n            p->GUID = *lpGUID;\n            p->lpGUID = &p->GUID;\n        }\n        else\n        {\n            p->lpGUID = NULL;\n        }\n        p->fFound = TRUE;\n        return FALSE;\n    }\n    return TRUE;\n}\n\n/*\n * DirectDrawCreateFromDevice\n *\n * create a DirectDraw object for a particular device\n */\nIDirectDraw *DirectDrawCreateFromDevice(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP,\n                                        PDRAWENUM DirectDrawEnumerateP)\n{\n    IDirectDraw *pdd = NULL;\n    FindDeviceData find;\n\n    if (szDevice == NULL)\n    {\n        DirectDrawCreateP(NULL, &pdd, NULL);\n        return pdd;\n    }\n\n    find.szDevice = szDevice;\n    find.fFound = FALSE;\n    DirectDrawEnumerateP(FindDeviceCallback, (LPVOID)&find);\n\n    if (find.fFound)\n    {\n        //\n        // In 4bpp mode the following DDraw call causes a message box to be popped\n        // up by DDraw (!?!).  It's DDraw's fault, but we don't like it.  So we\n        // make sure it doesn't happen.\n        //\n        UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);\n        DirectDrawCreateP(find.lpGUID, &pdd, NULL);\n        SetErrorMode(ErrorMode);\n    }\n\n    return pdd;\n}\n\n/*\n * DirectDrawCreateFromDeviceEx\n *\n * create a DirectDraw object for a particular device\n */\nIDirectDraw *DirectDrawCreateFromDeviceEx(__in_opt LPSTR szDevice, PDRAWCREATE DirectDrawCreateP,\n                                          LPDIRECTDRAWENUMERATEEXA DirectDrawEnumerateExP)\n{\n    IDirectDraw *pdd = NULL;\n    FindDeviceData find;\n\n    if (szDevice == NULL)\n    {\n        DirectDrawCreateP(NULL, &pdd, NULL);\n        return pdd;\n    }\n\n    find.szDevice = szDevice;\n    find.fFound = FALSE;\n    DirectDrawEnumerateExP(FindDeviceCallbackEx, (LPVOID)&find, DDENUM_ATTACHEDSECONDARYDEVICES);\n\n    if (find.fFound)\n    {\n        //\n        // In 4bpp mode the following DDraw call causes a message box to be popped\n        // up by DDraw (!?!).  It's DDraw's fault, but we don't like it.  So we\n        // make sure it doesn't happen.\n        //\n        UINT ErrorMode = SetErrorMode(SEM_FAILCRITICALERRORS);\n        DirectDrawCreateP(find.lpGUID, &pdd, NULL);\n        SetErrorMode(ErrorMode);\n    }\n\n    return pdd;\n}\n"
  },
  {
    "path": "common/baseclasses/ddmm.h",
    "content": "//------------------------------------------------------------------------------\n// File: DDMM.h\n//\n// Desc: DirectShow base classes - efines routines for using DirectDraw\n//       on a multimonitor system.\n//\n// Copyright (c) 1995-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifdef __cplusplus\nextern \"C\"\n{      /* Assume C declarations for C++ */\n#endif /* __cplusplus */\n\n// DDRAW.H might not include these\n#ifndef DDENUM_ATTACHEDSECONDARYDEVICES\n#define DDENUM_ATTACHEDSECONDARYDEVICES 0x00000001L\n#endif\n\n    typedef HRESULT (*PDRAWCREATE)(IID *, LPDIRECTDRAW *, LPUNKNOWN);\n    typedef HRESULT (*PDRAWENUM)(LPDDENUMCALLBACKA, LPVOID);\n\n    IDirectDraw *DirectDrawCreateFromDevice(__in_opt LPSTR, PDRAWCREATE, PDRAWENUM);\n    IDirectDraw *DirectDrawCreateFromDeviceEx(__in_opt LPSTR, PDRAWCREATE, LPDIRECTDRAWENUMERATEEXA);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n"
  },
  {
    "path": "common/baseclasses/dllentry.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: DlleEntry.cpp\n//\n// Desc: DirectShow base classes - implements classes used to support dll\n//       entry points for COM objects.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <initguid.h>\n\n#ifdef DEBUG\n#ifdef UNICODE\n#ifndef _UNICODE\n#define _UNICODE\n#endif // _UNICODE\n#endif // UNICODE\n\n#include <tchar.h>\n#endif // DEBUG\n#include <strsafe.h>\n\nextern CFactoryTemplate g_Templates[];\nextern int g_cTemplates;\n\nHINSTANCE g_hInst;\nDWORD g_amPlatform; // VER_PLATFORM_WIN32_WINDOWS etc... (from GetVersionEx)\nOSVERSIONINFO g_osInfo;\n\n//\n// an instance of this is created by the DLLGetClassObject entrypoint\n// it uses the CFactoryTemplate object it is given to support the\n// IClassFactory interface\n\nclass CClassFactory\n    : public IClassFactory\n    , public CBaseObject\n{\n\n  private:\n    const CFactoryTemplate *const m_pTemplate;\n\n    ULONG m_cRef;\n\n    static int m_cLocked;\n\n  public:\n    CClassFactory(const CFactoryTemplate *);\n\n    // IUnknown\n    STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) AddRef();\n    STDMETHODIMP_(ULONG) Release();\n\n    // IClassFactory\n    STDMETHODIMP CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, __deref_out void **pv);\n    STDMETHODIMP LockServer(BOOL fLock);\n\n    // allow DLLGetClassObject to know about global server lock status\n    static BOOL IsLocked() { return (m_cLocked > 0); };\n};\n\n// process-wide dll locked state\nint CClassFactory::m_cLocked = 0;\n\nCClassFactory::CClassFactory(const CFactoryTemplate *pTemplate)\n    : CBaseObject(NAME(\"Class Factory\"))\n    , m_cRef(0)\n    , m_pTemplate(pTemplate)\n{\n}\n\nSTDMETHODIMP\nCClassFactory::QueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER) ValidateReadWritePtr(ppv, sizeof(PVOID));\n    *ppv = NULL;\n\n    // any interface on this object is the object pointer.\n    if ((riid == IID_IUnknown) || (riid == IID_IClassFactory))\n    {\n        *ppv = (LPVOID)this;\n        // AddRef returned interface pointer\n        ((LPUNKNOWN)*ppv)->AddRef();\n        return NOERROR;\n    }\n\n    return ResultFromScode(E_NOINTERFACE);\n}\n\nSTDMETHODIMP_(ULONG)\nCClassFactory::AddRef()\n{\n    return ++m_cRef;\n}\n\nSTDMETHODIMP_(ULONG)\nCClassFactory::Release()\n{\n    LONG lRef = InterlockedDecrement((volatile LONG *)&m_cRef);\n    if (lRef == 0)\n    {\n        delete this;\n        return 0;\n    }\n    else\n    {\n        return lRef;\n    }\n}\n\nSTDMETHODIMP\nCClassFactory::CreateInstance(LPUNKNOWN pUnkOuter, REFIID riid, __deref_out void **pv)\n{\n    CheckPointer(pv, E_POINTER) ValidateReadWritePtr(pv, sizeof(void *));\n    *pv = NULL;\n\n    /* Enforce the normal OLE rules regarding interfaces and delegation */\n\n    if (pUnkOuter != NULL)\n    {\n        if (IsEqualIID(riid, IID_IUnknown) == FALSE)\n        {\n            *pv = NULL;\n            return ResultFromScode(E_NOINTERFACE);\n        }\n    }\n\n    /* Create the new object through the derived class's create function */\n\n    HRESULT hr = NOERROR;\n    CUnknown *pObj = m_pTemplate->CreateInstance(pUnkOuter, &hr);\n\n    if (pObj == NULL)\n    {\n        *pv = NULL;\n        if (SUCCEEDED(hr))\n        {\n            hr = E_OUTOFMEMORY;\n        }\n        return hr;\n    }\n\n    /* Delete the object if we got a construction error */\n\n    if (FAILED(hr))\n    {\n        delete pObj;\n        *pv = NULL;\n        return hr;\n    }\n\n    /* Get a reference counted interface on the object */\n\n    /* We wrap the non-delegating QI with NDAddRef & NDRelease. */\n    /* This protects any outer object from being prematurely    */\n    /* released by an inner object that may have to be created  */\n    /* in order to supply the requested interface.              */\n    pObj->NonDelegatingAddRef();\n    hr = pObj->NonDelegatingQueryInterface(riid, pv);\n    pObj->NonDelegatingRelease();\n    /* Note that if NonDelegatingQueryInterface fails, it will  */\n    /* not increment the ref count, so the NonDelegatingRelease */\n    /* will drop the ref back to zero and the object will \"self-*/\n    /* destruct\".  Hence we don't need additional tidy-up code  */\n    /* to cope with NonDelegatingQueryInterface failing.        */\n\n    if (SUCCEEDED(hr))\n    {\n        ASSERT(*pv);\n    }\n\n    return hr;\n}\n\nSTDMETHODIMP\nCClassFactory::LockServer(BOOL fLock)\n{\n    if (fLock)\n    {\n        m_cLocked++;\n    }\n    else\n    {\n        m_cLocked--;\n    }\n    return NOERROR;\n}\n\n// --- COM entrypoints -----------------------------------------\n\n// called by COM to get the class factory object for a given class\n__control_entrypoint(DllExport) STDAPI DllGetClassObject(__in REFCLSID rClsID, __in REFIID riid, __deref_out void **pv)\n{\n    *pv = NULL;\n    if (!(riid == IID_IUnknown) && !(riid == IID_IClassFactory))\n    {\n        return E_NOINTERFACE;\n    }\n\n    // traverse the array of templates looking for one with this\n    // class id\n    for (int i = 0; i < g_cTemplates; i++)\n    {\n        const CFactoryTemplate *pT = &g_Templates[i];\n        if (pT->IsClassID(rClsID))\n        {\n\n            // found a template - make a class factory based on this\n            // template\n\n            *pv = (LPVOID)(LPUNKNOWN) new CClassFactory(pT);\n            if (*pv == NULL)\n            {\n                return E_OUTOFMEMORY;\n            }\n            ((LPUNKNOWN)*pv)->AddRef();\n            return NOERROR;\n        }\n    }\n    return CLASS_E_CLASSNOTAVAILABLE;\n}\n\n//\n//  Call any initialization routines\n//\nvoid DllInitClasses(BOOL bLoading)\n{\n    int i;\n\n    // traverse the array of templates calling the init routine\n    // if they have one\n    for (i = 0; i < g_cTemplates; i++)\n    {\n        const CFactoryTemplate *pT = &g_Templates[i];\n        if (pT->m_lpfnInit != NULL)\n        {\n            (*pT->m_lpfnInit)(bLoading, pT->m_ClsID);\n        }\n    }\n}\n\n// called by COM to determine if this dll can be unloaded\n// return ok unless there are outstanding objects or a lock requested\n// by IClassFactory::LockServer\n//\n// CClassFactory has a static function that can tell us about the locks,\n// and CCOMObject has a static function that can tell us about the active\n// object count\nSTDAPI\nDllCanUnloadNow()\n{\n    DbgLog((LOG_MEMORY, 2, TEXT(\"DLLCanUnloadNow called - IsLocked = %d, Active objects = %d\"),\n            CClassFactory::IsLocked(), CBaseObject::ObjectsActive()));\n\n    if (CClassFactory::IsLocked() || CBaseObject::ObjectsActive())\n    {\n        return S_FALSE;\n    }\n    else\n    {\n        return S_OK;\n    }\n}\n\n// --- standard WIN32 entrypoints --------------------------------------\n\nextern \"C\" void __cdecl __security_init_cookie(void);\nextern \"C\" BOOL WINAPI _DllEntryPoint(HINSTANCE, ULONG, __inout_opt LPVOID);\n#pragma comment(linker, \"/merge:.CRT=.rdata\")\n\nextern \"C\" DECLSPEC_NOINLINE BOOL WINAPI DllEntryPoint(HINSTANCE hInstance, ULONG ulReason, __inout_opt LPVOID pv)\n{\n    if (ulReason == DLL_PROCESS_ATTACH)\n    {\n        // Must happen before any other code is executed.  Thankfully - it's re-entrant\n        __security_init_cookie();\n    }\n    return _DllEntryPoint(hInstance, ulReason, pv);\n}\n\nDECLSPEC_NOINLINE\nBOOL WINAPI _DllEntryPoint(HINSTANCE hInstance, ULONG ulReason, __inout_opt LPVOID pv)\n{\n#ifdef DEBUG\n    extern bool g_fDbgInDllEntryPoint;\n    g_fDbgInDllEntryPoint = true;\n#endif\n\n    switch (ulReason)\n    {\n\n    case DLL_PROCESS_ATTACH:\n        DisableThreadLibraryCalls(hInstance);\n        DbgInitialise(hInstance);\n\n        {\n            // The platform identifier is used to work out whether\n            // full unicode support is available or not.  Hence the\n            // default will be the lowest common denominator - i.e. N/A\n            g_amPlatform = VER_PLATFORM_WIN32_WINDOWS; // win95 assumed in case GetVersionEx fails\n\n            g_osInfo.dwOSVersionInfoSize = sizeof(g_osInfo);\n            if (GetVersionEx(&g_osInfo))\n            {\n                g_amPlatform = g_osInfo.dwPlatformId;\n            }\n            else\n            {\n                DbgLog((LOG_ERROR, 1, TEXT(\"Failed to get the OS platform, assuming Win95\")));\n            }\n        }\n\n        g_hInst = hInstance;\n        DllInitClasses(TRUE);\n        break;\n\n    case DLL_PROCESS_DETACH: DllInitClasses(FALSE);\n\n#ifdef DEBUG\n        if (CBaseObject::ObjectsActive())\n        {\n            DbgSetModuleLevel(LOG_MEMORY, 2);\n            TCHAR szInfo[512];\n            extern TCHAR m_ModuleName[]; // Cut down module name\n\n            TCHAR FullName[_MAX_PATH]; // Load the full path and module name\n            TCHAR *pName;              // Searches from the end for a backslash\n\n            GetModuleFileName(NULL, FullName, _MAX_PATH);\n            pName = _tcsrchr(FullName, '\\\\');\n            if (pName == NULL)\n            {\n                pName = FullName;\n            }\n            else\n            {\n                pName++;\n            }\n\n            (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"Executable: %s  Pid %x  Tid %x. \"), pName,\n                                  GetCurrentProcessId(), GetCurrentThreadId());\n\n            (void)StringCchPrintf(szInfo + lstrlen(szInfo), NUMELMS(szInfo) - lstrlen(szInfo),\n                                  TEXT(\"Module %s, %d objects left active!\"), m_ModuleName,\n                                  CBaseObject::ObjectsActive());\n            DbgAssert(szInfo, TEXT(__FILE__), __LINE__);\n\n            // If running remotely wait for the Assert to be acknowledged\n            // before dumping out the object register\n            DbgDumpObjectRegister();\n        }\n        DbgTerminate();\n#endif\n        break;\n    }\n\n#ifdef DEBUG\n    g_fDbgInDllEntryPoint = false;\n#endif\n    return TRUE;\n}\n"
  },
  {
    "path": "common/baseclasses/dllsetup.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: DllSetup.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <strsafe.h>\n\n//---------------------------------------------------------------------------\n// defines\n\n#define MAX_KEY_LEN 260\n\n//---------------------------------------------------------------------------\n// externally defined functions/variable\n\nextern int g_cTemplates;\nextern CFactoryTemplate g_Templates[];\n\n//---------------------------------------------------------------------------\n//\n// EliminateSubKey\n//\n// Try to enumerate all keys under this one.\n// if we find anything, delete it completely.\n// Otherwise just delete it.\n//\n// note - this was pinched/duplicated from\n// Filgraph\\Mapper.cpp - so should it be in\n// a lib somewhere?\n//\n//---------------------------------------------------------------------------\n\nSTDAPI\nEliminateSubKey(HKEY hkey, LPCTSTR strSubKey)\n{\n    HKEY hk;\n    if (0 == lstrlen(strSubKey))\n    {\n        // defensive approach\n        return E_FAIL;\n    }\n\n    LONG lreturn = RegOpenKeyEx(hkey, strSubKey, 0, MAXIMUM_ALLOWED, &hk);\n\n    ASSERT(lreturn == ERROR_SUCCESS || lreturn == ERROR_FILE_NOT_FOUND || lreturn == ERROR_INVALID_HANDLE);\n\n    if (ERROR_SUCCESS == lreturn)\n    {\n        // Keep on enumerating the first (zero-th)\n        // key and deleting that\n\n        for (;;)\n        {\n            TCHAR Buffer[MAX_KEY_LEN];\n            DWORD dw = MAX_KEY_LEN;\n            FILETIME ft;\n\n            lreturn = RegEnumKeyEx(hk, 0, Buffer, &dw, NULL, NULL, NULL, &ft);\n\n            ASSERT(lreturn == ERROR_SUCCESS || lreturn == ERROR_NO_MORE_ITEMS);\n\n            if (ERROR_SUCCESS == lreturn)\n            {\n                EliminateSubKey(hk, Buffer);\n            }\n            else\n            {\n                break;\n            }\n        }\n\n        RegCloseKey(hk);\n        RegDeleteKey(hkey, strSubKey);\n    }\n\n    return NOERROR;\n}\n\n//---------------------------------------------------------------------------\n//\n// AMovieSetupRegisterServer()\n//\n// registers specfied file \"szFileName\" as server for\n// CLSID \"clsServer\".  A description is also required.\n// The ThreadingModel and ServerType are optional, as\n// they default to InprocServer32 (i.e. dll) and Both.\n//\n//---------------------------------------------------------------------------\n\nSTDAPI\nAMovieSetupRegisterServer(CLSID clsServer, LPCWSTR szDescription, LPCWSTR szFileName,\n                          LPCWSTR szThreadingModel = L\"Both\", LPCWSTR szServerType = L\"InprocServer32\")\n{\n    // temp buffer\n    //\n    TCHAR achTemp[MAX_PATH];\n\n    // convert CLSID uuid to string and write\n    // out subkey as string - CLSID\\{}\n    //\n    OLECHAR szCLSID[CHARS_IN_GUID];\n    HRESULT hr = StringFromGUID2(clsServer, szCLSID, CHARS_IN_GUID);\n    ASSERT(SUCCEEDED(hr));\n\n    // create key\n    //\n    HKEY hkey;\n    (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT(\"CLSID\\\\%ls\"), szCLSID);\n    LONG lreturn = RegCreateKey(HKEY_CLASSES_ROOT, (LPCTSTR)achTemp, &hkey);\n    if (ERROR_SUCCESS != lreturn)\n    {\n        return AmHresultFromWin32(lreturn);\n    }\n\n    // set description string\n    //\n\n    (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT(\"%ls\"), szDescription);\n    lreturn = RegSetValue(hkey, (LPCTSTR)NULL, REG_SZ, achTemp, sizeof(achTemp));\n    if (ERROR_SUCCESS != lreturn)\n    {\n        RegCloseKey(hkey);\n        return AmHresultFromWin32(lreturn);\n    }\n\n    // create CLSID\\\\{\"CLSID\"}\\\\\"ServerType\" key,\n    // using key to CLSID\\\\{\"CLSID\"} passed back by\n    // last call to RegCreateKey().\n    //\n    HKEY hsubkey;\n\n    (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT(\"%ls\"), szServerType);\n    lreturn = RegCreateKey(hkey, achTemp, &hsubkey);\n    if (ERROR_SUCCESS != lreturn)\n    {\n        RegCloseKey(hkey);\n        return AmHresultFromWin32(lreturn);\n    }\n\n    // set Server string\n    //\n    (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT(\"%ls\"), szFileName);\n    lreturn = RegSetValue(hsubkey, (LPCTSTR)NULL, REG_SZ, (LPCTSTR)achTemp, sizeof(TCHAR) * (lstrlen(achTemp) + 1));\n    if (ERROR_SUCCESS != lreturn)\n    {\n        RegCloseKey(hkey);\n        RegCloseKey(hsubkey);\n        return AmHresultFromWin32(lreturn);\n    }\n\n    (void)StringCchPrintf(achTemp, NUMELMS(achTemp), TEXT(\"%ls\"), szThreadingModel);\n    lreturn = RegSetValueEx(hsubkey, TEXT(\"ThreadingModel\"), 0L, REG_SZ, (CONST BYTE *)achTemp,\n                            sizeof(TCHAR) * (lstrlen(achTemp) + 1));\n\n    // close hkeys\n    //\n    RegCloseKey(hkey);\n    RegCloseKey(hsubkey);\n\n    // and return\n    //\n    return HRESULT_FROM_WIN32(lreturn);\n}\n\n//---------------------------------------------------------------------------\n//\n// AMovieSetupUnregisterServer()\n//\n// default ActiveMovie dll setup function\n// - to use must be called from an exported\n//   function named DllRegisterServer()\n//\n//---------------------------------------------------------------------------\n\nSTDAPI\nAMovieSetupUnregisterServer(CLSID clsServer)\n{\n    // convert CLSID uuid to string and write\n    // out subkey CLSID\\{}\n    //\n    OLECHAR szCLSID[CHARS_IN_GUID];\n    HRESULT hr = StringFromGUID2(clsServer, szCLSID, CHARS_IN_GUID);\n    ASSERT(SUCCEEDED(hr));\n\n    TCHAR achBuffer[MAX_KEY_LEN];\n    (void)StringCchPrintf(achBuffer, NUMELMS(achBuffer), TEXT(\"CLSID\\\\%ls\"), szCLSID);\n\n    // delete subkey\n    //\n\n    hr = EliminateSubKey(HKEY_CLASSES_ROOT, achBuffer);\n    ASSERT(SUCCEEDED(hr));\n\n    // return\n    //\n    return NOERROR;\n}\n\n//---------------------------------------------------------------------------\n//\n// AMovieSetupRegisterFilter through IFilterMapper2\n//\n//---------------------------------------------------------------------------\n\nSTDAPI\nAMovieSetupRegisterFilter2(const AMOVIESETUP_FILTER *const psetupdata, IFilterMapper2 *pIFM2, BOOL bRegister)\n{\n    DbgLog((LOG_TRACE, 3, TEXT(\"= AMovieSetupRegisterFilter\")));\n\n    // check we've got data\n    //\n    if (NULL == psetupdata)\n        return S_FALSE;\n\n    // unregister filter\n    // (as pins are subkeys of filter's CLSID key\n    // they do not need to be removed separately).\n    //\n    DbgLog((LOG_TRACE, 3, TEXT(\"= = unregister filter\")));\n    HRESULT hr = pIFM2->UnregisterFilter(0, // default category\n                                         0, // default instance name\n                                         *psetupdata->clsID);\n\n    if (bRegister)\n    {\n        REGFILTER2 rf2;\n        rf2.dwVersion = 1;\n        rf2.dwMerit = psetupdata->dwMerit;\n        rf2.cPins = psetupdata->nPins;\n        rf2.rgPins = psetupdata->lpPin;\n\n        // register filter\n        //\n        DbgLog((LOG_TRACE, 3, TEXT(\"= = register filter\")));\n        hr = pIFM2->RegisterFilter(*psetupdata->clsID, psetupdata->strName, 0 // moniker\n                                   ,\n                                   &psetupdata->filterCategory // category\n                                   ,\n                                   NULL // instance\n                                   ,\n                                   &rf2);\n    }\n\n    // handle one acceptable \"error\" - that\n    // of filter not being registered!\n    // (couldn't find a suitable #define'd\n    // name for the error!)\n    //\n    if (0x80070002 == hr)\n        return NOERROR;\n    else\n        return hr;\n}\n\n//---------------------------------------------------------------------------\n//\n// RegisterAllServers()\n//\n//---------------------------------------------------------------------------\n\nSTDAPI\nRegisterAllServers(LPCWSTR szFileName, BOOL bRegister)\n{\n    HRESULT hr = NOERROR;\n\n    for (int i = 0; i < g_cTemplates; i++)\n    {\n        // get i'th template\n        //\n        const CFactoryTemplate *pT = &g_Templates[i];\n\n        DbgLog((LOG_TRACE, 2, TEXT(\"- - register %ls\"), (LPCWSTR)pT->m_Name));\n\n        // register CLSID and InprocServer32\n        //\n        if (bRegister)\n        {\n            hr = AMovieSetupRegisterServer(*(pT->m_ClsID), (LPCWSTR)pT->m_Name, szFileName);\n        }\n        else\n        {\n            hr = AMovieSetupUnregisterServer(*(pT->m_ClsID));\n        }\n\n        // check final error for this pass\n        // and break loop if we failed\n        //\n        if (FAILED(hr))\n            break;\n    }\n\n    return hr;\n}\n\n//---------------------------------------------------------------------------\n//\n// AMovieDllRegisterServer2()\n//\n// default ActiveMovie dll setup function\n// - to use must be called from an exported\n//   function named DllRegisterServer()\n//\n// this function is table driven using the\n// static members of the CFactoryTemplate\n// class defined in the dll.\n//\n// it registers the Dll as the InprocServer32\n// and then calls the IAMovieSetup.Register\n// method.\n//\n//---------------------------------------------------------------------------\n\nSTDAPI\nAMovieDllRegisterServer2(BOOL bRegister)\n{\n    HRESULT hr = NOERROR;\n\n    DbgLog((LOG_TRACE, 2, TEXT(\"AMovieDllRegisterServer2()\")));\n\n    // get file name (where g_hInst is the\n    // instance handle of the filter dll)\n    //\n    WCHAR achFileName[MAX_PATH];\n\n    // WIN95 doesn't support GetModuleFileNameW\n    //\n    {\n        char achTemp[MAX_PATH];\n\n        DbgLog((LOG_TRACE, 2, TEXT(\"- get module file name\")));\n\n        // g_hInst handle is set in our dll entry point. Make sure\n        // DllEntryPoint in dllentry.cpp is called\n        ASSERT(g_hInst != 0);\n\n        if (0 == GetModuleFileNameA(g_hInst, achTemp, sizeof(achTemp)))\n        {\n            // we've failed!\n            DWORD dwerr = GetLastError();\n            return AmHresultFromWin32(dwerr);\n        }\n\n        MultiByteToWideChar(CP_ACP, 0L, achTemp, lstrlenA(achTemp) + 1, achFileName, NUMELMS(achFileName));\n    }\n\n    //\n    // first registering, register all OLE servers\n    //\n    if (bRegister)\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"- register OLE Servers\")));\n        hr = RegisterAllServers(achFileName, TRUE);\n    }\n\n    //\n    // next, register/unregister all filters\n    //\n\n    if (SUCCEEDED(hr))\n    {\n        // init is ref counted so call just in case\n        // we're being called cold.\n        //\n        DbgLog((LOG_TRACE, 2, TEXT(\"- CoInitialize\")));\n        hr = CoInitialize((LPVOID)NULL);\n        ASSERT(SUCCEEDED(hr));\n\n        // get hold of IFilterMapper2\n        //\n        DbgLog((LOG_TRACE, 2, TEXT(\"- obtain IFilterMapper2\")));\n        IFilterMapper2 *pIFM2 = 0;\n        IFilterMapper *pIFM = 0;\n        hr = CoCreateInstance(CLSID_FilterMapper2, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper2, (void **)&pIFM2);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 2, TEXT(\"- trying IFilterMapper instead\")));\n\n            hr = CoCreateInstance(CLSID_FilterMapper, NULL, CLSCTX_INPROC_SERVER, IID_IFilterMapper, (void **)&pIFM);\n        }\n        if (SUCCEEDED(hr))\n        {\n            // scan through array of CFactoryTemplates\n            // registering servers and filters.\n            //\n            DbgLog((LOG_TRACE, 2, TEXT(\"- register Filters\")));\n            for (int i = 0; i < g_cTemplates; i++)\n            {\n                // get i'th template\n                //\n                const CFactoryTemplate *pT = &g_Templates[i];\n\n                if (NULL != pT->m_pAMovieSetup_Filter)\n                {\n                    DbgLog((LOG_TRACE, 2, TEXT(\"- - register %ls\"), (LPCWSTR)pT->m_Name));\n\n                    if (pIFM2)\n                    {\n                        hr = AMovieSetupRegisterFilter2(pT->m_pAMovieSetup_Filter, pIFM2, bRegister);\n                    }\n                    else\n                    {\n                        hr = AMovieSetupRegisterFilter(pT->m_pAMovieSetup_Filter, pIFM, bRegister);\n                    }\n                }\n\n                // check final error for this pass\n                // and break loop if we failed\n                //\n                if (FAILED(hr))\n                    break;\n            }\n\n            // release interface\n            //\n            if (pIFM2)\n                pIFM2->Release();\n            else\n                pIFM->Release();\n        }\n\n        // and clear up\n        //\n        CoFreeUnusedLibraries();\n        CoUninitialize();\n    }\n\n    //\n    // if unregistering, unregister all OLE servers\n    //\n    if (SUCCEEDED(hr) && !bRegister)\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"- register OLE Servers\")));\n        hr = RegisterAllServers(achFileName, FALSE);\n    }\n\n    DbgLog((LOG_TRACE, 2, TEXT(\"- return %0x\"), hr));\n    return hr;\n}\n\n//---------------------------------------------------------------------------\n//\n// AMovieDllRegisterServer()\n//\n// default ActiveMovie dll setup function\n// - to use must be called from an exported\n//   function named DllRegisterServer()\n//\n// this function is table driven using the\n// static members of the CFactoryTemplate\n// class defined in the dll.\n//\n// it registers the Dll as the InprocServer32\n// and then calls the IAMovieSetup.Register\n// method.\n//\n//---------------------------------------------------------------------------\n\nSTDAPI\nAMovieDllRegisterServer(void)\n{\n    HRESULT hr = NOERROR;\n\n    // get file name (where g_hInst is the\n    // instance handle of the filter dll)\n    //\n    WCHAR achFileName[MAX_PATH];\n\n    {\n        // WIN95 doesn't support GetModuleFileNameW\n        //\n        char achTemp[MAX_PATH];\n\n        if (0 == GetModuleFileNameA(g_hInst, achTemp, sizeof(achTemp)))\n        {\n            // we've failed!\n            DWORD dwerr = GetLastError();\n            return AmHresultFromWin32(dwerr);\n        }\n\n        MultiByteToWideChar(CP_ACP, 0L, achTemp, lstrlenA(achTemp) + 1, achFileName, NUMELMS(achFileName));\n    }\n\n    // scan through array of CFactoryTemplates\n    // registering servers and filters.\n    //\n    for (int i = 0; i < g_cTemplates; i++)\n    {\n        // get i'th template\n        //\n        const CFactoryTemplate *pT = &g_Templates[i];\n\n        // register CLSID and InprocServer32\n        //\n        hr = AMovieSetupRegisterServer(*(pT->m_ClsID), (LPCWSTR)pT->m_Name, achFileName);\n\n        // instantiate all servers and get hold of\n        // IAMovieSetup, if implemented, and call\n        // IAMovieSetup.Register() method\n        //\n        if (SUCCEEDED(hr) && (NULL != pT->m_lpfnNew))\n        {\n            // instantiate object\n            //\n            PAMOVIESETUP psetup;\n            hr = CoCreateInstance(*(pT->m_ClsID), 0, CLSCTX_INPROC_SERVER, IID_IAMovieSetup,\n                                  reinterpret_cast<void **>(&psetup));\n            if (SUCCEEDED(hr))\n            {\n                hr = psetup->Unregister();\n                if (SUCCEEDED(hr))\n                    hr = psetup->Register();\n                psetup->Release();\n            }\n            else\n            {\n                if ((E_NOINTERFACE == hr) || (VFW_E_NEED_OWNER == hr))\n                    hr = NOERROR;\n            }\n        }\n\n        // check final error for this pass\n        // and break loop if we failed\n        //\n        if (FAILED(hr))\n            break;\n\n    } // end-for\n\n    return hr;\n}\n\n//---------------------------------------------------------------------------\n//\n// AMovieDllUnregisterServer()\n//\n// default ActiveMovie dll uninstall function\n// - to use must be called from an exported\n//   function named DllRegisterServer()\n//\n// this function is table driven using the\n// static members of the CFactoryTemplate\n// class defined in the dll.\n//\n// it calls the IAMovieSetup.Unregister\n// method and then unregisters the Dll\n// as the InprocServer32\n//\n//---------------------------------------------------------------------------\n\nSTDAPI\nAMovieDllUnregisterServer()\n{\n    // initialize return code\n    //\n    HRESULT hr = NOERROR;\n\n    // scan through CFactory template and unregister\n    // all OLE servers and filters.\n    //\n    for (int i = g_cTemplates; i--;)\n    {\n        // get i'th template\n        //\n        const CFactoryTemplate *pT = &g_Templates[i];\n\n        // check method exists\n        //\n        if (NULL != pT->m_lpfnNew)\n        {\n            // instantiate object\n            //\n            PAMOVIESETUP psetup;\n            hr = CoCreateInstance(*(pT->m_ClsID), 0, CLSCTX_INPROC_SERVER, IID_IAMovieSetup,\n                                  reinterpret_cast<void **>(&psetup));\n            if (SUCCEEDED(hr))\n            {\n                hr = psetup->Unregister();\n                psetup->Release();\n            }\n            else\n            {\n                if ((E_NOINTERFACE == hr) || (VFW_E_NEED_OWNER == hr))\n                    hr = NOERROR;\n            }\n        }\n\n        // unregister CLSID and InprocServer32\n        //\n        if (SUCCEEDED(hr))\n        {\n            hr = AMovieSetupUnregisterServer(*(pT->m_ClsID));\n        }\n\n        // check final error for this pass\n        // and break loop if we failed\n        //\n        if (FAILED(hr))\n            break;\n    }\n\n    return hr;\n}\n"
  },
  {
    "path": "common/baseclasses/dllsetup.h",
    "content": "//------------------------------------------------------------------------------\n// File: DllSetup.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// To be self registering, OLE servers must\n// export functions named DllRegisterServer\n// and DllUnregisterServer.  To allow use of\n// custom and default implementations the\n// defaults are named AMovieDllRegisterServer\n// and AMovieDllUnregisterServer.\n//\n// To the use the default implementation you\n// must provide stub functions.\n//\n// i.e. STDAPI DllRegisterServer()\n//      {\n//        return AMovieDllRegisterServer();\n//      }\n//\n//      STDAPI DllUnregisterServer()\n//      {\n//        return AMovieDllUnregisterServer();\n//      }\n//\n//\n// AMovieDllRegisterServer   calls IAMovieSetup.Register(), and\n// AMovieDllUnregisterServer calls IAMovieSetup.Unregister().\n\nSTDAPI AMovieDllRegisterServer2(BOOL);\nSTDAPI AMovieDllRegisterServer();\nSTDAPI AMovieDllUnregisterServer();\n\n// helper functions\nSTDAPI EliminateSubKey(HKEY, LPCTSTR);\n\nSTDAPI\nAMovieSetupRegisterFilter2(const AMOVIESETUP_FILTER *const psetupdata, IFilterMapper2 *pIFM2, BOOL bRegister);\n"
  },
  {
    "path": "common/baseclasses/dxmperf.h",
    "content": "//------------------------------------------------------------------------------\n// File: DXMPerf.h\n//\n// Desc: Macros for DirectShow performance logging.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef _DXMPERF_H_\n#define _DXMPERF_H_\n\n#include <perfstruct.h>\n#include \"perflog.h\"\n\n#ifdef _IA64_\nextern \"C\" unsigned __int64 __getReg(int whichReg);\n#pragma intrinsic(__getReg)\n#endif // _IA64_\n\ninline ULONGLONG _RDTSC(void)\n{\n#ifdef _X86_\n    LARGE_INTEGER li;\n    __asm {\n        _emit   0x0F\n        _emit   0x31\n        mov li.LowPart,eax\n        mov li.HighPart,edx\n    }\n    return li.QuadPart;\n\n#if 0 // This isn't tested yet\n\n#elif defined(_IA64_)\n\n#define INL_REGID_APITC 3116\n    return __getReg(INL_REGID_APITC);\n\n#endif // 0\n\n#else  // unsupported platform\n    // not implemented on non x86/IA64 platforms\n    return 0;\n#endif // _X86_/_IA64_\n}\n\n#define DXMPERF_VIDEOREND 0x00000001\n#define DXMPERF_AUDIOGLITCH 0x00000002\n//#define GETTIME_BIT         0x00000001\n//#define AUDIOREND_BIT       0x00000004\n//#define FRAMEDROP_BIT       0x00000008\n#define AUDIOBREAK_BIT 0x00000010\n#define DXMPERF_AUDIORECV 0x00000020\n#define DXMPERF_AUDIOSLAVE 0x00000040\n#define DXMPERF_AUDIOBREAK 0x00000080\n\n#define PERFLOG_CTOR(name, iface)\n#define PERFLOG_DTOR(name, iface)\n#define PERFLOG_DELIVER(name, source, dest, sample, pmt)\n#define PERFLOG_RECEIVE(name, source, dest, sample, pmt)\n#define PERFLOG_RUN(name, iface, time, oldstate)\n#define PERFLOG_PAUSE(name, iface, oldstate)\n#define PERFLOG_STOP(name, iface, oldstate)\n#define PERFLOG_JOINGRAPH(name, iface, graph)\n#define PERFLOG_GETBUFFER(allocator, sample)\n#define PERFLOG_RELBUFFER(allocator, sample)\n#define PERFLOG_CONNECT(connector, connectee, status, pmt)\n#define PERFLOG_RXCONNECT(connector, connectee, status, pmt)\n#define PERFLOG_DISCONNECT(disconnector, disconnectee, status)\n\n#define PERFLOG_GETTIME(clock, time) /*{                                   \\\nPERFINFO_WMI_GETTIME    perfData;                                          \\\nif (NULL != g_pTraceEvent) {                                               \\\n   memset( &perfData, 0, sizeof( perfData ) );                             \\\n   perfData.header.Size  = sizeof( perfData );                             \\\n   perfData.header.Flags = WNODE_FLAG_TRACED_GUID;                         \\\n   perfData.header.Guid  = GUID_GETTIME;                                   \\\n   perfData.data.cycleCounter = _RDTSC();                                  \\\n   perfData.data.dshowClock   = (ULONGLONG) (time);                        \\\n   if (g_perfMasks[GETTIME_INDEX] & GETTIME_BIT)                           \\\n       (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \\\n   }                                                                       \\\n}*/\n\n#define PERFLOG_AUDIOREND(clocktime, sampletime, psample, bytetime, cbytes) /*{ \\\n  PERFINFO_WMI_AVREND    perfData;                                              \\\n  if (NULL != g_pTraceEvent) {                                                  \\\n      memset( &perfData, 0, sizeof( perfData ) );                               \\\n      perfData.header.Size  = sizeof( perfData );                               \\\n      perfData.header.Flags = WNODE_FLAG_TRACED_GUID;                           \\\n      perfData.header.Guid  = GUID_AUDIOREND;                                   \\\n      perfData.data.cycleCounter = _RDTSC();                                    \\\n      perfData.data.dshowClock   = (clocktime);                                 \\\n      perfData.data.sampleTime   = (sampletime);                                \\\n      if (g_perfMasks[AUDIOREND_INDEX] & AUDIOREND_BIT)                         \\\n          (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData );   \\\n      }                                                                         \\\n  }*/\n\n#define PERFLOG_AUDIORECV(StreamTime, SampleStart, SampleStop, Discontinuity, Duration) \\\n    if (PerflogEnableFlags & DXMPERF_AUDIORECV)                                         \\\n    {                                                                                   \\\n        PERFINFO_WMI_AUDIORECV perfData;                                                \\\n        memset(&perfData, 0, sizeof(perfData));                                         \\\n        perfData.header.Size = sizeof(perfData);                                        \\\n        perfData.header.Flags = WNODE_FLAG_TRACED_GUID;                                 \\\n        perfData.header.Guid = GUID_AUDIORECV;                                          \\\n        perfData.data.streamTime = StreamTime;                                          \\\n        perfData.data.sampleStart = SampleStart;                                        \\\n        perfData.data.sampleStop = SampleStop;                                          \\\n        perfData.data.discontinuity = Discontinuity;                                    \\\n        perfData.data.hwduration = Duration;                                            \\\n        PerflogTraceEvent((PEVENT_TRACE_HEADER)&perfData);                              \\\n    }\n\n#define PERFLOG_AUDIOSLAVE(MasterClock, SlaveClock, ErrorAccum, LastHighErrorSeen, LastLowErrorSeen) \\\n    if (PerflogEnableFlags & DXMPERF_AUDIOSLAVE)                                                     \\\n    {                                                                                                \\\n        PERFINFO_WMI_AUDIOSLAVE perfData;                                                            \\\n        memset(&perfData, 0, sizeof(perfData));                                                      \\\n        perfData.header.Size = sizeof(perfData);                                                     \\\n        perfData.header.Flags = WNODE_FLAG_TRACED_GUID;                                              \\\n        perfData.header.Guid = GUID_AUDIOSLAVE;                                                      \\\n        perfData.data.masterClock = MasterClock;                                                     \\\n        perfData.data.slaveClock = SlaveClock;                                                       \\\n        perfData.data.errorAccum = ErrorAccum;                                                       \\\n        perfData.data.lastHighErrorSeen = LastHighErrorSeen;                                         \\\n        perfData.data.lastLowErrorSeen = LastLowErrorSeen;                                           \\\n        PerflogTraceEvent((PEVENT_TRACE_HEADER)&perfData);                                           \\\n    }\n\n#define PERFLOG_AUDIOADDBREAK(IterNextWrite, OffsetNextWrite, IterWrite, OffsetWrite) \\\n    if (PerflogEnableFlags & DXMPERF_AUDIOBREAK)                                      \\\n    {                                                                                 \\\n        PERFINFO_WMI_AUDIOADDBREAK perfData;                                          \\\n        memset(&perfData, 0, sizeof(perfData));                                       \\\n        perfData.header.Size = sizeof(perfData);                                      \\\n        perfData.header.Flags = WNODE_FLAG_TRACED_GUID;                               \\\n        perfData.header.Guid = GUID_AUDIOADDBREAK;                                    \\\n        perfData.data.iterNextWrite = IterNextWrite;                                  \\\n        perfData.data.offsetNextWrite = OffsetNextWrite;                              \\\n        perfData.data.iterWrite = IterWrite;                                          \\\n        perfData.data.offsetWrite = OffsetWrite;                                      \\\n        PerflogTraceEvent((PEVENT_TRACE_HEADER)&perfData);                            \\\n    }\n\n#define PERFLOG_VIDEOREND(sampletime, clocktime, psample)  \\\n    if (PerflogEnableFlags & DXMPERF_VIDEOREND)            \\\n    {                                                      \\\n        PERFINFO_WMI_AVREND perfData;                      \\\n        memset(&perfData, 0, sizeof(perfData));            \\\n        perfData.header.Size = sizeof(perfData);           \\\n        perfData.header.Flags = WNODE_FLAG_TRACED_GUID;    \\\n        perfData.header.Guid = GUID_VIDEOREND;             \\\n        perfData.data.cycleCounter = _RDTSC();             \\\n        perfData.data.dshowClock = (clocktime);            \\\n        perfData.data.sampleTime = (sampletime);           \\\n        PerflogTraceEvent((PEVENT_TRACE_HEADER)&perfData); \\\n    }\n\n#define PERFLOG_AUDIOGLITCH(instance, glitchtype, currenttime, previoustime) \\\n    if (PerflogEnableFlags & DXMPERF_AUDIOGLITCH)                            \\\n    {                                                                        \\\n        PERFINFO_WMI_AUDIOGLITCH perfData;                                   \\\n        memset(&perfData, 0, sizeof(perfData));                              \\\n        perfData.header.Size = sizeof(perfData);                             \\\n        perfData.header.Flags = WNODE_FLAG_TRACED_GUID;                      \\\n        perfData.header.Guid = GUID_DSOUNDGLITCH;                            \\\n        perfData.data.cycleCounter = _RDTSC();                               \\\n        perfData.data.glitchType = (glitchtype);                             \\\n        perfData.data.sampleTime = (currenttime);                            \\\n        perfData.data.previousTime = (previoustime);                         \\\n        perfData.data.instanceId = (instance);                               \\\n        PerflogTraceEvent((PEVENT_TRACE_HEADER)&perfData);                   \\\n    }\n\n#define PERFLOG_FRAMEDROP(sampletime, clocktime, psample, renderer) /*{    \\\nPERFINFO_WMI_FRAMEDROP    perfData;                                        \\\nif (NULL != g_pTraceEvent) {                                               \\\n   memset( &perfData, 0, sizeof( perfData ) );                             \\\n   perfData.header.Size  = sizeof( perfData );                             \\\n   perfData.header.Flags = WNODE_FLAG_TRACED_GUID;                         \\\n   perfData.header.Guid  = GUID_FRAMEDROP;                                 \\\n   perfData.data.cycleCounter = _RDTSC();                                  \\\n   perfData.data.dshowClock   = (clocktime);                               \\\n   perfData.data.frameTime    = (sampletime);                              \\\n   if (g_perfMasks[FRAMEDROP_INDEX] & FRAMEDROP_BIT)                       \\\n       (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \\\n   }                                                                       \\\n}*/\n\n/*\n#define PERFLOG_AUDIOBREAK( nextwrite, writepos, msecs )    { \\\n    PERFINFO_WMI_AUDIOBREAK    perfData; \\\n    if (NULL != g_pTraceEvent) { \\\n        memset( &perfData, 0, sizeof( perfData ) ); \\\n        perfData.header.Size  = sizeof( perfData ); \\\n        perfData.header.Flags = WNODE_FLAG_TRACED_GUID; \\\n        perfData.header.Guid  = GUID_AUDIOBREAK; \\\n        perfData.data.cycleCounter   = _RDTSC(); \\\n        perfData.data.dshowClock     = (writepos); \\\n        perfData.data.sampleTime     = (nextwrite); \\\n        perfData.data.sampleDuration = (msecs); \\\n        if (g_perfMasks[AUDIOBREAK_INDEX] & AUDIOBREAK_BIT) \\\n            (*g_pTraceEvent)( g_traceHandle, (PEVENT_TRACE_HEADER) &perfData ); \\\n        } \\\n    }\n*/\n\n#define PERFLOG_AUDIOBREAK(nextwrite, writepos, msecs)     \\\n    if (PerflogEnableFlags & AUDIOBREAK_BIT)               \\\n    {                                                      \\\n        PERFINFO_WMI_AUDIOBREAK perfData;                  \\\n        memset(&perfData, 0, sizeof(perfData));            \\\n        perfData.header.Size = sizeof(perfData);           \\\n        perfData.header.Flags = WNODE_FLAG_TRACED_GUID;    \\\n        perfData.header.Guid = GUID_AUDIOBREAK;            \\\n        perfData.data.cycleCounter = _RDTSC();             \\\n        perfData.data.dshowClock = (writepos);             \\\n        perfData.data.sampleTime = (nextwrite);            \\\n        perfData.data.sampleDuration = (msecs);            \\\n        PerflogTraceEvent((PEVENT_TRACE_HEADER)&perfData); \\\n    }\n\ninline VOID PERFLOG_STREAMTRACE(ULONG Level, ULONG Id, ULONGLONG DShowClock, ULONGLONG Data1, ULONGLONG Data2,\n                                ULONGLONG Data3, ULONGLONG Data4)\n{\n    if (Level <= PerflogModuleLevel)\n    {\n        PERFINFO_WMI_STREAMTRACE perfData;\n        memset(&perfData, 0, sizeof(perfData));\n        perfData.header.Size = sizeof(perfData);\n        perfData.header.Flags = WNODE_FLAG_TRACED_GUID;\n        perfData.header.Guid = GUID_STREAMTRACE;\n        perfData.data.dshowClock = DShowClock;\n        perfData.data.id = Id;\n        perfData.data.data[0] = Data1;\n        perfData.data.data[1] = Data2;\n        perfData.data.data[2] = Data3;\n        perfData.data.data[3] = Data4;\n        PerflogTraceEvent((PEVENT_TRACE_HEADER)&perfData);\n    }\n}\n\n#endif // _DXMPERF_H_\n"
  },
  {
    "path": "common/baseclasses/fourcc.h",
    "content": "//------------------------------------------------------------------------------\n// File: FourCC.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// FOURCCMap\n//\n// provides a mapping between old-style multimedia format DWORDs\n// and new-style GUIDs.\n//\n// A range of 4 billion GUIDs has been allocated to ensure that this\n// mapping can be done straightforwardly one-to-one in both directions.\n//\n// January 95\n\n#ifndef __FOURCC__\n#define __FOURCC__\n\n// Multimedia format types are marked with DWORDs built from four 8-bit\n// chars and known as FOURCCs. New multimedia AM_MEDIA_TYPE definitions include\n// a subtype GUID. In order to simplify the mapping, GUIDs in the range:\n//    XXXXXXXX-0000-0010-8000-00AA00389B71\n// are reserved for FOURCCs.\n\nclass FOURCCMap : public GUID\n{\n\n  public:\n    FOURCCMap();\n    FOURCCMap(DWORD Fourcc);\n    FOURCCMap(const GUID *);\n\n    DWORD GetFOURCC(void);\n    void SetFOURCC(DWORD fourcc);\n    void SetFOURCC(const GUID *);\n\n  private:\n    void InitGUID();\n};\n\n#define GUID_Data2 0\n#define GUID_Data3 0x10\n#define GUID_Data4_1 0xaa000080\n#define GUID_Data4_2 0x719b3800\n\ninline void FOURCCMap::InitGUID()\n{\n    Data2 = GUID_Data2;\n    Data3 = GUID_Data3;\n    ((DWORD *)Data4)[0] = GUID_Data4_1;\n    ((DWORD *)Data4)[1] = GUID_Data4_2;\n}\n\ninline FOURCCMap::FOURCCMap()\n{\n    InitGUID();\n    SetFOURCC(DWORD(0));\n}\n\ninline FOURCCMap::FOURCCMap(DWORD fourcc)\n{\n    InitGUID();\n    SetFOURCC(fourcc);\n}\n\ninline FOURCCMap::FOURCCMap(const GUID *pGuid)\n{\n    InitGUID();\n    SetFOURCC(pGuid);\n}\n\ninline void FOURCCMap::SetFOURCC(const GUID *pGuid)\n{\n    FOURCCMap *p = (FOURCCMap *)pGuid;\n    SetFOURCC(p->GetFOURCC());\n}\n\ninline void FOURCCMap::SetFOURCC(DWORD fourcc)\n{\n    Data1 = fourcc;\n}\n\ninline DWORD FOURCCMap::GetFOURCC(void)\n{\n    return Data1;\n}\n\n#endif /* __FOURCC__ */\n"
  },
  {
    "path": "common/baseclasses/measure.h",
    "content": "//------------------------------------------------------------------------------\n// File: Measure.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n/*\n   The idea is to pepper the source code with interesting measurements and\n   have the last few thousand of these recorded in a circular buffer that\n   can be post-processed to give interesting numbers.\n\n   WHAT THE LOG LOOKS LIKE:\n\n  Time (sec)   Type        Delta  Incident_Name\n    0.055,41  NOTE      -.       Incident Nine  - Another note\n    0.055,42  NOTE      0.000,01 Incident Nine  - Another note\n    0.055,44  NOTE      0.000,02 Incident Nine  - Another note\n    0.055,45  STOP      -.       Incident Eight - Also random\n    0.055,47  START     -.       Incident Seven - Random\n    0.055,49  NOTE      0.000,05 Incident Nine  - Another note\n    ------- <etc.  there is a lot of this> ----------------\n    0.125,60  STOP      0.000,03 Msr_Stop\n    0.125,62  START     -.       Msr_Start\n    0.125,63  START     -.       Incident Two   - Start/Stop\n    0.125,65  STOP      0.000,03 Msr_Start\n    0.125,66  START     -.       Msr_Stop\n    0.125,68  STOP      0.000,05 Incident Two   - Start/Stop\n    0.125,70  STOP      0.000,04 Msr_Stop\n    0.125,72  START     -.       Msr_Start\n    0.125,73  START     -.       Incident Two   - Start/Stop\n    0.125,75  STOP      0.000,03 Msr_Start\n    0.125,77  START     -.       Msr_Stop\n    0.125,78  STOP      0.000,05 Incident Two   - Start/Stop\n    0.125,80  STOP      0.000,03 Msr_Stop\n    0.125,81  NOTE      -.       Incident Three - single Note\n    0.125,83  START     -.       Incident Four  - Start, no stop\n    0.125,85  START     -.       Incident Five  - Single Start/Stop\n    0.125,87  STOP      0.000,02 Incident Five  - Single Start/Stop\n\nNumber      Average       StdDev     Smallest      Largest Incident_Name\n    10     0.000,58     0.000,10     0.000,55     0.000,85 Incident One   - Note\n    50     0.000,05     0.000,00     0.000,05     0.000,05 Incident Two   - Start/Stop\n     1     -.           -.           -.           -.       Incident Three - single Note\n     0     -.           -.           -.           -.       Incident Four  - Start, no stop\n     1     0.000,02     -.           0.000,02     0.000,02 Incident Five  - Single Start/Stop\n     0     -.           -.           -.           -.       Incident Six   - zero occurrences\n   100     0.000,25     0.000,12     0.000,02     0.000,62 Incident Seven - Random\n   100     0.000,79     0.000,48     0.000,02     0.001,92 Incident Eight - Also random\n  5895     0.000,01     0.000,01     0.000,01     0.000,56 Incident Nine  - Another note\n    10     0.000,03     0.000,00     0.000,03     0.000,04 Msr_Note\n    50     0.000,03     0.000,00     0.000,03     0.000,04 Msr_Start\n    50     0.000,04     0.000,03     0.000,03     0.000,31 Msr_Stop\n\n  WHAT IT MEANS:\n    The log shows what happened and when.  Each line shows the time at which\n    something happened (see WHAT YOU CODE below) what it was that happened\n    and (if approporate) the time since the corresponding previous event\n    (that's the delta column).\n\n    The statistics show how many times each event occurred, what the average\n    delta time was, also the standard deviation, largest and smalles delta.\n\n   WHAT YOU CODE:\n\n   Before anything else executes: - register your ids\n\n    int id1     = Msr_Register(\"Incident One   - Note\");\n    int id2     = Msr_Register(\"Incident Two   - Start/Stop\");\n    int id3     = Msr_Register(\"Incident Three - single Note\");\n    etc.\n\n   At interesting moments:\n\n       // To measure a repetitive event - e.g. end of bitblt to screen\n       Msr_Note(Id9);             // e.g. \"video frame hiting the screen NOW!\"\n\n           or\n\n       // To measure an elapsed time e.g. time taken to decode an MPEG B-frame\n       Msr_Start(Id2);            // e.g. \"Starting to decode MPEG B-frame\"\n         . . .\n       MsrStop(Id2);              //      \"Finished MPEG decode\"\n\n   At the end:\n\n       HANDLE hFile;\n       hFile = CreateFile(\"Perf.log\", GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, 0, NULL);\n       Msr_Dump(hFile);           // This writes the log out to the file\n       CloseHandle(hFile);\n\n           or\n\n       Msr_Dump(NULL);            // This writes it to DbgLog((LOG_TRACE,0, ... ));\n                                  // but if you are writing it out to the debugger\n                                  // then the times are probably all garbage because\n                                  // the debugger can make things run awfully slow.\n\n    A given id should be used either for start / stop or Note calls.  If Notes\n    are mixed in with Starts and Stops their statistics will be gibberish.\n\n    If you code the calls in upper case i.e. MSR_START(idMunge); then you get\n    macros which will turn into nothing unless PERF is defined.\n\n    You can reset the statistical counts for a given id by calling Reset(Id).\n    They are reset by default at the start.\n    It logs Reset as a special incident, so you can see it in the log.\n\n    The log is a circular buffer in storage (to try to minimise disk I/O).\n    It overwrites the oldest entries once full.  The statistics include ALL\n    incidents since the last Reset, whether still visible in the log or not.\n*/\n\n#ifndef __MEASURE__\n#define __MEASURE__\n\n#ifdef PERF\n#define MSR_INIT() Msr_Init()\n#define MSR_TERMINATE() Msr_Terminate()\n#define MSR_REGISTER(a) Msr_Register(a)\n#define MSR_RESET(a) Msr_Reset(a)\n#define MSR_CONTROL(a) Msr_Control(a)\n#define MSR_START(a) Msr_Start(a)\n#define MSR_STOP(a) Msr_Stop(a)\n#define MSR_NOTE(a) Msr_Note(a)\n#define MSR_INTEGER(a, b) Msr_Integer(a, b)\n#define MSR_DUMP(a) Msr_Dump(a)\n#define MSR_DUMPSTATS(a) Msr_DumpStats(a)\n#else\n#define MSR_INIT() ((void)0)\n#define MSR_TERMINATE() ((void)0)\n#define MSR_REGISTER(a) 0\n#define MSR_RESET(a) ((void)0)\n#define MSR_CONTROL(a) ((void)0)\n#define MSR_START(a) ((void)0)\n#define MSR_STOP(a) ((void)0)\n#define MSR_NOTE(a) ((void)0)\n#define MSR_INTEGER(a, b) ((void)0)\n#define MSR_DUMP(a) ((void)0)\n#define MSR_DUMPSTATS(a) ((void)0)\n#endif\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n    // This must be called first - (called by the DllEntry)\n\n    void WINAPI Msr_Init(void);\n\n    // Call this last to clean up (or just let it fall off the end - who cares?)\n\n    void WINAPI Msr_Terminate(void);\n\n    // Call this to get an Id for an \"incident\" that you can pass to Start, Stop or Note\n    // everything that's logged is called an \"incident\".\n\n    int WINAPI Msr_Register(__in LPTSTR Incident);\n\n    // Reset the statistical counts for an incident\n\n    void WINAPI Msr_Reset(int Id);\n\n// Reset all the counts for all incidents\n#define MSR_RESET_ALL 0\n#define MSR_PAUSE 1\n#define MSR_RUN 2\n\n    void WINAPI Msr_Control(int iAction);\n\n    // log the start of an operation\n\n    void WINAPI Msr_Start(int Id);\n\n    // log the end of an operation\n\n    void WINAPI Msr_Stop(int Id);\n\n    // log a one-off or repetitive operation\n\n    void WINAPI Msr_Note(int Id);\n\n    // log an integer (on which we can see statistics later)\n    void WINAPI Msr_Integer(int Id, int n);\n\n    // print out all the vaialable log (it may have wrapped) and then the statistics.\n    // When the log wraps you lose log but the statistics are still complete.\n    // hFIle==NULL => use DbgLog\n    // otherwise hFile must have come from CreateFile or OpenFile.\n\n    void WINAPI Msr_Dump(HANDLE hFile);\n\n    // just dump the statistics - never mind the log\n\n    void WINAPI Msr_DumpStats(HANDLE hFile);\n\n    // Type definitions in case you want to declare a pointer to the dump functions\n    // (makes it a trifle easier to do dynamic linking\n    // i.e. LoadModule, GetProcAddress and call that)\n\n    // Typedefs so can declare MSR_DUMPPROC *MsrDumpStats; or whatever\n    typedef void WINAPI MSR_DUMPPROC(HANDLE hFile);\n    typedef void WINAPI MSR_CONTROLPROC(int iAction);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif // __MEASURE__\n"
  },
  {
    "path": "common/baseclasses/msgthrd.h",
    "content": "//------------------------------------------------------------------------------\n// File: MsgThrd.h\n//\n// Desc: DirectShow base classes - provides support for a worker thread\n//       class to which one can asynchronously post messages.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// Message class - really just a structure.\n//\nclass CMsg\n{\n  public:\n    UINT uMsg;\n    DWORD dwFlags;\n    LPVOID lpParam;\n    CAMEvent *pEvent;\n\n    CMsg(UINT u, DWORD dw, __inout_opt LPVOID lp, __in_opt CAMEvent *pEvnt)\n        : uMsg(u)\n        , dwFlags(dw)\n        , lpParam(lp)\n        , pEvent(pEvnt)\n    {\n    }\n\n    CMsg()\n        : uMsg(0)\n        , dwFlags(0L)\n        , lpParam(NULL)\n        , pEvent(NULL)\n    {\n    }\n};\n\n// This is the actual thread class.  It exports all the usual thread control\n// functions.  The created thread is different from a normal WIN32 thread in\n// that it is prompted to perform particaular tasks by responding to messages\n// posted to its message queue.\n//\nclass AM_NOVTABLE CMsgThread\n{\n  private:\n    static DWORD WINAPI DefaultThreadProc(__inout LPVOID lpParam);\n    DWORD m_ThreadId;\n    HANDLE m_hThread;\n\n  protected:\n    // if you want to override GetThreadMsg to block on other things\n    // as well as this queue, you need access to this\n    CGenericList<CMsg> m_ThreadQueue;\n    CCritSec m_Lock;\n    HANDLE m_hSem;\n    LONG m_lWaiting;\n\n  public:\n    CMsgThread()\n        : m_ThreadId(0)\n        , m_hThread(NULL)\n        , m_lWaiting(0)\n        , m_hSem(NULL)\n        ,\n        // make a list with a cache of 5 items\n        m_ThreadQueue(NAME(\"MsgThread list\"), 5)\n    {\n    }\n\n    ~CMsgThread();\n    // override this if you want to block on other things as well\n    // as the message loop\n    void virtual GetThreadMsg(__out CMsg *msg);\n\n    // override this if you want to do something on thread startup\n    virtual void OnThreadInit(){};\n\n    BOOL CreateThread();\n\n    BOOL WaitForThreadExit(__out LPDWORD lpdwExitCode)\n    {\n        if (m_hThread != NULL)\n        {\n            WaitForSingleObject(m_hThread, INFINITE);\n            return GetExitCodeThread(m_hThread, lpdwExitCode);\n        }\n        return FALSE;\n    }\n\n    DWORD ResumeThread() { return ::ResumeThread(m_hThread); }\n\n    DWORD SuspendThread() { return ::SuspendThread(m_hThread); }\n\n    int GetThreadPriority() { return ::GetThreadPriority(m_hThread); }\n\n    BOOL SetThreadPriority(int nPriority) { return ::SetThreadPriority(m_hThread, nPriority); }\n\n    HANDLE GetThreadHandle() { return m_hThread; }\n\n    DWORD GetThreadId() { return m_ThreadId; }\n\n    void PutThreadMsg(UINT uMsg, DWORD dwMsgFlags, __in_opt LPVOID lpMsgParam, __in_opt CAMEvent *pEvent = NULL)\n    {\n        CAutoLock lck(&m_Lock);\n        CMsg *pMsg = new CMsg(uMsg, dwMsgFlags, lpMsgParam, pEvent);\n        m_ThreadQueue.AddTail(pMsg);\n        if (m_lWaiting != 0)\n        {\n            ReleaseSemaphore(m_hSem, m_lWaiting, 0);\n            m_lWaiting = 0;\n        }\n    }\n\n    // This is the function prototype of the function that the client\n    // supplies.  It is always called on the created thread, never on\n    // the creator thread.\n    //\n    virtual LRESULT ThreadMessageProc(UINT uMsg, DWORD dwFlags, __inout_opt LPVOID lpParam,\n                                      __in_opt CAMEvent *pEvent) = 0;\n};\n"
  },
  {
    "path": "common/baseclasses/mtype.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: MType.cpp\n//\n// Desc: DirectShow base classes - implements a class that holds and\n//       manages media type information.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// helper class that derived pin objects can use to compare media\n// types etc. Has same data members as the struct AM_MEDIA_TYPE defined\n// in the streams IDL file, but also has (non-virtual) functions\n\n#include <streams.h>\n#include <mmreg.h>\n\nCMediaType::~CMediaType()\n{\n    FreeMediaType(*this);\n}\n\nCMediaType::CMediaType()\n{\n    InitMediaType();\n}\n\nCMediaType::CMediaType(const GUID *type)\n{\n    InitMediaType();\n    majortype = *type;\n}\n\n// copy constructor does a deep copy of the format block\n\nCMediaType::CMediaType(const AM_MEDIA_TYPE &rt, __out_opt HRESULT *phr)\n{\n    HRESULT hr = CopyMediaType(this, &rt);\n    if (FAILED(hr) && (NULL != phr))\n    {\n        *phr = hr;\n    }\n}\n\nCMediaType::CMediaType(const CMediaType &rt, __out_opt HRESULT *phr)\n{\n    HRESULT hr = CopyMediaType(this, &rt);\n    if (FAILED(hr) && (NULL != phr))\n    {\n        *phr = hr;\n    }\n}\n\n// this class inherits publicly from AM_MEDIA_TYPE so the compiler could generate\n// the following assignment operator itself, however it could introduce some\n// memory conflicts and leaks in the process because the structure contains\n// a dynamically allocated block (pbFormat) which it will not copy correctly\n\nCMediaType &CMediaType::operator=(const AM_MEDIA_TYPE &rt)\n{\n    Set(rt);\n    return *this;\n}\n\nCMediaType &CMediaType::operator=(const CMediaType &rt)\n{\n    *this = (AM_MEDIA_TYPE &)rt;\n    return *this;\n}\n\nBOOL CMediaType::operator==(const CMediaType &rt) const\n{\n    // I don't believe we need to check sample size or\n    // temporal compression flags, since I think these must\n    // be represented in the type, subtype and format somehow. They\n    // are pulled out as separate flags so that people who don't understand\n    // the particular format representation can still see them, but\n    // they should duplicate information in the format block.\n\n    return (\n        (IsEqualGUID(majortype, rt.majortype) == TRUE) && (IsEqualGUID(subtype, rt.subtype) == TRUE) &&\n        (IsEqualGUID(formattype, rt.formattype) == TRUE) && (cbFormat == rt.cbFormat) &&\n        ((cbFormat == 0) || pbFormat != NULL && rt.pbFormat != NULL && (memcmp(pbFormat, rt.pbFormat, cbFormat) == 0)));\n}\n\nBOOL CMediaType::operator!=(const CMediaType &rt) const\n{\n    /* Check to see if they are equal */\n\n    if (*this == rt)\n    {\n        return FALSE;\n    }\n    return TRUE;\n}\n\nHRESULT\nCMediaType::Set(const CMediaType &rt)\n{\n    return Set((AM_MEDIA_TYPE &)rt);\n}\n\nHRESULT\nCMediaType::Set(const AM_MEDIA_TYPE &rt)\n{\n    if (&rt != this)\n    {\n        FreeMediaType(*this);\n        HRESULT hr = CopyMediaType(this, &rt);\n        if (FAILED(hr))\n        {\n            return E_OUTOFMEMORY;\n        }\n    }\n\n    return S_OK;\n}\n\nBOOL CMediaType::IsValid() const\n{\n    return (!IsEqualGUID(majortype, GUID_NULL));\n}\n\nvoid CMediaType::SetType(const GUID *ptype)\n{\n    majortype = *ptype;\n}\n\nvoid CMediaType::SetSubtype(const GUID *ptype)\n{\n    subtype = *ptype;\n}\n\nULONG\nCMediaType::GetSampleSize() const\n{\n    if (IsFixedSize())\n    {\n        return lSampleSize;\n    }\n    else\n    {\n        return 0;\n    }\n}\n\nvoid CMediaType::SetSampleSize(ULONG sz)\n{\n    if (sz == 0)\n    {\n        SetVariableSize();\n    }\n    else\n    {\n        bFixedSizeSamples = TRUE;\n        lSampleSize = sz;\n    }\n}\n\nvoid CMediaType::SetVariableSize()\n{\n    bFixedSizeSamples = FALSE;\n}\n\nvoid CMediaType::SetTemporalCompression(BOOL bCompressed)\n{\n    bTemporalCompression = bCompressed;\n}\n\nBOOL CMediaType::SetFormat(__in_bcount(cb) BYTE *pformat, ULONG cb)\n{\n    if (NULL == AllocFormatBuffer(cb))\n        return (FALSE);\n\n    ASSERT(pbFormat);\n    memcpy(pbFormat, pformat, cb);\n    return (TRUE);\n}\n\n// set the type of the media type format block, this type defines what you\n// will actually find in the format pointer. For example FORMAT_VideoInfo or\n// FORMAT_WaveFormatEx. In the future this may be an interface pointer to a\n// property set. Before sending out media types this should be filled in.\n\nvoid CMediaType::SetFormatType(const GUID *pformattype)\n{\n    formattype = *pformattype;\n}\n\n// reset the format buffer\n\nvoid CMediaType::ResetFormatBuffer()\n{\n    if (cbFormat)\n    {\n        CoTaskMemFree((PVOID)pbFormat);\n    }\n    cbFormat = 0;\n    pbFormat = NULL;\n}\n\n// allocate length bytes for the format and return a read/write pointer\n// If we cannot allocate the new block of memory we return NULL leaving\n// the original block of memory untouched (as does ReallocFormatBuffer)\n\nBYTE *CMediaType::AllocFormatBuffer(ULONG length)\n{\n    ASSERT(length);\n\n    // do the types have the same buffer size\n\n    if (cbFormat == length)\n    {\n        return pbFormat;\n    }\n\n    // allocate the new format buffer\n\n    BYTE *pNewFormat = (PBYTE)CoTaskMemAlloc(length);\n    if (pNewFormat == NULL)\n    {\n        if (length <= cbFormat)\n            return pbFormat; // reuse the old block anyway.\n        return NULL;\n    }\n\n    // delete the old format\n\n    if (cbFormat != 0)\n    {\n        ASSERT(pbFormat);\n        CoTaskMemFree((PVOID)pbFormat);\n    }\n\n    cbFormat = length;\n    pbFormat = pNewFormat;\n    return pbFormat;\n}\n\n// reallocate length bytes for the format and return a read/write pointer\n// to it. We keep as much information as we can given the new buffer size\n// if this fails the original format buffer is left untouched. The caller\n// is responsible for ensuring the size of memory required is non zero\n\nBYTE *CMediaType::ReallocFormatBuffer(ULONG length)\n{\n    ASSERT(length);\n\n    // do the types have the same buffer size\n\n    if (cbFormat == length)\n    {\n        return pbFormat;\n    }\n\n    // allocate the new format buffer\n\n    BYTE *pNewFormat = (PBYTE)CoTaskMemAlloc(length);\n    if (pNewFormat == NULL)\n    {\n        if (length <= cbFormat)\n            return pbFormat; // reuse the old block anyway.\n        return NULL;\n    }\n\n    // copy any previous format (or part of if new is smaller)\n    // delete the old format and replace with the new one\n\n    if (cbFormat != 0)\n    {\n        ASSERT(pbFormat);\n        memcpy(pNewFormat, pbFormat, min(length, cbFormat));\n        CoTaskMemFree((PVOID)pbFormat);\n    }\n\n    cbFormat = length;\n    pbFormat = pNewFormat;\n    return pNewFormat;\n}\n\n// initialise a media type structure\n\nvoid CMediaType::InitMediaType()\n{\n    ZeroMemory((PVOID)this, sizeof(*this));\n    lSampleSize = 1;\n    bFixedSizeSamples = TRUE;\n}\n\n// a partially specified media type can be passed to IPin::Connect\n// as a constraint on the media type used in the connection.\n// the type, subtype or format type can be null.\nBOOL CMediaType::IsPartiallySpecified(void) const\n{\n    if ((majortype == GUID_NULL) || (formattype == GUID_NULL))\n    {\n        return TRUE;\n    }\n    else\n    {\n        return FALSE;\n    }\n}\n\nBOOL CMediaType::MatchesPartial(const CMediaType *ppartial) const\n{\n    if ((ppartial->majortype != GUID_NULL) && (majortype != ppartial->majortype))\n    {\n        return FALSE;\n    }\n    if ((ppartial->subtype != GUID_NULL) && (subtype != ppartial->subtype))\n    {\n        return FALSE;\n    }\n\n    if (ppartial->formattype != GUID_NULL)\n    {\n        // if the format block is specified then it must match exactly\n        if (formattype != ppartial->formattype)\n        {\n            return FALSE;\n        }\n        if (cbFormat != ppartial->cbFormat)\n        {\n            return FALSE;\n        }\n        if ((cbFormat != 0) && (memcmp(pbFormat, ppartial->pbFormat, cbFormat) != 0))\n        {\n            return FALSE;\n        }\n    }\n\n    return TRUE;\n}\n\n// general purpose function to delete a heap allocated AM_MEDIA_TYPE structure\n// which is useful when calling IEnumMediaTypes::Next as the interface\n// implementation allocates the structures which you must later delete\n// the format block may also be a pointer to an interface to release\n\nvoid WINAPI DeleteMediaType(__inout_opt AM_MEDIA_TYPE *pmt)\n{\n    // allow NULL pointers for coding simplicity\n\n    if (pmt == NULL)\n    {\n        return;\n    }\n\n    FreeMediaType(*pmt);\n    CoTaskMemFree((PVOID)pmt);\n}\n\n// this also comes in useful when using the IEnumMediaTypes interface so\n// that you can copy a media type, you can do nearly the same by creating\n// a CMediaType object but as soon as it goes out of scope the destructor\n// will delete the memory it allocated (this takes a copy of the memory)\n\nAM_MEDIA_TYPE *WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc)\n{\n    ASSERT(pSrc);\n\n    // Allocate a block of memory for the media type\n\n    AM_MEDIA_TYPE *pMediaType = (AM_MEDIA_TYPE *)CoTaskMemAlloc(sizeof(AM_MEDIA_TYPE));\n\n    if (pMediaType == NULL)\n    {\n        return NULL;\n    }\n    // Copy the variable length format block\n\n    HRESULT hr = CopyMediaType(pMediaType, pSrc);\n    if (FAILED(hr))\n    {\n        CoTaskMemFree((PVOID)pMediaType);\n        return NULL;\n    }\n\n    return pMediaType;\n}\n\n//  Copy 1 media type to another\n\nHRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource)\n{\n    //  We'll leak if we copy onto one that already exists - there's one\n    //  case we can check like that - copying to itself.\n    ASSERT(pmtSource != pmtTarget);\n    *pmtTarget = *pmtSource;\n    if (pmtSource->cbFormat != 0)\n    {\n        ASSERT(pmtSource->pbFormat != NULL);\n        pmtTarget->pbFormat = (PBYTE)CoTaskMemAlloc(pmtSource->cbFormat);\n        if (pmtTarget->pbFormat == NULL)\n        {\n            pmtTarget->cbFormat = 0;\n            return E_OUTOFMEMORY;\n        }\n        else\n        {\n            CopyMemory((PVOID)pmtTarget->pbFormat, (PVOID)pmtSource->pbFormat, pmtTarget->cbFormat);\n        }\n    }\n    if (pmtTarget->pUnk != NULL)\n    {\n        pmtTarget->pUnk->AddRef();\n    }\n\n    return S_OK;\n}\n\n//  Free an existing media type (ie free resources it holds)\n\nvoid WINAPI FreeMediaType(__inout AM_MEDIA_TYPE &mt)\n{\n    if (mt.cbFormat != 0)\n    {\n        CoTaskMemFree((PVOID)mt.pbFormat);\n\n        // Strictly unnecessary but tidier\n        mt.cbFormat = 0;\n        mt.pbFormat = NULL;\n    }\n    if (mt.pUnk != NULL)\n    {\n        mt.pUnk->Release();\n        mt.pUnk = NULL;\n    }\n}\n\n//  Initialize a media type from a WAVEFORMATEX\n\nSTDAPI CreateAudioMediaType(const WAVEFORMATEX *pwfx, __out AM_MEDIA_TYPE *pmt, BOOL bSetFormat)\n{\n    pmt->majortype = MEDIATYPE_Audio;\n    if (pwfx->wFormatTag == WAVE_FORMAT_EXTENSIBLE)\n    {\n        pmt->subtype = ((PWAVEFORMATEXTENSIBLE)pwfx)->SubFormat;\n    }\n    else\n    {\n        pmt->subtype = FOURCCMap(pwfx->wFormatTag);\n    }\n    pmt->formattype = FORMAT_WaveFormatEx;\n    pmt->bFixedSizeSamples = TRUE;\n    pmt->bTemporalCompression = FALSE;\n    pmt->lSampleSize = pwfx->nBlockAlign;\n    pmt->pUnk = NULL;\n    if (bSetFormat)\n    {\n        if (pwfx->wFormatTag == WAVE_FORMAT_PCM)\n        {\n            pmt->cbFormat = sizeof(WAVEFORMATEX);\n        }\n        else\n        {\n            pmt->cbFormat = sizeof(WAVEFORMATEX) + pwfx->cbSize;\n        }\n        pmt->pbFormat = (PBYTE)CoTaskMemAlloc(pmt->cbFormat);\n        if (pmt->pbFormat == NULL)\n        {\n            return E_OUTOFMEMORY;\n        }\n        if (pwfx->wFormatTag == WAVE_FORMAT_PCM)\n        {\n            CopyMemory(pmt->pbFormat, pwfx, sizeof(PCMWAVEFORMAT));\n            ((WAVEFORMATEX *)pmt->pbFormat)->cbSize = 0;\n        }\n        else\n        {\n            CopyMemory(pmt->pbFormat, pwfx, pmt->cbFormat);\n        }\n    }\n    return S_OK;\n}\n\n// eliminate very many spurious warnings from MS compiler\n#pragma warning(disable : 4514)\n"
  },
  {
    "path": "common/baseclasses/mtype.h",
    "content": "//------------------------------------------------------------------------------\n// File: MtType.h\n//\n// Desc: DirectShow base classes - defines a class that holds and manages\n//       media type information.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __MTYPE__\n#define __MTYPE__\n\n/* Helper class that derived pin objects can use to compare media\n   types etc. Has same data members as the struct AM_MEDIA_TYPE defined\n   in the streams IDL file, but also has (non-virtual) functions */\n\nclass CMediaType : public _AMMediaType\n{\n\n  public:\n    ~CMediaType();\n    CMediaType();\n    CMediaType(const GUID *majortype);\n    CMediaType(const AM_MEDIA_TYPE &, __out_opt HRESULT *phr = NULL);\n    CMediaType(const CMediaType &, __out_opt HRESULT *phr = NULL);\n\n    CMediaType &operator=(const CMediaType &);\n    CMediaType &operator=(const AM_MEDIA_TYPE &);\n\n    BOOL operator==(const CMediaType &) const;\n    BOOL operator!=(const CMediaType &) const;\n\n    HRESULT Set(const CMediaType &rt);\n    HRESULT Set(const AM_MEDIA_TYPE &rt);\n\n    BOOL IsValid() const;\n\n    const GUID *Type() const { return &majortype; };\n    void SetType(const GUID *);\n    const GUID *Subtype() const { return &subtype; };\n    void SetSubtype(const GUID *);\n\n    BOOL IsFixedSize() const { return bFixedSizeSamples; };\n    BOOL IsTemporalCompressed() const { return bTemporalCompression; };\n    ULONG GetSampleSize() const;\n\n    void SetSampleSize(ULONG sz);\n    void SetVariableSize();\n    void SetTemporalCompression(BOOL bCompressed);\n\n    // read/write pointer to format - can't change length without\n    // calling SetFormat, AllocFormatBuffer or ReallocFormatBuffer\n\n    BYTE *Format() const { return pbFormat; };\n    ULONG FormatLength() const { return cbFormat; };\n\n    void SetFormatType(const GUID *);\n    const GUID *FormatType() const { return &formattype; };\n    BOOL SetFormat(__in_bcount(length) BYTE *pFormat, ULONG length);\n    void ResetFormatBuffer();\n    BYTE *AllocFormatBuffer(ULONG length);\n    BYTE *ReallocFormatBuffer(ULONG length);\n\n    void InitMediaType();\n\n    BOOL MatchesPartial(const CMediaType *ppartial) const;\n    BOOL IsPartiallySpecified(void) const;\n};\n\n/* General purpose functions to copy and delete a task allocated AM_MEDIA_TYPE\n   structure which is useful when using the IEnumMediaFormats interface as\n   the implementation allocates the structures which you must later delete */\n\nvoid WINAPI DeleteMediaType(__inout_opt AM_MEDIA_TYPE *pmt);\nAM_MEDIA_TYPE *WINAPI CreateMediaType(AM_MEDIA_TYPE const *pSrc);\nHRESULT WINAPI CopyMediaType(__out AM_MEDIA_TYPE *pmtTarget, const AM_MEDIA_TYPE *pmtSource);\nvoid WINAPI FreeMediaType(__inout AM_MEDIA_TYPE &mt);\n\n//  Initialize a media type from a WAVEFORMATEX\n\nSTDAPI CreateAudioMediaType(const WAVEFORMATEX *pwfx, __out AM_MEDIA_TYPE *pmt, BOOL bSetFormat);\n\n#endif /* __MTYPE__ */\n"
  },
  {
    "path": "common/baseclasses/outputq.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: OutputQ.cpp\n//\n// Desc: DirectShow base classes - implements COutputQueue class used by an\n//       output pin which may sometimes want to queue output samples on a\n//       separate thread and sometimes call Receive() directly on the input\n//       pin.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n\n//\n//  COutputQueue Constructor :\n//\n//  Determines if a thread is to be created and creates resources\n//\n//     pInputPin  - the downstream input pin we're queueing samples to\n//\n//     phr        - changed to a failure code if this function fails\n//                  (otherwise unchanges)\n//\n//     bAuto      - Ask pInputPin if it can block in Receive by calling\n//                  its ReceiveCanBlock method and create a thread if\n//                  it can block, otherwise not.\n//\n//     bQueue     - if bAuto == FALSE then we create a thread if and only\n//                  if bQueue == TRUE\n//\n//     lBatchSize - work in batches of lBatchSize\n//\n//     bBatchEact - Use exact batch sizes so don't send until the\n//                  batch is full or SendAnyway() is called\n//\n//     lListSize  - If we create a thread make the list of samples queued\n//                  to the thread have this size cache\n//\n//     dwPriority - If we create a thread set its priority to this\n//\nCOutputQueue::COutputQueue(IPin *pInputPin,      //  Pin to send stuff to\n                           __inout HRESULT *phr, //  'Return code'\n                           BOOL bAuto,           //  Ask pin if queue or not\n                           BOOL bQueue,          //  Send through queue\n                           LONG lBatchSize,      //  Batch\n                           BOOL bBatchExact,     //  Batch exactly to BatchSize\n                           LONG lListSize, DWORD dwPriority,\n                           bool bFlushingOpt // flushing optimization\n                           )\n    : m_lBatchSize(lBatchSize)\n    , m_bBatchExact(bBatchExact && (lBatchSize > 1))\n    , m_hThread(NULL)\n    , m_hSem(NULL)\n    , m_List(NULL)\n    , m_pPin(pInputPin)\n    , m_ppSamples(NULL)\n    , m_lWaiting(0)\n    , m_evFlushComplete(FALSE, phr)\n    , m_pInputPin(NULL)\n    , m_bSendAnyway(FALSE)\n    , m_nBatched(0)\n    , m_bFlushing(FALSE)\n    , m_bFlushed(TRUE)\n    , m_bFlushingOpt(bFlushingOpt)\n    , m_bTerminate(FALSE)\n    , m_hEventPop(NULL)\n    , m_hr(S_OK)\n{\n    ASSERT(m_lBatchSize > 0);\n\n    if (FAILED(*phr))\n    {\n        return;\n    }\n\n    //  Check the input pin is OK and cache its IMemInputPin interface\n\n    *phr = pInputPin->QueryInterface(IID_IMemInputPin, (void **)&m_pInputPin);\n    if (FAILED(*phr))\n    {\n        return;\n    }\n\n    // See if we should ask the downstream pin\n\n    if (bAuto)\n    {\n        HRESULT hr = m_pInputPin->ReceiveCanBlock();\n        if (SUCCEEDED(hr))\n        {\n            bQueue = hr == S_OK;\n        }\n    }\n\n    //  Create our sample batch\n\n    m_ppSamples = new PMEDIASAMPLE[m_lBatchSize];\n    if (m_ppSamples == NULL)\n    {\n        *phr = E_OUTOFMEMORY;\n        return;\n    }\n\n    //  If we're queueing allocate resources\n\n    if (bQueue)\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"Creating thread for output pin\")));\n        m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);\n        if (m_hSem == NULL)\n        {\n            DWORD dwError = GetLastError();\n            *phr = AmHresultFromWin32(dwError);\n            return;\n        }\n        m_List = new CSampleList(NAME(\"Sample Queue List\"), lListSize,\n                                 FALSE // No lock\n        );\n        if (m_List == NULL)\n        {\n            *phr = E_OUTOFMEMORY;\n            return;\n        }\n\n        DWORD dwThreadId;\n        m_hThread = CreateThread(NULL, 0, InitialThreadProc, (LPVOID)this, 0, &dwThreadId);\n        if (m_hThread == NULL)\n        {\n            DWORD dwError = GetLastError();\n            *phr = AmHresultFromWin32(dwError);\n            return;\n        }\n        SetThreadPriority(m_hThread, dwPriority);\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"Calling input pin directly - no thread\")));\n    }\n}\n\n//\n//  COutputQueuee Destructor :\n//\n//  Free all resources -\n//\n//      Thread,\n//      Batched samples\n//\nCOutputQueue::~COutputQueue()\n{\n    DbgLog((LOG_TRACE, 3, TEXT(\"COutputQueue::~COutputQueue\")));\n    /*  Free our pointer */\n    if (m_pInputPin != NULL)\n    {\n        m_pInputPin->Release();\n    }\n    if (m_hThread != NULL)\n    {\n        {\n            CAutoLock lck(this);\n            m_bTerminate = TRUE;\n            m_hr = S_FALSE;\n            NotifyThread();\n        }\n        DbgWaitForSingleObject(m_hThread);\n        EXECUTE_ASSERT(CloseHandle(m_hThread));\n\n        //  The thread frees the samples when asked to terminate\n\n        ASSERT(m_List->GetCount() == 0);\n        delete m_List;\n    }\n    else\n    {\n        FreeSamples();\n    }\n    if (m_hSem != NULL)\n    {\n        EXECUTE_ASSERT(CloseHandle(m_hSem));\n    }\n    delete[] m_ppSamples;\n}\n\n//\n//  Call the real thread proc as a member function\n//\nDWORD WINAPI COutputQueue::InitialThreadProc(__in LPVOID pv)\n{\n    HRESULT hrCoInit = CAMThread::CoInitializeHelper();\n\n    COutputQueue *pSampleQueue = (COutputQueue *)pv;\n    DWORD dwReturn = pSampleQueue->ThreadProc();\n\n    if (hrCoInit == S_OK)\n    {\n        CoUninitialize();\n    }\n\n    return dwReturn;\n}\n\n//\n//  Thread sending the samples downstream :\n//\n//  When there is nothing to do the thread sets m_lWaiting (while\n//  holding the critical section) and then waits for m_hSem to be\n//  set (not holding the critical section)\n//\nDWORD COutputQueue::ThreadProc()\n{\n    while (TRUE)\n    {\n        BOOL bWait = FALSE;\n        IMediaSample *pSample;\n        LONG lNumberToSend; // Local copy\n        NewSegmentPacket *ppacket;\n\n        //\n        //  Get a batch of samples and send it if possible\n        //  In any case exit the loop if there is a control action\n        //  requested\n        //\n        {\n            CAutoLock lck(this);\n            while (TRUE)\n            {\n\n                if (m_bTerminate)\n                {\n                    FreeSamples();\n                    return 0;\n                }\n                if (m_bFlushing)\n                {\n                    FreeSamples();\n                    SetEvent(m_evFlushComplete);\n                }\n\n                //  Get a sample off the list\n\n                pSample = m_List->RemoveHead();\n                // inform derived class we took something off the queue\n                if (m_hEventPop)\n                {\n                    // DbgLog((LOG_TRACE,3,TEXT(\"Queue: Delivered  SET EVENT\")));\n                    SetEvent(m_hEventPop);\n                }\n\n                if (pSample != NULL && !IsSpecialSample(pSample))\n                {\n\n                    //  If its just a regular sample just add it to the batch\n                    //  and exit the loop if the batch is full\n\n                    m_ppSamples[m_nBatched++] = pSample;\n                    if (m_nBatched == m_lBatchSize)\n                    {\n                        break;\n                    }\n                }\n                else\n                {\n\n                    //  If there was nothing in the queue and there's nothing\n                    //  to send (either because there's nothing or the batch\n                    //  isn't full) then prepare to wait\n\n                    if (pSample == NULL && (m_bBatchExact || m_nBatched == 0))\n                    {\n\n                        //  Tell other thread to set the event when there's\n                        //  something do to\n\n                        ASSERT(m_lWaiting == 0);\n                        m_lWaiting++;\n                        bWait = TRUE;\n                    }\n                    else\n                    {\n\n                        //  We break out of the loop on SEND_PACKET unless\n                        //  there's nothing to send\n\n                        if (pSample == SEND_PACKET && m_nBatched == 0)\n                        {\n                            continue;\n                        }\n\n                        if (pSample == NEW_SEGMENT)\n                        {\n                            // now we need the parameters - we are\n                            // guaranteed that the next packet contains them\n                            ppacket = (NewSegmentPacket *)m_List->RemoveHead();\n                            // we took something off the queue\n                            if (m_hEventPop)\n                            {\n                                // DbgLog((LOG_TRACE,3,TEXT(\"Queue: Delivered  SET EVENT\")));\n                                SetEvent(m_hEventPop);\n                            }\n\n                            ASSERT(ppacket);\n                        }\n                        //  EOS_PACKET falls through here and we exit the loop\n                        //  In this way it acts like SEND_PACKET\n                    }\n                    break;\n                }\n            }\n            if (!bWait)\n            {\n                // We look at m_nBatched from the client side so keep\n                // it up to date inside the critical section\n                lNumberToSend = m_nBatched; // Local copy\n                m_nBatched = 0;\n            }\n        }\n\n        //  Wait for some more data\n\n        if (bWait)\n        {\n            DbgWaitForSingleObject(m_hSem);\n            continue;\n        }\n\n        //  OK - send it if there's anything to send\n        //  We DON'T check m_bBatchExact here because either we've got\n        //  a full batch or we dropped through because we got\n        //  SEND_PACKET or EOS_PACKET - both of which imply we should\n        //  flush our batch\n\n        if (lNumberToSend != 0)\n        {\n            long nProcessed;\n            if (m_hr == S_OK)\n            {\n                ASSERT(!m_bFlushed);\n                HRESULT hr = m_pInputPin->ReceiveMultiple(m_ppSamples, lNumberToSend, &nProcessed);\n                /*  Don't overwrite a flushing state HRESULT */\n                CAutoLock lck(this);\n                if (m_hr == S_OK)\n                {\n                    m_hr = hr;\n                }\n                ASSERT(!m_bFlushed);\n            }\n            while (lNumberToSend != 0)\n            {\n                m_ppSamples[--lNumberToSend]->Release();\n            }\n            if (m_hr != S_OK)\n            {\n\n                //  In any case wait for more data - S_OK just\n                //  means there wasn't an error\n\n                DbgLog((LOG_ERROR, 2, TEXT(\"ReceiveMultiple returned %8.8X\"), m_hr));\n            }\n        }\n\n        //  Check for end of stream\n\n        if (pSample == EOS_PACKET)\n        {\n\n            //  We don't send even end of stream on if we've previously\n            //  returned something other than S_OK\n            //  This is because in that case the pin which returned\n            //  something other than S_OK should have either sent\n            //  EndOfStream() or notified the filter graph\n\n            if (m_hr == S_OK)\n            {\n                DbgLog((LOG_TRACE, 2, TEXT(\"COutputQueue sending EndOfStream()\")));\n                HRESULT hr = m_pPin->EndOfStream();\n                if (FAILED(hr))\n                {\n                    DbgLog((LOG_ERROR, 2, TEXT(\"COutputQueue got code 0x%8.8X from EndOfStream()\")));\n                }\n            }\n        }\n\n        //  Data from a new source\n\n        if (pSample == RESET_PACKET)\n        {\n            m_hr = S_OK;\n            SetEvent(m_evFlushComplete);\n        }\n\n        if (pSample == NEW_SEGMENT)\n        {\n            m_pPin->NewSegment(ppacket->tStart, ppacket->tStop, ppacket->dRate);\n            delete ppacket;\n        }\n    }\n}\n\n//  Send batched stuff anyway\nvoid COutputQueue::SendAnyway()\n{\n    if (!IsQueued())\n    {\n\n        //  m_bSendAnyway is a private parameter checked in ReceiveMultiple\n\n        m_bSendAnyway = TRUE;\n        LONG nProcessed;\n        ReceiveMultiple(NULL, 0, &nProcessed);\n        m_bSendAnyway = FALSE;\n    }\n    else\n    {\n        CAutoLock lck(this);\n        QueueSample(SEND_PACKET);\n        NotifyThread();\n    }\n}\n\nvoid COutputQueue::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    if (!IsQueued())\n    {\n        if (S_OK == m_hr)\n        {\n            if (m_bBatchExact)\n            {\n                SendAnyway();\n            }\n            m_pPin->NewSegment(tStart, tStop, dRate);\n        }\n    }\n    else\n    {\n        if (m_hr == S_OK)\n        {\n            //\n            // we need to queue the new segment to appear in order in the\n            // data, but we need to pass parameters to it. Rather than\n            // take the hit of wrapping every single sample so we can tell\n            // special ones apart, we queue special pointers to indicate\n            // special packets, and we guarantee (by holding the\n            // critical section) that the packet immediately following a\n            // NEW_SEGMENT value is a NewSegmentPacket containing the\n            // parameters.\n            NewSegmentPacket *ppack = new NewSegmentPacket;\n            if (ppack == NULL)\n            {\n                return;\n            }\n            ppack->tStart = tStart;\n            ppack->tStop = tStop;\n            ppack->dRate = dRate;\n\n            CAutoLock lck(this);\n            QueueSample(NEW_SEGMENT);\n            QueueSample((IMediaSample *)ppack);\n            NotifyThread();\n        }\n    }\n}\n\n//\n//  End of Stream is queued to output device\n//\nvoid COutputQueue::EOS()\n{\n    CAutoLock lck(this);\n    if (!IsQueued())\n    {\n        if (m_bBatchExact)\n        {\n            SendAnyway();\n        }\n        if (m_hr == S_OK)\n        {\n            DbgLog((LOG_TRACE, 2, TEXT(\"COutputQueue sending EndOfStream()\")));\n            m_bFlushed = FALSE;\n            HRESULT hr = m_pPin->EndOfStream();\n            if (FAILED(hr))\n            {\n                DbgLog((LOG_ERROR, 2, TEXT(\"COutputQueue got code 0x%8.8X from EndOfStream()\")));\n            }\n        }\n    }\n    else\n    {\n        if (m_hr == S_OK)\n        {\n            m_bFlushed = FALSE;\n            QueueSample(EOS_PACKET);\n            NotifyThread();\n        }\n    }\n}\n\n//\n//  Flush all the samples in the queue\n//\nvoid COutputQueue::BeginFlush()\n{\n    if (IsQueued())\n    {\n        {\n            CAutoLock lck(this);\n\n            // block receives -- we assume this is done by the\n            // filter in which we are a component\n\n            // discard all queued data\n\n            m_bFlushing = TRUE;\n\n            //  Make sure we discard all samples from now on\n\n            if (m_hr == S_OK)\n            {\n                m_hr = S_FALSE;\n            }\n\n            // Optimize so we don't keep calling downstream all the time\n\n            if (m_bFlushed && m_bFlushingOpt)\n            {\n                return;\n            }\n\n            // Make sure we really wait for the flush to complete\n            m_evFlushComplete.Reset();\n\n            NotifyThread();\n        }\n\n        // pass this downstream\n\n        m_pPin->BeginFlush();\n    }\n    else\n    {\n        // pass downstream first to avoid deadlocks\n        m_pPin->BeginFlush();\n        CAutoLock lck(this);\n        // discard all queued data\n\n        m_bFlushing = TRUE;\n\n        //  Make sure we discard all samples from now on\n\n        if (m_hr == S_OK)\n        {\n            m_hr = S_FALSE;\n        }\n    }\n}\n\n//\n// leave flush mode - pass this downstream\nvoid COutputQueue::EndFlush()\n{\n    {\n        CAutoLock lck(this);\n        ASSERT(m_bFlushing);\n        if (m_bFlushingOpt && m_bFlushed && IsQueued())\n        {\n            m_bFlushing = FALSE;\n            m_hr = S_OK;\n            return;\n        }\n    }\n\n    // sync with pushing thread -- done in BeginFlush\n    // ensure no more data to go downstream -- done in BeginFlush\n    //\n    // Because we are synching here there is no need to hold the critical\n    // section (in fact we'd deadlock if we did!)\n\n    if (IsQueued())\n    {\n        m_evFlushComplete.Wait();\n    }\n    else\n    {\n        FreeSamples();\n    }\n\n    //  Be daring - the caller has guaranteed no samples will arrive\n    //  before EndFlush() returns\n\n    m_bFlushing = FALSE;\n    m_bFlushed = TRUE;\n\n    // call EndFlush on downstream pins\n\n    m_pPin->EndFlush();\n\n    m_hr = S_OK;\n}\n\n//  COutputQueue::QueueSample\n//\n//  private method to Send a sample to the output queue\n//  The critical section MUST be held when this is called\n\nvoid COutputQueue::QueueSample(IMediaSample *pSample)\n{\n    if (NULL == m_List->AddTail(pSample))\n    {\n        if (!IsSpecialSample(pSample))\n        {\n            pSample->Release();\n        }\n    }\n}\n\n//\n//  COutputQueue::Receive()\n//\n//  Send a single sample by the multiple sample route\n//  (NOTE - this could be optimized if necessary)\n//\n//  On return the sample will have been Release()'d\n//\n\nHRESULT COutputQueue::Receive(IMediaSample *pSample)\n{\n    LONG nProcessed;\n    return ReceiveMultiple(&pSample, 1, &nProcessed);\n}\n\n//\n//  COutputQueue::ReceiveMultiple()\n//\n//  Send a set of samples to the downstream pin\n//\n//      ppSamples           - array of samples\n//      nSamples            - how many\n//      nSamplesProcessed   - How many were processed\n//\n//  On return all samples will have been Release()'d\n//\n\nHRESULT COutputQueue::ReceiveMultiple(__in_ecount(nSamples) IMediaSample **ppSamples, long nSamples,\n                                      __out long *nSamplesProcessed)\n{\n    if (nSamples < 0)\n    {\n        return E_INVALIDARG;\n    }\n\n    CAutoLock lck(this);\n    //  Either call directly or queue up the samples\n\n    if (!IsQueued())\n    {\n\n        //  If we already had a bad return code then just return\n\n        if (S_OK != m_hr)\n        {\n\n            //  If we've never received anything since the last Flush()\n            //  and the sticky return code is not S_OK we must be\n            //  flushing\n            //  ((!A || B) is equivalent to A implies B)\n            ASSERT(!m_bFlushed || m_bFlushing);\n\n            //  We're supposed to Release() them anyway!\n            *nSamplesProcessed = 0;\n            for (int i = 0; i < nSamples; i++)\n            {\n                DbgLog(\n                    (LOG_TRACE, 3, TEXT(\"COutputQueue (direct) : Discarding %d samples code 0x%8.8X\"), nSamples, m_hr));\n                ppSamples[i]->Release();\n            }\n\n            return m_hr;\n        }\n        //\n        //  If we're flushing the sticky return code should be S_FALSE\n        //\n        ASSERT(!m_bFlushing);\n        m_bFlushed = FALSE;\n\n        ASSERT(m_nBatched < m_lBatchSize);\n        ASSERT(m_nBatched == 0 || m_bBatchExact);\n\n        //  Loop processing the samples in batches\n\n        LONG iLost = 0;\n        long iDone = 0;\n        for (iDone = 0; iDone < nSamples || (m_nBatched != 0 && m_bSendAnyway);)\n        {\n\n            // pragma message (REMIND(\"Implement threshold scheme\"))\n            ASSERT(m_nBatched < m_lBatchSize);\n            if (iDone < nSamples)\n            {\n                m_ppSamples[m_nBatched++] = ppSamples[iDone++];\n            }\n            if (m_nBatched == m_lBatchSize || nSamples == 0 && (m_bSendAnyway || !m_bBatchExact))\n            {\n                LONG nDone;\n                DbgLog((LOG_TRACE, 4, TEXT(\"Batching %d samples\"), m_nBatched));\n\n                if (m_hr == S_OK)\n                {\n                    m_hr = m_pInputPin->ReceiveMultiple(m_ppSamples, m_nBatched, &nDone);\n                }\n                else\n                {\n                    nDone = 0;\n                }\n                iLost += m_nBatched - nDone;\n                for (LONG i = 0; i < m_nBatched; i++)\n                {\n                    m_ppSamples[i]->Release();\n                }\n                m_nBatched = 0;\n            }\n        }\n        *nSamplesProcessed = iDone - iLost;\n        if (*nSamplesProcessed < 0)\n        {\n            *nSamplesProcessed = 0;\n        }\n        return m_hr;\n    }\n    else\n    {\n        /*  We're sending to our thread */\n\n        if (m_hr != S_OK)\n        {\n            *nSamplesProcessed = 0;\n            DbgLog((LOG_TRACE, 3, TEXT(\"COutputQueue (queued) : Discarding %d samples code 0x%8.8X\"), nSamples, m_hr));\n            for (int i = 0; i < nSamples; i++)\n            {\n                ppSamples[i]->Release();\n            }\n            return m_hr;\n        }\n        m_bFlushed = FALSE;\n        for (long i = 0; i < nSamples; i++)\n        {\n            QueueSample(ppSamples[i]);\n        }\n        *nSamplesProcessed = nSamples;\n        if (!m_bBatchExact || m_nBatched + m_List->GetCount() >= m_lBatchSize)\n        {\n            NotifyThread();\n        }\n        return S_OK;\n    }\n}\n\n//  Get ready for new data - cancels sticky m_hr\nvoid COutputQueue::Reset()\n{\n    if (!IsQueued())\n    {\n        m_hr = S_OK;\n    }\n    else\n    {\n        {\n            CAutoLock lck(this);\n            QueueSample(RESET_PACKET);\n            NotifyThread();\n        }\n        m_evFlushComplete.Wait();\n    }\n}\n\n//  Remove and Release() all queued and Batched samples\nvoid COutputQueue::FreeSamples()\n{\n    CAutoLock lck(this);\n    if (IsQueued())\n    {\n        while (TRUE)\n        {\n            IMediaSample *pSample = m_List->RemoveHead();\n            // inform derived class we took something off the queue\n            if (m_hEventPop)\n            {\n                // DbgLog((LOG_TRACE,3,TEXT(\"Queue: Delivered  SET EVENT\")));\n                SetEvent(m_hEventPop);\n            }\n\n            if (pSample == NULL)\n            {\n                break;\n            }\n            if (!IsSpecialSample(pSample))\n            {\n                pSample->Release();\n            }\n            else\n            {\n                if (pSample == NEW_SEGMENT)\n                {\n                    //  Free NEW_SEGMENT packet\n                    NewSegmentPacket *ppacket = (NewSegmentPacket *)m_List->RemoveHead();\n                    // inform derived class we took something off the queue\n                    if (m_hEventPop)\n                    {\n                        // DbgLog((LOG_TRACE,3,TEXT(\"Queue: Delivered  SET EVENT\")));\n                        SetEvent(m_hEventPop);\n                    }\n\n                    ASSERT(ppacket != NULL);\n                    delete ppacket;\n                }\n            }\n        }\n    }\n    for (int i = 0; i < m_nBatched; i++)\n    {\n        m_ppSamples[i]->Release();\n    }\n    m_nBatched = 0;\n}\n\n//  Notify the thread if there is something to do\n//\n//  The critical section MUST be held when this is called\nvoid COutputQueue::NotifyThread()\n{\n    //  Optimize - no need to signal if it's not waiting\n    ASSERT(IsQueued());\n    if (m_lWaiting)\n    {\n        ReleaseSemaphore(m_hSem, m_lWaiting, NULL);\n        m_lWaiting = 0;\n    }\n}\n\n//  See if there's any work to do\n//  Returns\n//      TRUE  if there is nothing on the queue and nothing in the batch\n//            and all data has been sent\n//      FALSE otherwise\n//\nBOOL COutputQueue::IsIdle()\n{\n    CAutoLock lck(this);\n\n    //  We're idle if\n    //      there is no thread (!IsQueued()) OR\n    //      the thread is waiting for more work  (m_lWaiting != 0)\n    //  AND\n    //      there's nothing in the current batch (m_nBatched == 0)\n\n    if (IsQueued() && m_lWaiting == 0 || m_nBatched != 0)\n    {\n        return FALSE;\n    }\n    else\n    {\n\n        //  If we're idle it shouldn't be possible for there\n        //  to be anything on the work queue\n\n        ASSERT(!IsQueued() || m_List->GetCount() == 0);\n        return TRUE;\n    }\n}\n\nvoid COutputQueue::SetPopEvent(HANDLE hEvent)\n{\n    m_hEventPop = hEvent;\n}\n"
  },
  {
    "path": "common/baseclasses/outputq.h",
    "content": "//------------------------------------------------------------------------------\n// File: OutputQ.h\n//\n// Desc: DirectShow base classes -  defines the COutputQueue class, which\n//       makes a queue of samples and sends them to an output pin.  The\n//       class will optionally send the samples to the pin directly.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\ntypedef CGenericList<IMediaSample> CSampleList;\n\nclass COutputQueue : public CCritSec\n{\n  public:\n    //  Constructor\n    COutputQueue(IPin *pInputPin,          //  Pin to send stuff to\n                 __inout HRESULT *phr,     //  'Return code'\n                 BOOL bAuto = TRUE,        //  Ask pin if blocks\n                 BOOL bQueue = TRUE,       //  Send through queue (ignored if\n                                           //  bAuto set)\n                 LONG lBatchSize = 1,      //  Batch\n                 BOOL bBatchExact = FALSE, //  Batch exactly to BatchSize\n                 LONG lListSize =          //  Likely number in the list\n                 DEFAULTCACHE,\n                 DWORD dwPriority = //  Priority of thread to create\n                 THREAD_PRIORITY_NORMAL,\n                 bool bFlushingOpt = false // flushing optimization\n    );\n    ~COutputQueue();\n\n    // enter flush state - discard all data\n    void BeginFlush(); // Begin flushing samples\n\n    // re-enable receives (pass this downstream)\n    void EndFlush(); // Complete flush of samples - downstream\n                     // pin guaranteed not to block at this stage\n\n    void EOS(); // Call this on End of stream\n\n    void SendAnyway(); // Send batched samples anyway (if bBatchExact set)\n\n    void NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n\n    HRESULT Receive(IMediaSample *pSample);\n\n    // do something with these media samples\n    HRESULT ReceiveMultiple(__in_ecount(nSamples) IMediaSample **pSamples, long nSamples,\n                            __out long *nSamplesProcessed);\n\n    void Reset(); // Reset m_hr ready for more data\n\n    //  See if its idle or not\n    BOOL IsIdle();\n\n    // give the class an event to fire after everything removed from the queue\n    void SetPopEvent(HANDLE hEvent);\n\n  protected:\n    static DWORD WINAPI InitialThreadProc(__in LPVOID pv);\n    DWORD ThreadProc();\n    BOOL IsQueued() { return m_List != NULL; };\n\n    //  The critical section MUST be held when this is called\n    void QueueSample(IMediaSample *pSample);\n\n    BOOL IsSpecialSample(IMediaSample *pSample) { return (DWORD_PTR)pSample > (DWORD_PTR)(LONG_PTR)(-16); };\n\n    //  Remove and Release() batched and queued samples\n    void FreeSamples();\n\n    //  Notify the thread there is something to do\n    void NotifyThread();\n\n  protected:\n//  Queue 'messages'\n#define SEND_PACKET ((IMediaSample *)(LONG_PTR)(-2))  // Send batch\n#define EOS_PACKET ((IMediaSample *)(LONG_PTR)(-3))   // End of stream\n#define RESET_PACKET ((IMediaSample *)(LONG_PTR)(-4)) // Reset m_hr\n#define NEW_SEGMENT ((IMediaSample *)(LONG_PTR)(-5))  // send NewSegment\n\n    // new segment packet is always followed by one of these\n    struct NewSegmentPacket\n    {\n        REFERENCE_TIME tStart;\n        REFERENCE_TIME tStop;\n        double dRate;\n    };\n\n    // Remember input stuff\n    IPin *const m_pPin;\n    IMemInputPin *m_pInputPin;\n    BOOL const m_bBatchExact;\n    LONG const m_lBatchSize;\n\n    CSampleList *m_List;\n    HANDLE m_hSem;\n    CAMEvent m_evFlushComplete;\n    HANDLE m_hThread;\n    __field_ecount_opt(m_lBatchSize) IMediaSample **m_ppSamples;\n    __range(0, m_lBatchSize) LONG m_nBatched;\n\n    //  Wait optimization\n    LONG m_lWaiting;\n    //  Flush synchronization\n    BOOL m_bFlushing;\n\n    // flushing optimization. some downstream filters have trouble\n    // with the queue's flushing optimization. other rely on it\n    BOOL m_bFlushed;\n    bool m_bFlushingOpt;\n\n    //  Terminate now\n    BOOL m_bTerminate;\n\n    //  Send anyway flag for batching\n    BOOL m_bSendAnyway;\n\n    //  Deferred 'return code'\n    HRESULT volatile m_hr;\n\n    // an event that can be fired after every deliver\n    HANDLE m_hEventPop;\n};\n"
  },
  {
    "path": "common/baseclasses/perflog.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: perflog.cpp\n//\n// Desc: Macros for DirectShow performance logging.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#pragma warning(disable : 4201)\n\n#include <streams.h>\n#include <windows.h>\n#include <tchar.h>\n#include <winperf.h>\n#include <wmistr.h>\n#include <evntrace.h>\n#include <strsafe.h>\n#include \"perflog.h\"\n\n//\n// Local function prototypes.\n//\n\nULONG\nWINAPI\nPerflogCallback(WMIDPREQUESTCODE RequestCode, __in PVOID Context, __out ULONG *BufferSize, __in PVOID Buffer);\n\n//\n// Event tracing function pointers.\n// We have to do this to run on down-level platforms.\n//\n\n#ifdef UNICODE\n\nULONG(__stdcall *_RegisterTraceGuids)\n(__in IN WMIDPREQUEST RequestAddress, __in IN PVOID RequestContext, IN LPCGUID ControlGuid, IN ULONG GuidCount,\n __in IN PTRACE_GUID_REGISTRATION TraceGuidReg, IN LPCWSTR MofImagePath, IN LPCWSTR MofResourceName,\n OUT PTRACEHANDLE RegistrationHandle);\n\n#define REGISTERTRACEGUIDS_NAME \"RegisterTraceGuidsW\"\n\n#else\n\nULONG(__stdcall *_RegisterTraceGuids)\n(__in IN WMIDPREQUEST RequestAddress, __in IN PVOID RequestContext, IN LPCGUID ControlGuid, IN ULONG GuidCount,\n __in IN PTRACE_GUID_REGISTRATION TraceGuidReg, IN LPCSTR MofImagePath, IN LPCSTR MofResourceName,\n __out OUT PTRACEHANDLE RegistrationHandle);\n\n#define REGISTERTRACEGUIDS_NAME \"RegisterTraceGuidsA\"\n\n#endif\n\nULONG(__stdcall *_UnregisterTraceGuids)(TRACEHANDLE RegistrationHandle);\n\nTRACEHANDLE(__stdcall *_GetTraceLoggerHandle)(__in PVOID Buffer);\n\nUCHAR(__stdcall *_GetTraceEnableLevel)(TRACEHANDLE TraceHandle);\n\nULONG(__stdcall *_GetTraceEnableFlags)(TRACEHANDLE TraceHandle);\n\nULONG(__stdcall *_TraceEvent)(TRACEHANDLE TraceHandle, __in PEVENT_TRACE_HEADER EventTrace);\n\nHINSTANCE _Advapi32;\n\n//\n// Global variables.\n//\n\nBOOL EventTracingAvailable = FALSE;\nULONG PerflogEnableFlags;\nUCHAR PerflogEnableLevel;\nULONG PerflogModuleLevel = 0;\nvoid (*OnStateChanged)(void);\nTRACEHANDLE PerflogTraceHandle = NULL;\nTRACEHANDLE PerflogRegHandle;\n\n// The Win32 wsprintf() function writes a maximum of 1024 characters to it's output buffer.\n// See the documentation for wsprintf()'s lpOut parameter for more information.\nconst INT iDEBUGINFO = 1024; // Used to format strings\n\n//\n// This routine initializes performance logging.\n// It should be called from DllMain().\n//\n\nVOID PerflogReadModuleLevel(HINSTANCE hInstance)\n{\n    LONG lReturn;                 // Create key return value\n    TCHAR szInfo[iDEBUGINFO];     // Constructs key names\n    TCHAR szFullName[iDEBUGINFO]; // Load the full path and module name\n    HKEY hModuleKey;              // Module key handle\n    LPTSTR pName;                 // Searches from the end for a backslash\n    DWORD dwKeySize, dwKeyType, dwKeyValue;\n\n    DWORD dwSize = GetModuleFileName((hInstance ? hInstance : GetModuleHandle(NULL)), szFullName, iDEBUGINFO);\n\n    if (0 == dwSize || iDEBUGINFO == dwSize)\n    {\n        return;\n    }\n\n    pName = _tcsrchr(szFullName, '\\\\');\n    if (pName == NULL)\n    {\n        pName = szFullName;\n    }\n    else\n    {\n        pName++;\n    }\n\n    /* Construct the base key name */\n    (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"SOFTWARE\\\\Debug\\\\%s\"), pName);\n\n    /* Open the key for this module */\n    lReturn = RegOpenKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key\n                           szInfo,             // Address of subkey name\n                           (DWORD)0,           // Reserved value\n                           KEY_QUERY_VALUE,    // Desired security access\n                           &hModuleKey);       // Opened handle buffer\n\n    if (lReturn != ERROR_SUCCESS)\n    {\n        return;\n    }\n\n    dwKeySize = sizeof(DWORD);\n    lReturn = RegQueryValueEx(hModuleKey, // Handle to an open key\n                              TEXT(\"PERFLOG\"),\n                              NULL,                // Reserved field\n                              &dwKeyType,          // Returns the field type\n                              (LPBYTE)&dwKeyValue, // Returns the field's value\n                              &dwKeySize);         // Number of bytes transferred\n\n    if ((lReturn == ERROR_SUCCESS) && (dwKeyType == REG_DWORD))\n    {\n        PerflogModuleLevel = dwKeyValue;\n    }\n\n    RegCloseKey(hModuleKey);\n}\n\nBOOL PerflogInitIfEnabled(IN HINSTANCE hInstance, __in IN PPERFLOG_LOGGING_PARAMS LogParams)\n{\n    PerflogReadModuleLevel(hInstance);\n    if (PerflogModuleLevel)\n    {\n        return PerflogInitialize(LogParams);\n    }\n    else\n    {\n        return FALSE;\n    }\n}\n\nBOOL PerflogInitialize(__in IN PPERFLOG_LOGGING_PARAMS LogParams)\n{\n    ULONG status;\n\n    //\n    // If we're running on a recent-enough platform, this will get\n    // pointers to the event tracing routines.\n    //\n\n    _Advapi32 = GetModuleHandle(_T(\"ADVAPI32.DLL\"));\n    if (_Advapi32 == NULL)\n    {\n        return FALSE;\n    }\n\n    *((FARPROC *)&_RegisterTraceGuids) = GetProcAddress(_Advapi32, REGISTERTRACEGUIDS_NAME);\n    *((FARPROC *)&_UnregisterTraceGuids) = GetProcAddress(_Advapi32, \"UnregisterTraceGuids\");\n    *((FARPROC *)&_GetTraceLoggerHandle) = GetProcAddress(_Advapi32, \"GetTraceLoggerHandle\");\n    *((FARPROC *)&_GetTraceEnableLevel) = GetProcAddress(_Advapi32, \"GetTraceEnableLevel\");\n    *((FARPROC *)&_GetTraceEnableFlags) = GetProcAddress(_Advapi32, \"GetTraceEnableFlags\");\n    *((FARPROC *)&_TraceEvent) = GetProcAddress(_Advapi32, \"TraceEvent\");\n\n    if (_RegisterTraceGuids == NULL || _UnregisterTraceGuids == NULL || _GetTraceEnableLevel == NULL ||\n        _GetTraceEnableFlags == NULL || _TraceEvent == NULL)\n    {\n\n        return FALSE;\n    }\n\n    EventTracingAvailable = TRUE;\n\n    OnStateChanged = LogParams->OnStateChanged;\n\n    //\n    // Register our GUIDs.\n    //\n\n    status = _RegisterTraceGuids(PerflogCallback, LogParams, &LogParams->ControlGuid, LogParams->NumberOfTraceGuids,\n                                 LogParams->TraceGuids, NULL, NULL, &PerflogRegHandle);\n\n    return (status == ERROR_SUCCESS);\n}\n\n//\n// This routine shuts down performance logging.\n//\n\nVOID PerflogShutdown(VOID)\n{\n    if (!EventTracingAvailable)\n    {\n        return;\n    }\n\n    _UnregisterTraceGuids(PerflogRegHandle);\n    PerflogRegHandle = NULL;\n    PerflogTraceHandle = NULL;\n}\n\n//\n// Event tracing callback routine.\n// It's called when controllers call event tracing control functions.\n//\n\nULONG\nWINAPI\nPerflogCallback(WMIDPREQUESTCODE RequestCode, __in PVOID Context, __out ULONG *BufferSize, __in PVOID Buffer)\n{\n    ULONG status;\n\n    UNREFERENCED_PARAMETER(Context);\n\n    ASSERT(EventTracingAvailable);\n\n    status = ERROR_SUCCESS;\n\n    switch (RequestCode)\n    {\n\n    case WMI_ENABLE_EVENTS:\n        PerflogTraceHandle = _GetTraceLoggerHandle(Buffer);\n        PerflogEnableFlags = _GetTraceEnableFlags(PerflogTraceHandle);\n        PerflogEnableLevel = _GetTraceEnableLevel(PerflogTraceHandle);\n        break;\n\n    case WMI_DISABLE_EVENTS:\n        PerflogTraceHandle = NULL;\n        PerflogEnableFlags = 0;\n        PerflogEnableLevel = 0;\n        break;\n\n    default: status = ERROR_INVALID_PARAMETER;\n    }\n\n    if (OnStateChanged != NULL)\n    {\n        OnStateChanged();\n    }\n\n    *BufferSize = 0;\n    return status;\n}\n\n//\n// Logging routine.\n//\n\nVOID PerflogTraceEvent(__in PEVENT_TRACE_HEADER Event)\n{\n    if (!EventTracingAvailable)\n    {\n        return;\n    }\n\n    _TraceEvent(PerflogTraceHandle, Event);\n}\n\nVOID PerflogTraceEventLevel(ULONG Level, __in PEVENT_TRACE_HEADER Event)\n{\n    if ((!EventTracingAvailable) || (Level <= PerflogModuleLevel))\n    {\n        return;\n    }\n\n    _TraceEvent(PerflogTraceHandle, Event);\n}\n"
  },
  {
    "path": "common/baseclasses/perflog.h",
    "content": "//------------------------------------------------------------------------------\n// File: perflog.h\n//\n// Desc: Performance logging framework.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\ntypedef struct _PERFLOG_LOGGING_PARAMS\n{\n    GUID ControlGuid;\n    void (*OnStateChanged)(void);\n    ULONG NumberOfTraceGuids;\n    TRACE_GUID_REGISTRATION TraceGuids[ANYSIZE_ARRAY];\n} PERFLOG_LOGGING_PARAMS, *PPERFLOG_LOGGING_PARAMS;\n\nBOOL PerflogInitIfEnabled(IN HINSTANCE hInstance, __in PPERFLOG_LOGGING_PARAMS LogParams);\n\nBOOL PerflogInitialize(__in PPERFLOG_LOGGING_PARAMS LogParams);\n\nVOID PerflogShutdown(VOID);\n\nVOID PerflogTraceEvent(__in PEVENT_TRACE_HEADER Event);\n\nextern ULONG PerflogEnableFlags;\nextern UCHAR PerflogEnableLevel;\nextern ULONG PerflogModuleLevel;\nextern TRACEHANDLE PerflogTraceHandle;\nextern TRACEHANDLE PerflogRegHandle;\n\n#define PerflogTracingEnabled() (PerflogTraceHandle != 0)\n\n#define PerflogEvent(_x_) PerflogTraceEventLevel _x_\n\nVOID PerflogTraceEventLevel(ULONG Level, __in PEVENT_TRACE_HEADER Event);\n\nVOID PerflogTraceEvent(__in PEVENT_TRACE_HEADER Event);\n"
  },
  {
    "path": "common/baseclasses/perfstruct.h",
    "content": "//------------------------------------------------------------------------------\n// File: PerfStruct.h\n//\n// Desc: Structures for DirectShow performance logging.\n//\n// Copyright (c) 2000-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef _PERFSTRUCT_H_\n#define _PERFSTRUCT_H_\n\n#include <wmistr.h>\n#include <evntrace.h>\n\n// {28CF047A-2437-4b24-B653-B9446A419A69}\nDEFINE_GUID(GUID_DSHOW_CTL, 0x28cf047a, 0x2437, 0x4b24, 0xb6, 0x53, 0xb9, 0x44, 0x6a, 0x41, 0x9a, 0x69);\n\n// {D0DA7AD6-AE80-4de5-AAFC-C126711E7593}\nDEFINE_GUID(GUID_VIDEOREND, 0xd0da7ad6, 0xae80, 0x4de5, 0xaa, 0xfc, 0xc1, 0x26, 0x71, 0x1e, 0x75, 0x93);\n\n// {DC70AC3E-93E5-48db-88AB-E42064EC276A}\nDEFINE_GUID(GUID_DSOUNDGLITCH, 0xdc70ac3e, 0x93e5, 0x48db, 0x88, 0xab, 0xe4, 0x20, 0x64, 0xec, 0x27, 0x6a);\n\n// {3d7e7d93-2fc8-4a07-a719-e0922ff2899}\nDEFINE_GUID(GUID_STREAMTRACE, 0x3d7e7d93, 0x2fc8, 0x4a07, 0xa7, 0x19, 0xe0, 0x92, 0x2f, 0xf2, 0x89, 0x9e);\n\n// AZFIX: the following GUIDs aren't useful right now.\n\n// {3C33F7F5-EE54-493c-BA25-1656539C05AC}\nDEFINE_GUID(GUID_GETTIME, 0x3c33f7f5, 0xee54, 0x493c, 0xba, 0x25, 0x16, 0x56, 0x53, 0x9c, 0x5, 0xac);\n\n// {CC44B44D-8169-4952-9E4A-A4E13295E492}\nDEFINE_GUID(GUID_AUDIOREND, 0xcc44b44d, 0x8169, 0x4952, 0x9e, 0x4a, 0xa4, 0xe1, 0x32, 0x95, 0xe4, 0x92);\n\n// {775D19BF-4D8B-4de6-8DC9-66BAC7B310A2}\nDEFINE_GUID(GUID_FRAMEDROP, 0x775d19bf, 0x4d8b, 0x4de6, 0x8d, 0xc9, 0x66, 0xba, 0xc7, 0xb3, 0x10, 0xa2);\n\n// {56D29065-EFBE-42dc-8C29-E325DC9C27D5}\nDEFINE_GUID(GUID_AUDIOBREAK, 0x56d29065, 0xefbe, 0x42dc, 0x8c, 0x29, 0xe3, 0x25, 0xdc, 0x9c, 0x27, 0xd5);\n\n// {E1E6EA87-95A8-497e-BFBA-0295AEBCC707}\nDEFINE_GUID(GUID_AUDIORECV, 0xe1e6ea87, 0x95a8, 0x497e, 0xbf, 0xba, 0x2, 0x95, 0xae, 0xbc, 0xc7, 0x7);\n\n// {10F7768A-B1E7-4242-AD90-A2D44683D9F0}\nDEFINE_GUID(GUID_AUDIOSLAVE, 0x10f7768a, 0xb1e7, 0x4242, 0xad, 0x90, 0xa2, 0xd4, 0x46, 0x83, 0xd9, 0xf0);\n\n// {8983803D-691A-49bc-8FF6-962A39C0198F}\nDEFINE_GUID(GUID_AUDIOADDBREAK, 0x8983803d, 0x691a, 0x49bc, 0x8f, 0xf6, 0x96, 0x2a, 0x39, 0xc0, 0x19, 0x8f);\n\n#define GLITCHTYPE_DSOUNDFIRSTGOOD 0\n#define GLITCHTYPE_DSOUNDFIRSTBAD 1\n\ntypedef struct PERFINFO_DSHOW_AUDIOGLITCH\n{\n    ULONGLONG cycleCounter;\n    DWORD glitchType;\n    LONGLONG sampleTime;\n    LONGLONG previousTime;\n    ULONG_PTR instanceId;\n} PERFINFO_DSHOW_AUDIOGLITCH, *PPERFINFO_DSHOW_AUDIOGLITCH;\n\ntypedef struct PERFINFO_WMI_AUDIOGLITCH\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_AUDIOGLITCH data;\n} PERFINFO_WMI_AUDIO_GLITCH, *PPERFINFO_WMI_AUDIOGLITCH;\n\ntypedef struct PERFINFO_DSHOW_GETTIME\n{\n    ULONGLONG cycleCounter;\n    ULONGLONG dshowClock;\n} PERFINFO_DSHOW_GETTIME, *PPERFINFO_DSHOW_GETTIME;\n\ntypedef struct PERFINFO_WMI_GETTIME\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_GETTIME data;\n} PERFINFO_WMI_GETTIME, *PPERFINFO_WMI_GETTIME;\n\ntypedef struct PERFINFO_DSHOW_AVREND\n{\n    ULONGLONG cycleCounter;\n    ULONGLONG dshowClock;\n    ULONGLONG sampleTime;\n} PERFINFO_DSHOW_AVREND, *PPERFINFO_DSHOW_AVREND;\n\ntypedef struct PERFINFO_WMI_AVREND\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_AVREND data;\n} PERFINFO_WMI_AVREND, *PPERFINFO_WMI_AVREND;\n\ntypedef struct PERFINFO_DSHOW_AUDIOBREAK\n{\n    ULONGLONG cycleCounter;\n    ULONGLONG dshowClock;\n    ULONGLONG sampleTime;\n    ULONGLONG sampleDuration;\n} PERFINFO_DSHOW_AUDIOBREAK, *PPERFINFO_DSHOW_AUDIOBREAK;\n\ntypedef struct PERFINFO_WMI_AUDIOBREAK\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_AUDIOBREAK data;\n} PERFINFO_WMI_AUDIOBREAK, *PPERFINFO_WMI_AUDIOBREAK;\n\ntypedef struct PERFINFO_DSHOW_FRAMEDROP\n{\n    ULONGLONG cycleCounter;\n    ULONGLONG dshowClock;\n    ULONGLONG frameTime;\n} PERFINFO_DSHOW_FRAMEDROP, *PPERFINFO_DSHOW_FRAMEDROP;\n\ntypedef struct PERFINFO_WMI_FRAMEDROP\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_FRAMEDROP data;\n} PERFINFO_WMI_FRAMEDROP, *PPERFINFO_WMI_FRAMEDROP;\n\n#define PERFINFO_STREAMTRACE_MPEG2DEMUX_PTS_TRANSLATION 1\n#define PERFINFO_STREAMTRACE_MPEG2DEMUX_SAMPLE_RECEIVED 2\n#define PERFINFO_STREAMTRACE_VMR_BEGIN_ADVISE 3\n#define PERFINFO_STREAMTRACE_VMR_END_ADVISE 4\n#define PERFINFO_STREAMTRACE_VMR_RECEIVE 5\n#define PERFINFO_STREAMTRACE_VMR_BEGIN_DEINTERLACE 6\n#define PERFINFO_STREAMTRACE_VMR_END_DEINTERLACE 7\n#define PERFINFO_STREAMTRACE_VMR_BEGIN_DECODE 8\n#define PERFINFO_STREAMTRACE_VMR_END_DECODE 9\n#define PERFINFO_STREAMTRACE_VMR_DROPPED_FRAME 10\n#define PERFINFO_STREAMTRACE_ENCDEC_DTFILTERINPUT 11\n#define PERFINFO_STREAMTRACE_ENCDEC_DTFILTEROUTPUT 12\n#define PERFINFO_STREAMTRACE_ENCDEC_ETFILTERINPUT 13\n#define PERFINFO_STREAMTRACE_ENCDEC_ETFILTEROUTPUT 14\n#define PERFINFO_STREAMTRACE_ENCDEC_XDSCODECINPUT 15\n#define PERFINFO_STREAMTRACE_SBE_DVRANALYSISINPUT_RECEIVE 16\n#define PERFINFO_STREAMTRACE_SBE_DVRANALYSISINPUT_DELIVER 17\n#define PERFINFO_STREAMTRACE_SBE_DVRINPUTPIN_RECEIVE 18\n#define PERFINFO_STREAMTRACE_SBE_DVROUTPUTPIN_RECEIVE 19\n#define PERFINFO_STREAMTRACE_VMR_RENDER_TIME 20\n\ntypedef struct _PERFINFO_DSHOW_STREAMTRACE\n{\n    ULONG id;\n    ULONG reserved;\n    ULONGLONG dshowClock;\n    ULONGLONG data[4];\n} PERFINFO_DSHOW_STREAMTRACE, *PPERFINFO_DSHOW_STREAMTRACE;\n\ntypedef struct _PERFINFO_WMI_STREAMTRACE\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_STREAMTRACE data;\n} PERFINFO_WMI_STREAMTRACE, *PPERFINFO_WMI_STREAMTRACE;\n\ntypedef struct PERFINFO_DSHOW_AUDIORECV\n{\n    LONGLONG streamTime;\n    LONGLONG sampleStart;\n    LONGLONG sampleStop;\n    LONGLONG hwduration;\n    BOOL discontinuity;\n} PERFINFO_DSHOW_AUDIORECV, *PPERFINFO_DSHOW_AUDIORECV;\n\ntypedef struct PERFINFO_WMI_AUDIORECV\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_AUDIORECV data;\n} PERFINFO_WMI_AUDIORECV, *PPERFINFO_WMI_AUDIORECV;\n\ntypedef struct PERFINFO_DSHOW_AUDIOSLAVE\n{\n    LONGLONG masterClock;\n    LONGLONG slaveClock;\n    LONGLONG errorAccum;\n    LONGLONG lastHighErrorSeen;\n    LONGLONG lastLowErrorSeen;\n} PERFINFO_DSHOW_AUDIOSLAVE, *PPERFINFO_DSHOW_AUDIOSLAVE;\n\ntypedef struct PERFINFO_WMI_AUDIOSLAVE\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_AUDIOSLAVE data;\n} PERFINFO_WMI_AUDIOSLAVE, *PPERFINFO_WMI_AUDIOSLAVE;\n\ntypedef struct PERFINFO_DSHOW_AUDIOADDBREAK\n{\n    DWORD iterNextWrite;\n    DWORD offsetNextWrite;\n    DWORD iterWrite;\n    DWORD offsetWrite;\n} PERFINFO_DSHOW_AUDIOADDBREAK, *PPERFINFO_DSHOW_AUDIOADDBREAK;\n\ntypedef struct PERFINFO_WMI_AUDIOADDBREAK\n{\n    EVENT_TRACE_HEADER header;\n    PERFINFO_DSHOW_AUDIOADDBREAK data;\n} PERFINFO_WMI_AUDIOADDBREAK, *PPERFINFO_WMI_AUDIOADDBREAK;\n\n#endif // _PREFSTRUCT_H_\n"
  },
  {
    "path": "common/baseclasses/pstream.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: PStream.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <strsafe.h>\n\n#ifdef PERF\n#include <measure.h>\n#endif\n// #include \"pstream.h\"  in streams.h\n\n//\n// Constructor\n//\nCPersistStream::CPersistStream(IUnknown *punk, __inout HRESULT *phr)\n    : mPS_fDirty(FALSE)\n{\n    mPS_dwFileVersion = GetSoftwareVersion();\n}\n\n//\n// Destructor\n//\nCPersistStream::~CPersistStream()\n{\n    // Nothing to do\n}\n\n#if 0\nSAMPLE CODE TO COPY - not active at the moment\n\n//\n// NonDelegatingQueryInterface\n//\n// This object supports IPersist & IPersistStream\nSTDMETHODIMP CPersistStream::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_IPersist) {\n        return GetInterface((IPersist *) this, ppv);      // ???\n    }\n    else if (riid == IID_IPersistStream) {\n        return GetInterface((IPersistStream *) this, ppv);\n    }\n    else {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n#endif\n\n//\n// WriteToStream\n//\n// Writes to the stream (default action is to write nothing)\nHRESULT CPersistStream::WriteToStream(IStream *pStream)\n{\n    // You can override this to do things like\n    // hr = pStream->Write(MyStructure, sizeof(MyStructure), NULL);\n\n    return NOERROR;\n}\n\nHRESULT CPersistStream::ReadFromStream(IStream *pStream)\n{\n    // You can override this to do things like\n    // hr = pStream->Read(MyStructure, sizeof(MyStructure), NULL);\n\n    return NOERROR;\n}\n\n//\n// Load\n//\n// Load all the data from the given stream\nSTDMETHODIMP CPersistStream::Load(LPSTREAM pStm)\n{\n    HRESULT hr;\n    // Load the version number then the data\n    mPS_dwFileVersion = ReadInt(pStm, hr);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return ReadFromStream(pStm);\n} // Load\n\n//\n// Save\n//\n// Save the contents of this Stream.\nSTDMETHODIMP CPersistStream::Save(LPSTREAM pStm, BOOL fClearDirty)\n{\n\n    HRESULT hr = WriteInt(pStm, GetSoftwareVersion());\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    hr = WriteToStream(pStm);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    mPS_fDirty = !fClearDirty;\n\n    return hr;\n} // Save\n\n// WriteInt\n//\n// Writes an integer to an IStream as 11 UNICODE characters followed by one space.\n// You could use this for shorts or unsigneds or anything (up to 32 bits)\n// where the value isn't actually truncated by squeezing it into 32 bits.\n// Values such as (unsigned) 0x80000000 would come out as -2147483648\n// but would then load as 0x80000000 through ReadInt.  Cast as you please.\n\nSTDAPI WriteInt(IStream *pIStream, int n)\n{\n    WCHAR Buff[13]; // Allows for trailing null that we don't write\n    (void)StringCchPrintfW(Buff, NUMELMS(Buff), L\"%011d \", n);\n    return pIStream->Write(&(Buff[0]), 12 * sizeof(WCHAR), NULL);\n} // WriteInt\n\n// ReadInt\n//\n// Reads an integer from an IStream.\n// Read as 4 bytes.  You could use this for shorts or unsigneds or anything\n// where the value isn't actually truncated by squeezing it into 32 bits\n// Striped down subset of what sscanf can do (without dragging in the C runtime)\n\nSTDAPI_(int) ReadInt(IStream *pIStream, __out HRESULT &hr)\n{\n\n    int Sign = 1;\n    unsigned int n = 0; // result wil be n*Sign\n    WCHAR wch;\n\n    hr = pIStream->Read(&wch, sizeof(wch), NULL);\n    if (FAILED(hr))\n    {\n        return 0;\n    }\n\n    if (wch == L'-')\n    {\n        Sign = -1;\n        hr = pIStream->Read(&wch, sizeof(wch), NULL);\n        if (FAILED(hr))\n        {\n            return 0;\n        }\n    }\n\n    for (;;)\n    {\n        if (wch >= L'0' && wch <= L'9')\n        {\n            n = 10 * n + (int)(wch - L'0');\n        }\n        else if (wch == L' ' || wch == L'\\t' || wch == L'\\r' || wch == L'\\n' || wch == L'\\0')\n        {\n            break;\n        }\n        else\n        {\n            hr = VFW_E_INVALID_FILE_FORMAT;\n            return 0;\n        }\n\n        hr = pIStream->Read(&wch, sizeof(wch), NULL);\n        if (FAILED(hr))\n        {\n            return 0;\n        }\n    }\n\n    if (n == 0x80000000 && Sign == -1)\n    {\n        // This is the negative number that has no positive version!\n        return (int)n;\n    }\n    else\n        return (int)n * Sign;\n} // ReadInt\n\n// The microsoft C/C++ compile generates level 4 warnings to the effect that\n// a particular inline function (from some base class) was not needed.\n// This line gets rid of hundreds of such unwanted messages and makes\n// -W4 compilation feasible:\n#pragma warning(disable : 4514)\n"
  },
  {
    "path": "common/baseclasses/pstream.h",
    "content": "//------------------------------------------------------------------------------\n// File: PStream.h\n//\n// Desc: DirectShow base classes - defines a class for persistent properties\n//       of filters.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __PSTREAM__\n#define __PSTREAM__\n\n// Base class for persistent properties of filters\n// (i.e. filter properties in saved graphs)\n\n// The simplest way to use this is:\n// 1. Arrange for your filter to inherit this class\n// 2. Implement in your class WriteToStream and ReadFromStream\n//    These will override the \"do nothing\" functions here.\n// 3. Change your NonDelegatingQueryInterface to handle IPersistStream\n// 4. Implement SizeMax to return the number of bytes of data you save.\n//    If you save UNICODE data, don't forget a char is 2 bytes.\n// 5. Whenever your data changes, call SetDirty()\n//\n// At some point you may decide to alter, or extend the format of your data.\n// At that point you will wish that you had a version number in all the old\n// saved graphs, so that you can tell, when you read them, whether they\n// represent the old or new form.  To assist you in this, this class\n// writes and reads a version number.\n// When it writes, it calls GetSoftwareVersion()  to enquire what version\n// of the software we have at the moment.  (In effect this is a version number\n// of the data layout in the file).  It writes this as the first thing in the data.\n// If you want to change the version, implement (override) GetSoftwareVersion().\n// It reads this from the file into mPS_dwFileVersion before calling ReadFromStream,\n// so in ReadFromStream you can check mPS_dwFileVersion to see if you are reading\n// an old version file.\n// Normally you should accept files whose version is no newer than the software\n// version that's reading them.\n\n// CPersistStream\n//\n// Implements IPersistStream.\n// See 'OLE Programmers Reference (Vol 1):Structured Storage Overview' for\n// more implementation information.\nclass CPersistStream : public IPersistStream\n{\n  private:\n    // Internal state:\n\n  protected:\n    DWORD mPS_dwFileVersion; // version number of file (being read)\n    BOOL mPS_fDirty;\n\n  public:\n    // IPersistStream methods\n\n    STDMETHODIMP IsDirty() { return (mPS_fDirty ? S_OK : S_FALSE); } // note FALSE means clean\n    STDMETHODIMP Load(LPSTREAM pStm);\n    STDMETHODIMP Save(LPSTREAM pStm, BOOL fClearDirty);\n    STDMETHODIMP GetSizeMax(__out ULARGE_INTEGER *pcbSize)\n    // Allow 24 bytes for version.\n    {\n        pcbSize->QuadPart = 12 * sizeof(WCHAR) + SizeMax();\n        return NOERROR;\n    }\n\n    // implementation\n\n    CPersistStream(IUnknown *punk, __inout HRESULT *phr);\n    ~CPersistStream();\n\n    HRESULT SetDirty(BOOL fDirty)\n    {\n        mPS_fDirty = fDirty;\n        return NOERROR;\n    }\n\n    // override to reveal IPersist & IPersistStream\n    // STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // --- IPersist ---\n\n    // You must override this to provide your own class id\n    STDMETHODIMP GetClassID(__out CLSID *pClsid) PURE;\n\n    // overrideable if you want\n    // file version number.  Override it if you ever change format\n    virtual DWORD GetSoftwareVersion(void) { return 0; }\n\n    //=========================================================================\n    // OVERRIDE THESE to read and write your data\n    // OVERRIDE THESE to read and write your data\n    // OVERRIDE THESE to read and write your data\n\n    virtual int SizeMax() { return 0; }\n    virtual HRESULT WriteToStream(IStream *pStream);\n    virtual HRESULT ReadFromStream(IStream *pStream);\n    //=========================================================================\n\n  private:\n};\n\n// --- Useful helpers ---\n\n// Writes an int to an IStream as UNICODE.\nSTDAPI WriteInt(IStream *pIStream, int n);\n\n// inverse of WriteInt\nSTDAPI_(int) ReadInt(IStream *pIStream, __out HRESULT &hr);\n\n#endif // __PSTREAM__\n"
  },
  {
    "path": "common/baseclasses/pullpin.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: PullPin.cpp\n//\n// Desc: DirectShow base classes - implements CPullPin class that pulls data\n//       from IAsyncReader.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include \"pullpin.h\"\n\n#ifdef DXMPERF\n#include \"dxmperf.h\"\n#endif // DXMPERF\n\nCPullPin::CPullPin()\n    : m_pReader(NULL)\n    , m_pAlloc(NULL)\n    , m_State(TM_Exit)\n{\n#ifdef DXMPERF\n    PERFLOG_CTOR(L\"CPullPin\", this);\n#endif // DXMPERF\n}\n\nCPullPin::~CPullPin()\n{\n    Disconnect();\n\n#ifdef DXMPERF\n    PERFLOG_DTOR(L\"CPullPin\", this);\n#endif // DXMPERF\n}\n\n// returns S_OK if successfully connected to an IAsyncReader interface\n// from this object\n// Optional allocator should be proposed as a preferred allocator if\n// necessary\nHRESULT\nCPullPin::Connect(IUnknown *pUnk, IMemAllocator *pAlloc, BOOL bSync)\n{\n    CAutoLock lock(&m_AccessLock);\n\n    if (m_pReader)\n    {\n        return VFW_E_ALREADY_CONNECTED;\n    }\n\n    HRESULT hr = pUnk->QueryInterface(IID_IAsyncReader, (void **)&m_pReader);\n    if (FAILED(hr))\n    {\n\n#ifdef DXMPERF\n        {\n            AM_MEDIA_TYPE *pmt = NULL;\n            PERFLOG_CONNECT(this, pUnk, hr, pmt);\n        }\n#endif // DXMPERF\n\n        return (hr);\n    }\n\n    hr = DecideAllocator(pAlloc, NULL);\n    if (FAILED(hr))\n    {\n        Disconnect();\n\n#ifdef DXMPERF\n        {\n            AM_MEDIA_TYPE *pmt = NULL;\n            PERFLOG_CONNECT(this, pUnk, hr, pmt);\n        }\n#endif // DXMPERF\n\n        return hr;\n    }\n\n    LONGLONG llTotal, llAvail;\n    hr = m_pReader->Length(&llTotal, &llAvail);\n    if (FAILED(hr))\n    {\n        Disconnect();\n\n#ifdef DXMPERF\n        {\n            AM_MEDIA_TYPE *pmt = NULL;\n            PERFLOG_CONNECT(this, pUnk, hr, pmt);\n        }\n#endif\n\n        return hr;\n    }\n\n    // convert from file position to reference time\n    m_tDuration = llTotal * UNITS;\n    m_tStop = m_tDuration;\n    m_tStart = 0;\n\n    m_bSync = bSync;\n\n#ifdef DXMPERF\n    {\n        AM_MEDIA_TYPE *pmt = NULL;\n        PERFLOG_CONNECT(this, pUnk, S_OK, pmt);\n    }\n#endif // DXMPERF\n\n    return S_OK;\n}\n\n// disconnect any connection made in Connect\nHRESULT\nCPullPin::Disconnect()\n{\n    CAutoLock lock(&m_AccessLock);\n\n    StopThread();\n\n#ifdef DXMPERF\n    PERFLOG_DISCONNECT(this, m_pReader, S_OK);\n#endif // DXMPERF\n\n    if (m_pReader)\n    {\n        m_pReader->Release();\n        m_pReader = NULL;\n    }\n\n    if (m_pAlloc)\n    {\n        m_pAlloc->Release();\n        m_pAlloc = NULL;\n    }\n\n    return S_OK;\n}\n\n// agree an allocator using RequestAllocator - optional\n// props param specifies your requirements (non-zero fields).\n// returns an error code if fail to match requirements.\n// optional IMemAllocator interface is offered as a preferred allocator\n// but no error occurs if it can't be met.\nHRESULT\nCPullPin::DecideAllocator(IMemAllocator *pAlloc, __inout_opt ALLOCATOR_PROPERTIES *pProps)\n{\n    ALLOCATOR_PROPERTIES *pRequest;\n    ALLOCATOR_PROPERTIES Request;\n    if (pProps == NULL)\n    {\n        Request.cBuffers = 3;\n        Request.cbBuffer = 64 * 1024;\n        Request.cbAlign = 0;\n        Request.cbPrefix = 0;\n        pRequest = &Request;\n    }\n    else\n    {\n        pRequest = pProps;\n    }\n    HRESULT hr = m_pReader->RequestAllocator(pAlloc, pRequest, &m_pAlloc);\n    return hr;\n}\n\n// start pulling data\nHRESULT\nCPullPin::Active(void)\n{\n    ASSERT(!ThreadExists());\n    return StartThread();\n}\n\n// stop pulling data\nHRESULT\nCPullPin::Inactive(void)\n{\n    StopThread();\n\n    return S_OK;\n}\n\nHRESULT\nCPullPin::Seek(REFERENCE_TIME tStart, REFERENCE_TIME tStop)\n{\n    CAutoLock lock(&m_AccessLock);\n\n    ThreadMsg AtStart = m_State;\n\n    if (AtStart == TM_Start)\n    {\n        BeginFlush();\n        PauseThread();\n        EndFlush();\n    }\n\n    m_tStart = tStart;\n    m_tStop = tStop;\n\n    HRESULT hr = S_OK;\n    if (AtStart == TM_Start)\n    {\n        hr = StartThread();\n    }\n\n    return hr;\n}\n\nHRESULT\nCPullPin::Duration(__out REFERENCE_TIME *ptDuration)\n{\n    *ptDuration = m_tDuration;\n    return S_OK;\n}\n\nHRESULT\nCPullPin::StartThread()\n{\n    CAutoLock lock(&m_AccessLock);\n\n    if (!m_pAlloc || !m_pReader)\n    {\n        return E_UNEXPECTED;\n    }\n\n    HRESULT hr;\n    if (!ThreadExists())\n    {\n\n        // commit allocator\n        hr = m_pAlloc->Commit();\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        // start thread\n        if (!Create())\n        {\n            return E_FAIL;\n        }\n    }\n\n    m_State = TM_Start;\n    hr = (HRESULT)CallWorker(m_State);\n    return hr;\n}\n\nHRESULT\nCPullPin::PauseThread()\n{\n    CAutoLock lock(&m_AccessLock);\n\n    if (!ThreadExists())\n    {\n        return E_UNEXPECTED;\n    }\n\n    // need to flush to ensure the thread is not blocked\n    // in WaitForNext\n    HRESULT hr = m_pReader->BeginFlush();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    m_State = TM_Pause;\n    hr = CallWorker(TM_Pause);\n\n    m_pReader->EndFlush();\n    return hr;\n}\n\nHRESULT\nCPullPin::StopThread()\n{\n    CAutoLock lock(&m_AccessLock);\n\n    if (!ThreadExists())\n    {\n        return S_FALSE;\n    }\n\n    // need to flush to ensure the thread is not blocked\n    // in WaitForNext\n    HRESULT hr = m_pReader->BeginFlush();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    m_State = TM_Exit;\n    hr = CallWorker(TM_Exit);\n\n    m_pReader->EndFlush();\n\n    // wait for thread to completely exit\n    Close();\n\n    // decommit allocator\n    if (m_pAlloc)\n    {\n        m_pAlloc->Decommit();\n    }\n\n    return S_OK;\n}\n\nDWORD\nCPullPin::ThreadProc(void)\n{\n    while (1)\n    {\n        DWORD cmd = GetRequest();\n        switch (cmd)\n        {\n        case TM_Exit: Reply(S_OK); return 0;\n\n        case TM_Pause:\n            // we are paused already\n            Reply(S_OK);\n            break;\n\n        case TM_Start:\n            Reply(S_OK);\n            Process();\n            break;\n        }\n\n        // at this point, there should be no outstanding requests on the\n        // upstream filter.\n        // We should force begin/endflush to ensure that this is true.\n        // !!!Note that we may currently be inside a BeginFlush/EndFlush pair\n        // on another thread, but the premature EndFlush will do no harm now\n        // that we are idle.\n        m_pReader->BeginFlush();\n        CleanupCancelled();\n        m_pReader->EndFlush();\n    }\n}\n\nHRESULT\nCPullPin::QueueSample(__inout REFERENCE_TIME &tCurrent, REFERENCE_TIME tAlignStop, BOOL bDiscontinuity)\n{\n    IMediaSample *pSample;\n\n    HRESULT hr = m_pAlloc->GetBuffer(&pSample, NULL, NULL, 0);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    LONGLONG tStopThis = tCurrent + (pSample->GetSize() * UNITS);\n    if (tStopThis > tAlignStop)\n    {\n        tStopThis = tAlignStop;\n    }\n    pSample->SetTime(&tCurrent, &tStopThis);\n    tCurrent = tStopThis;\n\n    pSample->SetDiscontinuity(bDiscontinuity);\n\n    hr = m_pReader->Request(pSample, 0);\n    if (FAILED(hr))\n    {\n        pSample->Release();\n\n        CleanupCancelled();\n        OnError(hr);\n    }\n    return hr;\n}\n\nHRESULT\nCPullPin::CollectAndDeliver(REFERENCE_TIME tStart, REFERENCE_TIME tStop)\n{\n    IMediaSample *pSample = NULL; // better be sure pSample is set\n    DWORD_PTR dwUnused;\n    HRESULT hr = m_pReader->WaitForNext(INFINITE, &pSample, &dwUnused);\n    if (FAILED(hr))\n    {\n        if (pSample)\n        {\n            pSample->Release();\n        }\n    }\n    else\n    {\n        hr = DeliverSample(pSample, tStart, tStop);\n    }\n    if (FAILED(hr))\n    {\n        CleanupCancelled();\n        OnError(hr);\n    }\n    return hr;\n}\n\nHRESULT\nCPullPin::DeliverSample(IMediaSample *pSample, REFERENCE_TIME tStart, REFERENCE_TIME tStop)\n{\n    // fix up sample if past actual stop (for sector alignment)\n    REFERENCE_TIME t1, t2;\n    if (S_OK == pSample->GetTime(&t1, &t2))\n    {\n        if (t2 > tStop)\n        {\n            t2 = tStop;\n        }\n\n        // adjust times to be relative to (aligned) start time\n        t1 -= tStart;\n        t2 -= tStart;\n        HRESULT hr = pSample->SetTime(&t1, &t2);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n    }\n\n#ifdef DXMPERF\n    {\n        AM_MEDIA_TYPE *pmt = NULL;\n        pSample->GetMediaType(&pmt);\n        PERFLOG_RECEIVE(L\"CPullPin\", m_pReader, this, pSample, pmt);\n    }\n#endif\n\n    HRESULT hr = Receive(pSample);\n    pSample->Release();\n    return hr;\n}\n\nvoid CPullPin::Process(void)\n{\n    // is there anything to do?\n    if (m_tStop <= m_tStart)\n    {\n        EndOfStream();\n        return;\n    }\n\n    BOOL bDiscontinuity = TRUE;\n\n    // if there is more than one sample at the allocator,\n    // then try to queue 2 at once in order to overlap.\n    // -- get buffer count and required alignment\n    ALLOCATOR_PROPERTIES Actual;\n    HRESULT hr = m_pAlloc->GetProperties(&Actual);\n\n    // align the start position downwards\n    REFERENCE_TIME tStart = AlignDown(m_tStart / UNITS, Actual.cbAlign) * UNITS;\n    REFERENCE_TIME tCurrent = tStart;\n\n    REFERENCE_TIME tStop = m_tStop;\n    if (tStop > m_tDuration)\n    {\n        tStop = m_tDuration;\n    }\n\n    // align the stop position - may be past stop, but that\n    // doesn't matter\n    REFERENCE_TIME tAlignStop = AlignUp(tStop / UNITS, Actual.cbAlign) * UNITS;\n\n    DWORD dwRequest;\n\n    if (!m_bSync)\n    {\n\n        //  Break out of the loop either if we get to the end or we're asked\n        //  to do something else\n        while (tCurrent < tAlignStop)\n        {\n\n            // Break out without calling EndOfStream if we're asked to\n            // do something different\n            if (CheckRequest(&dwRequest))\n            {\n                return;\n            }\n\n            // queue a first sample\n            if (Actual.cBuffers > 1)\n            {\n\n                hr = QueueSample(tCurrent, tAlignStop, TRUE);\n                bDiscontinuity = FALSE;\n\n                if (FAILED(hr))\n                {\n                    return;\n                }\n            }\n\n            // loop queueing second and waiting for first..\n            while (tCurrent < tAlignStop)\n            {\n\n                hr = QueueSample(tCurrent, tAlignStop, bDiscontinuity);\n                bDiscontinuity = FALSE;\n\n                if (FAILED(hr))\n                {\n                    return;\n                }\n\n                hr = CollectAndDeliver(tStart, tStop);\n                if (S_OK != hr)\n                {\n\n                    // stop if error, or if downstream filter said\n                    // to stop.\n                    return;\n                }\n            }\n\n            if (Actual.cBuffers > 1)\n            {\n                hr = CollectAndDeliver(tStart, tStop);\n                if (FAILED(hr))\n                {\n                    return;\n                }\n            }\n        }\n    }\n    else\n    {\n\n        // sync version of above loop\n        while (tCurrent < tAlignStop)\n        {\n\n            // Break out without calling EndOfStream if we're asked to\n            // do something different\n            if (CheckRequest(&dwRequest))\n            {\n                return;\n            }\n\n            IMediaSample *pSample;\n\n            hr = m_pAlloc->GetBuffer(&pSample, NULL, NULL, 0);\n            if (FAILED(hr))\n            {\n                OnError(hr);\n                return;\n            }\n\n            LONGLONG tStopThis = tCurrent + (pSample->GetSize() * UNITS);\n            if (tStopThis > tAlignStop)\n            {\n                tStopThis = tAlignStop;\n            }\n            pSample->SetTime(&tCurrent, &tStopThis);\n            tCurrent = tStopThis;\n\n            if (bDiscontinuity)\n            {\n                pSample->SetDiscontinuity(TRUE);\n                bDiscontinuity = FALSE;\n            }\n\n            hr = m_pReader->SyncReadAligned(pSample);\n\n            if (FAILED(hr))\n            {\n                pSample->Release();\n                OnError(hr);\n                return;\n            }\n\n            hr = DeliverSample(pSample, tStart, tStop);\n            if (hr != S_OK)\n            {\n                if (FAILED(hr))\n                {\n                    OnError(hr);\n                }\n                return;\n            }\n        }\n    }\n\n    EndOfStream();\n}\n\n// after a flush, cancelled i/o will be waiting for collection\n// and release\nvoid CPullPin::CleanupCancelled(void)\n{\n    while (1)\n    {\n        IMediaSample *pSample;\n        DWORD_PTR dwUnused;\n\n        HRESULT hr = m_pReader->WaitForNext(0, // no wait\n                                            &pSample, &dwUnused);\n        if (pSample)\n        {\n            pSample->Release();\n        }\n        else\n        {\n            // no more samples\n            return;\n        }\n    }\n}\n"
  },
  {
    "path": "common/baseclasses/pullpin.h",
    "content": "//------------------------------------------------------------------------------\n// File: PullPin.h\n//\n// Desc: DirectShow base classes - defines CPullPin class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __PULLPIN_H__\n#define __PULLPIN_H__\n\n//\n// CPullPin\n//\n// object supporting pulling data from an IAsyncReader interface.\n// Given a start/stop position, calls a pure Receive method with each\n// IMediaSample received.\n//\n// This is essentially for use in a MemInputPin when it finds itself\n// connected to an IAsyncReader pin instead of a pushing pin.\n//\n\nclass CPullPin : public CAMThread\n{\n    IAsyncReader *m_pReader;\n    REFERENCE_TIME m_tStart;\n    REFERENCE_TIME m_tStop;\n    REFERENCE_TIME m_tDuration;\n    BOOL m_bSync;\n\n    enum ThreadMsg\n    {\n        TM_Pause, // stop pulling and wait for next message\n        TM_Start, // start pulling\n        TM_Exit,  // stop and exit\n    };\n\n    ThreadMsg m_State;\n\n    // override pure thread proc from CAMThread\n    DWORD ThreadProc(void);\n\n    // running pull method (check m_bSync)\n    void Process(void);\n\n    // clean up any cancelled i/o after a flush\n    void CleanupCancelled(void);\n\n    // suspend thread from pulling, eg during seek\n    HRESULT PauseThread();\n\n    // start thread pulling - create thread if necy\n    HRESULT StartThread();\n\n    // stop and close thread\n    HRESULT StopThread();\n\n    // called from ProcessAsync to queue and collect requests\n    HRESULT QueueSample(__inout REFERENCE_TIME &tCurrent, REFERENCE_TIME tAlignStop, BOOL bDiscontinuity);\n\n    HRESULT CollectAndDeliver(REFERENCE_TIME tStart, REFERENCE_TIME tStop);\n\n    HRESULT DeliverSample(IMediaSample *pSample, REFERENCE_TIME tStart, REFERENCE_TIME tStop);\n\n  protected:\n    IMemAllocator *m_pAlloc;\n\n  public:\n    CPullPin();\n    virtual ~CPullPin();\n\n    // returns S_OK if successfully connected to an IAsyncReader interface\n    // from this object\n    // Optional allocator should be proposed as a preferred allocator if\n    // necessary\n    // bSync is TRUE if we are to use sync reads instead of the\n    // async methods.\n    HRESULT Connect(IUnknown *pUnk, IMemAllocator *pAlloc, BOOL bSync);\n\n    // disconnect any connection made in Connect\n    HRESULT Disconnect();\n\n    // agree an allocator using RequestAllocator - optional\n    // props param specifies your requirements (non-zero fields).\n    // returns an error code if fail to match requirements.\n    // optional IMemAllocator interface is offered as a preferred allocator\n    // but no error occurs if it can't be met.\n    virtual HRESULT DecideAllocator(IMemAllocator *pAlloc, __inout_opt ALLOCATOR_PROPERTIES *pProps);\n\n    // set start and stop position. if active, will start immediately at\n    // the new position. Default is 0 to duration\n    HRESULT Seek(REFERENCE_TIME tStart, REFERENCE_TIME tStop);\n\n    // return the total duration\n    HRESULT Duration(__out REFERENCE_TIME *ptDuration);\n\n    // start pulling data\n    HRESULT Active(void);\n\n    // stop pulling data\n    HRESULT Inactive(void);\n\n    // helper functions\n    LONGLONG AlignDown(LONGLONG ll, LONG lAlign)\n    {\n        // aligning downwards is just truncation\n        return ll & ~(lAlign - 1);\n    };\n\n    LONGLONG AlignUp(LONGLONG ll, LONG lAlign)\n    {\n        // align up: round up to next boundary\n        return (ll + (lAlign - 1)) & ~(lAlign - 1);\n    };\n\n    // GetReader returns the (addrefed) IAsyncReader interface\n    // for SyncRead etc\n    IAsyncReader *GetReader()\n    {\n        m_pReader->AddRef();\n        return m_pReader;\n    };\n\n    // -- pure --\n\n    // override this to handle data arrival\n    // return value other than S_OK will stop data\n    virtual HRESULT Receive(IMediaSample *) PURE;\n\n    // override this to handle end-of-stream\n    virtual HRESULT EndOfStream(void) PURE;\n\n    // called on runtime errors that will have caused pulling\n    // to stop\n    // these errors are all returned from the upstream filter, who\n    // will have already reported any errors to the filtergraph.\n    virtual void OnError(HRESULT hr) PURE;\n\n    // flush this pin and all downstream\n    virtual HRESULT BeginFlush() PURE;\n    virtual HRESULT EndFlush() PURE;\n};\n\n#endif //__PULLPIN_H__\n"
  },
  {
    "path": "common/baseclasses/refclock.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: RefClock.cpp\n//\n// Desc: DirectShow base classes - implements the IReferenceClock interface.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <limits.h>\n\n#ifdef DXMPERF\n#include \"dxmperf.h\"\n#endif // DXMPERF\n\n// 'this' used in constructor list\n#pragma warning(disable : 4355)\n\nSTDMETHODIMP CBaseReferenceClock::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    HRESULT hr;\n\n    if (riid == IID_IReferenceClock)\n    {\n        hr = GetInterface((IReferenceClock *)this, ppv);\n    }\n    else if (riid == IID_IReferenceClockTimerControl)\n    {\n        hr = GetInterface((IReferenceClockTimerControl *)this, ppv);\n    }\n    else\n    {\n        hr = CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n    return hr;\n}\n\nCBaseReferenceClock::~CBaseReferenceClock()\n{\n#ifdef DXMPERF\n    PERFLOG_DTOR(L\"CBaseReferenceClock\", (IReferenceClock *)this);\n#endif // DXMPERF\n\n    if (m_TimerResolution)\n        timeEndPeriod(m_TimerResolution);\n\n    if (m_pSchedule)\n    {\n        m_pSchedule->DumpLinkedList();\n    }\n\n    if (m_hThread)\n    {\n        m_bAbort = TRUE;\n        TriggerThread();\n        WaitForSingleObject(m_hThread, INFINITE);\n        EXECUTE_ASSERT(CloseHandle(m_hThread));\n        m_hThread = 0;\n        EXECUTE_ASSERT(CloseHandle(m_pSchedule->GetEvent()));\n        delete m_pSchedule;\n    }\n}\n\n// A derived class may supply a hThreadEvent if it has its own thread that will take care\n// of calling the schedulers Advise method.  (Refere to CBaseReferenceClock::AdviseThread()\n// to see what such a thread has to do.)\nCBaseReferenceClock::CBaseReferenceClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr,\n                                         __inout_opt CAMSchedule *pShed)\n    : CUnknown(pName, pUnk)\n    , m_rtLastGotTime(0)\n    , m_TimerResolution(0)\n    , m_bAbort(FALSE)\n    , m_pSchedule(pShed ? pShed : new CAMSchedule(CreateEvent(NULL, FALSE, FALSE, NULL)))\n    , m_hThread(0)\n{\n\n#ifdef DXMPERF\n    PERFLOG_CTOR(pName ? pName : L\"CBaseReferenceClock\", (IReferenceClock *)this);\n#endif // DXMPERF\n\n    ASSERT(m_pSchedule);\n    if (!m_pSchedule)\n    {\n        *phr = E_OUTOFMEMORY;\n    }\n    else\n    {\n        // Set up the highest resolution timer we can manage\n        TIMECAPS tc;\n        m_TimerResolution = (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc))) ? tc.wPeriodMin : 1;\n\n        timeBeginPeriod(m_TimerResolution);\n\n        /* Initialise our system times - the derived clock should set the right values */\n        m_dwPrevSystemTime = timeGetTime();\n        m_rtPrivateTime = (UNITS / MILLISECONDS) * m_dwPrevSystemTime;\n\n#ifdef PERF\n        m_idGetSystemTime = MSR_REGISTER(TEXT(\"CBaseReferenceClock::GetTime\"));\n#endif\n\n        if (!pShed)\n        {\n            DWORD ThreadID;\n            m_hThread = ::CreateThread(NULL,                 // Security attributes\n                                       (DWORD)0,             // Initial stack size\n                                       AdviseThreadFunction, // Thread start address\n                                       (LPVOID)this,         // Thread parameter\n                                       (DWORD)0,             // Creation flags\n                                       &ThreadID);           // Thread identifier\n\n            if (m_hThread)\n            {\n                SetThreadPriority(m_hThread, THREAD_PRIORITY_TIME_CRITICAL);\n            }\n            else\n            {\n                *phr = E_FAIL;\n                EXECUTE_ASSERT(CloseHandle(m_pSchedule->GetEvent()));\n                delete m_pSchedule;\n                m_pSchedule = NULL;\n            }\n        }\n    }\n}\n\nvoid CBaseReferenceClock::Restart(IN REFERENCE_TIME rtMinTime)\n{\n    Lock();\n    m_rtLastGotTime = rtMinTime;\n    Unlock();\n}\n\nSTDMETHODIMP CBaseReferenceClock::GetTime(__out REFERENCE_TIME *pTime)\n{\n    HRESULT hr;\n    if (pTime)\n    {\n        REFERENCE_TIME rtNow;\n        Lock();\n        rtNow = GetPrivateTime();\n        if (rtNow > m_rtLastGotTime)\n        {\n            m_rtLastGotTime = rtNow;\n            hr = S_OK;\n        }\n        else\n        {\n            hr = S_FALSE;\n        }\n        *pTime = m_rtLastGotTime;\n        Unlock();\n        MSR_INTEGER(m_idGetSystemTime, LONG((*pTime) / (UNITS / MILLISECONDS)));\n\n#ifdef DXMPERF\n        PERFLOG_GETTIME((IReferenceClock *)this, *pTime);\n#endif // DXMPERF\n    }\n    else\n        hr = E_POINTER;\n\n    return hr;\n}\n\n/* Ask for an async notification that a time has elapsed */\n\nSTDMETHODIMP CBaseReferenceClock::AdviseTime(REFERENCE_TIME baseTime,          // base reference time\n                                             REFERENCE_TIME streamTime,        // stream offset time\n                                             HEVENT hEvent,                    // advise via this event\n                                             __out DWORD_PTR *pdwAdviseCookie) // where your cookie goes\n{\n    CheckPointer(pdwAdviseCookie, E_POINTER);\n    *pdwAdviseCookie = 0;\n\n    // Check that the event is not already set\n    ASSERT(WAIT_TIMEOUT == WaitForSingleObject(HANDLE(hEvent), 0));\n\n    HRESULT hr;\n\n    const REFERENCE_TIME lRefTime = baseTime + streamTime;\n    if (lRefTime <= 0 || lRefTime == MAX_TIME)\n    {\n        hr = E_INVALIDARG;\n    }\n    else\n    {\n        *pdwAdviseCookie = m_pSchedule->AddAdvisePacket(lRefTime, 0, HANDLE(hEvent), FALSE);\n        hr = *pdwAdviseCookie ? NOERROR : E_OUTOFMEMORY;\n    }\n    return hr;\n}\n\n/* Ask for an asynchronous periodic notification that a time has elapsed */\n\nSTDMETHODIMP CBaseReferenceClock::AdvisePeriodic(REFERENCE_TIME StartTime,         // starting at this time\n                                                 REFERENCE_TIME PeriodTime,        // time between notifications\n                                                 HSEMAPHORE hSemaphore,            // advise via a semaphore\n                                                 __out DWORD_PTR *pdwAdviseCookie) // where your cookie goes\n{\n    CheckPointer(pdwAdviseCookie, E_POINTER);\n    *pdwAdviseCookie = 0;\n\n    HRESULT hr;\n    if (StartTime > 0 && PeriodTime > 0 && StartTime != MAX_TIME)\n    {\n        *pdwAdviseCookie = m_pSchedule->AddAdvisePacket(StartTime, PeriodTime, HANDLE(hSemaphore), TRUE);\n        hr = *pdwAdviseCookie ? NOERROR : E_OUTOFMEMORY;\n    }\n    else\n        hr = E_INVALIDARG;\n\n    return hr;\n}\n\nSTDMETHODIMP CBaseReferenceClock::Unadvise(DWORD_PTR dwAdviseCookie)\n{\n    return m_pSchedule->Unadvise(dwAdviseCookie);\n}\n\nREFERENCE_TIME CBaseReferenceClock::GetPrivateTime()\n{\n    CAutoLock cObjectLock(this);\n\n    /* If the clock has wrapped then the current time will be less than\n     * the last time we were notified so add on the extra milliseconds\n     *\n     * The time period is long enough so that the likelihood of\n     * successive calls spanning the clock cycle is not considered.\n     */\n\n    DWORD dwTime = timeGetTime();\n    {\n        m_rtPrivateTime += Int32x32To64(UNITS / MILLISECONDS, (DWORD)(dwTime - m_dwPrevSystemTime));\n        m_dwPrevSystemTime = dwTime;\n    }\n\n    return m_rtPrivateTime;\n}\n\n/* Adjust the current time by the input value.  This allows an\n   external time source to work out some of the latency of the clock\n   system and adjust the \"current\" time accordingly.  The intent is\n   that the time returned to the user is synchronised to a clock\n   source and allows drift to be catered for.\n\n   For example: if the clock source detects a drift it can pass a delta\n   to the current time rather than having to set an explicit time.\n*/\n\nSTDMETHODIMP CBaseReferenceClock::SetTimeDelta(const REFERENCE_TIME &TimeDelta)\n{\n#ifdef DEBUG\n\n    // Just break if passed an improper time delta value\n    LONGLONG llDelta = TimeDelta > 0 ? TimeDelta : -TimeDelta;\n    if (llDelta > UNITS * 1000)\n    {\n        DbgLog((LOG_TRACE, 0, TEXT(\"Bad Time Delta\")));\n        // DebugBreak();\n    }\n\n    // We're going to calculate a \"severity\" for the time change. Max -1\n    // min 8.  We'll then use this as the debug logging level for a\n    // debug log message.\n    const LONG usDelta = LONG(TimeDelta / 10); // Delta in micro-secs\n\n    DWORD delta = abs(usDelta); // varying delta\n    // Severity == 8 - ceil(log<base 8>(abs( micro-secs delta)))\n    int Severity = 8;\n    while (delta > 0)\n    {\n        delta >>= 3; // div 8\n        Severity--;\n    }\n\n    // Sev == 0 => > 2 second delta!\n    DbgLog((LOG_TIMING, Severity < 0 ? 0 : Severity,\n            TEXT(\"Sev %2i: CSystemClock::SetTimeDelta(%8ld us) %lu -> %lu ms.\"), Severity, usDelta,\n            DWORD(ConvertToMilliseconds(m_rtPrivateTime)), DWORD(ConvertToMilliseconds(TimeDelta + m_rtPrivateTime))));\n\n// Don't want the DbgBreak to fire when running stress on debug-builds.\n#ifdef BREAK_ON_SEVERE_TIME_DELTA\n    if (Severity < 0)\n        DbgBreakPoint(TEXT(\"SetTimeDelta > 16 seconds!\"), TEXT(__FILE__), __LINE__);\n#endif\n\n#endif\n\n    CAutoLock cObjectLock(this);\n    m_rtPrivateTime += TimeDelta;\n    // If time goes forwards, and we have advises, then we need to\n    // trigger the thread so that it can re-evaluate its wait time.\n    // Since we don't want the cost of the thread switches if the change\n    // is really small, only do it if clock goes forward by more than\n    // 0.5 millisecond.  If the time goes backwards, the thread will\n    // wake up \"early\" (relativly speaking) and will re-evaluate at\n    // that time.\n    if (TimeDelta > 5000 && m_pSchedule->GetAdviseCount() > 0)\n        TriggerThread();\n    return NOERROR;\n}\n\n// Thread stuff\n\nDWORD __stdcall CBaseReferenceClock::AdviseThreadFunction(__in LPVOID p)\n{\n    return DWORD(reinterpret_cast<CBaseReferenceClock *>(p)->AdviseThread());\n}\n\nHRESULT CBaseReferenceClock::AdviseThread()\n{\n    DWORD dwWait = INFINITE;\n\n    // The first thing we do is wait until something interesting happens\n    // (meaning a first advise or shutdown).  This prevents us calling\n    // GetPrivateTime immediately which is goodness as that is a virtual\n    // routine and the derived class may not yet be constructed.  (This\n    // thread is created in the base class constructor.)\n\n    while (!m_bAbort)\n    {\n        // Wait for an interesting event to happen\n        DbgLog((LOG_TIMING, 3, TEXT(\"CBaseRefClock::AdviseThread() Delay: %lu ms\"), dwWait));\n        WaitForSingleObject(m_pSchedule->GetEvent(), dwWait);\n        if (m_bAbort)\n            break;\n\n        // There are several reasons why we need to work from the internal\n        // time, mainly to do with what happens when time goes backwards.\n        // Mainly, it stop us looping madly if an event is just about to\n        // expire when the clock goes backward (i.e. GetTime stop for a\n        // while).\n        const REFERENCE_TIME rtNow = GetPrivateTime();\n\n        DbgLog((LOG_TIMING, 3, TEXT(\"CBaseRefClock::AdviseThread() Woke at = %lu ms\"), ConvertToMilliseconds(rtNow)));\n\n        // We must add in a millisecond, since this is the resolution of our\n        // WaitForSingleObject timer.  Failure to do so will cause us to loop\n        // franticly for (approx) 1 a millisecond.\n        m_rtNextAdvise = m_pSchedule->Advise(10000 + rtNow);\n        LONGLONG llWait = m_rtNextAdvise - rtNow;\n\n        ASSERT(llWait > 0);\n\n        llWait = ConvertToMilliseconds(llWait);\n        // DON'T replace this with a max!! (The type's of these things is VERY important)\n        dwWait = (llWait > REFERENCE_TIME(UINT_MAX)) ? UINT_MAX : DWORD(llWait);\n    };\n    return NOERROR;\n}\n\nHRESULT CBaseReferenceClock::SetDefaultTimerResolution(REFERENCE_TIME timerResolution // in 100ns\n)\n{\n    CAutoLock cObjectLock(this);\n    if (0 == timerResolution)\n    {\n        if (m_TimerResolution)\n        {\n            timeEndPeriod(m_TimerResolution);\n            m_TimerResolution = 0;\n        }\n    }\n    else\n    {\n        TIMECAPS tc;\n        DWORD dwMinResolution = (TIMERR_NOERROR == timeGetDevCaps(&tc, sizeof(tc))) ? tc.wPeriodMin : 1;\n        DWORD dwResolution = max(dwMinResolution, DWORD(timerResolution / 10000));\n        if (dwResolution != m_TimerResolution)\n        {\n            timeEndPeriod(m_TimerResolution);\n            m_TimerResolution = dwResolution;\n            timeBeginPeriod(m_TimerResolution);\n        }\n    }\n    return S_OK;\n}\n\nHRESULT CBaseReferenceClock::GetDefaultTimerResolution(__out REFERENCE_TIME *pTimerResolution // in 100ns\n)\n{\n    if (!pTimerResolution)\n    {\n        return E_POINTER;\n    }\n    CAutoLock cObjectLock(this);\n    *pTimerResolution = m_TimerResolution * 10000;\n    return S_OK;\n}\n"
  },
  {
    "path": "common/baseclasses/refclock.h",
    "content": "//------------------------------------------------------------------------------\n// File: RefClock.h\n//\n// Desc: DirectShow base classes - defines the IReferenceClock interface.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __BASEREFCLOCK__\n#define __BASEREFCLOCK__\n\n#include <Schedule.h>\n\nconst UINT RESOLUTION = 1;                    /* High resolution timer */\nconst INT ADVISE_CACHE = 4;                   /* Default cache size */\nconst LONGLONG MAX_TIME = 0x7FFFFFFFFFFFFFFF; /* Maximum LONGLONG value */\n\ninline LONGLONG WINAPI ConvertToMilliseconds(const REFERENCE_TIME &RT)\n{\n    /* This converts an arbitrary value representing a reference time\n       into a MILLISECONDS value for use in subsequent system calls */\n\n    return (RT / (UNITS / MILLISECONDS));\n}\n\n/* This class hierarchy will support an IReferenceClock interface so\n   that an audio card (or other externally driven clock) can update the\n   system wide clock that everyone uses.\n\n   The interface will be pretty thin with probably just one update method\n   This interface has not yet been defined.\n */\n\n/* This abstract base class implements the IReferenceClock\n * interface.  Classes that actually provide clock signals (from\n * whatever source) have to be derived from this class.\n *\n * The abstract class provides implementations for:\n *  CUnknown support\n *      locking support (CCritSec)\n *  client advise code (creates a thread)\n *\n * Question: what can we do about quality?  Change the timer\n * resolution to lower the system load?  Up the priority of the\n * timer thread to force more responsive signals?\n *\n * During class construction we create a worker thread that is destroyed during\n * destuction.  This thread executes a series of WaitForSingleObject calls,\n * waking up when a command is given to the thread or the next wake up point\n * is reached.  The wakeup points are determined by clients making Advise\n * calls.\n *\n * Each advise call defines a point in time when they wish to be notified.  A\n * periodic advise is a series of these such events.  We maintain a list of\n * advise links and calculate when the nearest event notification is due for.\n * We then call WaitForSingleObject with a timeout equal to this time.  The\n * handle we wait on is used by the class to signal that something has changed\n * and that we must reschedule the next event.  This typically happens when\n * someone comes in and asks for an advise link while we are waiting for an\n * event to timeout.\n *\n * While we are modifying the list of advise requests we\n * are protected from interference through a critical section.  Clients are NOT\n * advised through callbacks.  One shot clients have an event set, while\n * periodic clients have a semaphore released for each event notification.  A\n * semaphore allows a client to be kept up to date with the number of events\n * actually triggered and be assured that they can't miss multiple events being\n * set.\n *\n * Keeping track of advises is taken care of by the CAMSchedule class.\n */\n\nclass CBaseReferenceClock\n    : public CUnknown\n    , public IReferenceClock\n    , public CCritSec\n    , public IReferenceClockTimerControl\n{\n  protected:\n    virtual ~CBaseReferenceClock(); // Don't let me be created on the stack!\n  public:\n    CBaseReferenceClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr,\n                        __inout_opt CAMSchedule *pSched = 0);\n\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    DECLARE_IUNKNOWN\n\n    /* IReferenceClock methods */\n    // Derived classes must implement GetPrivateTime().  All our GetTime\n    // does is call GetPrivateTime and then check so that time does not\n    // go backwards.  A return code of S_FALSE implies that the internal\n    // clock has gone backwards and GetTime time has halted until internal\n    // time has caught up. (Don't know if this will be much use to folk,\n    // but it seems odd not to use the return code for something useful.)\n    STDMETHODIMP GetTime(__out REFERENCE_TIME *pTime);\n    // When this is called, it sets m_rtLastGotTime to the time it returns.\n\n    /* Provide standard mechanisms for scheduling events */\n\n    /* Ask for an async notification that a time has elapsed */\n    STDMETHODIMP AdviseTime(REFERENCE_TIME baseTime,         // base reference time\n                            REFERENCE_TIME streamTime,       // stream offset time\n                            HEVENT hEvent,                   // advise via this event\n                            __out DWORD_PTR *pdwAdviseCookie // where your cookie goes\n    );\n\n    /* Ask for an asynchronous periodic notification that a time has elapsed */\n    STDMETHODIMP AdvisePeriodic(REFERENCE_TIME StartTime,        // starting at this time\n                                REFERENCE_TIME PeriodTime,       // time between notifications\n                                HSEMAPHORE hSemaphore,           // advise via a semaphore\n                                __out DWORD_PTR *pdwAdviseCookie // where your cookie goes\n    );\n\n    /* Cancel a request for notification(s) - if the notification was\n     * a one shot timer then this function doesn't need to be called\n     * as the advise is automatically cancelled, however it does no\n     * harm to explicitly cancel a one-shot advise.  It is REQUIRED that\n     * clients call Unadvise to clear a Periodic advise setting.\n     */\n\n    STDMETHODIMP Unadvise(DWORD_PTR dwAdviseCookie);\n\n    /* Methods for the benefit of derived classes or outer objects */\n\n    // GetPrivateTime() is the REAL clock.  GetTime is just a cover for\n    // it.  Derived classes will probably override this method but not\n    // GetTime() itself.\n    // The important point about GetPrivateTime() is it's allowed to go\n    // backwards.  Our GetTime() will keep returning the LastGotTime\n    // until GetPrivateTime() catches up.\n    virtual REFERENCE_TIME GetPrivateTime();\n\n    /* Provide a method for correcting drift */\n    STDMETHODIMP SetTimeDelta(const REFERENCE_TIME &TimeDelta);\n\n    CAMSchedule *GetSchedule() const { return m_pSchedule; }\n\n    // IReferenceClockTimerControl methods\n    //\n    // Setting a default of 0 disables the default of 1ms\n    STDMETHODIMP SetDefaultTimerResolution(REFERENCE_TIME timerResolution // in 100ns\n    );\n    STDMETHODIMP GetDefaultTimerResolution(__out REFERENCE_TIME *pTimerResolution // in 100ns\n    );\n\n  private:\n    REFERENCE_TIME m_rtPrivateTime; // Current best estimate of time\n    DWORD m_dwPrevSystemTime;       // Last vaule we got from timeGetTime\n    REFERENCE_TIME m_rtLastGotTime; // Last time returned by GetTime\n    REFERENCE_TIME m_rtNextAdvise;  // Time of next advise\n    UINT m_TimerResolution;\n\n#ifdef PERF\n    int m_idGetSystemTime;\n#endif\n\n    // Thread stuff\n  public:\n    void TriggerThread() // Wakes thread up.  Need to do this if\n    {                    // time to next advise needs reevaluating.\n        EXECUTE_ASSERT(SetEvent(m_pSchedule->GetEvent()));\n    }\n\n  private:\n    BOOL m_bAbort;    // Flag used for thread shutdown\n    HANDLE m_hThread; // Thread handle\n\n    HRESULT AdviseThread();                                   // Method in which the advise thread runs\n    static DWORD __stdcall AdviseThreadFunction(__in LPVOID); // Function used to get there\n\n  protected:\n    CAMSchedule *m_pSchedule;\n\n    void Restart(IN REFERENCE_TIME rtMinTime = 0I64);\n};\n\n#endif\n"
  },
  {
    "path": "common/baseclasses/reftime.h",
    "content": "//------------------------------------------------------------------------------\n// File: RefTime.h\n//\n// Desc: DirectShow base classes - defines CRefTime, a class that manages\n//       reference times.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation. All rights reserved.\n//------------------------------------------------------------------------------\n\n//\n// CRefTime\n//\n// Manage reference times.\n// Shares same data layout as REFERENCE_TIME, but adds some (nonvirtual)\n// functions providing simple comparison, conversion and arithmetic.\n//\n// A reference time (at the moment) is a unit of seconds represented in\n// 100ns units as is used in the Win32 FILETIME structure. BUT the time\n// a REFERENCE_TIME represents is NOT the time elapsed since 1/1/1601 it\n// will either be stream time or reference time depending upon context\n//\n// This class provides simple arithmetic operations on reference times\n//\n// keep non-virtual otherwise the data layout will not be the same as\n// REFERENCE_TIME\n\n// -----\n// note that you are safe to cast a CRefTime* to a REFERENCE_TIME*, but\n// you will need to do so explicitly\n// -----\n\n#ifndef __REFTIME__\n#define __REFTIME__\n\nconst LONGLONG MILLISECONDS = (1000);       // 10 ^ 3\nconst LONGLONG NANOSECONDS = (1000000000);  // 10 ^ 9\nconst LONGLONG UNITS = (NANOSECONDS / 100); // 10 ^ 7\n\n/*  Unfortunately an inline function here generates a call to __allmul\n    - even for constants!\n*/\n#define MILLISECONDS_TO_100NS_UNITS(lMs) Int32x32To64((lMs), (UNITS / MILLISECONDS))\n\nclass CRefTime\n{\n  public:\n    // *MUST* be the only data member so that this class is exactly\n    // equivalent to a REFERENCE_TIME.\n    // Also, must be *no virtual functions*\n\n    REFERENCE_TIME m_time;\n\n    inline CRefTime()\n    {\n        // default to 0 time\n        m_time = 0;\n    };\n\n    inline CRefTime(LONG msecs) { m_time = MILLISECONDS_TO_100NS_UNITS(msecs); };\n\n    inline CRefTime(REFERENCE_TIME rt) { m_time = rt; };\n\n    inline operator REFERENCE_TIME() const { return m_time; };\n\n    inline CRefTime &operator=(const CRefTime &rt)\n    {\n        m_time = rt.m_time;\n        return *this;\n    };\n\n    inline CRefTime &operator=(const LONGLONG ll)\n    {\n        m_time = ll;\n        return *this;\n    };\n\n    inline CRefTime &operator+=(const CRefTime &rt) { return (*this = *this + rt); };\n\n    inline CRefTime &operator-=(const CRefTime &rt) { return (*this = *this - rt); };\n\n    inline LONG Millisecs(void) { return (LONG)(m_time / (UNITS / MILLISECONDS)); };\n\n    inline LONGLONG GetUnits(void) { return m_time; };\n};\n\nconst LONGLONG TimeZero = 0;\n\n#endif /* __REFTIME__ */\n"
  },
  {
    "path": "common/baseclasses/renbase.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: RenBase.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>  // DirectShow base class definitions\n#include <mmsystem.h> // Needed for definition of timeGetTime\n#include <limits.h>   // Standard data type limit definitions\n#include <measure.h>  // Used for time critical log functions\n\n#pragma warning(disable : 4355)\n\n//  Helper function for clamping time differences\nint inline TimeDiff(REFERENCE_TIME rt)\n{\n    if (rt < -(50 * UNITS))\n    {\n        return -(50 * UNITS);\n    }\n    else if (rt > 50 * UNITS)\n    {\n        return 50 * UNITS;\n    }\n    else\n        return (int)rt;\n}\n\n// Implements the CBaseRenderer class\n\nCBaseRenderer::CBaseRenderer(REFCLSID RenderClass,       // CLSID for this renderer\n                             __in_opt LPCTSTR pName,     // Debug ONLY description\n                             __inout_opt LPUNKNOWN pUnk, // Aggregated owner object\n                             __inout HRESULT *phr)\n    : // General OLE return code\n\n    CBaseFilter(pName, pUnk, &m_InterfaceLock, RenderClass)\n    , m_evComplete(TRUE, phr)\n    , m_RenderEvent(FALSE, phr)\n    , m_bAbort(FALSE)\n    , m_pPosition(NULL)\n    , m_ThreadSignal(TRUE, phr)\n    , m_bStreaming(FALSE)\n    , m_bEOS(FALSE)\n    , m_bEOSDelivered(FALSE)\n    , m_pMediaSample(NULL)\n    , m_dwAdvise(0)\n    , m_pQSink(NULL)\n    , m_pInputPin(NULL)\n    , m_bRepaintStatus(TRUE)\n    , m_SignalTime(0)\n    , m_bInReceive(FALSE)\n    , m_EndOfStreamTimer(0)\n{\n    if (SUCCEEDED(*phr))\n    {\n        Ready();\n#ifdef PERF\n        m_idBaseStamp = MSR_REGISTER(TEXT(\"BaseRenderer: sample time stamp\"));\n        m_idBaseRenderTime = MSR_REGISTER(TEXT(\"BaseRenderer: draw time (msec)\"));\n        m_idBaseAccuracy = MSR_REGISTER(TEXT(\"BaseRenderer: Accuracy (msec)\"));\n#endif\n    }\n}\n\n// Delete the dynamically allocated IMediaPosition and IMediaSeeking helper\n// object. The object is created when somebody queries us. These are standard\n// control interfaces for seeking and setting start/stop positions and rates.\n// We will probably also have made an input pin based on CRendererInputPin\n// that has to be deleted, it's created when an enumerator calls our GetPin\n\nCBaseRenderer::~CBaseRenderer()\n{\n    ASSERT(m_bStreaming == FALSE);\n    ASSERT(m_EndOfStreamTimer == 0);\n    StopStreaming();\n    ClearPendingSample();\n\n    // Delete any IMediaPosition implementation\n\n    if (m_pPosition)\n    {\n        delete m_pPosition;\n        m_pPosition = NULL;\n    }\n\n    // Delete any input pin created\n\n    if (m_pInputPin)\n    {\n        delete m_pInputPin;\n        m_pInputPin = NULL;\n    }\n\n    // Release any Quality sink\n\n    ASSERT(m_pQSink == NULL);\n}\n\n// This returns the IMediaPosition and IMediaSeeking interfaces\n\nHRESULT CBaseRenderer::GetMediaPositionInterface(REFIID riid, __deref_out void **ppv)\n{\n    CAutoLock cObjectCreationLock(&m_ObjectCreationLock);\n    if (m_pPosition)\n    {\n        return m_pPosition->NonDelegatingQueryInterface(riid, ppv);\n    }\n\n    CBasePin *pPin = GetPin(0);\n    if (NULL == pPin)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    HRESULT hr = NOERROR;\n\n    // Create implementation of this dynamically since sometimes we may\n    // never try and do a seek. The helper object implements a position\n    // control interface (IMediaPosition) which in fact simply takes the\n    // calls normally from the filter graph and passes them upstream\n\n    m_pPosition =\n        new CRendererPosPassThru(NAME(\"Renderer CPosPassThru\"), CBaseFilter::GetOwner(), (HRESULT *)&hr, pPin);\n    if (m_pPosition == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    if (FAILED(hr))\n    {\n        delete m_pPosition;\n        m_pPosition = NULL;\n        return E_NOINTERFACE;\n    }\n    return GetMediaPositionInterface(riid, ppv);\n}\n\n// Overriden to say what interfaces we support and where\n\nSTDMETHODIMP CBaseRenderer::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    // Do we have this interface\n\n    if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking)\n    {\n        return GetMediaPositionInterface(riid, ppv);\n    }\n    else\n    {\n        return CBaseFilter::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n// This is called whenever we change states, we have a manual reset event that\n// is signalled whenever we don't won't the source filter thread to wait in us\n// (such as in a stopped state) and likewise is not signalled whenever it can\n// wait (during paused and running) this function sets or resets the thread\n// event. The event is used to stop source filter threads waiting in Receive\n\nHRESULT CBaseRenderer::SourceThreadCanWait(BOOL bCanWait)\n{\n    if (bCanWait == TRUE)\n    {\n        m_ThreadSignal.Reset();\n    }\n    else\n    {\n        m_ThreadSignal.Set();\n    }\n    return NOERROR;\n}\n\n#ifdef DEBUG\n// Dump the current renderer state to the debug terminal. The hardest part of\n// the renderer is the window where we unlock everything to wait for a clock\n// to signal it is time to draw or for the application to cancel everything\n// by stopping the filter. If we get things wrong we can leave the thread in\n// WaitForRenderTime with no way for it to ever get out and we will deadlock\n\nvoid CBaseRenderer::DisplayRendererState()\n{\n    DbgLog((LOG_TIMING, 1, TEXT(\"\\nTimed out in WaitForRenderTime\")));\n\n    // No way should this be signalled at this point\n\n    BOOL bSignalled = m_ThreadSignal.Check();\n    DbgLog((LOG_TIMING, 1, TEXT(\"Signal sanity check %d\"), bSignalled));\n\n    // Now output the current renderer state variables\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Filter state %d\"), m_State));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Abort flag %d\"), m_bAbort));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Streaming flag %d\"), m_bStreaming));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Clock advise link %d\"), m_dwAdvise));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Current media sample %x\"), m_pMediaSample));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"EOS signalled %d\"), m_bEOS));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"EOS delivered %d\"), m_bEOSDelivered));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Repaint status %d\"), m_bRepaintStatus));\n\n    // Output the delayed end of stream timer information\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"End of stream timer %x\"), m_EndOfStreamTimer));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Deliver time %s\"), CDisp((LONGLONG)m_SignalTime)));\n\n    // Should never timeout during a flushing state\n\n    BOOL bFlushing = m_pInputPin->IsFlushing();\n    DbgLog((LOG_TIMING, 1, TEXT(\"Flushing sanity check %d\"), bFlushing));\n\n    // Display the time we were told to start at\n    DbgLog((LOG_TIMING, 1, TEXT(\"Last run time %s\"), CDisp((LONGLONG)m_tStart.m_time)));\n\n    // Have we got a reference clock\n    if (m_pClock == NULL)\n        return;\n\n    // Get the current time from the wall clock\n\n    CRefTime CurrentTime, StartTime, EndTime;\n    m_pClock->GetTime((REFERENCE_TIME *)&CurrentTime);\n    CRefTime Offset = CurrentTime - m_tStart;\n\n    // Display the current time from the clock\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Clock time %s\"), CDisp((LONGLONG)CurrentTime.m_time)));\n\n    DbgLog((LOG_TIMING, 1, TEXT(\"Time difference %dms\"), Offset.Millisecs()));\n\n    // Do we have a sample ready to render\n    if (m_pMediaSample == NULL)\n        return;\n\n    m_pMediaSample->GetTime((REFERENCE_TIME *)&StartTime, (REFERENCE_TIME *)&EndTime);\n    DbgLog((LOG_TIMING, 1, TEXT(\"Next sample stream times (Start %d End %d ms)\"), StartTime.Millisecs(),\n            EndTime.Millisecs()));\n\n    // Calculate how long it is until it is due for rendering\n    CRefTime Wait = (m_tStart + StartTime) - CurrentTime;\n    DbgLog((LOG_TIMING, 1, TEXT(\"Wait required %d ms\"), Wait.Millisecs()));\n}\n#endif\n\n// Wait until the clock sets the timer event or we're otherwise signalled. We\n// set an arbitrary timeout for this wait and if it fires then we display the\n// current renderer state on the debugger. It will often fire if the filter's\n// left paused in an application however it may also fire during stress tests\n// if the synchronisation with application seeks and state changes is faulty\n\n#define RENDER_TIMEOUT 10000\n\nHRESULT CBaseRenderer::WaitForRenderTime()\n{\n    HANDLE WaitObjects[] = {m_ThreadSignal, m_RenderEvent};\n    DWORD Result = WAIT_TIMEOUT;\n\n    // Wait for either the time to arrive or for us to be stopped\n\n    OnWaitStart();\n    while (Result == WAIT_TIMEOUT)\n    {\n        Result = WaitForMultipleObjects(2, WaitObjects, FALSE, RENDER_TIMEOUT);\n\n#ifdef DEBUG\n        if (Result == WAIT_TIMEOUT)\n            DisplayRendererState();\n#endif\n    }\n    OnWaitEnd();\n\n    // We may have been awoken without the timer firing\n\n    if (Result == WAIT_OBJECT_0)\n    {\n        return VFW_E_STATE_CHANGED;\n    }\n\n    SignalTimerFired();\n    return NOERROR;\n}\n\n// Poll waiting for Receive to complete.  This really matters when\n// Receive may set the palette and cause window messages\n// The problem is that if we don't really wait for a renderer to\n// stop processing we can deadlock waiting for a transform which\n// is calling the renderer's Receive() method because the transform's\n// Stop method doesn't know to process window messages to unblock\n// the renderer's Receive processing\nvoid CBaseRenderer::WaitForReceiveToComplete()\n{\n    for (;;)\n    {\n        if (!m_bInReceive)\n        {\n            break;\n        }\n\n        MSG msg;\n        //  Receive all interthread snedmessages\n        PeekMessage(&msg, NULL, WM_NULL, WM_NULL, PM_NOREMOVE);\n\n        Sleep(1);\n    }\n\n    // If the wakebit for QS_POSTMESSAGE is set, the PeekMessage call\n    // above just cleared the changebit which will cause some messaging\n    // calls to block (waitMessage, MsgWaitFor...) now.\n    // Post a dummy message to set the QS_POSTMESSAGE bit again\n    if (HIWORD(GetQueueStatus(QS_POSTMESSAGE)) & QS_POSTMESSAGE)\n    {\n        //  Send dummy message\n        PostThreadMessage(GetCurrentThreadId(), WM_NULL, 0, 0);\n    }\n}\n\n// A filter can have four discrete states, namely Stopped, Running, Paused,\n// Intermediate. We are in an intermediate state if we are currently trying\n// to pause but haven't yet got the first sample (or if we have been flushed\n// in paused state and therefore still have to wait for a sample to arrive)\n\n// This class contains an event called m_evComplete which is signalled when\n// the current state is completed and is not signalled when we are waiting to\n// complete the last state transition. As mentioned above the only time we\n// use this at the moment is when we wait for a media sample in paused state\n// If while we are waiting we receive an end of stream notification from the\n// source filter then we know no data is imminent so we can reset the event\n// This means that when we transition to paused the source filter must call\n// end of stream on us or send us an image otherwise we'll hang indefinately\n\n// Simple internal way of getting the real state\n\nFILTER_STATE CBaseRenderer::GetRealState()\n{\n    return m_State;\n}\n\n// The renderer doesn't complete the full transition to paused states until\n// it has got one media sample to render. If you ask it for its state while\n// it's waiting it will return the state along with VFW_S_STATE_INTERMEDIATE\n\nSTDMETHODIMP CBaseRenderer::GetState(DWORD dwMSecs, FILTER_STATE *State)\n{\n    CheckPointer(State, E_POINTER);\n\n    if (WaitDispatchingMessages(m_evComplete, dwMSecs) == WAIT_TIMEOUT)\n    {\n        *State = m_State;\n        return VFW_S_STATE_INTERMEDIATE;\n    }\n    *State = m_State;\n    return NOERROR;\n}\n\n// If we're pausing and we have no samples we don't complete the transition\n// to State_Paused and we return S_FALSE. However if the m_bAbort flag has\n// been set then all samples are rejected so there is no point waiting for\n// one. If we do have a sample then return NOERROR. We will only ever return\n// VFW_S_STATE_INTERMEDIATE from GetState after being paused with no sample\n// (calling GetState after either being stopped or Run will NOT return this)\n\nHRESULT CBaseRenderer::CompleteStateChange(FILTER_STATE OldState)\n{\n    // Allow us to be paused when disconnected\n\n    if (m_pInputPin->IsConnected() == FALSE)\n    {\n        Ready();\n        return S_OK;\n    }\n\n    // Have we run off the end of stream\n\n    if (IsEndOfStream() == TRUE)\n    {\n        Ready();\n        return S_OK;\n    }\n\n    // Make sure we get fresh data after being stopped\n\n    if (HaveCurrentSample() == TRUE)\n    {\n        if (OldState != State_Stopped)\n        {\n            Ready();\n            return S_OK;\n        }\n    }\n    NotReady();\n    return S_FALSE;\n}\n\n// When we stop the filter the things we do are:-\n\n//      Decommit the allocator being used in the connection\n//      Release the source filter if it's waiting in Receive\n//      Cancel any advise link we set up with the clock\n//      Any end of stream signalled is now obsolete so reset\n//      Allow us to be stopped when we are not connected\n\nSTDMETHODIMP CBaseRenderer::Stop()\n{\n    CAutoLock cRendererLock(&m_InterfaceLock);\n\n    // Make sure there really is a state change\n\n    if (m_State == State_Stopped)\n    {\n        return NOERROR;\n    }\n\n    // Is our input pin connected\n\n    if (m_pInputPin->IsConnected() == FALSE)\n    {\n        NOTE(\"Input pin is not connected\");\n        m_State = State_Stopped;\n        return NOERROR;\n    }\n\n    CBaseFilter::Stop();\n\n    // If we are going into a stopped state then we must decommit whatever\n    // allocator we are using it so that any source filter waiting in the\n    // GetBuffer can be released and unlock themselves for a state change\n\n    if (m_pInputPin->Allocator())\n    {\n        m_pInputPin->Allocator()->Decommit();\n    }\n\n    // Cancel any scheduled rendering\n\n    SetRepaintStatus(TRUE);\n    StopStreaming();\n    SourceThreadCanWait(FALSE);\n    ResetEndOfStream();\n    CancelNotification();\n\n    // There should be no outstanding clock advise\n    ASSERT(CancelNotification() == S_FALSE);\n    ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));\n    ASSERT(m_EndOfStreamTimer == 0);\n\n    Ready();\n    WaitForReceiveToComplete();\n    m_bAbort = FALSE;\n\n    return NOERROR;\n}\n\n// When we pause the filter the things we do are:-\n\n//      Commit the allocator being used in the connection\n//      Allow a source filter thread to wait in Receive\n//      Cancel any clock advise link (we may be running)\n//      Possibly complete the state change if we have data\n//      Allow us to be paused when we are not connected\n\nSTDMETHODIMP CBaseRenderer::Pause()\n{\n    CAutoLock cRendererLock(&m_InterfaceLock);\n    FILTER_STATE OldState = m_State;\n    ASSERT(m_pInputPin->IsFlushing() == FALSE);\n\n    // Make sure there really is a state change\n\n    if (m_State == State_Paused)\n    {\n        return CompleteStateChange(State_Paused);\n    }\n\n    // Has our input pin been connected\n\n    if (m_pInputPin->IsConnected() == FALSE)\n    {\n        NOTE(\"Input pin is not connected\");\n        m_State = State_Paused;\n        return CompleteStateChange(State_Paused);\n    }\n\n    // Pause the base filter class\n\n    HRESULT hr = CBaseFilter::Pause();\n    if (FAILED(hr))\n    {\n        NOTE(\"Pause failed\");\n        return hr;\n    }\n\n    // Enable EC_REPAINT events again\n\n    SetRepaintStatus(TRUE);\n    StopStreaming();\n    SourceThreadCanWait(TRUE);\n    CancelNotification();\n    ResetEndOfStreamTimer();\n\n    // If we are going into a paused state then we must commit whatever\n    // allocator we are using it so that any source filter can call the\n    // GetBuffer and expect to get a buffer without returning an error\n\n    if (m_pInputPin->Allocator())\n    {\n        m_pInputPin->Allocator()->Commit();\n    }\n\n    // There should be no outstanding advise\n    ASSERT(CancelNotification() == S_FALSE);\n    ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));\n    ASSERT(m_EndOfStreamTimer == 0);\n    ASSERT(m_pInputPin->IsFlushing() == FALSE);\n\n    // When we come out of a stopped state we must clear any image we were\n    // holding onto for frame refreshing. Since renderers see state changes\n    // first we can reset ourselves ready to accept the source thread data\n    // Paused or running after being stopped causes the current position to\n    // be reset so we're not interested in passing end of stream signals\n\n    if (OldState == State_Stopped)\n    {\n        m_bAbort = FALSE;\n        ClearPendingSample();\n    }\n    return CompleteStateChange(OldState);\n}\n\n// When we run the filter the things we do are:-\n\n//      Commit the allocator being used in the connection\n//      Allow a source filter thread to wait in Receive\n//      Signal the render event just to get us going\n//      Start the base class by calling StartStreaming\n//      Allow us to be run when we are not connected\n//      Signal EC_COMPLETE if we are not connected\n\nSTDMETHODIMP CBaseRenderer::Run(REFERENCE_TIME StartTime)\n{\n    CAutoLock cRendererLock(&m_InterfaceLock);\n    FILTER_STATE OldState = m_State;\n\n    // Make sure there really is a state change\n\n    if (m_State == State_Running)\n    {\n        return NOERROR;\n    }\n\n    // Send EC_COMPLETE if we're not connected\n\n    if (m_pInputPin->IsConnected() == FALSE)\n    {\n        NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)this);\n        m_State = State_Running;\n        return NOERROR;\n    }\n\n    Ready();\n\n    // Pause the base filter class\n\n    HRESULT hr = CBaseFilter::Run(StartTime);\n    if (FAILED(hr))\n    {\n        NOTE(\"Run failed\");\n        return hr;\n    }\n\n    // Allow the source thread to wait\n    ASSERT(m_pInputPin->IsFlushing() == FALSE);\n    SourceThreadCanWait(TRUE);\n    SetRepaintStatus(FALSE);\n\n    // There should be no outstanding advise\n    ASSERT(CancelNotification() == S_FALSE);\n    ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));\n    ASSERT(m_EndOfStreamTimer == 0);\n    ASSERT(m_pInputPin->IsFlushing() == FALSE);\n\n    // If we are going into a running state then we must commit whatever\n    // allocator we are using it so that any source filter can call the\n    // GetBuffer and expect to get a buffer without returning an error\n\n    if (m_pInputPin->Allocator())\n    {\n        m_pInputPin->Allocator()->Commit();\n    }\n\n    // When we come out of a stopped state we must clear any image we were\n    // holding onto for frame refreshing. Since renderers see state changes\n    // first we can reset ourselves ready to accept the source thread data\n    // Paused or running after being stopped causes the current position to\n    // be reset so we're not interested in passing end of stream signals\n\n    if (OldState == State_Stopped)\n    {\n        m_bAbort = FALSE;\n        ClearPendingSample();\n    }\n    return StartStreaming();\n}\n\n// Return the number of input pins we support\n\nint CBaseRenderer::GetPinCount()\n{\n    if (m_pInputPin == NULL)\n    {\n        //  Try to create it\n        (void)GetPin(0);\n    }\n    return m_pInputPin != NULL ? 1 : 0;\n}\n\n// We only support one input pin and it is numbered zero\n\nCBasePin *CBaseRenderer::GetPin(int n)\n{\n    CAutoLock cObjectCreationLock(&m_ObjectCreationLock);\n\n    // Should only ever be called with zero\n    ASSERT(n == 0);\n\n    if (n != 0)\n    {\n        return NULL;\n    }\n\n    // Create the input pin if not already done so\n\n    if (m_pInputPin == NULL)\n    {\n\n        // hr must be initialized to NOERROR because\n        // CRendererInputPin's constructor only changes\n        // hr's value if an error occurs.\n        HRESULT hr = NOERROR;\n\n        m_pInputPin = new CRendererInputPin(this, &hr, L\"In\");\n        if (NULL == m_pInputPin)\n        {\n            return NULL;\n        }\n\n        if (FAILED(hr))\n        {\n            delete m_pInputPin;\n            m_pInputPin = NULL;\n            return NULL;\n        }\n    }\n    return m_pInputPin;\n}\n\n// If \"In\" then return the IPin for our input pin, otherwise NULL and error\n\nSTDMETHODIMP CBaseRenderer::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)\n{\n    CheckPointer(ppPin, E_POINTER);\n\n    if (0 == lstrcmpW(Id, L\"In\"))\n    {\n        *ppPin = GetPin(0);\n        if (*ppPin)\n        {\n            (*ppPin)->AddRef();\n        }\n        else\n        {\n            return E_OUTOFMEMORY;\n        }\n    }\n    else\n    {\n        *ppPin = NULL;\n        return VFW_E_NOT_FOUND;\n    }\n    return NOERROR;\n}\n\n// Called when the input pin receives an EndOfStream notification. If we have\n// not got a sample, then notify EC_COMPLETE now. If we have samples, then set\n// m_bEOS and check for this on completing samples. If we're waiting to pause\n// then complete the transition to paused state by setting the state event\n\nHRESULT CBaseRenderer::EndOfStream()\n{\n    // Ignore these calls if we are stopped\n\n    if (m_State == State_Stopped)\n    {\n        return NOERROR;\n    }\n\n    // If we have a sample then wait for it to be rendered\n\n    m_bEOS = TRUE;\n    if (m_pMediaSample)\n    {\n        return NOERROR;\n    }\n\n    // If we are waiting for pause then we are now ready since we cannot now\n    // carry on waiting for a sample to arrive since we are being told there\n    // won't be any. This sets an event that the GetState function picks up\n\n    Ready();\n\n    // Only signal completion now if we are running otherwise queue it until\n    // we do run in StartStreaming. This is used when we seek because a seek\n    // causes a pause where early notification of completion is misleading\n\n    if (m_bStreaming)\n    {\n        SendEndOfStream();\n    }\n    return NOERROR;\n}\n\n// When we are told to flush we should release the source thread\n\nHRESULT CBaseRenderer::BeginFlush()\n{\n    // If paused then report state intermediate until we get some data\n\n    if (m_State == State_Paused)\n    {\n        NotReady();\n    }\n\n    SourceThreadCanWait(FALSE);\n    CancelNotification();\n    ClearPendingSample();\n    //  Wait for Receive to complete\n    WaitForReceiveToComplete();\n\n    return NOERROR;\n}\n\n// After flushing the source thread can wait in Receive again\n\nHRESULT CBaseRenderer::EndFlush()\n{\n    // Reset the current sample media time\n    if (m_pPosition)\n        m_pPosition->ResetMediaTime();\n\n    // There should be no outstanding advise\n\n    ASSERT(CancelNotification() == S_FALSE);\n    SourceThreadCanWait(TRUE);\n    return NOERROR;\n}\n\n// We can now send EC_REPAINTs if so required\n\nHRESULT CBaseRenderer::CompleteConnect(IPin *pReceivePin)\n{\n    // The caller should always hold the interface lock because\n    // the function uses CBaseFilter::m_State.\n    ASSERT(CritCheckIn(&m_InterfaceLock));\n\n    m_bAbort = FALSE;\n\n    if (State_Running == GetRealState())\n    {\n        HRESULT hr = StartStreaming();\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        SetRepaintStatus(FALSE);\n    }\n    else\n    {\n        SetRepaintStatus(TRUE);\n    }\n\n    return NOERROR;\n}\n\n// Called when we go paused or running\n\nHRESULT CBaseRenderer::Active()\n{\n    return NOERROR;\n}\n\n// Called when we go into a stopped state\n\nHRESULT CBaseRenderer::Inactive()\n{\n    if (m_pPosition)\n    {\n        m_pPosition->ResetMediaTime();\n    }\n    //  People who derive from this may want to override this behaviour\n    //  to keep hold of the sample in some circumstances\n    ClearPendingSample();\n\n    return NOERROR;\n}\n\n// Tell derived classes about the media type agreed\n\nHRESULT CBaseRenderer::SetMediaType(const CMediaType *pmt)\n{\n    return NOERROR;\n}\n\n// When we break the input pin connection we should reset the EOS flags. When\n// we are asked for either IMediaPosition or IMediaSeeking we will create a\n// CPosPassThru object to handles media time pass through. When we're handed\n// samples we store (by calling CPosPassThru::RegisterMediaTime) their media\n// times so we can then return a real current position of data being rendered\n\nHRESULT CBaseRenderer::BreakConnect()\n{\n    // Do we have a quality management sink\n\n    if (m_pQSink)\n    {\n        m_pQSink->Release();\n        m_pQSink = NULL;\n    }\n\n    // Check we have a valid connection\n\n    if (m_pInputPin->IsConnected() == FALSE)\n    {\n        return S_FALSE;\n    }\n\n    // Check we are stopped before disconnecting\n    if (m_State != State_Stopped && !m_pInputPin->CanReconnectWhenActive())\n    {\n        return VFW_E_NOT_STOPPED;\n    }\n\n    SetRepaintStatus(FALSE);\n    ResetEndOfStream();\n    ClearPendingSample();\n    m_bAbort = FALSE;\n\n    if (State_Running == m_State)\n    {\n        StopStreaming();\n    }\n\n    return NOERROR;\n}\n\n// Retrieves the sample times for this samples (note the sample times are\n// passed in by reference not value). We return S_FALSE to say schedule this\n// sample according to the times on the sample. We also return S_OK in\n// which case the object should simply render the sample data immediately\n\nHRESULT CBaseRenderer::GetSampleTimes(IMediaSample *pMediaSample, __out REFERENCE_TIME *pStartTime,\n                                      __out REFERENCE_TIME *pEndTime)\n{\n    ASSERT(m_dwAdvise == 0);\n    ASSERT(pMediaSample);\n\n    // If the stop time for this sample is before or the same as start time,\n    // then just ignore it (release it) and schedule the next one in line\n    // Source filters should always fill in the start and end times properly!\n\n    if (SUCCEEDED(pMediaSample->GetTime(pStartTime, pEndTime)))\n    {\n        if (*pEndTime < *pStartTime)\n        {\n            return VFW_E_START_TIME_AFTER_END;\n        }\n    }\n    else\n    {\n        // no time set in the sample... draw it now?\n        return S_OK;\n    }\n\n    // Can't synchronise without a clock so we return S_OK which tells the\n    // caller that the sample should be rendered immediately without going\n    // through the overhead of setting a timer advise link with the clock\n\n    if (m_pClock == NULL)\n    {\n        return S_OK;\n    }\n    return ShouldDrawSampleNow(pMediaSample, pStartTime, pEndTime);\n}\n\n// By default all samples are drawn according to their time stamps so we\n// return S_FALSE. Returning S_OK means draw immediately, this is used\n// by the derived video renderer class in its quality management.\n\nHRESULT CBaseRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample, __out REFERENCE_TIME *ptrStart,\n                                           __out REFERENCE_TIME *ptrEnd)\n{\n    return S_FALSE;\n}\n\n// We must always reset the current advise time to zero after a timer fires\n// because there are several possible ways which lead us not to do any more\n// scheduling such as the pending image being cleared after state changes\n\nvoid CBaseRenderer::SignalTimerFired()\n{\n    m_dwAdvise = 0;\n}\n\n// Cancel any notification currently scheduled. This is called by the owning\n// window object when it is told to stop streaming. If there is no timer link\n// outstanding then calling this is benign otherwise we go ahead and cancel\n// We must always reset the render event as the quality management code can\n// signal immediate rendering by setting the event without setting an advise\n// link. If we're subsequently stopped and run the first attempt to setup an\n// advise link with the reference clock will find the event still signalled\n\nHRESULT CBaseRenderer::CancelNotification()\n{\n    ASSERT(m_dwAdvise == 0 || m_pClock);\n    DWORD_PTR dwAdvise = m_dwAdvise;\n\n    // Have we a live advise link\n\n    if (m_dwAdvise)\n    {\n        m_pClock->Unadvise(m_dwAdvise);\n        SignalTimerFired();\n        ASSERT(m_dwAdvise == 0);\n    }\n\n    // Clear the event and return our status\n\n    m_RenderEvent.Reset();\n    return (dwAdvise ? S_OK : S_FALSE);\n}\n\n// Responsible for setting up one shot advise links with the clock\n// Return FALSE if the sample is to be dropped (not drawn at all)\n// Return TRUE if the sample is to be drawn and in this case also\n// arrange for m_RenderEvent to be set at the appropriate time\n\nBOOL CBaseRenderer::ScheduleSample(IMediaSample *pMediaSample)\n{\n    REFERENCE_TIME StartSample, EndSample;\n\n    // Is someone pulling our leg\n\n    if (pMediaSample == NULL)\n    {\n        return FALSE;\n    }\n\n    // Get the next sample due up for rendering.  If there aren't any ready\n    // then GetNextSampleTimes returns an error.  If there is one to be done\n    // then it succeeds and yields the sample times. If it is due now then\n    // it returns S_OK other if it's to be done when due it returns S_FALSE\n\n    HRESULT hr = GetSampleTimes(pMediaSample, &StartSample, &EndSample);\n    if (FAILED(hr))\n    {\n        return FALSE;\n    }\n\n    // If we don't have a reference clock then we cannot set up the advise\n    // time so we simply set the event indicating an image to render. This\n    // will cause us to run flat out without any timing or synchronisation\n\n    if (hr == S_OK)\n    {\n        EXECUTE_ASSERT(SetEvent((HANDLE)m_RenderEvent));\n        return TRUE;\n    }\n\n    ASSERT(m_dwAdvise == 0);\n    ASSERT(m_pClock);\n    ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));\n\n    // We do have a valid reference clock interface so we can ask it to\n    // set an event when the image comes due for rendering. We pass in\n    // the reference time we were told to start at and also the current\n    // stream time which is the offset from the start reference time\n\n    hr = m_pClock->AdviseTime((REFERENCE_TIME)m_tStart,      // Start run time\n                              StartSample,                   // Stream time\n                              (HEVENT)(HANDLE)m_RenderEvent, // Render notification\n                              &m_dwAdvise);                  // Advise cookie\n\n    if (SUCCEEDED(hr))\n    {\n        return TRUE;\n    }\n\n    // We could not schedule the next sample for rendering despite the fact\n    // we have a valid sample here. This is a fair indication that either\n    // the system clock is wrong or the time stamp for the sample is duff\n\n    ASSERT(m_dwAdvise == 0);\n    return FALSE;\n}\n\n// This is called when a sample comes due for rendering. We pass the sample\n// on to the derived class. After rendering we will initialise the timer for\n// the next sample, NOTE signal that the last one fired first, if we don't\n// do this it thinks there is still one outstanding that hasn't completed\n\nHRESULT CBaseRenderer::Render(IMediaSample *pMediaSample)\n{\n    // If the media sample is NULL then we will have been notified by the\n    // clock that another sample is ready but in the mean time someone has\n    // stopped us streaming which causes the next sample to be released\n\n    if (pMediaSample == NULL)\n    {\n        return S_FALSE;\n    }\n\n    // If we have stopped streaming then don't render any more samples, the\n    // thread that got in and locked us and then reset this flag does not\n    // clear the pending sample as we can use it to refresh any output device\n\n    if (m_bStreaming == FALSE)\n    {\n        return S_FALSE;\n    }\n\n    // Time how long the rendering takes\n\n    OnRenderStart(pMediaSample);\n    DoRenderSample(pMediaSample);\n    OnRenderEnd(pMediaSample);\n\n    return NOERROR;\n}\n\n// Checks if there is a sample waiting at the renderer\n\nBOOL CBaseRenderer::HaveCurrentSample()\n{\n    CAutoLock cRendererLock(&m_RendererLock);\n    return (m_pMediaSample == NULL ? FALSE : TRUE);\n}\n\n// Returns the current sample waiting at the video renderer. We AddRef the\n// sample before returning so that should it come due for rendering the\n// person who called this method will hold the remaining reference count\n// that will stop the sample being added back onto the allocator free list\n\nIMediaSample *CBaseRenderer::GetCurrentSample()\n{\n    CAutoLock cRendererLock(&m_RendererLock);\n    if (m_pMediaSample)\n    {\n        m_pMediaSample->AddRef();\n    }\n    return m_pMediaSample;\n}\n\n// Called when the source delivers us a sample. We go through a few checks to\n// make sure the sample can be rendered. If we are running (streaming) then we\n// have the sample scheduled with the reference clock, if we are not streaming\n// then we have received an sample in paused mode so we can complete any state\n// transition. On leaving this function everything will be unlocked so an app\n// thread may get in and change our state to stopped (for example) in which\n// case it will also signal the thread event so that our wait call is stopped\n\nHRESULT CBaseRenderer::PrepareReceive(IMediaSample *pMediaSample)\n{\n    CAutoLock cInterfaceLock(&m_InterfaceLock);\n    m_bInReceive = TRUE;\n\n    // Check our flushing and filter state\n\n    // This function must hold the interface lock because it calls\n    // CBaseInputPin::Receive() and CBaseInputPin::Receive() uses\n    // CBasePin::m_bRunTimeError.\n    HRESULT hr = m_pInputPin->CBaseInputPin::Receive(pMediaSample);\n\n    if (hr != NOERROR)\n    {\n        m_bInReceive = FALSE;\n        return E_FAIL;\n    }\n\n    // Has the type changed on a media sample. We do all rendering\n    // synchronously on the source thread, which has a side effect\n    // that only one buffer is ever outstanding. Therefore when we\n    // have Receive called we can go ahead and change the format\n    // Since the format change can cause a SendMessage we just don't\n    // lock\n    if (m_pInputPin->SampleProps()->pMediaType)\n    {\n        hr = m_pInputPin->SetMediaType((CMediaType *)m_pInputPin->SampleProps()->pMediaType);\n        if (FAILED(hr))\n        {\n            m_bInReceive = FALSE;\n            return hr;\n        }\n    }\n\n    CAutoLock cSampleLock(&m_RendererLock);\n\n    ASSERT(IsActive() == TRUE);\n    ASSERT(m_pInputPin->IsFlushing() == FALSE);\n    ASSERT(m_pInputPin->IsConnected() == TRUE);\n    ASSERT(m_pMediaSample == NULL);\n\n    // Return an error if we already have a sample waiting for rendering\n    // source pins must serialise the Receive calls - we also check that\n    // no data is being sent after the source signalled an end of stream\n\n    if (m_pMediaSample || m_bEOS || m_bAbort)\n    {\n        Ready();\n        m_bInReceive = FALSE;\n        return E_UNEXPECTED;\n    }\n\n    // Store the media times from this sample\n    if (m_pPosition)\n        m_pPosition->RegisterMediaTime(pMediaSample);\n\n    // Schedule the next sample if we are streaming\n\n    if ((m_bStreaming == TRUE) && (ScheduleSample(pMediaSample) == FALSE))\n    {\n        ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));\n        ASSERT(CancelNotification() == S_FALSE);\n        m_bInReceive = FALSE;\n        return VFW_E_SAMPLE_REJECTED;\n    }\n\n    // Store the sample end time for EC_COMPLETE handling\n    m_SignalTime = m_pInputPin->SampleProps()->tStop;\n\n    // BEWARE we sometimes keep the sample even after returning the thread to\n    // the source filter such as when we go into a stopped state (we keep it\n    // to refresh the device with) so we must AddRef it to keep it safely. If\n    // we start flushing the source thread is released and any sample waiting\n    // will be released otherwise GetBuffer may never return (see BeginFlush)\n\n    m_pMediaSample = pMediaSample;\n    m_pMediaSample->AddRef();\n\n    if (m_bStreaming == FALSE)\n    {\n        SetRepaintStatus(TRUE);\n    }\n    return NOERROR;\n}\n\n// Called by the source filter when we have a sample to render. Under normal\n// circumstances we set an advise link with the clock, wait for the time to\n// arrive and then render the data using the PURE virtual DoRenderSample that\n// the derived class will have overriden. After rendering the sample we may\n// also signal EOS if it was the last one sent before EndOfStream was called\n\nHRESULT CBaseRenderer::Receive(IMediaSample *pSample)\n{\n    ASSERT(pSample);\n\n    // It may return VFW_E_SAMPLE_REJECTED code to say don't bother\n\n    HRESULT hr = PrepareReceive(pSample);\n    ASSERT(m_bInReceive == SUCCEEDED(hr));\n    if (FAILED(hr))\n    {\n        if (hr == VFW_E_SAMPLE_REJECTED)\n        {\n            return NOERROR;\n        }\n        return hr;\n    }\n\n    // We realize the palette in \"PrepareRender()\" so we have to give away the\n    // filter lock here.\n    if (m_State == State_Paused)\n    {\n        PrepareRender();\n        // no need to use InterlockedExchange\n        m_bInReceive = FALSE;\n        {\n            // We must hold both these locks\n            CAutoLock cRendererLock(&m_InterfaceLock);\n            if (m_State == State_Stopped)\n                return NOERROR;\n\n            m_bInReceive = TRUE;\n            CAutoLock cSampleLock(&m_RendererLock);\n            OnReceiveFirstSample(pSample);\n        }\n        Ready();\n    }\n    // Having set an advise link with the clock we sit and wait. We may be\n    // awoken by the clock firing or by a state change. The rendering call\n    // will lock the critical section and check we can still render the data\n\n    hr = WaitForRenderTime();\n    if (FAILED(hr))\n    {\n        m_bInReceive = FALSE;\n        return NOERROR;\n    }\n\n    PrepareRender();\n\n    //  Set this here and poll it until we work out the locking correctly\n    //  It can't be right that the streaming stuff grabs the interface\n    //  lock - after all we want to be able to wait for this stuff\n    //  to complete\n    m_bInReceive = FALSE;\n\n    // We must hold both these locks\n    CAutoLock cRendererLock(&m_InterfaceLock);\n\n    // since we gave away the filter wide lock, the sate of the filter could\n    // have chnaged to Stopped\n    if (m_State == State_Stopped)\n        return NOERROR;\n\n    CAutoLock cSampleLock(&m_RendererLock);\n\n    // Deal with this sample\n\n    Render(m_pMediaSample);\n    ClearPendingSample();\n    SendEndOfStream();\n    CancelNotification();\n    return NOERROR;\n}\n\n// This is called when we stop or are inactivated to clear the pending sample\n// We release the media sample interface so that they can be allocated to the\n// source filter again, unless of course we are changing state to inactive in\n// which case GetBuffer will return an error. We must also reset the current\n// media sample to NULL so that we know we do not currently have an image\n\nHRESULT CBaseRenderer::ClearPendingSample()\n{\n    CAutoLock cRendererLock(&m_RendererLock);\n    if (m_pMediaSample)\n    {\n        m_pMediaSample->Release();\n        m_pMediaSample = NULL;\n    }\n    return NOERROR;\n}\n\n// Used to signal end of stream according to the sample end time\n\nvoid CALLBACK EndOfStreamTimer(UINT uID,         // Timer identifier\n                               UINT uMsg,        // Not currently used\n                               DWORD_PTR dwUser, // User information\n                               DWORD_PTR dw1,    // Windows reserved\n                               DWORD_PTR dw2)    // is also reserved\n{\n    CBaseRenderer *pRenderer = (CBaseRenderer *)dwUser;\n    NOTE1(\"EndOfStreamTimer called (%d)\", uID);\n    pRenderer->TimerCallback();\n}\n\n//  Do the timer callback work\nvoid CBaseRenderer::TimerCallback()\n{\n    //  Lock for synchronization (but don't hold this lock when calling\n    //  timeKillEvent)\n    CAutoLock cRendererLock(&m_RendererLock);\n\n    // See if we should signal end of stream now\n\n    if (m_EndOfStreamTimer)\n    {\n        m_EndOfStreamTimer = 0;\n        SendEndOfStream();\n    }\n}\n\n// If we are at the end of the stream signal the filter graph but do not set\n// the state flag back to FALSE. Once we drop off the end of the stream we\n// leave the flag set (until a subsequent ResetEndOfStream). Each sample we\n// get delivered will update m_SignalTime to be the last sample's end time.\n// We must wait this long before signalling end of stream to the filtergraph\n\n#define TIMEOUT_DELIVERYWAIT 50\n#define TIMEOUT_RESOLUTION 10\n\nHRESULT CBaseRenderer::SendEndOfStream()\n{\n    ASSERT(CritCheckIn(&m_RendererLock));\n    if (m_bEOS == FALSE || m_bEOSDelivered || m_EndOfStreamTimer)\n    {\n        return NOERROR;\n    }\n\n    // If there is no clock then signal immediately\n    if (m_pClock == NULL)\n    {\n        return NotifyEndOfStream();\n    }\n\n    // How long into the future is the delivery time\n\n    REFERENCE_TIME Signal = m_tStart + m_SignalTime;\n    REFERENCE_TIME CurrentTime;\n    m_pClock->GetTime(&CurrentTime);\n    LONG Delay = LONG((Signal - CurrentTime) / 10000);\n\n    // Dump the timing information to the debugger\n\n    NOTE1(\"Delay until end of stream delivery %d\", Delay);\n    NOTE1(\"Current %s\", (LPCTSTR)CDisp((LONGLONG)CurrentTime));\n    NOTE1(\"Signal %s\", (LPCTSTR)CDisp((LONGLONG)Signal));\n\n    // Wait for the delivery time to arrive\n\n    if (Delay < TIMEOUT_DELIVERYWAIT)\n    {\n        return NotifyEndOfStream();\n    }\n\n    // Signal a timer callback on another worker thread\n\n    m_EndOfStreamTimer = CompatibleTimeSetEvent((UINT)Delay,        // Period of timer\n                                                TIMEOUT_RESOLUTION, // Timer resolution\n                                                EndOfStreamTimer,   // Callback function\n                                                DWORD_PTR(this),    // Used information\n                                                TIME_ONESHOT);      // Type of callback\n    if (m_EndOfStreamTimer == 0)\n    {\n        return NotifyEndOfStream();\n    }\n    return NOERROR;\n}\n\n// Signals EC_COMPLETE to the filtergraph manager\n\nHRESULT CBaseRenderer::NotifyEndOfStream()\n{\n    CAutoLock cRendererLock(&m_RendererLock);\n    ASSERT(m_bEOSDelivered == FALSE);\n    ASSERT(m_EndOfStreamTimer == 0);\n\n    // Has the filter changed state\n\n    if (m_bStreaming == FALSE)\n    {\n        ASSERT(m_EndOfStreamTimer == 0);\n        return NOERROR;\n    }\n\n    // Reset the end of stream timer\n    m_EndOfStreamTimer = 0;\n\n    // If we've been using the IMediaPosition interface, set it's start\n    // and end media \"times\" to the stop position by hand.  This ensures\n    // that we actually get to the end, even if the MPEG guestimate has\n    // been bad or if the quality management dropped the last few frames\n\n    if (m_pPosition)\n        m_pPosition->EOS();\n    m_bEOSDelivered = TRUE;\n    NOTE(\"Sending EC_COMPLETE...\");\n    return NotifyEvent(EC_COMPLETE, S_OK, (LONG_PTR)(IBaseFilter *)this);\n}\n\n// Reset the end of stream flag, this is typically called when we transfer to\n// stopped states since that resets the current position back to the start so\n// we will receive more samples or another EndOfStream if there aren't any. We\n// keep two separate flags one to say we have run off the end of the stream\n// (this is the m_bEOS flag) and another to say we have delivered EC_COMPLETE\n// to the filter graph. We need the latter otherwise we can end up sending an\n// EC_COMPLETE every time the source changes state and calls our EndOfStream\n\nHRESULT CBaseRenderer::ResetEndOfStream()\n{\n    ResetEndOfStreamTimer();\n    CAutoLock cRendererLock(&m_RendererLock);\n\n    m_bEOS = FALSE;\n    m_bEOSDelivered = FALSE;\n    m_SignalTime = 0;\n\n    return NOERROR;\n}\n\n// Kills any outstanding end of stream timer\n\nvoid CBaseRenderer::ResetEndOfStreamTimer()\n{\n    ASSERT(CritCheckOut(&m_RendererLock));\n    if (m_EndOfStreamTimer)\n    {\n        timeKillEvent(m_EndOfStreamTimer);\n        m_EndOfStreamTimer = 0;\n    }\n}\n\n// This is called when we start running so that we can schedule any pending\n// image we have with the clock and display any timing information. If we\n// don't have any sample but we have queued an EOS flag then we send it. If\n// we do have a sample then we wait until that has been rendered before we\n// signal the filter graph otherwise we may change state before it's done\n\nHRESULT CBaseRenderer::StartStreaming()\n{\n    CAutoLock cRendererLock(&m_RendererLock);\n    if (m_bStreaming == TRUE)\n    {\n        return NOERROR;\n    }\n\n    // Reset the streaming times ready for running\n\n    m_bStreaming = TRUE;\n\n    timeBeginPeriod(1);\n    OnStartStreaming();\n\n    // There should be no outstanding advise\n    ASSERT(WAIT_TIMEOUT == WaitForSingleObject((HANDLE)m_RenderEvent, 0));\n    ASSERT(CancelNotification() == S_FALSE);\n\n    // If we have an EOS and no data then deliver it now\n\n    if (m_pMediaSample == NULL)\n    {\n        return SendEndOfStream();\n    }\n\n    // Have the data rendered\n\n    ASSERT(m_pMediaSample);\n    if (!ScheduleSample(m_pMediaSample))\n        m_RenderEvent.Set();\n\n    return NOERROR;\n}\n\n// This is called when we stop streaming so that we can set our internal flag\n// indicating we are not now to schedule any more samples arriving. The state\n// change methods in the filter implementation take care of cancelling any\n// clock advise link we have set up and clearing any pending sample we have\n\nHRESULT CBaseRenderer::StopStreaming()\n{\n    CAutoLock cRendererLock(&m_RendererLock);\n    m_bEOSDelivered = FALSE;\n\n    if (m_bStreaming == TRUE)\n    {\n        m_bStreaming = FALSE;\n        OnStopStreaming();\n        timeEndPeriod(1);\n    }\n    return NOERROR;\n}\n\n// We have a boolean flag that is reset when we have signalled EC_REPAINT to\n// the filter graph. We set this when we receive an image so that should any\n// conditions arise again we can send another one. By having a flag we ensure\n// we don't flood the filter graph with redundant calls. We do not set the\n// event when we receive an EndOfStream call since there is no point in us\n// sending further EC_REPAINTs. In particular the AutoShowWindow method and\n// the DirectDraw object use this method to control the window repainting\n\nvoid CBaseRenderer::SetRepaintStatus(BOOL bRepaint)\n{\n    CAutoLock cSampleLock(&m_RendererLock);\n    m_bRepaintStatus = bRepaint;\n}\n\n// Pass the window handle to the upstream filter\n\nvoid CBaseRenderer::SendNotifyWindow(IPin *pPin, HWND hwnd)\n{\n    IMediaEventSink *pSink;\n\n    // Does the pin support IMediaEventSink\n    HRESULT hr = pPin->QueryInterface(IID_IMediaEventSink, (void **)&pSink);\n    if (SUCCEEDED(hr))\n    {\n        pSink->Notify(EC_NOTIFY_WINDOW, LONG_PTR(hwnd), 0);\n        pSink->Release();\n    }\n    NotifyEvent(EC_NOTIFY_WINDOW, LONG_PTR(hwnd), 0);\n}\n\n// Signal an EC_REPAINT to the filter graph. This can be used to have data\n// sent to us. For example when a video window is first displayed it may\n// not have an image to display, at which point it signals EC_REPAINT. The\n// filtergraph will either pause the graph if stopped or if already paused\n// it will call put_CurrentPosition of the current position. Setting the\n// current position to itself has the stream flushed and the image resent\n\n#define RLOG(_x_) DbgLog((LOG_TRACE, 1, TEXT(_x_)));\n\nvoid CBaseRenderer::SendRepaint()\n{\n    CAutoLock cSampleLock(&m_RendererLock);\n    ASSERT(m_pInputPin);\n\n    // We should not send repaint notifications when...\n    //    - An end of stream has been notified\n    //    - Our input pin is being flushed\n    //    - The input pin is not connected\n    //    - We have aborted a video playback\n    //    - There is a repaint already sent\n\n    if (m_bAbort == FALSE)\n    {\n        if (m_pInputPin->IsConnected() == TRUE)\n        {\n            if (m_pInputPin->IsFlushing() == FALSE)\n            {\n                if (IsEndOfStream() == FALSE)\n                {\n                    if (m_bRepaintStatus == TRUE)\n                    {\n                        IPin *pPin = (IPin *)m_pInputPin;\n                        NotifyEvent(EC_REPAINT, (LONG_PTR)pPin, 0);\n                        SetRepaintStatus(FALSE);\n                        RLOG(\"Sending repaint\");\n                    }\n                }\n            }\n        }\n    }\n}\n\n// When a video window detects a display change (WM_DISPLAYCHANGE message) it\n// can send an EC_DISPLAY_CHANGED event code along with the renderer pin. The\n// filtergraph will stop everyone and reconnect our input pin. As we're then\n// reconnected we can accept the media type that matches the new display mode\n// since we may no longer be able to draw the current image type efficiently\n\nBOOL CBaseRenderer::OnDisplayChange()\n{\n    // Ignore if we are not connected yet\n\n    CAutoLock cSampleLock(&m_RendererLock);\n    if (m_pInputPin->IsConnected() == FALSE)\n    {\n        return FALSE;\n    }\n\n    RLOG(\"Notification of EC_DISPLAY_CHANGE\");\n\n    // Pass our input pin as parameter on the event\n\n    IPin *pPin = (IPin *)m_pInputPin;\n    m_pInputPin->AddRef();\n    NotifyEvent(EC_DISPLAY_CHANGED, (LONG_PTR)pPin, 0);\n    SetAbortSignal(TRUE);\n    ClearPendingSample();\n    m_pInputPin->Release();\n\n    return TRUE;\n}\n\n// Called just before we start drawing.\n// Store the current time in m_trRenderStart to allow the rendering time to be\n// logged.  Log the time stamp of the sample and how late it is (neg is early)\n\nvoid CBaseRenderer::OnRenderStart(IMediaSample *pMediaSample)\n{\n#ifdef PERF\n    REFERENCE_TIME trStart, trEnd;\n    pMediaSample->GetTime(&trStart, &trEnd);\n\n    MSR_INTEGER(m_idBaseStamp, (int)trStart); // dump low order 32 bits\n\n    m_pClock->GetTime(&m_trRenderStart);\n    MSR_INTEGER(0, (int)m_trRenderStart);\n    REFERENCE_TIME trStream;\n    trStream = m_trRenderStart - m_tStart; // convert reftime to stream time\n    MSR_INTEGER(0, (int)trStream);\n\n    const int trLate = (int)(trStream - trStart);\n    MSR_INTEGER(m_idBaseAccuracy, trLate / 10000); // dump in mSec\n#endif\n\n} // OnRenderStart\n\n// Called directly after drawing an image.\n// calculate the time spent drawing and log it.\n\nvoid CBaseRenderer::OnRenderEnd(IMediaSample *pMediaSample)\n{\n#ifdef PERF\n    REFERENCE_TIME trNow;\n    m_pClock->GetTime(&trNow);\n    MSR_INTEGER(0, (int)trNow);\n    int t = (int)((trNow - m_trRenderStart) / 10000); // convert UNITS->msec\n    MSR_INTEGER(m_idBaseRenderTime, t);\n#endif\n} // OnRenderEnd\n\n// Constructor must be passed the base renderer object\n\nCRendererInputPin::CRendererInputPin(__inout CBaseRenderer *pRenderer, __inout HRESULT *phr, __in_opt LPCWSTR pPinName)\n    : CBaseInputPin(NAME(\"Renderer pin\"), pRenderer, &pRenderer->m_InterfaceLock, (HRESULT *)phr, pPinName)\n{\n    m_pRenderer = pRenderer;\n    ASSERT(m_pRenderer);\n}\n\n// Signals end of data stream on the input pin\n\nSTDMETHODIMP CRendererInputPin::EndOfStream()\n{\n    CAutoLock cRendererLock(&m_pRenderer->m_InterfaceLock);\n    CAutoLock cSampleLock(&m_pRenderer->m_RendererLock);\n\n    // Make sure we're streaming ok\n\n    HRESULT hr = CheckStreaming();\n    if (hr != NOERROR)\n    {\n        return hr;\n    }\n\n    // Pass it onto the renderer\n\n    hr = m_pRenderer->EndOfStream();\n    if (SUCCEEDED(hr))\n    {\n        hr = CBaseInputPin::EndOfStream();\n    }\n    return hr;\n}\n\n// Signals start of flushing on the input pin - we do the final reset end of\n// stream with the renderer lock unlocked but with the interface lock locked\n// We must do this because we call timeKillEvent, our timer callback method\n// has to take the renderer lock to serialise our state. Therefore holding a\n// renderer lock when calling timeKillEvent could cause a deadlock condition\n\nSTDMETHODIMP CRendererInputPin::BeginFlush()\n{\n    CAutoLock cRendererLock(&m_pRenderer->m_InterfaceLock);\n    {\n        CAutoLock cSampleLock(&m_pRenderer->m_RendererLock);\n        CBaseInputPin::BeginFlush();\n        m_pRenderer->BeginFlush();\n    }\n    return m_pRenderer->ResetEndOfStream();\n}\n\n// Signals end of flushing on the input pin\n\nSTDMETHODIMP CRendererInputPin::EndFlush()\n{\n    CAutoLock cRendererLock(&m_pRenderer->m_InterfaceLock);\n    CAutoLock cSampleLock(&m_pRenderer->m_RendererLock);\n\n    HRESULT hr = m_pRenderer->EndFlush();\n    if (SUCCEEDED(hr))\n    {\n        hr = CBaseInputPin::EndFlush();\n    }\n    return hr;\n}\n\n// Pass the sample straight through to the renderer object\n\nSTDMETHODIMP CRendererInputPin::Receive(IMediaSample *pSample)\n{\n    HRESULT hr = m_pRenderer->Receive(pSample);\n    if (FAILED(hr))\n    {\n\n        // A deadlock could occur if the caller holds the renderer lock and\n        // attempts to acquire the interface lock.\n        ASSERT(CritCheckOut(&m_pRenderer->m_RendererLock));\n\n        {\n            // The interface lock must be held when the filter is calling\n            // IsStopped() or IsFlushing().  The interface lock must also\n            // be held because the function uses m_bRunTimeError.\n            CAutoLock cRendererLock(&m_pRenderer->m_InterfaceLock);\n\n            // We do not report errors which occur while the filter is stopping,\n            // flushing or if the m_bAbort flag is set .  Errors are expected to\n            // occur during these operations and the streaming thread correctly\n            // handles the errors.\n            if (!IsStopped() && !IsFlushing() && !m_pRenderer->m_bAbort && !m_bRunTimeError)\n            {\n\n                // EC_ERRORABORT's first parameter is the error which caused\n                // the event and its' last parameter is 0.  See the Direct\n                // Show SDK documentation for more information.\n                m_pRenderer->NotifyEvent(EC_ERRORABORT, hr, 0);\n\n                {\n                    CAutoLock alRendererLock(&m_pRenderer->m_RendererLock);\n                    if (m_pRenderer->IsStreaming() && !m_pRenderer->IsEndOfStreamDelivered())\n                    {\n                        m_pRenderer->NotifyEndOfStream();\n                    }\n                }\n\n                m_bRunTimeError = TRUE;\n            }\n        }\n    }\n\n    return hr;\n}\n\n// Called when the input pin is disconnected\n\nHRESULT CRendererInputPin::BreakConnect()\n{\n    HRESULT hr = m_pRenderer->BreakConnect();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return CBaseInputPin::BreakConnect();\n}\n\n// Called when the input pin is connected\n\nHRESULT CRendererInputPin::CompleteConnect(IPin *pReceivePin)\n{\n    HRESULT hr = m_pRenderer->CompleteConnect(pReceivePin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return CBaseInputPin::CompleteConnect(pReceivePin);\n}\n\n// Give the pin id of our one and only pin\n\nSTDMETHODIMP CRendererInputPin::QueryId(__deref_out LPWSTR *Id)\n{\n    CheckPointer(Id, E_POINTER);\n\n    const WCHAR szIn[] = L\"In\";\n\n    *Id = (LPWSTR)CoTaskMemAlloc(sizeof(szIn));\n    if (*Id == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n    CopyMemory(*Id, szIn, sizeof(szIn));\n    return NOERROR;\n}\n\n// Will the filter accept this media type\n\nHRESULT CRendererInputPin::CheckMediaType(const CMediaType *pmt)\n{\n    return m_pRenderer->CheckMediaType(pmt);\n}\n\n// Called when we go paused or running\n\nHRESULT CRendererInputPin::Active()\n{\n    return m_pRenderer->Active();\n}\n\n// Called when we go into a stopped state\n\nHRESULT CRendererInputPin::Inactive()\n{\n    // The caller must hold the interface lock because\n    // this function uses m_bRunTimeError.\n    ASSERT(CritCheckIn(&m_pRenderer->m_InterfaceLock));\n\n    m_bRunTimeError = FALSE;\n\n    return m_pRenderer->Inactive();\n}\n\n// Tell derived classes about the media type agreed\n\nHRESULT CRendererInputPin::SetMediaType(const CMediaType *pmt)\n{\n    HRESULT hr = CBaseInputPin::SetMediaType(pmt);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return m_pRenderer->SetMediaType(pmt);\n}\n\n// We do not keep an event object to use when setting up a timer link with\n// the clock but are given a pointer to one by the owning object through the\n// SetNotificationObject method - this must be initialised before starting\n// We can override the default quality management process to have it always\n// draw late frames, this is currently done by having the following registry\n// key (actually an INI key) called DrawLateFrames set to 1 (default is 0)\n\nconst TCHAR AMQUALITY[] = TEXT(\"ActiveMovie\");\nconst TCHAR DRAWLATEFRAMES[] = TEXT(\"DrawLateFrames\");\n\nCBaseVideoRenderer::CBaseVideoRenderer(REFCLSID RenderClass,       // CLSID for this renderer\n                                       __in_opt LPCTSTR pName,     // Debug ONLY description\n                                       __inout_opt LPUNKNOWN pUnk, // Aggregated owner object\n                                       __inout HRESULT *phr)\n    : // General OLE return code\n\n    CBaseRenderer(RenderClass, pName, pUnk, phr)\n    , m_cFramesDropped(0)\n    , m_cFramesDrawn(0)\n    , m_bSupplierHandlingQuality(FALSE)\n{\n    ResetStreamingTimes();\n\n#ifdef PERF\n    m_idTimeStamp = MSR_REGISTER(TEXT(\"Frame time stamp\"));\n    m_idEarliness = MSR_REGISTER(TEXT(\"Earliness fudge\"));\n    m_idTarget = MSR_REGISTER(TEXT(\"Target (mSec)\"));\n    m_idSchLateTime = MSR_REGISTER(TEXT(\"mSec late when scheduled\"));\n    m_idDecision = MSR_REGISTER(TEXT(\"Scheduler decision code\"));\n    m_idQualityRate = MSR_REGISTER(TEXT(\"Quality rate sent\"));\n    m_idQualityTime = MSR_REGISTER(TEXT(\"Quality time sent\"));\n    m_idWaitReal = MSR_REGISTER(TEXT(\"Render wait\"));\n    // m_idWait            = MSR_REGISTER(TEXT(\"wait time recorded (msec)\"));\n    m_idFrameAccuracy = MSR_REGISTER(TEXT(\"Frame accuracy (msecs)\"));\n    m_bDrawLateFrames = GetProfileInt(AMQUALITY, DRAWLATEFRAMES, FALSE);\n    // m_idSendQuality      = MSR_REGISTER(TEXT(\"Processing Quality message\"));\n\n    m_idRenderAvg = MSR_REGISTER(TEXT(\"Render draw time Avg\"));\n    m_idFrameAvg = MSR_REGISTER(TEXT(\"FrameAvg\"));\n    m_idWaitAvg = MSR_REGISTER(TEXT(\"WaitAvg\"));\n    m_idDuration = MSR_REGISTER(TEXT(\"Duration\"));\n    m_idThrottle = MSR_REGISTER(TEXT(\"Audio-video throttle wait\"));\n    // m_idDebug           = MSR_REGISTER(TEXT(\"Debug stuff\"));\n#endif // PERF\n} // Constructor\n\n// Destructor is just a placeholder\n\nCBaseVideoRenderer::~CBaseVideoRenderer()\n{\n    ASSERT(m_dwAdvise == 0);\n}\n\n// The timing functions in this class are called by the window object and by\n// the renderer's allocator.\n// The windows object calls timing functions as it receives media sample\n// images for drawing using GDI.\n// The allocator calls timing functions when it starts passing DCI/DirectDraw\n// surfaces which are not rendered in the same way; The decompressor writes\n// directly to the surface with no separate rendering, so those code paths\n// call direct into us.  Since we only ever hand out DCI/DirectDraw surfaces\n// when we have allocated one and only one image we know there cannot be any\n// conflict between the two.\n//\n// We use timeGetTime to return the timing counts we use (since it's relative\n// performance we are interested in rather than absolute compared to a clock)\n// The window object sets the accuracy of the system clock (normally 1ms) by\n// calling timeBeginPeriod/timeEndPeriod when it changes streaming states\n\n// Reset all times controlling streaming.\n// Set them so that\n// 1. Frames will not initially be dropped\n// 2. The first frame will definitely be drawn (achieved by saying that there\n//    has not ben a frame drawn for a long time).\n\nHRESULT CBaseVideoRenderer::ResetStreamingTimes()\n{\n    m_trLastDraw = -1000; // set up as first frame since ages (1 sec) ago\n    m_tStreamingStart = timeGetTime();\n    m_trRenderAvg = 0;\n    m_trFrameAvg = -1; // -1000 fps == \"unset\"\n    m_trDuration = 0;  // 0 - strange value\n    m_trRenderLast = 0;\n    m_trWaitAvg = 0;\n    m_tRenderStart = 0;\n    m_cFramesDrawn = 0;\n    m_cFramesDropped = 0;\n    m_iTotAcc = 0;\n    m_iSumSqAcc = 0;\n    m_iSumSqFrameTime = 0;\n    m_trFrame = 0; // hygeine - not really needed\n    m_trLate = 0;  // hygeine - not really needed\n    m_iSumFrameTime = 0;\n    m_nNormal = 0;\n    m_trEarliness = 0;\n    m_trTarget = -300000; // 30mSec early\n    m_trThrottle = 0;\n    m_trRememberStampForPerf = 0;\n\n#ifdef PERF\n    m_trRememberFrameForPerf = 0;\n#endif\n\n    return NOERROR;\n} // ResetStreamingTimes\n\n// Reset all times controlling streaming. Note that we're now streaming. We\n// don't need to set the rendering event to have the source filter released\n// as it is done during the Run processing. When we are run we immediately\n// release the source filter thread and draw any image waiting (that image\n// may already have been drawn once as a poster frame while we were paused)\n\nHRESULT CBaseVideoRenderer::OnStartStreaming()\n{\n    ResetStreamingTimes();\n    return NOERROR;\n} // OnStartStreaming\n\n// Called at end of streaming.  Fixes times for property page report\n\nHRESULT CBaseVideoRenderer::OnStopStreaming()\n{\n    m_tStreamingStart = timeGetTime() - m_tStreamingStart;\n    return NOERROR;\n} // OnStopStreaming\n\n// Called when we start waiting for a rendering event.\n// Used to update times spent waiting and not waiting.\n\nvoid CBaseVideoRenderer::OnWaitStart()\n{\n    MSR_START(m_idWaitReal);\n} // OnWaitStart\n\n// Called when we are awoken from the wait in the window OR by our allocator\n// when it is hanging around until the next sample is due for rendering on a\n// DCI/DirectDraw surface. We add the wait time into our rolling average.\n// We grab the interface lock so that we're serialised with the application\n// thread going through the run code - which in due course ends up calling\n// ResetStreaming times - possibly as we run through this section of code\n\nvoid CBaseVideoRenderer::OnWaitEnd()\n{\n#ifdef PERF\n    MSR_STOP(m_idWaitReal);\n    // for a perf build we want to know just exactly how late we REALLY are.\n    // even if this means that we have to look at the clock again.\n\n    REFERENCE_TIME trRealStream; // the real time now expressed as stream time.\n#if 0\n    m_pClock->GetTime(&trRealStream); // Calling clock here causes W95 deadlock!\n#else\n    // We will be discarding overflows like mad here!\n    // This is wrong really because timeGetTime() can wrap but it's\n    // only for PERF\n    REFERENCE_TIME tr = timeGetTime() * 10000;\n    trRealStream = tr + m_llTimeOffset;\n#endif\n    trRealStream -= m_tStart; // convert to stream time (this is a reftime)\n\n    if (m_trRememberStampForPerf == 0)\n    {\n        // This is probably the poster frame at the start, and it is not scheduled\n        // in the usual way at all.  Just count it.  The rememberstamp gets set\n        // in ShouldDrawSampleNow, so this does invalid frame recording until we\n        // actually start playing.\n        PreparePerformanceData(0, 0);\n    }\n    else\n    {\n        int trLate = (int)(trRealStream - m_trRememberStampForPerf);\n        int trFrame = (int)(tr - m_trRememberFrameForPerf);\n        PreparePerformanceData(trLate, trFrame);\n    }\n    m_trRememberFrameForPerf = tr;\n#endif // PERF\n} // OnWaitEnd\n\n// Put data on one side that describes the lateness of the current frame.\n// We don't yet know whether it will actually be drawn.  In direct draw mode,\n// this decision is up to the filter upstream, and it could change its mind.\n// The rules say that if it did draw it must call Receive().  One way or\n// another we eventually get into either OnRenderStart or OnDirectRender and\n// these both call RecordFrameLateness to update the statistics.\n\nvoid CBaseVideoRenderer::PreparePerformanceData(int trLate, int trFrame)\n{\n    m_trLate = trLate;\n    m_trFrame = trFrame;\n} // PreparePerformanceData\n\n// update the statistics:\n// m_iTotAcc, m_iSumSqAcc, m_iSumSqFrameTime, m_iSumFrameTime, m_cFramesDrawn\n// Note that because the properties page reports using these variables,\n// 1. We need to be inside a critical section\n// 2. They must all be updated together.  Updating the sums here and the count\n// elsewhere can result in imaginary jitter (i.e. attempts to find square roots\n// of negative numbers) in the property page code.\n\nvoid CBaseVideoRenderer::RecordFrameLateness(int trLate, int trFrame)\n{\n    // Record how timely we are.\n    int tLate = trLate / 10000;\n\n    // Best estimate of moment of appearing on the screen is average of\n    // start and end draw times.  Here we have only the end time.  This may\n    // tend to show us as spuriously late by up to 1/2 frame rate achieved.\n    // Decoder probably monitors draw time.  We don't bother.\n    MSR_INTEGER(m_idFrameAccuracy, tLate);\n\n    // This is a kludge - we can get frames that are very late\n    // especially (at start-up) and they invalidate the statistics.\n    // So ignore things that are more than 1 sec off.\n    if (tLate > 1000 || tLate < -1000)\n    {\n        if (m_cFramesDrawn <= 1)\n        {\n            tLate = 0;\n        }\n        else if (tLate > 0)\n        {\n            tLate = 1000;\n        }\n        else\n        {\n            tLate = -1000;\n        }\n    }\n    // The very first frame often has a invalid time, so don't\n    // count it into the statistics.   (???)\n    if (m_cFramesDrawn > 1)\n    {\n        m_iTotAcc += tLate;\n        m_iSumSqAcc += (tLate * tLate);\n    }\n\n    // calculate inter-frame time.  Doesn't make sense for first frame\n    // second frame suffers from invalid first frame stamp.\n    if (m_cFramesDrawn > 2)\n    {\n        int tFrame = trFrame / 10000; // convert to mSec else it overflows\n\n        // This is a kludge.  It can overflow anyway (a pause can cause\n        // a very long inter-frame time) and it overflows at 2**31/10**7\n        // or about 215 seconds i.e. 3min 35sec\n        if (tFrame > 1000 || tFrame < 0)\n            tFrame = 1000;\n        m_iSumSqFrameTime += tFrame * tFrame;\n        ASSERT(m_iSumSqFrameTime >= 0);\n        m_iSumFrameTime += tFrame;\n    }\n    ++m_cFramesDrawn;\n\n} // RecordFrameLateness\n\nvoid CBaseVideoRenderer::ThrottleWait()\n{\n    if (m_trThrottle > 0)\n    {\n        int iThrottle = m_trThrottle / 10000; // convert to mSec\n        MSR_INTEGER(m_idThrottle, iThrottle);\n        DbgLog((LOG_TRACE, 0, TEXT(\"Throttle %d ms\"), iThrottle));\n        Sleep(iThrottle);\n    }\n    else\n    {\n        Sleep(0);\n    }\n} // ThrottleWait\n\n// Whenever a frame is rendered it goes though either OnRenderStart\n// or OnDirectRender.  Data that are generated during ShouldDrawSample\n// are added to the statistics by calling RecordFrameLateness from both\n// these two places.\n\n// Called in place of OnRenderStart..OnRenderEnd\n// When a DirectDraw image is drawn\nvoid CBaseVideoRenderer::OnDirectRender(IMediaSample *pMediaSample)\n{\n    m_trRenderAvg = 0;\n    m_trRenderLast = 5000000; // If we mode switch, we do NOT want this\n                              // to inhibit the new average getting going!\n                              // so we set it to half a second\n    // MSR_INTEGER(m_idRenderAvg, m_trRenderAvg/10000);\n    RecordFrameLateness(m_trLate, m_trFrame);\n    ThrottleWait();\n} // OnDirectRender\n\n// Called just before we start drawing.  All we do is to get the current clock\n// time (from the system) and return.  We have to store the start render time\n// in a member variable because it isn't used until we complete the drawing\n// The rest is just performance logging.\n\nvoid CBaseVideoRenderer::OnRenderStart(IMediaSample *pMediaSample)\n{\n    RecordFrameLateness(m_trLate, m_trFrame);\n    m_tRenderStart = timeGetTime();\n} // OnRenderStart\n\n// Called directly after drawing an image.  We calculate the time spent in the\n// drawing code and if this doesn't appear to have any odd looking spikes in\n// it then we add it to the current average draw time.  Measurement spikes may\n// occur if the drawing thread is interrupted and switched to somewhere else.\n\nvoid CBaseVideoRenderer::OnRenderEnd(IMediaSample *pMediaSample)\n{\n    // The renderer time can vary erratically if we are interrupted so we do\n    // some smoothing to help get more sensible figures out but even that is\n    // not enough as figures can go 9,10,9,9,83,9 and we must disregard 83\n\n    int tr = (timeGetTime() - m_tRenderStart) * 10000; // convert mSec->UNITS\n    if (tr < m_trRenderAvg * 2 || tr < 2 * m_trRenderLast)\n    {\n        // DO_MOVING_AVG(m_trRenderAvg, tr);\n        m_trRenderAvg = (tr + (AVGPERIOD - 1) * m_trRenderAvg) / AVGPERIOD;\n    }\n    m_trRenderLast = tr;\n    ThrottleWait();\n} // OnRenderEnd\n\nSTDMETHODIMP CBaseVideoRenderer::SetSink(IQualityControl *piqc)\n{\n\n    m_pQSink = piqc;\n\n    return NOERROR;\n} // SetSink\n\nSTDMETHODIMP CBaseVideoRenderer::Notify(IBaseFilter *pSelf, Quality q)\n{\n    // NOTE:  We are NOT getting any locks here.  We could be called\n    // asynchronously and possibly even on a time critical thread of\n    // someone else's - so we do the minumum.  We only set one state\n    // variable (an integer) and if that happens to be in the middle\n    // of another thread reading it they will just get either the new\n    // or the old value.  Locking would achieve no more than this.\n\n    // It might be nice to check that we are being called from m_pGraph, but\n    // it turns out to be a millisecond or so per throw!\n\n    // This is heuristics, these numbers are aimed at being \"what works\"\n    // rather than anything based on some theory.\n    // We use a hyperbola because it's easy to calculate and it includes\n    // a panic button asymptote (which we push off just to the left)\n    // The throttling fits the following table (roughly)\n    // Proportion   Throttle (msec)\n    //     >=1000         0\n    //        900         3\n    //        800         7\n    //        700        11\n    //        600        17\n    //        500        25\n    //        400        35\n    //        300        50\n    //        200        72\n    //        125       100\n    //        100       112\n    //         50       146\n    //          0       200\n\n    // (some evidence that we could go for a sharper kink - e.g. no throttling\n    // until below the 750 mark - might give fractionally more frames on a\n    // P60-ish machine).  The easy way to get these coefficients is to use\n    // Renbase.xls follow the instructions therein using excel solver.\n\n    if (q.Proportion >= 1000)\n    {\n        m_trThrottle = 0;\n    }\n    else\n    {\n        // The DWORD is to make quite sure I get unsigned arithmetic\n        // as the constant is between 2**31 and 2**32\n        m_trThrottle = -330000 + (388880000 / (q.Proportion + 167));\n    }\n    return NOERROR;\n} // Notify\n\n// Send a message to indicate what our supplier should do about quality.\n// Theory:\n// What a supplier wants to know is \"is the frame I'm working on NOW\n// going to be late?\".\n// F1 is the frame at the supplier (as above)\n// Tf1 is the due time for F1\n// T1 is the time at that point (NOW!)\n// Tr1 is the time that f1 WILL actually be rendered\n// L1 is the latency of the graph for frame F1 = Tr1-T1\n// D1 (for delay) is how late F1 will be beyond its due time i.e.\n// D1 = (Tr1-Tf1) which is what the supplier really wants to know.\n// Unfortunately Tr1 is in the future and is unknown, so is L1\n//\n// We could estimate L1 by its value for a previous frame,\n// L0 = Tr0-T0 and work off\n// D1' = ((T1+L0)-Tf1) = (T1 + (Tr0-T0) -Tf1)\n// Rearranging terms:\n// D1' = (T1-T0) + (Tr0-Tf1)\n//       adding (Tf0-Tf0) and rearranging again:\n//     = (T1-T0) + (Tr0-Tf0) + (Tf0-Tf1)\n//     = (T1-T0) - (Tf1-Tf0) + (Tr0-Tf0)\n// But (Tr0-Tf0) is just D0 - how late frame zero was, and this is the\n// Late field in the quality message that we send.\n// The other two terms just state what correction should be applied before\n// using the lateness of F0 to predict the lateness of F1.\n// (T1-T0) says how much time has actually passed (we have lost this much)\n// (Tf1-Tf0) says how much time should have passed if we were keeping pace\n// (we have gained this much).\n//\n// Suppliers should therefore work off:\n//    Quality.Late + (T1-T0)  - (Tf1-Tf0)\n// and see if this is \"acceptably late\" or even early (i.e. negative).\n// They get T1 and T0 by polling the clock, they get Tf1 and Tf0 from\n// the time stamps in the frames.  They get Quality.Late from us.\n//\n\nHRESULT CBaseVideoRenderer::SendQuality(REFERENCE_TIME trLate, REFERENCE_TIME trRealStream)\n{\n    Quality q;\n    HRESULT hr;\n\n    // If we are the main user of time, then report this as Flood/Dry.\n    // If our suppliers are, then report it as Famine/Glut.\n    //\n    // We need to take action, but avoid hunting.  Hunting is caused by\n    // 1. Taking too much action too soon and overshooting\n    // 2. Taking too long to react (so averaging can CAUSE hunting).\n    //\n    // The reason why we use trLate as well as Wait is to reduce hunting;\n    // if the wait time is coming down and about to go into the red, we do\n    // NOT want to rely on some average which is only telling is that it used\n    // to be OK once.\n\n    q.TimeStamp = (REFERENCE_TIME)trRealStream;\n\n    if (m_trFrameAvg < 0)\n    {\n        q.Type = Famine; // guess\n    }\n    // Is the greater part of the time taken bltting or something else\n    else if (m_trFrameAvg > 2 * m_trRenderAvg)\n    {\n        q.Type = Famine; // mainly other\n    }\n    else\n    {\n        q.Type = Flood; // mainly bltting\n    }\n\n    q.Proportion = 1000; // default\n\n    if (m_trFrameAvg < 0)\n    {\n        // leave it alone - we don't know enough\n    }\n    else if (trLate > 0)\n    {\n        // try to catch up over the next second\n        // We could be Really, REALLY late, but rendering all the frames\n        // anyway, just because it's so cheap.\n\n        q.Proportion = 1000 - (int)((trLate) / (UNITS / 1000));\n        if (q.Proportion < 500)\n        {\n            q.Proportion = 500; // don't go daft. (could've been negative!)\n        }\n        else\n        {\n        }\n    }\n    else if (m_trWaitAvg > 20000 && trLate < -20000)\n    {\n        // Go cautiously faster - aim at 2mSec wait.\n        if (m_trWaitAvg >= m_trFrameAvg)\n        {\n            // This can happen because of some fudges.\n            // The waitAvg is how long we originally planned to wait\n            // The frameAvg is more honest.\n            // It means that we are spending a LOT of time waiting\n            q.Proportion = 2000; // double.\n        }\n        else\n        {\n            if (m_trFrameAvg + 20000 > m_trWaitAvg)\n            {\n                q.Proportion = 1000 * (m_trFrameAvg / (m_trFrameAvg + 20000 - m_trWaitAvg));\n            }\n            else\n            {\n                // We're apparently spending more than the whole frame time waiting.\n                // Assume that the averages are slightly out of kilter, but that we\n                // are indeed doing a lot of waiting.  (This leg probably never\n                // happens, but the code avoids any potential divide by zero).\n                q.Proportion = 2000;\n            }\n        }\n\n        if (q.Proportion > 2000)\n        {\n            q.Proportion = 2000; // don't go crazy.\n        }\n    }\n\n    // Tell the supplier how late frames are when they get rendered\n    // That's how late we are now.\n    // If we are in directdraw mode then the guy upstream can see the drawing\n    // times and we'll just report on the start time.  He can figure out any\n    // offset to apply.  If we are in DIB Section mode then we will apply an\n    // extra offset which is half of our drawing time.  This is usually small\n    // but can sometimes be the dominant effect.  For this we will use the\n    // average drawing time rather than the last frame.  If the last frame took\n    // a long time to draw and made us late, that's already in the lateness\n    // figure.  We should not add it in again unless we expect the next frame\n    // to be the same.  We don't, we expect the average to be a better shot.\n    // In direct draw mode the RenderAvg will be zero.\n\n    q.Late = trLate + m_trRenderAvg / 2;\n\n    // log what we're doing\n    MSR_INTEGER(m_idQualityRate, q.Proportion);\n    MSR_INTEGER(m_idQualityTime, (int)q.Late / 10000);\n\n    // A specific sink interface may be set through IPin\n\n    if (m_pQSink == NULL)\n    {\n        // Get our input pin's peer.  We send quality management messages\n        // to any nominated receiver of these things (set in the IPin\n        // interface), or else to our source filter.\n\n        IQualityControl *pQC = NULL;\n        IPin *pOutputPin = m_pInputPin->GetConnected();\n        ASSERT(pOutputPin != NULL);\n\n        // And get an AddRef'd quality control interface\n\n        hr = pOutputPin->QueryInterface(IID_IQualityControl, (void **)&pQC);\n        if (SUCCEEDED(hr))\n        {\n            m_pQSink = pQC;\n        }\n    }\n    if (m_pQSink)\n    {\n        return m_pQSink->Notify(this, q);\n    }\n\n    return S_FALSE;\n\n} // SendQuality\n\n// We are called with a valid IMediaSample image to decide whether this is to\n// be drawn or not.  There must be a reference clock in operation.\n// Return S_OK if it is to be drawn Now (as soon as possible)\n// Return S_FALSE if it is to be drawn when it's due\n// Return an error if we want to drop it\n// m_nNormal=-1 indicates that we dropped the previous frame and so this\n// one should be drawn early.  Respect it and update it.\n// Use current stream time plus a number of heuristics (detailed below)\n// to make the decision\n\nHRESULT CBaseVideoRenderer::ShouldDrawSampleNow(IMediaSample *pMediaSample, __inout REFERENCE_TIME *ptrStart,\n                                                __inout REFERENCE_TIME *ptrEnd)\n{\n\n    // Don't call us unless there's a clock interface to synchronise with\n    ASSERT(m_pClock);\n\n    MSR_INTEGER(m_idTimeStamp, (int)((*ptrStart) >> 32)); // high order 32 bits\n    MSR_INTEGER(m_idTimeStamp, (int)(*ptrStart));         // low order 32 bits\n\n    // We lose a bit of time depending on the monitor type waiting for the next\n    // screen refresh.  On average this might be about 8mSec - so it will be\n    // later than we think when the picture appears.  To compensate a bit\n    // we bias the media samples by -8mSec i.e. 80000 UNITs.\n    // We don't ever make a stream time negative (call it paranoia)\n    if (*ptrStart >= 80000)\n    {\n        *ptrStart -= 80000;\n        *ptrEnd -= 80000; // bias stop to to retain valid frame duration\n    }\n\n    // Cache the time stamp now.  We will want to compare what we did with what\n    // we started with (after making the monitor allowance).\n    m_trRememberStampForPerf = *ptrStart;\n\n    // Get reference times (current and late)\n    REFERENCE_TIME trRealStream; // the real time now expressed as stream time.\n    m_pClock->GetTime(&trRealStream);\n#ifdef PERF\n    // While the reference clock is expensive:\n    // Remember the offset from timeGetTime and use that.\n    // This overflows all over the place, but when we subtract to get\n    // differences the overflows all cancel out.\n    m_llTimeOffset = trRealStream - timeGetTime() * 10000;\n#endif\n    trRealStream -= m_tStart; // convert to stream time (this is a reftime)\n\n    // We have to wory about two versions of \"lateness\".  The truth, which we\n    // try to work out here and the one measured against m_trTarget which\n    // includes long term feedback.  We report statistics against the truth\n    // but for operational decisions we work to the target.\n    // We use TimeDiff to make sure we get an integer because we\n    // may actually be late (or more likely early if there is a big time\n    // gap) by a very long time.\n    const int trTrueLate = TimeDiff(trRealStream - *ptrStart);\n    const int trLate = trTrueLate;\n\n    MSR_INTEGER(m_idSchLateTime, trTrueLate / 10000);\n\n    // Send quality control messages upstream, measured against target\n    HRESULT hr = SendQuality(trLate, trRealStream);\n    // Note: the filter upstream is allowed to this FAIL meaning \"you do it\".\n    m_bSupplierHandlingQuality = (hr == S_OK);\n\n    // Decision time!  Do we drop, draw when ready or draw immediately?\n\n    const int trDuration = (int)(*ptrEnd - *ptrStart);\n    {\n        // We need to see if the frame rate of the file has just changed.\n        // This would make comparing our previous frame rate with the current\n        // frame rate inefficent.  Hang on a moment though.  I've seen files\n        // where the frames vary between 33 and 34 mSec so as to average\n        // 30fps.  A minor variation like that won't hurt us.\n        int t = m_trDuration / 32;\n        if (trDuration > m_trDuration + t || trDuration < m_trDuration - t)\n        {\n            // There's a major variation.  Reset the average frame rate to\n            // exactly the current rate to disable decision 9002 for this frame,\n            // and remember the new rate.\n            m_trFrameAvg = trDuration;\n            m_trDuration = trDuration;\n        }\n    }\n\n    MSR_INTEGER(m_idEarliness, m_trEarliness / 10000);\n    MSR_INTEGER(m_idRenderAvg, m_trRenderAvg / 10000);\n    MSR_INTEGER(m_idFrameAvg, m_trFrameAvg / 10000);\n    MSR_INTEGER(m_idWaitAvg, m_trWaitAvg / 10000);\n    MSR_INTEGER(m_idDuration, trDuration / 10000);\n\n#ifdef PERF\n    if (S_OK == pMediaSample->IsDiscontinuity())\n    {\n        MSR_INTEGER(m_idDecision, 9000);\n    }\n#endif\n\n    // Control the graceful slide back from slow to fast machine mode.\n    // After a frame drop accept an early frame and set the earliness to here\n    // If this frame is already later than the earliness then slide it to here\n    // otherwise do the standard slide (reduce by about 12% per frame).\n    // Note: earliness is normally NEGATIVE\n    BOOL bJustDroppedFrame = (m_bSupplierHandlingQuality\n                              //  Can't use the pin sample properties because we might\n                              //  not be in Receive when we call this\n                              && (S_OK == pMediaSample->IsDiscontinuity()) // he just dropped one\n                              ) ||\n                             (m_nNormal == -1); // we just dropped one\n\n    // Set m_trEarliness (slide back from slow to fast machine mode)\n    if (trLate > 0)\n    {\n        m_trEarliness = 0; // we are no longer in fast machine mode at all!\n    }\n    else if ((trLate >= m_trEarliness) || bJustDroppedFrame)\n    {\n        m_trEarliness = trLate; // Things have slipped of their own accord\n    }\n    else\n    {\n        m_trEarliness = m_trEarliness - m_trEarliness / 8; // graceful slide\n    }\n\n    // prepare the new wait average - but don't pollute the old one until\n    // we have finished with it.\n    int trWaitAvg;\n    {\n        // We never mix in a negative wait.  This causes us to believe in fast machines\n        // slightly more.\n        int trL = trLate < 0 ? -trLate : 0;\n        trWaitAvg = (trL + m_trWaitAvg * (AVGPERIOD - 1)) / AVGPERIOD;\n    }\n\n    int trFrame;\n    {\n        REFERENCE_TIME tr = trRealStream - m_trLastDraw; // Cd be large - 4 min pause!\n        if (tr > 10000000)\n        {\n            tr = 10000000; // 1 second - arbitrarily.\n        }\n        trFrame = int(tr);\n    }\n\n    // We will DRAW this frame IF...\n    if (\n        // ...the time we are spending drawing is a small fraction of the total\n        // observed inter-frame time so that dropping it won't help much.\n        (3 * m_trRenderAvg <= m_trFrameAvg)\n\n        // ...or our supplier is NOT handling things and the next frame would\n        // be less timely than this one or our supplier CLAIMS to be handling\n        // things, and is now less than a full FOUR frames late.\n        || (m_bSupplierHandlingQuality ? (trLate <= trDuration * 4) : (trLate + trLate < trDuration))\n\n        // ...or we are on average waiting for over eight milliseconds then\n        // this may be just a glitch.  Draw it and we'll hope to catch up.\n        || (m_trWaitAvg > 80000)\n\n        // ...or we haven't drawn an image for over a second.  We will update\n        // the display, which stops the video looking hung.\n        // Do this regardless of how late this media sample is.\n        || ((trRealStream - m_trLastDraw) > UNITS)\n\n    )\n    {\n        HRESULT Result;\n\n        // We are going to play this frame.  We may want to play it early.\n        // We will play it early if we think we are in slow machine mode.\n        // If we think we are NOT in slow machine mode, we will still play\n        // it early by m_trEarliness as this controls the graceful slide back.\n        // and in addition we aim at being m_trTarget late rather than \"on time\".\n\n        BOOL bPlayASAP = FALSE;\n\n        // we will play it AT ONCE (slow machine mode) if...\n\n        // ...we are playing catch-up\n        if (bJustDroppedFrame)\n        {\n            bPlayASAP = TRUE;\n            MSR_INTEGER(m_idDecision, 9001);\n        }\n\n        // ...or if we are running below the true frame rate\n        // exact comparisons are glitchy, for these measurements,\n        // so add an extra 5% or so\n        else if ((m_trFrameAvg > trDuration + trDuration / 16)\n\n                 // It's possible to get into a state where we are losing ground, but\n                 // are a very long way ahead.  To avoid this or recover from it\n                 // we refuse to play early by more than 10 frames.\n                 && (trLate > -trDuration * 10))\n        {\n            bPlayASAP = TRUE;\n            MSR_INTEGER(m_idDecision, 9002);\n        }\n#if 0\n            // ...or if we have been late and are less than one frame early\n        else if (  (trLate + trDuration > 0)\n                && (m_trWaitAvg<=20000)\n                ) {\n            bPlayASAP = TRUE;\n            MSR_INTEGER(m_idDecision, 9003);\n        }\n#endif\n        // We will NOT play it at once if we are grossly early.  On very slow frame\n        // rate movies - e.g. clock.avi - it is not a good idea to leap ahead just\n        // because we got starved (for instance by the net) and dropped one frame\n        // some time or other.  If we are more than 900mSec early, then wait.\n        if (trLate < -9000000)\n        {\n            bPlayASAP = FALSE;\n        }\n\n        if (bPlayASAP)\n        {\n\n            m_nNormal = 0;\n            MSR_INTEGER(m_idDecision, 0);\n            // When we are here, we are in slow-machine mode.  trLate may well\n            // oscillate between negative and positive when the supplier is\n            // dropping frames to keep sync.  We should not let that mislead\n            // us into thinking that we have as much as zero spare time!\n            // We just update with a zero wait.\n            m_trWaitAvg = (m_trWaitAvg * (AVGPERIOD - 1)) / AVGPERIOD;\n\n            // Assume that we draw it immediately.  Update inter-frame stats\n            m_trFrameAvg = (trFrame + m_trFrameAvg * (AVGPERIOD - 1)) / AVGPERIOD;\n#ifndef PERF\n            // If this is NOT a perf build, then report what we know so far\n            // without looking at the clock any more.  This assumes that we\n            // actually wait for exactly the time we hope to.  It also reports\n            // how close we get to the manipulated time stamps that we now have\n            // rather than the ones we originally started with.  It will\n            // therefore be a little optimistic.  However it's fast.\n            PreparePerformanceData(trTrueLate, trFrame);\n#endif\n            m_trLastDraw = trRealStream;\n            if (m_trEarliness > trLate)\n            {\n                m_trEarliness = trLate; // if we are actually early, this is neg\n            }\n            Result = S_OK; // Draw it now\n        }\n        else\n        {\n            ++m_nNormal;\n            // Set the average frame rate to EXACTLY the ideal rate.\n            // If we are exiting slow-machine mode then we will have caught up\n            // and be running ahead, so as we slide back to exact timing we will\n            // have a longer than usual gap at this point.  If we record this\n            // real gap then we'll think that we're running slow and go back\n            // into slow-machine mode and vever get it straight.\n            m_trFrameAvg = trDuration;\n            MSR_INTEGER(m_idDecision, 1);\n\n            // Play it early by m_trEarliness and by m_trTarget\n\n            {\n                int trE = m_trEarliness;\n                if (trE < -m_trFrameAvg)\n                {\n                    trE = -m_trFrameAvg;\n                }\n                *ptrStart += trE; // N.B. earliness is negative\n            }\n\n            int Delay = -trTrueLate;\n            Result = Delay <= 0 ? S_OK : S_FALSE; // OK = draw now, FALSE = wait\n\n            m_trWaitAvg = trWaitAvg;\n\n            // Predict when it will actually be drawn and update frame stats\n\n            if (Result == S_FALSE)\n            { // We are going to wait\n                trFrame = TimeDiff(*ptrStart - m_trLastDraw);\n                m_trLastDraw = *ptrStart;\n            }\n            else\n            {\n                // trFrame is already = trRealStream-m_trLastDraw;\n                m_trLastDraw = trRealStream;\n            }\n#ifndef PERF\n            int iAccuracy;\n            if (Delay > 0)\n            {\n                // Report lateness based on when we intend to play it\n                iAccuracy = TimeDiff(*ptrStart - m_trRememberStampForPerf);\n            }\n            else\n            {\n                // Report lateness based on playing it *now*.\n                iAccuracy = trTrueLate; // trRealStream-RememberStampForPerf;\n            }\n            PreparePerformanceData(iAccuracy, trFrame);\n#endif\n        }\n        return Result;\n    }\n\n    // We are going to drop this frame!\n    // Of course in DirectDraw mode the guy upstream may draw it anyway.\n\n    // This will probably give a large negative wack to the wait avg.\n    m_trWaitAvg = trWaitAvg;\n\n#ifdef PERF\n    // Respect registry setting - debug only!\n    if (m_bDrawLateFrames)\n    {\n        return S_OK; // draw it when it's ready\n    }                // even though it's late.\n#endif\n\n    // We are going to drop this frame so draw the next one early\n    // n.b. if the supplier is doing direct draw then he may draw it anyway\n    // but he's doing something funny to arrive here in that case.\n\n    MSR_INTEGER(m_idDecision, 2);\n    m_nNormal = -1;\n    return E_FAIL; // drop it\n\n} // ShouldDrawSampleNow\n\n// NOTE we're called by both the window thread and the source filter thread\n// so we have to be protected by a critical section (locked before called)\n// Also, when the window thread gets signalled to render an image, it always\n// does so regardless of how late it is. All the degradation is done when we\n// are scheduling the next sample to be drawn. Hence when we start an advise\n// link to draw a sample, that sample's time will always become the last one\n// drawn - unless of course we stop streaming in which case we cancel links\n\nBOOL CBaseVideoRenderer::ScheduleSample(IMediaSample *pMediaSample)\n{\n    // We override ShouldDrawSampleNow to add quality management\n\n    BOOL bDrawImage = CBaseRenderer::ScheduleSample(pMediaSample);\n    if (bDrawImage == FALSE)\n    {\n        ++m_cFramesDropped;\n        return FALSE;\n    }\n\n    // m_cFramesDrawn must NOT be updated here.  It has to be updated\n    // in RecordFrameLateness at the same time as the other statistics.\n    return TRUE;\n}\n\n// Implementation of IQualProp interface needed to support the property page\n// This is how the property page gets the data out of the scheduler. We are\n// passed into the constructor the owning object in the COM sense, this will\n// either be the video renderer or an external IUnknown if we're aggregated.\n// We initialise our CUnknown base class with this interface pointer. Then\n// all we have to do is to override NonDelegatingQueryInterface to expose\n// our IQualProp interface. The AddRef and Release are handled automatically\n// by the base class and will be passed on to the appropriate outer object\n\nSTDMETHODIMP CBaseVideoRenderer::get_FramesDroppedInRenderer(__out int *pcFramesDropped)\n{\n    CheckPointer(pcFramesDropped, E_POINTER);\n    CAutoLock cVideoLock(&m_InterfaceLock);\n    *pcFramesDropped = m_cFramesDropped;\n    return NOERROR;\n} // get_FramesDroppedInRenderer\n\n// Set *pcFramesDrawn to the number of frames drawn since\n// streaming started.\n\nSTDMETHODIMP CBaseVideoRenderer::get_FramesDrawn(int *pcFramesDrawn)\n{\n    CheckPointer(pcFramesDrawn, E_POINTER);\n    CAutoLock cVideoLock(&m_InterfaceLock);\n    *pcFramesDrawn = m_cFramesDrawn;\n    return NOERROR;\n} // get_FramesDrawn\n\n// Set iAvgFrameRate to the frames per hundred secs since\n// streaming started.  0 otherwise.\n\nSTDMETHODIMP CBaseVideoRenderer::get_AvgFrameRate(int *piAvgFrameRate)\n{\n    CheckPointer(piAvgFrameRate, E_POINTER);\n    CAutoLock cVideoLock(&m_InterfaceLock);\n\n    int t;\n    if (m_bStreaming)\n    {\n        t = timeGetTime() - m_tStreamingStart;\n    }\n    else\n    {\n        t = m_tStreamingStart;\n    }\n\n    if (t <= 0)\n    {\n        *piAvgFrameRate = 0;\n        ASSERT(m_cFramesDrawn == 0);\n    }\n    else\n    {\n        // i is frames per hundred seconds\n        *piAvgFrameRate = MulDiv(100000, m_cFramesDrawn, t);\n    }\n    return NOERROR;\n} // get_AvgFrameRate\n\n// Set *piAvg to the average sync offset since streaming started\n// in mSec.  The sync offset is the time in mSec between when the frame\n// should have been drawn and when the frame was actually drawn.\n\nSTDMETHODIMP CBaseVideoRenderer::get_AvgSyncOffset(__out int *piAvg)\n{\n    CheckPointer(piAvg, E_POINTER);\n    CAutoLock cVideoLock(&m_InterfaceLock);\n\n    if (NULL == m_pClock)\n    {\n        *piAvg = 0;\n        return NOERROR;\n    }\n\n    // Note that we didn't gather the stats on the first frame\n    // so we use m_cFramesDrawn-1 here\n    if (m_cFramesDrawn <= 1)\n    {\n        *piAvg = 0;\n    }\n    else\n    {\n        *piAvg = (int)(m_iTotAcc / (m_cFramesDrawn - 1));\n    }\n    return NOERROR;\n} // get_AvgSyncOffset\n\n// To avoid dragging in the maths library - a cheap\n// approximate integer square root.\n// We do this by getting a starting guess which is between 1\n// and 2 times too large, followed by THREE iterations of\n// Newton Raphson.  (That will give accuracy to the nearest mSec\n// for the range in question - roughly 0..1000)\n//\n// It would be faster to use a linear interpolation and ONE NR, but\n// who cares.  If anyone does - the best linear interpolation is\n// to approximates sqrt(x) by\n// y = x * (sqrt(2)-1) + 1 - 1/sqrt(2) + 1/(8*(sqrt(2)-1))\n// 0r y = x*0.41421 + 0.59467\n// This minimises the maximal error in the range in question.\n// (error is about +0.008883 and then one NR will give error .0000something\n// (Of course these are integers, so you can't just multiply by 0.41421\n// you'd have to do some sort of MulDiv).\n// Anyone wanna check my maths?  (This is only for a property display!)\n\nint isqrt(int x)\n{\n    int s = 1;\n    // Make s an initial guess for sqrt(x)\n    if (x > 0x40000000)\n    {\n        s = 0x8000; // prevent any conceivable closed loop\n    }\n    else\n    {\n        while (s * s < x)\n        {              // loop cannot possible go more than 31 times\n            s = 2 * s; // normally it goes about 6 times\n        }\n        // Three NR iterations.\n        if (x == 0)\n        {\n            s = 0; // Wouldn't it be tragic to divide by zero whenever our\n                   // accuracy was perfect!\n        }\n        else\n        {\n            s = (s * s + x) / (2 * s);\n            if (s >= 0)\n                s = (s * s + x) / (2 * s);\n            if (s >= 0)\n                s = (s * s + x) / (2 * s);\n        }\n    }\n    return s;\n}\n\n//\n//  Do estimates for standard deviations for per-frame\n//  statistics\n//\nHRESULT CBaseVideoRenderer::GetStdDev(int nSamples, __out int *piResult, LONGLONG llSumSq, LONGLONG iTot)\n{\n    CheckPointer(piResult, E_POINTER);\n    CAutoLock cVideoLock(&m_InterfaceLock);\n\n    if (NULL == m_pClock)\n    {\n        *piResult = 0;\n        return NOERROR;\n    }\n\n    // If S is the Sum of the Squares of observations and\n    //    T the Total (i.e. sum) of the observations and there were\n    //    N observations, then an estimate of the standard deviation is\n    //      sqrt( (S - T**2/N) / (N-1) )\n\n    if (nSamples <= 1)\n    {\n        *piResult = 0;\n    }\n    else\n    {\n        LONGLONG x;\n        // First frames have invalid stamps, so we get no stats for them\n        // So we need 2 frames to get 1 datum, so N is cFramesDrawn-1\n\n        // so we use m_cFramesDrawn-1 here\n        x = llSumSq - llMulDiv(iTot, iTot, nSamples, 0);\n        x = x / (nSamples - 1);\n        ASSERT(x >= 0);\n        *piResult = isqrt((LONG)x);\n    }\n    return NOERROR;\n}\n\n// Set *piDev to the standard deviation in mSec of the sync offset\n// of each frame since streaming started.\n\nSTDMETHODIMP CBaseVideoRenderer::get_DevSyncOffset(__out int *piDev)\n{\n    // First frames have invalid stamps, so we get no stats for them\n    // So we need 2 frames to get 1 datum, so N is cFramesDrawn-1\n    return GetStdDev(m_cFramesDrawn - 1, piDev, m_iSumSqAcc, m_iTotAcc);\n} // get_DevSyncOffset\n\n// Set *piJitter to the standard deviation in mSec of the inter-frame time\n// of frames since streaming started.\n\nSTDMETHODIMP CBaseVideoRenderer::get_Jitter(__out int *piJitter)\n{\n    // First frames have invalid stamps, so we get no stats for them\n    // So second frame gives invalid inter-frame time\n    // So we need 3 frames to get 1 datum, so N is cFramesDrawn-2\n    return GetStdDev(m_cFramesDrawn - 2, piJitter, m_iSumSqFrameTime, m_iSumFrameTime);\n} // get_Jitter\n\n// Overidden to return our IQualProp interface\n\nSTDMETHODIMP\nCBaseVideoRenderer::NonDelegatingQueryInterface(REFIID riid, __deref_out VOID **ppv)\n{\n    // We return IQualProp and delegate everything else\n\n    if (riid == IID_IQualProp)\n    {\n        return GetInterface((IQualProp *)this, ppv);\n    }\n    else if (riid == IID_IQualityControl)\n    {\n        return GetInterface((IQualityControl *)this, ppv);\n    }\n    return CBaseRenderer::NonDelegatingQueryInterface(riid, ppv);\n}\n\n// Override JoinFilterGraph so that, just before leaving\n// the graph we can send an EC_WINDOW_DESTROYED event\n\nSTDMETHODIMP\nCBaseVideoRenderer::JoinFilterGraph(__inout_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName)\n{\n    // Since we send EC_ACTIVATE, we also need to ensure\n    // we send EC_WINDOW_DESTROYED or the resource manager may be\n    // holding us as a focus object\n    if (!pGraph && m_pGraph)\n    {\n\n        // We were in a graph and now we're not\n        // Do this properly in case we are aggregated\n        IBaseFilter *pFilter = this;\n        NotifyEvent(EC_WINDOW_DESTROYED, (LPARAM)pFilter, 0);\n    }\n    return CBaseFilter::JoinFilterGraph(pGraph, pName);\n}\n\n// This removes a large number of level 4 warnings from the\n// Microsoft compiler which in this case are not very useful\n#pragma warning(disable : 4514)\n"
  },
  {
    "path": "common/baseclasses/renbase.h",
    "content": "//------------------------------------------------------------------------------\n// File: RenBase.h\n//\n// Desc: DirectShow base classes - defines a generic ActiveX base renderer\n//       class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __RENBASE__\n#define __RENBASE__\n\n// Forward class declarations\n\nclass CBaseRenderer;\nclass CBaseVideoRenderer;\nclass CRendererInputPin;\n\n// This is our input pin class that channels calls to the renderer\n\nclass CRendererInputPin : public CBaseInputPin\n{\n  protected:\n    CBaseRenderer *m_pRenderer;\n\n  public:\n    CRendererInputPin(__inout CBaseRenderer *pRenderer, __inout HRESULT *phr, __in_opt LPCWSTR Name);\n\n    // Overriden from the base pin classes\n\n    HRESULT BreakConnect();\n    HRESULT CompleteConnect(IPin *pReceivePin);\n    HRESULT SetMediaType(const CMediaType *pmt);\n    HRESULT CheckMediaType(const CMediaType *pmt);\n    HRESULT Active();\n    HRESULT Inactive();\n\n    // Add rendering behaviour to interface functions\n\n    STDMETHODIMP QueryId(__deref_out LPWSTR *Id);\n    STDMETHODIMP EndOfStream();\n    STDMETHODIMP BeginFlush();\n    STDMETHODIMP EndFlush();\n    STDMETHODIMP Receive(IMediaSample *pMediaSample);\n\n    // Helper\n    IMemAllocator inline *Allocator() const { return m_pAllocator; }\n};\n\n// Main renderer class that handles synchronisation and state changes\n\nclass CBaseRenderer : public CBaseFilter\n{\n  protected:\n    friend class CRendererInputPin;\n\n    friend void CALLBACK EndOfStreamTimer(UINT uID,         // Timer identifier\n                                          UINT uMsg,        // Not currently used\n                                          DWORD_PTR dwUser, // User information\n                                          DWORD_PTR dw1,    // Windows reserved\n                                          DWORD_PTR dw2);   // Is also reserved\n\n    CRendererPosPassThru *m_pPosition; // Media seeking pass by object\n    CAMEvent m_RenderEvent;            // Used to signal timer events\n    CAMEvent m_ThreadSignal;           // Signalled to release worker thread\n    CAMEvent m_evComplete;             // Signalled when state complete\n    BOOL m_bAbort;                     // Stop us from rendering more data\n    BOOL m_bStreaming;                 // Are we currently streaming\n    DWORD_PTR m_dwAdvise;              // Timer advise cookie\n    IMediaSample *m_pMediaSample;      // Current image media sample\n    BOOL m_bEOS;                       // Any more samples in the stream\n    BOOL m_bEOSDelivered;              // Have we delivered an EC_COMPLETE\n    CRendererInputPin *m_pInputPin;    // Our renderer input pin object\n    CCritSec m_InterfaceLock;          // Critical section for interfaces\n    CCritSec m_RendererLock;           // Controls access to internals\n    IQualityControl *m_pQSink;         // QualityControl sink\n    BOOL m_bRepaintStatus;             // Can we signal an EC_REPAINT\n    //  Avoid some deadlocks by tracking filter during stop\n    volatile BOOL m_bInReceive;    // Inside Receive between PrepareReceive\n                                   // And actually processing the sample\n    REFERENCE_TIME m_SignalTime;   // Time when we signal EC_COMPLETE\n    UINT m_EndOfStreamTimer;       // Used to signal end of stream\n    CCritSec m_ObjectCreationLock; // This lock protects the creation and\n                                   // of m_pPosition and m_pInputPin.  It\n                                   // ensures that two threads cannot create\n                                   // either object simultaneously.\n\n  public:\n    CBaseRenderer(REFCLSID RenderClass,       // CLSID for this renderer\n                  __in_opt LPCTSTR pName,     // Debug ONLY description\n                  __inout_opt LPUNKNOWN pUnk, // Aggregated owner object\n                  __inout HRESULT *phr);      // General OLE return code\n\n    ~CBaseRenderer();\n\n    // Overriden to say what interfaces we support and where\n\n    virtual HRESULT GetMediaPositionInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID, __deref_out void **);\n\n    virtual HRESULT SourceThreadCanWait(BOOL bCanWait);\n\n#ifdef DEBUG\n    // Debug only dump of the renderer state\n    void DisplayRendererState();\n#endif\n    virtual HRESULT WaitForRenderTime();\n    virtual HRESULT CompleteStateChange(FILTER_STATE OldState);\n\n    // Return internal information about this filter\n\n    BOOL IsEndOfStream() { return m_bEOS; };\n    BOOL IsEndOfStreamDelivered() { return m_bEOSDelivered; };\n    BOOL IsStreaming() { return m_bStreaming; };\n    void SetAbortSignal(BOOL bAbort) { m_bAbort = bAbort; };\n    virtual void OnReceiveFirstSample(IMediaSample *pMediaSample){};\n    CAMEvent *GetRenderEvent() { return &m_RenderEvent; };\n\n    // Permit access to the transition state\n\n    void Ready() { m_evComplete.Set(); };\n    void NotReady() { m_evComplete.Reset(); };\n    BOOL CheckReady() { return m_evComplete.Check(); };\n\n    virtual int GetPinCount();\n    virtual CBasePin *GetPin(int n);\n    FILTER_STATE GetRealState();\n    void SendRepaint();\n    void SendNotifyWindow(IPin *pPin, HWND hwnd);\n    BOOL OnDisplayChange();\n    void SetRepaintStatus(BOOL bRepaint);\n\n    // Override the filter and pin interface functions\n\n    STDMETHODIMP Stop();\n    STDMETHODIMP Pause();\n    STDMETHODIMP Run(REFERENCE_TIME StartTime);\n    STDMETHODIMP GetState(DWORD dwMSecs, __out FILTER_STATE *State);\n    STDMETHODIMP FindPin(LPCWSTR Id, __deref_out IPin **ppPin);\n\n    // These are available for a quality management implementation\n\n    virtual void OnRenderStart(IMediaSample *pMediaSample);\n    virtual void OnRenderEnd(IMediaSample *pMediaSample);\n    virtual HRESULT OnStartStreaming() { return NOERROR; };\n    virtual HRESULT OnStopStreaming() { return NOERROR; };\n    virtual void OnWaitStart(){};\n    virtual void OnWaitEnd(){};\n    virtual void PrepareRender(){};\n\n#ifdef PERF\n    REFERENCE_TIME m_trRenderStart; // Just before we started drawing\n                                    // Set in OnRenderStart, Used in OnRenderEnd\n    int m_idBaseStamp;              // MSR_id for frame time stamp\n    int m_idBaseRenderTime;         // MSR_id for true wait time\n    int m_idBaseAccuracy;           // MSR_id for time frame is late (int)\n#endif\n\n    // Quality management implementation for scheduling rendering\n\n    virtual BOOL ScheduleSample(IMediaSample *pMediaSample);\n    virtual HRESULT GetSampleTimes(IMediaSample *pMediaSample, __out REFERENCE_TIME *pStartTime,\n                                   __out REFERENCE_TIME *pEndTime);\n\n    virtual HRESULT ShouldDrawSampleNow(IMediaSample *pMediaSample, __out REFERENCE_TIME *ptrStart,\n                                        __out REFERENCE_TIME *ptrEnd);\n\n    // Lots of end of stream complexities\n\n    void TimerCallback();\n    void ResetEndOfStreamTimer();\n    HRESULT NotifyEndOfStream();\n    virtual HRESULT SendEndOfStream();\n    virtual HRESULT ResetEndOfStream();\n    virtual HRESULT EndOfStream();\n\n    // Rendering is based around the clock\n\n    void SignalTimerFired();\n    virtual HRESULT CancelNotification();\n    virtual HRESULT ClearPendingSample();\n\n    // Called when the filter changes state\n\n    virtual HRESULT Active();\n    virtual HRESULT Inactive();\n    virtual HRESULT StartStreaming();\n    virtual HRESULT StopStreaming();\n    virtual HRESULT BeginFlush();\n    virtual HRESULT EndFlush();\n\n    // Deal with connections and type changes\n\n    virtual HRESULT BreakConnect();\n    virtual HRESULT SetMediaType(const CMediaType *pmt);\n    virtual HRESULT CompleteConnect(IPin *pReceivePin);\n\n    // These look after the handling of data samples\n\n    virtual HRESULT PrepareReceive(IMediaSample *pMediaSample);\n    virtual HRESULT Receive(IMediaSample *pMediaSample);\n    virtual BOOL HaveCurrentSample();\n    virtual IMediaSample *GetCurrentSample();\n    virtual HRESULT Render(IMediaSample *pMediaSample);\n\n    // Derived classes MUST override these\n    virtual HRESULT DoRenderSample(IMediaSample *pMediaSample) PURE;\n    virtual HRESULT CheckMediaType(const CMediaType *) PURE;\n\n    // Helper\n    void WaitForReceiveToComplete();\n};\n\n// CBaseVideoRenderer is a renderer class (see its ancestor class) and\n// it handles scheduling of media samples so that they are drawn at the\n// correct time by the reference clock.  It implements a degradation\n// strategy.  Possible degradation modes are:\n//    Drop frames here (only useful if the drawing takes significant time)\n//    Signal supplier (upstream) to drop some frame(s) - i.e. one-off skip.\n//    Signal supplier to change the frame rate - i.e. ongoing skipping.\n//    Or any combination of the above.\n// In order to determine what's useful to try we need to know what's going\n// on.  This is done by timing various operations (including the supplier).\n// This timing is done by using timeGetTime as it is accurate enough and\n// usually cheaper than calling the reference clock.  It also tells the\n// truth if there is an audio break and the reference clock stops.\n// We provide a number of public entry points (named OnXxxStart, OnXxxEnd)\n// which the rest of the renderer calls at significant moments.  These do\n// the timing.\n\n// the number of frames that the sliding averages are averaged over.\n// the rule is (1024*NewObservation + (AVGPERIOD-1) * PreviousAverage)/AVGPERIOD\n#define AVGPERIOD 4\n#define DO_MOVING_AVG(avg, obs) (avg = (1024 * obs + (AVGPERIOD - 1) * avg) / AVGPERIOD)\n// Spot the bug in this macro - I can't. but it doesn't work!\n\nclass CBaseVideoRenderer\n    : public CBaseRenderer\n    , // Base renderer class\n      public IQualProp\n    ,                        // Property page guff\n      public IQualityControl // Allow throttling\n{\n  protected:\n    // Hungarian:\n    //     tFoo is the time Foo in mSec (beware m_tStart from filter.h)\n    //     trBar is the time Bar by the reference clock\n\n    //******************************************************************\n    // State variables to control synchronisation\n    //******************************************************************\n\n    // Control of sending Quality messages.  We need to know whether\n    // we are in trouble (e.g. frames being dropped) and where the time\n    // is being spent.\n\n    // When we drop a frame we play the next one early.\n    // The frame after that is likely to wait before drawing and counting this\n    // wait as spare time is unfair, so we count it as a zero wait.\n    // We therefore need to know whether we are playing frames early or not.\n\n    int m_nNormal; // The number of consecutive frames\n                   // drawn at their normal time (not early)\n                   // -1 means we just dropped a frame.\n\n#ifdef PERF\n    BOOL m_bDrawLateFrames; // Don't drop any frames (debug and I'm\n                            // not keen on people using it!)\n#endif\n\n    BOOL m_bSupplierHandlingQuality; // The response to Quality messages says\n                                     // our supplier is handling things.\n                                     // We will allow things to go extra late\n                                     // before dropping frames.  We will play\n                                     // very early after he has dropped one.\n\n    // Control of scheduling, frame dropping etc.\n    // We need to know where the time is being spent so as to tell whether\n    // we should be taking action here, signalling supplier or what.\n    // The variables are initialised to a mode of NOT dropping frames.\n    // They will tell the truth after a few frames.\n    // We typically record a start time for an event, later we get the time\n    // again and subtract to get the elapsed time, and we average this over\n    // a few frames.  The average is used to tell what mode we are in.\n\n    // Although these are reference times (64 bit) they are all DIFFERENCES\n    // between times which are small.  An int will go up to 214 secs before\n    // overflow.  Avoiding 64 bit multiplications and divisions seems\n    // worth while.\n\n    // Audio-video throttling.  If the user has turned up audio quality\n    // very high (in principle it could be any other stream, not just audio)\n    // then we can receive cries for help via the graph manager.  In this case\n    // we put in a wait for some time after rendering each frame.\n    int m_trThrottle;\n\n    // The time taken to render (i.e. BitBlt) frames controls which component\n    // needs to degrade.  If the blt is expensive, the renderer degrades.\n    // If the blt is cheap it's done anyway and the supplier degrades.\n    int m_trRenderAvg;  // Time frames are taking to blt\n    int m_trRenderLast; // Time for last frame blt\n    int m_tRenderStart; // Just before we started drawing (mSec)\n                        // derived from timeGetTime.\n\n    // When frames are dropped we will play the next frame as early as we can.\n    // If it was a false alarm and the machine is fast we slide gently back to\n    // normal timing.  To do this, we record the offset showing just how early\n    // we really are.  This will normally be negative meaning early or zero.\n    int m_trEarliness;\n\n    // Target provides slow long-term feedback to try to reduce the\n    // average sync offset to zero.  Whenever a frame is actually rendered\n    // early we add a msec or two, whenever late we take off a few.\n    // We add or take off 1/32 of the error time.\n    // Eventually we should be hovering around zero.  For a really bad case\n    // where we were (say) 300mSec off, it might take 100 odd frames to\n    // settle down.  The rate of change of this is intended to be slower\n    // than any other mechanism in Quartz, thereby avoiding hunting.\n    int m_trTarget;\n\n    // The proportion of time spent waiting for the right moment to blt\n    // controls whether we bother to drop a frame or whether we reckon that\n    // we're doing well enough that we can stand a one-frame glitch.\n    int m_trWaitAvg; // Average of last few wait times\n                     // (actually we just average how early\n                     // we were).  Negative here means LATE.\n\n    // The average inter-frame time.\n    // This is used to calculate the proportion of the time used by the\n    // three operations (supplying us, waiting, rendering)\n    int m_trFrameAvg; // Average inter-frame time\n    int m_trDuration; // duration of last frame.\n\n#ifdef PERF\n    // Performance logging identifiers\n    int m_idTimeStamp;     // MSR_id for frame time stamp\n    int m_idEarliness;     // MSR_id for earliness fudge\n    int m_idTarget;        // MSR_id for Target fudge\n    int m_idWaitReal;      // MSR_id for true wait time\n    int m_idWait;          // MSR_id for wait time recorded\n    int m_idFrameAccuracy; // MSR_id for time frame is late (int)\n    int m_idRenderAvg;     // MSR_id for Render time recorded (int)\n    int m_idSchLateTime;   // MSR_id for lateness at scheduler\n    int m_idQualityRate;   // MSR_id for Quality rate requested\n    int m_idQualityTime;   // MSR_id for Quality time requested\n    int m_idDecision;      // MSR_id for decision code\n    int m_idDuration;      // MSR_id for duration of a frame\n    int m_idThrottle;      // MSR_id for audio-video throttling\n    // int m_idDebug;                  // MSR_id for trace style debugging\n    // int m_idSendQuality;          // MSR_id for timing the notifications per se\n#endif                                       // PERF\n    REFERENCE_TIME m_trRememberStampForPerf; // original time stamp of frame\n                                             // with no earliness fudges etc.\n#ifdef PERF\n    REFERENCE_TIME m_trRememberFrameForPerf; // time when previous frame rendered\n\n    // debug...\n    int m_idFrameAvg;\n    int m_idWaitAvg;\n#endif\n\n    // PROPERTY PAGE\n    // This has edit fields that show the user what's happening\n    // These member variables hold these counts.\n\n    int m_cFramesDropped; // cumulative frames dropped IN THE RENDERER\n    int m_cFramesDrawn;   // Frames since streaming started seen BY THE\n                          // RENDERER (some may be dropped upstream)\n\n    // Next two support average sync offset and standard deviation of sync offset.\n    LONGLONG m_iTotAcc;   // Sum of accuracies in mSec\n    LONGLONG m_iSumSqAcc; // Sum of squares of (accuracies in mSec)\n\n    // Next two allow jitter calculation.  Jitter is std deviation of frame time.\n    REFERENCE_TIME m_trLastDraw; // Time of prev frame (for inter-frame times)\n    LONGLONG m_iSumSqFrameTime;  // Sum of squares of (inter-frame time in mSec)\n    LONGLONG m_iSumFrameTime;    // Sum of inter-frame times in mSec\n\n    // To get performance statistics on frame rate, jitter etc, we need\n    // to record the lateness and inter-frame time.  What we actually need are the\n    // data above (sum, sum of squares and number of entries for each) but the data\n    // is generated just ahead of time and only later do we discover whether the\n    // frame was actually drawn or not.  So we have to hang on to the data\n    int m_trLate;  // hold onto frame lateness\n    int m_trFrame; // hold onto inter-frame time\n\n    int m_tStreamingStart; // if streaming then time streaming started\n                           // else time of last streaming session\n                           // used for property page statistics\n#ifdef PERF\n    LONGLONG m_llTimeOffset; // timeGetTime()*10000+m_llTimeOffset==ref time\n#endif\n\n  public:\n    CBaseVideoRenderer(REFCLSID RenderClass,       // CLSID for this renderer\n                       __in_opt LPCTSTR pName,     // Debug ONLY description\n                       __inout_opt LPUNKNOWN pUnk, // Aggregated owner object\n                       __inout HRESULT *phr);      // General OLE return code\n\n    ~CBaseVideoRenderer();\n\n    // IQualityControl methods - Notify allows audio-video throttling\n\n    STDMETHODIMP SetSink(IQualityControl *piqc);\n    STDMETHODIMP Notify(IBaseFilter *pSelf, Quality q);\n\n    // These provide a full video quality management implementation\n\n    void OnRenderStart(IMediaSample *pMediaSample);\n    void OnRenderEnd(IMediaSample *pMediaSample);\n    void OnWaitStart();\n    void OnWaitEnd();\n    HRESULT OnStartStreaming();\n    HRESULT OnStopStreaming();\n    void ThrottleWait();\n\n    // Handle the statistics gathering for our quality management\n\n    void PreparePerformanceData(int trLate, int trFrame);\n    virtual void RecordFrameLateness(int trLate, int trFrame);\n    virtual void OnDirectRender(IMediaSample *pMediaSample);\n    virtual HRESULT ResetStreamingTimes();\n    BOOL ScheduleSample(IMediaSample *pMediaSample);\n    HRESULT ShouldDrawSampleNow(IMediaSample *pMediaSample, __inout REFERENCE_TIME *ptrStart,\n                                __inout REFERENCE_TIME *ptrEnd);\n\n    virtual HRESULT SendQuality(REFERENCE_TIME trLate, REFERENCE_TIME trRealStream);\n    STDMETHODIMP JoinFilterGraph(__inout_opt IFilterGraph *pGraph, __in_opt LPCWSTR pName);\n\n    //\n    //  Do estimates for standard deviations for per-frame\n    //  statistics\n    //\n    //  *piResult = (llSumSq - iTot * iTot / m_cFramesDrawn - 1) /\n    //                            (m_cFramesDrawn - 2)\n    //  or 0 if m_cFramesDrawn <= 3\n    //\n    HRESULT GetStdDev(int nSamples, __out int *piResult, LONGLONG llSumSq, LONGLONG iTot);\n\n  public:\n    // IQualProp property page support\n\n    STDMETHODIMP get_FramesDroppedInRenderer(__out int *cFramesDropped);\n    STDMETHODIMP get_FramesDrawn(__out int *pcFramesDrawn);\n    STDMETHODIMP get_AvgFrameRate(__out int *piAvgFrameRate);\n    STDMETHODIMP get_Jitter(__out int *piJitter);\n    STDMETHODIMP get_AvgSyncOffset(__out int *piAvg);\n    STDMETHODIMP get_DevSyncOffset(__out int *piDev);\n\n    // Implement an IUnknown interface and expose IQualProp\n\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out VOID **ppv);\n};\n\n#endif // __RENBASE__\n"
  },
  {
    "path": "common/baseclasses/schedule.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: Schedule.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1996-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n\n// DbgLog values (all on LOG_TIMING):\n//\n// 2 for schedulting, firing and shunting of events\n// 3 for wait delays and wake-up times of event thread\n// 4 for details of whats on the list when the thread awakes\n\n/* Construct & destructors */\n\nCAMSchedule::CAMSchedule(HANDLE ev)\n    : CBaseObject(TEXT(\"CAMSchedule\"))\n    , head(&z, 0)\n    , z(0, MAX_TIME)\n    , m_dwNextCookie(0)\n    , m_dwAdviseCount(0)\n    , m_pAdviseCache(0)\n    , m_dwCacheCount(0)\n    , m_ev(ev)\n{\n    head.m_dwAdviseCookie = z.m_dwAdviseCookie = 0;\n}\n\nCAMSchedule::~CAMSchedule()\n{\n    m_Serialize.Lock();\n\n    // Delete cache\n    CAdvisePacket *p = m_pAdviseCache;\n    while (p)\n    {\n        CAdvisePacket *const p_next = p->m_next;\n        delete p;\n        p = p_next;\n    }\n\n    ASSERT(m_dwAdviseCount == 0);\n    // Better to be safe than sorry\n    if (m_dwAdviseCount > 0)\n    {\n        DumpLinkedList();\n        while (!head.m_next->IsZ())\n        {\n            head.DeleteNext();\n            --m_dwAdviseCount;\n        }\n    }\n\n    // If, in the debug version, we assert twice, it means, not only\n    // did we have left over advises, but we have also let m_dwAdviseCount\n    // get out of sync. with the number of advises actually on the list.\n    ASSERT(m_dwAdviseCount == 0);\n\n    m_Serialize.Unlock();\n}\n\n/* Public methods */\n\nDWORD CAMSchedule::GetAdviseCount()\n{\n    // No need to lock, m_dwAdviseCount is 32bits & declared volatile\n    return m_dwAdviseCount;\n}\n\nREFERENCE_TIME CAMSchedule::GetNextAdviseTime()\n{\n    CAutoLock lck(&m_Serialize); // Need to stop the linked list from changing\n    return head.m_next->m_rtEventTime;\n}\n\nDWORD_PTR CAMSchedule::AddAdvisePacket(const REFERENCE_TIME &time1, const REFERENCE_TIME &time2, HANDLE h,\n                                       BOOL periodic)\n{\n    // Since we use MAX_TIME as a sentry, we can't afford to\n    // schedule a notification at MAX_TIME\n    ASSERT(time1 < MAX_TIME);\n    DWORD_PTR Result;\n    CAdvisePacket *p;\n\n    m_Serialize.Lock();\n\n    if (m_pAdviseCache)\n    {\n        p = m_pAdviseCache;\n        m_pAdviseCache = p->m_next;\n        --m_dwCacheCount;\n    }\n    else\n    {\n        p = new CAdvisePacket();\n    }\n    if (p)\n    {\n        p->m_rtEventTime = time1;\n        p->m_rtPeriod = time2;\n        p->m_hNotify = h;\n        p->m_bPeriodic = periodic;\n        Result = AddAdvisePacket(p);\n    }\n    else\n        Result = 0;\n\n    m_Serialize.Unlock();\n\n    return Result;\n}\n\nHRESULT CAMSchedule::Unadvise(DWORD_PTR dwAdviseCookie)\n{\n    HRESULT hr = S_FALSE;\n    CAdvisePacket *p_prev = &head;\n    CAdvisePacket *p_n;\n    m_Serialize.Lock();\n    while (p_n = p_prev->Next()) // The Next() method returns NULL when it hits z\n    {\n        if (p_n->m_dwAdviseCookie == dwAdviseCookie)\n        {\n            Delete(p_prev->RemoveNext());\n            --m_dwAdviseCount;\n            hr = S_OK;\n            // Having found one cookie that matches, there should be no more\n#ifdef DEBUG\n            while (p_n = p_prev->Next())\n            {\n                ASSERT(p_n->m_dwAdviseCookie != dwAdviseCookie);\n                p_prev = p_n;\n            }\n#endif\n            break;\n        }\n        p_prev = p_n;\n    };\n    m_Serialize.Unlock();\n    return hr;\n}\n\nREFERENCE_TIME CAMSchedule::Advise(const REFERENCE_TIME &rtTime)\n{\n    REFERENCE_TIME rtNextTime;\n    CAdvisePacket *pAdvise;\n\n    DbgLog((LOG_TIMING, 2, TEXT(\"CAMSchedule::Advise( %lu ms )\"), ULONG(rtTime / (UNITS / MILLISECONDS))));\n\n    CAutoLock lck(&m_Serialize);\n\n#ifdef DEBUG\n    if (DbgCheckModuleLevel(LOG_TIMING, 4))\n        DumpLinkedList();\n#endif\n\n    //  Note - DON'T cache the difference, it might overflow\n    while (rtTime >= (rtNextTime = (pAdvise = head.m_next)->m_rtEventTime) && !pAdvise->IsZ())\n    {\n        ASSERT(pAdvise->m_dwAdviseCookie); // If this is zero, its the head or the tail!!\n\n        ASSERT(pAdvise->m_hNotify != INVALID_HANDLE_VALUE);\n\n        if (pAdvise->m_bPeriodic == TRUE)\n        {\n            ReleaseSemaphore(pAdvise->m_hNotify, 1, NULL);\n            pAdvise->m_rtEventTime += pAdvise->m_rtPeriod;\n            ShuntHead();\n        }\n        else\n        {\n            ASSERT(pAdvise->m_bPeriodic == FALSE);\n            EXECUTE_ASSERT(SetEvent(pAdvise->m_hNotify));\n            --m_dwAdviseCount;\n            Delete(head.RemoveNext());\n        }\n    }\n\n    DbgLog((LOG_TIMING, 3, TEXT(\"CAMSchedule::Advise() Next time stamp: %lu ms, for advise %lu.\"),\n            DWORD(rtNextTime / (UNITS / MILLISECONDS)), pAdvise->m_dwAdviseCookie));\n\n    return rtNextTime;\n}\n\n/* Private methods */\n\nDWORD_PTR CAMSchedule::AddAdvisePacket(__inout CAdvisePacket *pPacket)\n{\n    ASSERT(pPacket->m_rtEventTime >= 0 && pPacket->m_rtEventTime < MAX_TIME);\n    ASSERT(CritCheckIn(&m_Serialize));\n\n    CAdvisePacket *p_prev = &head;\n    CAdvisePacket *p_n;\n\n    const DWORD_PTR Result = pPacket->m_dwAdviseCookie = ++m_dwNextCookie;\n    // This relies on the fact that z is a sentry with a maximal m_rtEventTime\n    for (;; p_prev = p_n)\n    {\n        p_n = p_prev->m_next;\n        if (p_n->m_rtEventTime >= pPacket->m_rtEventTime)\n            break;\n    }\n    p_prev->InsertAfter(pPacket);\n    ++m_dwAdviseCount;\n\n    DbgLog((LOG_TIMING, 2, TEXT(\"Added advise %lu, for thread 0x%02X, scheduled at %lu\"), pPacket->m_dwAdviseCookie,\n            GetCurrentThreadId(), (pPacket->m_rtEventTime / (UNITS / MILLISECONDS))));\n\n    // If packet added at the head, then clock needs to re-evaluate wait time.\n    if (p_prev == &head)\n        SetEvent(m_ev);\n\n    return Result;\n}\n\nvoid CAMSchedule::Delete(__inout CAdvisePacket *pPacket)\n{\n    if (m_dwCacheCount >= dwCacheMax)\n        delete pPacket;\n    else\n    {\n        m_Serialize.Lock();\n        pPacket->m_next = m_pAdviseCache;\n        m_pAdviseCache = pPacket;\n        ++m_dwCacheCount;\n        m_Serialize.Unlock();\n    }\n}\n\n// Takes the head of the list & repositions it\nvoid CAMSchedule::ShuntHead()\n{\n    CAdvisePacket *p_prev = &head;\n    CAdvisePacket *p_n;\n\n    m_Serialize.Lock();\n    CAdvisePacket *const pPacket = head.m_next;\n\n    // This will catch both an empty list,\n    // and if somehow a MAX_TIME time gets into the list\n    // (which would also break this method).\n    ASSERT(pPacket->m_rtEventTime < MAX_TIME);\n\n    // This relies on the fact that z is a sentry with a maximal m_rtEventTime\n    for (;; p_prev = p_n)\n    {\n        p_n = p_prev->m_next;\n        if (p_n->m_rtEventTime > pPacket->m_rtEventTime)\n            break;\n    }\n    // If p_prev == pPacket then we're already in the right place\n    if (p_prev != pPacket)\n    {\n        head.m_next = pPacket->m_next;\n        (p_prev->m_next = pPacket)->m_next = p_n;\n    }\n#ifdef DEBUG\n    DbgLog((LOG_TIMING, 2, TEXT(\"Periodic advise %lu, shunted to %lu\"), pPacket->m_dwAdviseCookie,\n            (pPacket->m_rtEventTime / (UNITS / MILLISECONDS))));\n#endif\n    m_Serialize.Unlock();\n}\n\n#ifdef DEBUG\nvoid CAMSchedule::DumpLinkedList()\n{\n    m_Serialize.Lock();\n    int i = 0;\n    DbgLog((LOG_TIMING, 1, TEXT(\"CAMSchedule::DumpLinkedList() this = 0x%p\"), this));\n    for (CAdvisePacket *p = &head; p; p = p->m_next, i++)\n    {\n        DbgLog((LOG_TIMING, 1, TEXT(\"Advise List # %lu, Cookie %d,  RefTime %lu\"), i, p->m_dwAdviseCookie,\n                p->m_rtEventTime / (UNITS / MILLISECONDS)));\n    }\n    m_Serialize.Unlock();\n}\n#endif\n"
  },
  {
    "path": "common/baseclasses/schedule.h",
    "content": "//------------------------------------------------------------------------------\n// File: Schedule.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1996-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __CAMSchedule__\n#define __CAMSchedule__\n\nclass CAMSchedule : private CBaseObject\n{\n  public:\n    virtual ~CAMSchedule();\n    // ev is the event we should fire if the advise time needs re-evaluating\n    CAMSchedule(HANDLE ev);\n\n    DWORD GetAdviseCount();\n    REFERENCE_TIME GetNextAdviseTime();\n\n    // We need a method for derived classes to add advise packets, we return the cookie\n    DWORD_PTR AddAdvisePacket(const REFERENCE_TIME &time1, const REFERENCE_TIME &time2, HANDLE h, BOOL periodic);\n    // And a way to cancel\n    HRESULT Unadvise(DWORD_PTR dwAdviseCookie);\n\n    // Tell us the time please, and we'll dispatch the expired events.  We return the time of the next event.\n    // NB: The time returned will be \"useless\" if you start adding extra Advises.  But that's the problem of\n    // whoever is using this helper class (typically a clock).\n    REFERENCE_TIME Advise(const REFERENCE_TIME &rtTime);\n\n    // Get the event handle which will be set if advise time requires re-evaluation.\n    HANDLE GetEvent() const { return m_ev; }\n\n  private:\n    // We define the nodes that will be used in our singly linked list\n    // of advise packets.  The list is ordered by time, with the\n    // elements that will expire first at the front.\n    class CAdvisePacket\n    {\n      public:\n        CAdvisePacket() {}\n\n        CAdvisePacket *m_next;\n        DWORD_PTR m_dwAdviseCookie;\n        REFERENCE_TIME m_rtEventTime; // Time at which event should be set\n        REFERENCE_TIME m_rtPeriod;    // Periodic time\n        HANDLE m_hNotify;             // Handle to event or semephore\n        BOOL m_bPeriodic;             // TRUE => Periodic event\n\n        CAdvisePacket(__inout_opt CAdvisePacket *next, LONGLONG time)\n            : m_next(next)\n            , m_rtEventTime(time)\n        {\n        }\n\n        void InsertAfter(__inout CAdvisePacket *p)\n        {\n            p->m_next = m_next;\n            m_next = p;\n        }\n\n        int IsZ() const // That is, is it the node that represents the end of the list\n        {\n            return m_next == 0;\n        }\n\n        CAdvisePacket *RemoveNext()\n        {\n            CAdvisePacket *const next = m_next;\n            CAdvisePacket *const new_next = next->m_next;\n            m_next = new_next;\n            return next;\n        }\n\n        void DeleteNext() { delete RemoveNext(); }\n\n        CAdvisePacket *Next() const\n        {\n            CAdvisePacket *result = m_next;\n            if (result->IsZ())\n                result = 0;\n            return result;\n        }\n\n        DWORD_PTR Cookie() const { return m_dwAdviseCookie; }\n    };\n\n    // Structure is:\n    // head -> elmt1 -> elmt2 -> z -> null\n    // So an empty list is:       head -> z -> null\n    // Having head & z as links makes insertaion,\n    // deletion and shunting much easier.\n    CAdvisePacket head, z; // z is both a tail and a sentry\n\n    volatile DWORD_PTR m_dwNextCookie; // Strictly increasing\n    volatile DWORD m_dwAdviseCount;    // Number of elements on list\n\n    CCritSec m_Serialize;\n\n    // AddAdvisePacket: adds the packet, returns the cookie (0 if failed)\n    DWORD_PTR AddAdvisePacket(__inout CAdvisePacket *pPacket);\n    // Event that we should set if the packed added above will be the next to fire.\n    const HANDLE m_ev;\n\n    // A Shunt is where we have changed the first element in the\n    // list and want it re-evaluating (i.e. repositioned) in\n    // the list.\n    void ShuntHead();\n\n    // Rather than delete advise packets, we cache them for future use\n    CAdvisePacket *m_pAdviseCache;\n    DWORD m_dwCacheCount;\n    enum\n    {\n        dwCacheMax = 5\n    }; // Don't bother caching more than five\n\n    void Delete(__inout CAdvisePacket *pLink); // This \"Delete\" will cache the Link\n\n    // Attributes and methods for debugging\n  public:\n#ifdef DEBUG\n    void DumpLinkedList();\n#else\n    void DumpLinkedList() {}\n#endif\n};\n\n#endif // __CAMSchedule__\n"
  },
  {
    "path": "common/baseclasses/seekpt.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: SeekPT.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include \"seekpt.h\"\n\n//==================================================================\n// CreateInstance\n// This goes in the factory template table to create new instances\n// If there is already a mapper instance - return that, else make one\n// and save it in a static variable so that forever after we can return that.\n//==================================================================\n\nCUnknown *CSeekingPassThru::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)\n{\n    return new CSeekingPassThru(NAME(\"Seeking PassThru\"), pUnk, phr);\n}\n\nSTDMETHODIMP CSeekingPassThru::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_ISeekingPassThru)\n    {\n        return GetInterface((ISeekingPassThru *)this, ppv);\n    }\n    else\n    {\n        if (m_pPosPassThru && (riid == IID_IMediaSeeking || riid == IID_IMediaPosition))\n        {\n            return m_pPosPassThru->NonDelegatingQueryInterface(riid, ppv);\n        }\n        else\n        {\n            return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n        }\n    }\n}\n\nCSeekingPassThru::CSeekingPassThru(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)\n    : CUnknown(pName, pUnk, phr)\n    , m_pPosPassThru(NULL)\n{\n}\n\nCSeekingPassThru::~CSeekingPassThru()\n{\n    delete m_pPosPassThru;\n}\n\nSTDMETHODIMP CSeekingPassThru::Init(BOOL bRendererSeeking, IPin *pPin)\n{\n    HRESULT hr = NOERROR;\n    if (m_pPosPassThru)\n    {\n        hr = E_FAIL;\n    }\n    else\n    {\n        m_pPosPassThru = bRendererSeeking\n                             ? new CRendererPosPassThru(NAME(\"Render Seeking COM object\"), (IUnknown *)this, &hr, pPin)\n                             : new CPosPassThru(NAME(\"Render Seeking COM object\"), (IUnknown *)this, &hr, pPin);\n        if (!m_pPosPassThru)\n        {\n            hr = E_OUTOFMEMORY;\n        }\n        else\n        {\n            if (FAILED(hr))\n            {\n                delete m_pPosPassThru;\n                m_pPosPassThru = NULL;\n            }\n        }\n    }\n    return hr;\n}\n"
  },
  {
    "path": "common/baseclasses/seekpt.h",
    "content": "//------------------------------------------------------------------------------\n// File: SeekPT.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __seekpt_h__\n#define __seekpt_h__\n\nclass CSeekingPassThru\n    : public ISeekingPassThru\n    , public CUnknown\n{\n  public:\n    static CUnknown *CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);\n    CSeekingPassThru(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);\n    ~CSeekingPassThru();\n\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    STDMETHODIMP Init(BOOL bSupportRendering, IPin *pPin);\n\n  private:\n    CPosPassThru *m_pPosPassThru;\n};\n\n#endif\n"
  },
  {
    "path": "common/baseclasses/source.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: Source.cpp\n//\n// Desc: DirectShow  base classes - implements CSource, which is a Quartz\n//       source filter 'template.'\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// Locking Strategy.\n//\n// Hold the filter critical section (m_pFilter->pStateLock()) to serialise\n// access to functions. Note that, in general, this lock may be held\n// by a function when the worker thread may want to hold it. Therefore\n// if you wish to access shared state from the worker thread you will\n// need to add another critical section object. The execption is during\n// the threads processing loop, when it is safe to get the filter critical\n// section from within FillBuffer().\n\n#include <streams.h>\n\n//\n// CSource::Constructor\n//\n// Initialise the pin count for the filter. The user will create the pins in\n// the derived class.\nCSource::CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid)\n    : CBaseFilter(pName, lpunk, &m_cStateLock, clsid)\n    , m_iPins(0)\n    , m_paStreams(NULL)\n{\n}\n\nCSource::CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr)\n    : CBaseFilter(pName, lpunk, &m_cStateLock, clsid)\n    , m_iPins(0)\n    , m_paStreams(NULL)\n{\n    UNREFERENCED_PARAMETER(phr);\n}\n\n#ifdef UNICODE\nCSource::CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid)\n    : CBaseFilter(pName, lpunk, &m_cStateLock, clsid)\n    , m_iPins(0)\n    , m_paStreams(NULL)\n{\n}\n\nCSource::CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr)\n    : CBaseFilter(pName, lpunk, &m_cStateLock, clsid)\n    , m_iPins(0)\n    , m_paStreams(NULL)\n{\n    UNREFERENCED_PARAMETER(phr);\n}\n#endif\n\n//\n// CSource::Destructor\n//\nCSource::~CSource()\n{\n    /*  Free our pins and pin array */\n    while (m_iPins != 0)\n    {\n        // deleting the pins causes them to be removed from the array...\n        delete m_paStreams[m_iPins - 1];\n    }\n\n    ASSERT(m_paStreams == NULL);\n}\n\n//\n//  Add a new pin\n//\nHRESULT CSource::AddPin(__in CSourceStream *pStream)\n{\n    CAutoLock lock(&m_cStateLock);\n\n    /*  Allocate space for this pin and the old ones */\n    CSourceStream **paStreams = new CSourceStream *[m_iPins + 1];\n    if (paStreams == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n    if (m_paStreams != NULL)\n    {\n        CopyMemory((PVOID)paStreams, (PVOID)m_paStreams, m_iPins * sizeof(m_paStreams[0]));\n        paStreams[m_iPins] = pStream;\n        delete[] m_paStreams;\n    }\n    m_paStreams = paStreams;\n    m_paStreams[m_iPins] = pStream;\n    m_iPins++;\n    return S_OK;\n}\n\n//\n//  Remove a pin - pStream is NOT deleted\n//\nHRESULT CSource::RemovePin(__in CSourceStream *pStream)\n{\n    int i;\n    for (i = 0; i < m_iPins; i++)\n    {\n        if (m_paStreams[i] == pStream)\n        {\n            if (m_iPins == 1)\n            {\n                delete[] m_paStreams;\n                m_paStreams = NULL;\n            }\n            else\n            {\n                /*  no need to reallocate */\n                while (++i < m_iPins)\n                    m_paStreams[i - 1] = m_paStreams[i];\n            }\n            m_iPins--;\n            return S_OK;\n        }\n    }\n    return S_FALSE;\n}\n\n//\n// FindPin\n//\n// Set *ppPin to the IPin* that has the id Id.\n// or to NULL if the Id cannot be matched.\nSTDMETHODIMP CSource::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)\n{\n    CheckPointer(ppPin, E_POINTER);\n    ValidateReadWritePtr(ppPin, sizeof(IPin *));\n    // The -1 undoes the +1 in QueryId and ensures that totally invalid\n    // strings (for which WstrToInt delivers 0) give a deliver a NULL pin.\n    int i = WstrToInt(Id) - 1;\n    *ppPin = GetPin(i);\n    if (*ppPin != NULL)\n    {\n        (*ppPin)->AddRef();\n        return NOERROR;\n    }\n    else\n    {\n        return VFW_E_NOT_FOUND;\n    }\n}\n\n//\n// FindPinNumber\n//\n// return the number of the pin with this IPin* or -1 if none\nint CSource::FindPinNumber(__in IPin *iPin)\n{\n    int i;\n    for (i = 0; i < m_iPins; ++i)\n    {\n        if ((IPin *)(m_paStreams[i]) == iPin)\n        {\n            return i;\n        }\n    }\n    return -1;\n}\n\n//\n// GetPinCount\n//\n// Returns the number of pins this filter has\nint CSource::GetPinCount(void)\n{\n\n    CAutoLock lock(&m_cStateLock);\n    return m_iPins;\n}\n\n//\n// GetPin\n//\n// Return a non-addref'd pointer to pin n\n// needed by CBaseFilter\nCBasePin *CSource::GetPin(int n)\n{\n\n    CAutoLock lock(&m_cStateLock);\n\n    // n must be in the range 0..m_iPins-1\n    // if m_iPins>n  && n>=0 it follows that m_iPins>0\n    // which is what used to be checked (i.e. checking that we have a pin)\n    if ((n >= 0) && (n < m_iPins))\n    {\n\n        ASSERT(m_paStreams[n]);\n        return m_paStreams[n];\n    }\n    return NULL;\n}\n\n//\n\n// *\n// * --- CSourceStream ----\n// *\n\n//\n// Set Id to point to a CoTaskMemAlloc'd\nSTDMETHODIMP CSourceStream::QueryId(__deref_out LPWSTR *Id)\n{\n    CheckPointer(Id, E_POINTER);\n    ValidateReadWritePtr(Id, sizeof(LPWSTR));\n\n    // We give the pins id's which are 1,2,...\n    // FindPinNumber returns -1 for an invalid pin\n    int i = 1 + m_pFilter->FindPinNumber(this);\n    if (i < 1)\n        return VFW_E_NOT_FOUND;\n    *Id = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * 12);\n    if (*Id == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n    IntToWstr(i, *Id);\n    return NOERROR;\n}\n\n//\n// CSourceStream::Constructor\n//\n// increments the number of pins present on the filter\nCSourceStream::CSourceStream(__in_opt LPCTSTR pObjectName, __inout HRESULT *phr, __inout CSource *ps,\n                             __in_opt LPCWSTR pPinName)\n    : CBaseOutputPin(pObjectName, ps, ps->pStateLock(), phr, pPinName)\n    , m_pFilter(ps)\n{\n\n    *phr = m_pFilter->AddPin(this);\n}\n\n#ifdef UNICODE\nCSourceStream::CSourceStream(__in_opt LPCSTR pObjectName, __inout HRESULT *phr, __inout CSource *ps,\n                             __in_opt LPCWSTR pPinName)\n    : CBaseOutputPin(pObjectName, ps, ps->pStateLock(), phr, pPinName)\n    , m_pFilter(ps)\n{\n\n    *phr = m_pFilter->AddPin(this);\n}\n#endif\n//\n// CSourceStream::Destructor\n//\n// Decrements the number of pins on this filter\nCSourceStream::~CSourceStream(void)\n{\n\n    m_pFilter->RemovePin(this);\n}\n\n//\n// CheckMediaType\n//\n// Do we support this type? Provides the default support for 1 type.\nHRESULT CSourceStream::CheckMediaType(const CMediaType *pMediaType)\n{\n\n    CAutoLock lock(m_pFilter->pStateLock());\n\n    CMediaType mt;\n    GetMediaType(&mt);\n\n    if (mt == *pMediaType)\n    {\n        return NOERROR;\n    }\n\n    return E_FAIL;\n}\n\n//\n// GetMediaType/3\n//\n// By default we support only one type\n// iPosition indexes are 0-n\nHRESULT CSourceStream::GetMediaType(int iPosition, __inout CMediaType *pMediaType)\n{\n\n    CAutoLock lock(m_pFilter->pStateLock());\n\n    if (iPosition < 0)\n    {\n        return E_INVALIDARG;\n    }\n    if (iPosition > 0)\n    {\n        return VFW_S_NO_MORE_ITEMS;\n    }\n    return GetMediaType(pMediaType);\n}\n\n//\n// Active\n//\n// The pin is active - start up the worker thread\nHRESULT CSourceStream::Active(void)\n{\n\n    CAutoLock lock(m_pFilter->pStateLock());\n\n    HRESULT hr;\n\n    if (m_pFilter->IsActive())\n    {\n        return S_FALSE; // succeeded, but did not allocate resources (they already exist...)\n    }\n\n    // do nothing if not connected - its ok not to connect to\n    // all pins of a source filter\n    if (!IsConnected())\n    {\n        return NOERROR;\n    }\n\n    hr = CBaseOutputPin::Active();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    ASSERT(!ThreadExists());\n\n    // start the thread\n    if (!Create())\n    {\n        return E_FAIL;\n    }\n\n    // Tell thread to initialize. If OnThreadCreate Fails, so does this.\n    hr = Init();\n    if (FAILED(hr))\n        return hr;\n\n    return Pause();\n}\n\n//\n// Inactive\n//\n// Pin is inactive - shut down the worker thread\n// Waits for the worker to exit before returning.\nHRESULT CSourceStream::Inactive(void)\n{\n\n    CAutoLock lock(m_pFilter->pStateLock());\n\n    HRESULT hr;\n\n    // do nothing if not connected - its ok not to connect to\n    // all pins of a source filter\n    if (!IsConnected())\n    {\n        return NOERROR;\n    }\n\n    // !!! need to do this before trying to stop the thread, because\n    // we may be stuck waiting for our own allocator!!!\n\n    hr = CBaseOutputPin::Inactive(); // call this first to Decommit the allocator\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    if (ThreadExists())\n    {\n        hr = Stop();\n\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        hr = Exit();\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        Close(); // Wait for the thread to exit, then tidy up.\n    }\n\n    // hr = CBaseOutputPin::Inactive();  // call this first to Decommit the allocator\n    // if (FAILED(hr)) {\n    //\treturn hr;\n    //}\n\n    return NOERROR;\n}\n\n//\n// ThreadProc\n//\n// When this returns the thread exits\n// Return codes > 0 indicate an error occured\nDWORD CSourceStream::ThreadProc(void)\n{\n\n    HRESULT hr; // the return code from calls\n    Command com;\n\n    do\n    {\n        com = GetRequest();\n        if (com != CMD_INIT)\n        {\n            DbgLog((LOG_ERROR, 1, TEXT(\"Thread expected init command\")));\n            Reply((DWORD)E_UNEXPECTED);\n        }\n    } while (com != CMD_INIT);\n\n    DbgLog((LOG_TRACE, 1, TEXT(\"CSourceStream worker thread initializing\")));\n\n    hr = OnThreadCreate(); // perform set up tasks\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"CSourceStream::OnThreadCreate failed. Aborting thread.\")));\n        OnThreadDestroy();\n        Reply(hr); // send failed return code from OnThreadCreate\n        return 1;\n    }\n\n    // Initialisation suceeded\n    Reply(NOERROR);\n\n    Command cmd;\n    do\n    {\n        cmd = GetRequest();\n\n        switch (cmd)\n        {\n\n        case CMD_EXIT: Reply(NOERROR); break;\n\n        case CMD_RUN:\n            DbgLog((LOG_ERROR, 1, TEXT(\"CMD_RUN received before a CMD_PAUSE???\")));\n            // !!! fall through???\n\n        case CMD_PAUSE:\n            Reply(NOERROR);\n            DoBufferProcessingLoop();\n            break;\n\n        case CMD_STOP: Reply(NOERROR); break;\n\n        default:\n            DbgLog((LOG_ERROR, 1, TEXT(\"Unknown command %d received!\"), cmd));\n            Reply((DWORD)E_NOTIMPL);\n            break;\n        }\n    } while (cmd != CMD_EXIT);\n\n    hr = OnThreadDestroy(); // tidy up.\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"CSourceStream::OnThreadDestroy failed. Exiting thread.\")));\n        return 1;\n    }\n\n    DbgLog((LOG_TRACE, 1, TEXT(\"CSourceStream worker thread exiting\")));\n    return 0;\n}\n\n//\n// DoBufferProcessingLoop\n//\n// Grabs a buffer and calls the users processing function.\n// Overridable, so that different delivery styles can be catered for.\nHRESULT CSourceStream::DoBufferProcessingLoop(void)\n{\n\n    Command com;\n\n    OnThreadStartPlay();\n\n    do\n    {\n        while (!CheckRequest(&com))\n        {\n\n            IMediaSample *pSample;\n\n            HRESULT hr = GetDeliveryBuffer(&pSample, NULL, NULL, 0);\n            if (FAILED(hr))\n            {\n                Sleep(1);\n                continue; // go round again. Perhaps the error will go away\n                          // or the allocator is decommited & we will be asked to\n                          // exit soon.\n            }\n\n            // Virtual function user will override.\n            hr = FillBuffer(pSample);\n\n            if (hr == S_OK)\n            {\n                hr = Deliver(pSample);\n                pSample->Release();\n\n                // downstream filter returns S_FALSE if it wants us to\n                // stop or an error if it's reporting an error.\n                if (hr != S_OK)\n                {\n                    DbgLog((LOG_TRACE, 2, TEXT(\"Deliver() returned %08x; stopping\"), hr));\n                    return S_OK;\n                }\n            }\n            else if (hr == S_FALSE)\n            {\n                // derived class wants us to stop pushing data\n                pSample->Release();\n                DeliverEndOfStream();\n                return S_OK;\n            }\n            else\n            {\n                // derived class encountered an error\n                pSample->Release();\n                DbgLog((LOG_ERROR, 1, TEXT(\"Error %08lX from FillBuffer!!!\"), hr));\n                DeliverEndOfStream();\n                m_pFilter->NotifyEvent(EC_ERRORABORT, hr, 0);\n                return hr;\n            }\n\n            // all paths release the sample\n        }\n\n        // For all commands sent to us there must be a Reply call!\n\n        if (com == CMD_RUN || com == CMD_PAUSE)\n        {\n            Reply(NOERROR);\n        }\n        else if (com != CMD_STOP)\n        {\n            Reply((DWORD)E_UNEXPECTED);\n            DbgLog((LOG_ERROR, 1, TEXT(\"Unexpected command!!!\")));\n        }\n    } while (com != CMD_STOP);\n\n    return S_FALSE;\n}\n"
  },
  {
    "path": "common/baseclasses/source.h",
    "content": "//------------------------------------------------------------------------------\n// File: Source.h\n//\n// Desc: DirectShow base classes - defines classes to simplify creation of\n//       ActiveX source filters that support continuous generation of data.\n//       No support is provided for IMediaControl or IMediaPosition.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n//\n// Derive your source filter from CSource.\n// During construction either:\n//    Create some CSourceStream objects to manage your pins\n//    Provide the user with a means of doing so eg, an IPersistFile interface.\n//\n// CSource provides:\n//    IBaseFilter interface management\n//    IMediaFilter interface management, via CBaseFilter\n//    Pin counting for CBaseFilter\n//\n// Derive a class from CSourceStream to manage your output pin types\n//  Implement GetMediaType/1 to return the type you support. If you support multiple\n//   types then overide GetMediaType/3, CheckMediaType and GetMediaTypeCount.\n//  Implement Fillbuffer() to put data into one buffer.\n//\n// CSourceStream provides:\n//    IPin management via CBaseOutputPin\n//    Worker thread management\n\n#ifndef __CSOURCE__\n#define __CSOURCE__\n\nclass CSourceStream; // The class that will handle each pin\n\n//\n// CSource\n//\n// Override construction to provide a means of creating\n// CSourceStream derived objects - ie a way of creating pins.\nclass CSource : public CBaseFilter\n{\n  public:\n    CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr);\n    CSource(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid);\n#ifdef UNICODE\n    CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid, __inout HRESULT *phr);\n    CSource(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN lpunk, CLSID clsid);\n#endif\n    ~CSource();\n\n    int GetPinCount(void);\n    CBasePin *GetPin(int n);\n\n    // -- Utilities --\n\n    CCritSec *pStateLock(void) { return &m_cStateLock; } // provide our critical section\n\n    HRESULT AddPin(__in CSourceStream *);\n    HRESULT RemovePin(__in CSourceStream *);\n\n    STDMETHODIMP FindPin(LPCWSTR Id, __deref_out IPin **ppPin);\n\n    int FindPinNumber(__in IPin *iPin);\n\n  protected:\n    int m_iPins;                 // The number of pins on this filter. Updated by CSourceStream\n                                 // constructors & destructors.\n    CSourceStream **m_paStreams; // the pins on this filter.\n\n    CCritSec m_cStateLock; // Lock this to serialize function accesses to the filter state\n};\n\n//\n// CSourceStream\n//\n// Use this class to manage a stream of data that comes from a\n// pin.\n// Uses a worker thread to put data on the pin.\nclass CSourceStream\n    : public CAMThread\n    , public CBaseOutputPin\n{\n  public:\n    CSourceStream(__in_opt LPCTSTR pObjectName, __inout HRESULT *phr, __inout CSource *pms, __in_opt LPCWSTR pName);\n#ifdef UNICODE\n    CSourceStream(__in_opt LPCSTR pObjectName, __inout HRESULT *phr, __inout CSource *pms, __in_opt LPCWSTR pName);\n#endif\n    virtual ~CSourceStream(void); // virtual destructor ensures derived class destructors are called too.\n\n  protected:\n    CSource *m_pFilter; // The parent of this stream\n\n    // *\n    // * Data Source\n    // *\n    // * The following three functions: FillBuffer, OnThreadCreate/Destroy, are\n    // * called from within the ThreadProc. They are used in the creation of\n    // * the media samples this pin will provide\n    // *\n\n    // Override this to provide the worker thread a means\n    // of processing a buffer\n    virtual HRESULT FillBuffer(IMediaSample *pSamp) PURE;\n\n    // Called as the thread is created/destroyed - use to perform\n    // jobs such as start/stop streaming mode\n    // If OnThreadCreate returns an error the thread will exit.\n    virtual HRESULT OnThreadCreate(void) { return NOERROR; };\n    virtual HRESULT OnThreadDestroy(void) { return NOERROR; };\n    virtual HRESULT OnThreadStartPlay(void) { return NOERROR; };\n\n    // *\n    // * Worker Thread\n    // *\n\n    HRESULT Active(void);   // Starts up the worker thread\n    HRESULT Inactive(void); // Exits the worker thread.\n\n  public:\n    // thread commands\n    enum Command\n    {\n        CMD_INIT,\n        CMD_PAUSE,\n        CMD_RUN,\n        CMD_STOP,\n        CMD_EXIT\n    };\n    HRESULT Init(void) { return CallWorker(CMD_INIT); }\n    HRESULT Exit(void) { return CallWorker(CMD_EXIT); }\n    HRESULT Run(void) { return CallWorker(CMD_RUN); }\n    HRESULT Pause(void) { return CallWorker(CMD_PAUSE); }\n    HRESULT Stop(void) { return CallWorker(CMD_STOP); }\n\n  protected:\n    Command GetRequest(void) { return (Command)CAMThread::GetRequest(); }\n    BOOL CheckRequest(Command *pCom) { return CAMThread::CheckRequest((DWORD *)pCom); }\n\n    // override these if you want to add thread commands\n    virtual DWORD ThreadProc(void); // the thread function\n\n    virtual HRESULT DoBufferProcessingLoop(void); // the loop executed whilst running\n\n    // *\n    // * AM_MEDIA_TYPE support\n    // *\n\n    // If you support more than one media type then override these 2 functions\n    virtual HRESULT CheckMediaType(const CMediaType *pMediaType);\n    virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType); // List pos. 0-n\n\n    // If you support only one type then override this fn.\n    // This will only be called by the default implementations\n    // of CheckMediaType and GetMediaType(int, CMediaType*)\n    // You must override this fn. or the above 2!\n    virtual HRESULT GetMediaType(__inout CMediaType *pMediaType) { return E_UNEXPECTED; }\n\n    STDMETHODIMP QueryId(__deref_out LPWSTR *Id);\n};\n\n#endif // __CSOURCE__\n"
  },
  {
    "path": "common/baseclasses/streams.h",
    "content": "//------------------------------------------------------------------------------\n// File: Streams.h\n//\n// Desc: DirectShow base classes - defines overall streams architecture.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __STREAMS__\n#define __STREAMS__\n\n#ifdef _MSC_VER\n// disable some level-4 warnings, use #pragma warning(enable:###) to re-enable\n#pragma warning(disable : 4100) // warning C4100: unreferenced formal parameter\n#pragma warning(disable : 4201) // warning C4201: nonstandard extension used : nameless struct/union\n#pragma warning(disable : 4511) // warning C4511: copy constructor could not be generated\n#pragma warning(disable : 4512) // warning C4512: assignment operator could not be generated\n#pragma warning(disable : 4514) // warning C4514: \"unreferenced inline function has been removed\"\n\n#if _MSC_VER >= 1100\n#define AM_NOVTABLE __declspec(novtable)\n#else\n#define AM_NOVTABLE\n#endif\n#endif // MSC_VER\n\n// Because of differences between Visual C++ and older Microsoft SDKs,\n// you may have defined _DEBUG without defining DEBUG.  This logic\n// ensures that both will be set if Visual C++ sets _DEBUG.\n#ifdef _DEBUG\n#ifndef DEBUG\n#define DEBUG\n#endif\n#endif\n\n#include <windows.h>\n#include <windowsx.h>\n#include <olectl.h>\n#include <ddraw.h>\n#include <mmsystem.h>\n\n#ifndef NUMELMS\n#if _WIN32_WINNT < 0x0600\n#define NUMELMS(aa) (sizeof(aa) / sizeof((aa)[0]))\n#else\n#define NUMELMS(aa) ARRAYSIZE(aa)\n#endif\n#endif\n\n///////////////////////////////////////////////////////////////////////////\n// The following definitions come from the Platform SDK and are required if\n// the applicaiton is being compiled with the headers from Visual C++ 6.0.\n/////////////////////////////////////////////////// ////////////////////////\n#ifndef InterlockedExchangePointer\n#define InterlockedExchangePointer(Target, Value) (PVOID) InterlockedExchange((PLONG)(Target), (LONG)(Value))\n#endif\n\n#ifndef _WAVEFORMATEXTENSIBLE_\n#define _WAVEFORMATEXTENSIBLE_\ntypedef struct\n{\n    WAVEFORMATEX Format;\n    union {\n        WORD wValidBitsPerSample; /* bits of precision  */\n        WORD wSamplesPerBlock;    /* valid if wBitsPerSample==0 */\n        WORD wReserved;           /* If neither applies, set to zero. */\n    } Samples;\n    DWORD dwChannelMask; /* which channels are */\n                         /* present in stream  */\n    GUID SubFormat;\n} WAVEFORMATEXTENSIBLE, *PWAVEFORMATEXTENSIBLE;\n#endif // !_WAVEFORMATEXTENSIBLE_\n\n#if !defined(WAVE_FORMAT_EXTENSIBLE)\n#define WAVE_FORMAT_EXTENSIBLE 0xFFFE\n#endif // !defined(WAVE_FORMAT_EXTENSIBLE)\n\n#ifndef GetWindowLongPtr\n#define GetWindowLongPtrA GetWindowLongA\n#define GetWindowLongPtrW GetWindowLongW\n#ifdef UNICODE\n#define GetWindowLongPtr GetWindowLongPtrW\n#else\n#define GetWindowLongPtr GetWindowLongPtrA\n#endif // !UNICODE\n#endif // !GetWindowLongPtr\n\n#ifndef SetWindowLongPtr\n#define SetWindowLongPtrA SetWindowLongA\n#define SetWindowLongPtrW SetWindowLongW\n#ifdef UNICODE\n#define SetWindowLongPtr SetWindowLongPtrW\n#else\n#define SetWindowLongPtr SetWindowLongPtrA\n#endif // !UNICODE\n#endif // !SetWindowLongPtr\n\n#ifndef GWLP_WNDPROC\n#define GWLP_WNDPROC (-4)\n#endif\n#ifndef GWLP_HINSTANCE\n#define GWLP_HINSTANCE (-6)\n#endif\n#ifndef GWLP_HWNDPARENT\n#define GWLP_HWNDPARENT (-8)\n#endif\n#ifndef GWLP_USERDATA\n#define GWLP_USERDATA (-21)\n#endif\n#ifndef GWLP_ID\n#define GWLP_ID (-12)\n#endif\n#ifndef DWLP_MSGRESULT\n#define DWLP_MSGRESULT 0\n#endif\n#ifndef DWLP_DLGPROC\n#define DWLP_DLGPROC DWLP_MSGRESULT + sizeof(LRESULT)\n#endif\n#ifndef DWLP_USER\n#define DWLP_USER DWLP_DLGPROC + sizeof(DLGPROC)\n#endif\n\n#pragma warning(push)\n#pragma warning(disable : 4312 4244)\n// _GetWindowLongPtr\n// Templated version of GetWindowLongPtr, to suppress spurious compiler warning.\ntemplate <class T> T _GetWindowLongPtr(HWND hwnd, int nIndex)\n{\n    return (T)GetWindowLongPtr(hwnd, nIndex);\n}\n\n// _SetWindowLongPtr\n// Templated version of SetWindowLongPtr, to suppress spurious compiler warning.\ntemplate <class T> LONG_PTR _SetWindowLongPtr(HWND hwnd, int nIndex, T p)\n{\n    return SetWindowLongPtr(hwnd, nIndex, (LONG_PTR)p);\n}\n#pragma warning(pop)\n\n///////////////////////////////////////////////////////////////////////////\n// End Platform SDK definitions\n///////////////////////////////////////////////////////////////////////////\n\n#include <strmif.h>  // Generated IDL header file for streams interfaces\n#include <intsafe.h> // required by amvideo.h\n\n#include <reftime.h> // Helper class for REFERENCE_TIME management\n#include <wxdebug.h> // Debug support for logging and ASSERTs\n#include <amvideo.h> // ActiveMovie video interfaces and definitions\n// include amaudio.h explicitly if you need it.  it requires the DX SDK.\n//#include <amaudio.h>    // ActiveMovie audio interfaces and definitions\n#include <wxutil.h>   // General helper classes for threads etc\n#include <combase.h>  // Base COM classes to support IUnknown\n#include <dllsetup.h> // Filter registration support functions\n#include <measure.h>  // Performance measurement\n#include <comlite.h>  // Light weight com function prototypes\n\n#include <cache.h>    // Simple cache container class\n#include <wxlist.h>   // Non MFC generic list class\n#include <msgthrd.h>  // CMsgThread\n#include <mtype.h>    // Helper class for managing media types\n#include <fourcc.h>   // conversions between FOURCCs and GUIDs\n#include <control.h>  // generated from control.odl\n#include <ctlutil.h>  // control interface utility classes\n#include <evcode.h>   // event code definitions\n#include <amfilter.h> // Main streams architecture class hierachy\n#include <transfrm.h> // Generic transform filter\n#include <transip.h>  // Generic transform-in-place filter\n#include <uuids.h>    // declaration of type GUIDs and well-known clsids\n#include <source.h>   // Generic source filter\n#include <outputq.h>  // Output pin queueing\n#include <errors.h>   // HRESULT status and error definitions\n#include <renbase.h>  // Base class for writing ActiveX renderers\n#include <winutil.h>  // Helps with filters that manage windows\n#include <winctrl.h>  // Implements the IVideoWindow interface\n#include <videoctl.h> // Specifically video related classes\n#include <refclock.h> // Base clock class\n#include <sysclock.h> // System clock\n#include <pstream.h>  // IPersistStream helper class\n#include <vtrans.h>   // Video Transform Filter base class\n#include <amextra.h>\n#include <cprop.h>    // Base property page class\n#include <strmctl.h>  // IAMStreamControl support\n#include <edevdefs.h> // External device control interface defines\n#include <audevcod.h> // audio filter device error event codes\n\n#else\n#ifdef DEBUG\n#pragma message(\"STREAMS.H included TWICE\")\n#endif\n#endif // __STREAMS__\n"
  },
  {
    "path": "common/baseclasses/strmctl.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: StrmCtl.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1996-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <strmctl.h>\n\nCBaseStreamControl::CBaseStreamControl(__inout HRESULT *phr)\n    : m_StreamState(STREAM_FLOWING)\n    , m_StreamStateOnStop(STREAM_FLOWING) // means no pending stop\n    , m_tStartTime(MAX_TIME)\n    , m_tStopTime(MAX_TIME)\n    , m_StreamEvent(FALSE, phr)\n    , m_dwStartCookie(0)\n    , m_dwStopCookie(0)\n    , m_pRefClock(NULL)\n    , m_FilterState(State_Stopped)\n    , m_bIsFlushing(FALSE)\n    , m_bStopSendExtra(FALSE)\n{\n}\n\nCBaseStreamControl::~CBaseStreamControl()\n{\n    // Make sure we release the clock.\n    SetSyncSource(NULL);\n    return;\n}\n\nSTDMETHODIMP CBaseStreamControl::StopAt(const REFERENCE_TIME *ptStop, BOOL bSendExtra, DWORD dwCookie)\n{\n    CAutoLock lck(&m_CritSec);\n    m_bStopSendExtra = FALSE; // reset\n    m_bStopExtraSent = FALSE;\n    if (ptStop)\n    {\n        if (*ptStop == MAX_TIME)\n        {\n            DbgLog((LOG_TRACE, 2, TEXT(\"StopAt: Cancel stop\")));\n            CancelStop();\n            // If there's now a command to start in the future, we assume\n            // they want to be stopped when the graph is first run\n            if (m_FilterState == State_Stopped && m_tStartTime < MAX_TIME)\n            {\n                m_StreamState = STREAM_DISCARDING;\n                DbgLog((LOG_TRACE, 2, TEXT(\"graph will begin by DISCARDING\")));\n            }\n            return NOERROR;\n        }\n        DbgLog((LOG_TRACE, 2, TEXT(\"StopAt: %dms extra=%d\"), (int)(*ptStop / 10000), bSendExtra));\n        // if the first command is to stop in the future, then we assume they\n        // want to be started when the graph is first run\n        if (m_FilterState == State_Stopped && m_tStartTime > *ptStop)\n        {\n            m_StreamState = STREAM_FLOWING;\n            DbgLog((LOG_TRACE, 2, TEXT(\"graph will begin by FLOWING\")));\n        }\n        m_bStopSendExtra = bSendExtra;\n        m_tStopTime = *ptStop;\n        m_dwStopCookie = dwCookie;\n        m_StreamStateOnStop = STREAM_DISCARDING;\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"StopAt: now\")));\n        // sending an extra frame when told to stop now would mess people up\n        m_bStopSendExtra = FALSE;\n        m_tStopTime = MAX_TIME;\n        m_dwStopCookie = 0;\n        m_StreamState = STREAM_DISCARDING;\n        m_StreamStateOnStop = STREAM_FLOWING; // no pending stop\n    }\n    // we might change our mind what to do with a sample we're blocking\n    m_StreamEvent.Set();\n    return NOERROR;\n}\n\nSTDMETHODIMP CBaseStreamControl::StartAt(const REFERENCE_TIME *ptStart, DWORD dwCookie)\n{\n    CAutoLock lck(&m_CritSec);\n    if (ptStart)\n    {\n        if (*ptStart == MAX_TIME)\n        {\n            DbgLog((LOG_TRACE, 2, TEXT(\"StartAt: Cancel start\")));\n            CancelStart();\n            // If there's now a command to stop in the future, we assume\n            // they want to be started when the graph is first run\n            if (m_FilterState == State_Stopped && m_tStopTime < MAX_TIME)\n            {\n                DbgLog((LOG_TRACE, 2, TEXT(\"graph will begin by FLOWING\")));\n                m_StreamState = STREAM_FLOWING;\n            }\n            return NOERROR;\n        }\n        DbgLog((LOG_TRACE, 2, TEXT(\"StartAt: %dms\"), (int)(*ptStart / 10000)));\n        // if the first command is to start in the future, then we assume they\n        // want to be stopped when the graph is first run\n        if (m_FilterState == State_Stopped && m_tStopTime >= *ptStart)\n        {\n            DbgLog((LOG_TRACE, 2, TEXT(\"graph will begin by DISCARDING\")));\n            m_StreamState = STREAM_DISCARDING;\n        }\n        m_tStartTime = *ptStart;\n        m_dwStartCookie = dwCookie;\n        // if (m_tStopTime == m_tStartTime) CancelStop();\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"StartAt: now\")));\n        m_tStartTime = MAX_TIME;\n        m_dwStartCookie = 0;\n        m_StreamState = STREAM_FLOWING;\n    }\n    // we might change our mind what to do with a sample we're blocking\n    m_StreamEvent.Set();\n    return NOERROR;\n}\n\n//  Retrieve information about current settings\nSTDMETHODIMP CBaseStreamControl::GetInfo(__out AM_STREAM_INFO *pInfo)\n{\n    if (pInfo == NULL)\n        return E_POINTER;\n\n    pInfo->tStart = m_tStartTime;\n    pInfo->tStop = m_tStopTime;\n    pInfo->dwStartCookie = m_dwStartCookie;\n    pInfo->dwStopCookie = m_dwStopCookie;\n    pInfo->dwFlags = m_bStopSendExtra ? AM_STREAM_INFO_STOP_SEND_EXTRA : 0;\n    pInfo->dwFlags |= m_tStartTime == MAX_TIME ? 0 : AM_STREAM_INFO_START_DEFINED;\n    pInfo->dwFlags |= m_tStopTime == MAX_TIME ? 0 : AM_STREAM_INFO_STOP_DEFINED;\n    switch (m_StreamState)\n    {\n    default: DbgBreak(\"Invalid stream state\");\n    case STREAM_FLOWING: break;\n    case STREAM_DISCARDING: pInfo->dwFlags |= AM_STREAM_INFO_DISCARDING; break;\n    }\n    return S_OK;\n}\n\nvoid CBaseStreamControl::ExecuteStop()\n{\n    ASSERT(CritCheckIn(&m_CritSec));\n    m_StreamState = m_StreamStateOnStop;\n    if (m_dwStopCookie && m_pSink)\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"*sending EC_STREAM_CONTROL_STOPPED (%d)\"), m_dwStopCookie));\n        m_pSink->Notify(EC_STREAM_CONTROL_STOPPED, (LONG_PTR)this, m_dwStopCookie);\n    }\n    CancelStop(); // This will do the tidy up\n}\n\nvoid CBaseStreamControl::ExecuteStart()\n{\n    ASSERT(CritCheckIn(&m_CritSec));\n    m_StreamState = STREAM_FLOWING;\n    if (m_dwStartCookie)\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"*sending EC_STREAM_CONTROL_STARTED (%d)\"), m_dwStartCookie));\n        m_pSink->Notify(EC_STREAM_CONTROL_STARTED, (LONG_PTR)this, m_dwStartCookie);\n    }\n    CancelStart(); // This will do the tidy up\n}\n\nvoid CBaseStreamControl::CancelStop()\n{\n    ASSERT(CritCheckIn(&m_CritSec));\n    m_tStopTime = MAX_TIME;\n    m_dwStopCookie = 0;\n    m_StreamStateOnStop = STREAM_FLOWING;\n}\n\nvoid CBaseStreamControl::CancelStart()\n{\n    ASSERT(CritCheckIn(&m_CritSec));\n    m_tStartTime = MAX_TIME;\n    m_dwStartCookie = 0;\n}\n\n// This guy will return one of the three StreamControlState's.  Here's what the caller\n// should do for each one:\n//\n// STREAM_FLOWING:      Proceed as usual (render or pass the sample on)\n// STREAM_DISCARDING:   Calculate the time 'til *pSampleStart and wait that long\n//                      for the event handle (GetStreamEventHandle()).  If the\n//                      wait expires, throw the sample away.  If the event\n//\t\t\tfires, call me back, I've changed my mind.\n//\t\t\tI use pSampleStart (not Stop) so that live sources don't\n// \t\t\tblock for the duration of their samples, since the clock\n//\t\t\twill always read approximately pSampleStart when called\n\n// All through this code, you'll notice the following rules:\n// - When start and stop time are the same, it's as if start was first\n// - An event is considered inside the sample when it's >= sample start time\n//   but < sample stop time\n// - if any part of the sample is supposed to be sent, we'll send the whole\n//   thing since we don't break it into smaller pieces\n// - If we skip over a start or stop without doing it, we still signal the event\n//   and reset ourselves in case somebody's waiting for the event, and to make\n//   sure we notice that the event is past and should be forgotten\n// Here are the 19 cases that have to be handled (x=start o=stop <-->=sample):\n//\n// 1.\txo<-->\t\tstart then stop\n// 2.\tox<-->\t\tstop then start\n// 3.\t x<o->\t\tstart\n// 4.\t o<x->\t\tstop then start\n// 5.\t x<-->o\t\tstart\n// 6.\t o<-->x\t\tstop\n// 7.\t  <x->o\t\tstart\n// 8.\t  <o->x\t\tno change\n// 9.\t  <xo>\t\tstart\n// 10.\t  <ox>\t\tstop then start\n// 11.\t  <-->xo\tno change\n// 12.\t  <-->ox\tno change\n// 13.\t x<-->\t\tstart\n// 14.    <x->\t\tstart\n// 15.    <-->x\t\tno change\n// 16.   o<-->\t\tstop\n// 17.\t  <o->\t\tno change\n// 18.\t  <-->o\t\tno change\n// 19.    <-->\t\tno change\n\nenum CBaseStreamControl::StreamControlState CBaseStreamControl::CheckSampleTimes(\n    __in const REFERENCE_TIME *pSampleStart, __in const REFERENCE_TIME *pSampleStop)\n{\n    CAutoLock lck(&m_CritSec);\n\n    ASSERT(!m_bIsFlushing);\n    ASSERT(pSampleStart && pSampleStop);\n\n    // Don't ask me how I came up with the code below to handle all 19 cases\n    // - DannyMi\n\n    if (m_tStopTime >= *pSampleStart)\n    {\n        if (m_tStartTime >= *pSampleStop)\n            return m_StreamState; // cases  8 11 12 15 17 18 19\n        if (m_tStopTime < m_tStartTime)\n            ExecuteStop(); // case 10\n        ExecuteStart();    // cases 3 5 7 9 13 14\n        return m_StreamState;\n    }\n\n    if (m_tStartTime >= *pSampleStop)\n    {\n        ExecuteStop(); // cases 6 16\n        return m_StreamState;\n    }\n\n    if (m_tStartTime <= m_tStopTime)\n    {\n        ExecuteStart();\n        ExecuteStop();\n        return m_StreamState; // case 1\n    }\n    else\n    {\n        ExecuteStop();\n        ExecuteStart();\n        return m_StreamState; // cases 2 4\n    }\n}\n\nenum CBaseStreamControl::StreamControlState CBaseStreamControl::CheckStreamState(IMediaSample *pSample)\n{\n\n    REFERENCE_TIME rtBufferStart, rtBufferStop;\n    const BOOL bNoBufferTimes = pSample == NULL || FAILED(pSample->GetTime(&rtBufferStart, &rtBufferStop));\n\n    StreamControlState state;\n    LONG lWait;\n\n    do\n    {\n        // something has to break out of the blocking\n        if (m_bIsFlushing || m_FilterState == State_Stopped)\n            return STREAM_DISCARDING;\n\n        if (bNoBufferTimes)\n        {\n            //  Can't do anything until we get a time stamp\n            state = m_StreamState;\n            break;\n        }\n        else\n        {\n            state = CheckSampleTimes(&rtBufferStart, &rtBufferStop);\n            if (state == STREAM_FLOWING)\n                break;\n\n            // we aren't supposed to send this, but we've been\n            // told to send one more than we were supposed to\n            // (and the stop isn't still pending and we're streaming)\n            if (m_bStopSendExtra && !m_bStopExtraSent && m_tStopTime == MAX_TIME && m_FilterState != State_Stopped)\n            {\n                m_bStopExtraSent = TRUE;\n                DbgLog((LOG_TRACE, 2, TEXT(\"%d sending an EXTRA frame\"), m_dwStopCookie));\n                state = STREAM_FLOWING;\n                break;\n            }\n        }\n\n        // We're in discarding mode\n\n        // If we've no clock, discard as fast as we can\n        if (!m_pRefClock)\n        {\n            break;\n\n            // If we're paused, we can't discard in a timely manner because\n            // there's no such thing as stream times.  We must block until\n            // we run or stop, or we'll end up throwing the whole stream away\n            // as quickly as possible\n        }\n        else if (m_FilterState == State_Paused)\n        {\n            lWait = INFINITE;\n        }\n        else\n        {\n            // wait until it's time for the sample until we say \"discard\"\n            // (\"discard in a timely fashion\")\n            REFERENCE_TIME rtNow;\n            EXECUTE_ASSERT(SUCCEEDED(m_pRefClock->GetTime(&rtNow)));\n            rtNow -= m_tRunStart;                          // Into relative ref-time\n            lWait = LONG((rtBufferStart - rtNow) / 10000); // 100ns -> ms\n            if (lWait < 10)\n                break; // Not worth waiting - discard early\n        }\n\n    } while (WaitForSingleObject(GetStreamEventHandle(), lWait) != WAIT_TIMEOUT);\n\n    return state;\n}\n\nvoid CBaseStreamControl::NotifyFilterState(FILTER_STATE new_state, REFERENCE_TIME tStart)\n{\n    CAutoLock lck(&m_CritSec);\n\n    // or we will get confused\n    if (m_FilterState == new_state)\n        return;\n\n    switch (new_state)\n    {\n    case State_Stopped:\n\n        DbgLog((LOG_TRACE, 2, TEXT(\"Filter is STOPPED\")));\n\n        // execute any pending starts and stops in the right order,\n        // to make sure all notifications get sent, and we end up\n        // in the right state to begin next time (??? why not?)\n\n        if (m_tStartTime != MAX_TIME && m_tStopTime == MAX_TIME)\n        {\n            ExecuteStart();\n        }\n        else if (m_tStopTime != MAX_TIME && m_tStartTime == MAX_TIME)\n        {\n            ExecuteStop();\n        }\n        else if (m_tStopTime != MAX_TIME && m_tStartTime != MAX_TIME)\n        {\n            if (m_tStartTime <= m_tStopTime)\n            {\n                ExecuteStart();\n                ExecuteStop();\n            }\n            else\n            {\n                ExecuteStop();\n                ExecuteStart();\n            }\n        }\n        // always start off flowing when the graph starts streaming\n        // unless told otherwise\n        m_StreamState = STREAM_FLOWING;\n        m_FilterState = new_state;\n        break;\n\n    case State_Running:\n\n        DbgLog((LOG_TRACE, 2, TEXT(\"Filter is RUNNING\")));\n\n        m_tRunStart = tStart;\n        // fall-through\n\n    default: // case State_Paused:\n        m_FilterState = new_state;\n    }\n    // unblock!\n    m_StreamEvent.Set();\n}\n\nvoid CBaseStreamControl::Flushing(BOOL bInProgress)\n{\n    CAutoLock lck(&m_CritSec);\n    m_bIsFlushing = bInProgress;\n    m_StreamEvent.Set();\n}\n"
  },
  {
    "path": "common/baseclasses/strmctl.h",
    "content": "//------------------------------------------------------------------------------\n// File: StrmCtl.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1996-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __strmctl_h__\n#define __strmctl_h__\n\nclass CBaseStreamControl : public IAMStreamControl\n{\n  public:\n    // Used by the implementation\n    enum StreamControlState\n    {\n        STREAM_FLOWING = 0x1000,\n        STREAM_DISCARDING\n    };\n\n  private:\n    enum StreamControlState m_StreamState;       // Current stream state\n    enum StreamControlState m_StreamStateOnStop; // State after next stop\n                                                 // (i.e.Blocking or Discarding)\n\n    REFERENCE_TIME m_tStartTime;    // MAX_TIME implies none\n    REFERENCE_TIME m_tStopTime;     // MAX_TIME implies none\n    DWORD m_dwStartCookie;          // Cookie for notification to app\n    DWORD m_dwStopCookie;           // Cookie for notification to app\n    volatile BOOL m_bIsFlushing;    // No optimization pls!\n    volatile BOOL m_bStopSendExtra; // bSendExtra was set\n    volatile BOOL m_bStopExtraSent; // the extra one was sent\n\n    CCritSec m_CritSec; // CritSec to guard above attributes\n\n    // Event to fire when we can come\n    // out of blocking, or to come out of waiting\n    // to discard if we change our minds.\n    //\n    CAMEvent m_StreamEvent;\n\n    // All of these methods execute immediately.  Helpers for others.\n    //\n    void ExecuteStop();\n    void ExecuteStart();\n    void CancelStop();\n    void CancelStart();\n\n    // Some things we need to be told by our owning filter\n    // Your pin must also expose IAMStreamControl when QI'd for it!\n    //\n    IReferenceClock *m_pRefClock; // Need it to set advises\n                                  // Filter must tell us via\n                                  // SetSyncSource\n    IMediaEventSink *m_pSink;     // Event sink\n                                  // Filter must tell us after it\n                                  // creates it in JoinFilterGraph()\n    FILTER_STATE m_FilterState;   // Just need it!\n                                  // Filter must tell us via\n                                  // NotifyFilterState\n    REFERENCE_TIME m_tRunStart;   // Per the Run call to the filter\n\n    // This guy will return one of the three StreamControlState's.  Here's what\n    // the caller should do for each one:\n    //\n    // STREAM_FLOWING:\t\tProceed as usual (render or pass the sample on)\n    // STREAM_DISCARDING:\tCalculate the time 'til *pSampleStop and wait\n    //\t\t\t\tthat long for the event handle\n    //\t\t\t\t(GetStreamEventHandle()).  If the wait\n    //\t\t\t\texpires, throw the sample away.  If the event\n    //\t\t\t\tfires, call me back - I've changed my mind.\n    //\n    enum StreamControlState CheckSampleTimes(__in const REFERENCE_TIME *pSampleStart,\n                                             __in const REFERENCE_TIME *pSampleStop);\n\n  public:\n    // You don't have to tell us much when we're created, but there are other\n    // obligations that must be met.  See SetSyncSource & NotifyFilterState\n    // below.\n    //\n    CBaseStreamControl(__inout_opt HRESULT *phr = NULL);\n    ~CBaseStreamControl();\n\n    // If you want this class to work properly, there are thing you need to\n    // (keep) telling it.  Filters with pins that use this class\n    // should ensure that they pass through to this method any calls they\n    // receive on their SetSyncSource.\n\n    // We need a clock to see what time it is.  This is for the\n    // \"discard in a timely fashion\" logic.  If we discard everything as\n    // quick as possible, a whole 60 minute file could get discarded in the\n    // first 10 seconds, and if somebody wants to turn streaming on at 30\n    // minutes into the file, and they make the call more than a few seconds\n    // after the graph is run, it may be too late!\n    // So we hold every sample until it's time has gone, then we discard it.\n    // The filter should call this when it gets a SetSyncSource\n    //\n    void SetSyncSource(IReferenceClock *pRefClock)\n    {\n        CAutoLock lck(&m_CritSec);\n        if (m_pRefClock)\n            m_pRefClock->Release();\n        m_pRefClock = pRefClock;\n        if (m_pRefClock)\n            m_pRefClock->AddRef();\n    }\n\n    // Set event sink for notifications\n    // The filter should call this in its JoinFilterGraph after it creates the\n    // IMediaEventSink\n    //\n    void SetFilterGraph(IMediaEventSink *pSink) { m_pSink = pSink; }\n\n    // Since we schedule in stream time, we need the tStart and must track the\n    // state of our owning filter.\n    // The app should call this ever state change\n    //\n    void NotifyFilterState(FILTER_STATE new_state, REFERENCE_TIME tStart = 0);\n\n    // Filter should call Flushing(TRUE) in BeginFlush,\n    // and Flushing(FALSE) in EndFlush.\n    //\n    void Flushing(BOOL bInProgress);\n\n    // The two main methods of IAMStreamControl\n\n    // Class adds default values suitable for immediate\n    // muting and unmuting of the stream.\n\n    STDMETHODIMP StopAt(const REFERENCE_TIME *ptStop = NULL, BOOL bSendExtra = FALSE, DWORD dwCookie = 0);\n    STDMETHODIMP StartAt(const REFERENCE_TIME *ptStart = NULL, DWORD dwCookie = 0);\n    STDMETHODIMP GetInfo(__out AM_STREAM_INFO *pInfo);\n\n    // Helper function for pin's receive method.  Call this with\n    // the sample and we'll tell you what to do with it.  We'll do a\n    // WaitForSingleObject within this call if one is required.  This is\n    // a \"What should I do with this sample?\" kind of call. We'll tell the\n    // caller to either flow it or discard it.\n    // If pSample is NULL we evaluate based on the current state\n    // settings\n    enum StreamControlState CheckStreamState(IMediaSample *pSample);\n\n  private:\n    // These don't require locking, but we are relying on the fact that\n    // m_StreamState can be retrieved with integrity, and is a snap shot that\n    // may have just been, or may be just about to be, changed.\n    HANDLE GetStreamEventHandle() const { return m_StreamEvent; }\n    enum StreamControlState GetStreamState() const { return m_StreamState; }\n    BOOL IsStreaming() const { return m_StreamState == STREAM_FLOWING; }\n};\n\n#endif\n"
  },
  {
    "path": "common/baseclasses/sysclock.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: SysClock.cpp\n//\n// Desc: DirectShow base classes - implements a system clock based on\n//       IReferenceClock.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <limits.h>\n\n#ifdef FILTER_DLL\n\n/* List of class IDs and creator functions for the class factory. This\n   provides the link between the OLE entry point in the DLL and an object\n   being created. The class factory will call the static CreateInstance\n   function when it is asked to create a CLSID_SystemClock object */\n\nCFactoryTemplate g_Templates[1] = {{&CLSID_SystemClock, CSystemClock::CreateInstance}};\n\nint g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);\n#endif\n\n/* This goes in the factory template table to create new instances */\nCUnknown *WINAPI CSystemClock::CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)\n{\n    return new CSystemClock(NAME(\"System reference clock\"), pUnk, phr);\n}\n\nCSystemClock::CSystemClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr)\n    : CBaseReferenceClock(pName, pUnk, phr)\n{\n}\n\nSTDMETHODIMP CSystemClock::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_IPersist)\n    {\n        return GetInterface(static_cast<IPersist *>(this), ppv);\n    }\n    else if (riid == IID_IAMClockAdjust)\n    {\n        return GetInterface(static_cast<IAMClockAdjust *>(this), ppv);\n    }\n    else\n    {\n        return CBaseReferenceClock::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n/* Return the clock's clsid */\nSTDMETHODIMP\nCSystemClock::GetClassID(__out CLSID *pClsID)\n{\n    CheckPointer(pClsID, E_POINTER);\n    ValidateReadWritePtr(pClsID, sizeof(CLSID));\n    *pClsID = CLSID_SystemClock;\n    return NOERROR;\n}\n\nSTDMETHODIMP\nCSystemClock::SetClockDelta(REFERENCE_TIME rtDelta)\n{\n    return SetTimeDelta(rtDelta);\n}\n"
  },
  {
    "path": "common/baseclasses/sysclock.h",
    "content": "//------------------------------------------------------------------------------\n// File: SysClock.h\n//\n// Desc: DirectShow base classes - defines a system clock implementation of\n//       IReferenceClock.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __SYSTEMCLOCK__\n#define __SYSTEMCLOCK__\n\n//\n// Base clock.  Uses timeGetTime ONLY\n// Uses most of the code in the base reference clock.\n// Provides GetTime\n//\n\nclass CSystemClock\n    : public CBaseReferenceClock\n    , public IAMClockAdjust\n    , public IPersist\n{\n  public:\n    // We must be able to create an instance of ourselves\n    static CUnknown *WINAPI CreateInstance(__inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);\n    CSystemClock(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, __inout HRESULT *phr);\n\n    DECLARE_IUNKNOWN\n\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    // Yield up our class id so that we can be persisted\n    // Implement required Ipersist method\n    STDMETHODIMP GetClassID(__out CLSID *pClsID);\n\n    //  IAMClockAdjust methods\n    STDMETHODIMP SetClockDelta(REFERENCE_TIME rtDelta);\n}; // CSystemClock\n\n#endif /* __SYSTEMCLOCK__ */\n"
  },
  {
    "path": "common/baseclasses/transfrm.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: Transfrm.cpp\n//\n// Desc: DirectShow base classes - implements class for simple transform\n//       filters such as video decompressors.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <measure.h>\n\n// =================================================================\n// Implements the CTransformFilter class\n// =================================================================\n\nCTransformFilter::CTransformFilter(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, REFCLSID clsid)\n    : CBaseFilter(pName, pUnk, &m_csFilter, clsid)\n    , m_pInput(NULL)\n    , m_pOutput(NULL)\n    , m_bEOSDelivered(FALSE)\n    , m_bQualityChanged(FALSE)\n    , m_bSampleSkipped(FALSE)\n{\n#ifdef PERF\n    RegisterPerfId();\n#endif //  PERF\n}\n\n#ifdef UNICODE\nCTransformFilter::CTransformFilter(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN pUnk, REFCLSID clsid)\n    : CBaseFilter(pName, pUnk, &m_csFilter, clsid)\n    , m_pInput(NULL)\n    , m_pOutput(NULL)\n    , m_bEOSDelivered(FALSE)\n    , m_bQualityChanged(FALSE)\n    , m_bSampleSkipped(FALSE)\n{\n#ifdef PERF\n    RegisterPerfId();\n#endif //  PERF\n}\n#endif\n\n// destructor\n\nCTransformFilter::~CTransformFilter()\n{\n    // Delete the pins\n\n    delete m_pInput;\n    delete m_pOutput;\n}\n\n// Transform place holder - should never be called\nHRESULT CTransformFilter::Transform(IMediaSample *pIn, IMediaSample *pOut)\n{\n    UNREFERENCED_PARAMETER(pIn);\n    UNREFERENCED_PARAMETER(pOut);\n    DbgBreak(\"CTransformFilter::Transform() should never be called\");\n    return E_UNEXPECTED;\n}\n\n// return the number of pins we provide\n\nint CTransformFilter::GetPinCount()\n{\n    return 2;\n}\n\n// return a non-addrefed CBasePin * for the user to addref if he holds onto it\n// for longer than his pointer to us. We create the pins dynamically when they\n// are asked for rather than in the constructor. This is because we want to\n// give the derived class an oppportunity to return different pin objects\n\n// We return the objects as and when they are needed. If either of these fails\n// then we return NULL, the assumption being that the caller will realise the\n// whole deal is off and destroy us - which in turn will delete everything.\n\nCBasePin *CTransformFilter::GetPin(int n)\n{\n    HRESULT hr = S_OK;\n\n    // Create an input pin if necessary\n\n    if (m_pInput == NULL)\n    {\n\n        m_pInput = new CTransformInputPin(NAME(\"Transform input pin\"),\n                                          this,         // Owner filter\n                                          &hr,          // Result code\n                                          L\"XForm In\"); // Pin name\n\n        //  Can't fail\n        ASSERT(SUCCEEDED(hr));\n        if (m_pInput == NULL)\n        {\n            return NULL;\n        }\n        m_pOutput = (CTransformOutputPin *)new CTransformOutputPin(NAME(\"Transform output pin\"),\n                                                                   this,          // Owner filter\n                                                                   &hr,           // Result code\n                                                                   L\"XForm Out\"); // Pin name\n\n        // Can't fail\n        ASSERT(SUCCEEDED(hr));\n        if (m_pOutput == NULL)\n        {\n            delete m_pInput;\n            m_pInput = NULL;\n        }\n    }\n\n    // Return the appropriate pin\n\n    if (n == 0)\n    {\n        return m_pInput;\n    }\n    else if (n == 1)\n    {\n        return m_pOutput;\n    }\n    else\n    {\n        return NULL;\n    }\n}\n\n//\n// FindPin\n//\n// If Id is In or Out then return the IPin* for that pin\n// creating the pin if need be.  Otherwise return NULL with an error.\n\nSTDMETHODIMP CTransformFilter::FindPin(LPCWSTR Id, __deref_out IPin **ppPin)\n{\n    CheckPointer(ppPin, E_POINTER);\n    ValidateReadWritePtr(ppPin, sizeof(IPin *));\n\n    if (0 == lstrcmpW(Id, L\"In\"))\n    {\n        *ppPin = GetPin(0);\n    }\n    else if (0 == lstrcmpW(Id, L\"Out\"))\n    {\n        *ppPin = GetPin(1);\n    }\n    else\n    {\n        *ppPin = NULL;\n        return VFW_E_NOT_FOUND;\n    }\n\n    HRESULT hr = NOERROR;\n    //  AddRef() returned pointer - but GetPin could fail if memory is low.\n    if (*ppPin)\n    {\n        (*ppPin)->AddRef();\n    }\n    else\n    {\n        hr = E_OUTOFMEMORY; // probably.  There's no pin anyway.\n    }\n    return hr;\n}\n\n// override these two functions if you want to inform something\n// about entry to or exit from streaming state.\n\nHRESULT\nCTransformFilter::StartStreaming()\n{\n    return NOERROR;\n}\n\nHRESULT\nCTransformFilter::StopStreaming()\n{\n    return NOERROR;\n}\n\n// override this to grab extra interfaces on connection\n\nHRESULT\nCTransformFilter::CheckConnect(PIN_DIRECTION dir, IPin *pPin)\n{\n    UNREFERENCED_PARAMETER(dir);\n    UNREFERENCED_PARAMETER(pPin);\n    return NOERROR;\n}\n\n// place holder to allow derived classes to release any extra interfaces\n\nHRESULT\nCTransformFilter::BreakConnect(PIN_DIRECTION dir)\n{\n    UNREFERENCED_PARAMETER(dir);\n    return NOERROR;\n}\n\n// Let derived classes know about connection completion\n\nHRESULT\nCTransformFilter::CompleteConnect(PIN_DIRECTION direction, IPin *pReceivePin)\n{\n    UNREFERENCED_PARAMETER(direction);\n    UNREFERENCED_PARAMETER(pReceivePin);\n    return NOERROR;\n}\n\n// override this to know when the media type is really set\n\nHRESULT\nCTransformFilter::SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt)\n{\n    UNREFERENCED_PARAMETER(direction);\n    UNREFERENCED_PARAMETER(pmt);\n    return NOERROR;\n}\n\n// Set up our output sample\nHRESULT\nCTransformFilter::InitializeOutputSample(IMediaSample *pSample, __deref_out IMediaSample **ppOutSample)\n{\n    IMediaSample *pOutSample;\n\n    // default - times are the same\n\n    AM_SAMPLE2_PROPERTIES *const pProps = m_pInput->SampleProps();\n    DWORD dwFlags = m_bSampleSkipped ? AM_GBF_PREVFRAMESKIPPED : 0;\n\n    // This will prevent the image renderer from switching us to DirectDraw\n    // when we can't do it without skipping frames because we're not on a\n    // keyframe.  If it really has to switch us, it still will, but then we\n    // will have to wait for the next keyframe\n    if (!(pProps->dwSampleFlags & AM_SAMPLE_SPLICEPOINT))\n    {\n        dwFlags |= AM_GBF_NOTASYNCPOINT;\n    }\n\n    ASSERT(m_pOutput->m_pAllocator != NULL);\n    HRESULT hr = m_pOutput->m_pAllocator->GetBuffer(\n        &pOutSample, pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID ? &pProps->tStart : NULL,\n        pProps->dwSampleFlags & AM_SAMPLE_STOPVALID ? &pProps->tStop : NULL, dwFlags);\n    *ppOutSample = pOutSample;\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    ASSERT(pOutSample);\n    IMediaSample2 *pOutSample2;\n    if (SUCCEEDED(pOutSample->QueryInterface(IID_IMediaSample2, (void **)&pOutSample2)))\n    {\n        /*  Modify it */\n        AM_SAMPLE2_PROPERTIES OutProps;\n        EXECUTE_ASSERT(\n            SUCCEEDED(pOutSample2->GetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, tStart), (PBYTE)&OutProps)));\n        OutProps.dwTypeSpecificFlags = pProps->dwTypeSpecificFlags;\n        OutProps.dwSampleFlags =\n            (OutProps.dwSampleFlags & AM_SAMPLE_TYPECHANGED) | (pProps->dwSampleFlags & ~AM_SAMPLE_TYPECHANGED);\n        OutProps.tStart = pProps->tStart;\n        OutProps.tStop = pProps->tStop;\n        OutProps.cbData = FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId);\n        hr = pOutSample2->SetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, dwStreamId), (PBYTE)&OutProps);\n        if (pProps->dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY)\n        {\n            m_bSampleSkipped = FALSE;\n        }\n        pOutSample2->Release();\n    }\n    else\n    {\n        if (pProps->dwSampleFlags & AM_SAMPLE_TIMEVALID)\n        {\n            pOutSample->SetTime(&pProps->tStart, &pProps->tStop);\n        }\n        if (pProps->dwSampleFlags & AM_SAMPLE_SPLICEPOINT)\n        {\n            pOutSample->SetSyncPoint(TRUE);\n        }\n        if (pProps->dwSampleFlags & AM_SAMPLE_DATADISCONTINUITY)\n        {\n            pOutSample->SetDiscontinuity(TRUE);\n            m_bSampleSkipped = FALSE;\n        }\n        // Copy the media times\n\n        LONGLONG MediaStart, MediaEnd;\n        if (pSample->GetMediaTime(&MediaStart, &MediaEnd) == NOERROR)\n        {\n            pOutSample->SetMediaTime(&MediaStart, &MediaEnd);\n        }\n    }\n    return S_OK;\n}\n\n// override this to customize the transform process\n\nHRESULT\nCTransformFilter::Receive(IMediaSample *pSample)\n{\n    /*  Check for other streams and pass them on */\n    AM_SAMPLE2_PROPERTIES *const pProps = m_pInput->SampleProps();\n    if (pProps->dwStreamId != AM_STREAM_MEDIA)\n    {\n        return m_pOutput->m_pInputPin->Receive(pSample);\n    }\n    HRESULT hr;\n    ASSERT(pSample);\n    IMediaSample *pOutSample;\n\n    // If no output to deliver to then no point sending us data\n\n    ASSERT(m_pOutput != NULL);\n\n    // Set up the output sample\n    hr = InitializeOutputSample(pSample, &pOutSample);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Start timing the transform (if PERF is defined)\n    MSR_START(m_idTransform);\n\n    // have the derived class transform the data\n\n    hr = Transform(pSample, pOutSample);\n\n    // Stop the clock and log it (if PERF is defined)\n    MSR_STOP(m_idTransform);\n\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 1, TEXT(\"Error from transform\")));\n    }\n    else\n    {\n        // the Transform() function can return S_FALSE to indicate that the\n        // sample should not be delivered; we only deliver the sample if it's\n        // really S_OK (same as NOERROR, of course.)\n        if (hr == NOERROR)\n        {\n            hr = m_pOutput->m_pInputPin->Receive(pOutSample);\n            m_bSampleSkipped = FALSE; // last thing no longer dropped\n        }\n        else\n        {\n            // S_FALSE returned from Transform is a PRIVATE agreement\n            // We should return NOERROR from Receive() in this cause because returning S_FALSE\n            // from Receive() means that this is the end of the stream and no more data should\n            // be sent.\n            if (S_FALSE == hr)\n            {\n\n                //  Release the sample before calling notify to avoid\n                //  deadlocks if the sample holds a lock on the system\n                //  such as DirectDraw buffers do\n                pOutSample->Release();\n                m_bSampleSkipped = TRUE;\n                if (!m_bQualityChanged)\n                {\n                    NotifyEvent(EC_QUALITY_CHANGE, 0, 0);\n                    m_bQualityChanged = TRUE;\n                }\n                return NOERROR;\n            }\n        }\n    }\n\n    // release the output buffer. If the connected pin still needs it,\n    // it will have addrefed it itself.\n    pOutSample->Release();\n\n    return hr;\n}\n\n// Return S_FALSE to mean \"pass the note on upstream\"\n// Return NOERROR (Same as S_OK)\n// to mean \"I've done something about it, don't pass it on\"\nHRESULT CTransformFilter::AlterQuality(Quality q)\n{\n    UNREFERENCED_PARAMETER(q);\n    return S_FALSE;\n}\n\n// EndOfStream received. Default behaviour is to deliver straight\n// downstream, since we have no queued data. If you overrode Receive\n// and have queue data, then you need to handle this and deliver EOS after\n// all queued data is sent\nHRESULT\nCTransformFilter::EndOfStream(void)\n{\n    HRESULT hr = NOERROR;\n    if (m_pOutput != NULL)\n    {\n        hr = m_pOutput->DeliverEndOfStream();\n    }\n\n    return hr;\n}\n\n// enter flush state. Receives already blocked\n// must override this if you have queued data or a worker thread\nHRESULT\nCTransformFilter::BeginFlush(void)\n{\n    HRESULT hr = NOERROR;\n    if (m_pOutput != NULL)\n    {\n        // block receives -- done by caller (CBaseInputPin::BeginFlush)\n\n        // discard queued data -- we have no queued data\n\n        // free anyone blocked on receive - not possible in this filter\n\n        // call downstream\n        hr = m_pOutput->DeliverBeginFlush();\n    }\n    return hr;\n}\n\n// leave flush state. must override this if you have queued data\n// or a worker thread\nHRESULT\nCTransformFilter::EndFlush(void)\n{\n    // sync with pushing thread -- we have no worker thread\n\n    // ensure no more data to go downstream -- we have no queued data\n\n    // call EndFlush on downstream pins\n    ASSERT(m_pOutput != NULL);\n    return m_pOutput->DeliverEndFlush();\n\n    // caller (the input pin's method) will unblock Receives\n}\n\n// override these so that the derived filter can catch them\n\nSTDMETHODIMP\nCTransformFilter::Stop()\n{\n    CAutoLock lck1(&m_csFilter);\n    if (m_State == State_Stopped)\n    {\n        return NOERROR;\n    }\n\n    // Succeed the Stop if we are not completely connected\n\n    ASSERT(m_pInput == NULL || m_pOutput != NULL);\n    if (m_pInput == NULL || m_pInput->IsConnected() == FALSE || m_pOutput->IsConnected() == FALSE)\n    {\n        m_State = State_Stopped;\n        m_bEOSDelivered = FALSE;\n        return NOERROR;\n    }\n\n    ASSERT(m_pInput);\n    ASSERT(m_pOutput);\n\n    // decommit the input pin before locking or we can deadlock\n    m_pInput->Inactive();\n\n    // synchronize with Receive calls\n\n    CAutoLock lck2(&m_csReceive);\n    m_pOutput->Inactive();\n\n    // allow a class derived from CTransformFilter\n    // to know about starting and stopping streaming\n\n    HRESULT hr = StopStreaming();\n    if (SUCCEEDED(hr))\n    {\n        // complete the state transition\n        m_State = State_Stopped;\n        m_bEOSDelivered = FALSE;\n    }\n    return hr;\n}\n\nSTDMETHODIMP\nCTransformFilter::Pause()\n{\n    CAutoLock lck(&m_csFilter);\n    HRESULT hr = NOERROR;\n\n    if (m_State == State_Paused)\n    {\n        // (This space left deliberately blank)\n    }\n\n    // If we have no input pin or it isn't yet connected then when we are\n    // asked to pause we deliver an end of stream to the downstream filter.\n    // This makes sure that it doesn't sit there forever waiting for\n    // samples which we cannot ever deliver without an input connection.\n\n    else if (m_pInput == NULL || m_pInput->IsConnected() == FALSE)\n    {\n        if (m_pOutput && m_bEOSDelivered == FALSE)\n        {\n            m_pOutput->DeliverEndOfStream();\n            m_bEOSDelivered = TRUE;\n        }\n        m_State = State_Paused;\n    }\n\n    // We may have an input connection but no output connection\n    // However, if we have an input pin we do have an output pin\n\n    else if (m_pOutput->IsConnected() == FALSE)\n    {\n        m_State = State_Paused;\n    }\n\n    else\n    {\n        if (m_State == State_Stopped)\n        {\n            // allow a class derived from CTransformFilter\n            // to know about starting and stopping streaming\n            CAutoLock lck2(&m_csReceive);\n            hr = StartStreaming();\n        }\n        if (SUCCEEDED(hr))\n        {\n            hr = CBaseFilter::Pause();\n        }\n    }\n\n    m_bSampleSkipped = FALSE;\n    m_bQualityChanged = FALSE;\n    return hr;\n}\n\nHRESULT\nCTransformFilter::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    if (m_pOutput != NULL)\n    {\n        return m_pOutput->DeliverNewSegment(tStart, tStop, dRate);\n    }\n    return S_OK;\n}\n\n// Check streaming status\nHRESULT\nCTransformInputPin::CheckStreaming()\n{\n    ASSERT(m_pTransformFilter->m_pOutput != NULL);\n    if (!m_pTransformFilter->m_pOutput->IsConnected())\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n    else\n    {\n        //  Shouldn't be able to get any data if we're not connected!\n        ASSERT(IsConnected());\n\n        //  we're flushing\n        if (m_bFlushing)\n        {\n            return S_FALSE;\n        }\n        //  Don't process stuff in Stopped state\n        if (IsStopped())\n        {\n            return VFW_E_WRONG_STATE;\n        }\n        if (m_bRunTimeError)\n        {\n            return VFW_E_RUNTIME_ERROR;\n        }\n        return S_OK;\n    }\n}\n\n// =================================================================\n// Implements the CTransformInputPin class\n// =================================================================\n\n// constructor\n\nCTransformInputPin::CTransformInputPin(__in_opt LPCTSTR pObjectName, __inout CTransformFilter *pTransformFilter,\n                                       __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName)\n{\n    DbgLog((LOG_TRACE, 2, TEXT(\"CTransformInputPin::CTransformInputPin\")));\n    m_pTransformFilter = pTransformFilter;\n}\n\n#ifdef UNICODE\nCTransformInputPin::CTransformInputPin(__in_opt LPCSTR pObjectName, __inout CTransformFilter *pTransformFilter,\n                                       __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CBaseInputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pName)\n{\n    DbgLog((LOG_TRACE, 2, TEXT(\"CTransformInputPin::CTransformInputPin\")));\n    m_pTransformFilter = pTransformFilter;\n}\n#endif\n\n// provides derived filter a chance to grab extra interfaces\n\nHRESULT\nCTransformInputPin::CheckConnect(IPin *pPin)\n{\n    HRESULT hr = m_pTransformFilter->CheckConnect(PINDIR_INPUT, pPin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return CBaseInputPin::CheckConnect(pPin);\n}\n\n// provides derived filter a chance to release it's extra interfaces\n\nHRESULT\nCTransformInputPin::BreakConnect()\n{\n    //  Can't disconnect unless stopped\n    ASSERT(IsStopped());\n    m_pTransformFilter->BreakConnect(PINDIR_INPUT);\n    return CBaseInputPin::BreakConnect();\n}\n\n// Let derived class know when the input pin is connected\n\nHRESULT\nCTransformInputPin::CompleteConnect(IPin *pReceivePin)\n{\n    HRESULT hr = m_pTransformFilter->CompleteConnect(PINDIR_INPUT, pReceivePin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return CBaseInputPin::CompleteConnect(pReceivePin);\n}\n\n// check that we can support a given media type\n\nHRESULT\nCTransformInputPin::CheckMediaType(const CMediaType *pmt)\n{\n    // Check the input type\n\n    HRESULT hr = m_pTransformFilter->CheckInputType(pmt);\n    if (S_OK != hr)\n    {\n        return hr;\n    }\n\n    // if the output pin is still connected, then we have\n    // to check the transform not just the input format\n\n    if ((m_pTransformFilter->m_pOutput != NULL) && (m_pTransformFilter->m_pOutput->IsConnected()))\n    {\n        return m_pTransformFilter->CheckTransform(pmt, &m_pTransformFilter->m_pOutput->CurrentMediaType());\n    }\n    else\n    {\n        return hr;\n    }\n}\n\n// set the media type for this connection\n\nHRESULT\nCTransformInputPin::SetMediaType(const CMediaType *mtIn)\n{\n    // Set the base class media type (should always succeed)\n    HRESULT hr = CBasePin::SetMediaType(mtIn);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // check the transform can be done (should always succeed)\n    ASSERT(SUCCEEDED(m_pTransformFilter->CheckInputType(mtIn)));\n\n    return m_pTransformFilter->SetMediaType(PINDIR_INPUT, mtIn);\n}\n\n// =================================================================\n// Implements IMemInputPin interface\n// =================================================================\n\n// provide EndOfStream that passes straight downstream\n// (there is no queued data)\nSTDMETHODIMP\nCTransformInputPin::EndOfStream(void)\n{\n    CAutoLock lck(&m_pTransformFilter->m_csReceive);\n    HRESULT hr = CheckStreaming();\n    if (S_OK == hr)\n    {\n        hr = m_pTransformFilter->EndOfStream();\n    }\n    return hr;\n}\n\n// enter flushing state. Call default handler to block Receives, then\n// pass to overridable method in filter\nSTDMETHODIMP\nCTransformInputPin::BeginFlush(void)\n{\n    CAutoLock lck(&m_pTransformFilter->m_csFilter);\n    //  Are we actually doing anything?\n    ASSERT(m_pTransformFilter->m_pOutput != NULL);\n    if (!IsConnected() || !m_pTransformFilter->m_pOutput->IsConnected())\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n    HRESULT hr = CBaseInputPin::BeginFlush();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return m_pTransformFilter->BeginFlush();\n}\n\n// leave flushing state.\n// Pass to overridable method in filter, then call base class\n// to unblock receives (finally)\nSTDMETHODIMP\nCTransformInputPin::EndFlush(void)\n{\n    CAutoLock lck(&m_pTransformFilter->m_csFilter);\n    //  Are we actually doing anything?\n    ASSERT(m_pTransformFilter->m_pOutput != NULL);\n    if (!IsConnected() || !m_pTransformFilter->m_pOutput->IsConnected())\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n\n    HRESULT hr = m_pTransformFilter->EndFlush();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return CBaseInputPin::EndFlush();\n}\n\n// here's the next block of data from the stream.\n// AddRef it yourself if you need to hold it beyond the end\n// of this call.\n\nHRESULT\nCTransformInputPin::Receive(IMediaSample *pSample)\n{\n    HRESULT hr;\n    CAutoLock lck(&m_pTransformFilter->m_csReceive);\n    ASSERT(pSample);\n\n    // check all is well with the base class\n    hr = CBaseInputPin::Receive(pSample);\n    if (S_OK == hr)\n    {\n        hr = m_pTransformFilter->Receive(pSample);\n    }\n    return hr;\n}\n\n// override to pass downstream\nSTDMETHODIMP\nCTransformInputPin::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    //  Save the values in the pin\n    CBasePin::NewSegment(tStart, tStop, dRate);\n    return m_pTransformFilter->NewSegment(tStart, tStop, dRate);\n}\n\n// =================================================================\n// Implements the CTransformOutputPin class\n// =================================================================\n\n// constructor\n\nCTransformOutputPin::CTransformOutputPin(__in_opt LPCTSTR pObjectName, __inout CTransformFilter *pTransformFilter,\n                                         __inout HRESULT *phr, __in_opt LPCWSTR pPinName)\n    : CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName)\n    , m_pPosition(NULL)\n{\n    DbgLog((LOG_TRACE, 2, TEXT(\"CTransformOutputPin::CTransformOutputPin\")));\n    m_pTransformFilter = pTransformFilter;\n}\n\n#ifdef UNICODE\nCTransformOutputPin::CTransformOutputPin(__in_opt LPCSTR pObjectName, __inout CTransformFilter *pTransformFilter,\n                                         __inout HRESULT *phr, __in_opt LPCWSTR pPinName)\n    : CBaseOutputPin(pObjectName, pTransformFilter, &pTransformFilter->m_csFilter, phr, pPinName)\n    , m_pPosition(NULL)\n{\n    DbgLog((LOG_TRACE, 2, TEXT(\"CTransformOutputPin::CTransformOutputPin\")));\n    m_pTransformFilter = pTransformFilter;\n}\n#endif\n\n// destructor\n\nCTransformOutputPin::~CTransformOutputPin()\n{\n    DbgLog((LOG_TRACE, 2, TEXT(\"CTransformOutputPin::~CTransformOutputPin\")));\n\n    if (m_pPosition)\n        m_pPosition->Release();\n}\n\n// overriden to expose IMediaPosition and IMediaSeeking control interfaces\n\nSTDMETHODIMP\nCTransformOutputPin::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n    *ppv = NULL;\n\n    if (riid == IID_IMediaPosition || riid == IID_IMediaSeeking)\n    {\n\n        // we should have an input pin by now\n\n        ASSERT(m_pTransformFilter->m_pInput != NULL);\n\n        if (m_pPosition == NULL)\n        {\n\n            HRESULT hr = CreatePosPassThru(GetOwner(), FALSE, (IPin *)m_pTransformFilter->m_pInput, &m_pPosition);\n            if (FAILED(hr))\n            {\n                return hr;\n            }\n        }\n        return m_pPosition->QueryInterface(riid, ppv);\n    }\n    else\n    {\n        return CBaseOutputPin::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\n// provides derived filter a chance to grab extra interfaces\n\nHRESULT\nCTransformOutputPin::CheckConnect(IPin *pPin)\n{\n    // we should have an input connection first\n\n    ASSERT(m_pTransformFilter->m_pInput != NULL);\n    if ((m_pTransformFilter->m_pInput->IsConnected() == FALSE))\n    {\n        return E_UNEXPECTED;\n    }\n\n    HRESULT hr = m_pTransformFilter->CheckConnect(PINDIR_OUTPUT, pPin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return CBaseOutputPin::CheckConnect(pPin);\n}\n\n// provides derived filter a chance to release it's extra interfaces\n\nHRESULT\nCTransformOutputPin::BreakConnect()\n{\n    //  Can't disconnect unless stopped\n    ASSERT(IsStopped());\n    m_pTransformFilter->BreakConnect(PINDIR_OUTPUT);\n    return CBaseOutputPin::BreakConnect();\n}\n\n// Let derived class know when the output pin is connected\n\nHRESULT\nCTransformOutputPin::CompleteConnect(IPin *pReceivePin)\n{\n    HRESULT hr = m_pTransformFilter->CompleteConnect(PINDIR_OUTPUT, pReceivePin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return CBaseOutputPin::CompleteConnect(pReceivePin);\n}\n\n// check a given transform - must have selected input type first\n\nHRESULT\nCTransformOutputPin::CheckMediaType(const CMediaType *pmtOut)\n{\n    // must have selected input first\n    ASSERT(m_pTransformFilter->m_pInput != NULL);\n    if ((m_pTransformFilter->m_pInput->IsConnected() == FALSE))\n    {\n        return E_INVALIDARG;\n    }\n\n    return m_pTransformFilter->CheckTransform(&m_pTransformFilter->m_pInput->CurrentMediaType(), pmtOut);\n}\n\n// called after we have agreed a media type to actually set it in which case\n// we run the CheckTransform function to get the output format type again\n\nHRESULT\nCTransformOutputPin::SetMediaType(const CMediaType *pmtOut)\n{\n    HRESULT hr = NOERROR;\n    ASSERT(m_pTransformFilter->m_pInput != NULL);\n\n    ASSERT(m_pTransformFilter->m_pInput->CurrentMediaType().IsValid());\n\n    // Set the base class media type (should always succeed)\n    hr = CBasePin::SetMediaType(pmtOut);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n#ifdef DEBUG\n    if (FAILED(m_pTransformFilter->CheckTransform(&m_pTransformFilter->m_pInput->CurrentMediaType(), pmtOut)))\n    {\n        DbgLog((LOG_ERROR, 0, TEXT(\"*** This filter is accepting an output media type\")));\n        DbgLog((LOG_ERROR, 0, TEXT(\"    that it can't currently transform to.  I hope\")));\n        DbgLog((LOG_ERROR, 0, TEXT(\"    it's smart enough to reconnect its input.\")));\n    }\n#endif\n\n    return m_pTransformFilter->SetMediaType(PINDIR_OUTPUT, pmtOut);\n}\n\n// pass the buffer size decision through to the main transform class\n\nHRESULT\nCTransformOutputPin::DecideBufferSize(IMemAllocator *pAllocator, __inout ALLOCATOR_PROPERTIES *pProp)\n{\n    return m_pTransformFilter->DecideBufferSize(pAllocator, pProp);\n}\n\n// return a specific media type indexed by iPosition\n\nHRESULT\nCTransformOutputPin::GetMediaType(int iPosition, __inout CMediaType *pMediaType)\n{\n    ASSERT(m_pTransformFilter->m_pInput != NULL);\n\n    //  We don't have any media types if our input is not connected\n\n    if (m_pTransformFilter->m_pInput->IsConnected())\n    {\n        return m_pTransformFilter->GetMediaType(iPosition, pMediaType);\n    }\n    else\n    {\n        return VFW_S_NO_MORE_ITEMS;\n    }\n}\n\n// Override this if you can do something constructive to act on the\n// quality message.  Consider passing it upstream as well\n\n// Pass the quality mesage on upstream.\n\nSTDMETHODIMP\nCTransformOutputPin::Notify(IBaseFilter *pSender, Quality q)\n{\n    UNREFERENCED_PARAMETER(pSender);\n    ValidateReadPtr(pSender, sizeof(IBaseFilter));\n\n    // First see if we want to handle this ourselves\n    HRESULT hr = m_pTransformFilter->AlterQuality(q);\n    if (hr != S_FALSE)\n    {\n        return hr; // either S_OK or a failure\n    }\n\n    // S_FALSE means we pass the message on.\n    // Find the quality sink for our input pin and send it there\n\n    ASSERT(m_pTransformFilter->m_pInput != NULL);\n\n    return m_pTransformFilter->m_pInput->PassNotify(q);\n\n} // Notify\n\n// the following removes a very large number of level 4 warnings from the microsoft\n// compiler output, which are not useful at all in this case.\n#pragma warning(disable : 4514)\n"
  },
  {
    "path": "common/baseclasses/transfrm.h",
    "content": "//------------------------------------------------------------------------------\n// File: Transfrm.h\n//\n// Desc: DirectShow base classes - defines classes from which simple\n//       transform codecs may be derived.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// It assumes the codec has one input and one output stream, and has no\n// interest in memory management, interface negotiation or anything else.\n//\n// derive your class from this, and supply Transform and the media type/format\n// negotiation functions. Implement that class, compile and link and\n// you're done.\n\n#ifndef __TRANSFRM__\n#define __TRANSFRM__\n\n// ======================================================================\n// This is the com object that represents a simple transform filter. It\n// supports IBaseFilter, IMediaFilter and two pins through nested interfaces\n// ======================================================================\n\nclass CTransformFilter;\n\n// ==================================================\n// Implements the input pin\n// ==================================================\n\nclass CTransformInputPin : public CBaseInputPin\n{\n    friend class CTransformFilter;\n\n  protected:\n    CTransformFilter *m_pTransformFilter;\n\n  public:\n    CTransformInputPin(__in_opt LPCTSTR pObjectName, __inout CTransformFilter *pTransformFilter, __inout HRESULT *phr,\n                       __in_opt LPCWSTR pName);\n#ifdef UNICODE\n    CTransformInputPin(__in_opt LPCSTR pObjectName, __inout CTransformFilter *pTransformFilter, __inout HRESULT *phr,\n                       __in_opt LPCWSTR pName);\n#endif\n\n    STDMETHODIMP QueryId(__deref_out LPWSTR *Id) { return AMGetWideString(L\"In\", Id); }\n\n    // Grab and release extra interfaces if required\n\n    HRESULT CheckConnect(IPin *pPin);\n    HRESULT BreakConnect();\n    HRESULT CompleteConnect(IPin *pReceivePin);\n\n    // check that we can support this output type\n    HRESULT CheckMediaType(const CMediaType *mtIn);\n\n    // set the connection media type\n    HRESULT SetMediaType(const CMediaType *mt);\n\n    // --- IMemInputPin -----\n\n    // here's the next block of data from the stream.\n    // AddRef it yourself if you need to hold it beyond the end\n    // of this call.\n    STDMETHODIMP Receive(IMediaSample *pSample);\n\n    // provide EndOfStream that passes straight downstream\n    // (there is no queued data)\n    STDMETHODIMP EndOfStream(void);\n\n    // passes it to CTransformFilter::BeginFlush\n    STDMETHODIMP BeginFlush(void);\n\n    // passes it to CTransformFilter::EndFlush\n    STDMETHODIMP EndFlush(void);\n\n    STDMETHODIMP NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n\n    // Check if it's OK to process samples\n    virtual HRESULT CheckStreaming();\n\n    // Media type\n  public:\n    CMediaType &CurrentMediaType() { return m_mt; };\n};\n\n// ==================================================\n// Implements the output pin\n// ==================================================\n\nclass CTransformOutputPin : public CBaseOutputPin\n{\n    friend class CTransformFilter;\n\n  protected:\n    CTransformFilter *m_pTransformFilter;\n\n  public:\n    // implement IMediaPosition by passing upstream\n    IUnknown *m_pPosition;\n\n    CTransformOutputPin(__in_opt LPCTSTR pObjectName, __inout CTransformFilter *pTransformFilter, __inout HRESULT *phr,\n                        __in_opt LPCWSTR pName);\n#ifdef UNICODE\n    CTransformOutputPin(__in_opt LPCSTR pObjectName, __inout CTransformFilter *pTransformFilter, __inout HRESULT *phr,\n                        __in_opt LPCWSTR pName);\n#endif\n    ~CTransformOutputPin();\n\n    // override to expose IMediaPosition\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    // --- CBaseOutputPin ------------\n\n    STDMETHODIMP QueryId(__deref_out LPWSTR *Id) { return AMGetWideString(L\"Out\", Id); }\n\n    // Grab and release extra interfaces if required\n\n    HRESULT CheckConnect(IPin *pPin);\n    HRESULT BreakConnect();\n    HRESULT CompleteConnect(IPin *pReceivePin);\n\n    // check that we can support this output type\n    HRESULT CheckMediaType(const CMediaType *mtOut);\n\n    // set the connection media type\n    HRESULT SetMediaType(const CMediaType *pmt);\n\n    // called from CBaseOutputPin during connection to ask for\n    // the count and size of buffers we need.\n    HRESULT DecideBufferSize(IMemAllocator *pAlloc, __inout ALLOCATOR_PROPERTIES *pProp);\n\n    // returns the preferred formats for a pin\n    HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType);\n\n    // inherited from IQualityControl via CBasePin\n    STDMETHODIMP Notify(IBaseFilter *pSender, Quality q);\n\n    // Media type\n  public:\n    CMediaType &CurrentMediaType() { return m_mt; };\n};\n\nclass AM_NOVTABLE CTransformFilter : public CBaseFilter\n{\n\n  public:\n    // map getpin/getpincount for base enum of pins to owner\n    // override this to return more specialised pin objects\n\n    virtual int GetPinCount();\n    virtual CBasePin *GetPin(int n);\n    STDMETHODIMP FindPin(LPCWSTR Id, __deref_out IPin **ppPin);\n\n    // override state changes to allow derived transform filter\n    // to control streaming start/stop\n    STDMETHODIMP Stop();\n    STDMETHODIMP Pause();\n\n  public:\n    CTransformFilter(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, REFCLSID clsid);\n#ifdef UNICODE\n    CTransformFilter(__in_opt LPCSTR, __inout_opt LPUNKNOWN, REFCLSID clsid);\n#endif\n    ~CTransformFilter();\n\n    // =================================================================\n    // ----- override these bits ---------------------------------------\n    // =================================================================\n\n    // These must be supplied in a derived class\n\n    virtual HRESULT Transform(IMediaSample *pIn, IMediaSample *pOut);\n\n    // check if you can support mtIn\n    virtual HRESULT CheckInputType(const CMediaType *mtIn) PURE;\n\n    // check if you can support the transform from this input to this output\n    virtual HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) PURE;\n\n    // this goes in the factory template table to create new instances\n    // static CCOMObject * CreateInstance(__inout_opt LPUNKNOWN, HRESULT *);\n\n    // call the SetProperties function with appropriate arguments\n    virtual HRESULT DecideBufferSize(IMemAllocator *pAllocator, __inout ALLOCATOR_PROPERTIES *pprop) PURE;\n\n    // override to suggest OUTPUT pin media types\n    virtual HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType) PURE;\n\n    // =================================================================\n    // ----- Optional Override Methods           -----------------------\n    // =================================================================\n\n    // you can also override these if you want to know about streaming\n    virtual HRESULT StartStreaming();\n    virtual HRESULT StopStreaming();\n\n    // override if you can do anything constructive with quality notifications\n    virtual HRESULT AlterQuality(Quality q);\n\n    // override this to know when the media type is actually set\n    virtual HRESULT SetMediaType(PIN_DIRECTION direction, const CMediaType *pmt);\n\n    // chance to grab extra interfaces on connection\n    virtual HRESULT CheckConnect(PIN_DIRECTION dir, IPin *pPin);\n    virtual HRESULT BreakConnect(PIN_DIRECTION dir);\n    virtual HRESULT CompleteConnect(PIN_DIRECTION direction, IPin *pReceivePin);\n\n    // chance to customize the transform process\n    virtual HRESULT Receive(IMediaSample *pSample);\n\n    // Standard setup for output sample\n    HRESULT InitializeOutputSample(IMediaSample *pSample, __deref_out IMediaSample **ppOutSample);\n\n    // if you override Receive, you may need to override these three too\n    virtual HRESULT EndOfStream(void);\n    virtual HRESULT BeginFlush(void);\n    virtual HRESULT EndFlush(void);\n    virtual HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n\n#ifdef PERF\n    // Override to register performance measurement with a less generic string\n    // You should do this to avoid confusion with other filters\n    virtual void RegisterPerfId() { m_idTransform = MSR_REGISTER(TEXT(\"Transform\")); }\n#endif // PERF\n\n    // implementation details\n\n  protected:\n#ifdef PERF\n    int m_idTransform; // performance measuring id\n#endif\n    BOOL m_bEOSDelivered;   // have we sent EndOfStream\n    BOOL m_bSampleSkipped;  // Did we just skip a frame\n    BOOL m_bQualityChanged; // Have we degraded?\n\n    // critical section protecting filter state.\n\n    CCritSec m_csFilter;\n\n    // critical section stopping state changes (ie Stop) while we're\n    // processing a sample.\n    //\n    // This critical section is held when processing\n    // events that occur on the receive thread - Receive() and EndOfStream().\n    //\n    // If you want to hold both m_csReceive and m_csFilter then grab\n    // m_csFilter FIRST - like CTransformFilter::Stop() does.\n\n    CCritSec m_csReceive;\n\n    // these hold our input and output pins\n\n    friend class CTransformInputPin;\n    friend class CTransformOutputPin;\n    CTransformInputPin *m_pInput;\n    CTransformOutputPin *m_pOutput;\n};\n\n#endif /* __TRANSFRM__ */\n"
  },
  {
    "path": "common/baseclasses/transip.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: TransIP.cpp\n//\n// Desc: DirectShow base classes - implements class for simple Transform-\n//       In-Place filters such as audio.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// How allocators are decided.\n//\n// An in-place transform tries to do its work in someone else's buffers.\n// It tries to persuade the filters on either side to use the same allocator\n// (and for that matter the same media type).  In desperation, if the downstream\n// filter refuses to supply an allocator and the upstream filter offers only\n// a read-only one then it will provide an allocator.\n// if the upstream filter insists on a read-only allocator then the transform\n// filter will (reluctantly) copy the data before transforming it.\n//\n// In order to pass an allocator through it needs to remember the one it got\n// from the first connection to pass it on to the second one.\n//\n// It is good if we can avoid insisting on a particular order of connection\n// (There is a precedent for insisting on the input\n// being connected first.  Insisting on the output being connected first is\n// not allowed.  That would break RenderFile.)\n//\n// The base pin classes (CBaseOutputPin and CBaseInputPin) both have a\n// m_pAllocator member which is used in places like\n// CBaseOutputPin::GetDeliveryBuffer and CBaseInputPin::Inactive.\n// To avoid lots of extra overriding, we should keep these happy\n// by using these pointers.\n//\n// When each pin is connected, it will set the corresponding m_pAllocator\n// and will have a single ref-count on that allocator.\n//\n// Refcounts are acquired by GetAllocator calls which return AddReffed\n// allocators and are released in one of:\n//     CBaseInputPin::Disconnect\n//     CBaseOutputPin::BreakConect\n// In each case m_pAllocator is set to NULL after the release, so this\n// is the last chance to ever release it.  If there should ever be\n// multiple refcounts associated with the same pointer, this had better\n// be cleared up before that happens.  To avoid such problems, we'll\n// stick with one per pointer.\n\n// RECONNECTING and STATE CHANGES\n//\n// Each pin could be disconnected, connected with a read-only allocator,\n// connected with an upstream read/write allocator, connected with an\n// allocator from downstream or connected with its own allocator.\n// Five states for each pin gives a data space of 25 states.\n//\n// Notation:\n//\n// R/W == read/write\n// R-O == read-only\n//\n// <input pin state> <output pin state> <comments>\n//\n// 00 means an unconnected pin.\n// <- means using a R/W allocator from the upstream filter\n// <= means using a R-O allocator from an upstream filter\n// || means using our own (R/W) allocator.\n// -> means using a R/W allocator from a downstream filter\n//    (a R-O allocator from downstream is nonsense, it can't ever work).\n//\n//\n// That makes 25 possible states.  Some states are nonsense (two different\n// allocators from the same place).  These are just an artifact of the notation.\n//        <=  <-  Nonsense.\n//        <-  <=  Nonsense\n// Some states are illegal (the output pin never accepts a R-O allocator):\n//        00  <=  !! Error !!\n//        <=  <=  !! Error !!\n//        ||  <=  !! Error !!\n//        ->  <=  !! Error !!\n// Three states appears to be inaccessible:\n//        ->  ||  Inaccessible\n//        ||  ->  Inaccessible\n//        ||  <-  Inaccessible\n// Some states only ever occur as intermediates with a pending reconnect which\n// is guaranteed to finish in another state.\n//        ->  00  ?? unstable goes to || 00\n//        00  <-  ?? unstable goes to 00 ||\n//        ->  <-  ?? unstable goes to -> ->\n//        <-  ||  ?? unstable goes to <- <-\n//        <-  ->  ?? unstable goes to <- <-\n// And that leaves 11 possible resting states:\n// 1      00  00  Nothing connected.\n// 2      <-  00  Input pin connected.\n// 3      <=  00  Input pin connected using R-O allocator.\n// 4      ||  00  Needs several state changes to get here.\n// 5      00  ||  Output pin connected using our allocator\n// 6      00  ->  Downstream only connected\n// 7      ||  ||  Undesirable but can be forced upon us.\n// 8      <=  ||  Copy forced.  <=  -> is preferable\n// 9      <=  ->  OK - forced to copy.\n// 10     <-  <-  Transform in place (ideal)\n// 11     ->  ->  Transform in place (ideal)\n//\n// The object of the exercise is to ensure that we finish up in states\n// 10 or 11 whenever possible.  State 10 is only possible if the upstream\n// filter has a R/W allocator (the AVI splitter notoriously\n// doesn't) and state 11 is only possible if the downstream filter does\n// offer an allocator.\n//\n// The transition table (entries marked * go via a reconnect)\n//\n// There are 8 possible transitions:\n// A: Connect upstream to filter with R-O allocator that insists on using it.\n// B: Connect upstream to filter with R-O allocator but chooses not to use it.\n// C: Connect upstream to filter with R/W allocator and insists on using it.\n// D: Connect upstream to filter with R/W allocator but chooses not to use it.\n// E: Connect downstream to a filter that offers an allocator\n// F: Connect downstream to a filter that does not offer an allocator\n// G: disconnect upstream\n// H: Disconnect downstream\n//\n//            A      B      C      D      E      F      G      H\n//           ---------------------------------------------------------\n// 00  00 1 | 3      3      2      2      6      5      .      .      |1  00  00\n// <-  00 2 | .      .      .      .      *10/11 10     1      .      |2  <-  00\n// <=  00 3 | .      .      .      .      *9/11  *7/8   1      .      |3  <=  00\n// ||  00 4 | .      .      .      .      *8     *7     1      .      |4  ||  00\n// 00  || 5 | 8      7      *10    7      .      .      .      1      |5  00  ||\n// 00  -> 6 | 9      11     *10    11     .      .      .      1      |6  00  ->\n// ||  || 7 | .      .      .      .      .      .      5      4      |7  ||  ||\n// <=  || 8 | .      .      .      .      .      .      5      3      |8  <=  ||\n// <=  -> 9 | .      .      .      .      .      .      6      3      |9  <=  ->\n// <-  <- 10| .      .      .      .      .      .      *5/6   2      |10 <-  <-\n// ->  -> 11| .      .      .      .      .      .      6      *2/3   |11 ->  ->\n//           ---------------------------------------------------------\n//            A      B      C      D      E      F      G      H\n//\n// All these states are accessible without requiring any filter to\n// change its behaviour but not all transitions are accessible, for\n// instance a transition from state 4 to anywhere other than\n// state 8 requires that the upstream filter first offer a R-O allocator\n// and then changes its mind and offer R/W.  This is NOT allowable - it\n// leads to things like the output pin getting a R/W allocator from\n// upstream and then the input pin being told it can only have a R-O one.\n// Note that you CAN change (say) the upstream filter for a different one, but\n// only as a disconnect / connect, not as a Reconnect.  (Exercise for\n// the reader is to see how you get into state 4).\n//\n// The reconnection stuff goes as follows (some of the cases shown here as\n// \"no reconnect\" may get one to finalise media type - an old story).\n// If there is a reconnect where it says \"no reconnect\" here then the\n// reconnection must not change the allocator choice.\n//\n// state 2: <- 00 transition E <- <- case C <- <- (no change)\n//                                   case D -> <- and then to -> ->\n//\n// state 2: <- 00 transition F <- <- (no reconnect)\n//\n// state 3: <= 00 transition E <= -> case A <= -> (no change)\n//                                   case B -> ->\n//                transition F <= || case A <= || (no change)\n//                                   case B || ||\n//\n// state 4: || 00 transition E || || case B -> || and then all cases to -> ->\n//                           F || || case B || || (no change)\n//\n// state 5: 00 || transition A <= || (no reconnect)\n//                           B || || (no reconnect)\n//                           C <- || all cases     <- <-\n//                           D || || (unfortunate, but upstream's choice)\n//\n// state 6: 00 -> transition A <= -> (no reconnect)\n//                           B -> -> (no reconnect)\n//                           C <- -> all cases <- <-\n//                           D -> -> (no reconnect)\n//\n// state 10:<- <- transition G 00 <- case E 00 ->\n//                                   case F 00 ||\n//\n// state 11:-> -> transition H -> 00 case A <= 00 (schizo)\n//                                   case B <= 00\n//                                   case C <- 00 (schizo)\n//                                   case D <- 00\n//\n// The Rules:\n// To sort out media types:\n// The input is reconnected\n//    if the input pin is connected and the output pin connects\n// The output is reconnected\n//    If the output pin is connected\n//    and the input pin connects to a different media type\n//\n// To sort out allocators:\n// The input is reconnected\n//    if the output disconnects and the input was using a downstream allocator\n// The output pin calls SetAllocator to pass on a new allocator\n//    if the output is connected and\n//       if the input disconnects and the output was using an upstream allocator\n//       if the input acquires an allocator different from the output one\n//          and that new allocator is not R-O\n//\n// Data is copied (i.e. call getbuffer and copy the data before transforming it)\n//    if the two allocators are different.\n\n// CHAINS of filters:\n//\n// We sit between two filters (call them A and Z).  We should finish up\n// with the same allocator on both of our pins and that should be the\n// same one that A and Z would have agreed on if we hadn't been in the\n// way.  Furthermore, it should not matter how many in-place transforms\n// are in the way.  Let B, C, D... be in-place transforms (\"us\").\n// Here's how it goes:\n//\n// 1.\n// A connects to B.  They agree on A's allocator.\n//   A-a->B\n//\n// 2.\n// B connects to C.  Same story. There is no point in a reconnect, but\n// B will request an input reconnect anyway.\n//   A-a->B-a->C\n//\n// 3.\n// C connects to Z.\n// C insists on using A's allocator, but compromises by requesting a reconnect.\n// of C's input.\n//   A-a->B-?->C-a->Z\n//\n// We now have pending reconnects on both A--->B and B--->C\n//\n// 4.\n// The A--->B link is reconnected.\n// A asks B for an allocator.  B sees that it has a downstream connection so\n// asks its downstream input pin i.e. C's input pin for an allocator.  C sees\n// that it too has a downstream connection so asks Z for an allocator.\n//\n// Even though Z's input pin is connected, it is being asked for an allocator.\n// It could refuse, in which case the chain is done and will use A's allocator\n// Alternatively, Z may supply one.  A chooses either Z's or A's own one.\n// B's input pin gets NotifyAllocator called to tell it the decision and it\n// propagates this downstream by calling ReceiveAllocator on its output pin\n// which calls NotifyAllocator on the next input pin downstream etc.\n// If the choice is Z then it goes:\n//   A-z->B-a->C-a->Z\n//   A-z->B-z->C-a->Z\n//   A-z->B-z->C-z->Z\n//\n// And that's IT!!  Any further (essentially spurious) reconnects peter out\n// with no change in the chain.\n\n#include <streams.h>\n#include <measure.h>\n#include <transip.h>\n\n// =================================================================\n// Implements the CTransInPlaceFilter class\n// =================================================================\n\nCTransInPlaceFilter::CTransInPlaceFilter(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, REFCLSID clsid,\n                                         __inout HRESULT *phr, bool bModifiesData)\n    : CTransformFilter(pName, pUnk, clsid)\n    , m_bModifiesData(bModifiesData)\n{\n#ifdef PERF\n    RegisterPerfId();\n#endif //  PERF\n\n} // constructor\n\n#ifdef UNICODE\nCTransInPlaceFilter::CTransInPlaceFilter(__in_opt LPCSTR pName, __inout_opt LPUNKNOWN pUnk, REFCLSID clsid,\n                                         __inout HRESULT *phr, bool bModifiesData)\n    : CTransformFilter(pName, pUnk, clsid)\n    , m_bModifiesData(bModifiesData)\n{\n#ifdef PERF\n    RegisterPerfId();\n#endif //  PERF\n\n} // constructor\n#endif\n\n// return a non-addrefed CBasePin * for the user to addref if he holds onto it\n// for longer than his pointer to us. We create the pins dynamically when they\n// are asked for rather than in the constructor. This is because we want to\n// give the derived class an oppportunity to return different pin objects\n\n// As soon as any pin is needed we create both (this is different from the\n// usual transform filter) because enumerators, allocators etc are passed\n// through from one pin to another and it becomes very painful if the other\n// pin isn't there.  If we fail to create either pin we ensure we fail both.\n\nCBasePin *CTransInPlaceFilter::GetPin(int n)\n{\n    HRESULT hr = S_OK;\n\n    // Create an input pin if not already done\n\n    if (m_pInput == NULL)\n    {\n\n        m_pInput = new CTransInPlaceInputPin(NAME(\"TransInPlace input pin\"), this // Owner filter\n                                             ,\n                                             &hr // Result code\n                                             ,\n                                             L\"Input\" // Pin name\n        );\n\n        // Constructor for CTransInPlaceInputPin can't fail\n        ASSERT(SUCCEEDED(hr));\n    }\n\n    // Create an output pin if not already done\n\n    if (m_pInput != NULL && m_pOutput == NULL)\n    {\n\n        m_pOutput = new CTransInPlaceOutputPin(NAME(\"TransInPlace output pin\"), this // Owner filter\n                                               ,\n                                               &hr // Result code\n                                               ,\n                                               L\"Output\" // Pin name\n        );\n\n        // a failed return code should delete the object\n\n        ASSERT(SUCCEEDED(hr));\n        if (m_pOutput == NULL)\n        {\n            delete m_pInput;\n            m_pInput = NULL;\n        }\n    }\n\n    // Return the appropriate pin\n\n    ASSERT(n >= 0 && n <= 1);\n    if (n == 0)\n    {\n        return m_pInput;\n    }\n    else if (n == 1)\n    {\n        return m_pOutput;\n    }\n    else\n    {\n        return NULL;\n    }\n\n} // GetPin\n\n// dir is the direction of our pin.\n// pReceivePin is the pin we are connecting to.\nHRESULT CTransInPlaceFilter::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin)\n{\n    UNREFERENCED_PARAMETER(pReceivePin);\n    ASSERT(m_pInput);\n    ASSERT(m_pOutput);\n\n    // if we are not part of a graph, then don't indirect the pointer\n    // this probably prevents use of the filter without a filtergraph\n    if (!m_pGraph)\n    {\n        return VFW_E_NOT_IN_GRAPH;\n    }\n\n    // Always reconnect the input to account for buffering changes\n    //\n    // Because we don't get to suggest a type on ReceiveConnection\n    // we need another way of making sure the right type gets used.\n    //\n    // One way would be to have our EnumMediaTypes return our output\n    // connection type first but more deterministic and simple is to\n    // call ReconnectEx passing the type we want to reconnect with\n    // via the base class ReconeectPin method.\n\n    if (dir == PINDIR_OUTPUT)\n    {\n        if (m_pInput->IsConnected())\n        {\n            return ReconnectPin(m_pInput, &m_pOutput->CurrentMediaType());\n        }\n        return NOERROR;\n    }\n\n    ASSERT(dir == PINDIR_INPUT);\n\n    // Reconnect output if necessary\n\n    if (m_pOutput->IsConnected())\n    {\n\n        if (m_pInput->CurrentMediaType() != m_pOutput->CurrentMediaType())\n        {\n            return ReconnectPin(m_pOutput, &m_pInput->CurrentMediaType());\n        }\n    }\n    return NOERROR;\n\n} // ComnpleteConnect\n\n//\n// DecideBufferSize\n//\n// Tell the output pin's allocator what size buffers we require.\n// *pAlloc will be the allocator our output pin is using.\n//\n\nHRESULT CTransInPlaceFilter::DecideBufferSize(IMemAllocator *pAlloc, __inout ALLOCATOR_PROPERTIES *pProperties)\n{\n    ALLOCATOR_PROPERTIES Request, Actual;\n    HRESULT hr;\n\n    // If we are connected upstream, get his views\n    if (m_pInput->IsConnected())\n    {\n        // Get the input pin allocator, and get its size and count.\n        // we don't care about his alignment and prefix.\n\n        hr = InputPin()->PeekAllocator()->GetProperties(&Request);\n        if (FAILED(hr))\n        {\n            // Input connected but with a secretive allocator - enough!\n            return hr;\n        }\n    }\n    else\n    {\n        // Propose one byte\n        // If this isn't enough then when the other pin does get connected\n        // we can revise it.\n        ZeroMemory(&Request, sizeof(Request));\n        Request.cBuffers = 1;\n        Request.cbBuffer = 1;\n    }\n\n    DbgLog((LOG_MEMORY, 1, TEXT(\"Setting Allocator Requirements\")));\n    DbgLog((LOG_MEMORY, 1, TEXT(\"Count %d, Size %d\"), Request.cBuffers, Request.cbBuffer));\n\n    // Pass the allocator requirements to our output side\n    // but do a little sanity checking first or we'll just hit\n    // asserts in the allocator.\n\n    pProperties->cBuffers = Request.cBuffers;\n    pProperties->cbBuffer = Request.cbBuffer;\n    pProperties->cbAlign = Request.cbAlign;\n    if (pProperties->cBuffers <= 0)\n    {\n        pProperties->cBuffers = 1;\n    }\n    if (pProperties->cbBuffer <= 0)\n    {\n        pProperties->cbBuffer = 1;\n    }\n    hr = pAlloc->SetProperties(pProperties, &Actual);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    DbgLog((LOG_MEMORY, 1, TEXT(\"Obtained Allocator Requirements\")));\n    DbgLog((LOG_MEMORY, 1, TEXT(\"Count %d, Size %d, Alignment %d\"), Actual.cBuffers, Actual.cbBuffer, Actual.cbAlign));\n\n    // Make sure we got the right alignment and at least the minimum required\n\n    if ((Request.cBuffers > Actual.cBuffers) || (Request.cbBuffer > Actual.cbBuffer) ||\n        (Request.cbAlign > Actual.cbAlign))\n    {\n        return E_FAIL;\n    }\n    return NOERROR;\n\n} // DecideBufferSize\n\n//\n// Copy\n//\n// return a pointer to an identical copy of pSample\n__out_opt IMediaSample *CTransInPlaceFilter::Copy(IMediaSample *pSource)\n{\n    IMediaSample *pDest;\n\n    HRESULT hr;\n    REFERENCE_TIME tStart, tStop;\n    const BOOL bTime = S_OK == pSource->GetTime(&tStart, &tStop);\n\n    // this may block for an indeterminate amount of time\n    hr = OutputPin()->PeekAllocator()->GetBuffer(&pDest, bTime ? &tStart : NULL, bTime ? &tStop : NULL,\n                                                 m_bSampleSkipped ? AM_GBF_PREVFRAMESKIPPED : 0);\n\n    if (FAILED(hr))\n    {\n        return NULL;\n    }\n\n    ASSERT(pDest);\n    IMediaSample2 *pSample2;\n    if (SUCCEEDED(pDest->QueryInterface(IID_IMediaSample2, (void **)&pSample2)))\n    {\n        HRESULT hrProps =\n            pSample2->SetProperties(FIELD_OFFSET(AM_SAMPLE2_PROPERTIES, pbBuffer), (PBYTE)m_pInput->SampleProps());\n        pSample2->Release();\n        if (FAILED(hrProps))\n        {\n            pDest->Release();\n            return NULL;\n        }\n    }\n    else\n    {\n        if (bTime)\n        {\n            pDest->SetTime(&tStart, &tStop);\n        }\n\n        if (S_OK == pSource->IsSyncPoint())\n        {\n            pDest->SetSyncPoint(TRUE);\n        }\n        if (S_OK == pSource->IsDiscontinuity() || m_bSampleSkipped)\n        {\n            pDest->SetDiscontinuity(TRUE);\n        }\n        if (S_OK == pSource->IsPreroll())\n        {\n            pDest->SetPreroll(TRUE);\n        }\n\n        // Copy the media type\n        AM_MEDIA_TYPE *pMediaType;\n        if (S_OK == pSource->GetMediaType(&pMediaType))\n        {\n            pDest->SetMediaType(pMediaType);\n            DeleteMediaType(pMediaType);\n        }\n    }\n\n    m_bSampleSkipped = FALSE;\n\n    // Copy the sample media times\n    REFERENCE_TIME TimeStart, TimeEnd;\n    if (pSource->GetMediaTime(&TimeStart, &TimeEnd) == NOERROR)\n    {\n        pDest->SetMediaTime(&TimeStart, &TimeEnd);\n    }\n\n    // Copy the actual data length and the actual data.\n    {\n        const long lDataLength = pSource->GetActualDataLength();\n        if (FAILED(pDest->SetActualDataLength(lDataLength)))\n        {\n            pDest->Release();\n            return NULL;\n        }\n\n        // Copy the sample data\n        {\n            BYTE *pSourceBuffer, *pDestBuffer;\n            long lSourceSize = pSource->GetSize();\n            long lDestSize = pDest->GetSize();\n\n            ASSERT(lDestSize >= lSourceSize && lDestSize >= lDataLength);\n\n            if (FAILED(pSource->GetPointer(&pSourceBuffer)) || FAILED(pDest->GetPointer(&pDestBuffer)) ||\n                lDestSize < lDataLength || lDataLength < 0)\n            {\n                pDest->Release();\n                return NULL;\n            }\n            ASSERT(lDestSize == 0 || pSourceBuffer != NULL && pDestBuffer != NULL);\n\n            CopyMemory((PVOID)pDestBuffer, (PVOID)pSourceBuffer, lDataLength);\n        }\n    }\n\n    return pDest;\n\n} // Copy\n\n// override this to customize the transform process\n\nHRESULT\nCTransInPlaceFilter::Receive(IMediaSample *pSample)\n{\n    /*  Check for other streams and pass them on */\n    AM_SAMPLE2_PROPERTIES *const pProps = m_pInput->SampleProps();\n    if (pProps->dwStreamId != AM_STREAM_MEDIA)\n    {\n        return m_pOutput->Deliver(pSample);\n    }\n    HRESULT hr;\n\n    // Start timing the TransInPlace (if PERF is defined)\n    MSR_START(m_idTransInPlace);\n\n    if (UsingDifferentAllocators())\n    {\n\n        // We have to copy the data.\n\n        pSample = Copy(pSample);\n\n        if (pSample == NULL)\n        {\n            MSR_STOP(m_idTransInPlace);\n            return E_UNEXPECTED;\n        }\n    }\n\n    // have the derived class transform the data\n    hr = Transform(pSample);\n\n    // Stop the clock and log it (if PERF is defined)\n    MSR_STOP(m_idTransInPlace);\n\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 1, TEXT(\"Error from TransInPlace\")));\n        if (UsingDifferentAllocators())\n        {\n            pSample->Release();\n        }\n        return hr;\n    }\n\n    // the Transform() function can return S_FALSE to indicate that the\n    // sample should not be delivered; we only deliver the sample if it's\n    // really S_OK (same as NOERROR, of course.)\n    if (hr == NOERROR)\n    {\n        hr = m_pOutput->Deliver(pSample);\n    }\n    else\n    {\n        //  But it would be an error to return this private workaround\n        //  to the caller ...\n        if (S_FALSE == hr)\n        {\n            // S_FALSE returned from Transform is a PRIVATE agreement\n            // We should return NOERROR from Receive() in this cause because\n            // returning S_FALSE from Receive() means that this is the end\n            // of the stream and no more data should be sent.\n            m_bSampleSkipped = TRUE;\n            if (!m_bQualityChanged)\n            {\n                NotifyEvent(EC_QUALITY_CHANGE, 0, 0);\n                m_bQualityChanged = TRUE;\n            }\n            hr = NOERROR;\n        }\n    }\n\n    // release the output buffer. If the connected pin still needs it,\n    // it will have addrefed it itself.\n    if (UsingDifferentAllocators())\n    {\n        pSample->Release();\n    }\n\n    return hr;\n\n} // Receive\n\n// =================================================================\n// Implements the CTransInPlaceInputPin class\n// =================================================================\n\n// constructor\n\nCTransInPlaceInputPin::CTransInPlaceInputPin(__in_opt LPCTSTR pObjectName, __inout CTransInPlaceFilter *pFilter,\n                                             __inout HRESULT *phr, __in_opt LPCWSTR pName)\n    : CTransformInputPin(pObjectName, pFilter, phr, pName)\n    , m_bReadOnly(FALSE)\n    , m_pTIPFilter(pFilter)\n{\n    DbgLog((LOG_TRACE, 2, TEXT(\"CTransInPlaceInputPin::CTransInPlaceInputPin\")));\n\n} // constructor\n\n// =================================================================\n// Implements IMemInputPin interface\n// =================================================================\n\n// If the downstream filter has one then offer that (even if our own output\n// pin is not using it yet.  If the upstream filter chooses it then we will\n// tell our output pin to ReceiveAllocator).\n// Else if our output pin is using an allocator then offer that.\n//     ( This could mean offering the upstream filter his own allocator,\n//       it could mean offerring our own\n//     ) or it could mean offering the one from downstream\n// Else fail to offer any allocator at all.\n\nSTDMETHODIMP CTransInPlaceInputPin::GetAllocator(__deref_out IMemAllocator **ppAllocator)\n{\n    CheckPointer(ppAllocator, E_POINTER);\n    ValidateReadWritePtr(ppAllocator, sizeof(IMemAllocator *));\n    CAutoLock cObjectLock(m_pLock);\n\n    HRESULT hr;\n\n    if (m_pTIPFilter->m_pOutput->IsConnected())\n    {\n        //  Store the allocator we got\n        hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()->GetAllocator(ppAllocator);\n        if (SUCCEEDED(hr))\n        {\n            m_pTIPFilter->OutputPin()->SetAllocator(*ppAllocator);\n        }\n    }\n    else\n    {\n        //  Help upstream filter (eg TIP filter which is having to do a copy)\n        //  by providing a temp allocator here - we'll never use\n        //  this allocator because when our output is connected we'll\n        //  reconnect this pin\n        hr = CTransformInputPin::GetAllocator(ppAllocator);\n    }\n    return hr;\n\n} // GetAllocator\n\n/* Get told which allocator the upstream output pin is actually going to use */\n\nSTDMETHODIMP\nCTransInPlaceInputPin::NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly)\n{\n    HRESULT hr = S_OK;\n    CheckPointer(pAllocator, E_POINTER);\n    ValidateReadPtr(pAllocator, sizeof(IMemAllocator));\n\n    CAutoLock cObjectLock(m_pLock);\n\n    m_bReadOnly = bReadOnly;\n    //  If we modify data then don't accept the allocator if it's\n    //  the same as the output pin's allocator\n\n    //  If our output is not connected just accept the allocator\n    //  We're never going to use this allocator because when our\n    //  output pin is connected we'll reconnect this pin\n    if (!m_pTIPFilter->OutputPin()->IsConnected())\n    {\n        return CTransformInputPin::NotifyAllocator(pAllocator, bReadOnly);\n    }\n\n    //  If the allocator is read-only and we're modifying data\n    //  and the allocator is the same as the output pin's\n    //  then reject\n    if (bReadOnly && m_pTIPFilter->m_bModifiesData)\n    {\n        IMemAllocator *pOutputAllocator = m_pTIPFilter->OutputPin()->PeekAllocator();\n\n        //  Make sure we have an output allocator\n        if (pOutputAllocator == NULL)\n        {\n            hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()->GetAllocator(&pOutputAllocator);\n            if (FAILED(hr))\n            {\n                hr = CreateMemoryAllocator(&pOutputAllocator);\n            }\n            if (SUCCEEDED(hr))\n            {\n                m_pTIPFilter->OutputPin()->SetAllocator(pOutputAllocator);\n                pOutputAllocator->Release();\n            }\n        }\n        if (pAllocator == pOutputAllocator)\n        {\n            hr = E_FAIL;\n        }\n        else if (SUCCEEDED(hr))\n        {\n            //  Must copy so set the allocator properties on the output\n            ALLOCATOR_PROPERTIES Props, Actual;\n            hr = pAllocator->GetProperties(&Props);\n            if (SUCCEEDED(hr))\n            {\n                hr = pOutputAllocator->SetProperties(&Props, &Actual);\n            }\n            if (SUCCEEDED(hr))\n            {\n                if ((Props.cBuffers > Actual.cBuffers) || (Props.cbBuffer > Actual.cbBuffer) ||\n                    (Props.cbAlign > Actual.cbAlign))\n                {\n                    hr = E_FAIL;\n                }\n            }\n\n            //  Set the allocator on the output pin\n            if (SUCCEEDED(hr))\n            {\n                hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()->NotifyAllocator(pOutputAllocator, FALSE);\n            }\n        }\n    }\n    else\n    {\n        hr = m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()->NotifyAllocator(pAllocator, bReadOnly);\n        if (SUCCEEDED(hr))\n        {\n            m_pTIPFilter->OutputPin()->SetAllocator(pAllocator);\n        }\n    }\n\n    if (SUCCEEDED(hr))\n    {\n\n        // It's possible that the old and the new are the same thing.\n        // AddRef before release ensures that we don't unload it.\n        pAllocator->AddRef();\n\n        if (m_pAllocator != NULL)\n            m_pAllocator->Release();\n\n        m_pAllocator = pAllocator; // We have an allocator for the input pin\n    }\n\n    return hr;\n\n} // NotifyAllocator\n\n// EnumMediaTypes\n// - pass through to our downstream filter\nSTDMETHODIMP CTransInPlaceInputPin::EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum)\n{\n    // Can only pass through if connected\n    if (!m_pTIPFilter->m_pOutput->IsConnected())\n        return VFW_E_NOT_CONNECTED;\n\n    return m_pTIPFilter->m_pOutput->GetConnected()->EnumMediaTypes(ppEnum);\n\n} // EnumMediaTypes\n\n// CheckMediaType\n// - agree to anything if not connected,\n// otherwise pass through to the downstream filter.\n// This assumes that the filter does not change the media type.\n\nHRESULT CTransInPlaceInputPin::CheckMediaType(const CMediaType *pmt)\n{\n    HRESULT hr = m_pTIPFilter->CheckInputType(pmt);\n    if (hr != S_OK)\n        return hr;\n\n    if (m_pTIPFilter->m_pOutput->IsConnected())\n        return m_pTIPFilter->m_pOutput->GetConnected()->QueryAccept(pmt);\n    else\n        return S_OK;\n\n} // CheckMediaType\n\n// If upstream asks us what our requirements are, we will try to ask downstream\n// if that doesn't work, we'll just take the defaults.\nSTDMETHODIMP\nCTransInPlaceInputPin::GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps)\n{\n\n    if (m_pTIPFilter->m_pOutput->IsConnected())\n        return m_pTIPFilter->OutputPin()->ConnectedIMemInputPin()->GetAllocatorRequirements(pProps);\n    else\n        return E_NOTIMPL;\n\n} // GetAllocatorRequirements\n\n// CTransInPlaceInputPin::CompleteConnect() calls CBaseInputPin::CompleteConnect()\n// and then calls CTransInPlaceFilter::CompleteConnect().  It does this because\n// CTransInPlaceFilter::CompleteConnect() can reconnect a pin and we do not\n// want to reconnect a pin if CBaseInputPin::CompleteConnect() fails.\nHRESULT\nCTransInPlaceInputPin::CompleteConnect(IPin *pReceivePin)\n{\n    HRESULT hr = CBaseInputPin::CompleteConnect(pReceivePin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return m_pTransformFilter->CompleteConnect(PINDIR_INPUT, pReceivePin);\n} // CompleteConnect\n\n// =================================================================\n// Implements the CTransInPlaceOutputPin class\n// =================================================================\n\n// constructor\n\nCTransInPlaceOutputPin::CTransInPlaceOutputPin(__in_opt LPCTSTR pObjectName, __inout CTransInPlaceFilter *pFilter,\n                                               __inout HRESULT *phr, __in_opt LPCWSTR pPinName)\n    : CTransformOutputPin(pObjectName, pFilter, phr, pPinName)\n    , m_pTIPFilter(pFilter)\n{\n    DbgLog((LOG_TRACE, 2, TEXT(\"CTransInPlaceOutputPin::CTransInPlaceOutputPin\")));\n\n} // constructor\n\n// EnumMediaTypes\n// - pass through to our upstream filter\nSTDMETHODIMP CTransInPlaceOutputPin::EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum)\n{\n    // Can only pass through if connected.\n    if (!m_pTIPFilter->m_pInput->IsConnected())\n        return VFW_E_NOT_CONNECTED;\n\n    return m_pTIPFilter->m_pInput->GetConnected()->EnumMediaTypes(ppEnum);\n\n} // EnumMediaTypes\n\n// CheckMediaType\n// - agree to anything if not connected,\n// otherwise pass through to the upstream filter.\n\nHRESULT CTransInPlaceOutputPin::CheckMediaType(const CMediaType *pmt)\n{\n    // Don't accept any output pin type changes if we're copying\n    // between allocators - it's too late to change the input\n    // allocator size.\n    if (m_pTIPFilter->UsingDifferentAllocators() && !m_pFilter->IsStopped())\n    {\n        if (*pmt == m_mt)\n        {\n            return S_OK;\n        }\n        else\n        {\n            return VFW_E_TYPE_NOT_ACCEPTED;\n        }\n    }\n\n    // Assumes the type does not change.  That's why we're calling\n    // CheckINPUTType here on the OUTPUT pin.\n    HRESULT hr = m_pTIPFilter->CheckInputType(pmt);\n    if (hr != S_OK)\n        return hr;\n\n    if (m_pTIPFilter->m_pInput->IsConnected())\n        return m_pTIPFilter->m_pInput->GetConnected()->QueryAccept(pmt);\n    else\n        return S_OK;\n\n} // CheckMediaType\n\n/* Save the allocator pointer in the output pin\n */\nvoid CTransInPlaceOutputPin::SetAllocator(IMemAllocator *pAllocator)\n{\n    pAllocator->AddRef();\n    if (m_pAllocator)\n    {\n        m_pAllocator->Release();\n    }\n    m_pAllocator = pAllocator;\n} // SetAllocator\n\n// CTransInPlaceOutputPin::CompleteConnect() calls CBaseOutputPin::CompleteConnect()\n// and then calls CTransInPlaceFilter::CompleteConnect().  It does this because\n// CTransInPlaceFilter::CompleteConnect() can reconnect a pin and we do not want to\n// reconnect a pin if CBaseOutputPin::CompleteConnect() fails.\n// CBaseOutputPin::CompleteConnect() often fails when our output pin is being connected\n// to the Video Mixing Renderer.\nHRESULT\nCTransInPlaceOutputPin::CompleteConnect(IPin *pReceivePin)\n{\n    HRESULT hr = CBaseOutputPin::CompleteConnect(pReceivePin);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    return m_pTransformFilter->CompleteConnect(PINDIR_OUTPUT, pReceivePin);\n} // CompleteConnect\n"
  },
  {
    "path": "common/baseclasses/transip.h",
    "content": "//------------------------------------------------------------------------------\n// File: TransIP.h\n//\n// Desc: DirectShow base classes - defines classes from which simple\n//       Transform-In-Place filters may be derived.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n//\n// The difference between this and Transfrm.h is that Transfrm copies the data.\n//\n// It assumes the filter has one input and one output stream, and has no\n// interest in memory management, interface negotiation or anything else.\n//\n// Derive your class from this, and supply Transform and the media type/format\n// negotiation functions. Implement that class, compile and link and\n// you're done.\n\n#ifndef __TRANSIP__\n#define __TRANSIP__\n\n// ======================================================================\n// This is the com object that represents a simple transform filter. It\n// supports IBaseFilter, IMediaFilter and two pins through nested interfaces\n// ======================================================================\n\nclass CTransInPlaceFilter;\n\n// Several of the pin functions call filter functions to do the work,\n// so you can often use the pin classes unaltered, just overriding the\n// functions in CTransInPlaceFilter.  If that's not enough and you want\n// to derive your own pin class, override GetPin in the filter to supply\n// your own pin classes to the filter.\n\n// ==================================================\n// Implements the input pin\n// ==================================================\n\nclass CTransInPlaceInputPin : public CTransformInputPin\n{\n\n  protected:\n    CTransInPlaceFilter *const m_pTIPFilter; // our filter\n    BOOL m_bReadOnly;                        // incoming stream is read only\n\n  public:\n    CTransInPlaceInputPin(__in_opt LPCTSTR pObjectName, __inout CTransInPlaceFilter *pFilter, __inout HRESULT *phr,\n                          __in_opt LPCWSTR pName);\n\n    // --- IMemInputPin -----\n\n    // Provide an enumerator for media types by getting one from downstream\n    STDMETHODIMP EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum);\n\n    // Say whether media type is acceptable.\n    HRESULT CheckMediaType(const CMediaType *pmt);\n\n    // Return our upstream allocator\n    STDMETHODIMP GetAllocator(__deref_out IMemAllocator **ppAllocator);\n\n    // get told which allocator the upstream output pin is actually\n    // going to use.\n    STDMETHODIMP NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly);\n\n    // Allow the filter to see what allocator we have\n    // N.B. This does NOT AddRef\n    __out IMemAllocator *PeekAllocator() const { return m_pAllocator; }\n\n    // Pass this on downstream if it ever gets called.\n    STDMETHODIMP GetAllocatorRequirements(__out ALLOCATOR_PROPERTIES *pProps);\n\n    HRESULT CompleteConnect(IPin *pReceivePin);\n\n    inline const BOOL ReadOnly() { return m_bReadOnly; }\n\n}; // CTransInPlaceInputPin\n\n// ==================================================\n// Implements the output pin\n// ==================================================\n\nclass CTransInPlaceOutputPin : public CTransformOutputPin\n{\n\n  protected:\n    // m_pFilter points to our CBaseFilter\n    CTransInPlaceFilter *const m_pTIPFilter;\n\n  public:\n    CTransInPlaceOutputPin(__in_opt LPCTSTR pObjectName, __inout CTransInPlaceFilter *pFilter, __inout HRESULT *phr,\n                           __in_opt LPCWSTR pName);\n\n    // --- CBaseOutputPin ------------\n\n    // negotiate the allocator and its buffer size/count\n    // Insists on using our own allocator.  (Actually the one upstream of us).\n    // We don't override this - instead we just agree the default\n    // then let the upstream filter decide for itself on reconnect\n    // virtual HRESULT DecideAllocator(IMemInputPin * pPin, IMemAllocator ** pAlloc);\n\n    // Provide a media type enumerator.  Get it from upstream.\n    STDMETHODIMP EnumMediaTypes(__deref_out IEnumMediaTypes **ppEnum);\n\n    // Say whether media type is acceptable.\n    HRESULT CheckMediaType(const CMediaType *pmt);\n\n    //  This just saves the allocator being used on the output pin\n    //  Also called by input pin's GetAllocator()\n    void SetAllocator(IMemAllocator *pAllocator);\n\n    __out_opt IMemInputPin *ConnectedIMemInputPin() { return m_pInputPin; }\n\n    // Allow the filter to see what allocator we have\n    // N.B. This does NOT AddRef\n    __out IMemAllocator *PeekAllocator() const { return m_pAllocator; }\n\n    HRESULT CompleteConnect(IPin *pReceivePin);\n\n}; // CTransInPlaceOutputPin\n\nclass AM_NOVTABLE CTransInPlaceFilter : public CTransformFilter\n{\n\n  public:\n    // map getpin/getpincount for base enum of pins to owner\n    // override this to return more specialised pin objects\n\n    virtual CBasePin *GetPin(int n);\n\n  public:\n    //  Set bModifiesData == false if your derived filter does\n    //  not modify the data samples (for instance it's just copying\n    //  them somewhere else or looking at the timestamps).\n\n    CTransInPlaceFilter(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, REFCLSID clsid, __inout HRESULT *,\n                        bool bModifiesData = true);\n#ifdef UNICODE\n    CTransInPlaceFilter(__in_opt LPCSTR, __inout_opt LPUNKNOWN, REFCLSID clsid, __inout HRESULT *,\n                        bool bModifiesData = true);\n#endif\n    // The following are defined to avoid undefined pure virtuals.\n    // Even if they are never called, they will give linkage warnings/errors\n\n    // We override EnumMediaTypes to bypass the transform class enumerator\n    // which would otherwise call this.\n    HRESULT GetMediaType(int iPosition, __inout CMediaType *pMediaType)\n    {\n        DbgBreak(\"CTransInPlaceFilter::GetMediaType should never be called\");\n        return E_UNEXPECTED;\n    }\n\n    // This is called when we actually have to provide our own allocator.\n    HRESULT DecideBufferSize(IMemAllocator *, __inout ALLOCATOR_PROPERTIES *);\n\n    // The functions which call this in CTransform are overridden in this\n    // class to call CheckInputType with the assumption that the type\n    // does not change.  In Debug builds some calls will be made and\n    // we just ensure that they do not assert.\n    HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut) { return S_OK; };\n\n    // =================================================================\n    // ----- You may want to override this -----------------------------\n    // =================================================================\n\n    HRESULT CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin);\n\n    // chance to customize the transform process\n    virtual HRESULT Receive(IMediaSample *pSample);\n\n    // =================================================================\n    // ----- You MUST override these -----------------------------------\n    // =================================================================\n\n    virtual HRESULT Transform(IMediaSample *pSample) PURE;\n\n    // this goes in the factory template table to create new instances\n    // static CCOMObject * CreateInstance(LPUNKNOWN, HRESULT *);\n\n#ifdef PERF\n    // Override to register performance measurement with a less generic string\n    // You should do this to avoid confusion with other filters\n    virtual void RegisterPerfId() { m_idTransInPlace = MSR_REGISTER(TEXT(\"TransInPlace\")); }\n#endif // PERF\n\n    // implementation details\n\n  protected:\n    __out_opt IMediaSample *CTransInPlaceFilter::Copy(IMediaSample *pSource);\n\n#ifdef PERF\n    int m_idTransInPlace; // performance measuring id\n#endif                    // PERF\n    bool m_bModifiesData; // Does this filter change the data?\n\n    // these hold our input and output pins\n\n    friend class CTransInPlaceInputPin;\n    friend class CTransInPlaceOutputPin;\n\n    __out CTransInPlaceInputPin *InputPin() const { return (CTransInPlaceInputPin *)m_pInput; };\n    __out CTransInPlaceOutputPin *OutputPin() const { return (CTransInPlaceOutputPin *)m_pOutput; };\n\n    //  Helper to see if the input and output types match\n    BOOL TypesMatch() { return InputPin()->CurrentMediaType() == OutputPin()->CurrentMediaType(); }\n\n    //  Are the input and output allocators different?\n    BOOL UsingDifferentAllocators() const { return InputPin()->PeekAllocator() != OutputPin()->PeekAllocator(); }\n}; // CTransInPlaceFilter\n\n#endif /* __TRANSIP__ */\n"
  },
  {
    "path": "common/baseclasses/videoctl.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: VideoCtl.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include \"ddmm.h\"\n\n// Load a string from the resource file string table. The buffer must be at\n// least STR_MAX_LENGTH bytes. The easiest way to use this is to declare a\n// buffer in the property page class and use it for all string loading. It\n// cannot be static as multiple property pages may be active simultaneously\n\nLPTSTR WINAPI StringFromResource(__out_ecount(STR_MAX_LENGTH) LPTSTR pBuffer, int iResourceID)\n{\n    if (LoadString(g_hInst, iResourceID, pBuffer, STR_MAX_LENGTH) == 0)\n    {\n        return TEXT(\"\");\n    }\n    return pBuffer;\n}\n\n#ifdef UNICODE\nLPSTR WINAPI StringFromResource(__out_ecount(STR_MAX_LENGTH) LPSTR pBuffer, int iResourceID)\n{\n    if (LoadStringA(g_hInst, iResourceID, pBuffer, STR_MAX_LENGTH) == 0)\n    {\n        return \"\";\n    }\n    return pBuffer;\n}\n#endif\n\n// Property pages typically are called through their OLE interfaces. These\n// use UNICODE strings regardless of how the binary is built. So when we\n// load strings from the resource file we sometimes want to convert them\n// to UNICODE. This method is passed the target UNICODE buffer and does a\n// convert after loading the string (if built UNICODE this is not needed)\n// On WinNT we can explicitly call LoadStringW which saves two conversions\n\n#ifndef UNICODE\n\nLPWSTR WINAPI WideStringFromResource(__out_ecount(STR_MAX_LENGTH) LPWSTR pBuffer, int iResourceID)\n{\n    *pBuffer = 0;\n\n    if (g_amPlatform == VER_PLATFORM_WIN32_NT)\n    {\n        LoadStringW(g_hInst, iResourceID, pBuffer, STR_MAX_LENGTH);\n    }\n    else\n    {\n\n        CHAR szBuffer[STR_MAX_LENGTH];\n        DWORD dwStringLength = LoadString(g_hInst, iResourceID, szBuffer, STR_MAX_LENGTH);\n        // if we loaded a string convert it to wide characters, ensuring\n        // that we also null terminate the result.\n        if (dwStringLength++)\n        {\n            MultiByteToWideChar(CP_ACP, 0, szBuffer, dwStringLength, pBuffer, STR_MAX_LENGTH);\n        }\n    }\n    return pBuffer;\n}\n\n#endif\n\n// Helper function to calculate the size of the dialog\n\nBOOL WINAPI GetDialogSize(int iResourceID, DLGPROC pDlgProc, LPARAM lParam, __out SIZE *pResult)\n{\n    RECT rc;\n    HWND hwnd;\n\n    // Create a temporary property page\n\n    hwnd = CreateDialogParam(g_hInst, MAKEINTRESOURCE(iResourceID), GetDesktopWindow(), pDlgProc, lParam);\n    if (hwnd == NULL)\n    {\n        return FALSE;\n    }\n\n    GetWindowRect(hwnd, &rc);\n    pResult->cx = rc.right - rc.left;\n    pResult->cy = rc.bottom - rc.top;\n\n    DestroyWindow(hwnd);\n    return TRUE;\n}\n\n// Class that aggregates on the IDirectDraw interface. Although DirectDraw\n// has the ability in its interfaces to be aggregated they're not currently\n// implemented. This makes it difficult for various parts of Quartz that want\n// to aggregate these interfaces. In particular the video renderer passes out\n// media samples that expose IDirectDraw and IDirectDrawSurface. The filter\n// graph manager also exposes IDirectDraw as a plug in distributor. For these\n// objects we provide these aggregation classes that republish the interfaces\n\nSTDMETHODIMP CAggDirectDraw::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    ASSERT(m_pDirectDraw);\n\n    // Do we have this interface\n\n    if (riid == IID_IDirectDraw)\n    {\n        return GetInterface((IDirectDraw *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP CAggDirectDraw::Compact()\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->Compact();\n}\n\nSTDMETHODIMP CAggDirectDraw::CreateClipper(DWORD dwFlags, __deref_out LPDIRECTDRAWCLIPPER *lplpDDClipper,\n                                           __inout_opt IUnknown *pUnkOuter)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->CreateClipper(dwFlags, lplpDDClipper, pUnkOuter);\n}\n\nSTDMETHODIMP CAggDirectDraw::CreatePalette(DWORD dwFlags, __in LPPALETTEENTRY lpColorTable,\n                                           __deref_out LPDIRECTDRAWPALETTE *lplpDDPalette,\n                                           __inout_opt IUnknown *pUnkOuter)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->CreatePalette(dwFlags, lpColorTable, lplpDDPalette, pUnkOuter);\n}\n\nSTDMETHODIMP CAggDirectDraw::CreateSurface(__in LPDDSURFACEDESC lpDDSurfaceDesc,\n                                           __deref_out LPDIRECTDRAWSURFACE *lplpDDSurface,\n                                           __inout_opt IUnknown *pUnkOuter)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->CreateSurface(lpDDSurfaceDesc, lplpDDSurface, pUnkOuter);\n}\n\nSTDMETHODIMP CAggDirectDraw::DuplicateSurface(__in LPDIRECTDRAWSURFACE lpDDSurface,\n                                              __deref_out LPDIRECTDRAWSURFACE *lplpDupDDSurface)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->DuplicateSurface(lpDDSurface, lplpDupDDSurface);\n}\n\nSTDMETHODIMP CAggDirectDraw::EnumDisplayModes(DWORD dwSurfaceDescCount, __in LPDDSURFACEDESC lplpDDSurfaceDescList,\n                                              __in LPVOID lpContext, __in LPDDENUMMODESCALLBACK lpEnumCallback)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->EnumDisplayModes(dwSurfaceDescCount, lplpDDSurfaceDescList, lpContext, lpEnumCallback);\n}\n\nSTDMETHODIMP CAggDirectDraw::EnumSurfaces(DWORD dwFlags, __in LPDDSURFACEDESC lpDDSD, __in LPVOID lpContext,\n                                          __in LPDDENUMSURFACESCALLBACK lpEnumCallback)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->EnumSurfaces(dwFlags, lpDDSD, lpContext, lpEnumCallback);\n}\n\nSTDMETHODIMP CAggDirectDraw::FlipToGDISurface()\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->FlipToGDISurface();\n}\n\nSTDMETHODIMP CAggDirectDraw::GetCaps(__out LPDDCAPS lpDDDriverCaps, __out LPDDCAPS lpDDHELCaps)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->GetCaps(lpDDDriverCaps, lpDDHELCaps);\n}\n\nSTDMETHODIMP CAggDirectDraw::GetDisplayMode(__out LPDDSURFACEDESC lpDDSurfaceDesc)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->GetDisplayMode(lpDDSurfaceDesc);\n}\n\nSTDMETHODIMP CAggDirectDraw::GetFourCCCodes(__inout LPDWORD lpNumCodes, __out_ecount(*lpNumCodes) LPDWORD lpCodes)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->GetFourCCCodes(lpNumCodes, lpCodes);\n}\n\nSTDMETHODIMP CAggDirectDraw::GetGDISurface(__deref_out LPDIRECTDRAWSURFACE *lplpGDIDDSurface)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->GetGDISurface(lplpGDIDDSurface);\n}\n\nSTDMETHODIMP CAggDirectDraw::GetMonitorFrequency(__out LPDWORD lpdwFrequency)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->GetMonitorFrequency(lpdwFrequency);\n}\n\nSTDMETHODIMP CAggDirectDraw::GetScanLine(__out LPDWORD lpdwScanLine)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->GetScanLine(lpdwScanLine);\n}\n\nSTDMETHODIMP CAggDirectDraw::GetVerticalBlankStatus(__out LPBOOL lpblsInVB)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->GetVerticalBlankStatus(lpblsInVB);\n}\n\nSTDMETHODIMP CAggDirectDraw::Initialize(__in GUID *lpGUID)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->Initialize(lpGUID);\n}\n\nSTDMETHODIMP CAggDirectDraw::RestoreDisplayMode()\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->RestoreDisplayMode();\n}\n\nSTDMETHODIMP CAggDirectDraw::SetCooperativeLevel(HWND hWnd, DWORD dwFlags)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->SetCooperativeLevel(hWnd, dwFlags);\n}\n\nSTDMETHODIMP CAggDirectDraw::SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBpp)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->SetDisplayMode(dwWidth, dwHeight, dwBpp);\n}\n\nSTDMETHODIMP CAggDirectDraw::WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent)\n{\n    ASSERT(m_pDirectDraw);\n    return m_pDirectDraw->WaitForVerticalBlank(dwFlags, hEvent);\n}\n\n// Class that aggregates an IDirectDrawSurface interface. Although DirectDraw\n// has the ability in its interfaces to be aggregated they're not currently\n// implemented. This makes it difficult for various parts of Quartz that want\n// to aggregate these interfaces. In particular the video renderer passes out\n// media samples that expose IDirectDraw and IDirectDrawSurface. The filter\n// graph manager also exposes IDirectDraw as a plug in distributor. For these\n// objects we provide these aggregation classes that republish the interfaces\n\nSTDMETHODIMP CAggDrawSurface::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    ASSERT(m_pDirectDrawSurface);\n\n    // Do we have this interface\n\n    if (riid == IID_IDirectDrawSurface)\n    {\n        return GetInterface((IDirectDrawSurface *)this, ppv);\n    }\n    else\n    {\n        return CUnknown::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP CAggDrawSurface::AddAttachedSurface(__in LPDIRECTDRAWSURFACE lpDDSAttachedSurface)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->AddAttachedSurface(lpDDSAttachedSurface);\n}\n\nSTDMETHODIMP CAggDrawSurface::AddOverlayDirtyRect(__in LPRECT lpRect)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->AddOverlayDirtyRect(lpRect);\n}\n\nSTDMETHODIMP CAggDrawSurface::Blt(__in LPRECT lpDestRect, __in LPDIRECTDRAWSURFACE lpDDSrcSurface,\n                                  __in LPRECT lpSrcRect, DWORD dwFlags, __in LPDDBLTFX lpDDBltFx)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->Blt(lpDestRect, lpDDSrcSurface, lpSrcRect, dwFlags, lpDDBltFx);\n}\n\nSTDMETHODIMP CAggDrawSurface::BltBatch(__in_ecount(dwCount) LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->BltBatch(lpDDBltBatch, dwCount, dwFlags);\n}\n\nSTDMETHODIMP CAggDrawSurface::BltFast(DWORD dwX, DWORD dwY, __in LPDIRECTDRAWSURFACE lpDDSrcSurface,\n                                      __in LPRECT lpSrcRect, DWORD dwTrans)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->BltFast(dwX, dwY, lpDDSrcSurface, lpSrcRect, dwTrans);\n}\n\nSTDMETHODIMP CAggDrawSurface::DeleteAttachedSurface(DWORD dwFlags, __in LPDIRECTDRAWSURFACE lpDDSAttachedSurface)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->DeleteAttachedSurface(dwFlags, lpDDSAttachedSurface);\n}\n\nSTDMETHODIMP CAggDrawSurface::EnumAttachedSurfaces(__in LPVOID lpContext,\n                                                   __in LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->EnumAttachedSurfaces(lpContext, lpEnumSurfacesCallback);\n}\n\nSTDMETHODIMP CAggDrawSurface::EnumOverlayZOrders(DWORD dwFlags, __in LPVOID lpContext,\n                                                 __in LPDDENUMSURFACESCALLBACK lpfnCallback)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->EnumOverlayZOrders(dwFlags, lpContext, lpfnCallback);\n}\n\nSTDMETHODIMP CAggDrawSurface::Flip(__in LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DWORD dwFlags)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->Flip(lpDDSurfaceTargetOverride, dwFlags);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetAttachedSurface(__in LPDDSCAPS lpDDSCaps,\n                                                 __deref_out LPDIRECTDRAWSURFACE *lplpDDAttachedSurface)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetAttachedSurface(lpDDSCaps, lplpDDAttachedSurface);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetBltStatus(DWORD dwFlags)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetBltStatus(dwFlags);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetCaps(__out LPDDSCAPS lpDDSCaps)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetCaps(lpDDSCaps);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetClipper(__deref_out LPDIRECTDRAWCLIPPER *lplpDDClipper)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetClipper(lplpDDClipper);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetColorKey(DWORD dwFlags, __out LPDDCOLORKEY lpDDColorKey)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetColorKey(dwFlags, lpDDColorKey);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetDC(__out HDC *lphDC)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetDC(lphDC);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetFlipStatus(DWORD dwFlags)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetFlipStatus(dwFlags);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetOverlayPosition(__out LPLONG lpdwX, __out LPLONG lpdwY)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetOverlayPosition(lpdwX, lpdwY);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetPalette(__deref_out LPDIRECTDRAWPALETTE *lplpDDPalette)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetPalette(lplpDDPalette);\n}\n\nSTDMETHODIMP CAggDrawSurface::GetPixelFormat(__out LPDDPIXELFORMAT lpDDPixelFormat)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->GetPixelFormat(lpDDPixelFormat);\n}\n\n// A bit of a warning here: Our media samples in DirectShow aggregate on\n// IDirectDraw and IDirectDrawSurface (ie are available through IMediaSample\n// by QueryInterface). Unfortunately the underlying DirectDraw code cannot\n// be aggregated so we have to use these classes. The snag is that when we\n// call a different surface and pass in this interface as perhaps the source\n// surface the call will fail because DirectDraw dereferences the pointer to\n// get at its private data structures. Therefore we supply this workaround to give\n// access to the real IDirectDraw surface. A filter can call GetSurfaceDesc\n// and we will fill in the lpSurface pointer with the real underlying surface\n\nSTDMETHODIMP CAggDrawSurface::GetSurfaceDesc(__out LPDDSURFACEDESC lpDDSurfaceDesc)\n{\n    ASSERT(m_pDirectDrawSurface);\n\n    // First call down to the underlying DirectDraw\n\n    HRESULT hr = m_pDirectDrawSurface->GetSurfaceDesc(lpDDSurfaceDesc);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Store the real DirectDrawSurface interface\n    lpDDSurfaceDesc->lpSurface = m_pDirectDrawSurface;\n    return hr;\n}\n\nSTDMETHODIMP CAggDrawSurface::Initialize(__in LPDIRECTDRAW lpDD, __in LPDDSURFACEDESC lpDDSurfaceDesc)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->Initialize(lpDD, lpDDSurfaceDesc);\n}\n\nSTDMETHODIMP CAggDrawSurface::IsLost()\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->IsLost();\n}\n\nSTDMETHODIMP CAggDrawSurface::Lock(__in LPRECT lpDestRect, __inout LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags,\n                                   HANDLE hEvent)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->Lock(lpDestRect, lpDDSurfaceDesc, dwFlags, hEvent);\n}\n\nSTDMETHODIMP CAggDrawSurface::ReleaseDC(HDC hDC)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->ReleaseDC(hDC);\n}\n\nSTDMETHODIMP CAggDrawSurface::Restore()\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->Restore();\n}\n\nSTDMETHODIMP CAggDrawSurface::SetClipper(__in LPDIRECTDRAWCLIPPER lpDDClipper)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->SetClipper(lpDDClipper);\n}\n\nSTDMETHODIMP CAggDrawSurface::SetColorKey(DWORD dwFlags, __in LPDDCOLORKEY lpDDColorKey)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->SetColorKey(dwFlags, lpDDColorKey);\n}\n\nSTDMETHODIMP CAggDrawSurface::SetOverlayPosition(LONG dwX, LONG dwY)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->SetOverlayPosition(dwX, dwY);\n}\n\nSTDMETHODIMP CAggDrawSurface::SetPalette(__in LPDIRECTDRAWPALETTE lpDDPalette)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->SetPalette(lpDDPalette);\n}\n\nSTDMETHODIMP CAggDrawSurface::Unlock(__in LPVOID lpSurfaceData)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->Unlock(lpSurfaceData);\n}\n\nSTDMETHODIMP CAggDrawSurface::UpdateOverlay(__in LPRECT lpSrcRect, __in LPDIRECTDRAWSURFACE lpDDDestSurface,\n                                            __in LPRECT lpDestRect, DWORD dwFlags, __in LPDDOVERLAYFX lpDDOverlayFX)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->UpdateOverlay(lpSrcRect, lpDDDestSurface, lpDestRect, dwFlags, lpDDOverlayFX);\n}\n\nSTDMETHODIMP CAggDrawSurface::UpdateOverlayDisplay(DWORD dwFlags)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->UpdateOverlayDisplay(dwFlags);\n}\n\nSTDMETHODIMP CAggDrawSurface::UpdateOverlayZOrder(DWORD dwFlags, __in LPDIRECTDRAWSURFACE lpDDSReference)\n{\n    ASSERT(m_pDirectDrawSurface);\n    return m_pDirectDrawSurface->UpdateOverlayZOrder(dwFlags, lpDDSReference);\n}\n\n// DirectShow must work on multiple platforms.  In particular, it also runs on\n// Windows NT 3.51 which does not have DirectDraw capabilities. The filters\n// cannot therefore link statically to the DirectDraw library. To make their\n// lives that little bit easier we provide this class that manages loading\n// and unloading the library and creating the initial IDirectDraw interface\n\nCLoadDirectDraw::CLoadDirectDraw()\n    : m_pDirectDraw(NULL)\n    , m_hDirectDraw(NULL)\n{\n}\n\n// Destructor forces unload\n\nCLoadDirectDraw::~CLoadDirectDraw()\n{\n    ReleaseDirectDraw();\n\n    if (m_hDirectDraw)\n    {\n        NOTE(\"Unloading library\");\n        FreeLibrary(m_hDirectDraw);\n    }\n}\n\n// We can't be sure that DirectDraw is always available so we can't statically\n// link to the library. Therefore we load the library, get the function entry\n// point addresses and call them to create the driver objects. We return S_OK\n// if we manage to load DirectDraw correctly otherwise we return E_NOINTERFACE\n// We initialise a DirectDraw instance by explicitely loading the library and\n// calling GetProcAddress on the DirectDrawCreate entry point that it exports\n\n// On a multi monitor system, we can get the DirectDraw object for any\n// monitor (device) with the optional szDevice parameter\n\nHRESULT CLoadDirectDraw::LoadDirectDraw(__in LPSTR szDevice)\n{\n    PDRAWCREATE pDrawCreate;\n    PDRAWENUM pDrawEnum;\n    LPDIRECTDRAWENUMERATEEXA pDrawEnumEx;\n    HRESULT hr = NOERROR;\n\n    NOTE(\"Entering DoLoadDirectDraw\");\n\n    // Is DirectDraw already loaded\n\n    if (m_pDirectDraw)\n    {\n        NOTE(\"Already loaded\");\n        ASSERT(m_hDirectDraw);\n        return NOERROR;\n    }\n\n    // Make sure the library is available\n\n    if (!m_hDirectDraw)\n    {\n        UINT ErrorMode = SetErrorMode(SEM_NOOPENFILEERRORBOX);\n        m_hDirectDraw = LoadLibrary(TEXT(\"DDRAW.DLL\"));\n        SetErrorMode(ErrorMode);\n\n        if (m_hDirectDraw == NULL)\n        {\n            DbgLog((LOG_ERROR, 1, TEXT(\"Can't load DDRAW.DLL\")));\n            NOTE(\"No library\");\n            return E_NOINTERFACE;\n        }\n    }\n\n    // Get the DLL address for the creator function\n\n    pDrawCreate = (PDRAWCREATE)GetProcAddress(m_hDirectDraw, \"DirectDrawCreate\");\n    // force ANSI, we assume it\n    pDrawEnum = (PDRAWENUM)GetProcAddress(m_hDirectDraw, \"DirectDrawEnumerateA\");\n    pDrawEnumEx = (LPDIRECTDRAWENUMERATEEXA)GetProcAddress(m_hDirectDraw, \"DirectDrawEnumerateExA\");\n\n    // We don't NEED DirectDrawEnumerateEx, that's just for multimon stuff\n    if (pDrawCreate == NULL || pDrawEnum == NULL)\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"Can't get functions: Create=%x Enum=%x\"), pDrawCreate, pDrawEnum));\n        NOTE(\"No entry point\");\n        ReleaseDirectDraw();\n        return E_NOINTERFACE;\n    }\n\n    DbgLog((LOG_TRACE, 3, TEXT(\"Creating DDraw for device %s\"), szDevice ? szDevice : \"<NULL>\"));\n\n    // Create a DirectDraw display provider for this device, using the fancy\n    // multimon-aware version, if it exists\n    if (pDrawEnumEx)\n        m_pDirectDraw = DirectDrawCreateFromDeviceEx(szDevice, pDrawCreate, pDrawEnumEx);\n    else\n        m_pDirectDraw = DirectDrawCreateFromDevice(szDevice, pDrawCreate, pDrawEnum);\n\n    if (m_pDirectDraw == NULL)\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"Can't create DDraw\")));\n        NOTE(\"No instance\");\n        ReleaseDirectDraw();\n        return E_NOINTERFACE;\n    }\n    return NOERROR;\n}\n\n// Called to release any DirectDraw provider we previously loaded. We may be\n// called at any time especially when something goes horribly wrong and when\n// we need to clean up before returning so we can't guarantee that all state\n// variables are consistent so free only those really allocated allocated\n// This should only be called once all reference counts have been released\n\nvoid CLoadDirectDraw::ReleaseDirectDraw()\n{\n    NOTE(\"Releasing DirectDraw driver\");\n\n    // Release any DirectDraw provider interface\n\n    if (m_pDirectDraw)\n    {\n        NOTE(\"Releasing instance\");\n        m_pDirectDraw->Release();\n        m_pDirectDraw = NULL;\n    }\n}\n\n// Return NOERROR (S_OK) if DirectDraw has been loaded by this object\n\nHRESULT CLoadDirectDraw::IsDirectDrawLoaded()\n{\n    NOTE(\"Entering IsDirectDrawLoaded\");\n\n    if (m_pDirectDraw == NULL)\n    {\n        NOTE(\"DirectDraw not loaded\");\n        return S_FALSE;\n    }\n    return NOERROR;\n}\n\n// Return the IDirectDraw interface we look after\n\nLPDIRECTDRAW CLoadDirectDraw::GetDirectDraw()\n{\n    NOTE(\"Entering GetDirectDraw\");\n\n    if (m_pDirectDraw == NULL)\n    {\n        NOTE(\"No DirectDraw\");\n        return NULL;\n    }\n\n    NOTE(\"Returning DirectDraw\");\n    m_pDirectDraw->AddRef();\n    return m_pDirectDraw;\n}\n\n// Are we running on Direct Draw version 1?  We need to find out as\n// we rely on specific bug fixes in DirectDraw 2 for fullscreen playback. To\n// find out, we simply see if it supports IDirectDraw2.  Only version 2 and\n// higher support this.\n\nBOOL CLoadDirectDraw::IsDirectDrawVersion1()\n{\n\n    if (m_pDirectDraw == NULL)\n        return FALSE;\n\n    IDirectDraw2 *p = NULL;\n    HRESULT hr = m_pDirectDraw->QueryInterface(IID_IDirectDraw2, (void **)&p);\n    if (p)\n        p->Release();\n    if (hr == NOERROR)\n    {\n        DbgLog((LOG_TRACE, 3, TEXT(\"Direct Draw Version 2 or greater\")));\n        return FALSE;\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 3, TEXT(\"Direct Draw Version 1\")));\n        return TRUE;\n    }\n}\n"
  },
  {
    "path": "common/baseclasses/videoctl.h",
    "content": "//------------------------------------------------------------------------------\n// File: VideoCtl.h\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __VIDEOCTL__\n#define __VIDEOCTL__\n\n// These help with property page implementations. The first can be used to\n// load any string from a resource file. The buffer to load into is passed\n// as an input parameter. The same buffer is the return value if the string\n// was found otherwise it returns TEXT(\"\"). The GetDialogSize is passed the\n// resource ID of a dialog box and returns the size of it in screen pixels\n\n#define STR_MAX_LENGTH 256\nLPTSTR WINAPI StringFromResource(__out_ecount(STR_MAX_LENGTH) LPTSTR pBuffer, int iResourceID);\n\n#ifdef UNICODE\n#define WideStringFromResource StringFromResource\nLPSTR WINAPI StringFromResource(__out_ecount(STR_MAX_LENGTH) LPSTR pBuffer, int iResourceID);\n#else\nLPWSTR WINAPI WideStringFromResource(__out_ecount(STR_MAX_LENGTH) LPWSTR pBuffer, int iResourceID);\n#endif\n\nBOOL WINAPI GetDialogSize(int iResourceID,      // Dialog box resource identifier\n                          DLGPROC pDlgProc,     // Pointer to dialog procedure\n                          LPARAM lParam,        // Any user data wanted in pDlgProc\n                          __out SIZE *pResult); // Returns the size of dialog box\n\n// Class that aggregates an IDirectDraw interface\n\nclass CAggDirectDraw\n    : public IDirectDraw\n    , public CUnknown\n{\n  protected:\n    LPDIRECTDRAW m_pDirectDraw;\n\n  public:\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    // Constructor and destructor\n\n    CAggDirectDraw(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk)\n        : CUnknown(pName, pUnk)\n        , m_pDirectDraw(NULL){};\n\n    virtual CAggDirectDraw::~CAggDirectDraw(){};\n\n    // Set the object we should be aggregating\n    void SetDirectDraw(__inout LPDIRECTDRAW pDirectDraw) { m_pDirectDraw = pDirectDraw; }\n\n    // IDirectDraw methods\n\n    STDMETHODIMP Compact();\n    STDMETHODIMP CreateClipper(DWORD dwFlags, __deref_out LPDIRECTDRAWCLIPPER *lplpDDClipper,\n                               __inout_opt IUnknown *pUnkOuter);\n    STDMETHODIMP CreatePalette(DWORD dwFlags, __in LPPALETTEENTRY lpColorTable,\n                               __deref_out LPDIRECTDRAWPALETTE *lplpDDPalette, __inout_opt IUnknown *pUnkOuter);\n    STDMETHODIMP CreateSurface(__in LPDDSURFACEDESC lpDDSurfaceDesc, __deref_out LPDIRECTDRAWSURFACE *lplpDDSurface,\n                               __inout_opt IUnknown *pUnkOuter);\n    STDMETHODIMP DuplicateSurface(__in LPDIRECTDRAWSURFACE lpDDSurface,\n                                  __deref_out LPDIRECTDRAWSURFACE *lplpDupDDSurface);\n    STDMETHODIMP EnumDisplayModes(DWORD dwSurfaceDescCount, __in LPDDSURFACEDESC lplpDDSurfaceDescList,\n                                  __in LPVOID lpContext, __in LPDDENUMMODESCALLBACK lpEnumCallback);\n    STDMETHODIMP EnumSurfaces(DWORD dwFlags, __in LPDDSURFACEDESC lpDDSD, __in LPVOID lpContext,\n                              __in LPDDENUMSURFACESCALLBACK lpEnumCallback);\n    STDMETHODIMP FlipToGDISurface();\n    STDMETHODIMP GetCaps(__out LPDDCAPS lpDDDriverCaps, __out LPDDCAPS lpDDHELCaps);\n    STDMETHODIMP GetDisplayMode(__out LPDDSURFACEDESC lpDDSurfaceDesc);\n    STDMETHODIMP GetFourCCCodes(__inout LPDWORD lpNumCodes, __out_ecount(*lpNumCodes) LPDWORD lpCodes);\n    STDMETHODIMP GetGDISurface(__deref_out LPDIRECTDRAWSURFACE *lplpGDIDDSurface);\n    STDMETHODIMP GetMonitorFrequency(__out LPDWORD lpdwFrequency);\n    STDMETHODIMP GetScanLine(__out LPDWORD lpdwScanLine);\n    STDMETHODIMP GetVerticalBlankStatus(__out LPBOOL lpblsInVB);\n    STDMETHODIMP Initialize(__in GUID *lpGUID);\n    STDMETHODIMP RestoreDisplayMode();\n    STDMETHODIMP SetCooperativeLevel(HWND hWnd, DWORD dwFlags);\n    STDMETHODIMP SetDisplayMode(DWORD dwWidth, DWORD dwHeight, DWORD dwBpp);\n    STDMETHODIMP WaitForVerticalBlank(DWORD dwFlags, HANDLE hEvent);\n};\n\n// Class that aggregates an IDirectDrawSurface interface\n\nclass CAggDrawSurface\n    : public IDirectDrawSurface\n    , public CUnknown\n{\n  protected:\n    LPDIRECTDRAWSURFACE m_pDirectDrawSurface;\n\n  public:\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv);\n\n    // Constructor and destructor\n\n    CAggDrawSurface(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk)\n        : CUnknown(pName, pUnk)\n        , m_pDirectDrawSurface(NULL){};\n\n    virtual ~CAggDrawSurface(){};\n\n    // Set the object we should be aggregating\n    void SetDirectDrawSurface(__inout LPDIRECTDRAWSURFACE pDirectDrawSurface)\n    {\n        m_pDirectDrawSurface = pDirectDrawSurface;\n    }\n\n    // IDirectDrawSurface methods\n\n    STDMETHODIMP AddAttachedSurface(__in LPDIRECTDRAWSURFACE lpDDSAttachedSurface);\n    STDMETHODIMP AddOverlayDirtyRect(__in LPRECT lpRect);\n    STDMETHODIMP Blt(__in LPRECT lpDestRect, __in LPDIRECTDRAWSURFACE lpDDSrcSurface, __in LPRECT lpSrcRect,\n                     DWORD dwFlags, __in LPDDBLTFX lpDDBltFx);\n    STDMETHODIMP BltBatch(__in_ecount(dwCount) LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags);\n    STDMETHODIMP BltFast(DWORD dwX, DWORD dwY, __in LPDIRECTDRAWSURFACE lpDDSrcSurface, __in LPRECT lpSrcRect,\n                         DWORD dwTrans);\n    STDMETHODIMP DeleteAttachedSurface(DWORD dwFlags, __in LPDIRECTDRAWSURFACE lpDDSAttachedSurface);\n    STDMETHODIMP EnumAttachedSurfaces(__in LPVOID lpContext, __in LPDDENUMSURFACESCALLBACK lpEnumSurfacesCallback);\n    STDMETHODIMP EnumOverlayZOrders(DWORD dwFlags, __in LPVOID lpContext, __in LPDDENUMSURFACESCALLBACK lpfnCallback);\n    STDMETHODIMP Flip(__in LPDIRECTDRAWSURFACE lpDDSurfaceTargetOverride, DWORD dwFlags);\n    STDMETHODIMP GetAttachedSurface(__in LPDDSCAPS lpDDSCaps, __deref_out LPDIRECTDRAWSURFACE *lplpDDAttachedSurface);\n    STDMETHODIMP GetBltStatus(DWORD dwFlags);\n    STDMETHODIMP GetCaps(__out LPDDSCAPS lpDDSCaps);\n    STDMETHODIMP GetClipper(__deref_out LPDIRECTDRAWCLIPPER *lplpDDClipper);\n    STDMETHODIMP GetColorKey(DWORD dwFlags, __out LPDDCOLORKEY lpDDColorKey);\n    STDMETHODIMP GetDC(__out HDC *lphDC);\n    STDMETHODIMP GetFlipStatus(DWORD dwFlags);\n    STDMETHODIMP GetOverlayPosition(__out LPLONG lpdwX, __out LPLONG lpdwY);\n    STDMETHODIMP GetPalette(__deref_out LPDIRECTDRAWPALETTE *lplpDDPalette);\n    STDMETHODIMP GetPixelFormat(__out LPDDPIXELFORMAT lpDDPixelFormat);\n    STDMETHODIMP GetSurfaceDesc(__out LPDDSURFACEDESC lpDDSurfaceDesc);\n    STDMETHODIMP Initialize(__in LPDIRECTDRAW lpDD, __in LPDDSURFACEDESC lpDDSurfaceDesc);\n    STDMETHODIMP IsLost();\n    STDMETHODIMP Lock(__in LPRECT lpDestRect, __inout LPDDSURFACEDESC lpDDSurfaceDesc, DWORD dwFlags, HANDLE hEvent);\n    STDMETHODIMP ReleaseDC(HDC hDC);\n    STDMETHODIMP Restore();\n    STDMETHODIMP SetClipper(__in LPDIRECTDRAWCLIPPER lpDDClipper);\n    STDMETHODIMP SetColorKey(DWORD dwFlags, __in LPDDCOLORKEY lpDDColorKey);\n    STDMETHODIMP SetOverlayPosition(LONG dwX, LONG dwY);\n    STDMETHODIMP SetPalette(__in LPDIRECTDRAWPALETTE lpDDPalette);\n    STDMETHODIMP Unlock(__in LPVOID lpSurfaceData);\n    STDMETHODIMP UpdateOverlay(__in LPRECT lpSrcRect, __in LPDIRECTDRAWSURFACE lpDDDestSurface, __in LPRECT lpDestRect,\n                               DWORD dwFlags, __in LPDDOVERLAYFX lpDDOverlayFX);\n    STDMETHODIMP UpdateOverlayDisplay(DWORD dwFlags);\n    STDMETHODIMP UpdateOverlayZOrder(DWORD dwFlags, __in LPDIRECTDRAWSURFACE lpDDSReference);\n};\n\nclass CLoadDirectDraw\n{\n    LPDIRECTDRAW m_pDirectDraw; // The DirectDraw driver instance\n    HINSTANCE m_hDirectDraw;    // Handle to the loaded library\n\n  public:\n    CLoadDirectDraw();\n    ~CLoadDirectDraw();\n\n    HRESULT LoadDirectDraw(__in LPSTR szDevice);\n    void ReleaseDirectDraw();\n    HRESULT IsDirectDrawLoaded();\n    LPDIRECTDRAW GetDirectDraw();\n    BOOL IsDirectDrawVersion1();\n};\n\n#endif // __VIDEOCTL__\n"
  },
  {
    "path": "common/baseclasses/vtrans.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: Vtrans.cpp\n//\n// Desc: DirectShow base classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <measure.h>\n// #include <vtransfr.h>         // now in precomp file streams.h\n\nCVideoTransformFilter::CVideoTransformFilter(__in_opt LPCTSTR pName, __inout_opt LPUNKNOWN pUnk, REFCLSID clsid)\n    : CTransformFilter(pName, pUnk, clsid)\n    , m_itrLate(0)\n    , m_nKeyFramePeriod(0) // No QM until we see at least 2 key frames\n    , m_nFramesSinceKeyFrame(0)\n    , m_bSkipping(FALSE)\n    , m_tDecodeStart(0)\n    , m_itrAvgDecode(300000) // 30mSec - probably allows skipping\n    , m_bQualityChanged(FALSE)\n{\n#ifdef PERF\n    RegisterPerfId();\n#endif //  PERF\n}\n\nCVideoTransformFilter::~CVideoTransformFilter()\n{\n    // nothing to do\n}\n\n// Reset our quality management state\n\nHRESULT CVideoTransformFilter::StartStreaming()\n{\n    m_itrLate = 0;\n    m_nKeyFramePeriod = 0; // No QM until we see at least 2 key frames\n    m_nFramesSinceKeyFrame = 0;\n    m_bSkipping = FALSE;\n    m_tDecodeStart = 0;\n    m_itrAvgDecode = 300000; // 30mSec - probably allows skipping\n    m_bQualityChanged = FALSE;\n    m_bSampleSkipped = FALSE;\n    return NOERROR;\n}\n\n// Overriden to reset quality management information\n\nHRESULT CVideoTransformFilter::EndFlush()\n{\n    {\n        //  Synchronize\n        CAutoLock lck(&m_csReceive);\n\n        // Reset our stats\n        //\n        // Note - we don't want to call derived classes here,\n        // we only want to reset our internal variables and this\n        // is a convenient way to do it\n        CVideoTransformFilter::StartStreaming();\n    }\n    return CTransformFilter::EndFlush();\n}\n\nHRESULT CVideoTransformFilter::AbortPlayback(HRESULT hr)\n{\n    NotifyEvent(EC_ERRORABORT, hr, 0);\n    m_pOutput->DeliverEndOfStream();\n    return hr;\n}\n\n// Receive()\n//\n// Accept a sample from upstream, decide whether to process it\n// or drop it.  If we process it then get a buffer from the\n// allocator of the downstream connection, transform it into the\n// new buffer and deliver it to the downstream filter.\n// If we decide not to process it then we do not get a buffer.\n\n// Remember that although this code will notice format changes coming into\n// the input pin, it will NOT change its output format if that results\n// in the filter needing to make a corresponding output format change.  Your\n// derived filter will have to take care of that.  (eg. a palette change if\n// the input and output is an 8 bit format).  If the input sample is discarded\n// and nothing is sent out for this Receive, please remember to put the format\n// change on the first output sample that you actually do send.\n// If your filter will produce the same output type even when the input type\n// changes, then this base class code will do everything you need.\n\nHRESULT CVideoTransformFilter::Receive(IMediaSample *pSample)\n{\n    // If the next filter downstream is the video renderer, then it may\n    // be able to operate in DirectDraw mode which saves copying the data\n    // and gives higher performance.  In that case the buffer which we\n    // get from GetDeliveryBuffer will be a DirectDraw buffer, and\n    // drawing into this buffer draws directly onto the display surface.\n    // This means that any waiting for the correct time to draw occurs\n    // during GetDeliveryBuffer, and that once the buffer is given to us\n    // the video renderer will count it in its statistics as a frame drawn.\n    // This means that any decision to drop the frame must be taken before\n    // calling GetDeliveryBuffer.\n\n    ASSERT(CritCheckIn(&m_csReceive));\n    AM_MEDIA_TYPE *pmtOut, *pmt;\n#ifdef DEBUG\n    FOURCCMap fccOut;\n#endif\n    HRESULT hr;\n    ASSERT(pSample);\n    IMediaSample *pOutSample;\n\n    // If no output pin to deliver to then no point sending us data\n    ASSERT(m_pOutput != NULL);\n\n    // The source filter may dynamically ask us to start transforming from a\n    // different media type than the one we're using now.  If we don't, we'll\n    // draw garbage. (typically, this is a palette change in the movie,\n    // but could be something more sinister like the compression type changing,\n    // or even the video size changing)\n\n#define rcS1 ((VIDEOINFOHEADER *)(pmt->pbFormat))->rcSource\n#define rcT1 ((VIDEOINFOHEADER *)(pmt->pbFormat))->rcTarget\n\n    pSample->GetMediaType(&pmt);\n    if (pmt != NULL && pmt->pbFormat != NULL)\n    {\n\n        // spew some debug output\n        ASSERT(!IsEqualGUID(pmt->majortype, GUID_NULL));\n#ifdef DEBUG\n        fccOut.SetFOURCC(&pmt->subtype);\n        LONG lCompression = HEADER(pmt->pbFormat)->biCompression;\n        LONG lBitCount = HEADER(pmt->pbFormat)->biBitCount;\n        LONG lStride = (HEADER(pmt->pbFormat)->biWidth * lBitCount + 7) / 8;\n        lStride = (lStride + 3) & ~3;\n        DbgLog((LOG_TRACE, 3, TEXT(\"*Changing input type on the fly to\")));\n        DbgLog((LOG_TRACE, 3, TEXT(\"FourCC: %lx Compression: %lx BitCount: %ld\"), fccOut.GetFOURCC(), lCompression,\n                lBitCount));\n        DbgLog((LOG_TRACE, 3, TEXT(\"biHeight: %ld rcDst: (%ld, %ld, %ld, %ld)\"), HEADER(pmt->pbFormat)->biHeight,\n                rcT1.left, rcT1.top, rcT1.right, rcT1.bottom));\n        DbgLog((LOG_TRACE, 3, TEXT(\"rcSrc: (%ld, %ld, %ld, %ld) Stride: %ld\"), rcS1.left, rcS1.top, rcS1.right,\n                rcS1.bottom, lStride));\n#endif\n\n        // now switch to using the new format.  I am assuming that the\n        // derived filter will do the right thing when its media type is\n        // switched and streaming is restarted.\n\n        StopStreaming();\n        m_pInput->CurrentMediaType() = *pmt;\n        DeleteMediaType(pmt);\n        // if this fails, playback will stop, so signal an error\n        hr = StartStreaming();\n        if (FAILED(hr))\n        {\n            return AbortPlayback(hr);\n        }\n    }\n\n    // Now that we have noticed any format changes on the input sample, it's\n    // OK to discard it.\n\n    if (ShouldSkipFrame(pSample))\n    {\n        MSR_NOTE(m_idSkip);\n        m_bSampleSkipped = TRUE;\n        return NOERROR;\n    }\n\n    // Set up the output sample\n    hr = InitializeOutputSample(pSample, &pOutSample);\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    m_bSampleSkipped = FALSE;\n\n    // The renderer may ask us to on-the-fly to start transforming to a\n    // different format.  If we don't obey it, we'll draw garbage\n\n#define rcS ((VIDEOINFOHEADER *)(pmtOut->pbFormat))->rcSource\n#define rcT ((VIDEOINFOHEADER *)(pmtOut->pbFormat))->rcTarget\n\n    pOutSample->GetMediaType(&pmtOut);\n    if (pmtOut != NULL && pmtOut->pbFormat != NULL)\n    {\n\n        // spew some debug output\n        ASSERT(!IsEqualGUID(pmtOut->majortype, GUID_NULL));\n#ifdef DEBUG\n        fccOut.SetFOURCC(&pmtOut->subtype);\n        LONG lCompression = HEADER(pmtOut->pbFormat)->biCompression;\n        LONG lBitCount = HEADER(pmtOut->pbFormat)->biBitCount;\n        LONG lStride = (HEADER(pmtOut->pbFormat)->biWidth * lBitCount + 7) / 8;\n        lStride = (lStride + 3) & ~3;\n        DbgLog((LOG_TRACE, 3, TEXT(\"*Changing output type on the fly to\")));\n        DbgLog((LOG_TRACE, 3, TEXT(\"FourCC: %lx Compression: %lx BitCount: %ld\"), fccOut.GetFOURCC(), lCompression,\n                lBitCount));\n        DbgLog((LOG_TRACE, 3, TEXT(\"biHeight: %ld rcDst: (%ld, %ld, %ld, %ld)\"), HEADER(pmtOut->pbFormat)->biHeight,\n                rcT.left, rcT.top, rcT.right, rcT.bottom));\n        DbgLog((LOG_TRACE, 3, TEXT(\"rcSrc: (%ld, %ld, %ld, %ld) Stride: %ld\"), rcS.left, rcS.top, rcS.right, rcS.bottom,\n                lStride));\n#endif\n\n        // now switch to using the new format.  I am assuming that the\n        // derived filter will do the right thing when its media type is\n        // switched and streaming is restarted.\n\n        StopStreaming();\n        m_pOutput->CurrentMediaType() = *pmtOut;\n        DeleteMediaType(pmtOut);\n        hr = StartStreaming();\n\n        if (SUCCEEDED(hr))\n        {\n            // a new format, means a new empty buffer, so wait for a keyframe\n            // before passing anything on to the renderer.\n            // !!! a keyframe may never come, so give up after 30 frames\n            DbgLog((LOG_TRACE, 3, TEXT(\"Output format change means we must wait for a keyframe\")));\n            m_nWaitForKey = 30;\n\n            // if this fails, playback will stop, so signal an error\n        }\n        else\n        {\n\n            //  Must release the sample before calling AbortPlayback\n            //  because we might be holding the win16 lock or\n            //  ddraw lock\n            pOutSample->Release();\n            AbortPlayback(hr);\n            return hr;\n        }\n    }\n\n    // After a discontinuity, we need to wait for the next key frame\n    if (pSample->IsDiscontinuity() == S_OK)\n    {\n        DbgLog((LOG_TRACE, 3, TEXT(\"Non-key discontinuity - wait for keyframe\")));\n        m_nWaitForKey = 30;\n    }\n\n    // Start timing the transform (and log it if PERF is defined)\n\n    if (SUCCEEDED(hr))\n    {\n        m_tDecodeStart = timeGetTime();\n        MSR_START(m_idTransform);\n\n        // have the derived class transform the data\n        hr = Transform(pSample, pOutSample);\n\n        // Stop the clock (and log it if PERF is defined)\n        MSR_STOP(m_idTransform);\n        m_tDecodeStart = timeGetTime() - m_tDecodeStart;\n        m_itrAvgDecode = m_tDecodeStart * (10000 / 16) + 15 * (m_itrAvgDecode / 16);\n\n        // Maybe we're waiting for a keyframe still?\n        if (m_nWaitForKey)\n            m_nWaitForKey--;\n        if (m_nWaitForKey && pSample->IsSyncPoint() == S_OK)\n            m_nWaitForKey = FALSE;\n\n        // if so, then we don't want to pass this on to the renderer\n        if (m_nWaitForKey && hr == NOERROR)\n        {\n            DbgLog((LOG_TRACE, 3, TEXT(\"still waiting for a keyframe\")));\n            hr = S_FALSE;\n        }\n    }\n\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 1, TEXT(\"Error from video transform\")));\n    }\n    else\n    {\n        // the Transform() function can return S_FALSE to indicate that the\n        // sample should not be delivered; we only deliver the sample if it's\n        // really S_OK (same as NOERROR, of course.)\n        // Try not to return S_FALSE to a direct draw buffer (it's wasteful)\n        // Try to take the decision earlier - before you get it.\n\n        if (hr == NOERROR)\n        {\n            hr = m_pOutput->Deliver(pOutSample);\n        }\n        else\n        {\n            // S_FALSE returned from Transform is a PRIVATE agreement\n            // We should return NOERROR from Receive() in this case because returning S_FALSE\n            // from Receive() means that this is the end of the stream and no more data should\n            // be sent.\n            if (S_FALSE == hr)\n            {\n\n                //  We must Release() the sample before doing anything\n                //  like calling the filter graph because having the\n                //  sample means we may have the DirectDraw lock\n                //  (== win16 lock on some versions)\n                pOutSample->Release();\n                m_bSampleSkipped = TRUE;\n                if (!m_bQualityChanged)\n                {\n                    m_bQualityChanged = TRUE;\n                    NotifyEvent(EC_QUALITY_CHANGE, 0, 0);\n                }\n                return NOERROR;\n            }\n        }\n    }\n\n    // release the output buffer. If the connected pin still needs it,\n    // it will have addrefed it itself.\n    pOutSample->Release();\n    ASSERT(CritCheckIn(&m_csReceive));\n\n    return hr;\n}\n\nBOOL CVideoTransformFilter::ShouldSkipFrame(IMediaSample *pIn)\n{\n    REFERENCE_TIME trStart, trStopAt;\n    HRESULT hr = pIn->GetTime(&trStart, &trStopAt);\n\n    // Don't skip frames with no timestamps\n    if (hr != S_OK)\n        return FALSE;\n\n    int itrFrame = (int)(trStopAt - trStart); // frame duration\n\n    if (S_OK == pIn->IsSyncPoint())\n    {\n        MSR_INTEGER(m_idFrameType, 1);\n        if (m_nKeyFramePeriod < m_nFramesSinceKeyFrame)\n        {\n            // record the max\n            m_nKeyFramePeriod = m_nFramesSinceKeyFrame;\n        }\n        m_nFramesSinceKeyFrame = 0;\n        m_bSkipping = FALSE;\n    }\n    else\n    {\n        MSR_INTEGER(m_idFrameType, 2);\n        if (m_nFramesSinceKeyFrame > m_nKeyFramePeriod && m_nKeyFramePeriod > 0)\n        {\n            // We haven't seen the key frame yet, but we were clearly being\n            // overoptimistic about how frequent they are.\n            m_nKeyFramePeriod = m_nFramesSinceKeyFrame;\n        }\n    }\n\n    // Whatever we might otherwise decide,\n    // if we are taking only a small fraction of the required frame time to decode\n    // then any quality problems are actually coming from somewhere else.\n    // Could be a net problem at the source for instance.  In this case there's\n    // no point in us skipping frames here.\n    if (m_itrAvgDecode * 4 > itrFrame)\n    {\n\n        // Don't skip unless we are at least a whole frame late.\n        // (We would skip B frames if more than 1/2 frame late, but they're safe).\n        if (m_itrLate > itrFrame)\n        {\n\n            // Don't skip unless the anticipated key frame would be no more than\n            // 1 frame early.  If the renderer has not been waiting (we *guess*\n            // it hasn't because we're late) then it will allow frames to be\n            // played early by up to a frame.\n\n            // Let T = Stream time from now to anticipated next key frame\n            // = (frame duration) * (KeyFramePeriod - FramesSinceKeyFrame)\n            // So we skip if T - Late < one frame  i.e.\n            //   (duration) * (freq - FramesSince) - Late < duration\n            // or (duration) * (freq - FramesSince - 1) < Late\n\n            // We don't dare skip until we have seen some key frames and have\n            // some idea how often they occur and they are reasonably frequent.\n            if (m_nKeyFramePeriod > 0)\n            {\n                // It would be crazy - but we could have a stream with key frames\n                // a very long way apart - and if they are further than about\n                // 3.5 minutes apart then we could get arithmetic overflow in\n                // reference time units.  Therefore we switch to mSec at this point\n                int it = (itrFrame / 10000) * (m_nKeyFramePeriod - m_nFramesSinceKeyFrame - 1);\n                MSR_INTEGER(m_idTimeTillKey, it);\n\n                // For debug - might want to see the details - dump them as scratch pad\n#ifdef VTRANSPERF\n                MSR_INTEGER(0, itrFrame);\n                MSR_INTEGER(0, m_nFramesSinceKeyFrame);\n                MSR_INTEGER(0, m_nKeyFramePeriod);\n#endif\n                if (m_itrLate / 10000 > it)\n                {\n                    m_bSkipping = TRUE;\n                    // Now we are committed.  Once we start skipping, we\n                    // cannot stop until we hit a key frame.\n                }\n                else\n                {\n#ifdef VTRANSPERF\n                    MSR_INTEGER(0, 777770); // not near enough to next key\n#endif\n                }\n            }\n            else\n            {\n#ifdef VTRANSPERF\n                MSR_INTEGER(0, 777771); // Next key not predictable\n#endif\n            }\n        }\n        else\n        {\n#ifdef VTRANSPERF\n            MSR_INTEGER(0, 777772); // Less than one frame late\n            MSR_INTEGER(0, m_itrLate);\n            MSR_INTEGER(0, itrFrame);\n#endif\n        }\n    }\n    else\n    {\n#ifdef VTRANSPERF\n        MSR_INTEGER(0, 777773); // Decode time short - not not worth skipping\n        MSR_INTEGER(0, m_itrAvgDecode);\n        MSR_INTEGER(0, itrFrame);\n#endif\n    }\n\n    ++m_nFramesSinceKeyFrame;\n\n    if (m_bSkipping)\n    {\n        // We will count down the lateness as we skip each frame.\n        // We re-assess each frame.  The key frame might not arrive when expected.\n        // We reset m_itrLate if we get a new Quality message, but actually that's\n        // not likely because we're not sending frames on to the Renderer.  In\n        // fact if we DID get another one it would mean that there's a long\n        // pipe between us and the renderer and we might need an altogether\n        // better strategy to avoid hunting!\n        m_itrLate = m_itrLate - itrFrame;\n    }\n\n    MSR_INTEGER(m_idLate, (int)m_itrLate / 10000); // Note how late we think we are\n    if (m_bSkipping)\n    {\n        if (!m_bQualityChanged)\n        {\n            m_bQualityChanged = TRUE;\n            NotifyEvent(EC_QUALITY_CHANGE, 0, 0);\n        }\n    }\n    return m_bSkipping;\n}\n\nHRESULT CVideoTransformFilter::AlterQuality(Quality q)\n{\n    // to reduce the amount of 64 bit arithmetic, m_itrLate is an int.\n    // +, -, >, == etc  are not too bad, but * and / are painful.\n    if (m_itrLate > 300000000)\n    {\n        // Avoid overflow and silliness - more than 30 secs late is already silly\n        m_itrLate = 300000000;\n    }\n    else\n    {\n        m_itrLate = (int)q.Late;\n    }\n    // We ignore the other fields\n\n    // We're actually not very good at handling this.  In non-direct draw mode\n    // most of the time can be spent in the renderer which can skip any frame.\n    // In that case we'd rather the renderer handled things.\n    // Nevertheless we will keep an eye on it and if we really start getting\n    // a very long way behind then we will actually skip - but we'll still tell\n    // the renderer (or whoever is downstream) that they should handle quality.\n\n    return E_FAIL; // Tell the renderer to do his thing.\n}\n\n// This will avoid several hundred useless warnings if compiled -W4 by MS VC++ v4\n#pragma warning(disable : 4514)\n"
  },
  {
    "path": "common/baseclasses/vtrans.h",
    "content": "//------------------------------------------------------------------------------\n// File: VTrans.h\n//\n// Desc: DirectShow base classes - defines a video transform class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// This class is derived from CTransformFilter, but is specialised to handle\n// the requirements of video quality control by frame dropping.\n// This is a non-in-place transform, (i.e. it copies the data) such as a decoder.\n\nclass CVideoTransformFilter : public CTransformFilter\n{\n  public:\n    CVideoTransformFilter(__in_opt LPCTSTR, __inout_opt LPUNKNOWN, REFCLSID clsid);\n    ~CVideoTransformFilter();\n    HRESULT EndFlush();\n\n    // =================================================================\n    // ----- override these bits ---------------------------------------\n    // =================================================================\n    // The following methods are in CTransformFilter which is inherited.\n    // They are mentioned here for completeness\n    //\n    // These MUST be supplied in a derived class\n    //\n    // NOTE:\n    // virtual HRESULT Transform(IMediaSample * pIn, IMediaSample *pOut);\n    // virtual HRESULT CheckInputType(const CMediaType* mtIn) PURE;\n    // virtual HRESULT CheckTransform\n    //     (const CMediaType* mtIn, const CMediaType* mtOut) PURE;\n    // static CCOMObject * CreateInstance(LPUNKNOWN, HRESULT *);\n    // virtual HRESULT DecideBufferSize\n    //     (IMemAllocator * pAllocator, ALLOCATOR_PROPERTIES *pprop) PURE;\n    // virtual HRESULT GetMediaType(int iPosition, CMediaType *pMediaType) PURE;\n    //\n    // These MAY also be overridden\n    //\n    // virtual HRESULT StopStreaming();\n    // virtual HRESULT SetMediaType(PIN_DIRECTION direction,const CMediaType *pmt);\n    // virtual HRESULT CheckConnect(PIN_DIRECTION dir,IPin *pPin);\n    // virtual HRESULT BreakConnect(PIN_DIRECTION dir);\n    // virtual HRESULT CompleteConnect(PIN_DIRECTION direction,IPin *pReceivePin);\n    // virtual HRESULT EndOfStream(void);\n    // virtual HRESULT BeginFlush(void);\n    // virtual HRESULT EndFlush(void);\n    // virtual HRESULT NewSegment\n    //     (REFERENCE_TIME tStart,REFERENCE_TIME tStop,double dRate);\n#ifdef PERF\n\n    // If you override this - ensure that you register all these ids\n    // as well as any of your own,\n    virtual void RegisterPerfId()\n    {\n        m_idSkip = MSR_REGISTER(TEXT(\"Video Transform Skip frame\"));\n        m_idFrameType = MSR_REGISTER(TEXT(\"Video transform frame type\"));\n        m_idLate = MSR_REGISTER(TEXT(\"Video Transform Lateness\"));\n        m_idTimeTillKey = MSR_REGISTER(TEXT(\"Video Transform Estd. time to next key\"));\n        CTransformFilter::RegisterPerfId();\n    }\n#endif\n\n  protected:\n    // =========== QUALITY MANAGEMENT IMPLEMENTATION ========================\n    // Frames are assumed to come in three types:\n    // Type 1: an AVI key frame or an MPEG I frame.\n    //        This frame can be decoded with no history.\n    //        Dropping this frame means that no further frame can be decoded\n    //        until the next type 1 frame.\n    //        Type 1 frames are sync points.\n    // Type 2: an AVI non-key frame or an MPEG P frame.\n    //        This frame cannot be decoded unless the previous type 1 frame was\n    //        decoded and all type 2 frames since have been decoded.\n    //        Dropping this frame means that no further frame can be decoded\n    //        until the next type 1 frame.\n    // Type 3: An MPEG B frame.\n    //        This frame cannot be decoded unless the previous type 1 or 2 frame\n    //        has been decoded AND the subsequent type 1 or 2 frame has also\n    //        been decoded.  (This requires decoding the frames out of sequence).\n    //        Dropping this frame affects no other frames.  This implementation\n    //        does not allow for these.  All non-sync-point frames are treated\n    //        as being type 2.\n    //\n    // The spacing of frames of type 1 in a file is not guaranteed.  There MUST\n    // be a type 1 frame at (well, near) the start of the file in order to start\n    // decoding at all.  After that there could be one every half second or so,\n    // there could be one at the start of each scene (aka \"cut\", \"shot\") or\n    // there could be no more at all.\n    // If there is only a single type 1 frame then NO FRAMES CAN BE DROPPED\n    // without losing all the rest of the movie.  There is no way to tell whether\n    // this is the case, so we find that we are in the gambling business.\n    // To try to improve the odds, we record the greatest interval between type 1s\n    // that we have seen and we bet on things being no worse than this in the\n    // future.\n\n    // You can tell if it's a type 1 frame by calling IsSyncPoint().\n    // there is no architected way to test for a type 3, so you should override\n    // the quality management here if you have B-frames.\n\n    int m_nKeyFramePeriod; // the largest observed interval between type 1 frames\n                           // 1 means every frame is type 1, 2 means every other.\n\n    int m_nFramesSinceKeyFrame; // Used to count frames since the last type 1.\n                                // becomes the new m_nKeyFramePeriod if greater.\n\n    BOOL m_bSkipping; // we are skipping to the next type 1 frame\n\n#ifdef PERF\n    int m_idFrameType;   // MSR id Frame type.  1=Key, 2=\"non-key\"\n    int m_idSkip;        // MSR id skipping\n    int m_idLate;        // MSR id lateness\n    int m_idTimeTillKey; // MSR id for guessed time till next key frame.\n#endif\n\n    virtual HRESULT StartStreaming();\n\n    HRESULT AbortPlayback(HRESULT hr); // if something bad happens\n\n    HRESULT Receive(IMediaSample *pSample);\n\n    HRESULT AlterQuality(Quality q);\n\n    BOOL ShouldSkipFrame(IMediaSample *pIn);\n\n    int m_itrLate;      // lateness from last Quality message\n                        // (this overflows at 214 secs late).\n    int m_tDecodeStart; // timeGetTime when decode started.\n    int m_itrAvgDecode; // Average decode time in reference units.\n\n    BOOL m_bNoSkip; // debug - no skipping.\n\n    // We send an EC_QUALITY_CHANGE notification to the app if we have to degrade.\n    // We send one when we start degrading, not one for every frame, this means\n    // we track whether we've sent one yet.\n    BOOL m_bQualityChanged;\n\n    // When non-zero, don't pass anything to renderer until next keyframe\n    // If there are few keys, give up and eventually draw something\n    int m_nWaitForKey;\n};\n"
  },
  {
    "path": "common/baseclasses/winctrl.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: WinCtrl.cpp\n//\n// Desc: DirectShow base classes - implements video control interface class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <intsafe.h>\n#include <checkbmi.h>\n\n// The control interface methods require us to be connected\n\n#define CheckConnected(pin, code)             \\\n    {                                         \\\n        if (pin == NULL)                      \\\n        {                                     \\\n            ASSERT(!TEXT(\"Pin not set\"));     \\\n        }                                     \\\n        else if (pin->IsConnected() == FALSE) \\\n        {                                     \\\n            return (code);                    \\\n        }                                     \\\n    }\n\n// This checks to see whether the window has a drain. An application can in\n// most environments set the owner/parent of windows so that they appear in\n// a compound document context (for example). In this case, the application\n// would probably like to be told of any keyboard/mouse messages. Therefore\n// we pass these messages on untranslated, returning TRUE if we're successful\n\nBOOL WINAPI PossiblyEatMessage(HWND hwndDrain, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    if (hwndDrain != NULL && !InSendMessage())\n    {\n        switch (uMsg)\n        {\n        case WM_CHAR:\n        case WM_DEADCHAR:\n        case WM_KEYDOWN:\n        case WM_KEYUP:\n        case WM_LBUTTONDBLCLK:\n        case WM_LBUTTONDOWN:\n        case WM_LBUTTONUP:\n        case WM_MBUTTONDBLCLK:\n        case WM_MBUTTONDOWN:\n        case WM_MBUTTONUP:\n        case WM_MOUSEACTIVATE:\n        case WM_MOUSEMOVE:\n        // If we pass this on we don't get any mouse clicks\n        // case WM_NCHITTEST:\n        case WM_NCLBUTTONDBLCLK:\n        case WM_NCLBUTTONDOWN:\n        case WM_NCLBUTTONUP:\n        case WM_NCMBUTTONDBLCLK:\n        case WM_NCMBUTTONDOWN:\n        case WM_NCMBUTTONUP:\n        case WM_NCMOUSEMOVE:\n        case WM_NCRBUTTONDBLCLK:\n        case WM_NCRBUTTONDOWN:\n        case WM_NCRBUTTONUP:\n        case WM_RBUTTONDBLCLK:\n        case WM_RBUTTONDOWN:\n        case WM_RBUTTONUP:\n        case WM_SYSCHAR:\n        case WM_SYSDEADCHAR:\n        case WM_SYSKEYDOWN:\n        case WM_SYSKEYUP:\n\n            DbgLog((LOG_TRACE, 2, TEXT(\"Forwarding %x to drain\")));\n            PostMessage(hwndDrain, uMsg, wParam, lParam);\n\n            return TRUE;\n        }\n    }\n    return FALSE;\n}\n\n// This class implements the IVideoWindow control functions (dual interface)\n// we support a large number of properties and methods designed to allow the\n// client (whether it be an automation controller or a C/C++ application) to\n// set and get a number of window related properties such as it's position.\n// We also support some methods that duplicate the properties but provide a\n// more direct and efficient mechanism as many values may be changed in one\n\nCBaseControlWindow::CBaseControlWindow(__inout CBaseFilter *pFilter,  // Owning filter\n                                       __in CCritSec *pInterfaceLock, // Locking object\n                                       __in_opt LPCTSTR pName,        // Object description\n                                       __inout_opt LPUNKNOWN pUnk,    // Normal COM ownership\n                                       __inout HRESULT *phr)\n    : // OLE return code\n\n    CBaseVideoWindow(pName, pUnk)\n    , m_pInterfaceLock(pInterfaceLock)\n    , m_hwndOwner(NULL)\n    , m_hwndDrain(NULL)\n    , m_bAutoShow(TRUE)\n    , m_pFilter(pFilter)\n    , m_bCursorHidden(FALSE)\n    , m_pPin(NULL)\n{\n    ASSERT(m_pFilter);\n    ASSERT(m_pInterfaceLock);\n    ASSERT(phr);\n    m_BorderColour = VIDEO_COLOUR;\n}\n\n// Set the title caption on the base window, we don't do any field checking\n// as we really don't care what title they intend to have. We can always get\n// it back again later with GetWindowText. The only other complication is to\n// do the necessary string conversions between ANSI and OLE Unicode strings\n\nSTDMETHODIMP CBaseControlWindow::put_Caption(__in BSTR strCaption)\n{\n    CheckPointer((PVOID)strCaption, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n#ifdef UNICODE\n    SetWindowText(m_hwnd, strCaption);\n#else\n    CHAR Caption[CAPTION];\n\n    WideCharToMultiByte(CP_ACP, 0, strCaption, -1, Caption, CAPTION, NULL, NULL);\n    SetWindowText(m_hwnd, Caption);\n#endif\n    return NOERROR;\n}\n\n// Get the current base window title caption, once again we do no real field\n// checking. We allocate a string for the window title to be filled in with\n// which ensures the interface doesn't fiddle around with getting memory. A\n// BSTR is a normal C string with the length at position (-1), we use the\n// WriteBSTR helper function to create the caption to try and avoid OLE32\n\nSTDMETHODIMP CBaseControlWindow::get_Caption(__out BSTR *pstrCaption)\n{\n    CheckPointer(pstrCaption, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    WCHAR WideCaption[CAPTION];\n\n#ifdef UNICODE\n    GetWindowText(m_hwnd, WideCaption, CAPTION);\n#else\n    // Convert the ASCII caption to a UNICODE string\n\n    TCHAR Caption[CAPTION];\n    GetWindowText(m_hwnd, Caption, CAPTION);\n    MultiByteToWideChar(CP_ACP, 0, Caption, -1, WideCaption, CAPTION);\n#endif\n    return WriteBSTR(pstrCaption, WideCaption);\n}\n\n// Set the window style using GWL_EXSTYLE\n\nSTDMETHODIMP CBaseControlWindow::put_WindowStyleEx(long WindowStyleEx)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n\n    // Should we be taking off WS_EX_TOPMOST\n\n    if (GetWindowLong(m_hwnd, GWL_EXSTYLE) & WS_EX_TOPMOST)\n    {\n        if ((WindowStyleEx & WS_EX_TOPMOST) == 0)\n        {\n            SendMessage(m_hwnd, m_ShowStageTop, (WPARAM)FALSE, (LPARAM)0);\n        }\n    }\n\n    // Likewise should we be adding WS_EX_TOPMOST\n\n    if (WindowStyleEx & WS_EX_TOPMOST)\n    {\n        SendMessage(m_hwnd, m_ShowStageTop, (WPARAM)TRUE, (LPARAM)0);\n        WindowStyleEx &= (~WS_EX_TOPMOST);\n        if (WindowStyleEx == 0)\n            return NOERROR;\n    }\n    return DoSetWindowStyle(WindowStyleEx, GWL_EXSTYLE);\n}\n\n// Gets the current GWL_EXSTYLE base window style\n\nSTDMETHODIMP CBaseControlWindow::get_WindowStyleEx(__out long *pWindowStyleEx)\n{\n    CheckPointer(pWindowStyleEx, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    return DoGetWindowStyle(pWindowStyleEx, GWL_EXSTYLE);\n}\n\n// Set the window style using GWL_STYLE\n\nSTDMETHODIMP CBaseControlWindow::put_WindowStyle(long WindowStyle)\n{\n    // These styles cannot be changed dynamically\n\n    if ((WindowStyle & WS_DISABLED) || (WindowStyle & WS_ICONIC) || (WindowStyle & WS_MAXIMIZE) ||\n        (WindowStyle & WS_MINIMIZE) || (WindowStyle & WS_HSCROLL) || (WindowStyle & WS_VSCROLL))\n    {\n\n        return E_INVALIDARG;\n    }\n\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    return DoSetWindowStyle(WindowStyle, GWL_STYLE);\n}\n\n// Get the current GWL_STYLE base window style\n\nSTDMETHODIMP CBaseControlWindow::get_WindowStyle(__out long *pWindowStyle)\n{\n    CheckPointer(pWindowStyle, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    return DoGetWindowStyle(pWindowStyle, GWL_STYLE);\n}\n\n// Change the base window style or the extended styles depending on whether\n// WindowLong is GWL_STYLE or GWL_EXSTYLE. We must call SetWindowPos to have\n// the window displayed in it's new style after the change which is a little\n// tricky if the window is not currently visible as we realise it offscreen.\n// In most cases the client will call get_WindowStyle before they call this\n// and then AND and OR in extra bit settings according to the requirements\n\nHRESULT CBaseControlWindow::DoSetWindowStyle(long Style, long WindowLong)\n{\n    RECT WindowRect;\n\n    // Get the window's visibility before setting the style\n    BOOL bVisible = IsWindowVisible(m_hwnd);\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n\n    // Set the new style flags for the window\n    SetWindowLong(m_hwnd, WindowLong, Style);\n    UINT WindowFlags = SWP_SHOWWINDOW | SWP_FRAMECHANGED | SWP_NOACTIVATE;\n    WindowFlags |= SWP_NOZORDER | SWP_NOSIZE | SWP_NOMOVE;\n\n    // Show the window again in the current position\n\n    if (bVisible == TRUE)\n    {\n\n        SetWindowPos(m_hwnd,       // Base window handle\n                     HWND_TOP,     // Just a place holder\n                     0, 0, 0, 0,   // Leave size and position\n                     WindowFlags); // Just draw it again\n\n        return NOERROR;\n    }\n\n    // Move the window offscreen so the user doesn't see the changes\n\n    MoveWindow((HWND)m_hwnd,                  // Base window handle\n               GetSystemMetrics(SM_CXSCREEN), // Current desktop width\n               GetSystemMetrics(SM_CYSCREEN), // Likewise it's height\n               WIDTH(&WindowRect),            // Use the same width\n               HEIGHT(&WindowRect),           // Keep height same to\n               TRUE);                         // May as well repaint\n\n    // Now show the previously hidden window\n\n    SetWindowPos(m_hwnd,       // Base window handle\n                 HWND_TOP,     // Just a place holder\n                 0, 0, 0, 0,   // Leave size and position\n                 WindowFlags); // Just draw it again\n\n    ShowWindow(m_hwnd, SW_HIDE);\n\n    if (GetParent(m_hwnd))\n    {\n\n        MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);\n    }\n\n    MoveWindow((HWND)m_hwnd,        // Base window handle\n               WindowRect.left,     // Existing x coordinate\n               WindowRect.top,      // Existing y coordinate\n               WIDTH(&WindowRect),  // Use the same width\n               HEIGHT(&WindowRect), // Keep height same to\n               TRUE);               // May as well repaint\n\n    return NOERROR;\n}\n\n// Get the current base window style (either GWL_STYLE or GWL_EXSTYLE)\n\nHRESULT CBaseControlWindow::DoGetWindowStyle(__out long *pStyle, long WindowLong)\n{\n    *pStyle = GetWindowLong(m_hwnd, WindowLong);\n    return NOERROR;\n}\n\n// Change the visibility of the base window, this takes the same parameters\n// as the ShowWindow Win32 API does, so the client can have the window hidden\n// or shown, minimised to an icon, or maximised to play in full screen mode\n// We pass the request on to the base window to actually make the change\n\nSTDMETHODIMP CBaseControlWindow::put_WindowState(long WindowState)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    DoShowWindow(WindowState);\n    return NOERROR;\n}\n\n// Get the current window state, this function returns a subset of the SW bit\n// settings available in ShowWindow, if the window is visible then SW_SHOW is\n// set, if it is hidden then the SW_HIDDEN is set, if it is either minimised\n// or maximised then the SW_MINIMIZE or SW_MAXIMIZE is set respectively. The\n// other SW bit settings are really set commands not readable output values\n\nSTDMETHODIMP CBaseControlWindow::get_WindowState(__out long *pWindowState)\n{\n    CheckPointer(pWindowState, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    ASSERT(pWindowState);\n    *pWindowState = FALSE;\n\n    // Is the window visible, a window is termed visible if it is somewhere on\n    // the current desktop even if it is completely obscured by other windows\n    // so the flag is a style for each window set with the WS_VISIBLE bit\n\n    if (IsWindowVisible(m_hwnd) == TRUE)\n    {\n\n        // Is the base window iconic\n        if (IsIconic(m_hwnd) == TRUE)\n        {\n            *pWindowState |= SW_MINIMIZE;\n        }\n\n        // Has the window been maximised\n        else if (IsZoomed(m_hwnd) == TRUE)\n        {\n            *pWindowState |= SW_MAXIMIZE;\n        }\n\n        // Window is normal\n        else\n        {\n            *pWindowState |= SW_SHOW;\n        }\n    }\n    else\n    {\n        *pWindowState |= SW_HIDE;\n    }\n    return NOERROR;\n}\n\n// This makes sure that any palette we realise in the base window (through a\n// media type or through the overlay interface) is done in the background and\n// is therefore mapped to existing device entries rather than taking it over\n// as it will do when we this window gets the keyboard focus. An application\n// uses this to make sure it doesn't have it's palette removed by the window\n\nSTDMETHODIMP CBaseControlWindow::put_BackgroundPalette(long BackgroundPalette)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cWindowLock(&m_WindowLock);\n\n    // Check this is a valid automation boolean type\n\n    if (BackgroundPalette != OATRUE)\n    {\n        if (BackgroundPalette != OAFALSE)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    // Make sure the window realises any palette it has again\n\n    m_bBackground = (BackgroundPalette == OATRUE ? TRUE : FALSE);\n    PostMessage(m_hwnd, m_RealizePalette, 0, 0);\n    PaintWindow(FALSE);\n\n    return NOERROR;\n}\n\n// This returns the current background realisation setting\n\nSTDMETHODIMP\nCBaseControlWindow::get_BackgroundPalette(__out long *pBackgroundPalette)\n{\n    CheckPointer(pBackgroundPalette, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cWindowLock(&m_WindowLock);\n\n    // Get the current background palette setting\n\n    *pBackgroundPalette = (m_bBackground == TRUE ? OATRUE : OAFALSE);\n    return NOERROR;\n}\n\n// Change the visibility of the base window\n\nSTDMETHODIMP CBaseControlWindow::put_Visible(long Visible)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n\n    // Check this is a valid automation boolean type\n\n    if (Visible != OATRUE)\n    {\n        if (Visible != OAFALSE)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    // Convert the boolean visibility into SW_SHOW and SW_HIDE\n\n    INT Mode = (Visible == OATRUE ? SW_SHOWNORMAL : SW_HIDE);\n    DoShowWindow(Mode);\n    return NOERROR;\n}\n\n// Return OATRUE if the window is currently visible otherwise OAFALSE\n\nSTDMETHODIMP CBaseControlWindow::get_Visible(__out long *pVisible)\n{\n    CheckPointer(pVisible, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n\n    // See if the base window has a WS_VISIBLE style - this will return TRUE\n    // even if the window is completely obscured by other desktop windows, we\n    // return FALSE if the window is not showing because of earlier calls\n\n    BOOL Mode = IsWindowVisible(m_hwnd);\n    *pVisible = (Mode == TRUE ? OATRUE : OAFALSE);\n    return NOERROR;\n}\n\n// Change the left position of the base window. This keeps the window width\n// and height properties the same so it effectively shunts the window left or\n// right accordingly - there is the Width property to change that dimension\n\nSTDMETHODIMP CBaseControlWindow::put_Left(long Left)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    BOOL bSuccess;\n    RECT WindowRect;\n\n    // Get the current window position in a RECT\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n\n    if (GetParent(m_hwnd))\n    {\n\n        MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);\n    }\n\n    // Adjust the coordinates ready for SetWindowPos, the window rectangle we\n    // get back from GetWindowRect is in left,top,right and bottom while the\n    // coordinates SetWindowPos wants are left,top,width and height values\n\n    WindowRect.bottom = WindowRect.bottom - WindowRect.top;\n    WindowRect.right = WindowRect.right - WindowRect.left;\n    UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;\n\n    bSuccess = SetWindowPos(m_hwnd,            // Window handle\n                            HWND_TOP,          // Put it at the top\n                            Left,              // New left position\n                            WindowRect.top,    // Leave top alone\n                            WindowRect.right,  // The WIDTH (not right)\n                            WindowRect.bottom, // The HEIGHT (not bottom)\n                            WindowFlags);      // Show window options\n\n    if (bSuccess == FALSE)\n    {\n        return E_INVALIDARG;\n    }\n    return NOERROR;\n}\n\n// Return the current base window left position\n\nSTDMETHODIMP CBaseControlWindow::get_Left(__out long *pLeft)\n{\n    CheckPointer(pLeft, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    RECT WindowRect;\n\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n    *pLeft = WindowRect.left;\n    return NOERROR;\n}\n\n// Change the current width of the base window. This property complements the\n// left position property so we must keep the left edge constant and expand or\n// contract to the right, the alternative would be to change the left edge so\n// keeping the right edge constant but this is maybe a little more intuitive\n\nSTDMETHODIMP CBaseControlWindow::put_Width(long Width)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    BOOL bSuccess;\n    RECT WindowRect;\n\n    // Adjust the coordinates ready for SetWindowPos, the window rectangle we\n    // get back from GetWindowRect is in left,top,right and bottom while the\n    // coordinates SetWindowPos wants are left,top,width and height values\n\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n\n    if (GetParent(m_hwnd))\n    {\n\n        MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);\n    }\n\n    WindowRect.bottom = WindowRect.bottom - WindowRect.top;\n    UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;\n\n    // This seems to have a bug in that calling SetWindowPos on a window with\n    // just the width changing causes it to ignore the width that you pass in\n    // and sets it to a mimimum value of 110 pixels wide (Windows NT 3.51)\n\n    bSuccess = SetWindowPos(m_hwnd,            // Window handle\n                            HWND_TOP,          // Put it at the top\n                            WindowRect.left,   // Leave left alone\n                            WindowRect.top,    // Leave top alone\n                            Width,             // New WIDTH dimension\n                            WindowRect.bottom, // The HEIGHT (not bottom)\n                            WindowFlags);      // Show window options\n\n    if (bSuccess == FALSE)\n    {\n        return E_INVALIDARG;\n    }\n    return NOERROR;\n}\n\n// Return the current base window width\n\nSTDMETHODIMP CBaseControlWindow::get_Width(__out long *pWidth)\n{\n    CheckPointer(pWidth, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    RECT WindowRect;\n\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n    *pWidth = WindowRect.right - WindowRect.left;\n    return NOERROR;\n}\n\n// This allows the client program to change the top position for the window in\n// the same way that changing the left position does not affect the width of\n// the image so changing the top position does not affect the window height\n\nSTDMETHODIMP CBaseControlWindow::put_Top(long Top)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    BOOL bSuccess;\n    RECT WindowRect;\n\n    // Get the current window position in a RECT\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n\n    if (GetParent(m_hwnd))\n    {\n\n        MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);\n    }\n\n    // Adjust the coordinates ready for SetWindowPos, the window rectangle we\n    // get back from GetWindowRect is in left,top,right and bottom while the\n    // coordinates SetWindowPos wants are left,top,width and height values\n\n    WindowRect.bottom = WindowRect.bottom - WindowRect.top;\n    WindowRect.right = WindowRect.right - WindowRect.left;\n    UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;\n\n    bSuccess = SetWindowPos(m_hwnd,            // Window handle\n                            HWND_TOP,          // Put it at the top\n                            WindowRect.left,   // Leave left alone\n                            Top,               // New top position\n                            WindowRect.right,  // The WIDTH (not right)\n                            WindowRect.bottom, // The HEIGHT (not bottom)\n                            WindowFlags);      // Show window flags\n\n    if (bSuccess == FALSE)\n    {\n        return E_INVALIDARG;\n    }\n    return NOERROR;\n}\n\n// Return the current base window top position\n\nSTDMETHODIMP CBaseControlWindow::get_Top(long *pTop)\n{\n    CheckPointer(pTop, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    RECT WindowRect;\n\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n    *pTop = WindowRect.top;\n    return NOERROR;\n}\n\n// Change the height of the window, this complements the top property so when\n// we change this we must keep the top position for the base window, as said\n// before we could keep the bottom and grow upwards although this is perhaps\n// a little more intuitive since we already have a top position property\n\nSTDMETHODIMP CBaseControlWindow::put_Height(long Height)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    BOOL bSuccess;\n    RECT WindowRect;\n\n    // Adjust the coordinates ready for SetWindowPos, the window rectangle we\n    // get back from GetWindowRect is in left,top,right and bottom while the\n    // coordinates SetWindowPos wants are left,top,width and height values\n\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n\n    if (GetParent(m_hwnd))\n    {\n\n        MapWindowPoints(HWND_DESKTOP, GetParent(m_hwnd), (LPPOINT)&WindowRect, 2);\n    }\n\n    WindowRect.right = WindowRect.right - WindowRect.left;\n    UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;\n\n    bSuccess = SetWindowPos(m_hwnd,           // Window handle\n                            HWND_TOP,         // Put it at the top\n                            WindowRect.left,  // Leave left alone\n                            WindowRect.top,   // Leave top alone\n                            WindowRect.right, // The WIDTH (not right)\n                            Height,           // New height dimension\n                            WindowFlags);     // Show window flags\n\n    if (bSuccess == FALSE)\n    {\n        return E_INVALIDARG;\n    }\n    return NOERROR;\n}\n\n// Return the current base window height\n\nSTDMETHODIMP CBaseControlWindow::get_Height(__out long *pHeight)\n{\n    CheckPointer(pHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    RECT WindowRect;\n\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n    *pHeight = WindowRect.bottom - WindowRect.top;\n    return NOERROR;\n}\n\n// This can be called to change the owning window. Setting the owner is done\n// through this function, however to make the window a true child window the\n// style must also be set to WS_CHILD. After resetting the owner to NULL an\n// application should also set the style to WS_OVERLAPPED | WS_CLIPCHILDREN.\n\n// We cannot lock the object here because the SetParent causes an interthread\n// SendMessage to the owner window. If they are in GetState we will sit here\n// incomplete with the critical section locked therefore blocking out source\n// filter threads from accessing us. Because the source thread can't enter us\n// it can't get buffers or call EndOfStream so the GetState will not complete\n\nSTDMETHODIMP CBaseControlWindow::put_Owner(OAHWND Owner)\n{\n    // Check we are connected otherwise reject the call\n\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    m_hwndOwner = (HWND)Owner;\n    HWND hwndParent = m_hwndOwner;\n\n    // Add or remove WS_CHILD as appropriate\n\n    LONG Style = GetWindowLong(m_hwnd, GWL_STYLE);\n    if (Owner == NULL)\n    {\n        Style &= (~WS_CHILD);\n    }\n    else\n    {\n        Style |= (WS_CHILD);\n    }\n    SetWindowLong(m_hwnd, GWL_STYLE, Style);\n\n    // Don't call this with the filter locked\n\n    SetParent(m_hwnd, hwndParent);\n\n    PaintWindow(TRUE);\n    NOTE1(\"Changed parent %lx\", hwndParent);\n\n    return NOERROR;\n}\n\n// This complements the put_Owner to get the current owning window property\n// we always return NOERROR although the returned window handle may be NULL\n// to indicate no owning window (the desktop window doesn't qualify as one)\n// If an application sets the owner we call SetParent, however that returns\n// NULL until the WS_CHILD bit is set on, so we store the owner internally\n\nSTDMETHODIMP CBaseControlWindow::get_Owner(__out OAHWND *Owner)\n{\n    CheckPointer(Owner, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    *Owner = (OAHWND)m_hwndOwner;\n    return NOERROR;\n}\n\n// And renderer supporting IVideoWindow may have an HWND set who will get any\n// keyboard and mouse messages we receive posted on to them. This is separate\n// from setting an owning window. By separating the two, applications may get\n// messages sent on even when they have set no owner (perhaps it's maximised)\n\nSTDMETHODIMP CBaseControlWindow::put_MessageDrain(OAHWND Drain)\n{\n    // Check we are connected otherwise reject the call\n\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    m_hwndDrain = (HWND)Drain;\n    return NOERROR;\n}\n\n// Return the current message drain\n\nSTDMETHODIMP CBaseControlWindow::get_MessageDrain(__out OAHWND *Drain)\n{\n    CheckPointer(Drain, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    *Drain = (OAHWND)m_hwndDrain;\n    return NOERROR;\n}\n\n// This is called by the filter graph to inform us of a message we should know\n// is being sent to our owning window. We have this because as a child window\n// we do not get certain messages that are only sent to top level windows. We\n// must see the palette changed/changing/query messages so that we know if we\n// have the foreground palette or not. We pass the message on to our window\n// using SendMessage - this will cause an interthread send message to occur\n\nSTDMETHODIMP\nCBaseControlWindow::NotifyOwnerMessage(OAHWND hwnd,     // Window handle\n                                       long uMsg,       // Message ID\n                                       LONG_PTR wParam, // Parameters\n                                       LONG_PTR lParam) // for message\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n\n    // Only interested in these Windows messages\n\n    switch (uMsg)\n    {\n\n    case WM_SYSCOLORCHANGE:\n    case WM_PALETTECHANGED:\n    case WM_PALETTEISCHANGING:\n    case WM_QUERYNEWPALETTE:\n    case WM_DEVMODECHANGE:\n    case WM_DISPLAYCHANGE:\n    case WM_ACTIVATEAPP:\n\n        // If we do not have an owner then ignore\n\n        if (m_hwndOwner == NULL)\n        {\n            return NOERROR;\n        }\n        SendMessage(m_hwnd, uMsg, (WPARAM)wParam, (LPARAM)lParam);\n        break;\n\n    // do NOT fwd WM_MOVE. the parameters are the location of the parent\n    // window, NOT what the renderer should be looking at.  But we need\n    // to make sure the overlay is moved with the parent window, so we\n    // do this.\n    case WM_MOVE: PostMessage(m_hwnd, WM_PAINT, 0, 0); break;\n    }\n    return NOERROR;\n}\n\n// Allow an application to have us set the base window in the foreground. We\n// have this because it is difficult for one thread to do do this to a window\n// owned by another thread. We ask the base window class to do the real work\n\nSTDMETHODIMP CBaseControlWindow::SetWindowForeground(long Focus)\n{\n    // Check this is a valid automation boolean type\n\n    if (Focus != OATRUE)\n    {\n        if (Focus != OAFALSE)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    // We shouldn't lock as this sends a message\n\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    BOOL bFocus = (Focus == OATRUE ? TRUE : FALSE);\n    DoSetWindowForeground(bFocus);\n\n    return NOERROR;\n}\n\n// This allows a client to set the complete window size and position in one\n// atomic operation. The same affect can be had by changing each dimension\n// in turn through their individual properties although some flashing will\n// occur as each of them gets updated (they are better set at design time)\n\nSTDMETHODIMP\nCBaseControlWindow::SetWindowPosition(long Left, long Top, long Width, long Height)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    BOOL bSuccess;\n\n    // Set the new size and position\n    UINT WindowFlags = SWP_NOZORDER | SWP_FRAMECHANGED | SWP_NOACTIVATE;\n\n    ASSERT(IsWindow(m_hwnd));\n    bSuccess = SetWindowPos(m_hwnd,       // Window handle\n                            HWND_TOP,     // Put it at the top\n                            Left,         // Left position\n                            Top,          // Top position\n                            Width,        // Window width\n                            Height,       // Window height\n                            WindowFlags); // Show window flags\n    ASSERT(bSuccess);\n#ifdef DEBUG\n    DbgLog((LOG_TRACE, 1, TEXT(\"SWP failed error %d\"), GetLastError()));\n#endif\n    if (bSuccess == FALSE)\n    {\n        return E_INVALIDARG;\n    }\n    return NOERROR;\n}\n\n// This complements the SetWindowPosition to return the current window place\n// in device coordinates. As before the same information can be retrived by\n// calling the property get functions individually but this is atomic and is\n// therefore more suitable to a live environment rather than design time\n\nSTDMETHODIMP\nCBaseControlWindow::GetWindowPosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight)\n{\n    // Should check the pointers are not NULL\n\n    CheckPointer(pLeft, E_POINTER);\n    CheckPointer(pTop, E_POINTER);\n    CheckPointer(pWidth, E_POINTER);\n    CheckPointer(pHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    RECT WindowRect;\n\n    // Get the current window coordinates\n\n    EXECUTE_ASSERT(GetWindowRect(m_hwnd, &WindowRect));\n\n    // Convert the RECT into left,top,width and height values\n\n    *pLeft = WindowRect.left;\n    *pTop = WindowRect.top;\n    *pWidth = WindowRect.right - WindowRect.left;\n    *pHeight = WindowRect.bottom - WindowRect.top;\n\n    return NOERROR;\n}\n\n// When a window is maximised or iconic calling GetWindowPosition will return\n// the current window position (likewise for the properties). However if the\n// restored size (ie the size we'll return to when normally shown) is needed\n// then this should be used. When in a normal position (neither iconic nor\n// maximised) then this returns the same coordinates as GetWindowPosition\n\nSTDMETHODIMP\nCBaseControlWindow::GetRestorePosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight)\n{\n    // Should check the pointers are not NULL\n\n    CheckPointer(pLeft, E_POINTER);\n    CheckPointer(pTop, E_POINTER);\n    CheckPointer(pWidth, E_POINTER);\n    CheckPointer(pHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n\n    // Use GetWindowPlacement to find the restore position\n\n    WINDOWPLACEMENT Place;\n    Place.length = sizeof(WINDOWPLACEMENT);\n    EXECUTE_ASSERT(GetWindowPlacement(m_hwnd, &Place));\n\n    RECT WorkArea;\n\n    // We must take into account any task bar present\n\n    if (SystemParametersInfo(SPI_GETWORKAREA, 0, &WorkArea, FALSE) == TRUE)\n    {\n        if (GetParent(m_hwnd) == NULL)\n        {\n            Place.rcNormalPosition.top += WorkArea.top;\n            Place.rcNormalPosition.bottom += WorkArea.top;\n            Place.rcNormalPosition.left += WorkArea.left;\n            Place.rcNormalPosition.right += WorkArea.left;\n        }\n    }\n\n    // Convert the RECT into left,top,width and height values\n\n    *pLeft = Place.rcNormalPosition.left;\n    *pTop = Place.rcNormalPosition.top;\n    *pWidth = Place.rcNormalPosition.right - Place.rcNormalPosition.left;\n    *pHeight = Place.rcNormalPosition.bottom - Place.rcNormalPosition.top;\n\n    return NOERROR;\n}\n\n// Return the current border colour, if we are playing something to a subset\n// of the base window display there is an outside area exposed. The default\n// action is to paint this colour in the Windows background colour (defined\n// as value COLOR_WINDOW) We reset to this default when we're disconnected\n\nSTDMETHODIMP CBaseControlWindow::get_BorderColor(__out long *Color)\n{\n    CheckPointer(Color, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    *Color = (long)m_BorderColour;\n    return NOERROR;\n}\n\n// This can be called to set the current border colour\n\nSTDMETHODIMP CBaseControlWindow::put_BorderColor(long Color)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n\n    // Have the window repainted with the new border colour\n\n    m_BorderColour = (COLORREF)Color;\n    PaintWindow(TRUE);\n    return NOERROR;\n}\n\n// Delegate fullscreen handling to plug in distributor\n\nSTDMETHODIMP CBaseControlWindow::get_FullScreenMode(__out long *FullScreenMode)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CheckPointer(FullScreenMode, E_POINTER);\n    return E_NOTIMPL;\n}\n\n// Delegate fullscreen handling to plug in distributor\n\nSTDMETHODIMP CBaseControlWindow::put_FullScreenMode(long FullScreenMode)\n{\n    return E_NOTIMPL;\n}\n\n// This sets the auto show property, this property causes the base window to\n// be displayed whenever we change state. This allows an application to have\n// to do nothing to have the window appear but still allow them to change the\n// default behaviour if for example they want to keep it hidden for longer\n\nSTDMETHODIMP CBaseControlWindow::put_AutoShow(long AutoShow)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n\n    // Check this is a valid automation boolean type\n\n    if (AutoShow != OATRUE)\n    {\n        if (AutoShow != OAFALSE)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    m_bAutoShow = (AutoShow == OATRUE ? TRUE : FALSE);\n    return NOERROR;\n}\n\n// This can be called to get the current auto show flag. The flag is updated\n// when we connect and disconnect and through this interface all of which are\n// controlled and serialised by means of the main renderer critical section\n\nSTDMETHODIMP CBaseControlWindow::get_AutoShow(__out long *AutoShow)\n{\n    CheckPointer(AutoShow, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    *AutoShow = (m_bAutoShow == TRUE ? OATRUE : OAFALSE);\n    return NOERROR;\n}\n\n// Return the minimum ideal image size for the current video. This may differ\n// to the actual video dimensions because we may be using DirectDraw hardware\n// that has specific stretching requirements. For example the Cirrus Logic\n// cards have a minimum stretch factor depending on the overlay surface size\n\nSTDMETHODIMP\nCBaseControlWindow::GetMinIdealImageSize(__out long *pWidth, __out long *pHeight)\n{\n    CheckPointer(pWidth, E_POINTER);\n    CheckPointer(pHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    FILTER_STATE State;\n\n    // Must not be stopped for this to work correctly\n\n    m_pFilter->GetState(0, &State);\n    if (State == State_Stopped)\n    {\n        return VFW_E_WRONG_STATE;\n    }\n\n    RECT DefaultRect = GetDefaultRect();\n    *pWidth = WIDTH(&DefaultRect);\n    *pHeight = HEIGHT(&DefaultRect);\n    return NOERROR;\n}\n\n// Return the maximum ideal image size for the current video. This may differ\n// to the actual video dimensions because we may be using DirectDraw hardware\n// that has specific stretching requirements. For example the Cirrus Logic\n// cards have a maximum stretch factor depending on the overlay surface size\n\nSTDMETHODIMP\nCBaseControlWindow::GetMaxIdealImageSize(__out long *pWidth, __out long *pHeight)\n{\n    CheckPointer(pWidth, E_POINTER);\n    CheckPointer(pHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    FILTER_STATE State;\n\n    // Must not be stopped for this to work correctly\n\n    m_pFilter->GetState(0, &State);\n    if (State == State_Stopped)\n    {\n        return VFW_E_WRONG_STATE;\n    }\n\n    RECT DefaultRect = GetDefaultRect();\n    *pWidth = WIDTH(&DefaultRect);\n    *pHeight = HEIGHT(&DefaultRect);\n    return NOERROR;\n}\n\n// Allow an application to hide the cursor on our window\n\nSTDMETHODIMP\nCBaseControlWindow::HideCursor(long HideCursor)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n\n    // Check this is a valid automation boolean type\n\n    if (HideCursor != OATRUE)\n    {\n        if (HideCursor != OAFALSE)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    m_bCursorHidden = (HideCursor == OATRUE ? TRUE : FALSE);\n    return NOERROR;\n}\n\n// Returns whether we have the cursor hidden or not\n\nSTDMETHODIMP CBaseControlWindow::IsCursorHidden(__out long *CursorHidden)\n{\n    CheckPointer(CursorHidden, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    *CursorHidden = (m_bCursorHidden == TRUE ? OATRUE : OAFALSE);\n    return NOERROR;\n}\n\n// This class implements the IBasicVideo control functions (dual interface)\n// we support a large number of properties and methods designed to allow the\n// client (whether it be an automation controller or a C/C++ application) to\n// set and get a number of video related properties such as the native video\n// size. We support some methods that duplicate the properties but provide a\n// more direct and efficient mechanism as many values may be changed in one\n\nCBaseControlVideo::CBaseControlVideo(__inout CBaseFilter *pFilter,  // Owning filter\n                                     __in CCritSec *pInterfaceLock, // Locking object\n                                     __in_opt LPCTSTR pName,        // Object description\n                                     __inout_opt LPUNKNOWN pUnk,    // Normal COM ownership\n                                     __inout HRESULT *phr)\n    : // OLE return code\n\n    CBaseBasicVideo(pName, pUnk)\n    , m_pFilter(pFilter)\n    , m_pInterfaceLock(pInterfaceLock)\n    , m_pPin(NULL)\n{\n    ASSERT(m_pFilter);\n    ASSERT(m_pInterfaceLock);\n    ASSERT(phr);\n}\n\n// Return an approximate average time per frame\n\nSTDMETHODIMP CBaseControlVideo::get_AvgTimePerFrame(__out REFTIME *pAvgTimePerFrame)\n{\n    CheckPointer(pAvgTimePerFrame, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    COARefTime AvgTime(pVideoInfo->AvgTimePerFrame);\n    *pAvgTimePerFrame = (REFTIME)AvgTime;\n\n    return NOERROR;\n}\n\n// Return an approximate bit rate for the video\n\nSTDMETHODIMP CBaseControlVideo::get_BitRate(__out long *pBitRate)\n{\n    CheckPointer(pBitRate, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    *pBitRate = pVideoInfo->dwBitRate;\n    return NOERROR;\n}\n\n// Return an approximate bit error rate\n\nSTDMETHODIMP CBaseControlVideo::get_BitErrorRate(__out long *pBitErrorRate)\n{\n    CheckPointer(pBitErrorRate, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    *pBitErrorRate = pVideoInfo->dwBitErrorRate;\n    return NOERROR;\n}\n\n// This returns the current video width\n\nSTDMETHODIMP CBaseControlVideo::get_VideoWidth(__out long *pVideoWidth)\n{\n    CheckPointer(pVideoWidth, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    *pVideoWidth = pVideoInfo->bmiHeader.biWidth;\n    return NOERROR;\n}\n\n// This returns the current video height\n\nSTDMETHODIMP CBaseControlVideo::get_VideoHeight(__out long *pVideoHeight)\n{\n    CheckPointer(pVideoHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    *pVideoHeight = pVideoInfo->bmiHeader.biHeight;\n    return NOERROR;\n}\n\n// This returns the current palette the video is using as an array allocated\n// by the user. To remain consistent we use PALETTEENTRY fields to return the\n// colours in rather than RGBQUADs that multimedia decided to use. The memory\n// is allocated by the user so we simple copy each in turn. We check that the\n// number of entries requested and the start position offset are both valid\n// If the number of entries evaluates to zero then we return an S_FALSE code\n\nSTDMETHODIMP CBaseControlVideo::GetVideoPaletteEntries(long StartIndex, long Entries, __out long *pRetrieved,\n                                                       __out_ecount_part(Entries, *pRetrieved) long *pPalette)\n{\n    CheckPointer(pRetrieved, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    CMediaType MediaType;\n\n    // Get the video format from the derived class\n\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    BITMAPINFOHEADER *pHeader = HEADER(pVideoInfo);\n\n    // Is the current format palettised\n\n    if (PALETTISED(pVideoInfo) == FALSE)\n    {\n        *pRetrieved = 0;\n        return VFW_E_NO_PALETTE_AVAILABLE;\n    }\n\n    // Do they just want to know how many are available\n\n    if (pPalette == NULL)\n    {\n        *pRetrieved = pHeader->biClrUsed;\n        return NOERROR;\n    }\n\n    // Make sure the start position is a valid offset\n\n    if (StartIndex >= (LONG)pHeader->biClrUsed || StartIndex < 0)\n    {\n        *pRetrieved = 0;\n        return E_INVALIDARG;\n    }\n\n    // Correct the number we can retrieve\n\n    LONG Available = (LONG)pHeader->biClrUsed - StartIndex;\n    *pRetrieved = max(0, min(Available, Entries));\n    if (*pRetrieved == 0)\n    {\n        return S_FALSE;\n    }\n\n    // Copy the palette entries to the output buffer\n\n    PALETTEENTRY *pEntries = (PALETTEENTRY *)pPalette;\n    RGBQUAD *pColours = COLORS(pVideoInfo) + StartIndex;\n\n    for (LONG Count = 0; Count < *pRetrieved; Count++)\n    {\n        pEntries[Count].peRed = pColours[Count].rgbRed;\n        pEntries[Count].peGreen = pColours[Count].rgbGreen;\n        pEntries[Count].peBlue = pColours[Count].rgbBlue;\n        pEntries[Count].peFlags = 0;\n    }\n    return NOERROR;\n}\n\n// This returns the current video dimensions as a method rather than a number\n// of individual property get calls. For the same reasons as said before we\n// cannot access the renderer media type directly as the window object thread\n// may be updating it since dynamic format changes may change these values\n\nSTDMETHODIMP CBaseControlVideo::GetVideoSize(__out long *pWidth, __out long *pHeight)\n{\n    CheckPointer(pWidth, E_POINTER);\n    CheckPointer(pHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n\n    // Get the video format from the derived class\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    *pWidth = pVideoInfo->bmiHeader.biWidth;\n    *pHeight = pVideoInfo->bmiHeader.biHeight;\n    return NOERROR;\n}\n\n// Set the source video rectangle as left,top,right and bottom coordinates\n// rather than left,top,width and height as per OLE automation interfaces\n// Then pass the rectangle on to the window object to set the source\n\nSTDMETHODIMP\nCBaseControlVideo::SetSourcePosition(long Left, long Top, long Width, long Height)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n    SourceRect.left = Left;\n    SourceRect.top = Top;\n    SourceRect.right = Left + Width;\n    SourceRect.bottom = Top + Height;\n\n    // Check the source rectangle is valid\n\n    HRESULT hr = CheckSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the source rectangle\n\n    hr = SetSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the source rectangle in left,top,width and height rather than the\n// left,top,right and bottom values that RECT uses (and which the window\n// object returns through GetSourceRect) which requires a little work\n\nSTDMETHODIMP\nCBaseControlVideo::GetSourcePosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight)\n{\n    // Should check the pointers are non NULL\n\n    CheckPointer(pLeft, E_POINTER);\n    CheckPointer(pTop, E_POINTER);\n    CheckPointer(pWidth, E_POINTER);\n    CheckPointer(pHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    RECT SourceRect;\n\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    GetSourceRect(&SourceRect);\n\n    *pLeft = SourceRect.left;\n    *pTop = SourceRect.top;\n    *pWidth = WIDTH(&SourceRect);\n    *pHeight = HEIGHT(&SourceRect);\n\n    return NOERROR;\n}\n\n// Set the video destination as left,top,right and bottom coordinates rather\n// than the left,top,width and height uses as per OLE automation interfaces\n// Then pass the rectangle on to the window object to set the destination\n\nSTDMETHODIMP\nCBaseControlVideo::SetDestinationPosition(long Left, long Top, long Width, long Height)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n\n    DestinationRect.left = Left;\n    DestinationRect.top = Top;\n    DestinationRect.right = Left + Width;\n    DestinationRect.bottom = Top + Height;\n\n    // Check the target rectangle is valid\n\n    HRESULT hr = CheckTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the new target rectangle\n\n    hr = SetTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the destination rectangle in left,top,width and height rather than\n// the left,top,right and bottom values that RECT uses (and which the window\n// object returns through GetDestinationRect) which requires a little work\n\nSTDMETHODIMP\nCBaseControlVideo::GetDestinationPosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight)\n{\n    // Should check the pointers are not NULL\n\n    CheckPointer(pLeft, E_POINTER);\n    CheckPointer(pTop, E_POINTER);\n    CheckPointer(pWidth, E_POINTER);\n    CheckPointer(pHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    RECT DestinationRect;\n\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    GetTargetRect(&DestinationRect);\n\n    *pLeft = DestinationRect.left;\n    *pTop = DestinationRect.top;\n    *pWidth = WIDTH(&DestinationRect);\n    *pHeight = HEIGHT(&DestinationRect);\n\n    return NOERROR;\n}\n\n// Set the source left position, the source rectangle we get back from the\n// window object is a true rectangle in left,top,right and bottom positions\n// so all we have to do is to update the left position and pass it back. We\n// must keep the current width constant when we're updating this property\n\nSTDMETHODIMP CBaseControlVideo::put_SourceLeft(long SourceLeft)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n    GetSourceRect(&SourceRect);\n    SourceRect.right = SourceLeft + WIDTH(&SourceRect);\n    SourceRect.left = SourceLeft;\n\n    // Check the source rectangle is valid\n\n    HRESULT hr = CheckSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the source rectangle\n\n    hr = SetSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the current left source video position\n\nSTDMETHODIMP CBaseControlVideo::get_SourceLeft(__out long *pSourceLeft)\n{\n    CheckPointer(pSourceLeft, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n\n    GetSourceRect(&SourceRect);\n    *pSourceLeft = SourceRect.left;\n    return NOERROR;\n}\n\n// Set the source width, we get the current source rectangle and then update\n// the right position to be the left position (thereby keeping it constant)\n// plus the new source width we are passed in (it expands to the right)\n\nSTDMETHODIMP CBaseControlVideo::put_SourceWidth(long SourceWidth)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n    GetSourceRect(&SourceRect);\n    SourceRect.right = SourceRect.left + SourceWidth;\n\n    // Check the source rectangle is valid\n\n    HRESULT hr = CheckSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the source rectangle\n\n    hr = SetSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the current source width\n\nSTDMETHODIMP CBaseControlVideo::get_SourceWidth(__out long *pSourceWidth)\n{\n    CheckPointer(pSourceWidth, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n\n    GetSourceRect(&SourceRect);\n    *pSourceWidth = WIDTH(&SourceRect);\n    return NOERROR;\n}\n\n// Set the source top position - changing this property does not affect the\n// current source height. So changing this shunts the source rectangle up and\n// down appropriately. Changing the height complements this functionality by\n// keeping the top position constant and simply changing the source height\n\nSTDMETHODIMP CBaseControlVideo::put_SourceTop(long SourceTop)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n    GetSourceRect(&SourceRect);\n    SourceRect.bottom = SourceTop + HEIGHT(&SourceRect);\n    SourceRect.top = SourceTop;\n\n    // Check the source rectangle is valid\n\n    HRESULT hr = CheckSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the source rectangle\n\n    hr = SetSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the current top position\n\nSTDMETHODIMP CBaseControlVideo::get_SourceTop(__out long *pSourceTop)\n{\n    CheckPointer(pSourceTop, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n\n    GetSourceRect(&SourceRect);\n    *pSourceTop = SourceRect.top;\n    return NOERROR;\n}\n\n// Set the source height\n\nSTDMETHODIMP CBaseControlVideo::put_SourceHeight(long SourceHeight)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n    GetSourceRect(&SourceRect);\n    SourceRect.bottom = SourceRect.top + SourceHeight;\n\n    // Check the source rectangle is valid\n\n    HRESULT hr = CheckSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the source rectangle\n\n    hr = SetSourceRect(&SourceRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the current source height\n\nSTDMETHODIMP CBaseControlVideo::get_SourceHeight(__out long *pSourceHeight)\n{\n    CheckPointer(pSourceHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT SourceRect;\n\n    GetSourceRect(&SourceRect);\n    *pSourceHeight = HEIGHT(&SourceRect);\n    return NOERROR;\n}\n\n// Set the target left position, the target rectangle we get back from the\n// window object is a true rectangle in left,top,right and bottom positions\n// so all we have to do is to update the left position and pass it back. We\n// must keep the current width constant when we're updating this property\n\nSTDMETHODIMP CBaseControlVideo::put_DestinationLeft(long DestinationLeft)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n    GetTargetRect(&DestinationRect);\n    DestinationRect.right = DestinationLeft + WIDTH(&DestinationRect);\n    DestinationRect.left = DestinationLeft;\n\n    // Check the target rectangle is valid\n\n    HRESULT hr = CheckTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the new target rectangle\n\n    hr = SetTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the left position for the destination rectangle\n\nSTDMETHODIMP CBaseControlVideo::get_DestinationLeft(__out long *pDestinationLeft)\n{\n    CheckPointer(pDestinationLeft, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n\n    GetTargetRect(&DestinationRect);\n    *pDestinationLeft = DestinationRect.left;\n    return NOERROR;\n}\n\n// Set the destination width\n\nSTDMETHODIMP CBaseControlVideo::put_DestinationWidth(long DestinationWidth)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n    GetTargetRect(&DestinationRect);\n    DestinationRect.right = DestinationRect.left + DestinationWidth;\n\n    // Check the target rectangle is valid\n\n    HRESULT hr = CheckTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the new target rectangle\n\n    hr = SetTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the width for the destination rectangle\n\nSTDMETHODIMP CBaseControlVideo::get_DestinationWidth(__out long *pDestinationWidth)\n{\n    CheckPointer(pDestinationWidth, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n\n    GetTargetRect(&DestinationRect);\n    *pDestinationWidth = WIDTH(&DestinationRect);\n    return NOERROR;\n}\n\n// Set the target top position - changing this property does not affect the\n// current target height. So changing this shunts the target rectangle up and\n// down appropriately. Changing the height complements this functionality by\n// keeping the top position constant and simply changing the target height\n\nSTDMETHODIMP CBaseControlVideo::put_DestinationTop(long DestinationTop)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n    GetTargetRect(&DestinationRect);\n    DestinationRect.bottom = DestinationTop + HEIGHT(&DestinationRect);\n    DestinationRect.top = DestinationTop;\n\n    // Check the target rectangle is valid\n\n    HRESULT hr = CheckTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the new target rectangle\n\n    hr = SetTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the top position for the destination rectangle\n\nSTDMETHODIMP CBaseControlVideo::get_DestinationTop(__out long *pDestinationTop)\n{\n    CheckPointer(pDestinationTop, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n\n    GetTargetRect(&DestinationRect);\n    *pDestinationTop = DestinationRect.top;\n    return NOERROR;\n}\n\n// Set the destination height\n\nSTDMETHODIMP CBaseControlVideo::put_DestinationHeight(long DestinationHeight)\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n    GetTargetRect(&DestinationRect);\n    DestinationRect.bottom = DestinationRect.top + DestinationHeight;\n\n    // Check the target rectangle is valid\n\n    HRESULT hr = CheckTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now set the new target rectangle\n\n    hr = SetTargetRect(&DestinationRect);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return the height for the destination rectangle\n\nSTDMETHODIMP CBaseControlVideo::get_DestinationHeight(__out long *pDestinationHeight)\n{\n    CheckPointer(pDestinationHeight, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    RECT DestinationRect;\n\n    GetTargetRect(&DestinationRect);\n    *pDestinationHeight = HEIGHT(&DestinationRect);\n    return NOERROR;\n}\n\n// Reset the source rectangle to the full video dimensions\n\nSTDMETHODIMP CBaseControlVideo::SetDefaultSourcePosition()\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    HRESULT hr = SetDefaultSourceRect();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return S_OK if we're using the default source otherwise S_FALSE\n\nSTDMETHODIMP CBaseControlVideo::IsUsingDefaultSource()\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    return IsDefaultSourceRect();\n}\n\n// Reset the video renderer to use the entire playback area\n\nSTDMETHODIMP CBaseControlVideo::SetDefaultDestinationPosition()\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    HRESULT hr = SetDefaultTargetRect();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return OnUpdateRectangles();\n}\n\n// Return S_OK if we're using the default target otherwise S_FALSE\n\nSTDMETHODIMP CBaseControlVideo::IsUsingDefaultDestination()\n{\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    return IsDefaultTargetRect();\n}\n\n// Return a copy of the current image in the video renderer\n\nSTDMETHODIMP\nCBaseControlVideo::GetCurrentImage(__inout long *pBufferSize,\n                                   __out_bcount_part(*pBufferSize, *pBufferSize) long *pVideoImage)\n{\n    CheckPointer(pBufferSize, E_POINTER);\n    CheckConnected(m_pPin, VFW_E_NOT_CONNECTED);\n    CAutoLock cInterfaceLock(m_pInterfaceLock);\n    FILTER_STATE State;\n\n    // Make sure we are in a paused state\n\n    if (pVideoImage != NULL)\n    {\n        m_pFilter->GetState(0, &State);\n        if (State != State_Paused)\n        {\n            return VFW_E_NOT_PAUSED;\n        }\n        return GetStaticImage(pBufferSize, pVideoImage);\n    }\n\n    // Just return the memory required\n\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    RECT SourceRect;\n    GetSourceRect(&SourceRect);\n    return GetImageSize(pVideoInfo, pBufferSize, &SourceRect);\n}\n\n// An application has two ways of using GetCurrentImage, one is to pass a real\n// buffer which should be filled with the current image. The other is to pass\n// a NULL buffer pointer which is interpreted as asking us to return how much\n// memory is required for the image. The constraints for when the latter can\n// be called are much looser. To calculate the memory required we synthesize\n// a VIDEOINFO that takes into account the source rectangle that's being used\n\nHRESULT CBaseControlVideo::GetImageSize(__in VIDEOINFOHEADER *pVideoInfo, __out long *pBufferSize,\n                                        __in RECT *pSourceRect)\n{\n    NOTE(\"Entering GetImageSize\");\n    ASSERT(pSourceRect);\n\n    // Check we have the correct input parameters\n\n    if (pSourceRect == NULL || pVideoInfo == NULL || pBufferSize == NULL)\n    {\n\n        return E_UNEXPECTED;\n    }\n\n    // Is the data format compatible\n\n    if (pVideoInfo->bmiHeader.biCompression != BI_RGB)\n    {\n        if (pVideoInfo->bmiHeader.biCompression != BI_BITFIELDS)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    ASSERT(IsRectEmpty(pSourceRect) == FALSE);\n\n    BITMAPINFOHEADER bih;\n    bih.biWidth = WIDTH(pSourceRect);\n    bih.biHeight = HEIGHT(pSourceRect);\n    bih.biBitCount = pVideoInfo->bmiHeader.biBitCount;\n    LONG Size = DIBSIZE(bih);\n    Size += GetBitmapFormatSize(HEADER(pVideoInfo)) - SIZE_PREHEADER;\n    *pBufferSize = Size;\n\n    return NOERROR;\n}\n\n// Given an IMediaSample containing a linear buffer with an image and a type\n// describing the bitmap make a rendering of the image into the output buffer\n// This may be called by derived classes who render typical video images to\n// handle the IBasicVideo GetCurrentImage method. The pVideoImage pointer may\n// be NULL when passed to GetCurrentImage in which case GetImageSize will be\n// called instead, which will just do the calculation of the memory required\n\nHRESULT CBaseControlVideo::CopyImage(IMediaSample *pMediaSample, __in VIDEOINFOHEADER *pVideoInfo,\n                                     __inout long *pBufferSize,\n                                     __out_bcount_part(*pBufferSize, *pBufferSize) BYTE *pVideoImage,\n                                     __in RECT *pSourceRect)\n{\n    NOTE(\"Entering CopyImage\");\n    ASSERT(pSourceRect);\n    BYTE *pCurrentImage;\n\n    // Check we have an image to copy\n\n    if (pMediaSample == NULL || pSourceRect == NULL || pVideoInfo == NULL || pVideoImage == NULL || pBufferSize == NULL)\n    {\n\n        return E_UNEXPECTED;\n    }\n\n    // Is the data format compatible\n\n    if (pVideoInfo->bmiHeader.biCompression != BI_RGB)\n    {\n        if (pVideoInfo->bmiHeader.biCompression != BI_BITFIELDS)\n        {\n            return E_INVALIDARG;\n        }\n    }\n\n    if (*pBufferSize < 0)\n    {\n        return E_INVALIDARG;\n    }\n\n    // Arbitrarily large size to prevent integer overflow problems\n    if (pVideoInfo->bmiHeader.biSize > 4096)\n    {\n        return E_INVALIDARG;\n    }\n\n    ASSERT(IsRectEmpty(pSourceRect) == FALSE);\n\n    BITMAPINFOHEADER bih;\n    bih.biWidth = WIDTH(pSourceRect);\n    bih.biHeight = HEIGHT(pSourceRect);\n    bih.biBitCount = pVideoInfo->bmiHeader.biBitCount;\n    DWORD Size = GetBitmapFormatSize(HEADER(pVideoInfo)) - SIZE_PREHEADER;\n    DWORD Total;\n    DWORD dwDibSize;\n\n    if (!ValidateBitmapInfoHeader(HEADER(pVideoInfo), Size))\n    {\n        return E_INVALIDARG;\n    }\n\n    //  ValidateBitmapInfoHeader checks this but for some reason code scanning\n    //  tools aren't picking up the annotation\n    __analysis_assume(Size >= sizeof(BITMAPINFOHEADER));\n\n    if (FAILED(SAFE_DIBSIZE(&bih, &dwDibSize)))\n    {\n        return E_INVALIDARG;\n    }\n\n    if (FAILED(DWordAdd(Size, dwDibSize, &Total)))\n    {\n        return E_INVALIDARG;\n    }\n\n    // Make sure we have a large enough buffer\n\n    if ((DWORD)*pBufferSize < Total)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    // Copy the BITMAPINFO\n\n    CopyMemory((PVOID)pVideoImage, (PVOID)&pVideoInfo->bmiHeader, Size);\n    ((BITMAPINFOHEADER *)pVideoImage)->biWidth = WIDTH(pSourceRect);\n    ((BITMAPINFOHEADER *)pVideoImage)->biHeight = HEIGHT(pSourceRect);\n    ((BITMAPINFOHEADER *)pVideoImage)->biSizeImage = DIBSIZE(bih);\n    BYTE *pImageData = pVideoImage + Size;\n\n    // Get the pointer to it's image data\n\n    HRESULT hr = pMediaSample->GetPointer(&pCurrentImage);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // Now we are ready to start copying the source scan lines\n\n    LONG ScanLine = (pVideoInfo->bmiHeader.biBitCount / 8) * WIDTH(pSourceRect);\n    LONG LinesToSkip = pVideoInfo->bmiHeader.biHeight;\n    LinesToSkip -= pSourceRect->top + HEIGHT(pSourceRect);\n    pCurrentImage += LinesToSkip * DIBWIDTHBYTES(pVideoInfo->bmiHeader);\n    pCurrentImage += pSourceRect->left * (pVideoInfo->bmiHeader.biBitCount / 8);\n\n    // Even money on this GP faulting sometime...\n\n    for (LONG Line = 0; Line < HEIGHT(pSourceRect); Line++)\n    {\n        CopyMemory((PVOID)pImageData, (PVOID)pCurrentImage, ScanLine);\n        pImageData += DIBWIDTHBYTES(*(BITMAPINFOHEADER *)pVideoImage);\n        pCurrentImage += DIBWIDTHBYTES(pVideoInfo->bmiHeader);\n    }\n    return NOERROR;\n}\n\n// Called when we change media types either during connection or dynamically\n// We inform the filter graph and therefore the application that the video\n// size may have changed, we don't bother looking to see if it really has as\n// we leave that to the application - the dimensions are the event parameters\n\nHRESULT CBaseControlVideo::OnVideoSizeChange()\n{\n    // Get the video format from the derived class\n\n    VIDEOINFOHEADER *pVideoInfo = GetVideoFormat();\n    if (pVideoInfo == NULL)\n        return E_OUTOFMEMORY;\n    WORD Width = (WORD)pVideoInfo->bmiHeader.biWidth;\n    WORD Height = (WORD)pVideoInfo->bmiHeader.biHeight;\n\n    return m_pFilter->NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(Width, Height), MAKEWPARAM(0, 0));\n}\n\n// Set the video source rectangle. We must check the source rectangle against\n// the actual video dimensions otherwise when we come to draw the pictures we\n// get access violations as GDI tries to touch data outside of the image data\n// Although we store the rectangle in left, top, right and bottom coordinates\n// instead of left, top, width and height as OLE uses we do take into account\n// that the rectangle is used up to, but not including, the right column and\n// bottom row of pixels, see the Win32 documentation on RECT for more details\n\nHRESULT CBaseControlVideo::CheckSourceRect(__in RECT *pSourceRect)\n{\n    CheckPointer(pSourceRect, E_POINTER);\n    LONG Width, Height;\n    GetVideoSize(&Width, &Height);\n\n    // Check the coordinates are greater than zero\n    // and that the rectangle is valid (left<right, top<bottom)\n\n    if ((pSourceRect->left >= pSourceRect->right) || (pSourceRect->left < 0) ||\n        (pSourceRect->top >= pSourceRect->bottom) || (pSourceRect->top < 0))\n    {\n\n        return E_INVALIDARG;\n    }\n\n    // Check the coordinates are less than the extents\n\n    if ((pSourceRect->right > Width) || (pSourceRect->bottom > Height))\n    {\n\n        return E_INVALIDARG;\n    }\n    return NOERROR;\n}\n\n// Check the target rectangle has some valid coordinates, which amounts to\n// little more than checking the destination rectangle isn't empty. Derived\n// classes may call this when they have their SetTargetRect method called to\n// check the rectangle validity, we do not update the rectangles passed in\n// Although we store the rectangle in left, top, right and bottom coordinates\n// instead of left, top, width and height as OLE uses we do take into account\n// that the rectangle is used up to, but not including, the right column and\n// bottom row of pixels, see the Win32 documentation on RECT for more details\n\nHRESULT CBaseControlVideo::CheckTargetRect(__in RECT *pTargetRect)\n{\n    // Check the pointer is valid\n\n    if (pTargetRect == NULL)\n    {\n        return E_POINTER;\n    }\n\n    // These overflow the WIDTH and HEIGHT checks\n\n    if (pTargetRect->left > pTargetRect->right || pTargetRect->top > pTargetRect->bottom)\n    {\n        return E_INVALIDARG;\n    }\n\n    // Check the rectangle has valid coordinates\n\n    if (WIDTH(pTargetRect) <= 0 || HEIGHT(pTargetRect) <= 0)\n    {\n        return E_INVALIDARG;\n    }\n\n    ASSERT(IsRectEmpty(pTargetRect) == FALSE);\n    return NOERROR;\n}\n"
  },
  {
    "path": "common/baseclasses/winctrl.h",
    "content": "//------------------------------------------------------------------------------\n// File: WinCtrl.h\n//\n// Desc: DirectShow base classes - defines classes for video control\n//       interfaces.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __WINCTRL__\n#define __WINCTRL__\n\n#define ABSOL(x) (x < 0 ? -x : x)\n#define NEGAT(x) (x > 0 ? -x : x)\n\n//  Helper\nBOOL WINAPI PossiblyEatMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\nclass CBaseControlWindow\n    : public CBaseVideoWindow\n    , public CBaseWindow\n{\n  protected:\n    CBaseFilter *m_pFilter;     // Pointer to owning media filter\n    CBasePin *m_pPin;           // Controls media types for connection\n    CCritSec *m_pInterfaceLock; // Externally defined critical section\n    COLORREF m_BorderColour;    // Current window border colour\n    BOOL m_bAutoShow;           // What happens when the state changes\n    HWND m_hwndOwner;           // Owner window that we optionally have\n    HWND m_hwndDrain;           // HWND to post any messages received\n    BOOL m_bCursorHidden;       // Should we hide the window cursor\n\n  public:\n    // Internal methods for other objects to get information out\n\n    HRESULT DoSetWindowStyle(long Style, long WindowLong);\n    HRESULT DoGetWindowStyle(__out long *pStyle, long WindowLong);\n    BOOL IsAutoShowEnabled() { return m_bAutoShow; };\n    COLORREF GetBorderColour() { return m_BorderColour; };\n    HWND GetOwnerWindow() { return m_hwndOwner; };\n    BOOL IsCursorHidden() { return m_bCursorHidden; };\n\n    inline BOOL PossiblyEatMessage(UINT uMsg, WPARAM wParam, LPARAM lParam)\n    {\n        return ::PossiblyEatMessage(m_hwndDrain, uMsg, wParam, lParam);\n    }\n\n    // Derived classes must call this to set the pin the filter is using\n    // We don't have the pin passed in to the constructor (as we do with\n    // the CBaseFilter object) because filters typically create the\n    // pins dynamically when requested in CBaseFilter::GetPin. This can\n    // not be called from our constructor because is is a virtual method\n\n    void SetControlWindowPin(CBasePin *pPin) { m_pPin = pPin; }\n\n  public:\n    CBaseControlWindow(__inout CBaseFilter *pFilter,  // Owning media filter\n                       __in CCritSec *pInterfaceLock, // Locking object\n                       __in_opt LPCTSTR pName,        // Object description\n                       __inout_opt LPUNKNOWN pUnk,    // Normal COM ownership\n                       __inout HRESULT *phr);         // OLE return code\n\n    // These are the properties we support\n\n    STDMETHODIMP put_Caption(__in BSTR strCaption);\n    STDMETHODIMP get_Caption(__out BSTR *pstrCaption);\n    STDMETHODIMP put_AutoShow(long AutoShow);\n    STDMETHODIMP get_AutoShow(__out long *AutoShow);\n    STDMETHODIMP put_WindowStyle(long WindowStyle);\n    STDMETHODIMP get_WindowStyle(__out long *pWindowStyle);\n    STDMETHODIMP put_WindowStyleEx(long WindowStyleEx);\n    STDMETHODIMP get_WindowStyleEx(__out long *pWindowStyleEx);\n    STDMETHODIMP put_WindowState(long WindowState);\n    STDMETHODIMP get_WindowState(__out long *pWindowState);\n    STDMETHODIMP put_BackgroundPalette(long BackgroundPalette);\n    STDMETHODIMP get_BackgroundPalette(__out long *pBackgroundPalette);\n    STDMETHODIMP put_Visible(long Visible);\n    STDMETHODIMP get_Visible(__out long *pVisible);\n    STDMETHODIMP put_Left(long Left);\n    STDMETHODIMP get_Left(__out long *pLeft);\n    STDMETHODIMP put_Width(long Width);\n    STDMETHODIMP get_Width(__out long *pWidth);\n    STDMETHODIMP put_Top(long Top);\n    STDMETHODIMP get_Top(__out long *pTop);\n    STDMETHODIMP put_Height(long Height);\n    STDMETHODIMP get_Height(__out long *pHeight);\n    STDMETHODIMP put_Owner(OAHWND Owner);\n    STDMETHODIMP get_Owner(__out OAHWND *Owner);\n    STDMETHODIMP put_MessageDrain(OAHWND Drain);\n    STDMETHODIMP get_MessageDrain(__out OAHWND *Drain);\n    STDMETHODIMP get_BorderColor(__out long *Color);\n    STDMETHODIMP put_BorderColor(long Color);\n    STDMETHODIMP get_FullScreenMode(__out long *FullScreenMode);\n    STDMETHODIMP put_FullScreenMode(long FullScreenMode);\n\n    // And these are the methods\n\n    STDMETHODIMP SetWindowForeground(long Focus);\n    STDMETHODIMP NotifyOwnerMessage(OAHWND hwnd, long uMsg, LONG_PTR wParam, LONG_PTR lParam);\n    STDMETHODIMP GetMinIdealImageSize(__out long *pWidth, __out long *pHeight);\n    STDMETHODIMP GetMaxIdealImageSize(__out long *pWidth, __out long *pHeight);\n    STDMETHODIMP SetWindowPosition(long Left, long Top, long Width, long Height);\n    STDMETHODIMP GetWindowPosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight);\n    STDMETHODIMP GetRestorePosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight);\n    STDMETHODIMP HideCursor(long HideCursor);\n    STDMETHODIMP IsCursorHidden(__out long *CursorHidden);\n};\n\n// This class implements the IBasicVideo interface\n\nclass CBaseControlVideo : public CBaseBasicVideo\n{\n  protected:\n    CBaseFilter *m_pFilter;     // Pointer to owning media filter\n    CBasePin *m_pPin;           // Controls media types for connection\n    CCritSec *m_pInterfaceLock; // Externally defined critical section\n\n  public:\n    // Derived classes must provide these for the implementation\n\n    virtual HRESULT IsDefaultTargetRect() PURE;\n    virtual HRESULT SetDefaultTargetRect() PURE;\n    virtual HRESULT SetTargetRect(RECT *pTargetRect) PURE;\n    virtual HRESULT GetTargetRect(RECT *pTargetRect) PURE;\n    virtual HRESULT IsDefaultSourceRect() PURE;\n    virtual HRESULT SetDefaultSourceRect() PURE;\n    virtual HRESULT SetSourceRect(RECT *pSourceRect) PURE;\n    virtual HRESULT GetSourceRect(RECT *pSourceRect) PURE;\n    virtual HRESULT GetStaticImage(__inout long *pBufferSize,\n                                   __out_bcount_part(*pBufferSize, *pBufferSize) long *pDIBImage) PURE;\n\n    // Derived classes must override this to return a VIDEOINFO representing\n    // the video format. We cannot call IPin ConnectionMediaType to get this\n    // format because various filters dynamically change the type when using\n    // DirectDraw such that the format shows the position of the logical\n    // bitmap in a frame buffer surface, so the size might be returned as\n    // 1024x768 pixels instead of 320x240 which is the real video dimensions\n\n    __out virtual VIDEOINFOHEADER *GetVideoFormat() PURE;\n\n    // Helper functions for creating memory renderings of a DIB image\n\n    HRESULT GetImageSize(__in VIDEOINFOHEADER *pVideoInfo, __out LONG *pBufferSize, __in RECT *pSourceRect);\n\n    HRESULT CopyImage(IMediaSample *pMediaSample, __in VIDEOINFOHEADER *pVideoInfo, __inout LONG *pBufferSize,\n                      __out_bcount_part(*pBufferSize, *pBufferSize) BYTE *pVideoImage, __in RECT *pSourceRect);\n\n    // Override this if you want notifying when the rectangles change\n    virtual HRESULT OnUpdateRectangles() { return NOERROR; };\n    virtual HRESULT OnVideoSizeChange();\n\n    // Derived classes must call this to set the pin the filter is using\n    // We don't have the pin passed in to the constructor (as we do with\n    // the CBaseFilter object) because filters typically create the\n    // pins dynamically when requested in CBaseFilter::GetPin. This can\n    // not be called from our constructor because is is a virtual method\n\n    void SetControlVideoPin(__inout CBasePin *pPin) { m_pPin = pPin; }\n\n    // Helper methods for checking rectangles\n    virtual HRESULT CheckSourceRect(__in RECT *pSourceRect);\n    virtual HRESULT CheckTargetRect(__in RECT *pTargetRect);\n\n  public:\n    CBaseControlVideo(__inout CBaseFilter *pFilter,  // Owning media filter\n                      __in CCritSec *pInterfaceLock, // Serialise interface\n                      __in_opt LPCTSTR pName,        // Object description\n                      __inout_opt LPUNKNOWN pUnk,    // Normal COM ownership\n                      __inout HRESULT *phr);         // OLE return code\n\n    // These are the properties we support\n\n    STDMETHODIMP get_AvgTimePerFrame(__out REFTIME *pAvgTimePerFrame);\n    STDMETHODIMP get_BitRate(__out long *pBitRate);\n    STDMETHODIMP get_BitErrorRate(__out long *pBitErrorRate);\n    STDMETHODIMP get_VideoWidth(__out long *pVideoWidth);\n    STDMETHODIMP get_VideoHeight(__out long *pVideoHeight);\n    STDMETHODIMP put_SourceLeft(long SourceLeft);\n    STDMETHODIMP get_SourceLeft(__out long *pSourceLeft);\n    STDMETHODIMP put_SourceWidth(long SourceWidth);\n    STDMETHODIMP get_SourceWidth(__out long *pSourceWidth);\n    STDMETHODIMP put_SourceTop(long SourceTop);\n    STDMETHODIMP get_SourceTop(__out long *pSourceTop);\n    STDMETHODIMP put_SourceHeight(long SourceHeight);\n    STDMETHODIMP get_SourceHeight(__out long *pSourceHeight);\n    STDMETHODIMP put_DestinationLeft(long DestinationLeft);\n    STDMETHODIMP get_DestinationLeft(__out long *pDestinationLeft);\n    STDMETHODIMP put_DestinationWidth(long DestinationWidth);\n    STDMETHODIMP get_DestinationWidth(__out long *pDestinationWidth);\n    STDMETHODIMP put_DestinationTop(long DestinationTop);\n    STDMETHODIMP get_DestinationTop(__out long *pDestinationTop);\n    STDMETHODIMP put_DestinationHeight(long DestinationHeight);\n    STDMETHODIMP get_DestinationHeight(__out long *pDestinationHeight);\n\n    // And these are the methods\n\n    STDMETHODIMP GetVideoSize(__out long *pWidth, __out long *pHeight);\n    STDMETHODIMP SetSourcePosition(long Left, long Top, long Width, long Height);\n    STDMETHODIMP GetSourcePosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight);\n    STDMETHODIMP GetVideoPaletteEntries(long StartIndex, long Entries, __out long *pRetrieved,\n                                        __out_ecount_part(Entries, *pRetrieved) long *pPalette);\n    STDMETHODIMP SetDefaultSourcePosition();\n    STDMETHODIMP IsUsingDefaultSource();\n    STDMETHODIMP SetDestinationPosition(long Left, long Top, long Width, long Height);\n    STDMETHODIMP GetDestinationPosition(__out long *pLeft, __out long *pTop, __out long *pWidth, __out long *pHeight);\n    STDMETHODIMP SetDefaultDestinationPosition();\n    STDMETHODIMP IsUsingDefaultDestination();\n    STDMETHODIMP GetCurrentImage(__inout long *pBufferSize,\n                                 __out_bcount_part(*pBufferSize, *pBufferSize) long *pVideoImage);\n};\n\n#endif // __WINCTRL__\n"
  },
  {
    "path": "common/baseclasses/winutil.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: WinUtil.cpp\n//\n// Desc: DirectShow base classes - implements generic window handler class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#include <limits.h>\n#include <dvdmedia.h>\n#include <strsafe.h>\n#include <checkbmi.h>\n\nstatic UINT MsgDestroy;\n\n// Constructor\n\nCBaseWindow::CBaseWindow(BOOL bDoGetDC, bool bDoPostToDestroy)\n    : m_hInstance(g_hInst)\n    , m_hwnd(NULL)\n    , m_hdc(NULL)\n    , m_bActivated(FALSE)\n    , m_pClassName(NULL)\n    , m_ClassStyles(0)\n    , m_WindowStyles(0)\n    , m_WindowStylesEx(0)\n    , m_ShowStageMessage(0)\n    , m_ShowStageTop(0)\n    , m_MemoryDC(NULL)\n    , m_hPalette(NULL)\n    , m_bBackground(FALSE)\n    ,\n#ifdef DEBUG\n    m_bRealizing(FALSE)\n    ,\n#endif\n    m_bNoRealize(FALSE)\n    , m_bDoPostToDestroy(bDoPostToDestroy)\n{\n    m_bDoGetDC = bDoGetDC;\n}\n\n// Prepare a window by spinning off a worker thread to do the creation and\n// also poll the message input queue. We leave this to be called by derived\n// classes because they might want to override methods like MessageLoop and\n// InitialiseWindow, if we do this during construction they'll ALWAYS call\n// this base class methods. We make the worker thread create the window so\n// it owns it rather than the filter graph thread which is constructing us\n\nHRESULT CBaseWindow::PrepareWindow()\n{\n    if (m_hwnd)\n        return NOERROR;\n    ASSERT(m_hwnd == NULL);\n    ASSERT(m_hdc == NULL);\n\n    // Get the derived object's window and class styles\n\n    m_pClassName = GetClassWindowStyles(&m_ClassStyles, &m_WindowStyles, &m_WindowStylesEx);\n    if (m_pClassName == NULL)\n    {\n        return E_FAIL;\n    }\n\n    // Register our special private messages\n    m_ShowStageMessage = RegisterWindowMessage(SHOWSTAGE);\n\n    // RegisterWindowMessage() returns 0 if an error occurs.\n    if (0 == m_ShowStageMessage)\n    {\n        return AmGetLastErrorToHResult();\n    }\n\n    m_ShowStageTop = RegisterWindowMessage(SHOWSTAGETOP);\n    if (0 == m_ShowStageTop)\n    {\n        return AmGetLastErrorToHResult();\n    }\n\n    m_RealizePalette = RegisterWindowMessage(REALIZEPALETTE);\n    if (0 == m_RealizePalette)\n    {\n        return AmGetLastErrorToHResult();\n    }\n\n    MsgDestroy = RegisterWindowMessage(TEXT(\"AM_DESTROY\"));\n    if (0 == MsgDestroy)\n    {\n        return AmGetLastErrorToHResult();\n    }\n\n    return DoCreateWindow();\n}\n\n// Destructor just a placeholder so that we know it becomes virtual\n// Derived classes MUST call DoneWithWindow in their destructors so\n// that no messages arrive after the derived class constructor ends\n\n#ifdef DEBUG\nCBaseWindow::~CBaseWindow()\n{\n    ASSERT(m_hwnd == NULL);\n    ASSERT(m_hdc == NULL);\n}\n#endif\n\n// We use the sync worker event to have the window destroyed. All we do is\n// signal the event and wait on the window thread handle. Trying to send it\n// messages causes too many problems, furthermore to be on the safe side we\n// just wait on the thread handle while it returns WAIT_TIMEOUT or there is\n// a sent message to process on this thread. If the constructor failed to\n// create the thread in the first place then the loop will get terminated\n\nHRESULT CBaseWindow::DoneWithWindow()\n{\n    if (!IsWindow(m_hwnd) || (GetWindowThreadProcessId(m_hwnd, NULL) != GetCurrentThreadId()))\n    {\n\n        if (IsWindow(m_hwnd))\n        {\n\n            // This code should only be executed if the window exists and if the window's\n            // messages are processed on a different thread.\n            ASSERT(GetWindowThreadProcessId(m_hwnd, NULL) != GetCurrentThreadId());\n\n            if (m_bDoPostToDestroy)\n            {\n\n                HRESULT hr = S_OK;\n                CAMEvent m_evDone(FALSE, &hr);\n                if (FAILED(hr))\n                {\n                    return hr;\n                }\n\n                //  We must post a message to destroy the window\n                //  That way we can't be in the middle of processing a\n                //  message posted to our window when we do go away\n                //  Sending a message gives less synchronization.\n                PostMessage(m_hwnd, MsgDestroy, (WPARAM)(HANDLE)m_evDone, 0);\n                WaitDispatchingMessages(m_evDone, INFINITE);\n            }\n            else\n            {\n                SendMessage(m_hwnd, MsgDestroy, 0, 0);\n            }\n        }\n\n        //\n        // This is not a leak, the window manager automatically free's\n        // hdc's that were got via GetDC, which is the case here.\n        // We set it to NULL so that we don't get any asserts later.\n        //\n        m_hdc = NULL;\n\n        //\n        // We need to free this DC though because USER32 does not know\n        // anything about it.\n        //\n        if (m_MemoryDC)\n        {\n            EXECUTE_ASSERT(DeleteDC(m_MemoryDC));\n            m_MemoryDC = NULL;\n        }\n\n        // Reset the window variables\n        m_hwnd = NULL;\n\n        return NOERROR;\n    }\n    const HWND hwnd = m_hwnd;\n    if (hwnd == NULL)\n    {\n        return NOERROR;\n    }\n\n    InactivateWindow();\n    NOTE(\"Inactivated\");\n\n    // Reset the window styles before destruction\n\n    SetWindowLong(hwnd, GWL_STYLE, m_WindowStyles);\n    ASSERT(GetParent(hwnd) == NULL);\n    NOTE1(\"Reset window styles %d\", m_WindowStyles);\n\n    //  UnintialiseWindow sets m_hwnd to NULL so save a copy\n    UninitialiseWindow();\n    DbgLog((LOG_TRACE, 2, TEXT(\"Destroying 0x%8.8X\"), hwnd));\n    if (!DestroyWindow(hwnd))\n    {\n        DbgLog((LOG_TRACE, 0, TEXT(\"DestroyWindow %8.8X failed code %d\"), hwnd, GetLastError()));\n        DbgBreak(\"\");\n    }\n\n    // Reset our state so we can be prepared again\n\n    m_pClassName = NULL;\n    m_ClassStyles = 0;\n    m_WindowStyles = 0;\n    m_WindowStylesEx = 0;\n    m_ShowStageMessage = 0;\n    m_ShowStageTop = 0;\n\n    return NOERROR;\n}\n\n// Called at the end to put the window in an inactive state. The pending list\n// will always have been cleared by this time so event if the worker thread\n// gets has been signaled and gets in to render something it will find both\n// the state has been changed and that there are no available sample images\n// Since we wait on the window thread to complete we don't lock the object\n\nHRESULT CBaseWindow::InactivateWindow()\n{\n    // Has the window been activated\n    if (m_bActivated == FALSE)\n    {\n        return S_FALSE;\n    }\n\n    m_bActivated = FALSE;\n    ShowWindow(m_hwnd, SW_HIDE);\n    return NOERROR;\n}\n\nHRESULT CBaseWindow::CompleteConnect()\n{\n    m_bActivated = FALSE;\n    return NOERROR;\n}\n\n// This displays a normal window. We ask the base window class for default\n// sizes which unless overriden will return DEFWIDTH and DEFHEIGHT. We go\n// through a couple of extra hoops to get the client area the right size\n// as the object specifies which accounts for the AdjustWindowRectEx calls\n// We also DWORD align the left and top coordinates of the window here to\n// maximise the chance of being able to use DCI/DirectDraw primary surface\n\nHRESULT CBaseWindow::ActivateWindow()\n{\n    // Has the window been sized and positioned already\n\n    if (m_bActivated == TRUE || GetParent(m_hwnd) != NULL)\n    {\n\n        SetWindowPos(m_hwnd,          // Our window handle\n                     HWND_TOP,        // Put it at the top\n                     0, 0, 0, 0,      // Leave in current position\n                     SWP_NOMOVE |     // Don't change it's place\n                         SWP_NOSIZE); // Change Z-order only\n\n        m_bActivated = TRUE;\n        return S_FALSE;\n    }\n\n    // Calculate the desired client rectangle\n\n    RECT WindowRect, ClientRect = GetDefaultRect();\n    GetWindowRect(m_hwnd, &WindowRect);\n    AdjustWindowRectEx(&ClientRect, GetWindowLong(m_hwnd, GWL_STYLE), FALSE, GetWindowLong(m_hwnd, GWL_EXSTYLE));\n\n    // Align left and top edges on DWORD boundaries\n\n    UINT WindowFlags = (SWP_NOACTIVATE | SWP_FRAMECHANGED);\n    WindowRect.left -= (WindowRect.left & 3);\n    WindowRect.top -= (WindowRect.top & 3);\n\n    SetWindowPos(m_hwnd,              // Window handle\n                 HWND_TOP,            // Put it at the top\n                 WindowRect.left,     // Align left edge\n                 WindowRect.top,      // And also top place\n                 WIDTH(&ClientRect),  // Horizontal size\n                 HEIGHT(&ClientRect), // Vertical size\n                 WindowFlags);        // Don't show window\n\n    m_bActivated = TRUE;\n    return NOERROR;\n}\n\n// This can be used to DWORD align the window for maximum performance\n\nHRESULT CBaseWindow::PerformanceAlignWindow()\n{\n    RECT ClientRect, WindowRect;\n    GetWindowRect(m_hwnd, &WindowRect);\n    ASSERT(m_bActivated == TRUE);\n\n    // Don't do this if we're owned\n\n    if (GetParent(m_hwnd))\n    {\n        return NOERROR;\n    }\n\n    // Align left and top edges on DWORD boundaries\n\n    GetClientRect(m_hwnd, &ClientRect);\n    MapWindowPoints(m_hwnd, HWND_DESKTOP, (LPPOINT)&ClientRect, 2);\n    WindowRect.left -= (ClientRect.left & 3);\n    WindowRect.top -= (ClientRect.top & 3);\n    UINT WindowFlags = (SWP_NOACTIVATE | SWP_NOSIZE);\n\n    SetWindowPos(m_hwnd,          // Window handle\n                 HWND_TOP,        // Put it at the top\n                 WindowRect.left, // Align left edge\n                 WindowRect.top,  // And also top place\n                 (int)0, (int)0,  // Ignore these sizes\n                 WindowFlags);    // Don't show window\n\n    return NOERROR;\n}\n\n// Install a palette into the base window - we may be called by a different\n// thread to the one that owns the window. We have to be careful how we do\n// the palette realisation as we could be a different thread to the window\n// which would cause an inter thread send message. Therefore we realise the\n// palette by sending it a special message but without the window locked\n\nHRESULT CBaseWindow::SetPalette(HPALETTE hPalette)\n{\n    // We must own the window lock during the change\n    {\n        CAutoLock cWindowLock(&m_WindowLock);\n        CAutoLock cPaletteLock(&m_PaletteLock);\n        ASSERT(hPalette);\n        m_hPalette = hPalette;\n    }\n    return SetPalette();\n}\n\nHRESULT CBaseWindow::SetPalette()\n{\n    if (!m_bNoRealize)\n    {\n        SendMessage(m_hwnd, m_RealizePalette, 0, 0);\n        return S_OK;\n    }\n    else\n    {\n        // Just select the palette\n        ASSERT(m_hdc);\n        ASSERT(m_MemoryDC);\n\n        CAutoLock cPaletteLock(&m_PaletteLock);\n        SelectPalette(m_hdc, m_hPalette, m_bBackground);\n        SelectPalette(m_MemoryDC, m_hPalette, m_bBackground);\n\n        return S_OK;\n    }\n}\n\nvoid CBaseWindow::UnsetPalette()\n{\n    CAutoLock cWindowLock(&m_WindowLock);\n    CAutoLock cPaletteLock(&m_PaletteLock);\n\n    // Get a standard VGA colour palette\n\n    HPALETTE hPalette = (HPALETTE)GetStockObject(DEFAULT_PALETTE);\n    ASSERT(hPalette);\n\n    SelectPalette(GetWindowHDC(), hPalette, TRUE);\n    SelectPalette(GetMemoryHDC(), hPalette, TRUE);\n\n    m_hPalette = NULL;\n}\n\nvoid CBaseWindow::LockPaletteLock()\n{\n    m_PaletteLock.Lock();\n}\n\nvoid CBaseWindow::UnlockPaletteLock()\n{\n    m_PaletteLock.Unlock();\n}\n\n// Realise our palettes in the window and device contexts\n\nHRESULT CBaseWindow::DoRealisePalette(BOOL bForceBackground)\n{\n    {\n        CAutoLock cPaletteLock(&m_PaletteLock);\n\n        if (m_hPalette == NULL)\n        {\n            return NOERROR;\n        }\n\n        // Realize the palette on the window thread\n        ASSERT(m_hdc);\n        ASSERT(m_MemoryDC);\n\n        SelectPalette(m_hdc, m_hPalette, m_bBackground || bForceBackground);\n        SelectPalette(m_MemoryDC, m_hPalette, m_bBackground);\n    }\n\n    //  If we grab a critical section here we can deadlock\n    //  with the window thread because one of the side effects\n    //  of RealizePalette is to send a WM_PALETTECHANGED message\n    //  to every window in the system.  In our handling\n    //  of WM_PALETTECHANGED we used to grab this CS too.\n    //  The really bad case is when our renderer calls DoRealisePalette()\n    //  while we're in the middle of processing a palette change\n    //  for another window.\n    //  So don't hold the critical section while actually realising\n    //  the palette.  In any case USER is meant to manage palette\n    //  handling - we shouldn't have to serialize everything as well\n    ASSERT(CritCheckOut(&m_WindowLock));\n    ASSERT(CritCheckOut(&m_PaletteLock));\n\n    EXECUTE_ASSERT(RealizePalette(m_hdc) != GDI_ERROR);\n    EXECUTE_ASSERT(RealizePalette(m_MemoryDC) != GDI_ERROR);\n\n    return (GdiFlush() == FALSE ? S_FALSE : S_OK);\n}\n\n// This is the global window procedure\n\nLRESULT CALLBACK WndProc(HWND hwnd,     // Window handle\n                         UINT uMsg,     // Message ID\n                         WPARAM wParam, // First parameter\n                         LPARAM lParam) // Other parameter\n{\n\n    // Get the window long that holds our window object pointer\n    // If it is NULL then we are initialising the window in which\n    // case the object pointer has been passed in the window creation\n    // structure.  IF we get any messages before WM_NCCREATE we will\n    // pass them to DefWindowProc.\n\n    CBaseWindow *pBaseWindow = _GetWindowLongPtr<CBaseWindow *>(hwnd, 0);\n\n    if (pBaseWindow == NULL)\n    {\n\n        // Get the structure pointer from the create struct.\n        // We can only do this for WM_NCCREATE which should be one of\n        // the first messages we receive.  Anything before this will\n        // have to be passed to DefWindowProc (i.e. WM_GETMINMAXINFO)\n\n        // If the message is WM_NCCREATE we set our pBaseWindow pointer\n        // and will then place it in the window structure\n\n        // turn off WS_EX_LAYOUTRTL style for quartz windows\n        if (uMsg == WM_NCCREATE)\n        {\n            SetWindowLong(hwnd, GWL_EXSTYLE, GetWindowLong(hwnd, GWL_EXSTYLE) & ~0x400000);\n        }\n\n        if ((uMsg != WM_NCCREATE) ||\n            (NULL == (pBaseWindow = *(CBaseWindow **)((LPCREATESTRUCT)lParam)->lpCreateParams)))\n        {\n            return (DefWindowProc(hwnd, uMsg, wParam, lParam));\n        }\n\n        // Set the window LONG to be the object who created us\n#ifdef DEBUG\n        SetLastError(0); // because of the way SetWindowLong works\n#endif\n\n        LONG_PTR rc = _SetWindowLongPtr(hwnd, (DWORD)0, pBaseWindow);\n\n#ifdef DEBUG\n        if (0 == rc)\n        {\n            // SetWindowLong MIGHT have failed.  (Read the docs which admit\n            // that it is awkward to work out if you have had an error.)\n            LONG lasterror = GetLastError();\n            ASSERT(0 == lasterror);\n            // If this is not the case we have not set the pBaseWindow pointer\n            // into the window structure and we will blow up.\n        }\n#endif\n    }\n    // See if this is the packet of death\n    if (uMsg == MsgDestroy && uMsg != 0)\n    {\n        pBaseWindow->DoneWithWindow();\n        if (pBaseWindow->m_bDoPostToDestroy)\n        {\n            EXECUTE_ASSERT(SetEvent((HANDLE)wParam));\n        }\n        return 0;\n    }\n    return pBaseWindow->OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n\n// When the window size changes we adjust our member variables that\n// contain the dimensions of the client rectangle for our window so\n// that we come to render an image we will know whether to stretch\n\nBOOL CBaseWindow::OnSize(LONG Width, LONG Height)\n{\n    m_Width = Width;\n    m_Height = Height;\n    return TRUE;\n}\n\n// This function handles the WM_CLOSE message\n\nBOOL CBaseWindow::OnClose()\n{\n    ShowWindow(m_hwnd, SW_HIDE);\n    return TRUE;\n}\n\n// This is called by the worker window thread when it receives a terminate\n// message from the window object destructor to delete all the resources we\n// allocated during initialisation. By the time the worker thread exits all\n// processing will have been completed as the source filter disconnection\n// flushes the image pending sample, therefore the GdiFlush should succeed\n\nHRESULT CBaseWindow::UninitialiseWindow()\n{\n    // Have we already cleaned up\n\n    if (m_hwnd == NULL)\n    {\n        ASSERT(m_hdc == NULL);\n        ASSERT(m_MemoryDC == NULL);\n        return NOERROR;\n    }\n\n    // Release the window resources\n\n    EXECUTE_ASSERT(GdiFlush());\n\n    if (m_hdc)\n    {\n        EXECUTE_ASSERT(ReleaseDC(m_hwnd, m_hdc));\n        m_hdc = NULL;\n    }\n\n    if (m_MemoryDC)\n    {\n        EXECUTE_ASSERT(DeleteDC(m_MemoryDC));\n        m_MemoryDC = NULL;\n    }\n\n    // Reset the window variables\n    m_hwnd = NULL;\n\n    return NOERROR;\n}\n\n// This is called by the worker window thread after it has created the main\n// window and it wants to initialise the rest of the owner objects window\n// variables such as the device contexts. We execute this function with the\n// critical section still locked. Nothing in this function must generate any\n// SendMessage calls to the window because this is executing on the window\n// thread so the message will never be processed and we will deadlock\n\nHRESULT CBaseWindow::InitialiseWindow(HWND hwnd)\n{\n    // Initialise the window variables\n\n    ASSERT(IsWindow(hwnd));\n    m_hwnd = hwnd;\n\n    if (m_bDoGetDC)\n    {\n        EXECUTE_ASSERT(m_hdc = GetDC(hwnd));\n        EXECUTE_ASSERT(m_MemoryDC = CreateCompatibleDC(m_hdc));\n\n        EXECUTE_ASSERT(SetStretchBltMode(m_hdc, COLORONCOLOR));\n        EXECUTE_ASSERT(SetStretchBltMode(m_MemoryDC, COLORONCOLOR));\n    }\n\n    return NOERROR;\n}\n\nHRESULT CBaseWindow::DoCreateWindow()\n{\n    WNDCLASS wndclass; // Used to register classes\n    BOOL bRegistered;  // Is this class registered\n    HWND hwnd;         // Handle to our window\n\n    bRegistered = GetClassInfo(m_hInstance,  // Module instance\n                               m_pClassName, // Window class\n                               &wndclass);   // Info structure\n\n    // if the window is to be used for drawing puposes and we are getting a DC\n    // for the entire lifetime of the window then changes the class style to do\n    // say so. If we don't set this flag then the DC comes from the cache and is\n    // really bad.\n    if (m_bDoGetDC)\n    {\n        m_ClassStyles |= CS_OWNDC;\n    }\n\n    if (bRegistered == FALSE)\n    {\n\n        // Register the renderer window class\n\n        wndclass.lpszClassName = m_pClassName;\n        wndclass.style = m_ClassStyles;\n        wndclass.lpfnWndProc = WndProc;\n        wndclass.cbClsExtra = 0;\n        wndclass.cbWndExtra = sizeof(CBaseWindow *);\n        wndclass.hInstance = m_hInstance;\n        wndclass.hIcon = NULL;\n        wndclass.hCursor = LoadCursor(NULL, IDC_ARROW);\n        wndclass.hbrBackground = (HBRUSH)NULL;\n        wndclass.lpszMenuName = NULL;\n\n        RegisterClass(&wndclass);\n    }\n\n    // Create the frame window.  Pass the pBaseWindow information in the\n    // CreateStruct which allows our message handling loop to get hold of\n    // the pBaseWindow pointer.\n\n    CBaseWindow *pBaseWindow = this;                  // The owner window object\n    hwnd = CreateWindowEx(m_WindowStylesEx,           // Extended styles\n                          m_pClassName,               // Registered name\n                          TEXT(\"ActiveMovie Window\"), // Window title\n                          m_WindowStyles,             // Window styles\n                          CW_USEDEFAULT,              // Start x position\n                          CW_USEDEFAULT,              // Start y position\n                          DEFWIDTH,                   // Window width\n                          DEFHEIGHT,                  // Window height\n                          NULL,                       // Parent handle\n                          NULL,                       // Menu handle\n                          m_hInstance,                // Instance handle\n                          &pBaseWindow);              // Creation data\n\n    // If we failed signal an error to the object constructor (based on the\n    // last Win32 error on this thread) then signal the constructor thread\n    // to continue, release the mutex to let others have a go and exit\n\n    if (hwnd == NULL)\n    {\n        DWORD Error = GetLastError();\n        return AmHresultFromWin32(Error);\n    }\n\n    // Check the window LONG is the object who created us\n    ASSERT(GetWindowLongPtr(hwnd, 0) == (LONG_PTR)this);\n\n    // Initialise the window and then signal the constructor so that it can\n    // continue and then finally unlock the object's critical section. The\n    // window class is left registered even after we terminate the thread\n    // as we don't know when the last window has been closed. So we allow\n    // the operating system to free the class resources as appropriate\n\n    InitialiseWindow(hwnd);\n\n    DbgLog((LOG_TRACE, 2, TEXT(\"Created window class (%s) HWND(%8.8X)\"), m_pClassName, hwnd));\n\n    return S_OK;\n}\n\n// The base class provides some default handling and calls DefWindowProc\n\nLRESULT CBaseWindow::OnReceiveMessage(HWND hwnd,     // Window handle\n                                      UINT uMsg,     // Message ID\n                                      WPARAM wParam, // First parameter\n                                      LPARAM lParam) // Other parameter\n{\n    ASSERT(IsWindow(hwnd));\n\n    if (PossiblyEatMessage(uMsg, wParam, lParam))\n        return 0;\n\n    // This is sent by the IVideoWindow SetWindowForeground method. If the\n    // window is invisible we will show it and make it topmost without the\n    // foreground focus. If the window is visible it will also be made the\n    // topmost window without the foreground focus. If wParam is TRUE then\n    // for both cases the window will be forced into the foreground focus\n\n    if (uMsg == m_ShowStageMessage)\n    {\n\n        BOOL bVisible = IsWindowVisible(hwnd);\n        SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0,\n                     SWP_NOMOVE | SWP_NOSIZE | SWP_SHOWWINDOW | (bVisible ? SWP_NOACTIVATE : 0));\n\n        // Should we bring the window to the foreground\n        if (wParam == TRUE)\n        {\n            SetForegroundWindow(hwnd);\n        }\n        return (LRESULT)1;\n    }\n\n    // When we go fullscreen we have to add the WS_EX_TOPMOST style to the\n    // video window so that it comes out above any task bar (this is more\n    // relevant to WindowsNT than Windows95). However the SetWindowPos call\n    // must be on the same thread as that which created the window. The\n    // wParam parameter can be TRUE or FALSE to set and reset the topmost\n\n    if (uMsg == m_ShowStageTop)\n    {\n        HWND HwndTop = (wParam == TRUE ? HWND_TOPMOST : HWND_NOTOPMOST);\n        BOOL bVisible = IsWindowVisible(hwnd);\n        SetWindowPos(hwnd, HwndTop, 0, 0, 0, 0,\n                     SWP_NOMOVE | SWP_NOSIZE | (wParam == TRUE ? SWP_SHOWWINDOW : 0) | (bVisible ? SWP_NOACTIVATE : 0));\n        return (LRESULT)1;\n    }\n\n    // New palette stuff\n    if (uMsg == m_RealizePalette)\n    {\n        ASSERT(m_hwnd == hwnd);\n        return OnPaletteChange(m_hwnd, WM_QUERYNEWPALETTE);\n    }\n\n    switch (uMsg)\n    {\n\n        // Repaint the window if the system colours change\n\n    case WM_SYSCOLORCHANGE: InvalidateRect(hwnd, NULL, FALSE); return (LRESULT)1;\n\n    // Somebody has changed the palette\n    case WM_PALETTECHANGED:\n\n        OnPaletteChange((HWND)wParam, uMsg);\n        return (LRESULT)0;\n\n        // We are about to receive the keyboard focus so we ask GDI to realise\n        // our logical palette again and hopefully it will be fully installed\n        // without any mapping having to be done during any picture rendering\n\n    case WM_QUERYNEWPALETTE: ASSERT(m_hwnd == hwnd); return OnPaletteChange(m_hwnd, uMsg);\n\n    // do NOT fwd WM_MOVE. the parameters are the location of the parent\n    // window, NOT what the renderer should be looking at.  But we need\n    // to make sure the overlay is moved with the parent window, so we\n    // do this.\n    case WM_MOVE:\n        if (IsWindowVisible(m_hwnd))\n        {\n            PostMessage(m_hwnd, WM_PAINT, 0, 0);\n        }\n        break;\n\n        // Store the width and height as useful base class members\n\n    case WM_SIZE:\n\n        OnSize(LOWORD(lParam), HIWORD(lParam));\n        return (LRESULT)0;\n\n        // Intercept the WM_CLOSE messages to hide the window\n\n    case WM_CLOSE: OnClose(); return (LRESULT)0;\n    }\n    return DefWindowProc(hwnd, uMsg, wParam, lParam);\n}\n\n// This handles the Windows palette change messages - if we do realise our\n// palette then we return TRUE otherwise we return FALSE. If our window is\n// foreground application then we should get first choice of colours in the\n// system palette entries. We get best performance when our logical palette\n// includes the standard VGA colours (at the beginning and end) otherwise\n// GDI may have to map from our palette to the device palette while drawing\n\nLRESULT CBaseWindow::OnPaletteChange(HWND hwnd, UINT Message)\n{\n    // First check we are not changing the palette during closedown\n\n    if (m_hwnd == NULL || hwnd == NULL)\n    {\n        return (LRESULT)0;\n    }\n    ASSERT(!m_bRealizing);\n\n    // Should we realise our palette again\n\n    if ((Message == WM_QUERYNEWPALETTE || hwnd != m_hwnd))\n    {\n        //  It seems that even if we're invisible that we can get asked\n        //  to realize our palette and this can cause really ugly side-effects\n        //  Seems like there's another bug but this masks it a least for the\n        //  shutting down case.\n        if (!IsWindowVisible(m_hwnd))\n        {\n            DbgLog((LOG_TRACE, 1, TEXT(\"Realizing when invisible!\")));\n            return (LRESULT)0;\n        }\n\n        // Avoid recursion with multiple graphs in the same app\n#ifdef DEBUG\n        m_bRealizing = TRUE;\n#endif\n        DoRealisePalette(Message != WM_QUERYNEWPALETTE);\n#ifdef DEBUG\n        m_bRealizing = FALSE;\n#endif\n\n        // Should we redraw the window with the new palette\n        if (Message == WM_PALETTECHANGED)\n        {\n            InvalidateRect(m_hwnd, NULL, FALSE);\n        }\n    }\n\n    return (LRESULT)1;\n}\n\n// Determine if the window exists.\n\nbool CBaseWindow::WindowExists()\n{\n    return !!IsWindow(m_hwnd);\n}\n\n// Return the default window rectangle\n\nRECT CBaseWindow::GetDefaultRect()\n{\n    RECT DefaultRect = {0, 0, DEFWIDTH, DEFHEIGHT};\n    ASSERT(m_hwnd);\n    // ASSERT(m_hdc);\n    return DefaultRect;\n}\n\n// Return the current window width\n\nLONG CBaseWindow::GetWindowWidth()\n{\n    ASSERT(m_hwnd);\n    // ASSERT(m_hdc);\n    return m_Width;\n}\n\n// Return the current window height\n\nLONG CBaseWindow::GetWindowHeight()\n{\n    ASSERT(m_hwnd);\n    // ASSERT(m_hdc);\n    return m_Height;\n}\n\n// Return the window handle\n\nHWND CBaseWindow::GetWindowHWND()\n{\n    ASSERT(m_hwnd);\n    // ASSERT(m_hdc);\n    return m_hwnd;\n}\n\n// Return the window drawing device context\n\nHDC CBaseWindow::GetWindowHDC()\n{\n    ASSERT(m_hwnd);\n    ASSERT(m_hdc);\n    return m_hdc;\n}\n\n// Return the offscreen window drawing device context\n\nHDC CBaseWindow::GetMemoryHDC()\n{\n    ASSERT(m_hwnd);\n    ASSERT(m_MemoryDC);\n    return m_MemoryDC;\n}\n\n#ifdef DEBUG\nHPALETTE CBaseWindow::GetPalette()\n{\n    // The palette lock should always be held when accessing\n    // m_hPalette.\n    ASSERT(CritCheckIn(&m_PaletteLock));\n    return m_hPalette;\n}\n#endif // DEBUG\n\n// This is available to clients who want to change the window visiblity. It's\n// little more than an indirection to the Win32 ShowWindow although these is\n// some benefit in going through here as this function may change sometime\n\nHRESULT CBaseWindow::DoShowWindow(LONG ShowCmd)\n{\n    ShowWindow(m_hwnd, ShowCmd);\n    return NOERROR;\n}\n\n// Generate a WM_PAINT message for the video window\n\nvoid CBaseWindow::PaintWindow(BOOL bErase)\n{\n    InvalidateRect(m_hwnd, NULL, bErase);\n}\n\n// Allow an application to have us set the video window in the foreground. We\n// have this because it is difficult for one thread to do do this to a window\n// owned by another thread. Rather than expose the message we use to execute\n// the inter thread send message we provide the interface function. All we do\n// is to SendMessage to the video window renderer thread with a WM_SHOWSTAGE\n\nvoid CBaseWindow::DoSetWindowForeground(BOOL bFocus)\n{\n    SendMessage(m_hwnd, m_ShowStageMessage, (WPARAM)bFocus, (LPARAM)0);\n}\n\n// Constructor initialises the owning object pointer. Since we are a worker\n// class for the main window object we have relatively few state variables to\n// look after. We are given device context handles to use later on as well as\n// the source and destination rectangles (but reset them here just in case)\n\nCDrawImage::CDrawImage(__inout CBaseWindow *pBaseWindow)\n    : m_pBaseWindow(pBaseWindow)\n    , m_hdc(NULL)\n    , m_MemoryDC(NULL)\n    , m_bStretch(FALSE)\n    , m_pMediaType(NULL)\n    , m_bUsingImageAllocator(FALSE)\n{\n    ASSERT(pBaseWindow);\n    ResetPaletteVersion();\n    SetRectEmpty(&m_TargetRect);\n    SetRectEmpty(&m_SourceRect);\n\n    m_perfidRenderTime = MSR_REGISTER(TEXT(\"Single Blt time\"));\n}\n\n// Overlay the image time stamps on the picture. Access to this method is\n// serialised by the caller. We display the sample start and end times on\n// top of the video using TextOut on the device context we are handed. If\n// there isn't enough room in the window for the times we don't show them\n\nvoid CDrawImage::DisplaySampleTimes(IMediaSample *pSample)\n{\n#ifdef DEBUG\n    //\n    // Only allow the \"annoying\" time messages if the users has turned the\n    // logging \"way up\"\n    //\n    BOOL bAccept = DbgCheckModuleLevel(LOG_TRACE, 5);\n    if (bAccept == FALSE)\n    {\n        return;\n    }\n#endif\n\n    TCHAR szTimes[TIMELENGTH]; // Time stamp strings\n    ASSERT(pSample);           // Quick sanity check\n    RECT ClientRect;           // Client window size\n    SIZE Size;                 // Size of text output\n\n    // Get the time stamps and window size\n\n    pSample->GetTime((REFERENCE_TIME *)&m_StartSample, (REFERENCE_TIME *)&m_EndSample);\n    HWND hwnd = m_pBaseWindow->GetWindowHWND();\n    EXECUTE_ASSERT(GetClientRect(hwnd, &ClientRect));\n\n    // Format the sample time stamps\n\n    (void)StringCchPrintf(szTimes, NUMELMS(szTimes), TEXT(\"%08d : %08d\"), m_StartSample.Millisecs(),\n                          m_EndSample.Millisecs());\n\n    ASSERT(lstrlen(szTimes) < TIMELENGTH);\n\n    // Put the times in the middle at the bottom of the window\n\n    GetTextExtentPoint32(m_hdc, szTimes, lstrlen(szTimes), &Size);\n    INT XPos = ((ClientRect.right - ClientRect.left) - Size.cx) / 2;\n    INT YPos = ((ClientRect.bottom - ClientRect.top) - Size.cy) * 4 / 5;\n\n    // Check the window is big enough to have sample times displayed\n\n    if ((XPos > 0) && (YPos > 0))\n    {\n        TextOut(m_hdc, XPos, YPos, szTimes, lstrlen(szTimes));\n    }\n}\n\n// This is called when the drawing code sees that the image has a down level\n// palette cookie. We simply call the SetDIBColorTable Windows API with the\n// palette that is found after the BITMAPINFOHEADER - we return no errors\n\nvoid CDrawImage::UpdateColourTable(HDC hdc, __in BITMAPINFOHEADER *pbmi)\n{\n    ASSERT(pbmi->biClrUsed);\n    RGBQUAD *pColourTable = (RGBQUAD *)(pbmi + 1);\n\n    // Set the new palette in the device context\n\n    UINT uiReturn = SetDIBColorTable(hdc, (UINT)0, pbmi->biClrUsed, pColourTable);\n\n    // Should always succeed but check in debug builds\n    ASSERT(uiReturn == pbmi->biClrUsed);\n}\n\n// No source rectangle scaling is done by the base class\n\nRECT CDrawImage::ScaleSourceRect(const RECT *pSource)\n{\n    ASSERT(pSource);\n    return *pSource;\n}\n\n// This is called when the funky output pin uses our allocator. The samples we\n// allocate are special because the memory is shared between us and GDI thus\n// removing one copy when we ask for the image to be rendered. The source type\n// information is in the main renderer m_mtIn field which is initialised when\n// the media type is agreed in SetMediaType, the media type may be changed on\n// the fly if, for example, the source filter needs to change the palette\n\nvoid CDrawImage::FastRender(IMediaSample *pMediaSample)\n{\n    BITMAPINFOHEADER *pbmi; // Image format data\n    DIBDATA *pDibData;      // Stores DIB information\n    BYTE *pImage;           // Pointer to image data\n    HBITMAP hOldBitmap;     // Store the old bitmap\n    CImageSample *pSample;  // Pointer to C++ object\n\n    ASSERT(m_pMediaType);\n\n    // From the untyped source format block get the VIDEOINFO and subsequently\n    // the BITMAPINFOHEADER structure. We can cast the IMediaSample interface\n    // to a CImageSample object so we can retrieve it's DIBSECTION details\n\n    pbmi = HEADER(m_pMediaType->Format());\n    pSample = (CImageSample *)pMediaSample;\n    pDibData = pSample->GetDIBData();\n    hOldBitmap = (HBITMAP)SelectObject(m_MemoryDC, pDibData->hBitmap);\n\n    // Get a pointer to the real image data\n\n    HRESULT hr = pMediaSample->GetPointer(&pImage);\n    if (FAILED(hr))\n    {\n        return;\n    }\n\n    // Do we need to update the colour table, we increment our palette cookie\n    // each time we get a dynamic format change. The sample palette cookie is\n    // stored in the DIBDATA structure so we try to keep the fields in sync\n    // By the time we get to draw the images the format change will be done\n    // so all we do is ask the renderer for what it's palette version is\n\n    if (pDibData->PaletteVersion < GetPaletteVersion())\n    {\n        ASSERT(pbmi->biBitCount <= iPALETTE);\n        UpdateColourTable(m_MemoryDC, pbmi);\n        pDibData->PaletteVersion = GetPaletteVersion();\n    }\n\n    // This allows derived classes to change the source rectangle that we do\n    // the drawing with. For example a renderer may ask a codec to stretch\n    // the video from 320x240 to 640x480, in which case the source we see in\n    // here will still be 320x240, although the source we want to draw with\n    // should be scaled up to 640x480. The base class implementation of this\n    // method does nothing but return the same rectangle as we are passed in\n\n    RECT SourceRect = ScaleSourceRect(&m_SourceRect);\n\n    // Is the window the same size as the video\n\n    if (m_bStretch == FALSE)\n    {\n\n        // Put the image straight into the window\n\n        BitBlt((HDC)m_hdc,                             // Target device HDC\n               m_TargetRect.left,                      // X sink position\n               m_TargetRect.top,                       // Y sink position\n               m_TargetRect.right - m_TargetRect.left, // Destination width\n               m_TargetRect.bottom - m_TargetRect.top, // Destination height\n               m_MemoryDC,                             // Source device context\n               SourceRect.left,                        // X source position\n               SourceRect.top,                         // Y source position\n               SRCCOPY);                               // Simple copy\n    }\n    else\n    {\n\n        // Stretch the image when copying to the window\n\n        StretchBlt((HDC)m_hdc,                             // Target device HDC\n                   m_TargetRect.left,                      // X sink position\n                   m_TargetRect.top,                       // Y sink position\n                   m_TargetRect.right - m_TargetRect.left, // Destination width\n                   m_TargetRect.bottom - m_TargetRect.top, // Destination height\n                   m_MemoryDC,                             // Source device HDC\n                   SourceRect.left,                        // X source position\n                   SourceRect.top,                         // Y source position\n                   SourceRect.right - SourceRect.left,     // Source width\n                   SourceRect.bottom - SourceRect.top,     // Source height\n                   SRCCOPY);                               // Simple copy\n    }\n\n    // This displays the sample times over the top of the image. This used to\n    // draw the times into the offscreen device context however that actually\n    // writes the text into the image data buffer which may not be writable\n\n#ifdef DEBUG\n    DisplaySampleTimes(pMediaSample);\n#endif\n\n    // Put the old bitmap back into the device context so we don't leak\n    SelectObject(m_MemoryDC, hOldBitmap);\n}\n\n// This is called when there is a sample ready to be drawn, unfortunately the\n// output pin was being rotten and didn't choose our super excellent shared\n// memory DIB allocator so we have to do this slow render using boring old GDI\n// SetDIBitsToDevice and StretchDIBits. The down side of using these GDI\n// functions is that the image data has to be copied across from our address\n// space into theirs before going to the screen (although in reality the cost\n// is small because all they do is to map the buffer into their address space)\n\nvoid CDrawImage::SlowRender(IMediaSample *pMediaSample)\n{\n    // Get the BITMAPINFOHEADER for the connection\n\n    ASSERT(m_pMediaType);\n    BITMAPINFOHEADER *pbmi = HEADER(m_pMediaType->Format());\n    BYTE *pImage;\n\n    // Get the image data buffer\n\n    HRESULT hr = pMediaSample->GetPointer(&pImage);\n    if (FAILED(hr))\n    {\n        return;\n    }\n\n    // This allows derived classes to change the source rectangle that we do\n    // the drawing with. For example a renderer may ask a codec to stretch\n    // the video from 320x240 to 640x480, in which case the source we see in\n    // here will still be 320x240, although the source we want to draw with\n    // should be scaled up to 640x480. The base class implementation of this\n    // method does nothing but return the same rectangle as we are passed in\n\n    RECT SourceRect = ScaleSourceRect(&m_SourceRect);\n\n    LONG lAdjustedSourceTop = SourceRect.top;\n    // if the origin of bitmap is bottom-left, adjust soruce_rect_top\n    // to be the bottom-left corner instead of the top-left.\n    if (pbmi->biHeight > 0)\n    {\n        lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;\n    }\n    // Is the window the same size as the video\n\n    if (m_bStretch == FALSE)\n    {\n\n        // Put the image straight into the window\n\n        SetDIBitsToDevice((HDC)m_hdc,                             // Target device HDC\n                          m_TargetRect.left,                      // X sink position\n                          m_TargetRect.top,                       // Y sink position\n                          m_TargetRect.right - m_TargetRect.left, // Destination width\n                          m_TargetRect.bottom - m_TargetRect.top, // Destination height\n                          SourceRect.left,                        // X source position\n                          lAdjustedSourceTop,                     // Adjusted Y source position\n                          (UINT)0,                                // Start scan line\n                          pbmi->biHeight,                         // Scan lines present\n                          pImage,                                 // Image data\n                          (BITMAPINFO *)pbmi,                     // DIB header\n                          DIB_RGB_COLORS);                        // Type of palette\n    }\n    else\n    {\n\n        // Stretch the image when copying to the window\n\n        StretchDIBits((HDC)m_hdc,                             // Target device HDC\n                      m_TargetRect.left,                      // X sink position\n                      m_TargetRect.top,                       // Y sink position\n                      m_TargetRect.right - m_TargetRect.left, // Destination width\n                      m_TargetRect.bottom - m_TargetRect.top, // Destination height\n                      SourceRect.left,                        // X source position\n                      lAdjustedSourceTop,                     // Adjusted Y source position\n                      SourceRect.right - SourceRect.left,     // Source width\n                      SourceRect.bottom - SourceRect.top,     // Source height\n                      pImage,                                 // Image data\n                      (BITMAPINFO *)pbmi,                     // DIB header\n                      DIB_RGB_COLORS,                         // Type of palette\n                      SRCCOPY);                               // Simple image copy\n    }\n\n    // This shows the sample reference times over the top of the image which\n    // looks a little flickery. I tried using GdiSetBatchLimit and GdiFlush to\n    // control the screen updates but it doesn't quite work as expected and\n    // only partially reduces the flicker. I also tried using a memory context\n    // and combining the two in that before doing a final BitBlt operation to\n    // the screen, unfortunately this has considerable performance penalties\n    // and also means that this code is not executed when compiled retail\n\n#ifdef DEBUG\n    DisplaySampleTimes(pMediaSample);\n#endif\n}\n\n// This is called with an IMediaSample interface on the image to be drawn. We\n// decide on the drawing mechanism based on who's allocator we are using. We\n// may be called when the window wants an image painted by WM_PAINT messages\n// We can't realise the palette here because we have the renderer lock, any\n// call to realise may cause an interthread send message to the window thread\n// which may in turn be waiting to get the renderer lock before servicing it\n\nBOOL CDrawImage::DrawImage(IMediaSample *pMediaSample)\n{\n    ASSERT(m_hdc);\n    ASSERT(m_MemoryDC);\n    NotifyStartDraw();\n\n    // If the output pin used our allocator then the samples passed are in\n    // fact CVideoSample objects that contain CreateDIBSection data that we\n    // use to do faster image rendering, they may optionally also contain a\n    // DirectDraw surface pointer in which case we do not do the drawing\n\n    if (m_bUsingImageAllocator == FALSE)\n    {\n        SlowRender(pMediaSample);\n        EXECUTE_ASSERT(GdiFlush());\n        NotifyEndDraw();\n        return TRUE;\n    }\n\n    // This is a DIBSECTION buffer\n\n    FastRender(pMediaSample);\n    EXECUTE_ASSERT(GdiFlush());\n    NotifyEndDraw();\n    return TRUE;\n}\n\nBOOL CDrawImage::DrawVideoImageHere(HDC hdc, IMediaSample *pMediaSample, __in LPRECT lprcSrc, __in LPRECT lprcDst)\n{\n    ASSERT(m_pMediaType);\n    BITMAPINFOHEADER *pbmi = HEADER(m_pMediaType->Format());\n    BYTE *pImage;\n\n    // Get the image data buffer\n\n    HRESULT hr = pMediaSample->GetPointer(&pImage);\n    if (FAILED(hr))\n    {\n        return FALSE;\n    }\n\n    RECT SourceRect;\n    RECT TargetRect;\n\n    if (lprcSrc)\n    {\n        SourceRect = *lprcSrc;\n    }\n    else\n        SourceRect = ScaleSourceRect(&m_SourceRect);\n\n    if (lprcDst)\n    {\n        TargetRect = *lprcDst;\n    }\n    else\n        TargetRect = m_TargetRect;\n\n    LONG lAdjustedSourceTop = SourceRect.top;\n    // if the origin of bitmap is bottom-left, adjust soruce_rect_top\n    // to be the bottom-left corner instead of the top-left.\n    if (pbmi->biHeight > 0)\n    {\n        lAdjustedSourceTop = pbmi->biHeight - SourceRect.bottom;\n    }\n\n    // Stretch the image when copying to the DC\n\n    BOOL bRet = (0 != StretchDIBits(hdc, TargetRect.left, TargetRect.top, TargetRect.right - TargetRect.left,\n                                    TargetRect.bottom - TargetRect.top, SourceRect.left, lAdjustedSourceTop,\n                                    SourceRect.right - SourceRect.left, SourceRect.bottom - SourceRect.top, pImage,\n                                    (BITMAPINFO *)pbmi, DIB_RGB_COLORS, SRCCOPY));\n    return bRet;\n}\n\n// This is called by the owning window object after it has created the window\n// and it's drawing contexts. We are constructed with the base window we'll\n// be drawing into so when given the notification we retrive the device HDCs\n// to draw with. We cannot call these in our constructor as they are virtual\n\nvoid CDrawImage::SetDrawContext()\n{\n    m_MemoryDC = m_pBaseWindow->GetMemoryHDC();\n    m_hdc = m_pBaseWindow->GetWindowHDC();\n}\n\n// This is called to set the target rectangle in the video window, it will be\n// called whenever a WM_SIZE message is retrieved from the message queue. We\n// simply store the rectangle and use it later when we do the drawing calls\n\nvoid CDrawImage::SetTargetRect(__in RECT *pTargetRect)\n{\n    ASSERT(pTargetRect);\n    m_TargetRect = *pTargetRect;\n    SetStretchMode();\n}\n\n// Return the current target rectangle\n\nvoid CDrawImage::GetTargetRect(__out RECT *pTargetRect)\n{\n    ASSERT(pTargetRect);\n    *pTargetRect = m_TargetRect;\n}\n\n// This is called when we want to change the section of the image to draw. We\n// use this information in the drawing operation calls later on. We must also\n// see if the source and destination rectangles have the same dimensions. If\n// not we must stretch during the drawing rather than a direct pixel copy\n\nvoid CDrawImage::SetSourceRect(__in RECT *pSourceRect)\n{\n    ASSERT(pSourceRect);\n    m_SourceRect = *pSourceRect;\n    SetStretchMode();\n}\n\n// Return the current source rectangle\n\nvoid CDrawImage::GetSourceRect(__out RECT *pSourceRect)\n{\n    ASSERT(pSourceRect);\n    *pSourceRect = m_SourceRect;\n}\n\n// This is called when either the source or destination rectanges change so we\n// can update the stretch flag. If the rectangles don't match we stretch the\n// video during the drawing otherwise we call the fast pixel copy functions\n// NOTE the source and/or the destination rectangle may be completely empty\n\nvoid CDrawImage::SetStretchMode()\n{\n    // Calculate the overall rectangle dimensions\n\n    LONG SourceWidth = m_SourceRect.right - m_SourceRect.left;\n    LONG SinkWidth = m_TargetRect.right - m_TargetRect.left;\n    LONG SourceHeight = m_SourceRect.bottom - m_SourceRect.top;\n    LONG SinkHeight = m_TargetRect.bottom - m_TargetRect.top;\n\n    m_bStretch = TRUE;\n    if (SourceWidth == SinkWidth)\n    {\n        if (SourceHeight == SinkHeight)\n        {\n            m_bStretch = FALSE;\n        }\n    }\n}\n\n// Tell us whose allocator we are using. This should be called with TRUE if\n// the filter agrees to use an allocator based around the CImageAllocator\n// SDK base class - whose image buffers are made through CreateDIBSection.\n// Otherwise this should be called with FALSE and we will draw the images\n// using SetDIBitsToDevice and StretchDIBitsToDevice. None of these calls\n// can handle buffers which have non zero strides (like DirectDraw uses)\n\nvoid CDrawImage::NotifyAllocator(BOOL bUsingImageAllocator)\n{\n    m_bUsingImageAllocator = bUsingImageAllocator;\n}\n\n// Are we using the image DIBSECTION allocator\n\nBOOL CDrawImage::UsingImageAllocator()\n{\n    return m_bUsingImageAllocator;\n}\n\n// We need the media type of the connection so that we can get the BITMAPINFO\n// from it. We use that in the calls to draw the image such as StretchDIBits\n// and also when updating the colour table held in shared memory DIBSECTIONs\n\nvoid CDrawImage::NotifyMediaType(__in CMediaType *pMediaType)\n{\n    m_pMediaType = pMediaType;\n}\n\n// We store in this object a cookie maintaining the current palette version.\n// Each time a palettised format is changed we increment this value so that\n// when we come to draw the images we look at the colour table value they\n// have and if less than the current we know to update it. This version is\n// only needed and indeed used when working with shared memory DIBSECTIONs\n\nLONG CDrawImage::GetPaletteVersion()\n{\n    return m_PaletteVersion;\n}\n\n// Resets the current palette version number\n\nvoid CDrawImage::ResetPaletteVersion()\n{\n    m_PaletteVersion = PALETTE_VERSION;\n}\n\n// Increment the current palette version\n\nvoid CDrawImage::IncrementPaletteVersion()\n{\n    m_PaletteVersion++;\n}\n\n// Constructor must initialise the base allocator. Each sample we create has a\n// palette version cookie on board. When the source filter changes the palette\n// during streaming the window object increments an internal cookie counter it\n// keeps as well. When it comes to render the samples it looks at the cookie\n// values and if they don't match then it knows to update the sample's colour\n// table. However we always create samples with a cookie of PALETTE_VERSION\n// If there have been multiple format changes and we disconnect and reconnect\n// thereby causing the samples to be reallocated we will create them with a\n// cookie much lower than the current version, this isn't a problem since it\n// will be seen by the window object and the versions will then be updated\n\nCImageAllocator::CImageAllocator(__inout CBaseFilter *pFilter, __in_opt LPCTSTR pName, __inout HRESULT *phr)\n    : CBaseAllocator(pName, NULL, phr, TRUE, TRUE)\n    , m_pFilter(pFilter)\n{\n    ASSERT(phr);\n    ASSERT(pFilter);\n}\n\n// Check our DIB buffers have been released\n\n#ifdef DEBUG\nCImageAllocator::~CImageAllocator()\n{\n    ASSERT(m_bCommitted == FALSE);\n}\n#endif\n\n// Called from destructor and also from base class to free resources. We work\n// our way through the list of media samples deleting the DIBSECTION created\n// for each. All samples should be back in our list so there is no chance a\n// filter is still using one to write on the display or hold on a pending list\n\nvoid CImageAllocator::Free()\n{\n    ASSERT(m_lAllocated == m_lFree.GetCount());\n    EXECUTE_ASSERT(GdiFlush());\n    CImageSample *pSample;\n    DIBDATA *pDibData;\n\n    while (m_lFree.GetCount() != 0)\n    {\n        pSample = (CImageSample *)m_lFree.RemoveHead();\n        pDibData = pSample->GetDIBData();\n        EXECUTE_ASSERT(DeleteObject(pDibData->hBitmap));\n        EXECUTE_ASSERT(CloseHandle(pDibData->hMapping));\n        delete pSample;\n    }\n\n    m_lAllocated = 0;\n}\n\n// Prepare the allocator by checking all the input parameters\n\nSTDMETHODIMP CImageAllocator::CheckSizes(__in ALLOCATOR_PROPERTIES *pRequest)\n{\n    // Check we have a valid connection\n\n    if (m_pMediaType == NULL)\n    {\n        return VFW_E_NOT_CONNECTED;\n    }\n\n    // NOTE We always create a DIB section with the source format type which\n    // may contain a source palette. When we do the BitBlt drawing operation\n    // the target display device may contain a different palette (we may not\n    // have the focus) in which case GDI will do after the palette mapping\n\n    VIDEOINFOHEADER *pVideoInfo = (VIDEOINFOHEADER *)m_pMediaType->Format();\n\n    // When we call CreateDIBSection it implicitly maps only enough memory\n    // for the image as defined by thee BITMAPINFOHEADER. If the user asks\n    // for an image smaller than this then we reject the call, if they ask\n    // for an image larger than this then we return what they can have\n\n    if ((DWORD)pRequest->cbBuffer < pVideoInfo->bmiHeader.biSizeImage)\n    {\n        return E_INVALIDARG;\n    }\n\n    // Reject buffer prefixes\n\n    if (pRequest->cbPrefix > 0)\n    {\n        return E_INVALIDARG;\n    }\n\n    pRequest->cbBuffer = pVideoInfo->bmiHeader.biSizeImage;\n    return NOERROR;\n}\n\n// Agree the number of media sample buffers and their sizes. The base class\n// this allocator is derived from allows samples to be aligned only on byte\n// boundaries NOTE the buffers are not allocated until the Commit call\n\nSTDMETHODIMP CImageAllocator::SetProperties(__in ALLOCATOR_PROPERTIES *pRequest, __out ALLOCATOR_PROPERTIES *pActual)\n{\n    ALLOCATOR_PROPERTIES Adjusted = *pRequest;\n\n    // Check the parameters fit with the current connection\n\n    HRESULT hr = CheckSizes(&Adjusted);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    return CBaseAllocator::SetProperties(&Adjusted, pActual);\n}\n\n// Commit the memory by allocating the agreed number of media samples. For\n// each sample we are committed to creating we have a CImageSample object\n// that we use to manage it's resources. This is initialised with a DIBDATA\n// structure that contains amongst other things the GDI DIBSECTION handle\n// We will access the renderer media type during this so we must have locked\n// (to prevent the format changing for example). The class overrides Commit\n// and Decommit to do this locking (base class Commit in turn calls Alloc)\n\nHRESULT CImageAllocator::Alloc(void)\n{\n    ASSERT(m_pMediaType);\n    CImageSample *pSample;\n    DIBDATA DibData;\n\n    // Check the base allocator says it's ok to continue\n\n    HRESULT hr = CBaseAllocator::Alloc();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    // We create a new memory mapped object although we don't map it into our\n    // address space because GDI does that in CreateDIBSection. It is possible\n    // that we run out of resources before creating all the samples in which\n    // case the available sample list is left with those already created\n\n    ASSERT(m_lAllocated == 0);\n    while (m_lAllocated < m_lCount)\n    {\n\n        // Create and initialise a shared memory GDI buffer\n\n        hr = CreateDIB(m_lSize, DibData);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        // Create the sample object and pass it the DIBDATA\n\n        pSample = CreateImageSample(DibData.pBase, m_lSize);\n        if (pSample == NULL)\n        {\n            EXECUTE_ASSERT(DeleteObject(DibData.hBitmap));\n            EXECUTE_ASSERT(CloseHandle(DibData.hMapping));\n            return E_OUTOFMEMORY;\n        }\n\n        // Add the completed sample to the available list\n\n        pSample->SetDIBData(&DibData);\n        m_lFree.Add(pSample);\n        m_lAllocated++;\n    }\n    return NOERROR;\n}\n\n// We have a virtual method that allocates the samples so that a derived class\n// may override it and allocate more specialised sample objects. So long as it\n// derives its samples from CImageSample then all this code will still work ok\n\nCImageSample *CImageAllocator::CreateImageSample(__in_bcount(Length) LPBYTE pData, LONG Length)\n{\n    HRESULT hr = NOERROR;\n    CImageSample *pSample;\n\n    // Allocate the new sample and check the return codes\n\n    pSample = new CImageSample((CBaseAllocator *)this, // Base class\n                               NAME(\"Video sample\"),   // DEBUG name\n                               (HRESULT *)&hr,         // Return code\n                               (LPBYTE)pData,          // DIB address\n                               (LONG)Length);          // Size of DIB\n\n    if (pSample == NULL || FAILED(hr))\n    {\n        delete pSample;\n        return NULL;\n    }\n    return pSample;\n}\n\n// This function allocates a shared memory block for use by the source filter\n// generating DIBs for us to render. The memory block is created in shared\n// memory so that GDI doesn't have to copy the memory when we do a BitBlt\n\nHRESULT CImageAllocator::CreateDIB(LONG InSize, DIBDATA &DibData)\n{\n    BITMAPINFO *pbmi; // Format information for pin\n    BYTE *pBase;      // Pointer to the actual image\n    HANDLE hMapping;  // Handle to mapped object\n    HBITMAP hBitmap;  // DIB section bitmap handle\n\n    // Create a file mapping object and map into our address space\n\n    hMapping = CreateFileMapping(hMEMORY,        // Use system page file\n                                 NULL,           // No security attributes\n                                 PAGE_READWRITE, // Full access to memory\n                                 (DWORD)0,       // Less than 4Gb in size\n                                 InSize,         // Size of buffer\n                                 NULL);          // No name to section\n    if (hMapping == NULL)\n    {\n        DWORD Error = GetLastError();\n        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, Error);\n    }\n\n    // NOTE We always create a DIB section with the source format type which\n    // may contain a source palette. When we do the BitBlt drawing operation\n    // the target display device may contain a different palette (we may not\n    // have the focus) in which case GDI will do after the palette mapping\n\n    pbmi = (BITMAPINFO *)HEADER(m_pMediaType->Format());\n    if (m_pMediaType == NULL)\n    {\n        DbgBreak(\"Invalid media type\");\n    }\n\n    hBitmap = CreateDIBSection((HDC)NULL,       // NO device context\n                               pbmi,            // Format information\n                               DIB_RGB_COLORS,  // Use the palette\n                               (VOID **)&pBase, // Pointer to image data\n                               hMapping,        // Mapped memory handle\n                               (DWORD)0);       // Offset into memory\n\n    if (hBitmap == NULL || pBase == NULL)\n    {\n        EXECUTE_ASSERT(CloseHandle(hMapping));\n        DWORD Error = GetLastError();\n        return MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, Error);\n    }\n\n    // Initialise the DIB information structure\n\n    DibData.hBitmap = hBitmap;\n    DibData.hMapping = hMapping;\n    DibData.pBase = pBase;\n    DibData.PaletteVersion = PALETTE_VERSION;\n    GetObject(hBitmap, sizeof(DIBSECTION), (VOID *)&DibData.DibSection);\n\n    return NOERROR;\n}\n\n// We use the media type during the DIBSECTION creation\n\nvoid CImageAllocator::NotifyMediaType(__in CMediaType *pMediaType)\n{\n    m_pMediaType = pMediaType;\n}\n\n// Overriden to increment the owning object's reference count\n\nSTDMETHODIMP_(ULONG) CImageAllocator::NonDelegatingAddRef()\n{\n    return m_pFilter->AddRef();\n}\n\n// Overriden to decrement the owning object's reference count\n\nSTDMETHODIMP_(ULONG) CImageAllocator::NonDelegatingRelease()\n{\n    return m_pFilter->Release();\n}\n\n// If you derive a class from CMediaSample that has to transport specialised\n// member variables and entry points then there are three alternate solutions\n// The first is to create a memory buffer larger than actually required by the\n// sample and store your information either at the beginning of it or at the\n// end, the former being moderately safer allowing for misbehaving transform\n// filters. You then adjust the buffer address when you create the base media\n// sample. This has the disadvantage of breaking up the memory allocated to\n// the samples into separate blocks. The second solution is to implement a\n// class derived from CMediaSample and support additional interface(s) that\n// convey your private data. This means defining a custom interface. The final\n// alternative is to create a class that inherits from CMediaSample and adds\n// the private data structures, when you get an IMediaSample in your Receive()\n// call check to see if your allocator is being used, and if it is then cast\n// the IMediaSample into one of your objects. Additional checks can be made\n// to ensure the sample's this pointer is known to be one of your own objects\n\nCImageSample::CImageSample(__inout CBaseAllocator *pAllocator, __in_opt LPCTSTR pName, __inout HRESULT *phr,\n                           __in_bcount(length) LPBYTE pBuffer, LONG length)\n    : CMediaSample(pName, pAllocator, phr, pBuffer, length)\n    , m_bInit(FALSE)\n{\n    ASSERT(pAllocator);\n    ASSERT(pBuffer);\n}\n\n// Set the shared memory DIB information\n\nvoid CImageSample::SetDIBData(__in DIBDATA *pDibData)\n{\n    ASSERT(pDibData);\n    m_DibData = *pDibData;\n    m_bInit = TRUE;\n}\n\n// Retrieve the shared memory DIB data\n\n__out DIBDATA *CImageSample::GetDIBData()\n{\n    ASSERT(m_bInit == TRUE);\n    return &m_DibData;\n}\n\n// This class handles the creation of a palette. It is fairly specialist and\n// is intended to simplify palette management for video renderer filters. It\n// is for this reason that the constructor requires three other objects with\n// which it interacts, namely a base media filter, a base window and a base\n// drawing object although the base window or the draw object may be NULL to\n// ignore that part of us. We try not to create and install palettes unless\n// absolutely necessary as they typically require WM_PALETTECHANGED messages\n// to be sent to every window thread in the system which is very expensive\n\nCImagePalette::CImagePalette(__inout CBaseFilter *pBaseFilter, __inout CBaseWindow *pBaseWindow,\n                             __inout CDrawImage *pDrawImage)\n    : m_pBaseWindow(pBaseWindow)\n    , m_pFilter(pBaseFilter)\n    , m_pDrawImage(pDrawImage)\n    , m_hPalette(NULL)\n{\n    ASSERT(m_pFilter);\n}\n\n// Destructor\n\n#ifdef DEBUG\nCImagePalette::~CImagePalette()\n{\n    ASSERT(m_hPalette == NULL);\n}\n#endif\n\n// We allow dynamic format changes of the palette but rather than change the\n// palette every time we call this to work out whether an update is required.\n// If the original type didn't use a palette and the new one does (or vica\n// versa) then we return TRUE. If neither formats use a palette we'll return\n// FALSE. If both formats use a palette we compare their colours and return\n// FALSE if they match. This therefore short circuits palette creation unless\n// absolutely necessary since installing palettes is an expensive operation\n\nBOOL CImagePalette::ShouldUpdate(const VIDEOINFOHEADER *pNewInfo, const VIDEOINFOHEADER *pOldInfo)\n{\n    // We may not have a current format yet\n\n    if (pOldInfo == NULL)\n    {\n        return TRUE;\n    }\n\n    // Do both formats not require a palette\n\n    if (ContainsPalette(pNewInfo) == FALSE)\n    {\n        if (ContainsPalette(pOldInfo) == FALSE)\n        {\n            return FALSE;\n        }\n    }\n\n    // Compare the colours to see if they match\n\n    DWORD VideoEntries = pNewInfo->bmiHeader.biClrUsed;\n    if (ContainsPalette(pNewInfo) == TRUE)\n        if (ContainsPalette(pOldInfo) == TRUE)\n            if (pOldInfo->bmiHeader.biClrUsed == VideoEntries)\n                if (pOldInfo->bmiHeader.biClrUsed > 0)\n                    if (memcmp((PVOID)GetBitmapPalette(pNewInfo), (PVOID)GetBitmapPalette(pOldInfo),\n                               VideoEntries * sizeof(RGBQUAD)) == 0)\n                    {\n\n                        return FALSE;\n                    }\n    return TRUE;\n}\n\n// This is normally called when the input pin type is set to install a palette\n// We will typically be called from two different places. The first is when we\n// have negotiated a palettised media type after connection, the other is when\n// we receive a new type during processing with an updated palette in which\n// case we must remove and release the resources held by the current palette\n\n// We can be passed an optional device name if we wish to prepare a palette\n// for a specific monitor on a multi monitor system\n\nHRESULT CImagePalette::PreparePalette(const CMediaType *pmtNew, const CMediaType *pmtOld, __in LPSTR szDevice)\n{\n    const VIDEOINFOHEADER *pNewInfo = (VIDEOINFOHEADER *)pmtNew->Format();\n    const VIDEOINFOHEADER *pOldInfo = (VIDEOINFOHEADER *)pmtOld->Format();\n    ASSERT(pNewInfo);\n\n    // This is an performance optimisation, when we get a media type we check\n    // to see if the format requires a palette change. If either we need one\n    // when previously we didn't or vica versa then this returns TRUE, if we\n    // previously needed a palette and we do now it compares their colours\n\n    if (ShouldUpdate(pNewInfo, pOldInfo) == FALSE)\n    {\n        NOTE(\"No update needed\");\n        return S_FALSE;\n    }\n\n    // We must notify the filter graph that the application may have changed\n    // the palette although in practice we don't bother checking to see if it\n    // is really different. If it tries to get the palette either the window\n    // or renderer lock will ensure it doesn't get in until we are finished\n\n    RemovePalette();\n    m_pFilter->NotifyEvent(EC_PALETTE_CHANGED, 0, 0);\n\n    // Do we need a palette for the new format\n\n    if (ContainsPalette(pNewInfo) == FALSE)\n    {\n        NOTE(\"New has no palette\");\n        return S_FALSE;\n    }\n\n    if (m_pBaseWindow)\n    {\n        m_pBaseWindow->LockPaletteLock();\n    }\n\n    // If we're changing the palette on the fly then we increment our palette\n    // cookie which is compared against the cookie also stored in all of our\n    // DIBSECTION media samples. If they don't match when we come to draw it\n    // then we know the sample is out of date and we'll update it's palette\n\n    NOTE(\"Making new colour palette\");\n    m_hPalette = MakePalette(pNewInfo, szDevice);\n    ASSERT(m_hPalette != NULL);\n\n    if (m_pBaseWindow)\n    {\n        m_pBaseWindow->UnlockPaletteLock();\n    }\n\n    // The window in which the new palette is to be realised may be a NULL\n    // pointer to signal that no window is in use, if so we don't call it\n    // Some filters just want to use this object to create/manage palettes\n\n    if (m_pBaseWindow)\n        m_pBaseWindow->SetPalette(m_hPalette);\n\n    // This is the only time where we need access to the draw object to say\n    // to it that a new palette will be arriving on a sample real soon. The\n    // constructor may take a NULL pointer in which case we don't call this\n\n    if (m_pDrawImage)\n        m_pDrawImage->IncrementPaletteVersion();\n    return NOERROR;\n}\n\n// Helper function to copy a palette out of any kind of VIDEOINFO (ie it may\n// be YUV or true colour) into a palettised VIDEOINFO. We use this changing\n// palettes on DirectDraw samples as a source filter can attach a palette to\n// any buffer (eg YUV) and hand it back. We make a new palette out of that\n// format and then copy the palette colours into the current connection type\n\nHRESULT CImagePalette::CopyPalette(const CMediaType *pSrc, __out CMediaType *pDest)\n{\n    // Reset the destination palette before starting\n\n    VIDEOINFOHEADER *pDestInfo = (VIDEOINFOHEADER *)pDest->Format();\n    pDestInfo->bmiHeader.biClrUsed = 0;\n    pDestInfo->bmiHeader.biClrImportant = 0;\n\n    // Does the destination have a palette\n\n    if (PALETTISED(pDestInfo) == FALSE)\n    {\n        NOTE(\"No destination palette\");\n        return S_FALSE;\n    }\n\n    // Does the source contain a palette\n\n    const VIDEOINFOHEADER *pSrcInfo = (VIDEOINFOHEADER *)pSrc->Format();\n    if (ContainsPalette(pSrcInfo) == FALSE)\n    {\n        NOTE(\"No source palette\");\n        return S_FALSE;\n    }\n\n    // The number of colours may be zero filled\n\n    DWORD PaletteEntries = pSrcInfo->bmiHeader.biClrUsed;\n    if (PaletteEntries == 0)\n    {\n        DWORD Maximum = (1 << pSrcInfo->bmiHeader.biBitCount);\n        NOTE1(\"Setting maximum colours (%d)\", Maximum);\n        PaletteEntries = Maximum;\n    }\n\n    // Make sure the destination has enough room for the palette\n\n    ASSERT(pSrcInfo->bmiHeader.biClrUsed <= iPALETTE_COLORS);\n    ASSERT(pSrcInfo->bmiHeader.biClrImportant <= PaletteEntries);\n    ASSERT(COLORS(pDestInfo) == GetBitmapPalette(pDestInfo));\n    pDestInfo->bmiHeader.biClrUsed = PaletteEntries;\n    pDestInfo->bmiHeader.biClrImportant = pSrcInfo->bmiHeader.biClrImportant;\n    ULONG BitmapSize = GetBitmapFormatSize(HEADER(pSrcInfo));\n\n    if (pDest->FormatLength() < BitmapSize)\n    {\n        NOTE(\"Reallocating destination\");\n        pDest->ReallocFormatBuffer(BitmapSize);\n    }\n\n    // Now copy the palette colours across\n\n    CopyMemory((PVOID)COLORS(pDestInfo), (PVOID)GetBitmapPalette(pSrcInfo), PaletteEntries * sizeof(RGBQUAD));\n\n    return NOERROR;\n}\n\n// This is normally called when the palette is changed (typically during a\n// dynamic format change) to remove any palette we previously installed. We\n// replace it (if necessary) in the video window with a standard VGA palette\n// that should always be available even if this is a true colour display\n\nHRESULT CImagePalette::RemovePalette()\n{\n    if (m_pBaseWindow)\n    {\n        m_pBaseWindow->LockPaletteLock();\n    }\n\n    // Do we have a palette to remove\n\n    if (m_hPalette != NULL)\n    {\n\n        if (m_pBaseWindow)\n        {\n            // Make sure that the window's palette handle matches\n            // our palette handle.\n            ASSERT(m_hPalette == m_pBaseWindow->GetPalette());\n\n            m_pBaseWindow->UnsetPalette();\n        }\n\n        EXECUTE_ASSERT(DeleteObject(m_hPalette));\n        m_hPalette = NULL;\n    }\n\n    if (m_pBaseWindow)\n    {\n        m_pBaseWindow->UnlockPaletteLock();\n    }\n\n    return NOERROR;\n}\n\n// Called to create a palette for the object, the data structure used by GDI\n// to describe a palette is a LOGPALETTE, this includes a variable number of\n// PALETTEENTRY fields which are the colours, we have to convert the RGBQUAD\n// colour fields we are handed in a BITMAPINFO from the media type into these\n// This handles extraction of palettes from true colour and YUV media formats\n\n// We can be passed an optional device name if we wish to prepare a palette\n// for a specific monitor on a multi monitor system\n\nHPALETTE CImagePalette::MakePalette(const VIDEOINFOHEADER *pVideoInfo, __in LPSTR szDevice)\n{\n    ASSERT(ContainsPalette(pVideoInfo) == TRUE);\n    ASSERT(pVideoInfo->bmiHeader.biClrUsed <= iPALETTE_COLORS);\n    BITMAPINFOHEADER *pHeader = HEADER(pVideoInfo);\n\n    const RGBQUAD *pColours; // Pointer to the palette\n    LOGPALETTE *lp;          // Used to create a palette\n    HPALETTE hPalette;       // Logical palette object\n\n    lp = (LOGPALETTE *)new BYTE[sizeof(LOGPALETTE) + SIZE_PALETTE];\n    if (lp == NULL)\n    {\n        return NULL;\n    }\n\n    // Unfortunately for some hare brained reason a GDI palette entry (a\n    // PALETTEENTRY structure) is different to a palette entry from a DIB\n    // format (a RGBQUAD structure) so we have to do the field conversion\n    // The VIDEOINFO containing the palette may be a true colour type so\n    // we use GetBitmapPalette to skip over any bit fields if they exist\n\n    lp->palVersion = PALVERSION;\n    lp->palNumEntries = (USHORT)pHeader->biClrUsed;\n    if (lp->palNumEntries == 0)\n        lp->palNumEntries = (1 << pHeader->biBitCount);\n    pColours = GetBitmapPalette(pVideoInfo);\n\n    for (DWORD dwCount = 0; dwCount < lp->palNumEntries; dwCount++)\n    {\n        lp->palPalEntry[dwCount].peRed = pColours[dwCount].rgbRed;\n        lp->palPalEntry[dwCount].peGreen = pColours[dwCount].rgbGreen;\n        lp->palPalEntry[dwCount].peBlue = pColours[dwCount].rgbBlue;\n        lp->palPalEntry[dwCount].peFlags = 0;\n    }\n\n    MakeIdentityPalette(lp->palPalEntry, lp->palNumEntries, szDevice);\n\n    // Create a logical palette\n\n    hPalette = CreatePalette(lp);\n    ASSERT(hPalette != NULL);\n    delete[] lp;\n    return hPalette;\n}\n\n// GDI does a fair job of compressing the palette entries you give it, so for\n// example if you have five entries with an RGB colour (0,0,0) it will remove\n// all but one of them. When you subsequently draw an image it will map from\n// your logical palette to the compressed device palette. This function looks\n// to see if it is trying to be an identity palette and if so sets the flags\n// field in the PALETTEENTRYs so they remain expanded to boost performance\n\n// We can be passed an optional device name if we wish to prepare a palette\n// for a specific monitor on a multi monitor system\n\nHRESULT CImagePalette::MakeIdentityPalette(__inout_ecount_full(iColours) PALETTEENTRY *pEntry, INT iColours,\n                                           __in LPSTR szDevice)\n{\n    PALETTEENTRY SystemEntries[10];      // System palette entries\n    BOOL bIdentityPalette = TRUE;        // Is an identity palette\n    ASSERT(iColours <= iPALETTE_COLORS); // Should have a palette\n    const int PalLoCount = 10;           // First ten reserved colours\n    const int PalHiStart = 246;          // Last VGA palette entries\n\n    // Does this have the full colour range\n\n    if (iColours < 10)\n    {\n        return S_FALSE;\n    }\n\n    // Apparently some displays have odd numbers of system colours\n\n    // Get a DC on the right monitor - it's ugly, but this is the way you have\n    // to do it\n    HDC hdc;\n    if (szDevice == NULL || lstrcmpiLocaleIndependentA(szDevice, \"DISPLAY\") == 0)\n        hdc = CreateDCA(\"DISPLAY\", NULL, NULL, NULL);\n    else\n        hdc = CreateDCA(NULL, szDevice, NULL, NULL);\n    if (NULL == hdc)\n    {\n        return E_OUTOFMEMORY;\n    }\n    INT Reserved = GetDeviceCaps(hdc, NUMRESERVED);\n    if (Reserved != 20)\n    {\n        DeleteDC(hdc);\n        return S_FALSE;\n    }\n\n    // Compare our palette against the first ten system entries. The reason I\n    // don't do a memory compare between our two arrays of colours is because\n    // I am not sure what will be in the flags fields for the system entries\n\n    UINT Result = GetSystemPaletteEntries(hdc, 0, PalLoCount, SystemEntries);\n    for (UINT Count = 0; Count < Result; Count++)\n    {\n        if (SystemEntries[Count].peRed != pEntry[Count].peRed ||\n            SystemEntries[Count].peGreen != pEntry[Count].peGreen ||\n            SystemEntries[Count].peBlue != pEntry[Count].peBlue)\n        {\n            bIdentityPalette = FALSE;\n        }\n    }\n\n    // And likewise compare against the last ten entries\n\n    Result = GetSystemPaletteEntries(hdc, PalHiStart, PalLoCount, SystemEntries);\n    for (UINT Count = 0; Count < Result; Count++)\n    {\n        if (INT(Count) + PalHiStart < iColours)\n        {\n            if (SystemEntries[Count].peRed != pEntry[PalHiStart + Count].peRed ||\n                SystemEntries[Count].peGreen != pEntry[PalHiStart + Count].peGreen ||\n                SystemEntries[Count].peBlue != pEntry[PalHiStart + Count].peBlue)\n            {\n                bIdentityPalette = FALSE;\n            }\n        }\n    }\n\n    // If not an identity palette then return S_FALSE\n\n    DeleteDC(hdc);\n    if (bIdentityPalette == FALSE)\n    {\n        return S_FALSE;\n    }\n\n    // Set the non VGA entries so that GDI doesn't map them\n\n    for (UINT Count = PalLoCount; INT(Count) < min(PalHiStart, iColours); Count++)\n    {\n        pEntry[Count].peFlags = PC_NOCOLLAPSE;\n    }\n    return NOERROR;\n}\n\n// Constructor initialises the VIDEOINFO we keep storing the current display\n// format. The format can be changed at any time, to reset the format held\n// by us call the RefreshDisplayType directly (it's a public method). Since\n// more than one thread will typically call us (ie window threads resetting\n// the type and source threads in the type checking methods) we have a lock\n\nCImageDisplay::CImageDisplay()\n{\n    RefreshDisplayType(NULL);\n}\n\n// This initialises the format we hold which contains the display device type\n// We do a conversion on the display device type in here so that when we start\n// type checking input formats we can assume that certain fields have been set\n// correctly, an example is when we make the 16 bit mask fields explicit. This\n// is normally called when we receive WM_DEVMODECHANGED device change messages\n\n// The optional szDeviceName parameter tells us which monitor we are interested\n// in for a multi monitor system\n\nHRESULT CImageDisplay::RefreshDisplayType(__in_opt LPSTR szDeviceName)\n{\n    CAutoLock cDisplayLock(this);\n\n    // Set the preferred format type\n\n    ZeroMemory((PVOID)&m_Display, sizeof(VIDEOINFOHEADER) + sizeof(TRUECOLORINFO));\n    m_Display.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);\n    m_Display.bmiHeader.biBitCount = FALSE;\n\n    // Get the bit depth of a device compatible bitmap\n\n    // get caps of whichever monitor they are interested in (multi monitor)\n    HDC hdcDisplay;\n    // it's ugly, but this is the way you have to do it\n    if (szDeviceName == NULL || lstrcmpiLocaleIndependentA(szDeviceName, \"DISPLAY\") == 0)\n        hdcDisplay = CreateDCA(\"DISPLAY\", NULL, NULL, NULL);\n    else\n        hdcDisplay = CreateDCA(NULL, szDeviceName, NULL, NULL);\n    if (hdcDisplay == NULL)\n    {\n        ASSERT(FALSE);\n        DbgLog((LOG_ERROR, 1, TEXT(\"ACK! Can't get a DC for %hs\"), szDeviceName ? szDeviceName : \"<NULL>\"));\n        return E_FAIL;\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 3, TEXT(\"Created a DC for %s\"), szDeviceName ? szDeviceName : \"<NULL>\"));\n    }\n    HBITMAP hbm = CreateCompatibleBitmap(hdcDisplay, 1, 1);\n    if (hbm)\n    {\n        GetDIBits(hdcDisplay, hbm, 0, 1, NULL, (BITMAPINFO *)&m_Display.bmiHeader, DIB_RGB_COLORS);\n\n        // This call will get the colour table or the proper bitfields\n        GetDIBits(hdcDisplay, hbm, 0, 1, NULL, (BITMAPINFO *)&m_Display.bmiHeader, DIB_RGB_COLORS);\n        DeleteObject(hbm);\n    }\n    DeleteDC(hdcDisplay);\n\n    // Complete the display type initialisation\n\n    ASSERT(CheckHeaderValidity(&m_Display));\n    UpdateFormat(&m_Display);\n    DbgLog((LOG_TRACE, 3, TEXT(\"New DISPLAY bit depth =%d\"), m_Display.bmiHeader.biBitCount));\n    return NOERROR;\n}\n\n// We assume throughout this code that any bitfields masks are allowed no\n// more than eight bits to store a colour component. This checks that the\n// bit count assumption is enforced and also makes sure that all the bits\n// set are contiguous. We return a boolean TRUE if the field checks out ok\n\nBOOL CImageDisplay::CheckBitFields(const VIDEOINFO *pInput)\n{\n    DWORD *pBitFields = (DWORD *)BITMASKS(pInput);\n\n    for (INT iColour = iRED; iColour <= iBLUE; iColour++)\n    {\n\n        // First of all work out how many bits are set\n\n        DWORD SetBits = CountSetBits(pBitFields[iColour]);\n        if (SetBits > iMAXBITS || SetBits == 0)\n        {\n            NOTE1(\"Bit fields for component %d invalid\", iColour);\n            return FALSE;\n        }\n\n        // Next work out the number of zero bits prefix\n        DWORD PrefixBits = CountPrefixBits(pBitFields[iColour]);\n\n        // This is going to see if all the bits set are contiguous (as they\n        // should be). We know how much to shift them right by from the\n        // count of prefix bits. The number of bits set defines a mask, we\n        // invert this (ones complement) and AND it with the shifted bit\n        // fields. If the result is NON zero then there are bit(s) sticking\n        // out the left hand end which means they are not contiguous\n\n        DWORD TestField = pBitFields[iColour] >> PrefixBits;\n        DWORD Mask = ULONG_MAX << SetBits;\n        if (TestField & Mask)\n        {\n            NOTE1(\"Bit fields for component %d not contiguous\", iColour);\n            return FALSE;\n        }\n    }\n    return TRUE;\n}\n\n// This counts the number of bits set in the input field\n\nDWORD CImageDisplay::CountSetBits(DWORD Field)\n{\n    // This is a relatively well known bit counting algorithm\n\n    DWORD Count = 0;\n    DWORD init = Field;\n\n    // Until the input is exhausted, count the number of bits\n\n    while (init)\n    {\n        init = init & (init - 1); // Turn off the bottommost bit\n        Count++;\n    }\n    return Count;\n}\n\n// This counts the number of zero bits upto the first one set NOTE the input\n// field should have been previously checked to ensure there is at least one\n// set although if we don't find one set we return the impossible value 32\n\nDWORD CImageDisplay::CountPrefixBits(DWORD Field)\n{\n    DWORD Mask = 1;\n    DWORD Count = 0;\n\n    while (TRUE)\n    {\n        if (Field & Mask)\n        {\n            return Count;\n        }\n        Count++;\n\n        ASSERT(Mask != 0x80000000);\n        if (Mask == 0x80000000)\n        {\n            return Count;\n        }\n        Mask <<= 1;\n    }\n}\n\n// This is called to check the BITMAPINFOHEADER for the input type. There are\n// many implicit dependancies between the fields in a header structure which\n// if we validate now make for easier manipulation in subsequent handling. We\n// also check that the BITMAPINFOHEADER matches it's specification such that\n// fields likes the number of planes is one, that it's structure size is set\n// correctly and that the bitmap dimensions have not been set as negative\n\nBOOL CImageDisplay::CheckHeaderValidity(const VIDEOINFO *pInput)\n{\n    // Check the bitmap width and height are not negative.\n\n    if (pInput->bmiHeader.biWidth <= 0 || pInput->bmiHeader.biHeight <= 0)\n    {\n        NOTE(\"Invalid bitmap dimensions\");\n        return FALSE;\n    }\n\n    // Check the compression is either BI_RGB or BI_BITFIELDS\n\n    if (pInput->bmiHeader.biCompression != BI_RGB)\n    {\n        if (pInput->bmiHeader.biCompression != BI_BITFIELDS)\n        {\n            NOTE(\"Invalid compression format\");\n            return FALSE;\n        }\n    }\n\n    // If BI_BITFIELDS compression format check the colour depth\n\n    if (pInput->bmiHeader.biCompression == BI_BITFIELDS)\n    {\n        if (pInput->bmiHeader.biBitCount != 16)\n        {\n            if (pInput->bmiHeader.biBitCount != 32)\n            {\n                NOTE(\"BI_BITFIELDS not 16/32 bit depth\");\n                return FALSE;\n            }\n        }\n    }\n\n    // Check the assumptions about the layout of the bit fields\n\n    if (pInput->bmiHeader.biCompression == BI_BITFIELDS)\n    {\n        if (CheckBitFields(pInput) == FALSE)\n        {\n            NOTE(\"Bit fields are not valid\");\n            return FALSE;\n        }\n    }\n\n    // Are the number of planes equal to one\n\n    if (pInput->bmiHeader.biPlanes != 1)\n    {\n        NOTE(\"Number of planes not one\");\n        return FALSE;\n    }\n\n    // Check the image size is consistent (it can be zero)\n\n    if (pInput->bmiHeader.biSizeImage != GetBitmapSize(&pInput->bmiHeader))\n    {\n        if (pInput->bmiHeader.biSizeImage)\n        {\n            NOTE(\"Image size incorrectly set\");\n            return FALSE;\n        }\n    }\n\n    // Check the size of the structure\n\n    if (pInput->bmiHeader.biSize != sizeof(BITMAPINFOHEADER))\n    {\n        NOTE(\"Size of BITMAPINFOHEADER wrong\");\n        return FALSE;\n    }\n    return CheckPaletteHeader(pInput);\n}\n\n// This runs a few simple tests against the palette fields in the input to\n// see if it looks vaguely correct. The tests look at the number of palette\n// colours present, the number considered important and the biCompression\n// field which should always be BI_RGB as no other formats are meaningful\n\nBOOL CImageDisplay::CheckPaletteHeader(const VIDEOINFO *pInput)\n{\n    // The checks here are for palettised videos only\n\n    if (PALETTISED(pInput) == FALSE)\n    {\n        if (pInput->bmiHeader.biClrUsed)\n        {\n            NOTE(\"Invalid palette entries\");\n            return FALSE;\n        }\n        return TRUE;\n    }\n\n    // Compression type of BI_BITFIELDS is meaningless for palette video\n\n    if (pInput->bmiHeader.biCompression != BI_RGB)\n    {\n        NOTE(\"Palettised video must be BI_RGB\");\n        return FALSE;\n    }\n\n    // Check the number of palette colours is correct\n\n    if (pInput->bmiHeader.biClrUsed > PALETTE_ENTRIES(pInput))\n    {\n        NOTE(\"Too many colours in palette\");\n        return FALSE;\n    }\n\n    // The number of important colours shouldn't exceed the number used\n\n    if (pInput->bmiHeader.biClrImportant > pInput->bmiHeader.biClrUsed)\n    {\n        NOTE(\"Too many important colours\");\n        return FALSE;\n    }\n    return TRUE;\n}\n\n// Return the format of the video display\n\nconst VIDEOINFO *CImageDisplay::GetDisplayFormat()\n{\n    return &m_Display;\n}\n\n// Return TRUE if the display uses a palette\n\nBOOL CImageDisplay::IsPalettised()\n{\n    return PALETTISED(&m_Display);\n}\n\n// Return the bit depth of the current display setting\n\nWORD CImageDisplay::GetDisplayDepth()\n{\n    return m_Display.bmiHeader.biBitCount;\n}\n\n// Initialise the optional fields in a VIDEOINFO. These are mainly to do with\n// the source and destination rectangles and palette information such as the\n// number of colours present. It simplifies our code just a little if we don't\n// have to keep checking for all the different valid permutations in a header\n// every time we want to do anything with it (an example would be creating a\n// palette). We set the base class media type before calling this function so\n// that the media types between the pins match after a connection is made\n\nHRESULT CImageDisplay::UpdateFormat(__inout VIDEOINFO *pVideoInfo)\n{\n    ASSERT(pVideoInfo);\n\n    BITMAPINFOHEADER *pbmi = HEADER(pVideoInfo);\n    SetRectEmpty(&pVideoInfo->rcSource);\n    SetRectEmpty(&pVideoInfo->rcTarget);\n\n    // Set the number of colours explicitly\n\n    if (PALETTISED(pVideoInfo))\n    {\n        if (pVideoInfo->bmiHeader.biClrUsed == 0)\n        {\n            pVideoInfo->bmiHeader.biClrUsed = PALETTE_ENTRIES(pVideoInfo);\n        }\n    }\n\n    // The number of important colours shouldn't exceed the number used, on\n    // some displays the number of important colours is not initialised when\n    // retrieving the display type so we set the colours used correctly\n\n    if (pVideoInfo->bmiHeader.biClrImportant > pVideoInfo->bmiHeader.biClrUsed)\n    {\n        pVideoInfo->bmiHeader.biClrImportant = PALETTE_ENTRIES(pVideoInfo);\n    }\n\n    // Change the image size field to be explicit\n\n    if (pVideoInfo->bmiHeader.biSizeImage == 0)\n    {\n        pVideoInfo->bmiHeader.biSizeImage = GetBitmapSize(&pVideoInfo->bmiHeader);\n    }\n    return NOERROR;\n}\n\n// Lots of video rendering filters want code to check proposed formats are ok\n// This checks the VIDEOINFO we are passed as a media type. If the media type\n// is a valid media type then we return NOERROR otherwise E_INVALIDARG. Note\n// however we only accept formats that can be easily displayed in the display\n// so if we are on a 16 bit device we will not accept 24 bit images. The one\n// complexity is that most displays draw 8 bit palettised images efficiently\n// Also if the input format is less colour bits per pixel then we also accept\n\nHRESULT CImageDisplay::CheckVideoType(const VIDEOINFO *pInput)\n{\n    // First of all check the VIDEOINFOHEADER looks correct\n\n    if (CheckHeaderValidity(pInput) == FALSE)\n    {\n        return E_INVALIDARG;\n    }\n\n    // Virtually all devices support palettised images efficiently\n\n    if (m_Display.bmiHeader.biBitCount == pInput->bmiHeader.biBitCount)\n    {\n        if (PALETTISED(pInput) == TRUE)\n        {\n            ASSERT(PALETTISED(&m_Display) == TRUE);\n            NOTE(\"(Video) Type connection ACCEPTED\");\n            return NOERROR;\n        }\n    }\n\n    // Is the display depth greater than the input format\n\n    if (m_Display.bmiHeader.biBitCount > pInput->bmiHeader.biBitCount)\n    {\n        NOTE(\"(Video) Mismatch agreed\");\n        return NOERROR;\n    }\n\n    // Is the display depth less than the input format\n\n    if (m_Display.bmiHeader.biBitCount < pInput->bmiHeader.biBitCount)\n    {\n        NOTE(\"(Video) Format mismatch\");\n        return E_INVALIDARG;\n    }\n\n    // Both input and display formats are either BI_RGB or BI_BITFIELDS\n\n    ASSERT(m_Display.bmiHeader.biBitCount == pInput->bmiHeader.biBitCount);\n    ASSERT(PALETTISED(pInput) == FALSE);\n    ASSERT(PALETTISED(&m_Display) == FALSE);\n\n    // BI_RGB 16 bit representation is implicitly RGB555, and likewise BI_RGB\n    // 24 bit representation is RGB888. So we initialise a pointer to the bit\n    // fields they really mean and check against the display device format\n    // This is only going to be called when both formats are equal bits pixel\n\n    const DWORD *pInputMask = GetBitMasks(pInput);\n    const DWORD *pDisplayMask = GetBitMasks((VIDEOINFO *)&m_Display);\n\n    if (pInputMask[iRED] != pDisplayMask[iRED] || pInputMask[iGREEN] != pDisplayMask[iGREEN] ||\n        pInputMask[iBLUE] != pDisplayMask[iBLUE])\n    {\n\n        NOTE(\"(Video) Bit field mismatch\");\n        return E_INVALIDARG;\n    }\n\n    NOTE(\"(Video) Type connection ACCEPTED\");\n    return NOERROR;\n}\n\n// Return the bit masks for the true colour VIDEOINFO provided\n\nconst DWORD *CImageDisplay::GetBitMasks(const VIDEOINFO *pVideoInfo)\n{\n    static const DWORD FailMasks[] = {0, 0, 0};\n\n    if (pVideoInfo->bmiHeader.biCompression == BI_BITFIELDS)\n    {\n        return BITMASKS(pVideoInfo);\n    }\n\n    ASSERT(pVideoInfo->bmiHeader.biCompression == BI_RGB);\n\n    switch (pVideoInfo->bmiHeader.biBitCount)\n    {\n    case 16: return bits555;\n    case 24: return bits888;\n    case 32: return bits888;\n    default: return FailMasks;\n    }\n}\n\n// Check to see if we can support media type pmtIn as proposed by the output\n// pin - We first check that the major media type is video and also identify\n// the media sub type. Then we thoroughly check the VIDEOINFO type provided\n// As well as the contained VIDEOINFO being correct the major type must be\n// video, the subtype a recognised video format and the type GUID correct\n\nHRESULT CImageDisplay::CheckMediaType(const CMediaType *pmtIn)\n{\n    // Does this have a VIDEOINFOHEADER format block\n\n    const GUID *pFormatType = pmtIn->FormatType();\n    if (*pFormatType != FORMAT_VideoInfo)\n    {\n        NOTE(\"Format GUID not a VIDEOINFOHEADER\");\n        return E_INVALIDARG;\n    }\n    ASSERT(pmtIn->Format());\n\n    // Check the format looks reasonably ok\n\n    ULONG Length = pmtIn->FormatLength();\n    if (Length < SIZE_VIDEOHEADER)\n    {\n        NOTE(\"Format smaller than a VIDEOHEADER\");\n        return E_FAIL;\n    }\n\n    VIDEOINFO *pInput = (VIDEOINFO *)pmtIn->Format();\n\n    // Check the major type is MEDIATYPE_Video\n\n    const GUID *pMajorType = pmtIn->Type();\n    if (*pMajorType != MEDIATYPE_Video)\n    {\n        NOTE(\"Major type not MEDIATYPE_Video\");\n        return E_INVALIDARG;\n    }\n\n    // Check we can identify the media subtype\n\n    const GUID *pSubType = pmtIn->Subtype();\n    if (GetBitCount(pSubType) == USHRT_MAX)\n    {\n        NOTE(\"Invalid video media subtype\");\n        return E_INVALIDARG;\n    }\n    return CheckVideoType(pInput);\n}\n\n// Given a video format described by a VIDEOINFO structure we return the mask\n// that is used to obtain the range of acceptable colours for this type, for\n// example, the mask for a 24 bit true colour format is 0xFF in all cases. A\n// 16 bit 5:6:5 display format uses 0xF8, 0xFC and 0xF8, therefore given any\n// RGB triplets we can AND them with these fields to find one that is valid\n\nBOOL CImageDisplay::GetColourMask(__out DWORD *pMaskRed, __out DWORD *pMaskGreen, __out DWORD *pMaskBlue)\n{\n    CAutoLock cDisplayLock(this);\n    *pMaskRed = 0xFF;\n    *pMaskGreen = 0xFF;\n    *pMaskBlue = 0xFF;\n\n    // If this format is palettised then it doesn't have bit fields\n\n    if (m_Display.bmiHeader.biBitCount < 16)\n    {\n        return FALSE;\n    }\n\n    // If this is a 24 bit true colour display then it can handle all the\n    // possible colour component ranges described by a byte. It is never\n    // allowed for a 24 bit colour depth image to have BI_BITFIELDS set\n\n    if (m_Display.bmiHeader.biBitCount == 24)\n    {\n        ASSERT(m_Display.bmiHeader.biCompression == BI_RGB);\n        return TRUE;\n    }\n\n    // Calculate the mask based on the format's bit fields\n\n    const DWORD *pBitFields = (DWORD *)GetBitMasks((VIDEOINFO *)&m_Display);\n    DWORD *pOutputMask[] = {pMaskRed, pMaskGreen, pMaskBlue};\n\n    // We know from earlier testing that there are no more than iMAXBITS\n    // bits set in the mask and that they are all contiguous. All that\n    // therefore remains is to shift them into the correct position\n\n    for (INT iColour = iRED; iColour <= iBLUE; iColour++)\n    {\n\n        // This works out how many bits there are and where they live\n\n        DWORD PrefixBits = CountPrefixBits(pBitFields[iColour]);\n        DWORD SetBits = CountSetBits(pBitFields[iColour]);\n\n        // The first shift moves the bit field so that it is right justified\n        // in the DWORD, after which we then shift it back left which then\n        // puts the leading bit in the bytes most significant bit position\n\n        *(pOutputMask[iColour]) = pBitFields[iColour] >> PrefixBits;\n        *(pOutputMask[iColour]) <<= (iMAXBITS - SetBits);\n    }\n    return TRUE;\n}\n\n/*  Helper to convert to VIDEOINFOHEADER2\n */\nSTDAPI ConvertVideoInfoToVideoInfo2(__inout AM_MEDIA_TYPE *pmt)\n{\n    if (pmt->formattype != FORMAT_VideoInfo)\n    {\n        return E_INVALIDARG;\n    }\n    if (NULL == pmt->pbFormat || pmt->cbFormat < sizeof(VIDEOINFOHEADER))\n    {\n        return E_INVALIDARG;\n    }\n    VIDEOINFO *pVideoInfo = (VIDEOINFO *)pmt->pbFormat;\n    DWORD dwNewSize;\n    HRESULT hr = DWordAdd(pmt->cbFormat, sizeof(VIDEOINFOHEADER2) - sizeof(VIDEOINFOHEADER), &dwNewSize);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    PVOID pvNew = CoTaskMemAlloc(dwNewSize);\n    if (pvNew == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n    CopyMemory(pvNew, pmt->pbFormat, FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader));\n    ZeroMemory((PBYTE)pvNew + FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader),\n               sizeof(VIDEOINFOHEADER2) - sizeof(VIDEOINFOHEADER));\n    CopyMemory((PBYTE)pvNew + FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader),\n               pmt->pbFormat + FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader),\n               pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader));\n    VIDEOINFOHEADER2 *pVideoInfo2 = (VIDEOINFOHEADER2 *)pvNew;\n    pVideoInfo2->dwPictAspectRatioX = (DWORD)pVideoInfo2->bmiHeader.biWidth;\n    pVideoInfo2->dwPictAspectRatioY = (DWORD)abs(pVideoInfo2->bmiHeader.biHeight);\n    pmt->formattype = FORMAT_VideoInfo2;\n    CoTaskMemFree(pmt->pbFormat);\n    pmt->pbFormat = (PBYTE)pvNew;\n    pmt->cbFormat += sizeof(VIDEOINFOHEADER2) - sizeof(VIDEOINFOHEADER);\n    return S_OK;\n}\n\n//  Check a media type containing VIDEOINFOHEADER\nSTDAPI CheckVideoInfoType(const AM_MEDIA_TYPE *pmt)\n{\n    if (NULL == pmt || NULL == pmt->pbFormat)\n    {\n        return E_POINTER;\n    }\n    if (pmt->majortype != MEDIATYPE_Video || pmt->formattype != FORMAT_VideoInfo ||\n        pmt->cbFormat < sizeof(VIDEOINFOHEADER))\n    {\n        return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n    const VIDEOINFOHEADER *pHeader = (const VIDEOINFOHEADER *)pmt->pbFormat;\n    if (!ValidateBitmapInfoHeader(&pHeader->bmiHeader, pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER, bmiHeader)))\n    {\n        return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n\n    return S_OK;\n}\n\n//  Check a media type containing VIDEOINFOHEADER2\nSTDAPI CheckVideoInfo2Type(const AM_MEDIA_TYPE *pmt)\n{\n    if (NULL == pmt || NULL == pmt->pbFormat)\n    {\n        return E_POINTER;\n    }\n    if (pmt->majortype != MEDIATYPE_Video || pmt->formattype != FORMAT_VideoInfo2 ||\n        pmt->cbFormat < sizeof(VIDEOINFOHEADER2))\n    {\n        return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n    const VIDEOINFOHEADER2 *pHeader = (const VIDEOINFOHEADER2 *)pmt->pbFormat;\n    if (!ValidateBitmapInfoHeader(&pHeader->bmiHeader, pmt->cbFormat - FIELD_OFFSET(VIDEOINFOHEADER2, bmiHeader)))\n    {\n        return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "common/baseclasses/winutil.h",
    "content": "//------------------------------------------------------------------------------\n// File: WinUtil.h\n//\n// Desc: DirectShow base classes - defines generic handler classes.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n// Make sure that you call PrepareWindow to initialise the window after\n// the object has been constructed. It is a separate method so that\n// derived classes can override useful methods like MessageLoop. Also\n// any derived class must call DoneWithWindow in its destructor. If it\n// doesn't a message may be retrieved and call a derived class member\n// function while a thread is executing the base class destructor code\n\n#ifndef __WINUTIL__\n#define __WINUTIL__\n\nconst int DEFWIDTH = 320;             // Initial window width\nconst int DEFHEIGHT = 240;            // Initial window height\nconst int CAPTION = 256;              // Maximum length of caption\nconst int TIMELENGTH = 50;            // Maximum length of times\nconst int PROFILESTR = 128;           // Normal profile string\nconst WORD PALVERSION = 0x300;        // GDI palette version\nconst LONG PALETTE_VERSION = (LONG)1; // Initial palette version\nconst COLORREF VIDEO_COLOUR = 0;      // Defaults to black background\nconst HANDLE hMEMORY = (HANDLE)(-1);  // Says to open as memory file\n\n#define WIDTH(x) ((*(x)).right - (*(x)).left)\n#define HEIGHT(x) ((*(x)).bottom - (*(x)).top)\n#define SHOWSTAGE TEXT(\"WM_SHOWSTAGE\")\n#define SHOWSTAGETOP TEXT(\"WM_SHOWSTAGETOP\")\n#define REALIZEPALETTE TEXT(\"WM_REALIZEPALETTE\")\n\nclass AM_NOVTABLE CBaseWindow\n{\n  protected:\n    HINSTANCE m_hInstance;   // Global module instance handle\n    HWND m_hwnd;             // Handle for our window\n    HDC m_hdc;               // Device context for the window\n    LONG m_Width;            // Client window width\n    LONG m_Height;           // Client window height\n    BOOL m_bActivated;       // Has the window been activated\n    LPTSTR m_pClassName;     // Static string holding class name\n    DWORD m_ClassStyles;     // Passed in to our constructor\n    DWORD m_WindowStyles;    // Likewise the initial window styles\n    DWORD m_WindowStylesEx;  // And the extended window styles\n    UINT m_ShowStageMessage; // Have the window shown with focus\n    UINT m_ShowStageTop;     // Makes the window WS_EX_TOPMOST\n    UINT m_RealizePalette;   // Makes us realize our new palette\n    HDC m_MemoryDC;          // Used for fast BitBlt operations\n    HPALETTE m_hPalette;     // Handle to any palette we may have\n    BYTE m_bNoRealize;       // Don't realize palette now\n    BYTE m_bBackground;      // Should we realise in background\n    BYTE m_bRealizing;       // already realizing the palette\n    CCritSec m_WindowLock;   // Serialise window object access\n    BOOL m_bDoGetDC;         // Should this window get a DC\n    bool m_bDoPostToDestroy; // Use PostMessage to destroy\n    CCritSec m_PaletteLock;  // This lock protects m_hPalette.\n                             // It should be held anytime the\n                             // program use the value of m_hPalette.\n\n    // Maps windows message procedure into C++ methods\n    friend LRESULT CALLBACK WndProc(HWND hwnd,      // Window handle\n                                    UINT uMsg,      // Message ID\n                                    WPARAM wParam,  // First parameter\n                                    LPARAM lParam); // Other parameter\n\n    virtual LRESULT OnPaletteChange(HWND hwnd, UINT Message);\n\n  public:\n    CBaseWindow(BOOL bDoGetDC = TRUE, bool bPostToDestroy = false);\n\n#ifdef DEBUG\n    virtual ~CBaseWindow();\n#endif\n\n    virtual HRESULT DoneWithWindow();\n    virtual HRESULT PrepareWindow();\n    virtual HRESULT InactivateWindow();\n    virtual HRESULT ActivateWindow();\n    virtual BOOL OnSize(LONG Width, LONG Height);\n    virtual BOOL OnClose();\n    virtual RECT GetDefaultRect();\n    virtual HRESULT UninitialiseWindow();\n    virtual HRESULT InitialiseWindow(HWND hwnd);\n\n    HRESULT CompleteConnect();\n    HRESULT DoCreateWindow();\n\n    HRESULT PerformanceAlignWindow();\n    HRESULT DoShowWindow(LONG ShowCmd);\n    void PaintWindow(BOOL bErase);\n    void DoSetWindowForeground(BOOL bFocus);\n    virtual HRESULT SetPalette(HPALETTE hPalette);\n    void SetRealize(BOOL bRealize) { m_bNoRealize = !bRealize; }\n\n    //  Jump over to the window thread to set the current palette\n    HRESULT SetPalette();\n    void UnsetPalette(void);\n    virtual HRESULT DoRealisePalette(BOOL bForceBackground = FALSE);\n\n    void LockPaletteLock();\n    void UnlockPaletteLock();\n\n    virtual BOOL PossiblyEatMessage(UINT uMsg, WPARAM wParam, LPARAM lParam) { return FALSE; };\n\n    // Access our window information\n\n    bool WindowExists();\n    LONG GetWindowWidth();\n    LONG GetWindowHeight();\n    HWND GetWindowHWND();\n    HDC GetMemoryHDC();\n    HDC GetWindowHDC();\n\n#ifdef DEBUG\n    HPALETTE GetPalette();\n#endif // DEBUG\n\n    // This is the window procedure the derived object should override\n\n    virtual LRESULT OnReceiveMessage(HWND hwnd,      // Window handle\n                                     UINT uMsg,      // Message ID\n                                     WPARAM wParam,  // First parameter\n                                     LPARAM lParam); // Other parameter\n\n    // Must be overriden to return class and window styles\n\n    virtual LPTSTR GetClassWindowStyles(__out DWORD *pClassStyles,          // Class styles\n                                        __out DWORD *pWindowStyles,         // Window styles\n                                        __out DWORD *pWindowStylesEx) PURE; // Extended styles\n};\n\n// This helper class is entirely subservient to the owning CBaseWindow object\n// All this object does is to split out the actual drawing operation from the\n// main object (because it was becoming too large). We have a number of entry\n// points to set things like the draw device contexts, to implement the actual\n// drawing and to set the destination rectangle in the client window. We have\n// no critical section locking in this class because we are used exclusively\n// by the owning window object which looks after serialising calls into us\n\n// If you want to use this class make sure you call NotifyAllocator once the\n// allocate has been agreed, also call NotifyMediaType with a pointer to a\n// NON stack based CMediaType once that has been set (we keep a pointer to\n// the original rather than taking a copy). When the palette changes call\n// IncrementPaletteVersion (easiest thing to do is to also call this method\n// in the SetMediaType method most filters implement). Finally before you\n// start rendering anything call SetDrawContext so that we can get the HDCs\n// for drawing from the CBaseWindow object we are given during construction\n\nclass CDrawImage\n{\n  protected:\n    CBaseWindow *m_pBaseWindow;  // Owning video window object\n    CRefTime m_StartSample;      // Start time for the current sample\n    CRefTime m_EndSample;        // And likewise it's end sample time\n    HDC m_hdc;                   // Main window device context\n    HDC m_MemoryDC;              // Offscreen draw device context\n    RECT m_TargetRect;           // Target destination rectangle\n    RECT m_SourceRect;           // Source image rectangle\n    BOOL m_bStretch;             // Do we have to stretch the images\n    BOOL m_bUsingImageAllocator; // Are the samples shared DIBSECTIONs\n    CMediaType *m_pMediaType;    // Pointer to the current format\n    int m_perfidRenderTime;      // Time taken to render an image\n    LONG m_PaletteVersion;       // Current palette version cookie\n\n    // Draw the video images in the window\n\n    void SlowRender(IMediaSample *pMediaSample);\n    void FastRender(IMediaSample *pMediaSample);\n    void DisplaySampleTimes(IMediaSample *pSample);\n    void UpdateColourTable(HDC hdc, __in BITMAPINFOHEADER *pbmi);\n    void SetStretchMode();\n\n  public:\n    // Used to control the image drawing\n\n    CDrawImage(__inout CBaseWindow *pBaseWindow);\n    BOOL DrawImage(IMediaSample *pMediaSample);\n    BOOL DrawVideoImageHere(HDC hdc, IMediaSample *pMediaSample, __in LPRECT lprcSrc, __in LPRECT lprcDst);\n    void SetDrawContext();\n    void SetTargetRect(__in RECT *pTargetRect);\n    void SetSourceRect(__in RECT *pSourceRect);\n    void GetTargetRect(__out RECT *pTargetRect);\n    void GetSourceRect(__out RECT *pSourceRect);\n    virtual RECT ScaleSourceRect(const RECT *pSource);\n\n    // Handle updating palettes as they change\n\n    LONG GetPaletteVersion();\n    void ResetPaletteVersion();\n    void IncrementPaletteVersion();\n\n    // Tell us media types and allocator assignments\n\n    void NotifyAllocator(BOOL bUsingImageAllocator);\n    void NotifyMediaType(__in CMediaType *pMediaType);\n    BOOL UsingImageAllocator();\n\n    // Called when we are about to draw an image\n\n    void NotifyStartDraw() { MSR_START(m_perfidRenderTime); };\n\n    // Called when we complete an image rendering\n\n    void NotifyEndDraw() { MSR_STOP(m_perfidRenderTime); };\n};\n\n// This is the structure used to keep information about each GDI DIB. All the\n// samples we create from our allocator will have a DIBSECTION allocated to\n// them. When we receive the sample we know we can BitBlt straight to an HDC\n\ntypedef struct tagDIBDATA\n{\n\n    LONG PaletteVersion;   // Current palette version in use\n    DIBSECTION DibSection; // Details of DIB section allocated\n    HBITMAP hBitmap;       // Handle to bitmap for drawing\n    HANDLE hMapping;       // Handle to shared memory block\n    BYTE *pBase;           // Pointer to base memory address\n\n} DIBDATA;\n\n// This class inherits from CMediaSample and uses all of it's methods but it\n// overrides the constructor to initialise itself with the DIBDATA structure\n// When we come to render an IMediaSample we will know if we are using our own\n// allocator, and if we are, we can cast the IMediaSample to a pointer to one\n// of these are retrieve the DIB section information and hence the HBITMAP\n\nclass CImageSample : public CMediaSample\n{\n  protected:\n    DIBDATA m_DibData; // Information about the DIBSECTION\n    BOOL m_bInit;      // Is the DIB information setup\n\n  public:\n    // Constructor\n\n    CImageSample(__inout CBaseAllocator *pAllocator, __in_opt LPCTSTR pName, __inout HRESULT *phr,\n                 __in_bcount(length) LPBYTE pBuffer, LONG length);\n\n    // Maintain the DIB/DirectDraw state\n\n    void SetDIBData(__in DIBDATA *pDibData);\n    __out DIBDATA *GetDIBData();\n};\n\n// This is an allocator based on the abstract CBaseAllocator base class that\n// allocates sample buffers in shared memory. The number and size of these\n// are determined when the output pin calls Prepare on us. The shared memory\n// blocks are used in subsequent calls to GDI CreateDIBSection, once that\n// has been done the output pin can fill the buffers with data which will\n// then be handed to GDI through BitBlt calls and thereby remove one copy\n\nclass CImageAllocator : public CBaseAllocator\n{\n  protected:\n    CBaseFilter *m_pFilter;   // Delegate reference counts to\n    CMediaType *m_pMediaType; // Pointer to the current format\n\n    // Used to create and delete samples\n\n    HRESULT Alloc();\n    void Free();\n\n    // Manage the shared DIBSECTION and DCI/DirectDraw buffers\n\n    HRESULT CreateDIB(LONG InSize, DIBDATA &DibData);\n    STDMETHODIMP CheckSizes(__in ALLOCATOR_PROPERTIES *pRequest);\n    virtual CImageSample *CreateImageSample(__in_bcount(Length) LPBYTE pData, LONG Length);\n\n  public:\n    // Constructor and destructor\n\n    CImageAllocator(__inout CBaseFilter *pFilter, __in_opt LPCTSTR pName, __inout HRESULT *phr);\n#ifdef DEBUG\n    ~CImageAllocator();\n#endif\n\n    STDMETHODIMP_(ULONG) NonDelegatingAddRef();\n    STDMETHODIMP_(ULONG) NonDelegatingRelease();\n    void NotifyMediaType(__in CMediaType *pMediaType);\n\n    // Agree the number of buffers to be used and their size\n\n    STDMETHODIMP SetProperties(__in ALLOCATOR_PROPERTIES *pRequest, __out ALLOCATOR_PROPERTIES *pActual);\n};\n\n// This class is a fairly specialised helper class for image renderers that\n// have to create and manage palettes. The CBaseWindow class looks after\n// realising palettes once they have been installed. This class can be used\n// to create the palette handles from a media format (which must contain a\n// VIDEOINFO structure in the format block). We try to make the palette an\n// identity palette to maximise performance and also only change palettes\n// if actually required to (we compare palette colours before updating).\n// All the methods are virtual so that they can be overriden if so required\n\nclass CImagePalette\n{\n  protected:\n    CBaseWindow *m_pBaseWindow; // Window to realise palette in\n    CBaseFilter *m_pFilter;     // Media filter to send events\n    CDrawImage *m_pDrawImage;   // Object who will be drawing\n    HPALETTE m_hPalette;        // The palette handle we own\n\n  public:\n    CImagePalette(__inout CBaseFilter *pBaseFilter, __inout CBaseWindow *pBaseWindow, __inout CDrawImage *pDrawImage);\n\n#ifdef DEBUG\n    virtual ~CImagePalette();\n#endif\n\n    static HPALETTE MakePalette(const VIDEOINFOHEADER *pVideoInfo, __in LPSTR szDevice);\n    HRESULT RemovePalette();\n    static HRESULT MakeIdentityPalette(__inout_ecount_full(iColours) PALETTEENTRY *pEntry, INT iColours,\n                                       __in LPSTR szDevice);\n    HRESULT CopyPalette(const CMediaType *pSrc, __out CMediaType *pDest);\n    BOOL ShouldUpdate(const VIDEOINFOHEADER *pNewInfo, const VIDEOINFOHEADER *pOldInfo);\n    HRESULT PreparePalette(const CMediaType *pmtNew, const CMediaType *pmtOld, __in LPSTR szDevice);\n\n    BOOL DrawVideoImageHere(HDC hdc, IMediaSample *pMediaSample, __in LPRECT lprcSrc, __in LPRECT lprcDst)\n    {\n        return m_pDrawImage->DrawVideoImageHere(hdc, pMediaSample, lprcSrc, lprcDst);\n    }\n};\n\n// Another helper class really for video based renderers. Most such renderers\n// need to know what the display format is to some degree or another. This\n// class initialises itself with the display format. The format can be asked\n// for through GetDisplayFormat and various other accessor functions. If a\n// filter detects a display format change (perhaps it gets a WM_DEVMODECHANGE\n// message then it can call RefreshDisplayType to reset that format). Also\n// many video renderers will want to check formats as they are proposed by\n// source filters. This class provides methods to check formats and only\n// accept those video formats that can be efficiently drawn using GDI calls\n\nclass CImageDisplay : public CCritSec\n{\n  protected:\n    // This holds the display format; biSize should not be too big, so we can\n    // safely use the VIDEOINFO structure\n    VIDEOINFO m_Display;\n\n    static DWORD CountSetBits(const DWORD Field);\n    static DWORD CountPrefixBits(const DWORD Field);\n    static BOOL CheckBitFields(const VIDEOINFO *pInput);\n\n  public:\n    // Constructor and destructor\n\n    CImageDisplay();\n\n    // Used to manage BITMAPINFOHEADERs and the display format\n\n    const VIDEOINFO *GetDisplayFormat();\n    HRESULT RefreshDisplayType(__in_opt LPSTR szDeviceName);\n    static BOOL CheckHeaderValidity(const VIDEOINFO *pInput);\n    static BOOL CheckPaletteHeader(const VIDEOINFO *pInput);\n    BOOL IsPalettised();\n    WORD GetDisplayDepth();\n\n    // Provide simple video format type checking\n\n    HRESULT CheckMediaType(const CMediaType *pmtIn);\n    HRESULT CheckVideoType(const VIDEOINFO *pInput);\n    HRESULT UpdateFormat(__inout VIDEOINFO *pVideoInfo);\n    const DWORD *GetBitMasks(const VIDEOINFO *pVideoInfo);\n\n    BOOL GetColourMask(__out DWORD *pMaskRed, __out DWORD *pMaskGreen, __out DWORD *pMaskBlue);\n};\n\n//  Convert a FORMAT_VideoInfo to FORMAT_VideoInfo2\nSTDAPI ConvertVideoInfoToVideoInfo2(__inout AM_MEDIA_TYPE *pmt);\n\n//  Check a media type containing VIDEOINFOHEADER\nSTDAPI CheckVideoInfoType(const AM_MEDIA_TYPE *pmt);\n\n//  Check a media type containing VIDEOINFOHEADER\nSTDAPI CheckVideoInfo2Type(const AM_MEDIA_TYPE *pmt);\n\n#endif // __WINUTIL__\n"
  },
  {
    "path": "common/baseclasses/wxdebug.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: WXDebug.cpp\n//\n// Desc: DirectShow base classes - implements ActiveX system debugging\n//       facilities.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#define _WINDLL\n\n#include <streams.h>\n#include <stdarg.h>\n#include <stdio.h>\n#include <dvdmedia.h>\n\n#ifdef DEBUG\n#ifdef UNICODE\n#ifndef _UNICODE\n#define _UNICODE\n#endif // _UNICODE\n#endif // UNICODE\n#endif // DEBUG\n\n#include <tchar.h>\n#include <strsafe.h>\n\n#ifdef DEBUG\nstatic void DisplayBITMAPINFO(const BITMAPINFOHEADER *pbmi);\nstatic void DisplayRECT(LPCTSTR szLabel, const RECT &rc);\n\n// The Win32 wsprintf() function writes a maximum of 1024 characters to it's output buffer.\n// See the documentation for wsprintf()'s lpOut parameter for more information.\nconst INT iDEBUGINFO = 1024; // Used to format strings\n\n/* For every module and executable we store a debugging level for each of\n   the five categories (eg LOG_ERROR and LOG_TIMING). This makes it easy\n   to isolate and debug individual modules without seeing everybody elses\n   spurious debug output. The keys are stored in the registry under the\n   HKEY_LOCAL_MACHINE\\SOFTWARE\\Debug\\<Module Name>\\<KeyName> key values\n   NOTE these must be in the same order as their enumeration definition */\n\nconst LPCTSTR pKeyNames[] = {TEXT(\"TIMING\"),  // Timing and performance measurements\n                             TEXT(\"TRACE\"),   // General step point call tracing\n                             TEXT(\"MEMORY\"),  // Memory and object allocation/destruction\n                             TEXT(\"LOCKING\"), // Locking/unlocking of critical sections\n                             TEXT(\"ERROR\"),   // Debug error notification\n                             TEXT(\"CUSTOM1\"), TEXT(\"CUSTOM2\"), TEXT(\"CUSTOM3\"), TEXT(\"CUSTOM4\"), TEXT(\"CUSTOM5\")};\n\nconst TCHAR CAutoTrace::_szEntering[] = TEXT(\"->: %s\");\nconst TCHAR CAutoTrace::_szLeaving[] = TEXT(\"<-: %s\");\n\nconst INT iMAXLEVELS = NUMELMS(pKeyNames); // Maximum debug categories\n\nHINSTANCE m_hInst;                       // Module instance handle\nTCHAR m_ModuleName[iDEBUGINFO];          // Cut down module name\nDWORD m_Levels[iMAXLEVELS];              // Debug level per category\nCRITICAL_SECTION m_CSDebug;              // Controls access to list\nDWORD m_dwNextCookie;                    // Next active object ID\nObjectDesc *pListHead = NULL;            // First active object\nDWORD m_dwObjectCount;                   // Active object count\nBOOL m_bInit = FALSE;                    // Have we been initialised\nHANDLE m_hOutput = INVALID_HANDLE_VALUE; // Optional output written here\nDWORD dwWaitTimeout = INFINITE;          // Default timeout value\nDWORD dwTimeOffset;                      // Time of first DbgLog call\nbool g_fUseKASSERT = false;              // don't create messagebox\nbool g_fDbgInDllEntryPoint = false;\nbool g_fAutoRefreshLevels = false;\n\nLPCTSTR pBaseKey = TEXT(\"SOFTWARE\\\\Microsoft\\\\DirectShow\\\\Debug\");\nLPCTSTR pGlobalKey = TEXT(\"GLOBAL\");\nstatic CHAR *pUnknownName = \"UNKNOWN\";\n\nLPCTSTR TimeoutName = TEXT(\"TIMEOUT\");\n\n/* This sets the instance handle that the debug library uses to find\n   the module's file name from the Win32 GetModuleFileName function */\n\nvoid WINAPI DbgInitialise(HINSTANCE hInst)\n{\n    InitializeCriticalSection(&m_CSDebug);\n    m_bInit = TRUE;\n\n    m_hInst = hInst;\n    DbgInitModuleName();\n    if (GetProfileInt(m_ModuleName, TEXT(\"BreakOnLoad\"), 0))\n        DebugBreak();\n    DbgInitModuleSettings(false);\n    DbgInitGlobalSettings(true);\n    dwTimeOffset = timeGetTime();\n}\n\n/* This is called to clear up any resources the debug library uses - at the\n   moment we delete our critical section and the object list. The values we\n   retrieve from the registry are all done during initialisation but we don't\n   go looking for update notifications while we are running, if the values\n   are changed then the application has to be restarted to pick them up */\n\nvoid WINAPI DbgTerminate()\n{\n    if (m_hOutput != INVALID_HANDLE_VALUE)\n    {\n        EXECUTE_ASSERT(CloseHandle(m_hOutput));\n        m_hOutput = INVALID_HANDLE_VALUE;\n    }\n    DeleteCriticalSection(&m_CSDebug);\n    m_bInit = FALSE;\n}\n\n/* This is called by DbgInitLogLevels to read the debug settings\n   for each logging category for this module from the registry */\n\nvoid WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax)\n{\n    LONG lReturn;     // Create key return value\n    LONG lKeyPos;     // Current key category\n    DWORD dwKeySize;  // Size of the key value\n    DWORD dwKeyType;  // Receives it's type\n    DWORD dwKeyValue; // This fields value\n\n    /* Try and read a value for each key position in turn */\n    for (lKeyPos = 0; lKeyPos < iMAXLEVELS; lKeyPos++)\n    {\n\n        dwKeySize = sizeof(DWORD);\n        lReturn = RegQueryValueEx(hKey,                // Handle to an open key\n                                  pKeyNames[lKeyPos],  // Subkey name derivation\n                                  NULL,                // Reserved field\n                                  &dwKeyType,          // Returns the field type\n                                  (LPBYTE)&dwKeyValue, // Returns the field's value\n                                  &dwKeySize);         // Number of bytes transferred\n\n        /* If either the key was not available or it was not a DWORD value\n           then we ensure only the high priority debug logging is output\n           but we try and update the field to a zero filled DWORD value */\n\n        if (lReturn != ERROR_SUCCESS || dwKeyType != REG_DWORD)\n        {\n\n            dwKeyValue = 0;\n            lReturn = RegSetValueEx(hKey,               // Handle of an open key\n                                    pKeyNames[lKeyPos], // Address of subkey name\n                                    (DWORD)0,           // Reserved field\n                                    REG_DWORD,          // Type of the key field\n                                    (PBYTE)&dwKeyValue, // Value for the field\n                                    sizeof(DWORD));     // Size of the field buffer\n\n            if (lReturn != ERROR_SUCCESS)\n            {\n                DbgLog((LOG_ERROR, 1, TEXT(\"Could not create subkey %s\"), pKeyNames[lKeyPos]));\n                dwKeyValue = 0;\n            }\n        }\n        if (fTakeMax)\n        {\n            m_Levels[lKeyPos] = max(dwKeyValue, m_Levels[lKeyPos]);\n        }\n        else\n        {\n            if ((m_Levels[lKeyPos] & LOG_FORCIBLY_SET) == 0)\n            {\n                m_Levels[lKeyPos] = dwKeyValue;\n            }\n        }\n    }\n\n    /*  Read the timeout value for catching hangs */\n    dwKeySize = sizeof(DWORD);\n    lReturn = RegQueryValueEx(hKey,                   // Handle to an open key\n                              TimeoutName,            // Subkey name derivation\n                              NULL,                   // Reserved field\n                              &dwKeyType,             // Returns the field type\n                              (LPBYTE)&dwWaitTimeout, // Returns the field's value\n                              &dwKeySize);            // Number of bytes transferred\n\n    /* If either the key was not available or it was not a DWORD value\n       then we ensure only the high priority debug logging is output\n       but we try and update the field to a zero filled DWORD value */\n\n    if (lReturn != ERROR_SUCCESS || dwKeyType != REG_DWORD)\n    {\n\n        dwWaitTimeout = INFINITE;\n        lReturn = RegSetValueEx(hKey,                  // Handle of an open key\n                                TimeoutName,           // Address of subkey name\n                                (DWORD)0,              // Reserved field\n                                REG_DWORD,             // Type of the key field\n                                (PBYTE)&dwWaitTimeout, // Value for the field\n                                sizeof(DWORD));        // Size of the field buffer\n\n        if (lReturn != ERROR_SUCCESS)\n        {\n            DbgLog((LOG_ERROR, 1, TEXT(\"Could not create subkey %s\"), pKeyNames[lKeyPos]));\n            dwWaitTimeout = INFINITE;\n        }\n    }\n}\n\nvoid WINAPI DbgOutString(LPCTSTR psz)\n{\n    if (m_hOutput != INVALID_HANDLE_VALUE)\n    {\n        UINT cb = lstrlen(psz);\n        DWORD dw;\n#ifdef UNICODE\n        CHAR szDest[2048];\n        WideCharToMultiByte(CP_ACP, 0, psz, -1, szDest, NUMELMS(szDest), 0, 0);\n        WriteFile(m_hOutput, szDest, cb, &dw, NULL);\n#else\n        WriteFile(m_hOutput, psz, cb, &dw, NULL);\n#endif\n    }\n    OutputDebugString(psz);\n}\n\nHRESULT DbgUniqueProcessName(LPCTSTR inName, LPTSTR outName)\n{\n    HRESULT hr = S_OK;\n    const TCHAR *pIn = inName;\n    int dotPos = -1;\n\n    // scan the input and record the last '.' position\n    while (*pIn && (pIn - inName) < MAX_PATH)\n    {\n        if (TEXT('.') == *pIn)\n            dotPos = (int)(pIn - inName);\n        ++pIn;\n    }\n\n    if (*pIn) // input should be zero-terminated within MAX_PATH\n        return E_INVALIDARG;\n\n    DWORD dwProcessId = GetCurrentProcessId();\n\n    if (dotPos < 0)\n    {\n        // no extension in the input, appending process id to the input\n        hr = StringCchPrintf(outName, MAX_PATH, TEXT(\"%s_%d\"), inName, dwProcessId);\n    }\n    else\n    {\n        TCHAR pathAndBasename[MAX_PATH] = {0};\n\n        // there's an extension  - zero-terminate the path and basename first by copying\n        hr = StringCchCopyN(pathAndBasename, MAX_PATH, inName, (size_t)dotPos);\n\n        // re-combine path, basename and extension with processId appended to a basename\n        if (SUCCEEDED(hr))\n            hr = StringCchPrintf(outName, MAX_PATH, TEXT(\"%s_%d%s\"), pathAndBasename, dwProcessId, inName + dotPos);\n    }\n\n    return hr;\n}\n\n/* Called by DbgInitGlobalSettings to setup alternate logging destinations\n */\n\nvoid WINAPI DbgInitLogTo(HKEY hKey)\n{\n    LONG lReturn;\n    DWORD dwKeyType;\n    DWORD dwKeySize;\n    TCHAR szFile[MAX_PATH] = {0};\n    static const TCHAR cszKey[] = TEXT(\"LogToFile\");\n\n    dwKeySize = MAX_PATH;\n    lReturn = RegQueryValueEx(hKey,           // Handle to an open key\n                              cszKey,         // Subkey name derivation\n                              NULL,           // Reserved field\n                              &dwKeyType,     // Returns the field type\n                              (LPBYTE)szFile, // Returns the field's value\n                              &dwKeySize);    // Number of bytes transferred\n\n    // create an empty key if it does not already exist\n    //\n    if (lReturn != ERROR_SUCCESS || dwKeyType != REG_SZ)\n    {\n        dwKeySize = sizeof(TCHAR);\n        lReturn = RegSetValueEx(hKey,          // Handle of an open key\n                                cszKey,        // Address of subkey name\n                                (DWORD)0,      // Reserved field\n                                REG_SZ,        // Type of the key field\n                                (PBYTE)szFile, // Value for the field\n                                dwKeySize);    // Size of the field buffer\n    }\n\n    // if an output-to was specified.  try to open it.\n    //\n    if (m_hOutput != INVALID_HANDLE_VALUE)\n    {\n        EXECUTE_ASSERT(CloseHandle(m_hOutput));\n        m_hOutput = INVALID_HANDLE_VALUE;\n    }\n    if (szFile[0] != 0)\n    {\n        if (!lstrcmpi(szFile, TEXT(\"Console\")))\n        {\n            m_hOutput = GetStdHandle(STD_OUTPUT_HANDLE);\n            if (m_hOutput == INVALID_HANDLE_VALUE)\n            {\n                AllocConsole();\n                m_hOutput = GetStdHandle(STD_OUTPUT_HANDLE);\n            }\n            SetConsoleTitle(TEXT(\"ActiveX Debug Output\"));\n        }\n        else if (szFile[0] && lstrcmpi(szFile, TEXT(\"Debug\")) && lstrcmpi(szFile, TEXT(\"Debugger\")) &&\n                 lstrcmpi(szFile, TEXT(\"Deb\")))\n        {\n            m_hOutput =\n                CreateFile(szFile, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);\n\n            if (INVALID_HANDLE_VALUE == m_hOutput && GetLastError() == ERROR_SHARING_VIOLATION)\n            {\n                TCHAR uniqueName[MAX_PATH] = {0};\n                if (SUCCEEDED(DbgUniqueProcessName(szFile, uniqueName)))\n                {\n                    m_hOutput = CreateFile(uniqueName, GENERIC_WRITE, FILE_SHARE_READ, NULL, OPEN_ALWAYS,\n                                           FILE_ATTRIBUTE_NORMAL, NULL);\n                }\n            }\n\n            if (INVALID_HANDLE_VALUE != m_hOutput)\n            {\n                static const TCHAR cszBar[] = TEXT(\"\\r\\n\\r\\n=====DbgInitialize()=====\\r\\n\\r\\n\");\n                SetFilePointer(m_hOutput, 0, NULL, FILE_END);\n                DbgOutString(cszBar);\n            }\n        }\n    }\n}\n\n/* This is called by DbgInitLogLevels to read the global debug settings for\n   each logging category for this module from the registry. Normally each\n   module has it's own values set for it's different debug categories but\n   setting the global SOFTWARE\\Debug\\Global applies them to ALL modules */\n\nvoid WINAPI DbgInitGlobalSettings(bool fTakeMax)\n{\n    LONG lReturn;             // Create key return value\n    TCHAR szInfo[iDEBUGINFO]; // Constructs key names\n    HKEY hGlobalKey;          // Global override key\n\n    /* Construct the global base key name */\n    (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%s\\\\%s\"), pBaseKey, pGlobalKey);\n\n    /* Create or open the key for this module */\n    lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE,           // Handle of an open key\n                             szInfo,                       // Address of subkey name\n                             (DWORD)0,                     // Reserved value\n                             NULL,                         // Address of class name\n                             (DWORD)0,                     // Special options flags\n                             GENERIC_READ | GENERIC_WRITE, // Desired security access\n                             NULL,                         // Key security descriptor\n                             &hGlobalKey,                  // Opened handle buffer\n                             NULL);                        // What really happened\n\n    if (lReturn != ERROR_SUCCESS)\n    {\n        lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key\n                                 szInfo,             // Address of subkey name\n                                 (DWORD)0,           // Reserved value\n                                 NULL,               // Address of class name\n                                 (DWORD)0,           // Special options flags\n                                 GENERIC_READ,       // Desired security access\n                                 NULL,               // Key security descriptor\n                                 &hGlobalKey,        // Opened handle buffer\n                                 NULL);              // What really happened\n        if (lReturn != ERROR_SUCCESS)\n        {\n            DbgLog((LOG_ERROR, 1, TEXT(\"Could not access GLOBAL module key\")));\n        }\n        return;\n    }\n\n    DbgInitKeyLevels(hGlobalKey, fTakeMax);\n    RegCloseKey(hGlobalKey);\n}\n\n/* This sets the debugging log levels for the different categories. We start\n   by opening (or creating if not already available) the SOFTWARE\\Debug key\n   that all these settings live under. We then look at the global values\n   set under SOFTWARE\\Debug\\Global which apply on top of the individual\n   module settings. We then load the individual module registry settings */\n\nvoid WINAPI DbgInitModuleSettings(bool fTakeMax)\n{\n    LONG lReturn;             // Create key return value\n    TCHAR szInfo[iDEBUGINFO]; // Constructs key names\n    HKEY hModuleKey;          // Module key handle\n\n    /* Construct the base key name */\n    (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%s\\\\%s\"), pBaseKey, m_ModuleName);\n\n    /* Create or open the key for this module */\n    lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE,           // Handle of an open key\n                             szInfo,                       // Address of subkey name\n                             (DWORD)0,                     // Reserved value\n                             NULL,                         // Address of class name\n                             (DWORD)0,                     // Special options flags\n                             GENERIC_READ | GENERIC_WRITE, // Desired security access\n                             NULL,                         // Key security descriptor\n                             &hModuleKey,                  // Opened handle buffer\n                             NULL);                        // What really happened\n\n    if (lReturn != ERROR_SUCCESS)\n    {\n        lReturn = RegCreateKeyEx(HKEY_LOCAL_MACHINE, // Handle of an open key\n                                 szInfo,             // Address of subkey name\n                                 (DWORD)0,           // Reserved value\n                                 NULL,               // Address of class name\n                                 (DWORD)0,           // Special options flags\n                                 GENERIC_READ,       // Desired security access\n                                 NULL,               // Key security descriptor\n                                 &hModuleKey,        // Opened handle buffer\n                                 NULL);              // What really happened\n        if (lReturn != ERROR_SUCCESS)\n        {\n            DbgLog((LOG_ERROR, 1, TEXT(\"Could not access module key\")));\n        }\n        return;\n    }\n\n    DbgInitLogTo(hModuleKey);\n    DbgInitKeyLevels(hModuleKey, fTakeMax);\n    RegCloseKey(hModuleKey);\n}\n\n/* Initialise the module file name */\n\nvoid WINAPI DbgInitModuleName()\n{\n    TCHAR FullName[iDEBUGINFO]; // Load the full path and module name\n    LPTSTR pName;               // Searches from the end for a backslash\n\n    GetModuleFileName(m_hInst, FullName, iDEBUGINFO);\n    pName = _tcsrchr(FullName, '\\\\');\n    if (pName == NULL)\n    {\n        pName = FullName;\n    }\n    else\n    {\n        pName++;\n    }\n    (void)StringCchCopy(m_ModuleName, NUMELMS(m_ModuleName), pName);\n}\n\nstruct MsgBoxMsg\n{\n    HWND hwnd;\n    LPCTSTR szTitle;\n    LPCTSTR szMessage;\n    DWORD dwFlags;\n    INT iResult;\n};\n\n//\n// create a thread to call MessageBox(). calling MessageBox() on\n// random threads at bad times can confuse the host (eg IE).\n//\nDWORD WINAPI MsgBoxThread(__inout LPVOID lpParameter // thread data\n)\n{\n    MsgBoxMsg *pmsg = (MsgBoxMsg *)lpParameter;\n    pmsg->iResult = MessageBox(pmsg->hwnd, pmsg->szTitle, pmsg->szMessage, pmsg->dwFlags);\n\n    return 0;\n}\n\nINT MessageBoxOtherThread(HWND hwnd, LPCTSTR szTitle, LPCTSTR szMessage, DWORD dwFlags)\n{\n    if (g_fDbgInDllEntryPoint)\n    {\n        // can't wait on another thread because we have the loader\n        // lock held in the dll entry point.\n        // This can crash sometimes so just skip it\n        // return MessageBox(hwnd, szTitle, szMessage, dwFlags);\n        return IDCANCEL;\n    }\n    else\n    {\n        MsgBoxMsg msg = {hwnd, szTitle, szMessage, dwFlags, 0};\n        DWORD dwid;\n        HANDLE hThread = CreateThread(0, // security\n                                      0, // stack size\n                                      MsgBoxThread,\n                                      (void *)&msg, // arg\n                                      0,            // flags\n                                      &dwid);\n        if (hThread)\n        {\n            WaitForSingleObject(hThread, INFINITE);\n            CloseHandle(hThread);\n            return msg.iResult;\n        }\n\n        // break into debugger on failure.\n        return IDCANCEL;\n    }\n}\n\n/* Displays a message box if the condition evaluated to FALSE */\n\nvoid WINAPI DbgAssert(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine)\n{\n    if (g_fUseKASSERT)\n    {\n        DbgKernelAssert(pCondition, pFileName, iLine);\n    }\n    else\n    {\n\n        TCHAR szInfo[iDEBUGINFO];\n\n        (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%s \\nAt line %d of %s\\nContinue? (Cancel to debug)\"),\n                              pCondition, iLine, pFileName);\n\n        INT MsgId = MessageBoxOtherThread(NULL, szInfo, TEXT(\"ASSERT Failed\"),\n                                          MB_SYSTEMMODAL | MB_ICONHAND | MB_YESNOCANCEL | MB_SETFOREGROUND);\n        switch (MsgId)\n        {\n        case IDNO: /* Kill the application */ FatalAppExit(FALSE, TEXT(\"Application terminated\")); break;\n\n        case IDCANCEL: /* Break into the debugger */ DebugBreak(); break;\n\n        case IDYES: /* Ignore assertion continue execution */ break;\n        }\n    }\n}\n\n/* Displays a message box at a break point */\n\nvoid WINAPI DbgBreakPoint(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine)\n{\n    if (g_fUseKASSERT)\n    {\n        DbgKernelAssert(pCondition, pFileName, iLine);\n    }\n    else\n    {\n        TCHAR szInfo[iDEBUGINFO];\n\n        (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%s \\nAt line %d of %s\\nContinue? (Cancel to debug)\"),\n                              pCondition, iLine, pFileName);\n\n        INT MsgId = MessageBoxOtherThread(NULL, szInfo, TEXT(\"Hard coded break point\"),\n                                          MB_SYSTEMMODAL | MB_ICONHAND | MB_YESNOCANCEL | MB_SETFOREGROUND);\n        switch (MsgId)\n        {\n        case IDNO: /* Kill the application */ FatalAppExit(FALSE, TEXT(\"Application terminated\")); break;\n\n        case IDCANCEL: /* Break into the debugger */ DebugBreak(); break;\n\n        case IDYES: /* Ignore break point continue execution */ break;\n        }\n    }\n}\n\nvoid WINAPI DbgBreakPoint(LPCTSTR pFileName, INT iLine, __format_string LPCTSTR szFormatString, ...)\n{\n    // A debug break point message can have at most 2000 characters if\n    // ANSI or UNICODE characters are being used.  A debug break point message\n    // can have between 1000 and 2000 double byte characters in it.  If a\n    // particular message needs more characters, then the value of this constant\n    // should be increased.\n    const DWORD MAX_BREAK_POINT_MESSAGE_SIZE = 2000;\n\n    TCHAR szBreakPointMessage[MAX_BREAK_POINT_MESSAGE_SIZE];\n\n    va_list va;\n    va_start(va, szFormatString);\n\n    HRESULT hr = StringCchVPrintf(szBreakPointMessage, NUMELMS(szBreakPointMessage), szFormatString, va);\n\n    va_end(va);\n\n    if (FAILED(hr))\n    {\n        DbgBreak(\"ERROR in DbgBreakPoint().  The variable length debug message could not be displayed because \"\n                 \"StringCchVPrintf() failed.\");\n        return;\n    }\n\n    ::DbgBreakPoint(szBreakPointMessage, pFileName, iLine);\n}\n\n/* When we initialised the library we stored in the m_Levels array the current\n   debug output level for this module for each of the five categories. When\n   some debug logging is sent to us it can be sent with a combination of the\n   categories (if it is applicable to many for example) in which case we map\n   the type's categories into their current debug levels and see if any of\n   them can be accepted. The function looks at each bit position in turn from\n   the input type field and then compares it's debug level with the modules.\n\n   A level of 0 means that output is always sent to the debugger.  This is\n   due to producing output if the input level is <= m_Levels.\n*/\n\nBOOL WINAPI DbgCheckModuleLevel(DWORD Type, DWORD Level)\n{\n    if (g_fAutoRefreshLevels)\n    {\n        // re-read the registry every second. We cannot use RegNotify() to\n        // notice registry changes because it's not available on win9x.\n        static DWORD g_dwLastRefresh = 0;\n        DWORD dwTime = timeGetTime();\n        if (dwTime - g_dwLastRefresh > 1000)\n        {\n            g_dwLastRefresh = dwTime;\n\n            // there's a race condition: multiple threads could update the\n            // values. plus read and write not synchronized. no harm\n            // though.\n            DbgInitModuleSettings(false);\n        }\n    }\n\n    DWORD Mask = 0x01;\n\n    // If no valid bits are set return FALSE\n    if ((Type & ((1 << iMAXLEVELS) - 1)))\n    {\n\n        // speed up unconditional output.\n        if (0 == Level)\n            return (TRUE);\n\n        for (LONG lKeyPos = 0; lKeyPos < iMAXLEVELS; lKeyPos++)\n        {\n            if (Type & Mask)\n            {\n                if (Level <= (m_Levels[lKeyPos] & ~LOG_FORCIBLY_SET))\n                {\n                    return TRUE;\n                }\n            }\n            Mask <<= 1;\n        }\n    }\n    return FALSE;\n}\n\n/* Set debug levels to a given value */\n\nvoid WINAPI DbgSetModuleLevel(DWORD Type, DWORD Level)\n{\n    DWORD Mask = 0x01;\n\n    for (LONG lKeyPos = 0; lKeyPos < iMAXLEVELS; lKeyPos++)\n    {\n        if (Type & Mask)\n        {\n            m_Levels[lKeyPos] = Level | LOG_FORCIBLY_SET;\n        }\n        Mask <<= 1;\n    }\n}\n\n/* whether to check registry values periodically. this isn't turned\n   automatically because of the potential performance hit. */\nvoid WINAPI DbgSetAutoRefreshLevels(bool fAuto)\n{\n    g_fAutoRefreshLevels = fAuto;\n}\n\n#ifdef UNICODE\n//\n// warning -- this function is implemented twice for ansi applications\n// linking to the unicode library\n//\nvoid WINAPI DbgLogInfo(DWORD Type, DWORD Level, __format_string LPCSTR pFormat, ...)\n{\n    /* Check the current level for this type combination */\n\n    BOOL bAccept = DbgCheckModuleLevel(Type, Level);\n    if (bAccept == FALSE)\n    {\n        return;\n    }\n\n    TCHAR szInfo[2000];\n\n    /* Format the variable length parameter list */\n\n    va_list va;\n    va_start(va, pFormat);\n\n    (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%s(tid %x) %8d : \"), m_ModuleName, GetCurrentThreadId(),\n                          timeGetTime() - dwTimeOffset);\n\n    CHAR szInfoA[2000];\n    WideCharToMultiByte(CP_ACP, 0, szInfo, -1, szInfoA, NUMELMS(szInfoA), 0, 0);\n\n    (void)StringCchVPrintfA(szInfoA + lstrlenA(szInfoA), NUMELMS(szInfoA) - lstrlenA(szInfoA), pFormat, va);\n    (void)StringCchCatA(szInfoA, NUMELMS(szInfoA), \"\\r\\n\");\n\n    WCHAR wszOutString[2000];\n    MultiByteToWideChar(CP_ACP, 0, szInfoA, -1, wszOutString, NUMELMS(wszOutString));\n    DbgOutString(wszOutString);\n\n    va_end(va);\n}\n\nvoid WINAPI DbgAssert(LPCSTR pCondition, LPCSTR pFileName, INT iLine)\n{\n    if (g_fUseKASSERT)\n    {\n        DbgKernelAssert(pCondition, pFileName, iLine);\n    }\n    else\n    {\n\n        TCHAR szInfo[iDEBUGINFO];\n\n        (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%hs \\nAt line %d of %hs\\nContinue? (Cancel to debug)\"),\n                              pCondition, iLine, pFileName);\n\n        INT MsgId = MessageBoxOtherThread(NULL, szInfo, TEXT(\"ASSERT Failed\"),\n                                          MB_SYSTEMMODAL | MB_ICONHAND | MB_YESNOCANCEL | MB_SETFOREGROUND);\n        switch (MsgId)\n        {\n        case IDNO: /* Kill the application */ FatalAppExit(FALSE, TEXT(\"Application terminated\")); break;\n\n        case IDCANCEL: /* Break into the debugger */ DebugBreak(); break;\n\n        case IDYES: /* Ignore assertion continue execution */ break;\n        }\n    }\n}\n\n/* Displays a message box at a break point */\n\nvoid WINAPI DbgBreakPoint(LPCSTR pCondition, LPCSTR pFileName, INT iLine)\n{\n    if (g_fUseKASSERT)\n    {\n        DbgKernelAssert(pCondition, pFileName, iLine);\n    }\n    else\n    {\n        TCHAR szInfo[iDEBUGINFO];\n\n        (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%hs \\nAt line %d of %hs\\nContinue? (Cancel to debug)\"),\n                              pCondition, iLine, pFileName);\n\n        INT MsgId = MessageBoxOtherThread(NULL, szInfo, TEXT(\"Hard coded break point\"),\n                                          MB_SYSTEMMODAL | MB_ICONHAND | MB_YESNOCANCEL | MB_SETFOREGROUND);\n        switch (MsgId)\n        {\n        case IDNO: /* Kill the application */ FatalAppExit(FALSE, TEXT(\"Application terminated\")); break;\n\n        case IDCANCEL: /* Break into the debugger */ DebugBreak(); break;\n\n        case IDYES: /* Ignore break point continue execution */ break;\n        }\n    }\n}\n\nvoid WINAPI DbgKernelAssert(LPCSTR pCondition, LPCSTR pFileName, INT iLine)\n{\n    DbgLog((LOG_ERROR, 0, TEXT(\"Assertion FAILED (%hs) at line %d in file %hs\"), pCondition, iLine, pFileName));\n    DebugBreak();\n}\n\n#endif\n\n/* Print a formatted string to the debugger prefixed with this module's name\n   Because the COMBASE classes are linked statically every module loaded will\n   have their own copy of this code. It therefore helps if the module name is\n   included on the output so that the offending code can be easily found */\n\n//\n// warning -- this function is implemented twice for ansi applications\n// linking to the unicode library\n//\nvoid WINAPI DbgLogInfo(DWORD Type, DWORD Level, LPCTSTR pFormat, ...)\n{\n\n    /* Check the current level for this type combination */\n\n    BOOL bAccept = DbgCheckModuleLevel(Type, Level);\n    if (bAccept == FALSE)\n    {\n        return;\n    }\n\n    TCHAR szInfo[2000];\n\n    /* Format the variable length parameter list */\n\n    va_list va;\n    va_start(va, pFormat);\n\n    (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%s(tid %x) %8d : \"), m_ModuleName, GetCurrentThreadId(),\n                          timeGetTime() - dwTimeOffset);\n\n    (void)StringCchVPrintf(szInfo + lstrlen(szInfo), NUMELMS(szInfo) - lstrlen(szInfo), pFormat, va);\n    (void)StringCchCat(szInfo, NUMELMS(szInfo), TEXT(\"\\r\\n\"));\n    DbgOutString(szInfo);\n\n    va_end(va);\n}\n\n/* If we are executing as a pure kernel filter we cannot display message\n   boxes to the user, this provides an alternative which puts the error\n   condition on the debugger output with a suitable eye catching message */\n\nvoid WINAPI DbgKernelAssert(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine)\n{\n    DbgLog((LOG_ERROR, 0, TEXT(\"Assertion FAILED (%s) at line %d in file %s\"), pCondition, iLine, pFileName));\n    DebugBreak();\n}\n\n/* Each time we create an object derived from CBaseObject the constructor will\n   call us to register the creation of the new object. We are passed a string\n   description which we store away. We return a cookie that the constructor\n   uses to identify the object when it is destroyed later on. We update the\n   total number of active objects in the DLL mainly for debugging purposes */\n\nDWORD WINAPI DbgRegisterObjectCreation(LPCSTR szObjectName, LPCWSTR wszObjectName)\n{\n    /* If this fires you have a mixed DEBUG/RETAIL build */\n\n    ASSERT(!!szObjectName ^ !!wszObjectName);\n\n    /* Create a place holder for this object description */\n\n    ObjectDesc *pObject = new ObjectDesc;\n    ASSERT(pObject);\n\n    /* It is valid to pass a NULL object name */\n    if (pObject == NULL)\n    {\n        return FALSE;\n    }\n\n    /* Check we have been initialised - we may not be initialised when we are\n       being pulled in from an executable which has globally defined objects\n       as they are created by the C++ run time before WinMain is called */\n\n    if (m_bInit == FALSE)\n    {\n        DbgInitialise(GetModuleHandle(NULL));\n    }\n\n    /* Grab the list critical section */\n    EnterCriticalSection(&m_CSDebug);\n\n    /* If no name then default to UNKNOWN */\n    if (!szObjectName && !wszObjectName)\n    {\n        szObjectName = pUnknownName;\n    }\n\n    /* Put the new description at the head of the list */\n\n    pObject->m_szName = szObjectName;\n    pObject->m_wszName = wszObjectName;\n    pObject->m_dwCookie = ++m_dwNextCookie;\n    pObject->m_pNext = pListHead;\n\n    pListHead = pObject;\n    m_dwObjectCount++;\n\n    DWORD ObjectCookie = pObject->m_dwCookie;\n    ASSERT(ObjectCookie);\n\n    if (wszObjectName)\n    {\n        DbgLog((LOG_MEMORY, 2, TEXT(\"Object created   %d (%ls) %d Active\"), pObject->m_dwCookie, wszObjectName,\n                m_dwObjectCount));\n    }\n    else\n    {\n        DbgLog((LOG_MEMORY, 2, TEXT(\"Object created   %d (%hs) %d Active\"), pObject->m_dwCookie, szObjectName,\n                m_dwObjectCount));\n    }\n\n    LeaveCriticalSection(&m_CSDebug);\n    return ObjectCookie;\n}\n\n/* This is called by the CBaseObject destructor when an object is about to be\n   destroyed, we are passed the cookie we returned during construction that\n   identifies this object. We scan the object list for a matching cookie and\n   remove the object if successful. We also update the active object count */\n\nBOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie)\n{\n    /* Grab the list critical section */\n    EnterCriticalSection(&m_CSDebug);\n\n    ObjectDesc *pObject = pListHead;\n    ObjectDesc *pPrevious = NULL;\n\n    /* Scan the object list looking for a cookie match */\n\n    while (pObject)\n    {\n        if (pObject->m_dwCookie == dwCookie)\n        {\n            break;\n        }\n        pPrevious = pObject;\n        pObject = pObject->m_pNext;\n    }\n\n    if (pObject == NULL)\n    {\n        DbgBreak(\"Apparently destroying a bogus object\");\n        LeaveCriticalSection(&m_CSDebug);\n        return FALSE;\n    }\n\n    /* Is the object at the head of the list */\n\n    if (pPrevious == NULL)\n    {\n        pListHead = pObject->m_pNext;\n    }\n    else\n    {\n        pPrevious->m_pNext = pObject->m_pNext;\n    }\n\n    /* Delete the object and update the housekeeping information */\n\n    m_dwObjectCount--;\n\n    if (pObject->m_wszName)\n    {\n        DbgLog((LOG_MEMORY, 2, TEXT(\"Object destroyed %d (%ls) %d Active\"), pObject->m_dwCookie, pObject->m_wszName,\n                m_dwObjectCount));\n    }\n    else\n    {\n        DbgLog((LOG_MEMORY, 2, TEXT(\"Object destroyed %d (%hs) %d Active\"), pObject->m_dwCookie, pObject->m_szName,\n                m_dwObjectCount));\n    }\n\n    delete pObject;\n    LeaveCriticalSection(&m_CSDebug);\n    return TRUE;\n}\n\n/* This runs through the active object list displaying their details */\n\nvoid WINAPI DbgDumpObjectRegister()\n{\n    TCHAR szInfo[iDEBUGINFO];\n\n    /* Grab the list critical section */\n\n    EnterCriticalSection(&m_CSDebug);\n    ObjectDesc *pObject = pListHead;\n\n    /* Scan the object list displaying the name and cookie */\n\n    DbgLog((LOG_MEMORY, 2, TEXT(\"\")));\n    DbgLog((LOG_MEMORY, 2, TEXT(\"   ID             Object Description\")));\n    DbgLog((LOG_MEMORY, 2, TEXT(\"\")));\n\n    while (pObject)\n    {\n        if (pObject->m_wszName)\n        {\n            (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%5d (%p) %30ls\"), pObject->m_dwCookie, &pObject,\n                                  pObject->m_wszName);\n        }\n        else\n        {\n            (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"%5d (%p) %30hs\"), pObject->m_dwCookie, &pObject,\n                                  pObject->m_szName);\n        }\n        DbgLog((LOG_MEMORY, 2, szInfo));\n        pObject = pObject->m_pNext;\n    }\n\n    (void)StringCchPrintf(szInfo, NUMELMS(szInfo), TEXT(\"Total object count %5d\"), m_dwObjectCount);\n    DbgLog((LOG_MEMORY, 2, TEXT(\"\")));\n    DbgLog((LOG_MEMORY, 1, szInfo));\n    LeaveCriticalSection(&m_CSDebug);\n}\n\n/*  Debug infinite wait stuff */\nDWORD WINAPI DbgWaitForSingleObject(HANDLE h)\n{\n    DWORD dwWaitResult;\n    do\n    {\n        dwWaitResult = WaitForSingleObject(h, dwWaitTimeout);\n        ASSERT(dwWaitResult == WAIT_OBJECT_0);\n    } while (dwWaitResult == WAIT_TIMEOUT);\n    return dwWaitResult;\n}\nDWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount, __in_ecount(nCount) CONST HANDLE *lpHandles, BOOL bWaitAll)\n{\n    DWORD dwWaitResult;\n    do\n    {\n        dwWaitResult = WaitForMultipleObjects(nCount, lpHandles, bWaitAll, dwWaitTimeout);\n        ASSERT((DWORD)(dwWaitResult - WAIT_OBJECT_0) < MAXIMUM_WAIT_OBJECTS);\n    } while (dwWaitResult == WAIT_TIMEOUT);\n    return dwWaitResult;\n}\n\nvoid WINAPI DbgSetWaitTimeout(DWORD dwTimeout)\n{\n    dwWaitTimeout = dwTimeout;\n}\n\n#endif /* DEBUG */\n\n#ifdef _OBJBASE_H_\n\n/*  Stuff for printing out our GUID names */\n\nGUID_STRING_ENTRY g_GuidNames[] = {\n#define OUR_GUID_ENTRY(name, l, w1, w2, b1, b2, b3, b4, b5, b6, b7, b8) \\\n    {#name, {l, w1, w2, {b1, b2, b3, b4, b5, b6, b7, b8}}},\n#include <uuids.h>\n};\n\nCGuidNameList GuidNames;\nint g_cGuidNames = sizeof(g_GuidNames) / sizeof(g_GuidNames[0]);\n\nchar *CGuidNameList::operator[](const GUID &guid)\n{\n    for (int i = 0; i < g_cGuidNames; i++)\n    {\n        if (g_GuidNames[i].guid == guid)\n        {\n            return g_GuidNames[i].szName;\n        }\n    }\n    if (guid == GUID_NULL)\n    {\n        return \"GUID_NULL\";\n    }\n\n    // !!! add something to print FOURCC guids?\n\n    // shouldn't this print the hex CLSID?\n    return \"Unknown GUID Name\";\n}\n\n#endif /* _OBJBASE_H_ */\n\n/*  CDisp class - display our data types */\n\n// clashes with REFERENCE_TIME\nCDisp::CDisp(LONGLONG ll, int Format)\n{\n    // note: this could be combined with CDisp(LONGLONG) by\n    // introducing a default format of CDISP_REFTIME\n    LARGE_INTEGER li;\n    li.QuadPart = ll;\n    switch (Format)\n    {\n    case CDISP_DEC: {\n        TCHAR temp[20];\n        int pos = 20;\n        temp[--pos] = 0;\n        int digit;\n        // always output at least one digit\n        do\n        {\n            // Get the rightmost digit - we only need the low word\n            digit = li.LowPart % 10;\n            li.QuadPart /= 10;\n            temp[--pos] = (TCHAR)digit + L'0';\n        } while (li.QuadPart);\n        (void)StringCchCopy(m_String, NUMELMS(m_String), temp + pos);\n        break;\n    }\n    case CDISP_HEX:\n    default: (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT(\"0x%X%8.8X\"), li.HighPart, li.LowPart);\n    }\n};\n\nCDisp::CDisp(REFCLSID clsid)\n{\n#ifdef UNICODE\n    (void)StringFromGUID2(clsid, m_String, NUMELMS(m_String));\n#else\n    WCHAR wszTemp[50];\n    (void)StringFromGUID2(clsid, wszTemp, NUMELMS(wszTemp));\n    (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT(\"%S\"), wszTemp);\n#endif\n};\n\n#ifdef __STREAMS__\n/*  Display stuff */\nCDisp::CDisp(CRefTime llTime)\n{\n    LONGLONG llDiv;\n    if (llTime < 0)\n    {\n        llTime = -llTime;\n        (void)StringCchCopy(m_String, NUMELMS(m_String), TEXT(\"-\"));\n    }\n    llDiv = (LONGLONG)24 * 3600 * 10000000;\n    if (llTime >= llDiv)\n    {\n        (void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT(\"%d days \"),\n                              (LONG)(llTime / llDiv));\n        llTime = llTime % llDiv;\n    }\n    llDiv = (LONGLONG)3600 * 10000000;\n    if (llTime >= llDiv)\n    {\n        (void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT(\"%d hrs \"),\n                              (LONG)(llTime / llDiv));\n        llTime = llTime % llDiv;\n    }\n    llDiv = (LONGLONG)60 * 10000000;\n    if (llTime >= llDiv)\n    {\n        (void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT(\"%d mins \"),\n                              (LONG)(llTime / llDiv));\n        llTime = llTime % llDiv;\n    }\n    (void)StringCchPrintf(m_String + lstrlen(m_String), NUMELMS(m_String) - lstrlen(m_String), TEXT(\"%d.%3.3d sec\"),\n                          (LONG)llTime / 10000000, (LONG)((llTime % 10000000) / 10000));\n};\n\n#endif // __STREAMS__\n\n/*  Display pin */\nCDisp::CDisp(IPin *pPin)\n{\n    PIN_INFO pi;\n    TCHAR str[MAX_PIN_NAME];\n    CLSID clsid;\n\n    if (pPin)\n    {\n        pPin->QueryPinInfo(&pi);\n        pi.pFilter->GetClassID(&clsid);\n        QueryPinInfoReleaseFilter(pi);\n#ifndef UNICODE\n        WideCharToMultiByte(GetACP(), 0, pi.achName, lstrlenW(pi.achName) + 1, str, MAX_PIN_NAME, NULL, NULL);\n#else\n        (void)StringCchCopy(str, NUMELMS(str), pi.achName);\n#endif\n    }\n    else\n    {\n        (void)StringCchCopy(str, NUMELMS(str), TEXT(\"NULL IPin\"));\n    }\n\n    m_pString = (PTCHAR) new TCHAR[lstrlen(str) + 64];\n    if (!m_pString)\n    {\n        return;\n    }\n\n    (void)StringCchPrintf(m_pString, lstrlen(str) + 64, TEXT(\"%hs(%s)\"), GuidNames[clsid], str);\n}\n\n/*  Display filter or pin */\nCDisp::CDisp(IUnknown *pUnk)\n{\n    IBaseFilter *pf;\n    HRESULT hr = pUnk->QueryInterface(IID_IBaseFilter, (void **)&pf);\n    if (SUCCEEDED(hr))\n    {\n        FILTER_INFO fi;\n        hr = pf->QueryFilterInfo(&fi);\n        if (SUCCEEDED(hr))\n        {\n            QueryFilterInfoReleaseGraph(fi);\n\n            size_t len = lstrlenW(fi.achName) + 1;\n\n            m_pString = new TCHAR[len];\n            if (m_pString)\n            {\n#ifdef UNICODE\n                (void)StringCchCopy(m_pString, len, fi.achName);\n#else\n                (void)StringCchPrintf(m_pString, len, \"%S\", fi.achName);\n#endif\n            }\n        }\n\n        pf->Release();\n\n        return;\n    }\n\n    IPin *pp;\n    hr = pUnk->QueryInterface(IID_IPin, (void **)&pp);\n    if (SUCCEEDED(hr))\n    {\n        CDisp::CDisp(pp);\n        pp->Release();\n        return;\n    }\n}\n\nCDisp::~CDisp()\n{\n}\n\nCDispBasic::~CDispBasic()\n{\n    if (m_pString != m_String)\n    {\n        delete[] m_pString;\n    }\n}\n\nCDisp::CDisp(double d)\n{\n    (void)StringCchPrintf(m_String, NUMELMS(m_String), TEXT(\"%d.%03d\"), (int)d, (int)((d - (int)d) * 1000));\n}\n\n/* If built for debug this will display the media type details. We convert the\n   major and subtypes into strings and also ask the base classes for a string\n   description of the subtype, so MEDIASUBTYPE_RGB565 becomes RGB 565 16 bit\n   We also display the fields in the BITMAPINFOHEADER structure, this should\n   succeed as we do not accept input types unless the format is big enough */\n\n#ifdef DEBUG\nvoid WINAPI DisplayType(LPCTSTR label, const AM_MEDIA_TYPE *pmtIn)\n{\n\n    /* Dump the GUID types and a short description */\n\n    DbgLog((LOG_TRACE, 5, TEXT(\"\")));\n    DbgLog((LOG_TRACE, 2, TEXT(\"%s  M type %hs  S type %hs\"), label, GuidNames[pmtIn->majortype],\n            GuidNames[pmtIn->subtype]));\n    DbgLog((LOG_TRACE, 5, TEXT(\"Subtype description %s\"), GetSubtypeName(&pmtIn->subtype)));\n\n    /* Dump the generic media types */\n\n    if (pmtIn->bTemporalCompression)\n    {\n        DbgLog((LOG_TRACE, 5, TEXT(\"Temporally compressed\")));\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 5, TEXT(\"Not temporally compressed\")));\n    }\n\n    if (pmtIn->bFixedSizeSamples)\n    {\n        DbgLog((LOG_TRACE, 5, TEXT(\"Sample size %d\"), pmtIn->lSampleSize));\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 5, TEXT(\"Variable size samples\")));\n    }\n\n    if (pmtIn->formattype == FORMAT_VideoInfo)\n    {\n\n        VIDEOINFOHEADER *pVideoInfo = (VIDEOINFOHEADER *)pmtIn->pbFormat;\n\n        DisplayRECT(TEXT(\"Source rectangle\"), pVideoInfo->rcSource);\n        DisplayRECT(TEXT(\"Target rectangle\"), pVideoInfo->rcTarget);\n        DisplayBITMAPINFO(HEADER(pmtIn->pbFormat));\n    }\n    if (pmtIn->formattype == FORMAT_VideoInfo2)\n    {\n\n        VIDEOINFOHEADER2 *pVideoInfo2 = (VIDEOINFOHEADER2 *)pmtIn->pbFormat;\n\n        DisplayRECT(TEXT(\"Source rectangle\"), pVideoInfo2->rcSource);\n        DisplayRECT(TEXT(\"Target rectangle\"), pVideoInfo2->rcTarget);\n        DbgLog((LOG_TRACE, 5, TEXT(\"Aspect Ratio: %d:%d\"), pVideoInfo2->dwPictAspectRatioX,\n                pVideoInfo2->dwPictAspectRatioY));\n        DisplayBITMAPINFO(&pVideoInfo2->bmiHeader);\n    }\n    else if (pmtIn->majortype == MEDIATYPE_Audio)\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"     Format type %hs\"), GuidNames[pmtIn->formattype]));\n        DbgLog((LOG_TRACE, 2, TEXT(\"     Subtype %hs\"), GuidNames[pmtIn->subtype]));\n\n        if ((pmtIn->subtype != MEDIASUBTYPE_MPEG1Packet) && (pmtIn->cbFormat >= sizeof(PCMWAVEFORMAT)))\n        {\n            /* Dump the contents of the WAVEFORMATEX type-specific format structure */\n\n            WAVEFORMATEX *pwfx = (WAVEFORMATEX *)pmtIn->pbFormat;\n            DbgLog((LOG_TRACE, 2, TEXT(\"wFormatTag %u\"), pwfx->wFormatTag));\n            DbgLog((LOG_TRACE, 2, TEXT(\"nChannels %u\"), pwfx->nChannels));\n            DbgLog((LOG_TRACE, 2, TEXT(\"nSamplesPerSec %lu\"), pwfx->nSamplesPerSec));\n            DbgLog((LOG_TRACE, 2, TEXT(\"nAvgBytesPerSec %lu\"), pwfx->nAvgBytesPerSec));\n            DbgLog((LOG_TRACE, 2, TEXT(\"nBlockAlign %u\"), pwfx->nBlockAlign));\n            DbgLog((LOG_TRACE, 2, TEXT(\"wBitsPerSample %u\"), pwfx->wBitsPerSample));\n\n            /* PCM uses a WAVEFORMAT and does not have the extra size field */\n\n            if (pmtIn->cbFormat >= sizeof(WAVEFORMATEX))\n            {\n                DbgLog((LOG_TRACE, 2, TEXT(\"cbSize %u\"), pwfx->cbSize));\n            }\n        }\n        else\n        {\n        }\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"     Format type %hs\"), GuidNames[pmtIn->formattype]));\n    }\n}\n\nvoid DisplayBITMAPINFO(const BITMAPINFOHEADER *pbmi)\n{\n    DbgLog((LOG_TRACE, 5, TEXT(\"Size of BITMAPINFO structure %d\"), pbmi->biSize));\n    if (pbmi->biCompression < 256)\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"%dx%dx%d bit  (%d)\"), pbmi->biWidth, pbmi->biHeight, pbmi->biBitCount,\n                pbmi->biCompression));\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 2, TEXT(\"%dx%dx%d bit '%4.4hs'\"), pbmi->biWidth, pbmi->biHeight, pbmi->biBitCount,\n                &pbmi->biCompression));\n    }\n\n    DbgLog((LOG_TRACE, 2, TEXT(\"Image size %d\"), pbmi->biSizeImage));\n    DbgLog((LOG_TRACE, 5, TEXT(\"Planes %d\"), pbmi->biPlanes));\n    DbgLog((LOG_TRACE, 5, TEXT(\"X Pels per metre %d\"), pbmi->biXPelsPerMeter));\n    DbgLog((LOG_TRACE, 5, TEXT(\"Y Pels per metre %d\"), pbmi->biYPelsPerMeter));\n    DbgLog((LOG_TRACE, 5, TEXT(\"Colours used %d\"), pbmi->biClrUsed));\n}\n\nvoid DisplayRECT(LPCTSTR szLabel, const RECT &rc)\n{\n    DbgLog(\n        (LOG_TRACE, 5, TEXT(\"%s (Left %d Top %d Right %d Bottom %d)\"), szLabel, rc.left, rc.top, rc.right, rc.bottom));\n}\n\nvoid WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel)\n{\n    if (!pGraph)\n    {\n        return;\n    }\n\n    IEnumFilters *pFilters;\n\n    DbgLog((LOG_TRACE, dwLevel, TEXT(\"DumpGraph [%x]\"), pGraph));\n\n    if (FAILED(pGraph->EnumFilters(&pFilters)))\n    {\n        DbgLog((LOG_TRACE, dwLevel, TEXT(\"EnumFilters failed!\")));\n    }\n\n    IBaseFilter *pFilter;\n    ULONG n;\n    while (pFilters->Next(1, &pFilter, &n) == S_OK)\n    {\n        FILTER_INFO info;\n\n        if (FAILED(pFilter->QueryFilterInfo(&info)))\n        {\n            DbgLog((LOG_TRACE, dwLevel, TEXT(\"    Filter [%p]  -- failed QueryFilterInfo\"), pFilter));\n        }\n        else\n        {\n            QueryFilterInfoReleaseGraph(info);\n\n            // !!! should QueryVendorInfo here!\n\n            DbgLog((LOG_TRACE, dwLevel, TEXT(\"    Filter [%p]  '%ls'\"), pFilter, info.achName));\n\n            IEnumPins *pins;\n\n            if (FAILED(pFilter->EnumPins(&pins)))\n            {\n                DbgLog((LOG_TRACE, dwLevel, TEXT(\"EnumPins failed!\")));\n            }\n            else\n            {\n\n                IPin *pPin;\n                while (pins->Next(1, &pPin, &n) == S_OK)\n                {\n                    PIN_INFO pinInfo;\n\n                    if (FAILED(pPin->QueryPinInfo(&pinInfo)))\n                    {\n                        DbgLog((LOG_TRACE, dwLevel, TEXT(\"          Pin [%x]  -- failed QueryPinInfo\"), pPin));\n                    }\n                    else\n                    {\n                        QueryPinInfoReleaseFilter(pinInfo);\n\n                        IPin *pPinConnected = NULL;\n\n                        HRESULT hr = pPin->ConnectedTo(&pPinConnected);\n\n                        if (pPinConnected)\n                        {\n                            DbgLog((LOG_TRACE, dwLevel,\n                                    TEXT(\"          Pin [%p]  '%ls' [%sput]\") TEXT(\"  Connected to pin [%p]\"), pPin,\n                                    pinInfo.achName, pinInfo.dir == PINDIR_INPUT ? TEXT(\"In\") : TEXT(\"Out\"),\n                                    pPinConnected));\n\n                            pPinConnected->Release();\n\n                            // perhaps we should really dump the type both ways as a sanity\n                            // check?\n                            if (pinInfo.dir == PINDIR_OUTPUT)\n                            {\n                                AM_MEDIA_TYPE mt;\n\n                                hr = pPin->ConnectionMediaType(&mt);\n\n                                if (SUCCEEDED(hr))\n                                {\n                                    DisplayType(TEXT(\"Connection type\"), &mt);\n\n                                    FreeMediaType(mt);\n                                }\n                            }\n                        }\n                        else\n                        {\n                            DbgLog((LOG_TRACE, dwLevel, TEXT(\"          Pin [%x]  '%ls' [%sput]\"), pPin,\n                                    pinInfo.achName, pinInfo.dir == PINDIR_INPUT ? TEXT(\"In\") : TEXT(\"Out\")));\n                        }\n                    }\n\n                    pPin->Release();\n                }\n\n                pins->Release();\n            }\n        }\n\n        pFilter->Release();\n    }\n\n    pFilters->Release();\n}\n\n#endif\n"
  },
  {
    "path": "common/baseclasses/wxdebug.h",
    "content": "//------------------------------------------------------------------------------\n// File: WXDebug.h\n//\n// Desc: DirectShow base classes - provides debugging facilities.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __WXDEBUG__\n#define __WXDEBUG__\n\n// This library provides fairly straight forward debugging functionality, this\n// is split into two main sections. The first is assertion handling, there are\n// three types of assertions provided here. The most commonly used one is the\n// ASSERT(condition) macro which will pop up a message box including the file\n// and line number if the condition evaluates to FALSE. Then there is the\n// EXECUTE_ASSERT macro which is the same as ASSERT except the condition will\n// still be executed in NON debug builds. The final type of assertion is the\n// KASSERT macro which is more suitable for pure (perhaps kernel) filters as\n// the condition is printed onto the debugger rather than in a message box.\n//\n// The other part of the debug module facilties is general purpose logging.\n// This is accessed by calling DbgLog(). The function takes a type and level\n// field which define the type of informational string you are presenting and\n// it's relative importance. The type field can be a combination (one or more)\n// of LOG_TIMING, LOG_TRACE, LOG_MEMORY, LOG_LOCKING and LOG_ERROR. The level\n// is a DWORD value where zero defines highest important. Use of zero as the\n// debug logging level is to be encouraged ONLY for major errors or events as\n// they will ALWAYS be displayed on the debugger. Other debug output has it's\n// level matched against the current debug output level stored in the registry\n// for this module and if less than the current setting it will be displayed.\n//\n// Each module or executable has it's own debug output level for each of the\n// five types. These are read in when the DbgInitialise function is called\n// for DLLs linking to STRMBASE.LIB this is done automatically when the DLL\n// is loaded, executables must call it explicitely with the module instance\n// handle given to them through the WINMAIN entry point. An executable must\n// also call DbgTerminate when they have finished to clean up the resources\n// the debug library uses, once again this is done automatically for DLLs\n\n// These are the five different categories of logging information\n\nenum\n{\n    LOG_TIMING = 0x01,  // Timing and performance measurements\n    LOG_TRACE = 0x02,   // General step point call tracing\n    LOG_MEMORY = 0x04,  // Memory and object allocation/destruction\n    LOG_LOCKING = 0x08, // Locking/unlocking of critical sections\n    LOG_ERROR = 0x10,   // Debug error notification\n    LOG_CUSTOM1 = 0x20,\n    LOG_CUSTOM2 = 0x40,\n    LOG_CUSTOM3 = 0x80,\n    LOG_CUSTOM4 = 0x100,\n    LOG_CUSTOM5 = 0x200,\n};\n\n#define LOG_FORCIBLY_SET 0x80000000\n\nenum\n{\n    CDISP_HEX = 0x01,\n    CDISP_DEC = 0x02\n};\n\n// For each object created derived from CBaseObject (in debug builds) we\n// create a descriptor that holds it's name (statically allocated memory)\n// and a cookie we assign it. We keep a list of all the active objects\n// we have registered so that we can dump a list of remaining objects\n\ntypedef struct tag_ObjectDesc\n{\n    LPCSTR m_szName;\n    LPCWSTR m_wszName;\n    DWORD m_dwCookie;\n    tag_ObjectDesc *m_pNext;\n} ObjectDesc;\n\n#define DLLIMPORT __declspec(dllimport)\n#define DLLEXPORT __declspec(dllexport)\n\n#ifdef DEBUG\n\n#define NAME(x) TEXT(x)\n\n// These are used internally by the debug library (PRIVATE)\n\nvoid WINAPI DbgInitKeyLevels(HKEY hKey, bool fTakeMax);\nvoid WINAPI DbgInitGlobalSettings(bool fTakeMax);\nvoid WINAPI DbgInitModuleSettings(bool fTakeMax);\nvoid WINAPI DbgInitModuleName();\nDWORD WINAPI DbgRegisterObjectCreation(LPCSTR szObjectName, LPCWSTR wszObjectName);\n\nBOOL WINAPI DbgRegisterObjectDestruction(DWORD dwCookie);\n\n// These are the PUBLIC entry points\n\nBOOL WINAPI DbgCheckModuleLevel(DWORD Type, DWORD Level);\nvoid WINAPI DbgSetModuleLevel(DWORD Type, DWORD Level);\nvoid WINAPI DbgSetAutoRefreshLevels(bool fAuto);\n\n// Initialise the library with the module handle\n\nvoid WINAPI DbgInitialise(HINSTANCE hInst);\nvoid WINAPI DbgTerminate();\n\nvoid WINAPI DbgDumpObjectRegister();\n\n// Display error and logging to the user\n\nvoid WINAPI DbgAssert(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine);\nvoid WINAPI DbgBreakPoint(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine);\nvoid WINAPI DbgBreakPoint(LPCTSTR pFileName, INT iLine, __format_string LPCTSTR szFormatString, ...);\n\nvoid WINAPI DbgKernelAssert(LPCTSTR pCondition, LPCTSTR pFileName, INT iLine);\nvoid WINAPI DbgLogInfo(DWORD Type, DWORD Level, __format_string LPCTSTR pFormat, ...);\n#ifdef UNICODE\nvoid WINAPI DbgLogInfo(DWORD Type, DWORD Level, __format_string LPCSTR pFormat, ...);\nvoid WINAPI DbgAssert(LPCSTR pCondition, LPCSTR pFileName, INT iLine);\nvoid WINAPI DbgBreakPoint(LPCSTR pCondition, LPCSTR pFileName, INT iLine);\nvoid WINAPI DbgKernelAssert(LPCSTR pCondition, LPCSTR pFileName, INT iLine);\n#endif\nvoid WINAPI DbgOutString(LPCTSTR psz);\n\n//  Debug infinite wait stuff\nDWORD WINAPI DbgWaitForSingleObject(HANDLE h);\nDWORD WINAPI DbgWaitForMultipleObjects(DWORD nCount, __in_ecount(nCount) CONST HANDLE *lpHandles, BOOL bWaitAll);\nvoid WINAPI DbgSetWaitTimeout(DWORD dwTimeout);\n\n#ifdef __strmif_h__\n// Display a media type: Terse at level 2, verbose at level 5\nvoid WINAPI DisplayType(LPCTSTR label, const AM_MEDIA_TYPE *pmtIn);\n\n// Dump lots of information about a filter graph\nvoid WINAPI DumpGraph(IFilterGraph *pGraph, DWORD dwLevel);\n#endif\n\n#define KASSERT(_x_) \\\n    if (!(_x_))      \\\n    DbgKernelAssert(TEXT(#_x_), TEXT(__FILE__), __LINE__)\n\n//  Break on the debugger without putting up a message box\n//  message goes to debugger instead\n\n#define KDbgBreak(_x_) DbgKernelAssert(TEXT(#_x_), TEXT(__FILE__), __LINE__)\n\n// We chose a common name for our ASSERT macro, MFC also uses this name\n// So long as the implementation evaluates the condition and handles it\n// then we will be ok. Rather than override the behaviour expected we\n// will leave whatever first defines ASSERT as the handler (i.e. MFC)\n#ifndef ASSERT\n#define ASSERT(_x_) \\\n    if (!(_x_))     \\\n    DbgAssert(TEXT(#_x_), TEXT(__FILE__), __LINE__)\n#endif\n\n#define DbgAssertAligned(_ptr_, _alignment_) ASSERT(((DWORD_PTR)(_ptr_)) % (_alignment_) == 0)\n\n//  Put up a message box informing the user of a halt\n//  condition in the program\n\n#define DbgBreak(_x_) DbgBreakPoint(TEXT(#_x_), TEXT(__FILE__), __LINE__)\n\n#define EXECUTE_ASSERT(_x_) ASSERT(_x_)\n#define DbgLog(_x_) DbgLogInfo _x_\n// MFC style trace macros\n\n#define NOTE(_x_) DbgLog((LOG_TRACE, 5, TEXT(_x_)))\n#define NOTE1(_x_, a) DbgLog((LOG_TRACE, 5, TEXT(_x_), a))\n#define NOTE2(_x_, a, b) DbgLog((LOG_TRACE, 5, TEXT(_x_), a, b))\n#define NOTE3(_x_, a, b, c) DbgLog((LOG_TRACE, 5, TEXT(_x_), a, b, c))\n#define NOTE4(_x_, a, b, c, d) DbgLog((LOG_TRACE, 5, TEXT(_x_), a, b, c, d))\n#define NOTE5(_x_, a, b, c, d, e) DbgLog((LOG_TRACE, 5, TEXT(_x_), a, b, c, d, e))\n\n#else\n\n// Retail builds make public debug functions inert  - WARNING the source\n// files do not define or build any of the entry points in debug builds\n// (public entry points compile to nothing) so if you go trying to call\n// any of the private entry points in your source they won't compile\n\n#define NAME(_x_) ((LPTSTR)NULL)\n\n#define DbgInitialise(hInst)\n#define DbgTerminate()\n#define DbgLog(_x_) 0\n#define DbgOutString(psz)\n#define DbgAssertAligned(_ptr_, _alignment_) 0\n\n#define DbgRegisterObjectCreation(pObjectName)\n#define DbgRegisterObjectDestruction(dwCookie)\n#define DbgDumpObjectRegister()\n\n#define DbgCheckModuleLevel(Type, Level)\n#define DbgSetModuleLevel(Type, Level)\n#define DbgSetAutoRefreshLevels(fAuto)\n\n#define DbgWaitForSingleObject(h) WaitForSingleObject(h, INFINITE)\n#define DbgWaitForMultipleObjects(nCount, lpHandles, bWaitAll) \\\n    WaitForMultipleObjects(nCount, lpHandles, bWaitAll, INFINITE)\n#define DbgSetWaitTimeout(dwTimeout)\n\n#define KDbgBreak(_x_)\n#define DbgBreak(_x_)\n\n#define KASSERT(_x_) ((void)0)\n#ifndef ASSERT\n#define ASSERT(_x_) ((void)0)\n#endif\n#define EXECUTE_ASSERT(_x_) ((void)(_x_))\n\n// MFC style trace macros\n\n#define NOTE(_x_) ((void)0)\n#define NOTE1(_x_, a) ((void)0)\n#define NOTE2(_x_, a, b) ((void)0)\n#define NOTE3(_x_, a, b, c) ((void)0)\n#define NOTE4(_x_, a, b, c, d) ((void)0)\n#define NOTE5(_x_, a, b, c, d, e) ((void)0)\n\n#define DisplayType(label, pmtIn) ((void)0)\n#define DumpGraph(pGraph, label) ((void)0)\n#endif\n\n// Checks a pointer which should be non NULL - can be used as follows.\n\n#define CheckPointer(p, ret) \\\n    {                        \\\n        if ((p) == NULL)     \\\n            return (ret);    \\\n    }\n\n//   HRESULT Foo(VOID *pBar)\n//   {\n//       CheckPointer(pBar,E_INVALIDARG)\n//   }\n//\n//   Or if the function returns a boolean\n//\n//   BOOL Foo(VOID *pBar)\n//   {\n//       CheckPointer(pBar,FALSE)\n//   }\n\n#define ValidateReadPtr(p, cb) 0\n#define ValidateWritePtr(p, cb) 0\n#define ValidateReadWritePtr(p, cb) 0\n#define ValidateStringPtr(p) 0\n#define ValidateStringPtrA(p) 0\n#define ValidateStringPtrW(p) 0\n\n#ifdef _OBJBASE_H_\n\n//  Outputting GUID names.  If you want to include the name\n//  associated with a GUID (eg CLSID_...) then\n//\n//      GuidNames[yourGUID]\n//\n//  Returns the name defined in uuids.h as a string\n\ntypedef struct\n{\n    CHAR *szName;\n    GUID guid;\n} GUID_STRING_ENTRY;\n\nclass CGuidNameList\n{\n  public:\n    CHAR *operator[](const GUID &guid);\n};\n\nextern CGuidNameList GuidNames;\n\n#endif\n\n#ifndef REMIND\n//  REMIND macro - generates warning as reminder to complete coding\n//  (eg) usage:\n//\n//  #pragma message (REMIND(\"Add automation support\"))\n\n#define QUOTE(x) #x\n#define QQUOTE(y) QUOTE(y)\n#define REMIND(str) __FILE__ \"(\" QQUOTE(__LINE__) \") :  \" str\n#endif\n\n//  Method to display objects in a useful format\n//\n//  eg If you want to display a LONGLONG ll in a debug string do (eg)\n//\n//  DbgLog((LOG_TRACE, n, TEXT(\"Value is %s\"), (LPCTSTR)CDisp(ll, CDISP_HEX)));\n\nclass CDispBasic\n{\n  public:\n    CDispBasic() { m_pString = m_String; };\n    ~CDispBasic();\n\n  protected:\n    PTCHAR m_pString; // normally points to m_String... unless too much data\n    TCHAR m_String[50];\n};\nclass CDisp : public CDispBasic\n{\n  public:\n    CDisp(LONGLONG ll, int Format = CDISP_HEX); // Display a LONGLONG in CDISP_HEX or CDISP_DEC form\n    CDisp(REFCLSID clsid);                      // Display a GUID\n    CDisp(double d);                            // Display a floating point number\n#ifdef __strmif_h__\n#ifdef __STREAMS__\n    CDisp(CRefTime t); // Display a Reference Time\n#endif\n    CDisp(IPin *pPin);     // Display a pin as {filter clsid}(pin name)\n    CDisp(IUnknown *pUnk); // Display a filter or pin\n#endif                     // __strmif_h__\n    ~CDisp();\n\n    //  Implement cast to (LPCTSTR) as parameter to logger\n    operator LPCTSTR() { return (LPCTSTR)m_pString; };\n};\n\n#if defined(DEBUG)\nclass CAutoTrace\n{\n  private:\n    LPCTSTR _szBlkName;\n    const int _level;\n    static const TCHAR _szEntering[];\n    static const TCHAR _szLeaving[];\n\n  public:\n    CAutoTrace(LPCTSTR szBlkName, const int level = 15)\n        : _szBlkName(szBlkName)\n        , _level(level)\n    {\n        DbgLog((LOG_TRACE, _level, _szEntering, _szBlkName));\n    }\n\n    ~CAutoTrace() { DbgLog((LOG_TRACE, _level, _szLeaving, _szBlkName)); }\n};\n\n#if defined(__FUNCTION__)\n\n#define AMTRACEFN() CAutoTrace __trace(TEXT(__FUNCTION__))\n#define AMTRACE(_x_) CAutoTrace __trace(TEXT(__FUNCTION__))\n\n#else\n\n#define AMTRACE(_x_) CAutoTrace __trace _x_\n#define AMTRACEFN()\n\n#endif\n\n#else\n\n#define AMTRACE(_x_)\n#define AMTRACEFN()\n\n#endif\n\n#endif // __WXDEBUG__\n"
  },
  {
    "path": "common/baseclasses/wxlist.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: WXList.cpp\n//\n// Desc: DirectShow base classes - implements a non-MFC based generic list\n//       template class.\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n/* A generic list of pointers to objects.\n   Objectives: avoid using MFC libraries in ndm kernel mode and\n   provide a really useful list type.\n\n   The class is thread safe in that separate threads may add and\n   delete items in the list concurrently although the application\n   must ensure that constructor and destructor access is suitably\n   synchronised.\n\n   The list name must not conflict with MFC classes as an\n   application may use both\n\n   The nodes form a doubly linked, NULL terminated chain with an anchor\n   block (the list object per se) holding pointers to the first and last\n   nodes and a count of the nodes.\n   There is a node cache to reduce the allocation and freeing overhead.\n   It optionally (determined at construction time) has an Event which is\n   set whenever the list becomes non-empty and reset whenever it becomes\n   empty.\n   It optionally (determined at construction time) has a Critical Section\n   which is entered during the important part of each operation.  (About\n   all you can do outside it is some parameter checking).\n\n   The node cache is a repository of nodes that are NOT in the list to speed\n   up storage allocation.  Each list has its own cache to reduce locking and\n   serialising.  The list accesses are serialised anyway for a given list - a\n   common cache would mean that we would have to separately serialise access\n   of all lists within the cache.  Because the cache only stores nodes that are\n   not in the list, releasing the cache does not release any list nodes.  This\n   means that list nodes can be copied or rechained from one list to another\n   without danger of creating a dangling reference if the original cache goes\n   away.\n\n   Questionable design decisions:\n   1. Retaining the warts for compatibility\n   2. Keeping an element count -i.e. counting whenever we do anything\n      instead of only when we want the count.\n   3. Making the chain pointers NULL terminated.  If the list object\n      itself looks just like a node and the list is kept as a ring then\n      it reduces the number of special cases.  All inserts look the same.\n*/\n\n#include <streams.h>\n\n/* set cursor to the position of each element of list in turn  */\n#define INTERNALTRAVERSELIST(list, cursor) \\\n    for (cursor = (list).GetHeadPositionI(); cursor != NULL; cursor = (list).Next(cursor))\n\n/* set cursor to the position of each element of list in turn\n   in reverse order\n*/\n#define INTERNALREVERSETRAVERSELIST(list, cursor) \\\n    for (cursor = (list).GetTailPositionI(); cursor != NULL; cursor = (list).Prev(cursor))\n\n/* Constructor calls a separate initialisation function that\n   creates a node cache, optionally creates a lock object\n   and optionally creates a signaling object.\n\n   By default we create a locking object, a DEFAULTCACHE sized\n   cache but no event object so the list cannot be used in calls\n   to WaitForSingleObject\n*/\nCBaseList::CBaseList(__in_opt LPCTSTR pName, // Descriptive list name\n                     INT iItems)\n    : // Node cache size\n#ifdef DEBUG\n    CBaseObject(pName)\n    ,\n#endif\n    m_pFirst(NULL)\n    , m_pLast(NULL)\n    , m_Count(0)\n    , m_Cache(iItems)\n{\n} // constructor\n\nCBaseList::CBaseList(__in_opt LPCTSTR pName)\n    : // Descriptive list name\n#ifdef DEBUG\n    CBaseObject(pName)\n    ,\n#endif\n    m_pFirst(NULL)\n    , m_pLast(NULL)\n    , m_Count(0)\n    , m_Cache(DEFAULTCACHE)\n{\n} // constructor\n\n#ifdef UNICODE\nCBaseList::CBaseList(__in_opt LPCSTR pName, // Descriptive list name\n                     INT iItems)\n    : // Node cache size\n#ifdef DEBUG\n    CBaseObject(pName)\n    ,\n#endif\n    m_pFirst(NULL)\n    , m_pLast(NULL)\n    , m_Count(0)\n    , m_Cache(iItems)\n{\n} // constructor\n\nCBaseList::CBaseList(__in_opt LPCSTR pName)\n    : // Descriptive list name\n#ifdef DEBUG\n    CBaseObject(pName)\n    ,\n#endif\n    m_pFirst(NULL)\n    , m_pLast(NULL)\n    , m_Count(0)\n    , m_Cache(DEFAULTCACHE)\n{\n} // constructor\n\n#endif\n\n/* The destructor enumerates all the node objects in the list and\n   in the cache deleting each in turn. We do not do any processing\n   on the objects that the list holds (i.e. points to) so if they\n   represent interfaces for example the creator of the list should\n   ensure that each of them is released before deleting us\n*/\nCBaseList::~CBaseList()\n{\n    /* Delete all our list nodes */\n\n    RemoveAll();\n\n} // destructor\n\n/* Remove all the nodes from the list but don't do anything\n   with the objects that each node looks after (this is the\n   responsibility of the creator).\n   Aa a last act we reset the signalling event\n   (if available) to indicate to clients that the list\n   does not have any entries in it.\n*/\nvoid CBaseList::RemoveAll()\n{\n    /* Free up all the CNode objects NOTE we don't bother putting the\n       deleted nodes into the cache as this method is only really called\n       in serious times of change such as when we are being deleted at\n       which point the cache will be deleted anway */\n\n    CNode *pn = m_pFirst;\n    while (pn)\n    {\n        CNode *op = pn;\n        pn = pn->Next();\n        delete op;\n    }\n\n    /* Reset the object count and the list pointers */\n\n    m_Count = 0;\n    m_pFirst = m_pLast = NULL;\n\n} // RemoveAll\n\n/* Return a position enumerator for the entire list.\n   A position enumerator is a pointer to a node object cast to a\n   transparent type so all we do is return the head/tail node\n   pointer in the list.\n   WARNING because the position is a pointer to a node there is\n   an implicit assumption for users a the list class that after\n   deleting an object from the list that any other position\n   enumerators that you have may be invalid (since the node\n   may be gone).\n*/\n__out_opt POSITION CBaseList::GetHeadPositionI() const\n{\n    return (POSITION)m_pFirst;\n} // GetHeadPosition\n\n__out_opt POSITION CBaseList::GetTailPositionI() const\n{\n    return (POSITION)m_pLast;\n} // GetTailPosition\n\n/* Get the number of objects in the list,\n   Get the lock before accessing the count.\n   Locking may not be entirely necessary but it has the side effect\n   of making sure that all operations are complete before we get it.\n   So for example if a list is being added to this list then that\n   will have completed in full before we continue rather than seeing\n   an intermediate albeit valid state\n*/\nint CBaseList::GetCountI() const\n{\n    return m_Count;\n} // GetCount\n\n/* Return the object at rp, update rp to the next object from\n   the list or NULL if you have moved over the last object.\n   You may still call this function once we return NULL but\n   we will continue to return a NULL position value\n*/\n__out void *CBaseList::GetNextI(__inout POSITION &rp) const\n{\n    /* have we reached the end of the list */\n\n    if (rp == NULL)\n    {\n        return NULL;\n    }\n\n    /* Lock the object before continuing */\n\n    void *pObject;\n\n    /* Copy the original position then step on */\n\n    CNode *pn = (CNode *)rp;\n    ASSERT(pn != NULL);\n    rp = (POSITION)pn->Next();\n\n    /* Get the object at the original position from the list */\n\n    pObject = pn->GetData();\n    // ASSERT(pObject != NULL);    // NULL pointers in the list are allowed.\n    return pObject;\n} // GetNext\n\n/* Return the object at p.\n   Asking for the object at NULL ASSERTs then returns NULL\n   The object is NOT locked.  The list is not being changed\n   in any way.  If another thread is busy deleting the object\n   then locking would only result in a change from one bad\n   behaviour to another.\n*/\n__out_opt void *CBaseList::GetI(__in_opt POSITION p) const\n{\n    if (p == NULL)\n    {\n        return NULL;\n    }\n\n    CNode *pn = (CNode *)p;\n    void *pObject = pn->GetData();\n    // ASSERT(pObject != NULL);    // NULL pointers in the list are allowed.\n    return pObject;\n} // Get\n\n__out void *CBaseList::GetValidI(__in POSITION p) const\n{\n    CNode *pn = (CNode *)p;\n    void *pObject = pn->GetData();\n    // ASSERT(pObject != NULL);    // NULL pointers in the list are allowed.\n    return pObject;\n} // Get\n\n/* Return the first position in the list which holds the given pointer.\n   Return NULL if it's not found.\n*/\n__out_opt POSITION CBaseList::FindI(__in void *pObj) const\n{\n    POSITION pn;\n    INTERNALTRAVERSELIST(*this, pn)\n    {\n        if (GetI(pn) == pObj)\n        {\n            return pn;\n        }\n    }\n    return NULL;\n} // Find\n\n/* Remove the first node in the list (deletes the pointer to its object\n   from the list, does not free the object itself).\n   Return the pointer to its object or NULL if empty\n*/\n__out_opt void *CBaseList::RemoveHeadI()\n{\n    /* All we do is get the head position and ask for that to be deleted.\n       We could special case this since some of the code path checking\n       in Remove() is redundant as we know there is no previous\n       node for example but it seems to gain little over the\n       added complexity\n    */\n\n    return RemoveI((POSITION)m_pFirst);\n} // RemoveHead\n\n/* Remove the last node in the list (deletes the pointer to its object\n   from the list, does not free the object itself).\n   Return the pointer to its object or NULL if empty\n*/\n__out_opt void *CBaseList::RemoveTailI()\n{\n    /* All we do is get the tail position and ask for that to be deleted.\n       We could special case this since some of the code path checking\n       in Remove() is redundant as we know there is no previous\n       node for example but it seems to gain little over the\n       added complexity\n    */\n\n    return RemoveI((POSITION)m_pLast);\n} // RemoveTail\n\n/* Remove the pointer to the object in this position from the list.\n   Deal with all the chain pointers\n   Return a pointer to the object removed from the list.\n   The node object that is freed as a result\n   of this operation is added to the node cache where\n   it can be used again.\n   Remove(NULL) is a harmless no-op - but probably is a wart.\n*/\n__out_opt void *CBaseList::RemoveI(__in_opt POSITION pos)\n{\n    /* Lock the critical section before continuing */\n\n    // ASSERT (pos!=NULL);     // Removing NULL is to be harmless!\n    if (pos == NULL)\n        return NULL;\n\n    CNode *pCurrent = (CNode *)pos;\n    ASSERT(pCurrent != NULL);\n\n    /* Update the previous node */\n\n    CNode *pNode = pCurrent->Prev();\n    if (pNode == NULL)\n    {\n        m_pFirst = pCurrent->Next();\n    }\n    else\n    {\n        pNode->SetNext(pCurrent->Next());\n    }\n\n    /* Update the following node */\n\n    pNode = pCurrent->Next();\n    if (pNode == NULL)\n    {\n        m_pLast = pCurrent->Prev();\n    }\n    else\n    {\n        pNode->SetPrev(pCurrent->Prev());\n    }\n\n    /* Get the object this node was looking after */\n\n    void *pObject = pCurrent->GetData();\n\n    // ASSERT(pObject != NULL);    // NULL pointers in the list are allowed.\n\n    /* Try and add the node object to the cache -\n       a NULL return code from the cache means we ran out of room.\n       The cache size is fixed by a constructor argument when the\n       list is created and defaults to DEFAULTCACHE.\n       This means that the cache will have room for this many\n       node objects. So if you have a list of media samples\n       and you know there will never be more than five active at\n       any given time of them for example then override the default\n       constructor\n    */\n\n    m_Cache.AddToCache(pCurrent);\n\n    /* If the list is empty then reset the list event */\n\n    --m_Count;\n    ASSERT(m_Count >= 0);\n    return pObject;\n} // Remove\n\n/* Add this object to the tail end of our list\n   Return the new tail position.\n*/\n\n__out_opt POSITION CBaseList::AddTailI(__in void *pObject)\n{\n    /* Lock the critical section before continuing */\n\n    CNode *pNode;\n    // ASSERT(pObject);   // NULL pointers in the list are allowed.\n\n    /* If there is a node objects in the cache then use\n       that otherwise we will have to create a new one */\n\n    pNode = (CNode *)m_Cache.RemoveFromCache();\n    if (pNode == NULL)\n    {\n        pNode = new CNode;\n    }\n\n    /* Check we have a valid object */\n\n    if (pNode == NULL)\n    {\n        return NULL;\n    }\n\n    /* Initialise all the CNode object\n       just in case it came from the cache\n    */\n\n    pNode->SetData(pObject);\n    pNode->SetNext(NULL);\n    pNode->SetPrev(m_pLast);\n\n    if (m_pLast == NULL)\n    {\n        m_pFirst = pNode;\n    }\n    else\n    {\n        m_pLast->SetNext(pNode);\n    }\n\n    /* Set the new last node pointer and also increment the number\n       of list entries, the critical section is unlocked when we\n       exit the function\n    */\n\n    m_pLast = pNode;\n    ++m_Count;\n\n    return (POSITION)pNode;\n} // AddTail(object)\n\n/* Add this object to the head end of our list\n   Return the new head position.\n*/\n__out_opt POSITION CBaseList::AddHeadI(__in void *pObject)\n{\n    CNode *pNode;\n    // ASSERT(pObject);  // NULL pointers in the list are allowed.\n\n    /* If there is a node objects in the cache then use\n       that otherwise we will have to create a new one */\n\n    pNode = (CNode *)m_Cache.RemoveFromCache();\n    if (pNode == NULL)\n    {\n        pNode = new CNode;\n    }\n\n    /* Check we have a valid object */\n\n    if (pNode == NULL)\n    {\n        return NULL;\n    }\n\n    /* Initialise all the CNode object\n       just in case it came from the cache\n    */\n\n    pNode->SetData(pObject);\n\n    /* chain it in (set four pointers) */\n    pNode->SetPrev(NULL);\n    pNode->SetNext(m_pFirst);\n\n    if (m_pFirst == NULL)\n    {\n        m_pLast = pNode;\n    }\n    else\n    {\n        m_pFirst->SetPrev(pNode);\n    }\n    m_pFirst = pNode;\n\n    ++m_Count;\n\n    return (POSITION)pNode;\n} // AddHead(object)\n\n/* Add all the elements in *pList to the tail of this list.\n   Return TRUE if it all worked, FALSE if it didn't.\n   If it fails some elements may have been added.\n*/\nBOOL CBaseList::AddTail(__in CBaseList *pList)\n{\n    /* lock the object before starting then enumerate\n       each entry in the source list and add them one by one to\n       our list (while still holding the object lock)\n       Lock the other list too.\n    */\n    POSITION pos = pList->GetHeadPositionI();\n\n    while (pos)\n    {\n        if (NULL == AddTailI(pList->GetNextI(pos)))\n        {\n            return FALSE;\n        }\n    }\n    return TRUE;\n} // AddTail(list)\n\n/* Add all the elements in *pList to the head of this list.\n   Return TRUE if it all worked, FALSE if it didn't.\n   If it fails some elements may have been added.\n*/\nBOOL CBaseList::AddHead(__in CBaseList *pList)\n{\n    /* lock the object before starting then enumerate\n       each entry in the source list and add them one by one to\n       our list (while still holding the object lock)\n       Lock the other list too.\n\n       To avoid reversing the list, traverse it backwards.\n    */\n\n    POSITION pos;\n\n    INTERNALREVERSETRAVERSELIST(*pList, pos)\n    {\n        if (NULL == AddHeadI(pList->GetValidI(pos)))\n        {\n            return FALSE;\n        }\n    }\n    return TRUE;\n} // AddHead(list)\n\n/* Add the object after position p\n   p is still valid after the operation.\n   AddAfter(NULL,x) adds x to the start - same as AddHead\n   Return the position of the new object, NULL if it failed\n*/\n__out_opt POSITION CBaseList::AddAfterI(__in_opt POSITION pos, __in void *pObj)\n{\n    if (pos == NULL)\n        return AddHeadI(pObj);\n\n    /* As someone else might be furkling with the list -\n       Lock the critical section before continuing\n    */\n    CNode *pAfter = (CNode *)pos;\n    ASSERT(pAfter != NULL);\n    if (pAfter == m_pLast)\n        return AddTailI(pObj);\n\n    /* set pnode to point to a new node, preferably from the cache */\n\n    CNode *pNode = (CNode *)m_Cache.RemoveFromCache();\n    if (pNode == NULL)\n    {\n        pNode = new CNode;\n    }\n\n    /* Check we have a valid object */\n\n    if (pNode == NULL)\n    {\n        return NULL;\n    }\n\n    /* Initialise all the CNode object\n       just in case it came from the cache\n    */\n\n    pNode->SetData(pObj);\n\n    /* It is to be added to the middle of the list - there is a before\n       and after node.  Chain it after pAfter, before pBefore.\n    */\n    CNode *pBefore = pAfter->Next();\n    ASSERT(pBefore != NULL);\n\n    /* chain it in (set four pointers) */\n    pNode->SetPrev(pAfter);\n    pNode->SetNext(pBefore);\n    pBefore->SetPrev(pNode);\n    pAfter->SetNext(pNode);\n\n    ++m_Count;\n\n    return (POSITION)pNode;\n\n} // AddAfter(object)\n\nBOOL CBaseList::AddAfter(__in_opt POSITION p, __in CBaseList *pList)\n{\n    POSITION pos;\n    INTERNALTRAVERSELIST(*pList, pos)\n    {\n        /* p follows along the elements being added */\n        p = AddAfterI(p, pList->GetValidI(pos));\n        if (p == NULL)\n            return FALSE;\n    }\n    return TRUE;\n} // AddAfter(list)\n\n/* Mirror images:\n   Add the element or list after position p.\n   p is still valid after the operation.\n   AddBefore(NULL,x) adds x to the end - same as AddTail\n*/\n__out_opt POSITION CBaseList::AddBeforeI(__in_opt POSITION pos, __in void *pObj)\n{\n    if (pos == NULL)\n        return AddTailI(pObj);\n\n    /* set pnode to point to a new node, preferably from the cache */\n\n    CNode *pBefore = (CNode *)pos;\n    ASSERT(pBefore != NULL);\n    if (pBefore == m_pFirst)\n        return AddHeadI(pObj);\n\n    CNode *pNode = (CNode *)m_Cache.RemoveFromCache();\n    if (pNode == NULL)\n    {\n        pNode = new CNode;\n    }\n\n    /* Check we have a valid object */\n\n    if (pNode == NULL)\n    {\n        return NULL;\n    }\n\n    /* Initialise all the CNode object\n       just in case it came from the cache\n    */\n\n    pNode->SetData(pObj);\n\n    /* It is to be added to the middle of the list - there is a before\n       and after node.  Chain it after pAfter, before pBefore.\n    */\n\n    CNode *pAfter = pBefore->Prev();\n    ASSERT(pAfter != NULL);\n\n    /* chain it in (set four pointers) */\n    pNode->SetPrev(pAfter);\n    pNode->SetNext(pBefore);\n    pBefore->SetPrev(pNode);\n    pAfter->SetNext(pNode);\n\n    ++m_Count;\n\n    return (POSITION)pNode;\n\n} // Addbefore(object)\n\nBOOL CBaseList::AddBefore(__in_opt POSITION p, __in CBaseList *pList)\n{\n    POSITION pos;\n    INTERNALREVERSETRAVERSELIST(*pList, pos)\n    {\n        /* p follows along the elements being added */\n        p = AddBeforeI(p, pList->GetValidI(pos));\n        if (p == NULL)\n            return FALSE;\n    }\n    return TRUE;\n} // AddBefore(list)\n\n/* Split *this after position p in *this\n   Retain as *this the tail portion of the original *this\n   Add the head portion to the tail end of *pList\n   Return TRUE if it all worked, FALSE if it didn't.\n\n   e.g.\n      foo->MoveToTail(foo->GetHeadPosition(), bar);\n          moves one element from the head of foo to the tail of bar\n      foo->MoveToTail(NULL, bar);\n          is a no-op\n      foo->MoveToTail(foo->GetTailPosition, bar);\n          concatenates foo onto the end of bar and empties foo.\n\n   A better, except excessively long name might be\n       MoveElementsFromHeadThroughPositionToOtherTail\n*/\nBOOL CBaseList::MoveToTail(__in_opt POSITION pos, __in CBaseList *pList)\n{\n    /* Algorithm:\n       Note that the elements (including their order) in the concatenation\n       of *pList to the head of *this is invariant.\n       1. Count elements to be moved\n       2. Join *pList onto the head of this to make one long chain\n       3. Set first/Last pointers in *this and *pList\n       4. Break the chain at the new place\n       5. Adjust counts\n       6. Set/Reset any events\n    */\n\n    if (pos == NULL)\n        return TRUE; // no-op.  Eliminates special cases later.\n\n    /* Make cMove the number of nodes to move */\n    CNode *p = (CNode *)pos;\n    int cMove = 0; // number of nodes to move\n    while (p != NULL)\n    {\n        p = p->Prev();\n        ++cMove;\n    }\n\n    /* Join the two chains together */\n    if (pList->m_pLast != NULL)\n        pList->m_pLast->SetNext(m_pFirst);\n    if (m_pFirst != NULL)\n        m_pFirst->SetPrev(pList->m_pLast);\n\n    /* set first and last pointers */\n    p = (CNode *)pos;\n\n    if (pList->m_pFirst == NULL)\n        pList->m_pFirst = m_pFirst;\n    m_pFirst = p->Next();\n    if (m_pFirst == NULL)\n        m_pLast = NULL;\n    pList->m_pLast = p;\n\n    /* Break the chain after p to create the new pieces */\n    if (m_pFirst != NULL)\n        m_pFirst->SetPrev(NULL);\n    p->SetNext(NULL);\n\n    /* Adjust the counts */\n    m_Count -= cMove;\n    pList->m_Count += cMove;\n\n    return TRUE;\n\n} // MoveToTail\n\n/* Mirror image of MoveToTail:\n   Split *this before position p in *this.\n   Retain in *this the head portion of the original *this\n   Add the tail portion to the start (i.e. head) of *pList\n   Return TRUE if it all worked, FALSE if it didn't.\n\n   e.g.\n      foo->MoveToHead(foo->GetTailPosition(), bar);\n          moves one element from the tail of foo to the head of bar\n      foo->MoveToHead(NULL, bar);\n          is a no-op\n      foo->MoveToHead(foo->GetHeadPosition, bar);\n          concatenates foo onto the start of bar and empties foo.\n*/\nBOOL CBaseList::MoveToHead(__in_opt POSITION pos, __in CBaseList *pList)\n{\n\n    /* See the comments on the algorithm in MoveToTail */\n\n    if (pos == NULL)\n        return TRUE; // no-op.  Eliminates special cases later.\n\n    /* Make cMove the number of nodes to move */\n    CNode *p = (CNode *)pos;\n    int cMove = 0; // number of nodes to move\n    while (p != NULL)\n    {\n        p = p->Next();\n        ++cMove;\n    }\n\n    /* Join the two chains together */\n    if (pList->m_pFirst != NULL)\n        pList->m_pFirst->SetPrev(m_pLast);\n    if (m_pLast != NULL)\n        m_pLast->SetNext(pList->m_pFirst);\n\n    /* set first and last pointers */\n    p = (CNode *)pos;\n\n    if (pList->m_pLast == NULL)\n        pList->m_pLast = m_pLast;\n\n    m_pLast = p->Prev();\n    if (m_pLast == NULL)\n        m_pFirst = NULL;\n    pList->m_pFirst = p;\n\n    /* Break the chain after p to create the new pieces */\n    if (m_pLast != NULL)\n        m_pLast->SetNext(NULL);\n    p->SetPrev(NULL);\n\n    /* Adjust the counts */\n    m_Count -= cMove;\n    pList->m_Count += cMove;\n\n    return TRUE;\n\n} // MoveToHead\n\n/* Reverse the order of the [pointers to] objects in *this\n */\nvoid CBaseList::Reverse()\n{\n    /* algorithm:\n       The obvious booby trap is that you flip pointers around and lose\n       addressability to the node that you are going to process next.\n       The easy way to avoid this is do do one chain at a time.\n\n       Run along the forward chain,\n       For each node, set the reverse pointer to the one ahead of us.\n       The reverse chain is now a copy of the old forward chain, including\n       the NULL termination.\n\n       Run along the reverse chain (i.e. old forward chain again)\n       For each node set the forward pointer of the node ahead to point back\n       to the one we're standing on.\n       The first node needs special treatment,\n       it's new forward pointer is NULL.\n       Finally set the First/Last pointers\n\n    */\n    CNode *p;\n\n    // Yes we COULD use a traverse, but it would look funny!\n    p = m_pFirst;\n    while (p != NULL)\n    {\n        CNode *q;\n        q = p->Next();\n        p->SetNext(p->Prev());\n        p->SetPrev(q);\n        p = q;\n    }\n\n    p = m_pFirst;\n    m_pFirst = m_pLast;\n    m_pLast = p;\n\n#if 0 // old version\n\n    if (m_pFirst==NULL) return;          // empty list\n    if (m_pFirst->Next()==NULL) return;  // single node list\n\n\n    /* run along forward chain */\n    for ( p = m_pFirst\n        ; p!=NULL\n        ; p = p->Next()\n        ){\n        p->SetPrev(p->Next());\n    }\n\n\n    /* special case first element */\n    m_pFirst->SetNext(NULL);     // fix the old first element\n\n\n    /* run along new reverse chain i.e. old forward chain again */\n    for ( p = m_pFirst           // start at the old first element\n        ; p->Prev()!=NULL        // while there's a node still to be set\n        ; p = p->Prev()          // work in the same direction as before\n        ){\n        p->Prev()->SetNext(p);\n    }\n\n\n    /* fix forward and reverse pointers\n       - the triple XOR swap would work but all the casts look hideous */\n    p = m_pFirst;\n    m_pFirst = m_pLast;\n    m_pLast = p;\n#endif\n\n} // Reverse\n"
  },
  {
    "path": "common/baseclasses/wxlist.h",
    "content": "//------------------------------------------------------------------------------\n// File: WXList.h\n//\n// Desc: DirectShow base classes - defines a non-MFC generic template list\n//       class.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n/* A generic list of pointers to objects.\n   No storage management or copying is done on the objects pointed to.\n   Objectives: avoid using MFC libraries in ndm kernel mode and\n   provide a really useful list type.\n\n   The class is thread safe in that separate threads may add and\n   delete items in the list concurrently although the application\n   must ensure that constructor and destructor access is suitably\n   synchronised. An application can cause deadlock with operations\n   which use two lists by simultaneously calling\n   list1->Operation(list2) and list2->Operation(list1).  So don't!\n\n   The names must not conflict with MFC classes as an application\n   may use both.\n   */\n\n#ifndef __WXLIST__\n#define __WXLIST__\n\n/* A POSITION represents (in some fashion that's opaque) a cursor\n   on the list that can be set to identify any element.  NULL is\n   a valid value and several operations regard NULL as the position\n   \"one step off the end of the list\".  (In an n element list there\n   are n+1 places to insert and NULL is that \"n+1-th\" value).\n   The POSITION of an element in the list is only invalidated if\n   that element is deleted.  Move operations may mean that what\n   was a valid POSITION in one list is now a valid POSITION in\n   a different list.\n\n   Some operations which at first sight are illegal are allowed as\n   harmless no-ops.  For instance RemoveHead is legal on an empty\n   list and it returns NULL.  This allows an atomic way to test if\n   there is an element there, and if so, get it.  The two operations\n   AddTail and RemoveHead thus implement a MONITOR (See Hoare's paper).\n\n   Single element operations return POSITIONs, non-NULL means it worked.\n   whole list operations return a BOOL.  TRUE means it all worked.\n\n   This definition is the same as the POSITION type for MFCs, so we must\n   avoid defining it twice.\n*/\n#ifndef __AFX_H__\nstruct __POSITION\n{\n    int unused;\n};\ntypedef __POSITION *POSITION;\n#endif\n\nconst int DEFAULTCACHE = 10; /* Default node object cache size */\n\n/* A class representing one node in a list.\n   Each node knows a pointer to it's adjacent nodes and also a pointer\n   to the object that it looks after.\n   All of these pointers can be retrieved or set through member functions.\n*/\nclass CBaseList\n#ifdef DEBUG\n    : public CBaseObject\n#endif\n{\n    /* Making these classes inherit from CBaseObject does nothing\n       functionally but it allows us to check there are no memory\n       leaks in debug builds.\n    */\n\n  public:\n#ifdef DEBUG\n    class CNode : public CBaseObject\n    {\n#else\n    class CNode\n    {\n#endif\n\n        CNode *m_pPrev;  /* Previous node in the list */\n        CNode *m_pNext;  /* Next node in the list */\n        void *m_pObject; /* Pointer to the object */\n\n      public:\n        /* Constructor - initialise the object's pointers */\n        CNode()\n#ifdef DEBUG\n            : CBaseObject(NAME(\"List node\"))\n#endif\n                  {};\n\n        /* Return the previous node before this one */\n        __out CNode *Prev() const { return m_pPrev; };\n\n        /* Return the next node after this one */\n        __out CNode *Next() const { return m_pNext; };\n\n        /* Set the previous node before this one */\n        void SetPrev(__in_opt CNode *p) { m_pPrev = p; };\n\n        /* Set the next node after this one */\n        void SetNext(__in_opt CNode *p) { m_pNext = p; };\n\n        /* Get the pointer to the object for this node */\n        __out void *GetData() const { return m_pObject; };\n\n        /* Set the pointer to the object for this node */\n        void SetData(__in void *p) { m_pObject = p; };\n    };\n\n    class CNodeCache\n    {\n      public:\n        CNodeCache(INT iCacheSize)\n            : m_iCacheSize(iCacheSize)\n            , m_pHead(NULL)\n            , m_iUsed(0){};\n        ~CNodeCache()\n        {\n            CNode *pNode = m_pHead;\n            while (pNode)\n            {\n                CNode *pCurrent = pNode;\n                pNode = pNode->Next();\n                delete pCurrent;\n            }\n        };\n        void AddToCache(__inout CNode *pNode)\n        {\n            if (m_iUsed < m_iCacheSize)\n            {\n                pNode->SetNext(m_pHead);\n                m_pHead = pNode;\n                m_iUsed++;\n            }\n            else\n            {\n                delete pNode;\n            }\n        };\n        CNode *RemoveFromCache()\n        {\n            CNode *pNode = m_pHead;\n            if (pNode != NULL)\n            {\n                m_pHead = pNode->Next();\n                m_iUsed--;\n                ASSERT(m_iUsed >= 0);\n            }\n            else\n            {\n                ASSERT(m_iUsed == 0);\n            }\n            return pNode;\n        };\n\n      private:\n        INT m_iCacheSize;\n        INT m_iUsed;\n        CNode *m_pHead;\n    };\n\n  protected:\n    CNode *m_pFirst; /* Pointer to first node in the list */\n    CNode *m_pLast;  /* Pointer to the last node in the list */\n    LONG m_Count;    /* Number of nodes currently in the list */\n\n  private:\n    CNodeCache m_Cache; /* Cache of unused node pointers */\n\n  private:\n    /* These override the default copy constructor and assignment\n       operator for all list classes. They are in the private class\n       declaration section so that anybody trying to pass a list\n       object by value will generate a compile time error of\n       \"cannot access the private member function\". If these were\n       not here then the compiler will create default constructors\n       and assignment operators which when executed first take a\n       copy of all member variables and then during destruction\n       delete them all. This must not be done for any heap\n       allocated data.\n    */\n    CBaseList(const CBaseList &refList);\n    CBaseList &operator=(const CBaseList &refList);\n\n  public:\n    CBaseList(__in_opt LPCTSTR pName, INT iItems);\n\n    CBaseList(__in_opt LPCTSTR pName);\n#ifdef UNICODE\n    CBaseList(__in_opt LPCSTR pName, INT iItems);\n\n    CBaseList(__in_opt LPCSTR pName);\n#endif\n    ~CBaseList();\n\n    /* Remove all the nodes from *this i.e. make the list empty */\n    void RemoveAll();\n\n    /* Return a cursor which identifies the first element of *this */\n    __out_opt POSITION GetHeadPositionI() const;\n\n    /* Return a cursor which identifies the last element of *this */\n    __out_opt POSITION GetTailPositionI() const;\n\n    /* Return the number of objects in *this */\n    int GetCountI() const;\n\n  protected:\n    /* Return the pointer to the object at rp,\n       Update rp to the next node in *this\n       but make it NULL if it was at the end of *this.\n       This is a wart retained for backwards compatibility.\n       GetPrev is not implemented.\n       Use Next, Prev and Get separately.\n    */\n    __out void *GetNextI(__inout POSITION &rp) const;\n\n    /* Return a pointer to the object at p\n       Asking for the object at NULL will return NULL harmlessly.\n    */\n    __out_opt void *GetI(__in_opt POSITION p) const;\n    __out void *GetValidI(__in POSITION p) const;\n\n  public:\n    /* return the next / prev position in *this\n       return NULL when going past the end/start.\n       Next(NULL) is same as GetHeadPosition()\n       Prev(NULL) is same as GetTailPosition()\n       An n element list therefore behaves like a n+1 element\n       cycle with NULL at the start/end.\n\n       !!WARNING!! - This handling of NULL is DIFFERENT from GetNext.\n\n       Some reasons are:\n       1. For a list of n items there are n+1 positions to insert\n          These are conveniently encoded as the n POSITIONs and NULL.\n       2. If you are keeping a list sorted (fairly common) and you\n          search forward for an element to insert before and don't\n          find it you finish up with NULL as the element before which\n          to insert.  You then want that NULL to be a valid POSITION\n          so that you can insert before it and you want that insertion\n          point to mean the (n+1)-th one that doesn't have a POSITION.\n          (symmetrically if you are working backwards through the list).\n       3. It simplifies the algebra which the methods generate.\n          e.g. AddBefore(p,x) is identical to AddAfter(Prev(p),x)\n          in ALL cases.  All the other arguments probably are reflections\n          of the algebraic point.\n    */\n    __out_opt POSITION Next(__in_opt POSITION pos) const\n    {\n        if (pos == NULL)\n        {\n            return (POSITION)m_pFirst;\n        }\n        CNode *pn = (CNode *)pos;\n        return (POSITION)pn->Next();\n    } // Next\n\n    // See Next\n    __out_opt POSITION Prev(__in_opt POSITION pos) const\n    {\n        if (pos == NULL)\n        {\n            return (POSITION)m_pLast;\n        }\n        CNode *pn = (CNode *)pos;\n        return (POSITION)pn->Prev();\n    } // Prev\n\n    /* Return the first position in *this which holds the given\n       pointer.  Return NULL if the pointer was not not found.\n    */\n  protected:\n    __out_opt POSITION FindI(__in void *pObj) const;\n\n    // ??? Should there be (or even should there be only)\n    // ??? POSITION FindNextAfter(void * pObj, POSITION p)\n    // ??? And of course FindPrevBefore too.\n    // ??? List.Find(&Obj) then becomes List.FindNextAfter(&Obj, NULL)\n\n    /* Remove the first node in *this (deletes the pointer to its\n       object from the list, does not free the object itself).\n       Return the pointer to its object.\n       If *this was already empty it will harmlessly return NULL.\n    */\n    __out_opt void *RemoveHeadI();\n\n    /* Remove the last node in *this (deletes the pointer to its\n       object from the list, does not free the object itself).\n       Return the pointer to its object.\n       If *this was already empty it will harmlessly return NULL.\n    */\n    __out_opt void *RemoveTailI();\n\n    /* Remove the node identified by p from the list (deletes the pointer\n       to its object from the list, does not free the object itself).\n       Asking to Remove the object at NULL will harmlessly return NULL.\n       Return the pointer to the object removed.\n    */\n    __out_opt void *RemoveI(__in_opt POSITION p);\n\n    /* Add single object *pObj to become a new last element of the list.\n       Return the new tail position, NULL if it fails.\n       If you are adding a COM objects, you might want AddRef it first.\n       Other existing POSITIONs in *this are still valid\n    */\n    __out_opt POSITION AddTailI(__in void *pObj);\n\n  public:\n    /* Add all the elements in *pList to the tail of *this.\n       This duplicates all the nodes in *pList (i.e. duplicates\n       all its pointers to objects).  It does not duplicate the objects.\n       If you are adding a list of pointers to a COM object into the list\n       it's a good idea to AddRef them all  it when you AddTail it.\n       Return TRUE if it all worked, FALSE if it didn't.\n       If it fails some elements may have been added.\n       Existing POSITIONs in *this are still valid\n\n       If you actually want to MOVE the elements, use MoveToTail instead.\n    */\n    BOOL AddTail(__in CBaseList *pList);\n\n    /* Mirror images of AddHead: */\n\n    /* Add single object to become a new first element of the list.\n       Return the new head position, NULL if it fails.\n       Existing POSITIONs in *this are still valid\n    */\n  protected:\n    __out_opt POSITION AddHeadI(__in void *pObj);\n\n  public:\n    /* Add all the elements in *pList to the head of *this.\n       Same warnings apply as for AddTail.\n       Return TRUE if it all worked, FALSE if it didn't.\n       If it fails some of the objects may have been added.\n\n       If you actually want to MOVE the elements, use MoveToHead instead.\n    */\n    BOOL AddHead(__in CBaseList *pList);\n\n    /* Add the object *pObj to *this after position p in *this.\n       AddAfter(NULL,x) adds x to the start - equivalent to AddHead\n       Return the position of the object added, NULL if it failed.\n       Existing POSITIONs in *this are undisturbed, including p.\n    */\n  protected:\n    __out_opt POSITION AddAfterI(__in_opt POSITION p, __in void *pObj);\n\n  public:\n    /* Add the list *pList to *this after position p in *this\n       AddAfter(NULL,x) adds x to the start - equivalent to AddHead\n       Return TRUE if it all worked, FALSE if it didn't.\n       If it fails, some of the objects may be added\n       Existing POSITIONs in *this are undisturbed, including p.\n    */\n    BOOL AddAfter(__in_opt POSITION p, __in CBaseList *pList);\n\n    /* Mirror images:\n       Add the object *pObj to this-List after position p in *this.\n       AddBefore(NULL,x) adds x to the end - equivalent to AddTail\n       Return the position of the new object, NULL if it fails\n       Existing POSITIONs in *this are undisturbed, including p.\n    */\n  protected:\n    __out_opt POSITION AddBeforeI(__in_opt POSITION p, __in void *pObj);\n\n  public:\n    /* Add the list *pList to *this before position p in *this\n       AddAfter(NULL,x) adds x to the start - equivalent to AddHead\n       Return TRUE if it all worked, FALSE if it didn't.\n       If it fails, some of the objects may be added\n       Existing POSITIONs in *this are undisturbed, including p.\n    */\n    BOOL AddBefore(__in_opt POSITION p, __in CBaseList *pList);\n\n    /* Note that AddAfter(p,x) is equivalent to AddBefore(Next(p),x)\n       even in cases where p is NULL or Next(p) is NULL.\n       Similarly for mirror images etc.\n       This may make it easier to argue about programs.\n    */\n\n    /* The following operations do not copy any elements.\n       They move existing blocks of elements around by switching pointers.\n       They are fairly efficient for long lists as for short lists.\n       (Alas, the Count slows things down).\n\n       They split the list into two parts.\n       One part remains as the original list, the other part\n       is appended to the second list.  There are eight possible\n       variations:\n       Split the list {after/before} a given element\n       keep the {head/tail} portion in the original list\n       append the rest to the {head/tail} of the new list.\n\n       Since After is strictly equivalent to Before Next\n       we are not in serious need of the Before/After variants.\n       That leaves only four.\n\n       If you are processing a list left to right and dumping\n       the bits that you have processed into another list as\n       you go, the Tail/Tail variant gives the most natural result.\n       If you are processing in reverse order, Head/Head is best.\n\n       By using NULL positions and empty lists judiciously either\n       of the other two can be built up in two operations.\n\n       The definition of NULL (see Next/Prev etc) means that\n       degenerate cases include\n          \"move all elements to new list\"\n          \"Split a list into two lists\"\n          \"Concatenate two lists\"\n          (and quite a few no-ops)\n\n       !!WARNING!! The type checking won't buy you much if you get list\n       positions muddled up - e.g. use a POSITION that's in a different\n       list and see what a mess you get!\n    */\n\n    /* Split *this after position p in *this\n       Retain as *this the tail portion of the original *this\n       Add the head portion to the tail end of *pList\n       Return TRUE if it all worked, FALSE if it didn't.\n\n       e.g.\n          foo->MoveToTail(foo->GetHeadPosition(), bar);\n              moves one element from the head of foo to the tail of bar\n          foo->MoveToTail(NULL, bar);\n              is a no-op, returns NULL\n          foo->MoveToTail(foo->GetTailPosition, bar);\n              concatenates foo onto the end of bar and empties foo.\n\n       A better, except excessively long name might be\n           MoveElementsFromHeadThroughPositionToOtherTail\n    */\n    BOOL MoveToTail(__in_opt POSITION pos, __in CBaseList *pList);\n\n    /* Mirror image:\n       Split *this before position p in *this.\n       Retain in *this the head portion of the original *this\n       Add the tail portion to the start (i.e. head) of *pList\n\n       e.g.\n          foo->MoveToHead(foo->GetTailPosition(), bar);\n              moves one element from the tail of foo to the head of bar\n          foo->MoveToHead(NULL, bar);\n              is a no-op, returns NULL\n          foo->MoveToHead(foo->GetHeadPosition, bar);\n              concatenates foo onto the start of bar and empties foo.\n    */\n    BOOL MoveToHead(__in_opt POSITION pos, __in CBaseList *pList);\n\n    /* Reverse the order of the [pointers to] objects in *this\n     */\n    void Reverse();\n\n/* set cursor to the position of each element of list in turn  */\n#define TRAVERSELIST(list, cursor) for (cursor = (list).GetHeadPosition(); cursor != NULL; cursor = (list).Next(cursor))\n\n/* set cursor to the position of each element of list in turn\n   in reverse order\n*/\n#define REVERSETRAVERSELIST(list, cursor) \\\n    for (cursor = (list).GetTailPosition(); cursor != NULL; cursor = (list).Prev(cursor))\n\n}; // end of class declaration\n\ntemplate <class OBJECT> class CGenericList : public CBaseList\n{\n  public:\n    CGenericList(__in_opt LPCTSTR pName, INT iItems, BOOL bLock = TRUE, BOOL bAlert = FALSE)\n        : CBaseList(pName, iItems)\n    {\n        UNREFERENCED_PARAMETER(bAlert);\n        UNREFERENCED_PARAMETER(bLock);\n    };\n    CGenericList(__in_opt LPCTSTR pName)\n        : CBaseList(pName){};\n\n    __out_opt POSITION GetHeadPosition() const { return (POSITION)m_pFirst; }\n    __out_opt POSITION GetTailPosition() const { return (POSITION)m_pLast; }\n    int GetCount() const { return m_Count; }\n\n    __out OBJECT *GetNext(__inout POSITION &rp) const { return (OBJECT *)GetNextI(rp); }\n\n    __out_opt OBJECT *Get(__in_opt POSITION p) const { return (OBJECT *)GetI(p); }\n    __out OBJECT *GetValid(__in POSITION p) const { return (OBJECT *)GetValidI(p); }\n    __out_opt OBJECT *GetHead() const { return Get(GetHeadPosition()); }\n\n    __out_opt OBJECT *RemoveHead() { return (OBJECT *)RemoveHeadI(); }\n\n    __out_opt OBJECT *RemoveTail() { return (OBJECT *)RemoveTailI(); }\n\n    __out_opt OBJECT *Remove(__in_opt POSITION p) { return (OBJECT *)RemoveI(p); }\n    __out_opt POSITION AddBefore(__in_opt POSITION p, __in OBJECT *pObj) { return AddBeforeI(p, pObj); }\n    __out_opt POSITION AddAfter(__in_opt POSITION p, __in OBJECT *pObj) { return AddAfterI(p, pObj); }\n    __out_opt POSITION AddHead(__in OBJECT *pObj) { return AddHeadI(pObj); }\n    __out_opt POSITION AddTail(__in OBJECT *pObj) { return AddTailI(pObj); }\n    BOOL AddTail(__in CGenericList<OBJECT> *pList) { return CBaseList::AddTail((CBaseList *)pList); }\n    BOOL AddHead(__in CGenericList<OBJECT> *pList) { return CBaseList::AddHead((CBaseList *)pList); }\n    BOOL AddAfter(__in_opt POSITION p, __in CGenericList<OBJECT> *pList)\n    {\n        return CBaseList::AddAfter(p, (CBaseList *)pList);\n    };\n    BOOL AddBefore(__in_opt POSITION p, __in CGenericList<OBJECT> *pList)\n    {\n        return CBaseList::AddBefore(p, (CBaseList *)pList);\n    };\n    __out_opt POSITION Find(__in OBJECT *pObj) const { return FindI(pObj); }\n}; // end of class declaration\n\n/* These define the standard list types */\n\ntypedef CGenericList<CBaseObject> CBaseObjectList;\ntypedef CGenericList<IUnknown> CBaseInterfaceList;\n\n#endif /* __WXLIST__ */\n"
  },
  {
    "path": "common/baseclasses/wxutil.cpp",
    "content": "//------------------------------------------------------------------------------\n// File: WXUtil.cpp\n//\n// Desc: DirectShow base classes - implements helper classes for building\n//       multimedia filters.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#include <streams.h>\n#define STRSAFE_NO_DEPRECATE\n#include <strsafe.h>\n#include <process.h>\n\n// --- CAMEvent -----------------------\nCAMEvent::CAMEvent(BOOL fManualReset, __inout_opt HRESULT *phr)\n{\n    m_hEvent = CreateEvent(NULL, fManualReset, FALSE, NULL);\n    if (NULL == m_hEvent)\n    {\n        if (NULL != phr && SUCCEEDED(*phr))\n        {\n            *phr = E_OUTOFMEMORY;\n        }\n    }\n}\n\nCAMEvent::CAMEvent(__inout_opt HRESULT *phr)\n{\n    m_hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);\n    if (NULL == m_hEvent)\n    {\n        if (NULL != phr && SUCCEEDED(*phr))\n        {\n            *phr = E_OUTOFMEMORY;\n        }\n    }\n}\n\nCAMEvent::~CAMEvent()\n{\n    if (m_hEvent)\n    {\n        EXECUTE_ASSERT(CloseHandle(m_hEvent));\n    }\n}\n\n// --- CAMMsgEvent -----------------------\n// One routine.  The rest is handled in CAMEvent\n\nCAMMsgEvent::CAMMsgEvent(__inout_opt HRESULT *phr)\n    : CAMEvent(FALSE, phr)\n{\n}\n\nBOOL CAMMsgEvent::WaitMsg(DWORD dwTimeout)\n{\n    // wait for the event to be signalled, or for the\n    // timeout (in MS) to expire.  allow SENT messages\n    // to be processed while we wait\n    DWORD dwWait;\n    DWORD dwStartTime;\n\n    // set the waiting period.\n    DWORD dwWaitTime = dwTimeout;\n\n    // the timeout will eventually run down as we iterate\n    // processing messages.  grab the start time so that\n    // we can calculate elapsed times.\n    if (dwWaitTime != INFINITE)\n    {\n        dwStartTime = timeGetTime();\n    }\n\n    do\n    {\n        dwWait = MsgWaitForMultipleObjects(1, &m_hEvent, FALSE, dwWaitTime, QS_SENDMESSAGE);\n        if (dwWait == WAIT_OBJECT_0 + 1)\n        {\n            MSG Message;\n            PeekMessage(&Message, NULL, 0, 0, PM_NOREMOVE);\n\n            // If we have an explicit length of time to wait calculate\n            // the next wake up point - which might be now.\n            // If dwTimeout is INFINITE, it stays INFINITE\n            if (dwWaitTime != INFINITE)\n            {\n\n                DWORD dwElapsed = timeGetTime() - dwStartTime;\n\n                dwWaitTime = (dwElapsed >= dwTimeout) ? 0 // wake up with WAIT_TIMEOUT\n                                                      : dwTimeout - dwElapsed;\n            }\n        }\n    } while (dwWait == WAIT_OBJECT_0 + 1);\n\n    // return TRUE if we woke on the event handle,\n    //        FALSE if we timed out.\n    return (dwWait == WAIT_OBJECT_0);\n}\n\n// --- CAMThread ----------------------\n\nCAMThread::CAMThread(__inout_opt HRESULT *phr)\n    : m_EventSend(TRUE, phr)\n    , // must be manual-reset for CheckRequest()\n    m_EventComplete(FALSE, phr)\n{\n    m_hThread = NULL;\n}\n\nCAMThread::~CAMThread()\n{\n    Close();\n}\n\n// when the thread starts, it calls this function. We unwrap the 'this'\n// pointer and call ThreadProc.\nunsigned int WINAPI CAMThread::InitialThreadProc(__inout LPVOID pv)\n{\n    HRESULT hrCoInit = CAMThread::CoInitializeHelper();\n    if (FAILED(hrCoInit))\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"CoInitializeEx failed.\")));\n    }\n\n    CAMThread *pThread = (CAMThread *)pv;\n\n    HRESULT hr = pThread->ThreadProc();\n\n    if (SUCCEEDED(hrCoInit))\n    {\n        CoUninitialize();\n    }\n\n    return hr;\n}\n\nBOOL CAMThread::Create()\n{\n    CAutoLock lock(&m_AccessLock);\n\n    if (ThreadExists())\n    {\n        return FALSE;\n    }\n\n    m_hThread = (HANDLE)_beginthreadex(NULL,                         /* Security */\n                                       0,                            /* Stack Size */\n                                       CAMThread::InitialThreadProc, /* Thread process */\n                                       (LPVOID)this,                 /* Arguments */\n                                       0,                            /* 0 = Start Immediately */\n                                       NULL                          /* Thread Address */\n    );\n    if (!m_hThread)\n    {\n        return FALSE;\n    }\n\n    return TRUE;\n}\n\nDWORD\nCAMThread::CallWorker(DWORD dwParam)\n{\n    // lock access to the worker thread for scope of this object\n    CAutoLock lock(&m_AccessLock);\n\n    if (!ThreadExists())\n    {\n        return (DWORD)E_FAIL;\n    }\n\n    // set the parameter\n    m_dwParam = dwParam;\n\n    // signal the worker thread\n    m_EventSend.Set();\n\n    // wait for the completion to be signalled\n    m_EventComplete.Wait();\n\n    // done - this is the thread's return value\n    return m_dwReturnVal;\n}\n\n// Wait for a request from the client\nDWORD\nCAMThread::GetRequest()\n{\n    m_EventSend.Wait();\n    return m_dwParam;\n}\n\n// is there a request?\nBOOL CAMThread::CheckRequest(__out_opt DWORD *pParam)\n{\n    if (!m_EventSend.Check())\n    {\n        return FALSE;\n    }\n    else\n    {\n        if (pParam)\n        {\n            *pParam = m_dwParam;\n        }\n        return TRUE;\n    }\n}\n\n// reply to the request\nvoid CAMThread::Reply(DWORD dw)\n{\n    m_dwReturnVal = dw;\n\n    // The request is now complete so CheckRequest should fail from\n    // now on\n    //\n    // This event should be reset BEFORE we signal the client or\n    // the client may Set it before we reset it and we'll then\n    // reset it (!)\n\n    m_EventSend.Reset();\n\n    // Tell the client we're finished\n\n    m_EventComplete.Set();\n}\n\nHRESULT CAMThread::CoInitializeHelper()\n{\n    // call CoInitializeEx and tell OLE not to create a window (this\n    // thread probably won't dispatch messages and will hang on\n    // broadcast msgs o/w).\n    //\n    // If CoInitEx is not available, threads that don't call CoCreate\n    // aren't affected. Threads that do will have to handle the\n    // failure. Perhaps we should fall back to CoInitialize and risk\n    // hanging?\n    //\n\n    // older versions of ole32.dll don't have CoInitializeEx\n\n    HRESULT hr = E_FAIL;\n    HINSTANCE hOle = GetModuleHandle(TEXT(\"ole32.dll\"));\n    if (hOle)\n    {\n        typedef HRESULT(STDAPICALLTYPE * PCoInitializeEx)(LPVOID pvReserved, DWORD dwCoInit);\n        PCoInitializeEx pCoInitializeEx = (PCoInitializeEx)(GetProcAddress(hOle, \"CoInitializeEx\"));\n        if (pCoInitializeEx)\n        {\n            hr = (*pCoInitializeEx)(0, COINIT_DISABLE_OLE1DDE);\n        }\n    }\n    else\n    {\n        // caller must load ole32.dll\n        DbgBreak(\"couldn't locate ole32.dll\");\n    }\n\n    return hr;\n}\n\n// destructor for CMsgThread  - cleans up any messages left in the\n// queue when the thread exited\nCMsgThread::~CMsgThread()\n{\n    if (m_hThread != NULL)\n    {\n        WaitForSingleObject(m_hThread, INFINITE);\n        EXECUTE_ASSERT(CloseHandle(m_hThread));\n    }\n\n    POSITION pos = m_ThreadQueue.GetHeadPosition();\n    while (pos)\n    {\n        CMsg *pMsg = m_ThreadQueue.GetNext(pos);\n        delete pMsg;\n    }\n    m_ThreadQueue.RemoveAll();\n\n    if (m_hSem != NULL)\n    {\n        EXECUTE_ASSERT(CloseHandle(m_hSem));\n    }\n}\n\nBOOL CMsgThread::CreateThread()\n{\n    m_hSem = CreateSemaphore(NULL, 0, 0x7FFFFFFF, NULL);\n    if (m_hSem == NULL)\n    {\n        return FALSE;\n    }\n\n    m_hThread = ::CreateThread(NULL, 0, DefaultThreadProc, (LPVOID)this, 0, &m_ThreadId);\n    return m_hThread != NULL;\n}\n\n// This is the threads message pump.  Here we get and dispatch messages to\n// clients thread proc until the client refuses to process a message.\n// The client returns a non-zero value to stop the message pump, this\n// value becomes the threads exit code.\n\nDWORD WINAPI CMsgThread::DefaultThreadProc(__inout LPVOID lpParam)\n{\n    CMsgThread *lpThis = (CMsgThread *)lpParam;\n    CMsg msg;\n    LRESULT lResult;\n\n    // !!!\n    CoInitialize(NULL);\n\n    // allow a derived class to handle thread startup\n    lpThis->OnThreadInit();\n\n    do\n    {\n        lpThis->GetThreadMsg(&msg);\n        lResult = lpThis->ThreadMessageProc(msg.uMsg, msg.dwFlags, msg.lpParam, msg.pEvent);\n    } while (lResult == 0L);\n\n    // !!!\n    CoUninitialize();\n\n    return (DWORD)lResult;\n}\n\n// Block until the next message is placed on the list m_ThreadQueue.\n// copies the message to the message pointed to by *pmsg\nvoid CMsgThread::GetThreadMsg(__out CMsg *msg)\n{\n    CMsg *pmsg = NULL;\n\n    // keep trying until a message appears\n    while (TRUE)\n    {\n        {\n            CAutoLock lck(&m_Lock);\n            pmsg = m_ThreadQueue.RemoveHead();\n            if (pmsg == NULL)\n            {\n                m_lWaiting++;\n            }\n            else\n            {\n                break;\n            }\n        }\n        // the semaphore will be signalled when it is non-empty\n        WaitForSingleObject(m_hSem, INFINITE);\n    }\n    // copy fields to caller's CMsg\n    *msg = *pmsg;\n\n    // this CMsg was allocated by the 'new' in PutThreadMsg\n    delete pmsg;\n}\n\n// Helper function - convert int to WSTR\nvoid WINAPI IntToWstr(int i, __out_ecount(12) LPWSTR wstr)\n{\n#ifdef UNICODE\n    if (FAILED(StringCchPrintf(wstr, 12, L\"%d\", i)))\n    {\n        wstr[0] = 0;\n    }\n#else\n    TCHAR temp[12];\n    if (FAILED(StringCchPrintf(temp, NUMELMS(temp), \"%d\", i)))\n    {\n        wstr[0] = 0;\n    }\n    else\n    {\n        MultiByteToWideChar(CP_ACP, 0, temp, -1, wstr, 12);\n    }\n#endif\n} // IntToWstr\n\n#define MEMORY_ALIGNMENT 4\n#define MEMORY_ALIGNMENT_LOG2 2\n#define MEMORY_ALIGNMENT_MASK MEMORY_ALIGNMENT - 1\n\nvoid *__stdcall memmoveInternal(void *dst, const void *src, size_t count)\n{\n    void *ret = dst;\n\n#ifdef _X86_\n    if (dst <= src || (char *)dst >= ((char *)src + count))\n    {\n\n        /*\n         * Non-Overlapping Buffers\n         * copy from lower addresses to higher addresses\n         */\n        _asm {\n            mov     esi,src\n            mov     edi,dst\n            mov     ecx,count\n            cld\n            mov     edx,ecx\n            and     edx,MEMORY_ALIGNMENT_MASK\n            shr     ecx,MEMORY_ALIGNMENT_LOG2\n            rep     movsd\n            or      ecx,edx\n            jz      memmove_done\n            rep     movsb\nmemmove_done:\n        }\n    }\n    else\n    {\n\n        /*\n         * Overlapping Buffers\n         * copy from higher addresses to lower addresses\n         */\n        _asm {\n            mov     esi,src\n            mov     edi,dst\n            mov     ecx,count\n            std\n            add     esi,ecx\n            add     edi,ecx\n            dec     esi\n            dec     edi\n            rep     movsb\n            cld\n        }\n    }\n#else\n    MoveMemory(dst, src, count);\n#endif\n\n    return ret;\n}\n\nHRESULT AMSafeMemMoveOffset(__in_bcount(dst_size) void *dst, __in size_t dst_size, __in DWORD cb_dst_offset,\n                            __in_bcount(src_size) const void *src, __in size_t src_size, __in DWORD cb_src_offset,\n                            __in size_t count)\n{\n    // prevent read overruns\n    if (count + cb_src_offset < count ||  // prevent integer overflow\n        count + cb_src_offset > src_size) // prevent read overrun\n    {\n        return E_INVALIDARG;\n    }\n\n    // prevent write overruns\n    if (count + cb_dst_offset < count ||  // prevent integer overflow\n        count + cb_dst_offset > dst_size) // prevent write overrun\n    {\n        return E_INVALIDARG;\n    }\n\n    memmoveInternal((BYTE *)dst + cb_dst_offset, (BYTE *)src + cb_src_offset, count);\n    return S_OK;\n}\n\n#ifdef DEBUG\n/******************************Public*Routine******************************\\\n* Debug CCritSec helpers\n*\n* We provide debug versions of the Constructor, destructor, Lock and Unlock\n* routines.  The debug code tracks who owns each critical section by\n* maintaining a depth count.\n*\n* History:\n*\n\\**************************************************************************/\n\nCCritSec::CCritSec()\n{\n    InitializeCriticalSection(&m_CritSec);\n    m_currentOwner = m_lockCount = 0;\n    m_fTrace = FALSE;\n}\n\nCCritSec::~CCritSec()\n{\n    DeleteCriticalSection(&m_CritSec);\n}\n\nvoid CCritSec::Lock()\n{\n    UINT tracelevel = 3;\n    DWORD us = GetCurrentThreadId();\n    DWORD currentOwner = m_currentOwner;\n    if (currentOwner && (currentOwner != us))\n    {\n        // already owned, but not by us\n        if (m_fTrace)\n        {\n            DbgLog((LOG_LOCKING, 2, TEXT(\"Thread %d about to wait for lock %x owned by %d\"), GetCurrentThreadId(),\n                    &m_CritSec, currentOwner));\n            tracelevel = 2;\n            // if we saw the message about waiting for the critical\n            // section we ensure we see the message when we get the\n            // critical section\n        }\n    }\n    EnterCriticalSection(&m_CritSec);\n    if (0 == m_lockCount++)\n    {\n        // we now own it for the first time.  Set owner information\n        m_currentOwner = us;\n\n        if (m_fTrace)\n        {\n            DbgLog((LOG_LOCKING, tracelevel, TEXT(\"Thread %d now owns lock %x\"), m_currentOwner, &m_CritSec));\n        }\n    }\n}\n\nvoid CCritSec::Unlock()\n{\n    if (0 == --m_lockCount)\n    {\n        // about to be unowned\n        if (m_fTrace)\n        {\n            DbgLog((LOG_LOCKING, 3, TEXT(\"Thread %d releasing lock %x\"), m_currentOwner, &m_CritSec));\n        }\n\n        m_currentOwner = 0;\n    }\n    LeaveCriticalSection(&m_CritSec);\n}\n\nvoid WINAPI DbgLockTrace(CCritSec *pcCrit, BOOL fTrace)\n{\n    pcCrit->m_fTrace = fTrace;\n}\n\nBOOL WINAPI CritCheckIn(CCritSec *pcCrit)\n{\n    return (GetCurrentThreadId() == pcCrit->m_currentOwner);\n}\n\nBOOL WINAPI CritCheckIn(const CCritSec *pcCrit)\n{\n    return (GetCurrentThreadId() == pcCrit->m_currentOwner);\n}\n\nBOOL WINAPI CritCheckOut(CCritSec *pcCrit)\n{\n    return (GetCurrentThreadId() != pcCrit->m_currentOwner);\n}\n\nBOOL WINAPI CritCheckOut(const CCritSec *pcCrit)\n{\n    return (GetCurrentThreadId() != pcCrit->m_currentOwner);\n}\n#endif\n\nSTDAPI WriteBSTR(__deref_out BSTR *pstrDest, LPCWSTR szSrc)\n{\n    *pstrDest = SysAllocString(szSrc);\n    if (!(*pstrDest))\n        return E_OUTOFMEMORY;\n    return NOERROR;\n}\n\nSTDAPI FreeBSTR(__deref_in BSTR *pstr)\n{\n    if ((PVOID)*pstr == NULL)\n        return S_FALSE;\n    SysFreeString(*pstr);\n    return NOERROR;\n}\n\n// Return a wide string - allocating memory for it\n// Returns:\n//    S_OK          - no error\n//    E_POINTER     - ppszReturn == NULL\n//    E_OUTOFMEMORY - can't allocate memory for returned string\nSTDAPI AMGetWideString(LPCWSTR psz, __deref_out LPWSTR *ppszReturn)\n{\n    CheckPointer(ppszReturn, E_POINTER);\n    ValidateReadWritePtr(ppszReturn, sizeof(LPWSTR));\n    *ppszReturn = NULL;\n    size_t nameLen;\n    HRESULT hr = StringCbLengthW(psz, 100000, &nameLen);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n    *ppszReturn = (LPWSTR)CoTaskMemAlloc(nameLen + sizeof(WCHAR));\n    if (*ppszReturn == NULL)\n    {\n        return E_OUTOFMEMORY;\n    }\n    CopyMemory(*ppszReturn, psz, nameLen + sizeof(WCHAR));\n    return NOERROR;\n}\n\n// Waits for the HANDLE hObject.  While waiting messages sent\n// to windows on our thread by SendMessage will be processed.\n// Using this function to do waits and mutual exclusion\n// avoids some deadlocks in objects with windows.\n// Return codes are the same as for WaitForSingleObject\nDWORD WINAPI WaitDispatchingMessages(HANDLE hObject, DWORD dwWait, HWND hwnd, UINT uMsg, HANDLE hEvent)\n{\n    BOOL bPeeked = FALSE;\n    DWORD dwResult;\n    DWORD dwStart;\n    DWORD dwThreadPriority;\n\n    static UINT uMsgId = 0;\n\n    HANDLE hObjects[2] = {hObject, hEvent};\n    if (dwWait != INFINITE && dwWait != 0)\n    {\n        dwStart = GetTickCount();\n    }\n    for (;;)\n    {\n        DWORD nCount = NULL != hEvent ? 2 : 1;\n\n        //  Minimize the chance of actually dispatching any messages\n        //  by seeing if we can lock immediately.\n        dwResult = WaitForMultipleObjects(nCount, hObjects, FALSE, 0);\n        if (dwResult < WAIT_OBJECT_0 + nCount)\n        {\n            break;\n        }\n\n        DWORD dwTimeOut = dwWait;\n        if (dwTimeOut > 10)\n        {\n            dwTimeOut = 10;\n        }\n        dwResult = MsgWaitForMultipleObjects(nCount, hObjects, FALSE, dwTimeOut,\n                                             hwnd == NULL ? QS_SENDMESSAGE : QS_SENDMESSAGE + QS_POSTMESSAGE);\n        if (dwResult == WAIT_OBJECT_0 + nCount || dwResult == WAIT_TIMEOUT && dwTimeOut != dwWait)\n        {\n            MSG msg;\n            if (hwnd != NULL)\n            {\n                while (PeekMessage(&msg, hwnd, uMsg, uMsg, PM_REMOVE))\n                {\n                    DispatchMessage(&msg);\n                }\n            }\n            // Do this anyway - the previous peek doesn't flush out the\n            // messages\n            PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE);\n\n            if (dwWait != INFINITE && dwWait != 0)\n            {\n                DWORD dwNow = GetTickCount();\n\n                // Working with differences handles wrap-around\n                DWORD dwDiff = dwNow - dwStart;\n                if (dwDiff > dwWait)\n                {\n                    dwWait = 0;\n                }\n                else\n                {\n                    dwWait -= dwDiff;\n                }\n                dwStart = dwNow;\n            }\n            if (!bPeeked)\n            {\n                //  Raise our priority to prevent our message queue\n                //  building up\n                dwThreadPriority = GetThreadPriority(GetCurrentThread());\n                if (dwThreadPriority < THREAD_PRIORITY_HIGHEST)\n                {\n                    SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_HIGHEST);\n                }\n                bPeeked = TRUE;\n            }\n        }\n        else\n        {\n            break;\n        }\n    }\n    if (bPeeked)\n    {\n        SetThreadPriority(GetCurrentThread(), dwThreadPriority);\n        if (HIWORD(GetQueueStatus(QS_POSTMESSAGE)) & QS_POSTMESSAGE)\n        {\n            if (uMsgId == 0)\n            {\n                uMsgId = RegisterWindowMessage(TEXT(\"AMUnblock\"));\n            }\n            if (uMsgId != 0)\n            {\n                MSG msg;\n                //  Remove old ones\n                while (PeekMessage(&msg, (HWND)-1, uMsgId, uMsgId, PM_REMOVE))\n                {\n                }\n            }\n            PostThreadMessage(GetCurrentThreadId(), uMsgId, 0, 0);\n        }\n    }\n    return dwResult;\n}\n\nHRESULT AmGetLastErrorToHResult()\n{\n    DWORD dwLastError = GetLastError();\n    if (dwLastError != 0)\n    {\n        return HRESULT_FROM_WIN32(dwLastError);\n    }\n    else\n    {\n        return E_FAIL;\n    }\n}\n\nIUnknown *QzAtlComPtrAssign(__deref_inout_opt IUnknown **pp, __in_opt IUnknown *lp)\n{\n    if (lp != NULL)\n        lp->AddRef();\n    if (*pp)\n        (*pp)->Release();\n    *pp = lp;\n    return lp;\n}\n"
  },
  {
    "path": "common/baseclasses/wxutil.h",
    "content": "//------------------------------------------------------------------------------\n// File: WXUtil.h\n//\n// Desc: DirectShow base classes - defines helper classes and functions for\n//       building multimedia filters.\n//\n// Copyright (c) 1992-2001 Microsoft Corporation.  All rights reserved.\n//------------------------------------------------------------------------------\n\n#ifndef __WXUTIL__\n#define __WXUTIL__\n\n// eliminate spurious \"statement has no effect\" warnings.\n#pragma warning(disable : 4705)\n\n// wrapper for whatever critical section we have\nclass CCritSec\n{\n\n    // make copy constructor and assignment operator inaccessible\n\n    CCritSec(const CCritSec &refCritSec);\n    CCritSec &operator=(const CCritSec &refCritSec);\n\n    CRITICAL_SECTION m_CritSec;\n\n#ifdef DEBUG\n  public:\n    DWORD m_currentOwner;\n    DWORD m_lockCount;\n    BOOL m_fTrace; // Trace this one\n  public:\n    CCritSec();\n    ~CCritSec();\n    void Lock();\n    void Unlock();\n#else\n\n  public:\n    CCritSec() { InitializeCriticalSection(&m_CritSec); };\n\n    ~CCritSec() { DeleteCriticalSection(&m_CritSec); };\n\n    void Lock() { EnterCriticalSection(&m_CritSec); };\n\n    void Unlock() { LeaveCriticalSection(&m_CritSec); };\n#endif\n};\n\n//\n// To make deadlocks easier to track it is useful to insert in the\n// code an assertion that says whether we own a critical section or\n// not.  We make the routines that do the checking globals to avoid\n// having different numbers of member functions in the debug and\n// retail class implementations of CCritSec.  In addition we provide\n// a routine that allows usage of specific critical sections to be\n// traced.  This is NOT on by default - there are far too many.\n//\n\n#ifdef DEBUG\nBOOL WINAPI CritCheckIn(CCritSec *pcCrit);\nBOOL WINAPI CritCheckIn(const CCritSec *pcCrit);\nBOOL WINAPI CritCheckOut(CCritSec *pcCrit);\nBOOL WINAPI CritCheckOut(const CCritSec *pcCrit);\nvoid WINAPI DbgLockTrace(CCritSec *pcCrit, BOOL fTrace);\n#else\n#define CritCheckIn(x) TRUE\n#define CritCheckOut(x) TRUE\n#define DbgLockTrace(pc, fT)\n#endif\n\n// locks a critical section, and unlocks it automatically\n// when the lock goes out of scope\nclass CAutoLock\n{\n\n    // make copy constructor and assignment operator inaccessible\n\n    CAutoLock(const CAutoLock &refAutoLock);\n    CAutoLock &operator=(const CAutoLock &refAutoLock);\n\n  protected:\n    CCritSec *m_pLock;\n\n  public:\n    CAutoLock(CCritSec *plock)\n    {\n        m_pLock = plock;\n        m_pLock->Lock();\n    };\n\n    ~CAutoLock() { m_pLock->Unlock(); };\n};\n\n// wrapper for event objects\nclass CAMEvent\n{\n\n    // make copy constructor and assignment operator inaccessible\n\n    CAMEvent(const CAMEvent &refEvent);\n    CAMEvent &operator=(const CAMEvent &refEvent);\n\n  protected:\n    HANDLE m_hEvent;\n\n  public:\n    CAMEvent(BOOL fManualReset = FALSE, __inout_opt HRESULT *phr = NULL);\n    CAMEvent(__inout_opt HRESULT *phr);\n    ~CAMEvent();\n\n    // Cast to HANDLE - we don't support this as an lvalue\n    operator HANDLE() const { return m_hEvent; };\n\n    void Set() { EXECUTE_ASSERT(SetEvent(m_hEvent)); };\n    BOOL Wait(DWORD dwTimeout = INFINITE) { return (WaitForSingleObject(m_hEvent, dwTimeout) == WAIT_OBJECT_0); };\n    void Reset() { ResetEvent(m_hEvent); };\n    BOOL Check() { return Wait(0); };\n};\n\n// wrapper for event objects that do message processing\n// This adds ONE method to the CAMEvent object to allow sent\n// messages to be processed while waiting\n\nclass CAMMsgEvent : public CAMEvent\n{\n\n  public:\n    CAMMsgEvent(__inout_opt HRESULT *phr = NULL);\n\n    // Allow SEND messages to be processed while waiting\n    BOOL WaitMsg(DWORD dwTimeout = INFINITE);\n};\n\n// old name supported for the time being\n#define CTimeoutEvent CAMEvent\n\n// support for a worker thread\n\n#ifdef AM_NOVTABLE\n// simple thread class supports creation of worker thread, synchronization\n// and communication. Can be derived to simplify parameter passing\nclass AM_NOVTABLE CAMThread\n{\n\n    // make copy constructor and assignment operator inaccessible\n\n    CAMThread(const CAMThread &refThread);\n    CAMThread &operator=(const CAMThread &refThread);\n\n    CAMEvent m_EventSend;\n    CAMEvent m_EventComplete;\n\n    DWORD m_dwParam;\n    DWORD m_dwReturnVal;\n\n  protected:\n    HANDLE m_hThread;\n\n    // thread will run this function on startup\n    // must be supplied by derived class\n    virtual DWORD ThreadProc() = 0;\n\n  public:\n    CAMThread(__inout_opt HRESULT *phr = NULL);\n    virtual ~CAMThread();\n\n    CCritSec m_AccessLock; // locks access by client threads\n    CCritSec m_WorkerLock; // locks access to shared objects\n\n    // thread initially runs this. param is actually 'this'. function\n    // just gets this and calls ThreadProc\n    static unsigned int WINAPI InitialThreadProc(__inout LPVOID pv);\n\n    // start thread running  - error if already running\n    BOOL Create();\n\n    // signal the thread, and block for a response\n    //\n    DWORD CallWorker(DWORD);\n\n    // accessor thread calls this when done with thread (having told thread\n    // to exit)\n    void Close()\n    {\n\n        // Disable warning: Conversion from LONG to PVOID of greater size\n#pragma warning(push)\n#pragma warning(disable : 4312)\n        HANDLE hThread = (HANDLE)InterlockedExchangePointer(&m_hThread, 0);\n#pragma warning(pop)\n\n        if (hThread)\n        {\n            WaitForSingleObject(hThread, INFINITE);\n            CloseHandle(hThread);\n        }\n    };\n\n    // ThreadExists\n    // Return TRUE if the thread exists. FALSE otherwise\n    BOOL ThreadExists(void) const\n    {\n        if (m_hThread == 0)\n        {\n            return FALSE;\n        }\n        else\n        {\n            return TRUE;\n        }\n    }\n\n    // wait for the next request\n    DWORD GetRequest();\n\n    // is there a request?\n    BOOL CheckRequest(__out_opt DWORD *pParam);\n\n    // reply to the request\n    void Reply(DWORD);\n\n    // If you want to do WaitForMultipleObjects you'll need to include\n    // this handle in your wait list or you won't be responsive\n    HANDLE GetRequestHandle() const { return m_EventSend; };\n\n    // Find out what the request was\n    DWORD GetRequestParam() const { return m_dwParam; };\n\n    // call CoInitializeEx (COINIT_DISABLE_OLE1DDE) if\n    // available. S_FALSE means it's not available.\n    static HRESULT CoInitializeHelper();\n};\n#endif // AM_NOVTABLE\n\n// CQueue\n//\n// Implements a simple Queue ADT.  The queue contains a finite number of\n// objects, access to which is controlled by a semaphore.  The semaphore\n// is created with an initial count (N).  Each time an object is added\n// a call to WaitForSingleObject is made on the semaphore's handle.  When\n// this function returns a slot has been reserved in the queue for the new\n// object.  If no slots are available the function blocks until one becomes\n// available.  Each time an object is removed from the queue ReleaseSemaphore\n// is called on the semaphore's handle, thus freeing a slot in the queue.\n// If no objects are present in the queue the function blocks until an\n// object has been added.\n\n#define DEFAULT_QUEUESIZE 2\n\ntemplate <class T> class CQueue\n{\n  private:\n    HANDLE hSemPut;            // Semaphore controlling queue \"putting\"\n    HANDLE hSemGet;            // Semaphore controlling queue \"getting\"\n    CRITICAL_SECTION CritSect; // Thread seriallization\n    int nMax;                  // Max objects allowed in queue\n    int iNextPut;              // Array index of next \"PutMsg\"\n    int iNextGet;              // Array index of next \"GetMsg\"\n    T *QueueObjects;           // Array of objects (ptr's to void)\n\n    void Initialize(int n)\n    {\n        iNextPut = iNextGet = 0;\n        nMax = n;\n        InitializeCriticalSection(&CritSect);\n        hSemPut = CreateSemaphore(NULL, n, n, NULL);\n        hSemGet = CreateSemaphore(NULL, 0, n, NULL);\n        QueueObjects = new T[n];\n    }\n\n  public:\n    CQueue(int n) { Initialize(n); }\n\n    CQueue() { Initialize(DEFAULT_QUEUESIZE); }\n\n    ~CQueue()\n    {\n        delete[] QueueObjects;\n        DeleteCriticalSection(&CritSect);\n        CloseHandle(hSemPut);\n        CloseHandle(hSemGet);\n    }\n\n    T GetQueueObject()\n    {\n        int iSlot;\n        T Object;\n        LONG lPrevious;\n\n        // Wait for someone to put something on our queue, returns straight\n        // away is there is already an object on the queue.\n        //\n        WaitForSingleObject(hSemGet, INFINITE);\n\n        EnterCriticalSection(&CritSect);\n        iSlot = iNextGet++ % nMax;\n        Object = QueueObjects[iSlot];\n        LeaveCriticalSection(&CritSect);\n\n        // Release anyone waiting to put an object onto our queue as there\n        // is now space available in the queue.\n        //\n        ReleaseSemaphore(hSemPut, 1L, &lPrevious);\n        return Object;\n    }\n\n    void PutQueueObject(T Object)\n    {\n        int iSlot;\n        LONG lPrevious;\n\n        // Wait for someone to get something from our queue, returns straight\n        // away is there is already an empty slot on the queue.\n        //\n        WaitForSingleObject(hSemPut, INFINITE);\n\n        EnterCriticalSection(&CritSect);\n        iSlot = iNextPut++ % nMax;\n        QueueObjects[iSlot] = Object;\n        LeaveCriticalSection(&CritSect);\n\n        // Release anyone waiting to remove an object from our queue as there\n        // is now an object available to be removed.\n        //\n        ReleaseSemaphore(hSemGet, 1L, &lPrevious);\n    }\n};\n\n// Ensures that memory is not read past the length source buffer\n// and that memory is not written past the length of the dst buffer\n//   dst - buffer to copy to\n//   dst_size - total size of destination buffer\n//   cb_dst_offset - offset, first byte copied to dst+cb_dst_offset\n//   src - buffer to copy from\n//   src_size - total size of source buffer\n//   cb_src_offset - offset, first byte copied from src+cb_src_offset\n//   count - number of bytes to copy\n//\n// Returns:\n//    S_OK          - no error\n//    E_INVALIDARG  - values passed would lead to overrun\nHRESULT AMSafeMemMoveOffset(__in_bcount(dst_size) void *dst, __in size_t dst_size, __in DWORD cb_dst_offset,\n                            __in_bcount(src_size) const void *src, __in size_t src_size, __in DWORD cb_src_offset,\n                            __in size_t count);\n\nextern \"C\" void *__stdcall memmoveInternal(void *, const void *, size_t);\n\ninline void *__cdecl memchrInternal(const void *buf, int chr, size_t cnt)\n{\n#ifdef _X86_\n    void *pRet = NULL;\n\n    _asm {\n        cld // make sure we get the direction right\n        mov     ecx, cnt // num of bytes to scan\n        mov     edi, buf // pointer byte stream\n        mov     eax, chr // byte to scan for\n        repne   scasb // look for the byte in the byte stream\n        jnz     exit_memchr // Z flag set if byte found\n        dec     edi // scasb always increments edi even when it\n                            // finds the required byte\n        mov     pRet, edi\nexit_memchr:\n    }\n    return pRet;\n\n#else\n    while (cnt && (*(unsigned char *)buf != (unsigned char)chr))\n    {\n        buf = (unsigned char *)buf + 1;\n        cnt--;\n    }\n\n    return (cnt ? (void *)buf : NULL);\n#endif\n}\n\nvoid WINAPI IntToWstr(int i, __out_ecount(12) LPWSTR wstr);\n\n#define WstrToInt(sz) _wtoi(sz)\n#define atoiW(sz) _wtoi(sz)\n#define atoiA(sz) atoi(sz)\n\n// These are available to help managing bitmap VIDEOINFOHEADER media structures\n\nextern const DWORD bits555[3];\nextern const DWORD bits565[3];\nextern const DWORD bits888[3];\n\n// These help convert between VIDEOINFOHEADER and BITMAPINFO structures\n\nSTDAPI_(const GUID) GetTrueColorType(const BITMAPINFOHEADER *pbmiHeader);\nSTDAPI_(const GUID) GetBitmapSubtype(const BITMAPINFOHEADER *pbmiHeader);\nSTDAPI_(WORD) GetBitCount(const GUID *pSubtype);\n\n// strmbase.lib implements this for compatibility with people who\n// managed to link to this directly.  we don't want to advertise it.\n//\n// STDAPI_(/* T */ CHAR *) GetSubtypeName(const GUID *pSubtype);\n\nSTDAPI_(CHAR *) GetSubtypeNameA(const GUID *pSubtype);\nSTDAPI_(WCHAR *) GetSubtypeNameW(const GUID *pSubtype);\n\n#ifdef UNICODE\n#define GetSubtypeName GetSubtypeNameW\n#else\n#define GetSubtypeName GetSubtypeNameA\n#endif\n\nSTDAPI_(LONG) GetBitmapFormatSize(const BITMAPINFOHEADER *pHeader);\nSTDAPI_(DWORD) GetBitmapSize(const BITMAPINFOHEADER *pHeader);\n\n#ifdef __AMVIDEO__\nSTDAPI_(BOOL) ContainsPalette(const VIDEOINFOHEADER *pVideoInfo);\nSTDAPI_(const RGBQUAD *) GetBitmapPalette(const VIDEOINFOHEADER *pVideoInfo);\n#endif // __AMVIDEO__\n\n// Compares two interfaces and returns TRUE if they are on the same object\nBOOL WINAPI IsEqualObject(IUnknown *pFirst, IUnknown *pSecond);\n\n// This is for comparing pins\n#define EqualPins(pPin1, pPin2) IsEqualObject(pPin1, pPin2)\n\n// Arithmetic helper functions\n\n// Compute (a * b + rnd) / c\nLONGLONG WINAPI llMulDiv(LONGLONG a, LONGLONG b, LONGLONG c, LONGLONG rnd);\nLONGLONG WINAPI Int64x32Div32(LONGLONG a, LONG b, LONG c, LONG rnd);\n\n// Avoids us dyna-linking to SysAllocString to copy BSTR strings\nSTDAPI WriteBSTR(__deref_out BSTR *pstrDest, LPCWSTR szSrc);\nSTDAPI FreeBSTR(__deref_in BSTR *pstr);\n\n// Return a wide string - allocating memory for it\n// Returns:\n//    S_OK          - no error\n//    E_POINTER     - ppszReturn == NULL\n//    E_OUTOFMEMORY - can't allocate memory for returned string\nSTDAPI AMGetWideString(LPCWSTR pszString, __deref_out LPWSTR *ppszReturn);\n\n// Special wait for objects owning windows\nDWORD WINAPI WaitDispatchingMessages(HANDLE hObject, DWORD dwWait, HWND hwnd = NULL, UINT uMsg = 0,\n                                     HANDLE hEvent = NULL);\n\n// HRESULT_FROM_WIN32 converts ERROR_SUCCESS to a success code, but in\n// our use of HRESULT_FROM_WIN32, it typically means a function failed\n// to call SetLastError(), and we still want a failure code.\n//\n#define AmHresultFromWin32(x) (MAKE_HRESULT(SEVERITY_ERROR, FACILITY_WIN32, x))\n\n// call GetLastError and return an HRESULT value that will fail the\n// SUCCEEDED() macro.\nHRESULT AmGetLastErrorToHResult(void);\n\n// duplicate of ATL's CComPtr to avoid linker conflicts.\n\nIUnknown *QzAtlComPtrAssign(__deref_inout_opt IUnknown **pp, __in_opt IUnknown *lp);\n\ntemplate <class T> class QzCComPtr\n{\n  public:\n    typedef T _PtrClass;\n    QzCComPtr() { p = NULL; }\n    QzCComPtr(T *lp)\n    {\n        if ((p = lp) != NULL)\n            p->AddRef();\n    }\n    QzCComPtr(const QzCComPtr<T> &lp)\n    {\n        if ((p = lp.p) != NULL)\n            p->AddRef();\n    }\n    ~QzCComPtr()\n    {\n        if (p)\n            p->Release();\n    }\n    void Release()\n    {\n        if (p)\n            p->Release();\n        p = NULL;\n    }\n    operator T *() { return (T *)p; }\n    T &operator*()\n    {\n        ASSERT(p != NULL);\n        return *p;\n    }\n    // The assert on operator& usually indicates a bug.  If this is really\n    // what is needed, however, take the address of the p member explicitly.\n    T **operator&()\n    {\n        ASSERT(p == NULL);\n        return &p;\n    }\n    T *operator->()\n    {\n        ASSERT(p != NULL);\n        return p;\n    }\n    T *operator=(T *lp) { return (T *)QzAtlComPtrAssign((IUnknown **)&p, lp); }\n    T *operator=(const QzCComPtr<T> &lp) { return (T *)QzAtlComPtrAssign((IUnknown **)&p, lp.p); }\n#if _MSC_VER > 1020\n    bool operator!() { return (p == NULL); }\n#else\n    BOOL operator!() { return (p == NULL) ? TRUE : FALSE; }\n#endif\n    T *p;\n};\n\n#define CompatibleTimeSetEvent(uDelay, uResolution, lpTimeProc, dwUser, fuEvent) \\\n    timeSetEvent((uDelay), (uResolution), (lpTimeProc), (dwUser), (fuEvent) | TIME_KILL_SYNCHRONOUS)\n\n//  Helper to replace lstrcpmi\n__inline int lstrcmpiLocaleIndependentW(LPCWSTR lpsz1, LPCWSTR lpsz2)\n{\n    return CompareStringW(LOCALE_INVARIANT, NORM_IGNORECASE, lpsz1, -1, lpsz2, -1) - CSTR_EQUAL;\n}\n__inline int lstrcmpiLocaleIndependentA(LPCSTR lpsz1, LPCSTR lpsz2)\n{\n    return CompareStringA(LOCALE_INVARIANT, NORM_IGNORECASE, lpsz1, -1, lpsz2, -1) - CSTR_EQUAL;\n}\n\n#endif /* __WXUTIL__ */\n"
  },
  {
    "path": "common/common.props",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <LinkIncremental Condition=\"'$(EnableASAN)'=='true'\">false</LinkIncremental>\n    <LinkIncremental Condition=\"'$(EnableASAN)'=='false'\">true</LinkIncremental>\n    <OutDir>$(SolutionDir)bin_$(PlatformName)d\\lib\\</OutDir>\n    <IntDir>$(SolutionDir)bin_$(PlatformName)d\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n    <LinkIncremental>false</LinkIncremental>\n    <OutDir>$(SolutionDir)bin_$(PlatformName)\\lib\\</OutDir>\n    <IntDir>$(SolutionDir)bin_$(PlatformName)\\$(ProjectName)\\</IntDir>\n  </PropertyGroup>\n  <ItemDefinitionGroup>\n    <ClCompile>\n      <AdditionalIncludeDirectories>$(ProjectDir);$(SolutionDir)include;$(SolutionDir)common\\includes;$(SolutionDir)common\\baseclasses;$(SolutionDir)ffmpeg;$(SolutionDir)libbluray\\src;$(SolutionDir)common\\DSUtilLite;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n      <AdditionalOptions>/Zc:inline,referenceBinding,rvalueCast,throwingNew,ternary %(AdditionalOptions)</AdditionalOptions>\n      <WarningLevel>Level3</WarningLevel>\n      <PrecompiledHeader>Use</PrecompiledHeader>\n      <PrecompiledHeaderFile>stdafx.h</PrecompiledHeaderFile>\n      <LanguageStandard>stdcpp17</LanguageStandard>\n      <LanguageStandard_C>stdc11</LanguageStandard_C>\n    </ClCompile>\n    <Link>\n      <SubSystem>Windows</SubSystem>\n      <GenerateDebugInformation>true</GenerateDebugInformation>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <ClCompile>\n      <Optimization>Disabled</Optimization>\n      <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>\n      <DebugInformationFormat Condition=\"'$(EnableASAN)'=='true'\">ProgramDatabase</DebugInformationFormat>\n      <BasicRuntimeChecks Condition=\"'$(EnableASAN)'=='true'\">Default</BasicRuntimeChecks>\n    </ClCompile>\n    <Link>\n      <AdditionalLibraryDirectories>$(SolutionDir)bin_$(PlatformName)d\\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Release'\">\n    <ClCompile>\n      <AdditionalOptions>/Gw /Zo %(AdditionalOptions)</AdditionalOptions>\n      <Optimization>MaxSpeed</Optimization>\n      <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>\n      <OmitFramePointers>true</OmitFramePointers>\n      <FunctionLevelLinking>true</FunctionLevelLinking>\n      <IntrinsicFunctions>true</IntrinsicFunctions>\n      <MultiProcessorCompilation>true</MultiProcessorCompilation>\n      <RuntimeLibrary>MultiThreaded</RuntimeLibrary>\n    </ClCompile>\n    <Link>\n      <AdditionalOptions>/OPT:ICF=3 %(AdditionalOptions)</AdditionalOptions>\n      <OptimizeReferences>true</OptimizeReferences>\n      <SetChecksum>true</SetChecksum>\n      <AdditionalLibraryDirectories>$(SolutionDir)bin_$(PlatformName)\\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|Win32'\">\n    <ClCompile>\n      <EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>\n    </ClCompile>\n  </ItemDefinitionGroup>\n</Project>\n"
  },
  {
    "path": "common/genversion.bat",
    "content": "@ECHO OFF\nSETLOCAL\n\nPUSHD \"%~dp0\"\n\nSET nbMAJOR_PART=0\nSET nbCOMMIT_PART=0\nSET nbHASH_PART=00000\nSET OLDVER=\n\n:: check for git presence\nCALL git describe >NUL 2>&1\nIF ERRORLEVEL 1 (\n    GOTO NOGIT\n)\n\n:: Get git-describe output\nFOR /F \"tokens=*\" %%A IN ('\"git describe --long --abbrev=5 HEAD\"') DO (\n  SET strFILE_VERSION=%%A\n)\n\n:: Split into tag, nb commits, hash\nFOR /F \"tokens=1,2,3 delims=-\" %%A IN (\"%strFILE_VERSION%\") DO (\n  SET nbMAJOR_PART=%%A\n  SET nbCOMMIT_PART=%%B\n  SET nbHASH_PART=%%C\n)\n\n:: strip the \"g\" off the hash\nSET nbHASH_PART=%nbHASH_PART:~1%\n\n:WRITE_VER\n\n:: check if info changed, and write if needed\nIF EXIST includes\\version_rev.h (\n    SET /P OLDVER=<includes\\version_rev.h\n)\nSET NEWVER=#define LAV_VERSION_BUILD %nbCOMMIT_PART%\nIF NOT \"%NEWVER%\" == \"%OLDVER%\" (\n    :: swapped order to avoid trailing newlines\n    > includes\\version_rev.h ECHO %NEWVER%\n)\nGOTO :END\n\n:NOGIT\necho Git not found\ngoto WRITE_VER\n\n:END\nPOPD\nENDLOCAL\n"
  },
  {
    "path": "common/includes/ILAVPinInfo.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n// {FD220BF4-3F26-4AD4-A4A9-348C1273A141}\nDEFINE_GUID(IID_ILAVPinInfo, 0xfd220bf4, 0x3f26, 0x4ad4, 0xa4, 0xa9, 0x34, 0x8c, 0x12, 0x73, 0xa1, 0x41);\n\ninterface __declspec(uuid(\"FD220BF4-3F26-4AD4-A4A9-348C1273A141\")) ILAVPinInfo : public IUnknown\n{\n    // Get a set of flags that convey a special information for this kind of stream\n    STDMETHOD_(DWORD, GetStreamFlags)() PURE;\n#define LAV_STREAM_FLAG_ONLY_DTS 0x0000001 ///< Stream has only DTS timestamps (AVI, MKV in MS-Compat mode)\n#define LAV_STREAM_FLAG_RV34_MKV 0x0000002 ///< RV30/40 in MKV or similar container with horrible timstamps\n#define LAV_STREAM_FLAG_LIVE 0x0000004     ///< Stream is from a Live source\n\n    // Get the pixel format detected for this video stream\n    STDMETHOD_(int, GetPixelFormat)() PURE;\n\n    // Get the interface version\n    STDMETHOD_(int, GetVersion)() PURE;\n\n    // Get the number of B-Frames probed for this format\n    STDMETHOD_(int, GetHasBFrames)() PURE;\n};\n"
  },
  {
    "path": "common/includes/IMediaSideDataFFmpeg.h",
    "content": "/*\n*      Copyright (C) 2010-2021 Hendrik Leppkes\n*      http://www.1f0.de\n*\n*  This program is free software; you can redistribute it and/or modify\n*  it under the terms of the GNU General Public License as published by\n*  the Free Software Foundation; either version 2 of the License, or\n*  (at your option) any later version.\n*\n*  This program is distributed in the hope that it will be useful,\n*  but WITHOUT ANY WARRANTY; without even the implied warranty of\n*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n*  GNU General Public License for more details.\n*\n*  You should have received a copy of the GNU General Public License along\n*  with this program; if not, write to the Free Software Foundation, Inc.,\n*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n*\n*  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n*  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n*/\n\n#pragma once\n\n// {08CA03D5-1803-4FDC-8515-5B9DEC92437A}\nDEFINE_GUID(IID_MediaSideDataFFMpeg,\n  0x8ca03d5, 0x1803, 0x4fdc, 0x85, 0x15, 0x5b, 0x9d, 0xec, 0x92, 0x43, 0x7a);\n\nextern \"C\" {\n#include \"libavcodec/avcodec.h\"\n}\n\n#pragma pack(push, 1)\nstruct MediaSideDataFFMpeg\n{\n  AVPacketSideData *side_data;\n  int side_data_elems;\n};\n#pragma pack(pop)\n"
  },
  {
    "path": "common/includes/LAVSplitterSettingsInternal.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"LAVSplitterSettings.h\"\n#include <set>\n\nclass FormatInfo\n{\n  public:\n    FormatInfo() {}\n    FormatInfo(LPCSTR name, LPCSTR desc)\n        : strName(name)\n        , strDescription(desc)\n    {\n    }\n    LPCSTR strName = nullptr;\n    LPCSTR strDescription = nullptr;\n\n    // Comparison operators for sorting (NULL safe)\n    bool FormatInfo::operator<(const FormatInfo &rhs) const\n    {\n        return strName ? (rhs.strName ? _stricmp(strName, rhs.strName) < 0 : false) : true;\n    }\n    bool FormatInfo::operator>(const FormatInfo &rhs) const { return !(*this < rhs); }\n    bool FormatInfo::operator==(const FormatInfo &rhs) const\n    {\n        return (strName == rhs.strName) || (strName && rhs.strName && (_stricmp(strName, rhs.strName) == 0));\n    }\n};\n\n// GUID: 72b2c5fa-a7a5-4463-9c1b-9f4749c35c79\nDEFINE_GUID(IID_ILAVFSettingsInternal, 0x72b2c5fa, 0xa7a5, 0x4463, 0x9c, 0x1b, 0x9f, 0x47, 0x49, 0xc3, 0x5c, 0x79);\n\ninterface __declspec(uuid(\"72b2c5fa-a7a5-4463-9c1b-9f4749c35c79\")) ILAVFSettingsInternal : public ILAVFSettings\n{\n    // Query if the current filter graph requires VC1 Correction\n    STDMETHOD_(BOOL, IsVC1CorrectionRequired)() = 0;\n\n    STDMETHOD_(LPCSTR, GetInputFormat)() = 0;\n    STDMETHOD_(std::set<FormatInfo> &, GetInputFormats)() = 0;\n    STDMETHOD_(CMediaType *, GetOutputMediatype)(int stream) = 0;\n    STDMETHOD_(IFilterGraph *, GetFilterGraph)() = 0;\n};\n"
  },
  {
    "path": "common/includes/SubRenderIntf.h",
    "content": "// ***************************************************************\n//  SubRenderIntf.h           version: 1.0.9  -  date: 2015-10-10\n//  -------------------------------------------------------------\n//  Copyright (C) 2011-2015, BSD license\n// ***************************************************************\n\n// 2015-10-10 1.0.9 added some optional information fields\n// 2014-03-06 1.0.8 added ISubRenderConsumer2::Clear() interface/method\n// 2014-03-05 1.0.7 auto-loading is now the provider's own responsibility\n// 2013-07-01 1.0.6 added support for TV level subtitle transport\n// 2013-06-05 1.0.5 added support for BT.2020 matrix\n// 2012-12-04 1.0.4 changed auto-loading to supports multiple sub renderers\n// 2012-10-15 1.0.3 (1) added some comments about interface management\n//                  (2) added \"context\" parameter to \"Request/DeliverFrame\"\n// 2012-09-11 1.0.2 (1) modified \"yuvMatrix\" fields to match Aegisub (\"None\")\n//                  (2) added a clarification about LPWSTR property case\n// 2012-08-30 1.0.1 (1) added mandatory consumer field \"arAdjustedVideoSize\"\n//                  (2) added \"subtitle color correction\" info text\n//                  (3) added mandatory provider field \"yuvMatrix\"\n//                  (4) modified optional consumer field \"yuvMatrix\"\n// 2011-12-20 1.0.0 initial release\n\n// ---------------------------------------------------------------------------\n// introduction\n// ---------------------------------------------------------------------------\n\n// This header defines a set of interfaces which a subtitle renderer can\n// export to make its services available. The purpose of these interfaces is\n// to allow a more flexible communication between subtitle renderer and\n// subtitle consumer (e.g. video renderer) than DirectShow allows.\n\n// A typical DirectShow subtitle renderer using these interfaces would have\n// a subtitle input pin, but no video input pin and no output pins.\n\n// ---------------------------------------------------------------------------\n// basic interface principle\n// ---------------------------------------------------------------------------\n\n// (1) The subtitle consumer exports the interface \"ISubRenderConsumer\" and\n//     waits for a subtitle renderer to connect.\n\n// (2) The first time the graph is paused or started the subtitle renderer\n//     searches through the DirectShow graph and looks for filters which\n//     expose the \"ISubRenderConsumer\" interface.\n\n// (3) If there are multiple subtitle consumers in the graph, the subtitle\n//     renderer needs to decide which one to service. This should be done by\n//     picking the consumer with the highest merit. There's a \"GetMerit()\"\n//     method in the \"ISubRenderConsumer\" interface for this purpose.\n\n// (4) Once the subtitle renderer has found a consumer it wants to service,\n//     it calls \"ISubRenderConsumer.Connect()\", providing the consumer with\n//     the \"ISubRenderProvider\" interface, which allows the consumer to\n//     configure the subtitle renderer and to fetch rendered subtitles.\n\n// ---------------------------------------------------------------------------\n// subtitle color correction\n// ---------------------------------------------------------------------------\n\n// Today we have a number of different subtitle formats which define colors\n// in different color spaces. E.g. SRT subtitles are usually considered to be\n// native RGB, while DVD and Blu-Ray bitmap subtitles are native YCbCr.\n\n// The most difficult to handle format is ASS. ASS subtitle colors are defined\n// as RGB values. However, the historically most commonly used ASS renderer\n// (VSFilter) and the most commonly used ASS authoring software (Aegisub) both\n// render subtitles by drawing them directly onto the YCbCr video. Furthermore\n// up until very recently Aegisub always used to convert all videos to RGB by\n// using the BT.601 matrix. Practically that means that almost every ASS\n// subtitle file out there which is color matched to the video, requires\n// rendering in the same way, with hard coded BT.601 matrix, in order to ensure\n// that subtitle and video colors match exactly.\n\n// The subtitle interface defined in this header file passes subtitles from\n// the subtitle provider to the consumer in RGB format. Since some subtitle\n// formats are native YCbCr and due to the ASS color problem mentioned above,\n// it may be necessary to perform color correction to guarantee that the\n// rendered subtitle colors match perfectly to the video colors.\n\n// When rendering native YCbCr subtitles (DVD and Blu-Ray bitmap subtitles),\n// the subtitle renderer should try to use the correct YCbCr -> RGB matrix.\n// The subtitle renderer may either use the \"yuvMatrix\" information field\n// which the subtitle consumer may optionally provide. Or alternatively the\n// subtitle renderer can auto guess the correct matrix based on subtitle\n// resolution. The subtitle renderer informs the consumer about the matrix\n// that was used for subtitle YCbCr -> RGB conversion by setting the\n// \"yuvMatrix\" information field.\n\n// When rendering native RGB subtitles (e.g. SRT), the subtitle renderer\n// should render the subtitles untouched, and set the \"yuvMatrix\" information\n// field to \"None\".\n\n// When rendering ASS subtitles, the subtitle renderer should render the\n// subtitles in untouched RGB. If the ASS subtitle file has a \"yuvMatrix\"\n// header field, the subtitle renderer has to forward this field to the\n// subtitle consumer. If the ASS subtitle file does not have a \"yuvMatrix\"\n// header field, the subtitle renderer should set the \"yuvMatrix\" field to\n// \"TV.601\".\n\n// Subtitle consumers should read the subtitle renderer's \"yuvMatrix\" field.\n// If it is set to anything other than \"None\", the subtitle consumer should\n// double check whether the subtitle matrix matches the video matrix. If the\n// matrixes differ, the consumer should perform the necessary color correction\n// to make sure that subtitle and video colors match perfectly.\n\n// ---------------------------------------------------------------------------\n// subtitle levels\n// ---------------------------------------------------------------------------\n\n// Subtitles are by default transported as premultiplied RGBA pixels with\n// PC levels (black = 0; white = 255). All consumers and providers are\n// required to support this format.\n\n// Optionally, the consumer can signal (see \"supportedLevels\" info field)\n// that it supports TV levels, too. If it does (and only then), the provider\n// can optionally output subtitles in TV levels. If it does, it has to set\n// the info field \"outputLevels\" to \"TV\".\n\n// ---------------------------------------------------------------------------\n// subtitle repositioning\n// ---------------------------------------------------------------------------\n\n// In certain situations a user might have specific wishes for subtitle\n// positioning. E.g. a 4:3 TV owner may want to have subtitles rendered into\n// the big black bars on his TV, when watching 16:9 content. Or a CIH front\n// projection owner may want to have subtitles rendered into the active video\n// area instead of the black bars of the Cinemascope movie.\n\n// Now some subtitle sources (e.g. many fan made ASS subtitles for Anime) are\n// designed to be positioned very exactly. Other subtitle formats (e.g. SRT)\n// don't care about positioning at all. The consumer doesn't really know\n// which formats can be repostioned and which can't. So this interface allows\n// the consumer to express a wish for subtitle positioning. The subtitle\n// renderer can then decide whether it can (and wants to) honor this wish.\n\n// If the consumer wants subtitles to be moved, he sets \"subtitleTargetRect\"\n// to a different value (can be bigger or smaller) than \"videoOutputRect\".\n\n// Example 1: anamorphic 16:9 DVD playback, 4:3 computer monitor\n// consumer sets:\n// - displayModeSize,     1024x768\n// - originalVideoSize,   720x480\n// - arAdjustedVideoSize, 853x480\n// - videoOutputRect,     0x96x1024x672\n// - subtitleTargetRect,  0x0x1024x768                   <-  move request\n// subtitle renderer provides:\n// - ISubRender.GetVideoOutputRect() -> 0x0x720x480\n// - ISubRender.GetClipRect()        -> 0x-80x720x560    <-  request granted\n\n// Example 2: anamorphic 16:9 DVD playback, CIH front projection\n// consumer sets:\n// - displayModeSize,     1920x1080\n// - originalVideoSize,   720x480\n// - arAdjustedVideoSize, 853x480\n// - videoOutputRect,     0x0x1920x1080\n// - subtitleTargetRect,  0x140x1920x940                 <-  move request\n// subtitle renderer provides:\n// - ISubRender.GetVideoOutputRect() -> 0x0x720x480\n// - ISubRender.GetClipRect()        -> 0x62x720x418     <-  request granted\n\n// Example 3: reencoded Anime, ASS subtitles, CIH front projection\n// consumer sets:\n// - displayModeSize,     1920x1080\n// - originalVideoSize,   853x480\n// - arAdjustedVideoSize, 853x480\n// - videoOutputRect,     0x0x1920x1080\n// - subtitleTargetRect,  0x140x1920x940                 <-  move request\n// subtitle renderer provides:\n// - ISubRender.GetVideoOutputRect() -> 0x0x1920x1080\n// - ISubRender.GetClipRect()        -> 0x0x1920x1080    <-  request denied\n\n// ---------------------------------------------------------------------------\n\n#ifndef __SubtitleInterface__\n#define __SubtitleInterface__\n\ninterface ISubRenderConsumer;\ninterface ISubRenderProvider;\ninterface ISubRenderFrame;\n\n// ---------------------------------------------------------------------------\n// ISubRenderOptions\n// ---------------------------------------------------------------------------\n\n// Base interface for both ISubRenderConsumer and ISubRenderProvider.\n\n//[uuid(\"7CFD3728-235E-4430-9A2D-9F25F426BD70\")]\n//interface ISubRenderOptions : public IUnknown\nDECLARE_INTERFACE_IID_(ISubRenderOptions, IUnknown, \"7CFD3728-235E-4430-9A2D-9F25F426BD70\")\n{\n  // Allows one party to get information from the other party.\n  // The memory for strings and binary data is allocated by the callee\n  // by using LocalAlloc. It is the caller's responsibility to release the\n  // memory by calling LocalFree.\n  // Field names and LPWSTR values should be read case insensitive.\n  STDMETHOD(GetBool     )(LPCSTR field, bool      *value) = 0;\n  STDMETHOD(GetInt      )(LPCSTR field, int       *value) = 0;\n  STDMETHOD(GetSize     )(LPCSTR field, SIZE      *value) = 0;\n  STDMETHOD(GetRect     )(LPCSTR field, RECT      *value) = 0;\n  STDMETHOD(GetUlonglong)(LPCSTR field, ULONGLONG *value) = 0;\n  STDMETHOD(GetDouble   )(LPCSTR field, double    *value) = 0;\n  STDMETHOD(GetString   )(LPCSTR field, LPWSTR    *value, int *chars) = 0;\n  STDMETHOD(GetBin      )(LPCSTR field, LPVOID    *value, int *size ) = 0;\n\n  // Allows one party to configure or send information to the other party.\n  // The callee should copy the strings/binary data, if needed.\n  // Field names and LPWSTR values should be set with the exact case listed\n  // in this header (just to be safe).\n  STDMETHOD(SetBool     )(LPCSTR field, bool      value) = 0;\n  STDMETHOD(SetInt      )(LPCSTR field, int       value) = 0;\n  STDMETHOD(SetSize     )(LPCSTR field, SIZE      value) = 0;\n  STDMETHOD(SetRect     )(LPCSTR field, RECT      value) = 0;\n  STDMETHOD(SetUlonglong)(LPCSTR field, ULONGLONG value) = 0;\n  STDMETHOD(SetDouble   )(LPCSTR field, double    value) = 0;\n  STDMETHOD(SetString   )(LPCSTR field, LPWSTR    value, int chars) = 0;\n  STDMETHOD(SetBin      )(LPCSTR field, LPVOID    value, int size ) = 0;\n\n  // \"field\" must be zero terminated\n\n  // mandatory fields for consumers:\n  // \"name\",                 LPWSTR,    info,   read only,  get name / description of the consumer\n  // \"version\",              LPWSTR,    info,   read only,  get version number of the consumer\n  // \"originalVideoSize\",    SIZE,      info,   read only,  size of the video before scaling and AR adjustments\n  // \"arAdjustedVideoSize\",  SIZE,      info,   read only,  size of the video after AR adjustments\n  // \"videoOutputRect\",      RECT,      info,   read only,  final pos/size of the video after all scaling operations\n  // \"subtitleTargetRect\",   RECT,      info,   read only,  consumer wish for where to place the subtitles\n  // \"frameRate\",            ULONGLONG, info,   read only,  frame rate of the video after deinterlacing (REFERENCE_TIME)\n  // \"refreshRate\",          double,    info,   read only,  display refresh rate (0, if unknown)\n\n  // mandatory fields for providers:\n  // \"name\",                 LPWSTR,    info,   read only,  get name / description of the provider\n  // \"version\",              LPWSTR,    info,   read only,  get version number of the provider\n  // \"yuvMatrix\",            LPWSTR,    info,   read only,  RGB Subtitles: \"None\" (fullrange); YCbCr Subtitles: \"Levels.Matrix\", Levels: TV|PC, Matrix: 601|709|240M|FCC|2020\n  // \"combineBitmaps\",       bool,      option, write/read, must the provider combine all bitmaps into one? (default: false)\n\n  // optional fields for consumers:\n  // \"videoCropRect\",        RECT,      info,   read only,  crops \"originalVideoSize\" down, e.g. because of detected black bars\n  // \"croppedVideoOutputRect\", RECT,    info,   read only,  final pos/size of the \"videoCropRect\", after all scaling operations\n  // \"fullscreenRect\",       RECT,      info,   read only,  for fullscreen drawing, this is the rect you want to stay in (left/top can be non-zero!)\n  // \"displayModeSize\",      SIZE,      info,   read only,  display mode width/height\n  // \"yuvMatrix\",            LPWSTR,    info,   read only,  RGB Video: \"None\" (fullrange); YCbCr Video: \"Levels.Matrix\", Levels: TV|PC, Matrix: 601|709|240M|FCC|2020\n  // \"supportedLevels\",      int,       info,   read only,  0: PC only (default); 1: PC+TV, no preference; 2: PC+TV, PC preferred; 3: PC+TV, TV preferred\n\n  // optional fields for providers:\n  // \"outputLevels\",         LPWSTR,    info,   read only,  are subtitles rendered/output in RGB \"PC\" (default) or \"TV\" levels?\n  // \"isBitmap\",             bool,      info,   read only,  are the subtitles bitmap based or text based?\n  // \"isMovable\",            bool,      info,   read only,  can the subtitles be repositioned safely?\n};\n\n// ---------------------------------------------------------------------------\n// ISubRenderConsumer\n// ---------------------------------------------------------------------------\n\n// This interface is exposed by every subtitle consumer.\n\n//[uuid(\"9DF90966-FE9F-4F0E-881E-DAF8A572D900\")]\n//interface ISubRenderConsumer : public ISubRenderOptions\nDECLARE_INTERFACE_IID_(ISubRenderConsumer, ISubRenderOptions, \"9DF90966-FE9F-4F0E-881E-DAF8A572D900\")\n{\n  // Called by the subtitle renderer to ask the merit of the consumer.\n  // Recommended merits:\n  // - Subtitle Manager     0x00080000\n  // - Video Renderer       0x00040000\n  // - Video Post Processor 0x00020000\n  // - Video Decoder        0x00010000\n  STDMETHOD(GetMerit)(ULONG *merit) = 0;\n\n  // Called by the subtitle renderer to init the provider <-> consumer\n  // connection. The subtitle renderer provides an \"ISubRenderProvider\"\n  // interface for the consumer to store and use. The consumer should\n  // call \"AddRef()\" to make sure that the interface instance stays alive\n  // as long as needed.\n  STDMETHOD(Connect)(ISubRenderProvider *subtitleRenderer) = 0;\n\n  // Called by the subtitle renderer to close the connection. The\n  // consumer should react by immediately \"Release()\"ing the stored\n  // \"ISubRenderProvider\" instance.\n  STDMETHOD(Disconnect)(void) = 0;\n\n  // Called by the subtitle renderer to deliver a rendered subtitle frame\n  // to the consumer. The renderer may only deliver frames which were\n  // requested before by the consumer.\n  // The frames will be delivered in the same order as they were requested.\n  // The deliverance can occur in different threads than the request, though.\n  // The subtitle renderer can deliver a \"NULL\" subtitle frame to indicate\n  // that the specified frame has no visible subtitles. The subtitle renderer\n  // can also reuse the same \"ISubRenderFrame\" instance for multiple video\n  // frames, if the subtitles didn't change.\n  // The consumer should \"AddRef()\" the \"ISubRenderFrame\", if the consumer\n  // wants to use it after returning from \"DeliverFrame()\". If the consumer\n  // does that, it also needs to call \"Release()\" later when the\n  // \"ISubRenderFrame\" instance is no longer needed.\n  // The subtitle renderer should not require the \"ISubRenderFrame\" instance\n  // to be released immediately. The consumer may store it for buffering/queue\n  // purposes. All properties of the \"ISubRenderFrame\" instance must return\n  // the correct results until it is released by the consumer.\n  STDMETHOD(DeliverFrame)(REFERENCE_TIME start, REFERENCE_TIME stop, LPVOID context, ISubRenderFrame *subtitleFrame) = 0;\n};\n\n//[uuid(\"1A1737C8-2BF8-4BEA-97EA-3AB4FA8F7AC9\")]\n//interface ISubRenderConsumer2 : public ISubRenderConsumer\nDECLARE_INTERFACE_IID_(ISubRenderConsumer2, ISubRenderConsumer, \"1A1737C8-2BF8-4BEA-97EA-3AB4FA8F7AC9\")\n{\n  // Called by the subtitle renderer e.g. when the user switches to a\n  // different subtitle track. The consumer should immediately release\n  // all stored subtitle frames and request them anew from the subtitle\n  // renderer.\n  STDMETHOD(Clear)(REFERENCE_TIME clearNewerThan = 0) = 0;\n};\n\n// ---------------------------------------------------------------------------\n// ISubRenderProvider\n// ---------------------------------------------------------------------------\n\n// The subtitle renderer provides the consumer with this interface, when\n// calling the \"ISubRenderConsumer.Connect()\" method.\n\n//[uuid(\"20752113-C883-455A-BA7B-ABA4E9115CA8\")]\n//interface ISubRenderProvider : public ISubRenderOptions\nDECLARE_INTERFACE_IID_(ISubRenderProvider, ISubRenderOptions, \"20752113-C883-455A-BA7B-ABA4E9115CA8\")\n{\n  // Called by the consumer to request a rendered subtitle frame.\n  // The subtitle renderer will deliver the frame when it is completed, by\n  // calling \"ISubRenderConsumer.DeliverFrame()\".\n  // The subtitle renderer must pass the \"context\" parameter to the\n  // consumer when calling \"DeliverFrame()\".\n  // Depending on the internal thread design of the subtitle renderer,\n  // \"RequestFrame()\" can return at once, with delivery being performed\n  // asynchronously in a different thread. Alternatively, \"RequestFrame()\"\n  // may also block until the frame was delivered. The consumer should not\n  // depend on either threading model, but leave this decision to the\n  // subtitle renderer.\n  STDMETHOD(RequestFrame)(REFERENCE_TIME start, REFERENCE_TIME stop, LPVOID context) = 0;\n\n  // Called by the consumer to close the connection. The subtitle renderer\n  // should react by immediately \"Release()\"ing any stored\n  // \"ISubRenderConsumer\" interface instances pointing to this specific\n  // consumer.\n  STDMETHOD(Disconnect)(void) = 0;\n};\n\n// ---------------------------------------------------------------------------\n// ISubRenderFrame\n// ---------------------------------------------------------------------------\n\n// This interface is the reply to a consumer's frame render request.\n\n//[uuid(\"81746AB5-9407-4B43-A014-1FAAC340F973\")]\n//interface ISubRenderFrame : public IUnknown\nDECLARE_INTERFACE_IID_(ISubRenderFrame, IUnknown, \"81746AB5-9407-4B43-A014-1FAAC340F973\")\n{\n  // \"GetOutputRect()\" specifies for which video rect the subtitles were\n  // rendered. If the subtitle renderer doesn't scale the subtitles at all,\n  // which is the recommended method for bitmap (DVD/PGS) subtitles formats,\n  // GetOutputRect() should return \"0, 0, originalVideoSize\". If the subtitle\n  // renderer scales the subtitles, which is the recommend method for text\n  // (SRT, ASS) subtitle formats, GetOutputRect() should aim to match the\n  // consumer's \"videoOutputRect\". In any case, the consumer can look at\n  // GetOutputRect() to see if (and how) the rendered subtitles need to be\n  // scaled before blending them onto the video image.\n  STDMETHOD(GetOutputRect)(RECT *outputRect) = 0;\n\n  // \"GetClipRect()\" specifies how the consumer should clip the rendered\n  // subtitles, before blending them onto the video image. Usually,\n  // GetClipRect() should be identical to \"GetVideoOutputRect()\", unless the\n  // subtitle renderer repositioned the subtitles (see the top of this header\n  // for more information about repositioning).\n  STDMETHOD(GetClipRect)(RECT *clipRect) = 0;\n\n  // How many separate bitmaps does this subtitle frame consist of?\n  // The subtitle renderer should combine small subtitle elements which are\n  // positioned near to each other, in order to optimize performance.\n  // Ideally, if there are e.g. two subtitle lines, one at the top and one\n  // at the bottom of the frame, the subtitle renderer should output two\n  // bitmaps per frame.\n  STDMETHOD(GetBitmapCount)(int *count) = 0;\n\n  // Returns the premultiplied RGBA pixel data for the specified bitmap.\n  // The ID is guaranteed to change if the content of the bitmap has changed.\n  // The ID can stay identical if only the position changes.\n  // Reusing the same ID for unchanged bitmaps can improve performance.\n  // Subtitle bitmaps may move in and out of the video frame rectangle, so\n  // the position of the subtitle bitmaps can become negative. The consumer\n  // is required to do proper clipping if the subtitle bitmap is partially\n  // outside the video rectangle.\n  // The memory pointed to by \"pixels\" is only valid until the next\n  // \"GetBitmap\" call, or until the \"ISubRenderFrame\" instance is released.\n  STDMETHOD(GetBitmap)(int index, ULONGLONG *id, POINT *position, SIZE *size, LPCVOID *pixels, int *pitch) = 0;\n};\n\n// ===========================================================================\n\n#endif // __SubtitelInterface__\n"
  },
  {
    "path": "common/includes/common_defines.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n// Set minimal target OS (Vista+)\n#ifdef _WIN32_WINNT\n#undef _WIN32_WINNT\n#endif\n#define _WIN32_WINNT 0x0600\n#ifdef WINVER\n#undef WINVER\n#endif\n#define WINVER _WIN32_WINNT\n\n#define WIN32_LEAN_AND_MEAN\n#define VC_EXTRALEAN\n\n#define LAV_AUDIO \"LAV Audio Decoder\"\n#define LAV_VIDEO \"LAV Video Decoder\"\n#define LAV_SPLITTER \"LAV Splitter\"\n"
  },
  {
    "path": "common/includes/moreuuids.h",
    "content": "/*\n *      Copyright (C) 2003-2006 Gabest\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Note: This interface was defined for the matroska container format\n *  originally, but can be implemented for other formats as well.\n */\n\n#pragma once\n\n#include <dvdmedia.h>\n#include <dmodshow.h>\n#include <ks.h>\n#include <ksmedia.h>\n#include <MMReg.h>\n#include <wmcodecdsp.h>\n\n#define WAVE_FORMAT_DOLBY_AC3 0x2000\n// {00002000-0000-0010-8000-00aa00389b71}\nDEFINE_GUID(MEDIASUBTYPE_WAVE_DOLBY_AC3, WAVE_FORMAT_DOLBY_AC3, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38,\n            0x9b, 0x71);\n\n#define WAVE_FORMAT_DVD_DTS 0x2001\n// {00002001-0000-0010-8000-00aa00389b71}\nDEFINE_GUID(MEDIASUBTYPE_WAVE_DTS, WAVE_FORMAT_DVD_DTS, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// Be compatible with 3ivx\n#define WAVE_FORMAT_AAC 0x00FF\n// {000000FF-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_AAC, WAVE_FORMAT_AAC, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_LATM_AAC 0x01FF\n// {000001FF-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_LATM_AAC, WAVE_FORMAT_LATM_AAC, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b,\n            0x71);\n\n// ... and also compatible with nero\n// btw, older nero parsers use a lower-case fourcc, newer upper-case (why can't it just offer both?)\n// {4134504D-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_MP4A, 0x4134504D, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// {6134706D-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_mp4a, 0x6134706D, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_MP3 0x0055\n// 00000055-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MP3, WAVE_FORMAT_MP3, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_FLAC 0xF1AC\n// 0000F1AC-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_FLAC, WAVE_FORMAT_FLAC, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// {1541C5C0-CDDF-477d-BC0A-86F8AE7F8354}\nDEFINE_GUID(MEDIASUBTYPE_FLAC_FRAMED, 0x1541c5c0, 0xcddf, 0x477d, 0xbc, 0xa, 0x86, 0xf8, 0xae, 0x7f, 0x83, 0x54);\n\n#define WAVE_FORMAT_TTA1 0x77A1\n// {000077A1-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_TTA1, WAVE_FORMAT_TTA1, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_WAVPACK4 0x5756\n// {00005756-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_WAVPACK4, WAVE_FORMAT_WAVPACK4, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_AMR, 0x000000FE, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n// {726D6173-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_SAMR, 0x726D6173, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_VP70, 0x30375056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_VP80, 0x30385056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_VP90, 0x30395056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_AV01, 0x31305641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_IMA4, 0x34616D69, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n// {34616D69-0000-0010-8000-00AA00389B71}\n\nDEFINE_GUID(MEDIASUBTYPE_SAWB, 0x62776173, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// {DA5B82EE-6BD2-426f-BF1E-30112DA78AE1}\nDEFINE_GUID(MEDIASUBTYPE_SVCD_SUBPICTURE, 0xda5b82ee, 0x6bd2, 0x426f, 0xbf, 0x1e, 0x30, 0x11, 0x2d, 0xa7, 0x8a, 0xe1);\n\n// {7B57308F-5154-4c36-B903-52FE76E184FC}\nDEFINE_GUID(MEDIASUBTYPE_CVD_SUBPICTURE, 0x7b57308f, 0x5154, 0x4c36, 0xb9, 0x3, 0x52, 0xfe, 0x76, 0xe1, 0x84, 0xfc);\n\n// {0E3A2342-F6E2-4c91-BDAE-87C71EAD0D63}\nDEFINE_GUID(MEDIASUBTYPE_MPEG2_PVA, 0xe3a2342, 0xf6e2, 0x4c91, 0xbd, 0xae, 0x87, 0xc7, 0x1e, 0xad, 0xd, 0x63);\n\n// {6B6D0800-9ADA-11d0-A520-00A0D10129C0}\nDEFINE_GUID(CLSID_NetShowSource, 0x6b6d0800, 0x9ada, 0x11d0, 0xa5, 0x20, 0x0, 0xa0, 0xd1, 0x1, 0x29, 0xc0);\n\n// DirectShowMedia\n\n// {5E9C9EE0-2E4A-4f22-9906-7BBBB75AA2B6}\nDEFINE_GUID(MEDIASUBTYPE_DirectShowMedia, 0x5e9c9ee0, 0x2e4a, 0x4f22, 0x99, 0x6, 0x7b, 0xbb, 0xb7, 0x5a, 0xa2, 0xb6);\n\n// Dirac\n\n// {A29DA00F-A22B-40ea-98DE-2F7FECADA5DE}\nDEFINE_GUID(MEDIASUBTYPE_Dirac, 0xa29da00f, 0xa22b, 0x40ea, 0x98, 0xde, 0x2f, 0x7f, 0xec, 0xad, 0xa5, 0xde);\n\n// {64726376-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_DiracVideo, 0x64726376, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// {D2667A7E-4055-4244-A65F-DDDDF2B74BD7}\nDEFINE_GUID(FORMAT_DiracVideoInfo, 0xd2667a7e, 0x4055, 0x4244, 0xa6, 0x5f, 0xdd, 0xdd, 0xf2, 0xb7, 0x4b, 0xd7);\n\n// {63617264-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_DRAC, 0x63617264, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nstruct DIRACINFOHEADER\n{\n    VIDEOINFOHEADER2 hdr;\n    DWORD cbSequenceHeader;\n    DWORD dwSequenceHeader[1];\n};\n\n// MP4\n\n// {08E22ADA-B715-45ed-9D20-7B87750301D4}\nDEFINE_GUID(MEDIASUBTYPE_MP4, 0x8e22ada, 0xb715, 0x45ed, 0x9d, 0x20, 0x7b, 0x87, 0x75, 0x3, 0x1, 0xd4);\n\n// FLV\n\n// {F2FAC0F1-3852-4670-AAC0-9051D400AC54}\nDEFINE_GUID(MEDIASUBTYPE_FLV, 0xf2fac0f1, 0x3852, 0x4670, 0xaa, 0xc0, 0x90, 0x51, 0xd4, 0x0, 0xac, 0x54);\n\n// 31564C46-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_FLV1, 0x31564C46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31766C66-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_flv1, 0x31766C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34564C46-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_FLV4, 0x34564C46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34766C66-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_flv4, 0x34766C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30355056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP50, 0x30355056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30357076-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_vp50, 0x30357076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30365056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP60, 0x30365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30367076-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_vp60, 0x30367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31365056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP61, 0x31365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31367076-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_vp61, 0x31367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32365056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP62, 0x32365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32367076-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_vp62, 0x32367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 41365056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP6A, 0x41365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 61367076-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_vp6a, 0x61367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 46365056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP6F, 0x46365056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 66367076-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_vp6f, 0x66367076, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n//\n// RealMedia\n//\n\nenum\n{\n    WAVE_FORMAT_14_4 = 0x2002,\n    WAVE_FORMAT_28_8 = 0x2003,\n    WAVE_FORMAT_ATRC = 0x0270, // WAVE_FORMAT_SONY_SCX,\n    WAVE_FORMAT_COOK = 0x2004,\n    WAVE_FORMAT_DNET = 0x2005,\n    WAVE_FORMAT_RAAC = 0x2006,\n    WAVE_FORMAT_RACP = 0x2007,\n    WAVE_FORMAT_SIPR = 0x0130, // WAVE_FORMAT_SIPROLAB_ACEPLNET,\n};\n\n// {57428EC6-C2B2-44a2-AA9C-28F0B6A5C48E}\nDEFINE_GUID(MEDIASUBTYPE_RealMedia, 0x57428ec6, 0xc2b2, 0x44a2, 0xaa, 0x9c, 0x28, 0xf0, 0xb6, 0xa5, 0xc4, 0x8e);\n\n// 30315652-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RV10, 0x30315652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30325652-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RV20, 0x30325652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30335652-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RV30, 0x30335652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30345652-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RV40, 0x30345652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31345652-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RV41, 0x31345652, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 345f3431-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_14_4, 0x345f3431, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 385f3832-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_28_8, 0x385f3832, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 4b4f4f43-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_COOK, 0x4b4f4f43, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 54454e44-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DNET, 0x54454e44, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 52504953-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SIPR, 0x52504953, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 00000130-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SIPR_WAVE, WAVE_FORMAT_SIPR, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 43414152-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RAAC, 0x43414152, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 50434152-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RACP, 0x50434152, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n#define WAVE_FORMAT_RALF mmioFOURCC('R', 'A', 'L', 'F')\nDEFINE_GUID(MEDIASUBTYPE_RALF, WAVE_FORMAT_RALF, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// QuickTime PCM\n\n// 454E4F4E-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_PCM_NONE, 0x454E4F4E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 20776172-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_PCM_RAW, 0x20776172, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 736f7774-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_PCM_TWOS, 0x736f7774, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 74776f73-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_PCM_SOWT, 0x74776f73, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34326E69-0000-0010-8000-00AA00389B71 (big-endian int24)\nDEFINE_GUID(MEDIASUBTYPE_PCM_IN24, 0x34326E69, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32336E69-0000-0010-8000-00AA00389B71 (big-endian int32)\nDEFINE_GUID(MEDIASUBTYPE_PCM_IN32, 0x32336E69, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32336C66-0000-0010-8000-00AA00389B71 (big-endian float32)\nDEFINE_GUID(MEDIASUBTYPE_PCM_FL32, 0x32336C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34366C66-0000-0010-8000-00AA00389B71 (big-endian float64)\nDEFINE_GUID(MEDIASUBTYPE_PCM_FL64, 0x34366C66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// Reverse GUIDs for little-endian 'in24', 'in32', 'fl32', 'fl64'\n// 696E3234-0000-0010-8000-00AA00389B71 (little-endian int24, reverse 'in24')\nDEFINE_GUID(MEDIASUBTYPE_PCM_IN24_le, 0x696E3234, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n// 696E3332-0000-0010-8000-00AA00389B71 (little-endian int32, reverse 'in32')\nDEFINE_GUID(MEDIASUBTYPE_PCM_IN32_le, 0x696E3332, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n// 666C3332-0000-0010-8000-00AA00389B71 (little-endian float32, reverse 'fl32')\nDEFINE_GUID(MEDIASUBTYPE_PCM_FL32_le, 0x666C3332, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n// 666C3634-0000-0010-8000-00AA00389B71 (little-endian float64, reverse 'fl64')\nDEFINE_GUID(MEDIASUBTYPE_PCM_FL64_le, 0x666C3634, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n//\n// PS2\n//\n\n#define WAVE_FORMAT_PS2_PCM 0xF521\n// 0000F521-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_PS2_PCM, WAVE_FORMAT_PS2_PCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_PS2_ADPCM 0xF522\n// 0000F522-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_PS2_ADPCM, WAVE_FORMAT_PS2_ADPCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b,\n            0x71);\n\nstruct WAVEFORMATEXPS2 : public WAVEFORMATEX\n{\n    DWORD dwInterleave;\n\n    struct WAVEFORMATEXPS2()\n    {\n        memset(this, 0, sizeof(*this));\n        cbSize = sizeof(WAVEFORMATEXPS2) - sizeof(WAVEFORMATEX);\n    }\n};\n\n// {4F3D3D21-6D7C-4f73-AA05-E397B5EAE0AA}\nDEFINE_GUID(MEDIASUBTYPE_PS2_SUB, 0x4f3d3d21, 0x6d7c, 0x4f73, 0xaa, 0x5, 0xe3, 0x97, 0xb5, 0xea, 0xe0, 0xaa);\n\n// ATRAC\n\n// 43525441-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ATRC, 0x43525441, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 00000270-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ATRAC3, WAVE_FORMAT_SONY_SCX, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n#define WAVE_FORMAT_ATRAC3P 0xE923AABF\n// E923AABF-CB58-4471-A119-FFFA01E4CE62\nDEFINE_GUID(MEDIASUBTYPE_ATRAC3P, 0xE923AABF, 0xCB58, 0x4471, 0xA1, 0x19, 0xFF, 0xFA, 0x01, 0xE4, 0xCE, 0x62);\n\n// Haali's video renderer\n\n// {760A8F35-97E7-479d-AAF5-DA9EFF95D751}\nDEFINE_GUID(CLSID_DXR, 0x760a8f35, 0x97e7, 0x479d, 0xaa, 0xf5, 0xda, 0x9e, 0xff, 0x95, 0xd7, 0x51);\n\nDEFINE_GUID(CLSID_madVR, 0xe1a8b82a, 0x32ce, 0x4b0d, 0xbe, 0x0d, 0xaa, 0x68, 0xc7, 0x72, 0xe4, 0x23);\n\nDEFINE_GUID(CLSID_JRVR, 0x555E6803, 0x14EF, 0x4946, 0x86, 0x46, 0xB6, 0xEF, 0x9E, 0x91, 0x21, 0xE2);\n\n//\n// Ogg\n//\n\n// 9FF48807-E133-40AA-826F-9B2959E5232D\nDEFINE_GUID(CLSID_MPCHCOggSplitter, 0x9FF48807, 0xE133, 0x40AA, 0x82, 0x6F, 0x9B, 0x29, 0x59, 0xE5, 0x23, 0x2D);\n\n// 6D3688CE-3E9D-42F4-92CA-8A11119D25CD\nDEFINE_GUID(CLSID_MPCHCOggSource, 0x6D3688CE, 0x3E9D, 0x42F4, 0x92, 0xCA, 0x8A, 0x11, 0x11, 0x9D, 0x25, 0xCD);\n\n// f07e245f-5a1f-4d1e-8bff-dc31d84a55ab\nDEFINE_GUID(CLSID_OggSplitter, 0xf07e245f, 0x5a1f, 0x4d1e, 0x8b, 0xff, 0xdc, 0x31, 0xd8, 0x4a, 0x55, 0xab);\n\n// {078C3DAA-9E58-4d42-9E1C-7C8EE79539C5}\nDEFINE_GUID(CLSID_OggSplitPropPage, 0x78c3daa, 0x9e58, 0x4d42, 0x9e, 0x1c, 0x7c, 0x8e, 0xe7, 0x95, 0x39, 0xc5);\n\n// 8cae96b7-85b1-4605-b23c-17ff5262b296\nDEFINE_GUID(CLSID_OggMux, 0x8cae96b7, 0x85b1, 0x4605, 0xb2, 0x3c, 0x17, 0xff, 0x52, 0x62, 0xb2, 0x96);\n\n// {AB97AFC3-D08E-4e2d-98E0-AEE6D4634BA4}\nDEFINE_GUID(CLSID_OggMuxPropPage, 0xab97afc3, 0xd08e, 0x4e2d, 0x98, 0xe0, 0xae, 0xe6, 0xd4, 0x63, 0x4b, 0xa4);\n\n// {889EF574-0656-4B52-9091-072E52BB1B80}\nDEFINE_GUID(CLSID_VorbisEnc, 0x889ef574, 0x0656, 0x4b52, 0x90, 0x91, 0x07, 0x2e, 0x52, 0xbb, 0x1b, 0x80);\n\n// {c5379125-fd36-4277-a7cd-fab469ef3a2f}\nDEFINE_GUID(CLSID_VorbisEncPropPage, 0xc5379125, 0xfd36, 0x4277, 0xa7, 0xcd, 0xfa, 0xb4, 0x69, 0xef, 0x3a, 0x2f);\n\n// 02391f44-2767-4e6a-a484-9b47b506f3a4\nDEFINE_GUID(CLSID_VorbisDec, 0x02391f44, 0x2767, 0x4e6a, 0xa4, 0x84, 0x9b, 0x47, 0xb5, 0x06, 0xf3, 0xa4);\n\n// 77983549-ffda-4a88-b48f-b924e8d1f01c\nDEFINE_GUID(CLSID_OggDSAboutPage, 0x77983549, 0xffda, 0x4a88, 0xb4, 0x8f, 0xb9, 0x24, 0xe8, 0xd1, 0xf0, 0x1c);\n\n// {D2855FA9-61A7-4db0-B979-71F297C17A04}\nDEFINE_GUID(MEDIASUBTYPE_Ogg, 0xd2855fa9, 0x61a7, 0x4db0, 0xb9, 0x79, 0x71, 0xf2, 0x97, 0xc1, 0x7a, 0x4);\n\n// cddca2d5-6d75-4f98-840e-737bedd5c63b\nDEFINE_GUID(MEDIASUBTYPE_Vorbis, 0xcddca2d5, 0x6d75, 0x4f98, 0x84, 0x0e, 0x73, 0x7b, 0xed, 0xd5, 0xc6, 0x3b);\n\n// 6bddfa7e-9f22-46a9-ab5e-884eff294d9f\nDEFINE_GUID(FORMAT_VorbisFormat, 0x6bddfa7e, 0x9f22, 0x46a9, 0xab, 0x5e, 0x88, 0x4e, 0xff, 0x29, 0x4d, 0x9f);\n\ntypedef struct tagVORBISFORMAT\n{\n    WORD nChannels;\n    DWORD nSamplesPerSec;\n    DWORD nMinBitsPerSec;\n    DWORD nAvgBitsPerSec;\n    DWORD nMaxBitsPerSec;\n    float fQuality;\n} VORBISFORMAT, *PVORBISFORMAT, FAR *LPVORBISFORMAT;\n\n// {8D2FD10B-5841-4a6b-8905-588FEC1ADED9}\nDEFINE_GUID(MEDIASUBTYPE_Vorbis2, 0x8d2fd10b, 0x5841, 0x4a6b, 0x89, 0x5, 0x58, 0x8f, 0xec, 0x1a, 0xde, 0xd9);\n\n// {B36E107F-A938-4387-93C7-55E966757473}\nDEFINE_GUID(FORMAT_VorbisFormat2, 0xb36e107f, 0xa938, 0x4387, 0x93, 0xc7, 0x55, 0xe9, 0x66, 0x75, 0x74, 0x73);\n\ntypedef struct tagVORBISFORMAT2\n{\n    DWORD Channels;\n    DWORD SamplesPerSec;\n    DWORD BitsPerSample;\n    DWORD HeaderSize[3]; // 0: Identification, 1: Comment, 2: Setup\n} VORBISFORMAT2, *PVORBISFORMAT2, FAR *LPVORBISFORMAT2;\n\n//\n// Matroska\n//\n\n// {1AC0BEBD-4D2B-45ad-BCEB-F2C41C5E3788}\nDEFINE_GUID(MEDIASUBTYPE_Matroska, 0x1ac0bebd, 0x4d2b, 0x45ad, 0xbc, 0xeb, 0xf2, 0xc4, 0x1c, 0x5e, 0x37, 0x88);\n\n// {E487EB08-6B26-4be9-9DD3-993434D313FD}\nDEFINE_GUID(MEDIATYPE_Subtitle, 0xe487eb08, 0x6b26, 0x4be9, 0x9d, 0xd3, 0x99, 0x34, 0x34, 0xd3, 0x13, 0xfd);\n\n// {87C0B230-03A8-4fdf-8010-B27A5848200D}\nDEFINE_GUID(MEDIASUBTYPE_UTF8, 0x87c0b230, 0x3a8, 0x4fdf, 0x80, 0x10, 0xb2, 0x7a, 0x58, 0x48, 0x20, 0xd);\n\n// {3020560F-255A-4ddc-806E-6C5CC6DCD70A}\nDEFINE_GUID(MEDIASUBTYPE_SSA, 0x3020560f, 0x255a, 0x4ddc, 0x80, 0x6e, 0x6c, 0x5c, 0xc6, 0xdc, 0xd7, 0xa);\n\n// {326444F7-686F-47ff-A4B2-C8C96307B4C2}\nDEFINE_GUID(MEDIASUBTYPE_ASS, 0x326444f7, 0x686f, 0x47ff, 0xa4, 0xb2, 0xc8, 0xc9, 0x63, 0x7, 0xb4, 0xc2);\n\n// {370689E7-B226-4f67-978D-F10BC1A9C6AE}\nDEFINE_GUID(MEDIASUBTYPE_ASS2, 0x370689e7, 0xb226, 0x4f67, 0x97, 0x8d, 0xf1, 0xb, 0xc1, 0xa9, 0xc6, 0xae);\n\n// {76C421C4-DB89-42ec-936E-A9FBC1794714}\nDEFINE_GUID(MEDIASUBTYPE_SSF, 0x76c421c4, 0xdb89, 0x42ec, 0x93, 0x6e, 0xa9, 0xfb, 0xc1, 0x79, 0x47, 0x14);\n\n// {B753B29A-0A96-45be-985F-68351D9CAB90}\nDEFINE_GUID(MEDIASUBTYPE_USF, 0xb753b29a, 0xa96, 0x45be, 0x98, 0x5f, 0x68, 0x35, 0x1d, 0x9c, 0xab, 0x90);\n\n// {F7239E31-9599-4e43-8DD5-FBAF75CF37F1}\nDEFINE_GUID(MEDIASUBTYPE_VOBSUB, 0xf7239e31, 0x9599, 0x4e43, 0x8d, 0xd5, 0xfb, 0xaf, 0x75, 0xcf, 0x37, 0xf1);\n\n// {A33D2F7D-96BC-4337-B23B-A8B9FBC295E9}\nDEFINE_GUID(FORMAT_SubtitleInfo, 0xa33d2f7d, 0x96bc, 0x4337, 0xb2, 0x3b, 0xa8, 0xb9, 0xfb, 0xc2, 0x95, 0xe9);\n\n// {04EBA53E-9330-436c-9133-553EC87031DC}\nDEFINE_GUID(MEDIASUBTYPE_HDMVSUB, 0x4eba53e, 0x9330, 0x436c, 0x91, 0x33, 0x55, 0x3e, 0xc8, 0x70, 0x31, 0xdc);\n\n// {C886D215-F485-40BB-8DB6-FADBC619A45D}\nDEFINE_GUID(MEDIASUBTYPE_WEBVTT, 0xc886d215, 0xf485, 0x40bb, 0x8d, 0xb6, 0xfa, 0xdb, 0xc6, 0x19, 0xa4, 0x5d);\n\n#pragma pack(push, 1)\ntypedef struct\n{\n    DWORD dwOffset;\n    CHAR IsoLang[4];      // three letter lang code + terminating zero\n    WCHAR TrackName[256]; // 256 chars ought to be enough for everyone :)\n} SUBTITLEINFO;\n#pragma pack(pop)\n\n// SUBTITLEINFO structure content starting at dwOffset (also the content of CodecPrivate)\n// --------------------------------------------------------------------------------------\n//\n// Here the text should start with the Byte Order Mark, even though\n// UTF-8 is preferred, it also helps identifying the encoding type.\n//\n// MEDIASUBTYPE_USF:\n//\n// <?xml version=\"1.0\" encoding=\"UTF-8\"?>\n// <!-- DOCTYPE USFSubtitles SYSTEM \"USFV100.dtd\" -->\n// <?xml-stylesheet type=\"text/xsl\" href=\"USFV100.xsl\"?>\n//\n// <USFSubtitles version=\"1.0\">\n// ... every element excluding <subtitles></subtitles> ...\n// </USFSubtitles>\n//\n// MEDIASUBTYPE_SSA/ASS:\n//\n// The file header and all sub-sections except [Events]\n//\n// MEDIATYPE_VOBSUB:\n//\n// TODO\n//\n\n// Data description of the media samples (everything is UTF-8 encoded here)\n// ------------------------------------------------------------------------\n//\n// MEDIASUBTYPE_USF:\n//\n// The text _inside_ the <subtitle>..</subtitle> element.\n//\n// Since timing is set on the sample, there is no need to put\n// <subtitle start=\"..\" stop=\"..\" duration=\"..\"> into the data.\n//\n// MEDIASUBTYPE_SSA/ASS:\n//\n// Comma separated values similar to the \"Dialogue: ...\" line with these fields:\n// ReadOrder, Layer, Style, Name, MarginL, MarginR, MarginV, Effect, Text\n//\n// With the exception of ReadOrder every field can be found in ASS files. The\n// ReadOrder field is needed for the decoder to be able to reorder the streamed\n// samples as they were placed originally in the file.\n//\n// If the source is only SSA, the Layer field can be left empty.\n//\n// MEDIATYPE_VOBSUB:\n//\n// Standard dvd subpic data, without the stream id at the beginning.\n//\n\n// Matroska CodecID mappings\n// ------------------------\n//\n// S_TEXT/ASCII\t<->\tMEDIATYPE_Text\t\tMEDIASUBTYPE_NULL\tFORMAT_None\n// S_TEXT/UTF8\t<->\tMEDIATYPE_Subtitle\tMEDIASUBTYPE_UTF8\tFORMAT_SubtitleInfo\n// S_TEXT/SSA\t<->\tMEDIATYPE_Subtitle\tMEDIASUBTYPE_SSA\tFORMAT_SubtitleInfo\n// S_TEXT/ASS\t<->\tMEDIATYPE_Subtitle\tMEDIASUBTYPE_ASS\tFORMAT_SubtitleInfo\n// S_TEXT/USF\t<->\tMEDIATYPE_Subtitle\tMEDIASUBTYPE_USF\tFORMAT_SubtitleInfo\n// S_VOBSUB\t\t<-> MEDIATYPE_Subtitle\tMEDIASUBTYPE_VOBSUB\tFORMAT_SubtitleInfo\n// S_VOBSUB/ZLIB<-> MEDIATYPE_Subtitle\tMEDIASUBTYPE_VOBSUB\tFORMAT_SubtitleInfo\n//\n\n/*\nDEFINE_GUID( MEDIATYPE_MPEG2_SECTIONS,\n    0x455f176c, 0x4b06, 0x47ce, 0x9a, 0xef, 0x8c, 0xae, 0xf7, 0x3d, 0xf7, 0xb5);\n\nDEFINE_GUID(MEDIASUBTYPE_ATSC_SI,\n0xb3c7397c, 0xd303, 0x414d, 0xb3, 0x3c, 0x4e, 0xd2, 0xc9, 0xd2, 0x97, 0x33);\n\nDEFINE_GUID(MEDIASUBTYPE_DVB_SI,\n0xe9dd31a3, 0x221d, 0x4adb, 0x85, 0x32, 0x9a, 0xf3, 0x9, 0xc1, 0xa4, 0x8);\n\n\n// {C892E55B-252D-42b5-A316-D997E7A5D995}\nDEFINE_GUID(MEDIASUBTYPE_MPEG2DATA,\n0xc892e55b, 0x252d, 0x42b5, 0xa3, 0x16, 0xd9, 0x97, 0xe7, 0xa5, 0xd9, 0x95);\n\n*/\n\n// H264\n\n// 6F29D2AD-E130-45AA-B42F-F623AD354A90\nDEFINE_GUID(MEDIASUBTYPE_ArcsoftH264, 0x6F29D2AD, 0xE130, 0x45AA, 0xB4, 0x2F, 0xF6, 0x23, 0xAD, 0x35, 0x4A, 0x90);\n\n// 48535356-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VSSH, 0x48535356, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 68737376-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_vssh, 0x68737376, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 43564144-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DAVC, 0x43564144, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 63766164-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_davc, 0x63766164, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 43564150-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_PAVC, 0x43564150, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 63766170-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_pavc, 0x63766170, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31637661-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_avc1, 0x31637661, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31564343-0000-0010-8000-00AA00389B71 (custom H.264 FourCC used by Haali Media Splitter)\nDEFINE_GUID(MEDIASUBTYPE_CCV1, 0x31564343, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 8D2D71CB-243F-45E3-B2D8-5FD7967EC09B\t\t<= Use by MediaPortal for example...\nDEFINE_GUID(MEDIASUBTYPE_H264_bis, 0x8D2D71CB, 0x243F, 0x45E3, 0xB2, 0xD8, 0x5F, 0xD7, 0x96, 0x7E, 0xC0, 0x9B);\n\n// 33515653-0000-0010-8000-00aa00389b71\nDEFINE_GUID(MEDIASUBTYPE_SVQ3, 0x33515653, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 56564D41-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_XVID, 0x44495658, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 56564D41-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_xvid, 0x64697678, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30355844-0000-0010-8000-00aa00389b71\nDEFINE_GUID(MEDIASUBTYPE_DX50, 0x30355844, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30357864-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_dx50, 0x30357864, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 56564D41-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DIVX, 0x58564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 78766964-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_divx, 0x78766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 78766944-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_Divx, 0x78766944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 5634504d-0000-0010-8000-00aa00389b71\nDEFINE_GUID(MEDIASUBTYPE_MP4V, 0x5634504d, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 7634706D-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_mp4v, 0x7634706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31564933-0000-0010-8000-00aa00389b71\nDEFINE_GUID(MEDIASUBTYPE_3IV1, 0x31564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31766933-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_3iv1, 0x31766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32564933-0000-0010-8000-00aa00389b71\nDEFINE_GUID(MEDIASUBTYPE_3IV2, 0x32564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32766933-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_3iv2, 0x32766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 58564933-0000-0010-8000-00aa00389b71\nDEFINE_GUID(MEDIASUBTYPE_3IVX, 0x58564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 78766933-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_3ivx, 0x78766933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 305A4C42-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_BLZ0, 0x305A4C42, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 307A6C62-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_blz0, 0x307A6C62, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// {564F4547-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_GEOV, 0x564F4547, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 56344D44-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DM4V, 0x56344D44, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 76346D64-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_dm4v, 0x76346D64, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 4D475844-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DXGM, 0x4D475844, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 6D677864-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_dxgm, 0x6D677864, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 53444646-0000-0010-8000-00aa00389b71\nDEFINE_GUID(MEDIASUBTYPE_FFDS, 0x53444646, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 73646666-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ffds, 0x73646666, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 57465646-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_FVFW, 0x57465646, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 77667666-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_fvfw, 0x77667666, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34504D46-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_FMP4, 0x34504D46, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34706D66-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_fmp4, 0x34706D66, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34584448-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_HDX4, 0x34584448, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34786468-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_hdx4, 0x34786468, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34504D4C-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_LMP4, 0x34504D4C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34706D6C-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_lmp4, 0x34706D6C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 4749444E-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_NDIG, 0x4749444E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 6769646E-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ndig, 0x6769646E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34504D52-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RMP4, 0x34504D52, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34706D72-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_rmp4, 0x34706D72, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34504D53-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SMP4, 0x34504D53, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34706D73-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_smp4, 0x34706D73, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 47444553-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SEDG, 0x47444553, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 67646573-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_sedg, 0x67646573, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34504D55-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_UMP4, 0x34504D55, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34706D75-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ump4, 0x34706D75, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 46315657-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_WV1F, 0x46315657, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 66317677-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_wv1f, 0x66317677, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 58495658-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_XVIX, 0x58495658, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 78697678-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_xvix, 0x78697678, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31515653-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SVQ1, 0x31515653, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33363248-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_H263, 0x33363248, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33363268-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_h263, 0x33363268, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33363249-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_I263, 0x33363249, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33363269-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_i263, 0x33363269, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31363248-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_H261, 0x31363248, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31363268-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_h261, 0x31363268, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_S263, 0x33363273, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33363273-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_s263, 0x33363273, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 56564D41-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_AMVV, 0x56564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 46564D41-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_AMVF, 0x46564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33585644-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVX3, 0x33585644, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33787664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_dvx3, 0x33787664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 44564933-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_3IVD, 0x44564933, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33564944-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DIV3, 0x33564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33766964-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_div3, 0x33766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 314C4F43-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_COL1, 0x314C4F43, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 316C6F63-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_col1, 0x316C6F63, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34564944-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DIV4, 0x34564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34766964-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_div4, 0x34766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 35564944-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DIV5, 0x35564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 35766964-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_div5, 0x35766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 36564944-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DIV6, 0x36564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 36766964-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_div6, 0x36766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31345041-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_AP41, 0x31345041, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31347061-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ap41, 0x31347061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 3347504D-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MPG3, 0x3347504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 3367706D-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_mpg3, 0x3367706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32564944-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DIV2, 0x32564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32766964-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_div2, 0x32766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31564944-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DIV1, 0x31564944, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31766964-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_div1, 0x31766964, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 3134504D-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MP41, 0x3134504D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 3134706D-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_mp41, 0x3134706D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 4F454854-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_THEORA, 0x4F454854, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 6F656874-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_theora, 0x6F656874, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 63637374-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_TSCC, 0x63637374, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32637374-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_TSC2, 0x32637374, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30355649-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_IV50, 0x30355649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31345649-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_IV41, 0x31345649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31335649-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_IV31, 0x31335649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32335649-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_IV32, 0x32335649, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 48564443-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_CDVH, 0x48564443, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 43564443-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_CDVC, 0x43564443, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 35564443-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_CDV5, 0x35564443, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 35325644-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DV25, 0x35325644, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 30355644-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DV50, 0x30355644, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 70637664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVCP, 0x70637664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 70707664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVPP, 0x70707664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 70357664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DV5P, 0x70357664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 6E357664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DV5N, 0x6E357664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 70637664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVC, 0x20637664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 31687664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVH1, 0x31687664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 32687664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVH2, 0x32687664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 33687664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVH3, 0x33687664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 34687664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVH4, 0x34687664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 35687664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVH5, 0x35687664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 36687664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVH6, 0x36687664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 71687664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVHQ, 0x71687664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 70687664-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DVHP, 0x70687664, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 76645641-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_AVdv, 0x76645641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 31645641-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_AVd1, 0x31645641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 31535046-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_FPS1, 0x31535046, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 55594648-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_HuffYUV, 0x55594648, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 5347414C-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_Lagarith, 0x5347414C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 64697663-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_CVID, 0x64697663, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 694B4942-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_BIKI, 0x694B4942, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 624B4942-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_BIKB, 0x624B4942, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 664b4942-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_BIKf, 0x664b4942, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nDEFINE_GUID(FORMAT_RLTheora, 0xe69b30d1, 0x7d65, 0x4166, 0xb9, 0x90, 0x10, 0x3d, 0xa8, 0xc9, 0x11, 0xe3);\n\n// 62706A6D-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MJPGB, 0x62706A6D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 30365056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP30, 0x30335056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30365056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP31, 0x31335056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 324B4D53-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SMK2, 0x324B4D53, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 344B4D53-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SMK4, 0x344B4D53, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 44435343-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_CSCD, 0x44435343, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 47455051-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_QPEG, 0x47455051, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 302E3151-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_QP10, 0x302E3151, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 312E3151-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_QP11, 0x312E3151, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 485A534D-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MSZH, 0x485A534D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 42494C5A-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ZLIB, 0x42494C5A, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 20676E70-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_PNG, 0x20676E70, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_TIFF, MAKEFOURCC('T', 'I', 'F', 'F'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_BMP, MAKEFOURCC('B', 'M', 'P', ' '), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_GIF, MAKEFOURCC('G', 'I', 'F', ' '), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_TGA, MAKEFOURCC('T', 'G', 'A', ' '), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_FSV1, 0x31565346, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_CRAM, MAKEFOURCC('C', 'R', 'A', 'M'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_MSVC, MAKEFOURCC('M', 'S', 'V', 'C'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_WHAM, MAKEFOURCC('W', 'H', 'A', 'M'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_8BPS, MAKEFOURCC('8', 'B', 'P', 'S'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_LOCO, MAKEFOURCC('L', 'O', 'C', 'O'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ZMBV, MAKEFOURCC('Z', 'M', 'B', 'V'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_VCR1, MAKEFOURCC('V', 'C', 'R', '1'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_AASC, MAKEFOURCC('A', 'A', 'S', 'C'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_SNOW, MAKEFOURCC('S', 'N', 'O', 'W'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_FFV1, MAKEFOURCC('F', 'F', 'V', '1'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_FFVH, MAKEFOURCC('F', 'F', 'V', 'H'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_v410, MAKEFOURCC('v', '4', '1', '0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_VMNC, MAKEFOURCC('V', 'M', 'n', 'c'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// Apple ProRes\nDEFINE_GUID(MEDIASUBTYPE_apch, 0x68637061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_apcn, 0x6e637061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_apcs, 0x73637061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_apco, 0x6f637061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ap4h, 0x68347061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ap4x, 0x78347061, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// Apple ICOD\nDEFINE_GUID(MEDIASUBTYPE_icod, 0x646F6369, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// Ut Video\nDEFINE_GUID(MEDIASUBTYPE_ULRA, MAKEFOURCC('U', 'L', 'R', 'A'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ULRG, MAKEFOURCC('U', 'L', 'R', 'G'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ULY0, MAKEFOURCC('U', 'L', 'Y', '0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ULY2, MAKEFOURCC('U', 'L', 'Y', '2'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ULY4, MAKEFOURCC('U', 'L', 'Y', '4'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UQY2, MAKEFOURCC('U', 'Q', 'Y', '2'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UQRG, MAKEFOURCC('U', 'Q', 'R', 'G'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UQRA, MAKEFOURCC('U', 'Q', 'R', 'A'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ULH0, MAKEFOURCC('U', 'L', 'H', '0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ULH2, MAKEFOURCC('U', 'L', 'H', '2'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ULH4, MAKEFOURCC('U', 'L', 'H', '4'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UMY2, MAKEFOURCC('U', 'M', 'Y', '2'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UMH2, MAKEFOURCC('U', 'M', 'H', '2'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UMY4, MAKEFOURCC('U', 'M', 'Y', '4'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UMH4, MAKEFOURCC('U', 'M', 'H', '4'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UMRG, MAKEFOURCC('U', 'M', 'R', 'G'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_UMRA, MAKEFOURCC('U', 'M', 'R', 'A'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// G2M\nDEFINE_GUID(MEDIASUBTYPE_G2M2, MAKEFOURCC('G', '2', 'M', '2'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_G2M3, MAKEFOURCC('G', '2', 'M', '3'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_G2M4, MAKEFOURCC('G', '2', 'M', '4'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_G2M5, MAKEFOURCC('G', '2', 'M', '5'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// CFHD\nDEFINE_GUID(MEDIASUBTYPE_CFHD, MAKEFOURCC('C', 'F', 'H', 'D'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// MagicYUV\nDEFINE_GUID(MEDIASUBTYPE_MAGY, MAKEFOURCC('M', 'A', 'G', 'Y'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_M8RG, MAKEFOURCC('M', '8', 'R', 'G'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_M8RA, MAKEFOURCC('M', '8', 'R', 'A'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_M8G0, MAKEFOURCC('M', '8', 'G', '0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_M8Y0, MAKEFOURCC('M', '8', 'Y', '0'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38,\n                0x9B, 0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_M8Y2, MAKEFOURCC('M', '8', 'Y', '2'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_M8Y4, MAKEFOURCC('M', '8', 'Y', '4'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_M8YA, MAKEFOURCC('M', '8', 'Y', 'A'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// MagicYUV\nDEFINE_GUID(MEDIASUBTYPE_FICV, MAKEFOURCC('F', 'I', 'C', 'V'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// DNxHD\n// {6E645641-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_AVdn, 0x6E645641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// DNxHR\n// {68645641-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_AVdh, 0x68645641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// JPEG2000\n// {32706A6D-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_mjp2, 0x32706A6D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// {43324A4D-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_MJ2C, 0x43324A4D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// {43324A4C-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_LJ2C, 0x43324A4C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// {4B324A4C-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_LJ2K, 0x4B324A4C, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// {324A5049-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_IPJ2, 0x324A5049, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// {D80FA03C-35C1-4FA1-8C8E-375C8667166E}\nDEFINE_GUID(MEDIASUBTYPE_LAV_RAWVIDEO, 0xd80fa03c, 0x35c1, 0x4fa1, 0x8c, 0x8e, 0x37, 0x5c, 0x86, 0x67, 0x16, 0x6e);\n\n// {434C4641-0000-0010-8000-00AA00389B71}\nDEFINE_GUID(MEDIASUBTYPE_FLIC, 0x434C4641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// {}\nDEFINE_GUID(MEDIASUBTYPE_THPV, MAKEFOURCC('T', 'H', 'P', 'V'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_ROQV, MAKEFOURCC('R', 'o', 'Q', 'V'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// 31435648-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_HVC1, 0x31435648, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 43564548-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_HEVC, 0x43564548, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30314D48-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_HM10, 0x30314D48, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 35363248-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_H265, 0x35363248, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// VVC (\"VVC1\")\nDEFINE_GUID(MEDIASUBTYPE_VVC1, MAKEFOURCC('V', 'V', 'C', '1'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// Full MVC\nDEFINE_GUID(MEDIASUBTYPE_AMVC, MAKEFOURCC('A', 'M', 'V', 'C'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b,\n            0x71);\n\n// Full MVC in mp4-form\nDEFINE_GUID(MEDIASUBTYPE_MVC1, MAKEFOURCC('M', 'V', 'C', '1'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b,\n            0x71);\n\n// Subset MVC\nDEFINE_GUID(MEDIASUBTYPE_EMVC, MAKEFOURCC('E', 'M', 'V', 'C'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_WEBP, MAKEFOURCC('W', 'E', 'B', 'P'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\nDEFINE_GUID(MEDIASUBTYPE_APV1, MAKEFOURCC('A', 'P', 'V', '1'), 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B,\n            0x71);\n\n// 4B435544-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DUCK, 0x4B435544, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30324D54-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_TM20, 0x30324D54, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 20636D73-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_smc, 0x20636D73, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 4C584956-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VIXL, 0x4C584956, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 49544C55-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ULTI, 0x49544C55, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31564E57-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_WNV1, 0x31564E57, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 76757963-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_CYUV, 0x76757963, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31565341-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_AVS1, 0x31565341, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 32565341-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_AVS2, 0x32565341, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31325452-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_RT21, 0x31325452, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 6E525641-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_AVRn, 0x6E525641, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 47504a4c-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_LJPG, 0x47504a4c, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 4C47504A-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_JPGL, 0x4C47504A, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 534c4a4d-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MJLS, 0x534c4a4d, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 41504a4d-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MJPA, 0x41504a4d, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 42504a4d-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MJPB, 0x42504a4d, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 58355053-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SP5X, 0x58355053, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 31706148-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_Hap1, 0x31706148, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 35706148-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_Hap5, 0x35706148, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 59706148-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_HapY, 0x59706148, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 33445844-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DXD3, 0x33445844, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 49445844-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_DXDI, 0x49445844, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 574D5632-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_2VMW, 0x574D5632, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 56334357-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_WC3V, 0x56334357, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 4345444D-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MDEC, 0x4345444D, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 564D5834-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_4XMV, 0x564D5834, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 43425241-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ARBC, 0x43425241, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 30345056-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VP40, 0x30345056, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 34355053-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_SP54, 0x34355053, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// 3156474B-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_KGV1, 0x3156474B, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n// Audio codecs\n\n// 41564D41-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_IMA_AMV, 0x41564D41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 4C4C454E-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_NELLYMOSER, 0x4C4C454E, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 00000006-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ALAW, WAVE_FORMAT_ALAW, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 00000007-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MULAW, WAVE_FORMAT_MULAW, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 00000031-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_MSGSM610, WAVE_FORMAT_GSM610, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 00000002-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ADPCM_MS, WAVE_FORMAT_ADPCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 00000022-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_TRUESPEECH, WAVE_FORMAT_DSPGROUP_TRUESPEECH, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00,\n            0x38, 0x9b, 0x71);\n\n// 00000075-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_VOXWARE_RT29, WAVE_FORMAT_VOXWARE_RT29, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38,\n            0x9b, 0x71);\n\n// 324D4451-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_QDM2, 0x324D4451, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 63616C61-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ALAC, 0x63616C61, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// B82196E9-1B3F-4796-A636-46239087B38E   dsfTAKsource specific\nDEFINE_GUID(MEDIASUBTYPE_TAK, 0xB82196E9, 0x1B3F, 0x4796, 0xA6, 0x36, 0x46, 0x23, 0x90, 0x87, 0xB3, 0x8E);\n\n// 20534C41-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_ALS, 0x20534C41, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 0000729A-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_729A, 0x0000729A, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 00000133-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_G729, 0x00000133, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 36323767-0000-0010-8000-00AA00389B71Add commentMore actions\nDEFINE_GUID(MEDIASUBTYPE_G726, 0x36323767, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 00000401-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_IMC, 0x00000401, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// 0000011-0000-0010-8000-00AA00389B71\nDEFINE_GUID(MEDIASUBTYPE_IMA_WAV, WAVE_FORMAT_IMA_ADPCM, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// {A23EB7FC-510B-466F-9FBF-5F878F69347C}   LAVF/LAVC specific\nDEFINE_GUID(MEDIASUBTYPE_BD_LPCM_AUDIO, 0xa23eb7fc, 0x510b, 0x466f, 0x9f, 0xbf, 0x5f, 0x87, 0x8f, 0x69, 0x34, 0x7c);\n\n// {53544441-0000-0010-8000-00AA00389B71}   AAC-ADTS LAVF/LAVC specific\n#define WAVE_FORMAT_AAC_ADTS mmioFOURCC('A', 'D', 'T', 'S')\nDEFINE_GUID(MEDIASUBTYPE_AAC_ADTS, WAVE_FORMAT_AAC_ADTS, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// {33534541-0000-0010-8000-00AA00389B71} S302M AES3\n#define WAVE_FORMAT_S302M_AES3 mmioFOURCC('A', 'E', 'S', '3')\nDEFINE_GUID(MEDIASUBTYPE_AES3, WAVE_FORMAT_S302M_AES3, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// {949F97FD-56F6-4527-B4AE-DDEB375AB80F}\t\tMpc-hc specific !\nDEFINE_GUID(MEDIASUBTYPE_HDMV_LPCM_AUDIO, 0x949f97fd, 0x56f6, 0x4527, 0xb4, 0xae, 0xdd, 0xeb, 0x37, 0x5a, 0xb8, 0xf);\n\n#define WAVE_FORMAT_MLP mmioFOURCC('M', 'L', 'P', ' ')\nDEFINE_GUID(MEDIASUBTYPE_MLP, WAVE_FORMAT_MLP, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n#define WAVE_FORMAT_SPEEX 0xA109\nDEFINE_GUID(MEDIASUBTYPE_SPEEX, WAVE_FORMAT_SPEEX, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xAA, 0x00, 0x38, 0x9B, 0x71);\n\n#ifndef WAVE_FORMAT_OPUS\n#define WAVE_FORMAT_OPUS 0x704F\n#endif\nDEFINE_GUID(MEDIASUBTYPE_OPUS, WAVE_FORMAT_OPUS, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_OPUS_OLD mmioFOURCC('O', 'P', 'U', 'S')\nDEFINE_GUID(MEDIASUBTYPE_OPUS_OLD, WAVE_FORMAT_OPUS_OLD, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_DSDL mmioFOURCC('D', 'S', 'D', 'L')\nDEFINE_GUID(MEDIASUBTYPE_DSDL, WAVE_FORMAT_DSDL, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_DSDM mmioFOURCC('D', 'S', 'D', 'M')\nDEFINE_GUID(MEDIASUBTYPE_DSDM, WAVE_FORMAT_DSDM, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_DSD1 mmioFOURCC('D', 'S', 'D', '1')\nDEFINE_GUID(MEDIASUBTYPE_DSD1, WAVE_FORMAT_DSD1, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n#define WAVE_FORMAT_DSD8 mmioFOURCC('D', 'S', 'D', '8')\nDEFINE_GUID(MEDIASUBTYPE_DSD8, WAVE_FORMAT_DSD8, 0x000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\nstruct WAVEFORMATEX_HDMV_LPCM : public WAVEFORMATEX\n{\n    BYTE channel_conf;\n\n    struct WAVEFORMATEX_HDMV_LPCM()\n    {\n        memset(this, 0, sizeof(*this));\n        cbSize = sizeof(WAVEFORMATEX_HDMV_LPCM) - sizeof(WAVEFORMATEX);\n    }\n};\n\n// {AFBC2343-3DCB-4047-9655-E1E62A61B1C5}\nDEFINE_GUID(MEDIASUBTYPE_FFMPEG_AUDIO, 0xafbc2343, 0x3dcb, 0x4047, 0x96, 0x55, 0xe1, 0xe6, 0x2a, 0x61, 0xb1, 0xc5);\n\n// {35189950-CAC9-4C8D-819D-B6FAEE15DD9D}\nDEFINE_GUID(FORMAT_WaveFormatExFFMPEG, 0x35189950, 0xcac9, 0x4c8d, 0x81, 0x9d, 0xb6, 0xfa, 0xee, 0x15, 0xdd, 0x9d);\n\nstruct WAVEFORMATEXFFMPEG\n{\n    int nCodecId;\n    WAVEFORMATEX wfex;\n\n    struct WAVEFORMATEXFFMPEG()\n    {\n        nCodecId = 0;\n    }\n};\n\n// {20884BC2-629F-45EA-B1C5-FA4FFA438250}\nDEFINE_GUID(MEDIASUBTYPE_LAVBluRay, 0x20884bc2, 0x629f, 0x45ea, 0xb1, 0xc5, 0xfa, 0x4f, 0xfa, 0x43, 0x82, 0x50);\n\n// Additionnal DXVA GUIDs\n\n// Intel ClearVideo VC1 bitstream decoder\nDEFINE_GUID(DXVA_Intel_VC1_ClearVideo, 0xBCC5DB6D, 0xA2B6, 0x4AF0, 0xAC, 0xE4, 0xAD, 0xB1, 0xF7, 0x87, 0xBC, 0x89);\nDEFINE_GUID(DXVA_Intel_VC1_ClearVideo_2, 0xE07EC519, 0xE651, 0x4CD6, 0xAC, 0x84, 0x13, 0x70, 0xCC, 0xEE, 0xC8, 0x51);\n\n// Intel ClearVideo H264 decoders\nDEFINE_GUID(DXVADDI_Intel_ModeH264_A, 0x604F8E64, 0x4951, 0x4c54, 0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6);\nDEFINE_GUID(DXVADDI_Intel_ModeH264_C, 0x604F8E66, 0x4951, 0x4c54, 0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6);\nDEFINE_GUID(DXVADDI_Intel_ModeH264_E, 0x604F8E68, 0x4951, 0x4C54, 0x88, 0xFE, 0xAB, 0xD2, 0x5C, 0x15, 0xB3, 0xD6);\n\n// Generic DXVA2 GUIDs\nDEFINE_GUID(DXVA2_ModeMPEG2and1_VLD, 0x86695f12, 0x340e, 0x4f04, 0x9f, 0xd3, 0x92, 0x53, 0xdd, 0x32, 0x74, 0x60);\nDEFINE_GUID(DXVA2_ModeMPEG1_VLD, 0x6f3ec719, 0x3735, 0x42cc, 0x80, 0x63, 0x65, 0xcc, 0x3c, 0xb3, 0x66, 0x16);\n\nDEFINE_GUID(DXVA_ModeH264_VLD_WithFMOASO_NoFGT, 0xd5f04ff9, 0x3418, 0x45d8, 0x95, 0x61, 0x32, 0xa7, 0x6a, 0xae, 0x2d,\n            0xdd);\nDEFINE_GUID(DXVA_ModeH264_VLD_NoFGT_Flash, 0x4245F676, 0x2BBC, 0x4166, 0xa0, 0xBB, 0x54, 0xE7, 0xB8, 0x49, 0xC3, 0x80);\n\n/* Conformity to the August 2010 update of the specification, ModeVC1_VLD2010 */\nDEFINE_GUID(DXVA2_ModeVC1_D2010, 0x1b81beA4, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\n\n// MPEG4-ASP\nDEFINE_GUID(DXVA_nVidia_MPEG4_ASP, 0x9947EC6F, 0x689B, 0x11DC, 0xA3, 0x20, 0x00, 0x19, 0xDB, 0xBC, 0x41, 0x84);\nDEFINE_GUID(DXVA_ModeMPEG4pt2_VLD_Simple, 0xefd64d74, 0xc9e8, 0x41d7, 0xa5, 0xe9, 0xe9, 0xb0, 0xe3, 0x9f, 0xa3, 0x19);\nDEFINE_GUID(DXVA_ModeMPEG4pt2_VLD_AdvSimple_NoGMC, 0xed418a9f, 0x10d, 0x4eda, 0x9a, 0xe3, 0x9a, 0x65, 0x35, 0x8d, 0x8d,\n            0x2e);\nDEFINE_GUID(DXVA_ModeMPEG4pt2_VLD_AdvSimple_GMC, 0xab998b5b, 0x4258, 0x44a9, 0x9f, 0xeb, 0x94, 0xe5, 0x97, 0xa6, 0xba,\n            0xae);\nDEFINE_GUID(DXVA_ModeMPEG4pt2_VLD_AdvSimple_Avivo, 0x7C74ADC6, 0xe2ba, 0x4ade, 0x86, 0xde, 0x30, 0xbe, 0xab, 0xb4, 0x0c,\n            0xc1);\n\n// DXVA2 MVC modes\nDEFINE_GUID(DXVA_ModeH264_VLD_Stereo_Progressive_NoFGT, 0xd79be8da, 0xcf1, 0x4c81, 0xb8, 0x2a, 0x69, 0xa4, 0xe2, 0x36,\n            0xf4, 0x3d);\nDEFINE_GUID(DXVA_ModeH264_VLD_Stereo_NoFGT, 0xf9aaccbb, 0xc2b6, 0x4cfc, 0x87, 0x79, 0x57, 0x7, 0xb1, 0x76, 0x5, 0x52);\nDEFINE_GUID(DXVA_ModeH264_VLD_Multiview_NoFGT, 0x705b9d82, 0x76cf, 0x49d6, 0xb7, 0xe6, 0xac, 0x88, 0x72, 0xdb, 0x1,\n            0x3c);\n\n// DXVA2 SVC modes\nDEFINE_GUID(DXVA_ModeH264_VLD_SVC_Scalable_Baseline, 0xc30700c4, 0xe384, 0x43e0, 0xb9, 0x82, 0x2d, 0x89, 0xee, 0x7f,\n            0x77, 0xc4);\nDEFINE_GUID(DXVA_ModeH264_VLD_SVC_Restricted_Scalable_Baseline, 0x9b8175d4, 0xd670, 0x4cf2, 0xa9, 0xf0, 0xfa, 0x56,\n            0xdf, 0x71, 0xa1, 0xae);\nDEFINE_GUID(DXVA_ModeH264_VLD_SVC_Scalable_High, 0x728012c9, 0x66a8, 0x422f, 0x97, 0xe9, 0xb5, 0xe3, 0x9b, 0x51, 0xc0,\n            0x53);\nDEFINE_GUID(DXVA_ModeH264_VLD_SVC_Restricted_Scalable_High_Progressive, 0x8efa5926, 0xbd9e, 0x4b04, 0x8b, 0x72, 0x8f,\n            0x97, 0x7d, 0xc4, 0x4c, 0x36);\n\nDEFINE_GUID(DXVA2_ModeMPEG2_MoComp, 0xe6a9f44b, 0x61b0, 0x4563, 0x9e, 0xa4, 0x63, 0xd2, 0xa3, 0xc6, 0xfe, 0x66);\nDEFINE_GUID(DXVA2_ModeMPEG2_IDCT, 0xbf22ad00, 0x03ea, 0x4690, 0x80, 0x77, 0x47, 0x33, 0x46, 0x20, 0x9b, 0x7e);\nDEFINE_GUID(DXVA2_ModeMPEG2_VLD, 0xee27417f, 0x5e28, 0x4e65, 0xbe, 0xea, 0x1d, 0x26, 0xb5, 0x08, 0xad, 0xc9);\nDEFINE_GUID(DXVA2_ModeH264_A, 0x1b81be64, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeH264_B, 0x1b81be65, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeH264_C, 0x1b81be66, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeH264_D, 0x1b81be67, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeH264_E, 0x1b81be68, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeH264_F, 0x1b81be69, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeWMV8_A, 0x1b81be80, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeWMV8_B, 0x1b81be81, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeWMV9_A, 0x1b81be90, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeWMV9_B, 0x1b81be91, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeWMV9_C, 0x1b81be94, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeVC1_A, 0x1b81beA0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeVC1_B, 0x1b81beA1, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeVC1_C, 0x1b81beA2, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_ModeVC1_D, 0x1b81beA3, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\nDEFINE_GUID(DXVA2_NoEncrypt, 0x1b81beD0, 0xa0c7, 0x11d3, 0xb9, 0x84, 0x00, 0xc0, 0x4f, 0x2e, 0x73, 0xc5);\n\n// HEVC\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main, 0x5b11d51b, 0x2f4c, 0x4452, 0xbc, 0xc3, 0x09, 0xf2, 0xa1, 0x16, 0x0c, 0xc0);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main10, 0x107af0e0, 0xef1a, 0x4d19, 0xab, 0xa8, 0x67, 0xa1, 0x63, 0x07, 0x3d, 0x13);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Monochrome, 0x0685b993, 0x3d8c, 0x43a0, 0x8b, 0x28, 0xd7, 0x4c, 0x2d, 0x68, 0x99, 0xa4);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Monochrome10, 0x142a1d0f, 0x69dd, 0x4ec9, 0x85, 0x91, 0xb1, 0x2f, 0xfc, 0xb9, 0x1a, 0x29);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main12, 0x1a72925f, 0x0c2c, 0x4f15, 0x96, 0xfb, 0xb1, 0x7d, 0x14, 0x73, 0x60, 0x3f);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main10_422, 0x0bac4fe5, 0x1532, 0x4429, 0xa8, 0x54, 0xf8, 0x4d, 0xe0, 0x49, 0x53, 0xdb);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main12_422, 0x55bcac81, 0xf311, 0x4093, 0xa7, 0xd0, 0x1c, 0xbc, 0x0b, 0x84, 0x9b, 0xee);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main_444, 0x4008018f, 0xf537, 0x4b36, 0x98, 0xcf, 0x61, 0xaf, 0x8a, 0x2c, 0x1a, 0x33);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main10_Ext, 0x9cc55490, 0xe37c, 0x4932, 0x86, 0x84, 0x49, 0x20, 0xf9, 0xf6, 0x40, 0x9c);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main10_444, 0x0dabeffa, 0x4458, 0x4602, 0xbc, 0x03, 0x07, 0x95, 0x65, 0x9d, 0x61, 0x7c);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main12_444, 0x9798634d, 0xfe9d, 0x48e5, 0xb4, 0xda, 0xdb, 0xec, 0x45, 0xb3, 0xdf, 0x01);\nDEFINE_GUID(DXVA_ModeHEVC_VLD_Main16, 0xa4fbdbb0, 0xa113, 0x482b, 0xa2, 0x32, 0x63, 0x5c, 0xc0, 0x69, 0x7f, 0x6d);\n\n// VP8/9\nDEFINE_GUID(DXVA_ModeVP9_VLD_Profile0, 0x463707f8, 0xa1d0, 0x4585, 0x87, 0x6d, 0x83, 0xaa, 0x6d, 0x60, 0xb8, 0x9e);\nDEFINE_GUID(DXVA_ModeVP9_VLD_10bit_Profile2, 0xa4c749ef, 0x6ecf, 0x48aa, 0x84, 0x48, 0x50, 0xa7, 0xa1, 0x16, 0x5f,\n            0xf7);\nDEFINE_GUID(DXVA_ModeVP8_VLD, 0x90b899ea, 0x3a62, 0x4705, 0x88, 0xb3, 0x8d, 0xf0, 0x4b, 0x27, 0x44, 0xe7);\n\nDEFINE_GUID(DXVA_ModeAV1_VLD_Profile0, 0xb8be4ccb, 0xcf53, 0x46ba, 0x8d, 0x59, 0xd6, 0xb8, 0xa6, 0xda, 0x5d, 0x2a);\nDEFINE_GUID(DXVA_ModeAV1_VLD_Profile1, 0x6936ff0f, 0x45b1, 0x4163, 0x9c, 0xc1, 0x64, 0x6e, 0xf6, 0x94, 0x61, 0x08);\nDEFINE_GUID(DXVA_ModeAV1_VLD_Profile2, 0x0c5f2aa1, 0xe541, 0x4089, 0xbb, 0x7b, 0x98, 0x11, 0x0a, 0x19, 0xd7, 0xc8);\nDEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2, 0x17127009, 0xa00f, 0x4ce1, 0x99, 0x4e, 0xbf, 0x40, 0x81, 0xf6, 0xf3,\n            0xf0);\nDEFINE_GUID(DXVA_ModeAV1_VLD_12bit_Profile2_420, 0x2d80bed6, 0x9cac, 0x4835, 0x9e, 0x91, 0x32, 0x7b, 0xbc, 0x4f, 0x9e,\n            0xe8);\n\nDEFINE_GUID(IID_IDirectXVideoDecoderService, 0xfc51a551, 0xd5e7, 0x11d9, 0xaf, 0x55, 0x00, 0x05, 0x4e, 0x43, 0xff,\n            0x02);\n\nDEFINE_GUID(CLSID_AC3Filter, 0xA753A1EC, 0x973E, 0x4718, 0xAF, 0x8E, 0xA3, 0xF5, 0x54, 0xD4, 0x5C, 0x44);\n// \"{48025243-2D39-11CE-875D-00608CB78066}\nDEFINE_GUID(CLSID_ISCR, 0x48025243, 0x2D39, 0x11CE, 0x87, 0x5D, 0x00, 0x60, 0x8C, 0xB7, 0x80, 0x66);\n\n// Filter/Commercial GUIDs\n\n// MPC-HC MPEG-TS Splitter\n// DC257063-045F-4BE2-BD5B-E12279C464F0\nDEFINE_GUID(CLSID_MPCHCMPEGSplitter, 0xDC257063, 0x045F, 0x4BE2, 0xBD, 0x5B, 0xE1, 0x22, 0x79, 0xC4, 0x64, 0xF0);\n\n// MPC-HC MPEG-TS Splitter Source\n// 1365BE7A-C86A-473C-9A41-C0A6E82C9FA3\nDEFINE_GUID(CLSID_MPCHCMPEGSplitterSource, 0x1365BE7A, 0xC86A, 0x473C, 0x9A, 0x41, 0xC0, 0xA6, 0xE8, 0x2C, 0x9F, 0xA3);\n\n// MPC-HC MP4 Splitter\n// 61F47056-E400-43d3-AF1E-AB7DFFD4C4AD\nDEFINE_GUID(CLSID_MPCHCMP4Splitter, 0x61F47056, 0xE400, 0x43D3, 0xAF, 0x1E, 0xAB, 0x7D, 0xFF, 0xD4, 0xC4, 0xAD);\n\n// MPC-HC MP4 Splitter Source\n// 3CCC052E-BDEE-408a-BEA7-90914EF2964B\nDEFINE_GUID(CLSID_MPCHCMP4SplitterSource, 0x3CCC052E, 0xBDEE, 0x408A, 0xBE, 0xA7, 0x90, 0x91, 0x4E, 0xF2, 0x96, 0x4B);\n\n// MediaPortal BD Reader\nDEFINE_GUID(CLSID_MPBDReader, 0x79a37017, 0x3178, 0x4859, 0x80, 0x79, 0xec, 0xb9, 0xd5, 0x46, 0xfe, 0xb2);\n\n// MPC Video Dec\n// 008BAC12-FBAF-497b-9670-BC6F6FBAE2C4\nDEFINE_GUID(CLSID_MPCVideoDec, 0x008BAC12, 0xFBAF, 0x497B, 0x96, 0x70, 0xBC, 0x6F, 0x6F, 0xBA, 0xE2, 0xC4);\n\n// ffdshow DXVA Video Decoder\n// 0B0EFF97-C750-462C-9488-B10E7D87F1A6\nDEFINE_GUID(CLSID_ffdshowDXVA, 0x0B0EFF97, 0xC750, 0x462C, 0x94, 0x88, 0xB1, 0x0E, 0x7D, 0x87, 0xF1, 0xA6);\n\n// LAV CUVID Decoder\n// 62D767FE-4F1B-478B-B350-8ACE9E4DB00E\nDEFINE_GUID(CLSID_LAVCUVID, 0x62D767FE, 0x4F1B, 0x478B, 0xB3, 0x50, 0x8A, 0xCE, 0x9E, 0x4D, 0xB0, 0x0E);\n\n// LAV Video Decoder\n// EE30215D-164F-4A92-A4EB-9D4C13390F9F\nDEFINE_GUID(CLSID_LAVVideo, 0xEE30215D, 0x164F, 0x4A92, 0xA4, 0xEB, 0x9D, 0x4C, 0x13, 0x39, 0x0F, 0x9F);\n\n// LAV Splitter\n// 171252A0-8820-4AFE-9DF8-5C92B2D66B04\nDEFINE_GUID(CLSID_LAVSplitter, 0x171252A0, 0x8820, 0x4AFE, 0x9D, 0xF8, 0x5C, 0x92, 0xB2, 0xD6, 0x6B, 0x04);\n\n// LAV Splitter\n// B98D13E7-55DB-4385-A33D-09FD1BA26338\nDEFINE_GUID(CLSID_LAVSplitterSource, 0xB98D13E7, 0x55DB, 0x4385, 0xA3, 0x3D, 0x09, 0xFD, 0x1B, 0xA2, 0x63, 0x38);\n\n// SageTV MpegDeMux\n// ABD65DEA-5701-4F21-863B-591B057D2268\nDEFINE_GUID(CLSID_SageTVMpegDeMux, 0xABD65DEA, 0x5701, 0x4F21, 0x86, 0x3B, 0x59, 0x1B, 0x05, 0x7D, 0x22, 0x68);\n\n// Cyberlink VC-1 GUID\n// D979F77B-DBEA-4BF6-9E6D-1D7E57FBAD53\nDEFINE_GUID(MEDIASUBTYPE_WVC1_CYBERLINK, 0xD979F77B, 0xDBEA, 0x4BF6, 0x9E, 0x6D, 0x1D, 0x7E, 0x57, 0xFB, 0xAD, 0x53);\n\n// Cyberlink Video Decoder GUID (PDVD10)\n// D00E73D7-06F5-44F9-8BE4-B7DB191E9E7E\nDEFINE_GUID(CLSID_CyberlinkVidDec, 0xD00E73D7, 0x06F5, 0x44F9, 0x8B, 0xE4, 0xB7, 0xDB, 0x19, 0x1E, 0x9E, 0x7E);\n\n// ArcSoft VC-1 GUID\n// 629B40AD-AD74-4EF4-A985-F0C8D92E5ECA\nDEFINE_GUID(MEDIASUBTYPE_WVC1_ARCSOFT, 0x629B40AD, 0xAD74, 0x4EF4, 0xA9, 0x85, 0xF0, 0xC8, 0xD9, 0x2E, 0x5E, 0xCA);\n\n// ArcSoft Video Decoder\n// B793E9A8-C53E-4845-9DE9-C32326EACCAD\nDEFINE_GUID(CLSID_ArcSoftVidDec, 0xB793E9A8, 0xC53E, 0x4845, 0x9D, 0xE9, 0xC3, 0x23, 0x26, 0xEA, 0xCC, 0xAD);\n\n// ArcSoft TrueHD\n// 4288B843-610B-4E15-A53B-43007FCFF614\nDEFINE_GUID(MEDIASUBTYPE_DOLBY_TRUEHD_ARCSOFT, 0x4288B843, 0x610B, 0x4E15, 0xA5, 0x3B, 0x43, 0x00, 0x7F, 0xCF, 0xF6,\n            0x14);\n\n// ArcSoft DD+\nDEFINE_GUID(MEDIASUBTYPE_DOLBY_DDPLUS_ARCSOFT, 0x71cfa727, 0x37e4, 0x404a, 0xae, 0xc0, 0x34, 0x84, 0x25, 0x32, 0xef,\n            0xf7);\n\n// uncompressed\n#define DEFINE_GUID_FOURCC(FOURCC) \\\n    DEFINE_GUID(MEDIASUBTYPE_##FOURCC, FOURCC_##FOURCC, 0x0000, 0x0010, 0x80, 0x00, 0x00, 0xaa, 0x00, 0x38, 0x9b, 0x71);\n\n// uncompressed\n#define FOURCC_YUY2 mmioFOURCC('Y', 'U', 'Y', '2')\n#define FOURCC_V422 mmioFOURCC('V', '4', '2', '2')\n#define FOURCC_YV12 mmioFOURCC('Y', 'V', '1', '2')\n#define FOURCC_YVYU mmioFOURCC('Y', 'V', 'Y', 'U')\n#define FOURCC_UYVY mmioFOURCC('U', 'Y', 'V', 'Y')\n#define FOURCC_YUYV mmioFOURCC('Y', 'U', 'Y', 'V')\n#define FOURCC_VYUY mmioFOURCC('V', 'Y', 'U', 'Y')\n#define FOURCC_I420 mmioFOURCC('I', '4', '2', '0')\n#define FOURCC_IYUV mmioFOURCC('I', 'Y', 'U', 'V')\n#define FOURCC_444P mmioFOURCC('4', '4', '4', 'P')\n#define FOURCC_YV24 mmioFOURCC('Y', 'V', '2', '4') // YUV 4:4:4\n#define FOURCC_422P mmioFOURCC('4', '2', '2', 'P')\n#define FOURCC_YV16 mmioFOURCC('Y', 'V', '1', '6') // YUV 4:2:2\n#define FOURCC_411P mmioFOURCC('4', '1', '1', 'P')\n#define FOURCC_Y41B mmioFOURCC('Y', '4', '1', 'B') // YUV 4:1:1\n#define FOURCC_410P mmioFOURCC('4', '1', '0', 'P')\n#define FOURCC_PAL1 mmioFOURCC('P', 'A', 'L', '1')\n#define FOURCC_PAL4 mmioFOURCC('P', 'A', 'L', '4')\n#define FOURCC_PAL8 mmioFOURCC('P', 'A', 'L', '8')\n#define FOURCC_RGB2 mmioFOURCC('R', 'G', 'B', '2')\n#define FOURCC_RGB3 mmioFOURCC('R', 'G', 'B', '3')\n#define FOURCC_RGB5 mmioFOURCC('R', 'G', 'B', '5')\n#define FOURCC_RGB6 mmioFOURCC('R', 'G', 'B', '6')\n#define FOURCC_CLJR mmioFOURCC('C', 'L', 'J', 'R')\n#define FOURCC_Y800 mmioFOURCC('Y', '8', '0', '0')\n#define FOURCC_NV12 mmioFOURCC('N', 'V', '1', '2')\n#define FOURCC_NV21 mmioFOURCC('N', 'V', '2', '1')\n#define FOURCC_P010 mmioFOURCC('P', '0', '1', '0')\n#define FOURCC_P016 mmioFOURCC('P', '0', '1', '6')\n#define FOURCC_Y410 mmioFOURCC('Y', '4', '1', '0')\n#define FOURCC_Y416 mmioFOURCC('Y', '4', '1', '6')\n\nDEFINE_GUID_FOURCC(422P)\nDEFINE_GUID_FOURCC(444P)\nDEFINE_GUID_FOURCC(411P)\nDEFINE_GUID_FOURCC(410P)\nDEFINE_GUID_FOURCC(VYUY)\nDEFINE_GUID_FOURCC(Y800)\nDEFINE_GUID_FOURCC(NV21)\nDEFINE_GUID_FOURCC(YV16)\nDEFINE_GUID_FOURCC(YV24)\nDEFINE_GUID_FOURCC(Y410)\nDEFINE_GUID_FOURCC(Y416)\n"
  },
  {
    "path": "common/includes/version.h",
    "content": "#pragma once\n\n#include \"version_rev.h\"\n\n#define LAV_VERSION_MAJOR     0\n#define LAV_VERSION_MINOR    81\n#define LAV_VERSION_REVISION  0\n\n/////////////////////////////////////////////////////////\n#ifndef ISPP_INCLUDED\n\n#define DO_MAKE_STR(x) #x\n#define MAKE_STR(x) DO_MAKE_STR(x)\n\n#if LAV_VERSION_BUILD > 0\n#define LAV_VERSION LAV_VERSION_MAJOR.LAV_VERSION_MINOR.LAV_VERSION_REVISION.LAV_VERSION_BUILD-git\n#define LAV_VERSION_TAG LAV_VERSION_MAJOR, LAV_VERSION_MINOR, LAV_VERSION_REVISION, LAV_VERSION_BUILD\n#else\n#define LAV_VERSION LAV_VERSION_MAJOR.LAV_VERSION_MINOR.LAV_VERSION_REVISION\n#define LAV_VERSION_TAG LAV_VERSION_MAJOR, LAV_VERSION_MINOR, LAV_VERSION_REVISION\n#endif\n\n#define LAV_VERSION_STR MAKE_STR(LAV_VERSION)\n\n#endif\n"
  },
  {
    "path": "common/platform.props",
    "content": "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <PropertyGroup Label=\"Configuration\" Condition=\"'$(VisualStudioVersion)' == '15.0'\">\n    <PlatformToolset>v141</PlatformToolset>\n    <SpectreMitigation>false</SpectreMitigation>\n    <WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\" Condition=\"'$(VisualStudioVersion)' == '16.0'\">\n    <PlatformToolset>v142</PlatformToolset>\n    <SpectreMitigation>false</SpectreMitigation>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\" Condition=\"'$(VisualStudioVersion)' == '17.0'\">\n    <PlatformToolset>v143</PlatformToolset>\n    <SpectreMitigation>false</SpectreMitigation>\n    <WindowsTargetPlatformVersion>10.0</WindowsTargetPlatformVersion>\n  </PropertyGroup>\n  <PropertyGroup>\n    <UseNativeEnvironment>true</UseNativeEnvironment>\n  </PropertyGroup>\n  <PropertyGroup Label=\"Configuration\" Condition=\"'$(Configuration)'=='Debug'\">\n    <!-- EnableASAN>true</EnableASAN-->\n  </PropertyGroup>\n</Project>\n"
  },
  {
    "path": "decoder/LAVAudio/AudioSettingsProp.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"AudioSettingsProp.h\"\n#include \"Media.h\"\n\n#include <Commctrl.h>\n\n#include \"resource.h\"\n#include \"version.h\"\n\nCLAVAudioSettingsProp::CLAVAudioSettingsProp(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseDSPropPage(NAME(\"LAVCAudioProp\"), pUnk, IDD_PROPPAGE_AUDIO_SETTINGS, IDS_SETTINGS)\n{\n}\n\nCLAVAudioSettingsProp::~CLAVAudioSettingsProp()\n{\n}\n\nHRESULT CLAVAudioSettingsProp::OnConnect(IUnknown *pUnk)\n{\n    if (pUnk == nullptr)\n    {\n        return E_POINTER;\n    }\n    ASSERT(m_pAudioSettings == nullptr);\n    return pUnk->QueryInterface(&m_pAudioSettings);\n}\n\nHRESULT CLAVAudioSettingsProp::OnDisconnect()\n{\n    SafeRelease(&m_pAudioSettings);\n    return S_OK;\n}\n\nHRESULT CLAVAudioSettingsProp::OnApplyChanges()\n{\n    ASSERT(m_pAudioSettings != nullptr);\n    HRESULT hr = S_OK;\n    BOOL bFlag;\n\n    // DRC\n    int iDRCLevel = (int)SendDlgItemMessage(m_Dlg, IDC_DRC_LEVEL, TBM_GETPOS, 0, 0);\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_DRC, BM_GETCHECK, 0, 0);\n    hr = m_pAudioSettings->SetDRC(bFlag, iDRCLevel);\n\n    // Bitstreaming codec options\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BS_AC3, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetBitstreamConfig(Bitstream_AC3, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BS_EAC3, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetBitstreamConfig(Bitstream_EAC3, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BS_TRUEHD, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetBitstreamConfig(Bitstream_TRUEHD, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BS_DTS, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetBitstreamConfig(Bitstream_DTS, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BS_DTSHD, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetBitstreamConfig(Bitstream_DTSHD, bFlag);\n\n    // DTS-HD framing\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BS_DTSHD_FRAMING, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetDTSHDFraming(bFlag);\n\n    // Fallback to audio decoding\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BS_FALLBACK, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetBitstreamingFallback(bFlag);\n\n    // The other playback options\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_AUTO_AVSYNC, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetAutoAVSync(bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_STANDARD_CH_LAYOUT, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetOutputStandardLayout(bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUTPUT51_LEGACY, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetOutput51LegacyLayout(bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_EXPAND_MONO, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetExpandMono(bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_EXPAND61, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetExpand61(bFlag);\n\n    // Sample Formats\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_S16, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetSampleFormat(SampleFormat_16, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_S24, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetSampleFormat(SampleFormat_24, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_S32, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetSampleFormat(SampleFormat_32, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_FP32, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetSampleFormat(SampleFormat_FP32, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_U8, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetSampleFormat(SampleFormat_U8, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_S16_DITHER, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetSampleConvertDithering(bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_DELAY_ENABLED, BM_GETCHECK, 0, 0);\n    WCHAR buffer[100];\n    SendDlgItemMessage(m_Dlg, IDC_DELAY, WM_GETTEXT, 100, (LPARAM)&buffer);\n    int delay = _wtoi(buffer);\n    m_pAudioSettings->SetAudioDelay(bFlag, delay);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetTrayIcon(bFlag);\n\n    LoadData();\n\n    return hr;\n}\n\nHRESULT CLAVAudioSettingsProp::OnActivate()\n{\n    HRESULT hr = S_OK;\n    INITCOMMONCONTROLSEX icc;\n    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);\n    icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;\n    if (InitCommonControlsEx(&icc) == FALSE)\n    {\n        return E_FAIL;\n    }\n    ASSERT(m_pAudioSettings != nullptr);\n\n    const WCHAR *version = TEXT(LAV_AUDIO) L\" \" TEXT(LAV_VERSION_STR);\n    SendDlgItemMessage(m_Dlg, IDC_LAVAUDIO_FOOTER, WM_SETTEXT, 0, (LPARAM)version);\n\n    hr = LoadData();\n    if (SUCCEEDED(hr))\n    {\n        SendDlgItemMessage(m_Dlg, IDC_DRC, BM_SETCHECK, m_bDRCEnabled, 0);\n\n        EnableWindow(GetDlgItem(m_Dlg, IDC_DRC_LEVEL), m_bDRCEnabled);\n        SendDlgItemMessage(m_Dlg, IDC_DRC_LEVEL, TBM_SETRANGE, 0, MAKELONG(0, 100));\n        SendDlgItemMessage(m_Dlg, IDC_DRC_LEVEL, TBM_SETTICFREQ, 10, 0);\n        SendDlgItemMessage(m_Dlg, IDC_DRC_LEVEL, TBM_SETPOS, 1, m_iDRCLevel);\n\n        WCHAR buffer[10];\n        _snwprintf_s(buffer, _TRUNCATE, L\"%d%%\", m_iDRCLevel);\n        SendDlgItemMessage(m_Dlg, IDC_DRC_LEVEL_TEXT, WM_SETTEXT, 0, (LPARAM)buffer);\n\n        SendDlgItemMessage(m_Dlg, IDC_BS_AC3, BM_SETCHECK, m_bBitstreaming[Bitstream_AC3], 0);\n        SendDlgItemMessage(m_Dlg, IDC_BS_EAC3, BM_SETCHECK, m_bBitstreaming[Bitstream_EAC3], 0);\n        SendDlgItemMessage(m_Dlg, IDC_BS_TRUEHD, BM_SETCHECK, m_bBitstreaming[Bitstream_TRUEHD], 0);\n        SendDlgItemMessage(m_Dlg, IDC_BS_DTS, BM_SETCHECK, m_bBitstreaming[Bitstream_DTS], 0);\n        SendDlgItemMessage(m_Dlg, IDC_BS_DTSHD, BM_SETCHECK, m_bBitstreaming[Bitstream_DTSHD], 0);\n        EnableWindow(GetDlgItem(m_Dlg, IDC_BS_DTSHD), m_bBitstreaming[Bitstream_DTS]);\n\n        SendDlgItemMessage(m_Dlg, IDC_BS_DTSHD_FRAMING, BM_SETCHECK, m_bDTSHDFraming, 0);\n        EnableWindow(GetDlgItem(m_Dlg, IDC_BS_DTSHD_FRAMING), m_bBitstreaming[Bitstream_DTSHD]);\n        addHint(IDC_BS_DTSHD_FRAMING,\n                L\"With some Receivers, this setting might be needed to achieve the full features of DTS. However, on \"\n                L\"other Receivers, this option will cause DTS to not work at all.\\n\\nIf you do not experience any \"\n                L\"problems, its recommended to leave this setting untouched.\");\n\n        SendDlgItemMessage(m_Dlg, IDC_BS_FALLBACK, BM_SETCHECK, m_bBitstreamingFallback, 0);\n        addHint(IDC_BS_FALLBACK,\n                L\"Fallback to audio decoding if bitstreaming is not supported by the audio renderer/hardware.\");\n\n        SendDlgItemMessage(m_Dlg, IDC_AUTO_AVSYNC, BM_SETCHECK, m_bAutoAVSync, 0);\n        addHint(IDC_AUTO_AVSYNC, L\"Enables automatic tracking and correction of A/V sync.\\n\\nIf you encounter any sync \"\n                                 L\"issues, disabling this option can help in debugging the source of the problem.\");\n\n        SendDlgItemMessage(m_Dlg, IDC_STANDARD_CH_LAYOUT, BM_SETCHECK, m_bOutputStdLayout, 0);\n        addHint(IDC_STANDARD_CH_LAYOUT,\n                L\"Converts all channel layouts to one of the \\\"standard\\\" layouts (5.1/6.1/7.1) by adding silent \"\n                L\"channels. This is required for sending the PCM over HDMI if not using another downstream mixer, for \"\n                L\"example when using WASAPI.\");\n\n        SendDlgItemMessage(m_Dlg, IDC_OUTPUT51_LEGACY, BM_SETCHECK, m_bOutput51Legacy, 0);\n        addHint(IDC_OUTPUT51_LEGACY, L\"Use the legacy 5.1 channel layout which uses back channels instead of side \"\n                                     L\"channels, required for some audio devices and/or software.\");\n\n        SendDlgItemMessage(m_Dlg, IDC_EXPAND_MONO, BM_SETCHECK, m_bExpandMono, 0);\n        addHint(IDC_EXPAND_MONO, L\"Plays Mono Audio in both Left/Right Front channels, instead of the center.\");\n        SendDlgItemMessage(m_Dlg, IDC_EXPAND61, BM_SETCHECK, m_bExpand61, 0);\n        addHint(IDC_EXPAND61,\n                L\"Converts 6.1 Audio to 7.1 by copying the Back Center into both Back Left and Right channels.\");\n\n        SendDlgItemMessage(m_Dlg, IDC_OUT_S16, BM_SETCHECK, m_bSampleFormats[SampleFormat_16], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_S24, BM_SETCHECK, m_bSampleFormats[SampleFormat_24], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_S32, BM_SETCHECK, m_bSampleFormats[SampleFormat_32], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_FP32, BM_SETCHECK, m_bSampleFormats[SampleFormat_FP32], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_U8, BM_SETCHECK, m_bSampleFormats[SampleFormat_U8], 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_OUT_S16_DITHER, BM_SETCHECK, m_bDither, 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_DELAY_ENABLED, BM_SETCHECK, m_bAudioDelay, 0);\n        EnableWindow(GetDlgItem(m_Dlg, IDC_DELAYSPIN), m_bAudioDelay);\n        EnableWindow(GetDlgItem(m_Dlg, IDC_DELAY), m_bAudioDelay);\n\n        SendDlgItemMessage(m_Dlg, IDC_DELAYSPIN, UDM_SETRANGE32, -1000 * 60 * 60 * 24, 1000 * 60 * 60 * 24);\n\n        WCHAR stringBuffer[100];\n        swprintf_s(stringBuffer, L\"%d\", m_iAudioDelay);\n        SendDlgItemMessage(m_Dlg, IDC_DELAY, WM_SETTEXT, 0, (LPARAM)stringBuffer);\n\n        SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_SETCHECK, m_TrayIcon, 0);\n    }\n\n    return hr;\n}\n\nHRESULT CLAVAudioSettingsProp::LoadData()\n{\n    HRESULT hr = S_OK;\n    hr = m_pAudioSettings->GetDRC(&m_bDRCEnabled, &m_iDRCLevel);\n    for (unsigned i = 0; i < Bitstream_NB; ++i)\n        m_bBitstreaming[i] = m_pAudioSettings->GetBitstreamConfig((LAVBitstreamCodec)i) != 0;\n    m_bDTSHDFraming = m_pAudioSettings->GetDTSHDFraming();\n    m_bBitstreamingFallback = m_pAudioSettings->GetBitstreamingFallback();\n    m_bAutoAVSync = m_pAudioSettings->GetAutoAVSync();\n    m_bOutputStdLayout = m_pAudioSettings->GetOutputStandardLayout();\n    m_bOutput51Legacy = m_pAudioSettings->GetOutput51LegacyLayout();\n    m_bExpandMono = m_pAudioSettings->GetExpandMono();\n    m_bExpand61 = m_pAudioSettings->GetExpand61();\n\n    for (unsigned i = 0; i < SampleFormat_NB; ++i)\n        m_bSampleFormats[i] = m_pAudioSettings->GetSampleFormat((LAVAudioSampleFormat)i) != 0;\n    m_bDither = m_pAudioSettings->GetSampleConvertDithering();\n\n    m_pAudioSettings->GetAudioDelay(&m_bAudioDelay, &m_iAudioDelay);\n\n    m_TrayIcon = m_pAudioSettings->GetTrayIcon();\n\n    return hr;\n}\n\nINT_PTR CLAVAudioSettingsProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    LRESULT lValue;\n    switch (uMsg)\n    {\n    case WM_COMMAND:\n        if (LOWORD(wParam) == IDC_DRC && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, IDC_DRC, BM_GETCHECK, 0, 0);\n            if (lValue != m_bDRCEnabled)\n            {\n                SetDirty();\n            }\n            EnableWindow(GetDlgItem(m_Dlg, IDC_DRC_LEVEL), (BOOL)lValue);\n        }\n        else if (LOWORD(wParam) == IDC_BS_AC3 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bBitstreaming[Bitstream_AC3])\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_BS_EAC3 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bBitstreaming[Bitstream_EAC3])\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_BS_TRUEHD && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bBitstreaming[Bitstream_TRUEHD])\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_BS_DTS && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bBitstreaming[Bitstream_DTS])\n                SetDirty();\n            EnableWindow(GetDlgItem(m_Dlg, IDC_BS_DTSHD), bFlag);\n        }\n        else if (LOWORD(wParam) == IDC_BS_DTSHD && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bBitstreaming[Bitstream_DTSHD])\n                SetDirty();\n            EnableWindow(GetDlgItem(m_Dlg, IDC_BS_DTSHD_FRAMING), bFlag);\n        }\n        else if (LOWORD(wParam) == IDC_BS_DTSHD_FRAMING && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bDTSHDFraming)\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_BS_FALLBACK && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bBitstreamingFallback)\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_AUTO_AVSYNC && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bAutoAVSync)\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_STANDARD_CH_LAYOUT && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bOutputStdLayout)\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_OUTPUT51_LEGACY && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bOutput51Legacy)\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_EXPAND_MONO && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bExpandMono)\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_EXPAND61 && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bExpand61)\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_OUT_S16 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bSampleFormats[SampleFormat_16])\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_OUT_S24 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bSampleFormats[SampleFormat_24])\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_OUT_S32 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bSampleFormats[SampleFormat_32])\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_OUT_FP32 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bSampleFormats[SampleFormat_FP32])\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_OUT_U8 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bool bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_bSampleFormats[SampleFormat_U8])\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_OUT_S16_DITHER && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bDither)\n                SetDirty();\n        }\n        else if (LOWORD(wParam) == IDC_DELAY_ENABLED && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bFlag != m_bAudioDelay)\n                SetDirty();\n            EnableWindow(GetDlgItem(m_Dlg, IDC_DELAYSPIN), bFlag);\n            EnableWindow(GetDlgItem(m_Dlg, IDC_DELAY), bFlag);\n        }\n        else if (LOWORD(wParam) == IDC_DELAY && HIWORD(wParam) == EN_CHANGE)\n        {\n            WCHAR buffer[100];\n            SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, 100, (LPARAM)&buffer);\n            int delay = _wtoi(buffer);\n            size_t len = wcslen(buffer);\n            if (delay == 0 && (buffer[0] != L'0' || len > 1))\n            {\n                SendDlgItemMessage(m_Dlg, LOWORD(wParam), EM_UNDO, 0, 0);\n            }\n            else\n            {\n                swprintf_s(buffer, L\"%d\", delay);\n                if (wcslen(buffer) != len)\n                    SendDlgItemMessage(m_Dlg, IDC_DELAY, WM_SETTEXT, 0, (LPARAM)buffer);\n                if (delay != m_iAudioDelay)\n                    SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_TRAYICON && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0) != 0;\n            if (bFlag != m_TrayIcon)\n                SetDirty();\n        }\n\n        break;\n    case WM_HSCROLL:\n        lValue = SendDlgItemMessage(m_Dlg, IDC_DRC_LEVEL, TBM_GETPOS, 0, 0);\n        if (lValue != m_iDRCLevel)\n        {\n            SetDirty();\n        }\n        WCHAR buffer[10];\n        _snwprintf_s(buffer, _TRUNCATE, L\"%d%%\", (int)lValue);\n        SendDlgItemMessage(m_Dlg, IDC_DRC_LEVEL_TEXT, WM_SETTEXT, 0, (LPARAM)buffer);\n        break;\n    }\n    // Let the parent class handle the message.\n    return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n// Mixer Configurations\n\nCLAVAudioMixingProp::CLAVAudioMixingProp(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseDSPropPage(NAME(\"LAVCAudioMixing\"), pUnk, IDD_PROPPAGE_AUDIO_MIXING, IDS_MIXER)\n{\n}\n\nCLAVAudioMixingProp::~CLAVAudioMixingProp()\n{\n}\n\nHRESULT CLAVAudioMixingProp::OnConnect(IUnknown *pUnk)\n{\n    if (pUnk == nullptr)\n    {\n        return E_POINTER;\n    }\n    ASSERT(m_pAudioSettings == nullptr);\n    return pUnk->QueryInterface(&m_pAudioSettings);\n}\n\nHRESULT CLAVAudioMixingProp::OnDisconnect()\n{\n    SafeRelease(&m_pAudioSettings);\n    return S_OK;\n}\n\nstatic DWORD dwSpkLayouts[] = {\n    AV_CH_LAYOUT_MONO,    AV_CH_LAYOUT_STEREO,  AV_CH_LAYOUT_2_2,\n    AV_CH_LAYOUT_5POINT1, AV_CH_LAYOUT_6POINT1, AV_CH_LAYOUT_7POINT1,\n};\nstatic DWORD get_speaker_index(DWORD dwLayout)\n{\n    int i = 0;\n    for (i = 0; i < countof(dwSpkLayouts); i++)\n    {\n        if (dwSpkLayouts[i] == dwLayout)\n            return i;\n    }\n    return (DWORD)-1;\n}\n\nHRESULT CLAVAudioMixingProp::OnApplyChanges()\n{\n    ASSERT(m_pAudioSettings != nullptr);\n    HRESULT hr = S_OK;\n    DWORD dwVal = 0;\n    BOOL bVal = FALSE;\n\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_GETCURSEL, 0, 0);\n    if (dwVal >= 0 && dwVal < countof(dwSpkLayouts))\n        m_pAudioSettings->SetMixingLayout(dwSpkLayouts[dwVal]);\n\n    bVal = (BOOL)SendDlgItemMessage(m_Dlg, IDC_MIXING, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetMixingEnabled(bVal);\n\n    DWORD dwMixingFlags = 0;\n    bVal = (BOOL)SendDlgItemMessage(m_Dlg, IDC_UNTOUCHED_STEREO, BM_GETCHECK, 0, 0);\n    if (bVal)\n        dwMixingFlags |= LAV_MIXING_FLAG_UNTOUCHED_STEREO;\n\n    bVal = (BOOL)SendDlgItemMessage(m_Dlg, IDC_NORMALIZE_MATRIX, BM_GETCHECK, 0, 0);\n    if (bVal)\n        dwMixingFlags |= LAV_MIXING_FLAG_NORMALIZE_MATRIX;\n\n    bVal = (BOOL)SendDlgItemMessage(m_Dlg, IDC_CLIP_PROTECTION, BM_GETCHECK, 0, 0);\n    if (bVal)\n        dwMixingFlags |= LAV_MIXING_FLAG_CLIP_PROTECTION;\n\n    m_pAudioSettings->SetMixingFlags(dwMixingFlags);\n\n    BOOL bNormal = (BOOL)SendDlgItemMessage(m_Dlg, IDC_MIXMODE_NORMAL, BM_GETCHECK, 0, 0);\n    BOOL bDolby = (BOOL)SendDlgItemMessage(m_Dlg, IDC_MIXMODE_DOLBY, BM_GETCHECK, 0, 0);\n    BOOL bDPL2 = (BOOL)SendDlgItemMessage(m_Dlg, IDC_MIXMODE_DPL2, BM_GETCHECK, 0, 0);\n    m_pAudioSettings->SetMixingMode(bDolby ? MatrixEncoding_Dolby\n                                           : (bDPL2 ? MatrixEncoding_DPLII : MatrixEncoding_None));\n\n    DWORD dwMixCenter = (DWORD)SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER, TBM_GETPOS, 0, 0);\n    DWORD dwMixSurround = (DWORD)SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND, TBM_GETPOS, 0, 0);\n    DWORD dwMixLFE = (DWORD)SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE, TBM_GETPOS, 0, 0);\n    m_pAudioSettings->SetMixingLevels(dwMixCenter, dwMixSurround, dwMixLFE);\n\n    LoadData();\n\n    return hr;\n}\n\nHRESULT CLAVAudioMixingProp::OnActivate()\n{\n    HRESULT hr = S_OK;\n    INITCOMMONCONTROLSEX icc;\n    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);\n    icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;\n    if (InitCommonControlsEx(&icc) == FALSE)\n    {\n        return E_FAIL;\n    }\n    ASSERT(m_pAudioSettings != nullptr);\n\n    WCHAR spkMono[] = L\"Mono\";\n    WCHAR spkStereo[] = L\"Stereo\";\n    WCHAR spkQuadro[] = L\"4.0\";\n    WCHAR spk51Surround[] = L\"5.1\";\n    WCHAR spk61Surround[] = L\"6.1\";\n    WCHAR spk71Surround[] = L\"7.1\";\n\n    SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_RESETCONTENT, 0, 0);\n    SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_ADDSTRING, 0, (LPARAM)spkMono);\n    SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_ADDSTRING, 0, (LPARAM)spkStereo);\n    SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_ADDSTRING, 0, (LPARAM)spkQuadro);\n    SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_ADDSTRING, 0, (LPARAM)spk51Surround);\n    SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_ADDSTRING, 0, (LPARAM)spk61Surround);\n    SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_ADDSTRING, 0, (LPARAM)spk71Surround);\n\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER, TBM_SETRANGE, 0, MAKELONG(0, 10000));\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER, TBM_SETTICFREQ, 100, 0);\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER, TBM_SETLINESIZE, 0, 100);\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER, TBM_SETPAGESIZE, 0, 100);\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND, TBM_SETRANGE, 0, MAKELONG(0, 10000));\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND, TBM_SETTICFREQ, 100, 0);\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND, TBM_SETLINESIZE, 0, 100);\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND, TBM_SETPAGESIZE, 0, 100);\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE, TBM_SETRANGE, 0, MAKELONG(0, 30000));\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE, TBM_SETTICFREQ, 100, 0);\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE, TBM_SETLINESIZE, 0, 100);\n    SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE, TBM_SETPAGESIZE, 0, 100);\n\n    addHint(IDC_UNTOUCHED_STEREO, L\"With this option on, stereo sources will not be mixed. This is useful when you \"\n                                  L\"want to mix all surround sources to e.g. 5.1, but leave stereo untouched.\");\n    addHint(IDC_NORMALIZE_MATRIX,\n            L\"Normalizing the matrix will apply a global attenuation to the audio, in effect making it quieter to \"\n            L\"ensure that there is a consistent volume throughout the file, and no clipping occurs.\\n\\n\"\n            L\"This mode will produce inconsistent volumes between different source formats (stereo will be louder than \"\n            L\"5.1), but the volume during playback of one file will not change.\");\n    addHint(IDC_CLIP_PROTECTION,\n            L\"Clipping protection analyzes the audio, and reduces the volume if clipping is detected.\\n\\n\"\n            L\"This mode tries to preserve the original volume of the audio, and is generally more consistent between \"\n            L\"different source formats. It may however cause a sudden volume change during playback. \"\n            L\"In addition, this mode has a higher volume than a normalized matrix and is preferred on weak speakers or \"\n            L\"headphones.\");\n\n    hr = LoadData();\n    if (SUCCEEDED(hr))\n    {\n        SendDlgItemMessage(m_Dlg, IDC_MIXING, BM_SETCHECK, m_bMixing, 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SPEAKERS, CB_SETCURSEL, get_speaker_index(m_dwSpeakerLayout), 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_UNTOUCHED_STEREO, BM_SETCHECK, !!(m_dwFlags & LAV_MIXING_FLAG_UNTOUCHED_STEREO),\n                           0);\n        SendDlgItemMessage(m_Dlg, IDC_NORMALIZE_MATRIX, BM_SETCHECK, !!(m_dwFlags & LAV_MIXING_FLAG_NORMALIZE_MATRIX),\n                           0);\n        SendDlgItemMessage(m_Dlg, IDC_CLIP_PROTECTION, BM_SETCHECK, !!(m_dwFlags & LAV_MIXING_FLAG_CLIP_PROTECTION), 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_MIXMODE_NORMAL, BM_SETCHECK, (m_dwMixingMode == MatrixEncoding_None), 0);\n        SendDlgItemMessage(m_Dlg, IDC_MIXMODE_DOLBY, BM_SETCHECK, (m_dwMixingMode == MatrixEncoding_Dolby), 0);\n        SendDlgItemMessage(m_Dlg, IDC_MIXMODE_DPL2, BM_SETCHECK, (m_dwMixingMode == MatrixEncoding_DPLII), 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER, TBM_SETPOS, 1, m_dwMixCenter);\n        SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND, TBM_SETPOS, 1, m_dwMixSurround);\n        SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE, TBM_SETPOS, 1, m_dwMixLFE);\n\n        WCHAR buffer[10];\n        _snwprintf_s(buffer, _TRUNCATE, L\"%.2f\", (double)m_dwMixCenter / 10000.0);\n        SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER_TEXT, WM_SETTEXT, 0, (LPARAM)buffer);\n        _snwprintf_s(buffer, _TRUNCATE, L\"%.2f\", (double)m_dwMixSurround / 10000.0);\n        SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND_TEXT, WM_SETTEXT, 0, (LPARAM)buffer);\n        _snwprintf_s(buffer, _TRUNCATE, L\"%.2f\", (double)m_dwMixLFE / 10000.0);\n        SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE_TEXT, WM_SETTEXT, 0, (LPARAM)buffer);\n    }\n\n    return hr;\n}\n\nHRESULT CLAVAudioMixingProp::LoadData()\n{\n    HRESULT hr = S_OK;\n\n    m_dwSpeakerLayout = m_pAudioSettings->GetMixingLayout();\n    m_bMixing = m_pAudioSettings->GetMixingEnabled();\n    m_dwFlags = m_pAudioSettings->GetMixingFlags();\n    m_dwMixingMode = m_pAudioSettings->GetMixingMode();\n    m_pAudioSettings->GetMixingLevels(&m_dwMixCenter, &m_dwMixSurround, &m_dwMixLFE);\n\n    return hr;\n}\n\nINT_PTR CLAVAudioMixingProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    LRESULT lValue;\n    switch (uMsg)\n    {\n    case WM_COMMAND:\n        if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_OUTPUT_SPEAKERS)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);\n            if (dwSpkLayouts[lValue] != m_dwSpeakerLayout)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_MIXING && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != m_bMixing)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_UNTOUCHED_STEREO && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue == !(m_dwFlags & LAV_MIXING_FLAG_UNTOUCHED_STEREO))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_NORMALIZE_MATRIX && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue == !(m_dwFlags & LAV_MIXING_FLAG_NORMALIZE_MATRIX))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_CLIP_PROTECTION && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue == !(m_dwFlags & LAV_MIXING_FLAG_CLIP_PROTECTION))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_MIXMODE_NORMAL && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != (m_dwMixingMode == MatrixEncoding_None))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_MIXMODE_DOLBY && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != (m_dwMixingMode == MatrixEncoding_Dolby))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_MIXMODE_DPL2 && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != (m_dwMixingMode == MatrixEncoding_DPLII))\n            {\n                SetDirty();\n            }\n        }\n        break;\n    case WM_HSCROLL:\n        if ((HWND)lParam == GetDlgItem(m_Dlg, IDC_MIX_LEVEL_CENTER))\n        {\n            lValue = SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER, TBM_GETPOS, 0, 0);\n            if (lValue != m_dwMixCenter)\n            {\n                SetDirty();\n            }\n            WCHAR buffer[10];\n            _snwprintf_s(buffer, _TRUNCATE, L\"%.2f\", (double)lValue / 10000.0);\n            SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_CENTER_TEXT, WM_SETTEXT, 0, (LPARAM)buffer);\n        }\n        else if ((HWND)lParam == GetDlgItem(m_Dlg, IDC_MIX_LEVEL_SURROUND))\n        {\n            lValue = SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND, TBM_GETPOS, 0, 0);\n            if (lValue != m_dwMixSurround)\n            {\n                SetDirty();\n            }\n            WCHAR buffer[10];\n            _snwprintf_s(buffer, _TRUNCATE, L\"%.2f\", (double)lValue / 10000.0);\n            SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_SURROUND_TEXT, WM_SETTEXT, 0, (LPARAM)buffer);\n        }\n        else if ((HWND)lParam == GetDlgItem(m_Dlg, IDC_MIX_LEVEL_LFE))\n        {\n            lValue = SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE, TBM_GETPOS, 0, 0);\n            if (lValue != m_dwMixLFE)\n            {\n                SetDirty();\n            }\n            WCHAR buffer[10];\n            _snwprintf_s(buffer, _TRUNCATE, L\"%.2f\", (double)lValue / 10000.0);\n            SendDlgItemMessage(m_Dlg, IDC_MIX_LEVEL_LFE_TEXT, WM_SETTEXT, 0, (LPARAM)buffer);\n        }\n        break;\n    }\n    // Let the parent class handle the message.\n    return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n// Format Configurations\n\nCLAVAudioFormatsProp::CLAVAudioFormatsProp(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseDSPropPage(NAME(\"LAVCAudioFormats\"), pUnk, IDD_PROPPAGE_FORMATS, IDS_FORMATS)\n{\n}\n\nCLAVAudioFormatsProp::~CLAVAudioFormatsProp()\n{\n}\n\nHRESULT CLAVAudioFormatsProp::OnConnect(IUnknown *pUnk)\n{\n    if (pUnk == nullptr)\n    {\n        return E_POINTER;\n    }\n    ASSERT(m_pAudioSettings == nullptr);\n    return pUnk->QueryInterface(&m_pAudioSettings);\n}\n\nHRESULT CLAVAudioFormatsProp::OnDisconnect()\n{\n    SafeRelease(&m_pAudioSettings);\n    return S_OK;\n}\n\nHRESULT CLAVAudioFormatsProp::OnApplyChanges()\n{\n    ASSERT(m_pAudioSettings != nullptr);\n    HRESULT hr = S_OK;\n\n    HWND hlv = GetDlgItem(m_Dlg, IDC_CODECS);\n\n    // Get checked state\n    BOOL bFlag;\n    for (int nItem = 0; nItem < ListView_GetItemCount(hlv); nItem++)\n    {\n        bFlag = ListView_GetCheckState(hlv, nItem);\n        m_pAudioSettings->SetFormatConfiguration((LAVAudioCodec)nItem, bFlag);\n    }\n\n    LoadData();\n\n    return hr;\n}\n\nHRESULT CLAVAudioFormatsProp::OnActivate()\n{\n    HRESULT hr = S_OK;\n    INITCOMMONCONTROLSEX icc;\n    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);\n    icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES | ICC_LISTVIEW_CLASSES;\n    if (InitCommonControlsEx(&icc) == FALSE)\n    {\n        return E_FAIL;\n    }\n    ASSERT(m_pAudioSettings != nullptr);\n\n    // Setup ListView control for format configuration\n    SendDlgItemMessage(m_Dlg, IDC_CODECS, CCM_DPISCALE, TRUE, 0);\n\n    HWND hlv = GetDlgItem(m_Dlg, IDC_CODECS);\n    ListView_SetExtendedListViewStyle(hlv, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);\n\n    int nCol = 1;\n    LVCOLUMN lvc = {LVCF_WIDTH, 0, 20, 0};\n    ListView_InsertColumn(hlv, 0, &lvc);\n    ListView_AddCol(hlv, nCol, 75, L\"Codec\", false);\n    ListView_AddCol(hlv, nCol, 350, L\"Description\", false);\n\n    ListView_DeleteAllItems(hlv);\n    ListView_SetItemCount(hlv, Codec_AudioNB);\n\n    // Create entries for the formats\n    LVITEM lvi;\n    memset(&lvi, 0, sizeof(lvi));\n    lvi.mask = LVIF_TEXT | LVIF_PARAM;\n\n    int nItem = 0;\n    for (nItem = 0; nItem < Codec_AudioNB; ++nItem)\n    {\n        const codec_config_t *config = get_codec_config((LAVAudioCodec)nItem);\n\n        // Create main entry\n        lvi.iItem = nItem + 1;\n        ListView_InsertItem(hlv, &lvi);\n\n        // Set sub item texts\n        ATL::CA2W name(config->name);\n        ListView_SetItemText(hlv, nItem, 1, (LPWSTR)name);\n\n        ATL::CA2W desc(config->description);\n        ListView_SetItemText(hlv, nItem, 2, (LPWSTR)desc);\n    }\n\n    hr = LoadData();\n    if (SUCCEEDED(hr))\n    {\n        // Set checked state\n        for (nItem = 0; nItem < ListView_GetItemCount(hlv); nItem++)\n        {\n            ListView_SetCheckState(hlv, nItem, m_bFormats[nItem]);\n        }\n    }\n\n    return hr;\n}\n\nHRESULT CLAVAudioFormatsProp::LoadData()\n{\n    HRESULT hr = S_OK;\n    for (unsigned i = 0; i < Codec_AudioNB; ++i)\n        m_bFormats[i] = m_pAudioSettings->GetFormatConfiguration((LAVAudioCodec)i) != 0;\n    return hr;\n}\n\nINT_PTR CLAVAudioFormatsProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    switch (uMsg)\n    {\n    case WM_NOTIFY:\n        NMHDR *hdr = (LPNMHDR)lParam;\n        if (hdr->idFrom == IDC_CODECS)\n        {\n            switch (hdr->code)\n            {\n            case LVN_ITEMCHANGED:\n                LPNMLISTVIEW nmlv = (LPNMLISTVIEW)lParam;\n                bool check = ListView_GetCheckState(hdr->hwndFrom, nmlv->iItem) ? true : false;\n                if (check != m_bFormats[nmlv->iItem])\n                {\n                    SetDirty();\n                }\n                return TRUE;\n            }\n        }\n        break;\n    }\n    // Let the parent class handle the message.\n    return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n// Audio Status Panel\n\n#define MAX_CHANNELS 8\nstatic int iddVolumeControls[MAX_CHANNELS] = {IDC_VOLUME1, IDC_VOLUME2, IDC_VOLUME3, IDC_VOLUME4,\n                                              IDC_VOLUME5, IDC_VOLUME6, IDC_VOLUME7, IDC_VOLUME8};\nstatic int iddVolumeDescs[MAX_CHANNELS] = {IDC_VOLUME1_DESC, IDC_VOLUME2_DESC, IDC_VOLUME3_DESC, IDC_VOLUME4_DESC,\n                                           IDC_VOLUME5_DESC, IDC_VOLUME6_DESC, IDC_VOLUME7_DESC, IDC_VOLUME8_DESC};\n\nCLAVAudioStatusProp::CLAVAudioStatusProp(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseDSPropPage(NAME(\"LAVCAudioStatusProp\"), pUnk, IDD_PROPPAGE_STATUS, IDS_STATUS)\n{\n}\n\nCLAVAudioStatusProp::~CLAVAudioStatusProp()\n{\n}\n\nHRESULT CLAVAudioStatusProp::OnConnect(IUnknown *pUnk)\n{\n    if (pUnk == nullptr)\n    {\n        return E_POINTER;\n    }\n    ASSERT(m_pAudioStatus == nullptr);\n    return pUnk->QueryInterface(&m_pAudioStatus);\n}\n\nHRESULT CLAVAudioStatusProp::OnDisconnect()\n{\n    SafeRelease(&m_pAudioStatus);\n    return S_OK;\n}\n\nHRESULT CLAVAudioStatusProp::OnActivate()\n{\n    HRESULT hr = S_OK;\n    INITCOMMONCONTROLSEX icc;\n    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);\n    icc.dwICC = ICC_STANDARD_CLASSES | ICC_BAR_CLASSES;\n    if (InitCommonControlsEx(&icc) == FALSE)\n    {\n        return E_FAIL;\n    }\n    ASSERT(m_pAudioStatus != nullptr);\n\n    m_nChannels = 0;\n\n    const char *codec = nullptr;\n    const char *decodeFormat = nullptr;\n    int nDecodeChannels = 0;\n    int nDecodeSampleRate = 0;\n    DWORD dwDecodeChannelMask;\n    hr = m_pAudioStatus->GetDecodeDetails(&codec, &decodeFormat, &nDecodeChannels, &nDecodeSampleRate,\n                                          &dwDecodeChannelMask);\n    if (SUCCEEDED(hr))\n    {\n        WCHAR buffer[100];\n        _snwprintf_s(buffer, _TRUNCATE, L\"%d / 0x%x\", nDecodeChannels, dwDecodeChannelMask);\n        SendDlgItemMessage(m_Dlg, IDC_INPUT_CHANNEL, WM_SETTEXT, 0, (LPARAM)buffer);\n\n        _snwprintf_s(buffer, _TRUNCATE, L\"%d\", nDecodeSampleRate);\n        SendDlgItemMessage(m_Dlg, IDC_INPUT_SAMPLERATE, WM_SETTEXT, 0, (LPARAM)buffer);\n\n        _snwprintf_s(buffer, _TRUNCATE, L\"%S\", codec);\n        SendDlgItemMessage(m_Dlg, IDC_INPUT_CODEC, WM_SETTEXT, 0, (LPARAM)buffer);\n\n        _snwprintf_s(buffer, _TRUNCATE, L\"%S\", decodeFormat);\n        SendDlgItemMessage(m_Dlg, IDC_INPUT_FORMAT, WM_SETTEXT, 0, (LPARAM)buffer);\n    }\n\n    const char *outputFormat = nullptr;\n    int nOutputChannels = 0;\n    int nOutputSampleRate = 0;\n    DWORD dwOutputChannelMask = 0;\n    hr = m_pAudioStatus->GetOutputDetails(&outputFormat, &nOutputChannels, &nOutputSampleRate, &dwOutputChannelMask);\n    if (SUCCEEDED(hr))\n    {\n        WCHAR buffer[100];\n\n        if (hr == S_OK)\n        {\n            _snwprintf_s(buffer, _TRUNCATE, L\"%d / 0x%x\", nOutputChannels, dwOutputChannelMask);\n            SendDlgItemMessage(m_Dlg, IDC_OUTPUT_CHANNEL, WM_SETTEXT, 0, (LPARAM)buffer);\n\n            _snwprintf_s(buffer, _TRUNCATE, L\"%d\", nOutputSampleRate);\n            SendDlgItemMessage(m_Dlg, IDC_OUTPUT_SAMPLERATE, WM_SETTEXT, 0, (LPARAM)buffer);\n\n            _snwprintf_s(buffer, _TRUNCATE, L\"PCM\");\n            SendDlgItemMessage(m_Dlg, IDC_OUTPUT_CODEC, WM_SETTEXT, 0, (LPARAM)buffer);\n\n            _snwprintf_s(buffer, _TRUNCATE, L\"%S\", outputFormat);\n            SendDlgItemMessage(m_Dlg, IDC_OUTPUT_FORMAT, WM_SETTEXT, 0, (LPARAM)buffer);\n\n            m_nChannels = nOutputChannels;\n        }\n        else\n        {\n            _snwprintf_s(buffer, _TRUNCATE, L\"Bitstreaming\");\n            SendDlgItemMessage(m_Dlg, IDC_OUTPUT_CODEC, WM_SETTEXT, 0, (LPARAM)buffer);\n        }\n    }\n\n    SetTimer(m_Dlg, 1, 250, nullptr);\n    m_pAudioStatus->EnableVolumeStats();\n\n    WCHAR chBuffer[5];\n    if (dwOutputChannelMask == 0 && nOutputChannels != 0)\n    {\n        // 0x4 is only front center, 0x3 is front left+right\n        dwOutputChannelMask = nOutputChannels == 1 ? 0x4 : 0x3;\n    }\n    for (int i = 0; i < MAX_CHANNELS; ++i)\n    {\n        SendDlgItemMessage(m_Dlg, iddVolumeControls[i], PBM_SETRANGE, 0, MAKELPARAM(0, 50));\n        _snwprintf_s(chBuffer, _TRUNCATE, L\"%S\", get_channel_desc(get_flag_from_channel(dwOutputChannelMask, i)));\n        SendDlgItemMessage(m_Dlg, iddVolumeDescs[i], WM_SETTEXT, 0, (LPARAM)chBuffer);\n    }\n\n    return hr;\n}\n\nHRESULT CLAVAudioStatusProp::OnDeactivate()\n{\n    KillTimer(m_Dlg, 1);\n    m_pAudioStatus->DisableVolumeStats();\n    return S_OK;\n}\n\nvoid CLAVAudioStatusProp::UpdateVolumeDisplay()\n{\n    for (int i = 0; i < m_nChannels; ++i)\n    {\n        float fDB = 0.0f;\n        if (SUCCEEDED(m_pAudioStatus->GetChannelVolumeAverage(i, &fDB)))\n        {\n            int value = (int)fDB + 50;\n            SendDlgItemMessage(m_Dlg, iddVolumeControls[i], PBM_SETPOS, value, 0);\n        }\n        else\n        {\n            SendDlgItemMessage(m_Dlg, iddVolumeControls[i], PBM_SETPOS, 0, 0);\n        }\n    }\n}\n\nINT_PTR CLAVAudioStatusProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    switch (uMsg)\n    {\n    case WM_TIMER: UpdateVolumeDisplay(); break;\n    }\n    // Let the parent class handle the message.\n    return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n"
  },
  {
    "path": "decoder/LAVAudio/AudioSettingsProp.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"LAVAudioSettings.h\"\n#include \"BaseDSPropPage.h\"\n#include \"Media.h\"\n\n// {2D8F1801-A70D-48F4-B76B-7F5AE022AB54}\nDEFINE_GUID(CLSID_LAVAudioSettingsProp, 0x2d8f1801, 0xa70d, 0x48f4, 0xb7, 0x6b, 0x7f, 0x5a, 0xe0, 0x22, 0xab, 0x54);\n\n// {C89FC33C-E60A-4C97-BEF4-ACC5762B6404}\nDEFINE_GUID(CLSID_LAVAudioMixingProp, 0xc89fc33c, 0xe60a, 0x4c97, 0xbe, 0xf4, 0xac, 0xc5, 0x76, 0x2b, 0x64, 0x4);\n\n// {20ED4A03-6AFD-4FD9-980B-2F6143AA0892}\nDEFINE_GUID(CLSID_LAVAudioStatusProp, 0x20ed4a03, 0x6afd, 0x4fd9, 0x98, 0xb, 0x2f, 0x61, 0x43, 0xaa, 0x8, 0x92);\n\n// {BD72668E-6BFF-4CD1-8480-D465708B336B}\nDEFINE_GUID(CLSID_LAVAudioFormatsProp, 0xbd72668e, 0x6bff, 0x4cd1, 0x84, 0x80, 0xd4, 0x65, 0x70, 0x8b, 0x33, 0x6b);\n\nclass CLAVAudioSettingsProp : public CBaseDSPropPage\n{\n  public:\n    CLAVAudioSettingsProp(LPUNKNOWN pUnk, HRESULT *phr);\n    ~CLAVAudioSettingsProp();\n\n    HRESULT OnActivate();\n    HRESULT OnConnect(IUnknown *pUnk);\n    HRESULT OnDisconnect();\n    HRESULT OnApplyChanges();\n    INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    HRESULT LoadData();\n\n    void SetDirty()\n    {\n        m_bDirty = TRUE;\n        if (m_pPageSite)\n        {\n            m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);\n        }\n    }\n\n  private:\n    ILAVAudioSettings *m_pAudioSettings = nullptr;\n\n    BOOL m_bDRCEnabled;\n    int m_iDRCLevel;\n\n    bool m_bBitstreaming[Bitstream_NB];\n    BOOL m_bDTSHDFraming;\n    BOOL m_bBitstreamingFallback;\n    BOOL m_bAutoAVSync;\n    BOOL m_bOutputStdLayout;\n    BOOL m_bOutput51Legacy;\n    BOOL m_bExpandMono;\n    BOOL m_bExpand61;\n    bool m_bSampleFormats[SampleFormat_NB];\n    BOOL m_bDither;\n    BOOL m_bAudioDelay;\n    int m_iAudioDelay;\n    BOOL m_TrayIcon;\n};\n\nclass CLAVAudioMixingProp : public CBaseDSPropPage\n{\n  public:\n    CLAVAudioMixingProp(LPUNKNOWN pUnk, HRESULT *phr);\n    ~CLAVAudioMixingProp();\n\n    HRESULT OnActivate();\n    HRESULT OnConnect(IUnknown *pUnk);\n    HRESULT OnDisconnect();\n    HRESULT OnApplyChanges();\n    INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    HRESULT LoadData();\n\n    void SetDirty()\n    {\n        m_bDirty = TRUE;\n        if (m_pPageSite)\n        {\n            m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);\n        }\n    }\n\n  private:\n    ILAVAudioSettings *m_pAudioSettings = nullptr;\n\n    BOOL m_bMixing;\n    DWORD m_dwSpeakerLayout;\n    DWORD m_dwFlags;\n    DWORD m_dwMixingMode;\n    DWORD m_dwMixCenter;\n    DWORD m_dwMixSurround;\n    DWORD m_dwMixLFE;\n};\n\nclass CLAVAudioFormatsProp : public CBaseDSPropPage\n{\n  public:\n    CLAVAudioFormatsProp(LPUNKNOWN pUnk, HRESULT *phr);\n    ~CLAVAudioFormatsProp();\n\n    HRESULT OnActivate();\n    HRESULT OnConnect(IUnknown *pUnk);\n    HRESULT OnDisconnect();\n    HRESULT OnApplyChanges();\n    INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    HRESULT LoadData();\n\n    void SetDirty()\n    {\n        m_bDirty = TRUE;\n        if (m_pPageSite)\n        {\n            m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);\n        }\n    }\n\n  private:\n    ILAVAudioSettings *m_pAudioSettings = nullptr;\n\n    bool m_bFormats[Codec_AudioNB];\n};\n\nclass CLAVAudioStatusProp : public CBaseDSPropPage\n{\n  public:\n    CLAVAudioStatusProp(LPUNKNOWN pUnk, HRESULT *phr);\n    ~CLAVAudioStatusProp();\n\n    HRESULT OnActivate();\n    HRESULT OnDeactivate();\n    HRESULT OnConnect(IUnknown *pUnk);\n    HRESULT OnDisconnect();\n    INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    void UpdateVolumeDisplay();\n\n  private:\n    ILAVAudioStatus *m_pAudioStatus = nullptr;\n    int m_nChannels = 0;\n};\n"
  },
  {
    "path": "decoder/LAVAudio/Bitstream.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVAudio.h\"\n\n#include <MMReg.h>\n#include \"moreuuids.h\"\n\n#define LAV_BITSTREAM_BUFFER_SIZE 4096\n#define LAV_BITSTREAM_DTS_HD_HR_RATE 192000\n#define LAV_BITSTREAM_DTS_HD_MA_RATE 768000\n\nstatic struct\n{\n    AVCodecID codec;\n    LAVBitstreamCodec config;\n} lavf_bitstream_config[] = {\n    {AV_CODEC_ID_AC3, Bitstream_AC3},\n    {AV_CODEC_ID_EAC3, Bitstream_EAC3},\n    {AV_CODEC_ID_TRUEHD, Bitstream_TRUEHD},\n    {AV_CODEC_ID_DTS, Bitstream_DTS} // DTS-HD is still DTS, and handled special below\n};\n\n// Check whether a codec is bitstreaming eligible and enabled\nBOOL CLAVAudio::IsBitstreaming(AVCodecID codec)\n{\n    for (int i = 0; i < countof(lavf_bitstream_config); ++i)\n    {\n        if (lavf_bitstream_config[i].codec == codec)\n        {\n            return m_bBitstreamOverride[lavf_bitstream_config[i].config]\n                       ? FALSE\n                       : m_settings.bBitstream[lavf_bitstream_config[i].config];\n        }\n    }\n    return FALSE;\n}\n\nHRESULT CLAVAudio::InitBitstreaming()\n{\n    // Alloc buffer for the AVIO context\n    BYTE *buffer = (BYTE *)CoTaskMemAlloc(LAV_BITSTREAM_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);\n    if (!buffer)\n        return E_OUTOFMEMORY;\n\n    // Create AVIO context\n    m_avioBitstream = avio_alloc_context(buffer, LAV_BITSTREAM_BUFFER_SIZE, 1, this, nullptr, BSWriteBuffer, nullptr);\n    if (!m_avioBitstream)\n    {\n        SAFE_CO_FREE(buffer);\n        return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::ShutdownBitstreaming()\n{\n    if (m_avioBitstream)\n    {\n        SAFE_CO_FREE(m_avioBitstream->buffer);\n        av_freep(&m_avioBitstream);\n    }\n    return S_OK;\n}\n\n// Static function for the AVIO context that writes the buffer into our own output buffer\nint CLAVAudio::BSWriteBuffer(void *opaque, const uint8_t *buf, int buf_size)\n{\n    CLAVAudio *filter = (CLAVAudio *)opaque;\n    filter->m_bsOutput.Append(buf, buf_size);\n    return buf_size;\n}\n\nHRESULT CLAVAudio::CreateBitstreamContext(AVCodecID codec, WAVEFORMATEX *wfe)\n{\n    int ret = 0;\n\n    if (m_avBSContext)\n        FreeBitstreamContext();\n    m_bsParser.Reset();\n\n    DbgLog((LOG_TRACE, 20, \"Creating Bistreaming Context...\"));\n\n    ret = avformat_alloc_output_context2(&m_avBSContext, nullptr, \"spdif\", nullptr);\n    if (ret < 0 || !m_avBSContext)\n    {\n        DbgLog((LOG_ERROR, 10, L\"::CreateBitstreamContext() -- alloc of avformat spdif muxer failed (ret: %d)\", ret));\n        goto fail;\n    }\n\n    m_avBSContext->pb = m_avioBitstream;\n\n    // flush IO after every packet, so we can send it to the audio renderer immediately\n    m_avBSContext->flags |= AVFMT_FLAG_FLUSH_PACKETS;\n\n    // DTS-HD is by default off, unless explicitly asked for\n    if (m_settings.DTSHDFraming && m_settings.bBitstream[Bitstream_DTSHD] && !m_bForceDTSCore)\n    {\n        m_DTSBitstreamMode = DTS_HDMA;\n        av_opt_set_int(m_avBSContext->priv_data, \"dtshd_rate\", LAV_BITSTREAM_DTS_HD_MA_RATE, 0);\n    }\n    else\n    {\n        m_DTSBitstreamMode = DTS_Core;\n        av_opt_set_int(m_avBSContext->priv_data, \"dtshd_rate\", 0, 0);\n    }\n    av_opt_set_int(m_avBSContext->priv_data, \"dtshd_fallback_time\", -1, 0);\n\n    AVStream *st = avformat_new_stream(m_avBSContext, 0);\n    if (!st)\n    {\n        DbgLog((LOG_ERROR, 10, L\"::CreateBitstreamContext() -- alloc of output stream failed\"));\n        goto fail;\n    }\n    st->codecpar->codec_id = codec;\n    st->codecpar->codec_type = AVMEDIA_TYPE_AUDIO;\n    st->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;\n    st->codecpar->ch_layout.nb_channels = wfe->nChannels;\n    st->codecpar->sample_rate = wfe->nSamplesPerSec;\n\n    ret = avformat_write_header(m_avBSContext, nullptr);\n    if (ret < 0)\n    {\n        DbgLog((LOG_ERROR, 10, L\"::CreateBitstreamContext() -- av_write_header returned an error code (%d)\", -ret));\n        goto fail;\n    }\n\n    return S_OK;\nfail:\n    FreeBitstreamContext();\n    return E_FAIL;\n}\n\nHRESULT CLAVAudio::UpdateBitstreamContext()\n{\n    if (!m_pInput || !m_pInput->IsConnected())\n        return E_UNEXPECTED;\n\n    BOOL bBitstream = IsBitstreaming(m_nCodecId);\n    if ((bBitstream && !m_avBSContext) || (!bBitstream && m_avBSContext))\n    {\n        CMediaType mt = m_pInput->CurrentMediaType();\n\n        const void *format = mt.Format();\n        GUID format_type = mt.formattype;\n        DWORD formatlen = mt.cbFormat;\n\n        // Override the format type\n        if (mt.subtype == MEDIASUBTYPE_FFMPEG_AUDIO && format_type == FORMAT_WaveFormatExFFMPEG)\n        {\n            WAVEFORMATEXFFMPEG *wfexff = (WAVEFORMATEXFFMPEG *)mt.Format();\n            format = &wfexff->wfex;\n            format_type = FORMAT_WaveFormatEx;\n            formatlen -= sizeof(WAVEFORMATEXFFMPEG) - sizeof(WAVEFORMATEX);\n        }\n\n        ffmpeg_init(m_nCodecId, format, format_type, formatlen);\n        m_bQueueResync = TRUE;\n    }\n\n    // Configure DTS-HD setting\n    if (m_avBSContext)\n    {\n        if (m_settings.bBitstream[Bitstream_DTSHD] && m_settings.DTSHDFraming && !m_bForceDTSCore)\n        {\n            m_DTSBitstreamMode = DTS_HDMA;\n            av_opt_set_int(m_avBSContext->priv_data, \"dtshd_rate\", LAV_BITSTREAM_DTS_HD_MA_RATE, 0);\n        }\n        else\n        {\n            m_DTSBitstreamMode = DTS_Core; // Force auto-detection\n            av_opt_set_int(m_avBSContext->priv_data, \"dtshd_rate\", 0, 0);\n        }\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::FreeBitstreamContext()\n{\n    if (m_avBSContext)\n    {\n        av_write_trailer(m_avBSContext); // For the SPDIF muxer that frees the buffers\n        avformat_free_context(m_avBSContext);\n    }\n    m_avBSContext = nullptr;\n\n    av_packet_free(&m_pBitstreamPacket);\n\n    // Dump any remaining data\n    m_bsOutput.SetSize(0);\n\n    // reset TrueHD MAT state\n    memset(&m_TrueHDMATState, 0, sizeof(m_TrueHDMATState));\n\n    return S_OK;\n}\n\nCMediaType CLAVAudio::CreateBitstreamMediaType(AVCodecID codec, DWORD dwSampleRate, BOOL bDTSHDOverride)\n{\n    CMediaType mt;\n\n    mt.majortype = MEDIATYPE_Audio;\n    mt.subtype = MEDIASUBTYPE_PCM;\n    mt.formattype = FORMAT_WaveFormatEx;\n\n    WAVEFORMATEXTENSIBLE wfex;\n    memset(&wfex, 0, sizeof(wfex));\n\n    WAVEFORMATEX *wfe = &wfex.Format;\n\n    wfe->nChannels = 2;\n    wfe->wBitsPerSample = 16;\n\n    GUID subtype = GUID_NULL;\n\n    switch (codec)\n    {\n    case AV_CODEC_ID_AC3:\n        wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF;\n        wfe->nSamplesPerSec = min(dwSampleRate, 48000);\n        break;\n    case AV_CODEC_ID_EAC3:\n        wfe->nSamplesPerSec = 192000;\n        wfe->nChannels = 2;\n        subtype = KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_DIGITAL_PLUS;\n        break;\n    case AV_CODEC_ID_TRUEHD:\n        wfe->nSamplesPerSec = 192000;\n        wfe->nChannels = 8;\n        subtype = KSDATAFORMAT_SUBTYPE_IEC61937_DOLBY_MLP;\n        break;\n    case AV_CODEC_ID_DTS:\n        if (m_settings.bBitstream[Bitstream_DTSHD] && !bDTSHDOverride && m_DTSBitstreamMode != DTS_Core)\n        {\n            wfe->nSamplesPerSec = 192000;\n            wfe->nChannels = (m_DTSBitstreamMode == DTS_HDHR) ? 2 : 8;\n            subtype = KSDATAFORMAT_SUBTYPE_IEC61937_DTS_HD;\n        }\n        else\n        {\n            wfe->wFormatTag = WAVE_FORMAT_DOLBY_AC3_SPDIF; // huh? but it works.\n            wfe->nSamplesPerSec = min(dwSampleRate, 48000);\n        }\n        break;\n    default: ASSERT(0); break;\n    }\n\n    wfe->nBlockAlign = wfe->nChannels * wfe->wBitsPerSample / 8;\n    wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;\n\n    if (subtype != GUID_NULL)\n    {\n        wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;\n        wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);\n        wfex.dwChannelMask = get_channel_mask(wfe->nChannels);\n        wfex.Samples.wValidBitsPerSample = wfex.Format.wBitsPerSample;\n        wfex.SubFormat = subtype;\n    }\n\n    mt.SetSampleSize(1);\n    mt.SetFormat((BYTE *)&wfex, sizeof(wfex.Format) + wfex.Format.cbSize);\n\n    return mt;\n}\n\nCLAVAudio::DTSBitstreamMode CLAVAudio::GetDTSHDBitstreamMode()\n{\n    if (m_bForceDTSCore || !m_settings.bBitstream[Bitstream_DTSHD])\n        return DTS_Core;\n\n    if (m_settings.DTSHDFraming)\n        return DTS_HDMA;\n\n    if (!m_bsParser.m_bDTSHD)\n        return DTS_Core;\n\n    if (m_pAVCtx->profile == AV_PROFILE_DTS_HD_HRA)\n        return DTS_HDHR;\n\n    return DTS_HDMA;\n}\n\nvoid CLAVAudio::ActivateDTSHDMuxing()\n{\n    DbgLog((LOG_TRACE, 20, L\"::ActivateDTSHDMuxing(): Found DTS-HD marker - switching to DTS-HD muxing mode\"));\n    m_DTSBitstreamMode = GetDTSHDBitstreamMode();\n\n    // Check if downstream actually accepts it..\n    const CMediaType &mt = CreateBitstreamMediaType(m_nCodecId, m_bsParser.m_dwSampleRate);\n    HRESULT hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n    if (hr != S_OK)\n    {\n        DbgLog((LOG_TRACE, 20, L\"-> But downstream doesn't want DTS-HD, sticking to DTS core\"));\n        m_DTSBitstreamMode = DTS_Core;\n        m_bForceDTSCore = TRUE;\n    }\n    else\n    {\n        av_opt_set_int(m_avBSContext->priv_data, \"dtshd_rate\",\n                       (m_DTSBitstreamMode == DTS_HDHR) ? LAV_BITSTREAM_DTS_HD_HR_RATE : LAV_BITSTREAM_DTS_HD_MA_RATE,\n                       0);\n    }\n}\n\nHRESULT CLAVAudio::Bitstream(const BYTE *pDataBuffer, int buffsize, int &consumed, HRESULT *hrDeliver)\n{\n    HRESULT hr = S_OK;\n    int ret = 0;\n    BOOL bFlush = (pDataBuffer == nullptr);\n\n    if (m_pBitstreamPacket == nullptr)\n        m_pBitstreamPacket = av_packet_alloc();\n\n    m_pBitstreamPacket->duration = 1;\n\n    consumed = 0;\n    while (buffsize > 0)\n    {\n        if (bFlush)\n            buffsize = 0;\n\n        BYTE *pOut = nullptr;\n        int pOut_size = 0;\n        int used_bytes = av_parser_parse2(m_pParser, m_pAVCtx, &pOut, &pOut_size, pDataBuffer, buffsize, AV_NOPTS_VALUE,\n                                          AV_NOPTS_VALUE, 0);\n        if (used_bytes < 0)\n        {\n            DbgLog((LOG_TRACE, 50, L\"::Bitstream() - audio parsing failed (ret: %d)\", -used_bytes));\n            return E_FAIL;\n        }\n        else if (used_bytes == 0 && pOut_size == 0)\n        {\n            DbgLog((LOG_TRACE, 50, L\"::Bitstream() - could not process buffer, starving?\"));\n            break;\n        }\n\n        // Timestamp cache to compensate for one frame delay the parser might introduce, in case the frames were already\n        // perfectly sliced apart If we used more (or equal) bytes then was output again, we encountered a new frame,\n        // update timestamps\n        if (used_bytes >= pOut_size && m_bUpdateTimeCache)\n        {\n            m_rtStartInputCache = m_rtStartInput;\n            m_rtStopInputCache = m_rtStopInput;\n            m_bUpdateTimeCache = FALSE;\n        }\n\n        if (!bFlush && used_bytes > 0)\n        {\n            buffsize -= used_bytes;\n            pDataBuffer += used_bytes;\n            consumed += used_bytes;\n        }\n\n        if (pOut_size > 0)\n        {\n            hr = m_bsParser.Parse(m_nCodecId, pOut, pOut_size);\n            if (FAILED(hr))\n            {\n                continue;\n            }\n\n            if (m_nCodecId == AV_CODEC_ID_TRUEHD)\n            {\n                m_bUpdateTimeCache = TRUE;\n\n                // Set long-time cache to the first timestamp encountered, used by TrueHD and E-AC3 because the S/PDIF\n                // muxer caches data internally If the current timestamp is not valid, use the last delivery timestamp\n                // in m_rtStart\n                if (m_rtBitstreamCache == AV_NOPTS_VALUE)\n                    m_rtBitstreamCache = m_rtStartInputCache != AV_NOPTS_VALUE ? m_rtStartInputCache : m_rtStart;\n\n                BitstreamTrueHD(pOut, pOut_size, hrDeliver);\n            }\n            else\n            {\n                if (m_nCodecId == AV_CODEC_ID_DTS)\n                {\n                    DTSBitstreamMode mode = GetDTSHDBitstreamMode();\n                    if (mode != DTS_Core && mode != m_DTSBitstreamMode)\n                        ActivateDTSHDMuxing();\n                }\n\n                m_pBitstreamPacket->data = pOut;\n                m_pBitstreamPacket->size = pOut_size;\n\n                // Write SPDIF muxed frame\n                ret = av_write_frame(m_avBSContext, m_pBitstreamPacket);\n                if (ret < 0)\n                {\n                    DbgLog((LOG_ERROR, 20, \"::Bitstream(): av_write_frame returned error code (%d)\", -ret));\n                    m_bsOutput.SetSize(0);\n                    continue;\n                }\n\n                m_bUpdateTimeCache = TRUE;\n\n                // Set long-time cache to the first timestamp encountered, used by TrueHD and E-AC3 because the S/PDIF\n                // muxer caches data internally If the current timestamp is not valid, use the last delivery timestamp\n                // in m_rtStart\n                if (m_rtBitstreamCache == AV_NOPTS_VALUE)\n                    m_rtBitstreamCache = m_rtStartInputCache != AV_NOPTS_VALUE ? m_rtStartInputCache : m_rtStart;\n\n                // Deliver frame\n                if (m_bsOutput.GetCount() > 0)\n                {\n                    *hrDeliver = DeliverBitstream(m_nCodecId, m_bsOutput.Ptr(), m_bsOutput.GetCount(),\n                                                  m_rtStartInputCache, m_rtStopInputCache);\n                    m_bsOutput.SetSize(0);\n                }\n            }\n\n            /* if the bitstreaming context is lost at this point, then the deliver function caused a fallback to PCM */\n            if (m_avBSContext == nullptr)\n                return S_FALSE;\n        }\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::DeliverBitstream(AVCodecID codec, const BYTE *buffer, DWORD dwSize, REFERENCE_TIME rtStartInput,\n                                    REFERENCE_TIME rtStopInput, BOOL bSwap, int nSamplesOffset)\n{\n    HRESULT hr = S_OK;\n\n    if (m_bFlushing)\n        return S_FALSE;\n\n    CMediaType mt = CreateBitstreamMediaType(codec, m_bsParser.m_dwSampleRate);\n\n    if (FAILED(hr = ReconnectOutput(dwSize, mt)))\n    {\n        return hr;\n    }\n\n    IMediaSample *pOut;\n    BYTE *pDataOut = nullptr;\n    if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut)))\n    {\n        return E_FAIL;\n    }\n\n    if (m_bResyncTimestamp && (rtStartInput != AV_NOPTS_VALUE || m_rtBitstreamCache != AV_NOPTS_VALUE))\n    {\n        if (m_rtBitstreamCache != AV_NOPTS_VALUE)\n            m_rtStart = m_rtBitstreamCache;\n        else\n            m_rtStart = rtStartInput;\n        m_bResyncTimestamp = FALSE;\n    }\n\n    REFERENCE_TIME rtStart = m_rtStart, rtStop = AV_NOPTS_VALUE;\n    REFERENCE_TIME rtOffset = (REFERENCE_TIME)round(DBL_SECOND_MULT * (double)nSamplesOffset / m_bsParser.m_dwSampleRate / m_dRate);\n    double dDuration = DBL_SECOND_MULT * (double)m_bsParser.m_dwSamples / m_bsParser.m_dwSampleRate / m_dRate;\n    m_dStartOffset += fmod(dDuration, 1.0);\n\n    // Add rounded duration to rtStop\n    rtStop = rtStart + (REFERENCE_TIME)(dDuration + 0.5);\n    // and unrounded to m_rtStart..\n    m_rtStart += (REFERENCE_TIME)dDuration;\n    // and accumulate error..\n    if (m_dStartOffset > 0.5)\n    {\n        m_rtStart++;\n        m_dStartOffset -= 1.0;\n    }\n\n    REFERENCE_TIME rtJitter = 0;\n    if (m_rtBitstreamCache != AV_NOPTS_VALUE)\n        rtJitter = rtStart - m_rtBitstreamCache + rtOffset;\n    m_faJitter.Sample(rtJitter);\n\n    REFERENCE_TIME rtJitterMin = m_faJitter.AbsMinimum();\n    if (m_settings.AutoAVSync && abs(rtJitterMin) > m_JitterLimit)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::Deliver(): corrected A/V sync by %I64d\", rtJitterMin));\n        m_rtStart -= rtJitterMin;\n        rtStart -= rtJitterMin;\n        m_faJitter.OffsetValues(-rtJitterMin);\n        m_bDiscontinuity = TRUE;\n    }\n\n#ifdef DEBUG\n    DbgLog((LOG_CUSTOM5, 20,\n            L\"Bitstream Delivery, rtStart(calc): %I64d, rtStart(input): %I64d, duration: %I64d, offset: %I64d, diff: %I64d\", rtStart,\n            m_rtBitstreamCache, rtStop - rtStart, rtOffset, rtJitter));\n\n    if (m_faJitter.CurrentSample() == 0)\n    {\n        DbgLog((LOG_CUSTOM2, 20, L\"Jitter Stats: min: %I64d - max: %I64d - avg: %I64d\", rtJitterMin,\n                m_faJitter.AbsMaximum(), m_faJitter.Average()));\n    }\n#endif\n    m_rtBitstreamCache = AV_NOPTS_VALUE;\n\n    if (m_settings.AudioDelayEnabled)\n    {\n        REFERENCE_TIME rtDelay = (REFERENCE_TIME)((m_settings.AudioDelay * 10000i64) / m_dRate);\n        rtStart += rtDelay;\n        rtStop += rtDelay;\n    }\n\n    pOut->SetTime(&rtStart, &rtStop);\n    pOut->SetMediaTime(nullptr, nullptr);\n\n    pOut->SetPreroll(FALSE);\n    pOut->SetDiscontinuity(m_bDiscontinuity);\n    m_bDiscontinuity = FALSE;\n    pOut->SetSyncPoint(TRUE);\n\n    pOut->SetActualDataLength(dwSize);\n\n    // byte-swap if needed\n    if (bSwap)\n    {\n        lav_spdif_bswap_buf16((uint16_t *)pDataOut, (uint16_t *)buffer, dwSize >> 1);\n    }\n    else\n    {\n        memcpy(pDataOut, buffer, dwSize);\n    }\n\n    if (hr == S_OK)\n    {\n        hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n        if (hr == S_FALSE && m_nCodecId == AV_CODEC_ID_DTS && m_DTSBitstreamMode != DTS_Core)\n        {\n            DbgLog((LOG_TRACE, 1, L\"DTS-HD Media Type failed with %0#.8x, trying fallback to DTS core\", hr));\n            m_bForceDTSCore = TRUE;\n            UpdateBitstreamContext();\n            goto done;\n        }\n        else if (hr == S_FALSE && m_settings.bBitstreamingFallback)\n        {\n            BitstreamFallbackToPCM();\n            goto done;\n        }\n        DbgLog((LOG_TRACE, 1, L\"Sending new Media Type (QueryAccept: %0#.8x)\", hr));\n        m_pOutput->SetMediaType(&mt);\n        pOut->SetMediaType(&mt);\n    }\n\n    hr = m_pOutput->Deliver(pOut);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"::DeliverBitstream failed with code: %0#.8x\", hr));\n    }\n\ndone:\n    SafeRelease(&pOut);\n    return hr;\n}\n\nHRESULT CLAVAudio::BitstreamFallbackToPCM()\n{\n    // fallback to decoding\n    FreeBitstreamContext();\n\n    for (int i = 0; i < countof(lavf_bitstream_config); ++i)\n    {\n        if (lavf_bitstream_config[i].codec == m_nCodecId)\n        {\n            m_bBitstreamOverride[lavf_bitstream_config[i].config] = TRUE;\n        }\n    }\n\n    m_bQueueResync = TRUE;\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVAudio/BitstreamMAT.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n * This code was inspired by the ffdshow-tryouts TaudioCodecBitstream module, licensed under GPL 2.0\n */\n\n#include \"stdafx.h\"\n#include \"LAVAudio.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4101)\n#pragma warning(disable : 5033)\nextern \"C\"\n{\n#include \"libavformat/spdif.h\"\n#define AVCODEC_X86_MATHOPS_H\n#include \"libavcodec/get_bits.h\"\n}\n#pragma warning(pop)\n\n#define MAT_BUFFER_SIZE (61440)\n#define MAT_BUFFER_LIMIT (MAT_BUFFER_SIZE - 24 /* MAT end code size */)\n#define MAT_POS_MIDDLE (30708 /* middle point*/ + 8 /* IEC header in front */)\n\nstatic const BYTE mat_start_code[20] = {0x07, 0x9E, 0x00, 0x03, 0x84, 0x01, 0x01, 0x01, 0x80, 0x00,\n                                        0x56, 0xA5, 0x3B, 0xF4, 0x81, 0x83, 0x49, 0x80, 0x77, 0xE0};\nstatic const BYTE mat_middle_code[12] = {0xC3, 0xC1, 0x42, 0x49, 0x3B, 0xFA, 0x82, 0x83, 0x49, 0x80, 0x77, 0xE0};\nstatic const BYTE mat_end_code[24] = {0xC3, 0xC2, 0xC0, 0xC4, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,\n                                      0x00, 0x00, 0x97, 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};\n\nvoid CLAVAudio::MATWriteHeader()\n{\n    ASSERT(m_bsOutput.GetCount() == 0);\n\n    DWORD dwSize = BURST_HEADER_SIZE + sizeof(mat_start_code);\n\n    // reserve size for the IEC header and the MAT start code\n    m_bsOutput.SetSize(dwSize);\n\n    BYTE *p = m_bsOutput.Ptr();\n\n    // IEC burst header\n    AV_WB16(p + 0, SYNCWORD1);\n    AV_WB16(p + 2, SYNCWORD2);\n    AV_WB16(p + 4, IEC61937_TRUEHD);\n    AV_WB16(p + 6, 61424);\n\n    // MAT start code\n    memcpy(p + BURST_HEADER_SIZE, mat_start_code, sizeof(mat_start_code));\n\n    // unless the start code falls into the padding,  its considered part of the current MAT frame\n    // Note that audio frames are not always aligned with MAT frames, so we might already have a partial frame at this\n    // point\n    m_TrueHDMATState.mat_framesize += dwSize;\n\n    // The MAT metadata counts as padding, if we're scheduled to write any, which mean the start bytes should reduce any\n    // further padding.\n    if (m_TrueHDMATState.padding > 0)\n    {\n        // if the header fits into the padding of the last frame, just reduce the amount of needed padding\n        if (m_TrueHDMATState.padding > dwSize)\n        {\n            m_TrueHDMATState.padding -= dwSize;\n            m_TrueHDMATState.mat_framesize = 0;\n        }\n        else // otherwise, consume all padding and set the size of the next MAT frame to the remaining data\n        {\n            m_TrueHDMATState.mat_framesize = (dwSize - m_TrueHDMATState.padding);\n            m_TrueHDMATState.padding = 0;\n        }\n    }\n}\n\nvoid CLAVAudio::MATWritePadding()\n{\n    if (m_TrueHDMATState.padding > 0)\n    {\n        int remaining = MATFillDataBuffer(nullptr, m_TrueHDMATState.padding, true);\n\n        // not all padding could be written to the buffer, write it later\n        if (remaining >= 0)\n        {\n            m_TrueHDMATState.padding = remaining;\n            m_TrueHDMATState.mat_framesize = 0;\n        }\n        else // more padding then requested was written, eg. there was a MAT middle/end marker that needed to be written\n        {\n            m_TrueHDMATState.padding = 0;\n            m_TrueHDMATState.mat_framesize = -remaining;\n        }\n    }\n}\n\nvoid CLAVAudio::MATAppendData(const BYTE * const p, int size)\n{\n    if (p)\n        m_bsOutput.Append(p, size);\n    else\n        m_bsOutput.AppendZero(size);\n\n    m_TrueHDMATState.mat_framesize += size;\n}\n\nint CLAVAudio::MATFillDataBuffer(const BYTE *const p, int size, bool padding)\n{\n    ASSERT(p || padding);\n\n    if (m_bsOutput.GetCount() >= MAT_BUFFER_LIMIT)\n        return size;\n\n    int remaining = size;\n\n    // Write MAT middle marker, if needed\n    // The MAT middle marker always needs to be in the exact same spot, any audio data will be split.\n    // If we're currently writing padding, then the marker will be considered as padding data and reduce the amount of\n    // padding still required.\n    if (m_bsOutput.GetCount() <= MAT_POS_MIDDLE && m_bsOutput.GetCount() + size > MAT_POS_MIDDLE)\n    {\n        // write as much data before the middle code as we can\n        int nBytesBefore = MAT_POS_MIDDLE - m_bsOutput.GetCount();\n        MATAppendData(p, nBytesBefore);\n        remaining -= nBytesBefore;\n\n        // write the MAT middle code\n        MATAppendData(mat_middle_code, sizeof(mat_middle_code));\n\n        // if we're writing padding, deduct the size of the code from it\n        if (padding)\n            remaining -= sizeof(mat_middle_code);\n\n        // write remaining data after the MAT marker\n        if (remaining > 0)\n        {\n            return MATFillDataBuffer(p ? p + nBytesBefore : nullptr, remaining, padding);\n        }\n\n        return remaining;\n    }\n\n    // not enough room in the buffer to write all the data, write as much as we can and add the MAT footer\n    if (m_bsOutput.GetCount() + size >= MAT_BUFFER_LIMIT)\n    {\n        // write as much data before the middle code as we can\n        int nBytesBefore = MAT_BUFFER_LIMIT - m_bsOutput.GetCount();\n        MATAppendData(p, nBytesBefore);\n        remaining -= nBytesBefore;\n\n        // write the MAT end code\n        MATAppendData(mat_end_code, sizeof(mat_end_code));\n\n        ASSERT(m_bsOutput.GetCount() == MAT_BUFFER_SIZE);\n\n        // MAT markers don't displace padding, so reduce the amount of padding\n        if (padding)\n            remaining -= sizeof(mat_end_code);\n\n        // any remaining data will be written in future calls\n        return remaining;\n    }\n\n    MATAppendData(p, size);\n\n    return 0;\n}\n\nvoid CLAVAudio::MATFlushPacket(HRESULT *hrDeliver)\n{\n    if (m_bsOutput.GetCount() > 0)\n    {\n        ASSERT(m_bsOutput.GetCount() == 61440);\n\n        // normal number of samples per frame\n        uint16_t frame_samples = 40 << (m_TrueHDMATState.ratebits & 7);\n        int nMATSamples = (frame_samples * 24);\n\n        // Deliver MAT packet to the audio renderer\n        *hrDeliver = DeliverBitstream(m_nCodecId, m_bsOutput.Ptr(), m_bsOutput.GetCount(), m_rtStartInputCache,\n                                      m_rtStopInputCache, true, m_TrueHDMATState.nSamplesOffset);\n\n        // we expect 24 frames per MAT frame, so calculate an offset from that\n        // this is done after delivery, because it modifies the duration of the frame, eg. the start of the next frame\n        if (nMATSamples != m_TrueHDMATState.nSamples)\n            m_TrueHDMATState.nSamplesOffset += m_TrueHDMATState.nSamples - nMATSamples;\n\n        m_bsOutput.SetSize(0);\n        m_TrueHDMATState.nSamples = 0;\n    }\n}\n\nstatic bool ParseTrueHDMajorSyncHeaders(const BYTE *p, int buffsize, int &ratebits, uint16_t &output_timing,\n                                        bool &output_timing_present)\n{\n    ASSERT(AV_RB32(p + 4) == 0xf8726fba);\n\n    int length = (AV_RB16(p) & 0xfff) * 2;\n    if (buffsize < 32)\n        return false;\n\n    // parse major sync and look for a restart header\n    int major_sync_size = 28;\n    if (p[29] & 1)\n    {\n        int extension_size = p[30] >> 4;\n        major_sync_size += 2 + extension_size * 2;\n    }\n\n    GetBitContext gb;\n    init_get_bits8(&gb, p + 4, buffsize - 4);\n    skip_bits_long(&gb, 32); // format_sync\n\n    // v(32) format_info\n    ratebits = get_bits(&gb, 4); // ratebits\n    skip_bits1(&gb);             // 6ch_multichannel_type\n    skip_bits1(&gb);             // 8ch_multichannel_type\n    skip_bits(&gb, 2);           // reserved\n\n    skip_bits(&gb, 2);  // 2ch_presentation_channel_modifier\n    skip_bits(&gb, 2);  // 6ch_presentation_channel_modifier\n    skip_bits(&gb, 5);  // 6ch_presentation_channel_assignment\n    skip_bits(&gb, 2);  // 8ch_presentation_channel_modifier\n    skip_bits(&gb, 13); // 8ch_presentation_channel_assignment\n\n    skip_bits(&gb, 16); // signature\n    skip_bits(&gb, 16); // flags\n    skip_bits(&gb, 16); // reserved\n\n    skip_bits1(&gb);    // variable_rate\n    skip_bits(&gb, 15); // peak_data_rate\n\n    int num_substreams = get_bits(&gb, 4);\n    skip_bits_long(&gb, 4 + (major_sync_size - 17) * 8);\n\n    // substream directory\n    for (int i = 0; i < num_substreams; i++)\n    {\n        int extra_substream_word = get_bits1(&gb);\n        skip_bits1(&gb);    // restart_nonexistent\n        skip_bits1(&gb);    // crc_present\n        skip_bits1(&gb);    // reserved\n        skip_bits(&gb, 12); // substream_end_ptr\n        if (extra_substream_word)\n            skip_bits(&gb, 16); // drc_gain_update, drc_time_update, reserved\n    }\n\n    // substream segments\n    for (int i = 0; i < num_substreams; i++)\n    {\n        if (get_bits1(&gb))\n        { // block_header_exists\n            if (get_bits1(&gb))\n            {                       // restart_header_exists\n                skip_bits(&gb, 14); // restart_sync_word\n                output_timing = get_bits(&gb, 16);\n                output_timing_present = true;\n                // XXX: restart header\n            }\n            // XXX: Block header\n        }\n        // XXX: All blocks, all substreams?\n        break;\n    }\n\n    return true;\n}\n\nHRESULT CLAVAudio::BitstreamTrueHD(const BYTE *p, int buffsize, HRESULT *hrDeliver)\n{\n    // On a high level, a MAT frame consists of a sequence of padded TrueHD frames\n    // The size of the padded frame can be determined from the frame time/sequence code in the frame header,\n    // since it varies to accommodate spikes in bitrate.\n    // In average all frames are always padded to 2560 bytes, so that 24 frames fit in one MAT frame, however\n    // due to bitrate spikes single sync frames have been observed to use up to twice that size, in which\n    // case they'll be preceded by smaller frames to keep the average bitrate constant.\n    // A constant padding to 2560 bytes can work (this is how the ffmpeg spdifenc module works), however\n    // high-bitrate streams can overshoot this size and therefor require proper handling of dynamic padding.\n\n    uint16_t output_timing = 0;\n    bool bOutputTimingPresent = false;\n\n    // get the ratebits and output timing from the sync frame\n    if (AV_RB32(p + 4) == 0xf8726fba)\n    {\n        if (ParseTrueHDMajorSyncHeaders(p, buffsize, m_TrueHDMATState.ratebits, output_timing, bOutputTimingPresent) ==\n            false)\n            return E_FAIL;\n    }\n    else if (m_TrueHDMATState.prev_frametime_valid == false)\n    {\n        // only start streaming on a major sync frame\n        m_rtBitstreamCache = AV_NOPTS_VALUE;\n        m_TrueHDMATState.nSamplesOffset = 0;\n        return S_FALSE;\n    }\n\n    uint16_t frame_time = AV_RB16(p + 2);\n    uint32_t space_size = 0;\n\n    uint16_t frame_samples = 40 << (m_TrueHDMATState.ratebits & 7);\n    m_TrueHDMATState.output_timing += frame_samples;\n    if (bOutputTimingPresent)\n    {\n        if (m_TrueHDMATState.output_timing_valid && (output_timing != m_TrueHDMATState.output_timing))\n        {\n            DbgLog((LOG_TRACE, 10, _T(\"BitstreamTrueHD(): Detected a stream discontinuity, reseting framesize cache\")));\n            m_TrueHDMATState.prev_frametime_valid = false;\n            space_size = 40 * (64 >> (m_TrueHDMATState.ratebits & 7));\n\n            // the output timing is always one frame ahead for buffering reasons, so deduct one frame worth\n            uint32_t prev_output = (uint16_t)(output_timing - frame_samples);\n            if (prev_output < frame_time) // wrap around, output is always in front of frame time\n                prev_output += UINT16_MAX;\n\n            // get the offset of this frame, so we can compare to the previous frame, and determine the amount of padding that needs to be inserted\n            int currentFrameOutputOffset = (prev_output - frame_time);\n\n            // the previous offset should never be smaller then the incoming offset, or we will lack the reserved space\n            ASSERT(m_TrueHDMATState.nOutputTimeOffset >= currentFrameOutputOffset);\n            if (m_TrueHDMATState.nOutputTimeOffset >= currentFrameOutputOffset)\n                m_TrueHDMATState.padding += (m_TrueHDMATState.nOutputTimeOffset - currentFrameOutputOffset) * (64 >> (m_TrueHDMATState.ratebits & 7));\n\n            DbgLog((LOG_TRACE, 10, _T(\"BitstreamTrueHD(): Carrying forward %d padding (offset %d - %d)\"),\n                    m_TrueHDMATState.padding, m_TrueHDMATState.nOutputTimeOffset, currentFrameOutputOffset));\n        }\n        m_TrueHDMATState.output_timing = output_timing;\n        m_TrueHDMATState.output_timing_valid = true;\n    }\n\n    // compute final padded size for the previous frame, if any\n    if (m_TrueHDMATState.prev_frametime_valid)\n        space_size = uint16_t(frame_time - m_TrueHDMATState.prev_frametime) * (64 >> (m_TrueHDMATState.ratebits & 7));\n\n    // compute padding (ie. difference to the size of the previous frame)\n    ASSERT(!m_TrueHDMATState.prev_frametime_valid || space_size >= m_TrueHDMATState.prev_mat_framesize);\n\n    // if for some reason the space_size fails, align the actual frame size\n    if (space_size < m_TrueHDMATState.prev_mat_framesize)\n        space_size = FFALIGN(m_TrueHDMATState.prev_mat_framesize, (64 >> (m_TrueHDMATState.ratebits & 7)));\n\n    m_TrueHDMATState.padding += (space_size - m_TrueHDMATState.prev_mat_framesize);\n\n    // record the offset of frame time to output time, which is used to verify the size of the padding on discontinuities\n    if (m_TrueHDMATState.output_timing_valid)\n    {\n        uint32_t prev_output = (uint16_t)(m_TrueHDMATState.output_timing - frame_samples);\n        if (prev_output < frame_time) // wrap around, output is always in front of frame time\n            prev_output += UINT16_MAX;\n\n        m_TrueHDMATState.nOutputTimeOffset = (prev_output - frame_time);\n    }\n\n    // store frame time of the previous frame\n    m_TrueHDMATState.prev_frametime = frame_time;\n    m_TrueHDMATState.prev_frametime_valid = true;\n\n    // Write the MAT header into the fresh buffer\n    if (m_bsOutput.GetCount() == 0)\n    {\n        MATWriteHeader();\n\n        // initial header, don't count it for the frame size\n        if (m_TrueHDMATState.init == false)\n        {\n            m_TrueHDMATState.init = true;\n            m_TrueHDMATState.mat_framesize = 0;\n        }\n    }\n\n    // write padding of the previous frame (if any)\n    while (m_TrueHDMATState.padding > 0)\n    {\n        MATWritePadding();\n\n        ASSERT(m_TrueHDMATState.padding == 0 || m_bsOutput.GetCount() == MAT_BUFFER_SIZE);\n\n        // Buffer is full, submit it\n        if (m_bsOutput.GetCount() == MAT_BUFFER_SIZE)\n        {\n            MATFlushPacket(hrDeliver);\n\n            // and setup a new buffer\n            MATWriteHeader();\n        }\n    }\n\n    // count the number of samples in this frame\n    m_TrueHDMATState.nSamples += frame_samples;\n\n    // write actual audio data to the buffer\n    int remaining = MATFillDataBuffer(p, buffsize);\n\n    // not all data could be written, or the buffer is full\n    if (remaining || m_bsOutput.GetCount() == MAT_BUFFER_SIZE)\n    {\n        // flush out old data\n        MATFlushPacket(hrDeliver);\n\n        if (remaining)\n        {\n            // .. setup a new buffer\n            MATWriteHeader();\n\n            // and write the remaining data\n            remaining = MATFillDataBuffer(p + (buffsize - remaining), remaining);\n\n            ASSERT(remaining == 0);\n        }\n    }\n\n    // store the size of the current MAT frame, so we can add padding later\n    m_TrueHDMATState.prev_mat_framesize = m_TrueHDMATState.mat_framesize;\n    m_TrueHDMATState.mat_framesize = 0;\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVAudio/BitstreamParser.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"BitstreamParser.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4101)\n#pragma warning(disable : 5033)\nextern \"C\"\n{\n#define AVCODEC_X86_MATHOPS_H\n#include \"libavcodec/ac3_parser_internal.h\"\n}\n#pragma warning(pop)\n\n#include \"parser/dts.h\"\n\nCBitstreamParser::CBitstreamParser()\n{\n    init_dts_parser((DTSParserContext **)&m_pParserContext);\n    Reset();\n}\n\nCBitstreamParser::~CBitstreamParser()\n{\n    close_dts_parser((DTSParserContext **)&m_pParserContext);\n}\n\nvoid CBitstreamParser::Reset()\n{\n    m_dwBlocks = 0;\n    m_dwFrameSize = 0;\n    m_dwSampleRate = 0;\n    m_dwSamples = 0;\n    m_bDTSHD = FALSE;\n    memset(&m_DTSHeader, 0, sizeof(m_DTSHeader));\n}\n\nHRESULT CBitstreamParser::Parse(AVCodecID codec, BYTE *pBuffer, DWORD dwSize)\n{\n    switch (codec)\n    {\n    case AV_CODEC_ID_DTS: return ParseDTS(pBuffer, dwSize);\n    case AV_CODEC_ID_AC3:\n    case AV_CODEC_ID_EAC3: return ParseAC3(pBuffer, dwSize);\n    case AV_CODEC_ID_TRUEHD: return ParseTrueHD(pBuffer, dwSize);\n    }\n    return S_OK;\n}\n\nHRESULT CBitstreamParser::ParseDTS(BYTE *pBuffer, DWORD dwSize)\n{\n    int ret = parse_dts_header((DTSParserContext *)m_pParserContext, &m_DTSHeader, pBuffer, (unsigned)dwSize);\n    if (ret < 0)\n        return E_FAIL;\n\n    m_bDTSHD = m_bDTSHD || m_DTSHeader.IsHD;\n\n    m_dwBlocks = m_DTSHeader.Blocks;\n    m_dwSampleRate = m_DTSHeader.SampleRate;\n    m_dwFrameSize = m_DTSHeader.FrameSize;\n    m_dwSamples = m_DTSHeader.SamplesPerBlock * m_dwBlocks;\n\n    return S_OK;\n}\n\nHRESULT CBitstreamParser::ParseAC3(BYTE *pBuffer, DWORD dwSize)\n{\n    AC3HeaderInfo hdr{};\n    AC3HeaderInfo *phdr = &hdr;\n    if (avpriv_ac3_parse_header(&phdr, pBuffer, dwSize) >= 0)\n    {\n        m_dwSampleRate = hdr.sample_rate;\n\n        // E-AC3 always combines 6 blocks, resulting in 1536 samples\n        m_dwSamples = (hdr.bitstream_id > 10) ? (6 * 256) : (hdr.num_blocks * 256);\n    }\n    else\n    {\n        if (m_dwSampleRate == 0) // not seen a valid frame yet, error out\n            return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nHRESULT CBitstreamParser::ParseTrueHD(BYTE *pBuffer, DWORD dwSize)\n{\n    if (AV_RB32(pBuffer + 4) == 0xf8726fba)\n    {\n        int nRatebits = pBuffer[8] >> 4;\n\n        m_dwSampleRate = (nRatebits & 8 ? 44100 : 48000) << (nRatebits & 7);\n        m_dwSamples = 24 * (40 << (nRatebits & 7));\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVAudio/BitstreamParser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"parser/dts.h\"\n\nstruct GetBitContext;\n\nclass CBitstreamParser\n{\n  public:\n    CBitstreamParser();\n    ~CBitstreamParser();\n\n    HRESULT Parse(AVCodecID codec, BYTE *pBuffer, DWORD dwSize);\n    void Reset();\n\n  private:\n    HRESULT ParseDTS(BYTE *pBuffer, DWORD dwSize);\n    HRESULT ParseAC3(BYTE *pBuffer, DWORD dwSize);\n    HRESULT ParseTrueHD(BYTE *pBuffer, DWORD dwSize);\n\n  public:\n    DWORD m_dwSampleRate = 0;\n    DWORD m_dwBlocks = 0;\n    DWORD m_dwFrameSize = 0;\n    DWORD m_dwSamples = 0;\n\n    BOOL m_bDTSHD = FALSE;\n    DTSHeader m_DTSHeader;\n\n  private:\n    GetBitContext *m_gb = nullptr;\n    void *m_pParserContext = nullptr;\n};\n"
  },
  {
    "path": "decoder/LAVAudio/LAVAudio.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVAudio.h\"\n#include \"PostProcessor.h\"\n\n#include <MMReg.h>\n#include <assert.h>\n\n#include \"moreuuids.h\"\n#include \"DShowUtil.h\"\n#include \"IMediaSideData.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n\n#include \"AudioSettingsProp.h\"\n\n#include \"registry.h\"\n#include \"resource.h\"\n\n#include \"DeCSS/DeCSSInputPin.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4018)\n#pragma warning(disable : 4101)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 5033)\nextern \"C\"\n{\n#define AVCODEC_X86_MATHOPS_H\n#include \"libavformat/spdif.h\"\n#include \"libavcodec/flac_parse.h\"\n#include \"libavcodec/flac.h\"\n#include \"libavcodec/mpegaudiodecheader.h\"\n\n    extern int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, const uint8_t *buf, int size,\n                                 int parse_picture);\n    extern void ff_rm_reorder_sipr_data(uint8_t *buf, int sub_packet_h, int framesize);\n    __declspec(dllimport) extern const unsigned char ff_sipr_subpk_size[4];\n};\n#pragma warning(pop)\n\n#ifdef DEBUG\n#include \"lavf_log.h\"\n#endif\n\nstatic DWORD get_lav_channel_layout(AVChannelLayout * layout);\n\nextern HINSTANCE g_hInst;\n\n// Constructor\nCLAVAudio::CLAVAudio(LPUNKNOWN pUnk, HRESULT *phr)\n    : CTransformFilter(NAME(\"lavc audio decoder\"), 0, __uuidof(CLAVAudio))\n{\n    m_pInput = new CDeCSSTransformInputPin(TEXT(\"CDeCSSTransformInputPin\"), this, phr, L\"Input\");\n    if (!m_pInput)\n    {\n        *phr = E_OUTOFMEMORY;\n    }\n    if (FAILED(*phr))\n    {\n        return;\n    }\n\n    m_pOutput = new CTransformOutputPin(NAME(\"CTransformOutputPin\"), this, phr, L\"Output\");\n    if (!m_pOutput)\n    {\n        *phr = E_OUTOFMEMORY;\n    }\n    if (FAILED(*phr))\n    {\n        SAFE_DELETE(m_pInput);\n        return;\n    }\n\n    LoadSettings();\n\n    InitBitstreaming();\n\n#ifdef DEBUG\n    DbgSetModuleLevel(LOG_CUSTOM1, DWORD_MAX); // FFMPEG messages use custom1\n    av_log_set_callback(lavf_log_callback);\n\n    DbgSetModuleLevel(LOG_ERROR, DWORD_MAX);\n    DbgSetModuleLevel(LOG_TRACE, DWORD_MAX);\n    // DbgSetModuleLevel (LOG_CUSTOM2, DWORD_MAX); // Jitter statistics\n    // DbgSetModuleLevel (LOG_CUSTOM5, DWORD_MAX); // Extensive timing options\n#else\n    av_log_set_callback(nullptr);\n#endif\n}\n\nCLAVAudio::~CLAVAudio()\n{\n    SAFE_DELETE(m_pTrayIcon);\n    ffmpeg_shutdown();\n\n    ShutdownBitstreaming();\n}\n\nSTDMETHODIMP CLAVAudio::CreateTrayIcon()\n{\n    CAutoLock cObjectLock(m_pLock);\n    if (m_pTrayIcon)\n        return E_UNEXPECTED;\n    if (CBaseTrayIcon::ProcessBlackList())\n        return S_FALSE;\n    m_pTrayIcon = new CBaseTrayIcon(this, TEXT(LAV_AUDIO), IDI_ICON1);\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVAudio::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName)\n{\n    CAutoLock cObjectLock(m_pLock);\n    HRESULT hr = __super::JoinFilterGraph(pGraph, pName);\n    if (pGraph && !m_pTrayIcon && m_settings.TrayIcon)\n    {\n        CreateTrayIcon();\n    }\n    else if (!pGraph && m_pTrayIcon)\n    {\n        SAFE_DELETE(m_pTrayIcon);\n    }\n    return hr;\n}\n\nHRESULT CLAVAudio::LoadDefaults()\n{\n    m_settings.TrayIcon = FALSE;\n\n    m_settings.DRCEnabled = FALSE;\n    m_settings.DRCLevel = 100;\n\n    // Default all Codecs to enabled\n    for (int i = 0; i < Codec_AudioNB; ++i)\n        m_settings.bFormats[i] = TRUE;\n\n    // Disable WMA codecs by default\n    m_settings.bFormats[Codec_WMA2] = FALSE;\n    m_settings.bFormats[Codec_WMAPRO] = FALSE;\n    m_settings.bFormats[Codec_WMALL] = FALSE;\n\n    // Default bitstreaming to disabled\n    memset(m_settings.bBitstream, 0, sizeof(m_settings.bBitstream));\n\n    m_settings.DTSHDFraming = FALSE;\n    m_settings.bBitstreamingFallback = TRUE;\n    m_settings.AutoAVSync = TRUE;\n    m_settings.ExpandMono = FALSE;\n    m_settings.Expand61 = FALSE;\n    m_settings.OutputStandardLayout = TRUE;\n    m_settings.Output51Legacy = FALSE;\n    m_settings.AllowRawSPDIF = FALSE;\n\n    // Default all Sample Formats to enabled\n    for (int i = 0; i < SampleFormat_NB; ++i)\n        m_settings.bSampleFormats[i] = TRUE;\n    m_settings.SampleConvertDither = TRUE;\n\n    m_settings.AudioDelayEnabled = FALSE;\n    m_settings.AudioDelay = 0;\n\n    m_settings.MixingEnabled = FALSE;\n    m_settings.MixingLayout = AV_CH_LAYOUT_STEREO;\n    m_settings.MixingFlags = LAV_MIXING_FLAG_CLIP_PROTECTION;\n    m_settings.MixingMode = MatrixEncoding_None;\n    m_settings.MixingCenterLevel = 7071;\n    m_settings.MixingSurroundLevel = 7071;\n    m_settings.MixingLFELevel = 0;\n\n    m_settings.SuppressFormatChanges = FALSE;\n\n    return S_OK;\n}\n\nstatic const WCHAR *bitstreamingCodecs[Bitstream_NB] = {L\"ac3\", L\"eac3\", L\"truehd\", L\"dts\", L\"dtshd\"};\n\nstatic const WCHAR *sampleFormats[SampleFormat_Bitstream] = {L\"s16\", L\"s24\", L\"s32\", L\"u8\", L\"fp32\"};\n\nHRESULT CLAVAudio::LoadSettings()\n{\n    LoadDefaults();\n    if (m_bRuntimeConfig)\n        return S_FALSE;\n\n    ReadSettings(HKEY_LOCAL_MACHINE);\n    return ReadSettings(HKEY_CURRENT_USER);\n}\n\nHRESULT CLAVAudio::ReadSettings(HKEY rootKey)\n{\n    HRESULT hr;\n    DWORD dwVal;\n    BOOL bFlag;\n    BYTE *pBuf = nullptr;\n\n    CRegistry reg = CRegistry(rootKey, LAVC_AUDIO_REGISTRY_KEY, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        bFlag = reg.ReadDWORD(L\"TrayIcon\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.TrayIcon = bFlag;\n\n        bFlag = reg.ReadDWORD(L\"DRCEnabled\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.DRCEnabled = bFlag;\n\n        dwVal = reg.ReadDWORD(L\"DRCLevel\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.DRCLevel = (int)dwVal;\n\n        // Deprecated format storage\n        pBuf = reg.ReadBinary(L\"Formats\", dwVal, hr);\n        if (SUCCEEDED(hr))\n        {\n            memcpy(&m_settings.bFormats, pBuf, min(dwVal, sizeof(m_settings.bFormats)));\n            SAFE_CO_FREE(pBuf);\n        }\n\n        // Deprecated bitstreaming storage\n        pBuf = reg.ReadBinary(L\"Bitstreaming\", dwVal, hr);\n        if (SUCCEEDED(hr))\n        {\n            memcpy(&m_settings.bBitstream, pBuf, min(dwVal, sizeof(m_settings.bBitstream)));\n            SAFE_CO_FREE(pBuf);\n        }\n\n        bFlag = reg.ReadBOOL(L\"DTSHDFraming\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.DTSHDFraming = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"BitstreamingFallback\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bBitstreamingFallback = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"AutoAVSync\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.AutoAVSync = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"ExpandMono\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.ExpandMono = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"Expand61\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.Expand61 = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"OutputStandardLayout\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.OutputStandardLayout = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"Output51Legacy\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.Output51Legacy = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"Mixing\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.MixingEnabled = bFlag;\n\n        dwVal = reg.ReadDWORD(L\"MixingLayout\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.MixingLayout = dwVal;\n\n        if (m_settings.MixingLayout == AV_CH_LAYOUT_5POINT1_BACK)\n            m_settings.MixingLayout = AV_CH_LAYOUT_5POINT1;\n\n        dwVal = reg.ReadDWORD(L\"MixingFlags\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.MixingFlags = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"MixingMode\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.MixingMode = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"MixingCenterLevel\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.MixingCenterLevel = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"MixingSurroundLevel\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.MixingSurroundLevel = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"MixingLFELevel\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.MixingLFELevel = dwVal;\n\n        // Deprecated sample format storage\n        pBuf = reg.ReadBinary(L\"SampleFormats\", dwVal, hr);\n        if (SUCCEEDED(hr))\n        {\n            memcpy(&m_settings.bSampleFormats, pBuf, min(dwVal, sizeof(m_settings.bSampleFormats)));\n            SAFE_CO_FREE(pBuf);\n        }\n\n        bFlag = reg.ReadBOOL(L\"AudioDelayEnabled\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.AudioDelayEnabled = bFlag;\n\n        dwVal = reg.ReadDWORD(L\"AudioDelay\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.AudioDelay = (int)dwVal;\n\n        for (int i = 0; i < Bitstream_NB; ++i)\n        {\n            std::wstring key = std::wstring(L\"Bitstreaming_\") + std::wstring(bitstreamingCodecs[i]);\n            bFlag = reg.ReadBOOL(key.c_str(), hr);\n            if (SUCCEEDED(hr))\n                m_settings.bBitstream[i] = bFlag;\n        }\n\n        for (int i = 0; i < SampleFormat_Bitstream; ++i)\n        {\n            std::wstring key = std::wstring(L\"SampleFormat_\") + std::wstring(sampleFormats[i]);\n            bFlag = reg.ReadBOOL(key.c_str(), hr);\n            if (SUCCEEDED(hr))\n                m_settings.bSampleFormats[i] = bFlag;\n        }\n\n        bFlag = reg.ReadBOOL(L\"SampleConvertDither\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.SampleConvertDither = bFlag;\n    }\n\n    CRegistry regF = CRegistry(rootKey, LAVC_AUDIO_REGISTRY_KEY_FORMATS, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        for (int i = 0; i < Codec_AudioNB; ++i)\n        {\n            const codec_config_t *info = get_codec_config((LAVAudioCodec)i);\n            ATL::CA2W name(info->name);\n            bFlag = regF.ReadBOOL(name, hr);\n            if (SUCCEEDED(hr))\n                m_settings.bFormats[i] = bFlag;\n        }\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::SaveSettings()\n{\n    if (m_bRuntimeConfig)\n        return S_FALSE;\n\n    HRESULT hr;\n    CreateRegistryKey(HKEY_CURRENT_USER, LAVC_AUDIO_REGISTRY_KEY);\n    CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVC_AUDIO_REGISTRY_KEY, hr);\n    if (SUCCEEDED(hr))\n    {\n        reg.WriteBOOL(L\"TrayIcon\", m_settings.TrayIcon);\n        reg.WriteBOOL(L\"DRCEnabled\", m_settings.DRCEnabled);\n        reg.WriteDWORD(L\"DRCLevel\", m_settings.DRCLevel);\n        reg.WriteBOOL(L\"DTSHDFraming\", m_settings.DTSHDFraming);\n        reg.WriteBOOL(L\"BitstreamingFallback\", m_settings.bBitstreamingFallback);\n        reg.WriteBOOL(L\"AutoAVSync\", m_settings.AutoAVSync);\n        reg.WriteBOOL(L\"ExpandMono\", m_settings.ExpandMono);\n        reg.WriteBOOL(L\"Expand61\", m_settings.Expand61);\n        reg.WriteBOOL(L\"OutputStandardLayout\", m_settings.OutputStandardLayout);\n        reg.WriteBOOL(L\"Output51Legacy\", m_settings.Output51Legacy);\n        reg.WriteBOOL(L\"AudioDelayEnabled\", m_settings.AudioDelayEnabled);\n        reg.WriteDWORD(L\"AudioDelay\", m_settings.AudioDelay);\n\n        reg.WriteBOOL(L\"Mixing\", m_settings.MixingEnabled);\n        reg.WriteDWORD(L\"MixingLayout\", m_settings.MixingLayout);\n        reg.WriteDWORD(L\"MixingFlags\", m_settings.MixingFlags);\n        reg.WriteDWORD(L\"MixingMode\", m_settings.MixingMode);\n        reg.WriteDWORD(L\"MixingCenterLevel\", m_settings.MixingCenterLevel);\n        reg.WriteDWORD(L\"MixingSurroundLevel\", m_settings.MixingSurroundLevel);\n        reg.WriteDWORD(L\"MixingLFELevel\", m_settings.MixingLFELevel);\n\n        reg.DeleteKey(L\"Formats\");\n        CreateRegistryKey(HKEY_CURRENT_USER, LAVC_AUDIO_REGISTRY_KEY_FORMATS);\n        CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVC_AUDIO_REGISTRY_KEY_FORMATS, hr);\n        for (int i = 0; i < Codec_AudioNB; ++i)\n        {\n            const codec_config_t *info = get_codec_config((LAVAudioCodec)i);\n            ATL::CA2W name(info->name);\n            regF.WriteBOOL(name, m_settings.bFormats[i]);\n        }\n\n        reg.DeleteKey(L\"Bitstreaming\");\n        for (int i = 0; i < Bitstream_NB; ++i)\n        {\n            std::wstring key = std::wstring(L\"Bitstreaming_\") + std::wstring(bitstreamingCodecs[i]);\n            reg.WriteBOOL(key.c_str(), m_settings.bBitstream[i]);\n        }\n\n        reg.DeleteKey(L\"SampleFormats\");\n        for (int i = 0; i < SampleFormat_Bitstream; ++i)\n        {\n            std::wstring key = std::wstring(L\"SampleFormat_\") + std::wstring(sampleFormats[i]);\n            reg.WriteBOOL(key.c_str(), m_settings.bSampleFormats[i]);\n        }\n\n        reg.WriteBOOL(L\"SampleConvertDither\", m_settings.SampleConvertDither);\n    }\n    return S_OK;\n}\n\nvoid CLAVAudio::ffmpeg_shutdown()\n{\n    m_pAVCodec = nullptr;\n    if (m_pAVCtx)\n    {\n        av_freep(&m_pAVCtx->extradata);\n        avcodec_free_context(&m_pAVCtx);\n    }\n    av_frame_free(&m_pFrame);\n    av_packet_free(&m_pDecodePacket);\n\n    if (m_pParser)\n    {\n        av_parser_close(m_pParser);\n        m_pParser = nullptr;\n    }\n\n    if (m_swrContext)\n    {\n        swr_free(&m_swrContext);\n    }\n\n    FreeBitstreamContext();\n\n    m_nCodecId = AV_CODEC_ID_NONE;\n\n    av_channel_layout_uninit(&m_DecodeLayout);\n    av_channel_layout_uninit(&m_DecodeLayoutSanified);\n    av_channel_layout_uninit(&m_SuppressLayout);\n    av_channel_layout_uninit(&m_chRemixLayout);\n    av_channel_layout_uninit(&m_chOverrideMixer);\n    av_channel_layout_uninit(&m_MixingInputLayout);\n    av_channel_layout_uninit(&m_ChannelMapOutputLayout);\n}\n\n// IUnknown\nSTDMETHODIMP CLAVAudio::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    *ppv = nullptr;\n\n    return QI(ISpecifyPropertyPages) QI(ISpecifyPropertyPages2) QI2(ILAVAudioSettings)\n        QI2(ILAVAudioStatus) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\n// ISpecifyPropertyPages2\nSTDMETHODIMP CLAVAudio::GetPages(CAUUID *pPages)\n{\n    CheckPointer(pPages, E_POINTER);\n    BOOL bShowStatusPage = m_pInput && m_pInput->IsConnected();\n    pPages->cElems = bShowStatusPage ? 4 : 3;\n    pPages->pElems = (GUID *)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);\n    if (pPages->pElems == nullptr)\n    {\n        return E_OUTOFMEMORY;\n    }\n    pPages->pElems[0] = CLSID_LAVAudioSettingsProp;\n    pPages->pElems[1] = CLSID_LAVAudioMixingProp;\n    pPages->pElems[2] = CLSID_LAVAudioFormatsProp;\n    if (bShowStatusPage)\n        pPages->pElems[3] = CLSID_LAVAudioStatusProp;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVAudio::CreatePage(const GUID &guid, IPropertyPage **ppPage)\n{\n    CheckPointer(ppPage, E_POINTER);\n    HRESULT hr = S_OK;\n\n    if (*ppPage != nullptr)\n        return E_INVALIDARG;\n\n    if (guid == CLSID_LAVAudioSettingsProp)\n        *ppPage = new CLAVAudioSettingsProp(nullptr, &hr);\n    else if (guid == CLSID_LAVAudioMixingProp)\n        *ppPage = new CLAVAudioMixingProp(nullptr, &hr);\n    else if (guid == CLSID_LAVAudioFormatsProp)\n        *ppPage = new CLAVAudioFormatsProp(nullptr, &hr);\n    else if (guid == CLSID_LAVAudioStatusProp)\n        *ppPage = new CLAVAudioStatusProp(nullptr, &hr);\n\n    if (SUCCEEDED(hr) && *ppPage)\n    {\n        (*ppPage)->AddRef();\n        return S_OK;\n    }\n    else\n    {\n        SAFE_DELETE(*ppPage);\n        return E_FAIL;\n    }\n}\n\n// ILAVAudioSettings\nHRESULT CLAVAudio::GetDRC(BOOL *pbDRCEnabled, int *piDRCLevel)\n{\n    if (pbDRCEnabled)\n    {\n        *pbDRCEnabled = m_settings.DRCEnabled;\n    }\n    if (piDRCLevel)\n    {\n        *piDRCLevel = m_settings.DRCLevel;\n    }\n    return S_OK;\n}\n\n// ILAVAudioSettings\nHRESULT CLAVAudio::SetRuntimeConfig(BOOL bRuntimeConfig)\n{\n    m_bRuntimeConfig = bRuntimeConfig;\n    LoadSettings();\n\n    // Tray Icon is disabled by default\n    SAFE_DELETE(m_pTrayIcon);\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::SetDRC(BOOL bDRCEnabled, int fDRCLevel)\n{\n    m_settings.DRCEnabled = bDRCEnabled;\n    m_settings.DRCLevel = fDRCLevel;\n\n    if (m_pAVCtx)\n    {\n        float fDRC = bDRCEnabled ? (float)fDRCLevel / 100.0f : 0.0f;\n        av_opt_set_double(m_pAVCtx, \"drc_scale\", fDRC, AV_OPT_SEARCH_CHILDREN);\n    }\n\n    SaveSettings();\n    return S_OK;\n}\n\nBOOL CLAVAudio::GetFormatConfiguration(LAVAudioCodec aCodec)\n{\n    if (aCodec < 0 || aCodec >= Codec_AudioNB)\n        return FALSE;\n    return m_settings.bFormats[aCodec];\n}\n\nHRESULT CLAVAudio::SetFormatConfiguration(LAVAudioCodec aCodec, BOOL bEnabled)\n{\n    if (aCodec < 0 || aCodec >= Codec_AudioNB)\n        return E_FAIL;\n\n    m_settings.bFormats[aCodec] = (bEnabled != 0);\n\n    SaveSettings();\n    return S_OK;\n}\n\nBOOL CLAVAudio::GetBitstreamConfig(LAVBitstreamCodec bsCodec)\n{\n    if (bsCodec < 0 || bsCodec >= Bitstream_NB)\n        return FALSE;\n\n    return m_settings.bBitstream[bsCodec];\n}\n\nHRESULT CLAVAudio::SetBitstreamConfig(LAVBitstreamCodec bsCodec, BOOL bEnabled)\n{\n    if (bsCodec >= Bitstream_NB)\n        return E_FAIL;\n\n    m_settings.bBitstream[bsCodec] = (bEnabled != 0);\n\n    SaveSettings();\n\n    m_bBitStreamingSettingsChanged = TRUE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetDTSHDFraming()\n{\n    return m_settings.DTSHDFraming;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetBitstreamingFallback()\n{\n    return m_settings.bBitstreamingFallback;\n}\n\nSTDMETHODIMP CLAVAudio::SetDTSHDFraming(BOOL bHDFraming)\n{\n    m_settings.DTSHDFraming = bHDFraming;\n    SaveSettings();\n\n    if (m_nCodecId == AV_CODEC_ID_DTS)\n        m_bBitStreamingSettingsChanged = TRUE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVAudio::SetBitstreamingFallback(BOOL bBitstreamingFallback)\n{\n    m_settings.bBitstreamingFallback = bBitstreamingFallback;\n    SaveSettings();\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetAutoAVSync()\n{\n    return m_settings.AutoAVSync;\n}\n\nSTDMETHODIMP CLAVAudio::SetAutoAVSync(BOOL bAutoSync)\n{\n    m_settings.AutoAVSync = bAutoSync;\n    SaveSettings();\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetOutputStandardLayout()\n{\n    return m_settings.OutputStandardLayout;\n}\n\nSTDMETHODIMP CLAVAudio::SetOutputStandardLayout(BOOL bStdLayout)\n{\n    m_settings.OutputStandardLayout = bStdLayout;\n    SaveSettings();\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetExpandMono()\n{\n    return m_settings.ExpandMono;\n}\n\nSTDMETHODIMP CLAVAudio::SetExpandMono(BOOL bExpandMono)\n{\n    m_settings.ExpandMono = bExpandMono;\n    SaveSettings();\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetExpand61()\n{\n    return m_settings.Expand61;\n}\n\nSTDMETHODIMP CLAVAudio::SetExpand61(BOOL bExpand61)\n{\n    m_settings.Expand61 = bExpand61;\n    SaveSettings();\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetAllowRawSPDIFInput()\n{\n    return m_settings.AllowRawSPDIF;\n}\n\nSTDMETHODIMP CLAVAudio::SetAllowRawSPDIFInput(BOOL bAllow)\n{\n    m_settings.AllowRawSPDIF = bAllow;\n    SaveSettings();\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetSampleFormat(LAVAudioSampleFormat format)\n{\n    if (format < 0 || format >= SampleFormat_NB)\n        return FALSE;\n\n    return m_settings.bSampleFormats[format];\n}\n\nSTDMETHODIMP CLAVAudio::SetSampleFormat(LAVAudioSampleFormat format, BOOL bEnabled)\n{\n    if (format < 0 || format >= SampleFormat_NB)\n        return E_FAIL;\n\n    m_settings.bSampleFormats[format] = (bEnabled != 0);\n    SaveSettings();\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVAudio::GetAudioDelay(BOOL *pbEnabled, int *pDelay)\n{\n    if (pbEnabled)\n        *pbEnabled = m_settings.AudioDelayEnabled;\n    if (pDelay)\n        *pDelay = m_settings.AudioDelay;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVAudio::SetAudioDelay(BOOL bEnabled, int delay)\n{\n    m_settings.AudioDelayEnabled = bEnabled;\n    m_settings.AudioDelay = delay;\n    SaveSettings();\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVAudio::SetMixingEnabled(BOOL bEnabled)\n{\n    m_settings.MixingEnabled = bEnabled;\n    SaveSettings();\n\n    m_bMixingSettingsChanged = TRUE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetMixingEnabled()\n{\n    return m_settings.MixingEnabled;\n}\n\nSTDMETHODIMP CLAVAudio::SetMixingLayout(DWORD dwLayout)\n{\n    m_settings.MixingLayout = dwLayout;\n    SaveSettings();\n\n    m_bMixingSettingsChanged = TRUE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(DWORD) CLAVAudio::GetMixingLayout()\n{\n    return m_settings.MixingLayout;\n}\n\nSTDMETHODIMP CLAVAudio::SetMixingFlags(DWORD dwFlags)\n{\n    m_settings.MixingFlags = dwFlags;\n    SaveSettings();\n\n    m_bMixingSettingsChanged = TRUE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(DWORD) CLAVAudio::GetMixingFlags()\n{\n    return m_settings.MixingFlags;\n}\n\nSTDMETHODIMP CLAVAudio::SetMixingMode(LAVAudioMixingMode mixingMode)\n{\n    m_settings.MixingMode = mixingMode;\n    SaveSettings();\n\n    m_bMixingSettingsChanged = TRUE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(LAVAudioMixingMode) CLAVAudio::GetMixingMode()\n{\n    return (LAVAudioMixingMode)m_settings.MixingMode;\n}\n\nSTDMETHODIMP CLAVAudio::SetMixingLevels(DWORD dwCenterLevel, DWORD dwSurroundLevel, DWORD dwLFELevel)\n{\n    m_settings.MixingCenterLevel = dwCenterLevel;\n    m_settings.MixingSurroundLevel = dwSurroundLevel;\n    m_settings.MixingLFELevel = dwLFELevel;\n    SaveSettings();\n\n    m_bMixingSettingsChanged = TRUE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVAudio::GetMixingLevels(DWORD *dwCenterLevel, DWORD *dwSurroundLevel, DWORD *dwLFELevel)\n{\n    if (dwCenterLevel)\n        *dwCenterLevel = m_settings.MixingCenterLevel;\n    if (dwSurroundLevel)\n        *dwSurroundLevel = m_settings.MixingSurroundLevel;\n    if (dwLFELevel)\n        *dwLFELevel = m_settings.MixingLFELevel;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVAudio::SetTrayIcon(BOOL bEnabled)\n{\n    m_settings.TrayIcon = bEnabled;\n    // The tray icon is created if not yet done so, however its not removed on the fly\n    // Removing the icon on the fly can cause deadlocks if the config is changed from the icons thread\n    if (bEnabled && m_pGraph && !m_pTrayIcon)\n    {\n        CreateTrayIcon();\n    }\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetTrayIcon()\n{\n    return m_settings.TrayIcon;\n}\n\nSTDMETHODIMP CLAVAudio::SetSampleConvertDithering(BOOL bEnabled)\n{\n    m_settings.SampleConvertDither = bEnabled;\n    m_bMixingSettingsChanged = TRUE;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetSampleConvertDithering()\n{\n    return m_settings.SampleConvertDither;\n}\n\nSTDMETHODIMP CLAVAudio::SetSuppressFormatChanges(BOOL bEnabled)\n{\n    m_settings.SuppressFormatChanges = bEnabled;\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetSuppressFormatChanges()\n{\n    return m_settings.SuppressFormatChanges;\n}\n\nSTDMETHODIMP CLAVAudio::SetOutput51LegacyLayout(BOOL b51Legacy)\n{\n    m_settings.Output51Legacy = b51Legacy;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVAudio::GetOutput51LegacyLayout()\n{\n    return m_settings.Output51Legacy;\n}\n\n// ILAVAudioStatus\nBOOL CLAVAudio::IsSampleFormatSupported(LAVAudioSampleFormat sfCheck)\n{\n    return FALSE;\n}\n\nHRESULT CLAVAudio::GetDecodeDetails(const char **pCodec, const char **pDecodeFormat, int *pnChannels, int *pSampleRate,\n                                    DWORD *pChannelMask)\n{\n    if (!m_pInput || m_pInput->IsConnected() == FALSE || !m_pAVCtx)\n    {\n        return E_UNEXPECTED;\n    }\n    if (m_avBSContext)\n    {\n        if (pCodec)\n        {\n            const AVCodec *codec = avcodec_find_decoder(m_nCodecId);\n            *pCodec = codec->name;\n        }\n        if (pnChannels)\n        {\n            *pnChannels = m_avBSContext->streams[0]->codecpar->ch_layout.nb_channels;\n        }\n        if (pSampleRate)\n        {\n            *pSampleRate = m_avBSContext->streams[0]->codecpar->sample_rate;\n        }\n        if (pDecodeFormat)\n        {\n            *pDecodeFormat = \"\";\n        }\n        if (pChannelMask)\n        {\n            *pChannelMask = 0;\n        }\n    }\n    else\n    {\n        if (pCodec)\n        {\n            if (m_pAVCodec)\n            {\n                if (m_nCodecId == AV_CODEC_ID_DTS && m_pAVCtx && m_pAVCtx->profile != AV_PROFILE_UNKNOWN)\n                {\n                    static const char *DTSProfiles[] = {nullptr,     nullptr,      \"dts\",       \"dts-es\",\n                                                        \"dts 96/24\", \"dts-hd hra\", \"dts-hd ma\", \"dts express\"};\n                    int index = m_pAVCtx->profile / 10;\n                    if (index >= 0 && index < countof(DTSProfiles) && DTSProfiles[index])\n                        *pCodec = DTSProfiles[index];\n                    else\n                        *pCodec = \"dts\";\n                }\n                else\n                    *pCodec = m_pAVCodec->name;\n            }\n        }\n        if (pnChannels)\n        {\n            *pnChannels = m_pAVCtx->ch_layout.nb_channels;\n        }\n        if (pSampleRate)\n        {\n            *pSampleRate = m_pAVCtx->sample_rate;\n        }\n        if (pDecodeFormat)\n        {\n            if (IsActive())\n                *pDecodeFormat = get_sample_format_desc(m_DecodeFormat);\n            else\n                *pDecodeFormat = \"Not Running\";\n        }\n        if (pChannelMask)\n        {\n            if (m_DecodeLayout.order == AV_CHANNEL_ORDER_NATIVE)\n                *pChannelMask = (DWORD)m_DecodeLayout.u.mask;\n            else\n                *pChannelMask = 0;\n        }\n    }\n    return S_OK;\n}\n\nHRESULT CLAVAudio::GetOutputDetails(const char **pOutputFormat, int *pnChannels, int *pSampleRate, DWORD *pChannelMask)\n{\n    if (!m_pOutput || m_pOutput->IsConnected() == FALSE)\n    {\n        return E_UNEXPECTED;\n    }\n    if (m_avBSContext)\n    {\n        if (pOutputFormat)\n        {\n            *pOutputFormat = get_sample_format_desc(SampleFormat_Bitstream);\n        }\n        return S_FALSE;\n    }\n    if (pOutputFormat)\n    {\n        *pOutputFormat = get_sample_format_desc(m_OutputQueue.sfFormat);\n    }\n    if (pnChannels)\n    {\n        *pnChannels = m_OutputQueue.layout.nb_channels;\n    }\n    if (pSampleRate)\n    {\n        *pSampleRate = m_OutputQueue.dwSamplesPerSec;\n    }\n    if (pChannelMask)\n    {\n        if (m_OutputQueue.layout.order == AV_CHANNEL_ORDER_NATIVE)\n            *pChannelMask = (DWORD)m_OutputQueue.layout.u.mask;\n        else\n            *pChannelMask = 0;\n    }\n    return S_OK;\n}\n\nHRESULT CLAVAudio::EnableVolumeStats()\n{\n    DbgLog((LOG_TRACE, 1, L\"Volume Statistics Enabled\"));\n    m_bVolumeStats = TRUE;\n    return S_OK;\n}\n\nHRESULT CLAVAudio::DisableVolumeStats()\n{\n    DbgLog((LOG_TRACE, 1, L\"Volume Statistics Disabled\"));\n    m_bVolumeStats = FALSE;\n    return S_OK;\n}\n\nHRESULT CLAVAudio::GetChannelVolumeAverage(WORD nChannel, float *pfDb)\n{\n    CheckPointer(pfDb, E_POINTER);\n    if (!m_pOutput || m_pOutput->IsConnected() == FALSE || !m_bVolumeStats || m_avBSContext)\n    {\n        return E_UNEXPECTED;\n    }\n    if (nChannel >= m_OutputQueue.layout.nb_channels || nChannel >= MAX_VOLUME_STAT_CHANNEL)\n    {\n        return E_INVALIDARG;\n    }\n    *pfDb = m_faVolume[nChannel].Average();\n    return S_OK;\n}\n\n// CTransformFilter\nHRESULT CLAVAudio::CheckInputType(const CMediaType *mtIn)\n{\n    for (UINT i = 0; i < sudPinTypesInCount; i++)\n    {\n        if (*sudPinTypesIn[i].clsMajorType == mtIn->majortype && *sudPinTypesIn[i].clsMinorType == mtIn->subtype &&\n            (mtIn->formattype == FORMAT_WaveFormatEx || mtIn->formattype == FORMAT_WaveFormatExFFMPEG ||\n             mtIn->formattype == FORMAT_VorbisFormat2))\n        {\n            return S_OK;\n        }\n    }\n\n    if (m_settings.AllowRawSPDIF)\n    {\n        if (mtIn->majortype == MEDIATYPE_Audio && mtIn->formattype == FORMAT_WaveFormatEx &&\n            (mtIn->subtype == MEDIASUBTYPE_PCM || mtIn->subtype == MEDIASUBTYPE_IEEE_FLOAT ||\n             mtIn->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF))\n        {\n            return S_OK;\n        }\n    }\n\n    return VFW_E_TYPE_NOT_ACCEPTED;\n}\n\n// Get the output media types\nHRESULT CLAVAudio::GetMediaType(int iPosition, CMediaType *pMediaType)\n{\n    DbgLog((LOG_TRACE, 5, L\"GetMediaType\"));\n    if (m_pInput->IsConnected() == FALSE || !((m_pAVCtx && m_pAVCodec) || m_avBSContext))\n    {\n        return E_UNEXPECTED;\n    }\n\n    if (iPosition < 0)\n    {\n        return E_INVALIDARG;\n    }\n\n    if (m_avBSContext)\n    {\n        if (iPosition == 0)\n        {\n            *pMediaType = CreateBitstreamMediaType(m_nCodecId, m_pAVCtx->sample_rate, TRUE);\n            return S_OK;\n        }\n        else\n        {\n            if (!m_settings.bBitstreamingFallback)\n                return VFW_S_NO_MORE_ITEMS;\n\n            iPosition--;\n        }\n    }\n\n    const int nSamplesPerSec = m_pAVCtx->sample_rate;\n    int nChannels = m_pAVCtx->ch_layout.nb_channels;\n    DWORD dwChannelMask = get_lav_channel_layout(&m_pAVCtx->ch_layout);\n    if (dwChannelMask == 0)\n        dwChannelMask = get_channel_mask(nChannels);\n\n    AVSampleFormat sample_fmt = m_pAVCtx->sample_fmt;\n    if (sample_fmt == AV_SAMPLE_FMT_NONE)\n    {\n        int num_configs = 0;\n        const enum AVSampleFormat *SampleFormats = NULL;\n        int ret = avcodec_get_supported_config(m_pAVCtx, m_pAVCodec, AV_CODEC_CONFIG_SAMPLE_FORMAT, 0, (const void **)&SampleFormats, &num_configs);\n\n        if (ret >= 0 && num_configs > 0 && SampleFormats)\n            sample_fmt = SampleFormats[0];\n    }\n\n    if (sample_fmt == AV_SAMPLE_FMT_NONE)\n        sample_fmt = AV_SAMPLE_FMT_S32; // this gets mapped to S16/S24/S32 in get_lav_sample_fmt based on the bits per sample\n\n    // Prefer bits_per_raw_sample if set, but if not, try to do a better guess with bits per coded sample\n    int bits = m_pAVCtx->bits_per_raw_sample ? m_pAVCtx->bits_per_raw_sample : m_pAVCtx->bits_per_coded_sample;\n\n    LAVAudioSampleFormat lav_sample_fmt = get_lav_sample_fmt(sample_fmt, bits);\n    if (m_settings.MixingEnabled)\n    {\n        if (nChannels != av_popcount(m_settings.MixingLayout) &&\n            (nChannels > 2 || !(m_settings.MixingFlags & LAV_MIXING_FLAG_UNTOUCHED_STEREO)))\n        {\n            lav_sample_fmt = SampleFormat_FP32;\n            bits = 32;\n            dwChannelMask = m_settings.MixingLayout;\n            nChannels = av_popcount(dwChannelMask);\n        }\n        else if (nChannels == 7 && m_settings.Expand61)\n        {\n            nChannels = 8;\n            dwChannelMask = get_channel_mask(nChannels);\n        }\n        else if (nChannels == 1 && m_settings.ExpandMono)\n        {\n            nChannels = 2;\n            dwChannelMask = get_channel_mask(nChannels);\n        }\n    }\n\n    // possible format combinations:\n    // 0: original\n    // 1: 16-bit integer fallback\n    // 2: alternate channel layout/count (5.1 back, or downmix to 8 channel)\n    // 3: alternate channel layout, 16-bit\n\n    // map to legacy 5.1 if user requested\n    if (dwChannelMask == AV_CH_LAYOUT_5POINT1 && m_settings.Output51Legacy)\n        dwChannelMask = AV_CH_LAYOUT_5POINT1_BACK;\n\n    if (dwChannelMask == AV_CH_LAYOUT_5POINT1 && iPosition > 1 && iPosition < 4)\n        dwChannelMask = AV_CH_LAYOUT_5POINT1_BACK;\n    else if (nChannels > 8 && iPosition > 1 && iPosition < 4) // more then 8 channel, offer a downmix to 8 channel\n    {\n        nChannels = 8;\n        dwChannelMask = AV_CH_LAYOUT_7POINT1;\n    }\n    else if (iPosition > 1)\n        return VFW_S_NO_MORE_ITEMS;\n\n    if (iPosition % 2)\n    {\n        lav_sample_fmt = SampleFormat_16;\n        bits = 16;\n    }\n    else\n    {\n        lav_sample_fmt = GetBestAvailableSampleFormat(lav_sample_fmt, &bits, TRUE);\n    }\n\n    *pMediaType = CreateMediaType(lav_sample_fmt, nSamplesPerSec, nChannels, dwChannelMask, bits);\n    return S_OK;\n}\n\nHRESULT CLAVAudio::ReconnectOutput(long cbBuffer, CMediaType &mt)\n{\n    HRESULT hr = S_FALSE;\n\n    IMemInputPin *pPin = nullptr;\n    IMemAllocator *pAllocator = nullptr;\n\n    CHECK_HR(hr = m_pOutput->GetConnected()->QueryInterface(&pPin));\n\n    if (FAILED(hr = pPin->GetAllocator(&pAllocator)) || !pAllocator)\n    {\n        goto done;\n    }\n\n    ALLOCATOR_PROPERTIES props, actual;\n    CHECK_HR(hr = pAllocator->GetProperties(&props));\n\n    hr = S_FALSE;\n\n    if (mt != m_pOutput->CurrentMediaType() || cbBuffer > props.cbBuffer)\n    {\n        DbgLog(\n            (LOG_TRACE, 10, L\"::ReconnectOutput(): Reconnecting output because media type or buffer size changed...\"));\n        if (cbBuffer > props.cbBuffer)\n        {\n            DbgLog((LOG_TRACE, 10, L\"::ReconnectOutput(): -> Increasing buffer size\"));\n            props.cBuffers = 4;\n            props.cbBuffer = cbBuffer * 3 / 2;\n\n            if (FAILED(hr = m_pOutput->DeliverBeginFlush()) || FAILED(hr = m_pOutput->DeliverEndFlush()) ||\n                FAILED(hr = pAllocator->Decommit()) || FAILED(hr = pAllocator->SetProperties(&props, &actual)) ||\n                FAILED(hr = pAllocator->Commit()))\n            {\n                goto done;\n            }\n\n            if (props.cBuffers > actual.cBuffers || props.cbBuffer > actual.cbBuffer)\n            {\n                NotifyEvent(EC_ERRORABORT, hr, 0);\n                hr = E_FAIL;\n                goto done;\n            }\n        }\n\n        hr = S_OK;\n    }\n\ndone:\n    SafeRelease(&pPin);\n    SafeRelease(&pAllocator);\n    return hr;\n}\n\nCMediaType CLAVAudio::CreateMediaType(LAVAudioSampleFormat outputFormat, DWORD nSamplesPerSec, WORD nChannels,\n                                      DWORD dwChannelMask, WORD wBitsPerSample) const\n{\n    CMediaType mt;\n\n    mt.majortype = MEDIATYPE_Audio;\n    mt.subtype = (outputFormat == SampleFormat_FP32) ? MEDIASUBTYPE_IEEE_FLOAT : MEDIASUBTYPE_PCM;\n    mt.formattype = FORMAT_WaveFormatEx;\n\n    WAVEFORMATEXTENSIBLE wfex;\n    memset(&wfex, 0, sizeof(wfex));\n\n    if (wBitsPerSample >> 3 > get_byte_per_sample(outputFormat))\n    {\n        DbgLog((LOG_TRACE, 20, L\"Invalid combination of sample format and bits per sample\"));\n        outputFormat = get_lav_sample_fmt(AV_SAMPLE_FMT_S32, wBitsPerSample);\n    }\n\n    WAVEFORMATEX *wfe = &wfex.Format;\n    wfe->wFormatTag = (WORD)mt.subtype.Data1;\n    wfe->nChannels = nChannels;\n    wfe->nSamplesPerSec = nSamplesPerSec;\n    wfe->wBitsPerSample = get_byte_per_sample(outputFormat) << 3;\n    wfe->nBlockAlign = wfe->nChannels * wfe->wBitsPerSample / 8;\n    wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;\n\n    BOOL bUseExtensible = FALSE;\n\n    // non-standard mono/stereo\n    if (dwChannelMask != 0 && (nChannels == 1 && dwChannelMask != KSAUDIO_SPEAKER_MONO ||\n                               nChannels == 2 && dwChannelMask != KSAUDIO_SPEAKER_STEREO))\n        bUseExtensible = TRUE;\n    else if (nChannels > 2) // more then two channels\n        bUseExtensible = TRUE;\n    else if (wfe->wBitsPerSample > 16 && outputFormat != SampleFormat_FP32) // high bitdepth integer\n        bUseExtensible = TRUE;\n    else if (wfe->nSamplesPerSec > 48000) // high sample rate\n        bUseExtensible = TRUE;\n\n    if (bUseExtensible)\n    {\n        wfex.Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;\n        wfex.Format.cbSize = sizeof(wfex) - sizeof(wfex.Format);\n        wfex.dwChannelMask = dwChannelMask;\n        if (wBitsPerSample > 0 && (outputFormat == SampleFormat_24 || outputFormat == SampleFormat_32))\n        {\n            WORD wBpp = wBitsPerSample;\n            if ((outputFormat == SampleFormat_24 && wBpp <= 16) || (outputFormat == SampleFormat_32 && wBpp < 24))\n                wBpp = 24;\n            wfex.Samples.wValidBitsPerSample = wBpp;\n        }\n        else\n        {\n            wfex.Samples.wValidBitsPerSample = wfex.Format.wBitsPerSample;\n        }\n        wfex.SubFormat = mt.subtype;\n    }\n\n    mt.SetSampleSize(wfe->wBitsPerSample * wfe->nChannels / 8);\n    mt.SetFormat((BYTE *)&wfex, sizeof(wfex.Format) + wfex.Format.cbSize);\n\n    return mt;\n}\n\n// Check if the types are compatible\nHRESULT CLAVAudio::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut)\n{\n    // Check major types\n    if (FAILED(CheckInputType(mtIn)) || mtOut->majortype != MEDIATYPE_Audio ||\n        (mtOut->subtype != MEDIASUBTYPE_PCM && mtOut->subtype != MEDIASUBTYPE_IEEE_FLOAT) ||\n        mtOut->formattype != FORMAT_WaveFormatEx)\n    {\n        return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n    else\n    {\n        // Check for valid pcm settings, but only when output type is changing\n        if (!m_avBSContext && m_pAVCtx && *mtOut != m_pOutput->CurrentMediaType())\n        {\n            WAVEFORMATEX *wfex = (WAVEFORMATEX *)mtOut->pbFormat;\n            if (wfex->nSamplesPerSec != m_pAVCtx->sample_rate)\n            {\n                return VFW_E_TYPE_NOT_ACCEPTED;\n            }\n        }\n    }\n    return S_OK;\n}\n\nHRESULT CLAVAudio::DecideBufferSize(IMemAllocator *pAllocator, ALLOCATOR_PROPERTIES *pProperties)\n{\n    if (m_pInput->IsConnected() == FALSE)\n    {\n        return E_UNEXPECTED;\n    }\n\n    /*CMediaType& mt = m_pInput->CurrentMediaType();\n    WAVEFORMATEX* wfe = (WAVEFORMATEX*)mt.Format();\n    UNUSED_ALWAYS(wfe); */\n\n    pProperties->cBuffers = 4;\n    // TODO: we should base this on the output media type\n    pProperties->cbBuffer = LAV_AUDIO_BUFFER_SIZE; // 48KHz 6ch 32bps 100ms\n    pProperties->cbAlign = 1;\n    pProperties->cbPrefix = 0;\n\n    HRESULT hr;\n    ALLOCATOR_PROPERTIES Actual;\n    if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))\n    {\n        return hr;\n    }\n\n    return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer ? E_FAIL : NOERROR;\n}\n\nHRESULT CLAVAudio::ffmpeg_init(AVCodecID codec, const void *format, const GUID format_type, DWORD formatlen)\n{\n    CAutoLock lock(&m_csReceive);\n    ffmpeg_shutdown();\n    DbgLog((LOG_TRACE, 10, L\"::ffmpeg_init(): Initializing decoder for codec %S\", avcodec_get_name(codec)));\n\n    if (codec == AV_CODEC_ID_DTS || codec == AV_CODEC_ID_TRUEHD)\n    {\n        m_faJitter.SetNumSamples(256);\n        m_JitterLimit = MAX_JITTER_DESYNC * 10;\n    }\n    else\n    {\n        m_faJitter.SetNumSamples(64);\n        m_JitterLimit = MAX_JITTER_DESYNC;\n    }\n\n    // Fake codecs that are dependant in input bits per sample, mostly to handle QT PCM tracks\n    if (codec == AV_CODEC_ID_PCM_QTRAW || codec == AV_CODEC_ID_PCM_SxxBE || codec == AV_CODEC_ID_PCM_SxxLE ||\n        codec == AV_CODEC_ID_PCM_UxxBE || codec == AV_CODEC_ID_PCM_UxxLE)\n    {\n        if (format_type == FORMAT_WaveFormatEx)\n        {\n            WAVEFORMATEX *wfein = (WAVEFORMATEX *)format;\n            ASSERT(wfein->wBitsPerSample == 8 || wfein->wBitsPerSample == 16);\n            switch (codec)\n            {\n            case AV_CODEC_ID_PCM_QTRAW:\n                codec = wfein->wBitsPerSample == 8 ? AV_CODEC_ID_PCM_U8 : AV_CODEC_ID_PCM_S16BE;\n                break;\n            case AV_CODEC_ID_PCM_SxxBE:\n                codec = wfein->wBitsPerSample == 8 ? AV_CODEC_ID_PCM_S8 : AV_CODEC_ID_PCM_S16BE;\n                break;\n            case AV_CODEC_ID_PCM_SxxLE:\n                codec = wfein->wBitsPerSample == 8 ? AV_CODEC_ID_PCM_S8 : AV_CODEC_ID_PCM_S16LE;\n                break;\n            case AV_CODEC_ID_PCM_UxxBE:\n                codec = wfein->wBitsPerSample == 8 ? AV_CODEC_ID_PCM_U8 : AV_CODEC_ID_PCM_U16BE;\n                break;\n            case AV_CODEC_ID_PCM_UxxLE:\n                codec = wfein->wBitsPerSample == 8 ? AV_CODEC_ID_PCM_U8 : AV_CODEC_ID_PCM_U16LE;\n                break;\n            }\n        }\n    }\n\n    // Special check for enabled PCM\n    if (codec >= 0x10000 && codec < 0x12000 && codec != AV_CODEC_ID_PCM_BLURAY && codec != AV_CODEC_ID_PCM_DVD &&\n        !m_settings.bFormats[Codec_PCM])\n        return VFW_E_UNSUPPORTED_AUDIO;\n\n    for (int i = 0; i < Codec_AudioNB; ++i)\n    {\n        const codec_config_t *config = get_codec_config((LAVAudioCodec)i);\n        bool bMatched = false;\n        for (int k = 0; k < config->nCodecs; ++k)\n        {\n            if (config->codecs[k] == codec)\n            {\n                bMatched = true;\n                break;\n            }\n        }\n        if (bMatched && !m_settings.bFormats[i])\n        {\n            return VFW_E_UNSUPPORTED_AUDIO;\n        }\n    }\n\n    // If the codec is bitstreaming, and enabled for it, go there now\n    if (IsBitstreaming(codec))\n    {\n        WAVEFORMATEX *wfe = (format_type == FORMAT_WaveFormatEx) ? (WAVEFORMATEX *)format : nullptr;\n\n        if (wfe)\n            CreateBitstreamContext(codec, wfe);\n    }\n\n    m_pAVCodec = nullptr;\n\n    // Try codec overrides\n    const char *codec_override = find_codec_override(codec);\n    if (codec_override)\n        m_pAVCodec = avcodec_find_decoder_by_name(codec_override);\n\n    // Fallback to default\n    if (!m_pAVCodec)\n        m_pAVCodec = avcodec_find_decoder(codec);\n    CheckPointer(m_pAVCodec, VFW_E_UNSUPPORTED_AUDIO);\n\n    m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);\n    CheckPointer(m_pAVCtx, E_POINTER);\n\n    if ((codec != AV_CODEC_ID_AAC || m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_MPEG_ADTS_AAC) &&\n        codec != AV_CODEC_ID_FLAC && codec != AV_CODEC_ID_COOK)\n        m_pParser = av_parser_init(codec);\n\n    if (codec == AV_CODEC_ID_OPUS)\n    {\n        m_pAVCtx->request_sample_fmt = AV_SAMPLE_FMT_FLT;\n    }\n    else if (codec == AV_CODEC_ID_ALAC)\n    {\n        m_pAVCtx->request_sample_fmt = AV_SAMPLE_FMT_S32P;\n    }\n\n    // We can only trust LAV Splitters LATM AAC header...\n    BOOL bTrustExtraData = TRUE;\n    if (codec == AV_CODEC_ID_AAC_LATM)\n    {\n        if (!(FilterInGraphSafe(m_pInput, CLSID_LAVSplitter) || FilterInGraphSafe(m_pInput, CLSID_LAVSplitterSource)))\n        {\n            bTrustExtraData = FALSE;\n        }\n    }\n\n    DWORD nSamples, nBytesPerSec, nChannelMask;\n    WORD nChannels, nBitsPerSample, nBlockAlign;\n    audioFormatTypeHandler((BYTE *)format, &format_type, &nSamples, &nChannels, &nBitsPerSample, &nBlockAlign,\n                           &nBytesPerSec, &nChannelMask);\n\n    size_t extralen = 0;\n    getExtraData((BYTE *)format, &format_type, formatlen, nullptr, &extralen);\n\n    m_pAVCtx->thread_count = 1;\n    m_pAVCtx->thread_type = 0;\n    m_pAVCtx->sample_rate = nSamples;\n    m_pAVCtx->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;\n    m_pAVCtx->ch_layout.nb_channels = nChannels;\n    if (nChannelMask != 0 && av_popcount(nChannelMask) == nChannels)\n    {\n        av_channel_layout_uninit(&m_pAVCtx->ch_layout);\n        av_channel_layout_from_mask(&m_pAVCtx->ch_layout, nChannelMask);\n    }\n    m_pAVCtx->bit_rate = nBytesPerSec << 3;\n    m_pAVCtx->bits_per_coded_sample = nBitsPerSample;\n    m_pAVCtx->block_align = nBlockAlign;\n    m_pAVCtx->err_recognition = 0;\n    m_pAVCtx->pkt_timebase.num = 1;\n    m_pAVCtx->pkt_timebase.den = 10000000;\n\n    memset(&m_raData, 0, sizeof(m_raData));\n\n    if (bTrustExtraData && extralen)\n    {\n        if (codec == AV_CODEC_ID_COOK || codec == AV_CODEC_ID_ATRAC3 || codec == AV_CODEC_ID_SIPR)\n        {\n            uint8_t *extra = (uint8_t *)av_mallocz(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n            getExtraData((BYTE *)format, &format_type, formatlen, extra, nullptr);\n\n            if (extra[0] == '.' && extra[1] == 'r' && extra[2] == 'a' && extra[3] == 0xfd)\n            {\n                HRESULT hr = ParseRealAudioHeader(extra, extralen);\n                av_freep(&extra);\n                if (FAILED(hr))\n                    return hr;\n\n                if (codec == AV_CODEC_ID_SIPR)\n                {\n                    if (m_raData.flavor > 3)\n                    {\n                        DbgLog((LOG_TRACE, 10, L\"->  Invalid SIPR flavor (%d)\", m_raData.flavor));\n                        return VFW_E_UNSUPPORTED_AUDIO;\n                    }\n                    m_pAVCtx->block_align = ff_sipr_subpk_size[m_raData.flavor];\n                }\n                else if (codec == AV_CODEC_ID_COOK || codec == AV_CODEC_ID_ATRAC3)\n                {\n                    m_pAVCtx->block_align = m_raData.sub_packet_size;\n                }\n\n                // Validate some settings\n                if (m_raData.deint_id == MKBETAG('g', 'e', 'n', 'r'))\n                {\n                    if (m_raData.sub_packet_size <= 0 || m_raData.sub_packet_size > m_raData.audio_framesize)\n                        return VFW_E_UNSUPPORTED_AUDIO;\n                }\n            }\n            else\n            {\n                // Try without any processing?\n                m_pAVCtx->extradata_size = (int)extralen;\n                m_pAVCtx->extradata = extra;\n            }\n        }\n        else\n        {\n            m_pAVCtx->extradata_size = (int)extralen;\n            m_pAVCtx->extradata = (uint8_t *)av_mallocz(m_pAVCtx->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);\n            getExtraData((BYTE *)format, &format_type, formatlen, m_pAVCtx->extradata, nullptr);\n        }\n    }\n\n    m_nCodecId = codec;\n\n    int ret = avcodec_open2(m_pAVCtx, m_pAVCodec, nullptr);\n    if (ret >= 0)\n    {\n        m_pFrame = av_frame_alloc();\n    }\n    else\n    {\n        return VFW_E_UNSUPPORTED_AUDIO;\n    }\n\n    // Set initial format for DTS based on the best guess\n    if (codec == AV_CODEC_ID_DTS)\n    {\n        if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_DTS_HD)\n        {\n            // HD with 16 or 24 bits is likely HD MA\n            // everything else outputs float\n            if (nBitsPerSample == 24)\n            {\n                m_pAVCtx->sample_fmt = AV_SAMPLE_FMT_S32P;\n                m_pAVCtx->bits_per_raw_sample = 24;\n            }\n            else if (nBitsPerSample == 16)\n            {\n                m_pAVCtx->sample_fmt = AV_SAMPLE_FMT_S16P;\n                m_pAVCtx->bits_per_raw_sample = 16;\n            }\n            else\n            {\n                m_pAVCtx->sample_fmt = AV_SAMPLE_FMT_FLTP;\n            }\n        }\n        // Lossy is by default float output\n        else\n        {\n            m_pAVCtx->sample_fmt = AV_SAMPLE_FMT_FLTP;\n        }\n    }\n\n    // Parse VorbisComment entries from FLAC extradata to find the WAVEFORMATEXTENSIBLE_CHANNEL_MASK tag\n    // This tag is used to store non-standard channel layouts in FLAC files, see LAV-8 / Issue 342\n    if (codec == AV_CODEC_ID_FLAC)\n    {\n        uint8_t *streaminfo;\n        ret = ff_flac_is_extradata_valid(m_pAVCtx, &streaminfo);\n        // full FLAC header\n        if (ret && AV_RL32(m_pAVCtx->extradata) == MKTAG('f','L','a','C'))\n        {\n            AVDictionary *metadata = nullptr;\n            int metadata_last = 0, metadata_type, metadata_size;\n            uint8_t *header = m_pAVCtx->extradata + 4, *end = m_pAVCtx->extradata + m_pAVCtx->extradata_size;\n            while (header + 4 < end && !metadata_last)\n            {\n                flac_parse_block_header(header, &metadata_last, &metadata_type, &metadata_size);\n                header += 4;\n                if (header + metadata_size > end)\n                    break;\n                switch (metadata_type)\n                {\n                case FLAC_METADATA_TYPE_VORBIS_COMMENT:\n                    ff_vorbis_comment(nullptr, &metadata, header, metadata_size, 0);\n                    break;\n                }\n                header += metadata_size;\n            }\n            if (metadata)\n            {\n                AVDictionaryEntry *entry = av_dict_get(metadata, \"WAVEFORMATEXTENSIBLE_CHANNEL_MASK\", nullptr, 0);\n                if (entry && entry->value)\n                {\n                    uint64_t channel_layout = strtol(entry->value, nullptr, 0);\n                    if (channel_layout && av_popcount64(channel_layout) == m_pAVCtx->ch_layout.nb_channels)\n                    {\n                        av_channel_layout_uninit(&m_pAVCtx->ch_layout);\n                        av_channel_layout_from_mask(&m_pAVCtx->ch_layout, channel_layout);\n                    }\n                }\n                av_dict_free(&metadata);\n            }\n        }\n    }\n\n    // Set Dynamic Range Compression\n    float drc_scale = m_settings.DRCEnabled ? (float)m_settings.DRCLevel / 100.0f : 0.0f;\n    ret = av_opt_set_double(m_pAVCtx, \"drc_scale\", drc_scale, AV_OPT_SEARCH_CHILDREN);\n\n    // This could probably be a bit smarter..\n    if (codec == AV_CODEC_ID_PCM_BLURAY || codec == AV_CODEC_ID_PCM_DVD)\n    {\n        m_pAVCtx->bits_per_raw_sample = m_pAVCtx->bits_per_coded_sample;\n    }\n\n    // Some sanity checks\n    if (m_pAVCtx->ch_layout.nb_channels > 64)\n    {\n        return VFW_E_UNSUPPORTED_AUDIO;\n    }\n\n    m_bFindDTSInPCM = (codec == AV_CODEC_ID_PCM_S16LE && m_settings.bFormats[Codec_DTS]);\n    m_FallbackFormat = SampleFormat_None;\n    av_channel_layout_uninit(&m_chOverrideMixer);\n    av_channel_layout_uninit(&m_SuppressLayout);\n    m_bMixingSettingsChanged = TRUE;\n    m_bMPEGAudioResync = (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_MPEG1AudioPayload);\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::SetMediaType(PIN_DIRECTION dir, const CMediaType *pmt)\n{\n    DbgLog((LOG_TRACE, 5, L\"SetMediaType -- %S\", dir == PINDIR_INPUT ? \"in\" : \"out\"));\n    if (dir == PINDIR_INPUT)\n    {\n        AVCodecID codec = AV_CODEC_ID_NONE;\n        const void *format = pmt->Format();\n        GUID format_type = pmt->formattype;\n        DWORD formatlen = pmt->cbFormat;\n\n        // Override the format type\n        if (pmt->subtype == MEDIASUBTYPE_FFMPEG_AUDIO && pmt->formattype == FORMAT_WaveFormatExFFMPEG)\n        {\n            WAVEFORMATEXFFMPEG *wfexff = (WAVEFORMATEXFFMPEG *)pmt->Format();\n            codec = (AVCodecID)wfexff->nCodecId;\n            format = &wfexff->wfex;\n            format_type = FORMAT_WaveFormatEx;\n            formatlen -= sizeof(WAVEFORMATEXFFMPEG) - sizeof(WAVEFORMATEX);\n        }\n        else\n        {\n            codec = FindCodecId(pmt);\n        }\n\n        if (codec == AV_CODEC_ID_NONE)\n        {\n            if (m_settings.AllowRawSPDIF)\n            {\n                if (pmt->formattype == FORMAT_WaveFormatEx && pmt->subtype == MEDIASUBTYPE_PCM)\n                {\n                    WAVEFORMATEX *wfex = (WAVEFORMATEX *)pmt->Format();\n                    switch (wfex->wBitsPerSample)\n                    {\n                    case 8: codec = AV_CODEC_ID_PCM_U8; break;\n                    case 16: codec = AV_CODEC_ID_PCM_S16LE; break;\n                    case 24: codec = AV_CODEC_ID_PCM_S24LE; break;\n                    case 32: codec = AV_CODEC_ID_PCM_S32LE; break;\n                    }\n                }\n                else if (pmt->formattype == FORMAT_WaveFormatEx && pmt->subtype == MEDIASUBTYPE_IEEE_FLOAT)\n                {\n                    codec = AV_CODEC_ID_PCM_F32LE;\n                }\n                else if (pmt->subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF)\n                {\n                    codec = AV_CODEC_ID_AC3;\n                }\n            }\n            if (codec == AV_CODEC_ID_NONE)\n                return VFW_E_TYPE_NOT_ACCEPTED;\n        }\n\n        HRESULT hr = ffmpeg_init(codec, format, format_type, formatlen);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n\n        m_bDVDPlayback = (pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK || pmt->majortype == MEDIATYPE_MPEG2_PACK ||\n                          pmt->majortype == MEDIATYPE_MPEG2_PES);\n    }\n    return __super::SetMediaType(dir, pmt);\n}\n\nHRESULT CLAVAudio::CheckConnect(PIN_DIRECTION dir, IPin *pPin)\n{\n    DbgLog((LOG_TRACE, 5, L\"CheckConnect -- %S\", dir == PINDIR_INPUT ? \"in\" : \"out\"));\n    if (dir == PINDIR_INPUT)\n    {\n        if (!m_bRuntimeConfig && CheckApplicationBlackList(LAVC_AUDIO_REGISTRY_KEY L\"\\\\Blacklist\"))\n            return E_FAIL;\n\n        // TODO: Check if the upstream source filter is LAVFSplitter, and store that somewhere\n        // Validate that this is called before any media type negotiation\n    }\n    return __super::CheckConnect(dir, pPin);\n}\n\nHRESULT CLAVAudio::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin)\n{\n    DbgLog((LOG_TRACE, 5, L\"CompleteConnect -- %S\", dir == PINDIR_INPUT ? \"in\" : \"out\"));\n    if (dir == PINDIR_OUTPUT)\n    {\n        // check that we connected with a bitstream type, or go back to decoding otherwise\n        if (m_avBSContext && m_settings.bBitstreamingFallback)\n        {\n            CMediaType &mt = m_pOutput->CurrentMediaType();\n            WAVEFORMATEX *wfe = (WAVEFORMATEX *)mt.Format();\n            bool bPCM = false;\n\n            // float is always PCM\n            if (mt.subtype == MEDIASUBTYPE_IEEE_FLOAT || wfe->wFormatTag == WAVE_FORMAT_PCM)\n                bPCM = true;\n            else if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE)\n            {\n                WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE *)wfe;\n                if (wfex->SubFormat == MEDIASUBTYPE_IEEE_FLOAT || wfex->SubFormat == MEDIASUBTYPE_PCM)\n                    bPCM = true;\n            }\n\n            if (bPCM)\n                BitstreamFallbackToPCM();\n        }\n    }\n    return __super::CompleteConnect(dir, pReceivePin);\n}\n\nHRESULT CLAVAudio::EndOfStream()\n{\n    DbgLog((LOG_TRACE, 10, L\"CLAVAudio::EndOfStream()\"));\n    CAutoLock cAutoLock(&m_csReceive);\n\n    // Flush the last data out of the parser\n    ProcessBuffer(nullptr);\n    ProcessBuffer(nullptr, TRUE);\n\n    FlushOutput(TRUE);\n    return __super::EndOfStream();\n}\n\nHRESULT CLAVAudio::PerformFlush()\n{\n    CAutoLock cAutoLock(&m_csReceive);\n\n    m_buff.Clear();\n    FlushOutput(FALSE);\n    FlushDecoder();\n\n    m_bsOutput.SetSize(0);\n\n    m_rtStart = 0;\n    m_bQueueResync = TRUE;\n    m_bNeedSyncpoint = (m_raData.deint_id != 0);\n    av_channel_layout_uninit(&m_SuppressLayout);\n    m_bMPEGAudioResync = (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_MPEG1AudioPayload);\n\n    memset(&m_TrueHDMATState, 0, sizeof(m_TrueHDMATState));\n    m_rtBitstreamCache = AV_NOPTS_VALUE;\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::BeginFlush()\n{\n    DbgLog((LOG_TRACE, 10, L\"CLAVAudio::BeginFlush()\"));\n    m_bFlushing = TRUE;\n    return __super::BeginFlush();\n}\n\nHRESULT CLAVAudio::EndFlush()\n{\n    DbgLog((LOG_TRACE, 10, L\"CLAVAudio::EndFlush()\"));\n    CAutoLock cAutoLock(&m_csReceive);\n\n    if (m_bDVDPlayback)\n        PerformFlush();\n\n    HRESULT hr = __super::EndFlush();\n    m_bFlushing = FALSE;\n    return hr;\n}\n\nHRESULT CLAVAudio::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    DbgLog((LOG_TRACE, 10, L\"CLAVAudio::NewSegment() tStart: %I64d, tStop: %I64d, dRate: %.2f\", tStart, tStop, dRate));\n    CAutoLock cAutoLock(&m_csReceive);\n\n    PerformFlush();\n\n    if (dRate > 0.0)\n        m_dRate = dRate;\n    else\n        m_dRate = 1.0;\n    return __super::NewSegment(tStart, tStop, dRate);\n}\n\nHRESULT CLAVAudio::FlushDecoder()\n{\n    if (m_bJustFlushed)\n        return S_OK;\n\n    if (m_pParser)\n    {\n        av_parser_close(m_pParser);\n        m_pParser = av_parser_init(m_nCodecId);\n        m_bUpdateTimeCache = TRUE;\n    }\n\n    if (m_pAVCtx && avcodec_is_open(m_pAVCtx))\n    {\n        avcodec_flush_buffers(m_pAVCtx);\n    }\n\n    m_bJustFlushed = TRUE;\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::Receive(IMediaSample *pIn)\n{\n    CAutoLock cAutoLock(&m_csReceive);\n\n    HRESULT hr;\n\n    AM_SAMPLE2_PROPERTIES const *pProps = m_pInput->SampleProps();\n    if (pProps->dwStreamId != AM_STREAM_MEDIA)\n    {\n        return m_pOutput->Deliver(pIn);\n    }\n\n    AM_MEDIA_TYPE *pmt;\n    if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::Receive(): Input sample contained media type, dynamic format change...\"));\n        CMediaType mt(*pmt);\n        m_pInput->SetMediaType(&mt);\n        DeleteMediaType(pmt);\n        pmt = nullptr;\n        m_buff.Clear();\n\n        m_bQueueResync = TRUE;\n    }\n\n    if (m_bBitStreamingSettingsChanged)\n    {\n        m_bBitStreamingSettingsChanged = FALSE;\n        UpdateBitstreamContext();\n    }\n\n    if (!m_pAVCtx)\n    {\n        return E_FAIL;\n    }\n\n    BYTE *pDataIn = nullptr;\n    if (FAILED(hr = pIn->GetPointer(&pDataIn)))\n    {\n        return hr;\n    }\n\n    long len = pIn->GetActualDataLength();\n    if (len < 0)\n    {\n        DbgLog((LOG_ERROR, 10, L\"Invalid data length, aborting\"));\n        return E_FAIL;\n    }\n    else if (len == 0)\n    {\n        return S_OK;\n    }\n\n    (static_cast<CDeCSSTransformInputPin *>(m_pInput))->StripPacket(pDataIn, len);\n\n    REFERENCE_TIME rtStart = _I64_MIN, rtStop = _I64_MIN;\n    hr = pIn->GetTime(&rtStart, &rtStop);\n\n    if ((pIn->IsDiscontinuity() == S_OK || (m_bNeedSyncpoint && pIn->IsSyncPoint() == S_OK)))\n    {\n        DbgLog((LOG_ERROR, 10, L\"::Receive(): Discontinuity, flushing decoder..\"));\n        m_buff.Clear();\n        FlushOutput(FALSE);\n        FlushDecoder();\n        m_bQueueResync = TRUE;\n        m_bDiscontinuity = TRUE;\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\" -> Discontinuity without timestamp\"));\n        }\n\n        if (m_bNeedSyncpoint && pIn->IsSyncPoint() == S_OK)\n        {\n            DbgLog((LOG_TRACE, 10, L\"::Receive(): Got SyncPoint, resuming decoding....\"));\n            m_bNeedSyncpoint = FALSE;\n        }\n    }\n\n    if (m_bQueueResync && SUCCEEDED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"Resync Request; old: %I64d; new: %I64d; buffer: %d\", m_rtStart, rtStart,\n                m_buff.GetCount()));\n        FlushOutput();\n        if (m_rtStart != AV_NOPTS_VALUE && rtStart != m_rtStart)\n            m_bDiscontinuity = TRUE;\n\n        m_rtStart = rtStart;\n        m_rtStartInputCache = AV_NOPTS_VALUE;\n        m_rtBitstreamCache = AV_NOPTS_VALUE;\n        m_dStartOffset = 0.0;\n        m_bQueueResync = FALSE;\n        m_bResyncTimestamp = TRUE;\n    }\n\n    m_bJustFlushed = FALSE;\n\n    m_rtStartInput = SUCCEEDED(hr) ? rtStart : AV_NOPTS_VALUE;\n    m_rtStopInput = (hr == S_OK) ? rtStop : AV_NOPTS_VALUE;\n\n    DWORD bufflen = m_buff.GetCount();\n\n    // Hack to re-create the BD LPCM header because in the MPC-HC format its stripped off.\n    CMediaType inMt(m_pInput->CurrentMediaType());\n    if (inMt.subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO && inMt.formattype == FORMAT_WaveFormatEx)\n    {\n        m_buff.SetSize(bufflen + 4);\n        BYTE *buf = m_buff.Ptr() + bufflen;\n        CreateBDLPCMHeader(buf, (WAVEFORMATEX_HDMV_LPCM *)inMt.pbFormat);\n        bufflen = m_buff.GetCount();\n    }\n    else if (inMt.subtype == MEDIASUBTYPE_DVD_LPCM_AUDIO && inMt.formattype == FORMAT_WaveFormatEx)\n    {\n        m_buff.SetSize(bufflen + 3);\n        BYTE *buf = m_buff.Ptr() + bufflen;\n        CreateDVDLPCMHeader(buf, (WAVEFORMATEX *)inMt.pbFormat);\n        bufflen = m_buff.GetCount();\n    }\n\n    // Ensure the size of the buffer doesn't overflow (its used as signed int in various places)\n    if (bufflen > (INT_MAX - (DWORD)len))\n    {\n        DbgLog((LOG_TRACE, 10, L\"Too much audio buffered, aborting\"));\n        m_buff.Clear();\n        m_bQueueResync = TRUE;\n        return E_FAIL;\n    }\n\n    m_buff.Allocate(bufflen + len + AV_INPUT_BUFFER_PADDING_SIZE);\n    m_buff.Append(pDataIn, len);\n\n    hr = ProcessBuffer(pIn);\n\n    if (FAILED(hr))\n        return hr;\n\n    return S_OK;\n}\n\n#define SAME_HEADER_MASK (0xffe00000 | (3 << 17) | (3 << 10) | (3 << 19))\n\nstatic int check_mpegaudio_header(uint8_t *buf, uint32_t *retheader)\n{\n    MPADecodeHeader sd;\n    uint32_t header = AV_RB32(buf);\n\n    if (avpriv_mpegaudio_decode_header(&sd, header) != 0)\n        return -1;\n\n    if (retheader)\n        *retheader = header;\n\n    return sd.frame_size;\n}\n\nHRESULT CLAVAudio::ResyncMPEGAudio()\n{\n    uint8_t *buf = m_buff.Ptr();\n    int size = m_buff.GetCount();\n\n    for (int i = 0; i < (size - 3); i++)\n    {\n        uint32_t header, header2;\n        int frame_size = check_mpegaudio_header(buf + i, &header);\n        if (frame_size > 0 && (i + frame_size + 4) < size)\n        {\n            int ret = check_mpegaudio_header(buf + i + frame_size, &header2);\n            if (ret >= 0 && (header & SAME_HEADER_MASK) == (header2 & SAME_HEADER_MASK))\n            {\n                if (i > 0)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"CLAVAudio::ResyncMPEGAudio(): Skipping %d bytes of junk\", i));\n                    m_buff.Consume(i);\n                }\n                return S_OK;\n            }\n        }\n    }\n\n    if (size > 64 * 1024)\n    {\n        DbgLog((LOG_TRACE, 10,\n                L\"CLAVAudio::ResyncMPEGAudio(): No matching headers found in 64kb of data, aborting search\"));\n        return S_OK;\n    }\n\n    return S_FALSE;\n}\n\nHRESULT CLAVAudio::ProcessBuffer(IMediaSample *pMediaSample, BOOL bEOF)\n{\n    HRESULT hr = S_OK, hr2 = S_OK;\n\n    int buffer_size = m_buff.GetCount();\n\n    BYTE *p = m_buff.Ptr();\n    int consumed = 0, consumed_header = 0;\n\n    if (!bEOF)\n    {\n        if (m_bFindDTSInPCM)\n        {\n            int i = 0, count = 0;\n            uint32_t state = -1;\n            for (i = 0; i < buffer_size; ++i)\n            {\n                state = (state << 8) | p[i];\n                if ((state == DCA_MARKER_14B_LE && (i < buffer_size - 2) && (p[i + 1] & 0xF0) == 0xF0 &&\n                     p[i + 2] == 0x07) ||\n                    (state == DCA_MARKER_14B_BE && (i < buffer_size - 2) && p[i + 1] == 0x07 &&\n                     (p[i + 2] & 0xF0) == 0xF0) ||\n                    state == DCA_MARKER_RAW_LE || state == DCA_MARKER_RAW_BE)\n                {\n                    count++;\n                }\n            }\n            if (count >= 4)\n            {\n                DbgLog((LOG_TRACE, 10,\n                        L\"::ProcessBuffer(): Detected %d DTS sync words in %d bytes of data, switching to DTS-in-WAV \"\n                        L\"decoding\",\n                        count, buffer_size));\n                CMediaType mt = m_pInput->CurrentMediaType();\n                ffmpeg_init(AV_CODEC_ID_DTS, mt.Format(), *mt.FormatType(), mt.FormatLength());\n                m_bFindDTSInPCM = FALSE;\n            }\n\n            if (buffer_size > (16384 * (4 + count)))\n            {\n                m_bFindDTSInPCM = FALSE;\n            }\n\n            if (m_bFindDTSInPCM)\n            {\n                if (m_rtStartInputCache == AV_NOPTS_VALUE)\n                    m_rtStartInputCache = m_rtStartInput;\n                return S_FALSE;\n            }\n\n            m_rtStartInput = m_rtStartInputCache;\n            m_rtStartInputCache = AV_NOPTS_VALUE;\n        }\n\n        if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_DOLBY_AC3_SPDIF)\n        {\n            if (buffer_size < BURST_HEADER_SIZE)\n                return S_FALSE;\n            uint16_t word1 = AV_RL16(p);\n            uint16_t word2 = AV_RL16(p + 2);\n            if (word1 == SYNCWORD1 && word2 == SYNCWORD2)\n            {\n                uint16_t type = AV_RL16(p + 4);\n                int spdif_buffer_size = AV_RL16(p + 6) >> 3;\n\n                p += BURST_HEADER_SIZE;\n\n                if (spdif_buffer_size + BURST_HEADER_SIZE > buffer_size)\n                {\n                    DbgLog((LOG_ERROR, 10, L\"::ProcessBuffer(): SPDIF sample is too small (%d required, %d present)\",\n                            spdif_buffer_size + BURST_HEADER_SIZE, buffer_size));\n                    m_buff.Clear();\n                    m_bQueueResync = TRUE;\n                    return S_FALSE;\n                }\n                buffer_size = spdif_buffer_size;\n\n                // SPDIF is apparently big-endian coded\n                lav_spdif_bswap_buf16((uint16_t *)p, (uint16_t *)p, buffer_size >> 1);\n\n                // adjust buffer size to strip off spdif padding\n                consumed_header = BURST_HEADER_SIZE;\n                m_buff.SetSize(buffer_size + BURST_HEADER_SIZE);\n            }\n        }\n\n        if (m_bMPEGAudioResync)\n        {\n            if (ResyncMPEGAudio() != S_OK)\n                return S_FALSE;\n\n            m_bMPEGAudioResync = FALSE;\n            return ProcessBuffer(pMediaSample, FALSE);\n        }\n    }\n    else\n    {\n        // In DTSinPCm mode, make sure the timestamps are correct, and process the remaining buffer\n        if (m_bFindDTSInPCM)\n        {\n            m_rtStartInput = m_rtStartInputCache;\n            m_rtStartInputCache = AV_NOPTS_VALUE;\n        }\n        // Otherwise, performa proper flush and stop working\n        else\n        {\n            p = nullptr;\n            buffer_size = -1;\n        }\n    }\n\n    // If a bitstreaming context exists, we should bitstream\n    if (m_avBSContext)\n    {\n        hr2 = Bitstream(p, buffer_size, consumed, &hr);\n        if (FAILED(hr2))\n        {\n            DbgLog((LOG_TRACE, 10, L\"Invalid sample when bitstreaming!\"));\n            m_buff.Clear();\n            m_bQueueResync = TRUE;\n            return S_FALSE;\n        }\n        else if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"::Bitstream indicates delivery failed\"));\n        }\n        else if (hr2 == S_FALSE)\n        {\n            // DbgLog((LOG_TRACE, 10, L\"::Bitstream returned S_FALSE\"));\n            hr = S_FALSE;\n        }\n    }\n    else\n    {\n        // Decoding\n        // Consume the buffer data\n        hr2 = Decode(p, buffer_size, consumed, &hr, pMediaSample);\n        // FAILED - throw away the data\n        if (FAILED(hr2))\n        {\n            DbgLog((LOG_TRACE, 10, L\"Dropped invalid sample in ProcessBuffer\"));\n            m_buff.Clear();\n            m_bQueueResync = TRUE;\n            return S_FALSE;\n        }\n        else if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"::Decode indicates delivery failed\"));\n        }\n        else if (hr2 == S_FALSE)\n        {\n            // DbgLog((LOG_TRACE, 10, L\"::Decode returned S_FALSE\"));\n            hr = S_FALSE;\n        }\n    }\n\n    if (bEOF || consumed <= 0)\n    {\n        return hr;\n    }\n\n    // Determine actual buffer consumption\n    consumed = consumed_header + min(consumed, buffer_size);\n\n    // Remove the consumed data from the buffer\n    m_buff.Consume(consumed);\n\n    return hr;\n}\n\nstatic DWORD get_lav_channel_layout(AVChannelLayout *layout)\n{\n    if (layout->order != AV_CHANNEL_ORDER_NATIVE)\n        return 0;\n\n    uint64_t mask = layout->u.mask;\n    if (mask > DWORD_MAX)\n    {\n        if (mask & AV_CH_WIDE_LEFT)\n            mask = (mask & ~AV_CH_WIDE_LEFT) | AV_CH_FRONT_LEFT_OF_CENTER;\n        if (mask & AV_CH_WIDE_RIGHT)\n            mask = (mask & ~AV_CH_WIDE_RIGHT) | AV_CH_FRONT_RIGHT_OF_CENTER;\n\n        if (mask & AV_CH_SURROUND_DIRECT_LEFT)\n            mask = (mask & ~AV_CH_SURROUND_DIRECT_LEFT) | AV_CH_SIDE_LEFT;\n        if (mask & AV_CH_SURROUND_DIRECT_RIGHT)\n            mask = (mask & ~AV_CH_SURROUND_DIRECT_RIGHT) | AV_CH_SIDE_RIGHT;\n    }\n\n    // sanity check\n    if (av_popcount64(mask) != layout->nb_channels || mask > DWORD_MAX)\n        return 0;\n\n    return (DWORD)mask;\n}\n\nHRESULT CLAVAudio::Decode(const BYTE *pDataBuffer, int buffsize, int &consumed, HRESULT *hrDeliver,\n                          IMediaSample *pMediaSample)\n{\n    int got_frame = 0;\n    BYTE *tmpProcessBuf = nullptr;\n    HRESULT hr = S_FALSE;\n\n    BOOL bFlush = (pDataBuffer == nullptr);\n\n    if (m_pDecodePacket == nullptr)\n        m_pDecodePacket = av_packet_alloc();\n\n    const MediaSideDataFFMpeg *pFFSideData = nullptr;\n\n    if (!bFlush &&\n        (m_raData.deint_id == MKBETAG('g', 'e', 'n', 'r') || m_raData.deint_id == MKBETAG('s', 'i', 'p', 'r')))\n    {\n        int w = m_raData.audio_framesize;\n        int h = m_raData.sub_packet_h;\n        int sps = m_raData.sub_packet_size;\n        int len = w * h;\n        if (buffsize >= len)\n        {\n            tmpProcessBuf = (BYTE *)av_mallocz(len + AV_INPUT_BUFFER_PADDING_SIZE);\n\n            // \"genr\" deinterleaving is used for COOK and ATRAC\n            if (m_raData.deint_id == MKBETAG('g', 'e', 'n', 'r'))\n            {\n                const BYTE *srcBuf = pDataBuffer;\n                for (int y = 0; y < h; y++)\n                {\n                    for (int x = 0, w2 = w / sps; x < w2; x++)\n                    {\n                        memcpy(tmpProcessBuf + sps * (h * x + ((h + 1) / 2) * (y & 1) + (y >> 1)), srcBuf, sps);\n                        srcBuf += sps;\n                    }\n                }\n                // \"sipr\" deinterleaving is used for ... SIPR\n            }\n            else if (m_raData.deint_id == MKBETAG('s', 'i', 'p', 'r'))\n            {\n                memcpy(tmpProcessBuf, pDataBuffer, len);\n                ff_rm_reorder_sipr_data(tmpProcessBuf, h, w);\n            }\n\n            pDataBuffer = tmpProcessBuf;\n            buffsize = len;\n\n            m_rtStartInput = m_rtStartInputCache;\n            m_rtStartInputCache = AV_NOPTS_VALUE;\n        }\n        else\n        {\n            if (m_rtStartInputCache == AV_NOPTS_VALUE)\n                m_rtStartInputCache = m_rtStartInput;\n            return S_FALSE;\n        }\n    }\n#ifdef DEBUG\n    else if (!bFlush && m_raData.deint_id)\n    {\n        const char *deint = (const char *)&m_raData.deint_id;\n        DbgLog((LOG_TRACE, 10, L\"::Decode(): Unsupported deinterleaving algorithm '%c%c%c%c'\", deint[3], deint[2],\n                deint[1], deint[0]));\n    }\n#endif\n\n    if (pMediaSample)\n    {\n        IMediaSideData *pSideData = nullptr;\n        if (SUCCEEDED(pMediaSample->QueryInterface(&pSideData)))\n        {\n            size_t nFFSideDataSize = 0;\n            if (FAILED(\n                    pSideData->GetSideData(IID_MediaSideDataFFMpeg, (const BYTE **)&pFFSideData, &nFFSideDataSize)) ||\n                nFFSideDataSize != sizeof(MediaSideDataFFMpeg))\n            {\n                pFFSideData = nullptr;\n            }\n\n            SafeRelease(&pSideData);\n        }\n    }\n\n    consumed = 0;\n    while (buffsize > 0 || bFlush)\n    {\n        got_frame = 0;\n        if (bFlush)\n            buffsize = 0;\n\n        if (m_pParser)\n        {\n            BYTE *pOut = nullptr;\n            int pOut_size = 0;\n            int used_bytes = av_parser_parse2(m_pParser, m_pAVCtx, &pOut, &pOut_size, pDataBuffer, buffsize,\n                                              AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);\n            if (used_bytes < 0)\n            {\n                DbgLog((LOG_TRACE, 50, L\"::Decode() - audio parsing failed (ret: %d)\", -used_bytes));\n                goto fail;\n            }\n            else if (used_bytes == 0 && pOut_size == 0)\n            {\n                DbgLog((LOG_TRACE, 50, L\"::Decode() - could not process buffer, starving?\"));\n                break;\n            }\n\n            // Timestamp cache to compensate for one frame delay the parser might introduce, in case the frames were\n            // already perfectly sliced apart If we used more (or equal) bytes then was output again, we encountered a\n            // new frame, update timestamps\n            if (used_bytes >= pOut_size && m_bUpdateTimeCache)\n            {\n                m_rtStartInputCache = m_rtStartInput;\n                m_rtStopInputCache = m_rtStopInput;\n                m_rtStartInput = m_rtStopInput = AV_NOPTS_VALUE;\n                m_bUpdateTimeCache = FALSE;\n            }\n\n            if (!bFlush && used_bytes > 0)\n            {\n                buffsize -= used_bytes;\n                pDataBuffer += used_bytes;\n                consumed += used_bytes;\n            }\n\n            if (pOut_size > 0)\n            {\n                m_pDecodePacket->data = pOut;\n                m_pDecodePacket->size = pOut_size;\n                m_pDecodePacket->dts = m_rtStartInputCache;\n                m_pDecodePacket->pts = m_rtStartInputCache;\n                m_pDecodePacket->time_base = m_pAVCtx->pkt_timebase;\n\n                CopyMediaSideDataFF(m_pDecodePacket, &pFFSideData);\n\n                int ret2 = avcodec_send_packet(m_pAVCtx, m_pDecodePacket);\n\n                // decoder wants us to drain it first\n                if (ret2 == AVERROR(EAGAIN))\n                {\n                    DecodeReceive(hrDeliver);\n                    ret2 = avcodec_send_packet(m_pAVCtx, m_pDecodePacket);\n                }\n\n                if (ret2 < 0)\n                {\n                    DbgLog((LOG_TRACE, 50, L\"::Decode() - decoding failed despite successful parsing\"));\n                    m_bQueueResync = TRUE;\n                    av_packet_unref(m_pDecodePacket);\n                    continue;\n                }\n\n                m_rtStartInputCache = AV_NOPTS_VALUE;\n                m_bUpdateTimeCache = TRUE;\n                hr = DecodeReceive(hrDeliver);\n            }\n            else\n            {\n                continue;\n            }\n        }\n        else if (bFlush)\n        {\n            hr = S_FALSE;\n            break;\n        }\n        else\n        {\n            m_pDecodePacket->data = (uint8_t *)pDataBuffer;\n            m_pDecodePacket->size = buffsize;\n            m_pDecodePacket->dts = m_rtStartInput;\n            m_pDecodePacket->pts = m_rtStartInput;\n            m_pDecodePacket->time_base = m_pAVCtx->pkt_timebase;\n\n            CopyMediaSideDataFF(m_pDecodePacket, &pFFSideData);\n\n            int ret2 = avcodec_send_packet(m_pAVCtx, m_pDecodePacket);\n\n            // decoder wants us to drain it first\n            if (ret2 == AVERROR(EAGAIN))\n            {\n                DecodeReceive(hrDeliver);\n                ret2 = avcodec_send_packet(m_pAVCtx, m_pDecodePacket);\n            }\n\n            if (ret2 < 0)\n            {\n                av_packet_unref(m_pDecodePacket);\n                goto fail;\n            }\n\n\n            if (!bFlush)\n            {\n                pDataBuffer += buffsize;\n                consumed += buffsize;\n                buffsize = 0;\n            }\n\n            m_rtStartInput = AV_NOPTS_VALUE;\n            hr = DecodeReceive(hrDeliver);\n        }\n\n        av_packet_unref(m_pDecodePacket);\n    }\n\n    av_free(tmpProcessBuf);\n    return hr;\nfail:\n    av_free(tmpProcessBuf);\n    return E_FAIL;\n}\n\nHRESULT CLAVAudio::DecodeReceive(HRESULT *hrDeliver)\n{\n    BufferDetails out;\n\n    while (1)\n    {\n        int ret = avcodec_receive_frame(m_pAVCtx, m_pFrame);\n        if (ret == AVERROR(EAGAIN))\n            return S_OK;\n        else if (ret < 0)\n            return E_FAIL;\n\n        // Send current input time to the delivery function\n        out.rtStart = m_pFrame->pts;\n\n        // Channel re-mapping and sample format conversion\n        ASSERT(m_pFrame->nb_samples > 0);\n        av_channel_layout_copy(&out.layout, &m_pFrame->ch_layout);\n        out.dwSamplesPerSec = m_pAVCtx->sample_rate;\n\n        if (out.layout.order == AV_CHANNEL_ORDER_UNSPEC)\n        {\n            DWORD dwMask = get_channel_mask(out.layout.nb_channels);\n            if (dwMask > 0)\n                av_channel_layout_from_mask(&out.layout, dwMask);\n        }\n\n        out.nSamples = m_pFrame->nb_samples;\n        DWORD dwPCMSize = out.nSamples * out.layout.nb_channels * av_get_bytes_per_sample(m_pAVCtx->sample_fmt);\n        DWORD dwPCMSizeAligned =\n            FFALIGN(out.nSamples, 32) * out.layout.nb_channels * av_get_bytes_per_sample(m_pAVCtx->sample_fmt);\n\n        if (m_pFrame->decode_error_flags & FF_DECODE_ERROR_INVALID_BITSTREAM)\n        {\n            if (av_channel_layout_compare(&m_DecodeLayout, &out.layout) != 0)\n            {\n                DbgLog((LOG_TRACE, 50, L\"::Decode() - Corrupted audio frame with channel layout change, dropping.\"));\n                av_frame_unref(m_pFrame);\n                continue;\n            }\n        }\n\n        switch (m_pAVCtx->sample_fmt)\n        {\n        case AV_SAMPLE_FMT_U8:\n            out.bBuffer->Allocate(dwPCMSizeAligned);\n            out.bBuffer->Append(m_pFrame->data[0], dwPCMSize);\n            out.sfFormat = SampleFormat_U8;\n            break;\n        case AV_SAMPLE_FMT_S16:\n            out.bBuffer->Allocate(dwPCMSizeAligned);\n            out.bBuffer->Append(m_pFrame->data[0], dwPCMSize);\n            out.sfFormat = SampleFormat_16;\n            break;\n        case AV_SAMPLE_FMT_S32:\n            out.bBuffer->Allocate(dwPCMSizeAligned);\n            out.bBuffer->Append(m_pFrame->data[0], dwPCMSize);\n            out.sfFormat = SampleFormat_32;\n            out.wBitsPerSample = m_pAVCtx->bits_per_raw_sample;\n            break;\n        case AV_SAMPLE_FMT_FLT:\n            out.bBuffer->Allocate(dwPCMSizeAligned);\n            out.bBuffer->Append(m_pFrame->data[0], dwPCMSize);\n            out.sfFormat = SampleFormat_FP32;\n            break;\n        case AV_SAMPLE_FMT_DBL: {\n            out.bBuffer->Allocate(dwPCMSizeAligned / 2);\n            out.bBuffer->SetSize(dwPCMSize / 2);\n            float *pDataOut = (float *)(out.bBuffer->Ptr());\n\n            for (size_t i = 0; i < out.nSamples; ++i)\n            {\n                for (int ch = 0; ch < out.layout.nb_channels; ++ch)\n                {\n                    *pDataOut = (float)((double *)m_pFrame->data[0])[ch + i * m_pAVCtx->ch_layout.nb_channels];\n                    pDataOut++;\n                }\n            }\n        }\n            out.sfFormat = SampleFormat_FP32;\n            break;\n        // Planar Formats\n        case AV_SAMPLE_FMT_U8P: {\n            out.bBuffer->Allocate(dwPCMSizeAligned);\n            out.bBuffer->SetSize(dwPCMSize);\n            uint8_t *pOut = (uint8_t *)(out.bBuffer->Ptr());\n\n            for (size_t i = 0; i < out.nSamples; ++i)\n            {\n                for (int ch = 0; ch < out.layout.nb_channels; ++ch)\n                {\n                    *pOut++ = ((uint8_t *)m_pFrame->extended_data[ch])[i];\n                }\n            }\n        }\n            out.sfFormat = SampleFormat_U8;\n            break;\n        case AV_SAMPLE_FMT_S16P: {\n            out.bBuffer->Allocate(dwPCMSizeAligned);\n            out.bBuffer->SetSize(dwPCMSize);\n            int16_t *pOut = (int16_t *)(out.bBuffer->Ptr());\n\n            for (size_t i = 0; i < out.nSamples; ++i)\n            {\n                for (int ch = 0; ch < out.layout.nb_channels; ++ch)\n                {\n                    *pOut++ = ((int16_t *)m_pFrame->extended_data[ch])[i];\n                }\n            }\n        }\n            out.sfFormat = SampleFormat_16;\n            break;\n        case AV_SAMPLE_FMT_S32P: {\n            out.bBuffer->Allocate(dwPCMSizeAligned);\n            out.bBuffer->SetSize(dwPCMSize);\n            int32_t *pOut = (int32_t *)(out.bBuffer->Ptr());\n\n            for (size_t i = 0; i < out.nSamples; ++i)\n            {\n                for (int ch = 0; ch < out.layout.nb_channels; ++ch)\n                {\n                    *pOut++ = ((int32_t *)m_pFrame->extended_data[ch])[i];\n                }\n            }\n        }\n            out.sfFormat = SampleFormat_32;\n            out.wBitsPerSample = m_pAVCtx->bits_per_raw_sample;\n            break;\n        case AV_SAMPLE_FMT_FLTP: {\n            out.bBuffer->Allocate(dwPCMSizeAligned);\n            out.bBuffer->SetSize(dwPCMSize);\n            float *pOut = (float *)(out.bBuffer->Ptr());\n\n            for (size_t i = 0; i < out.nSamples; ++i)\n            {\n                for (int ch = 0; ch < out.layout.nb_channels; ++ch)\n                {\n                    *pOut++ = ((float *)m_pFrame->extended_data[ch])[i];\n                }\n            }\n        }\n            out.sfFormat = SampleFormat_FP32;\n            break;\n        case AV_SAMPLE_FMT_DBLP: {\n            out.bBuffer->Allocate(dwPCMSizeAligned / 2);\n            out.bBuffer->SetSize(dwPCMSize / 2);\n            float *pOut = (float *)(out.bBuffer->Ptr());\n\n            for (size_t i = 0; i < out.nSamples; ++i)\n            {\n                for (int ch = 0; ch < out.layout.nb_channels; ++ch)\n                {\n                    *pOut++ = (float)((double *)m_pFrame->extended_data[ch])[i];\n                }\n            }\n        }\n            out.sfFormat = SampleFormat_FP32;\n            break;\n        default: assert(FALSE); break;\n        }\n        av_frame_unref(m_pFrame);\n\n        m_DecodeFormat = out.sfFormat == SampleFormat_32 && out.wBitsPerSample > 0 && out.wBitsPerSample <= 24\n                             ? (out.wBitsPerSample <= 16 ? SampleFormat_16 : SampleFormat_24)\n                             : out.sfFormat;\n        av_channel_layout_copy(&m_DecodeLayout, &out.layout);\n\n        if (SUCCEEDED(PostProcess(&out)))\n        {\n            *hrDeliver = QueueOutput(out);\n            if (FAILED(*hrDeliver))\n            {\n                return S_FALSE;\n            }\n        }\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::GetDeliveryBuffer(IMediaSample **pSample, BYTE **pData)\n{\n    HRESULT hr;\n\n    *pData = nullptr;\n    if (FAILED(hr = m_pOutput->GetDeliveryBuffer(pSample, nullptr, nullptr, 0)) ||\n        FAILED(hr = (*pSample)->GetPointer(pData)))\n    {\n        return hr;\n    }\n\n    AM_MEDIA_TYPE *pmt = nullptr;\n    if (SUCCEEDED((*pSample)->GetMediaType(&pmt)) && pmt)\n    {\n        CMediaType mt = *pmt;\n        m_pOutput->SetMediaType(&mt);\n        DeleteMediaType(pmt);\n        pmt = nullptr;\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::QueueOutput(BufferDetails &buffer)\n{\n    HRESULT hr = S_OK;\n    if (av_channel_layout_compare(&m_OutputQueue.layout, &buffer.layout) != 0 ||\n        m_OutputQueue.sfFormat != buffer.sfFormat ||\n        m_OutputQueue.dwSamplesPerSec != buffer.dwSamplesPerSec ||\n        m_OutputQueue.wBitsPerSample != buffer.wBitsPerSample)\n    {\n        if (m_OutputQueue.nSamples > 0)\n            FlushOutput();\n\n        m_OutputQueue.sfFormat = buffer.sfFormat;\n        av_channel_layout_copy(&m_OutputQueue.layout, &buffer.layout);\n        m_OutputQueue.dwSamplesPerSec = buffer.dwSamplesPerSec;\n        m_OutputQueue.wBitsPerSample = buffer.wBitsPerSample;\n    }\n\n    if (m_OutputQueue.nSamples == 0)\n        m_OutputQueue.rtStart = buffer.rtStart;\n    else if (m_OutputQueue.rtStart == AV_NOPTS_VALUE && buffer.rtStart != AV_NOPTS_VALUE)\n        m_OutputQueue.rtStart = buffer.rtStart - (REFERENCE_TIME)((double)m_OutputQueue.nSamples /\n                                                                  m_OutputQueue.dwSamplesPerSec * 10000000.0);\n\n    // Try to retain the buffer, if possible\n    if (m_OutputQueue.nSamples == 0)\n    {\n        FFSWAP(GrowableArray<BYTE> *, m_OutputQueue.bBuffer, buffer.bBuffer);\n    }\n    else\n    {\n        m_OutputQueue.bBuffer->Append(buffer.bBuffer);\n    }\n    m_OutputQueue.nSamples += buffer.nSamples;\n\n    buffer.bBuffer->SetSize(0);\n    buffer.nSamples = 0;\n\n    // Length of the current sample\n    double dDuration = (double)m_OutputQueue.nSamples / m_OutputQueue.dwSamplesPerSec * 10000000.0;\n    double dOffset = fmod(dDuration, 1.0);\n\n    // Don't exceed the buffer\n    if (dDuration >= PCM_BUFFER_MAX_DURATION || (dDuration >= PCM_BUFFER_MIN_DURATION && dOffset <= FLT_EPSILON))\n    {\n        hr = FlushOutput();\n    }\n\n    return hr;\n}\n\nHRESULT CLAVAudio::FlushOutput(BOOL bDeliver)\n{\n    CAutoLock cAutoLock(&m_csReceive);\n\n    HRESULT hr = S_OK;\n    if (bDeliver && m_OutputQueue.nSamples > 0)\n        hr = Deliver(m_OutputQueue);\n\n    // Clear Queue\n    m_OutputQueue.nSamples = 0;\n    m_OutputQueue.bBuffer->SetSize(0);\n    m_OutputQueue.rtStart = AV_NOPTS_VALUE;\n\n    return hr;\n}\n\nHRESULT CLAVAudio::Deliver(BufferDetails &buffer)\n{\n    HRESULT hr = S_OK;\n\n    if (m_bFlushing)\n        return S_FALSE;\n\n    CMediaType mt = CreateMediaType(buffer.sfFormat, buffer.dwSamplesPerSec, buffer.layout.nb_channels,\n                                    (DWORD)buffer.layout.u.mask,\n                                    buffer.wBitsPerSample);\n    WAVEFORMATEX *wfe = (WAVEFORMATEX *)mt.Format();\n\n    long cbBuffer = buffer.nSamples * wfe->nBlockAlign;\n    if (FAILED(hr = ReconnectOutput(cbBuffer, mt)))\n    {\n        return hr;\n    }\n\n    IMediaSample *pOut;\n    BYTE *pDataOut = nullptr;\n    if (FAILED(GetDeliveryBuffer(&pOut, &pDataOut)))\n    {\n        return E_FAIL;\n    }\n\n    if (m_bResyncTimestamp && buffer.rtStart != AV_NOPTS_VALUE)\n    {\n        m_rtStart = buffer.rtStart;\n        m_bResyncTimestamp = FALSE;\n    }\n\n    // Length of the current sample\n    double dDuration = (double)buffer.nSamples / buffer.dwSamplesPerSec * DBL_SECOND_MULT / m_dRate;\n    m_dStartOffset += fmod(dDuration, 1.0);\n\n    // Delivery Timestamps\n    REFERENCE_TIME rtStart = m_rtStart, rtStop = m_rtStart + (REFERENCE_TIME)(dDuration + 0.5);\n\n    // Compute next start time\n    m_rtStart += (REFERENCE_TIME)dDuration;\n    // If the offset reaches one (100ns), add it to the next frame\n    if (m_dStartOffset > 0.5)\n    {\n        m_rtStart++;\n        m_dStartOffset -= 1.0;\n    }\n\n    if (buffer.rtStart != AV_NOPTS_VALUE)\n    {\n        REFERENCE_TIME rtJitter = rtStart - buffer.rtStart;\n        m_faJitter.Sample(rtJitter);\n        REFERENCE_TIME rtJitterMin = m_faJitter.AbsMinimum();\n        if (m_settings.AutoAVSync && abs(rtJitterMin) > m_JitterLimit)\n        {\n            DbgLog((LOG_TRACE, 10, L\"::Deliver(): corrected A/V sync by %I64d\", rtJitterMin));\n            m_rtStart -= rtJitterMin;\n            rtStart -= rtJitterMin;\n            rtStop -= rtJitterMin;\n            m_faJitter.OffsetValues(-rtJitterMin);\n            m_bDiscontinuity = TRUE;\n        }\n\n#ifdef DEBUG\n        if (m_faJitter.CurrentSample() == 0)\n        {\n            DbgLog((LOG_CUSTOM2, 20, L\"Jitter Stats: min: %I64d - max: %I64d - avg: %I64d\", rtJitterMin,\n                    m_faJitter.AbsMaximum(), m_faJitter.Average()));\n        }\n#endif\n        DbgLog((LOG_CUSTOM5, 20,\n                L\"PCM Delivery, rtStart(calc): %I64d, rtStart(input): %I64d, sample duration: %I64d, diff: %I64d\",\n                rtStart, buffer.rtStart, rtStop - rtStart, rtJitter));\n    }\n    else\n    {\n        DbgLog((LOG_CUSTOM5, 20,\n                L\"PCM Delivery, rtStart(calc): %I64d, rtStart(input): N/A, sample duration: %I64d, diff: N/A\", rtStart,\n                rtStop - rtStart));\n    }\n\n    if (rtStart < 0)\n    {\n        goto done;\n    }\n\n    if (hr == S_OK)\n    {\n    retry_qa:\n        hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n        DbgLog((LOG_TRACE, 1, L\"Sending new Media Type (QueryAccept: %0#.8x)\", hr));\n        if (hr != S_OK)\n        {\n            if (buffer.sfFormat != SampleFormat_16)\n            {\n                mt = CreateMediaType(SampleFormat_16, buffer.dwSamplesPerSec, buffer.layout.nb_channels, (DWORD)buffer.layout.u.mask,\n                                     16);\n                hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n                if (hr == S_OK)\n                {\n                    DbgLog((LOG_TRACE, 1, L\"-> 16-bit fallback type accepted\"));\n                    m_FallbackFormat = SampleFormat_16;\n                    PerformAVRProcessing(&buffer);\n                }\n            }\n            // Try 5.1 back fallback format\n            if (buffer.layout.u.mask == AV_CH_LAYOUT_5POINT1)\n            {\n                DbgLog((LOG_TRACE, 1, L\"-> Trying to fallback to 5.1 back\"));\n                buffer.layout.u.mask = AV_CH_LAYOUT_5POINT1_BACK;\n                mt = CreateMediaType(buffer.sfFormat, buffer.dwSamplesPerSec, buffer.layout.nb_channels,\n                                     (DWORD)buffer.layout.u.mask,\n                                     buffer.wBitsPerSample);\n                goto retry_qa;\n            }\n            // more then 8 channel, try 7.1 fallback format\n            if (buffer.layout.nb_channels > 8)\n            {\n                DbgLog((LOG_TRACE, 1, L\"-> Trying to fallback to 7.1 (have more then 8 channel)\"));\n                mt = CreateMediaType(buffer.sfFormat, buffer.dwSamplesPerSec, 8,\n                                     (DWORD)AV_CH_LAYOUT_7POINT1, buffer.wBitsPerSample);\n\n                hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n\n                if (hr != S_OK)\n                {\n                    mt = CreateMediaType(SampleFormat_16, buffer.dwSamplesPerSec, 8, AV_CH_LAYOUT_7POINT1, 16);\n                    hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n                    if (hr == S_OK)\n                        m_FallbackFormat = SampleFormat_16;\n                }\n\n                if (hr == S_OK)\n                {\n                    DbgLog((LOG_TRACE, 1, L\"-> Override Mixing to layout to 7.1\"));\n                    av_channel_layout_uninit(&m_chOverrideMixer);\n                    av_channel_layout_from_mask(&m_chOverrideMixer, AV_CH_LAYOUT_7POINT1);\n                    m_bMixingSettingsChanged = TRUE;\n                    // Mix to the new layout\n                    PerformAVRProcessing(&buffer);\n                }\n            }\n            // If a 16-bit fallback isn't enough, try to retain current channel layout as well\n            if (hr != S_OK)\n            {\n                WAVEFORMATEX *wfeCurrent = (WAVEFORMATEX *)m_pOutput->CurrentMediaType().Format();\n                WORD wChannels = wfeCurrent->nChannels;\n                DWORD dwChannelMask = 0;\n                if (wfeCurrent->wFormatTag == WAVE_FORMAT_EXTENSIBLE)\n                {\n                    WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE *)wfeCurrent;\n                    dwChannelMask = wfex->dwChannelMask;\n                }\n                else\n                {\n                    dwChannelMask = get_channel_mask(wChannels);\n                }\n                if (buffer.layout.nb_channels != wfeCurrent->nChannels || buffer.layout.u.mask != dwChannelMask)\n                {\n                    mt = CreateMediaType(buffer.sfFormat, buffer.dwSamplesPerSec, wChannels, dwChannelMask,\n                                         buffer.wBitsPerSample);\n                    hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n                    if (hr != S_OK)\n                    {\n                        mt = CreateMediaType(SampleFormat_16, buffer.dwSamplesPerSec, wChannels, dwChannelMask, 16);\n                        hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n                        if (hr == S_OK)\n                            m_FallbackFormat = SampleFormat_16;\n                    }\n                    if (hr == S_OK)\n                    {\n                        DbgLog((LOG_TRACE, 1, L\"-> Override Mixing to layout 0x%x\", dwChannelMask));\n                        av_channel_layout_uninit(&m_chOverrideMixer);\n                        av_channel_layout_from_mask(&m_chOverrideMixer, dwChannelMask);\n                        m_bMixingSettingsChanged = TRUE;\n                        // Mix to the new layout\n                        PerformAVRProcessing(&buffer);\n                    }\n                }\n            }\n        }\n        m_pOutput->SetMediaType(&mt);\n        pOut->SetMediaType(&mt);\n    }\n\n    if (m_settings.AudioDelayEnabled)\n    {\n        REFERENCE_TIME rtDelay = (REFERENCE_TIME)((m_settings.AudioDelay * 10000i64) / m_dRate);\n        rtStart += rtDelay;\n        rtStop += rtDelay;\n    }\n\n    pOut->SetTime(&rtStart, &rtStop);\n    pOut->SetMediaTime(nullptr, nullptr);\n\n    pOut->SetPreroll(FALSE);\n    pOut->SetDiscontinuity(m_bDiscontinuity);\n    m_bDiscontinuity = FALSE;\n    pOut->SetSyncPoint(TRUE);\n\n    pOut->SetActualDataLength(buffer.bBuffer->GetCount());\n\n    memcpy(pDataOut, buffer.bBuffer->Ptr(), buffer.bBuffer->GetCount());\n\n    hr = m_pOutput->Deliver(pOut);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"::Deliver failed with code: %0#.8x\", hr));\n    }\ndone:\n    SafeRelease(&pOut);\n    return hr;\n}\n\nHRESULT CLAVAudio::BreakConnect(PIN_DIRECTION dir)\n{\n    if (dir == PINDIR_INPUT)\n    {\n        ffmpeg_shutdown();\n    }\n    return __super::BreakConnect(dir);\n}\n"
  },
  {
    "path": "decoder/LAVAudio/LAVAudio.def",
    "content": "; LAVAudio.def ; declares the exports\n\nLIBRARY         \"LAVAudio.ax\"\n\nEXPORTS\n                DllGetClassObject PRIVATE\n                DllCanUnloadNow PRIVATE\n                DllRegisterServer PRIVATE\n                DllUnregisterServer PRIVATE\n                OpenConfiguration PRIVATE\n"
  },
  {
    "path": "decoder/LAVAudio/LAVAudio.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"LAVAudioSettings.h\"\n#include \"FloatingAverage.h\"\n#include \"Media.h\"\n#include \"BitstreamParser.h\"\n#include \"PostProcessor.h\"\n\n#include \"ISpecifyPropertyPages2.h\"\n#include \"BaseTrayIcon.h\"\n\n//////////////////// Configuration //////////////////////////\n\n// Buffer Size for decoded PCM: 1s of 192kHz 32-bit with 8 channels\n// 192000 (Samples) * 4 (Bytes per Sample) * 8 (channels)\n#define LAV_AUDIO_BUFFER_SIZE 6144000\n\n// Maximum Durations (in reference time)\n// 10ms (DTS has 10.6667 ms samples, don't want to queue them up)\n#define PCM_BUFFER_MAX_DURATION 100000\n// 6ms\n#define PCM_BUFFER_MIN_DURATION 60000\n\n// Maximum desync that we attribute to jitter before re-syncing (10ms)\n#define MAX_JITTER_DESYNC 100000i64\n\n#define MAX_VOLUME_STAT_CHANNEL 8\n\n//////////////////// End Configuration //////////////////////\n\n#define AV_CODEC_ID_PCM_SxxBE (AVCodecID)0x19001\n#define AV_CODEC_ID_PCM_SxxLE (AVCodecID)0x19002\n#define AV_CODEC_ID_PCM_UxxBE (AVCodecID)0x19003\n#define AV_CODEC_ID_PCM_UxxLE (AVCodecID)0x19004\n#define AV_CODEC_ID_PCM_QTRAW (AVCodecID)0x19005\n\n#define LAVC_AUDIO_REGISTRY_KEY L\"Software\\\\LAV\\\\Audio\"\n#define LAVC_AUDIO_REGISTRY_KEY_FORMATS L\"Software\\\\LAV\\\\Audio\\\\Formats\"\n#define LAVC_AUDIO_LOG_FILE L\"LAVAudio.txt\"\n\nstruct WAVEFORMATEX_HDMV_LPCM;\n\nstruct BufferDetails\n{\n    GrowableArray<BYTE> *bBuffer = nullptr;          // PCM Buffer\n    LAVAudioSampleFormat sfFormat = SampleFormat_16; // Sample Format\n    WORD wBitsPerSample = 0;                         // Bits per sample\n    DWORD dwSamplesPerSec = 0;                       // Samples per second\n    unsigned nSamples = 0;   // Samples in the buffer (every sample is sizeof(sfFormat) * nChannels in the buffer)\n    AVChannelLayout layout{};\n    REFERENCE_TIME rtStart = AV_NOPTS_VALUE; // Start Time of the buffer\n    BOOL bPlanar = FALSE;                    // Planar (not used)\n\n    BufferDetails() { bBuffer = new GrowableArray<BYTE>(); };\n    ~BufferDetails()\n    {\n        delete bBuffer;\n        av_channel_layout_uninit(&layout);\n    }\n};\n\nclass __declspec(uuid(\"E8E73B6B-4CB3-44A4-BE99-4F7BCB96E491\")) CLAVAudio\n    : public CTransformFilter\n    , public ISpecifyPropertyPages2\n    , public ILAVAudioSettings\n    , public ILAVAudioStatus\n{\n  public:\n    CLAVAudio(LPUNKNOWN pUnk, HRESULT *phr);\n    ~CLAVAudio();\n\n    // IUnknown\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // ISpecifyPropertyPages2\n    STDMETHODIMP GetPages(CAUUID *pPages);\n    STDMETHODIMP CreatePage(const GUID &guid, IPropertyPage **ppPage);\n\n    // ILAVAudioSettings\n    STDMETHODIMP SetRuntimeConfig(BOOL bRuntimeConfig);\n    STDMETHODIMP GetDRC(BOOL *pbDRCEnabled, int *piDRCLevel);\n    STDMETHODIMP SetDRC(BOOL bDRCEnabled, int iDRCLevel);\n    STDMETHODIMP_(BOOL) GetFormatConfiguration(LAVAudioCodec aCodec);\n    STDMETHODIMP SetFormatConfiguration(LAVAudioCodec aCodec, BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetBitstreamConfig(LAVBitstreamCodec bsCodec);\n    STDMETHODIMP SetBitstreamConfig(LAVBitstreamCodec bsCodec, BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetDTSHDFraming();\n    STDMETHODIMP SetDTSHDFraming(BOOL bHDFraming);\n    STDMETHODIMP_(BOOL) GetBitstreamingFallback();\n    STDMETHODIMP SetBitstreamingFallback(BOOL bBitstreamingFallback);\n    STDMETHODIMP_(BOOL) GetAutoAVSync();\n    STDMETHODIMP SetAutoAVSync(BOOL bAutoSync);\n    STDMETHODIMP_(BOOL) GetOutputStandardLayout();\n    STDMETHODIMP SetOutputStandardLayout(BOOL bStdLayout);\n    STDMETHODIMP_(BOOL) GetExpandMono();\n    STDMETHODIMP SetExpandMono(BOOL bExpandMono);\n    STDMETHODIMP_(BOOL) GetExpand61();\n    STDMETHODIMP SetExpand61(BOOL bExpand61);\n    STDMETHODIMP_(BOOL) GetAllowRawSPDIFInput();\n    STDMETHODIMP SetAllowRawSPDIFInput(BOOL bAllow);\n    STDMETHODIMP_(BOOL) GetSampleFormat(LAVAudioSampleFormat format);\n    STDMETHODIMP SetSampleFormat(LAVAudioSampleFormat format, BOOL bEnabled);\n    STDMETHODIMP GetAudioDelay(BOOL *pbEnabled, int *pDelay);\n    STDMETHODIMP SetAudioDelay(BOOL bEnabled, int delay);\n    STDMETHODIMP SetMixingEnabled(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetMixingEnabled();\n    STDMETHODIMP SetMixingLayout(DWORD dwLayout);\n    STDMETHODIMP_(DWORD) GetMixingLayout();\n    STDMETHODIMP SetMixingFlags(DWORD dwFlags);\n    STDMETHODIMP_(DWORD) GetMixingFlags();\n    STDMETHODIMP SetMixingMode(LAVAudioMixingMode mixingMode);\n    STDMETHODIMP_(LAVAudioMixingMode) GetMixingMode();\n    STDMETHODIMP SetMixingLevels(DWORD dwCenterLevel, DWORD dwSurroundLevel, DWORD dwLFELevel);\n    STDMETHODIMP GetMixingLevels(DWORD *dwCenterLevel, DWORD *dwSurroundLevel, DWORD *dwLFELevel);\n    STDMETHODIMP SetTrayIcon(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetTrayIcon();\n    STDMETHODIMP SetSampleConvertDithering(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetSampleConvertDithering();\n    STDMETHODIMP SetSuppressFormatChanges(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetSuppressFormatChanges();\n    STDMETHODIMP SetOutput51LegacyLayout(BOOL b51Legacy);\n    STDMETHODIMP_(BOOL) GetOutput51LegacyLayout();\n\n    // ILAVAudioStatus\n    STDMETHODIMP_(BOOL) IsSampleFormatSupported(LAVAudioSampleFormat sfCheck);\n    STDMETHODIMP GetDecodeDetails(const char **pCodec, const char **pDecodeFormat, int *pnChannels, int *pSampleRate,\n                                  DWORD *pChannelMask);\n    STDMETHODIMP GetOutputDetails(const char **pOutputFormat, int *pnChannels, int *pSampleRate, DWORD *pChannelMask);\n    STDMETHODIMP EnableVolumeStats();\n    STDMETHODIMP DisableVolumeStats();\n    STDMETHODIMP GetChannelVolumeAverage(WORD nChannel, float *pfDb);\n\n    // CTransformFilter\n    HRESULT CheckInputType(const CMediaType *mtIn);\n    HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut);\n    HRESULT DecideBufferSize(IMemAllocator *pAllocator, ALLOCATOR_PROPERTIES *pprop);\n    HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);\n\n    HRESULT Receive(IMediaSample *pIn);\n\n    STDMETHODIMP JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName);\n\n    // Optional Overrides\n    HRESULT CheckConnect(PIN_DIRECTION dir, IPin *pPin);\n    HRESULT CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin);\n    HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType *pmt);\n\n    HRESULT EndOfStream();\n    HRESULT BeginFlush();\n    HRESULT EndFlush();\n    HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n\n    HRESULT BreakConnect(PIN_DIRECTION Dir);\n\n  public:\n    // Pin Configuration\n    const static AMOVIESETUP_MEDIATYPE sudPinTypesIn[];\n    const static UINT sudPinTypesInCount;\n    const static AMOVIESETUP_MEDIATYPE sudPinTypesOut[];\n    const static UINT sudPinTypesOutCount;\n\n  private:\n    enum DTSBitstreamMode\n    {\n        DTS_Core,\n        DTS_HDMA,\n        DTS_HDHR\n    };\n\n    HRESULT LoadDefaults();\n    HRESULT ReadSettings(HKEY rootKey);\n    HRESULT LoadSettings();\n    HRESULT SaveSettings();\n\n    STDMETHODIMP CreateTrayIcon();\n\n    HRESULT ffmpeg_init(AVCodecID codec, const void *format, GUID format_type, DWORD formatlen);\n    void ffmpeg_shutdown();\n\n    CMediaType CreateMediaType(LAVAudioSampleFormat outputFormat, DWORD nSamplesPerSec, WORD nChannels,\n                               DWORD dwChannelMask, WORD wBitsPerSample = 0) const;\n    HRESULT ReconnectOutput(long cbBuffer, CMediaType &mt);\n    HRESULT ProcessBuffer(IMediaSample *pMediaSample, BOOL bEOF = FALSE);\n    HRESULT Decode(const BYTE *p, int buffsize, int &consumed, HRESULT *hrDeliver, IMediaSample *pMediaSample);\n    HRESULT DecodeReceive(HRESULT *hrDeliver);\n    HRESULT PostProcess(BufferDetails *buffer);\n    HRESULT GetDeliveryBuffer(IMediaSample **pSample, BYTE **pData);\n\n    HRESULT QueueOutput(BufferDetails &buffer);\n    HRESULT FlushOutput(BOOL bDeliver = TRUE);\n    HRESULT FlushDecoder();\n\n    HRESULT PerformFlush();\n    HRESULT Deliver(BufferDetails &buffer);\n\n    void CreateBDLPCMHeader(BYTE *pBuf, const WAVEFORMATEX_HDMV_LPCM *wfex_lpcm) const;\n    void CreateDVDLPCMHeader(BYTE *pBuf, const WAVEFORMATEX *wfex) const;\n    HRESULT ParseRealAudioHeader(const BYTE *extra, const size_t extralen);\n    HRESULT ResyncMPEGAudio();\n\n    void UpdateVolumeStats(const BufferDetails &buffer);\n\n    BOOL IsBitstreaming(AVCodecID codec);\n    HRESULT InitBitstreaming();\n    HRESULT ShutdownBitstreaming();\n    static int BSWriteBuffer(void *opaque, const uint8_t *buf, int buf_size);\n\n    HRESULT CreateBitstreamContext(AVCodecID codec, WAVEFORMATEX *wfe);\n    HRESULT UpdateBitstreamContext();\n    HRESULT FreeBitstreamContext();\n    HRESULT BitstreamFallbackToPCM();\n\n    HRESULT Bitstream(const BYTE *p, int buffsize, int &consumed, HRESULT *hrDeliver);\n    HRESULT DeliverBitstream(AVCodecID codec, const BYTE *buffer, DWORD dwSize, REFERENCE_TIME rtStartInput,\n                             REFERENCE_TIME rtStopInput, BOOL bSwap = false, int nSamplesOffset = 0);\n\n    HRESULT BitstreamTrueHD(const BYTE *p, int buffsize, HRESULT *hrDeliver);\n    void MATWriteHeader();\n    void MATWritePadding();\n    void MATAppendData(const BYTE * const p, int size);\n    int MATFillDataBuffer(const BYTE * const p, int size, bool padding = false);\n    void MATFlushPacket(HRESULT *hrDeliver);\n\n    CMediaType CreateBitstreamMediaType(AVCodecID codec, DWORD dwSampleRate, BOOL bDTSHDOverride = FALSE);\n    void ActivateDTSHDMuxing();\n    DTSBitstreamMode GetDTSHDBitstreamMode();\n\n    HRESULT CheckChannelLayoutConformity(AVChannelLayout *layout);\n    HRESULT Create51Conformity(DWORD dwLayout);\n    HRESULT Create61Conformity(DWORD dwLayout);\n    HRESULT Create71Conformity(DWORD dwLayout);\n\n    LAVAudioSampleFormat GetBestAvailableSampleFormat(LAVAudioSampleFormat inFormat, int *bits = NULL,\n                                                      BOOL bNoFallback = FALSE);\n    HRESULT Truncate32Buffer(BufferDetails *buffer);\n    HRESULT PadTo32(BufferDetails *buffer);\n\n    HRESULT PerformAVRProcessing(BufferDetails *buffer);\n\n  private:\n    AVCodecID m_nCodecId = AV_CODEC_ID_NONE;\n    const AVCodec *m_pAVCodec = nullptr;\n    AVCodecContext *m_pAVCtx = nullptr;\n    AVCodecParserContext *m_pParser = nullptr;\n    AVFrame *m_pFrame = nullptr;\n\n    BOOL m_bFlushing = FALSE;\n    BOOL m_bDiscontinuity = FALSE;\n    REFERENCE_TIME m_rtStart = 0;\n    double m_dStartOffset = 0.0;\n    double m_dRate = 1.0;\n\n    REFERENCE_TIME m_rtStartInput = AV_NOPTS_VALUE;      // rtStart of the current input package\n    REFERENCE_TIME m_rtStopInput = AV_NOPTS_VALUE;       // rtStop of the current input package\n    REFERENCE_TIME m_rtStartInputCache = AV_NOPTS_VALUE; // rtStart of the last input package\n    REFERENCE_TIME m_rtStopInputCache = AV_NOPTS_VALUE;  // rtStop of the last input package\n    REFERENCE_TIME m_rtBitstreamCache = AV_NOPTS_VALUE;  // Bitstreaming time cache\n    BOOL m_bUpdateTimeCache = TRUE;\n\n    GrowableArray<BYTE> m_buff; // Input Buffer\n    LAVAudioSampleFormat m_DecodeFormat = SampleFormat_16;\n    LAVAudioSampleFormat m_MixingInputFormat = SampleFormat_None;\n    LAVAudioSampleFormat m_FallbackFormat = SampleFormat_None;\n    AVChannelLayout m_chOverrideMixer{};\n\n    SwrContext *m_swrContext = nullptr;\n    LAVAudioSampleFormat m_sfRemixFormat = SampleFormat_None;\n    AVChannelLayout m_chRemixLayout{};\n    BOOL m_bAVResampleFailed = FALSE;\n    BOOL m_bMixingSettingsChanged = FALSE;\n\n    // Settings\n    struct AudioSettings\n    {\n        BOOL TrayIcon;\n        BOOL DRCEnabled;\n        int DRCLevel;\n        BOOL bFormats[Codec_AudioNB];\n        BOOL bBitstream[Bitstream_NB];\n        BOOL DTSHDFraming;\n        BOOL bBitstreamingFallback;\n        BOOL AutoAVSync;\n        BOOL ExpandMono;\n        BOOL Expand61;\n        BOOL OutputStandardLayout;\n        BOOL Output51Legacy;\n        BOOL AllowRawSPDIF;\n        BOOL bSampleFormats[SampleFormat_NB];\n        BOOL SampleConvertDither;\n        BOOL AudioDelayEnabled;\n        int AudioDelay;\n\n        BOOL MixingEnabled;\n        DWORD MixingLayout;\n        DWORD MixingFlags;\n        DWORD MixingMode;\n        DWORD MixingCenterLevel;\n        DWORD MixingSurroundLevel;\n        DWORD MixingLFELevel;\n\n        BOOL SuppressFormatChanges;\n    } m_settings;\n    BOOL m_bRuntimeConfig = FALSE;\n\n    BOOL m_bVolumeStats = FALSE;          // Volume Stats gathering enabled\n    FloatingAverage<float> m_faVolume[MAX_VOLUME_STAT_CHANNEL]; // Floating Average for volume (8 channels)\n\n    BOOL m_bQueueResync = FALSE;\n    BOOL m_bResyncTimestamp = FALSE;\n    BOOL m_bNeedSyncpoint = FALSE;\n    BOOL m_bJustFlushed = TRUE;\n    BufferDetails m_OutputQueue;\n\n    AVIOContext *m_avioBitstream = nullptr;\n    AVFormatContext *m_avBSContext = nullptr;\n    GrowableArray<BYTE> m_bsOutput;\n    BOOL m_bBitStreamingSettingsChanged = FALSE;\n    BOOL m_bBitstreamOverride[Bitstream_NB] = {FALSE};\n\n    DTSBitstreamMode m_DTSBitstreamMode = DTS_Core;\n    BOOL m_bForceDTSCore = FALSE;\n    CBitstreamParser m_bsParser;\n    BOOL m_bFindDTSInPCM = FALSE;\n    BOOL m_bDVDPlayback = FALSE;\n    BOOL m_bMPEGAudioResync = FALSE;\n\n    FloatingAverage<REFERENCE_TIME> m_faJitter{50};\n    REFERENCE_TIME m_JitterLimit = MAX_JITTER_DESYNC;\n\n    AVChannelLayout m_DecodeLayout{};\n    AVChannelLayout m_DecodeLayoutSanified{};\n    AVChannelLayout m_MixingInputLayout{};\n    BOOL m_bChannelMappingRequired = FALSE;\n\n    AVChannelLayout m_SuppressLayout{};\n\n    ExtendedChannelMap m_ChannelMap;\n    AVChannelLayout m_ChannelMapOutputLayout{};\n\n    AVPacket *m_pDecodePacket = nullptr;\n    AVPacket *m_pBitstreamPacket = nullptr;\n\n    // TrueHD Bitstreaming\n    struct\n    {\n        bool init = false;\n        int ratebits = 0;\n        uint16_t output_timing = 0;\n        BOOL output_timing_valid = FALSE;\n\n        uint16_t prev_frametime = 0;\n        BOOL prev_frametime_valid = FALSE;\n\n        uint32_t mat_framesize = 0;\n        uint32_t prev_mat_framesize = 0;\n\n        DWORD padding = 0;\n        DWORD nSamples = 0;\n        int nSamplesOffset = 0;\n\n        int nOutputTimeOffset = 0;\n    } m_TrueHDMATState;\n\n    struct\n    {\n        int flavor;\n        int coded_frame_size;\n        int audio_framesize;\n        int sub_packet_h;\n        int sub_packet_size;\n        unsigned int deint_id;\n    } m_raData;\n\n    CBaseTrayIcon *m_pTrayIcon = nullptr;\n};\n"
  },
  {
    "path": "decoder/LAVAudio/LAVAudio.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n  <dependency>\n    <dependentAssembly>\n      <assemblyIdentity type=\"win32\" name=\"LAVFilters.Dependencies\" version=\"1.0.0.0\" />\n    </dependentAssembly>\n  </dependency>\n</assembly>\n"
  },
  {
    "path": "decoder/LAVAudio/LAVAudio.rc",
    "content": "// Microsoft Visual C++ generated resource script.\n//\n#include \"resource.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"winres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (United States) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Icon\n//\n\n// Icon with lowest ID value placed first to ensure application icon\n// remains consistent on all systems.\nIDI_ICON1               ICON                    \"..\\\\..\\\\resources\\\\blue.ico\"\n\n\n#ifdef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// TEXTINCLUDE\n//\n\n1 TEXTINCLUDE \nBEGIN\n    \"resource.h\\0\"\nEND\n\n2 TEXTINCLUDE \nBEGIN\n    \"#include \"\"winres.h\"\"\\r\\n\"\n    \"\\0\"\nEND\n\n3 TEXTINCLUDE \nBEGIN\n    \"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\\r\\n\"\n    \"LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\\r\\n\"\n    \"#pragma code_page(1252)\\r\\n\"\n    \"#include \"\"LAVAudio.rc2\"\" // non-Microsoft Visual C++ edited resources\\r\\n\"\n    \"#endif\\r\\n\"\n    \"\\0\"\nEND\n\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Dialog\n//\n\nIDD_PROPPAGE_AUDIO_SETTINGS DIALOGEX 0, 0, 369, 234\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0\nBEGIN\n    GROUPBOX        \"Dynamic Range Compression\",IDC_DRC_BOX,7,7,196,40\n    CONTROL         \"Apply DRC on formats that support it (AC3, EAC3)\",IDC_DRC,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,17,177,10\n    CONTROL         \"\",IDC_DRC_LEVEL,\"msctls_trackbar32\",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,50,30,100,12\n    LTEXT           \"Level: \",IDC_LBL_DRC_LEVEL,15,30,28,8\n    LTEXT           \"100%\",IDC_DRC_LEVEL_TEXT,150,30,20,8,0,WS_EX_RIGHT\n    GROUPBOX        \"Bitstreaming (S/PDIF, HDMI)\",IDC_BITSTREAMING,7,50,196,98\n    LTEXT           \"Formats\",IDC_BS_FORMATS,12,60,122,8\n    CONTROL         \"Dolby Digital (AC-3)\",IDC_BS_AC3,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,20,72,79,10\n    CONTROL         \"Dolby Digital Plus (E-AC3)\",IDC_BS_EAC3,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,20,86,97,10\n    CONTROL         \"Dolby TrueHD\",IDC_BS_TRUEHD,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,20,100,60,10\n    CONTROL         \"DTS\",IDC_BS_DTS,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,130,72,29,10\n    CONTROL         \"DTS-HD\",IDC_BS_DTSHD,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,130,86,41,10\n    LTEXT           \"Options\",IDC_BS_OPTIONS,12,112,26,8\n    CONTROL         \"Force max DTS-HD rate (not recommended)\",IDC_BS_DTSHD_FRAMING,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,20,123,151,10\n    CONTROL         \"Fallback to PCM if Bitstreaming is not supported\",IDC_BS_FALLBACK,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,20,135,161,10\n    GROUPBOX        \"Options\",IDC_OPTIONS,7,149,196,65\n    CONTROL         \"Auto A/V Sync correction\",IDC_AUTO_AVSYNC,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,160,96,10\n    CONTROL         \"Convert Output to Standard Channel Layouts\",IDC_STANDARD_CH_LAYOUT,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,174,162,10\n    CONTROL         \"Expand Mono to Stereo\",IDC_EXPAND_MONO,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,188,91,10\n    CONTROL         \"Expand 6.1 to 7.1\",IDC_EXPAND61,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,118,188,74,10\n    CONTROL         \"Use Legacy 5.1 channel layout\",IDC_OUTPUT51_LEGACY,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,202,162,10\n    LTEXT           \"LAV Audio Decoder x.xx\",IDC_LAVAUDIO_FOOTER,209,221,149,8,0,WS_EX_RIGHT\n    GROUPBOX        \"Output Formats\",IDC_OUTPUT_FORMATS,207,59,151,132\n    LTEXT           \"Select which output formats are available.\\nThe best format is used automatically.\",IDC_LBL_OUTPUTFORMATS,213,70,140,22\n    CONTROL         \"16-bit Integer\",IDC_OUT_S16,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,216,91,61,10\n    CONTROL         \"24-bit Integer\",IDC_OUT_S24,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,286,91,61,10\n    CONTROL         \"32-bit Integer\",IDC_OUT_S32,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,216,107,61,10\n    CONTROL         \"32-bit Floating-point\",IDC_OUT_FP32,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,216,123,81,10\n    CONTROL         \"8-bit Integer\",IDC_OUT_U8,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,286,107,54,10\n    CONTROL         \"Use Dithering for 16-bit Output\",IDC_OUT_S16_DITHER,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,216,139,125,10\n    LTEXT           \"Enabling all formats will allow untouched / bitexact output. Only if a format is not compatible with your hard- or software it should be disabled.\",IDC_LBL_OUTNOTE,213,152,140,37\n    GROUPBOX        \"Audio Delay\",IDC_GROUP_DELAY,207,7,151,50\n    CONTROL         \"Enable Audio Delay\",IDC_DELAY_ENABLED,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,214,20,113,10\n    LTEXT           \"Delay (in ms):\",IDC_STATIC,213,37,47,8\n    EDITTEXT        IDC_DELAY,261,35,46,13,ES_AUTOHSCROLL,WS_EX_RIGHT\n    CONTROL         \"\",IDC_DELAYSPIN,\"msctls_updown32\",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,305,35,11,13\n    CONTROL         \"Enable System Tray Icon\", IDC_TRAYICON, \"Button\", BS_AUTOCHECKBOX | WS_TABSTOP, 7, 219, 192, 10\nEND\n\nIDD_PROPPAGE_AUDIO_MIXING DIALOGEX 0, 0, 369, 215\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0\nBEGIN\n    GROUPBOX        \"Mixer\",IDC_LBL_MIXING,7,7,214,112\n    CONTROL         \"Enable Mixing\",IDC_MIXING,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,14,19,59,10\n    LTEXT           \"Output Speaker Configuration:\",IDC_LBL_OUTPUT_SPEAKERS,15,32,100,8\n    COMBOBOX        IDC_OUTPUT_SPEAKERS,121,30,90,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n    GROUPBOX        \"Settings\",IDC_MIX_SETTINGS,225,7,133,56\n    CONTROL         \"Don't mix Stereo sources\",IDC_UNTOUCHED_STEREO,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,235,19,100,10\n    CONTROL         \"Normalize Matrix\",IDC_NORMALIZE_MATRIX,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,235,33,100,10\n    CONTROL         \"Clipping Protection\",IDC_CLIP_PROTECTION,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,235,47,100,10\n    GROUPBOX        \"Matrix Encoding\",IDC_MIXING_MODE,225,67,133,51\n    CONTROL         \"None\",IDC_MIXMODE_NORMAL,\"Button\",BS_AUTORADIOBUTTON,235,79,116,10\n    CONTROL         \"Dolby Pro Logic\",IDC_MIXMODE_DOLBY,\"Button\",BS_AUTORADIOBUTTON,235,91,116,10\n    CONTROL         \"Dolby Pro Logic II\",IDC_MIXMODE_DPL2,\"Button\",BS_AUTORADIOBUTTON,235,103,116,10\n    LTEXT           \"Center Mix Level\",IDC_LBL_CENTER_LEVEL,12,50,54,8\n    CONTROL         \"\",IDC_MIX_LEVEL_CENTER,\"msctls_trackbar32\",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,72,47,130,15\n    LTEXT           \"0.00\",IDC_MIX_LEVEL_CENTER_TEXT,202,50,16,8\n    LTEXT           \"Surround Mix Level\",IDC_LBL_SURROUND_LEVEL,12,65,62,8\n    CONTROL         \"\",IDC_MIX_LEVEL_SURROUND,\"msctls_trackbar32\",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,72,62,130,15\n    LTEXT           \"0.00\",IDC_MIX_LEVEL_SURROUND_TEXT,202,65,16,8\n    LTEXT           \"LFE Mix Level\",IDC_LBL_LFE_LEVEL,12,80,44,8\n    CONTROL         \"\",IDC_MIX_LEVEL_LFE,\"msctls_trackbar32\",TBS_BOTH | TBS_NOTICKS | WS_TABSTOP,72,77,130,15\n    LTEXT           \"0.00\",IDC_MIX_LEVEL_LFE_TEXT,202,80,16,8\n    LTEXT           \"The mixing levels control the volume of the individual channels when being mixed with other channels into a downmix.\",IDC_LBL_MIXING_LEVEL,12,97,200,18\nEND\n\nIDD_PROPPAGE_FORMATS DIALOGEX 0, 0, 369, 234\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0\nBEGIN\n    LTEXT           \"Here you can select which formats LAV Audio should decode.\\nBecause LAV Audio supports a wide range of (rare) formats, not all are listed here.\\nIf you need to configure a specific format which is not listed, submit a ticket asking for the option.\",IDC_LBL_FORMATS,8,10,333,30\n    CONTROL         \"\",IDC_CODECS,\"SysListView32\",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,40,351,185\nEND\n\nIDD_PROPPAGE_STATUS DIALOGEX 0, 0, 214, 156\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0\nBEGIN\n    GROUPBOX        \"Input\",IDC_INPUT_STATUS,7,7,98,61\n    LTEXT           \"Codec:\",IDC_LBL_INPUT_CODEC,12,18,44,8\n    LTEXT           \"Channel:\",IDC_LBL_INPUT_CHANNEL,12,30,44,8\n    LTEXT           \"Sample Rate:\",IDC_LBL_INPUT_SAMPLERATE,12,42,44,8\n    LTEXT           \"Format:\",IDC_LBL_INPUT_FORMAT,12,54,44,8\n    LTEXT           \"\",IDC_INPUT_CODEC,58,18,45,8\n    LTEXT           \"\",IDC_INPUT_CHANNEL,58,30,45,8\n    LTEXT           \"\",IDC_INPUT_SAMPLERATE,58,42,45,8\n    LTEXT           \"\",IDC_INPUT_FORMAT,58,54,45,8\n    GROUPBOX        \"Output\",IDC_OUTPUT_STATUS,109,7,98,61\n    LTEXT           \"Codec:\",IDC_LBL_OUTPUT_CODEC,114,18,44,8\n    LTEXT           \"Channel:\",IDC_LBL_OUTPUT_CHANNEL,114,30,44,8\n    LTEXT           \"Sample Rate:\",IDC_LBL_OUTPUT_SAMPLERATE,114,42,44,8\n    LTEXT           \"Format:\",IDC_LBL_OUTPUT_FORMAT,114,54,44,8\n    LTEXT           \"\",IDC_OUTPUT_CODEC,160,18,45,8\n    LTEXT           \"\",IDC_OUTPUT_CHANNEL,160,30,45,8\n    LTEXT           \"\",IDC_OUTPUT_SAMPLERATE,160,42,45,8\n    LTEXT           \"\",IDC_OUTPUT_FORMAT,160,54,45,8\n    GROUPBOX        \"Channel Output\",IDC_VOLUME,7,71,200,77\n    CONTROL         \"\",IDC_VOLUME1,\"msctls_progress32\",PBS_VERTICAL | WS_BORDER,14,84,12,45\n    CONTROL         \"\",IDC_VOLUME2,\"msctls_progress32\",PBS_VERTICAL | WS_BORDER,39,84,12,45\n    CONTROL         \"\",IDC_VOLUME3,\"msctls_progress32\",PBS_VERTICAL | WS_BORDER,64,84,12,45\n    CONTROL         \"\",IDC_VOLUME4,\"msctls_progress32\",PBS_VERTICAL | WS_BORDER,89,84,12,45\n    CONTROL         \"\",IDC_VOLUME5,\"msctls_progress32\",PBS_VERTICAL | WS_BORDER,114,84,12,45\n    CONTROL         \"\",IDC_VOLUME6,\"msctls_progress32\",PBS_VERTICAL | WS_BORDER,139,84,12,45\n    CONTROL         \"\",IDC_VOLUME7,\"msctls_progress32\",PBS_VERTICAL | WS_BORDER,164,84,12,45\n    CONTROL         \"\",IDC_VOLUME8,\"msctls_progress32\",PBS_VERTICAL | WS_BORDER,189,84,12,45\n    CTEXT           \"L\",IDC_VOLUME1_DESC,9,132,21,8\n    CTEXT           \"R\",IDC_VOLUME2_DESC,34,132,21,8\n    CTEXT           \"C\",IDC_VOLUME3_DESC,59,132,21,8\n    CTEXT           \"LFE\",IDC_VOLUME4_DESC,84,132,21,8\n    CTEXT           \"BL\",IDC_VOLUME5_DESC,109,132,21,8\n    CTEXT           \"BR\",IDC_VOLUME6_DESC,134,132,21,8\n    CTEXT           \"SL\",IDC_VOLUME7_DESC,159,132,21,8\n    CTEXT           \"SR\",IDC_VOLUME8_DESC,184,132,21,8\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// DESIGNINFO\n//\n\n#ifdef APSTUDIO_INVOKED\nGUIDELINES DESIGNINFO\nBEGIN\n    IDD_PROPPAGE_AUDIO_SETTINGS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 358\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 229\n    END\n\n    IDD_PROPPAGE_AUDIO_MIXING, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 358\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 210\n    END\n\n    IDD_PROPPAGE_FORMATS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 358\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 210\n    END\n\n    IDD_PROPPAGE_STATUS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 207\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 148\n    END\nEND\n#endif    // APSTUDIO_INVOKED\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// String Table\n//\n\nSTRINGTABLE\nBEGIN\n    IDS_SETTINGS            \"Audio Settings\"\n    IDS_STATUS              \"Status\"\n    IDS_FORMATS             \"Formats\"\n    IDS_MIXER               \"Mixing\"\nEND\n\n#endif    // English (United States) resources\n/////////////////////////////////////////////////////////////////////////////\n\n\n\n#ifndef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 3 resource.\n//\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n#include \"LAVAudio.rc2\" // non-Microsoft Visual C++ edited resources\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n#endif    // not APSTUDIO_INVOKED\n\n"
  },
  {
    "path": "decoder/LAVAudio/LAVAudio.rc2",
    "content": "//\n// LAVAudio.rc2 - resources Microsoft Visual C++ does not edit directly\n//\n\n#ifdef APSTUDIO_INVOKED\n#error This file is not editable by Microsoft Visual C++\n#endif //APSTUDIO_INVOKED\n\n/////////////////////////////////////////////////////////////////////////////\n// Add manually edited resources here...\n\n/////////////////////////////////////////////////////////////////////////////\n\n#include \"resource.h\"\n#include \"..\\..\\common\\includes\\version.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"winres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (United States) resources\n\n/////////////////////////////////////////////////////////////////////////////\n// Neutral (Sys. Default) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Version\n//\n\nVS_VERSION_INFO VERSIONINFO\n FILEVERSION LAV_VERSION_TAG\n PRODUCTVERSION LAV_VERSION_TAG\n FILEFLAGSMASK 0x3fL\n#ifdef _DEBUG\n FILEFLAGS 0x1L\n#else\n FILEFLAGS 0x0L\n#endif\n FILEOS 0x40004L\n FILETYPE 0x2L\n FILESUBTYPE 0x0L\nBEGIN\n    BLOCK \"StringFileInfo\"\n    BEGIN\n        BLOCK \"040904b0\"\n        BEGIN\n            VALUE \"CompanyName\", \"1f0.de - Hendrik Leppkes\"\n            VALUE \"FileDescription\", \"LAV Audio Decoder - DirectShow Audio Decoder\"\n            VALUE \"FileVersion\", LAV_VERSION_STR\n            VALUE \"InternalName\", \"LAVAudio.ax\"\n            VALUE \"LegalCopyright\", \"Copyright (C) 2010-2021 Hendrik Leppkes\"\n            VALUE \"OriginalFilename\", \"LAVAudio.ax\"\n            VALUE \"ProductName\", \"LAV Audio Decoder\"\n            VALUE \"ProductVersion\", LAV_VERSION_STR\n        END\n    END\n    BLOCK \"VarFileInfo\"\n    BEGIN\n        VALUE \"Translation\", 0x409, 1200\n    END\nEND\n\n#endif\n"
  },
  {
    "path": "decoder/LAVAudio/LAVAudio.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{12154C64-9136-4C21-92FA-665008C6FD27}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n    <RootNamespace>LAVAudio</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <Import Project=\"$(SolutionDir)common\\platform.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Import Project=\"$(SolutionDir)common\\common.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <TargetExt>.ax</TargetExt>\n    <OutDir>$(SolutionDir)bin_$(PlatformName)d\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n    <TargetExt>.ax</TargetExt>\n    <OutDir>$(SolutionDir)bin_$(PlatformName)\\$(ProjectName)\\</OutDir>\n    <CustomBuildAfterTargets>Build</CustomBuildAfterTargets>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LAVAUDIO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n    <Link>\n      <AdditionalDependencies>advapi32.lib;ole32.lib;winmm.lib;user32.lib;oleaut32.lib;shell32.lib;Shlwapi.lib;Comctl32.lib;version.lib;avformat-lav.lib;avutil-lav.lib;avcodec-lav.lib;swresample-lav.lib</AdditionalDependencies>\n      <ModuleDefinitionFile>LAVAudio.def</ModuleDefinitionFile>\n    </Link>\n    <Manifest>\n      <AdditionalManifestFiles>$(ProjectDir)\\$(ProjectName).manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>\n    </Manifest>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Release'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LAVAUDIO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n    <Link>\n      <AdditionalDependencies>advapi32.lib;ole32.lib;winmm.lib;user32.lib;oleaut32.lib;shell32.lib;Shlwapi.lib;Comctl32.lib;version.lib;avformat-lav.lib;avutil-lav.lib;avcodec-lav.lib;swresample-lav.lib</AdditionalDependencies>\n      <ModuleDefinitionFile>LAVAudio.def</ModuleDefinitionFile>\n    </Link>\n    <CustomBuildStep>\n      <Command>copy \"$(TargetDir)\\$(TargetName)$(TargetExt)\" \"$(OutDir)..\"</Command>\n      <Outputs>$(OutDir)..\\$(TargetFileName)</Outputs>\n      <Inputs>$(TargetDir)\\$(TargetName)$(TargetExt)</Inputs>\n    </CustomBuildStep>\n    <Manifest>\n      <AdditionalManifestFiles>$(ProjectDir)\\$(ProjectName).manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>\n    </Manifest>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"Bitstream.cpp\" />\n    <ClCompile Include=\"BitstreamMAT.cpp\" />\n    <ClCompile Include=\"BitstreamParser.cpp\" />\n    <ClCompile Include=\"dllmain.cpp\" />\n    <ClCompile Include=\"LAVAudio.cpp\" />\n    <ClCompile Include=\"AudioSettingsProp.cpp\" />\n    <ClCompile Include=\"Media.cpp\" />\n    <ClCompile Include=\"parser\\dts.cpp\">\n      <PrecompiledHeader>NotUsing</PrecompiledHeader>\n    </ClCompile>\n    <ClCompile Include=\"PostProcessor.cpp\" />\n    <ClCompile Include=\"stdafx.cpp\">\n      <PrecompiledHeader>Create</PrecompiledHeader>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\..\\include\\LAVAudioSettings.h\" />\n    <ClInclude Include=\"BitstreamParser.h\" />\n    <ClInclude Include=\"LAVAudio.h\" />\n    <ClInclude Include=\"AudioSettingsProp.h\" />\n    <ClInclude Include=\"Media.h\" />\n    <ClInclude Include=\"parser\\dts.h\" />\n    <ClInclude Include=\"parser\\parser.h\" />\n    <ClInclude Include=\"PostProcessor.h\" />\n    <ClInclude Include=\"resource.h\" />\n    <ClInclude Include=\"stdafx.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"LAVAudio.rc\">\n      <FileType>RC</FileType>\n    </ResourceCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"..\\..\\resources\\blue.ico\" />\n    <None Include=\"LAVAudio.rc2\" />\n    <Manifest Include=\"LAVAudio.manifest\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\..\\common\\baseclasses\\baseclasses.vcxproj\">\n      <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>\n    </ProjectReference>\n    <ProjectReference Include=\"..\\..\\common\\DSUtilLite\\DSUtilLite.vcxproj\">\n      <Project>{0a058024-41f4-4509-97d2-803a1806ce86}</Project>\n    </ProjectReference>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "decoder/LAVAudio/LAVAudio.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\\parser\">\n      <UniqueIdentifier>{5d05f06d-934e-4454-a2e6-07c4aebe26c6}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\parser\">\n      <UniqueIdentifier>{322b942d-d30d-4738-abf1-3934ed971b11}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"stdafx.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dllmain.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Media.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVAudio.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"AudioSettingsProp.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Bitstream.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"BitstreamParser.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"parser\\dts.cpp\">\n      <Filter>Source Files\\parser</Filter>\n    </ClCompile>\n    <ClCompile Include=\"PostProcessor.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"BitstreamMAT.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"stdafx.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"resource.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVAudio.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"AudioSettingsProp.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"Media.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"BitstreamParser.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"parser\\dts.h\">\n      <Filter>Header Files\\parser</Filter>\n    </ClInclude>\n    <ClInclude Include=\"parser\\parser.h\">\n      <Filter>Header Files\\parser</Filter>\n    </ClInclude>\n    <ClInclude Include=\"PostProcessor.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\LAVAudioSettings.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"LAVAudio.rc\">\n      <Filter>Resource Files</Filter>\n    </ResourceCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"LAVAudio.rc2\">\n      <Filter>Resource Files</Filter>\n    </None>\n    <None Include=\"..\\..\\resources\\blue.ico\">\n      <Filter>Resource Files</Filter>\n    </None>\n  </ItemGroup>\n  <ItemGroup>\n    <Manifest Include=\"LAVAudio.manifest\">\n      <Filter>Resource Files</Filter>\n    </Manifest>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "decoder/LAVAudio/Media.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVAudio.h\"\n\n#include <ks.h>\n#include <ksmedia.h>\n#include <MMReg.h>\n\n#include \"moreuuids.h\"\n\nextern \"C\"\n{\n#include \"libavutil/intreadwrite.h\"\n};\n\ntypedef struct\n{\n    const CLSID *clsMinorType;\n    const enum AVCodecID nFFCodec;\n} FFMPEG_SUBTYPE_MAP;\n\n// clang-format off\n// Map Media Subtype <> FFMPEG Codec Id\nstatic const FFMPEG_SUBTYPE_MAP lavc_audio_codecs[] = {\n  // AAC\n  { &MEDIASUBTYPE_AAC,          AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_LATM_AAC,     AV_CODEC_ID_AAC_LATM },\n  { &MEDIASUBTYPE_MPEG_LOAS,    AV_CODEC_ID_AAC_LATM },\n  { &MEDIASUBTYPE_MP4A,         AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_mp4a,         AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_AAC_ADTS,     AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_MPEG_ADTS_AAC,AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_MPEG_RAW_AAC, AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_MPEG_HEAAC,   AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_ALS,          AV_CODEC_ID_MP4ALS   },\n\n  // Dolby\n  { &MEDIASUBTYPE_DOLBY_AC3,    AV_CODEC_ID_AC3      },\n  { &MEDIASUBTYPE_DOLBY_DDPLUS, AV_CODEC_ID_EAC3     },\n  { &MEDIASUBTYPE_DOLBY_DDPLUS_ARCSOFT, AV_CODEC_ID_EAC3 },\n  { &MEDIASUBTYPE_DOLBY_TRUEHD, AV_CODEC_ID_TRUEHD   },\n  { &MEDIASUBTYPE_WAVE_DOLBY_AC3, AV_CODEC_ID_AC3    },\n\n  // DTS\n  { &MEDIASUBTYPE_DTS,          AV_CODEC_ID_DTS      },\n  { &MEDIASUBTYPE_DTS_HD,       AV_CODEC_ID_DTS      },\n  { &MEDIASUBTYPE_WAVE_DTS,     AV_CODEC_ID_DTS      },\n\n  // MPEG Audio\n  { &MEDIASUBTYPE_MPEG1Packet,  AV_CODEC_ID_MP1      },\n  { &MEDIASUBTYPE_MPEG1Payload, AV_CODEC_ID_MP1      },\n  { &MEDIASUBTYPE_MPEG1AudioPayload, AV_CODEC_ID_MP1 },\n  { &MEDIASUBTYPE_MPEG2_AUDIO,  AV_CODEC_ID_MP2      },\n  { &MEDIASUBTYPE_MP3,          AV_CODEC_ID_MP3      },\n\n  // FLAC\n  { &MEDIASUBTYPE_FLAC,         AV_CODEC_ID_FLAC     },\n  { &MEDIASUBTYPE_FLAC_FRAMED,  AV_CODEC_ID_FLAC     },\n\n  // Ogg Vorbis\n  { &MEDIASUBTYPE_Vorbis2,      AV_CODEC_ID_VORBIS   },\n\n  // Other Lossless formats\n  { &MEDIASUBTYPE_TTA1,         AV_CODEC_ID_TTA      },\n  { &MEDIASUBTYPE_WAVPACK4,     AV_CODEC_ID_WAVPACK  },\n  { &MEDIASUBTYPE_MLP,          AV_CODEC_ID_MLP      },\n  { &MEDIASUBTYPE_ALAC,         AV_CODEC_ID_ALAC     },\n  { &MEDIASUBTYPE_TAK,          AV_CODEC_ID_TAK      },\n  { &MEDIASUBTYPE_AES3,         AV_CODEC_ID_S302M    },\n\n  // BluRay LPCM\n  { &MEDIASUBTYPE_DVD_LPCM_AUDIO, AV_CODEC_ID_PCM_DVD },\n  { &MEDIASUBTYPE_BD_LPCM_AUDIO,   AV_CODEC_ID_PCM_BLURAY },\n  { &MEDIASUBTYPE_HDMV_LPCM_AUDIO, AV_CODEC_ID_PCM_BLURAY }, // MPC-HC MPEG Splitter type with header stripped off\n\n  // QT PCM\n  { &MEDIASUBTYPE_PCM_NONE,     AV_CODEC_ID_PCM_QTRAW},\n  { &MEDIASUBTYPE_PCM_RAW,      AV_CODEC_ID_PCM_QTRAW},\n  { &MEDIASUBTYPE_PCM_TWOS,     AV_CODEC_ID_PCM_SxxBE},\n  { &MEDIASUBTYPE_PCM_SOWT,     AV_CODEC_ID_PCM_SxxLE},\n  { &MEDIASUBTYPE_PCM_IN24,     AV_CODEC_ID_PCM_S24BE},\n  { &MEDIASUBTYPE_PCM_IN32,     AV_CODEC_ID_PCM_S32BE},\n  { &MEDIASUBTYPE_PCM_FL32,     AV_CODEC_ID_PCM_F32BE},\n  { &MEDIASUBTYPE_PCM_FL64,     AV_CODEC_ID_PCM_F64BE},\n  { &MEDIASUBTYPE_PCM_IN24_le,  AV_CODEC_ID_PCM_S24LE},\n  { &MEDIASUBTYPE_PCM_IN32_le,  AV_CODEC_ID_PCM_S32LE},\n  { &MEDIASUBTYPE_PCM_FL32_le,  AV_CODEC_ID_PCM_F32LE},\n  { &MEDIASUBTYPE_PCM_FL64_le,  AV_CODEC_ID_PCM_F64LE},\n\n  // WMV\n  { &MEDIASUBTYPE_MSAUDIO1,     AV_CODEC_ID_WMAV1    },\n  { &MEDIASUBTYPE_WMAUDIO2,     AV_CODEC_ID_WMAV2    },\n  { &MEDIASUBTYPE_WMAUDIO3,     AV_CODEC_ID_WMAPRO   },\n  { &MEDIASUBTYPE_WMAUDIO_LOSSLESS, AV_CODEC_ID_WMALOSSLESS },\n\n  // RealMedia Audio\n  { &MEDIASUBTYPE_COOK,         AV_CODEC_ID_COOK     },\n  { &MEDIASUBTYPE_RAAC,         AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_RACP,         AV_CODEC_ID_AAC      },\n  { &MEDIASUBTYPE_SIPR,         AV_CODEC_ID_SIPR     },\n  { &MEDIASUBTYPE_SIPR_WAVE,    AV_CODEC_ID_SIPR     },\n  { &MEDIASUBTYPE_DNET,         AV_CODEC_ID_AC3      },\n  { &MEDIASUBTYPE_28_8,         AV_CODEC_ID_RA_288   },\n  { &MEDIASUBTYPE_14_4,         AV_CODEC_ID_RA_144   },\n  { &MEDIASUBTYPE_RALF,         AV_CODEC_ID_RALF     },\n\n  // Misc\n  { &MEDIASUBTYPE_SPEEX,        AV_CODEC_ID_SPEEX    },\n  { &MEDIASUBTYPE_OPUS,         AV_CODEC_ID_OPUS     },\n  { &MEDIASUBTYPE_OPUS_OLD,     AV_CODEC_ID_OPUS     },\n  { &MEDIASUBTYPE_SAMR,         AV_CODEC_ID_AMR_NB   },\n  { &MEDIASUBTYPE_NELLYMOSER,   AV_CODEC_ID_NELLYMOSER },\n  { &MEDIASUBTYPE_ALAW,         AV_CODEC_ID_PCM_ALAW },\n  { &MEDIASUBTYPE_MULAW,        AV_CODEC_ID_PCM_MULAW },\n  { &MEDIASUBTYPE_MSGSM610,     AV_CODEC_ID_GSM_MS   },\n  { &MEDIASUBTYPE_ADPCM_MS,     AV_CODEC_ID_ADPCM_MS },\n  { &MEDIASUBTYPE_TRUESPEECH,   AV_CODEC_ID_TRUESPEECH },\n  { &MEDIASUBTYPE_QDM2,         AV_CODEC_ID_QDM2     },\n  { &MEDIASUBTYPE_VOXWARE_RT29, AV_CODEC_ID_METASOUND },\n  { &MEDIASUBTYPE_ATRAC3,       AV_CODEC_ID_ATRAC3   },\n  { &MEDIASUBTYPE_ATRC,         AV_CODEC_ID_ATRAC3   },\n  { &MEDIASUBTYPE_ATRAC3P,      AV_CODEC_ID_ATRAC3P  },\n  { &MEDIASUBTYPE_IMA_WAV,      AV_CODEC_ID_ADPCM_IMA_WAV },\n  { &MEDIASUBTYPE_G726,         AV_CODEC_ID_ADPCM_G726 },\n  { &MEDIASUBTYPE_729A,         AV_CODEC_ID_G729     },\n  { &MEDIASUBTYPE_G729,         AV_CODEC_ID_G729     },\n  { &MEDIASUBTYPE_IMC,          AV_CODEC_ID_IMC      },\n\n  // Special LAVFSplitter interface\n  { &MEDIASUBTYPE_FFMPEG_AUDIO, AV_CODEC_ID_NONE     },\n};\n\n// Define Input Media Types\nconst AMOVIESETUP_MEDIATYPE CLAVAudio::sudPinTypesIn[] = {\n  // DVD Types\n  { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_AUDIO },\n  { &MEDIATYPE_MPEG2_PACK,         &MEDIASUBTYPE_MPEG2_AUDIO },\n  { &MEDIATYPE_MPEG2_PES,          &MEDIASUBTYPE_MPEG2_AUDIO },\n  { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DOLBY_AC3 },\n  { &MEDIATYPE_MPEG2_PACK,         &MEDIASUBTYPE_DOLBY_AC3 },\n  { &MEDIATYPE_MPEG2_PES,          &MEDIASUBTYPE_DOLBY_AC3 },\n  { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DTS },\n  { &MEDIATYPE_MPEG2_PACK,         &MEDIASUBTYPE_DTS },\n  { &MEDIATYPE_MPEG2_PES,          &MEDIASUBTYPE_DTS },\n  { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DVD_LPCM_AUDIO },\n  { &MEDIATYPE_MPEG2_PACK,         &MEDIASUBTYPE_DVD_LPCM_AUDIO },\n  { &MEDIATYPE_MPEG2_PES,          &MEDIASUBTYPE_DVD_LPCM_AUDIO },\n\n  // AAC\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_AAC          },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_LATM_AAC     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG_LOAS    },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MP4A         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_mp4a         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_AAC_ADTS     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG_ADTS_AAC},\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG_RAW_AAC },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG_HEAAC   },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_ALS          },\n\n  // Dolby\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_AC3    },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_DDPLUS },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_DDPLUS_ARCSOFT },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_DOLBY_TRUEHD },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DOLBY_AC3 },\n\n  // DTS\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_DTS          },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_WAVE_DTS     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_DTS_HD       },\n\n  // MPEG Audio\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Packet  },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1Payload },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG1AudioPayload },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MPEG2_AUDIO  },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MP3          },\n\n  // FLAC\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC,        },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_FLAC_FRAMED  },\n\n  // Ogg Vorbis\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_Vorbis2      },\n\n  // Other Lossless formats\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_TTA1         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_WAVPACK4     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MLP          },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_ALAC         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_TAK          },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_AES3         },\n\n  // BluRay LPCM\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_DVD_LPCM_AUDIO  },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_BD_LPCM_AUDIO   },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_HDMV_LPCM_AUDIO }, // MPC-HC MPEG Splitter type with header stripped off\n\n  // QT PCM\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_NONE     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_RAW      },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_TWOS     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_SOWT     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN24     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN32     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL32     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL64     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN24_le  },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_IN32_le  },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL32_le  },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM_FL64_le  },\n\n  // WMV\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MSAUDIO1     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_WMAUDIO2     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_WMAUDIO3     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_WMAUDIO_LOSSLESS },\n\n  // RealMedia Audio\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_COOK         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_RAAC         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_RACP         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_SIPR_WAVE    },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_DNET         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_28_8         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_14_4         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_RALF         },\n\n  // Misc\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_SPEEX        },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_OPUS         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_OPUS_OLD     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_SAMR         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_NELLYMOSER   },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_ALAW         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MULAW        },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_MSGSM610     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_ADPCM_MS     },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_TRUESPEECH   },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_QDM2,        },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_VOXWARE_RT29 },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_ATRAC3       },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_ATRC         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_ATRAC3P      },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_IMA_WAV      },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_G726         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_729A         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_G729         },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_IMC          },\n\n  // Special LAVFSplitter interface\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_FFMPEG_AUDIO },\n};\nconst UINT CLAVAudio::sudPinTypesInCount = countof(CLAVAudio::sudPinTypesIn);\n\n// Define Output Media Types\nconst AMOVIESETUP_MEDIATYPE CLAVAudio::sudPinTypesOut[] = {\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_PCM        },\n  { &MEDIATYPE_Audio, &MEDIASUBTYPE_IEEE_FLOAT },\n};\nconst UINT CLAVAudio::sudPinTypesOutCount = countof(CLAVAudio::sudPinTypesOut);\n// clang-format on\n\n// Crawl the lavc_audio_codecs array for the proper codec\nAVCodecID FindCodecId(const CMediaType *mt)\n{\n    for (int i = 0; i < countof(lavc_audio_codecs); ++i)\n    {\n        if (mt->subtype == *lavc_audio_codecs[i].clsMinorType)\n        {\n            return lavc_audio_codecs[i].nFFCodec;\n        }\n    }\n    return AV_CODEC_ID_NONE;\n}\n\nstatic const struct s_ffmpeg_codec_overrides\n{\n    AVCodecID codec;\n    const char *override;\n} ffmpeg_codec_overrides[] = {\n    {AV_CODEC_ID_MP1, \"mp1float\"},\n    {AV_CODEC_ID_MP2, \"mp2float\"},\n    {AV_CODEC_ID_MP3, \"mp3float\"},\n    {AV_CODEC_ID_AMR_NB, \"libopencore_amrnb\"},\n    {AV_CODEC_ID_AMR_WB, \"libopencore_amrwb\"},\n};\n\nconst char *find_codec_override(AVCodecID codec)\n{\n    for (int i = 0; i < countof(ffmpeg_codec_overrides); ++i)\n    {\n        if (ffmpeg_codec_overrides[i].codec == codec)\n            return ffmpeg_codec_overrides[i].override;\n    }\n    return nullptr;\n}\n\n// Default Channel to Speaker Map\nstatic const scmap_t m_scmap_default[] = {\n    // FL  FR  FC  LFe BL  BR  FLC FRC\n    {1, KSAUDIO_SPEAKER_MONO},    // Mono       M1, 0\n    {2, KSAUDIO_SPEAKER_STEREO},  // Stereo     FL, FR\n    {3, KSAUDIO_SPEAKER_3POINT0}, // 3/0        FL, FR, FC\n    {4, KSAUDIO_SPEAKER_3POINT1}, // 3/1        FL, FR, FC, Surround\n    {5, KSAUDIO_SPEAKER_5POINT0}, // 3/2        FL, FR, FC, BL, BR\n    {6, KSAUDIO_SPEAKER_5POINT1_SURROUND}, // 3/2+LFe    FL, FR, FC, SL, SR, LFe\n    {7, KSAUDIO_SPEAKER_7POINT0}, // 3/4        FL, FR, FC, BL, Bls, Brs, BR\n    {8, KSAUDIO_SPEAKER_7POINT1_SURROUND}, // 3/4+LFe    FL, FR, FC, BL, BR, SL, SR, LFe\n};\n\nDWORD get_channel_mask(int num_channels)\n{\n    if (num_channels < 1 || num_channels > 8)\n        return 0;\n    return m_scmap_default[num_channels - 1].dwChannelMask;\n}\n\nstatic const char *sample_format_strings[] = {\"16bit Integer\", \"24bit Integer\", \"32bit Integer\",\n                                              \"8bit Integer\",  \"32bit Float\",   \"Bitstreaming\"};\n\nconst char *get_sample_format_desc(LAVAudioSampleFormat sfFormat)\n{\n    return sample_format_strings[sfFormat];\n}\n\nconst char *get_sample_format_desc(CMediaType &mt)\n{\n    LAVAudioSampleFormat format;\n    if (mt.subtype == MEDIASUBTYPE_IEEE_FLOAT)\n    {\n        format = SampleFormat_FP32;\n    }\n    else\n    {\n        WAVEFORMATEX *wfout = (WAVEFORMATEX *)mt.Format();\n\n        switch (wfout->wBitsPerSample)\n        {\n        case 8: format = SampleFormat_U8; break;\n        case 16: format = SampleFormat_16; break;\n        case 24: format = SampleFormat_24; break;\n        case 32: format = SampleFormat_32; break;\n        default: ASSERT(false);\n        }\n    }\n    return get_sample_format_desc(format);\n}\n\nBYTE get_byte_per_sample(LAVAudioSampleFormat sfFormat)\n{\n    switch (sfFormat)\n    {\n    case SampleFormat_U8: return 1;\n    case SampleFormat_16: return 2;\n    case SampleFormat_24: return 3;\n    case SampleFormat_32:\n    case SampleFormat_FP32: return 4;\n    }\n    return 0;\n}\n\nLAVAudioSampleFormat get_lav_sample_fmt(AVSampleFormat sample_fmt, int bits)\n{\n    LAVAudioSampleFormat lav_sample_fmt;\n    switch (sample_fmt)\n    {\n    case AV_SAMPLE_FMT_S16:\n    case AV_SAMPLE_FMT_S16P:\n    case AV_SAMPLE_FMT_S32:\n    case AV_SAMPLE_FMT_S32P:\n        if (bits > 24 || (!bits && (sample_fmt == AV_SAMPLE_FMT_S32 || sample_fmt == AV_SAMPLE_FMT_S32P)))\n            lav_sample_fmt = SampleFormat_32;\n        else if (bits > 16)\n            lav_sample_fmt = SampleFormat_24;\n        else\n            lav_sample_fmt = SampleFormat_16;\n        break;\n    case AV_SAMPLE_FMT_DBL:\n    case AV_SAMPLE_FMT_DBLP:\n    case AV_SAMPLE_FMT_FLT:\n    case AV_SAMPLE_FMT_FLTP: lav_sample_fmt = SampleFormat_FP32; break;\n    case AV_SAMPLE_FMT_U8:\n    case AV_SAMPLE_FMT_U8P: lav_sample_fmt = SampleFormat_U8; break;\n    default: lav_sample_fmt = SampleFormat_16; break;\n    }\n    return lav_sample_fmt;\n}\n\nAVSampleFormat get_ff_sample_fmt(LAVAudioSampleFormat sample_fmt)\n{\n    AVSampleFormat ff_sample_fmt;\n    switch (sample_fmt)\n    {\n    case SampleFormat_16: ff_sample_fmt = AV_SAMPLE_FMT_S16; break;\n    case SampleFormat_24:\n    case SampleFormat_32: ff_sample_fmt = AV_SAMPLE_FMT_S32; break;\n    case SampleFormat_FP32: ff_sample_fmt = AV_SAMPLE_FMT_FLT; break;\n    case SampleFormat_U8: ff_sample_fmt = AV_SAMPLE_FMT_U8; break;\n    default: assert(0); break;\n    }\n    return ff_sample_fmt;\n}\n\nstatic BYTE get_lpcm_sample_rate_index(int sample_rate)\n{\n    switch (sample_rate)\n    {\n    case 48000: return 1;\n    case 96000: return 4;\n    case 192000: return 5;\n    }\n    return 0;\n}\n\nstatic BYTE get_lpcm_bit_per_sample_index(int bit_per_sample)\n{\n    switch (bit_per_sample)\n    {\n    case 16: return 1;\n    case 20: return 2;\n    case 24: return 3;\n    }\n    return 0;\n}\n\nvoid CLAVAudio::CreateBDLPCMHeader(BYTE *const pBuf, const WAVEFORMATEX_HDMV_LPCM *const wfex_lpcm) const\n{\n    const BYTE channel_conf = (wfex_lpcm->cbSize >= 1) ? wfex_lpcm->channel_conf : 0;\n    pBuf[0] = 0;\n    pBuf[1] = 0;\n    pBuf[2] = ((channel_conf) << 4) | (get_lpcm_sample_rate_index(wfex_lpcm->nSamplesPerSec) & 0x0f);\n    pBuf[3] = get_lpcm_bit_per_sample_index(wfex_lpcm->wBitsPerSample) << 6;\n}\n\nstatic BYTE get_dvdlpcm_sample_rate_index(int sample_rate)\n{\n    switch (sample_rate)\n    {\n    case 48000: return 0;\n    case 96000: return 1;\n    case 44100: return 2;\n    case 32000: return 3;\n    }\n    return 0;\n}\n\nvoid CLAVAudio::CreateDVDLPCMHeader(BYTE *const pBuf, const WAVEFORMATEX *const wfex) const\n{\n    pBuf[0] = 0;\n    pBuf[1] = (((wfex->wBitsPerSample - 16) / 4) << 6) | (get_dvdlpcm_sample_rate_index(wfex->nSamplesPerSec) << 4) |\n              ((wfex->nChannels - 1) & 7);\n    pBuf[2] = 0;\n}\n\nHRESULT CLAVAudio::ParseRealAudioHeader(const BYTE *extra, const size_t extralen)\n{\n    const uint8_t *fmt = extra + 4;\n    uint16_t version = AV_RB16(fmt);\n    fmt += 2;\n    if (version == 3)\n    {\n        DbgLog((LOG_TRACE, 10, L\"RealAudio Header version 3 unsupported\"));\n        return VFW_E_UNSUPPORTED_AUDIO;\n    }\n    else if (version == 4 || version == 5 && extralen > 50)\n    {\n        // main format block\n        fmt += 2; // word - unused (always 0)\n        fmt += 4; // byte[4] - .ra4/.ra5 signature\n        fmt += 4; // dword - unknown\n        fmt += 2; // word - Version2\n        fmt += 4; // dword - header size\n        m_raData.flavor = AV_RB16(fmt);\n        fmt += 2; // word - codec flavor\n        m_raData.coded_frame_size = AV_RB32(fmt);\n        fmt += 4;  // dword - coded frame size\n        fmt += 12; // byte[12] - unknown\n        m_raData.sub_packet_h = AV_RB16(fmt);\n        fmt += 2; // word - sub packet h\n        m_raData.audio_framesize = m_pAVCtx->block_align = AV_RB16(fmt);\n        fmt += 2; // word - frame size\n        m_raData.sub_packet_size = AV_RB16(fmt);\n        fmt += 2; // word - subpacket size\n        fmt += 2; // word - unknown\n        // 6 Unknown bytes in ver 5\n        if (version == 5)\n            fmt += 6;\n        // Audio format block\n        fmt += 8;\n        // Tag info in v4\n        if (version == 4)\n        {\n            int len = *fmt++;\n            m_raData.deint_id = AV_RB32(fmt);\n            fmt += len;\n            len = *fmt++;\n            fmt += len;\n        }\n        else if (version == 5)\n        {\n            m_raData.deint_id = AV_RB32(fmt);\n            fmt += 4;\n            fmt += 4;\n        }\n        fmt += 3;\n        if (version == 5)\n            fmt++;\n\n        size_t ra_extralen = min((size_t)((extra + extralen) - (fmt + 4)), AV_RB32(fmt));\n        if (ra_extralen > 0)\n        {\n            m_pAVCtx->extradata_size = (int)ra_extralen;\n            m_pAVCtx->extradata = (uint8_t *)av_mallocz(ra_extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n            memcpy(m_pAVCtx->extradata, fmt + 4, ra_extralen);\n        }\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 10, L\"Unknown RealAudio Header version: %d\", version));\n        return VFW_E_UNSUPPORTED_AUDIO;\n    }\n\n    return S_OK;\n}\n\n// Gets a sample from the buffer for processing\n// The sample is returned as a floating point, with either single or double precision, depending on the template type\n// DO NOT USE WITH AN INTEGER TYPE - only double and float are allowed\ntemplate <class T> T get_sample_from_buffer(const BYTE *const pBuffer, LAVAudioSampleFormat sfFormat)\n{\n    T fSample = 0.0;\n    switch (sfFormat)\n    {\n    case SampleFormat_U8:\n        fSample = (T)(*(uint8_t *)pBuffer);\n        fSample = (fSample + INT8_MIN) / INT8_MAX;\n        break;\n    case SampleFormat_16:\n        fSample = (T)(*(int16_t *)pBuffer);\n        fSample /= INT16_MAX;\n        break;\n    case SampleFormat_24:\n        fSample += pBuffer[0] << 8;\n        fSample += pBuffer[1] << 16;\n        fSample += pBuffer[2] << 24;\n        fSample /= INT32_MAX;\n        break;\n    case SampleFormat_32:\n        fSample = (T)(*(int32_t *)pBuffer);\n        fSample /= INT32_MAX;\n        break;\n    case SampleFormat_FP32: fSample = (T) * (float *)pBuffer; break;\n    }\n    return fSample;\n}\n\n// This function calculates the Root mean square (RMS) of all samples in the buffer,\n// converts the result into a reference dB value, and adds it to the volume floating average\nvoid CLAVAudio::UpdateVolumeStats(const BufferDetails &buffer)\n{\n    const BYTE bSampleSize = get_byte_per_sample(buffer.sfFormat);\n    const DWORD dwSamplesPerChannel = buffer.nSamples;\n    const BYTE *pBuffer = buffer.bBuffer->Ptr();\n    float *const fChAvg = (float *)calloc(buffer.layout.nb_channels, sizeof(float));\n    for (DWORD i = 0; i < dwSamplesPerChannel; ++i)\n    {\n        for (WORD ch = 0; ch < buffer.layout.nb_channels; ++ch)\n        {\n            const float fSample = get_sample_from_buffer<float>(pBuffer, buffer.sfFormat);\n            fChAvg[ch] += fSample * fSample;\n            pBuffer += bSampleSize;\n        }\n    }\n\n    for (int ch = 0; ch < min(buffer.layout.nb_channels, MAX_VOLUME_STAT_CHANNEL); ++ch)\n    {\n        if (fChAvg[ch] > FLT_EPSILON)\n        {\n            const float fAvgSqrt = sqrtf(fChAvg[ch] / dwSamplesPerChannel);\n            const float fDb = 20.0f * log10f(fAvgSqrt);\n            m_faVolume[ch].Sample(fDb);\n        }\n        else\n        {\n            m_faVolume[ch].Sample(-100.0f);\n        }\n    }\n    free(fChAvg);\n}\n\n#define MAX_SPEAKER_LAYOUT 18\n\n// Get the channel index for the given speaker flag\n// First channel starts at index 0\nWORD get_channel_from_flag(DWORD dwMask, DWORD dwFlag)\n{\n    WORD nChannel = 0;\n    for (int i = 0; i < MAX_SPEAKER_LAYOUT; i++)\n    {\n        DWORD flag = 1 << i;\n        if (dwMask & flag)\n        {\n            if (dwFlag == flag)\n                break;\n            else\n                nChannel++;\n        }\n    }\n    return nChannel;\n}\n\n// Get the speaker flag for the given channel in the mask\n// First channel starts at index 0\nDWORD get_flag_from_channel(DWORD dwMask, WORD wChannel)\n{\n    WORD nChannel = 0;\n    for (int i = 0; i < MAX_SPEAKER_LAYOUT; i++)\n    {\n        DWORD flag = 1 << i;\n        if (dwMask & flag)\n        {\n            if (nChannel == wChannel)\n                return flag;\n            else\n                nChannel++;\n        }\n    }\n    return 0;\n}\n\nstatic const char *channel_short_descs[] = {\"L\",  \"R\",  \"C\",  \"LFE\", \"BL\",  \"BR\",  \"FLC\", \"FRC\", \"BC\",\n                                            \"SL\", \"SR\", \"TC\", \"TFL\", \"TFC\", \"TFR\", \"TBL\", \"TBC\", \"TBR\"};\n\nconst char *get_channel_desc(DWORD dwFlag)\n{\n    for (int i = 0; i < MAX_SPEAKER_LAYOUT; i++)\n    {\n        DWORD flag = 1 << i;\n        if (flag & dwFlag)\n        {\n            return channel_short_descs[i];\n        }\n    }\n    return \"-\";\n}\n\n// Strings will be filled in eventually.\n// AV_CODEC_ID_NONE means there is some special handling going on.\n// Order is Important, has to be the same as the CC Enum\n// Also, the order is used for storage in the Registry\n// clang-format off\nstatic codec_config_t m_codec_config[] = {\n  { 2, { AV_CODEC_ID_AAC, AV_CODEC_ID_AAC_LATM }},       // CC_AAC\n  { 1, { AV_CODEC_ID_AC3 }},                          // CC_AC3\n  { 1, { AV_CODEC_ID_EAC3 }},                         // CC_EAC3\n  { 1, { AV_CODEC_ID_DTS }, \"dts\", \"DTS Coherent Acoustics (DTS, DTS-HD)\"},                          // CC_DTS\n  { 2, { AV_CODEC_ID_MP2, AV_CODEC_ID_MP1 }},            // CC_MP2\n  { 1, { AV_CODEC_ID_MP3 }},                          // CC_MP3\n  { 2, { AV_CODEC_ID_TRUEHD, AV_CODEC_ID_MLP }},         // CC_TRUEHD\n  { 1, { AV_CODEC_ID_FLAC }},                         // CC_FLAC\n  { 1, { AV_CODEC_ID_VORBIS }},                       // CC_VORBIS\n  { 2, { AV_CODEC_ID_PCM_BLURAY, AV_CODEC_ID_PCM_DVD }, \"lpcm\", \"Linear PCM (BluRay & DVD)\"}, // CC_LPCM\n  { 1, { AV_CODEC_ID_NONE }, \"pcm\", \"Raw PCM Types (including QT PCM)\" }, // CC_LPCM\n  { 1, { AV_CODEC_ID_WAVPACK }},                      // CC_WAVPACK\n  { 1, { AV_CODEC_ID_TTA }},                          // CC_TTA\n  { 2, { AV_CODEC_ID_WMAV2, AV_CODEC_ID_WMAV1 }, \"wma\", \"Windows Media Audio 1/2\"}, // CC_WMA2\n  { 1, { AV_CODEC_ID_WMAPRO }},                       // CC_WMAPRO\n  { 1, { AV_CODEC_ID_COOK }},                         // CC_COOK\n  { 4, { AV_CODEC_ID_SIPR, AV_CODEC_ID_RA_144, AV_CODEC_ID_RA_288, AV_CODEC_ID_RALF }, \"realaudio\", \"Real Audio (SIPR, RALF, 14.4 28.8)\" }, // CC_REAL\n  { 1, { AV_CODEC_ID_WMALOSSLESS }},                  // CC_WMALL\n  { 1, { AV_CODEC_ID_ALAC }},                         // CC_ALAC\n  { 1, { AV_CODEC_ID_OPUS }, \"opus\", \"Opus Audio Codec\"}, // CC_OPUS\n  { 2, { AV_CODEC_ID_AMR_NB, AV_CODEC_ID_AMR_WB }, \"amr\", \"AMR-NB/WB (Adaptive Multi-Rate NarrowBand/WideBand)\" }, // CC_AMR\n  { 1, { AV_CODEC_ID_NELLYMOSER }},                   // CC_Nellymoser\n  { 4, { AV_CODEC_ID_PCM_ALAW, AV_CODEC_ID_PCM_MULAW, AV_CODEC_ID_GSM_MS, AV_CODEC_ID_ADPCM_MS }, \"mspcm\", \"Microsoft PCM (A-Law, muLaw, MS-GSM, MS ADPCM)\" }, // CC_MSPCM\n  { 1, { AV_CODEC_ID_TRUESPEECH }},                   // CC_Truespeech\n  { 1, { AV_CODEC_ID_TAK }},                          // CC_TAK\n  { 3, { AV_CODEC_ID_ATRAC1, AV_CODEC_ID_ATRAC3, AV_CODEC_ID_ATRAC3P }, \"atrac\", \"ATRAC (Adaptive TRansform Acoustic Coding)\"}, // CC_ATRAC\n  { 3, { AV_CODEC_ID_ADPCM_IMA_WAV, AV_CODEC_ID_ADPCM_G726, AV_CODEC_ID_G729 }, \"adpcm\", \"ADPCM (adaptive differential pcm)\"},  // CC_ADPCM\n  { 1, { AV_CODEC_ID_IMC }},                          // CC_IMC\n};\n// clang-format on\n\nconst codec_config_t *get_codec_config(LAVAudioCodec codec)\n{\n    codec_config_t *config = &m_codec_config[codec];\n\n    const AVCodec *avcodec = avcodec_find_decoder(config->codecs[0]);\n    if (avcodec)\n    {\n        if (!config->name)\n        {\n            config->name = avcodec->name;\n        }\n\n        if (!config->description)\n        {\n            config->description = avcodec->long_name;\n        }\n    }\n\n    return &m_codec_config[codec];\n}\n\nstatic LAVAudioSampleFormat sampleFormatMapping[5][5] = {\n    {SampleFormat_16, SampleFormat_24, SampleFormat_FP32, SampleFormat_32, SampleFormat_U8}, // SampleFormat_16\n    {SampleFormat_24, SampleFormat_FP32, SampleFormat_32, SampleFormat_16, SampleFormat_U8}, // SampleFormat_24\n    {SampleFormat_32, SampleFormat_FP32, SampleFormat_24, SampleFormat_16, SampleFormat_U8}, // SampleFormat_32\n    {SampleFormat_U8, SampleFormat_16, SampleFormat_24, SampleFormat_FP32, SampleFormat_32}, // SampleFormat_U8\n    {SampleFormat_FP32, SampleFormat_24, SampleFormat_32, SampleFormat_16, SampleFormat_U8}, // SampleFormat_FP32\n};\n\nLAVAudioSampleFormat CLAVAudio::GetBestAvailableSampleFormat(LAVAudioSampleFormat inFormat, int *bits, BOOL bNoFallback)\n{\n    ASSERT(inFormat >= 0 && inFormat < SampleFormat_Bitstream);\n\n    if (m_FallbackFormat != SampleFormat_None && !bNoFallback)\n        return m_FallbackFormat;\n\n    LAVAudioSampleFormat outFormat = sampleFormatMapping[inFormat][0];\n    for (int i = 0; i < 5; i++)\n    {\n        if (GetSampleFormat(sampleFormatMapping[inFormat][i]))\n        {\n            outFormat = sampleFormatMapping[inFormat][i];\n            break;\n        }\n    }\n\n    if (bits && outFormat != inFormat)\n        *bits = get_byte_per_sample(outFormat) << 3;\n\n    return outFormat;\n}\n\n// Copy of ff_spdif_bswap_buf16, which sadly is a private symbol\nvoid lav_spdif_bswap_buf16(uint16_t *dst, const uint16_t *src, int w)\n{\n    int i;\n\n    for (i = 0; i + 8 <= w; i += 8)\n    {\n        dst[i + 0] = av_bswap16(src[i + 0]);\n        dst[i + 1] = av_bswap16(src[i + 1]);\n        dst[i + 2] = av_bswap16(src[i + 2]);\n        dst[i + 3] = av_bswap16(src[i + 3]);\n        dst[i + 4] = av_bswap16(src[i + 4]);\n        dst[i + 5] = av_bswap16(src[i + 5]);\n        dst[i + 6] = av_bswap16(src[i + 6]);\n        dst[i + 7] = av_bswap16(src[i + 7]);\n    }\n    for (; i < w; i++)\n        dst[i + 0] = av_bswap16(src[i + 0]);\n}\n"
  },
  {
    "path": "decoder/LAVAudio/Media.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#define DBL_SECOND_MULT 10000000.0\n#define RT_SECOND_MULT 10000000LL\n\n#define INT24_MAX 8388607i32\n#define INT24_MIN (-8388607i32 - 1)\n\n#define LAV_CH_LAYOUT_5POINT1_BC (AV_CH_LAYOUT_SURROUND | AV_CH_LOW_FREQUENCY | AV_CH_BACK_CENTER)\n#define LAV_CH_LAYOUT_5POINT1_WIDE \\\n    (AV_CH_LAYOUT_SURROUND | AV_CH_LOW_FREQUENCY | AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER)\n#define LAV_CH_LAYOUT_7POINT1_EXTRAWIDE (LAV_CH_LAYOUT_5POINT1_WIDE | AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT)\n\nstruct scmap_t\n{\n    WORD nChannels;\n    DWORD dwChannelMask;\n};\n\n#define MAX_NUM_CC_CODECS 5\n\nstruct codec_config_t\n{\n    int nCodecs;\n    AVCodecID codecs[MAX_NUM_CC_CODECS];\n    const char *name;\n    const char *description;\n};\n\nconst codec_config_t *get_codec_config(LAVAudioCodec codec);\n\nAVCodecID FindCodecId(const CMediaType *mt);\n\nconst char *find_codec_override(AVCodecID codec);\n\nDWORD get_channel_mask(int num_channels);\n\nconst char *get_sample_format_desc(LAVAudioSampleFormat sfFormat);\nconst char *get_sample_format_desc(CMediaType &mt);\n\nBYTE get_byte_per_sample(LAVAudioSampleFormat sfFormat);\n\nLAVAudioSampleFormat get_lav_sample_fmt(AVSampleFormat sample_fmt, int bits = 0);\nAVSampleFormat get_ff_sample_fmt(LAVAudioSampleFormat sample_fmt);\n\nWORD get_channel_from_flag(DWORD dwMask, DWORD dwFlag);\nDWORD get_flag_from_channel(DWORD dwMask, WORD wChannel);\nconst char *get_channel_desc(DWORD dwFlag);\n\n// Gets a sample from the buffer for processing\n// The sample is returned as a floating point, with either single or double precision, depending on the template type\n// DO NOT USE WITH AN INTEGER TYPE - only double and float are allowed\ntemplate <class T> T get_sample_from_buffer(const BYTE *pBuffer, LAVAudioSampleFormat sfFormat);\n\nvoid lav_spdif_bswap_buf16(uint16_t *dst, const uint16_t *src, int w);\n"
  },
  {
    "path": "decoder/LAVAudio/PostProcessor.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"PostProcessor.h\"\n#include \"LAVAudio.h\"\n#include \"Media.h\"\n\nextern \"C\"\n{\n#include \"libavutil/intreadwrite.h\"\n};\n\n// PCM Volume Adjustment Factors, both for integer and float math\n// entries start at 2 channel mixing, half volume\nstatic int pcm_volume_adjust_integer[7] = {362, 443, 512, 572, 627, 677, 724};\n\nstatic float pcm_volume_adjust_float[7] = {1.41421356f, 1.73205081f, 2.00000000f, 2.23606798f,\n                                           2.44948974f, 2.64575131f, 2.82842712f};\n\n// SCALE_CA helper macro for SampleCopyAdjust\n#define SCALE_CA(sample, iFactor, factor) \\\n    {                                     \\\n        if (iFactor > 0)                  \\\n        {                                 \\\n            sample *= factor;             \\\n            sample >>= 8;                 \\\n        }                                 \\\n        else                              \\\n        {                                 \\\n            sample <<= 8;                 \\\n            sample /= factor;             \\\n        }                                 \\\n    }\n\n//\n// Helper Function that reads one sample from pIn, applys the scale specified by iFactor, and writes it to pOut\n//\nstatic inline void SampleCopyAdjust(BYTE *pOut, const BYTE *pIn, int iFactor, LAVAudioSampleFormat sfSampleFormat)\n{\n    ASSERT(abs(iFactor) > 1 && abs(iFactor) <= 8);\n    const int factorIndex = abs(iFactor) - 2;\n\n    switch (sfSampleFormat)\n    {\n    case SampleFormat_U8: {\n        uint8_t *pOutSample = pOut;\n        int32_t sample = *pIn + INT8_MIN;\n        SCALE_CA(sample, iFactor, pcm_volume_adjust_integer[factorIndex]);\n        *pOutSample = av_clip_uint8(sample - INT8_MIN);\n    }\n    break;\n    case SampleFormat_16: {\n        int16_t *pOutSample = (int16_t *)pOut;\n        int32_t sample = *((int16_t *)pIn);\n        SCALE_CA(sample, iFactor, pcm_volume_adjust_integer[factorIndex]);\n        *pOutSample = av_clip_int16(sample);\n    }\n    break;\n    case SampleFormat_24: {\n        int32_t sample = (pIn[0] << 8) + (pIn[1] << 16) + (pIn[2] << 24);\n        sample >>= 8;\n        SCALE_CA(sample, iFactor, pcm_volume_adjust_integer[factorIndex]);\n        sample = av_clip(sample, INT24_MIN, INT24_MAX);\n        pOut[0] = sample & 0xff;\n        pOut[1] = (sample >> 8) & 0xff;\n        pOut[2] = (sample >> 16) & 0xff;\n    }\n    break;\n    case SampleFormat_32: {\n        int32_t *pOutSample = (int32_t *)pOut;\n        int64_t sample = *((int32_t *)pIn);\n        SCALE_CA(sample, iFactor, pcm_volume_adjust_integer[factorIndex]);\n        *pOutSample = av_clipl_int32(sample);\n    }\n    break;\n    case SampleFormat_FP32: {\n        float *pOutSample = (float *)pOut;\n        float sample = *((float *)pIn);\n        if (iFactor > 0)\n        {\n            sample *= pcm_volume_adjust_float[factorIndex];\n        }\n        else\n        {\n            sample /= pcm_volume_adjust_float[factorIndex];\n        }\n        *pOutSample = av_clipf(sample, -1.0f, 1.0f);\n    }\n    break;\n    default: ASSERT(0); break;\n    }\n}\n\n//\n// Writes one sample of silence into the buffer\n//\nstatic inline void Silence(BYTE *pBuffer, LAVAudioSampleFormat sfSampleFormat)\n{\n    switch (sfSampleFormat)\n    {\n    case SampleFormat_16:\n    case SampleFormat_24:\n    case SampleFormat_32:\n    case SampleFormat_FP32: memset(pBuffer, 0, get_byte_per_sample(sfSampleFormat)); break;\n    case SampleFormat_U8: *pBuffer = 128U; break;\n    default: ASSERT(0);\n    }\n}\n\n//\n// Extended Channel Remapping Processor\n//\n// This function can process a PCM buffer of any sample format, and remap the channels\n// into any arbitrary layout and channel count.\n//\n// The samples are copied byte-by-byte, without any conversion or loss.\n//\n// The ExtendedChannelMap is assumed to always have at least uOutChannels valid entries.\n// Its layout is in output format:\n//      Map[0] is the first output channel, and should contain the index in the source stream (or -1 for silence)\n//      Map[1] is the second output channel\n//\n// Source channels can be applied multiple times to the Destination, but multiple Source channels cannot be merged into one channel.\n// Note that when copying one source channel into multiple destinations, you always want to reduce its volume.\n// You can either do this in a second step, or use the factor documented below\n//\n// Examples:\n// 5.1 Input Buffer, following map will extract the Center channel, and return it as Mono:\n// uOutChannels == 1; map = {2}\n//\n// Mono Input Buffer, Convert to Stereo\n// uOutChannels == 2; map = {0, 0}\n//\n// Additionally, a factor can be applied to all PCM samples\n//\n// For optimization, the factor cannot be freely specified.\n// Factors -1, 0, 1 are ignored.\n// A Factor of 2 doubles the volume, 3 trippled, etc.\n// A Factor of -2 will produce half volume, -3 one third, etc.\n// The limit is a factor of 8/-8\n//\n// Otherwise, see ChannelMapping\nHRESULT ExtendedChannelMapping(BufferDetails *pcm, const unsigned uOutChannels, const ExtendedChannelMap extMap)\n{\n#ifdef DEBUG\n    ASSERT(pcm && pcm->bBuffer);\n    ASSERT(uOutChannels > 0 && uOutChannels <= 8);\n    for (unsigned idx = 0; idx < uOutChannels; ++idx)\n    {\n        ASSERT(extMap[idx].idx >= -1 && extMap[idx].idx < pcm->layout.nb_channels);\n    }\n#endif\n    // Sample Size\n    const unsigned uSampleSize = get_byte_per_sample(pcm->sfFormat);\n\n    // New Output Buffer\n    GrowableArray<BYTE> *out = new GrowableArray<BYTE>();\n    out->SetSize(uOutChannels * pcm->nSamples * uSampleSize);\n\n    const BYTE *pIn = pcm->bBuffer->Ptr();\n    BYTE *pOut = out->Ptr();\n\n    for (unsigned i = 0; i < pcm->nSamples; ++i)\n    {\n        for (unsigned ch = 0; ch < uOutChannels; ++ch)\n        {\n            if (extMap[ch].idx >= 0)\n            {\n                if (!extMap[ch].factor || abs(extMap[ch].factor) == 1)\n                    memcpy(pOut, pIn + (extMap[ch].idx * uSampleSize), uSampleSize);\n                else\n                    SampleCopyAdjust(pOut, pIn + (extMap[ch].idx * uSampleSize), extMap[ch].factor, pcm->sfFormat);\n            }\n            else\n                Silence(pOut, pcm->sfFormat);\n            pOut += uSampleSize;\n        }\n        pIn += uSampleSize * pcm->layout.nb_channels;\n    }\n\n    // Apply changes to buffer\n    delete pcm->bBuffer;\n    pcm->bBuffer = out;\n    av_channel_layout_uninit(&pcm->layout);\n    pcm->layout.order = AV_CHANNEL_ORDER_UNSPEC;\n    pcm->layout.nb_channels = uOutChannels;\n\n    return S_OK;\n}\n\n#define CHL_CONTAINS_ALL(l, m) (((l) & (m)) == (m))\n#define CHL_ALL_OR_NONE(l, m) (((l) & (m)) == (m) || ((l) & (m)) == 0)\n\nHRESULT CLAVAudio::CheckChannelLayoutConformity(AVChannelLayout * layout)\n{\n    int channels = layout->nb_channels;\n\n    if (layout->order != AV_CHANNEL_ORDER_NATIVE)\n    {\n        DbgLog((LOG_ERROR, 10,\n                L\"::CheckChannelLayoutConformity(): Only native channel orders are supported\"));\n        goto noprocessing;\n    }\n\n    if (layout->u.mask > INT32_MAX)\n    {\n        DbgLog((LOG_ERROR, 10,\n                L\"::CheckChannelLayoutConformity(): Layout channels above 32-bit are not handled (mask: 0x%llx)\",\n                layout->u.mask));\n        goto noprocessing;\n    }\n\n    DWORD dwMask = (DWORD)layout->u.mask;\n\n    // We require multi-channel and at least containing stereo\n    if (!CHL_CONTAINS_ALL(dwMask, AV_CH_LAYOUT_STEREO) || channels == 2)\n        goto noprocessing;\n\n    // We do not know what to do with \"top\" channels\n    if (dwMask & (AV_CH_TOP_CENTER | AV_CH_TOP_FRONT_LEFT | AV_CH_TOP_FRONT_CENTER | AV_CH_TOP_FRONT_RIGHT |\n                    AV_CH_TOP_BACK_LEFT | AV_CH_TOP_BACK_CENTER | AV_CH_TOP_BACK_RIGHT))\n    {\n        DbgLog((LOG_ERROR, 10,\n                L\"::CheckChannelLayoutConformity(): Layout with top channels is not supported (mask: 0x%x)\", dwMask));\n        goto noprocessing;\n    }\n\n    // We need either both surround channels, or none. One of a type is not supported\n    if (!CHL_ALL_OR_NONE(dwMask, AV_CH_BACK_LEFT | AV_CH_BACK_RIGHT) ||\n        !CHL_ALL_OR_NONE(dwMask, AV_CH_SIDE_LEFT | AV_CH_SIDE_RIGHT) ||\n        !CHL_ALL_OR_NONE(dwMask, AV_CH_FRONT_LEFT_OF_CENTER | AV_CH_FRONT_RIGHT_OF_CENTER))\n    {\n        DbgLog(\n            (LOG_ERROR, 10,\n             L\"::CheckChannelLayoutConformity(): Layout with only one surround channel is not supported (mask: 0x%x)\",\n             dwMask));\n        goto noprocessing;\n    }\n\n    // No need to process full 5.1/6.1 layouts, or any 8 channel layouts\n    if (dwMask == AV_CH_LAYOUT_5POINT1 || dwMask == AV_CH_LAYOUT_5POINT1_BACK || dwMask == AV_CH_LAYOUT_6POINT1_BACK ||\n        channels == 8)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::CheckChannelLayoutConformity(): Layout is already a default layout (mask: 0x%x)\",\n                dwMask));\n        goto noprocessing;\n    }\n\n    // Check 5.1 channels\n    if (CHL_CONTAINS_ALL(AV_CH_LAYOUT_5POINT1, dwMask)            /* 5.1 with side channels */\n        || CHL_CONTAINS_ALL(AV_CH_LAYOUT_5POINT1_BACK, dwMask)    /* 5.1 with back channels */\n        || CHL_CONTAINS_ALL(LAV_CH_LAYOUT_5POINT1_WIDE, dwMask)  /* 5.1 with side-front channels */\n        || CHL_CONTAINS_ALL(LAV_CH_LAYOUT_5POINT1_BC, dwMask))  /* 3/1/x layouts, front channels with a back center */\n        return Create51Conformity(dwMask);\n\n    // Check 6.1 channels (5.1 layouts + Back Center)\n    if (CHL_CONTAINS_ALL(AV_CH_LAYOUT_6POINT1, dwMask)           /* 6.1 with side channels */\n        || CHL_CONTAINS_ALL(AV_CH_LAYOUT_6POINT1_BACK, dwMask) /* 6.1 with back channels */\n        || CHL_CONTAINS_ALL(LAV_CH_LAYOUT_5POINT1_WIDE | AV_CH_BACK_CENTER, dwMask)) /* 6.1 with side-front channels */\n        return Create61Conformity(dwMask);\n\n    // Check 7.1 channels\n    if (CHL_CONTAINS_ALL(AV_CH_LAYOUT_7POINT1, dwMask)                  /* 7.1 with side+back channels */\n        || CHL_CONTAINS_ALL(AV_CH_LAYOUT_7POINT1_WIDE, dwMask)          /* 7.1 with front-side+back channels */\n        || CHL_CONTAINS_ALL(LAV_CH_LAYOUT_7POINT1_EXTRAWIDE, dwMask)) /* 7.1 with front-side+side channels */\n        return Create71Conformity(dwMask);\n\nnoprocessing:\n    m_bChannelMappingRequired = FALSE;\n    return S_FALSE;\n}\n\nHRESULT CLAVAudio::Create51Conformity(DWORD dwLayout)\n{\n    DbgLog((LOG_TRACE, 10, L\"::Create51Conformity(): Creating 5.1 default layout (mask: 0x%x)\", dwLayout));\n    int ch = 0;\n    ExtChMapClear(&m_ChannelMap);\n    // All layouts we support have to contain L/R\n    ExtChMapSet(&m_ChannelMap, 0, ch++, 0);\n    ExtChMapSet(&m_ChannelMap, 1, ch++, 0);\n    // Center channel\n    if (dwLayout & AV_CH_FRONT_CENTER)\n        ExtChMapSet(&m_ChannelMap, 2, ch++, 0);\n    // LFE\n    if (dwLayout & AV_CH_LOW_FREQUENCY)\n        ExtChMapSet(&m_ChannelMap, 3, ch++, 0);\n    // Back/Side\n    if (dwLayout & (AV_CH_SIDE_LEFT | AV_CH_BACK_LEFT | AV_CH_FRONT_LEFT_OF_CENTER))\n    {\n        ExtChMapSet(&m_ChannelMap, 4, ch++, 0);\n        ExtChMapSet(&m_ChannelMap, 5, ch++, 0);\n        // Back Center\n    }\n    else if (dwLayout & AV_CH_BACK_CENTER)\n    {\n        ExtChMapSet(&m_ChannelMap, 4, ch, -2);\n        ExtChMapSet(&m_ChannelMap, 5, ch++, -2);\n    }\n    m_bChannelMappingRequired = TRUE;\n    av_channel_layout_uninit(&m_ChannelMapOutputLayout);\n    av_channel_layout_from_mask(&m_ChannelMapOutputLayout, AV_CH_LAYOUT_5POINT1);\n    return S_OK;\n}\n\nHRESULT CLAVAudio::Create61Conformity(DWORD dwLayout)\n{\n    if (m_settings.Expand61)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::Create61Conformity(): Expanding to 7.1\"));\n        return Create71Conformity(dwLayout);\n    }\n\n    DbgLog((LOG_TRACE, 10, L\"::Create61Conformity(): Creating 6.1 default layout (mask: 0x%x)\", dwLayout));\n    int ch = 0;\n    ExtChMapClear(&m_ChannelMap);\n    // All layouts we support have to contain L/R\n    ExtChMapSet(&m_ChannelMap, 0, ch++, 0);\n    ExtChMapSet(&m_ChannelMap, 1, ch++, 0);\n    // Center channel\n    if (dwLayout & AV_CH_FRONT_CENTER)\n        ExtChMapSet(&m_ChannelMap, 2, ch++, 0);\n    // LFE\n    if (dwLayout & AV_CH_LOW_FREQUENCY)\n        ExtChMapSet(&m_ChannelMap, 3, ch++, 0);\n    // Back channels, if before BC\n    if (dwLayout & (AV_CH_BACK_LEFT | AV_CH_FRONT_LEFT_OF_CENTER))\n    {\n        DbgLog((LOG_TRACE, 10, L\"::Create61Conformity(): Using surround channels *before* BC\"));\n        ExtChMapSet(&m_ChannelMap, 4, ch++, 0);\n        ExtChMapSet(&m_ChannelMap, 5, ch++, 0);\n    }\n    // Back Center\n    if (dwLayout & AV_CH_BACK_CENTER)\n        ExtChMapSet(&m_ChannelMap, 6, ch++, 0);\n    // Back channels, if after BC\n    if (dwLayout & AV_CH_SIDE_LEFT)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::Create61Conformity(): Using surround channels *after* BC\"));\n        ExtChMapSet(&m_ChannelMap, 4, ch++, 0);\n        ExtChMapSet(&m_ChannelMap, 5, ch++, 0);\n    }\n\n    m_bChannelMappingRequired = TRUE;\n    av_channel_layout_uninit(&m_ChannelMapOutputLayout);\n    av_channel_layout_from_mask(&m_ChannelMapOutputLayout, AV_CH_LAYOUT_6POINT1_BACK);\n    return S_OK;\n}\n\nHRESULT CLAVAudio::Create71Conformity(DWORD dwLayout)\n{\n    DbgLog((LOG_TRACE, 10, L\"::Create71Conformity(): Creating 7.1 default layout (mask: 0x%x)\", dwLayout));\n    int ch = 0;\n    ExtChMapClear(&m_ChannelMap);\n    // All layouts we support have to contain L/R\n    ExtChMapSet(&m_ChannelMap, 0, ch++, 0);\n    ExtChMapSet(&m_ChannelMap, 1, ch++, 0);\n    // Center channel\n    if (dwLayout & AV_CH_FRONT_CENTER)\n        ExtChMapSet(&m_ChannelMap, 2, ch++, 0);\n    // LFE\n    if (dwLayout & AV_CH_LOW_FREQUENCY)\n        ExtChMapSet(&m_ChannelMap, 3, ch++, 0);\n    // Back channels\n    if (dwLayout & AV_CH_BACK_CENTER)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::Create71Conformity(): Usign BC to fill back channels\"));\n        if (dwLayout & AV_CH_SIDE_LEFT)\n        {\n            DbgLog((LOG_TRACE, 10, L\"::Create71Conformity(): Using BC before side-surround channels\"));\n            ExtChMapSet(&m_ChannelMap, 4, ch, -2);\n            ExtChMapSet(&m_ChannelMap, 5, ch++, -2);\n            ExtChMapSet(&m_ChannelMap, 6, ch++, 0);\n            ExtChMapSet(&m_ChannelMap, 7, ch++, 0);\n        }\n        else\n        {\n            DbgLog((LOG_TRACE, 10, L\"::Create71Conformity(): Using BC after side-surround channels\"));\n            ExtChMapSet(&m_ChannelMap, 6, ch++, 0);\n            ExtChMapSet(&m_ChannelMap, 7, ch++, 0);\n            ExtChMapSet(&m_ChannelMap, 4, ch, -2);\n            ExtChMapSet(&m_ChannelMap, 5, ch++, -2);\n        }\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 10, L\"::Create71Conformity(): Using original 4 surround channels\"));\n        ExtChMapSet(&m_ChannelMap, 4, ch++, 0);\n        ExtChMapSet(&m_ChannelMap, 5, ch++, 0);\n        ExtChMapSet(&m_ChannelMap, 6, ch++, 0);\n        ExtChMapSet(&m_ChannelMap, 7, ch++, 0);\n    }\n\n    m_bChannelMappingRequired = TRUE;\n    av_channel_layout_uninit(&m_ChannelMapOutputLayout);\n    av_channel_layout_from_mask(&m_ChannelMapOutputLayout, AV_CH_LAYOUT_7POINT1);\n    return S_OK;\n}\n\nHRESULT CLAVAudio::PadTo32(BufferDetails *buffer)\n{\n    ASSERT(buffer->sfFormat == SampleFormat_24);\n\n    const DWORD size = (buffer->nSamples * buffer->layout.nb_channels) * 4;\n    GrowableArray<BYTE> *pcmOut = new GrowableArray<BYTE>();\n    pcmOut->SetSize(size);\n\n    const BYTE *pDataIn = buffer->bBuffer->Ptr();\n    BYTE *pDataOut = pcmOut->Ptr();\n\n    for (unsigned int i = 0; i < buffer->nSamples; ++i)\n    {\n        for (int ch = 0; ch < buffer->layout.nb_channels; ++ch)\n        {\n            AV_WL32(pDataOut, AV_RL24(pDataIn) << 8);\n            pDataOut += 4;\n            pDataIn += 3;\n        }\n    }\n    delete buffer->bBuffer;\n    buffer->bBuffer = pcmOut;\n    buffer->sfFormat = SampleFormat_32;\n    buffer->wBitsPerSample = 24;\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::Truncate32Buffer(BufferDetails *buffer)\n{\n    ASSERT(buffer->sfFormat == SampleFormat_32 && buffer->wBitsPerSample <= 24);\n\n    // Determine the bytes per sample to keep. Cut a 16-bit sample to 24 if 16-bit is disabled for some reason\n    const int bytes_per_sample = buffer->wBitsPerSample <= 16 && GetSampleFormat(SampleFormat_16) ? 2 : 3;\n    if (bytes_per_sample == 3 && !GetSampleFormat(SampleFormat_24))\n        return S_FALSE;\n\n    const int skip = 4 - bytes_per_sample;\n    const DWORD size = (buffer->nSamples * buffer->layout.nb_channels) * bytes_per_sample;\n    GrowableArray<BYTE> *pcmOut = new GrowableArray<BYTE>();\n    pcmOut->SetSize(size);\n\n    const BYTE *pDataIn = buffer->bBuffer->Ptr();\n    BYTE *pDataOut = pcmOut->Ptr();\n\n    pDataIn += skip;\n    for (unsigned int i = 0; i < buffer->nSamples; ++i)\n    {\n        for (int ch = 0; ch < buffer->layout.nb_channels; ++ch)\n        {\n            memcpy(pDataOut, pDataIn, bytes_per_sample);\n            pDataOut += bytes_per_sample;\n            pDataIn += 4;\n        }\n    }\n\n    delete buffer->bBuffer;\n    buffer->bBuffer = pcmOut;\n    buffer->sfFormat = bytes_per_sample == 3 ? SampleFormat_24 : SampleFormat_16;\n\n    return S_OK;\n}\n\nHRESULT CLAVAudio::PerformAVRProcessing(BufferDetails *buffer)\n{\n    int ret = 0;\n\n    AVChannelLayout chMixingLayout{};\n    if (av_channel_layout_check(&m_chOverrideMixer) != 0)\n    {\n        av_channel_layout_copy(&chMixingLayout, &m_chOverrideMixer);\n    }\n    else if (m_settings.MixingEnabled)\n    {\n        av_channel_layout_from_mask(&chMixingLayout, m_settings.MixingLayout);\n    }\n    else\n    {\n        av_channel_layout_copy(&chMixingLayout, &buffer->layout);\n    }\n\n    // No mixing stereo, if the user doesn't want it\n    if (buffer->layout.nb_channels <= 2 && (m_settings.MixingFlags & LAV_MIXING_FLAG_UNTOUCHED_STEREO))\n    {\n        av_channel_layout_uninit(&chMixingLayout);\n        av_channel_layout_copy(&chMixingLayout, &buffer->layout);\n    }\n\n    LAVAudioSampleFormat outputFormat = av_channel_layout_compare(&buffer->layout, &chMixingLayout) != 0\n                                            ? GetBestAvailableSampleFormat(SampleFormat_FP32)\n                                            : GetBestAvailableSampleFormat(buffer->sfFormat);\n\n    // Short Circuit some processing\n    if (av_channel_layout_compare(&buffer->layout, &chMixingLayout) == 0 && !buffer->bPlanar)\n    {\n        if (buffer->sfFormat == SampleFormat_24 && outputFormat == SampleFormat_32)\n        {\n            PadTo32(buffer);\n            return S_OK;\n        }\n        else if (buffer->sfFormat == SampleFormat_32 && outputFormat == SampleFormat_24)\n        {\n            buffer->wBitsPerSample = 24;\n            Truncate32Buffer(buffer);\n            return S_OK;\n        }\n    }\n\n    // Sadly, we need to convert this, avresample has no 24-bit mode\n    if (buffer->sfFormat == SampleFormat_24)\n    {\n        PadTo32(buffer);\n    }\n\n    if (av_channel_layout_compare(&buffer->layout, &m_MixingInputLayout) != 0 || (!m_swrContext && !m_bAVResampleFailed) || m_bMixingSettingsChanged ||\n        av_channel_layout_compare(&m_chRemixLayout, &chMixingLayout) != 0 || outputFormat != m_sfRemixFormat ||\n        buffer->sfFormat != m_MixingInputFormat)\n    {\n        m_bAVResampleFailed = FALSE;\n        m_bMixingSettingsChanged = FALSE;\n        if (m_swrContext)\n        {\n            swr_free(&m_swrContext);\n        }\n\n        av_channel_layout_copy(&m_MixingInputLayout, &buffer->layout);\n        av_channel_layout_copy(&m_chRemixLayout, &chMixingLayout);\n\n        m_MixingInputFormat = buffer->sfFormat;\n        m_sfRemixFormat = outputFormat;\n\n        swr_alloc_set_opts2(&m_swrContext, &chMixingLayout, get_ff_sample_fmt(m_sfRemixFormat), buffer->dwSamplesPerSec,\n                               &buffer->layout, get_ff_sample_fmt(buffer->sfFormat), buffer->dwSamplesPerSec, 0, NULL);\n\n        av_opt_set_int(m_swrContext, \"dither_method\",\n                       m_settings.SampleConvertDither ? SWR_DITHER_TRIANGULAR_HIGHPASS : SWR_DITHER_NONE, 0);\n\n        // Setup mixing properties, if needed\n        if (av_channel_layout_compare(&buffer->layout, &chMixingLayout) != 0)\n        {\n            ASSERT(chMixingLayout.order == AV_CHANNEL_ORDER_NATIVE);\n\n            BOOL bNormalize = !!(m_settings.MixingFlags & LAV_MIXING_FLAG_NORMALIZE_MATRIX);\n            BOOL bClipProtection = !!(m_settings.MixingFlags & LAV_MIXING_FLAG_CLIP_PROTECTION);\n            av_opt_set_int(m_swrContext, \"clip_protection\", !bNormalize && bClipProtection, 0);\n            av_opt_set_int(m_swrContext, \"internal_sample_fmt\", AV_SAMPLE_FMT_FLTP, 0);\n\n            // setup matrix parameters\n            const double center_mix_level = (double)m_settings.MixingCenterLevel / 10000.0;\n            const double surround_mix_level = (double)m_settings.MixingSurroundLevel / 10000.0;\n            const double lfe_mix_level =\n                (double)m_settings.MixingLFELevel / 10000.0 / (chMixingLayout.u.mask == AV_CH_LAYOUT_MONO ? 1.0 : M_SQRT1_2);\n\n            av_opt_set_double(m_swrContext, \"center_mix_level\", center_mix_level, 0);\n            av_opt_set_double(m_swrContext, \"surround_mix_level\", surround_mix_level, 0);\n            av_opt_set_double(m_swrContext, \"lfe_mix_level\", lfe_mix_level, 0);\n            av_opt_set_double(m_swrContext, \"rematrix_maxval\", bNormalize ? 1.0 : 0.0, 0);\n            av_opt_set_int(m_swrContext, \"matrix_encoding\", (AVMatrixEncoding)m_settings.MixingMode, 0);\n        }\n\n        // Open Resample Context\n        ret = swr_init(m_swrContext);\n        if (ret < 0)\n        {\n            DbgLog((LOG_ERROR, 10, L\"swr_init failed\"));\n            goto setuperr;\n        }\n    }\n\n    if (!m_swrContext)\n    {\n        DbgLog((LOG_ERROR, 10, L\"swresample context missing?\"));\n        goto setuperr;\n    }\n\n    av_channel_layout_uninit(&chMixingLayout);\n\n    LAVAudioSampleFormat bufferFormat =\n        (m_sfRemixFormat == SampleFormat_24) ? SampleFormat_32 : m_sfRemixFormat; // avresample always outputs 32-bit\n\n    GrowableArray<BYTE> *pcmOut = new GrowableArray<BYTE>();\n    pcmOut->Allocate(FFALIGN(buffer->nSamples, 32) * m_chRemixLayout.nb_channels *\n                     get_byte_per_sample(bufferFormat));\n    BYTE *pOut = pcmOut->Ptr();\n\n    BYTE *pIn = buffer->bBuffer->Ptr();\n    ret = swr_convert(m_swrContext, &pOut, pcmOut->GetAllocated(), (const uint8_t **)&pIn, buffer->nSamples);\n    if (ret < 0)\n    {\n        DbgLog((LOG_ERROR, 10, L\"swr_convert failed\"));\n        delete pcmOut;\n        return S_FALSE;\n    }\n\n    delete buffer->bBuffer;\n    buffer->bBuffer = pcmOut;\n    av_channel_layout_copy(&buffer->layout, &m_chRemixLayout);\n    buffer->sfFormat = bufferFormat;\n    buffer->wBitsPerSample = get_byte_per_sample(m_sfRemixFormat) << 3;\n    buffer->bBuffer->SetSize(buffer->layout.nb_channels * buffer->nSamples * get_byte_per_sample(buffer->sfFormat));\n\n    return S_OK;\nsetuperr:\n    swr_free(&m_swrContext);\n    m_bAVResampleFailed = TRUE;\n    av_channel_layout_uninit(&chMixingLayout);\n    return E_FAIL;\n}\n\nHRESULT CLAVAudio::PostProcess(BufferDetails *buffer)\n{\n    // Validate channel mask\n    if (buffer->layout.order == AV_CHANNEL_ORDER_UNSPEC || (buffer->layout.order == AV_CHANNEL_ORDER_NATIVE && buffer->layout.u.mask == 0) || (buffer->layout.order != AV_CHANNEL_ORDER_UNSPEC && buffer->layout.order != AV_CHANNEL_ORDER_NATIVE))\n    {\n        int layout_channels = buffer->layout.nb_channels;\n\n        av_channel_layout_uninit(&buffer->layout);\n        DWORD dwMask = get_channel_mask(layout_channels);\n        if (dwMask)\n        {\n            av_channel_layout_from_mask(&buffer->layout, dwMask);\n        }\n        else\n        {\n            buffer->layout.order = AV_CHANNEL_ORDER_UNSPEC;\n            buffer->layout.nb_channels = layout_channels;\n        }\n    }\n\n    if (m_settings.SuppressFormatChanges)\n    {\n        if (av_channel_layout_check(&m_SuppressLayout) == 0)\n        {\n            av_channel_layout_copy(&m_SuppressLayout, &buffer->layout);\n        }\n        else\n        {\n            if (av_channel_layout_compare(&buffer->layout, &m_SuppressLayout) != 0 && buffer->layout.nb_channels <= m_SuppressLayout.nb_channels)\n            {\n                // only warn once\n                if (av_channel_layout_compare(&m_chOverrideMixer, &m_SuppressLayout) != 0)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"Channel Format change suppressed\"));\n                    av_channel_layout_copy(&m_chOverrideMixer, &m_SuppressLayout);\n                }\n            }\n            else if (buffer->layout.nb_channels > m_SuppressLayout.nb_channels)\n            {\n                DbgLog((LOG_TRACE, 10, L\"Channel count increased, allowing change\"));\n                av_channel_layout_uninit(&m_chOverrideMixer);\n                av_channel_layout_copy(&m_SuppressLayout, &buffer->layout);\n            }\n        }\n    }\n\n    ASSERT(buffer->layout.order == AV_CHANNEL_ORDER_NATIVE || buffer->layout.order == AV_CHANNEL_ORDER_UNSPEC);\n\n    BOOL bOverrideMixing = av_channel_layout_check(&m_chOverrideMixer) != 0;\n\n    // determine the layout we're mixing to\n    AVChannelLayout chMixingLayout{};\n    if (bOverrideMixing)\n        av_channel_layout_copy(&chMixingLayout, &m_chOverrideMixer);\n    else if (m_settings.MixingEnabled)\n        av_channel_layout_from_mask(&chMixingLayout, m_settings.MixingLayout);\n\n    BOOL bMixing = (m_settings.MixingEnabled || bOverrideMixing) &&\n                   av_channel_layout_compare(&buffer->layout, &chMixingLayout) != 0;\n    LAVAudioSampleFormat outputFormat = GetBestAvailableSampleFormat(buffer->sfFormat);\n    // Perform conversion to layout and sample format, if required\n    if (bMixing || outputFormat != buffer->sfFormat)\n    {\n        PerformAVRProcessing(buffer);\n    }\n\n    // Remap to standard configurations, if requested (not in combination with mixing)\n    if (!bMixing && m_settings.OutputStandardLayout)\n    {\n        if (av_channel_layout_compare(&buffer->layout, &m_DecodeLayoutSanified) != 0)\n        {\n            av_channel_layout_copy(&m_DecodeLayoutSanified, &buffer->layout);\n            CheckChannelLayoutConformity(&buffer->layout);\n        }\n        if (m_bChannelMappingRequired)\n        {\n            ExtendedChannelMapping(buffer, m_ChannelMapOutputLayout.nb_channels, m_ChannelMap);\n            av_channel_layout_copy(&buffer->layout, &m_ChannelMapOutputLayout);\n        }\n    }\n\n    // Map to the requested 5.1 layout\n    if (m_settings.Output51Legacy && buffer->layout.u.mask == AV_CH_LAYOUT_5POINT1)\n        buffer->layout.u.mask = AV_CH_LAYOUT_5POINT1_BACK;\n    else if (!m_settings.Output51Legacy && buffer->layout.u.mask == AV_CH_LAYOUT_5POINT1_BACK)\n        buffer->layout.u.mask = AV_CH_LAYOUT_5POINT1;\n\n    // Check if current output uses back layout, and keep it active in that case\n    if (buffer->layout.u.mask == AV_CH_LAYOUT_5POINT1)\n    {\n        WAVEFORMATEX *wfe = (WAVEFORMATEX *)m_pOutput->CurrentMediaType().Format();\n        if (wfe->wFormatTag == WAVE_FORMAT_EXTENSIBLE)\n        {\n            WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE *)wfe;\n            if (wfex->dwChannelMask == AV_CH_LAYOUT_5POINT1_BACK)\n                buffer->layout.u.mask = AV_CH_LAYOUT_5POINT1_BACK;\n        }\n    }\n\n    // Mono -> Stereo expansion\n    if (buffer->layout.nb_channels == 1 && m_settings.ExpandMono)\n    {\n        ExtendedChannelMap map = {{0, -2}, {0, -2}};\n        ExtendedChannelMapping(buffer, 2, map);\n        av_channel_layout_uninit(&buffer->layout);\n        av_channel_layout_default(&buffer->layout, 2);\n    }\n\n    // 6.1 -> 7.1 expansion\n    if (m_settings.Expand61)\n    {\n        if (buffer->layout.u.mask == AV_CH_LAYOUT_6POINT1_BACK)\n        {\n            ExtendedChannelMap map = {{0, 0}, {1, 0}, {2, 0}, {3, 0}, {6, -2}, {6, -2}, {4, 0}, {5, 0}};\n            ExtendedChannelMapping(buffer, 8, map);\n            buffer->layout.u.mask = AV_CH_LAYOUT_7POINT1;\n        }\n        else if (buffer->layout.u.mask == AV_CH_LAYOUT_6POINT1)\n        {\n            ExtendedChannelMap map = {{0, 0}, {1, 0}, {2, 0}, {3, 0}, {4, -2}, {4, -2}, {5, 0}, {6, 0}};\n            ExtendedChannelMapping(buffer, 8, map);\n            buffer->layout.u.mask = AV_CH_LAYOUT_7POINT1;\n        }\n    }\n\n    if (m_bVolumeStats)\n    {\n        UpdateVolumeStats(*buffer);\n    }\n\n    // Truncate 24-in-32 to real 24\n    if (buffer->sfFormat == SampleFormat_32 && buffer->wBitsPerSample && buffer->wBitsPerSample <= 24)\n    {\n        Truncate32Buffer(buffer);\n    }\n\n    av_channel_layout_uninit(&chMixingLayout);\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVAudio/PostProcessor.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nstruct BufferDetails;\n\ntypedef struct ExtendedChannelMap_s\n{\n    int idx;\n    int factor;\n} ExtendedChannelMap[8];\n\ninline void ExtChMapSet(ExtendedChannelMap *map, int ch, int idx, int factor)\n{\n    (*map)[ch].idx = idx;\n    (*map)[ch].factor = factor;\n}\n\ninline void ExtChMapClear(ExtendedChannelMap *map)\n{\n    for (unsigned i = 0; i < 8; ++i)\n    {\n        (*map)[i].idx = -1;\n        (*map)[i].factor = 0;\n    }\n}\n\nHRESULT ExtendedChannelMapping(BufferDetails *pcm, unsigned uOutChannels, const ExtendedChannelMap extMap);\n"
  },
  {
    "path": "decoder/LAVAudio/dllmain.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n// Based on the SampleParser Template by GDCL\n// --------------------------------------------------------------------------------\n// Copyright (c) GDCL 2004. All Rights Reserved.\n// You are free to re-use this as the basis for your own filter development,\n// provided you retain this copyright notice in the source.\n// http://www.gdcl.co.uk\n// --------------------------------------------------------------------------------\n\n#include \"stdafx.h\"\n\n// Initialize the GUIDs\n#include <InitGuid.h>\n\n#include <qnetwork.h>\n#include \"LAVAudio.h\"\n#include \"AudioSettingsProp.h\"\n#include \"moreuuids.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n\n#include \"registry.h\"\n\n// --- COM factory table and registration code --------------\n\nconst AMOVIESETUP_PIN sudpPinsAudioDec[] = {{L\"Input\", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr,\n                                             CLAVAudio::sudPinTypesInCount, CLAVAudio::sudPinTypesIn},\n                                            {L\"Output\", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr,\n                                             CLAVAudio::sudPinTypesOutCount, CLAVAudio::sudPinTypesOut}};\n\nconst AMOVIESETUP_FILTER sudFilterReg = {&__uuidof(CLAVAudio), // filter clsid\n                                         L\"LAV Audio Decoder\", // filter name\n                                         MERIT_PREFERRED + 3,  // merit\n                                         countof(sudpPinsAudioDec), sudpPinsAudioDec, CLSID_LegacyAmFilterCategory};\n\n// --- COM factory table and registration code --------------\n\n// DirectShow base class COM factory requires this table,\n// declaring all the COM objects in this DLL\nCFactoryTemplate g_Templates[] = {\n    // one entry for each CoCreate-able object\n    {sudFilterReg.strName, sudFilterReg.clsID, CreateInstance<CLAVAudio>, nullptr, &sudFilterReg},\n    // This entry is for the property page.\n    {L\"LAV Audio Properties\", &CLSID_LAVAudioSettingsProp, CreateInstance<CLAVAudioSettingsProp>, nullptr, nullptr},\n    {L\"LAV Audio Mixer\", &CLSID_LAVAudioMixingProp, CreateInstance<CLAVAudioMixingProp>, nullptr, nullptr},\n    {L\"LAV Audio Format Settings\", &CLSID_LAVAudioFormatsProp, CreateInstance<CLAVAudioFormatsProp>, nullptr, nullptr},\n    {L\"LAV Audio Status\", &CLSID_LAVAudioStatusProp, CreateInstance<CLAVAudioStatusProp>, nullptr, nullptr}};\nint g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);\n\n// self-registration entrypoint\nSTDAPI DllRegisterServer()\n{\n    // base classes will handle registration using the factory template table\n    return AMovieDllRegisterServer2(true);\n}\n\nSTDAPI DllUnregisterServer()\n{\n    // base classes will handle de-registration using the factory template table\n    return AMovieDllRegisterServer2(false);\n}\n\n// if we declare the correct C runtime entrypoint and then forward it to the DShow base\n// classes we will be sure that both the C/C++ runtimes and the base classes are initialized\n// correctly\nextern \"C\" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);\nBOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpReserved)\n{\n    return DllEntryPoint(reinterpret_cast<HINSTANCE>(hDllHandle), dwReason, lpReserved);\n}\n\nvoid CALLBACK OpenConfiguration(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)\n{\n    HRESULT hr = S_OK;\n    CUnknown *pInstance = CreateInstance<CLAVAudio>(nullptr, &hr);\n    IBaseFilter *pFilter = nullptr;\n    pInstance->NonDelegatingQueryInterface(IID_IBaseFilter, (void **)&pFilter);\n    if (pFilter)\n    {\n        pFilter->AddRef();\n        CBaseDSPropPage::ShowPropPageDialog(pFilter);\n    }\n    delete pInstance;\n}\n"
  },
  {
    "path": "decoder/LAVAudio/parser/dts.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#define __STDC_CONSTANT_MACROS\n\n// Exclude inline asm from being included\n#define AVCODEC_X86_MATHOPS_H\n\nextern \"C\"\n{\n#pragma warning(push)\n#pragma warning(disable : 4101)\n#pragma warning(disable : 4244)\n#pragma warning(disable : 4305)\n#pragma warning(disable : 5033)\n#include \"libavcodec/avcodec.h\"\n#include \"libavcodec/get_bits.h\"\n#include \"libavcodec/dca_sample_rate_tab.h\"\n#pragma warning(pop)\n\n    extern int avpriv_dca_convert_bitstream(const uint8_t *src, int src_size, uint8_t *dst, int max_size);\n};\n\n#include \"dts.h\"\n#include \"parser.h\"\n\n#include <vector>\n\nstruct DTSParserContext\n{\n    GetBitContext *gb;\n};\n\nint init_dts_parser(DTSParserContext **pContext)\n{\n    if (!pContext)\n        return -1;\n\n    *pContext = (DTSParserContext *)malloc(sizeof(DTSParserContext));\n    if (*pContext == nullptr)\n        return -1;\n    memset(*pContext, 0, sizeof(DTSParserContext));\n\n    (*pContext)->gb = new GetBitContext();\n\n    return 0;\n}\n\nint close_dts_parser(DTSParserContext **pContext)\n{\n    if (!pContext)\n        return -1;\n\n    delete (*pContext)->gb;\n    free(*pContext);\n    *pContext = nullptr;\n\n    return 0;\n}\n\nstatic int parse_dts_xch_header(DTSParserContext *pContext, DTSHeader *pHeader, const uint8_t *pBuffer, unsigned uSize)\n{\n    GetBitContext *gb = pContext->gb;\n    init_get_bits(gb, pBuffer, uSize << 3);\n\n    get_bits(gb, 32);                            /* DCA_XCH_MARKER */\n    get_bits(gb, 10);                            /* XCh Frame Size */\n    pHeader->XChChannelLayout = get_bits(gb, 4); /* Extension Channel Arrangement */\n\n    return 0;\n}\n\nstatic int parse_dts_xch_hd_header(DTSParserContext *pContext, DTSHeader *pHeader, const uint8_t *pBuffer,\n                                   unsigned uSize)\n{\n    GetBitContext *gb = pContext->gb;\n    init_get_bits(gb, pBuffer, uSize << 3);\n\n    /* Huh? */\n    pHeader->XChChannelLayout = 1;\n\n    return 0;\n}\n\nstatic int parse_dts_xxch_header(DTSParserContext *pContext, DTSHeader *pHeader, const uint8_t *pBuffer, unsigned uSize)\n{\n    GetBitContext *gb = pContext->gb;\n    init_get_bits(gb, pBuffer, uSize << 3);\n\n    get_bits(gb, 32);                            /* DCA_XXCH_MARKER */\n    get_bits(gb, 8);                             /* ? */\n    pHeader->XChChannelLayout = get_bits(gb, 2); /* Channels Added? */\n    get_bits(gb, 6);                             /* ? */\n\n    return 0;\n}\n\nstatic int parse_dts_xxch_hd_header(DTSParserContext *pContext, DTSHeader *pHeader, const uint8_t *pBuffer,\n                                    unsigned uSize)\n{\n    GetBitContext *gb = pContext->gb;\n    init_get_bits(gb, pBuffer, uSize << 3);\n\n    get_bits(gb, 32);                            /* DCA_XXCH_MARKER */\n    get_bits(gb, 8);                             /* ? */\n    pHeader->XChChannelLayout = get_bits(gb, 2); /* Channels Added? */\n    get_bits(gb, 6);                             /* ? */\n\n    return 0;\n}\n\nstatic int parse_dts_hd_header(DTSParserContext *pContext, DTSHeader *pHeader, const uint8_t *pBuffer, unsigned uSize)\n{\n    GetBitContext *gb = pContext->gb;\n    init_get_bits(gb, pBuffer, uSize << 3);\n\n    unsigned NumAudio = 1;\n    unsigned NumAssets = 1;\n\n    get_bits(gb, 32);                   /* DCA_HD_MARKER */\n    get_bits(gb, 8);                    /* Unknown */\n    unsigned SubIdx = get_bits(gb, 2);  /* Substream Index */\n    unsigned blownUp = get_bits(gb, 1); /* Blown Up Header */\n    if (blownUp)\n    {\n        get_bits(gb, 12); /* Header Size */\n        get_bits(gb, 20); /* HD Size */\n    }\n    else\n    {\n        get_bits(gb, 8);  /* Header Size */\n        get_bits(gb, 16); /* HD Size */\n    }\n    unsigned staticFields = get_bits(gb, 1); /* Static fields present */\n    if (staticFields)\n    {\n        std::vector<uint32_t> ActiveExSSMasks;\n\n        get_bits(gb, 2);                 /* Reference clock code */\n        get_bits(gb, 3);                 /* ExSS frame duration code */\n        if (get_bits(gb, 1))             /* Timestamp flag */\n            get_bits(gb, 36);            /* Timestamp */\n        NumAudio = get_bits(gb, 3) + 1;  /* Num audio present */\n        NumAssets = get_bits(gb, 3) + 1; /* Num assets */\n        for (uint8_t Pos = 0; Pos < NumAudio; Pos++)\n        {\n            uint32_t mask = get_bits(gb, SubIdx + 1); /* Active ExSS masks */\n            ActiveExSSMasks.push_back(mask);\n        }\n        for (uint8_t Pos = 0; Pos < NumAudio; Pos++)\n            for (uint8_t Pos2 = 0; Pos2 < SubIdx + 1; Pos2 += 2)\n                if (ActiveExSSMasks[Pos] % 2)\n                    get_bits(gb, 8); /* Active ExSS masks 2 */\n        if (get_bits(gb, 1))\n        {                                    /* Mix Metadata Flag */\n            get_bits(gb, 2);                 /* Mix Metadata Adjustment Level */\n            unsigned bits = get_bits(gb, 2); /* Bits4Mix Mask */\n            bits = 4 + bits * 4;\n            unsigned num = get_bits(gb, 2) + 1; /* Num Configs */\n            for (uint8_t Pos = 0; Pos < num; Pos++)\n                get_bits(gb, bits); /* Mix Out Ch Mask */\n        }\n    } /* END: Static Fields */\n    // Sizes\n    for (uint8_t Pos = 0; Pos < NumAssets; Pos++)\n    {\n        if (blownUp)\n        {\n            get_bits(gb, 20); /* Size */\n        }\n        else\n        {\n            get_bits(gb, 16); /* Size */\n        }\n    }\n\n    for (uint8_t Pos = 0; Pos < NumAssets; Pos++)\n    {\n        get_bits(gb, 9); /* Asset Size */\n        get_bits(gb, 3); /* Asset Descriptor Data */\n        if (staticFields)\n        {\n            if (get_bits(gb, 1))  /* Asset type descriptor present */\n                get_bits(gb, 4);  /* Asset type descriptor */\n            if (get_bits(gb, 1))  /* Language descriptor present */\n                get_bits(gb, 24); /* Language descriptor */\n            if (get_bits(gb, 1))\n            {                                          /* Info text present */\n                unsigned bytes = get_bits(gb, 10) + 1; /* Info text size */\n                for (unsigned Pos = 0; Pos < bytes; Pos++)\n                    get_bits(gb, 8); /* Info Text */\n            }\n            get_bits(gb, 5);                                /* Bit Resolution */\n            get_bits(gb, 4);                                /* Maximum Sample Rate */\n            pHeader->HDTotalChannels = get_bits(gb, 8) + 1; /* Total Number of Channels */\n            if (get_bits(gb, 1))\n            { /* 1 to 1 speaker map present */\n                unsigned SpeakerActivityMaskBits = 0, SpeakerRemapSetsCount;\n                if (pHeader->HDTotalChannels > 2)\n                    get_bits(gb, 1); /* Embedded stereo flag */\n                if (pHeader->HDTotalChannels > 6)\n                    get_bits(gb, 1); /* Embedded 6 channels flag */\n                if (get_bits(gb, 1))\n                {                                              /* Speaker Mask Flag */\n                    SpeakerActivityMaskBits = get_bits(gb, 2); /* Speaker mask bits */\n                    SpeakerActivityMaskBits = 4 + SpeakerActivityMaskBits * 4;\n                    pHeader->HDSpeakerMask = get_bits(gb, SpeakerActivityMaskBits); /* Speaker activity Mask */\n                }\n                SpeakerRemapSetsCount = get_bits(gb, 3); /* Speaker remap sets count */\n                for (uint8_t Pos = 0; Pos < SpeakerRemapSetsCount; Pos++)\n                    get_bits(gb, SpeakerActivityMaskBits); /* Standard Speaker Layout mask */\n                                                           /* unfinished\n                                                           for (uint8_t Pos = 0; Pos < SpeakerRemapSetsCount; Pos++)\n                                                           get_bits(gb, 5);                            /* NumDecCh4Remap\n                                                           */\n            }\n        }\n    }\n\n    return 0;\n}\n\nint parse_dts_header(DTSParserContext *pContext, DTSHeader *pHeader, uint8_t *pBuffer, unsigned uSize)\n{\n    if (!pContext)\n        return -1;\n    if (!pHeader)\n        return -1;\n\n    unsigned ExtDescriptor = 0, ExtCoding = 0;\n\n    uint8_t dts_buffer[32 + AV_INPUT_BUFFER_PADDING_SIZE] = {0};\n    int ret = avpriv_dca_convert_bitstream(pBuffer, uSize, dts_buffer, 32);\n\n    bool is16be = (AV_RB32(pBuffer) == DCA_MARKER_RAW_BE);\n\n    /* Parse Core Header */\n    if (ret >= 0)\n    {\n        pHeader->HasCore = 1;\n\n        GetBitContext *gb = pContext->gb;\n        init_get_bits(gb, dts_buffer, 32 << 3);\n\n        skip_bits_long(gb, 32);                         /* Sync code */\n        skip_bits1(gb);                                 /* Frame type */\n        pHeader->SamplesPerBlock = get_bits(gb, 5) + 1; /* Samples deficit */\n        pHeader->CRCPresent = get_bits1(gb);            /* CRC present */\n        pHeader->Blocks = get_bits(gb, 7) + 1;          /* Number of Blocks */\n        pHeader->FrameSize = get_bits(gb, 14) + 1;      /* Primary (core) Frame Size */\n        pHeader->ChannelLayout = get_bits(gb, 6);       /* Channel configuration */\n        unsigned sample_index = get_bits(gb, 4);        /* Sample frequency index */\n        pHeader->SampleRate = ff_dca_sample_rates[sample_index];\n        skip_bits(gb, 5);                /* Bitrate index */\n        skip_bits1(gb);                  /* Down mix */\n        skip_bits1(gb);                  /* Dynamic range */\n        skip_bits1(gb);                  /* Time stamp */\n        skip_bits1(gb);                  /* Auxiliary data */\n        skip_bits1(gb);                  /* HDCD */\n        ExtDescriptor = get_bits(gb, 3); /* External descriptor  */\n        ExtCoding = get_bits1(gb);       /* Extended coding */\n        skip_bits1(gb);                  /* ASPF */\n        pHeader->LFE = get_bits(gb, 2);  /* LFE */\n        skip_bits1(gb);                  /* Predictor History */\n        if (pHeader->CRCPresent)\n            skip_bits(gb, 16);       /* CRC */\n        skip_bits1(gb);              /* Multirate Interpolator */\n        skip_bits(gb, 4);            /* Encoder Software Revision */\n        skip_bits(gb, 2);            /* Copy history */\n        pHeader->ES = get_bits1(gb); /* ES */\n        skip_bits(gb, 2);            /* PCMR (source PCM resolution) */\n        skip_bits1(gb);              /* SUMF (Front Sum/Difference Flag) */\n        skip_bits1(gb);              /* SUMS (Surround Sum/Difference Flag) */\n        skip_bits(gb, 4);            /* Dialog Normalization Parameter or Unspecified (dependent on encoder version) */\n\n        // Check some basic validity\n        if (uSize < pHeader->FrameSize)\n            return -1;\n    }\n    else\n    {\n        pHeader->HasCore = 0;\n    }\n\n    if (pHeader->HasCore && !is16be)\n        return 0;\n\n    // DTS-HD parsing\n    const uint8_t *pHD = nullptr;\n    if (pHeader->HasCore)\n    { // If we have a core, only search after the normal buffer\n        if (uSize > (pHeader->FrameSize + 4))\n        { // at least 4 bytes extra, could probably insert a minimal size of a HD header, but so what\n            pHD = find_marker32_position(pBuffer + pHeader->FrameSize, uSize - pHeader->FrameSize, DCA_HD_MARKER);\n        }\n    }\n    else\n    {\n        pHD = find_marker32_position(pBuffer, uSize, DCA_HD_MARKER);\n    }\n    if (pHD)\n    {\n        pHeader->IsHD = 1;\n        size_t remaining = uSize - (pHD - pBuffer);\n        parse_dts_hd_header(pContext, pHeader, pHD, (unsigned)remaining);\n\n        const uint8_t *pXChHD = find_marker32_position(pHD, remaining, DCA_XCH_MARKER);\n        if (pXChHD)\n        {\n            size_t remaining = uSize - (pXChHD - pBuffer);\n            parse_dts_xch_hd_header(pContext, pHeader, pXChHD, (unsigned)remaining);\n        }\n\n        const uint8_t *pXXChHD = find_marker32_position(pHD, remaining, DCA_XXCH_MARKER);\n        if (pXXChHD)\n        {\n            size_t remaining = uSize - (pXXChHD - pBuffer);\n            parse_dts_xxch_hd_header(pContext, pHeader, pXXChHD, (unsigned)remaining);\n        }\n    }\n\n    // Handle DTS extensions\n    if (ExtCoding)\n    {\n        size_t coreSize = pHD ? (pHD - pBuffer) : uSize;\n        if (ExtDescriptor == 0 || ExtDescriptor == 3)\n        {\n            const uint8_t *pXCh = find_marker32_position(pBuffer, coreSize, DCA_XCH_MARKER);\n            if (pXCh)\n            {\n                size_t remaining = coreSize - (pXCh - pBuffer);\n                parse_dts_xch_header(pContext, pHeader, pXCh, (unsigned)remaining);\n            }\n        }\n        if (ExtDescriptor == 6)\n        {\n            const uint8_t *pXXCh = find_marker32_position(pBuffer, coreSize, DCA_XXCH_MARKER);\n            if (pXXCh)\n            {\n                size_t remaining = coreSize - (pXXCh - pBuffer);\n                parse_dts_xxch_header(pContext, pHeader, pXXCh, (unsigned)remaining);\n            }\n        }\n    }\n\n    return 0;\n}\n"
  },
  {
    "path": "decoder/LAVAudio/parser/dts.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"parser.h\"\n\n/** DCA syncwords */\n#define DCA_MARKER_RAW_BE 0x7FFE8001\n#define DCA_MARKER_RAW_LE 0xFE7F0180\n#define DCA_MARKER_14B_BE 0x1FFFE800\n#define DCA_MARKER_14B_LE 0xFF1F00E8\n\n/** DCA-HD specific block starts with this marker. */\n#define DCA_HD_MARKER     0x64582025\n\n/** DCA extension blocks */\n#define DCA_XCH_MARKER    0x5a5a5a5a\n#define DCA_XXCH_MARKER   0x47004A03\n\nstruct DTSParserContext;\n\nstruct DTSHeader\n{\n    unsigned HasCore;\n    unsigned CRCPresent;\n    unsigned SamplesPerBlock;\n    unsigned Blocks;\n    unsigned FrameSize;\n    unsigned ChannelLayout;\n    unsigned SampleRate;\n    unsigned LFE;\n\n    // Extensions\n    unsigned ES;\n    unsigned XChChannelLayout;\n\n    unsigned IsHD;\n    unsigned HDTotalChannels;\n    unsigned HDSpeakerMask;\n};\n\nint init_dts_parser(DTSParserContext **pContext);\nint close_dts_parser(DTSParserContext **pContext);\n\nint parse_dts_header(DTSParserContext *pContext, DTSHeader *pHeader, uint8_t *pBuffer, unsigned uSize);\n"
  },
  {
    "path": "decoder/LAVAudio/parser/parser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nstatic inline const uint8_t *find_marker32_position(const uint8_t *pBuffer, size_t uBufSize, uint32_t marker)\n{\n    uint32_t state = 0;\n    for (size_t i = 0; i < uBufSize; ++i)\n    {\n        state = (state << 8) | pBuffer[i];\n        if (state == marker)\n        {\n            return pBuffer + (i - 3);\n        }\n    }\n\n    return nullptr;\n}\n"
  },
  {
    "path": "decoder/LAVAudio/resource.h",
    "content": "//{{NO_DEPENDENCIES}}\n// Microsoft Visual C++ generated include file.\n// Used by LAVAudio.rc\n//\n#define IDD_PROPPAGE_AUDIO_SETTINGS     9\n#define IDD_PROPPAGE_AUDIO_MIXING       10\n#define IDD_PROPPAGE_FORMATS            11\n#define IDD_PROPPAGE_STATUS             12\n#define IDS_SETTINGS                    101\n#define IDS_STATUS                      102\n#define IDS_FORMATS                     103\n#define IDI_ICON1                       104\n#define IDS_MIXER                       105\n#define IDC_INPUT_STATUS                1013\n#define IDC_OUTPUT_STATUS               1026\n#define IDC_DRC                         1034\n#define IDC_DRC_LEVEL                   1035\n#define IDC_DRC_BOX                     1036\n#define IDC_DRC_LEVEL_TEXT              1037\n#define IDC_LBL_DRC_LEVEL               1038\n#define IDC_VOLUME                      1039\n#define IDC_VOLUME1                     1040\n#define IDC_VOLUME2                     1041\n#define IDC_VOLUME3                     1042\n#define IDC_VOLUME4                     1043\n#define IDC_VOLUME5                     1044\n#define IDC_VOLUME6                     1045\n#define IDC_VOLUME7                     1046\n#define IDC_VOLUME8                     1047\n#define IDC_VOLUME1_DESC                1048\n#define IDC_VOLUME2_DESC                1049\n#define IDC_VOLUME3_DESC                1050\n#define IDC_VOLUME4_DESC                1051\n#define IDC_VOLUME5_DESC                1052\n#define IDC_VOLUME6_DESC                1053\n#define IDC_VOLUME7_DESC                1054\n#define IDC_VOLUME8_DESC                1055\n#define IDC_CODECS                      1056\n#define IDC_CODECS_NONE                 1059\n#define IDC_LAVAUDIO_FOOTER             1060\n#define IDC_BITSTREAMING                1061\n#define IDC_BS_AC3                      1062\n#define IDC_BS_EAC3                     1063\n#define IDC_BS_TRUEHD                   1064\n#define IDC_BS_DTS                      1065\n#define IDC_BS_DTSHD                    1066\n#define IDC_BS_FORMATS                  1067\n#define IDC_BS_DTSHD_FRAMING            1068\n#define IDC_BS_OPTIONS                  1069\n#define IDC_OPTIONS                     1070\n#define IDC_AUTO_AVSYNC                 1071\n#define IDC_LBL_INPUT_CODEC             1072\n#define IDC_LBL_INPUT_CHANNEL           1073\n#define IDC_LBL_INPUT_SAMPLERATE        1074\n#define IDC_LBL_INPUT_FORMAT            1075\n#define IDC_INPUT_SAMPLERATE            1076\n#define IDC_INPUT_CODEC                 1077\n#define IDC_INPUT_CHANNEL               1078\n#define IDC_INPUT_FORMAT                1079\n#define IDC_LBL_OUTPUT_CODEC            1080\n#define IDC_LBL_OUTPUT_CHANNEL          1081\n#define IDC_LBL_OUTPUT_SAMPLERATE       1082\n#define IDC_LBL_OUTPUT_FORMAT           1083\n#define IDC_OUTPUT_SAMPLERATE           1084\n#define IDC_OUTPUT_CODEC                1085\n#define IDC_OUTPUT_CHANNEL              1086\n#define IDC_OUTPUT_FORMAT               1087\n#define IDC_STANDARD_CH_LAYOUT          1088\n#define IDC_EXPAND_MONO                 1089\n#define IDC_EXPAND61                    1090\n#define IDC_OUTPUT_FORMATS              1091\n#define IDC_LBL_OUTPUTFORMATS           1092\n#define IDC_OUT_S16                     1093\n#define IDC_OUT_S24                     1094\n#define IDC_OUT_S32                     1095\n#define IDC_OUT_FP32                    1096\n#define IDC_OUT_U8                      1097\n#define IDC_LBL_OUTNOTE                 1098\n#define IDC_GROUP_DELAY                 1099\n#define IDC_DELAY_ENABLED               1100\n#define IDC_DELAY                       1101\n#define IDC_DELAYSPIN                   1102\n#define IDC_LBL_FORMATS                 1103\n#define IDC_MIXING                      1104\n#define IDC_MIXER                       1105\n#define IDC_DOWNMIX                     1106\n#define IDC_OUTPUT_SPEAKERS             1108\n#define IDC_UNTOUCHED_STEREO            1109\n#define IDC_MIX_SETTINGS                1110\n#define IDC_LBL_OUTPUT_SPEAKERS         1111\n#define IDC_LBL_MIXING                  1112\n#define IDC_NORMALIZE_MATRIX            1113\n#define IDC_CLIP_PROTECTION             1114\n#define IDC_MIXING_MODE                 1115\n#define IDC_MIXMODE_NORMAL              1116\n#define IDC_MIXMODE_DOLBY               1117\n#define IDC_MIXMODE_DPL2                1118\n#define IDC_MIX_LEVEL_CENTER            1121\n#define IDC_MIX_LEVEL_SURROUND          1122\n#define IDC_MIX_LEVEL_LFE               1123\n#define IDC_LBL_CENTER_LEVEL            1124\n#define IDC_LBL_SURROUND_LEVEL          1125\n#define IDC_LBL_LFE_LEVEL               1126\n#define IDC_MIX_LEVEL_CENTER_TEXT       1127\n#define IDC_MIX_LEVEL_SURROUND_TEXT     1128\n#define IDC_MIX_LEVEL_LFE_TEXT          1129\n#define IDC_LBL_MIXING_LEVEL            1130\n#define IDC_TRAYICON                    1131\n#define IDC_OUT_S16_DITHER              1132\n#define IDC_OUTPUT51_LEGACY             1133\n#define IDC_BS_FALLBACK                 1135\n\n// Next default values for new objects\n// \n#ifdef APSTUDIO_INVOKED\n#ifndef APSTUDIO_READONLY_SYMBOLS\n#define _APS_NEXT_RESOURCE_VALUE        106\n#define _APS_NEXT_COMMAND_VALUE         40001\n#define _APS_NEXT_CONTROL_VALUE         1134\n#define _APS_NEXT_SYMED_VALUE           101\n#endif\n#endif\n"
  },
  {
    "path": "decoder/LAVAudio/stdafx.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n// Pre-compiled header\n#include \"stdafx.h\"\n"
  },
  {
    "path": "decoder/LAVAudio/stdafx.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n// pre-compiled header\n\n#pragma once\n\n// Support for Version 6.0 styles\n#pragma comment( \\\n    linker,      \\\n    \"\\\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\\\"\")\n\n#include \"common_defines.h\"\n\n// include headers\n#include <Windows.h>\n#include <Commctrl.h>\n\n#include <atlbase.h>\n#include <atlconv.h>\n\n#pragma warning(push)\n#pragma warning(disable : 4244)\nextern \"C\"\n{\n#define __STDC_CONSTANT_MACROS\n#include \"libavformat/avformat.h\"\n#include \"libavcodec/avcodec.h\"\n#include \"libavutil/opt.h\"\n#include \"libavutil/intreadwrite.h\"\n#include \"libswresample/swresample.h\"\n}\n#pragma warning(pop)\n\n#include \"streams.h\"\n\n#include \"DShowUtil.h\"\n#include \"growarray.h\"\n"
  },
  {
    "path": "decoder/LAVVideo/CCOutputPin.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"CCOutputPin.h\"\n\n#include \"LAVVideo.h\"\n\nCCCOutputPin::CCCOutputPin(TCHAR *pObjectName, CLAVVideo *pFilter, CCritSec *pcsFilter, HRESULT *phr, LPWSTR pName)\n    : CBaseOutputPin(pObjectName, pFilter, pcsFilter, phr, pName)\n{\n    m_CCmt.SetType(&MEDIATYPE_DTVCCData);\n    m_CCmt.SetSubtype(&IID_MediaSideDataEIA608CC);\n    m_CCmt.SetFormatType(&FORMAT_None);\n    m_CCmt.SetVariableSize();\n    m_CCmt.SetSampleSize(4096);\n}\n\nCCCOutputPin::~CCCOutputPin()\n{\n}\n\nHRESULT CCCOutputPin::Active(void)\n{\n    return __super::Active();\n}\n\nSTDMETHODIMP CCCOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    return __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\nHRESULT CCCOutputPin::DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProperties)\n{\n    CheckPointer(pAlloc, E_POINTER);\n    CheckPointer(pProperties, E_POINTER);\n\n    HRESULT hr = S_OK;\n\n    pProperties->cBuffers = max(pProperties->cBuffers, 1);\n    pProperties->cbBuffer = max((ULONG)pProperties->cbBuffer, 4096);\n\n    // Sanity checks\n    ALLOCATOR_PROPERTIES Actual;\n    if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual)))\n        return hr;\n    if (Actual.cbBuffer < pProperties->cbBuffer)\n        return E_FAIL;\n    ASSERT(Actual.cBuffers >= pProperties->cBuffers);\n\n    return S_OK;\n}\n\nHRESULT CCCOutputPin::CheckMediaType(const CMediaType *pmt)\n{\n    if (*pmt == m_CCmt)\n        return S_OK;\n\n    return E_INVALIDARG;\n}\n\nHRESULT CCCOutputPin::GetMediaType(int iPosition, CMediaType *pmt)\n{\n    if (iPosition < 0 || iPosition > 0)\n        return E_INVALIDARG;\n    *pmt = m_CCmt;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CCCOutputPin::DeliverCCData(BYTE *pDataIn, size_t size, REFERENCE_TIME rtTime)\n{\n    HRESULT hr;\n    IMediaSample *pSample = nullptr;\n\n    CHECK_HR(hr = GetDeliveryBuffer(&pSample, nullptr, nullptr, 0));\n\n    // Resize buffer if it is too small\n    // This can cause a playback hick-up, we should avoid this if possible by setting a big enough buffer size\n    if (size > (size_t)pSample->GetSize())\n    {\n        SafeRelease(&pSample);\n        ALLOCATOR_PROPERTIES props, actual;\n        CHECK_HR(hr = m_pAllocator->GetProperties(&props));\n        // Give us 2 times the requested size, so we don't resize every time\n        props.cbBuffer = (long)(size * 2);\n        if (props.cBuffers > 1)\n        {\n            CHECK_HR(hr = __super::DeliverBeginFlush());\n            CHECK_HR(hr = __super::DeliverEndFlush());\n        }\n        CHECK_HR(hr = m_pAllocator->Decommit());\n        CHECK_HR(hr = m_pAllocator->SetProperties(&props, &actual));\n        CHECK_HR(hr = m_pAllocator->Commit());\n        CHECK_HR(hr = GetDeliveryBuffer(&pSample, nullptr, nullptr, 0));\n    }\n\n    // Fill the sample\n    BYTE *pData = nullptr;\n    if (FAILED(hr = pSample->GetPointer(&pData)) || !pData)\n        goto done;\n\n    memcpy(pData, pDataIn, size);\n\n    // set properties\n    CHECK_HR(hr = pSample->SetActualDataLength((long)size));\n    CHECK_HR(hr = pSample->SetTime(rtTime != AV_NOPTS_VALUE ? &rtTime : nullptr,\n                                   rtTime != AV_NOPTS_VALUE ? &rtTime : nullptr));\n    CHECK_HR(hr = pSample->SetMediaTime(nullptr, nullptr));\n\n    // Deliver\n    CHECK_HR(hr = Deliver(pSample));\n\ndone:\n    SafeRelease(&pSample);\n    return hr;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/CCOutputPin.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nclass CLAVVideo;\n\nclass CCCOutputPin : public CBaseOutputPin\n{\n  public:\n    CCCOutputPin(TCHAR *pObjectName, CLAVVideo *pFilter, CCritSec *pcsFilter, HRESULT *phr, LPWSTR pName);\n    virtual ~CCCOutputPin();\n\n    // IUnknown\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // CBasePin\n    virtual HRESULT CheckMediaType(const CMediaType *pmt);\n    virtual HRESULT GetMediaType(int iPosition, CMediaType *pmt);\n    virtual HRESULT Active(void);\n\n    // CBaseOutputPin\n    virtual HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *ppropInputRequest);\n\n    // CCOutputPin\n    STDMETHODIMP DeliverCCData(BYTE *pData, size_t size, REFERENCE_TIME rtTime);\n\n  private:\n    CMediaType m_CCmt;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/DecodeManager.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n#include \"stdafx.h\"\n#include \"DecodeManager.h\"\n\n#include \"LAVVideo.h\"\n\n#include <Shlwapi.h>\n\nCDecodeManager::CDecodeManager(CLAVVideo *pLAVVideo)\n    : m_pLAVVideo(pLAVVideo)\n{\n    WCHAR fileName[1024];\n    GetModuleFileName(nullptr, fileName, 1024);\n    m_processName = PathFindFileName(fileName);\n}\n\nCDecodeManager::~CDecodeManager(void)\n{\n    Close();\n}\n\nSTDMETHODIMP CDecodeManager::Close()\n{\n    CAutoLock decoderLock(this);\n    SAFE_DELETE(m_pDecoder);\n    FreeSideDataCache();\n\n    return S_OK;\n}\n\n#define HWFORMAT_ENABLED                                                                                       \\\n    ((codec == AV_CODEC_ID_H264 && m_pLAVVideo->GetHWAccelCodec(HWCodec_H264)) ||                              \\\n     ((codec == AV_CODEC_ID_VC1 || codec == AV_CODEC_ID_WMV3) && m_pLAVVideo->GetHWAccelCodec(HWCodec_VC1)) || \\\n     ((codec == AV_CODEC_ID_MPEG2VIDEO || codec == AV_CODEC_ID_MPEG1VIDEO) &&                                  \\\n      m_pLAVVideo->GetHWAccelCodec(HWCodec_MPEG2)) ||                                                          \\\n     (codec == AV_CODEC_ID_MPEG4 && m_pLAVVideo->GetHWAccelCodec(HWCodec_MPEG4)) ||                            \\\n     (codec == AV_CODEC_ID_HEVC && m_pLAVVideo->GetHWAccelCodec(HWCodec_HEVC)) ||                              \\\n     (codec == AV_CODEC_ID_VP9 && m_pLAVVideo->GetHWAccelCodec(HWCodec_VP9))  ||                               \\\n     (codec == AV_CODEC_ID_AV1 && m_pLAVVideo->GetHWAccelCodec(HWCodec_AV1)))\n\n#define HWRESOLUTION_ENABLED                                                                                           \\\n    ((pBMI->biHeight <= 576 && pBMI->biWidth <= 1024 && m_pLAVVideo->GetHWAccelResolutionFlags() & LAVHWResFlag_SD) || \\\n     ((pBMI->biHeight > 576 || pBMI->biWidth > 1024) && pBMI->biHeight <= 1200 && pBMI->biWidth <= 1920 &&             \\\n      m_pLAVVideo->GetHWAccelResolutionFlags() & LAVHWResFlag_HD) ||                                                   \\\n     ((pBMI->biHeight > 1200 || pBMI->biWidth > 1920) && m_pLAVVideo->GetHWAccelResolutionFlags() & LAVHWResFlag_UHD))\n\nILAVDecoder *CDecodeManager::CreateHWAccelDecoder(LAVHWAccel hwAccel)\n{\n    ILAVDecoder *pDecoder = nullptr;\n    if (hwAccel == HWAccel_CUDA)\n        pDecoder = CreateDecoderCUVID();\n    else if (hwAccel == HWAccel_QuickSync)\n        pDecoder = CreateDecoderQuickSync();\n    else if (hwAccel == HWAccel_DXVA2CopyBack)\n        pDecoder = CreateDecoderDXVA2();\n    else if (hwAccel == HWAccel_DXVA2Native)\n        pDecoder = CreateDecoderDXVA2Native();\n    else if (hwAccel == HWAccel_D3D11)\n        pDecoder = CreateDecoderD3D11();\n\n    return pDecoder;\n}\n\nSTDMETHODIMP CDecodeManager::CreateSideDataCache(const MediaSideDataFFMpeg* pSideData)\n{\n    FreeSideDataCache();\n\n    if (pSideData && pSideData->side_data_elems > 0)\n    {\n        m_SideDataCache.side_data = (AVPacketSideData *)av_calloc(pSideData->side_data_elems, sizeof(*m_SideDataCache.side_data));\n        if (m_SideDataCache.side_data == nullptr)\n            return E_OUTOFMEMORY;\n\n        for (int i = 0; i < pSideData->side_data_elems; i++)\n        {\n            const AVPacketSideData *src_sd = &pSideData->side_data[i];\n            AVPacketSideData *dst_sd = &m_SideDataCache.side_data[i];\n\n            dst_sd->data = (uint8_t *)av_memdup(src_sd->data, src_sd->size);\n            if (!dst_sd->data)\n                return E_OUTOFMEMORY;\n\n            dst_sd->type = src_sd->type;\n            dst_sd->size = src_sd->size;\n            m_SideDataCache.side_data_elems++;\n        }\n    }\n\n    return S_OK;\n}\n\nvoid CDecodeManager::FreeSideDataCache()\n{\n    av_packet_side_data_free(&m_SideDataCache.side_data, &m_SideDataCache.side_data_elems);\n}\n\nSTDMETHODIMP CDecodeManager::CreateDecoder(const CMediaType *pmt, AVCodecID codec, const MediaSideDataFFMpeg *pSideData)\n{\n    CAutoLock decoderLock(this);\n\n    DbgLog(\n        (LOG_TRACE, 10, L\"CDecodeThread::CreateDecoder(): Creating new decoder for codec %S\", avcodec_get_name(codec)));\n    HRESULT hr = S_OK;\n    BOOL bWMV9 = FALSE;\n\n    BOOL bHWDecBlackList = _wcsicmp(m_processName.c_str(), L\"dllhost.exe\") == 0 ||\n                           _wcsicmp(m_processName.c_str(), L\"explorer.exe\") == 0 ||\n                           _wcsicmp(m_processName.c_str(), L\"ReClockHelper.dll\") == 0;\n    DbgLog((LOG_TRACE, 10, L\"-> Process is %s, blacklist: %d\", m_processName.c_str(), bHWDecBlackList));\n\n    BITMAPINFOHEADER *pBMI = nullptr;\n    videoFormatTypeHandler(*pmt, &pBMI);\n\n    CreateSideDataCache(pSideData);\n\n    // disable HW for DVD decoding\n    if (m_pLAVVideo->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD)\n        bHWDecBlackList = true;\n\n    // Try reusing the current HW decoder\n    if (m_pDecoder && m_bHWDecoder && !bHWDecBlackList && !m_bHWDecoderFailed && HWFORMAT_ENABLED && HWRESOLUTION_ENABLED)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Trying to re-use old HW Decoder\"));\n        hr = m_pDecoder->InitDecoder(codec, pmt, &m_SideDataCache);\n        goto done;\n    }\n    SAFE_DELETE(m_pDecoder);\n\n    LAVHWAccel hwAccel = m_pLAVVideo->GetHWAccel();\n    if (!bHWDecBlackList && hwAccel != HWAccel_None && !m_bHWDecoderFailed && HWFORMAT_ENABLED && HWRESOLUTION_ENABLED)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Trying Hardware Codec %d\", hwAccel));\n        m_pDecoder = CreateHWAccelDecoder(hwAccel);\n        m_bHWDecoder = TRUE;\n    }\n\nsoftwaredec:\n    // Fallback for software\n    if (!m_pDecoder)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> No HW Codec, using Software\"));\n        m_bHWDecoder = FALSE;\n        if (m_pLAVVideo->GetUseMSWMV9Decoder() && (codec == AV_CODEC_ID_VC1 || codec == AV_CODEC_ID_WMV3) &&\n            !m_bWMV9Failed)\n        {\n            m_pDecoder = CreateDecoderWMV9MFT();\n            bWMV9 = TRUE;\n        }\n        else if (codec == AV_CODEC_ID_H264_MVC)\n        {\n            m_pDecoder = CreateDecoderMSDKMVC();\n        }\n        else\n            m_pDecoder = CreateDecoderAVCodec();\n    }\n    DbgLog((LOG_TRACE, 10, L\"-> Created Codec '%s'\", m_pDecoder->GetDecoderName()));\n\n    hr = m_pDecoder->InitInterfaces(static_cast<ILAVVideoSettings *>(m_pLAVVideo),\n                                    static_cast<ILAVVideoCallback *>(m_pLAVVideo));\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Init Interfaces failed (hr: 0x%x)\", hr));\n        goto done;\n    }\n\n    hr = m_pDecoder->InitDecoder(codec, pmt, pSideData);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Init Decoder failed (hr: 0x%x)\", hr));\n        goto done;\n    }\n\ndone:\n    if (FAILED(hr))\n    {\n        SAFE_DELETE(m_pDecoder);\n        if (m_bHWDecoder)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Hardware decoder failed to initialize, re-trying with software...\"));\n            m_bHWDecoderFailed = TRUE;\n            goto softwaredec;\n        }\n        if (bWMV9)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> WMV9 MFT decoder failed, trying avcodec instead...\"));\n            m_bWMV9Failed = TRUE;\n            bWMV9 = FALSE;\n            goto softwaredec;\n        }\n        return hr;\n    }\n\n    m_Codec = codec;\n\n    return hr;\n}\n\nSTDMETHODIMP CDecodeManager::Decode(IMediaSample *pSample)\n{\n    CAutoLock decoderLock(this);\n    HRESULT hr = S_OK;\n\n    if (!m_pDecoder)\n        return E_UNEXPECTED;\n\n    hr = m_pDecoder->Decode(pSample);\n\n    // If a hardware decoder indicates a hard failure, we switch back to software\n    // This is used to indicate incompatible media\n    if (FAILED(hr) && m_bHWDecoder)\n    {\n        DbgLog((LOG_TRACE, 10,\n                L\"CDecodeManager::Decode(): Hardware decoder indicates failure, switching back to software\"));\n        m_bHWDecoderFailed = TRUE;\n\n        // If we're disabling DXVA2 Native decoding, we need to release resources now\n        if (wcscmp(m_pDecoder->GetDecoderName(), L\"dxva2n\") == 0 ||\n            wcscmp(m_pDecoder->GetDecoderName(), L\"d3d11 native\") == 0)\n        {\n            m_pLAVVideo->ReleaseAllDXVAResources();\n            m_pLAVVideo->GetOutputPin()->GetConnected()->BeginFlush();\n            m_pLAVVideo->GetOutputPin()->GetConnected()->EndFlush();\n\n            // TODO: further decoding still fails when DXVA2-Native fails mid-decoding, since we can't inform the\n            // renderer about no longer delivering DXVA surfaces\n        }\n\n        CMediaType &mt = m_pLAVVideo->GetInputMediaType();\n        hr = CreateDecoder(&mt, m_Codec, &m_SideDataCache);\n\n        if (SUCCEEDED(hr))\n        {\n            hr = m_pDecoder->Decode(pSample);\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecodeManager::Flush()\n{\n    CAutoLock decoderLock(this);\n\n    if (!m_pDecoder)\n        return E_UNEXPECTED;\n\n    return m_pDecoder->Flush();\n}\n\nSTDMETHODIMP CDecodeManager::EndOfStream()\n{\n    CAutoLock decoderLock(this);\n\n    if (!m_pDecoder)\n        return E_UNEXPECTED;\n\n    return m_pDecoder->EndOfStream();\n}\n\nSTDMETHODIMP CDecodeManager::InitAllocator(IMemAllocator **ppAlloc)\n{\n    CAutoLock decoderLock(this);\n\n    if (!m_pDecoder)\n        return E_UNEXPECTED;\n\n    return m_pDecoder->InitAllocator(ppAlloc);\n}\n\nSTDMETHODIMP CDecodeManager::PostConnect(IPin *pPin)\n{\n    CAutoLock decoderLock(this);\n    HRESULT hr = S_OK;\n    if (m_pDecoder)\n    {\n        hr = m_pDecoder->PostConnect(pPin);\n        if (FAILED(hr))\n        {\n            m_bHWDecoderFailed = TRUE;\n            CMediaType &mt = m_pLAVVideo->GetInputMediaType();\n            hr = CreateDecoder(&mt, m_Codec, &m_SideDataCache);\n        }\n    }\n    return hr;\n}\n\nSTDMETHODIMP CDecodeManager::BreakConnect()\n{\n    CAutoLock decoderLock(this);\n\n    if (!m_pDecoder)\n        return E_UNEXPECTED;\n\n    return m_pDecoder->BreakConnect();\n}\n"
  },
  {
    "path": "decoder/LAVVideo/DecodeManager.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"decoders/ILAVDecoder.h\"\n#include \"SynchronizedQueue.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n\nclass CLAVVideo;\n\nclass CDecodeManager : protected CCritSec\n{\n  public:\n    CDecodeManager(CLAVVideo *pLAVVideo);\n    ~CDecodeManager();\n\n    static ILAVDecoder *CreateHWAccelDecoder(LAVHWAccel hwAccel);\n\n    // Decoder management\n    STDMETHODIMP CreateDecoder(const CMediaType *pmt, AVCodecID codec, const MediaSideDataFFMpeg *pSideData);\n    STDMETHODIMP Close();\n\n    // Media control\n    STDMETHODIMP Decode(IMediaSample *pSample);\n    STDMETHODIMP Flush();\n    STDMETHODIMP EndOfStream();\n\n    // Allocator/memory management\n    STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc);\n    STDMETHODIMP PostConnect(IPin *pPin);\n    STDMETHODIMP BreakConnect();\n\n    // HWAccel Query\n    STDMETHODIMP_(BOOL) IsHWDecoderActive() { return m_bHWDecoder; }\n    STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName)\n    {\n        return m_pDecoder ? m_pDecoder->GetHWAccelActiveDevice(pstrDeviceName) : E_UNEXPECTED;\n    }\n\n    // ILAVDecoder (partial)\n    STDMETHODIMP_(const WCHAR *) GetDecoderName() { return m_pDecoder ? m_pDecoder->GetDecoderName() : nullptr; }\n    STDMETHODIMP_(long) GetBufferCount(long *pMaxBuffers)\n    {\n        return m_pDecoder ? m_pDecoder->GetBufferCount(pMaxBuffers) : 4;\n    }\n    STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess)\n    {\n        return m_pDecoder ? m_pDecoder->IsInterlaced(bAllowGuess) : TRUE;\n    }\n    STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware)\n    {\n        if (m_pDecoder == NULL)\n        {\n            if (pPix)\n                *pPix = LAVPixFmt_None;\n            if (pBpp)\n                *pBpp = 8;\n            if (pPixSoftware)\n                *pPixSoftware = LAVPixFmt_None;\n\n            return S_FALSE;\n        }\n\n        return m_pDecoder->GetPixelFormat(pPix, pBpp, pPixSoftware);\n    }\n    STDMETHODIMP_(REFERENCE_TIME) GetFrameDuration()\n    {\n        ASSERT(m_pDecoder);\n        return m_pDecoder->GetFrameDuration();\n    }\n    STDMETHODIMP HasThreadSafeBuffers() { return m_pDecoder ? m_pDecoder->HasThreadSafeBuffers() : S_FALSE; }\n    STDMETHODIMP SetDirectOutput(BOOL bDirect) { return m_pDecoder ? m_pDecoder->SetDirectOutput(bDirect) : S_FALSE; }\n\n  private:\n    STDMETHODIMP CreateSideDataCache(const MediaSideDataFFMpeg *pSideData);\n    void FreeSideDataCache();\n\n  private:\n    CLAVVideo *m_pLAVVideo = nullptr;\n    ILAVDecoder *m_pDecoder = nullptr;\n\n    AVCodecID m_Codec = AV_CODEC_ID_NONE;\n\n    MediaSideDataFFMpeg m_SideDataCache{};\n\n    BOOL m_bHWDecoder = FALSE;\n    BOOL m_bHWDecoderFailed = FALSE;\n\n    BOOL m_bWMV9Failed = FALSE;\n\n    std::wstring m_processName;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/Filtering.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVVideo.h\"\n\nstatic void lav_free_lavframe(void *opaque, uint8_t *data)\n{\n    LAVFrame *frame = (LAVFrame *)opaque;\n    FreeLAVFrameBuffers(frame);\n    SAFE_CO_FREE(opaque);\n}\n\nstatic void lav_unref_frame(void *opaque, uint8_t *data)\n{\n    AVBufferRef *buf = (AVBufferRef *)opaque;\n    av_buffer_unref(&buf);\n}\n\nstatic void avfilter_free_lav_buffer(LAVFrame *pFrame)\n{\n    av_frame_free((AVFrame **)&pFrame->priv_data);\n}\n\nHRESULT CLAVVideo::Filter(LAVFrame *pFrame)\n{\n    int ret = 0;\n    BOOL bFlush = pFrame->flags & LAV_FRAME_FLAG_FLUSH;\n    if (m_Decoder.IsInterlaced(FALSE) && m_settings.DeintMode != DeintMode_Disable &&\n        m_settings.SWDeintMode != SWDeintMode_None &&\n        ((bFlush && m_pFilterGraph) || pFrame->format == LAVPixFmt_YUV420 || pFrame->format == LAVPixFmt_YUV422 ||\n         pFrame->format == LAVPixFmt_NV12))\n    {\n        AVPixelFormat ff_pixfmt = (pFrame->format == LAVPixFmt_YUV420)\n                                      ? AV_PIX_FMT_YUV420P\n                                      : (pFrame->format == LAVPixFmt_YUV422) ? AV_PIX_FMT_YUV422P : AV_PIX_FMT_NV12;\n\n        if (!bFlush && (!m_pFilterGraph || pFrame->format != m_filterPixFmt || pFrame->width != m_filterWidth ||\n                        pFrame->height != m_filterHeight))\n        {\n            DbgLog((LOG_TRACE, 10, L\":Filter()(init) Initializing software deinterlacing filter...\"));\n            if (m_pFilterGraph)\n            {\n                avfilter_graph_free(&m_pFilterGraph);\n                m_pFilterBufferSrc = nullptr;\n                m_pFilterBufferSink = nullptr;\n            }\n\n            m_filterPixFmt = pFrame->format;\n            m_filterWidth = pFrame->width;\n            m_filterHeight = pFrame->height;\n\n            char args[512];\n\n            const AVFilter *buffersrc = avfilter_get_by_name(\"buffer\");\n            const AVFilter *buffersink = avfilter_get_by_name(\"buffersink\");\n            AVFilterInOut *outputs = avfilter_inout_alloc();\n            AVFilterInOut *inputs = avfilter_inout_alloc();\n\n            m_pFilterGraph = avfilter_graph_alloc();\n\n            av_opt_set(m_pFilterGraph, \"thread_type\", \"slice\", AV_OPT_SEARCH_CHILDREN);\n            av_opt_set_int(m_pFilterGraph, \"threads\", FFMAX(1, av_cpu_count() / 2), AV_OPT_SEARCH_CHILDREN);\n\n            // 0/0 is not a valid value for avfilter, make sure it doesn't happen\n            AVRational aspect_ratio = pFrame->aspect_ratio;\n            if (aspect_ratio.num == 0 || aspect_ratio.den == 0)\n                aspect_ratio = {0, 1};\n\n            _snprintf_s(args, sizeof(args), \"video_size=%dx%d:pix_fmt=%s:time_base=1/10000000:pixel_aspect=%d/%d\",\n                        pFrame->width, pFrame->height, av_get_pix_fmt_name(ff_pixfmt), pFrame->aspect_ratio.num,\n                        pFrame->aspect_ratio.den);\n            ret = avfilter_graph_create_filter(&m_pFilterBufferSrc, buffersrc, \"in\", args, nullptr, m_pFilterGraph);\n            if (ret < 0)\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Filter()(init) Creating the input buffer filter failed with code %d\", ret));\n                avfilter_graph_free(&m_pFilterGraph);\n                goto deliver;\n            }\n\n            _snprintf_s(args, sizeof(args), \"pixel_formats=%s\",\n                        (ff_pixfmt == AV_PIX_FMT_NV12) ? \"nv12,yuv420p\" : av_get_pix_fmt_name(ff_pixfmt));\n            ret = avfilter_graph_create_filter(&m_pFilterBufferSink, buffersink, \"out\", args, nullptr, m_pFilterGraph);\n            if (ret < 0)\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Filter()(init) Creating the buffer sink filter failed with code %d\", ret));\n                avfilter_free(m_pFilterBufferSrc);\n                m_pFilterBufferSrc = nullptr;\n                avfilter_graph_free(&m_pFilterGraph);\n                goto deliver;\n            }\n\n            /* Endpoints for the filter graph. */\n            outputs->name = av_strdup(\"in\");\n            outputs->filter_ctx = m_pFilterBufferSrc;\n            outputs->pad_idx = 0;\n            outputs->next = nullptr;\n\n            inputs->name = av_strdup(\"out\");\n            inputs->filter_ctx = m_pFilterBufferSink;\n            inputs->pad_idx = 0;\n            inputs->next = nullptr;\n\n            if (m_settings.SWDeintMode == SWDeintMode_YADIF)\n                _snprintf_s(args, sizeof(args), \"yadif=mode=%s:parity=auto:deint=interlaced\",\n                            (m_settings.SWDeintOutput == DeintOutput_FramePerField) ? \"send_field\" : \"send_frame\");\n            else if (m_settings.SWDeintMode == SWDeintMode_W3FDIF_Simple)\n                _snprintf_s(args, sizeof(args), \"w3fdif=filter=simple:deint=interlaced:mode=%s:parity=auto\",\n                            (m_settings.SWDeintOutput == DeintOutput_FramePerField) ? \"field\" : \"frame\");\n            else if (m_settings.SWDeintMode == SWDeintMode_W3FDIF_Complex)\n                _snprintf_s(args, sizeof(args), \"w3fdif=filter=complex:deint=interlaced:mode=%s:parity=auto\",\n                            (m_settings.SWDeintOutput == DeintOutput_FramePerField) ? \"field\" : \"frame\");\n            else if (m_settings.SWDeintMode == SWDeintMode_BWDIF)\n                _snprintf_s(args, sizeof(args), \"bwdif=mode=%s:parity=auto:deint=interlaced\",\n                            (m_settings.SWDeintOutput == DeintOutput_FramePerField) ? \"send_field\" : \"send_frame\");\n            else\n                ASSERT(0);\n\n            if ((ret = avfilter_graph_parse_ptr(m_pFilterGraph, args, &inputs, &outputs, nullptr)) < 0)\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Filter()(init) Parsing the graph failed with code %d\", ret));\n                avfilter_graph_free(&m_pFilterGraph);\n                goto deliver;\n            }\n\n            if ((ret = avfilter_graph_config(m_pFilterGraph, nullptr)) < 0)\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Filter()(init) Configuring the graph failed with code %d\", ret));\n                avfilter_graph_free(&m_pFilterGraph);\n                goto deliver;\n            }\n\n            DbgLog((LOG_TRACE, 10, L\":Filter()(init) avfilter Initialization complete\"));\n        }\n\n        if (!m_pFilterGraph)\n            goto deliver;\n\n        if (pFrame->direct)\n        {\n            HRESULT hr = DeDirectFrame(pFrame, true);\n            if (FAILED(hr))\n            {\n                ReleaseFrame(&pFrame);\n                return hr;\n            }\n        }\n\n        AVFrame *in_frame = nullptr;\n        BOOL refcountedFrame = (m_Decoder.HasThreadSafeBuffers() == S_OK);\n        // When flushing, we feed a NULL frame\n        if (!bFlush)\n        {\n            in_frame = av_frame_alloc();\n\n            for (int i = 0; i < 4; i++)\n            {\n                in_frame->data[i] = pFrame->data[i];\n                in_frame->linesize[i] = (int)pFrame->stride[i];\n            }\n\n            in_frame->width = pFrame->width;\n            in_frame->height = pFrame->height;\n            in_frame->format = ff_pixfmt;\n            in_frame->pts = pFrame->rtStart;\n            in_frame->flags |= pFrame->interlaced ? AV_FRAME_FLAG_INTERLACED : 0;\n            in_frame->flags |= pFrame->tff ? AV_FRAME_FLAG_TOP_FIELD_FIRST : 0;\n            in_frame->sample_aspect_ratio = pFrame->aspect_ratio;\n\n            if (refcountedFrame)\n            {\n                AVBufferRef *pFrameBuf = av_buffer_create(nullptr, 0, lav_free_lavframe, pFrame, 0);\n                const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get((AVPixelFormat)in_frame->format);\n                int planes = (in_frame->format == AV_PIX_FMT_NV12) ? 2 : desc->nb_components;\n\n                for (int i = 0; i < planes; i++)\n                {\n                    int h_shift = (i == 1 || i == 2) ? desc->log2_chroma_h : 0;\n                    int plane_size = (in_frame->height >> h_shift) * in_frame->linesize[i];\n\n                    AVBufferRef *planeRef = av_buffer_ref(pFrameBuf);\n                    in_frame->buf[i] = av_buffer_create(in_frame->data[i], plane_size, lav_unref_frame, planeRef,\n                                                        AV_BUFFER_FLAG_READONLY);\n                }\n                av_buffer_unref(&pFrameBuf);\n            }\n\n            m_FilterPrevFrame = *pFrame;\n            memset(m_FilterPrevFrame.data, 0, sizeof(m_FilterPrevFrame.data));\n            m_FilterPrevFrame.destruct = nullptr;\n        }\n        else\n        {\n            if (!m_FilterPrevFrame.height) // if height is not set, the frame is most likely not valid\n                return S_OK;\n            *pFrame = m_FilterPrevFrame;\n        }\n\n        if ((ret = av_buffersrc_write_frame(m_pFilterBufferSrc, in_frame)) < 0)\n        {\n            av_frame_free(&in_frame);\n            goto deliver;\n        }\n\n        BOOL bFramePerField =\n            (m_settings.SWDeintMode != SWDeintMode_None && m_settings.SWDeintOutput == DeintOutput_FramePerField);\n\n        AVFrame *out_frame = av_frame_alloc();\n        HRESULT hrDeliver = S_OK;\n        while (SUCCEEDED(hrDeliver) && (av_buffersink_get_frame(m_pFilterBufferSink, out_frame) >= 0))\n        {\n            LAVFrame *outFrame = nullptr;\n            AllocateFrame(&outFrame);\n\n            REFERENCE_TIME rtDuration = pFrame->rtStop - pFrame->rtStart;\n            if (bFramePerField)\n                rtDuration >>= 1;\n\n            // Copy most settings over\n            outFrame->format = (out_frame->format == AV_PIX_FMT_YUV420P)\n                                   ? LAVPixFmt_YUV420\n                                   : (out_frame->format == AV_PIX_FMT_YUV422P) ? LAVPixFmt_YUV422 : LAVPixFmt_NV12;\n            outFrame->sw_format = outFrame->format;\n            outFrame->bpp = pFrame->bpp;\n            outFrame->ext_format = pFrame->ext_format;\n            outFrame->avgFrameDuration = pFrame->avgFrameDuration;\n            outFrame->flags = pFrame->flags;\n\n            outFrame->width = out_frame->width;\n            outFrame->height = out_frame->height;\n            outFrame->aspect_ratio = out_frame->sample_aspect_ratio;\n            outFrame->tff = !!(out_frame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST);\n\n            REFERENCE_TIME pts = av_rescale(out_frame->pts, m_pFilterBufferSink->inputs[0]->time_base.num * 10000000LL,\n                                            m_pFilterBufferSink->inputs[0]->time_base.den);\n            outFrame->rtStart = pts;\n            outFrame->rtStop = pts + rtDuration;\n\n            if (bFramePerField)\n            {\n                if (outFrame->avgFrameDuration != AV_NOPTS_VALUE)\n                    outFrame->avgFrameDuration /= 2;\n            }\n\n            for (int i = 0; i < 4; i++)\n            {\n                outFrame->data[i] = out_frame->data[i];\n                outFrame->stride[i] = out_frame->linesize[i];\n            }\n\n            outFrame->destruct = avfilter_free_lav_buffer;\n            outFrame->priv_data = av_frame_alloc();\n            av_frame_move_ref((AVFrame *)outFrame->priv_data, out_frame);\n\n            hrDeliver = DeliverToRenderer(outFrame);\n        }\n        if (!refcountedFrame)\n            ReleaseFrame(&pFrame);\n        av_frame_free(&in_frame);\n        av_frame_free(&out_frame);\n\n        // We EOF'ed the graph, need to close it\n        if (bFlush)\n        {\n            if (m_pFilterGraph)\n            {\n                avfilter_graph_free(&m_pFilterGraph);\n                m_pFilterBufferSrc = nullptr;\n                m_pFilterBufferSink = nullptr;\n            }\n        }\n\n        return S_OK;\n    }\n    else\n    {\n        m_filterPixFmt = LAVPixFmt_None;\n    deliver:\n        return DeliverToRenderer(pFrame);\n    }\n}\n"
  },
  {
    "path": "decoder/LAVVideo/LAVPixFmtConverter.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVPixFmtConverter.h\"\n#include \"Media.h\"\n\n#include \"decoders/ILAVDecoder.h\"\n\n#include <MMReg.h>\n#include \"moreuuids.h\"\n\n#include <time.h>\n#include \"rand_sse.h\"\n\n/*\n * Availability of custom high-quality converters\n * x = formatter available, - = fallback using swscale\n * 1 = up to 14-bit only\n * in/out       YV12    NV12    YV16     YUY2    UYVY    YV24   AYUV    P010    P210    v210    Y410    v410    P016\n * P216    Y416   RGB24   RGB32 YUV420         x       x       -       x       x       -       -       -       -       -\n * -       -       -       -       -      x       x YUV420bX       x       x       -       x1      x1      -       - x\n * -       -       -       -       x       -       -      x       x YUV422         -       -       x       x       x -\n * -       -       -       -       -       -       -       -       -      x       x YUV422bX       -       -       x x\n * x       -       -       -       x       -       -       -       -       x       -      x       x YUV444         - -\n * -       -       -       x       x       -       -       -       -       -       -       -       -      x       x\n * YUV444bX       -       -       -       -       -       x       x       -       -       -       x       -       - - x\n * x       x NV12           x       x       -       x       x       -       -       -       -       -       -       - -\n * -       -      x       x P010           -       x       -       -       -       -       -       x       -       - -\n * -       x       -       -      x       x YUY2           -       -       -       -       -       -       -       - -\n * -       -       -       -       -       -      -       - RGB24          -       -       -       -       -       - -\n * -       -       -       -       -       -       -       -      x       - RGB32          -       -       -       - -\n * -       -       -       -       -       -       -       -       -       -      -       x ARGB32         -       - -\n * -       -       -       -       -       -       -       -       -       -       -       -      -       x RGB48 - - -\n * -       -       -       -       -       -       -       -       -       -       -       -      x       x\n *\n * Every processing path has a swscale fallback (even those with a \"-\" above), every combination of input/output is\n * possible, just not optimized (ugly and/or slow)\n */\n\ntypedef struct\n{\n    LAVPixelFormat in_pix_fmt;\n    int maxbpp;\n    LAVOutPixFmts lav_pix_fmts[LAVOutPixFmt_NB + 1];\n} LAV_INOUT_PIXFMT_MAP;\n\n#define PIXOUT_420_8 LAVOutPixFmt_NV12, LAVOutPixFmt_YV12\n#define PIXOUT_422_8 LAVOutPixFmt_YUY2, LAVOutPixFmt_UYVY, LAVOutPixFmt_YV16\n#define PIXOUT_444_8 LAVOutPixFmt_YV24, LAVOutPixFmt_AYUV\n#define PIXOUT_RGB_8 LAVOutPixFmt_RGB32, LAVOutPixFmt_RGB24\n\n#define PIXOUT_420_10 LAVOutPixFmt_P010\n#define PIXOUT_422_10 LAVOutPixFmt_P210, LAVOutPixFmt_v210\n#define PIXOUT_444_10 LAVOutPixFmt_Y410, LAVOutPixFmt_v410\n\n#define PIXOUT_420_16 LAVOutPixFmt_P016\n#define PIXOUT_422_16 LAVOutPixFmt_P216\n#define PIXOUT_444_16 LAVOutPixFmt_Y416\n#define PIXOUT_RGB_16 LAVOutPixFmt_RGB48\n\n// clang-format off\nstatic LAV_INOUT_PIXFMT_MAP lav_pixfmt_map[] = {\n  // Default\n  { LAVPixFmt_None, 8,      { PIXOUT_420_8, PIXOUT_420_10, PIXOUT_420_16, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n\n  // 4:2:0\n  { LAVPixFmt_YUV420, 8,    { PIXOUT_420_8, PIXOUT_420_10, PIXOUT_420_16, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n  { LAVPixFmt_NV12,   8,    { PIXOUT_420_8, PIXOUT_420_10, PIXOUT_420_16, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n  { LAVPixFmt_P016,   10,   { PIXOUT_420_10, PIXOUT_420_16, PIXOUT_420_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n  { LAVPixFmt_P016,   16,   { PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n\n  { LAVPixFmt_YUV420bX, 10, { PIXOUT_420_10, PIXOUT_420_16, PIXOUT_420_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n  { LAVPixFmt_YUV420bX, 16, { PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n\n  // 4:2:2\n  { LAVPixFmt_YUV422, 8,    { PIXOUT_422_8, PIXOUT_422_10, PIXOUT_422_16, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_YUY2,   8,    { PIXOUT_422_8, PIXOUT_422_10, PIXOUT_422_16, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n\n  { LAVPixFmt_YUV422bX, 10, { PIXOUT_422_10, PIXOUT_422_16, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_YUV422bX, 16, { PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n\n  { LAVPixFmt_Y216,     10, { PIXOUT_422_10, PIXOUT_422_16, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_Y216,     16, { PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  \n  // 4:4:4\n  { LAVPixFmt_YUV444,    8, { PIXOUT_444_8, PIXOUT_444_10, PIXOUT_444_16, PIXOUT_RGB_16, PIXOUT_RGB_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_YUV444bX, 10, { PIXOUT_444_10, PIXOUT_444_16, PIXOUT_444_8, PIXOUT_RGB_16, PIXOUT_RGB_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_YUV444bX, 16, { PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_RGB_16, PIXOUT_RGB_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n\n  { LAVPixFmt_AYUV,      8, { LAVOutPixFmt_AYUV, LAVOutPixFmt_YV24, PIXOUT_444_10, PIXOUT_444_16, PIXOUT_RGB_16, PIXOUT_RGB_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_Y410,     10, { PIXOUT_444_10, PIXOUT_444_16, PIXOUT_444_8, PIXOUT_RGB_16, PIXOUT_RGB_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_Y416,     16, { PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_RGB_16, PIXOUT_RGB_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n\n  // RGB\n  { LAVPixFmt_RGB24,  8,    { LAVOutPixFmt_RGB24, LAVOutPixFmt_RGB32, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_RGB32,  8,    { PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_ARGB32, 8,    { PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n  { LAVPixFmt_RGB48,  8,    { PIXOUT_RGB_16, PIXOUT_RGB_8, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8 } },\n\n  { LAVPixFmt_DXVA2,  8,    { PIXOUT_420_8, PIXOUT_420_10, PIXOUT_420_16, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_RGB_16 } },\n  { LAVPixFmt_DXVA2, 10,    { PIXOUT_420_10, PIXOUT_420_16, PIXOUT_420_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n  { LAVPixFmt_DXVA2, 16,    { PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n\n  { LAVPixFmt_D3D11,  8,    { PIXOUT_420_8, PIXOUT_420_10, PIXOUT_420_16, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8, PIXOUT_RGB_16 } },\n  { LAVPixFmt_D3D11, 10,    { PIXOUT_420_10, PIXOUT_420_16, PIXOUT_420_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n  { LAVPixFmt_D3D11, 16,    { PIXOUT_420_16, PIXOUT_420_10, PIXOUT_420_8, PIXOUT_422_16, PIXOUT_422_10, PIXOUT_422_8, PIXOUT_RGB_8, PIXOUT_RGB_16, PIXOUT_444_16, PIXOUT_444_10, PIXOUT_444_8 } },\n};\n\nLAVOutPixFmtDesc lav_pixfmt_desc[] = {\n  { MEDIASUBTYPE_YV12,  12, 1, 3, { 1, 2, 2 }, { 1, 2, 2 } },        // YV12\n  { MEDIASUBTYPE_NV12,  12, 1, 2, { 1, 2 }, { 1, 1 } },              // NV12\n  { MEDIASUBTYPE_YUY2,  16, 2, 0, { 1 }, { 1 } },                    // YUY2 (packed)\n  { MEDIASUBTYPE_UYVY,  16, 2, 0, { 1 }, { 1 } },                    // UYVY (packed)\n  { MEDIASUBTYPE_AYUV,  32, 4, 0, { 1 }, { 1 } },                    // AYUV (packed)\n  { MEDIASUBTYPE_P010,  24, 2, 2, { 1, 2 }, { 1, 1 } },              // P010\n  { MEDIASUBTYPE_P210,  32, 2, 2, { 1, 1 }, { 1, 1 } },              // P210\n  { MEDIASUBTYPE_Y410,  32, 4, 0, { 1 }, { 1 }  },                   // Y410 (packed)\n  { MEDIASUBTYPE_P016,  24, 2, 2, { 1, 2 }, { 1, 1 } },              // P016\n  { MEDIASUBTYPE_P216,  32, 2, 2, { 1, 1 }, { 1, 1 } },              // P216\n  { MEDIASUBTYPE_Y416,  64, 8, 0, { 1 }, { 1 } },                    // Y416 (packed)\n  { MEDIASUBTYPE_RGB32, 32, 4, 0, { 1 }, { 1 } },                    // RGB32\n  { MEDIASUBTYPE_RGB24, 24, 3, 0, { 1 }, { 1 } },                    // RGB24\n  { FOURCCMap('012v'),  24, 4, 0, { 1 }, { 1 } },                    // v210 (packed)\n  { FOURCCMap('014v'),  32, 4, 0, { 1 }, { 1 }  },                   // v410 (packed)\n  { MEDIASUBTYPE_YV16,  16, 1, 3, { 1, 1, 1 }, { 1, 2, 2 } },        // YV16\n  { MEDIASUBTYPE_YV24,  24, 1, 3, { 1, 1, 1 }, { 1, 1, 1 } },        // YV24\n  { FOURCCMap('0BGR'),  48, 6, 0, { 1 }, { 1 } },                    // RGB48\n};\n// clang-format on\n\nstatic LAV_INOUT_PIXFMT_MAP *lookupFormatMap(LAVPixelFormat informat, int bpp, BOOL bFallbackToDefault = TRUE)\n{\n    for (int i = 0; i < countof(lav_pixfmt_map); ++i)\n    {\n        if (lav_pixfmt_map[i].in_pix_fmt == informat && bpp <= lav_pixfmt_map[i].maxbpp)\n        {\n            return &lav_pixfmt_map[i];\n        }\n    }\n    if (bFallbackToDefault)\n        return &lav_pixfmt_map[0];\n    return nullptr;\n}\n\nCLAVPixFmtConverter::CLAVPixFmtConverter()\n{\n    convert = &CLAVPixFmtConverter::convert_generic;\n    convert_direct = nullptr;\n\n    m_NumThreads = min(8, max(1, av_cpu_count() / 2));\n\n    ZeroMemory(&m_ColorProps, sizeof(m_ColorProps));\n}\n\nCLAVPixFmtConverter::~CLAVPixFmtConverter()\n{\n    DestroySWScale();\n    av_freep(&m_pAlignedBuffer);\n}\n\nLAVOutPixFmts CLAVPixFmtConverter::GetOutputBySubtype(const GUID *guid)\n{\n    for (int i = 0; i < countof(lav_pixfmt_desc); ++i)\n    {\n        if (lav_pixfmt_desc[i].subtype == *guid)\n        {\n            return (LAVOutPixFmts)i;\n        }\n    }\n    return LAVOutPixFmt_None;\n}\n\nint CLAVPixFmtConverter::GetFilteredFormatCount()\n{\n    LAV_INOUT_PIXFMT_MAP *pixFmtMap = lookupFormatMap(m_InputPixFmt, m_InBpp);\n    int count = 0;\n    for (int i = 0; i < LAVOutPixFmt_NB; ++i)\n    {\n        if (m_pSettings->GetPixelFormat(pixFmtMap->lav_pix_fmts[i]))\n            count++;\n    }\n\n    if (count == 0)\n        count = LAVOutPixFmt_NB;\n\n    return count;\n}\n\nLAVOutPixFmts CLAVPixFmtConverter::GetFilteredFormat(int index)\n{\n    LAV_INOUT_PIXFMT_MAP *pixFmtMap = lookupFormatMap(m_InputPixFmt, m_InBpp);\n    int actualIndex = -1;\n    for (int i = 0; i < LAVOutPixFmt_NB; ++i)\n    {\n        if (m_pSettings->GetPixelFormat(pixFmtMap->lav_pix_fmts[i]))\n            actualIndex++;\n        if (index == actualIndex)\n            return pixFmtMap->lav_pix_fmts[i];\n    }\n\n    // If no format is enabled, we use the fallback formats to avoid catastrophic failure\n    if (index >= LAVOutPixFmt_NB)\n        index = 0;\n    return lav_pixfmt_map[0].lav_pix_fmts[index];\n}\n\nLAVOutPixFmts CLAVPixFmtConverter::GetPreferredOutput()\n{\n    return GetFilteredFormat(0);\n}\n\nint CLAVPixFmtConverter::GetNumMediaTypes()\n{\n    return GetFilteredFormatCount();\n}\n\nvoid CLAVPixFmtConverter::GetMediaType(CMediaType *mt, int index, LONG biWidth, LONG biHeight, DWORD dwAspectX,\n                                       DWORD dwAspectY, REFERENCE_TIME rtAvgTime, BOOL bInterlaced, BOOL bVIH1)\n{\n    if (index < 0 || index >= GetFilteredFormatCount())\n        index = 0;\n\n    LAVOutPixFmts pixFmt = GetFilteredFormat(index);\n\n    GUID guid = lav_pixfmt_desc[pixFmt].subtype;\n\n    mt->SetType(&MEDIATYPE_Video);\n    mt->SetSubtype(&guid);\n\n    BITMAPINFOHEADER *pBIH = nullptr;\n    if (bVIH1)\n    {\n        mt->SetFormatType(&FORMAT_VideoInfo);\n\n        VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)mt->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER));\n        memset(vih, 0, sizeof(VIDEOINFOHEADER));\n\n        vih->rcSource.right = vih->rcTarget.right = biWidth;\n        vih->rcSource.bottom = vih->rcTarget.bottom = abs(biHeight);\n        vih->AvgTimePerFrame = rtAvgTime;\n\n        pBIH = &vih->bmiHeader;\n    }\n    else\n    {\n        mt->SetFormatType(&FORMAT_VideoInfo2);\n\n        VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)mt->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2));\n        memset(vih2, 0, sizeof(VIDEOINFOHEADER2));\n\n        // Validate the Aspect Ratio - an AR of 0 crashes VMR-9\n        if (dwAspectX == 0 || dwAspectY == 0)\n        {\n            dwAspectX = biWidth;\n            dwAspectY = abs(biHeight);\n        }\n\n        // Always reduce the AR to the smalles fraction\n        int dwX = 0, dwY = 0;\n        av_reduce(&dwX, &dwY, dwAspectX, dwAspectY, max(dwAspectX, dwAspectY));\n\n        vih2->rcSource.right = vih2->rcTarget.right = biWidth;\n        vih2->rcSource.bottom = vih2->rcTarget.bottom = abs(biHeight);\n        vih2->AvgTimePerFrame = rtAvgTime;\n        vih2->dwPictAspectRatioX = dwX;\n        vih2->dwPictAspectRatioY = dwY;\n\n        if (bInterlaced)\n            vih2->dwInterlaceFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;\n\n        pBIH = &vih2->bmiHeader;\n    }\n\n    pBIH->biSize = sizeof(BITMAPINFOHEADER);\n    pBIH->biWidth = biWidth;\n    pBIH->biHeight = biHeight;\n    pBIH->biBitCount = lav_pixfmt_desc[pixFmt].bpp;\n    pBIH->biPlanes = 1;\n    pBIH->biSizeImage = GetImageSize(biWidth, abs(biHeight), pixFmt);\n    pBIH->biCompression = guid.Data1;\n\n    if (guid == MEDIASUBTYPE_RGB32 || guid == MEDIASUBTYPE_RGB24)\n    {\n        pBIH->biCompression = BI_RGB;\n    }\n\n    // Correct implied stride for v210\n    if (guid == FOURCCMap('012v'))\n    {\n        pBIH->biWidth = FFALIGN(biWidth, 48);\n    }\n\n    mt->SetSampleSize(pBIH->biSizeImage);\n    mt->SetTemporalCompression(0);\n}\n\nDWORD CLAVPixFmtConverter::GetImageSize(int width, int height, LAVOutPixFmts pixFmt)\n{\n    if (pixFmt == LAVOutPixFmt_None)\n        pixFmt = m_OutputPixFmt;\n\n    if (pixFmt == LAVOutPixFmt_None)\n    {\n        ASSERT(0);\n        // Safe value that should work for all pixel formats, just in case this happens\n        return width * height * 16;\n    }\n\n    if (pixFmt == LAVOutPixFmt_v210)\n        return ((width + 47) / 48) * 128 * height;\n    else\n    {\n        return (width * height * lav_pixfmt_desc[pixFmt].bpp) >> 3;\n    }\n}\n\nBOOL CLAVPixFmtConverter::IsAllowedSubtype(const GUID *guid)\n{\n    for (int i = 0; i < GetFilteredFormatCount(); ++i)\n    {\n        if (lav_pixfmt_desc[GetFilteredFormat(i)].subtype == *guid)\n            return TRUE;\n    }\n\n    return FALSE;\n}\n\nvoid CLAVPixFmtConverter::SelectConvertFunction()\n{\n    m_RequiredAlignment = 16;\n    m_bRGBConverter = FALSE;\n    convert = nullptr;\n\n    int cpu = av_get_cpu_flags();\n    if (m_OutputPixFmt == LAVOutPixFmt_v210 || m_OutputPixFmt == LAVOutPixFmt_v410)\n    {\n        // We assume that every filter that understands v210 will also properly handle it\n        m_RequiredAlignment = 0;\n    }\n    else if ((m_OutputPixFmt == LAVOutPixFmt_RGB32 &&\n              (m_InputPixFmt == LAVPixFmt_RGB32 || m_InputPixFmt == LAVPixFmt_ARGB32)) ||\n             (m_OutputPixFmt == LAVOutPixFmt_RGB24 && m_InputPixFmt == LAVPixFmt_RGB24) ||\n             (m_OutputPixFmt == LAVOutPixFmt_RGB48 && m_InputPixFmt == LAVPixFmt_RGB48) ||\n             (m_OutputPixFmt == LAVOutPixFmt_YUY2 && m_InputPixFmt == LAVPixFmt_YUY2) ||\n             (m_OutputPixFmt == LAVOutPixFmt_AYUV && m_InputPixFmt == LAVPixFmt_AYUV) ||\n             (m_OutputPixFmt == LAVOutPixFmt_Y410 && m_InputPixFmt == LAVPixFmt_Y410) ||\n             (m_OutputPixFmt == LAVOutPixFmt_Y416 && m_InputPixFmt == LAVPixFmt_Y416) ||\n             (m_OutputPixFmt == LAVOutPixFmt_NV12 && m_InputPixFmt == LAVPixFmt_NV12) ||\n             ((m_OutputPixFmt == LAVOutPixFmt_P010 || m_OutputPixFmt == LAVOutPixFmt_P016) &&\n              m_InputPixFmt == LAVPixFmt_P016))\n    {\n        if (cpu & AV_CPU_FLAG_SSE2)\n            convert = &CLAVPixFmtConverter::plane_copy_sse2;\n        else\n            convert = &CLAVPixFmtConverter::plane_copy;\n        m_RequiredAlignment = 0;\n    }\n    else if (m_InputPixFmt == LAVPixFmt_RGB48 && m_OutputPixFmt == LAVOutPixFmt_RGB32 && (cpu & AV_CPU_FLAG_SSSE3))\n    {\n        convert = &CLAVPixFmtConverter::convert_rgb48_rgb32_ssse3;\n    }\n    else if (cpu & AV_CPU_FLAG_SSE2)\n    {\n        if (m_OutputPixFmt == LAVOutPixFmt_AYUV && m_InputPixFmt == LAVPixFmt_YUV444bX)\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv444_ayuv_dither_le;\n        }\n        else if (m_OutputPixFmt == LAVOutPixFmt_AYUV && m_InputPixFmt == LAVPixFmt_YUV444)\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv444_ayuv;\n        }\n        else if (m_OutputPixFmt == LAVOutPixFmt_Y410 && m_InputPixFmt == LAVPixFmt_YUV444bX && m_InBpp <= 10)\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv444_y410;\n        }\n        else if (((m_OutputPixFmt == LAVOutPixFmt_YV12 || m_OutputPixFmt == LAVOutPixFmt_NV12) &&\n                  m_InputPixFmt == LAVPixFmt_YUV420bX) ||\n                 (m_OutputPixFmt == LAVOutPixFmt_YV16 && m_InputPixFmt == LAVPixFmt_YUV422bX) ||\n                 (m_OutputPixFmt == LAVOutPixFmt_YV24 && m_InputPixFmt == LAVPixFmt_YUV444bX))\n        {\n            if (m_OutputPixFmt == LAVOutPixFmt_NV12)\n            {\n                convert = &CLAVPixFmtConverter::convert_yuv_yv_nv12_dither_le<TRUE>;\n            }\n            else\n            {\n                convert = &CLAVPixFmtConverter::convert_yuv_yv_nv12_dither_le<FALSE>;\n            }\n            m_RequiredAlignment = 32;\n        }\n        else if (((m_OutputPixFmt == LAVOutPixFmt_P010 || m_OutputPixFmt == LAVOutPixFmt_P016) &&\n                  m_InputPixFmt == LAVPixFmt_YUV420bX) ||\n                 ((m_OutputPixFmt == LAVOutPixFmt_P210 || m_OutputPixFmt == LAVOutPixFmt_P216) &&\n                  m_InputPixFmt == LAVPixFmt_YUV422bX))\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv420_px1x_le;\n        }\n        else if (m_OutputPixFmt == LAVOutPixFmt_NV12 && m_InputPixFmt == LAVPixFmt_YUV420)\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv420_nv12;\n            m_RequiredAlignment = 32;\n        }\n        else if (m_OutputPixFmt == LAVOutPixFmt_YUY2 && m_InputPixFmt == LAVPixFmt_YUV422)\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv422_yuy2_uyvy<0>;\n            m_RequiredAlignment = 32;\n        }\n        else if (m_OutputPixFmt == LAVOutPixFmt_UYVY && m_InputPixFmt == LAVPixFmt_YUV422)\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv422_yuy2_uyvy<1>;\n            m_RequiredAlignment = 32;\n        }\n        else if ((m_OutputPixFmt == LAVOutPixFmt_RGB32 || m_OutputPixFmt == LAVOutPixFmt_RGB24) &&\n                 (m_InputPixFmt == LAVPixFmt_YUV420 || m_InputPixFmt == LAVPixFmt_YUV420bX ||\n                  m_InputPixFmt == LAVPixFmt_YUV422 || m_InputPixFmt == LAVPixFmt_YUV422bX ||\n                  m_InputPixFmt == LAVPixFmt_YUV444 || m_InputPixFmt == LAVPixFmt_YUV444bX ||\n                  m_InputPixFmt == LAVPixFmt_NV12 || m_InputPixFmt == LAVPixFmt_P016))\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv_rgb;\n            if (m_OutputPixFmt == LAVOutPixFmt_RGB32)\n            {\n                m_RequiredAlignment = 4;\n            }\n            m_bRGBConverter = TRUE;\n        }\n        else if (m_OutputPixFmt == LAVOutPixFmt_YV12 && m_InputPixFmt == LAVPixFmt_NV12)\n        {\n            convert = &CLAVPixFmtConverter::convert_nv12_yv12;\n            m_RequiredAlignment = 32;\n        }\n        else if ((m_OutputPixFmt == LAVOutPixFmt_YUY2 || m_OutputPixFmt == LAVOutPixFmt_UYVY) &&\n                 (m_InputPixFmt == LAVPixFmt_YUV420 || m_InputPixFmt == LAVPixFmt_NV12 ||\n                  m_InputPixFmt == LAVPixFmt_YUV420bX) &&\n                 m_InBpp <= 14)\n        {\n            if (m_OutputPixFmt == LAVOutPixFmt_YUY2)\n            {\n                convert = &CLAVPixFmtConverter::convert_yuv420_yuy2<0>;\n            }\n            else\n            {\n                convert = &CLAVPixFmtConverter::convert_yuv420_yuy2<1>;\n            }\n            m_RequiredAlignment = 8; // Pixel alignment of 8 guarantees a byte alignment of 16\n        }\n        else if ((m_OutputPixFmt == LAVOutPixFmt_YUY2 || m_OutputPixFmt == LAVOutPixFmt_UYVY) &&\n                 m_InputPixFmt == LAVPixFmt_YUV422bX)\n        {\n            if (m_OutputPixFmt == LAVOutPixFmt_YUY2)\n            {\n                convert = &CLAVPixFmtConverter::convert_yuv422_yuy2_uyvy_dither_le<0>;\n            }\n            else\n            {\n                convert = &CLAVPixFmtConverter::convert_yuv422_yuy2_uyvy_dither_le<1>;\n            }\n\n            m_RequiredAlignment = 8; // Pixel alignment of 8 guarantees a byte alignment of 16\n        }\n        else if ((m_OutputPixFmt == LAVOutPixFmt_YV12 && m_InputPixFmt == LAVPixFmt_YUV420) ||\n                 (m_OutputPixFmt == LAVOutPixFmt_YV16 && m_InputPixFmt == LAVPixFmt_YUV422) ||\n                 (m_OutputPixFmt == LAVOutPixFmt_YV24 && m_InputPixFmt == LAVPixFmt_YUV444))\n        {\n            convert = &CLAVPixFmtConverter::convert_yuv_yv;\n            m_RequiredAlignment = 0;\n        }\n        else if (m_InputPixFmt == LAVPixFmt_RGB48 &&\n                 (m_OutputPixFmt == LAVOutPixFmt_RGB24 || m_OutputPixFmt == LAVOutPixFmt_RGB32))\n        {\n            if (m_OutputPixFmt == LAVOutPixFmt_RGB32)\n                convert = &CLAVPixFmtConverter::convert_rgb48_rgb<1>;\n            else\n                convert = &CLAVPixFmtConverter::convert_rgb48_rgb<0>;\n        }\n        else if (m_InputPixFmt == LAVPixFmt_P016 && m_OutputPixFmt == LAVOutPixFmt_NV12)\n        {\n            convert = &CLAVPixFmtConverter::convert_p010_nv12_sse2;\n        }\n        else if (m_InputPixFmt == LAVPixFmt_Y216 &&\n                 (m_OutputPixFmt == LAVOutPixFmt_P210 || m_OutputPixFmt == LAVOutPixFmt_P216) &&\n                  (cpu & AV_CPU_FLAG_SSE4))\n        {\n            convert = &CLAVPixFmtConverter::convert_y210_p210_sse4;\n            m_RequiredAlignment = 4; // alignment of four pixel gives us a byte alignment of 16, the absolute minimum requirement\n        }\n        else if (m_InputPixFmt == LAVPixFmt_YUY2 && m_OutputPixFmt == LAVOutPixFmt_YV16)\n        {\n            convert = &CLAVPixFmtConverter::convert_yuy2_yv16_sse2;\n        }\n    }\n\n    if (convert == nullptr)\n    {\n        convert = &CLAVPixFmtConverter::convert_generic;\n    }\n\n    SelectConvertFunctionDirect();\n}\n\nvoid CLAVPixFmtConverter::SelectConvertFunctionDirect()\n{\n    convert_direct = nullptr;\n    m_bDirectMode = FALSE;\n\n    int cpu = av_get_cpu_flags();\n    if ((m_InputPixFmt == LAVPixFmt_NV12 && m_OutputPixFmt == LAVOutPixFmt_NV12) ||\n        (m_InputPixFmt == LAVPixFmt_P016 &&\n         (m_OutputPixFmt == LAVOutPixFmt_P010 || m_OutputPixFmt == LAVOutPixFmt_P016)))\n    {\n        if (cpu & AV_CPU_FLAG_SSE4)\n            convert_direct = &CLAVPixFmtConverter::plane_copy_direct_nv12_sse4;\n        else if (cpu & AV_CPU_FLAG_SSE2)\n            convert_direct = &CLAVPixFmtConverter::plane_copy_sse2;\n        else\n            convert_direct = &CLAVPixFmtConverter::plane_copy;\n    }\n    else if ((m_InputPixFmt == LAVPixFmt_YUY2 && m_OutputPixFmt == LAVOutPixFmt_YUY2) ||\n        (m_InputPixFmt == LAVPixFmt_AYUV && m_OutputPixFmt == LAVOutPixFmt_AYUV) ||\n        (m_InputPixFmt == LAVPixFmt_Y410 && m_OutputPixFmt == LAVOutPixFmt_Y410) ||\n        (m_InputPixFmt == LAVPixFmt_Y416 && m_OutputPixFmt == LAVOutPixFmt_Y416))\n    {\n        if (cpu & AV_CPU_FLAG_SSE4)\n            convert_direct = &CLAVPixFmtConverter::plane_copy_direct_sse4;\n        else if (cpu & AV_CPU_FLAG_SSE2)\n            convert_direct = &CLAVPixFmtConverter::plane_copy_sse2;\n        else\n            convert_direct = &CLAVPixFmtConverter::plane_copy;\n    }\n    else if (m_InputPixFmt == LAVPixFmt_P016 && m_OutputPixFmt == LAVOutPixFmt_NV12)\n    {\n        if (cpu & AV_CPU_FLAG_SSE4)\n            convert_direct = &CLAVPixFmtConverter::convert_p010_nv12_direct_sse4;\n        else if (cpu & AV_CPU_FLAG_SSE2)\n            convert_direct = &CLAVPixFmtConverter::convert_p010_nv12_sse2;\n    }\n    else if (m_InputPixFmt == LAVPixFmt_NV12 && m_OutputPixFmt == LAVOutPixFmt_YV12)\n    {\n        if (cpu & AV_CPU_FLAG_SSE4)\n            convert_direct = &CLAVPixFmtConverter::convert_nv12_yv12_direct_sse4;\n        else if (cpu & AV_CPU_FLAG_SSE2)\n            convert_direct = &CLAVPixFmtConverter::convert_nv12_yv12;\n    }\n    else if (m_InputPixFmt == LAVPixFmt_Y216 && (m_OutputPixFmt == LAVOutPixFmt_P210 || m_OutputPixFmt == LAVOutPixFmt_P216))\n    {\n        if (cpu & AV_CPU_FLAG_SSE4)\n            convert_direct = &CLAVPixFmtConverter::convert_y210_p210_direct_sse4;\n    }\n    else if (m_InputPixFmt == LAVPixFmt_YUY2 && m_OutputPixFmt == LAVOutPixFmt_YV16)\n    {\n        if (cpu & AV_CPU_FLAG_SSE4)\n            convert_direct = &CLAVPixFmtConverter::convert_yuy2_yv16_direct_sse4;\n        else if (cpu & AV_CPU_FLAG_SSE2)\n            convert_direct = &CLAVPixFmtConverter::convert_yuy2_yv16_sse2;\n    }\n\n    if (convert_direct != nullptr)\n        m_bDirectMode = TRUE;\n}\n\nHRESULT CLAVPixFmtConverter::Convert(const BYTE *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst, int width,\n                                     int height, ptrdiff_t dstStride, int planeHeight)\n{\n    uint8_t *out = dst;\n    ptrdiff_t outStride = dstStride, i;\n    planeHeight = max(height, planeHeight);\n    // Check if we have proper pixel alignment and the dst memory is actually aligned\n    if (m_RequiredAlignment && (FFALIGN(dstStride, m_RequiredAlignment) != dstStride || ((uintptr_t)dst % 16u)))\n    {\n        outStride = FFALIGN(dstStride, m_RequiredAlignment);\n        size_t requiredSize = (outStride * planeHeight * lav_pixfmt_desc[m_OutputPixFmt].bpp) >> 3;\n        if (requiredSize > m_nAlignedBufferSize || !m_pAlignedBuffer)\n        {\n            DbgLog((LOG_TRACE, 10,\n                    L\"::Convert(): Conversion requires a bigger stride (need: %d, have: %d), allocating buffer...\",\n                    outStride, dstStride));\n            av_freep(&m_pAlignedBuffer);\n            m_pAlignedBuffer = (uint8_t *)av_malloc(requiredSize + AV_INPUT_BUFFER_PADDING_SIZE);\n            if (!m_pAlignedBuffer)\n            {\n                return E_FAIL;\n            }\n            m_nAlignedBufferSize = requiredSize;\n        }\n        out = m_pAlignedBuffer;\n    }\n\n    uint8_t *dstArray[4] = {0};\n    ptrdiff_t dstStrideArray[4] = {0};\n    ptrdiff_t byteStride = outStride * lav_pixfmt_desc[m_OutputPixFmt].codedbytes;\n\n    dstArray[0] = out;\n    dstStrideArray[0] = byteStride;\n\n    for (i = 1; i < lav_pixfmt_desc[m_OutputPixFmt].planes; ++i)\n    {\n        dstArray[i] = dstArray[i - 1] +\n                      dstStrideArray[i - 1] * (planeHeight / lav_pixfmt_desc[m_OutputPixFmt].planeHeight[i - 1]);\n        dstStrideArray[i] = byteStride / lav_pixfmt_desc[m_OutputPixFmt].planeWidth[i];\n    }\n\n    HRESULT hr = (this->*convert)(src, srcStride, dstArray, dstStrideArray, width, height, m_InputPixFmt, m_InBpp,\n                                  m_OutputPixFmt);\n    if (out != dst)\n    {\n        ChangeStride(out, outStride, dst, dstStride, width, height, planeHeight, m_OutputPixFmt);\n    }\n    return hr;\n}\n\nBOOL CLAVPixFmtConverter::IsDirectModeSupported(uintptr_t dst, ptrdiff_t stride)\n{\n    const int stride_align = ((m_OutputPixFmt == LAVOutPixFmt_YV12 || m_OutputPixFmt == LAVOutPixFmt_YV16) ? 32 : 16);\n    if (FFALIGN(stride, stride_align) != stride || (dst % 16u))\n        return false;\n    return m_bDirectMode;\n}\n\nHRESULT CLAVPixFmtConverter::ConvertDirect(LAVFrame *pFrame, uint8_t *dst, int width, int height, ptrdiff_t dstStride,\n                                           int planeHeight)\n{\n    HRESULT hr = S_OK;\n    planeHeight = max(height, planeHeight);\n    ASSERT(pFrame->direct && pFrame->direct_lock && pFrame->direct_unlock);\n\n    LAVDirectBuffer buffer{};\n    if (pFrame->direct_lock(pFrame, &buffer))\n    {\n        uint8_t *dstArray[4] = {0};\n        ptrdiff_t dstStrideArray[4] = {0};\n        ptrdiff_t byteStride = dstStride * lav_pixfmt_desc[m_OutputPixFmt].codedbytes;\n\n        dstArray[0] = dst;\n        dstStrideArray[0] = byteStride;\n\n        for (int i = 1; i < lav_pixfmt_desc[m_OutputPixFmt].planes; ++i)\n        {\n            dstArray[i] = dstArray[i - 1] +\n                          dstStrideArray[i - 1] * (planeHeight / lav_pixfmt_desc[m_OutputPixFmt].planeHeight[i - 1]);\n            dstStrideArray[i] = byteStride / lav_pixfmt_desc[m_OutputPixFmt].planeWidth[i];\n        }\n\n        hr = (this->*convert_direct)(buffer.data, buffer.stride, dstArray, dstStrideArray, width, height, m_InputPixFmt,\n                                     m_InBpp, m_OutputPixFmt);\n        pFrame->direct_unlock(pFrame);\n    }\n\n    return hr;\n}\n\nvoid CLAVPixFmtConverter::ChangeStride(const uint8_t *src, ptrdiff_t srcStride, uint8_t *dst, ptrdiff_t dstStride,\n                                       int width, int height, int planeHeight, LAVOutPixFmts format)\n{\n    LAVOutPixFmtDesc desc = lav_pixfmt_desc[format];\n\n    int line = 0;\n\n    // Copy first plane\n    const size_t widthBytes = width * desc.codedbytes;\n    const ptrdiff_t srcStrideBytes = srcStride * desc.codedbytes;\n    const ptrdiff_t dstStrideBytes = dstStride * desc.codedbytes;\n    for (line = 0; line < height; ++line)\n    {\n        memcpy(dst, src, widthBytes);\n        src += srcStrideBytes;\n        dst += dstStrideBytes;\n    }\n    dst += (planeHeight - height) * dstStrideBytes;\n\n    for (int plane = 1; plane < desc.planes; ++plane)\n    {\n        const size_t planeWidth = widthBytes / desc.planeWidth[plane];\n        const int activePlaneHeight = height / desc.planeHeight[plane];\n        const int totalPlaneHeight = planeHeight / desc.planeHeight[plane];\n        const ptrdiff_t srcPlaneStride = srcStrideBytes / desc.planeWidth[plane];\n        const ptrdiff_t dstPlaneStride = dstStrideBytes / desc.planeWidth[plane];\n        for (line = 0; line < activePlaneHeight; ++line)\n        {\n            memcpy(dst, src, planeWidth);\n            src += srcPlaneStride;\n            dst += dstPlaneStride;\n        }\n        dst += (totalPlaneHeight - activePlaneHeight) * dstPlaneStride;\n    }\n}\n\nconst uint16_t *CLAVPixFmtConverter::GetRandomDitherCoeffs(int height, int coeffs, int bits, int line)\n{\n    if (m_pSettings->GetDitherMode() != LAVDither_Random)\n        return nullptr;\n\n    int totalWidth = 8 * coeffs;\n    if (!m_pRandomDithers || totalWidth > m_ditherWidth || height > m_ditherHeight || bits != m_ditherBits)\n    {\n        if (m_pRandomDithers)\n            _aligned_free(m_pRandomDithers);\n        m_pRandomDithers = nullptr;\n        m_ditherWidth = totalWidth;\n        m_ditherHeight = height;\n        m_ditherBits = bits;\n        m_pRandomDithers = (uint16_t *)_aligned_malloc(m_ditherWidth * m_ditherHeight * 2, 16);\n        if (m_pRandomDithers == nullptr)\n            return nullptr;\n\n#ifdef DEBUG\n        LARGE_INTEGER frequency, start, end;\n        QueryPerformanceFrequency(&frequency);\n        QueryPerformanceCounter(&start);\n        DbgLog((LOG_TRACE, 10, L\"Creating dither matrix\"));\n#endif\n\n        // Seed random number generator\n        time_t seed = time(nullptr);\n        seed >>= 1;\n        srand_sse((unsigned int)seed);\n\n        bits = (1 << bits);\n        for (int i = 0; i < m_ditherHeight; i++)\n        {\n            uint16_t *ditherline = m_pRandomDithers + (m_ditherWidth * i);\n            for (int j = 0; j < m_ditherWidth; j += 4)\n            {\n                int rnds[4];\n                rand_sse(rnds);\n                ditherline[j + 0] = rnds[0] % bits;\n                ditherline[j + 1] = rnds[1] % bits;\n                ditherline[j + 2] = rnds[2] % bits;\n                ditherline[j + 3] = rnds[3] % bits;\n            }\n        }\n#ifdef DEBUG\n        QueryPerformanceCounter(&end);\n        double diff = (end.QuadPart - start.QuadPart) * 1000.0 / frequency.QuadPart;\n        DbgLog((LOG_TRACE, 10, L\"Finished creating dither matrix (took %2.3fms)\", diff));\n#endif\n    }\n\n    if (line < 0 || line >= m_ditherHeight)\n        line = rand() % m_ditherHeight;\n\n    return &m_pRandomDithers[line * m_ditherWidth];\n}\n"
  },
  {
    "path": "decoder/LAVVideo/LAVPixFmtConverter.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"LAVVideoSettings.h\"\n#include \"decoders/ILAVDecoder.h\"\n\n#include <emmintrin.h>\n\n#define CONV_FUNC_PARAMS                                                                                       \\\n    (const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[4], const ptrdiff_t dstStride[4], \\\n     int width, int height, LAVPixelFormat inputFormat, int bpp, LAVOutPixFmts outputFormat)\n\n#define DECLARE_CONV_FUNC(name) HRESULT name CONV_FUNC_PARAMS\n\n#define DECLARE_CONV_FUNC_IMPL(name) DECLARE_CONV_FUNC(CLAVPixFmtConverter::name)\n\n// Important, when adding new pixel formats, they need to be added in LAVPixFmtConverter.cpp as well to the format\n// descriptors\ntypedef struct\n{\n    GUID subtype;\n    int bpp;\n    int codedbytes;\n    int planes;\n    int planeHeight[4];\n    int planeWidth[4];\n} LAVOutPixFmtDesc;\n\ntypedef struct _RGBCoeffs\n{\n    __m128i Ysub;\n    __m128i CbCr_center;\n    __m128i rgb_add;\n    __m128i cy;\n    __m128i cR_Cr;\n    __m128i cG_Cb_cG_Cr;\n    __m128i cB_Cb;\n} RGBCoeffs;\n\ntypedef int(__stdcall *YUVRGBConversionFunc)(const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV,\n                                             uint8_t *dst, int width, int height, ptrdiff_t srcStrideY,\n                                             ptrdiff_t srcStrideUV, ptrdiff_t dstStride, ptrdiff_t sliceYStart,\n                                             ptrdiff_t sliceYEnd, const RGBCoeffs *coeffs, const uint16_t *dithers);\n\nextern LAVOutPixFmtDesc lav_pixfmt_desc[];\n\nclass CLAVPixFmtConverter\n{\n  public:\n    CLAVPixFmtConverter();\n    ~CLAVPixFmtConverter();\n\n    void SetSettings(ILAVVideoSettings *pSettings) { m_pSettings = pSettings; }\n\n    BOOL SetInputFmt(enum LAVPixelFormat pixfmt, int bpp)\n    {\n        ASSERT(pixfmt != LAVPixFmt_None && pixfmt != LAVPixFmt_D3D11 && pixfmt != LAVPixFmt_DXVA2);\n        if (m_InputPixFmt != pixfmt || m_InBpp != bpp)\n        {\n            m_InputPixFmt = pixfmt;\n            m_InBpp = bpp;\n            DestroySWScale();\n            SelectConvertFunction();\n            return TRUE;\n        }\n        return FALSE;\n    }\n    HRESULT SetOutputPixFmt(enum LAVOutPixFmts pix_fmt)\n    {\n        m_OutputPixFmt = pix_fmt;\n        DestroySWScale();\n        SelectConvertFunction();\n        return S_OK;\n    }\n\n    LAVOutPixFmts GetOutputBySubtype(const GUID *guid);\n    LAVOutPixFmts GetPreferredOutput();\n\n    LAVOutPixFmts GetOutputPixFmt() { return m_OutputPixFmt; }\n    void SetColorProps(DXVA2_ExtendedFormat props, int RGBOutputRange)\n    {\n        if (props.value != m_ColorProps.value || swsOutputRange != RGBOutputRange)\n        {\n            DestroySWScale();\n            m_ColorProps = props;\n            swsOutputRange = RGBOutputRange;\n        }\n    }\n\n    int GetNumMediaTypes();\n    void GetMediaType(CMediaType *mt, int index, LONG biWidth, LONG biHeight, DWORD dwAspectX, DWORD dwAspectY,\n                      REFERENCE_TIME rtAvgTime, BOOL bInterlaced = TRUE, BOOL bVIH1 = FALSE);\n    BOOL IsAllowedSubtype(const GUID *guid);\n\n    HRESULT Convert(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst, int width, int height,\n                    ptrdiff_t dstStride, int planeHeight);\n    HRESULT ConvertDirect(LAVFrame *pFrame, uint8_t *dst, int width, int height, ptrdiff_t dstStride, int planeHeight);\n\n    BOOL IsRGBConverterActive() { return m_bRGBConverter; }\n    BOOL IsDirectModeSupported(uintptr_t dst, ptrdiff_t stride);\n\n    DWORD GetImageSize(int width, int height, LAVOutPixFmts pixFmt = LAVOutPixFmt_None);\n\n  private:\n    AVPixelFormat GetFFInput() { return getFFPixelFormatFromLAV(m_InputPixFmt, m_InBpp); }\n\n    int GetFilteredFormatCount();\n    LAVOutPixFmts GetFilteredFormat(int index);\n\n    void SelectConvertFunction();\n    void SelectConvertFunctionDirect();\n\n    // Helper functions for convert_generic\n    HRESULT swscale_scale(enum AVPixelFormat srcPix, enum AVPixelFormat dstPix, const uint8_t *const src[4],\n                          const ptrdiff_t srcStride[4], uint8_t *dst[4], int width, int height,\n                          const ptrdiff_t dstStride[4], LAVOutPixFmtDesc pixFmtDesc, bool swapPlanes12 = false);\n    HRESULT ConvertTo422Packed(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[4], int width,\n                               int height, const ptrdiff_t dstStride[4]);\n    HRESULT ConvertToAYUV(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[4], int width,\n                          int height, const ptrdiff_t dstStride[4]);\n    HRESULT ConvertToPX1X(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[4], int width,\n                          int height, const ptrdiff_t dstStride[4], int chromaVertical);\n    HRESULT ConvertToY410(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[4], int width,\n                          int height, const ptrdiff_t dstStride[4]);\n    HRESULT ConvertToY416(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[4], int width,\n                          int height, const ptrdiff_t dstStride[4]);\n    HRESULT ConvertTov210(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[4], int width,\n                          int height, const ptrdiff_t dstStride[4]);\n    HRESULT ConvertTov410(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[4], int width,\n                          int height, const ptrdiff_t dstStride[4]);\n\n    void DestroySWScale()\n    {\n        if (m_pSwsContext)\n            sws_freeContext(m_pSwsContext);\n        m_pSwsContext = nullptr;\n        if (m_rgbCoeffs)\n            _aligned_free(m_rgbCoeffs);\n        m_rgbCoeffs = nullptr;\n        if (m_pRandomDithers)\n            _aligned_free(m_pRandomDithers);\n        m_pRandomDithers = nullptr;\n    };\n    SwsContext *GetSWSContext(int width, int height, enum AVPixelFormat srcPix, enum AVPixelFormat dstPix, int flags);\n\n    void ChangeStride(const uint8_t *src, ptrdiff_t srcStride, uint8_t *dst, ptrdiff_t dstStride, int width, int height,\n                      int planeHeight, LAVOutPixFmts format);\n\n    typedef HRESULT(CLAVPixFmtConverter::*ConverterFn) CONV_FUNC_PARAMS;\n\n    // Conversion function pointer\n    ConverterFn convert;\n    ConverterFn convert_direct;\n\n    // Pixel Implementations\n    DECLARE_CONV_FUNC(convert_generic);\n    DECLARE_CONV_FUNC(plane_copy);\n    DECLARE_CONV_FUNC(plane_copy_sse2);\n    DECLARE_CONV_FUNC(convert_yuv444_ayuv);\n    DECLARE_CONV_FUNC(convert_yuv444_ayuv_dither_le);\n    DECLARE_CONV_FUNC(convert_yuv444_y410);\n    DECLARE_CONV_FUNC(convert_yuv420_px1x_le);\n    DECLARE_CONV_FUNC(convert_yuv420_nv12);\n    DECLARE_CONV_FUNC(convert_yuv_yv);\n    DECLARE_CONV_FUNC(convert_nv12_yv12);\n    DECLARE_CONV_FUNC(convert_p010_nv12_sse2);\n    DECLARE_CONV_FUNC(convert_y210_p210_sse4);\n    template <int uyvy> DECLARE_CONV_FUNC(convert_yuv420_yuy2);\n    template <int uyvy> DECLARE_CONV_FUNC(convert_yuv422_yuy2_uyvy);\n    template <int uyvy> DECLARE_CONV_FUNC(convert_yuv422_yuy2_uyvy_dither_le);\n    template <int nv12> DECLARE_CONV_FUNC(convert_yuv_yv_nv12_dither_le);\n\n    DECLARE_CONV_FUNC(convert_rgb48_rgb32_ssse3);\n    template <int out32> DECLARE_CONV_FUNC(convert_rgb48_rgb);\n\n    DECLARE_CONV_FUNC(plane_copy_direct_sse4);\n    DECLARE_CONV_FUNC(plane_copy_direct_nv12_sse4);\n    DECLARE_CONV_FUNC(convert_nv12_yv12_direct_sse4);\n    DECLARE_CONV_FUNC(convert_p010_nv12_direct_sse4);\n    DECLARE_CONV_FUNC(convert_y210_p210_direct_sse4);\n\n    DECLARE_CONV_FUNC(convert_yuy2_yv16_sse2);\n    DECLARE_CONV_FUNC(convert_yuy2_yv16_direct_sse4);\n\n    DECLARE_CONV_FUNC(convert_yuv_rgb);\n    const RGBCoeffs *getRGBCoeffs(int width, int height);\n    void InitRGBConvDispatcher();\n\n    const uint16_t *GetRandomDitherCoeffs(int height, int coeffs, int bits, int line);\n\n  private:\n    LAVPixelFormat m_InputPixFmt = LAVPixFmt_None;\n    LAVOutPixFmts m_OutputPixFmt = LAVOutPixFmt_YV12;\n    int m_InBpp = 0;\n\n    BOOL m_bDirectMode = false;\n\n    int swsWidth = 0;\n    int swsHeight = 0;\n    int swsOutputRange = 0;\n\n    DXVA2_ExtendedFormat m_ColorProps;\n\n    ptrdiff_t m_RequiredAlignment = 0;\n\n    SwsContext *m_pSwsContext = nullptr;\n\n    size_t m_nAlignedBufferSize = 0;\n    uint8_t *m_pAlignedBuffer = nullptr;\n\n    int m_NumThreads = 1;\n\n    ILAVVideoSettings *m_pSettings = nullptr;\n\n    RGBCoeffs *m_rgbCoeffs = nullptr;\n    BOOL m_bRGBConverter = FALSE;\n    BOOL m_bRGBConvInit = FALSE;\n\n    // [out32][dithermode][ycgco][format][shift]\n    YUVRGBConversionFunc m_RGBConvFuncs[2][2][2][LAVPixFmt_NB][9];\n\n    uint16_t *m_pRandomDithers = nullptr;\n    int m_ditherWidth = 0;\n    int m_ditherHeight = 0;\n    int m_ditherBits = 0;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/LAVVideo.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVVideo.h\"\n#include \"VideoSettingsProp.h\"\n#include \"Media.h\"\n#include <dvdmedia.h>\n\n#include \"VideoInputPin.h\"\n#include \"VideoOutputPin.h\"\n\n#include \"moreuuids.h\"\n#include \"registry.h\"\n#include \"resource.h\"\n\n#include \"IMediaSample3D.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n\n#include <Shlwapi.h>\n\n#include \"parsers/VC1HeaderParser.h\"\n#include \"parsers/MPEG2HeaderParser.h\"\n\n#include <Mfidl.h>\n#include <evr.h>\n#include <d3d9.h>\n\n#pragma warning(disable : 4355)\n\nCLAVVideo::CLAVVideo(LPUNKNOWN pUnk, HRESULT *phr)\n    : CTransformFilter(NAME(\"LAV Video Decoder\"), 0, __uuidof(CLAVVideo))\n    , m_Decoder(this)\n{\n    *phr = S_OK;\n    m_pInput = new CVideoInputPin(TEXT(\"CVideoInputPin\"), this, phr, L\"Input\");\n    ASSERT(SUCCEEDED(*phr));\n\n    m_pOutput = new CVideoOutputPin(TEXT(\"CVideoOutputPin\"), this, phr, L\"Output\");\n    ASSERT(SUCCEEDED(*phr));\n\n    memset(&m_LAVPinInfo, 0, sizeof(m_LAVPinInfo));\n    memset(&m_FilterPrevFrame, 0, sizeof(m_FilterPrevFrame));\n    memset(&m_SideData, 0, sizeof(m_SideData));\n\n    LoadSettings();\n\n    m_PixFmtConverter.SetSettings(this);\n\n#ifdef DEBUG\n    DbgSetModuleLevel(LOG_TRACE, DWORD_MAX);\n    DbgSetModuleLevel(LOG_ERROR, DWORD_MAX);\n    DbgSetModuleLevel(LOG_CUSTOM1, DWORD_MAX); // FFMPEG messages use custom1\n#endif\n}\n\nCLAVVideo::~CLAVVideo()\n{\n    SAFE_DELETE(m_pTrayIcon);\n\n    ReleaseLastSequenceFrame();\n    m_Decoder.Close();\n\n    if (m_pFilterGraph)\n        avfilter_graph_free(&m_pFilterGraph);\n    m_pFilterBufferSrc = nullptr;\n    m_pFilterBufferSink = nullptr;\n\n    if (m_SubtitleConsumer)\n        m_SubtitleConsumer->DisconnectProvider();\n    SafeRelease(&m_SubtitleConsumer);\n\n    SAFE_DELETE(m_pSubtitleInput);\n    SAFE_DELETE(m_pCCOutputPin);\n}\n\nHRESULT CLAVVideo::CreateTrayIcon()\n{\n    CAutoLock cObjectLock(m_pLock);\n    if (m_pTrayIcon)\n        return E_UNEXPECTED;\n    if (CBaseTrayIcon::ProcessBlackList())\n        return S_FALSE;\n    m_pTrayIcon = new CBaseTrayIcon(this, TEXT(LAV_VIDEO), IDI_ICON1);\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideo::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName)\n{\n    CAutoLock cObjectLock(m_pLock);\n    HRESULT hr = __super::JoinFilterGraph(pGraph, pName);\n    if (pGraph && !m_pTrayIcon && m_settings.TrayIcon)\n    {\n        CreateTrayIcon();\n    }\n    else if (!pGraph && m_pTrayIcon)\n    {\n        SAFE_DELETE(m_pTrayIcon);\n    }\n    return hr;\n}\n\nHRESULT CLAVVideo::LoadDefaults()\n{\n    m_settings.TrayIcon = FALSE;\n\n    // Set Defaults\n    m_settings.StreamAR = 2;\n    m_settings.NumThreads = 0;\n    m_settings.DeintFieldOrder = DeintFieldOrder_Auto;\n    m_settings.DeintMode = DeintMode_Auto;\n    m_settings.RGBRange = 2; // Full range default\n\n    for (int i = 0; i < Codec_VideoNB; ++i)\n        m_settings.bFormats[i] = TRUE;\n\n    m_settings.bFormats[Codec_RV12] = FALSE;\n    m_settings.bFormats[Codec_QPEG] = FALSE;\n    m_settings.bFormats[Codec_MSRLE] = FALSE;\n\n    m_settings.bDVDVideo = TRUE;\n    m_settings.bMSWMV9DMO = TRUE;\n\n    // Raw formats, off by default\n    m_settings.bFormats[Codec_v210] = FALSE;\n\n    for (int i = 0; i < LAVOutPixFmt_NB; ++i)\n        m_settings.bPixFmts[i] = TRUE;\n\n    m_settings.bPixFmts[LAVOutPixFmt_YV16] = FALSE;\n    m_settings.bPixFmts[LAVOutPixFmt_AYUV] = FALSE;\n\n    m_settings.HWAccel = HWAccel_None;\n    for (int i = 0; i < HWCodec_NB; ++i)\n        m_settings.bHWFormats[i] = TRUE;\n\n    m_settings.bHWFormats[HWCodec_MPEG4] = FALSE;\n    m_settings.bHWFormats[HWCodec_H264MVC] = FALSE;\n\n    m_settings.HWAccelResFlags = LAVHWResFlag_SD | LAVHWResFlag_HD | LAVHWResFlag_UHD;\n\n    m_settings.HWAccelCUVIDXVA = TRUE;\n\n    m_settings.HWDeintMode = HWDeintMode_Weave;\n    m_settings.HWDeintOutput = DeintOutput_FramePerField;\n\n    m_settings.SWDeintMode = SWDeintMode_None;\n    m_settings.SWDeintOutput = DeintOutput_FramePerField;\n\n    m_settings.DitherMode = LAVDither_Random;\n\n    m_settings.HWAccelDeviceDXVA2 = LAVHWACCEL_DEVICE_DEFAULT;\n    m_settings.HWAccelDeviceDXVA2Desc = 0;\n\n    m_settings.HWAccelDeviceD3D11 = LAVHWACCEL_DEVICE_DEFAULT;\n    m_settings.HWAccelDeviceD3D11Desc = 0;\n\n    m_settings.bH264MVCOverride = TRUE;\n    m_settings.bCCOutputPinEnabled = FALSE;\n\n    return S_OK;\n}\n\nstatic const WCHAR *pixFmtSettingsMap[LAVOutPixFmt_NB] = {L\"yv12\",  L\"nv12\", L\"yuy2\", L\"uyvy\", L\"ayuv\", L\"p010\",\n                                                          L\"p210\",  L\"y410\", L\"p016\", L\"p216\", L\"y416\", L\"rgb32\",\n                                                          L\"rgb24\", L\"v210\", L\"v410\", L\"yv16\", L\"yv24\", L\"rgb48\"};\n\nHRESULT CLAVVideo::LoadSettings()\n{\n    LoadDefaults();\n    if (m_bRuntimeConfig)\n        return S_FALSE;\n\n    ReadSettings(HKEY_LOCAL_MACHINE);\n    return ReadSettings(HKEY_CURRENT_USER);\n}\n\nHRESULT CLAVVideo::ReadSettings(HKEY rootKey)\n{\n    HRESULT hr;\n    BOOL bFlag;\n    DWORD dwVal;\n\n    CRegistry reg = CRegistry(rootKey, LAVC_VIDEO_REGISTRY_KEY, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        bFlag = reg.ReadBOOL(L\"TrayIcon\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.TrayIcon = bFlag;\n\n        dwVal = reg.ReadDWORD(L\"StreamAR\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.StreamAR = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"NumThreads\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.NumThreads = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"DeintFieldOrder\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.DeintFieldOrder = dwVal;\n\n        // Load deprecated deint flags and convert them\n        bFlag = reg.ReadBOOL(L\"DeintAggressive\", hr);\n        if (SUCCEEDED(hr) && bFlag)\n            m_settings.DeintMode = DeintMode_Aggressive;\n\n        bFlag = reg.ReadBOOL(L\"DeintForce\", hr);\n        if (SUCCEEDED(hr) && bFlag)\n            m_settings.DeintMode = DeintMode_Force;\n\n        bFlag = reg.ReadBOOL(L\"DeintTreatAsProgressive\", hr);\n        if (SUCCEEDED(hr) && bFlag)\n            m_settings.DeintMode = DeintMode_Disable;\n\n        dwVal = reg.ReadDWORD(L\"DeintMode\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.DeintMode = (LAVDeintMode)dwVal;\n\n        dwVal = reg.ReadDWORD(L\"RGBRange\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.RGBRange = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"SWDeintMode\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.SWDeintMode = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"SWDeintOutput\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.SWDeintOutput = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"DitherMode\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.DitherMode = dwVal;\n\n        bFlag = reg.ReadBOOL(L\"DVDVideo\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bDVDVideo = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"MSWMV9DMO\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bMSWMV9DMO = bFlag;\n    }\n\n    CRegistry regF = CRegistry(rootKey, LAVC_VIDEO_REGISTRY_KEY_FORMATS, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        for (int i = 0; i < Codec_VideoNB; ++i)\n        {\n            const codec_config_t *info = get_codec_config((LAVVideoCodec)i);\n            ATL::CA2W name(info->name);\n            bFlag = regF.ReadBOOL(name, hr);\n            if (SUCCEEDED(hr))\n                m_settings.bFormats[i] = bFlag;\n        }\n    }\n\n    CRegistry regP = CRegistry(rootKey, LAVC_VIDEO_REGISTRY_KEY_OUTPUT, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        for (int i = 0; i < LAVOutPixFmt_NB; ++i)\n        {\n            bFlag = regP.ReadBOOL(pixFmtSettingsMap[i], hr);\n            if (SUCCEEDED(hr))\n                m_settings.bPixFmts[i] = bFlag;\n        }\n        // Force disable, for future use\n        m_settings.bPixFmts[LAVOutPixFmt_YV16] = FALSE;\n    }\n\n    CRegistry regHW = CRegistry(rootKey, LAVC_VIDEO_REGISTRY_KEY_HWACCEL, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        dwVal = regHW.ReadDWORD(L\"HWAccel\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWAccel = dwVal;\n\n        bFlag = regHW.ReadBOOL(L\"h264\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bHWFormats[HWCodec_H264] = bFlag;\n\n        bFlag = regHW.ReadBOOL(L\"vc1\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bHWFormats[HWCodec_VC1] = bFlag;\n\n        bFlag = regHW.ReadBOOL(L\"mpeg2\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bHWFormats[HWCodec_MPEG2] = bFlag;\n\n        bFlag = regHW.ReadBOOL(L\"mpeg4\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bHWFormats[HWCodec_MPEG4] = bFlag;\n\n        bFlag = regHW.ReadBOOL(L\"hevc\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bHWFormats[HWCodec_HEVC] = bFlag;\n\n        bFlag = regHW.ReadBOOL(L\"vp9\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bHWFormats[HWCodec_VP9] = bFlag;\n\n        bFlag = regHW.ReadBOOL(L\"h264mvc\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bHWFormats[HWCodec_H264MVC] = bFlag;\n\n        bFlag = regHW.ReadBOOL(L\"av1\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.bHWFormats[HWCodec_AV1] = bFlag;\n\n        dwVal = regHW.ReadDWORD(L\"HWResFlags\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWAccelResFlags = dwVal;\n\n        dwVal = regHW.ReadDWORD(L\"HWDeintMode\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWDeintMode = dwVal;\n\n        dwVal = regHW.ReadDWORD(L\"HWDeintOutput\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWDeintOutput = dwVal;\n\n        dwVal = regHW.ReadDWORD(L\"HWAccelDeviceDXVA2\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWAccelDeviceDXVA2 = dwVal;\n\n        dwVal = regHW.ReadDWORD(L\"HWAccelDeviceDXVA2Desc\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWAccelDeviceDXVA2Desc = dwVal;\n\n        dwVal = regHW.ReadDWORD(L\"HWAccelDeviceD3D11\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWAccelDeviceD3D11 = dwVal;\n\n        dwVal = regHW.ReadDWORD(L\"HWAccelDeviceD3D11Desc\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWAccelDeviceD3D11Desc = dwVal;\n\n        bFlag = regHW.ReadBOOL(L\"HWAccelCUVIDXVA\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.HWAccelCUVIDXVA = bFlag;\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVVideo::SaveSettings()\n{\n    if (m_bRuntimeConfig)\n        return S_FALSE;\n\n    HRESULT hr;\n    CreateRegistryKey(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY);\n    CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY, hr);\n    if (SUCCEEDED(hr))\n    {\n        reg.WriteBOOL(L\"TrayIcon\", m_settings.TrayIcon);\n        reg.WriteDWORD(L\"StreamAR\", m_settings.StreamAR);\n        reg.WriteDWORD(L\"NumThreads\", m_settings.NumThreads);\n        reg.WriteDWORD(L\"DeintFieldOrder\", m_settings.DeintFieldOrder);\n        reg.WriteDWORD(L\"DeintMode\", m_settings.DeintMode);\n        reg.WriteDWORD(L\"RGBRange\", m_settings.RGBRange);\n\n        CreateRegistryKey(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_FORMATS);\n        CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_FORMATS, hr);\n        for (int i = 0; i < Codec_VideoNB; ++i)\n        {\n            const codec_config_t *info = get_codec_config((LAVVideoCodec)i);\n            ATL::CA2W name(info->name);\n            regF.WriteBOOL(name, m_settings.bFormats[i]);\n        }\n\n        reg.WriteBOOL(L\"DVDVideo\", m_settings.bDVDVideo);\n        reg.WriteBOOL(L\"MSWMV9DMO\", m_settings.bMSWMV9DMO);\n\n        CreateRegistryKey(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_OUTPUT);\n        CRegistry regP = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_OUTPUT, hr);\n        for (int i = 0; i < LAVOutPixFmt_NB; ++i)\n        {\n            regP.WriteBOOL(pixFmtSettingsMap[i], m_settings.bPixFmts[i]);\n        }\n\n        CreateRegistryKey(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_HWACCEL);\n        CRegistry regHW = CRegistry(HKEY_CURRENT_USER, LAVC_VIDEO_REGISTRY_KEY_HWACCEL, hr);\n        regHW.WriteDWORD(L\"HWAccel\", m_settings.HWAccel);\n        regHW.WriteBOOL(L\"h264\", m_settings.bHWFormats[HWCodec_H264]);\n        regHW.WriteBOOL(L\"vc1\", m_settings.bHWFormats[HWCodec_VC1]);\n        regHW.WriteBOOL(L\"mpeg2\", m_settings.bHWFormats[HWCodec_MPEG2]);\n        regHW.WriteBOOL(L\"mpeg4\", m_settings.bHWFormats[HWCodec_MPEG4]);\n        regHW.WriteBOOL(L\"hevc\", m_settings.bHWFormats[HWCodec_HEVC]);\n        regHW.WriteBOOL(L\"vp9\", m_settings.bHWFormats[HWCodec_VP9]);\n        regHW.WriteBOOL(L\"h264mvc\", m_settings.bHWFormats[HWCodec_H264MVC]);\n        regHW.WriteBOOL(L\"av1\", m_settings.bHWFormats[HWCodec_AV1]);\n\n        regHW.WriteDWORD(L\"HWResFlags\", m_settings.HWAccelResFlags);\n\n        regHW.WriteDWORD(L\"HWDeintMode\", m_settings.HWDeintMode);\n        regHW.WriteDWORD(L\"HWDeintOutput\", m_settings.HWDeintOutput);\n\n        regHW.WriteDWORD(L\"HWAccelDeviceDXVA2\", m_settings.HWAccelDeviceDXVA2);\n        regHW.WriteDWORD(L\"HWAccelDeviceDXVA2Desc\", m_settings.HWAccelDeviceDXVA2Desc);\n\n        regHW.WriteDWORD(L\"HWAccelDeviceD3D11\", m_settings.HWAccelDeviceD3D11);\n        regHW.WriteDWORD(L\"HWAccelDeviceD3D11Desc\", m_settings.HWAccelDeviceD3D11Desc);\n\n        regHW.WriteBOOL(L\"HWAccelCUVIDXVA\", m_settings.HWAccelCUVIDXVA);\n\n        reg.WriteDWORD(L\"SWDeintMode\", m_settings.SWDeintMode);\n        reg.WriteDWORD(L\"SWDeintOutput\", m_settings.SWDeintOutput);\n        reg.WriteDWORD(L\"DitherMode\", m_settings.DitherMode);\n\n        reg.DeleteKey(L\"DeintAggressive\");\n        reg.DeleteKey(L\"DeintForce\");\n        reg.DeleteKey(L\"DeintTreatAsProgressive\");\n    }\n    return S_OK;\n}\n\n// IUnknown\nSTDMETHODIMP CLAVVideo::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    *ppv = nullptr;\n\n    return QI(ISpecifyPropertyPages) QI(ISpecifyPropertyPages2) QI(IPropertyBag) QI2(ILAVVideoSettings)\n        QI2(ILAVVideoStatus) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\n// ISpecifyPropertyPages2\nSTDMETHODIMP CLAVVideo::GetPages(CAUUID *pPages)\n{\n    CheckPointer(pPages, E_POINTER);\n    pPages->cElems = 2;\n    pPages->pElems = (GUID *)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);\n    if (pPages->pElems == nullptr)\n    {\n        return E_OUTOFMEMORY;\n    }\n    pPages->pElems[0] = CLSID_LAVVideoSettingsProp;\n    pPages->pElems[1] = CLSID_LAVVideoFormatsProp;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideo::CreatePage(const GUID &guid, IPropertyPage **ppPage)\n{\n    CheckPointer(ppPage, E_POINTER);\n    HRESULT hr = S_OK;\n\n    if (*ppPage != nullptr)\n        return E_INVALIDARG;\n\n    if (guid == CLSID_LAVVideoSettingsProp)\n        *ppPage = new CLAVVideoSettingsProp(nullptr, &hr);\n    else if (guid == CLSID_LAVVideoFormatsProp)\n        *ppPage = new CLAVVideoFormatsProp(nullptr, &hr);\n\n    if (SUCCEEDED(hr) && *ppPage)\n    {\n        (*ppPage)->AddRef();\n        return S_OK;\n    }\n    else\n    {\n        SAFE_DELETE(*ppPage);\n        return E_FAIL;\n    }\n}\n\nSTDMETHODIMP_(LPWSTR) CLAVVideo::GetFileExtension()\n{\n    if (m_strExtension.empty())\n    {\n        m_strExtension = L\"\";\n\n        IFileSourceFilter *pSource = nullptr;\n        if (SUCCEEDED(FindIntefaceInGraph(m_pInput, IID_IFileSourceFilter, (void **)&pSource)))\n        {\n            LPOLESTR pwszFile = nullptr;\n            if (SUCCEEDED(pSource->GetCurFile(&pwszFile, nullptr)) && pwszFile)\n            {\n                LPWSTR pwszExtension = PathFindExtensionW(pwszFile);\n                m_strExtension = std::wstring(pwszExtension);\n                CoTaskMemFree(pwszFile);\n            }\n            SafeRelease(&pSource);\n        }\n    }\n\n    size_t len = m_strExtension.size() + 1;\n    LPWSTR pszExtension = (LPWSTR)CoTaskMemAlloc(sizeof(WCHAR) * len);\n    if (!pszExtension)\n        return nullptr;\n\n    wcscpy_s(pszExtension, len, m_strExtension.c_str());\n    return pszExtension;\n}\n\n// CTransformFilter\n\nint CLAVVideo::GetPinCount()\n{\n    int nCount = 2;\n\n    if (m_pSubtitleInput)\n        nCount++;\n\n    if (m_pCCOutputPin)\n        nCount++;\n\n    return nCount;\n}\n\nCBasePin *CLAVVideo::GetPin(int n)\n{\n    if (n >= 2)\n    {\n        if (m_pSubtitleInput && n == 2)\n            return m_pSubtitleInput;\n        else if ((m_pSubtitleInput && n == 3) || (!m_pSubtitleInput && n == 2))\n            return m_pCCOutputPin;\n    }\n    return __super::GetPin(n);\n}\n\nHRESULT CLAVVideo::CheckInputType(const CMediaType *mtIn)\n{\n    for (UINT i = 0; i < sudPinTypesInCount; i++)\n    {\n        if (*sudPinTypesIn[i].clsMajorType == mtIn->majortype && *sudPinTypesIn[i].clsMinorType == mtIn->subtype &&\n            (mtIn->formattype == FORMAT_VideoInfo || mtIn->formattype == FORMAT_VideoInfo2 ||\n             mtIn->formattype == FORMAT_MPEGVideo || mtIn->formattype == FORMAT_MPEG2Video))\n        {\n            return S_OK;\n        }\n    }\n    return VFW_E_TYPE_NOT_ACCEPTED;\n}\n\n// Check if the types are compatible\nHRESULT CLAVVideo::CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut)\n{\n    DbgLog((LOG_TRACE, 10, L\"::CheckTransform()\"));\n    if (SUCCEEDED(CheckInputType(mtIn)) && mtOut->majortype == MEDIATYPE_Video)\n    {\n        if (m_PixFmtConverter.IsAllowedSubtype(&mtOut->subtype))\n        {\n            return S_OK;\n        }\n    }\n    return VFW_E_TYPE_NOT_ACCEPTED;\n}\n\nHRESULT CLAVVideo::DecideBufferSize(IMemAllocator *pAllocator, ALLOCATOR_PROPERTIES *pProperties)\n{\n    DbgLog((LOG_TRACE, 10, L\"::DecideBufferSize()\"));\n    if (m_pInput->IsConnected() == FALSE)\n    {\n        return E_UNEXPECTED;\n    }\n\n    BITMAPINFOHEADER *pBIH = nullptr;\n    CMediaType &mtOut = m_pOutput->CurrentMediaType();\n    videoFormatTypeHandler(mtOut, &pBIH);\n\n    // try to honor the requested number of downstream buffers, but cap at the decoders maximum\n    long decoderBuffersMax = LONG_MAX;\n    long decoderBuffs = m_Decoder.GetBufferCount(&decoderBuffersMax);\n    long downstreamBuffers = pProperties->cBuffers;\n    pProperties->cBuffers = min(max(pProperties->cBuffers, 2) + decoderBuffs, decoderBuffersMax);\n    pProperties->cbBuffer = pBIH ? pBIH->biSizeImage : 3110400;\n    pProperties->cbAlign = 1;\n    pProperties->cbPrefix = 0;\n\n    DbgLog((LOG_TRACE, 10, L\" -> Downstream wants %d buffers, decoder wants %d, for a total of: %d\", downstreamBuffers,\n            decoderBuffs, pProperties->cBuffers));\n\n    HRESULT hr;\n    ALLOCATOR_PROPERTIES Actual;\n    if (FAILED(hr = pAllocator->SetProperties(pProperties, &Actual)))\n    {\n        return hr;\n    }\n\n    return pProperties->cBuffers > Actual.cBuffers || pProperties->cbBuffer > Actual.cbBuffer ? E_FAIL : S_OK;\n}\n\nHRESULT CLAVVideo::GetMediaType(int iPosition, CMediaType *pMediaType)\n{\n    DbgLog((LOG_TRACE, 10, L\"::GetMediaType(): position: %d\", iPosition));\n    if (m_pInput->IsConnected() == FALSE)\n    {\n        return E_UNEXPECTED;\n    }\n    if (iPosition < 0)\n    {\n        return E_INVALIDARG;\n    }\n\n    if (iPosition >= (m_PixFmtConverter.GetNumMediaTypes() * 2))\n    {\n        return VFW_S_NO_MORE_ITEMS;\n    }\n\n    int index = iPosition / 2;\n    BOOL bVIH1 = iPosition % 2;\n\n    CMediaType &mtIn = m_pInput->CurrentMediaType();\n\n    BITMAPINFOHEADER *pBIH = nullptr;\n    REFERENCE_TIME rtAvgTime = 0;\n    DWORD dwAspectX = 0, dwAspectY = 0;\n    videoFormatTypeHandler(mtIn.Format(), mtIn.FormatType(), &pBIH, &rtAvgTime, &dwAspectX, &dwAspectY);\n\n    // Adjust for deinterlacing\n    if (m_Decoder.IsInterlaced(FALSE) && m_settings.DeintMode != DeintMode_Disable)\n    {\n        BOOL bFramePerField = (m_settings.SWDeintMode != SWDeintMode_None && m_settings.SWDeintOutput == DeintOutput_FramePerField);\n        if (bFramePerField)\n            rtAvgTime /= 2;\n    }\n\n    m_PixFmtConverter.GetMediaType(pMediaType, index, pBIH->biWidth, pBIH->biHeight, dwAspectX, dwAspectY, rtAvgTime,\n                                   IsInterlacedOutput(), bVIH1);\n\n    return S_OK;\n}\n\nBOOL CLAVVideo::IsInterlacedOutput()\n{\n    return (m_settings.SWDeintMode == SWDeintMode_None || m_filterPixFmt == LAVPixFmt_None) &&\n           m_Decoder.IsInterlaced(TRUE) && !(m_settings.DeintMode == DeintMode_Disable);\n}\n\nstatic const LPWSTR stream_ar_blacklist[] = {\n    L\".mkv\", L\".webm\", L\".mp4\", L\".mov\", L\".m4v\",\n};\n\nHRESULT CLAVVideo::CreateDecoder(const CMediaType *pmt)\n{\n    DbgLog((LOG_TRACE, 10, L\"::CreateDecoder(): Creating new decoder...\"));\n    HRESULT hr = S_OK;\n\n    AVCodecID codec = FindCodecId(pmt);\n    if (codec == AV_CODEC_ID_NONE)\n    {\n        return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n\n    // Check if codec is activated\n    for (int i = 0; i < Codec_VideoNB; ++i)\n    {\n        const codec_config_t *config = get_codec_config((LAVVideoCodec)i);\n        bool bMatched = false;\n        for (int k = 0; k < config->nCodecs; ++k)\n        {\n            if (config->codecs[k] == codec)\n            {\n                bMatched = true;\n                break;\n            }\n        }\n        if (bMatched && !m_settings.bFormats[i])\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Codec is disabled\"));\n            return VFW_E_TYPE_NOT_ACCEPTED;\n        }\n    }\n\n    if (codec == AV_CODEC_ID_H264_MVC && !m_settings.bH264MVCOverride)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> H.264 MVC override, refusing\"));\n        return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n\n    ILAVPinInfo *pPinInfo = nullptr;\n    hr = FindPinIntefaceInGraph(m_pInput, IID_ILAVPinInfo, (void **)&pPinInfo);\n    if (SUCCEEDED(hr))\n    {\n        memset(&m_LAVPinInfo, 0, sizeof(m_LAVPinInfo));\n\n        m_LAVPinInfoValid = TRUE;\n        m_LAVPinInfo.flags = pPinInfo->GetStreamFlags();\n        m_LAVPinInfo.pix_fmt = (AVPixelFormat)pPinInfo->GetPixelFormat();\n        m_LAVPinInfo.has_b_frames = pPinInfo->GetHasBFrames();\n\n        SafeRelease(&pPinInfo);\n    }\n    else\n    {\n        m_LAVPinInfoValid = FALSE;\n    }\n\n    // Clear old sidedata\n    memset(&m_SideData, 0, sizeof(m_SideData));\n\n    // Read and store stream-level sidedata\n    IMediaSideData *pPinSideData = nullptr;\n    MediaSideDataFFMpeg *pSideDataFFmpeg = nullptr;\n    hr = FindPinIntefaceInGraph(m_pInput, __uuidof(IMediaSideData), (void **)&pPinSideData);\n    if (SUCCEEDED(hr))\n    {\n        size_t size = 0;\n        hr = pPinSideData->GetSideData(IID_MediaSideDataFFMpeg, (const BYTE **)&pSideDataFFmpeg, &size);\n        if (SUCCEEDED(hr) && size == sizeof(MediaSideDataFFMpeg))\n        {\n            for (int i = 0; i < pSideDataFFmpeg->side_data_elems; i++)\n            {\n                AVPacketSideData *sd = &pSideDataFFmpeg->side_data[i];\n\n                // Display Mastering metadata, including color info\n                if (sd->type == AV_PKT_DATA_MASTERING_DISPLAY_METADATA &&\n                    sd->size == sizeof(AVMasteringDisplayMetadata))\n                {\n                    m_SideData.Mastering = *(AVMasteringDisplayMetadata *)sd->data;\n                }\n                else if (sd->type == AV_PKT_DATA_CONTENT_LIGHT_LEVEL && sd->size == sizeof(AVContentLightMetadata))\n                {\n                    m_SideData.ContentLight = *(AVContentLightMetadata *)sd->data;\n                }\n                else if (sd->type == AV_PKT_DATA_X264_BUILD && sd->size == 4 && codec == AV_CODEC_ID_H264)\n                {\n                    SetX264Build(*(int *)sd->data);\n                }\n            }\n        }\n\n        SafeRelease(&pPinSideData);\n    }\n\n    m_dwDecodeFlags = 0;\n\n    LPWSTR pszExtension = GetFileExtension();\n    if (pszExtension)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> File extension: %s\", pszExtension));\n\n        for (int i = 0; i < countof(stream_ar_blacklist); i++)\n        {\n            if (_wcsicmp(stream_ar_blacklist[i], pszExtension) == 0)\n            {\n                m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST;\n                break;\n            }\n        }\n        if (m_dwDecodeFlags & LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST)\n        {\n            // MPC-HC MP4 Splitter fails at Container AR\n            if (FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMP4Splitter) ||\n                FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMP4SplitterSource))\n            {\n                m_dwDecodeFlags &= ~LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST;\n            }\n        }\n    }\n\n    BOOL bSageVC1Hack = (codec == AV_CODEC_ID_VC1) && FilterInGraph(PINDIR_INPUT, CLSID_SageTVMpegDeMux);\n\n    // Certain filters send VC-1 in PTS instead of DTS, so list them here\n    // Usually, these are MPEG systems.\n    BOOL bVC1DTS = (codec == AV_CODEC_ID_VC1) && !(FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMPEGSplitter) ||\n                                                   FilterInGraph(PINDIR_INPUT, CLSID_MPCHCMPEGSplitterSource) ||\n                                                   FilterInGraph(PINDIR_INPUT, CLSID_MPBDReader) || bSageVC1Hack);\n\n    BOOL bH2645IsAVI = ((codec == AV_CODEC_ID_H264 || codec == AV_CODEC_ID_HEVC) &&\n                        (!m_LAVPinInfoValid && pszExtension && _wcsicmp(pszExtension, L\".avi\") == 0));\n    BOOL bLAVSplitter =\n        FilterInGraph(PINDIR_INPUT, CLSID_LAVSplitterSource) || FilterInGraph(PINDIR_INPUT, CLSID_LAVSplitter);\n    BOOL bDVDPlayback = (pmt->majortype == MEDIATYPE_DVD_ENCRYPTED_PACK || pmt->majortype == MEDIATYPE_MPEG2_PACK ||\n                         pmt->majortype == MEDIATYPE_MPEG2_PES);\n    BOOL bTheoraMPCHCOgg =\n        (codec == AV_CODEC_ID_THEORA || codec == AV_CODEC_ID_VP3) &&\n        (FilterInGraph(PINDIR_INPUT, CLSID_MPCHCOggSplitter) || FilterInGraph(PINDIR_INPUT, CLSID_MPCHCOggSource));\n\n    if (bDVDPlayback && !m_settings.bDVDVideo)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> DVD Video support is disabled\"));\n        return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n\n    if (m_LAVPinInfoValid && (m_LAVPinInfo.flags & LAV_STREAM_FLAG_ONLY_DTS))\n        m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_ONLY_DTS;\n    if (bVC1DTS)\n        m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_ONLY_DTS;\n    if (bH2645IsAVI)\n        m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_ONLY_DTS;\n    if (bLAVSplitter)\n        m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_LAVSPLITTER;\n    if (bDVDPlayback)\n        m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_DVD;\n    if (bTheoraMPCHCOgg)\n        m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_NO_MT;\n    if (bSageVC1Hack)\n        m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_SAGE_HACK;\n    if (m_LAVPinInfoValid && (m_LAVPinInfo.flags & LAV_STREAM_FLAG_LIVE))\n        m_dwDecodeFlags |= LAV_VIDEO_DEC_FLAG_LIVE;\n\n    SAFE_CO_FREE(pszExtension);\n\n    hr = m_Decoder.CreateDecoder(pmt, codec, pSideDataFFmpeg);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Decoder creation failed\"));\n        goto done;\n    }\n\n    // Get avg time per frame\n    videoFormatTypeHandler(pmt->Format(), pmt->FormatType(), nullptr, &m_rtAvgTimePerFrame);\n\n    LAVPixelFormat pix, sw_pixfmt;\n    int bpp;\n    m_Decoder.GetPixelFormat(&pix, &bpp, &sw_pixfmt);\n\n    // Set input on the converter, and force negotiation if needed\n    if (m_PixFmtConverter.SetInputFmt(sw_pixfmt, bpp) && m_pOutput->IsConnected())\n        m_bForceFormatNegotiation = TRUE;\n\n    if (pix == LAVPixFmt_YUV420 || pix == LAVPixFmt_YUV422 || pix == LAVPixFmt_NV12)\n        m_filterPixFmt = pix;\n\n    if (m_settings.bCCOutputPinEnabled && !bDVDPlayback &&\n        (codec == AV_CODEC_ID_MPEG2VIDEO || codec == AV_CODEC_ID_H264))\n    {\n        if (m_pCCOutputPin == nullptr && CBaseFilter::IsStopped())\n            m_pCCOutputPin = new CCCOutputPin(TEXT(\"CCCOutputPin\"), this, &m_csFilter, &hr, L\"~CC Output\");\n    }\n\ndone:\n    return SUCCEEDED(hr) ? S_OK : VFW_E_TYPE_NOT_ACCEPTED;\n}\n\nHRESULT CLAVVideo::CheckDirectMode()\n{\n    LAVPixelFormat pix;\n    int bpp;\n    m_Decoder.GetPixelFormat(&pix, &bpp, nullptr);\n\n    GUID outputSubtype = m_pOutput->CurrentMediaType().subtype;\n\n    BOOL bDirect = (pix == LAVPixFmt_NV12 || pix == LAVPixFmt_P016 || pix == LAVPixFmt_YUY2 || pix == LAVPixFmt_Y216 || pix == LAVPixFmt_AYUV || pix == LAVPixFmt_Y410 || pix == LAVPixFmt_Y416);\n    if (pix == LAVPixFmt_NV12 && m_Decoder.IsInterlaced(FALSE) && m_settings.SWDeintMode != SWDeintMode_None)\n        bDirect = FALSE;\n    else if (pix == LAVPixFmt_NV12 && outputSubtype != MEDIASUBTYPE_NV12 && outputSubtype != MEDIASUBTYPE_YV12)\n        bDirect = FALSE;\n    else if (pix == LAVPixFmt_P016 && outputSubtype != MEDIASUBTYPE_P010 && outputSubtype != MEDIASUBTYPE_P016 &&\n             outputSubtype != MEDIASUBTYPE_NV12)\n        bDirect = FALSE;\n    else if (pix == LAVPixFmt_YUY2 && outputSubtype != MEDIASUBTYPE_YUY2 && outputSubtype != MEDIASUBTYPE_YV16)\n        bDirect = FALSE;\n    else if (pix == LAVPixFmt_Y216 && outputSubtype != MEDIASUBTYPE_P210 && outputSubtype != MEDIASUBTYPE_P216)\n        bDirect = FALSE;\n    else if (pix == LAVPixFmt_AYUV && outputSubtype != MEDIASUBTYPE_AYUV)\n        bDirect = FALSE;\n    else if (pix == LAVPixFmt_Y410 && outputSubtype != MEDIASUBTYPE_Y410)\n        bDirect = FALSE;\n    else if (pix == LAVPixFmt_Y416 && outputSubtype != MEDIASUBTYPE_Y416)\n        bDirect = FALSE;\n    else if (m_SubtitleConsumer && m_SubtitleConsumer->HasProvider())\n        bDirect = FALSE;\n\n    m_Decoder.SetDirectOutput(bDirect);\n\n    return S_OK;\n}\n\nHRESULT CLAVVideo::SetMediaType(PIN_DIRECTION dir, const CMediaType *pmt)\n{\n    HRESULT hr = S_OK;\n    DbgLog((LOG_TRACE, 5, L\"SetMediaType -- %S\", dir == PINDIR_INPUT ? \"in\" : \"out\"));\n    if (dir == PINDIR_INPUT)\n    {\n        hr = CreateDecoder(pmt);\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n        m_bForceInputAR = TRUE;\n    }\n    else if (dir == PINDIR_OUTPUT)\n    {\n        m_PixFmtConverter.SetOutputPixFmt(m_PixFmtConverter.GetOutputBySubtype(pmt->Subtype()));\n    }\n    return __super::SetMediaType(dir, pmt);\n}\n\nHRESULT CLAVVideo::EndOfStream()\n{\n    DbgLog((LOG_TRACE, 1, L\"EndOfStream, flushing decoder\"));\n    CAutoLock cAutoLock(&m_csReceive);\n\n    m_Decoder.EndOfStream();\n    Filter(GetFlushFrame());\n\n    if (m_pCCOutputPin)\n        m_pCCOutputPin->DeliverEndOfStream();\n\n    DbgLog((LOG_TRACE, 1, L\"EndOfStream finished, decoder flushed\"));\n    return __super::EndOfStream();\n}\n\nHRESULT CLAVVideo::EndOfSegment()\n{\n    DbgLog((LOG_TRACE, 1, L\"EndOfSegment, flushing decoder\"));\n    CAutoLock cAutoLock(&m_csReceive);\n\n    m_Decoder.EndOfStream();\n    Filter(GetFlushFrame());\n\n    // Forward the EndOfSegment call downstream\n    if (m_pOutput != NULL && m_pOutput->IsConnected())\n    {\n        IPin *pConnected = m_pOutput->GetConnected();\n\n        IPinSegmentEx *pPinSegmentEx = NULL;\n        if (pConnected->QueryInterface(&pPinSegmentEx) == S_OK)\n        {\n            pPinSegmentEx->EndOfSegment();\n        }\n        SafeRelease(&pPinSegmentEx);\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVVideo::BeginFlush()\n{\n    DbgLog((LOG_TRACE, 1, L\"::BeginFlush\"));\n    m_bFlushing = TRUE;\n\n    if (m_pCCOutputPin)\n        m_pCCOutputPin->DeliverBeginFlush();\n\n    return __super::BeginFlush();\n}\n\nHRESULT CLAVVideo::EndFlush()\n{\n    DbgLog((LOG_TRACE, 1, L\"::EndFlush\"));\n    CAutoLock cAutoLock(&m_csReceive);\n\n    ReleaseLastSequenceFrame();\n\n    if (m_dwDecodeFlags & LAV_VIDEO_DEC_FLAG_DVD)\n    {\n        PerformFlush();\n    }\n\n    HRESULT hr = __super::EndFlush();\n\n    if (m_pCCOutputPin)\n        m_pCCOutputPin->DeliverEndFlush();\n    m_bFlushing = FALSE;\n\n    return hr;\n}\n\nHRESULT CLAVVideo::ReleaseLastSequenceFrame()\n{\n    // Release DXVA2 frames hold in the last sequence frame\n    if (m_pLastSequenceFrame && m_pLastSequenceFrame->format == LAVPixFmt_DXVA2)\n    {\n        IMediaSample *pSample = (IMediaSample *)m_pLastSequenceFrame->data[0];\n        IDirect3DSurface9 *pSurface = (IDirect3DSurface9 *)m_pLastSequenceFrame->data[3];\n        SafeRelease(&pSample);\n        SafeRelease(&pSurface);\n    }\n    else if (m_pLastSequenceFrame && m_pLastSequenceFrame->format == LAVPixFmt_D3D11)\n    {\n        // TODO D3D11\n    }\n    ReleaseFrame(&m_pLastSequenceFrame);\n\n    return S_OK;\n}\n\nHRESULT CLAVVideo::PerformFlush()\n{\n    CAutoLock cAutoLock(&m_csReceive);\n\n    ReleaseLastSequenceFrame();\n    m_Decoder.Flush();\n\n    m_bInDVDMenu = FALSE;\n\n    if (m_pFilterGraph)\n        avfilter_graph_free(&m_pFilterGraph);\n\n    m_rtPrevStart = m_rtPrevStop = 0;\n    memset(&m_FilterPrevFrame, 0, sizeof(m_FilterPrevFrame));\n\n    return S_OK;\n}\n\nHRESULT CLAVVideo::NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    DbgLog((LOG_TRACE, 1, L\"::NewSegment - %I64d / %I64d\", tStart, tStop));\n\n    PerformFlush();\n\n    if (m_pCCOutputPin)\n        m_pCCOutputPin->DeliverNewSegment(tStart, tStop, dRate);\n\n    return __super::NewSegment(tStart, tStop, dRate);\n}\n\nHRESULT CLAVVideo::CheckConnect(PIN_DIRECTION dir, IPin *pPin)\n{\n    if (dir == PINDIR_INPUT)\n    {\n        if (!m_bRuntimeConfig && CheckApplicationBlackList(LAVC_VIDEO_REGISTRY_KEY L\"\\\\Blacklist\"))\n            return E_FAIL;\n\n        if (FilterInGraphSafe(pPin, CLSID_LAVVideo, TRUE))\n        {\n            DbgLog((LOG_TRACE, 10, L\"CLAVVideo::CheckConnect(): LAVVideo is already in this graph branch, aborting.\"));\n            return E_FAIL;\n        }\n    }\n    else if (dir == PINDIR_OUTPUT)\n    {\n        // Get the filter we're connecting to\n        IBaseFilter *pFilter = GetFilterFromPin(pPin);\n        CLSID guidFilter = GUID_NULL;\n        if (pFilter != nullptr)\n        {\n            if (FAILED(pFilter->GetClassID(&guidFilter)))\n                guidFilter = GUID_NULL;\n\n            SafeRelease(&pFilter);\n        }\n\n        // Don't allow connection to the AVI Decompressor, it doesn't support a variety of our output formats properly\n        if (guidFilter == CLSID_AVIDec)\n            return VFW_E_TYPE_NOT_ACCEPTED;\n    }\n    return __super::CheckConnect(dir, pPin);\n}\n\nHRESULT CLAVVideo::BreakConnect(PIN_DIRECTION dir)\n{\n    DbgLog((LOG_TRACE, 10, L\"::BreakConnect\"));\n    if (dir == PINDIR_INPUT)\n    {\n        if (m_pFilterGraph)\n            avfilter_graph_free(&m_pFilterGraph);\n\n        m_Decoder.Close();\n        m_X264Build = -1;\n    }\n    else if (dir == PINDIR_OUTPUT)\n    {\n        m_Decoder.BreakConnect();\n    }\n    return __super::BreakConnect(dir);\n}\n\nHRESULT CLAVVideo::CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin)\n{\n    DbgLog((LOG_TRACE, 10, L\"::CompleteConnect\"));\n    HRESULT hr = S_OK;\n    if (dir == PINDIR_OUTPUT)\n    {\n        BOOL bFailNonDXVA = false;\n        // Fail P010 software connections before Windows 10 Creators Update (presumably it was fixed before Creators\n        // already, but this is definitely a safe known condition)\n        if (!IsWindows10BuildOrNewer(15063) && (m_pOutput->CurrentMediaType().subtype == MEDIASUBTYPE_P010 ||\n                                                m_pOutput->CurrentMediaType().subtype == MEDIASUBTYPE_P016))\n        {\n            // Check if we're connecting to EVR\n            IBaseFilter *pFilter = GetFilterFromPin(pReceivePin);\n            if (pFilter != nullptr)\n            {\n                CLSID guid;\n                if (SUCCEEDED(pFilter->GetClassID(&guid)))\n                {\n                    DbgLog((LOG_TRACE, 10, L\"-> Connecting P010/P016 to %s\", WStringFromGUID(guid).c_str()));\n                    bFailNonDXVA = (guid == CLSID_EnhancedVideoRenderer || guid == CLSID_VideoMixingRenderer9 ||\n                                    guid == CLSID_VideoMixingRenderer);\n                }\n                SafeRelease(&pFilter);\n            }\n        }\n\n        hr = m_Decoder.PostConnect(pReceivePin);\n        if (SUCCEEDED(hr))\n        {\n            if (bFailNonDXVA)\n            {\n                LAVPixelFormat fmt;\n                m_Decoder.GetPixelFormat(&fmt, nullptr, nullptr);\n\n                if (fmt != LAVPixFmt_DXVA2)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"-> Non-DXVA2 Connection rejected on this renderer and subtype\"));\n                    return VFW_E_TYPE_NOT_ACCEPTED;\n                }\n            }\n\n            CheckDirectMode();\n        }\n    }\n    else if (dir == PINDIR_INPUT)\n    {\n        if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_MPEG2_VIDEO && !m_pSubtitleInput &&\n            (m_dwDecodeFlags & LAV_VIDEO_DEC_FLAG_DVD))\n        {\n            m_pSubtitleInput = new CLAVVideoSubtitleInputPin(TEXT(\"CLAVVideoSubtitleInputPin\"), this, &m_csFilter, &hr,\n                                                             L\"Subtitle Input\");\n            ASSERT(SUCCEEDED(hr));\n            m_SubtitleConsumer = new CLAVSubtitleConsumer(this);\n            m_SubtitleConsumer->AddRef();\n            m_pSubtitleInput->SetSubtitleConsumer(m_SubtitleConsumer);\n\n            BITMAPINFOHEADER *pBIH = nullptr;\n            videoFormatTypeHandler(m_pInput->CurrentMediaType(), &pBIH);\n            if (pBIH)\n            {\n                m_SubtitleConsumer->SetVideoSize(pBIH->biWidth, pBIH->biHeight);\n            }\n        }\n    }\n    return hr;\n}\n\nHRESULT CLAVVideo::StartStreaming()\n{\n    CAutoLock cAutoLock(&m_csReceive);\n\n    if (m_pSubtitleInput)\n    {\n        bool bFoundConsumer = false;\n        ISubRenderConsumer *pSubConsumer = nullptr;\n        if (SUCCEEDED(FindIntefaceInGraph(m_pOutput, __uuidof(ISubRenderConsumer), (void **)&pSubConsumer)))\n        {\n            int nc = 0;\n            LPWSTR strName = nullptr, strVersion = nullptr;\n            pSubConsumer->GetString(\"name\", &strName, &nc);\n            pSubConsumer->GetString(\"version\", &strVersion, &nc);\n            DbgLog((LOG_TRACE, 10, L\"CLAVVideo::StartStreaming():: Found ISubRenderConsumer (%s %s)\", strName,\n                    strVersion));\n\n            // only support madVR for now, and only recent versions (anything before 0.89.10 crashes)\n            if (strName && strVersion)\n            {\n                if (wcscmp(strName, L\"madVR\") == 0)\n                {\n                    int major, minor, build, rev;\n                    if (swscanf_s(strVersion, L\"%d.%d.%d.%d\", &major, &minor, &build, &rev) == 4)\n                    {\n                        if (major > 0 || (major == 0 && (minor > 89 || (minor == 89 && build >= 10))))\n                            bFoundConsumer = true;\n                    }\n                }\n                else if (wcscmp(strName, L\"JRVR\") == 0)\n                {\n                    bFoundConsumer = true;\n                }\n            }\n\n            if (bFoundConsumer)\n            {\n                m_pSubtitleInput->SetSubtitleConsumer(pSubConsumer);\n                SafeRelease(&m_SubtitleConsumer);\n            }\n\n            SafeRelease(&pSubConsumer);\n        }\n\n        if (bFoundConsumer == false)\n        {\n            if (m_SubtitleConsumer == nullptr)\n            {\n                m_SubtitleConsumer = new CLAVSubtitleConsumer(this);\n                m_SubtitleConsumer->AddRef();\n\n                BITMAPINFOHEADER *pBIH = nullptr;\n                videoFormatTypeHandler(m_pInput->CurrentMediaType(), &pBIH);\n                if (pBIH)\n                {\n                    m_SubtitleConsumer->SetVideoSize(pBIH->biWidth, pBIH->biHeight);\n                }\n            }\n\n            m_pSubtitleInput->SetSubtitleConsumer(m_SubtitleConsumer);\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideo::Stop()\n{\n    // Get the receiver lock and prevent frame delivery\n    {\n        CAutoLock lck3(&m_csReceive);\n        m_bFlushing = TRUE;\n    }\n\n    // actually perform the stop\n    HRESULT hr = __super::Stop();\n\n    // unblock delivery again, if we continue receiving frames\n    m_bFlushing = FALSE;\n    return hr;\n}\n\nHRESULT CLAVVideo::GetDeliveryBuffer(IMediaSample **ppOut, int width, int height, AVRational ar,\n                                     DXVA2_ExtendedFormat dxvaExtFlags, REFERENCE_TIME avgFrameDuration)\n{\n    CheckPointer(ppOut, E_POINTER);\n\n    HRESULT hr;\n\n    if (FAILED(hr = ReconnectOutput(width, height, ar, dxvaExtFlags, avgFrameDuration)))\n    {\n        return hr;\n    }\n\n    if (FAILED(hr = m_pOutput->GetDeliveryBuffer(ppOut, nullptr, nullptr, 0)))\n    {\n        return hr;\n    }\n\n    CheckPointer(*ppOut, E_UNEXPECTED);\n\n    AM_MEDIA_TYPE *pmt = nullptr;\n    if (SUCCEEDED((*ppOut)->GetMediaType(&pmt)) && pmt)\n    {\n        CMediaType &outMt = m_pOutput->CurrentMediaType();\n        BITMAPINFOHEADER *pBMINew = nullptr;\n        videoFormatTypeHandler(pmt->pbFormat, &pmt->formattype, &pBMINew);\n#ifdef DEBUG\n        BITMAPINFOHEADER *pBMIOld = nullptr;\n        videoFormatTypeHandler(outMt.pbFormat, &outMt.formattype, &pBMIOld);\n\n        RECT rcTarget = {0};\n        if (pmt->formattype == FORMAT_VideoInfo2)\n        {\n            rcTarget = ((VIDEOINFOHEADER2 *)pmt->pbFormat)->rcTarget;\n        }\n        else if (pmt->formattype == FORMAT_VideoInfo)\n        {\n            rcTarget = ((VIDEOINFOHEADER *)pmt->pbFormat)->rcTarget;\n        }\n        DbgLog((LOG_TRACE, 10, L\"::GetDeliveryBuffer(): Sample contains new media type from downstream filter..\"));\n        DbgLog((LOG_TRACE, 10, L\"-> Width changed from %d to %d (target: %d)\", pBMIOld->biWidth, pBMINew->biWidth,\n                rcTarget.right));\n#endif\n\n        if (pBMINew->biWidth < width)\n        {\n            DbgLog((LOG_TRACE, 10, L\" -> Renderer is trying to shrink the output window, failing!\"));\n            (*ppOut)->Release();\n            (*ppOut) = nullptr;\n            DeleteMediaType(pmt);\n            return E_FAIL;\n        }\n\n        if (pmt->formattype == FORMAT_VideoInfo2 && outMt.formattype == FORMAT_VideoInfo2 && m_bDXVAExtFormatSupport)\n        {\n            VIDEOINFOHEADER2 *vih2Current = (VIDEOINFOHEADER2 *)outMt.pbFormat;\n            VIDEOINFOHEADER2 *vih2New = (VIDEOINFOHEADER2 *)pmt->pbFormat;\n            if (vih2Current->dwControlFlags && vih2Current->dwControlFlags != vih2New->dwControlFlags)\n            {\n                m_bDXVAExtFormatSupport = FALSE;\n                DbgLog((LOG_TRACE, 10, L\"-> Disabled DXVA2ExtFormat Support, because renderer changed our value.\"));\n            }\n        }\n\n        // Check image size\n        DWORD lSampleSize = m_PixFmtConverter.GetImageSize(pBMINew->biWidth, abs(pBMINew->biHeight));\n        if (lSampleSize != pBMINew->biSizeImage)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> biSizeImage does not match our calculated sample size, correcting\"));\n            pBMINew->biSizeImage = lSampleSize;\n            pmt->lSampleSize = lSampleSize;\n            m_bSendMediaType = TRUE;\n        }\n\n        CMediaType mt = *pmt;\n        m_pOutput->SetMediaType(&mt);\n        DeleteMediaType(pmt);\n        pmt = nullptr;\n    }\n\n    (*ppOut)->SetDiscontinuity(FALSE);\n    (*ppOut)->SetSyncPoint(TRUE);\n\n    return S_OK;\n}\n\nHRESULT CLAVVideo::ReconnectOutput(int width, int height, AVRational ar, DXVA2_ExtendedFormat dxvaExtFlags,\n                                   REFERENCE_TIME avgFrameDuration, BOOL bDXVA)\n{\n    CMediaType mt = m_pOutput->CurrentMediaType();\n\n    HRESULT hr = S_FALSE;\n    BOOL bNeedReconnect = FALSE;\n    int timeout = 100;\n\n    DWORD dwAspectX = 0, dwAspectY = 0;\n    RECT rcTargetOld = {0};\n    LONG biWidthOld = 0;\n\n    // HACK: 1280 is the value when only chroma location is set to MPEG2, do not bother to send this information, as its\n    // the same for basically every clip.\n    if ((dxvaExtFlags.value & ~0xff) != 0 && (dxvaExtFlags.value & ~0xff) != 1280)\n        dxvaExtFlags.SampleFormat = AMCONTROL_USED | AMCONTROL_COLORINFO_PRESENT;\n    else\n        dxvaExtFlags.value = 0;\n\n    if (m_bMadVR == -1)\n        m_bMadVR = FilterInGraph(PINDIR_OUTPUT, CLSID_madVR);\n\n    if (m_bJRVR == -1)\n        m_bJRVR = !m_bMadVR && FilterInGraph(PINDIR_OUTPUT, CLSID_JRVR);\n\n    if (m_bOverlayMixer == -1)\n    {\n        m_bOverlayMixer = !m_bMadVR && FilterInGraph(PINDIR_OUTPUT, CLSID_OverlayMixer);\n        if (m_bOverlayMixer)\n            m_bDXVAExtFormatSupport = 0;\n    }\n\n    // Determine Interlaced flags\n    // - madVR handles the flags properly, so properly indicate forced deint, adaptive deint and progressive\n    // - The OverlayMixer fails at interlaced support, so completely disable interlaced flags for it\n    BOOL bInterlaced = IsInterlacedOutput();\n    DWORD dwInterlacedFlags = 0;\n    if (m_bMadVR || m_bJRVR)\n    {\n        if (bInterlaced && m_settings.DeintMode == DeintMode_Force)\n        {\n            dwInterlacedFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOnly;\n        }\n        else if (bInterlaced)\n        {\n            dwInterlacedFlags = AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave;\n        }\n        else\n        {\n            dwInterlacedFlags = 0;\n        }\n    }\n    else if (!m_bOverlayMixer)\n    {\n        dwInterlacedFlags = bInterlaced ? AMINTERLACE_IsInterlaced | AMINTERLACE_DisplayModeBobOrWeave : 0;\n    }\n\n    // Remove custom matrix settings, which are not understood upstream\n    if (dxvaExtFlags.VideoTransferMatrix == 6)\n    {\n        dxvaExtFlags.VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT601;\n    }\n    else if (dxvaExtFlags.VideoTransferMatrix > 5 && !(m_bMadVR || m_bJRVR))\n    {\n        dxvaExtFlags.VideoTransferMatrix = DXVA2_VideoTransferMatrix_Unknown;\n    }\n\n    // madVR doesn't understand HLG yet, fallback to BT.709, which makes use of the backwards-compatible nature of HLG\n    // Value 16 was used for ST2084 by madVR, which results in a terrible experience with HLG videos otherwise\n    // TODO: remove once madVR learns HLG\n    if (dxvaExtFlags.VideoTransferFunction == 16 && m_bMadVR)\n    {\n        dxvaExtFlags.VideoTransferFunction = DXVA2_VideoTransFunc_709;\n    }\n\n    if (mt.formattype == FORMAT_VideoInfo)\n    {\n        VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)mt.Format();\n        if (avgFrameDuration == AV_NOPTS_VALUE)\n            avgFrameDuration = vih->AvgTimePerFrame;\n\n        bNeedReconnect = (vih->rcTarget.right != width || vih->rcTarget.bottom != height ||\n                          abs(vih->AvgTimePerFrame - avgFrameDuration) > 10);\n    }\n    else if (mt.formattype == FORMAT_VideoInfo2)\n    {\n        VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)mt.Format();\n        if (avgFrameDuration == AV_NOPTS_VALUE)\n            avgFrameDuration = vih2->AvgTimePerFrame;\n\n        DWORD dwARX, dwARY;\n        videoFormatTypeHandler(m_pInput->CurrentMediaType().Format(), m_pInput->CurrentMediaType().FormatType(),\n                               nullptr, nullptr, &dwARX, &dwARY);\n\n        int num = ar.num, den = ar.den;\n        BOOL bStreamAR = (m_settings.StreamAR == 1) ||\n                         (m_settings.StreamAR == 2 &&\n                          (!(m_dwDecodeFlags & LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST) || !(dwARX && dwARY)));\n        if (!bStreamAR || num == 0 || den == 0)\n        {\n            if (m_bForceInputAR && dwARX && dwARY)\n            {\n                num = dwARX;\n                den = dwARY;\n            }\n            else\n            {\n                num = vih2->dwPictAspectRatioX;\n                den = vih2->dwPictAspectRatioY;\n            }\n            m_bForceInputAR = FALSE;\n        }\n        dwAspectX = num;\n        dwAspectY = den;\n\n        // Disallow switching to non-interlaced mediatype for most renderers, as it causes dropped frames without real\n        // advantages\n        if (!m_bMadVR && vih2->dwInterlaceFlags)\n            dwInterlacedFlags = vih2->dwInterlaceFlags;\n\n        bNeedReconnect =\n            (vih2->rcTarget.right != width || vih2->rcTarget.bottom != height || vih2->dwPictAspectRatioX != num ||\n             vih2->dwPictAspectRatioY != den || abs(vih2->AvgTimePerFrame - avgFrameDuration) > 10 ||\n             (m_bDXVAExtFormatSupport && vih2->dwControlFlags != dxvaExtFlags.value) ||\n             (vih2->dwInterlaceFlags != dwInterlacedFlags));\n    }\n\n    if (!bNeedReconnect && bDXVA)\n    {\n        BITMAPINFOHEADER *pBMI = nullptr;\n        videoFormatTypeHandler(mt.Format(), mt.FormatType(), &pBMI);\n        bNeedReconnect = (pBMI->biCompression != mmioFOURCC('d', 'x', 'v', 'a'));\n    }\n\n    if (bNeedReconnect)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::ReconnectOutput(): Performing reconnect\"));\n        BITMAPINFOHEADER *pBIH = nullptr;\n        if (mt.formattype == FORMAT_VideoInfo)\n        {\n            VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)mt.Format();\n\n            rcTargetOld = vih->rcTarget;\n\n            DbgLog((LOG_TRACE, 10, L\"Using VIH, Format dump:\"));\n            DbgLog((LOG_TRACE, 10, L\"-> width: %d -> %d\", vih->rcTarget.right, width));\n            DbgLog((LOG_TRACE, 10, L\"-> height: %d -> %d\", vih->rcTarget.bottom, height));\n            DbgLog((LOG_TRACE, 10, L\"-> FPS: %I64d -> %I64d\", vih->AvgTimePerFrame, avgFrameDuration));\n\n            SetRect(&vih->rcSource, 0, 0, width, height);\n            SetRect(&vih->rcTarget, 0, 0, width, height);\n\n            vih->AvgTimePerFrame = avgFrameDuration;\n\n            pBIH = &vih->bmiHeader;\n        }\n        else if (mt.formattype == FORMAT_VideoInfo2)\n        {\n            VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)mt.Format();\n\n            rcTargetOld = vih2->rcTarget;\n\n            DbgLog((LOG_TRACE, 10, L\"Using VIH2, Format dump:\"));\n            DbgLog((LOG_TRACE, 10, L\"-> width: %d -> %d\", vih2->rcTarget.right, width));\n            DbgLog((LOG_TRACE, 10, L\"-> height: %d -> %d\", vih2->rcTarget.bottom, height));\n            DbgLog((LOG_TRACE, 10, L\"-> AR: %d:%d -> %d:%d\", vih2->dwPictAspectRatioX, vih2->dwPictAspectRatioY,\n                    dwAspectX, dwAspectY));\n            DbgLog((LOG_TRACE, 10, L\"-> FPS: %I64d -> %I64d\", vih2->AvgTimePerFrame, avgFrameDuration));\n            DbgLog((LOG_TRACE, 10, L\"-> interlaced: 0x%0.8x -> 0x%0.8x\", vih2->dwInterlaceFlags, dwInterlacedFlags));\n            DbgLog((LOG_TRACE, 10, L\"-> flags: 0x%0.8x -> 0x%0.8x\", vih2->dwControlFlags,\n                    m_bDXVAExtFormatSupport ? dxvaExtFlags.value : vih2->dwControlFlags));\n\n            vih2->dwPictAspectRatioX = dwAspectX;\n            vih2->dwPictAspectRatioY = dwAspectY;\n\n            SetRect(&vih2->rcSource, 0, 0, width, height);\n            SetRect(&vih2->rcTarget, 0, 0, width, height);\n\n            vih2->AvgTimePerFrame = avgFrameDuration;\n            vih2->dwInterlaceFlags = dwInterlacedFlags;\n            if (m_bDXVAExtFormatSupport)\n                vih2->dwControlFlags = dxvaExtFlags.value;\n\n            pBIH = &vih2->bmiHeader;\n        }\n\n        DWORD oldSizeImage = pBIH->biSizeImage;\n\n        biWidthOld = pBIH->biWidth;\n        pBIH->biWidth = width;\n        pBIH->biHeight = pBIH->biHeight < 0 ? -height : height;\n        pBIH->biSizeImage = m_PixFmtConverter.GetImageSize(width, height);\n\n        if (bDXVA)\n            pBIH->biCompression = mmioFOURCC('d', 'x', 'v', 'a');\n\n        if (mt.subtype == FOURCCMap('012v'))\n        {\n            pBIH->biWidth = FFALIGN(width, 48);\n        }\n\n        HRESULT hrQA = m_pOutput->GetConnected()->QueryAccept(&mt);\n        if (bDXVA)\n        {\n            m_bSendMediaType = TRUE;\n            m_pOutput->SetMediaType(&mt);\n        }\n        else\n        {\n        receiveconnection:\n            hr = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt);\n            if (SUCCEEDED(hr))\n            {\n                IMediaSample *pOut = nullptr;\n                if (SUCCEEDED(hr = m_pOutput->GetDeliveryBuffer(&pOut, nullptr, nullptr, 0)) && pOut)\n                {\n                    AM_MEDIA_TYPE *pmt = nullptr;\n                    if (SUCCEEDED(pOut->GetMediaType(&pmt)) && pmt)\n                    {\n                        CMediaType newmt = *pmt;\n                        videoFormatTypeHandler(newmt.Format(), newmt.FormatType(), &pBIH);\n                        DbgLog((LOG_TRACE, 10,\n                                L\"-> New MediaType negotiated; actual width: %d - renderer requests: %ld\", width,\n                                pBIH->biWidth));\n                        if (pBIH->biWidth < width)\n                        {\n                            DbgLog((LOG_ERROR, 10, L\"-> Renderer requests width smaller than image width, failing..\"));\n                            DeleteMediaType(pmt);\n                            pOut->Release();\n                            return E_FAIL;\n                        }\n                        // Check image size\n                        DWORD lSampleSize = m_PixFmtConverter.GetImageSize(pBIH->biWidth, abs(pBIH->biHeight));\n                        if (lSampleSize != pBIH->biSizeImage)\n                        {\n                            DbgLog((LOG_TRACE, 10,\n                                    L\"-> biSizeImage does not match our calculated sample size, correcting\"));\n                            pBIH->biSizeImage = lSampleSize;\n                            newmt.SetSampleSize(lSampleSize);\n                            m_bSendMediaType = TRUE;\n                        }\n                        // Store media type\n                        m_pOutput->SetMediaType(&newmt);\n                        m_bSendMediaType = TRUE;\n                        if (newmt.formattype == FORMAT_VideoInfo2 && mt.formattype == FORMAT_VideoInfo2 &&\n                            m_bDXVAExtFormatSupport)\n                        {\n                            VIDEOINFOHEADER2 *vih2New = (VIDEOINFOHEADER2 *)newmt.pbFormat;\n                            if (dxvaExtFlags.value && dxvaExtFlags.value != vih2New->dwControlFlags)\n                            {\n                                m_bDXVAExtFormatSupport = FALSE;\n                                DbgLog((LOG_TRACE, 10,\n                                        L\"-> Disabled DXVA2ExtFormat Support, because renderer changed our value.\"));\n                            }\n                        }\n                        DeleteMediaType(pmt);\n                    }\n                    else\n                    { // No Stride Request? We're ok with that, too!\n                        // The overlay mixer doesn't ask for a stride, but it needs one anyway\n                        // It'll provide a buffer just in the right size, so we can calculate this here.\n                        if (m_bOverlayMixer)\n                        {\n                            long size = pOut->GetSize();\n                            pBIH->biWidth = size / abs(pBIH->biHeight) * 8 / pBIH->biBitCount;\n                        }\n                        DbgLog((LOG_TRACE, 10, L\"-> We did not get a stride request, using width %d for stride\",\n                                pBIH->biWidth));\n                        m_bSendMediaType = TRUE;\n                        m_pOutput->SetMediaType(&mt);\n                    }\n                    pOut->Release();\n                }\n            }\n            else if (hr == VFW_E_BUFFERS_OUTSTANDING && timeout != -1)\n            {\n                if (timeout > 0)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"-> Buffers outstanding, retrying in 10ms..\"));\n                    Sleep(10);\n                    timeout -= 10;\n                }\n                else\n                {\n                    DbgLog((LOG_TRACE, 10, L\"-> Buffers outstanding, timeout reached, flushing..\"));\n                    m_pOutput->DeliverBeginFlush();\n                    m_pOutput->DeliverEndFlush();\n                    timeout = -1;\n                }\n                goto receiveconnection;\n            }\n            else if (hrQA == S_OK)\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> Downstream accepts new format, but cannot reconnect dynamically...\"));\n                if (pBIH->biSizeImage > oldSizeImage)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"-> But, we need a bigger buffer, try to adapt allocator manually\"));\n                    IMemInputPin *pMemPin = nullptr;\n                    if (SUCCEEDED(hr = m_pOutput->GetConnected()->QueryInterface<IMemInputPin>(&pMemPin)) && pMemPin)\n                    {\n                        IMemAllocator *pMemAllocator = nullptr;\n                        if (SUCCEEDED(hr = pMemPin->GetAllocator(&pMemAllocator)) && pMemAllocator)\n                        {\n                            ALLOCATOR_PROPERTIES props, actual;\n                            hr = pMemAllocator->GetProperties(&props);\n                            hr = pMemAllocator->Decommit();\n                            props.cbBuffer = pBIH->biSizeImage;\n                            hr = pMemAllocator->SetProperties(&props, &actual);\n                            hr = pMemAllocator->Commit();\n                            SafeRelease(&pMemAllocator);\n                        }\n                    }\n                    SafeRelease(&pMemPin);\n                }\n                else\n                {\n                    // Check if there was a stride before..\n                    if (rcTargetOld.right && biWidthOld > rcTargetOld.right && biWidthOld > pBIH->biWidth)\n                    {\n                        // If we had a stride before, the filter is apparently stride aware\n                        // Try to make it easier by keeping the old stride around\n                        pBIH->biWidth = biWidthOld;\n                    }\n                }\n                m_pOutput->SetMediaType(&mt);\n                m_bSendMediaType = TRUE;\n            }\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> Receive Connection failed (hr: %x); QueryAccept: %x\", hr, hrQA));\n            }\n        }\n        if (bNeedReconnect && !bDXVA)\n            NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(width, height), 0);\n\n        hr = S_OK;\n\n        CheckDirectMode();\n    }\n\n    return hr;\n}\n\nHRESULT CLAVVideo::NegotiatePixelFormat(CMediaType &outMt, int width, int height)\n{\n    DbgLog((LOG_TRACE, 10, L\"::NegotiatePixelFormat()\"));\n\n    HRESULT hr = S_OK;\n    int i = 0;\n    int timeout = 100;\n\n    DWORD dwAspectX, dwAspectY;\n    REFERENCE_TIME rtAvg;\n    BOOL bVIH1 = (outMt.formattype == FORMAT_VideoInfo);\n    videoFormatTypeHandler(outMt.Format(), outMt.FormatType(), nullptr, &rtAvg, &dwAspectX, &dwAspectY);\n\n    CMediaType mt;\n    for (i = 0; i < m_PixFmtConverter.GetNumMediaTypes(); ++i)\n    {\n        m_PixFmtConverter.GetMediaType(&mt, i, width, height, dwAspectX, dwAspectY, rtAvg, IsInterlacedOutput(), bVIH1);\n        // hr = m_pOutput->GetConnected()->QueryAccept(&mt);\n    receiveconnection:\n        hr = m_pOutput->GetConnected()->ReceiveConnection(m_pOutput, &mt);\n        if (hr == S_OK)\n        {\n            DbgLog((LOG_TRACE, 10, L\"::NegotiatePixelFormat(): Filter accepted format with index %d\", i));\n            m_pOutput->SetMediaType(&mt);\n            hr = S_OK;\n            goto done;\n        }\n        else if (hr == VFW_E_BUFFERS_OUTSTANDING && timeout != -1)\n        {\n            if (timeout > 0)\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> Buffers outstanding, retrying in 10ms..\"));\n                Sleep(10);\n                timeout -= 10;\n            }\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> Buffers outstanding, timeout reached, flushing..\"));\n                m_pOutput->DeliverBeginFlush();\n                m_pOutput->DeliverEndFlush();\n                timeout = -1;\n            }\n            goto receiveconnection;\n        }\n    }\n\n    DbgLog((LOG_ERROR, 10, L\"::NegotiatePixelFormat(): Unable to agree on a pixel format\"));\n    hr = E_FAIL;\n\ndone:\n    FreeMediaType(mt);\n    return hr;\n}\n\nHRESULT CLAVVideo::Receive(IMediaSample *pIn)\n{\n    CAutoLock cAutoLock(&m_csReceive);\n    HRESULT hr = S_OK;\n\n    AM_SAMPLE2_PROPERTIES const *pProps = m_pInput->SampleProps();\n    if (pProps->dwStreamId != AM_STREAM_MEDIA)\n    {\n        return m_pOutput->Deliver(pIn);\n    }\n\n    AM_MEDIA_TYPE *pmt = nullptr;\n    if (SUCCEEDED(pIn->GetMediaType(&pmt)) && pmt)\n    {\n        CMediaType mt = *pmt;\n        DeleteMediaType(pmt);\n        if (mt != m_pInput->CurrentMediaType() || !(m_dwDecodeFlags & LAV_VIDEO_DEC_FLAG_DVD))\n        {\n            DbgLog((LOG_TRACE, 10, L\"::Receive(): Input sample contained media type, dynamic format change...\"));\n            m_Decoder.EndOfStream();\n            hr = m_pInput->SetMediaType(&mt);\n            if (FAILED(hr))\n            {\n                DbgLog((LOG_ERROR, 10, L\"::Receive(): Setting new media type failed...\"));\n                return hr;\n            }\n        }\n    }\n\n    m_hrDeliver = S_OK;\n\n    // Skip over empty packets\n    if (pIn->GetActualDataLength() == 0)\n    {\n        return S_OK;\n    }\n\n    hr = m_Decoder.Decode(pIn);\n    if (FAILED(hr))\n        return hr;\n\n    if (FAILED(m_hrDeliver))\n        return m_hrDeliver;\n\n    return S_OK;\n}\n\n// ILAVVideoCallback\nSTDMETHODIMP CLAVVideo::AllocateFrame(LAVFrame **ppFrame)\n{\n    CheckPointer(ppFrame, E_POINTER);\n\n    *ppFrame = (LAVFrame *)CoTaskMemAlloc(sizeof(LAVFrame));\n    if (!*ppFrame)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    // Initialize with zero\n    ZeroMemory(*ppFrame, sizeof(LAVFrame));\n\n    // Set some defaults\n    (*ppFrame)->sw_format = LAVPixFmt_None;\n    (*ppFrame)->bpp = 8;\n    (*ppFrame)->rtStart = AV_NOPTS_VALUE;\n    (*ppFrame)->rtStop = AV_NOPTS_VALUE;\n    (*ppFrame)->aspect_ratio = {0, 1};\n\n    (*ppFrame)->frame_type = '?';\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideo::ReleaseFrame(LAVFrame **ppFrame)\n{\n    CheckPointer(ppFrame, E_POINTER);\n\n    // Allow *ppFrame to be NULL already\n    if (*ppFrame)\n    {\n        FreeLAVFrameBuffers(*ppFrame);\n        SAFE_CO_FREE(*ppFrame);\n    }\n    return S_OK;\n}\n\nHRESULT CLAVVideo::DeDirectFrame(LAVFrame *pFrame, bool bDisableDirectMode)\n{\n    if (!pFrame->direct)\n        return S_FALSE;\n\n    ASSERT(pFrame->direct_lock && pFrame->direct_unlock);\n\n    LAVPixFmtDesc desc = getPixelFormatDesc(pFrame->format);\n\n    LAVFrame tmpFrame = *pFrame;\n    pFrame->destruct = nullptr;\n    pFrame->priv_data = nullptr;\n    pFrame->direct = false;\n    pFrame->direct_lock = nullptr;\n    pFrame->direct_unlock = nullptr;\n    memset(pFrame->data, 0, sizeof(pFrame->data));\n\n    // sidedata remains on the main frame\n    tmpFrame.side_data = nullptr;\n    tmpFrame.side_data_count = 0;\n\n    LAVDirectBuffer buffer;\n    if (tmpFrame.direct_lock(&tmpFrame, &buffer))\n    {\n        HRESULT hr = AllocLAVFrameBuffers(pFrame, buffer.stride[0] / desc.codedbytes);\n        if (FAILED(hr))\n        {\n            tmpFrame.direct_unlock(&tmpFrame);\n            FreeLAVFrameBuffers(&tmpFrame);\n            return hr;\n        }\n\n        // use slow copy, this should only be used extremely rarely\n        memcpy(pFrame->data[0], buffer.data[0], pFrame->height * buffer.stride[0]);\n        for (int i = 1; i < desc.planes; i++)\n            memcpy(pFrame->data[i], buffer.data[i], (pFrame->height / desc.planeHeight[i]) * buffer.stride[i]);\n\n        tmpFrame.direct_unlock(&tmpFrame);\n    }\n    else\n    {\n        // fallack, alloc anyway so nothing blows up\n        HRESULT hr = AllocLAVFrameBuffers(pFrame);\n        if (FAILED(hr))\n        {\n            FreeLAVFrameBuffers(&tmpFrame);\n            return hr;\n        }\n    }\n\n    FreeLAVFrameBuffers(&tmpFrame);\n\n    if (bDisableDirectMode)\n        m_Decoder.SetDirectOutput(false);\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(LAVFrame *) CLAVVideo::GetFlushFrame()\n{\n    LAVFrame *pFlushFrame = nullptr;\n    AllocateFrame(&pFlushFrame);\n    pFlushFrame->flags |= LAV_FRAME_FLAG_FLUSH;\n    pFlushFrame->rtStart = INT64_MAX;\n    pFlushFrame->rtStop = INT64_MAX;\n    return pFlushFrame;\n}\n\nSTDMETHODIMP CLAVVideo::Deliver(LAVFrame *pFrame)\n{\n    // Out-of-sequence flush event to get all frames delivered,\n    // only triggered by decoders when they are already \"empty\"\n    // so no need to flush the decoder here\n    if (pFrame->flags & LAV_FRAME_FLAG_FLUSH)\n    {\n        DbgLog((LOG_TRACE, 10, L\"Decoder triggered a flush...\"));\n        Filter(GetFlushFrame());\n\n        ReleaseFrame(&pFrame);\n        return S_FALSE;\n    }\n\n    if (m_bFlushing)\n    {\n        ReleaseFrame(&pFrame);\n        return S_FALSE;\n    }\n\n    if (ValidateLAVFrameBuffers(pFrame) == false)\n    {\n        ReleaseFrame(&pFrame);\n        return S_FALSE;\n    }\n\n    if (pFrame->rtStart == AV_NOPTS_VALUE)\n    {\n        pFrame->rtStart = m_rtPrevStop;\n        pFrame->rtStop = AV_NOPTS_VALUE;\n    }\n\n    if (pFrame->rtStop == AV_NOPTS_VALUE)\n    {\n        REFERENCE_TIME duration = 0;\n\n        CMediaType &mt = m_pOutput->CurrentMediaType();\n        videoFormatTypeHandler(mt.Format(), mt.FormatType(), nullptr, &duration, nullptr, nullptr);\n\n        REFERENCE_TIME decoderDuration = m_Decoder.GetFrameDuration();\n        if (pFrame->avgFrameDuration && pFrame->avgFrameDuration != AV_NOPTS_VALUE)\n        {\n            duration = pFrame->avgFrameDuration;\n        }\n        else if (!duration && decoderDuration)\n        {\n            duration = decoderDuration;\n        }\n        else if (!duration)\n        {\n            duration = 1;\n        }\n\n        pFrame->rtStop = pFrame->rtStart + (duration * (pFrame->repeat ? 3 : 2) / 2);\n    }\n\n#if defined(DEBUG) && DEBUG_FRAME_TIMINGS\n    DbgLog((LOG_TRACE, 10,\n            L\"Frame, rtStart: %I64d, dur: %I64d, diff: %I64d, key: %d, type: %C, repeat: %d, interlaced: %d, tff: %d\",\n            pFrame->rtStart, pFrame->rtStop - pFrame->rtStart, pFrame->rtStart - m_rtPrevStart, pFrame->key_frame,\n            pFrame->frame_type, pFrame->repeat, pFrame->interlaced, pFrame->tff));\n#endif\n\n    m_rtPrevStart = pFrame->rtStart;\n    m_rtPrevStop = pFrame->rtStop;\n\n    if (!pFrame->avgFrameDuration || pFrame->avgFrameDuration == AV_NOPTS_VALUE)\n        pFrame->avgFrameDuration = m_rtAvgTimePerFrame;\n    else\n        m_rtAvgTimePerFrame = pFrame->avgFrameDuration;\n\n    if (pFrame->rtStart < 0)\n    {\n        ReleaseFrame(&pFrame);\n        return S_OK;\n    }\n\n    // Only perform filtering if we have to.\n    // DXVA Native generally can't be filtered, and the only filtering we currently support is software deinterlacing\n    if (pFrame->format == LAVPixFmt_DXVA2 || pFrame->format == LAVPixFmt_D3D11 ||\n        !(m_Decoder.IsInterlaced(FALSE) && m_settings.SWDeintMode != SWDeintMode_None) ||\n        pFrame->flags & LAV_FRAME_FLAG_REDRAW)\n    {\n        return DeliverToRenderer(pFrame);\n    }\n    else\n    {\n        Filter(pFrame);\n    }\n    return S_OK;\n}\n\nHRESULT CLAVVideo::DeliverToRenderer(LAVFrame *pFrame)\n{\n    HRESULT hr = S_OK;\n\n    // This should never get here, but better check\n    if (pFrame->flags & LAV_FRAME_FLAG_FLUSH)\n    {\n        ReleaseFrame(&pFrame);\n        return S_FALSE;\n    }\n\n    if (!(pFrame->flags & LAV_FRAME_FLAG_REDRAW))\n    {\n        // Release the old End-of-Sequence frame, this ensures any \"normal\" frame will clear the stored EOS frame\n        if (pFrame->format != LAVPixFmt_DXVA2 && pFrame->format != LAVPixFmt_D3D11)\n        {\n            ReleaseFrame(&m_pLastSequenceFrame);\n            if ((pFrame->flags & LAV_FRAME_FLAG_END_OF_SEQUENCE || m_bInDVDMenu))\n            {\n                if (pFrame->direct)\n                {\n                    hr = DeDirectFrame(pFrame, false);\n                    if (FAILED(hr))\n                    {\n                        ReleaseFrame(&pFrame);\n                        return hr;\n                    }\n                }\n                CopyLAVFrame(pFrame, &m_pLastSequenceFrame);\n            }\n        }\n        else if (pFrame->format == LAVPixFmt_DXVA2)\n        {\n            if ((pFrame->flags & LAV_FRAME_FLAG_END_OF_SEQUENCE || m_bInDVDMenu))\n            {\n                if (!m_pLastSequenceFrame)\n                {\n                    hr = AllocateFrame(&m_pLastSequenceFrame);\n                    if (SUCCEEDED(hr))\n                    {\n                        m_pLastSequenceFrame->format = LAVPixFmt_DXVA2;\n\n                        hr = GetD3DBuffer(m_pLastSequenceFrame);\n                        if (FAILED(hr))\n                        {\n                            ReleaseFrame(&m_pLastSequenceFrame);\n                        }\n                    }\n                }\n                if (m_pLastSequenceFrame && m_pLastSequenceFrame->data[0] && m_pLastSequenceFrame->data[3])\n                {\n                    BYTE *data0 = m_pLastSequenceFrame->data[0], *data3 = m_pLastSequenceFrame->data[3];\n                    *m_pLastSequenceFrame = *pFrame;\n                    m_pLastSequenceFrame->data[0] = data0;\n                    m_pLastSequenceFrame->data[3] = data3;\n\n                    // Be careful not to accidentally copy the destructor of the original frame, that would end up being\n                    // bad\n                    m_pLastSequenceFrame->destruct = nullptr;\n                    m_pLastSequenceFrame->priv_data = nullptr;\n\n                    // don't copy side data\n                    m_pLastSequenceFrame->side_data = nullptr;\n                    m_pLastSequenceFrame->side_data_count = 0;\n\n                    IDirect3DSurface9 *pSurface = (IDirect3DSurface9 *)m_pLastSequenceFrame->data[3];\n\n                    IDirect3DDevice9 *pDevice = nullptr;\n                    hr = pSurface->GetDevice(&pDevice);\n                    if (SUCCEEDED(hr))\n                    {\n                        hr = pDevice->StretchRect((IDirect3DSurface9 *)pFrame->data[3], nullptr, pSurface, nullptr,\n                                                  D3DTEXF_NONE);\n                        if (FAILED(hr))\n                        {\n                            DbgLog((LOG_TRACE, 10, L\"::Decode(): Copying DXVA2 surface failed\"));\n                        }\n                        SafeRelease(&pDevice);\n                    }\n                }\n            }\n        }\n        else if (pFrame->format == LAVPixFmt_D3D11)\n        {\n            // TODO D3D11\n        }\n    }\n\n    if (m_bFlushing)\n    {\n        ReleaseFrame(&pFrame);\n        return S_FALSE;\n    }\n\n    // Process stream-level sidedata and attach it to the frame if necessary\n    if (m_SideData.Mastering.has_colorspace)\n    {\n        // preserve HLG setting, as the container can often indicate the corresponding SDR format\n        if (pFrame->ext_format.VideoTransferFunction == MFVideoTransFunc_HLG)\n            m_SideData.Mastering.color_trc = AVCOL_TRC_ARIB_STD_B67;\n\n        fillDXVAExtFormat(pFrame->ext_format, m_SideData.Mastering.color_range - 1,\n                          m_SideData.Mastering.color_primaries, m_SideData.Mastering.colorspace,\n                          m_SideData.Mastering.color_trc, m_SideData.Mastering.chroma_location, false);\n    }\n    if (m_SideData.Mastering.has_luminance || m_SideData.Mastering.has_primaries)\n    {\n        MediaSideDataHDR *hdr = nullptr;\n\n        // Check if HDR data already exists\n        if (pFrame->side_data && pFrame->side_data_count)\n        {\n            for (int i = 0; i < pFrame->side_data_count; i++)\n            {\n                if (pFrame->side_data[i].guidType == IID_MediaSideDataHDR)\n                {\n                    hdr = (MediaSideDataHDR *)pFrame->side_data[i].data;\n                    break;\n                }\n            }\n        }\n\n        if (hdr == nullptr)\n            hdr = (MediaSideDataHDR *)AddLAVFrameSideData(pFrame, IID_MediaSideDataHDR, sizeof(MediaSideDataHDR));\n\n        processFFHDRData(hdr, &m_SideData.Mastering);\n    }\n\n    if (m_SideData.ContentLight.MaxCLL && m_SideData.ContentLight.MaxFALL)\n    {\n        MediaSideDataHDRContentLightLevel *hdr = nullptr;\n\n        // Check if data already exists\n        if (pFrame->side_data && pFrame->side_data_count)\n        {\n            for (int i = 0; i < pFrame->side_data_count; i++)\n            {\n                if (pFrame->side_data[i].guidType == IID_MediaSideDataHDRContentLightLevel)\n                {\n                    hdr = (MediaSideDataHDRContentLightLevel *)pFrame->side_data[i].data;\n                    break;\n                }\n            }\n        }\n\n        if (hdr == nullptr)\n            hdr = (MediaSideDataHDRContentLightLevel *)AddLAVFrameSideData(\n                pFrame, IID_MediaSideDataHDRContentLightLevel, sizeof(MediaSideDataHDRContentLightLevel));\n\n        hdr->MaxCLL = m_SideData.ContentLight.MaxCLL;\n        hdr->MaxFALL = m_SideData.ContentLight.MaxFALL;\n    }\n\n    // Collect width/height\n    int width = pFrame->width;\n    int height = pFrame->height;\n\n    if (width == 1920 && height == 1088)\n    {\n        height = 1080;\n    }\n\n    if (m_PixFmtConverter.SetInputFmt(pFrame->sw_format, pFrame->bpp) || m_bForceFormatNegotiation)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::Decode(): Changed input pixel format to %d (%d bpp, hw: %d)\", pFrame->sw_format, pFrame->bpp, (pFrame->format != pFrame->sw_format)));\n\n        CMediaType &mt = m_pOutput->CurrentMediaType();\n\n        if (m_PixFmtConverter.GetOutputBySubtype(mt.Subtype()) != m_PixFmtConverter.GetPreferredOutput())\n        {\n            NegotiatePixelFormat(mt, width, height);\n        }\n        m_bForceFormatNegotiation = FALSE;\n    }\n    m_PixFmtConverter.SetColorProps(pFrame->ext_format, m_settings.RGBRange);\n\n    // Update flags for cases where the converter can change the nominal range\n    if (m_PixFmtConverter.IsRGBConverterActive())\n    {\n        if (m_settings.RGBRange != 0)\n            pFrame->ext_format.NominalRange =\n                m_settings.RGBRange == 1 ? DXVA2_NominalRange_16_235 : DXVA2_NominalRange_0_255;\n        else if (pFrame->ext_format.NominalRange == DXVA2_NominalRange_Unknown)\n            pFrame->ext_format.NominalRange = DXVA2_NominalRange_16_235;\n    }\n    else if (m_PixFmtConverter.GetOutputPixFmt() == LAVOutPixFmt_RGB32 ||\n             m_PixFmtConverter.GetOutputPixFmt() == LAVOutPixFmt_RGB24 ||\n             m_PixFmtConverter.GetOutputPixFmt() == LAVOutPixFmt_RGB48)\n    {\n        pFrame->ext_format.NominalRange = DXVA2_NominalRange_0_255;\n    }\n\n    // Check if we are doing RGB output\n    BOOL bRGBOut = (m_PixFmtConverter.GetOutputPixFmt() == LAVOutPixFmt_RGB24 ||\n                    m_PixFmtConverter.GetOutputPixFmt() == LAVOutPixFmt_RGB32);\n    // And blend subtitles if we're on YUV output before blending (because the output YUV formats are more complicated\n    // to handle)\n    if (m_SubtitleConsumer && m_SubtitleConsumer->HasProvider())\n    {\n        m_SubtitleConsumer->SetVideoSize(width, height);\n        m_SubtitleConsumer->RequestFrame(pFrame->rtStart, pFrame->rtStop);\n        if (!bRGBOut)\n        {\n            if (pFrame->direct)\n            {\n                hr = DeDirectFrame(pFrame, true);\n                if (FAILED(hr))\n                {\n                    ReleaseFrame(&pFrame);\n                    return hr;\n                }\n            }\n            m_SubtitleConsumer->ProcessFrame(pFrame);\n        }\n    }\n\n    // Grab a media sample, and start assembling the data for it.\n    IMediaSample *pSampleOut = nullptr;\n    BYTE *pDataOut = nullptr;\n\n    REFERENCE_TIME avgDuration = pFrame->avgFrameDuration;\n    if (avgDuration == 0)\n        avgDuration = AV_NOPTS_VALUE;\n\n    if (pFrame->format == LAVPixFmt_DXVA2 || pFrame->format == LAVPixFmt_D3D11)\n    {\n        pSampleOut = (IMediaSample *)pFrame->data[0];\n        // Addref the sample if we need to. If its coming from the decoder, it should be addref'ed,\n        // but if its a copy from the subtitle engine, then it should not be addref'ed.\n        if (!(pFrame->flags & LAV_FRAME_FLAG_DXVA_NOADDREF))\n            pSampleOut->AddRef();\n\n        ReconnectOutput(width, height, pFrame->aspect_ratio, pFrame->ext_format, avgDuration, TRUE);\n    }\n    else\n    {\n        if (FAILED(hr = GetDeliveryBuffer(&pSampleOut, width, height, pFrame->aspect_ratio, pFrame->ext_format,\n                                          avgDuration)) ||\n            FAILED(hr = pSampleOut->GetPointer(&pDataOut)) || pDataOut == nullptr)\n        {\n            SafeRelease(&pSampleOut);\n            ReleaseFrame(&pFrame);\n            return hr;\n        }\n    }\n\n    CMediaType &mt = m_pOutput->CurrentMediaType();\n    BITMAPINFOHEADER *pBIH = nullptr;\n    videoFormatTypeHandler(mt.Format(), mt.FormatType(), &pBIH);\n\n    // Set side data on the media sample\n    if (pFrame->side_data_count)\n    {\n        IMediaSideData *pMediaSideData = nullptr;\n        if (SUCCEEDED(hr = pSampleOut->QueryInterface(&pMediaSideData)))\n        {\n            for (int i = 0; i < pFrame->side_data_count; i++)\n            {\n                if (pFrame->side_data[i].guidType != IID_MediaSideDataEIA608CC)\n                    pMediaSideData->SetSideData(pFrame->side_data[i].guidType, pFrame->side_data[i].data,\n                                                pFrame->side_data[i].size);\n            }\n\n            SafeRelease(&pMediaSideData);\n        }\n\n        if (m_pCCOutputPin && m_pCCOutputPin->IsConnected())\n        {\n            size_t sCC = 0;\n            BYTE *CC = GetLAVFrameSideData(pFrame, IID_MediaSideDataEIA608CC, &sCC);\n            if (CC && sCC)\n            {\n                m_pCCOutputPin->DeliverCCData(CC, sCC, pFrame->rtStart);\n            }\n        }\n    }\n\n    if (pFrame->flags & (LAV_FRAME_FLAG_END_OF_SEQUENCE | LAV_FRAME_FLAG_REDRAW))\n    {\n        IMediaSideData *pMediaSideData = nullptr;\n        if (SUCCEEDED(hr = pSampleOut->QueryInterface(&pMediaSideData)))\n        {\n            DWORD dwControlFlags = MediaSideDataControlFlags_EndOfSequence;\n            pMediaSideData->SetSideData(IID_MediaSideDataControlFlags, (const BYTE *)&dwControlFlags, sizeof(dwControlFlags));\n\n            SafeRelease(&pMediaSideData);\n        }\n    }\n\n    if (pFrame->format != LAVPixFmt_DXVA2 && pFrame->format != LAVPixFmt_D3D11)\n    {\n        long required = m_PixFmtConverter.GetImageSize(pBIH->biWidth, abs(pBIH->biHeight));\n\n        long lSampleSize = pSampleOut->GetSize();\n        if (lSampleSize < required)\n        {\n            DbgLog(\n                (LOG_ERROR, 10, L\"::Decode(): Buffer is too small! Actual: %d, Required: %d\", lSampleSize, required));\n            SafeRelease(&pSampleOut);\n            ReleaseFrame(&pFrame);\n            return E_FAIL;\n        }\n        pSampleOut->SetActualDataLength(required);\n\n#if defined(DEBUG) && DEBUG_PIXELCONV_TIMINGS\n        LARGE_INTEGER frequency, start, end;\n        QueryPerformanceFrequency(&frequency);\n        QueryPerformanceCounter(&start);\n#endif\n\n        if (pFrame->direct && !m_PixFmtConverter.IsDirectModeSupported((uintptr_t)pDataOut, pBIH->biWidth))\n        {\n            DeDirectFrame(pFrame, true);\n        }\n\n        if (pFrame->direct)\n            m_PixFmtConverter.ConvertDirect(pFrame, pDataOut, width, height, pBIH->biWidth, abs(pBIH->biHeight));\n        else\n            m_PixFmtConverter.Convert(pFrame->data, pFrame->stride, pDataOut, width, height, pBIH->biWidth,\n                                      abs(pBIH->biHeight));\n\n#if defined(DEBUG) && DEBUG_PIXELCONV_TIMINGS\n        QueryPerformanceCounter(&end);\n        double diff = (end.QuadPart - start.QuadPart) * 1000.0 / frequency.QuadPart;\n        m_pixFmtTimingAvg.Sample(diff);\n\n        DbgLog((LOG_TRACE, 10, L\"Pixel Mapping took %2.3fms in avg\", m_pixFmtTimingAvg.Average()));\n#endif\n\n        // Write the second view into IMediaSample3D, if available\n        if (pFrame->flags & LAV_FRAME_FLAG_MVC)\n        {\n            IMediaSample3D *pSample3D = nullptr;\n            if (SUCCEEDED(hr = pSampleOut->QueryInterface(&pSample3D)))\n            {\n                BYTE *pDataOut3D = nullptr;\n                if (SUCCEEDED(pSample3D->Enable3D()) && SUCCEEDED(pSample3D->GetPointer3D(&pDataOut3D)))\n                {\n                    m_PixFmtConverter.Convert(pFrame->stereo, pFrame->stride, pDataOut3D, width, height, pBIH->biWidth,\n                                              abs(pBIH->biHeight));\n                }\n                SafeRelease(&pSample3D);\n            }\n        }\n\n        // Once we're done with the old frame, release its buffers\n        // This does not release the frame yet, just free its buffers\n        FreeLAVFrameBuffers(pFrame);\n\n        // .. and if we do RGB conversion, blend after the conversion, for improved quality\n        if (bRGBOut && m_SubtitleConsumer && m_SubtitleConsumer->HasProvider())\n        {\n            int strideBytes = pBIH->biWidth;\n            LAVPixelFormat pixFmt;\n            if (m_PixFmtConverter.GetOutputPixFmt() == LAVOutPixFmt_RGB32)\n            {\n                pixFmt = LAVPixFmt_RGB32;\n                strideBytes *= 4;\n            }\n            else\n            {\n                pixFmt = LAVPixFmt_RGB24;\n                strideBytes *= 3;\n            }\n\n            // We need to supply a LAV Frame to the subtitle API\n            // So update it with the appropriate settings\n            pFrame->data[0] = pDataOut;\n            pFrame->stride[0] = strideBytes;\n            pFrame->format = pixFmt;\n            pFrame->sw_format = pixFmt;\n            pFrame->bpp = 8;\n            pFrame->flags |= LAV_FRAME_FLAG_BUFFER_MODIFY;\n            m_SubtitleConsumer->ProcessFrame(pFrame);\n        }\n\n        if ((mt.subtype == MEDIASUBTYPE_RGB32 || mt.subtype == MEDIASUBTYPE_RGB24) && pBIH->biHeight > 0)\n        {\n            int bpp = (mt.subtype == MEDIASUBTYPE_RGB32) ? 4 : 3;\n            flip_plane(pDataOut, pBIH->biWidth * bpp, height);\n        }\n    }\n\n    BOOL bSizeChanged = FALSE;\n    if (m_bSendMediaType)\n    {\n        AM_MEDIA_TYPE *sendmt = CreateMediaType(&mt);\n        pSampleOut->SetMediaType(sendmt);\n        DeleteMediaType(sendmt);\n        m_bSendMediaType = FALSE;\n        if (pFrame->format == LAVPixFmt_DXVA2 || pFrame->format == LAVPixFmt_D3D11)\n            bSizeChanged = TRUE;\n    }\n\n    // Handle DVD playback rate..\n    if (GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD)\n    {\n        CVideoInputPin *pPin = dynamic_cast<CVideoInputPin *>(m_pInput);\n        AM_SimpleRateChange pinRate = pPin->GetDVDRateChange();\n        if (abs(pinRate.Rate) != m_DVDRate.Rate)\n        {\n            DbgLog((LOG_TRACE, 10, L\"DVD Rate changed to: %d\", pinRate.Rate));\n            m_DVDRate.Rate = abs(pinRate.Rate);\n            m_DVDRate.StartTime = pFrame->rtStart;\n        }\n\n        if (m_DVDRate.StartTime != AV_NOPTS_VALUE && m_DVDRate.Rate != 10000)\n        {\n            pFrame->rtStart = m_DVDRate.StartTime + (pFrame->rtStart - m_DVDRate.StartTime) * m_DVDRate.Rate / 10000;\n            pFrame->rtStop = m_DVDRate.StartTime + (pFrame->rtStop - m_DVDRate.StartTime) * m_DVDRate.Rate / 10000;\n        }\n    }\n\n    // Set frame timings..\n    pSampleOut->SetTime(&pFrame->rtStart, &pFrame->rtStop);\n    pSampleOut->SetMediaTime(nullptr, nullptr);\n\n    // And frame flags..\n    SetFrameFlags(pSampleOut, pFrame);\n\n    // Release frame before delivery, so it can be re-used by the decoder (if required)\n    ReleaseFrame(&pFrame);\n\n    hr = m_pOutput->Deliver(pSampleOut);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"::Decode(): Deliver failed with hr: %x\", hr));\n        m_hrDeliver = hr;\n    }\n\n    if (bSizeChanged)\n        NotifyEvent(EC_VIDEO_SIZE_CHANGED, MAKELPARAM(pBIH->biWidth, abs(pBIH->biHeight)), 0);\n\n    SafeRelease(&pSampleOut);\n\n    return hr;\n}\n\nHRESULT CLAVVideo::GetD3DBuffer(LAVFrame *pFrame)\n{\n    CheckPointer(pFrame, E_POINTER);\n\n    IMediaSample *pSample = nullptr;\n    HRESULT hr = m_pOutput->GetDeliveryBuffer(&pSample, nullptr, nullptr, 0);\n    if (SUCCEEDED(hr))\n    {\n        IMFGetService *pService = nullptr;\n        hr = pSample->QueryInterface(&pService);\n        if (SUCCEEDED(hr))\n        {\n            IDirect3DSurface9 *pSurface = nullptr;\n            hr = pService->GetService(MR_BUFFER_SERVICE, __uuidof(IDirect3DSurface9), (LPVOID *)&pSurface);\n            if (SUCCEEDED(hr))\n            {\n                pFrame->data[0] = (BYTE *)pSample;\n                pFrame->data[3] = (BYTE *)pSurface;\n            }\n            SafeRelease(&pService);\n        }\n    }\n    return hr;\n}\n\nHRESULT CLAVVideo::RedrawStillImage()\n{\n    IMediaControl *pMC = nullptr;\n    if (m_pGraph->QueryInterface(&pMC) == S_OK && pMC)\n    {\n        OAFilterState state = State_Stopped;\n        pMC->GetState(0, &state);\n        SafeRelease(&pMC);\n        if (state != State_Running)\n        {\n            DbgLog((LOG_TRACE, 10, L\"CLAVVideo::RedrawStillImage(): Redraw ignored, graph is not running.\"));\n            return S_FALSE;\n        }\n    }\n\n    if (m_pLastSequenceFrame)\n    {\n        CAutoLock lock(&m_csReceive);\n        // Since a delivery call can clear the stored sequence frame, we need a second check here\n        // Because only after we obtained the receive lock, we are in charge..\n        if (!m_pLastSequenceFrame)\n            return S_FALSE;\n\n        DbgLog((LOG_TRACE, 10, L\"CLAVVideo::RedrawStillImage(): Redrawing still image\"));\n\n        LAVFrame *pFrame = nullptr;\n\n        if (m_pLastSequenceFrame->format == LAVPixFmt_DXVA2)\n        {\n            HRESULT hr = AllocateFrame(&pFrame);\n            if (FAILED(hr))\n                return hr;\n\n            *pFrame = *m_pLastSequenceFrame;\n            hr = GetD3DBuffer(pFrame);\n            if (SUCCEEDED(hr))\n            {\n                IMediaSample *pSample = (IMediaSample *)pFrame->data[0];\n                IDirect3DSurface9 *pSurface = (IDirect3DSurface9 *)pFrame->data[3];\n\n                pSample->SetTime(&m_pLastSequenceFrame->rtStart, &m_pLastSequenceFrame->rtStop);\n\n                IDirect3DDevice9 *pDevice = nullptr;\n                if (SUCCEEDED(pSurface->GetDevice(&pDevice)))\n                {\n                    hr = pDevice->StretchRect((IDirect3DSurface9 *)m_pLastSequenceFrame->data[3], nullptr, pSurface,\n                                              nullptr, D3DTEXF_NONE);\n                    if (SUCCEEDED(hr))\n                    {\n                        pFrame->flags |= LAV_FRAME_FLAG_REDRAW | LAV_FRAME_FLAG_BUFFER_MODIFY;\n                        hr = Deliver(pFrame);\n                    }\n                    SafeRelease(&pDevice);\n                }\n\n                SafeRelease(&pSurface);\n                SafeRelease(&pSample);\n            }\n            return hr;\n        }\n        else if (m_pLastSequenceFrame->format == LAVPixFmt_D3D11)\n        {\n            // TODO D3D11\n        }\n        else\n        {\n            LAVFrame *pFrame = nullptr;\n            HRESULT hr = CopyLAVFrame(m_pLastSequenceFrame, &pFrame);\n            if (FAILED(hr))\n                return hr;\n\n            pFrame->flags |= LAV_FRAME_FLAG_REDRAW;\n            return Deliver(pFrame);\n        }\n        return S_FALSE;\n    }\n\n    return S_FALSE;\n}\n\nHRESULT CLAVVideo::SetFrameFlags(IMediaSample *pMS, LAVFrame *pFrame)\n{\n    HRESULT hr = S_OK;\n    IMediaSample2 *pMS2 = nullptr;\n    if (SUCCEEDED(hr = pMS->QueryInterface(&pMS2)))\n    {\n        AM_SAMPLE2_PROPERTIES props;\n        if (SUCCEEDED(pMS2->GetProperties(sizeof(props), (BYTE *)&props)))\n        {\n            props.dwTypeSpecificFlags &= ~0x7f;\n\n            if (!pFrame->interlaced)\n                props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_WEAVE;\n\n            if (pFrame->tff)\n                props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_FIELD1FIRST;\n\n            if (pFrame->repeat)\n                props.dwTypeSpecificFlags |= AM_VIDEO_FLAG_REPEAT_FIELD;\n\n            pMS2->SetProperties(sizeof(props), (BYTE *)&props);\n        }\n    }\n    SafeRelease(&pMS2);\n    return hr;\n}\n\nSTDMETHODIMP CLAVVideo::Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog)\n{\n    CheckPointer(pszPropName, E_INVALIDARG);\n    CheckPointer(pVar, E_INVALIDARG);\n\n    if (_wcsicmp(pszPropName, L\"STEREOSCOPIC3D\") == 0)\n    {\n        const WCHAR *pszDecoder = GetActiveDecoderName();\n        bool bMVC = pszDecoder && wcscmp(pszDecoder, L\"msdk mvc\") == 0;\n\n        VariantClear(pVar);\n        pVar->vt = VT_BSTR;\n        pVar->bstrVal = SysAllocString(bMVC ? L\"1\" : L\"0\");\n        return S_OK;\n    }\n\n    return E_INVALIDARG;\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::HasDynamicInputAllocator()\n{\n    return dynamic_cast<CVideoInputPin *>(m_pInput)->HasDynamicAllocator();\n}\n\n// ILAVVideoSettings\nSTDMETHODIMP CLAVVideo::SetRuntimeConfig(BOOL bRuntimeConfig)\n{\n    m_bRuntimeConfig = bRuntimeConfig;\n    LoadSettings();\n\n    // Tray Icon is disabled by default\n    SAFE_DELETE(m_pTrayIcon);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideo::SetFormatConfiguration(LAVVideoCodec vCodec, BOOL bEnabled)\n{\n    if (vCodec < 0 || vCodec >= Codec_VideoNB)\n        return E_FAIL;\n\n    m_settings.bFormats[vCodec] = bEnabled;\n\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetFormatConfiguration(LAVVideoCodec vCodec)\n{\n    if (vCodec < 0 || vCodec >= Codec_VideoNB)\n        return FALSE;\n\n    return m_settings.bFormats[vCodec];\n}\n\nSTDMETHODIMP CLAVVideo::SetNumThreads(DWORD dwNum)\n{\n    m_settings.NumThreads = dwNum;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(DWORD) CLAVVideo::GetNumThreads()\n{\n    return m_settings.NumThreads;\n}\n\nSTDMETHODIMP CLAVVideo::SetStreamAR(DWORD bStreamAR)\n{\n    m_settings.StreamAR = bStreamAR;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(DWORD) CLAVVideo::GetStreamAR()\n{\n    return m_settings.StreamAR;\n}\n\nSTDMETHODIMP CLAVVideo::SetDeintFieldOrder(LAVDeintFieldOrder order)\n{\n    m_settings.DeintFieldOrder = order;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVDeintFieldOrder) CLAVVideo::GetDeintFieldOrder()\n{\n    return (LAVDeintFieldOrder)m_settings.DeintFieldOrder;\n}\n\nSTDMETHODIMP CLAVVideo::SetDeintAggressive(BOOL bAggressive)\n{\n    if (m_settings.DeintMode == DeintMode_Auto && bAggressive)\n        m_settings.DeintMode = DeintMode_Aggressive;\n    else if (m_settings.DeintMode == DeintMode_Aggressive && !bAggressive)\n        m_settings.DeintMode = DeintMode_Auto;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetDeintAggressive()\n{\n    return (m_settings.DeintMode == DeintMode_Aggressive);\n}\n\nSTDMETHODIMP CLAVVideo::SetDeintForce(BOOL bForce)\n{\n    if ((m_settings.DeintMode == DeintMode_Auto || m_settings.DeintMode == DeintMode_Aggressive) && bForce)\n        m_settings.DeintMode = DeintMode_Force;\n    else if (m_settings.DeintMode == DeintMode_Force && !bForce)\n        m_settings.DeintMode = DeintMode_Auto;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetDeintForce()\n{\n    return (m_settings.DeintMode == DeintMode_Force);\n}\n\nSTDMETHODIMP CLAVVideo::SetPixelFormat(LAVOutPixFmts pixFmt, BOOL bEnabled)\n{\n    if (pixFmt < 0 || pixFmt >= LAVOutPixFmt_NB)\n        return E_FAIL;\n\n    m_settings.bPixFmts[pixFmt] = bEnabled;\n\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetPixelFormat(LAVOutPixFmts pixFmt)\n{\n    if (pixFmt < 0 || pixFmt >= LAVOutPixFmt_NB)\n        return FALSE;\n\n    return m_settings.bPixFmts[pixFmt];\n}\n\nSTDMETHODIMP CLAVVideo::SetRGBOutputRange(DWORD dwRange)\n{\n    m_settings.RGBRange = dwRange;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(DWORD) CLAVVideo::GetRGBOutputRange()\n{\n    return m_settings.RGBRange;\n}\n\nSTDMETHODIMP_(DWORD) CLAVVideo::CheckHWAccelSupport(LAVHWAccel hwAccel)\n{\n    if (hwAccel == m_settings.HWAccel && m_Decoder.IsHWDecoderActive())\n        return 2;\n\n    HRESULT hr = E_FAIL;\n    ILAVDecoder *pDecoder = CDecodeManager::CreateHWAccelDecoder(hwAccel);\n\n    if (pDecoder)\n    {\n        hr = pDecoder->InitInterfaces(this, this);\n        if (SUCCEEDED(hr))\n        {\n            hr = pDecoder->Check();\n        }\n        SAFE_DELETE(pDecoder);\n    }\n\n    return SUCCEEDED(hr) ? 1 : 0;\n}\n\nSTDMETHODIMP CLAVVideo::SetHWAccel(LAVHWAccel hwAccel)\n{\n    m_settings.HWAccel = hwAccel;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVHWAccel) CLAVVideo::GetHWAccel()\n{\n    return (LAVHWAccel)m_settings.HWAccel;\n}\n\nSTDMETHODIMP CLAVVideo::SetHWAccelCodec(LAVVideoHWCodec hwAccelCodec, BOOL bEnabled)\n{\n    if (hwAccelCodec < 0 || hwAccelCodec >= HWCodec_NB)\n        return E_FAIL;\n\n    m_settings.bHWFormats[hwAccelCodec] = bEnabled;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetHWAccelCodec(LAVVideoHWCodec hwAccelCodec)\n{\n    if (hwAccelCodec < 0 || hwAccelCodec >= HWCodec_NB)\n        return FALSE;\n\n    return m_settings.bHWFormats[hwAccelCodec];\n}\n\nSTDMETHODIMP CLAVVideo::SetHWAccelDeintMode(LAVHWDeintModes deintMode)\n{\n    m_settings.HWDeintMode = deintMode;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVHWDeintModes) CLAVVideo::GetHWAccelDeintMode()\n{\n    return (LAVHWDeintModes)m_settings.HWDeintMode;\n}\n\nSTDMETHODIMP CLAVVideo::SetHWAccelDeintOutput(LAVDeintOutput deintOutput)\n{\n    m_settings.HWDeintOutput = deintOutput;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVDeintOutput) CLAVVideo::GetHWAccelDeintOutput()\n{\n    return (LAVDeintOutput)m_settings.HWDeintOutput;\n}\n\nSTDMETHODIMP CLAVVideo::SetHWAccelDeintHQ(BOOL bHQ)\n{\n    m_settings.HWAccelCUVIDXVA = bHQ;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetHWAccelDeintHQ()\n{\n    return m_settings.HWAccelCUVIDXVA;\n}\n\nSTDMETHODIMP CLAVVideo::SetSWDeintMode(LAVSWDeintModes deintMode)\n{\n    m_settings.SWDeintMode = deintMode;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVSWDeintModes) CLAVVideo::GetSWDeintMode()\n{\n    return (LAVSWDeintModes)m_settings.SWDeintMode;\n}\n\nSTDMETHODIMP CLAVVideo::SetSWDeintOutput(LAVDeintOutput deintOutput)\n{\n    m_settings.SWDeintOutput = deintOutput;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVDeintOutput) CLAVVideo::GetSWDeintOutput()\n{\n    return (LAVDeintOutput)m_settings.SWDeintOutput;\n}\n\nSTDMETHODIMP CLAVVideo::SetDeintTreatAsProgressive(BOOL bEnabled)\n{\n    m_settings.DeintMode = bEnabled ? DeintMode_Disable : DeintMode_Auto;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetDeintTreatAsProgressive()\n{\n    return (m_settings.DeintMode == DeintMode_Disable);\n}\n\nSTDMETHODIMP CLAVVideo::SetDitherMode(LAVDitherMode ditherMode)\n{\n    m_settings.DitherMode = ditherMode;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVDitherMode) CLAVVideo::GetDitherMode()\n{\n    return (LAVDitherMode)m_settings.DitherMode;\n}\n\nSTDMETHODIMP CLAVVideo::SetUseMSWMV9Decoder(BOOL bEnabled)\n{\n    m_settings.bMSWMV9DMO = bEnabled;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetUseMSWMV9Decoder()\n{\n    return m_settings.bMSWMV9DMO;\n}\n\nSTDMETHODIMP CLAVVideo::SetDVDVideoSupport(BOOL bEnabled)\n{\n    m_settings.bDVDVideo = bEnabled;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetDVDVideoSupport()\n{\n    return m_settings.bDVDVideo;\n}\n\nSTDMETHODIMP CLAVVideo::SetHWAccelResolutionFlags(DWORD dwResFlags)\n{\n    m_settings.HWAccelResFlags = dwResFlags;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(DWORD) CLAVVideo::GetHWAccelResolutionFlags()\n{\n    return m_settings.HWAccelResFlags;\n}\n\nSTDMETHODIMP CLAVVideo::SetTrayIcon(BOOL bEnabled)\n{\n    m_settings.TrayIcon = bEnabled;\n    // The tray icon is created if not yet done so, however its not removed on the fly\n    // Removing the icon on the fly can cause deadlocks if the config is changed from the icons thread\n    if (bEnabled && m_pGraph && !m_pTrayIcon)\n    {\n        CreateTrayIcon();\n    }\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVVideo::GetTrayIcon()\n{\n    return m_settings.TrayIcon;\n}\n\nSTDMETHODIMP CLAVVideo::SetDeinterlacingMode(LAVDeintMode deintMode)\n{\n    m_settings.DeintMode = deintMode;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVDeintMode) CLAVVideo::GetDeinterlacingMode()\n{\n    return m_settings.DeintMode;\n}\n\nSTDMETHODIMP CLAVVideo::SetGPUDeviceIndex(DWORD dwDevice)\n{\n    m_dwGPUDeviceIndex = dwDevice;\n    return S_OK;\n}\n\nSTDMETHODIMP_(DWORD) CLAVVideo::GetHWAccelNumDevices(LAVHWAccel hwAccel)\n{\n    HRESULT hr = S_OK;\n    ILAVDecoder *pDecoder = CDecodeManager::CreateHWAccelDecoder(hwAccel);\n    DWORD dwDevices = 0;\n    if (pDecoder)\n    {\n        hr = pDecoder->InitInterfaces(this, this);\n        if (SUCCEEDED(hr))\n        {\n            dwDevices = pDecoder->GetHWAccelNumDevices();\n        }\n        SAFE_DELETE(pDecoder);\n    }\n    return dwDevices;\n}\n\nSTDMETHODIMP CLAVVideo::GetHWAccelDeviceInfo(LAVHWAccel hwAccel, DWORD dwIndex, BSTR *pstrDeviceName,\n                                             DWORD *pdwDeviceIdentifier)\n{\n    HRESULT hr = E_NOINTERFACE;\n    ILAVDecoder *pDecoder = CDecodeManager::CreateHWAccelDecoder(hwAccel);\n    if (pDecoder)\n    {\n        hr = pDecoder->InitInterfaces(this, this);\n        if (SUCCEEDED(hr))\n        {\n            hr = pDecoder->GetHWAccelDeviceInfo(dwIndex, pstrDeviceName, pdwDeviceIdentifier);\n        }\n        SAFE_DELETE(pDecoder);\n    }\n    return hr;\n}\n\nSTDMETHODIMP_(DWORD) CLAVVideo::GetHWAccelDeviceIndex(LAVHWAccel hwAccel, DWORD *pdwDeviceIdentifier)\n{\n    HRESULT hr = S_OK;\n    if (hwAccel == HWAccel_DXVA2CopyBack)\n    {\n        DWORD dwDeviceIndex = m_settings.HWAccelDeviceDXVA2;\n        DWORD dwDeviceId = m_settings.HWAccelDeviceDXVA2Desc;\n\n        // verify the values and re-match them to adapters appropriately\n        if (dwDeviceIndex != LAVHWACCEL_DEVICE_DEFAULT && dwDeviceId != 0)\n        {\n            hr = VerifyD3D9Device(dwDeviceIndex, dwDeviceId);\n            if (FAILED(hr))\n            {\n                dwDeviceIndex = LAVHWACCEL_DEVICE_DEFAULT;\n                dwDeviceId = 0;\n            }\n        }\n\n        if (pdwDeviceIdentifier)\n            *pdwDeviceIdentifier = dwDeviceId;\n\n        return dwDeviceIndex;\n    }\n    else if (hwAccel == HWAccel_D3D11)\n    {\n        DWORD dwDeviceIndex = m_settings.HWAccelDeviceD3D11;\n        DWORD dwDeviceId = m_settings.HWAccelDeviceD3D11Desc;\n\n        // verify the values and re-match them to adapters appropriately\n        if (dwDeviceIndex != LAVHWACCEL_DEVICE_DEFAULT && dwDeviceId != 0)\n        {\n            hr = VerifyD3D11Device(dwDeviceIndex, dwDeviceId);\n            if (FAILED(hr))\n            {\n                dwDeviceIndex = LAVHWACCEL_DEVICE_DEFAULT;\n                dwDeviceId = 0;\n            }\n        }\n\n        if (pdwDeviceIdentifier)\n            *pdwDeviceIdentifier = dwDeviceId;\n\n        return dwDeviceIndex;\n    }\n\n    if (pdwDeviceIdentifier)\n        *pdwDeviceIdentifier = 0;\n    return LAVHWACCEL_DEVICE_DEFAULT;\n}\n\nSTDMETHODIMP CLAVVideo::SetHWAccelDeviceIndex(LAVHWAccel hwAccel, DWORD dwIndex, DWORD dwDeviceIdentifier)\n{\n    HRESULT hr = S_OK;\n\n    if (dwIndex != LAVHWACCEL_DEVICE_DEFAULT && dwDeviceIdentifier == 0 && !m_bRuntimeConfig)\n        hr = GetHWAccelDeviceInfo(hwAccel, dwIndex, nullptr, &dwDeviceIdentifier);\n\n    if (SUCCEEDED(hr))\n    {\n        if (hwAccel == HWAccel_DXVA2CopyBack)\n        {\n            m_settings.HWAccelDeviceDXVA2 = dwIndex;\n            m_settings.HWAccelDeviceDXVA2Desc = dwDeviceIdentifier;\n        }\n        else if (hwAccel == HWAccel_D3D11)\n        {\n            m_settings.HWAccelDeviceD3D11 = dwIndex;\n            m_settings.HWAccelDeviceD3D11Desc = dwDeviceIdentifier;\n        }\n        return SaveSettings();\n    }\n    else\n    {\n        return E_INVALIDARG;\n    }\n}\n\nSTDMETHODIMP CLAVVideo::SetH264MVCDecodingOverride(BOOL bEnabled)\n{\n    m_settings.bH264MVCOverride = bEnabled;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideo::SetEnableCCOutputPin(BOOL bEnabled)\n{\n    m_settings.bCCOutputPinEnabled = bEnabled;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideo::GetHWAccelActiveDevice(BSTR *pstrDeviceName)\n{\n    return m_Decoder.GetHWAccelActiveDevice(pstrDeviceName);\n}\n"
  },
  {
    "path": "decoder/LAVVideo/LAVVideo.def",
    "content": "; LAVVideo.def ; declares the exports\n\nLIBRARY         \"LAVVideo.ax\"\n\nEXPORTS\n                DllGetClassObject PRIVATE\n                DllCanUnloadNow PRIVATE\n                DllRegisterServer PRIVATE\n                DllUnregisterServer PRIVATE\n                OpenConfiguration PRIVATE\n"
  },
  {
    "path": "decoder/LAVVideo/LAVVideo.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"decoders/ILAVDecoder.h\"\n#include \"DecodeManager.h\"\n#include \"ILAVPinInfo.h\"\n\n#include \"LAVPixFmtConverter.h\"\n#include \"LAVVideoSettings.h\"\n#include \"FloatingAverage.h\"\n\n#include \"ISpecifyPropertyPages2.h\"\n#include \"SynchronizedQueue.h\"\n\n#include \"subtitles/LAVSubtitleConsumer.h\"\n#include \"subtitles/LAVVideoSubtitleInputPin.h\"\n\n#include \"CCOutputPin.h\"\n\n#include \"BaseTrayIcon.h\"\n#include \"IMediaSideData.h\"\n\nextern \"C\"\n{\n#include \"libavutil/mastering_display_metadata.h\"\n};\n\n#define LAVC_VIDEO_REGISTRY_KEY L\"Software\\\\LAV\\\\Video\"\n#define LAVC_VIDEO_REGISTRY_KEY_FORMATS L\"Software\\\\LAV\\\\Video\\\\Formats\"\n#define LAVC_VIDEO_REGISTRY_KEY_OUTPUT L\"Software\\\\LAV\\\\Video\\\\Output\"\n#define LAVC_VIDEO_REGISTRY_KEY_HWACCEL L\"Software\\\\LAV\\\\Video\\\\HWAccel\"\n\n#define LAVC_VIDEO_LOG_FILE L\"LAVVideo.txt\"\n\n#define DEBUG_FRAME_TIMINGS 0\n#define DEBUG_PIXELCONV_TIMINGS 0\n\ntypedef struct\n{\n    REFERENCE_TIME rtStart;\n    REFERENCE_TIME rtStop;\n} TimingCache;\n\nclass __declspec(uuid(\"EE30215D-164F-4A92-A4EB-9D4C13390F9F\")) CLAVVideo\n    : public CTransformFilter\n    , public ISpecifyPropertyPages2\n    , public ILAVVideoSettings\n    , public ILAVVideoStatus\n    , public ILAVVideoCallback\n    , public IPropertyBag\n{\n  public:\n    CLAVVideo(LPUNKNOWN pUnk, HRESULT *phr);\n    ~CLAVVideo();\n\n    // IUnknown\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // ISpecifyPropertyPages2\n    STDMETHODIMP GetPages(CAUUID *pPages);\n    STDMETHODIMP CreatePage(const GUID &guid, IPropertyPage **ppPage);\n\n    // ILAVVideoSettings\n    STDMETHODIMP SetRuntimeConfig(BOOL bRuntimeConfig);\n    STDMETHODIMP SetFormatConfiguration(LAVVideoCodec vCodec, BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetFormatConfiguration(LAVVideoCodec vCodec);\n    STDMETHODIMP SetNumThreads(DWORD dwNum);\n    STDMETHODIMP_(DWORD) GetNumThreads();\n    STDMETHODIMP SetStreamAR(DWORD bStreamAR);\n    STDMETHODIMP_(DWORD) GetStreamAR();\n    STDMETHODIMP SetPixelFormat(LAVOutPixFmts pixFmt, BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetPixelFormat(LAVOutPixFmts pixFmt);\n    STDMETHODIMP SetRGBOutputRange(DWORD dwRange);\n    STDMETHODIMP_(DWORD) GetRGBOutputRange();\n\n    STDMETHODIMP SetDeintFieldOrder(LAVDeintFieldOrder fieldOrder);\n    STDMETHODIMP_(LAVDeintFieldOrder) GetDeintFieldOrder();\n    STDMETHODIMP SetDeintForce(BOOL bForce);\n    STDMETHODIMP_(BOOL) GetDeintForce();\n    STDMETHODIMP SetDeintAggressive(BOOL bAggressive);\n    STDMETHODIMP_(BOOL) GetDeintAggressive();\n\n    STDMETHODIMP_(DWORD) CheckHWAccelSupport(LAVHWAccel hwAccel);\n    STDMETHODIMP SetHWAccel(LAVHWAccel hwAccel);\n    STDMETHODIMP_(LAVHWAccel) GetHWAccel();\n    STDMETHODIMP SetHWAccelCodec(LAVVideoHWCodec hwAccelCodec, BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetHWAccelCodec(LAVVideoHWCodec hwAccelCodec);\n    STDMETHODIMP SetHWAccelDeintMode(LAVHWDeintModes deintMode);\n    STDMETHODIMP_(LAVHWDeintModes) GetHWAccelDeintMode();\n    STDMETHODIMP SetHWAccelDeintOutput(LAVDeintOutput deintOutput);\n    STDMETHODIMP_(LAVDeintOutput) GetHWAccelDeintOutput();\n    STDMETHODIMP SetHWAccelDeintHQ(BOOL bHQ);\n    STDMETHODIMP_(BOOL) GetHWAccelDeintHQ();\n    STDMETHODIMP SetSWDeintMode(LAVSWDeintModes deintMode);\n    STDMETHODIMP_(LAVSWDeintModes) GetSWDeintMode();\n    STDMETHODIMP SetSWDeintOutput(LAVDeintOutput deintOutput);\n    STDMETHODIMP_(LAVDeintOutput) GetSWDeintOutput();\n\n    STDMETHODIMP SetDeintTreatAsProgressive(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetDeintTreatAsProgressive();\n\n    STDMETHODIMP SetDitherMode(LAVDitherMode ditherMode);\n    STDMETHODIMP_(LAVDitherMode) GetDitherMode();\n\n    STDMETHODIMP SetUseMSWMV9Decoder(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetUseMSWMV9Decoder();\n\n    STDMETHODIMP SetDVDVideoSupport(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetDVDVideoSupport();\n\n    STDMETHODIMP SetHWAccelResolutionFlags(DWORD dwResFlags);\n    STDMETHODIMP_(DWORD) GetHWAccelResolutionFlags();\n\n    STDMETHODIMP SetTrayIcon(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetTrayIcon();\n\n    STDMETHODIMP SetDeinterlacingMode(LAVDeintMode deintMode);\n    STDMETHODIMP_(LAVDeintMode) GetDeinterlacingMode();\n\n    STDMETHODIMP SetGPUDeviceIndex(DWORD dwDevice);\n\n    STDMETHODIMP_(DWORD) GetHWAccelNumDevices(LAVHWAccel hwAccel);\n    STDMETHODIMP GetHWAccelDeviceInfo(LAVHWAccel hwAccel, DWORD dwIndex, BSTR *pstrDeviceName,\n                                      DWORD *pdwDeviceIdentifier);\n\n    STDMETHODIMP_(DWORD) GetHWAccelDeviceIndex(LAVHWAccel hwAccel, DWORD *pdwDeviceIdentifier);\n    STDMETHODIMP SetHWAccelDeviceIndex(LAVHWAccel hwAccel, DWORD dwIndex, DWORD dwDeviceIdentifier);\n\n    STDMETHODIMP SetH264MVCDecodingOverride(BOOL bEnabled);\n\n    STDMETHODIMP SetEnableCCOutputPin(BOOL bEnabled);\n\n    // ILAVVideoStatus\n    STDMETHODIMP_(const WCHAR *) GetActiveDecoderName() { return m_Decoder.GetDecoderName(); }\n    STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName);\n\n    // CTransformFilter\n    STDMETHODIMP Stop();\n\n    HRESULT CheckInputType(const CMediaType *mtIn);\n    HRESULT CheckTransform(const CMediaType *mtIn, const CMediaType *mtOut);\n    HRESULT DecideBufferSize(IMemAllocator *pAllocator, ALLOCATOR_PROPERTIES *pprop);\n    HRESULT GetMediaType(int iPosition, CMediaType *pMediaType);\n\n    HRESULT SetMediaType(PIN_DIRECTION dir, const CMediaType *pmt);\n    HRESULT EndOfStream();\n    HRESULT BeginFlush();\n    HRESULT EndFlush();\n    HRESULT NewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n    HRESULT Receive(IMediaSample *pIn);\n\n    HRESULT CheckConnect(PIN_DIRECTION dir, IPin *pPin);\n    HRESULT BreakConnect(PIN_DIRECTION dir);\n    HRESULT CompleteConnect(PIN_DIRECTION dir, IPin *pReceivePin);\n\n    HRESULT StartStreaming();\n\n    int GetPinCount();\n    CBasePin *GetPin(int n);\n\n    STDMETHODIMP JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName);\n\n    // IPinSegmentEx\n    HRESULT EndOfSegment();\n\n    // ILAVVideoCallback\n    STDMETHODIMP AllocateFrame(LAVFrame **ppFrame);\n    STDMETHODIMP ReleaseFrame(LAVFrame **ppFrame);\n    STDMETHODIMP Deliver(LAVFrame *pFrame);\n    STDMETHODIMP_(LPWSTR) GetFileExtension();\n    STDMETHODIMP_(BOOL) FilterInGraph(PIN_DIRECTION dir, const GUID &clsid)\n    {\n        if (dir == PINDIR_INPUT)\n            return FilterInGraphSafe(m_pInput, clsid);\n        else\n            return FilterInGraphSafe(m_pOutput, clsid);\n    }\n    STDMETHODIMP_(DWORD) GetDecodeFlags() { return m_dwDecodeFlags; }\n    STDMETHODIMP_(CMediaType &) GetInputMediaType() { return m_pInput->CurrentMediaType(); }\n    STDMETHODIMP GetLAVPinInfo(LAVPinInfo &info)\n    {\n        if (m_LAVPinInfoValid)\n        {\n            info = m_LAVPinInfo;\n            return S_OK;\n        }\n        return E_FAIL;\n    }\n    STDMETHODIMP_(CBasePin *) GetOutputPin() { return m_pOutput; }\n    STDMETHODIMP_(CMediaType &) GetOutputMediaType() { return m_pOutput->CurrentMediaType(); }\n    STDMETHODIMP DVDStripPacket(BYTE *&p, long &len)\n    {\n        static_cast<CDeCSSTransformInputPin *>(m_pInput)->StripPacket(p, len);\n        return S_OK;\n    }\n    STDMETHODIMP_(LAVFrame *) GetFlushFrame();\n    STDMETHODIMP ReleaseAllDXVAResources()\n    {\n        ReleaseLastSequenceFrame();\n        return S_OK;\n    }\n    STDMETHODIMP_(DWORD) GetGPUDeviceIndex() { return m_dwGPUDeviceIndex; }\n    STDMETHODIMP_(BOOL) HasDynamicInputAllocator();\n    STDMETHODIMP SetX264Build(int nBuild)\n    {\n        m_X264Build = nBuild;\n        return S_OK;\n    }\n    STDMETHODIMP_(int) GetX264Build() { return m_X264Build; }\n\n    // IPropertyBag\n    STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog);\n    STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT *pVar) { return E_NOTIMPL; }\n\n  public:\n    // Pin Configuration\n    const static AMOVIESETUP_MEDIATYPE sudPinTypesIn[];\n    const static UINT sudPinTypesInCount;\n    const static AMOVIESETUP_MEDIATYPE sudPinTypesOut[];\n    const static UINT sudPinTypesOutCount;\n\n  private:\n    HRESULT LoadDefaults();\n    HRESULT ReadSettings(HKEY rootKey);\n    HRESULT LoadSettings();\n    HRESULT SaveSettings();\n\n    HRESULT CreateTrayIcon();\n\n    HRESULT CreateDecoder(const CMediaType *pmt);\n\n    HRESULT GetDeliveryBuffer(IMediaSample **ppOut, int width, int height, AVRational ar,\n                              DXVA2_ExtendedFormat dxvaExtFormat, REFERENCE_TIME avgFrameDuration);\n    HRESULT ReconnectOutput(int width, int height, AVRational ar, DXVA2_ExtendedFormat dxvaExtFlags,\n                            REFERENCE_TIME avgFrameDuration, BOOL bDXVA = FALSE);\n\n    HRESULT SetFrameFlags(IMediaSample *pMS, LAVFrame *pFrame);\n\n    HRESULT NegotiatePixelFormat(CMediaType &mt, int width, int height);\n    BOOL IsInterlacedOutput();\n\n    HRESULT CheckDirectMode();\n    HRESULT DeDirectFrame(LAVFrame *pFrame, bool bDisableDirectMode = true);\n\n    HRESULT Filter(LAVFrame *pFrame);\n    HRESULT DeliverToRenderer(LAVFrame *pFrame);\n\n    HRESULT PerformFlush();\n    HRESULT ReleaseLastSequenceFrame();\n\n    HRESULT GetD3DBuffer(LAVFrame *pFrame);\n    HRESULT RedrawStillImage();\n    HRESULT SetInDVDMenu(bool menu)\n    {\n        m_bInDVDMenu = menu;\n        return S_OK;\n    }\n\n  private:\n    friend class CVideoInputPin;\n    friend class CVideoOutputPin;\n    friend class CDecodeManager;\n    friend class CLAVSubtitleProvider;\n    friend class CLAVSubtitleConsumer;\n\n    CDecodeManager m_Decoder;\n\n    REFERENCE_TIME m_rtPrevStart = 0;\n    REFERENCE_TIME m_rtPrevStop = 0;\n    REFERENCE_TIME m_rtAvgTimePerFrame = AV_NOPTS_VALUE;\n\n    BOOL m_bForceInputAR = FALSE;\n    BOOL m_bSendMediaType = FALSE;\n    BOOL m_bFlushing = FALSE;\n    BOOL m_bForceFormatNegotiation = FALSE;\n\n    HRESULT m_hrDeliver = S_OK;\n\n    CLAVPixFmtConverter m_PixFmtConverter;\n    std::wstring m_strExtension;\n\n    BOOL m_bDXVAExtFormatSupport = TRUE;\n    DWORD m_bMadVR = -1;\n    DWORD m_bJRVR = -1;\n    DWORD m_bOverlayMixer = -1;\n    DWORD m_dwDecodeFlags = 0;\n\n    BOOL m_bInDVDMenu = FALSE;\n\n    AVFilterGraph *m_pFilterGraph = nullptr;\n    AVFilterContext *m_pFilterBufferSrc = nullptr;\n    AVFilterContext *m_pFilterBufferSink = nullptr;\n\n    LAVPixelFormat m_filterPixFmt = LAVPixFmt_None;\n    int m_filterWidth = 0;\n    int m_filterHeight = 0;\n    LAVFrame m_FilterPrevFrame;\n\n    BOOL m_LAVPinInfoValid = FALSE;\n    LAVPinInfo m_LAVPinInfo;\n    int m_X264Build = -1;\n\n    struct\n    {\n        AVMasteringDisplayMetadata Mastering;\n        AVContentLightMetadata ContentLight;\n    } m_SideData;\n\n    CLAVVideoSubtitleInputPin *m_pSubtitleInput = nullptr;\n    CLAVSubtitleConsumer *m_SubtitleConsumer = nullptr;\n\n    CCCOutputPin *m_pCCOutputPin = nullptr;\n\n    LAVFrame *m_pLastSequenceFrame = nullptr;\n\n    AM_SimpleRateChange m_DVDRate = AM_SimpleRateChange{AV_NOPTS_VALUE, 10000};\n\n    BOOL m_bRuntimeConfig = FALSE;\n    struct VideoSettings\n    {\n        BOOL TrayIcon;\n        DWORD StreamAR;\n        DWORD NumThreads;\n        BOOL bFormats[Codec_VideoNB];\n        BOOL bMSWMV9DMO;\n        BOOL bPixFmts[LAVOutPixFmt_NB];\n        DWORD RGBRange;\n        DWORD HWAccel;\n        BOOL bHWFormats[HWCodec_NB];\n        DWORD HWAccelResFlags;\n        BOOL HWAccelCUVIDXVA;\n        DWORD HWDeintMode;\n        DWORD HWDeintOutput;\n        DWORD DeintFieldOrder;\n        LAVDeintMode DeintMode;\n        DWORD SWDeintMode;\n        DWORD SWDeintOutput;\n        DWORD DitherMode;\n        BOOL bDVDVideo;\n        DWORD HWAccelDeviceDXVA2;\n        DWORD HWAccelDeviceDXVA2Desc;\n        DWORD HWAccelDeviceD3D11;\n        DWORD HWAccelDeviceD3D11Desc;\n        BOOL bH264MVCOverride;\n        BOOL bCCOutputPinEnabled;\n    } m_settings;\n\n    DWORD m_dwGPUDeviceIndex = DWORD_MAX;\n\n    CBaseTrayIcon *m_pTrayIcon = nullptr;\n\n#ifdef DEBUG\n    FloatingAverage<double> m_pixFmtTimingAvg;\n#endif\n};\n"
  },
  {
    "path": "decoder/LAVVideo/LAVVideo.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n  <dependency>\n    <dependentAssembly>\n      <assemblyIdentity type=\"win32\" name=\"LAVFilters.Dependencies\" version=\"1.0.0.0\" />\n    </dependentAssembly>\n  </dependency>\n</assembly>\n"
  },
  {
    "path": "decoder/LAVVideo/LAVVideo.rc",
    "content": "// Microsoft Visual C++ generated resource script.\n//\n#include \"resource.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"winres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (United States) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Icon\n//\n\n// Icon with lowest ID value placed first to ensure application icon\n// remains consistent on all systems.\nIDI_ICON1               ICON                    \"..\\\\..\\\\resources\\\\red.ico\"\n\n\n#ifdef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// TEXTINCLUDE\n//\n\n1 TEXTINCLUDE \nBEGIN\n    \"resource.h\\0\"\nEND\n\n2 TEXTINCLUDE \nBEGIN\n    \"#include \"\"winres.h\"\"\\r\\n\"\n    \"\\0\"\nEND\n\n3 TEXTINCLUDE \nBEGIN\n    \"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\\r\\n\"\n    \"LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\\r\\n\"\n    \"#pragma code_page(1252)\\r\\n\"\n    \"#include \"\"LAVVideo.rc2\"\" // non-Microsoft Visual C++ edited resources\\r\\n\"\n    \"#endif\\r\\n\"\n    \"\\0\"\nEND\n\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Dialog\n//\n\nIDD_PROPPAGE_VIDEO_SETTINGS DIALOGEX 0, 0, 415, 295\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0\nBEGIN\n    GROUPBOX        \"Settings\",IDC_VIDEO_SETTINGS,7,7,140,132\n    LTEXT           \"Threads for Multi-Threading\",IDC_LBL_MULTITHREAD,14,20,91,8\n    COMBOBOX        IDC_THREADS,15,30,75,200,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n    CONTROL         \"Use Stream Aspect Ratio\",IDC_STREAMAR,\"Button\",BS_AUTO3STATE | WS_TABSTOP,15,50,100,10\n    LTEXT           \"Settings for Interlaced Video Streams\",IDC_DEINT_SETTINGS,12,64,131,8\n    LTEXT           \"Field Order\",IDC_LBL_DEINT_FIELDORDER,14,76,79,8\n    COMBOBOX        IDC_DEINT_FIELDORDER,15,87,110,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n    LTEXT           \"Deinterlacing Mode\",IDC_LBL_DEINT_MODE,14,106,79,8\n    COMBOBOX        IDC_DEINT_MODE,15,116,110,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n    GROUPBOX        \"Output Formats\",IDC_OUTPUT_FORMATS,7,143,226,131\n    LTEXT           \"8-bit\",IDC_OUT_8BIT,38,154,32,8\n    LTEXT           \"10-bit\",IDC_OUT_10BIT,115,154,32,8\n    LTEXT           \"16-bit\",IDC_OUT_16BIT,191,154,24,8\n    LTEXT           \"4:2:0\",IDC_OUT_420,14,164,20,8\n    CONTROL         \"NV12\",IDC_OUT_NV12,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,38,164,32,10\n    CONTROL         \"YV12\",IDC_OUT_YV12,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,78,164,32,10\n    CONTROL         \"P010\",IDC_OUT_P010,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,115,164,32,10\n    CONTROL         \"P016\",IDC_OUT_P016,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,191,164,32,10\n    LTEXT           \"4:2:2\",IDC_OUT_422,14,178,20,8\n    CONTROL         \"YUY2\",IDC_OUT_YUY2,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,38,178,32,10\n    CONTROL         \"UYVY\",IDC_OUT_UYVY,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,78,178,32,10\n    CONTROL         \"P210\",IDC_OUT_P210,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,115,178,32,10\n    CONTROL         \"v210\",IDC_OUT_V210,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,151,178,32,10\n    CONTROL         \"P216\",IDC_OUT_P216,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,191,178,32,10\n    LTEXT           \"4:4:4\",IDC_OUT_444,14,193,20,8\n    CONTROL         \"YV24\",IDC_OUT_YV24,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,38,193,32,10\n    CONTROL         \"AYUV\",IDC_OUT_AYUV,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,78,193,32,10\n    CONTROL         \"Y410\",IDC_OUT_Y410,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,115,193,32,10\n    CONTROL         \"v410\",IDC_OUT_V410,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,151,193,32,10\n    CONTROL         \"Y416\",IDC_OUT_Y416,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,191,193,32,10\n    LTEXT           \"RGB\",IDC_OUT_RGB,14,207,20,8\n    CONTROL         \"RGB32\",IDC_OUT_RGB32,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,38,207,40,10\n    CONTROL         \"RGB24\",IDC_OUT_RGB24,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,78,207,40,10\n    CONTROL         \"RGB48\",IDC_OUT_RGB48,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,191,207,40,10\n    LTEXT           \"RGB Output levels (for YUV -> RGB conversion)\",IDC_LBL_RGBOUT,14,223,188,8\n    CONTROL         \"TV (16-235)\",IDC_RGBOUT_TV,\"Button\",BS_AUTORADIOBUTTON,19,234,50,10\n    CONTROL         \"PC (0-255)\",IDC_RGBOUT_PC,\"Button\",BS_AUTORADIOBUTTON,71,234,46,10\n    CONTROL         \"Untouched (as input)\",IDC_RGBOUT_AUTO,\"Button\",BS_AUTORADIOBUTTON,120,234,80,10\n    LTEXT           \"Dithering Mode\",IDC_STATIC,14,247,188,8\n    CONTROL         \"Ordered Dithering\",IDC_DITHER_ORDERED,\"Button\",BS_AUTORADIOBUTTON | WS_GROUP,19,258,92,10\n    CONTROL         \"Random Dithering\",IDC_DITHER_RANDOM,\"Button\",BS_AUTORADIOBUTTON,120,258,90,10\n    GROUPBOX        \"Hardware Acceleration\",IDC_HWACCEL_SETTINGS,151,7,253,132\n    LTEXT           \"Hardware Decoder to use:\",IDC_LBL_HWACCEL,157,17,107,8\n    COMBOBOX        IDC_HWACCEL,160,28,85,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n    LTEXT           \"N/A\",IDC_HWACCEL_AVAIL,247,31,20,8\n    LTEXT           \"Active Decoder: \",IDC_STATIC,157,46,56,8\n    LTEXT           \"<inactive>\",IDC_ACTIVE_DECODER,213,46,55,8\n    LTEXT           \"Resolutions\",IDC_LBL_HWRESOLUTIONS,271,17,47,8\n    CONTROL         \"SD\",IDC_HWRES_SD,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,274,27,32,10\n    CONTROL         \"HD\",IDC_HWRES_HD,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,315,27,32,10\n    CONTROL         \"UHD (4K)\",IDC_HWRES_UHD,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,356,27,43,10\n    LTEXT           \"Codecs for HW Decoding\",IDC_LBL_HWCODECS,271,42,80,8\n    CONTROL         \"H.264\",IDC_HWACCEL_H264,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,274,53,39,10\n    CONTROL         \"HEVC\",IDC_HWACCEL_HEVC,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,315,53,39,10\n    CONTROL         \"VC-1\",IDC_HWACCEL_VC1,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,356,53,39,10\n    CONTROL         \"MPEG-2\",IDC_HWACCEL_MPEG2,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,274,67,39,10\n    CONTROL         \"MPEG-4\",IDC_HWACCEL_MPEG4,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,356,67,39,10\n    CONTROL         \"VP9\",IDC_HWACCEL_VP9,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,274,81,39,10\n    CONTROL         \"AV1\",IDC_HWACCEL_AV1,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,315,81,39,10\n    CONTROL         \"H.264 MVC\",IDC_HWACCEL_H264MVC,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,356,81,46,10\n    LTEXT           \"Active Hardware Accelerator:\",IDC_LBL_HWACCEL_DEVICE,157,62,110,8\n    LTEXT           \"<none>\",IDC_HWACCEL_DEVICE,160,72,105,8\n    LTEXT           \"Hardware Device to use:\",IDC_LBL_HWACCEL_DEVICE_SELECT,157,87,105,8\n    COMBOBOX        IDC_HWACCEL_DEVICE_SELECT,160,98,235,30,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n    LTEXT           \"The selected Hardware Decoder does not support using a specific device.\",IDC_LBL_HWACCEL_DEVICE_HINT,160,115,235,18\n    CONTROL         \"Enable CUVID DXVA processing\", IDC_HWACCEL_CUVID_DXVA, \"Button\", BS_AUTOCHECKBOX | WS_TABSTOP, 160,125,139,10\n    GROUPBOX        \"Hardware/GPU Deinterlacing (CUVID/QS only)\",IDC_GROUP_HWDEINT,237,143,167,52\n    CONTROL         \"Enable Adaptive HW Deinterlacing\",IDC_HWDEINT_ENABLE,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,244,155,139,10\n    LTEXT           \"Output Mode\",IDC_LBL_HWDEINT_MODE,243,167,62,8\n    CONTROL         \"25p/30p (Film)\",IDC_HWDEINT_OUT_FILM,\"Button\",BS_AUTORADIOBUTTON | WS_GROUP,247,180,58,10\n    CONTROL         \"50p/60p (Video)\",IDC_HWDEINT_OUT_VIDEO,\"Button\",BS_AUTORADIOBUTTON,315,180,62,10\n    GROUPBOX        \"Software Deinterlacing\",IDC_SWDEINT,237,197,167,67\n    LTEXT           \"Algorithm\",IDC_LBL_SWDEINT_ALGO,243,208,100,11\n    COMBOBOX        IDC_SWDEINT_MODE,246,220,140,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n    LTEXT           \"Output Mode\",IDC_LBL_SWDEINT_MODE,243,237,100,11\n    CONTROL         \"25p/30p (Film)\",IDC_SWDEINT_OUT_FILM,\"Button\",BS_AUTORADIOBUTTON | WS_GROUP,247,248,58,10\n    CONTROL         \"50p/60p (Video)\",IDC_SWDEINT_OUT_VIDEO,\"Button\",BS_AUTORADIOBUTTON,315,248,62,10\n    CONTROL         \"Enable System Tray Icon\",IDC_TRAYICON,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,7,280,192,10\n    LTEXT           \"LAV Video Decoder x.xx\",IDC_LAVVIDEO_FOOTER,248,282,156,8,0,WS_EX_RIGHT\nEND\n\nIDD_PROPPAGE_FORMATS DIALOGEX 0, 0, 405, 250\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0\nBEGIN\n    LTEXT           \"Select which formats LAV Video should decode:\",IDC_LBL_FORMATS,8,10,378,10\n    CONTROL         \"\",IDC_CODECS,\"SysListView32\",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,20,387,193\n    CONTROL         \"Use Microsoft WMV9 MFT decoder for WMV3 and VC-1\",IDC_CODECS_MSWMVDMO,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,7,230,352,10\n    CONTROL         \"Enable DVD Video support\",IDC_DVD_VIDEO,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,7,217,313,10\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// DESIGNINFO\n//\n\n#ifdef APSTUDIO_INVOKED\nGUIDELINES DESIGNINFO\nBEGIN\n    IDD_PROPPAGE_VIDEO_SETTINGS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 404\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 290\n    END\n\n    IDD_PROPPAGE_FORMATS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 394\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 243\n    END\nEND\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// AFX_DIALOG_LAYOUT\n//\n\nIDD_PROPPAGE_VIDEO_SETTINGS AFX_DIALOG_LAYOUT\nBEGIN\n    0\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// String Table\n//\n\nSTRINGTABLE\nBEGIN\n    IDS_SETTINGS            \"Video Settings\"\n    IDS_FORMATS             \"Formats\"\n    IDS_FIELDORDER_AUTO     \"Auto\"\n    IDS_FIELDORDER_TOP      \"Top-Field First\"\n    IDS_FIELDORDER_BOTTOM   \"Bottom-Field First\"\n    IDS_DEINTMODE_AUTO      \"Auto\"\n    IDS_DEINTMODE_AGGRESSIVE \"Aggressive\"\n    IDS_DEINTMODE_FORCE     \"Force\"\n    IDS_DEINTMODE_DISABLE   \"Disabled (Progressive)\"\nEND\n\n#endif    // English (United States) resources\n/////////////////////////////////////////////////////////////////////////////\n\n\n\n#ifndef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 3 resource.\n//\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n#include \"LAVVideo.rc2\" // non-Microsoft Visual C++ edited resources\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n#endif    // not APSTUDIO_INVOKED\n\n"
  },
  {
    "path": "decoder/LAVVideo/LAVVideo.rc2",
    "content": "//\n// LAVVideo.rc2 - resources Microsoft Visual C++ does not edit directly\n//\n\n#ifdef APSTUDIO_INVOKED\n#error This file is not editable by Microsoft Visual C++\n#endif //APSTUDIO_INVOKED\n\n/////////////////////////////////////////////////////////////////////////////\n// Add manually edited resources here...\n\n/////////////////////////////////////////////////////////////////////////////\n\n#include \"resource.h\"\n#include \"..\\..\\common\\includes\\version.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"winres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (United States) resources\n\n/////////////////////////////////////////////////////////////////////////////\n// Neutral (Sys. Default) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Version\n//\n\nVS_VERSION_INFO VERSIONINFO\n FILEVERSION LAV_VERSION_TAG\n PRODUCTVERSION LAV_VERSION_TAG\n FILEFLAGSMASK 0x3fL\n#ifdef _DEBUG\n FILEFLAGS 0x1L\n#else\n FILEFLAGS 0x0L\n#endif\n FILEOS 0x40004L\n FILETYPE 0x2L\n FILESUBTYPE 0x0L\nBEGIN\n    BLOCK \"StringFileInfo\"\n    BEGIN\n        BLOCK \"040904b0\"\n        BEGIN\n            VALUE \"CompanyName\", \"1f0.de - Hendrik Leppkes\"\n            VALUE \"FileDescription\", \"LAV Video Decoder - DirectShow Video Decoder\"\n            VALUE \"FileVersion\", LAV_VERSION_STR\n            VALUE \"InternalName\", \"LAVVideo.ax\"\n            VALUE \"LegalCopyright\", \"Copyright (C) 2010-2021 Hendrik Leppkes\"\n            VALUE \"OriginalFilename\", \"LAVVideo.ax\"\n            VALUE \"ProductName\", \"LAV Video Decoder\"\n            VALUE \"ProductVersion\", LAV_VERSION_STR\n        END\n    END\n    BLOCK \"VarFileInfo\"\n    BEGIN\n        VALUE \"Translation\", 0x409, 1200\n    END\nEND\n\n#endif\n"
  },
  {
    "path": "decoder/LAVVideo/LAVVideo.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{D29ADED3-086B-46A8-9455-97EFF6B14775}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n    <RootNamespace>LAVVideo</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <Import Project=\"$(SolutionDir)common\\platform.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Import Project=\"$(SolutionDir)common\\common.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <TargetExt>.ax</TargetExt>\n    <OutDir>$(SolutionDir)bin_$(PlatformName)d\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n    <TargetExt>.ax</TargetExt>\n    <OutDir>$(SolutionDir)bin_$(PlatformName)\\$(ProjectName)\\</OutDir>\n    <CustomBuildAfterTargets>Build</CustomBuildAfterTargets>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LAVVIDEO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)qsdecoder;$(ProjectDir)decoders\\mvc\\include</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <AdditionalDependencies>advapi32.lib;ole32.lib;gdi32.lib;winmm.lib;user32.lib;oleaut32.lib;shell32.lib;Shlwapi.lib;Comctl32.lib;d3d9.lib;mfuuid.lib;dmoguids.lib;avutil-lav.lib;avcodec-lav.lib;swscale-lav.lib;avfilter-lav.lib;libmfx.lib</AdditionalDependencies>\n      <ModuleDefinitionFile>LAVVideo.def</ModuleDefinitionFile>\n      <AdditionalLibraryDirectories Condition=\"'$(Platform)'=='Win32'\">$(ProjectDir)decoders\\mvc\\lib32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <AdditionalLibraryDirectories Condition=\"'$(Platform)'=='x64'\">$(ProjectDir)decoders\\mvc\\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <IgnoreSpecificDefaultLibraries>libcmt.lib</IgnoreSpecificDefaultLibraries>\n    </Link>\n    <Manifest>\n      <AdditionalManifestFiles>$(ProjectDir)\\$(ProjectName).manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>\n    </Manifest>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Release'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LAVVIDEO_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>%(AdditionalIncludeDirectories);$(SolutionDir)qsdecoder;$(ProjectDir)decoders\\mvc\\include</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <AdditionalDependencies>advapi32.lib;ole32.lib;gdi32.lib;winmm.lib;user32.lib;oleaut32.lib;shell32.lib;Shlwapi.lib;Comctl32.lib;d3d9.lib;mfuuid.lib;dmoguids.lib;avutil-lav.lib;avcodec-lav.lib;swscale-lav.lib;avfilter-lav.lib;libmfx.lib</AdditionalDependencies>\n      <ModuleDefinitionFile>LAVVideo.def</ModuleDefinitionFile>\n      <AdditionalLibraryDirectories Condition=\"'$(Platform)'=='Win32'\">$(ProjectDir)decoders\\mvc\\lib32;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n      <AdditionalLibraryDirectories Condition=\"'$(Platform)'=='x64'\">$(ProjectDir)decoders\\mvc\\lib64;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>\n    </Link>\n    <CustomBuildStep>\n      <Command>copy \"$(TargetDir)\\$(TargetName)$(TargetExt)\" \"$(OutDir)..\"</Command>\n      <Outputs>$(OutDir)..\\$(TargetFileName)</Outputs>\n      <Inputs>$(TargetDir)\\$(TargetName)$(TargetExt)</Inputs>\n    </CustomBuildStep>\n    <Manifest>\n      <AdditionalManifestFiles>$(ProjectDir)\\$(ProjectName).manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>\n    </Manifest>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"CCOutputPin.cpp\" />\n    <ClCompile Include=\"decoders\\avcodec.cpp\" />\n    <ClCompile Include=\"decoders\\cuvid.cpp\" />\n    <ClCompile Include=\"decoders\\d3d11va.cpp\" />\n    <ClCompile Include=\"decoders\\d3d11\\D3D11SurfaceAllocator.cpp\" />\n    <ClCompile Include=\"decoders\\dxva2dec.cpp\" />\n    <ClCompile Include=\"decoders\\dxva2\\DXVA2SurfaceAllocator.cpp\" />\n    <ClCompile Include=\"decoders\\dxva2\\dxva_common.cpp\" />\n    <ClCompile Include=\"decoders\\msdk_mvc.cpp\" />\n    <ClCompile Include=\"decoders\\pixfmt.cpp\" />\n    <ClCompile Include=\"decoders\\quicksync.cpp\" />\n    <ClCompile Include=\"decoders\\wmv9mft.cpp\" />\n    <ClCompile Include=\"DecodeManager.cpp\" />\n    <ClCompile Include=\"dllmain.cpp\" />\n    <ClCompile Include=\"Filtering.cpp\" />\n    <ClCompile Include=\"LAVPixFmtConverter.cpp\" />\n    <ClCompile Include=\"LAVVideo.cpp\" />\n    <ClCompile Include=\"Media.cpp\" />\n    <ClCompile Include=\"parsers\\AnnexBConverter.cpp\" />\n    <ClCompile Include=\"parsers\\H264SequenceParser.cpp\" />\n    <ClCompile Include=\"parsers\\HEVCSequenceParser.cpp\" />\n    <ClCompile Include=\"parsers\\MPEG2HeaderParser.cpp\" />\n    <ClCompile Include=\"parsers\\VC1HeaderParser.cpp\" />\n    <ClCompile Include=\"pixconv\\convert_direct.cpp\" />\n    <ClCompile Include=\"pixconv\\convert_generic.cpp\" />\n    <ClCompile Include=\"pixconv\\interleave.cpp\" />\n    <ClCompile Include=\"pixconv\\pixconv.cpp\" />\n    <ClCompile Include=\"pixconv\\rgb2rgb_unscaled.cpp\" />\n    <ClCompile Include=\"pixconv\\yuv2rgb.cpp\" />\n    <ClCompile Include=\"pixconv\\yuv2yuv_unscaled.cpp\" />\n    <ClCompile Include=\"pixconv\\yuv420_yuy2.cpp\" />\n    <ClCompile Include=\"pixconv\\yuv444_ayuv.cpp\" />\n    <ClCompile Include=\"stdafx.cpp\">\n      <PrecompiledHeader>Create</PrecompiledHeader>\n    </ClCompile>\n    <ClCompile Include=\"subtitles\\blend\\blend_generic.cpp\" />\n    <ClCompile Include=\"subtitles\\LAVSubtitleConsumer.cpp\" />\n    <ClCompile Include=\"subtitles\\LAVSubtitleFrame.cpp\" />\n    <ClCompile Include=\"subtitles\\LAVSubtitleProvider.cpp\" />\n    <ClCompile Include=\"subtitles\\LAVVideoSubtitleInputPin.cpp\" />\n    <ClCompile Include=\"subtitles\\SubRenderOptionsImpl.cpp\" />\n    <ClCompile Include=\"VideoInputPin.cpp\" />\n    <ClCompile Include=\"VideoOutputPin.cpp\" />\n    <ClCompile Include=\"VideoSettingsProp.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\..\\common\\includes\\SubRenderIntf.h\" />\n    <ClInclude Include=\"..\\..\\include\\ID3DVideoMemoryConfiguration.h\" />\n    <ClInclude Include=\"..\\..\\include\\IMediaSample3D.h\" />\n    <ClInclude Include=\"..\\..\\include\\IMediaSideData.h\" />\n    <ClInclude Include=\"..\\..\\include\\LAVVideoSettings.h\" />\n    <ClInclude Include=\"CCOutputPin.h\" />\n    <ClInclude Include=\"decoders\\avcodec.h\" />\n    <ClInclude Include=\"decoders\\cuvid.h\" />\n    <ClInclude Include=\"decoders\\d3d11va.h\" />\n    <ClInclude Include=\"decoders\\d3d11\\D3D11SurfaceAllocator.h\" />\n    <ClInclude Include=\"decoders\\DecBase.h\" />\n    <ClInclude Include=\"decoders\\dxva2dec.h\" />\n    <ClInclude Include=\"decoders\\dxva2\\DXVA2SurfaceAllocator.h\" />\n    <ClInclude Include=\"decoders\\dxva2\\dxva_common.h\" />\n    <ClInclude Include=\"decoders\\ILAVDecoder.h\" />\n    <ClInclude Include=\"decoders\\msdk_mvc.h\" />\n    <ClInclude Include=\"decoders\\quicksync.h\" />\n    <ClInclude Include=\"decoders\\wmv9mft.h\" />\n    <ClInclude Include=\"DecodeManager.h\" />\n    <ClInclude Include=\"LAVPixFmtConverter.h\" />\n    <ClInclude Include=\"LAVVideo.h\" />\n    <ClInclude Include=\"Media.h\" />\n    <ClInclude Include=\"parsers\\AnnexBConverter.h\" />\n    <ClInclude Include=\"parsers\\H264SequenceParser.h\" />\n    <ClInclude Include=\"parsers\\HEVCSequenceParser.h\" />\n    <ClInclude Include=\"parsers\\MPEG2HeaderParser.h\" />\n    <ClInclude Include=\"parsers\\VC1HeaderParser.h\" />\n    <ClInclude Include=\"pixconv\\pixconv_internal.h\" />\n    <ClInclude Include=\"pixconv\\pixconv_sse2_templates.h\" />\n    <ClInclude Include=\"resource.h\" />\n    <ClInclude Include=\"stdafx.h\" />\n    <ClInclude Include=\"subtitles\\LAVSubtitleConsumer.h\" />\n    <ClInclude Include=\"subtitles\\LAVSubtitleFrame.h\" />\n    <ClInclude Include=\"subtitles\\LAVSubtitleProvider.h\" />\n    <ClInclude Include=\"subtitles\\LAVVideoSubtitleInputPin.h\" />\n    <ClInclude Include=\"subtitles\\SubRenderOptionsImpl.h\" />\n    <ClInclude Include=\"VideoInputPin.h\" />\n    <ClInclude Include=\"VideoOutputPin.h\" />\n    <ClInclude Include=\"VideoSettingsProp.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"LAVVideo.rc\" />\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"..\\..\\resources\\red.ico\" />\n    <None Include=\"LAVVideo.rc2\" />\n    <Manifest Include=\"LAVVideo.manifest\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\..\\common\\baseclasses\\baseclasses.vcxproj\">\n      <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>\n    </ProjectReference>\n    <ProjectReference Include=\"..\\..\\common\\DSUtilLite\\DSUtilLite.vcxproj\">\n      <Project>{0a058024-41f4-4509-97d2-803a1806ce86}</Project>\n    </ProjectReference>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "decoder/LAVVideo/LAVVideo.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n    <Filter Include=\"Source Files\\parsers\">\n      <UniqueIdentifier>{30aabf4d-c49c-4299-82a6-eda004fc7b22}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\parsers\">\n      <UniqueIdentifier>{a78d7ea2-1b41-4d14-bcbc-7367aee8f548}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\pixconv\">\n      <UniqueIdentifier>{785bf298-6050-43e0-81d0-54dd1389be17}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\pixconv\">\n      <UniqueIdentifier>{4b09de39-e456-4b36-98fa-aba7f24526bd}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\decoders\">\n      <UniqueIdentifier>{e2f0f0cd-c474-4ba2-aa2e-dd8e689907e7}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\decoders\">\n      <UniqueIdentifier>{c5cd3602-30d6-48ff-8100-230758b36fb4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\decoders\\dxva2\">\n      <UniqueIdentifier>{2417dd22-d693-40ad-a3f7-a6e3b4e22b9d}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\decoders\\dxva2\">\n      <UniqueIdentifier>{d3bbf10b-cfb1-45d9-8cb4-6323349e6b22}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\subtitles\">\n      <UniqueIdentifier>{fb30ec43-26d9-4ea0-950b-4a055654a2e6}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\subtitles\">\n      <UniqueIdentifier>{edcd1461-a03c-4080-84ef-a1e5d2e4f2b4}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\subtitles\\blend\">\n      <UniqueIdentifier>{313fee8a-af36-434b-9ac0-808a14d70bb0}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Source Files\\decoders\\d3d11\">\n      <UniqueIdentifier>{aa256837-6553-43d3-bdf9-bce2e149fb21}</UniqueIdentifier>\n    </Filter>\n    <Filter Include=\"Header Files\\decoders\\d3d11\">\n      <UniqueIdentifier>{5bef8a26-ba3d-4eb9-aa69-0bfaf1c6a433}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"stdafx.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dllmain.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVVideo.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Media.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVPixFmtConverter.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"VideoSettingsProp.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"parsers\\VC1HeaderParser.cpp\">\n      <Filter>Source Files\\parsers</Filter>\n    </ClCompile>\n    <ClCompile Include=\"parsers\\MPEG2HeaderParser.cpp\">\n      <Filter>Source Files\\parsers</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\pixconv.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\convert_generic.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\yuv444_ayuv.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\interleave.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\yuv2yuv_unscaled.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\yuv2rgb.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\avcodec.cpp\">\n      <Filter>Source Files\\decoders</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\pixfmt.cpp\">\n      <Filter>Source Files\\decoders</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\cuvid.cpp\">\n      <Filter>Source Files\\decoders</Filter>\n    </ClCompile>\n    <ClCompile Include=\"parsers\\H264SequenceParser.cpp\">\n      <Filter>Source Files\\parsers</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\yuv420_yuy2.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Filtering.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\quicksync.cpp\">\n      <Filter>Source Files\\decoders</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\dxva2dec.cpp\">\n      <Filter>Source Files\\decoders</Filter>\n    </ClCompile>\n    <ClCompile Include=\"VideoOutputPin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\dxva2\\DXVA2SurfaceAllocator.cpp\">\n      <Filter>Source Files\\decoders\\dxva2</Filter>\n    </ClCompile>\n    <ClCompile Include=\"subtitles\\LAVSubtitleProvider.cpp\">\n      <Filter>Source Files\\subtitles</Filter>\n    </ClCompile>\n    <ClCompile Include=\"subtitles\\SubRenderOptionsImpl.cpp\">\n      <Filter>Source Files\\subtitles</Filter>\n    </ClCompile>\n    <ClCompile Include=\"subtitles\\LAVSubtitleFrame.cpp\">\n      <Filter>Source Files\\subtitles</Filter>\n    </ClCompile>\n    <ClCompile Include=\"subtitles\\LAVSubtitleConsumer.cpp\">\n      <Filter>Source Files\\subtitles</Filter>\n    </ClCompile>\n    <ClCompile Include=\"subtitles\\blend\\blend_generic.cpp\">\n      <Filter>Source Files\\subtitles\\blend</Filter>\n    </ClCompile>\n    <ClCompile Include=\"subtitles\\LAVVideoSubtitleInputPin.cpp\">\n      <Filter>Source Files\\subtitles</Filter>\n    </ClCompile>\n    <ClCompile Include=\"VideoInputPin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\rgb2rgb_unscaled.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\wmv9mft.cpp\">\n      <Filter>Source Files\\decoders</Filter>\n    </ClCompile>\n    <ClCompile Include=\"parsers\\AnnexBConverter.cpp\">\n      <Filter>Source Files\\parsers</Filter>\n    </ClCompile>\n    <ClCompile Include=\"parsers\\HEVCSequenceParser.cpp\">\n      <Filter>Source Files\\parsers</Filter>\n    </ClCompile>\n    <ClCompile Include=\"pixconv\\convert_direct.cpp\">\n      <Filter>Source Files\\pixconv</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\msdk_mvc.cpp\">\n      <Filter>Source Files\\decoders</Filter>\n    </ClCompile>\n    <ClCompile Include=\"DecodeManager.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\dxva2\\dxva_common.cpp\">\n      <Filter>Source Files\\decoders\\dxva2</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\d3d11va.cpp\">\n      <Filter>Source Files\\decoders</Filter>\n    </ClCompile>\n    <ClCompile Include=\"decoders\\d3d11\\D3D11SurfaceAllocator.cpp\">\n      <Filter>Source Files\\decoders\\d3d11</Filter>\n    </ClCompile>\n    <ClCompile Include=\"CCOutputPin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"stdafx.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVVideo.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"Media.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVPixFmtConverter.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"resource.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"VideoSettingsProp.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"parsers\\VC1HeaderParser.h\">\n      <Filter>Header Files\\parsers</Filter>\n    </ClInclude>\n    <ClInclude Include=\"parsers\\MPEG2HeaderParser.h\">\n      <Filter>Header Files\\parsers</Filter>\n    </ClInclude>\n    <ClInclude Include=\"pixconv\\pixconv_internal.h\">\n      <Filter>Header Files\\pixconv</Filter>\n    </ClInclude>\n    <ClInclude Include=\"pixconv\\pixconv_sse2_templates.h\">\n      <Filter>Header Files\\pixconv</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\ILAVDecoder.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\DecBase.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\avcodec.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\cuvid.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"parsers\\H264SequenceParser.h\">\n      <Filter>Header Files\\parsers</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\quicksync.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\dxva2dec.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"VideoOutputPin.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\dxva2\\DXVA2SurfaceAllocator.h\">\n      <Filter>Header Files\\decoders\\dxva2</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\common\\includes\\SubRenderIntf.h\">\n      <Filter>Header Files\\subtitles</Filter>\n    </ClInclude>\n    <ClInclude Include=\"subtitles\\LAVSubtitleProvider.h\">\n      <Filter>Header Files\\subtitles</Filter>\n    </ClInclude>\n    <ClInclude Include=\"subtitles\\SubRenderOptionsImpl.h\">\n      <Filter>Header Files\\subtitles</Filter>\n    </ClInclude>\n    <ClInclude Include=\"subtitles\\LAVSubtitleFrame.h\">\n      <Filter>Header Files\\subtitles</Filter>\n    </ClInclude>\n    <ClInclude Include=\"subtitles\\LAVSubtitleConsumer.h\">\n      <Filter>Header Files\\subtitles</Filter>\n    </ClInclude>\n    <ClInclude Include=\"subtitles\\LAVVideoSubtitleInputPin.h\">\n      <Filter>Header Files\\subtitles</Filter>\n    </ClInclude>\n    <ClInclude Include=\"VideoInputPin.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\wmv9mft.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"parsers\\AnnexBConverter.h\">\n      <Filter>Header Files\\parsers</Filter>\n    </ClInclude>\n    <ClInclude Include=\"parsers\\HEVCSequenceParser.h\">\n      <Filter>Header Files\\parsers</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\msdk_mvc.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"DecodeManager.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\dxva2\\dxva_common.h\">\n      <Filter>Header Files\\decoders\\dxva2</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\d3d11va.h\">\n      <Filter>Header Files\\decoders</Filter>\n    </ClInclude>\n    <ClInclude Include=\"decoders\\d3d11\\D3D11SurfaceAllocator.h\">\n      <Filter>Header Files\\decoders\\d3d11</Filter>\n    </ClInclude>\n    <ClInclude Include=\"CCOutputPin.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IMediaSample3D.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IMediaSideData.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\LAVVideoSettings.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\ID3DVideoMemoryConfiguration.h\">\n      <Filter>Header Files\\decoders\\d3d11</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"LAVVideo.rc\">\n      <Filter>Resource Files</Filter>\n    </ResourceCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"LAVVideo.rc2\">\n      <Filter>Resource Files</Filter>\n    </None>\n    <None Include=\"..\\..\\resources\\red.ico\">\n      <Filter>Resource Files</Filter>\n    </None>\n  </ItemGroup>\n  <ItemGroup>\n    <Manifest Include=\"LAVVideo.manifest\">\n      <Filter>Resource Files</Filter>\n    </Manifest>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "decoder/LAVVideo/Media.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVVideo.h\"\n#include \"Media.h\"\n\n#include <MMReg.h>\n#include <Mfidl.h>\n\n#include \"moreuuids.h\"\n\ntypedef struct\n{\n    const CLSID *clsMinorType;\n    const enum AVCodecID nFFCodec;\n} FFMPEG_SUBTYPE_MAP;\n\n// clang-format off\n// Map Media Subtype <> FFMPEG Codec Id\nstatic const FFMPEG_SUBTYPE_MAP lavc_video_codecs[] = {\n  // H264\n  { &MEDIASUBTYPE_H264, AV_CODEC_ID_H264 },\n  { &MEDIASUBTYPE_h264, AV_CODEC_ID_H264 },\n  { &MEDIASUBTYPE_X264, AV_CODEC_ID_H264 },\n  { &MEDIASUBTYPE_x264, AV_CODEC_ID_H264 },\n  { &MEDIASUBTYPE_AVC1, AV_CODEC_ID_H264 },\n  { &MEDIASUBTYPE_avc1, AV_CODEC_ID_H264 },\n  { &MEDIASUBTYPE_CCV1, AV_CODEC_ID_H264 }, // Used by Haali Splitter\n  { &MEDIASUBTYPE_H264_bis, AV_CODEC_ID_H264}, // MainConcept specific\n\n  { &MEDIASUBTYPE_AMVC, AV_CODEC_ID_H264_MVC },\n  { &MEDIASUBTYPE_MVC1, AV_CODEC_ID_H264_MVC },\n\n  // HEVC\n  { &MEDIASUBTYPE_HEVC, AV_CODEC_ID_HEVC },\n  { &MEDIASUBTYPE_HVC1, AV_CODEC_ID_HEVC },\n  { &MEDIASUBTYPE_HM10, AV_CODEC_ID_HEVC },\n  { &MEDIASUBTYPE_H265, AV_CODEC_ID_HEVC },\n\n  // VVC\n  { &MEDIASUBTYPE_VVC1, AV_CODEC_ID_VVC },\n\n  // MPEG1/2\n  { &MEDIASUBTYPE_MPEG1Payload, AV_CODEC_ID_MPEG1VIDEO },\n  { &MEDIASUBTYPE_MPEG1Video,   AV_CODEC_ID_MPEG1VIDEO },\n  { &MEDIASUBTYPE_MPEG2_VIDEO,  AV_CODEC_ID_MPEG2VIDEO },\n\n  // MJPEG\n  { &MEDIASUBTYPE_MJPG,   AV_CODEC_ID_MJPEG  },\n  { &MEDIASUBTYPE_QTJpeg, AV_CODEC_ID_MJPEG  },\n  { &MEDIASUBTYPE_MJPA,   AV_CODEC_ID_MJPEG  },\n  { &MEDIASUBTYPE_MJPB,   AV_CODEC_ID_MJPEGB },\n  { &MEDIASUBTYPE_MJPGB,  AV_CODEC_ID_MJPEGB },\n  { &MEDIASUBTYPE_LJPG,   AV_CODEC_ID_JPEGLS },\n  { &MEDIASUBTYPE_JPGL,   AV_CODEC_ID_JPEGLS },\n  { &MEDIASUBTYPE_MJLS,   AV_CODEC_ID_JPEGLS },\n\n  // VC-1\n  { &MEDIASUBTYPE_WVC1, AV_CODEC_ID_VC1 },\n  { &MEDIASUBTYPE_wvc1, AV_CODEC_ID_VC1 },\n  { &MEDIASUBTYPE_WMVA, AV_CODEC_ID_VC1 },\n  { &MEDIASUBTYPE_wmva, AV_CODEC_ID_VC1 },\n  { &MEDIASUBTYPE_WVP2, AV_CODEC_ID_VC1IMAGE },\n  { &MEDIASUBTYPE_wvp2, AV_CODEC_ID_VC1IMAGE },\n\n  // WMV\n  { &MEDIASUBTYPE_WMV1, AV_CODEC_ID_WMV1 },\n  { &MEDIASUBTYPE_wmv1, AV_CODEC_ID_WMV1 },\n  { &MEDIASUBTYPE_WMV2, AV_CODEC_ID_WMV2 },\n  { &MEDIASUBTYPE_wmv2, AV_CODEC_ID_WMV2 },\n  { &MEDIASUBTYPE_2VMW, AV_CODEC_ID_WMV2 },\n  { &MEDIASUBTYPE_WMV3, AV_CODEC_ID_WMV3 },\n  { &MEDIASUBTYPE_wmv3, AV_CODEC_ID_WMV3 },\n  { &MEDIASUBTYPE_WMVP, AV_CODEC_ID_WMV3IMAGE },\n  { &MEDIASUBTYPE_wmvp, AV_CODEC_ID_WMV3IMAGE },\n\n  // VP7/8/9\n  { &MEDIASUBTYPE_VP70, AV_CODEC_ID_VP7 },\n  { &MEDIASUBTYPE_VP80, AV_CODEC_ID_VP8 },\n  { &MEDIASUBTYPE_VP90, AV_CODEC_ID_VP9 },\n\n  // AV1\n  { &MEDIASUBTYPE_AV01, AV_CODEC_ID_AV1 },\n\n  // MPEG4 ASP\n  { &MEDIASUBTYPE_XVID, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_xvid, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_DIVX, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_divx, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_Divx, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_DX50, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_dx50, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_MP4V, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_mp4v, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_M4S2, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_m4s2, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_MP4S, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_mp4s, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_FMP4, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_3IVX, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_3ivx, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_3IV1, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_3iv1, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_3IV2, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_3iv2, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_BLZ0, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_GEOV, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_SEDG, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_SMP4, AV_CODEC_ID_MPEG4 },\n  { &MEDIASUBTYPE_DXGM, AV_CODEC_ID_MPEG4 },\n\n  // MS-MPEG4\n  { &MEDIASUBTYPE_MPG4, AV_CODEC_ID_MSMPEG4V1 },\n  { &MEDIASUBTYPE_mpg4, AV_CODEC_ID_MSMPEG4V1 },\n  { &MEDIASUBTYPE_MP41, AV_CODEC_ID_MSMPEG4V1 },\n  { &MEDIASUBTYPE_mp41, AV_CODEC_ID_MSMPEG4V1 },\n  { &MEDIASUBTYPE_DIV1, AV_CODEC_ID_MSMPEG4V1 },\n  { &MEDIASUBTYPE_div1, AV_CODEC_ID_MSMPEG4V1 },\n\n  { &MEDIASUBTYPE_MP42, AV_CODEC_ID_MSMPEG4V2 },\n  { &MEDIASUBTYPE_mp42, AV_CODEC_ID_MSMPEG4V2 },\n  { &MEDIASUBTYPE_DIV2, AV_CODEC_ID_MSMPEG4V2 },\n  { &MEDIASUBTYPE_div2, AV_CODEC_ID_MSMPEG4V2 },\n\n  { &MEDIASUBTYPE_MP43, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_mp43, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_DIV3, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_div3, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_MPG3, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_mpg3, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_DIV4, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_div4, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_DIV5, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_div5, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_DIV6, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_div6, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_DVX3, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_dvx3, AV_CODEC_ID_MSMPEG4V3 },\n  { &MEDIASUBTYPE_3IVD, AV_CODEC_ID_MSMPEG4V3 },\n\n  // Flash\n  { &MEDIASUBTYPE_FLV1, AV_CODEC_ID_FLV1 },\n  { &MEDIASUBTYPE_flv1, AV_CODEC_ID_FLV1 },\n  { &MEDIASUBTYPE_VP60, AV_CODEC_ID_VP6  },\n  { &MEDIASUBTYPE_vp60, AV_CODEC_ID_VP6  },\n  { &MEDIASUBTYPE_VP61, AV_CODEC_ID_VP6  },\n  { &MEDIASUBTYPE_vp61, AV_CODEC_ID_VP6  },\n  { &MEDIASUBTYPE_VP62, AV_CODEC_ID_VP6  },\n  { &MEDIASUBTYPE_vp62, AV_CODEC_ID_VP6  },\n  { &MEDIASUBTYPE_VP6A, AV_CODEC_ID_VP6A },\n  { &MEDIASUBTYPE_vp6a, AV_CODEC_ID_VP6A },\n  { &MEDIASUBTYPE_VP6F, AV_CODEC_ID_VP6F },\n  { &MEDIASUBTYPE_vp6f, AV_CODEC_ID_VP6F },\n  { &MEDIASUBTYPE_FLV4, AV_CODEC_ID_VP6F },\n  { &MEDIASUBTYPE_flv4, AV_CODEC_ID_VP6F },\n  { &MEDIASUBTYPE_FSV1, AV_CODEC_ID_FLASHSV },\n\n  // Real\n  { &MEDIASUBTYPE_RV10, AV_CODEC_ID_RV10 },\n  { &MEDIASUBTYPE_RV20, AV_CODEC_ID_RV20 },\n  { &MEDIASUBTYPE_RV30, AV_CODEC_ID_RV30 },\n  { &MEDIASUBTYPE_RV40, AV_CODEC_ID_RV40 },\n\n  // DV Video\n  { &MEDIASUBTYPE_dvsd, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVSD, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_CDVH, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_CDVC, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_CDV5, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_dv25, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DV25, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_dv50, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DV50, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVCP, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DV5P, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DV5N, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVPP, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVC,  AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVH1, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVH2, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVH3, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVH4, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVH5, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVH6, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVHQ, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_DVHP, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_AVdv, AV_CODEC_ID_DVVIDEO },\n  { &MEDIASUBTYPE_AVd1, AV_CODEC_ID_DVVIDEO },\n\n  // JPEG 2000\n  { &MEDIASUBTYPE_mjp2, AV_CODEC_ID_JPEG2000 },\n  { &MEDIASUBTYPE_MJ2C, AV_CODEC_ID_JPEG2000 },\n  { &MEDIASUBTYPE_LJ2C, AV_CODEC_ID_JPEG2000 },\n  { &MEDIASUBTYPE_LJ2K, AV_CODEC_ID_JPEG2000 },\n  { &MEDIASUBTYPE_IPJ2, AV_CODEC_ID_JPEG2000 },\n\n  // Misc Formats\n  { &MEDIASUBTYPE_SVQ1, AV_CODEC_ID_SVQ1 },\n  { &MEDIASUBTYPE_SVQ3, AV_CODEC_ID_SVQ3 },\n  { &MEDIASUBTYPE_H261, AV_CODEC_ID_H261 },\n  { &MEDIASUBTYPE_h261, AV_CODEC_ID_H261 },\n  { &MEDIASUBTYPE_H263, AV_CODEC_ID_H263 },\n  { &MEDIASUBTYPE_h263, AV_CODEC_ID_H263 },\n  { &MEDIASUBTYPE_S263, AV_CODEC_ID_H263 },\n  { &MEDIASUBTYPE_s263, AV_CODEC_ID_H263 },\n  { &MEDIASUBTYPE_I263, AV_CODEC_ID_H263I },\n  { &MEDIASUBTYPE_i263, AV_CODEC_ID_H263I },\n  { &MEDIASUBTYPE_THEORA, AV_CODEC_ID_THEORA },\n  { &MEDIASUBTYPE_theora, AV_CODEC_ID_THEORA },\n  { &MEDIASUBTYPE_TSCC, AV_CODEC_ID_TSCC },\n  { &MEDIASUBTYPE_TSC2, AV_CODEC_ID_TSCC2 },\n  { &MEDIASUBTYPE_IV50, AV_CODEC_ID_INDEO5 },\n  { &MEDIASUBTYPE_IV41, AV_CODEC_ID_INDEO4 },\n  { &MEDIASUBTYPE_IV31, AV_CODEC_ID_INDEO3 },\n  { &MEDIASUBTYPE_IV32, AV_CODEC_ID_INDEO3 },\n  { &MEDIASUBTYPE_RT21, AV_CODEC_ID_INDEO2 },\n  { &MEDIASUBTYPE_FPS1, AV_CODEC_ID_FRAPS },\n  { &MEDIASUBTYPE_HuffYUV,  AV_CODEC_ID_HUFFYUV },\n  { &MEDIASUBTYPE_Lagarith, AV_CODEC_ID_LAGARITH },\n  { &MEDIASUBTYPE_CVID,  AV_CODEC_ID_CINEPAK },\n  { &MEDIASUBTYPE_QTRle, AV_CODEC_ID_QTRLE },\n  { &MEDIASUBTYPE_VP30, AV_CODEC_ID_VP3  },\n  { &MEDIASUBTYPE_VP31, AV_CODEC_ID_VP3  },\n  { &MEDIASUBTYPE_VP40, AV_CODEC_ID_VP4  },\n  { &MEDIASUBTYPE_CSCD, AV_CODEC_ID_CSCD },\n  { &MEDIASUBTYPE_QPEG, AV_CODEC_ID_QPEG },\n  { &MEDIASUBTYPE_QP10, AV_CODEC_ID_QPEG },\n  { &MEDIASUBTYPE_QP11, AV_CODEC_ID_QPEG },\n  { &MEDIASUBTYPE_MSZH, AV_CODEC_ID_MSZH },\n  { &MEDIASUBTYPE_ZLIB, AV_CODEC_ID_ZLIB },\n  { &MEDIASUBTYPE_QTRpza, AV_CODEC_ID_RPZA },\n  { &MEDIASUBTYPE_PCM, AV_CODEC_ID_MSRLE }, // Yeah, PCM. Its the same FourCC as used by MS-RLE\n  { &MEDIASUBTYPE_apch, AV_CODEC_ID_PRORES },\n  { &MEDIASUBTYPE_apcn, AV_CODEC_ID_PRORES },\n  { &MEDIASUBTYPE_apcs, AV_CODEC_ID_PRORES },\n  { &MEDIASUBTYPE_apco, AV_CODEC_ID_PRORES },\n  { &MEDIASUBTYPE_ap4h, AV_CODEC_ID_PRORES },\n  { &MEDIASUBTYPE_ap4x, AV_CODEC_ID_PRORES },\n  { &MEDIASUBTYPE_ULRA, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_ULRG, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_ULY0, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_ULY2, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_ULY4, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UQY2, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UQRG, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UQRA, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_ULH0, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_ULH2, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_ULH4, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UMY2, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UMH2, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UMY4, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UMH4, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UMRG, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_UMRA, AV_CODEC_ID_UTVIDEO },\n  { &MEDIASUBTYPE_AMVV, AV_CODEC_ID_AMV     },\n  { &MEDIASUBTYPE_AMVF, AV_CODEC_ID_AMV     },\n  { &MEDIASUBTYPE_DiracVideo, AV_CODEC_ID_DIRAC },\n  { &MEDIASUBTYPE_DRAC, AV_CODEC_ID_DIRAC },\n  { &MEDIASUBTYPE_AVdn, AV_CODEC_ID_DNXHD },\n  { &MEDIASUBTYPE_AVdh, AV_CODEC_ID_DNXHD },\n  { &MEDIASUBTYPE_CRAM, AV_CODEC_ID_MSVIDEO1 },\n  { &MEDIASUBTYPE_MSVC, AV_CODEC_ID_MSVIDEO1 },\n  { &MEDIASUBTYPE_WHAM, AV_CODEC_ID_MSVIDEO1 },\n  { &MEDIASUBTYPE_8BPS, AV_CODEC_ID_8BPS  },\n  { &MEDIASUBTYPE_LOCO, AV_CODEC_ID_LOCO  },\n  { &MEDIASUBTYPE_ZMBV, AV_CODEC_ID_ZMBV  },\n  { &MEDIASUBTYPE_VCR1, AV_CODEC_ID_VCR1 },\n  { &MEDIASUBTYPE_AASC, AV_CODEC_ID_AASC },\n  { &MEDIASUBTYPE_SNOW, AV_CODEC_ID_SNOW },\n  { &MEDIASUBTYPE_FFV1, AV_CODEC_ID_FFV1 },\n  { &MEDIASUBTYPE_FFVH, AV_CODEC_ID_FFVHUFF },\n  { &MEDIASUBTYPE_VMNC, AV_CODEC_ID_VMNC },\n  { &MEDIASUBTYPE_FLIC, AV_CODEC_ID_FLIC },\n  //{ &MEDIASUBTYPE_G2M2, AV_CODEC_ID_G2M },\n  //{ &MEDIASUBTYPE_G2M3, AV_CODEC_ID_G2M },\n  { &MEDIASUBTYPE_G2M4, AV_CODEC_ID_G2M },\n  { &MEDIASUBTYPE_G2M5, AV_CODEC_ID_G2M },\n  { &MEDIASUBTYPE_icod, AV_CODEC_ID_AIC },\n  { &MEDIASUBTYPE_DUCK, AV_CODEC_ID_TRUEMOTION1 },\n  { &MEDIASUBTYPE_TM20, AV_CODEC_ID_TRUEMOTION2 },\n  { &MEDIASUBTYPE_CFHD, AV_CODEC_ID_CFHD },\n  { &MEDIASUBTYPE_MAGY, AV_CODEC_ID_MAGICYUV },\n  { &MEDIASUBTYPE_M8RG, AV_CODEC_ID_MAGICYUV },\n  { &MEDIASUBTYPE_M8RA, AV_CODEC_ID_MAGICYUV },\n  { &MEDIASUBTYPE_M8G0, AV_CODEC_ID_MAGICYUV },\n  { &MEDIASUBTYPE_M8Y0, AV_CODEC_ID_MAGICYUV },\n  { &MEDIASUBTYPE_M8Y2, AV_CODEC_ID_MAGICYUV },\n  { &MEDIASUBTYPE_M8Y4, AV_CODEC_ID_MAGICYUV },\n  { &MEDIASUBTYPE_M8YA, AV_CODEC_ID_MAGICYUV },\n  { &MEDIASUBTYPE_FICV, AV_CODEC_ID_FIC },\n  { &MEDIASUBTYPE_QTSmc, AV_CODEC_ID_SMC },\n  { &MEDIASUBTYPE_smc,  AV_CODEC_ID_SMC },\n  { &MEDIASUBTYPE_VIXL, AV_CODEC_ID_VIXL },\n  { &MEDIASUBTYPE_ULTI, AV_CODEC_ID_ULTI },\n  { &MEDIASUBTYPE_WNV1, AV_CODEC_ID_WNV1 },\n  { &MEDIASUBTYPE_CYUV, AV_CODEC_ID_CYUV },\n  { &MEDIASUBTYPE_AVS1, AV_CODEC_ID_ASV1 },\n  { &MEDIASUBTYPE_AVS2, AV_CODEC_ID_ASV2 },\n  { &MEDIASUBTYPE_AVRn, AV_CODEC_ID_AVRN },\n  { &MEDIASUBTYPE_SP5X, AV_CODEC_ID_SP5X },\n  { &MEDIASUBTYPE_SP54, AV_CODEC_ID_SP5X },\n  { &MEDIASUBTYPE_Hap1, AV_CODEC_ID_HAP },\n  { &MEDIASUBTYPE_Hap5, AV_CODEC_ID_HAP },\n  { &MEDIASUBTYPE_HapY, AV_CODEC_ID_HAP },\n  { &MEDIASUBTYPE_DXD3, AV_CODEC_ID_DXV },\n  { &MEDIASUBTYPE_DXDI, AV_CODEC_ID_DXV },\n  { &MEDIASUBTYPE_ARBC, AV_CODEC_ID_ARBC },\n  { &MEDIASUBTYPE_KGV1, AV_CODEC_ID_KGV1 },\n  { &MEDIASUBTYPE_APV1, AV_CODEC_ID_APV },\n\n  // Game Formats\n  { &MEDIASUBTYPE_BIKI, AV_CODEC_ID_BINKVIDEO  },\n  { &MEDIASUBTYPE_BIKB, AV_CODEC_ID_BINKVIDEO  },\n  { &MEDIASUBTYPE_BIKf, AV_CODEC_ID_BINKVIDEO  },\n  { &MEDIASUBTYPE_SMK2, AV_CODEC_ID_SMACKVIDEO },\n  { &MEDIASUBTYPE_SMK4, AV_CODEC_ID_SMACKVIDEO },\n  { &MEDIASUBTYPE_THPV, AV_CODEC_ID_THP },\n  { &MEDIASUBTYPE_ROQV, AV_CODEC_ID_ROQ },\n\n  // Image Formats\n  { &MEDIASUBTYPE_PNG,  AV_CODEC_ID_PNG   },\n  { &MEDIASUBTYPE_TIFF, AV_CODEC_ID_TIFF  },\n  { &MEDIASUBTYPE_BMP,  AV_CODEC_ID_BMP   },\n  { &MEDIASUBTYPE_GIF,  AV_CODEC_ID_GIF   },\n  { &MEDIASUBTYPE_TGA,  AV_CODEC_ID_TARGA },\n  { &MEDIASUBTYPE_WEBP, AV_CODEC_ID_WEBP },\n\n  // Special raw formats\n  { &MEDIASUBTYPE_v210, AV_CODEC_ID_V210 },\n  { &MEDIASUBTYPE_v410, AV_CODEC_ID_V410 },\n  { &MEDIASUBTYPE_LAV_RAWVIDEO, AV_CODEC_ID_RAWVIDEO },\n};\n\n// Define Input Media Types\nconst AMOVIESETUP_MEDIATYPE CLAVVideo::sudPinTypesIn[] = {\n  // H264\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_H264 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_h264 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_X264 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_x264 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AVC1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_avc1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CCV1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_H264_bis },\n\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AMVC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MVC1 },\n\n  // HEVC\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_HEVC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_HVC1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_HM10 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_H265 },\n\n  // VVC\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VVC1 },\n\n  // MPEG1/2\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Payload },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG1Video   },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MPEG2_VIDEO  },\n\n  { &MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_MPEG2_VIDEO },\n  { &MEDIATYPE_MPEG2_PACK,         &MEDIASUBTYPE_MPEG2_VIDEO },\n  { &MEDIATYPE_MPEG2_PES,          &MEDIASUBTYPE_MPEG2_VIDEO },\n\n  // MJPEG\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPG   },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_QTJpeg },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPA   },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPB   },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MJPGB  },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_LJPG   },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_JPGL   },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MJLS   },\n\n  // VC-1\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WVC1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_wvc1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WMVA },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_wmva },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WVP2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_wvp2 },\n\n  // WMV\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_2VMW },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WMV3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_wmv3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WMVP },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_wmvp },\n\n  // VP7/8/9\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP70 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP80 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP90 },\n\n  // AV1\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AV01 },\n\n  // MPEG4 ASP\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_XVID },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_xvid },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DIVX },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_divx },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_Divx },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DX50 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_dx50 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4V },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4v },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_M4S2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_m4s2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MP4S },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_mp4s },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FMP4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_3IVX },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_3ivx },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_3IV2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_3iv2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_BLZ0 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_GEOV },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SEDG },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SMP4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DXGM },\n\n  // MS-MPEG4\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MP41 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_mp41 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_div1 },\n\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MP42 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_mp42 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_div2 },\n\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MP43 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_mp43 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_div3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MPG3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_mpg3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_div4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV5 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_div5 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DIV6 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_div6 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVX3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_dvx3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_3IVD },\n\n  // Flash\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_flv1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP60 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_vp60 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP61 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_vp61 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP62 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_vp62 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6A },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6a },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP6F },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_vp6f },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FLV4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_flv4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FSV1 },\n\n  // Real\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_RV10 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_RV20 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_RV30 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_RV40 },\n\n  // DV Video\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_dvsd },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVSD },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CDVH },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CDVC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CDV5 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_dv25 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DV25 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_dv50 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DV50 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVCP },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DV5P },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DV5N },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVPP },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVC  },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVH1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVH2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVH3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVH4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVH5 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVH6 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVHQ },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DVHP },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AVdv },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AVd1 },\n\n  // JPEG 2000\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_mjp2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MJ2C },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_LJ2C },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_LJ2K },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_IPJ2 },\n\n  // Misc Formats\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SVQ3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_H261 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_h261 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_H263 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_h263 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_S263 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_s263 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_I263 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_i263 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_THEORA },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_theora },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_TSCC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_TSC2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_IV50 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_IV41 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_IV31 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_IV32 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_RT21 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FPS1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_HuffYUV },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_Lagarith },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CVID },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_QTRle },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP30 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP31 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VP40 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CSCD },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_QPEG },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_QP10 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_QP11 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MSZH },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ZLIB },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_QTRpza },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_PCM  }, // Yeah, PCM. Its the same FourCC as used by MS-RLE\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_apch },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_apcn },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_apcs },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_apco },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ap4h },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ap4x },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULRA },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULRG },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULY0 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULY2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULY4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UQY2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UQRG },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UQRA },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULH0 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULH2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULH4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UMY2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UMH2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UMY4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UMH4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UMRG },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UMRA },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AMVV },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AMVF },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DiracVideo },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DRAC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AVdn },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AVdh },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CRAM },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MSVC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WHAM },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_8BPS },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_LOCO },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ZMBV },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VCR1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AASC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SNOW },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FFV1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FFVH },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VMNC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FLIC },\n  //{ &MEDIATYPE_Video, &MEDIASUBTYPE_G2M2 },\n  //{ &MEDIATYPE_Video, &MEDIASUBTYPE_G2M3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_G2M4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_G2M5 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_icod },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DUCK },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_TM20 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CFHD },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_MAGY },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_M8RG },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_M8RA },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_M8G0 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_M8Y0 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_M8Y2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_M8Y4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_M8YA },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_FICV },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_QTSmc },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_smc, },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_VIXL },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ULTI },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WNV1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_CYUV },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AVS1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AVS2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_AVRn },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SP5X },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SP54 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_Hap1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_Hap5 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_HapY },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DXD3 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_DXDI },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ARBC },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_KGV1 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_APV1 },\n\n  // Game Formats\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_BIKI },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_BIKB },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_BIKf },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SMK2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_SMK4 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_THPV },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_ROQV },\n\n  // Image Formats\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_PNG  },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_TIFF },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_BMP  },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_GIF  },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_TGA  },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_WEBP },\n\n  // Special raw formats\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_v210 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_v410 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_LAV_RAWVIDEO },\n};\nconst UINT CLAVVideo::sudPinTypesInCount = countof(CLAVVideo::sudPinTypesIn);\n\n// Define Output Media Types\nconst AMOVIESETUP_MEDIATYPE CLAVVideo::sudPinTypesOut[] = {\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_YV12 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_NV12 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_YUY2 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_UYVY },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_RGB32 },\n  { &MEDIATYPE_Video, &MEDIASUBTYPE_RGB24 },\n};\nconst UINT CLAVVideo::sudPinTypesOutCount = countof(CLAVVideo::sudPinTypesOut);\n\n// Crawl the lavc_video_codecs array for the proper codec\nAVCodecID FindCodecId(const CMediaType *mt)\n{\n    for (int i = 0; i < countof(lavc_video_codecs); ++i)\n    {\n        if (mt->subtype == *lavc_video_codecs[i].clsMinorType)\n        {\n            return lavc_video_codecs[i].nFFCodec;\n        }\n    }\n    return AV_CODEC_ID_NONE;\n}\n\n// Strings will be filled in eventually.\n// AV_CODEC_ID_NONE means there is some special handling going on.\n// Order is Important, has to be the same as the CC Enum\n// Also, the order is used for storage in the Registry\nstatic codec_config_t m_codec_config[] = {\n  { 1, { AV_CODEC_ID_H264 }},                                                // Codec_H264\n  { 2, { AV_CODEC_ID_VC1, AV_CODEC_ID_VC1IMAGE }},                           // Codec_VC1\n  { 1, { AV_CODEC_ID_MPEG1VIDEO }, \"mpeg1\"},                                 // Codec_MPEG1\n  { 1, { AV_CODEC_ID_MPEG2VIDEO }, \"mpeg2\"},                                 // Codec_MPEG2\n  { 1, { AV_CODEC_ID_MPEG4 }},                                               // Codec_MPEG4\n  { 3, { AV_CODEC_ID_MSMPEG4V1, AV_CODEC_ID_MSMPEG4V2, AV_CODEC_ID_MSMPEG4V3 }, \"msmpeg4\", \"MS-MPEG-4 (DIVX3)\" },   // Codec_MSMPEG4\n  { 1, { AV_CODEC_ID_VP8 }},                                                 // Codec_VP8\n  { 2, { AV_CODEC_ID_WMV3, AV_CODEC_ID_WMV3IMAGE }},                         // Codec_WMV3\n  { 2, { AV_CODEC_ID_WMV1, AV_CODEC_ID_WMV2 }, \"wmv12\", \"Windows Media Video 7/8\" },  // Codec_WMV12\n  { 3, { AV_CODEC_ID_MJPEG, AV_CODEC_ID_MJPEGB, AV_CODEC_ID_AMV }},                // Codec_MJPEG\n  { 2, { AV_CODEC_ID_THEORA, AV_CODEC_ID_VP3 }},                                // Codec_Theora\n  { 2, { AV_CODEC_ID_FLV1, AV_CODEC_ID_FLASHSV }, \"flash\", \"Flash Video (FLV1, FSV1)\"}, // Codec_FLV1\n  { 3, { AV_CODEC_ID_VP6, AV_CODEC_ID_VP6A, AV_CODEC_ID_VP6F }},                   // Codec_VP6\n  { 2, { AV_CODEC_ID_SVQ1, AV_CODEC_ID_SVQ3 }, \"svq\", \"SVQ 1 / SVQ 3\"},         // Codec_SVQ\n  { 1, { AV_CODEC_ID_H261 }},                                                // Codec_H261\n  { 2, { AV_CODEC_ID_H263, AV_CODEC_ID_H263I }},                             // Codec_H263\n  { 3, { AV_CODEC_ID_INDEO3, AV_CODEC_ID_INDEO4, AV_CODEC_ID_INDEO5 }, \"indeo\", \"Intel Indeo 3/4/5\"}, // Codec_Indeo\n  { 2, { AV_CODEC_ID_TSCC, AV_CODEC_ID_TSCC2 }},                             // Codec_TSCC\n  { 1, { AV_CODEC_ID_FRAPS }},                                               // Codec_Fraps\n  { 2, { AV_CODEC_ID_HUFFYUV, AV_CODEC_ID_FFVHUFF }},                           // Codec_HuffYUV\n  { 1, { AV_CODEC_ID_QTRLE }},                                               // Codec_QTRle\n  { 1, { AV_CODEC_ID_DVVIDEO }},                                             // Codec_DV\n  { 1, { AV_CODEC_ID_BINKVIDEO }, \"bink\"},                                   // Codec_Bink\n  { 1, { AV_CODEC_ID_SMACKVIDEO }},                                          // Codec_Smacker\n  { 2, { AV_CODEC_ID_RV10, AV_CODEC_ID_RV20 }, \"rv12\", \"RealVideo 1/2\" },       // Codev_RV12\n  { 2, { AV_CODEC_ID_RV30, AV_CODEC_ID_RV40 }, \"rv34\", \"RealVideo 3/4\" },       // Codec_RV34\n  { 1, { AV_CODEC_ID_LAGARITH }},                                            // Codec_Lagarith\n  { 1, { AV_CODEC_ID_CINEPAK }},                                             // Codec_Cinepak\n  { 1, { AV_CODEC_ID_CSCD }},                                                // Codec_Camstudio\n  { 1, { AV_CODEC_ID_QPEG }},                                                // Codec_QPEG\n  { 2, { AV_CODEC_ID_ZLIB, AV_CODEC_ID_MSZH }, \"zlib\", \"ZLIB/MSZH lossless\" },  // Codec_ZLIB\n  { 1, { AV_CODEC_ID_RPZA }},                                                // Codec_QTRpza\n  { 1, { AV_CODEC_ID_PNG }},                                                 // Codec_PNG\n  { 2, { AV_CODEC_ID_MSRLE, AV_CODEC_ID_AASC }},                                // Codec_MSRLE\n  { 1, { AV_CODEC_ID_PRORES }},                                              // Codec_ProRes\n  { 1, { AV_CODEC_ID_UTVIDEO }},                                             // Codec_UtVideo\n  { 1, { AV_CODEC_ID_DIRAC }},                                               // Codec_Dirac\n  { 1, { AV_CODEC_ID_DNXHD }},                                               // Codec_DNxHD\n  { 1, { AV_CODEC_ID_MSVIDEO1 }},                                            // Codec_MSVideo1\n  { 1, { AV_CODEC_ID_8BPS }},                                                // Codec_8BPS\n  { 1, { AV_CODEC_ID_LOCO }},                                                // Codec_LOCO\n  { 1, { AV_CODEC_ID_ZMBV }},                                                // Codec_ZMBV\n  { 1, { AV_CODEC_ID_VCR1 }},                                                // Codec_VCR1\n  { 1, { AV_CODEC_ID_SNOW }},                                                // Codec_Snow\n  { 1, { AV_CODEC_ID_FFV1 }},                                                // Codec_FFV1\n  { 2, { AV_CODEC_ID_V210, AV_CODEC_ID_V410 }, \"v210/v410\", \"v210/v410 uncompressed\"}, // Codec_v210\n  { 1, { AV_CODEC_ID_JPEG2000 }},                                            // Codec_JPEG2000\n  { 1, { AV_CODEC_ID_VMNC }},                                                // Codec_VMNC\n  { 1, { AV_CODEC_ID_FLIC }},                                                // Codec_FLIC\n  { 1, { AV_CODEC_ID_G2M }},                                                 // Codec_G2M\n  { 1, { AV_CODEC_ID_AIC }, \"icod\", \"Apple Intermediate Codec (ICOD)\"},      // Codec_ICOD\n  { 1, { AV_CODEC_ID_THP }},                                                 // Codec_THP\n  { 1, { AV_CODEC_ID_HEVC }},                                                // Codec_HEVC\n  { 1, { AV_CODEC_ID_VP9 }},                                                 // Codec_VP9\n  { 2, { AV_CODEC_ID_TRUEMOTION1, AV_CODEC_ID_TRUEMOTION2 }, \"truemotion\", \"Duck TrueMotion 1/2\"}, // Codec_TrueMotion\n  { 1, { AV_CODEC_ID_VP7 }},                                                 // Codec_VP7\n  { 1, { AV_CODEC_ID_H264_MVC }, \"h264mvc\", \"H.264 MVC 3D\" },                // Codec_H264MVC\n  { 1, { AV_CODEC_ID_CFHD }},                                                // Codec_CineformHD\n  { 1, { AV_CODEC_ID_MAGICYUV }},                                            // Codec_MagicYUV\n  { 1, { AV_CODEC_ID_AV1 }},                                                 // Codec_AV1\n  { 1, { AV_CODEC_ID_VVC }},                                                 // Codec_VVC\n  { 1, { AV_CODEC_ID_VP4 }},                                                 // Codec_VP4\n  { 1, { AV_CODEC_ID_FIC }},                                                 // Codec_FIC\n  { 1, { AV_CODEC_ID_APV }},                                                 // Codec_APV\n};\n// clang-format off\n\nconst codec_config_t *get_codec_config(LAVVideoCodec codec)\n{\n  codec_config_t *config = &m_codec_config[codec];\n\n  const AVCodecDescriptor *desc = avcodec_descriptor_get(config->codecs[0]);\n  if (desc) {\n    if (!config->name) {\n      config->name = desc->name;\n    }\n\n    if (!config->description) {\n      config->description = desc->long_name;\n    }\n  }\n\n  return &m_codec_config[codec];\n}\n\nint flip_plane(BYTE *buffer, int stride, int height)\n{\n  BYTE *line_buffer = (BYTE *)av_malloc(stride);\n  BYTE *cur_front   = buffer;\n  BYTE *cur_back    = buffer + (stride * (height - 1));\n  height /= 2;\n  for (int i = 0; i < height; i++) {\n    memcpy(line_buffer, cur_front, stride);\n    memcpy(cur_front, cur_back, stride);\n    memcpy(cur_back, line_buffer, stride);\n    cur_front += stride;\n    cur_back -= stride;\n  }\n  av_freep(&line_buffer);\n  return 0;\n}\n\nvoid fillDXVAExtFormat(DXVA2_ExtendedFormat &fmt, int range, int primaries, int matrix, int transfer, int chroma_sample_location, bool bClear)\n{\n  if (bClear)\n    fmt.value = 0;\n\n  if (range != -1)\n      fmt.NominalRange = range ? DXVA2_NominalRange_0_255 : DXVA2_NominalRange_16_235;\n\n  // Color Primaries\n  switch(primaries) {\n  case AVCOL_PRI_BT709:\n    fmt.VideoPrimaries = DXVA2_VideoPrimaries_BT709;\n    break;\n  case AVCOL_PRI_BT470M:\n    fmt.VideoPrimaries = DXVA2_VideoPrimaries_BT470_2_SysM;\n    break;\n  case AVCOL_PRI_BT470BG:\n    fmt.VideoPrimaries = DXVA2_VideoPrimaries_BT470_2_SysBG;\n    break;\n  case AVCOL_PRI_SMPTE170M:\n    fmt.VideoPrimaries = DXVA2_VideoPrimaries_SMPTE170M;\n    break;\n  case AVCOL_PRI_SMPTE240M:\n    fmt.VideoPrimaries = DXVA2_VideoPrimaries_SMPTE240M;\n    break;\n  // Values from newer Windows SDK (MediaFoundation)\n  case AVCOL_PRI_BT2020:\n    fmt.VideoPrimaries = MFVideoPrimaries_BT2020;\n    break;\n  case AVCOL_PRI_SMPTE428:\n    fmt.VideoPrimaries = MFVideoPrimaries_XYZ;\n    break;\n  case AVCOL_PRI_SMPTE431:\n    fmt.VideoPrimaries = MFVideoPrimaries_DCI_P3;\n    break;\n  }\n\n  // Color Space / Transfer Matrix\n  switch (matrix) {\n  case AVCOL_SPC_BT709:\n    fmt.VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT709;\n    break;\n  case AVCOL_SPC_BT470BG:\n  case AVCOL_SPC_SMPTE170M:\n    fmt.VideoTransferMatrix = DXVA2_VideoTransferMatrix_BT601;\n    break;\n  case AVCOL_SPC_SMPTE240M:\n    fmt.VideoTransferMatrix = DXVA2_VideoTransferMatrix_SMPTE240M;\n    break;\n  // Values from newer Windows SDK (MediaFoundation)\n  case AVCOL_SPC_BT2020_CL:\n  case AVCOL_SPC_BT2020_NCL:\n    fmt.VideoTransferMatrix = MFVideoTransferMatrix_BT2020_10;\n    break;\n  // Custom values, not official standard, but understood by madVR\n  case AVCOL_SPC_FCC:\n    fmt.VideoTransferMatrix = (DXVA2_VideoTransferMatrix)6;\n    break;\n  case AVCOL_SPC_YCGCO:\n    fmt.VideoTransferMatrix = (DXVA2_VideoTransferMatrix)7;\n    break;\n  }\n\n  // Color Transfer Function\n  switch(transfer) {\n  case AVCOL_TRC_BT709:\n  case AVCOL_TRC_SMPTE170M:\n    fmt.VideoTransferFunction = DXVA2_VideoTransFunc_709;\n    break;\n  case AVCOL_TRC_BT2020_10:\n  case AVCOL_TRC_BT2020_12:\n    fmt.VideoTransferFunction = (matrix == AVCOL_SPC_BT2020_CL) ? MFVideoTransFunc_2020_const : MFVideoTransFunc_2020;\n    break;\n  case AVCOL_TRC_GAMMA22:\n    fmt.VideoTransferFunction = DXVA2_VideoTransFunc_22;\n    break;\n  case AVCOL_TRC_GAMMA28:\n    fmt.VideoTransferFunction = DXVA2_VideoTransFunc_28;\n    break;\n  case AVCOL_TRC_SMPTE240M:\n    fmt.VideoTransferFunction = DXVA2_VideoTransFunc_240M;\n    break;\n  case AVCOL_TRC_LINEAR:\n    fmt.VideoTransferFunction = DXVA2_VideoTransFunc_10;\n    break;\n  case AVCOL_TRC_LOG:\n    fmt.VideoTransferFunction = MFVideoTransFunc_Log_100;\n    break;\n  case AVCOL_TRC_LOG_SQRT:\n    fmt.VideoTransferFunction = MFVideoTransFunc_Log_316;\n    break;\n  // Values from newer Windows SDK (MediaFoundation)\n  case AVCOL_TRC_SMPTEST2084:\n    fmt.VideoTransferFunction = MFVideoTransFunc_2084;\n    break;\n  case AVCOL_TRC_ARIB_STD_B67:\n    fmt.VideoTransferFunction = MFVideoTransFunc_HLG;\n    break;\n  }\n\n  // Chroma location\n  switch (chroma_sample_location) {\n  case AVCHROMA_LOC_LEFT:\n    fmt.VideoChromaSubsampling = DXVA2_VideoChromaSubsampling_MPEG2;\n    break;\n  case AVCHROMA_LOC_CENTER:\n    fmt.VideoChromaSubsampling = DXVA2_VideoChromaSubsampling_MPEG1;\n    break;\n  case AVCHROMA_LOC_TOPLEFT:\n    fmt.VideoChromaSubsampling = DXVA2_VideoChromaSubsampling_Cosited;\n    break;\n  }\n}\n\nvoid processFFHDRData(MediaSideDataHDR *sd, AVMasteringDisplayMetadata *ff)\n{\n  if (!sd || !ff)\n    return;\n\n  // avcodec exports the display primaries in RGB order, we export them in GBR\n  if (ff->has_primaries) {\n    sd->display_primaries_x[0] = av_q2d(ff->display_primaries[1][0]);\n    sd->display_primaries_y[0] = av_q2d(ff->display_primaries[1][1]);\n    sd->display_primaries_x[1] = av_q2d(ff->display_primaries[2][0]);\n    sd->display_primaries_y[1] = av_q2d(ff->display_primaries[2][1]);\n    sd->display_primaries_x[2] = av_q2d(ff->display_primaries[0][0]);\n    sd->display_primaries_y[2] = av_q2d(ff->display_primaries[0][1]);\n\n    sd->white_point_x = av_q2d(ff->white_point[0]);\n    sd->white_point_y = av_q2d(ff->white_point[1]);\n  }\n\n  if (ff->has_luminance) {\n    sd->max_display_mastering_luminance = av_q2d(ff->max_luminance);\n    sd->min_display_mastering_luminance = av_q2d(ff->min_luminance);\n  }\n}\n\nvoid processFFHDR10PlusData(MediaSideDataHDR10Plus *sd, AVDynamicHDRPlus *ff, int width, int height)\n{\n  if (!sd || !ff)\n    return;\n\n  if (ff->num_windows > 3)\n    return;\n\n  sd->num_windows = ff->num_windows;\n  for (int i = 0; i < ff->num_windows; i++)\n  {\n    sd->windows[i].upper_left_corner_x = (int)av_q2d(ff->params[i].window_upper_left_corner_x) * (width - 1);\n    sd->windows[i].upper_left_corner_y = (int)av_q2d(ff->params[i].window_upper_left_corner_y) * (height - 1);\n\n    sd->windows[i].lower_right_corner_x = (int)av_q2d(ff->params[i].window_lower_right_corner_x) * (width - 1);\n    sd->windows[i].lower_right_corner_y = (int)av_q2d(ff->params[i].window_lower_right_corner_y) * (height - 1);\n\n    sd->windows[i].center_of_ellipse_x = ff->params[i].center_of_ellipse_x;\n    sd->windows[i].center_of_ellipse_y = ff->params[i].center_of_ellipse_y;\n\n    sd->windows[i].rotation_angle = ff->params[i].rotation_angle;\n    sd->windows[i].semimajor_axis_internal_ellipse = ff->params[i].semimajor_axis_internal_ellipse;\n    sd->windows[i].semimajor_axis_external_ellipse = ff->params[i].semimajor_axis_external_ellipse;\n    sd->windows[i].semiminor_axis_external_ellipse = ff->params[i].semiminor_axis_external_ellipse;\n\n    sd->windows[i].overlap_process_option = ff->params[i].overlap_process_option;\n\n    for (int k = 0; k < 3; k++)\n      sd->windows[i].maxscl[k] = av_q2d(ff->params[i].maxscl[k]);\n\n    sd->windows[i].average_maxrgb = av_q2d(ff->params[i].average_maxrgb);\n\n    sd->windows[i].num_distribution_maxrgb_percentiles = ff->params[i].num_distribution_maxrgb_percentiles;\n    for (int k = 0; k < ff->params[i].num_distribution_maxrgb_percentiles; k++)\n    {\n      sd->windows[i].distribution_maxrgb_percentiles[k].percentage = ff->params[i].distribution_maxrgb[k].percentage;\n      sd->windows[i].distribution_maxrgb_percentiles[k].percentile = av_q2d(ff->params[i].distribution_maxrgb[k].percentile);\n    }\n\n    sd->windows[i].fraction_bright_pixels = av_q2d(ff->params[i].fraction_bright_pixels);\n    sd->windows[i].tone_mapping_flag = ff->params[i].tone_mapping_flag;\n\n    if (sd->windows[i].tone_mapping_flag)\n    {\n      sd->windows[i].knee_point_x = av_q2d(ff->params[i].knee_point_x);\n      sd->windows[i].knee_point_y = av_q2d(ff->params[i].knee_point_y);\n\n      sd->windows[i].num_bezier_curve_anchors = ff->params[i].num_bezier_curve_anchors;\n      for (int k = 0; k < ff->params[i].num_bezier_curve_anchors; k++)\n        sd->windows[i].bezier_curve_anchors[k] = av_q2d(ff->params[i].bezier_curve_anchors[k]);\n    }\n\n    sd->windows[i].color_saturation_mapping_flag = ff->params[i].color_saturation_mapping_flag;\n    if (sd->windows[i].color_saturation_mapping_flag)\n      sd->windows[i].color_saturation_weight = av_q2d(ff->params[i].color_saturation_weight);\n  }\n\n  sd->targeted_system_display_maximum_luminance = av_q2d(ff->targeted_system_display_maximum_luminance);\n\n  sd->targeted_system_display_actual_peak_luminance_flag = ff->targeted_system_display_actual_peak_luminance_flag;\n  sd->num_rows_targeted_system_display_actual_peak_luminance = ff->num_rows_targeted_system_display_actual_peak_luminance;\n  sd->num_cols_targeted_system_display_actual_peak_luminance = ff->num_cols_targeted_system_display_actual_peak_luminance;\n  for (int i = 0; i < ff->num_rows_targeted_system_display_actual_peak_luminance; i++)\n    for (int j = 0; j < ff->num_cols_targeted_system_display_actual_peak_luminance; j++)\n      sd->targeted_system_display_actual_peak_luminance[i][j] = av_q2d(ff->targeted_system_display_actual_peak_luminance[i][j]);\n\n  sd->mastering_display_actual_peak_luminance_flag = ff->mastering_display_actual_peak_luminance_flag;\n  sd->num_rows_mastering_display_actual_peak_luminance = ff->num_rows_mastering_display_actual_peak_luminance;\n  sd->num_cols_mastering_display_actual_peak_luminance = ff->num_cols_mastering_display_actual_peak_luminance;\n  for (int i = 0; i < ff->num_rows_mastering_display_actual_peak_luminance; i++)\n    for (int j = 0; j < ff->num_cols_mastering_display_actual_peak_luminance; j++)\n      sd->mastering_display_actual_peak_luminance[i][j] = av_q2d(ff->mastering_display_actual_peak_luminance[i][j]);\n}\n\nvoid processFFDOVIData(MediaSideDataDOVIMetadata* sd, const AVDOVIMetadata* ff)\n{\n    const AVDOVIRpuDataHeader *header = av_dovi_get_header(ff);\n    const AVDOVIDataMapping *mapping = av_dovi_get_mapping(ff);\n    const AVDOVIColorMetadata *color = av_dovi_get_color(ff);\n\n#define RPU_HDR(name) sd->Header.##name = header->##name;\n#define RPU_MAP(name) sd->Mapping.##name = mapping->##name;\n#define RPU_COLOR(name) sd->ColorMetadata.##name = color->##name;\n\n    RPU_HDR(rpu_type);\n    RPU_HDR(rpu_format);\n    RPU_HDR(vdr_rpu_profile);\n    RPU_HDR(vdr_rpu_level);\n    RPU_HDR(chroma_resampling_explicit_filter_flag);\n    RPU_HDR(coef_data_type);\n    RPU_HDR(coef_log2_denom);\n    RPU_HDR(vdr_rpu_normalized_idc);\n    RPU_HDR(bl_video_full_range_flag);\n    RPU_HDR(bl_bit_depth);\n    RPU_HDR(el_bit_depth);\n    RPU_HDR(vdr_bit_depth);\n    RPU_HDR(spatial_resampling_filter_flag);\n    RPU_HDR(el_spatial_resampling_filter_flag);\n    RPU_HDR(disable_residual_flag);\n\n    RPU_MAP(vdr_rpu_id);\n    RPU_MAP(mapping_color_space);\n    RPU_MAP(mapping_chroma_format_idc);\n\n    for (int i = 0; i < 3; i++)\n    {\n        sd->Mapping.curves[i].num_pivots = mapping->curves[i].num_pivots;\n        for (int j = 0; j < AV_DOVI_MAX_PIECES + 1; j++)\n            sd->Mapping.curves[i].pivots[j] = mapping->curves[i].pivots[j];\n        for (int j = 0; j < AV_DOVI_MAX_PIECES; j++)\n        {\n            sd->Mapping.curves[i].mapping_idc[j] = mapping->curves[i].mapping_idc[j];\n\n            // poly\n            sd->Mapping.curves[i].poly_order[j] = mapping->curves[i].poly_order[j];\n            sd->Mapping.curves[i].poly_coef[j][0] = mapping->curves[i].poly_coef[j][0];\n            sd->Mapping.curves[i].poly_coef[j][1] = mapping->curves[i].poly_coef[j][1];\n            sd->Mapping.curves[i].poly_coef[j][2] = mapping->curves[i].poly_coef[j][2];\n\n            // mmr\n            sd->Mapping.curves[i].mmr_order[j] = mapping->curves[i].mmr_order[j];\n            sd->Mapping.curves[i].mmr_constant[j] = mapping->curves[i].mmr_constant[j];\n            for (int k = 0; k < 3; k++)\n                for (int l = 0; l < 7; l++)\n                    sd->Mapping.curves[i].mmr_coef[j][k][l] = mapping->curves[i].mmr_coef[j][k][l];\n        }\n    }\n\n    RPU_MAP(nlq_method_idc);\n    RPU_MAP(num_x_partitions);\n    RPU_MAP(num_y_partitions);\n\n    for (int i = 0; i < 3; i++)\n    {\n        sd->Mapping.nlq[i].nlq_offset = mapping->nlq[i].nlq_offset;\n        sd->Mapping.nlq[i].vdr_in_max = mapping->nlq[i].vdr_in_max;\n        sd->Mapping.nlq[i].linear_deadzone_slope = mapping->nlq[i].linear_deadzone_slope;\n        sd->Mapping.nlq[i].linear_deadzone_threshold = mapping->nlq[i].linear_deadzone_threshold;\n    }\n\n    RPU_COLOR(dm_metadata_id);\n    RPU_COLOR(scene_refresh_flag);\n\n    for (int i = 0; i < 9; i++)\n    {\n        sd->ColorMetadata.ycc_to_rgb_matrix[i] = av_q2d(color->ycc_to_rgb_matrix[i]);\n        sd->ColorMetadata.rgb_to_lms_matrix[i] = av_q2d(color->rgb_to_lms_matrix[i]);\n    }\n\n    for (int i = 0; i < 3; i++)\n    {\n        sd->ColorMetadata.ycc_to_rgb_offset[i] = av_q2d(color->ycc_to_rgb_offset[i]);\n    }\n\n    RPU_COLOR(signal_eotf);\n    RPU_COLOR(signal_eotf_param0);\n    RPU_COLOR(signal_eotf_param1);\n    RPU_COLOR(signal_eotf_param2);\n    RPU_COLOR(signal_bit_depth);\n    RPU_COLOR(signal_color_space);\n    RPU_COLOR(signal_chroma_format);\n    RPU_COLOR(signal_full_range_flag);\n    RPU_COLOR(source_min_pq);\n    RPU_COLOR(source_max_pq);\n    RPU_COLOR(source_diagonal);\n\n#undef RPU_HDR\n#undef RPU_MAP\n#undef RPU_COLOR\n\n    int LAVExtIdx = 0;\n    for (int i = 0; i < ff->num_ext_blocks; i++)\n    {\n        AVDOVIDmData *ext = av_dovi_get_ext(ff, i);\n        auto lavext = &sd->Extensions[LAVExtIdx];\n\n        lavext->level = ext->level;\n        switch (ext->level)\n        {\n        case 1:\n            lavext->Level1.min_pq = ext->l1.min_pq;\n            lavext->Level1.max_pq = ext->l1.max_pq;\n            lavext->Level1.avg_pq = ext->l1.avg_pq;\n            break;\n        case 2:\n            lavext->Level2.target_max_pq = ext->l2.target_max_pq;\n            lavext->Level2.trim_slope = ext->l2.trim_slope;\n            lavext->Level2.trim_offset = ext->l2.trim_offset;\n            lavext->Level2.trim_power = ext->l2.trim_power;\n            lavext->Level2.trim_chroma_weight = ext->l2.trim_chroma_weight;\n            lavext->Level2.trim_saturation_gain = ext->l2.trim_saturation_gain;\n            lavext->Level2.ms_weight = ext->l2.ms_weight;\n            break;\n        case 3:\n            lavext->Level3.min_pq_offset = ext->l3.min_pq_offset;\n            lavext->Level3.max_pq_offset = ext->l3.max_pq_offset;\n            lavext->Level3.avg_pq_offset = ext->l3.avg_pq_offset;\n            break;\n        case 4:\n            lavext->Level4.anchor_pq = ext->l4.anchor_pq;\n            lavext->Level4.anchor_power = ext->l4.anchor_power;\n            break;\n        case 5:\n            lavext->Level5.left_offset = ext->l5.left_offset;\n            lavext->Level5.right_offset = ext->l5.right_offset;\n            lavext->Level5.top_offset = ext->l5.top_offset;\n            lavext->Level5.bottom_offset = ext->l5.bottom_offset;\n            break;\n        case 6:\n            lavext->Level6.max_luminance = ext->l6.max_luminance;\n            lavext->Level6.min_luminance = ext->l6.min_luminance;\n            lavext->Level6.max_cll = ext->l6.max_cll;\n            lavext->Level6.max_fall = ext->l6.max_fall;\n            break;\n        case 8:\n            lavext->Level8.target_display_index = ext->l8.target_display_index;\n            lavext->Level8.trim_slope = ext->l8.trim_slope;\n            lavext->Level8.trim_offset = ext->l8.trim_offset;\n            lavext->Level8.trim_power = ext->l8.trim_power;\n            lavext->Level8.trim_chroma_weight = ext->l8.trim_chroma_weight;\n            lavext->Level8.trim_saturation_gain = ext->l8.trim_saturation_gain;\n            lavext->Level8.ms_weight = ext->l8.ms_weight;\n            lavext->Level8.target_mid_contrast = ext->l8.target_mid_contrast;\n            lavext->Level8.clip_trim = ext->l8.clip_trim;\n            for (int j = 0; j < 6; j++) {\n                lavext->Level8.saturation_vector_field[j] = ext->l8.saturation_vector_field[j];\n                lavext->Level8.hue_vector_field[j] = ext->l8.hue_vector_field[j];\n            }\n            break;\n        case 9:\n            lavext->Level9.source_primary_index = ext->l9.source_primary_index;\n            lavext->Level9.white_point_x = av_q2d(ext->l9.source_display_primaries.wp.x);\n            lavext->Level9.white_point_y = av_q2d(ext->l9.source_display_primaries.wp.y);\n            lavext->Level9.display_primaries_x[0] = av_q2d(ext->l9.source_display_primaries.prim.r.x);\n            lavext->Level9.display_primaries_x[1] = av_q2d(ext->l9.source_display_primaries.prim.g.x);\n            lavext->Level9.display_primaries_x[2] = av_q2d(ext->l9.source_display_primaries.prim.b.x);\n            lavext->Level9.display_primaries_y[0] = av_q2d(ext->l9.source_display_primaries.prim.r.y);\n            lavext->Level9.display_primaries_y[1] = av_q2d(ext->l9.source_display_primaries.prim.g.y);\n            lavext->Level9.display_primaries_y[2] = av_q2d(ext->l9.source_display_primaries.prim.b.y);\n            break;\n        case 10:\n            lavext->Level10.target_display_index = ext->l10.target_display_index;\n            lavext->Level10.target_max_pq = ext->l10.target_max_pq;\n            lavext->Level10.target_min_pq = ext->l10.target_min_pq;\n            lavext->Level10.target_primary_index = ext->l10.target_primary_index;\n            lavext->Level10.white_point_x = av_q2d(ext->l10.target_display_primaries.wp.x);\n            lavext->Level10.white_point_y = av_q2d(ext->l10.target_display_primaries.wp.y);\n            lavext->Level10.display_primaries_x[0] = av_q2d(ext->l10.target_display_primaries.prim.r.x);\n            lavext->Level10.display_primaries_x[1] = av_q2d(ext->l10.target_display_primaries.prim.g.x);\n            lavext->Level10.display_primaries_x[2] = av_q2d(ext->l10.target_display_primaries.prim.b.x);\n            lavext->Level10.display_primaries_y[0] = av_q2d(ext->l10.target_display_primaries.prim.r.y);\n            lavext->Level10.display_primaries_y[1] = av_q2d(ext->l10.target_display_primaries.prim.g.y);\n            lavext->Level10.display_primaries_y[2] = av_q2d(ext->l10.target_display_primaries.prim.b.y);\n            break;\n        case 11:\n            lavext->Level11.content_type = ext->l11.content_type;\n            lavext->Level11.whitepoint = ext->l11.whitepoint;\n            lavext->Level11.reference_mode_flag = ext->l11.reference_mode_flag;\n            break;\n        case 254:\n            lavext->Level254.dm_mode = ext->l254.dm_mode;\n            lavext->Level254.dm_version_index = ext->l254.dm_version_index;\n            break;\n        default:\n            lavext->level = 0; /* reset level, unknown/not implemented extension */\n            break;\n        }\n\n        /* if the block is valid/recognized, go to the next one */\n        if (lavext->level > 0)\n            LAVExtIdx++;\n\n        /* only 32 blocks are allowed, sanity check here */\n        if (LAVExtIdx >= LAV_DOVI_MAX_EXTENSIONS)\n            break;\n    }\n}\n\nextern \"C\" const uint8_t *avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state);\n\nint CheckForSequenceMarkers(AVCodecID codec, const uint8_t *buf, long len, uint32_t *state, const uint8_t **pos)\n{\n  int status = 0;\n  if (buf && len > 0) {\n    const uint8_t *p = buf, *end = buf + len;\n    if (codec == AV_CODEC_ID_MPEG2VIDEO) {\n      while (p < end) {\n        p = avpriv_find_start_code(p, end, state);\n        if (*state == 0x000001b7) {\n          DbgLog((LOG_TRACE, 50, L\"Found SEQ_END_CODE at %p (end: %p)\", p, end));\n          status |= STATE_EOS_FOUND;\n          if (pos)\n            *pos = p;\n          return status;\n        } else if (*state == 0x000001b8) {\n          status |= STATE_GOP_FOUND;\n        }\n      }\n    }\n    return status;\n  }\n  return status;\n}\n\nint sws_scale2(struct SwsContext *c, const uint8_t *const srcSlice[], const ptrdiff_t srcStride[], int srcSliceY, int srcSliceH, uint8_t *const dst[], const ptrdiff_t dstStride[])\n{\n  if (!c)\n    return -1;\n\n  int srcStride2[4];\n  int dstStride2[4];\n\n  for (int i = 0; i < 4; i++) {\n    srcStride2[i] = (int)srcStride[i];\n    dstStride2[i] = (int)dstStride[i];\n  }\n  return sws_scale(c, srcSlice, srcStride2, srcSliceY, srcSliceH, dst, dstStride2);\n}\n"
  },
  {
    "path": "decoder/LAVVideo/Media.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"IMediaSideData.h\"\n#include \"libavutil/mastering_display_metadata.h\"\n#include \"libavutil/hdr_dynamic_metadata.h\"\n#include \"libavutil/dovi_meta.h\"\n\nAVCodecID FindCodecId(const CMediaType *mt);\nint getThreadFlags(AVCodecID codecId);\n\n#define MAX_NUM_CC_CODECS 3\n\nstruct codec_config_t\n{\n    int nCodecs;\n    AVCodecID codecs[MAX_NUM_CC_CODECS];\n    const char *name;\n    const char *description;\n};\nconst codec_config_t *get_codec_config(LAVVideoCodec codec);\n\nint flip_plane(BYTE *buffer, int stride, int height);\nvoid fillDXVAExtFormat(DXVA2_ExtendedFormat &fmt, int range, int primaries, int matrix, int transfer,\n                       int chroma_sample_location = 0, bool bClear = true);\nvoid processFFHDRData(MediaSideDataHDR *sd, AVMasteringDisplayMetadata *ff);\nvoid processFFHDR10PlusData(MediaSideDataHDR10Plus *sd, AVDynamicHDRPlus *ff, int width, int height);\nvoid processFFDOVIData(MediaSideDataDOVIMetadata *sd, const AVDOVIMetadata *ff);\n\n#define STATE_NOT_FOUND 0\n#define STATE_EOS_FOUND 1\n#define STATE_GOP_FOUND 2\nint CheckForSequenceMarkers(AVCodecID codec, const uint8_t *buf, long len, uint32_t *state,\n                            const uint8_t **pos = nullptr);\n\nint sws_scale2(struct SwsContext *c, const uint8_t *const srcSlice[], const ptrdiff_t srcStride[], int srcSliceY,\n               int srcSliceH, uint8_t *const dst[], const ptrdiff_t dstStride[]);\n"
  },
  {
    "path": "decoder/LAVVideo/VideoInputPin.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"VideoInputPin.h\"\n#include \"ILAVDynamicAllocator.h\"\n\nCVideoInputPin::CVideoInputPin(TCHAR *pObjectName, CLAVVideo *pFilter, HRESULT *phr, LPWSTR pName)\n    : CDeCSSTransformInputPin(pObjectName, pFilter, phr, pName)\n    , m_pLAVVideo(pFilter)\n{\n}\n\nSTDMETHODIMP CVideoInputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    return QI(IPinSegmentEx) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\nSTDMETHODIMP CVideoInputPin::NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly)\n{\n    HRESULT hr = __super::NotifyAllocator(pAllocator, bReadOnly);\n\n    m_bDynamicAllocator = FALSE;\n    if (SUCCEEDED(hr) && pAllocator)\n    {\n        ILAVDynamicAllocator *pDynamicAllocator = nullptr;\n        if (SUCCEEDED(pAllocator->QueryInterface(&pDynamicAllocator)))\n        {\n            m_bDynamicAllocator = pDynamicAllocator->IsDynamicAllocator();\n        }\n        SafeRelease(&pDynamicAllocator);\n    }\n\n    return hr;\n}\n\nSTDMETHODIMP CVideoInputPin::EndOfSegment()\n{\n    CAutoLock lck(&m_pLAVVideo->m_csReceive);\n    HRESULT hr = CheckStreaming();\n    if (S_OK == hr)\n    {\n        hr = m_pLAVVideo->EndOfSegment();\n    }\n\n    return hr;\n}\n\n// IKsPropertySet\n\nSTDMETHODIMP CVideoInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength,\n                                 LPVOID pPropertyData, ULONG DataLength)\n{\n    if (PropSet != AM_KSPROPSETID_TSRateChange)\n    {\n        return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);\n    }\n\n    switch (Id)\n    {\n    case AM_RATE_SimpleRateChange: {\n        AM_SimpleRateChange *p = (AM_SimpleRateChange *)pPropertyData;\n        if (!m_CorrectTS)\n        {\n            return E_PROP_ID_UNSUPPORTED;\n        }\n        CAutoLock cAutoLock(&m_csRateLock);\n        m_ratechange = *p;\n    }\n    break;\n    case AM_RATE_UseRateVersion: {\n        WORD *p = (WORD *)pPropertyData;\n        if (*p > 0x0101)\n        {\n            return E_PROP_ID_UNSUPPORTED;\n        }\n    }\n    break;\n    case AM_RATE_CorrectTS: {\n        LONG *p = (LONG *)pPropertyData;\n        m_CorrectTS = *p;\n    }\n    break;\n    default: return E_PROP_ID_UNSUPPORTED;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CVideoInputPin::Get(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength,\n                                 LPVOID pPropertyData, ULONG DataLength, ULONG *pBytesReturned)\n{\n    if (PropSet != AM_KSPROPSETID_TSRateChange)\n    {\n        return __super::Get(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength, pBytesReturned);\n    }\n\n    switch (Id)\n    {\n    case AM_RATE_SimpleRateChange: {\n        AM_SimpleRateChange *p = (AM_SimpleRateChange *)pPropertyData;\n        CAutoLock cAutoLock(&m_csRateLock);\n        *p = m_ratechange;\n        *pBytesReturned = sizeof(AM_SimpleRateChange);\n    }\n    break;\n    case AM_RATE_MaxFullDataRate: {\n        AM_MaxFullDataRate *p = (AM_MaxFullDataRate *)pPropertyData;\n        *p = 2 * 10000;\n        *pBytesReturned = sizeof(AM_MaxFullDataRate);\n    }\n    break;\n    case AM_RATE_QueryFullFrameRate: {\n        AM_QueryRate *p = (AM_QueryRate *)pPropertyData;\n        p->lMaxForwardFullFrame = 2 * 10000;\n        p->lMaxReverseFullFrame = 0;\n        *pBytesReturned = sizeof(AM_QueryRate);\n    }\n    break;\n    case AM_RATE_QueryLastRateSegPTS: {\n        // REFERENCE_TIME* p = (REFERENCE_TIME*)pPropertyData;\n        return E_PROP_ID_UNSUPPORTED;\n    }\n    break;\n    default: return E_PROP_ID_UNSUPPORTED;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CVideoInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG *pTypeSupport)\n{\n    if (PropSet != AM_KSPROPSETID_TSRateChange)\n    {\n        return __super::QuerySupported(PropSet, Id, pTypeSupport);\n    }\n\n    switch (Id)\n    {\n    case AM_RATE_SimpleRateChange: *pTypeSupport = KSPROPERTY_SUPPORT_GET | KSPROPERTY_SUPPORT_SET; break;\n    case AM_RATE_MaxFullDataRate: *pTypeSupport = KSPROPERTY_SUPPORT_GET; break;\n    case AM_RATE_UseRateVersion: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    case AM_RATE_QueryFullFrameRate: *pTypeSupport = KSPROPERTY_SUPPORT_GET; break;\n    case AM_RATE_QueryLastRateSegPTS: *pTypeSupport = KSPROPERTY_SUPPORT_GET; break;\n    case AM_RATE_CorrectTS: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    default: return E_PROP_ID_UNSUPPORTED;\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/VideoInputPin.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"DeCSS/DeCSSInputPin.h\"\n#include \"LAVVideo.h\"\n#include \"IPinSegmentEx.h\"\n\nclass CVideoInputPin\n    : public CDeCSSTransformInputPin\n    , public IPinSegmentEx\n{\n  public:\n    CVideoInputPin(TCHAR *pObjectName, CLAVVideo *pFilter, HRESULT *phr, LPWSTR pName);\n\n    // CUnknown\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // IMemInputPin\n    STDMETHODIMP NotifyAllocator(IMemAllocator *pAllocator, BOOL bReadOnly);\n\n    // IPinSegmentEx\n    STDMETHODIMP EndOfSegment();\n\n    // IKsPropertySet\n    STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData,\n                     ULONG DataLength);\n    STDMETHODIMP Get(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData,\n                     ULONG DataLength, ULONG *pBytesReturned);\n    STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG *pTypeSupport);\n\n    AM_SimpleRateChange GetDVDRateChange()\n    {\n        CAutoLock cAutoLock(&m_csRateLock);\n        return m_ratechange;\n    }\n\n    BOOL HasDynamicAllocator() { return m_bDynamicAllocator; }\n\n  private:\n    CLAVVideo *m_pLAVVideo = nullptr;\n    CCritSec m_csRateLock;\n\n    int m_CorrectTS = 0;\n    AM_SimpleRateChange m_ratechange = AM_SimpleRateChange{AV_NOPTS_VALUE, 10000};\n\n    BOOL m_bDynamicAllocator = FALSE;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/VideoOutputPin.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVVideo.h\"\n#include \"VideoOutputPin.h\"\n\nCVideoOutputPin::CVideoOutputPin(LPCTSTR pObjectName, CLAVVideo *pFilter, HRESULT *phr, LPCWSTR pName)\n    : CTransformOutputPin(pObjectName, (CTransformFilter *)pFilter, phr, pName)\n    , m_pFilter(pFilter)\n{\n}\n\nCVideoOutputPin::~CVideoOutputPin()\n{\n}\n\nHRESULT CVideoOutputPin::InitAllocator(IMemAllocator **ppAlloc)\n{\n    HRESULT hr = S_FALSE;\n    hr = m_pFilter->m_Decoder.InitAllocator(ppAlloc);\n\n    if (hr != S_OK)\n        hr = __super::InitAllocator(ppAlloc);\n\n    return hr;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/VideoOutputPin.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nclass CVideoOutputPin : public CTransformOutputPin\n{\n  public:\n    CVideoOutputPin(LPCTSTR pObjectName, CLAVVideo *pFilter, HRESULT *phr, LPCWSTR pName);\n    virtual ~CVideoOutputPin();\n\n    HRESULT InitAllocator(IMemAllocator **ppAlloc);\n\n  private:\n    CLAVVideo *m_pFilter = nullptr;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/VideoSettingsProp.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"VideoSettingsProp.h\"\n#include \"Media.h\"\n\n#include <Commctrl.h>\n\n#include \"resource.h\"\n#include \"version.h\"\n\nCLAVVideoSettingsProp::CLAVVideoSettingsProp(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseDSPropPage(NAME(\"LAVVideoProp\"), pUnk, IDD_PROPPAGE_VIDEO_SETTINGS, IDS_SETTINGS)\n{\n}\n\nCLAVVideoSettingsProp::~CLAVVideoSettingsProp()\n{\n}\n\nHRESULT CLAVVideoSettingsProp::OnConnect(IUnknown *pUnk)\n{\n    if (pUnk == nullptr)\n    {\n        return E_POINTER;\n    }\n    ASSERT(m_pVideoSettings == nullptr);\n    HRESULT hr = pUnk->QueryInterface(&m_pVideoSettings);\n    if (FAILED(hr))\n        return hr;\n    hr = pUnk->QueryInterface(&m_pVideoStatus);\n    if (FAILED(hr))\n        return hr;\n    return S_OK;\n}\n\nHRESULT CLAVVideoSettingsProp::OnDisconnect()\n{\n    SafeRelease(&m_pVideoSettings);\n    SafeRelease(&m_pVideoStatus);\n    return S_OK;\n}\n\nHRESULT CLAVVideoSettingsProp::OnApplyChanges()\n{\n    ASSERT(m_pVideoSettings != nullptr);\n    ASSERT(m_pVideoStatus != nullptr);\n    HRESULT hr = S_OK;\n    BOOL bFlag;\n    DWORD dwVal;\n\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_STREAMAR, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetStreamAR(dwVal);\n\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_THREADS, CB_GETCURSEL, 0, 0);\n    m_pVideoSettings->SetNumThreads(dwVal);\n\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_DEINT_FIELDORDER, CB_GETCURSEL, 0, 0);\n    m_pVideoSettings->SetDeintFieldOrder((LAVDeintFieldOrder)dwVal);\n\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_DEINT_MODE, CB_GETCURSEL, 0, 0);\n    m_pVideoSettings->SetDeinterlacingMode((LAVDeintMode)dwVal);\n\n    m_bPixFmts[LAVOutPixFmt_YV12] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_YV12, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_NV12] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_NV12, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_P010] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_P010, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_P016] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_P016, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_YUY2] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_YUY2, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_UYVY] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_UYVY, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_P210] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_P210, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_v210] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_V210, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_P216] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_P216, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_YV24] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_YV24, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_AYUV] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_AYUV, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_Y410] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_Y410, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_v410] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_V410, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_Y416] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_Y416, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_RGB32] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_RGB32, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_RGB24] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_RGB24, BM_GETCHECK, 0, 0);\n    m_bPixFmts[LAVOutPixFmt_RGB48] = (BOOL)SendDlgItemMessage(m_Dlg, IDC_OUT_RGB48, BM_GETCHECK, 0, 0);\n\n    for (int i = 0; i < LAVOutPixFmt_NB; ++i)\n    {\n        m_pVideoSettings->SetPixelFormat((LAVOutPixFmts)i, m_bPixFmts[i]);\n    }\n\n    BOOL bRGBAuto = (BOOL)SendDlgItemMessage(m_Dlg, IDC_RGBOUT_AUTO, BM_GETCHECK, 0, 0);\n    BOOL bRGBTV = (BOOL)SendDlgItemMessage(m_Dlg, IDC_RGBOUT_TV, BM_GETCHECK, 0, 0);\n    BOOL bRGBPC = (BOOL)SendDlgItemMessage(m_Dlg, IDC_RGBOUT_PC, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetRGBOutputRange(bRGBAuto ? 0 : bRGBTV ? 1 : 2);\n\n    LRESULT retVal = SendDlgItemMessage(m_Dlg, IDC_HWACCEL, CB_GETCURSEL, 0, 0);\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_HWACCEL, CB_GETITEMDATA, retVal, 0);\n    m_pVideoSettings->SetHWAccel((LAVHWAccel)dwVal);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_H264, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelCodec(HWCodec_H264, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_VC1, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelCodec(HWCodec_VC1, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_MPEG2, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelCodec(HWCodec_MPEG2, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_MPEG4, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelCodec(HWCodec_MPEG4, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_HEVC, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelCodec(HWCodec_HEVC, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_VP9, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelCodec(HWCodec_VP9, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_AV1, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelCodec(HWCodec_AV1, bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_H264MVC, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelCodec(HWCodec_H264MVC, bFlag);\n\n    DWORD dwHWResFlags = 0;\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWRES_SD, BM_GETCHECK, 0, 0);\n    if (bFlag)\n        dwHWResFlags |= LAVHWResFlag_SD;\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWRES_HD, BM_GETCHECK, 0, 0);\n    if (bFlag)\n        dwHWResFlags |= LAVHWResFlag_HD;\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWRES_UHD, BM_GETCHECK, 0, 0);\n    if (bFlag)\n        dwHWResFlags |= LAVHWResFlag_UHD;\n\n    m_pVideoSettings->SetHWAccelResolutionFlags(dwHWResFlags);\n\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_DEVICE_SELECT, CB_GETCURSEL, 0, 0);\n    if (dwVal == 0)\n        dwVal = LAVHWACCEL_DEVICE_DEFAULT;\n    else\n        dwVal--;\n    m_pVideoSettings->SetHWAccelDeviceIndex(m_pVideoSettings->GetHWAccel(), dwVal, 0);\n\n    BOOL bHWAccelCUVIDDXVA = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_CUVID_DXVA, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelDeintHQ(bHWAccelCUVIDDXVA);\n\n    BOOL bHWDeint = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWDEINT_ENABLE, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelDeintMode(bHWDeint ? HWDeintMode_Hardware : HWDeintMode_Weave);\n\n    BOOL bFilm = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWDEINT_OUT_FILM, BM_GETCHECK, 0, 0);\n    // BOOL bVideo = (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWDEINT_OUT_VIDEO, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetHWAccelDeintOutput(bFilm ? DeintOutput_FramePer2Field : DeintOutput_FramePerField);\n\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_SWDEINT_MODE, CB_GETCURSEL, 0, 0);\n    m_pVideoSettings->SetSWDeintMode((LAVSWDeintModes)dwVal);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SWDEINT_OUT_FILM, BM_GETCHECK, 0, 0);\n    // BOOL bVideo = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SWDEINT_OUT_VIDEO, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetSWDeintOutput(bFlag ? DeintOutput_FramePer2Field : DeintOutput_FramePerField);\n\n    BOOL bOrdered = (BOOL)SendDlgItemMessage(m_Dlg, IDC_DITHER_ORDERED, BM_GETCHECK, 0, 0);\n    BOOL bRandom = (BOOL)SendDlgItemMessage(m_Dlg, IDC_DITHER_RANDOM, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetDitherMode(bOrdered ? LAVDither_Ordered : LAVDither_Random);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetTrayIcon(bFlag);\n\n    LoadData();\n\n    return hr;\n}\n\nstatic void AddComboBoxEntryWithData(HWND hwnd, int nIDDlgItem, WCHAR *pszText, UINT Data)\n{\n    // add the entry\n    LRESULT ret = SendDlgItemMessage(hwnd, nIDDlgItem, CB_ADDSTRING, 0, (LPARAM)pszText);\n    if (ret < 0)\n        return;\n\n    // set its data\n    SendDlgItemMessage(hwnd, nIDDlgItem, CB_SETITEMDATA, ret, Data);\n}\n\nstatic void SelectComboBoxItemByValue(HWND hwnd, int nIDDlgItem, UINT Data)\n{\n    LRESULT count = SendDlgItemMessage(hwnd, nIDDlgItem, CB_GETCOUNT, 0, 0);\n    for (int i = 0; i < count; i++)\n    {\n        LRESULT ItemData = SendDlgItemMessage(hwnd, nIDDlgItem, CB_GETITEMDATA, i, 0);\n        if (ItemData == Data)\n        {\n            SendDlgItemMessage(hwnd, nIDDlgItem, CB_SETCURSEL, i, 0);\n            break;\n        }\n    }\n}\n\nHRESULT CLAVVideoSettingsProp::OnActivate()\n{\n    HRESULT hr = S_OK;\n    INITCOMMONCONTROLSEX icc;\n    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);\n    icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;\n    if (InitCommonControlsEx(&icc) == FALSE)\n    {\n        return E_FAIL;\n    }\n    ASSERT(m_pVideoSettings != nullptr);\n\n    const WCHAR *version = TEXT(LAV_VIDEO) L\" \" TEXT(LAV_VERSION_STR);\n    SendDlgItemMessage(m_Dlg, IDC_LAVVIDEO_FOOTER, WM_SETTEXT, 0, (LPARAM)version);\n\n    WCHAR stringBuffer[512] = L\"Auto\";\n\n    // Init the Combo Box\n    SendDlgItemMessage(m_Dlg, IDC_THREADS, CB_RESETCONTENT, 0, 0);\n    SendDlgItemMessage(m_Dlg, IDC_THREADS, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n\n    for (unsigned i = 1; i <= 32; ++i)\n    {\n        swprintf_s(stringBuffer, L\"%d\", i);\n        SendDlgItemMessage(m_Dlg, IDC_THREADS, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    }\n\n    addHint(IDC_THREADS, L\"Enable Multi-Threading for codecs that support it.\\nAuto will automatically use the maximum \"\n                         L\"number of threads suitable for your CPU. Using 1 thread disables multi-threading.\\n\\nMT \"\n                         L\"decoding is supported for H264, MPEG2, MPEG4, VP8, VP3/Theora, DV and HuffYUV\");\n\n    addHint(IDC_STREAMAR, L\"Checked - Stream AR will be used.\\nUnchecked - Frame AR will not be used.\\nIndeterminate \"\n                          L\"(Auto) - Stream AR will not be used on files with a container AR (recommended).\");\n\n    WCHAR hwAccelNone[] = L\"None\";\n    WCHAR hwAccelCUDA[] = L\"NVIDIA CUVID (old)\";\n    WCHAR hwAccelQuickSync[] = L\"Intel\\xae QuickSync (old)\";\n    WCHAR hwAccelDXVA2CB[] = L\"DXVA2 (copy-back)\";\n    WCHAR hwAccelDXVA2N[] = L\"DXVA2 (native)\";\n    WCHAR hwAccelD3D11[] = L\"D3D11\";\n    AddComboBoxEntryWithData(m_Dlg, IDC_HWACCEL, hwAccelNone, HWAccel_None);\n    AddComboBoxEntryWithData(m_Dlg, IDC_HWACCEL, hwAccelDXVA2CB, HWAccel_DXVA2CopyBack);\n    AddComboBoxEntryWithData(m_Dlg, IDC_HWACCEL, hwAccelDXVA2N, HWAccel_DXVA2Native);\n    AddComboBoxEntryWithData(m_Dlg, IDC_HWACCEL, hwAccelD3D11, HWAccel_D3D11);\n    AddComboBoxEntryWithData(m_Dlg, IDC_HWACCEL, hwAccelCUDA, HWAccel_CUDA);\n    AddComboBoxEntryWithData(m_Dlg, IDC_HWACCEL, hwAccelQuickSync, HWAccel_QuickSync);\n\n    // Init the fieldorder Combo Box\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_FIELDORDER, CB_RESETCONTENT, 0, 0);\n    WideStringFromResource(stringBuffer, IDS_FIELDORDER_AUTO);\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_FIELDORDER, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    WideStringFromResource(stringBuffer, IDS_FIELDORDER_TOP);\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_FIELDORDER, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    WideStringFromResource(stringBuffer, IDS_FIELDORDER_BOTTOM);\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_FIELDORDER, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n\n    // Deint Mode combo box\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_MODE, CB_RESETCONTENT, 0, 0);\n    WideStringFromResource(stringBuffer, IDS_DEINTMODE_AUTO);\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    WideStringFromResource(stringBuffer, IDS_DEINTMODE_AGGRESSIVE);\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    WideStringFromResource(stringBuffer, IDS_DEINTMODE_FORCE);\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    WideStringFromResource(stringBuffer, IDS_DEINTMODE_DISABLE);\n    SendDlgItemMessage(m_Dlg, IDC_DEINT_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n\n    // SW Deint Mode\n    WCHAR swdeintNone[] = L\"No Software Deinterlacing\";\n    WCHAR swdeintYADIF[] = L\"YADIF\";\n    WCHAR swdeintW3FDIFS[] = L\"Weston Three Field (Simple)\";\n    WCHAR swdeintW3FDIFC[] = L\"Weston Three Field (Complex)\";\n    WCHAR swdeintBWDIF[] = L\"BobWeaver (bwdif)\";\n    SendDlgItemMessage(m_Dlg, IDC_SWDEINT_MODE, CB_ADDSTRING, 0, (LPARAM)swdeintNone);\n    SendDlgItemMessage(m_Dlg, IDC_SWDEINT_MODE, CB_ADDSTRING, 0, (LPARAM)swdeintYADIF);\n    SendDlgItemMessage(m_Dlg, IDC_SWDEINT_MODE, CB_ADDSTRING, 0, (LPARAM)swdeintW3FDIFS);\n    SendDlgItemMessage(m_Dlg, IDC_SWDEINT_MODE, CB_ADDSTRING, 0, (LPARAM)swdeintW3FDIFC);\n    SendDlgItemMessage(m_Dlg, IDC_SWDEINT_MODE, CB_ADDSTRING, 0, (LPARAM)swdeintBWDIF);\n\n    addHint(IDC_HWACCEL_MPEG4, L\"EXPERIMENTAL! The MPEG4-ASP decoder is known to be unstable! Use at your own peril!\");\n    addHint(IDC_HWACCEL_H264MVC, L\"Intel GPU only.\\nMVC acceleration is not supported on other graphics cards.\");\n    addHint(IDC_HWACCEL_CUVID_DXVA, L\"Enable DXVA video processing for CUVID decoding, enables hybrid decoding and can \"\n                                    L\"affect deinterlacing quality.\\n\\nNote: Using DXVA2-CopyBack is recommended for \"\n                                    L\"hybrid decoding instead of using CUVID in DXVA mode.\");\n\n    addHint(IDC_HWRES_SD, L\"Use Hardware Decoding for Standard-definition content (DVD, SDTV)\\n\\nThis affects all \"\n                          L\"videos with a resolution less than 1024x576 (DVD resolution)\");\n    addHint(IDC_HWRES_HD, L\"Use Hardware Decoding for High-definition content (Blu-ray, HDTV)\\n\\nAffects all videos \"\n                          L\"above SD resolution, up to Full-HD, 1920x1200\");\n    addHint(IDC_HWRES_UHD,\n            L\"Use Hardware Decoding for Ultra-high-definition content (4K, UHDTV)\\n\\nAffects all videos above HD \"\n            L\"resolution. Note that not all hardware supports decoding 4K/UHD content. On AMD GPUs, 4K support is very \"\n            L\"fragile, and may even cause crashes or BSODs, use at your own risk.\");\n\n    addHint(IDC_DEINT_MODE,\n            L\"Controls how interlaced material is handled.\\n\\nAuto: Frame flags are used to determine content \"\n            L\"type.\\nAggressive: All frames in an interlaced streams are handled interlaced.\\nForce: All frames are \"\n            L\"handles as interlaced.\\nDisabled: All frames are handled as progressive.\");\n\n    addHint(IDC_HWDEINT_OUT_FILM, L\"Deinterlace in \\\"Film\\\" Mode.\\nFor every pair of interlaced fields, one frame will \"\n                                  L\"be created, resulting in 25/30 fps.\");\n    addHint(IDC_HWDEINT_OUT_VIDEO, L\"Deinterlace in \\\"Video\\\" Mode. (Recommended)\\nFor every interlaced field, one \"\n                                   L\"frame will be created, resulting in 50/60 fps.\");\n\n    addHint(IDC_DITHER_ORDERED, L\"Ordered Dithering uses a static pattern, resulting in very smooth and regular \"\n                                L\"pattern. However, in some cases the regular pattern can be visible and distracting.\");\n    addHint(IDC_DITHER_RANDOM,\n            L\"Random Dithering uses random noise to dither the video frames. This has the advantage of not creating \"\n            L\"any visible pattern, at the downside of increasing the noise floor slightly.\");\n\n    hr = LoadData();\n    if (SUCCEEDED(hr))\n    {\n        SendDlgItemMessage(m_Dlg, IDC_THREADS, CB_SETCURSEL, m_dwNumThreads, 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_STREAMAR, BM_SETCHECK, m_StreamAR, 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_DEINT_FIELDORDER, CB_SETCURSEL, m_DeintFieldOrder, 0);\n        SendDlgItemMessage(m_Dlg, IDC_DEINT_MODE, CB_SETCURSEL, m_DeintMode, 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_OUT_YV12, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_YV12], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_NV12, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_NV12], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_P010, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_P010], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_P016, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_P016], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_YUY2, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_YUY2], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_UYVY, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_UYVY], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_P210, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_P210], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_V210, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_v210], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_P216, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_P216], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_YV24, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_YV24], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_AYUV, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_AYUV], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_Y410, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_Y410], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_V410, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_v410], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_Y416, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_Y416], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_RGB32, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_RGB32], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_RGB24, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_RGB24], 0);\n        SendDlgItemMessage(m_Dlg, IDC_OUT_RGB48, BM_SETCHECK, m_bPixFmts[LAVOutPixFmt_RGB48], 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_RGBOUT_AUTO, BM_SETCHECK, (m_dwRGBOutput == 0), 0);\n        SendDlgItemMessage(m_Dlg, IDC_RGBOUT_TV, BM_SETCHECK, (m_dwRGBOutput == 1), 0);\n        SendDlgItemMessage(m_Dlg, IDC_RGBOUT_PC, BM_SETCHECK, (m_dwRGBOutput == 2), 0);\n\n        SelectComboBoxItemByValue(m_Dlg, IDC_HWACCEL, m_HWAccel);\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_H264, BM_SETCHECK, m_HWAccelCodecs[HWCodec_H264], 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_VC1, BM_SETCHECK, m_HWAccelCodecs[HWCodec_VC1], 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_MPEG2, BM_SETCHECK, m_HWAccelCodecs[HWCodec_MPEG2], 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_MPEG4, BM_SETCHECK, m_HWAccelCodecs[HWCodec_MPEG4], 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_HEVC, BM_SETCHECK, m_HWAccelCodecs[HWCodec_HEVC], 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_VP9, BM_SETCHECK, m_HWAccelCodecs[HWCodec_VP9], 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_AV1, BM_SETCHECK, m_HWAccelCodecs[HWCodec_AV1], 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_H264MVC, BM_SETCHECK, m_HWAccelCodecs[HWCodec_H264MVC], 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_HWRES_SD, BM_SETCHECK, !!(m_HWRes & LAVHWResFlag_SD), 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWRES_HD, BM_SETCHECK, !!(m_HWRes & LAVHWResFlag_HD), 0);\n        SendDlgItemMessage(m_Dlg, IDC_HWRES_UHD, BM_SETCHECK, !!(m_HWRes & LAVHWResFlag_UHD), 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_CUVID_DXVA, BM_SETCHECK, m_HWAccelCUVIDDXVA, 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_HWDEINT_ENABLE, BM_SETCHECK, (m_HWDeintAlgo == HWDeintMode_Hardware), 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_HWDEINT_OUT_FILM, BM_SETCHECK, (m_HWDeintOutMode == DeintOutput_FramePer2Field),\n                           0);\n        SendDlgItemMessage(m_Dlg, IDC_HWDEINT_OUT_VIDEO, BM_SETCHECK, (m_HWDeintOutMode == DeintOutput_FramePerField),\n                           0);\n\n        SendDlgItemMessage(m_Dlg, IDC_SWDEINT_MODE, CB_SETCURSEL, m_SWDeint, 0);\n        SendDlgItemMessage(m_Dlg, IDC_SWDEINT_OUT_FILM, BM_SETCHECK, (m_SWDeintOutMode == DeintOutput_FramePer2Field),\n                           0);\n        SendDlgItemMessage(m_Dlg, IDC_SWDEINT_OUT_VIDEO, BM_SETCHECK, (m_SWDeintOutMode == DeintOutput_FramePerField),\n                           0);\n\n        SendDlgItemMessage(m_Dlg, IDC_DITHER_ORDERED, BM_SETCHECK, (m_DitherMode == LAVDither_Ordered), 0);\n        SendDlgItemMessage(m_Dlg, IDC_DITHER_RANDOM, BM_SETCHECK, (m_DitherMode == LAVDither_Random), 0);\n\n        SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_SETCHECK, m_TrayIcon, 0);\n\n        UpdateHWOptions();\n        UpdateYADIFOptions();\n    }\n\n    const WCHAR *decoder = m_pVideoStatus->GetActiveDecoderName();\n    SendDlgItemMessage(m_Dlg, IDC_ACTIVE_DECODER, WM_SETTEXT, 0, (LPARAM)(decoder ? decoder : L\"<inactive>\"));\n\n    BSTR bstrHWDevice = nullptr;\n    if (SUCCEEDED(m_pVideoStatus->GetHWAccelActiveDevice(&bstrHWDevice)))\n    {\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_DEVICE, WM_SETTEXT, 0, (LPARAM)bstrHWDevice);\n        SysFreeString(bstrHWDevice);\n    }\n    else\n    {\n        SendDlgItemMessage(m_Dlg, IDC_HWACCEL_DEVICE, WM_SETTEXT, 0, (LPARAM)L\"<none>\");\n    }\n\n    return hr;\n}\n\nHRESULT CLAVVideoSettingsProp::UpdateHWOptions()\n{\n    LRESULT lValue = SendDlgItemMessage(m_Dlg, IDC_HWACCEL, CB_GETCURSEL, 0, 0);\n    LAVHWAccel hwAccel = (LAVHWAccel)SendDlgItemMessage(m_Dlg, IDC_HWACCEL, CB_GETITEMDATA, lValue, 0);\n\n    DWORD dwSupport = m_pVideoSettings->CheckHWAccelSupport(hwAccel);\n    BOOL bEnabled = (hwAccel != HWAccel_None) && dwSupport;\n    BOOL bHWDeint = bEnabled && (hwAccel == HWAccel_CUDA || hwAccel == HWAccel_QuickSync);\n    BOOL bHWDeintEnabled = bHWDeint && (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWDEINT_ENABLE, BM_GETCHECK, 0, 0);\n    BOOL bCUDAOnly = bEnabled && (hwAccel == HWAccel_CUDA);\n    BOOL bDVD = bEnabled && (BOOL)SendDlgItemMessage(m_Dlg, IDC_HWACCEL_MPEG2, BM_GETCHECK, 0, 0);\n    BOOL bHEVC = bEnabled && (hwAccel != HWAccel_QuickSync);\n    BOOL bVP9 = bEnabled && (hwAccel != HWAccel_QuickSync);\n    BOOL bAV1 = bEnabled && (hwAccel != HWAccel_QuickSync) && (hwAccel != HWAccel_CUDA);\n\n    ShowWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_CUVID_DXVA),\n               (hwAccel == HWAccel_CUDA && !IsWindows10OrNewer()) ? SW_SHOW : SW_HIDE);\n\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_H264), bEnabled);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_VC1), bEnabled);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_MPEG2), bEnabled);\n\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_MPEG4), bCUDAOnly);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_HEVC), bHEVC);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_VP9), bVP9);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_AV1), bAV1);\n\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWRES_SD), bEnabled);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWRES_HD), bEnabled);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWRES_UHD), bEnabled);\n\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWDEINT_ENABLE), bHWDeint);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_LBL_HWDEINT_MODE), bHWDeintEnabled);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWDEINT_OUT_FILM), bHWDeintEnabled);\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWDEINT_OUT_VIDEO), bHWDeintEnabled);\n\n    WCHAR hwAccelEmpty[] = L\"\";\n    WCHAR hwAccelUnavailable[] = L\"N/A\";\n    WCHAR hwAccelAvailable[] = L\"OK\";\n\n    SendDlgItemMessage(\n        m_Dlg, IDC_HWACCEL_AVAIL, WM_SETTEXT, 0,\n        (LPARAM)(hwAccel == HWAccel_None ? hwAccelEmpty : dwSupport == 0 ? hwAccelUnavailable : hwAccelAvailable));\n\n    const WCHAR hwHintNoDeviceChoice[] = L\"The selected Hardware Decoder does not support using a specific device.\";\n    const WCHAR hwHintDXVA2Display[] = L\"DXVA2 requires an active display for GPUs to be available.\\nNote that GPUs \"\n                                       L\"are listed once for each connected display.\";\n    const WCHAR hwHintD3D11NotSupported[] = L\"D3D11 requires Windows 8 or newer, and is not supported on this OS.\";\n    const WCHAR hwHintD3D11DeviceHint[] = L\"Selecting a specific device for D3D11 disables Native mode and forces \"\n                                          L\"Copy-Back, use Automatic for the best performance.\";\n\n    SendDlgItemMessage(m_Dlg, IDC_HWACCEL_DEVICE_SELECT, CB_RESETCONTENT, 0, 0);\n    SendDlgItemMessage(m_Dlg, IDC_HWACCEL_DEVICE_SELECT, CB_ADDSTRING, 0,\n                       (hwAccel == HWAccel_D3D11) ? (LPARAM)L\"Automatic (Native)\" : (LPARAM)L\"Automatic\");\n\n    DWORD dwnDevices = m_pVideoSettings->GetHWAccelNumDevices(hwAccel);\n    for (DWORD dwDevice = 0; dwDevice < dwnDevices; dwDevice++)\n    {\n        BSTR bstrDeviceName = nullptr;\n        HRESULT hr = m_pVideoSettings->GetHWAccelDeviceInfo(hwAccel, dwDevice, &bstrDeviceName, NULL);\n        if (SUCCEEDED(hr))\n        {\n            SendDlgItemMessage(m_Dlg, IDC_HWACCEL_DEVICE_SELECT, CB_ADDSTRING, 0, (LPARAM)bstrDeviceName);\n            SysFreeString(bstrDeviceName);\n        }\n    }\n\n    if (hwAccel == HWAccel_D3D11 && !IsWindows8OrNewer())\n    {\n        m_HWDeviceIndex = 0;\n        dwnDevices = 0;\n        SendDlgItemMessage(m_Dlg, IDC_LBL_HWACCEL_DEVICE_HINT, WM_SETTEXT, 0, (LPARAM)hwHintD3D11NotSupported);\n    }\n    else if (dwnDevices == 0)\n    {\n        m_HWDeviceIndex = 0;\n        SendDlgItemMessage(m_Dlg, IDC_LBL_HWACCEL_DEVICE_HINT, WM_SETTEXT, 0, (LPARAM)hwHintNoDeviceChoice);\n    }\n    else\n    {\n        DWORD dwDeviceId = 0;\n        m_HWDeviceIndex = m_pVideoSettings->GetHWAccelDeviceIndex(hwAccel, &dwDeviceId);\n        if (m_HWDeviceIndex == LAVHWACCEL_DEVICE_DEFAULT)\n            m_HWDeviceIndex = 0;\n        else\n            m_HWDeviceIndex++;\n\n        if (hwAccel == HWAccel_DXVA2CopyBack)\n            SendDlgItemMessage(m_Dlg, IDC_LBL_HWACCEL_DEVICE_HINT, WM_SETTEXT, 0, (LPARAM)hwHintDXVA2Display);\n        else if (hwAccel == HWAccel_D3D11)\n            SendDlgItemMessage(m_Dlg, IDC_LBL_HWACCEL_DEVICE_HINT, WM_SETTEXT, 0, (LPARAM)hwHintD3D11DeviceHint);\n        else\n            SendDlgItemMessage(m_Dlg, IDC_LBL_HWACCEL_DEVICE_HINT, WM_SETTEXT, 0, (LPARAM)L\"\");\n    }\n\n    EnableWindow(GetDlgItem(m_Dlg, IDC_LBL_HWACCEL_DEVICE_SELECT), (dwnDevices > 0));\n    EnableWindow(GetDlgItem(m_Dlg, IDC_HWACCEL_DEVICE_SELECT), (dwnDevices > 0));\n\n    SendDlgItemMessage(m_Dlg, IDC_HWACCEL_DEVICE_SELECT, CB_SETCURSEL, m_HWDeviceIndex, 0);\n\n    return S_OK;\n}\n\nHRESULT CLAVVideoSettingsProp::UpdateYADIFOptions()\n{\n    DWORD dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_SWDEINT_MODE, CB_GETCURSEL, 0, 0);\n\n    EnableWindow(GetDlgItem(m_Dlg, IDC_LBL_SWDEINT_MODE), (dwVal != SWDeintMode_None));\n    EnableWindow(GetDlgItem(m_Dlg, IDC_SWDEINT_OUT_FILM), (dwVal != SWDeintMode_None));\n    EnableWindow(GetDlgItem(m_Dlg, IDC_SWDEINT_OUT_VIDEO), (dwVal != SWDeintMode_None));\n\n    return S_OK;\n}\n\nHRESULT CLAVVideoSettingsProp::LoadData()\n{\n    HRESULT hr = S_OK;\n\n    m_dwNumThreads = m_pVideoSettings->GetNumThreads();\n    m_StreamAR = m_pVideoSettings->GetStreamAR();\n    m_DeintFieldOrder = m_pVideoSettings->GetDeintFieldOrder();\n    m_DeintMode = m_pVideoSettings->GetDeinterlacingMode();\n    m_dwRGBOutput = m_pVideoSettings->GetRGBOutputRange();\n\n    for (int i = 0; i < LAVOutPixFmt_NB; ++i)\n    {\n        m_bPixFmts[i] = m_pVideoSettings->GetPixelFormat((LAVOutPixFmts)i);\n    }\n\n    m_HWAccel = m_pVideoSettings->GetHWAccel();\n    for (int i = 0; i < HWCodec_NB; ++i)\n    {\n        m_HWAccelCodecs[i] = m_pVideoSettings->GetHWAccelCodec((LAVVideoHWCodec)i);\n    }\n\n    m_HWRes = m_pVideoSettings->GetHWAccelResolutionFlags();\n    m_HWAccelCUVIDDXVA = m_pVideoSettings->GetHWAccelDeintHQ();\n\n    m_HWDeintAlgo = m_pVideoSettings->GetHWAccelDeintMode();\n    m_HWDeintOutMode = m_pVideoSettings->GetHWAccelDeintOutput();\n\n    m_SWDeint = m_pVideoSettings->GetSWDeintMode();\n    m_SWDeintOutMode = m_pVideoSettings->GetSWDeintOutput();\n\n    m_DitherMode = m_pVideoSettings->GetDitherMode();\n\n    m_TrayIcon = m_pVideoSettings->GetTrayIcon();\n\n    return hr;\n}\n\nINT_PTR CLAVVideoSettingsProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    LRESULT lValue;\n    BOOL bValue;\n    switch (uMsg)\n    {\n    case WM_COMMAND:\n        if (LOWORD(wParam) == IDC_STREAMAR && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != m_StreamAR)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_THREADS)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);\n            if (lValue != m_dwNumThreads)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_DEINT_FIELDORDER && HIWORD(wParam) == CBN_SELCHANGE)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);\n            if (lValue != m_DeintFieldOrder)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_DEINT_MODE && HIWORD(wParam) == CBN_SELCHANGE)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);\n            if (lValue != m_DeintMode)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_YV12 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_YV12])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_NV12 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_NV12])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_P010 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_P010])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_P016 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_P016])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_YUY2 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_YUY2])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_UYVY && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_UYVY])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_P210 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_P210])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_V210 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_v210])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_P216 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_P216])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_YV24 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_YV24])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_AYUV && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_AYUV])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_Y410 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_Y410])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_V410 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_v410])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_Y416 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_Y416])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_RGB32 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_RGB32])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_RGB24 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_RGB24])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_OUT_RGB48 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bPixFmts[LAVOutPixFmt_RGB48])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_RGBOUT_AUTO && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != (m_dwRGBOutput == 0))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_RGBOUT_TV && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != (m_dwRGBOutput == 1))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_RGBOUT_PC && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != (m_dwRGBOutput == 2))\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_HWACCEL)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), CB_GETITEMDATA, lValue, 0);\n            if (lValue != m_HWAccel)\n            {\n                SetDirty();\n            }\n            UpdateHWOptions();\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_H264 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCodecs[HWCodec_H264])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_VC1 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCodecs[HWCodec_VC1])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_MPEG2 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCodecs[HWCodec_MPEG2])\n            {\n                SetDirty();\n            }\n            UpdateHWOptions();\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_MPEG4 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCodecs[HWCodec_MPEG4])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_HEVC && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCodecs[HWCodec_HEVC])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_VP9 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCodecs[HWCodec_VP9])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_AV1 && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCodecs[HWCodec_AV1])\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_H264MVC && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCodecs[HWCodec_H264MVC])\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_HWACCEL_DEVICE_SELECT)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);\n            if (lValue != m_HWDeviceIndex)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWACCEL_CUVID_DXVA && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_HWAccelCUVIDDXVA)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWDEINT_ENABLE && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != (m_HWDeintAlgo == HWDeintMode_Hardware))\n            {\n                SetDirty();\n            }\n            UpdateHWOptions();\n        }\n        else if (LOWORD(wParam) == IDC_HWDEINT_OUT_FILM && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != (m_HWDeintOutMode == DeintOutput_FramePer2Field))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWDEINT_OUT_VIDEO && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != (m_HWDeintOutMode == DeintOutput_FramePerField))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_SWDEINT_OUT_FILM && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != (m_SWDeintOutMode == DeintOutput_FramePer2Field))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_SWDEINT_OUT_VIDEO && HIWORD(wParam) == BN_CLICKED)\n        {\n            bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != (m_SWDeintOutMode == DeintOutput_FramePerField))\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_SWDEINT_MODE)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), CB_GETCURSEL, 0, 0);\n            if (lValue != m_SWDeint)\n            {\n                SetDirty();\n            }\n            UpdateYADIFOptions();\n        }\n        else if (LOWORD(wParam) == IDC_DITHER_ORDERED && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != (m_DitherMode == LAVDither_Ordered))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_DITHER_RANDOM && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != (m_DitherMode == LAVDither_Random))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWRES_SD && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue == !(m_HWRes & LAVHWResFlag_SD))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWRES_HD && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue == !(m_HWRes & LAVHWResFlag_HD))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_HWRES_UHD && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue == !(m_HWRes & LAVHWResFlag_UHD))\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_TRAYICON && HIWORD(wParam) == BN_CLICKED)\n        {\n            lValue = SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (lValue != m_TrayIcon)\n            {\n                SetDirty();\n            }\n        }\n        break;\n    }\n    // Let the parent class handle the message.\n    return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n\n/////////////////////////////////////////////////////////////////////////////////////////////////////////\n// Format Configurations\n\nCLAVVideoFormatsProp::CLAVVideoFormatsProp(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseDSPropPage(NAME(\"LAVVideoFormats\"), pUnk, IDD_PROPPAGE_FORMATS, IDS_FORMATS)\n{\n}\n\nCLAVVideoFormatsProp::~CLAVVideoFormatsProp()\n{\n}\n\nHRESULT CLAVVideoFormatsProp::OnConnect(IUnknown *pUnk)\n{\n    if (pUnk == nullptr)\n    {\n        return E_POINTER;\n    }\n    ASSERT(m_pVideoSettings == nullptr);\n    return pUnk->QueryInterface(&m_pVideoSettings);\n}\n\nHRESULT CLAVVideoFormatsProp::OnDisconnect()\n{\n    SafeRelease(&m_pVideoSettings);\n    return S_OK;\n}\n\nHRESULT CLAVVideoFormatsProp::OnApplyChanges()\n{\n    ASSERT(m_pVideoSettings != nullptr);\n    HRESULT hr = S_OK;\n\n    HWND hlv = GetDlgItem(m_Dlg, IDC_CODECS);\n\n    // Get checked state\n    BOOL bFlag;\n    for (int nItem = 0; nItem < ListView_GetItemCount(hlv); nItem++)\n    {\n        bFlag = ListView_GetCheckState(hlv, nItem);\n        m_pVideoSettings->SetFormatConfiguration((LAVVideoCodec)nItem, bFlag);\n    }\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_CODECS_MSWMVDMO, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetUseMSWMV9Decoder(bFlag);\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_DVD_VIDEO, BM_GETCHECK, 0, 0);\n    m_pVideoSettings->SetDVDVideoSupport(bFlag);\n\n    LoadData();\n\n    return hr;\n}\n\nHRESULT CLAVVideoFormatsProp::OnActivate()\n{\n    HRESULT hr = S_OK;\n    INITCOMMONCONTROLSEX icc;\n    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);\n    icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES | ICC_LISTVIEW_CLASSES;\n    if (InitCommonControlsEx(&icc) == FALSE)\n    {\n        return E_FAIL;\n    }\n    ASSERT(m_pVideoSettings != nullptr);\n\n    // Setup ListView control for format configuration\n    SendDlgItemMessage(m_Dlg, IDC_CODECS, CCM_DPISCALE, TRUE, 0);\n\n    HWND hlv = GetDlgItem(m_Dlg, IDC_CODECS);\n    ListView_SetExtendedListViewStyle(hlv, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);\n\n    int nCol = 1;\n    LVCOLUMN lvc = {LVCF_WIDTH, 0, 20, 0};\n    ListView_InsertColumn(hlv, 0, &lvc);\n    ListView_AddCol(hlv, nCol, 85, L\"Codec\", false);\n    ListView_AddCol(hlv, nCol, 400, L\"Description\", false);\n\n    ListView_DeleteAllItems(hlv);\n    ListView_SetItemCount(hlv, Codec_VideoNB);\n\n    // Create entries for the formats\n    LVITEM lvi;\n    memset(&lvi, 0, sizeof(lvi));\n    lvi.mask = LVIF_TEXT | LVIF_PARAM;\n\n    int nItem = 0;\n    for (nItem = 0; nItem < Codec_VideoNB; ++nItem)\n    {\n        const codec_config_t *config = get_codec_config((LAVVideoCodec)nItem);\n\n        // Create main entry\n        lvi.iItem = nItem + 1;\n        ListView_InsertItem(hlv, &lvi);\n\n        // Set sub item texts\n        ATL::CA2W name(config->name);\n        ListView_SetItemText(hlv, nItem, 1, (LPWSTR)name);\n\n        ATL::CA2W desc(config->description);\n        ListView_SetItemText(hlv, nItem, 2, (LPWSTR)desc);\n    }\n\n    hr = LoadData();\n    if (SUCCEEDED(hr))\n    {\n        // Set checked state\n        for (nItem = 0; nItem < ListView_GetItemCount(hlv); nItem++)\n        {\n            ListView_SetCheckState(hlv, nItem, m_bFormats[nItem]);\n        }\n    }\n\n    SendDlgItemMessage(m_Dlg, IDC_CODECS_MSWMVDMO, BM_SETCHECK, m_bWMVDMO, 0);\n    SendDlgItemMessage(m_Dlg, IDC_DVD_VIDEO, BM_SETCHECK, m_bDVD, 0);\n\n    return hr;\n}\n\nHRESULT CLAVVideoFormatsProp::LoadData()\n{\n    HRESULT hr = S_OK;\n\n    for (unsigned i = 0; i < Codec_VideoNB; ++i)\n        m_bFormats[i] = m_pVideoSettings->GetFormatConfiguration((LAVVideoCodec)i) != 0;\n\n    m_bWMVDMO = m_pVideoSettings->GetUseMSWMV9Decoder();\n    m_bDVD = m_pVideoSettings->GetDVDVideoSupport();\n\n    return hr;\n}\n\nINT_PTR CLAVVideoFormatsProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    switch (uMsg)\n    {\n    case WM_COMMAND:\n        if (LOWORD(wParam) == IDC_CODECS_MSWMVDMO && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bWMVDMO)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_DVD_VIDEO && HIWORD(wParam) == BN_CLICKED)\n        {\n            BOOL bValue = (BOOL)SendDlgItemMessage(m_Dlg, LOWORD(wParam), BM_GETCHECK, 0, 0);\n            if (bValue != m_bDVD)\n            {\n                SetDirty();\n            }\n        }\n        break;\n    case WM_NOTIFY:\n        NMHDR *hdr = (LPNMHDR)lParam;\n        if (hdr->idFrom == IDC_CODECS)\n        {\n            switch (hdr->code)\n            {\n            case LVN_ITEMCHANGED:\n                LPNMLISTVIEW nmlv = (LPNMLISTVIEW)lParam;\n                BOOL check = ListView_GetCheckState(hdr->hwndFrom, nmlv->iItem);\n                if (check != m_bFormats[nmlv->iItem])\n                {\n                    SetDirty();\n                }\n                return TRUE;\n            }\n        }\n        break;\n    }\n    // Let the parent class handle the message.\n    return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n"
  },
  {
    "path": "decoder/LAVVideo/VideoSettingsProp.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"LAVVideoSettings.h\"\n#include \"BaseDSPropPage.h\"\n#include \"Media.h\"\n\n// {278407C2-558C-4BED-83A0-B6FA454200BD}\nDEFINE_GUID(CLSID_LAVVideoSettingsProp, 0x278407c2, 0x558c, 0x4bed, 0x83, 0xa0, 0xb6, 0xfa, 0x45, 0x42, 0x0, 0xbd);\n\n// {2D4D6F88-8B41-40A2-B297-3D722816648B}\nDEFINE_GUID(CLSID_LAVVideoFormatsProp, 0x2d4d6f88, 0x8b41, 0x40a2, 0xb2, 0x97, 0x3d, 0x72, 0x28, 0x16, 0x64, 0x8b);\n\nclass CLAVVideoSettingsProp : public CBaseDSPropPage\n{\n  public:\n    CLAVVideoSettingsProp(LPUNKNOWN pUnk, HRESULT *phr);\n    ~CLAVVideoSettingsProp();\n\n    HRESULT OnActivate();\n    HRESULT OnConnect(IUnknown *pUnk);\n    HRESULT OnDisconnect();\n    HRESULT OnApplyChanges();\n    INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    HRESULT LoadData();\n    HRESULT UpdateHWOptions();\n    HRESULT UpdateYADIFOptions();\n\n    void SetDirty()\n    {\n        m_bDirty = TRUE;\n        if (m_pPageSite)\n        {\n            m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);\n        }\n    }\n\n  private:\n    ILAVVideoSettings *m_pVideoSettings = nullptr;\n    ILAVVideoStatus *m_pVideoStatus = nullptr;\n\n    DWORD m_dwNumThreads;\n    DWORD m_StreamAR;\n    DWORD m_DeintFieldOrder;\n    LAVDeintMode m_DeintMode;\n    DWORD m_dwRGBOutput;\n\n    BOOL m_bPixFmts[LAVOutPixFmt_NB];\n    DWORD m_HWAccel;\n    BOOL m_HWAccelCodecs[HWCodec_NB];\n    BOOL m_HWAccelCUVIDDXVA;\n\n    DWORD m_HWRes;\n    DWORD m_HWDeviceIndex;\n\n    DWORD m_HWDeintAlgo;\n    DWORD m_HWDeintOutMode;\n    LAVSWDeintModes m_SWDeint;\n    DWORD m_SWDeintOutMode;\n\n    DWORD m_DitherMode;\n    BOOL m_TrayIcon;\n};\n\nclass CLAVVideoFormatsProp : public CBaseDSPropPage\n{\n  public:\n    CLAVVideoFormatsProp(LPUNKNOWN pUnk, HRESULT *phr);\n    ~CLAVVideoFormatsProp();\n\n    HRESULT OnActivate();\n    HRESULT OnConnect(IUnknown *pUnk);\n    HRESULT OnDisconnect();\n    HRESULT OnApplyChanges();\n    INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    HRESULT LoadData();\n\n    void SetDirty()\n    {\n        m_bDirty = TRUE;\n        if (m_pPageSite)\n        {\n            m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);\n        }\n    }\n\n  private:\n    ILAVVideoSettings *m_pVideoSettings = nullptr;\n\n    BOOL m_bFormats[Codec_VideoNB];\n    BOOL m_bWMVDMO;\n    BOOL m_bDVD;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/DecBase.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"ILAVDecoder.h\"\n#include \"DeCSS/DeCSSInputPin.h\"\n\nclass CDecBase : public ILAVDecoder\n{\n  public:\n    CDecBase(void) {}\n    virtual ~CDecBase(void) {}\n\n    STDMETHOD(Init)() PURE;\n    STDMETHOD(Decode)\n    (const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BOOL bSyncPoint,\n     BOOL bDiscontinuity, IMediaSample *pSample) PURE;\n\n    // ILAVDecoder\n    STDMETHODIMP InitInterfaces(ILAVVideoSettings *pSettings, ILAVVideoCallback *pCallback)\n    {\n        m_pSettings = pSettings;\n        m_pCallback = pCallback;\n        return Init();\n    }\n    STDMETHODIMP Check() { return S_FALSE; }\n    STDMETHODIMP_(REFERENCE_TIME) GetFrameDuration() { return 0; }\n    STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess) { return TRUE; }\n    STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc) { return E_NOTIMPL; }\n    STDMETHODIMP PostConnect(IPin *pPin) { return S_FALSE; }\n    STDMETHODIMP BreakConnect() { return S_FALSE; }\n    STDMETHODIMP_(long) GetBufferCount(long *pMaxBuffers = nullptr) { return 2; }\n\n    STDMETHODIMP HasThreadSafeBuffers() { return S_FALSE; }\n\n    STDMETHODIMP SetDirectOutput(BOOL bDirect) { return S_FALSE; }\n\n    STDMETHODIMP_(DWORD) GetHWAccelNumDevices() { return 0; }\n    STDMETHODIMP GetHWAccelDeviceInfo(DWORD dwIndex, BSTR *pstrDeviceName, DWORD *dwDeviceIdentifier)\n    {\n        return E_UNEXPECTED;\n    }\n    STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName) { return E_UNEXPECTED; }\n\n    STDMETHODIMP Decode(IMediaSample *pSample)\n    {\n        HRESULT hr;\n\n        // Retrieve buffer\n        BYTE *pData = nullptr;\n        if (FAILED(hr = pSample->GetPointer(&pData)))\n        {\n            return hr;\n        }\n\n        // Retrieve timestamps\n        REFERENCE_TIME rtStart, rtStop;\n        hr = pSample->GetTime(&rtStart, &rtStop);\n\n        if (FAILED(hr))\n        {\n            rtStart = rtStop = AV_NOPTS_VALUE;\n        }\n        else if (hr == VFW_S_NO_STOP_TIME || rtStop - 1 <= rtStart)\n        {\n            rtStop = AV_NOPTS_VALUE;\n        }\n\n        // DVD Stripping\n        long nSize = pSample->GetActualDataLength();\n        m_pCallback->DVDStripPacket(pData, nSize);\n\n        if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_SAGE_HACK)\n        {\n            FFSWAP(REFERENCE_TIME, rtStart, m_rtTimestampBuffer);\n            rtStop = AV_NOPTS_VALUE;\n        }\n\n        return Decode(pData, nSize, rtStart, rtStop, pSample->IsSyncPoint() == S_OK, pSample->IsDiscontinuity() == S_OK,\n                      pSample);\n    }\n\n    STDMETHODIMP Flush()\n    {\n        m_rtTimestampBuffer = 0;\n        m_MpegParserState = (uint32_t)-1;\n        return S_OK;\n    };\n\n  protected:\n    // Convenience wrapper around m_pCallback\n    inline HRESULT Deliver(LAVFrame *pFrame) { return m_pCallback->Deliver(pFrame); }\n\n    inline HRESULT AllocateFrame(LAVFrame **ppFrame) { return m_pCallback->AllocateFrame(ppFrame); }\n\n    inline HRESULT ReleaseFrame(LAVFrame **ppFrame) { return m_pCallback->ReleaseFrame(ppFrame); }\n\n  protected:\n    ILAVVideoSettings *m_pSettings = nullptr;\n    ILAVVideoCallback *m_pCallback = nullptr;\n\n    REFERENCE_TIME m_rtTimestampBuffer = AV_NOPTS_VALUE;\n\n    uint32_t m_MpegParserState = (uint32_t)-1;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/ILAVDecoder.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"LAVVideoSettings.h\"\n#include \"ILAVPinInfo.h\"\n\n/**\n * List of internally used pixel formats\n *\n * Note for high bit-depth formats:\n * All bX (9-16 bit) formats always use 2 bytes, are little-endian, and the values are right-aligned.\n * That means that there are leading zero-bits, and not trailing like in DirectShow\n * The actual number of valid bits is stored in the LAVFrame\n */\n// clang-format off\ntypedef enum LAVPixelFormat {\n    LAVPixFmt_None = -1,\n    /* planar YUV */\n    LAVPixFmt_YUV420,      ///< YUV 4:2:0, 8 bit\n    LAVPixFmt_YUV420bX,    ///< YUV 4:2:0, 9-16 bit\n\n    LAVPixFmt_YUV422,      ///< YUV 4:2:2, 8 bit\n    LAVPixFmt_YUV422bX,    ///< YUV 4:2:2, 9-16 bit\n\n    LAVPixFmt_YUV444,      ///< YUV 4:4:4, 8 bit\n    LAVPixFmt_YUV444bX,    ///< YUV 4:4:4, 9-16 bit\n\n    /* packed/half-packed YUV */\n    LAVPixFmt_NV12,        ///< YUV 4:2:0, U/V interleaved\n    LAVPixFmt_YUY2,        ///< YUV 4:2:2, packed, YUYV order\n    LAVPixFmt_P016,        ///< YUV 4:2:0, 10 to 16-bit, U/V interleaved, MSB aligned\n\n    /* RGB */\n    LAVPixFmt_RGB24,       ///< RGB24, in BGR order\n    LAVPixFmt_RGB32,       ///< RGB32, in BGRA order (A is invalid and should be 0xFF)\n    LAVPixFmt_ARGB32,      ///< ARGB32, in BGRA order\n    LAVPixFmt_RGB48,       ///< RGB48, in RGB order (16-bit per pixel)\n\n    /* HW formats */\n    LAVPixFmt_AYUV,        ///< AYUV, 4:4:4 8-bit\n    LAVPixFmt_Y410,        ///< Y410, 4:4:4 10-bit packed into 32-bit, AVYU order (A is 2 bit)\n    LAVPixFmt_Y416,        ///< Y416, 4:4:4 16-bit, AVYU order\n    LAVPixFmt_Y216,        ///< Y210/Y216, 4:2:2, 10 to 16-bit packed into 64-bit, Y0/U/Y1/V\n\n    LAVPixFmt_HWFormats,\n    LAVPixFmt_DXVA2 = LAVPixFmt_HWFormats, ///< DXVA2 Surface\n    LAVPixFmt_D3D11,       ///< D3D11 Surface\n\n    LAVPixFmt_NB,          ///< number of formats\n} LAVPixelFormat;\n// clang-format on\n\n/**\n * Structure describing a pixel format\n */\ntypedef struct LAVPixFmtDesc\n{\n    int codedbytes;     ///< coded byte per pixel in one plane (for packed and multibyte formats)\n    int planes;         ///< number of planes\n    int planeWidth[4];  ///< log2 width factor\n    int planeHeight[4]; ///< log2 height factor\n} LAVPixFmtDesc;\n\n/**\n * Get the Pixel Format Descriptor for the given format\n */\nLAVPixFmtDesc getPixelFormatDesc(LAVPixelFormat pixFmt);\n\n/**\n * Map the LAV Pixel Format to a FFMpeg pixel format (for swscale, etc)\n */\nAVPixelFormat getFFPixelFormatFromLAV(LAVPixelFormat pixFmt, int bpp);\n\ntypedef struct LAVDirectBuffer\n{\n    BYTE *data[4];       ///< pointer to the picture planes\n    ptrdiff_t stride[4]; ///< stride of the planes (in bytes)\n\n    UINT Width, Height;  ///< width/height of the locked texture\n} LAVDirectBuffer;\n\ntypedef struct LAVFrameSideData\n{\n    GUID guidType; ///< type of the side data\n    BYTE *data;    ///< side data\n    size_t size;   ///< size\n} LAVFrameSideData;\n\n/**\n * A Video Frame\n *\n * Allocated by the decoder and passed through the processing chain.\n *\n * The Decoder should allocate frames by using ILAVVideoCallback::AllocateFrame()\n * Frames need to be free'd with ILAVVideoCallback::ReleaseFrame()\n *\n * FIXME: Right now the avcodec decoder always reuses the buffers the next time its called!\n * NYI: Some Post-Processing filters will require to hang on to frames longer then the normal delivery process.\n * NYI: That means that the image buffers should not be re-used unless \"destruct\" released them.\n */\ntypedef struct LAVFrame\n{\n    int width;  ///< width of the frame (in pixel)\n    int height; ///< height of the frame (in pixel)\n\n    BYTE *data[4];       ///< pointer to the picture planes\n    BYTE *stereo[4];     ///< pointer to the second view picture planes\n    ptrdiff_t stride[4]; ///< stride of the planes (in bytes)\n\n    LAVPixelFormat format; ///< pixel format of the frame\n    LAVPixelFormat sw_format;\n    int bpp;               ///< bits per pixel, only meaningful for YUV420bX, YUV422bX or YUV444bX\n\n    REFERENCE_TIME rtStart; ///< start time of the frame. unset if AV_NOPTS_VALUE\n    REFERENCE_TIME rtStop;  ///< stop time of the frame. unset if AV_NOPTS_VALUE\n    int repeat;             ///< repeat frame flag, signals how much the frame should be delayed\n\n    AVRational aspect_ratio;         ///< display aspect ratio (unset/invalid if either num or den is 0)\n    REFERENCE_TIME avgFrameDuration; ///< frame duration used for the media type to indicate fps (AV_NOPTS_VALUE or 0 =\n                                     ///< use from input pin)\n\n    DXVA2_ExtendedFormat ext_format; ///< extended format flags (critical uses: indicate progressive/interlaced,\n                                     ///< indicate limited/full range)\n    int key_frame;                   ///< frame is a key frame (field is not mandatory)\n    int interlaced;                  ///< frame is interlaced\n    int tff;                         ///< top field is first\n    char frame_type;                 ///< frame type char (I/P/B/?)\n\n    int flags; ///< frame flags\n#define LAV_FRAME_FLAG_BUFFER_MODIFY 0x00000001\n#define LAV_FRAME_FLAG_END_OF_SEQUENCE 0x00000002\n#define LAV_FRAME_FLAG_FLUSH 0x00000004\n#define LAV_FRAME_FLAG_REDRAW 0x00000008\n#define LAV_FRAME_FLAG_DXVA_NOADDREF 0x00000010\n#define LAV_FRAME_FLAG_MVC 0x00000020\n\n    LAVFrameSideData *side_data;\n    int side_data_count;\n\n    /* destruct function to free any buffers being held by this frame (may be null) */\n    void (*destruct)(struct LAVFrame *);\n    void *priv_data; ///< private data from the decoder (mostly for destruct)\n\n    bool direct;\n    bool (*direct_lock)(struct LAVFrame *, struct LAVDirectBuffer *);\n    void (*direct_unlock)(struct LAVFrame *);\n} LAVFrame;\n\n/**\n * Allocate buffers for the LAVFrame \"data\" element to fit the pixfmt with the given stride\n *\n * This method also fills the stride argument in the LAVFrame properly.\n * Its required that width/height and format are already set on the frame.\n *\n * @param pFrame Frame to fill\n * @param stride stride to use (in pixel). If 0, a stride will be computed to fill usual alignment rules\n * @return HRESULT\n */\nHRESULT AllocLAVFrameBuffers(LAVFrame *pFrame, ptrdiff_t stride = 0);\n\n/**\n * Destruct a LAV Frame, freeing its data pointers\n */\nHRESULT FreeLAVFrameBuffers(LAVFrame *pFrame);\n\n/**\n * Copy a LAV Frame, including a memcpy of the data\n */\nHRESULT CopyLAVFrame(LAVFrame *pSrc, LAVFrame **ppDst);\n\n/**\n * Copy the buffers in the LAV Frame, calling destruct on the old buffers.\n *\n * Usually useful to release decoder-specific buffers, and move to memory buffers\n */\nHRESULT CopyLAVFrameInPlace(LAVFrame *pFrame);\n\n/**\n * Add Side Data to the frame and return a pointer to it\n */\nBYTE *AddLAVFrameSideData(LAVFrame *pFrame, GUID guidType, size_t size);\n\n/**\n * Get a side data entry from the frame by its type\n */\nBYTE *GetLAVFrameSideData(LAVFrame *pFrame, GUID guidType, size_t *pSize);\n\n/**\n * Validate that the frame has the correct number of allocated buffers\n */\nbool ValidateLAVFrameBuffers(LAVFrame *pFrame);\n\ntypedef struct LAVPinInfo\n{\n    DWORD flags;           ///< Flags that describe the video content (see ILAVPinInfo.h for valid values)\n    AVPixelFormat pix_fmt; ///< The pixel format used\n    int has_b_frames;\n} LAVPinInfo;\n\n/**\n * Interface into the LAV Video core for the decoder implementations\n * This interface offers all required functions to properly communicate with the core\n */\ninterface ILAVVideoCallback\n{\n    /**\n     * Allocate and initialize a new frame\n     *\n     * @param ppFrame variable to receive the frame\n     * @return HRESULT\n     */\n    STDMETHOD(AllocateFrame)(LAVFrame * *ppFrame) PURE;\n\n    /**\n     * Destruct and release frame\n     * This function calls the \"destruct\" function on the frame, and releases it afterwards\n     *\n     * @param ppFrame variable of the frame, will be nulled\n     * @return HRESULT\n     */\n    STDMETHOD(ReleaseFrame)(LAVFrame * *ppFrame) PURE;\n\n    /**\n     * Deliver the frame\n     * The decoder gives up control of the frame at this point, and hands it over to the processing chain\n     *\n     * @param pFrame frame to deliver\n     * @return HRESULT\n     */\n    STDMETHOD(Deliver)(LAVFrame * pFrame) PURE;\n\n    /**\n     * Get the extension of the currently loaded file\n     *\n     * @result WCHAR string to the extension. Callers needs to free the memory with CoTaskMemFree\n     */\n    STDMETHOD_(LPWSTR, GetFileExtension)() PURE;\n\n    /**\n     * Get Decode Flags\n     *\n     * @return flags\n     */\n    STDMETHOD_(DWORD, GetDecodeFlags)() PURE;\n#define LAV_VIDEO_DEC_FLAG_STREAMAR_BLACKLIST 0x00000001\n#define LAV_VIDEO_DEC_FLAG_ONLY_DTS 0x00000002\n#define LAV_VIDEO_DEC_FLAG_LAVSPLITTER 0x00000008\n#define LAV_VIDEO_DEC_FLAG_DVD 0x00000010\n#define LAV_VIDEO_DEC_FLAG_NO_MT 0x00000020\n#define LAV_VIDEO_DEC_FLAG_SAGE_HACK 0x00000040\n#define LAV_VIDEO_DEC_FLAG_LIVE 0x00000080\n\n    /**\n     * Get the input media type\n     *\n     * @result media type\n     */\n    STDMETHOD_(CMediaType &, GetInputMediaType)() PURE;\n\n    /**\n     * Query the LAVPinInfo\n     */\n    STDMETHOD(GetLAVPinInfo)(LAVPinInfo & info) PURE;\n\n    /**\n     * Get a reference to the output pin\n     */\n    STDMETHOD_(CBasePin *, GetOutputPin)() PURE;\n\n    /**\n     * Get the output media type\n     *\n     * @result media type\n     */\n    STDMETHOD_(CMediaType &, GetOutputMediaType)() PURE;\n\n    /**\n     * Strip the packet for DVD decoding\n     */\n    STDMETHOD(DVDStripPacket)(BYTE * &p, long &len) PURE;\n\n    /**\n     * Get a Dummy frame used for flusing\n     */\n    STDMETHOD_(LAVFrame *, GetFlushFrame)() PURE;\n\n    /**\n     * Ask the decoder to release all DXVA resources\n     */\n    STDMETHOD(ReleaseAllDXVAResources)() PURE;\n\n    /**\n     * Get the index of the GPU device to be used for HW decoding, DWORD_MAX if not set\n     */\n    STDMETHOD_(DWORD, GetGPUDeviceIndex)() PURE;\n\n    /**\n     * Check if the input is using a dynamic allocator\n     */\n    STDMETHOD_(BOOL, HasDynamicInputAllocator)() PURE;\n\n    /**\n     * Set the x264 build info\n     */\n    STDMETHOD(SetX264Build)(int nBuild) PURE;\n\n    /**\n     * Get the x264 build info\n     */\n    STDMETHOD_(int, GetX264Build)() PURE;\n};\n\n/**\n * Decoder interface\n *\n * Every decoder needs to implement this to interface with the LAV Video core\n */\ninterface ILAVDecoder\n{\n    /**\n     * Virtual destructor\n     */\n    virtual ~ILAVDecoder(void){};\n\n    /**\n     * Initialize interfaces with the LAV Video core\n     * This function should also be used to create all interfaces with external DLLs\n     *\n     * @param pSettings reference to the settings interface\n     * @param pCallback reference to the callback interface\n     * @return S_OK on success, error code if this decoder is lacking an external support dll\n     */\n    STDMETHOD(InitInterfaces)(ILAVVideoSettings * pSettings, ILAVVideoCallback * pCallback) PURE;\n\n    /**\n     * Check if the decoder is functional\n     */\n    STDMETHOD(Check)() PURE;\n\n    /**\n     * Initialize the codec to decode a stream specified by codec and pmt.\n     *\n     * @param codec Codec Id\n     * @param pmt DirectShow Media Type\n     * @return S_OK on success, an error code otherwise\n     */\n    STDMETHOD(InitDecoder)(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData) PURE;\n\n    /**\n     * Decode a frame.\n     *\n     * @param pSample Media Sample to decode\n     * @return S_OK if decoding was successful, S_FALSE if no frame could be extracted, an error code if the decoder is\n     * not compatible with the bitstream\n     *\n     * Note: When returning an actual error code, the filter will switch to the fallback software decoder! This should\n     * only be used for catastrophic failures, like trying to decode a unsupported format on a hardware decoder.\n     */\n    STDMETHOD(Decode)(IMediaSample * pSample) PURE;\n\n    /**\n     * Flush the decoder after a seek.\n     * The decoder should discard any remaining data.\n     *\n     * @return unused\n     */\n    STDMETHOD(Flush)() PURE;\n\n    /**\n     * End of Stream\n     * The decoder is asked to output any buffered frames for immediate delivery\n     *\n     * @return unused\n     */\n    STDMETHOD(EndOfStream)() PURE;\n\n    /**\n     * Query the decoder for the current pixel format\n     * Mostly used by the media type creation logic before playback starts\n     *\n     * @return the pixel format used in the decoding process\n     */\n    STDMETHOD(GetPixelFormat)(LAVPixelFormat * pPix, int *pBpp, LAVPixelFormat *pPixSoftware) PURE;\n\n    /**\n     * Get the frame duration.\n     *\n     * This function is not mandatory, and if you cannot provide any specific duration, return 0.\n     */\n    STDMETHOD_(REFERENCE_TIME, GetFrameDuration)() PURE;\n\n    /**\n     * Query whether the format can potentially be interlaced.\n     * This function should return false if the format can 100% not be interlaced, and true if it can be interlaced (but\n     * also progressive).\n     */\n    STDMETHOD_(BOOL, IsInterlaced)(BOOL bAllowGuess) PURE;\n\n    /**\n     * Allows the decoder to handle an allocator.\n     * Used by DXVA2 decoding\n     */\n    STDMETHOD(InitAllocator)(IMemAllocator * *ppAlloc) PURE;\n\n    /**\n     * Function called after connection is established, with the pin as argument\n     */\n    STDMETHOD(PostConnect)(IPin * pPin) PURE;\n\n    /**\n     * Notify the decoder the output connection was broken\n     */\n    STDMETHOD(BreakConnect)() PURE;\n\n    /**\n     * Get the number of sample buffers optimal for this decoder\n     */\n    STDMETHOD_(long, GetBufferCount)(long *pMaxBuffers = nullptr) PURE;\n\n    /**\n     * Get the name of the decoder\n     */\n    STDMETHOD_(const WCHAR *, GetDecoderName)() PURE;\n\n    /**\n     * Get whether the decoder outputs thread-safe buffers\n     */\n    STDMETHOD(HasThreadSafeBuffers)() PURE;\n\n    /**\n     * Toggle direct frame output mode for hardware decoders\n     */\n    STDMETHOD(SetDirectOutput)(BOOL bDirect) PURE;\n\n    /**\n     * Get the number of available hw accel devices\n     */\n    STDMETHOD_(DWORD, GetHWAccelNumDevices)() PURE;\n\n    /**\n     * Get information about a hwaccel device\n     */\n    STDMETHOD(GetHWAccelDeviceInfo)(DWORD dwIndex, BSTR * pstrDeviceName, DWORD * dwDeviceIdentifier) PURE;\n\n    /**\n     * Get the description of the currently active hwaccel device\n     */\n    STDMETHOD(GetHWAccelActiveDevice)(BSTR * pstrDeviceName) PURE;\n};\n\n/**\n * Decoder creation functions\n *\n * They are listed here so that including their header files is not required\n */\nILAVDecoder *CreateDecoderAVCodec();\nILAVDecoder *CreateDecoderWMV9MFT();\nILAVDecoder *CreateDecoderCUVID();\nILAVDecoder *CreateDecoderQuickSync();\nILAVDecoder *CreateDecoderDXVA2();\nILAVDecoder *CreateDecoderDXVA2Native();\nILAVDecoder *CreateDecoderD3D11();\nILAVDecoder *CreateDecoderMSDKMVC();\n\nHRESULT VerifyD3D9Device(DWORD &dwIndex, DWORD dwDeviceId);\nHRESULT VerifyD3D11Device(DWORD &dwIndex, DWORD dwDeviceId);\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/avcodec.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"avcodec.h\"\n\n#include \"moreuuids.h\"\n#include \"parsers/MPEG2HeaderParser.h\"\n#include \"parsers/H264SequenceParser.h\"\n#include \"parsers/VC1HeaderParser.h\"\n\n#include \"Media.h\"\n#include \"IMediaSideData.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n#include \"ByteParser.h\"\n\n#ifdef DEBUG\n#include \"lavf_log.h\"\n#endif\n\nextern \"C\"\n{\n#include \"libavutil/pixdesc.h\"\n#include \"libavutil/mastering_display_metadata.h\"\n#include \"libavutil/hdr_dynamic_metadata.h\"\n#include \"libavutil/dovi_meta.h\"\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// Constructor\n////////////////////////////////////////////////////////////////////////////////\n\nILAVDecoder *CreateDecoderAVCodec()\n{\n    return new CDecAvcodec();\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Create DXVA2 Extended Flags from a AVFrame and AVCodecContext\n////////////////////////////////////////////////////////////////////////////////\n\nstatic DXVA2_ExtendedFormat GetDXVA2ExtendedFlags(AVFrame *frame)\n{\n    DXVA2_ExtendedFormat fmt;\n    ZeroMemory(&fmt, sizeof(fmt));\n\n    fillDXVAExtFormat(fmt, -1, frame->color_primaries, frame->colorspace, frame->color_trc, frame->chroma_location);\n\n    if (frame->format == AV_PIX_FMT_XYZ12LE || frame->format == AV_PIX_FMT_XYZ12BE)\n        fmt.VideoPrimaries = DXVA2_VideoPrimaries_BT709;\n\n    // Color Range, 0-255 or 16-235\n    BOOL ffFullRange = (frame->color_range == AVCOL_RANGE_JPEG) || frame->format == AV_PIX_FMT_YUVJ420P ||\n                       frame->format == AV_PIX_FMT_YUVJ422P || frame->format == AV_PIX_FMT_YUVJ444P ||\n                       frame->format == AV_PIX_FMT_YUVJ440P || frame->format == AV_PIX_FMT_YUVJ411P;\n    fmt.NominalRange =\n        ffFullRange ? DXVA2_NominalRange_0_255\n                       : (frame->color_range == AVCOL_RANGE_MPEG) ? DXVA2_NominalRange_16_235\n                                                                  : DXVA2_NominalRange_Unknown;\n\n    return fmt;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// avcodec -> LAV codec mappings\n////////////////////////////////////////////////////////////////////////////////\n\n// This mapping table should contain all pixel formats, except hardware formats (VDPAU, XVMC, DXVA, etc)\n// A format that is not listed will be converted to YUV420\nstatic struct PixelFormatMapping\n{\n    AVPixelFormat ffpixfmt;\n    LAVPixelFormat lavpixfmt;\n    BOOL conversion;\n    int bpp;\n} ff_pix_map[] = {\n    {AV_PIX_FMT_YUV420P, LAVPixFmt_YUV420, FALSE},\n    {AV_PIX_FMT_YUYV422, LAVPixFmt_YUY2, FALSE},\n    {AV_PIX_FMT_BGR24, LAVPixFmt_RGB24, FALSE},\n    {AV_PIX_FMT_YUV422P, LAVPixFmt_YUV422, FALSE},\n    {AV_PIX_FMT_YUV444P, LAVPixFmt_YUV444, FALSE},\n    {AV_PIX_FMT_YUVJ420P, LAVPixFmt_YUV420, FALSE},\n    {AV_PIX_FMT_YUVJ422P, LAVPixFmt_YUV422, FALSE},\n    {AV_PIX_FMT_YUVJ444P, LAVPixFmt_YUV444, FALSE},\n\n    {AV_PIX_FMT_NV12, LAVPixFmt_NV12, FALSE},\n    {AV_PIX_FMT_NV21, LAVPixFmt_NV12, TRUE},\n\n    {AV_PIX_FMT_BGRA, LAVPixFmt_ARGB32, FALSE},\n    {AV_PIX_FMT_RGB48LE, LAVPixFmt_RGB48, FALSE},\n\n    {AV_PIX_FMT_YUV420P16LE, LAVPixFmt_YUV420bX, FALSE, 16},\n    {AV_PIX_FMT_YUV420P16BE, LAVPixFmt_YUV420bX, TRUE, 16},\n    {AV_PIX_FMT_YUV422P16LE, LAVPixFmt_YUV422bX, FALSE, 16},\n    {AV_PIX_FMT_YUV422P16BE, LAVPixFmt_YUV422bX, TRUE, 16},\n    {AV_PIX_FMT_YUV444P16LE, LAVPixFmt_YUV444bX, FALSE, 16},\n    {AV_PIX_FMT_YUV444P16BE, LAVPixFmt_YUV444bX, TRUE, 16},\n\n    {AV_PIX_FMT_YUV420P9BE, LAVPixFmt_YUV420bX, TRUE, 9},\n    {AV_PIX_FMT_YUV420P9LE, LAVPixFmt_YUV420bX, FALSE, 9},\n    {AV_PIX_FMT_YUV420P10BE, LAVPixFmt_YUV420bX, TRUE, 10},\n    {AV_PIX_FMT_YUV420P10LE, LAVPixFmt_YUV420bX, FALSE, 10},\n    {AV_PIX_FMT_YUV422P10BE, LAVPixFmt_YUV422bX, TRUE, 10},\n    {AV_PIX_FMT_YUV422P10LE, LAVPixFmt_YUV422bX, FALSE, 10},\n    {AV_PIX_FMT_YUV444P9BE, LAVPixFmt_YUV444bX, TRUE, 9},\n    {AV_PIX_FMT_YUV444P9LE, LAVPixFmt_YUV444bX, FALSE, 9},\n    {AV_PIX_FMT_YUV444P10BE, LAVPixFmt_YUV444bX, TRUE, 10},\n    {AV_PIX_FMT_YUV444P10LE, LAVPixFmt_YUV444bX, FALSE, 10},\n    {AV_PIX_FMT_YUV422P9BE, LAVPixFmt_YUV422bX, TRUE, 9},\n    {AV_PIX_FMT_YUV422P9LE, LAVPixFmt_YUV422bX, FALSE, 9},\n\n    {AV_PIX_FMT_YUVA420P9BE, LAVPixFmt_YUV420bX, TRUE, 9},\n    {AV_PIX_FMT_YUVA420P9LE, LAVPixFmt_YUV420bX, FALSE, 9},\n    {AV_PIX_FMT_YUVA422P9BE, LAVPixFmt_YUV422bX, TRUE, 9},\n    {AV_PIX_FMT_YUVA422P9LE, LAVPixFmt_YUV422bX, FALSE, 9},\n    {AV_PIX_FMT_YUVA444P9BE, LAVPixFmt_YUV444bX, TRUE, 9},\n    {AV_PIX_FMT_YUVA444P9LE, LAVPixFmt_YUV444bX, FALSE, 9},\n    {AV_PIX_FMT_YUVA420P10BE, LAVPixFmt_YUV420bX, TRUE, 10},\n    {AV_PIX_FMT_YUVA420P10LE, LAVPixFmt_YUV420bX, FALSE, 10},\n    {AV_PIX_FMT_YUVA422P10BE, LAVPixFmt_YUV422bX, TRUE, 10},\n    {AV_PIX_FMT_YUVA422P10LE, LAVPixFmt_YUV422bX, FALSE, 10},\n    {AV_PIX_FMT_YUVA444P10BE, LAVPixFmt_YUV444bX, TRUE, 10},\n    {AV_PIX_FMT_YUVA444P10LE, LAVPixFmt_YUV444bX, FALSE, 10},\n    {AV_PIX_FMT_YUVA420P16BE, LAVPixFmt_YUV420bX, TRUE, 16},\n    {AV_PIX_FMT_YUVA420P16LE, LAVPixFmt_YUV420bX, FALSE, 16},\n    {AV_PIX_FMT_YUVA422P16BE, LAVPixFmt_YUV422bX, TRUE, 16},\n    {AV_PIX_FMT_YUVA422P16LE, LAVPixFmt_YUV422bX, FALSE, 16},\n    {AV_PIX_FMT_YUVA444P16BE, LAVPixFmt_YUV444bX, TRUE, 16},\n    {AV_PIX_FMT_YUVA444P16LE, LAVPixFmt_YUV444bX, FALSE, 16},\n\n    {AV_PIX_FMT_BGR0, LAVPixFmt_RGB32, FALSE},\n\n    {AV_PIX_FMT_YUV420P12BE, LAVPixFmt_YUV420bX, TRUE, 12},\n    {AV_PIX_FMT_YUV420P12LE, LAVPixFmt_YUV420bX, FALSE, 12},\n    {AV_PIX_FMT_YUV420P14BE, LAVPixFmt_YUV420bX, TRUE, 14},\n    {AV_PIX_FMT_YUV420P14LE, LAVPixFmt_YUV420bX, FALSE, 14},\n    {AV_PIX_FMT_YUV422P12BE, LAVPixFmt_YUV422bX, TRUE, 12},\n    {AV_PIX_FMT_YUV422P12LE, LAVPixFmt_YUV422bX, FALSE, 12},\n    {AV_PIX_FMT_YUV422P14BE, LAVPixFmt_YUV422bX, TRUE, 14},\n    {AV_PIX_FMT_YUV422P14LE, LAVPixFmt_YUV422bX, FALSE, 14},\n    {AV_PIX_FMT_YUV444P12BE, LAVPixFmt_YUV444bX, TRUE, 12},\n    {AV_PIX_FMT_YUV444P12LE, LAVPixFmt_YUV444bX, FALSE, 12},\n    {AV_PIX_FMT_YUV444P14BE, LAVPixFmt_YUV444bX, TRUE, 14},\n    {AV_PIX_FMT_YUV444P14LE, LAVPixFmt_YUV444bX, FALSE, 14},\n\n    {AV_PIX_FMT_P010LE, LAVPixFmt_P016, FALSE, 10},\n    {AV_PIX_FMT_P010BE, LAVPixFmt_P016, TRUE, 10},\n\n    {AV_PIX_FMT_P016LE, LAVPixFmt_P016, FALSE, 16},\n    {AV_PIX_FMT_P016BE, LAVPixFmt_P016, TRUE, 16},\n\n    {AV_PIX_FMT_YUVA422P12BE, LAVPixFmt_YUV422bX, TRUE, 12},\n    {AV_PIX_FMT_YUVA422P12LE, LAVPixFmt_YUV422bX, FALSE, 12},\n    {AV_PIX_FMT_YUVA444P12BE, LAVPixFmt_YUV444bX, TRUE, 12},\n    {AV_PIX_FMT_YUVA444P12LE, LAVPixFmt_YUV444bX, FALSE, 12},\n\n    {AV_PIX_FMT_Y210BE, LAVPixFmt_Y216, TRUE, 10},\n    {AV_PIX_FMT_Y210LE, LAVPixFmt_Y216, FALSE, 10},\n\n    {AV_PIX_FMT_VUYA, LAVPixFmt_AYUV, FALSE},\n    {AV_PIX_FMT_VUYX, LAVPixFmt_AYUV, FALSE},\n\n    {AV_PIX_FMT_P012LE, LAVPixFmt_P016, FALSE, 12},\n    {AV_PIX_FMT_P012BE, LAVPixFmt_P016, TRUE, 12},\n\n    {AV_PIX_FMT_Y212BE, LAVPixFmt_Y216, TRUE, 12},\n    {AV_PIX_FMT_Y212LE, LAVPixFmt_Y216, FALSE, 12},\n\n    {AV_PIX_FMT_XV30BE, LAVPixFmt_Y410, TRUE, 10},\n    {AV_PIX_FMT_XV30LE, LAVPixFmt_Y410, FALSE, 10},\n\n    {AV_PIX_FMT_XV48BE, LAVPixFmt_Y416, TRUE, 10},\n    {AV_PIX_FMT_XV48LE, LAVPixFmt_Y416, FALSE, 10},\n\n    {AV_PIX_FMT_Y216BE, LAVPixFmt_Y216, TRUE, 16},\n    {AV_PIX_FMT_Y216LE, LAVPixFmt_Y216, FALSE, 16},\n\n    {AV_PIX_FMT_DXVA2_VLD, LAVPixFmt_DXVA2, FALSE},\n    {AV_PIX_FMT_D3D11, LAVPixFmt_D3D11, FALSE},\n};\n\nstatic AVCodecID ff_interlace_capable[] = {AV_CODEC_ID_DNXHD,  AV_CODEC_ID_DVVIDEO,  AV_CODEC_ID_FRWU,\n                                           AV_CODEC_ID_MJPEG,  AV_CODEC_ID_MPEG4,    AV_CODEC_ID_MPEG2VIDEO,\n                                           AV_CODEC_ID_H264,   AV_CODEC_ID_VC1,      AV_CODEC_ID_PNG,\n                                           AV_CODEC_ID_PRORES, AV_CODEC_ID_RAWVIDEO, AV_CODEC_ID_UTVIDEO};\n\nstatic struct PixelFormatMapping getPixFmtMapping(AVPixelFormat pixfmt)\n{\n    const PixelFormatMapping def = {pixfmt, LAVPixFmt_YUV420, TRUE, 8};\n    PixelFormatMapping result = { AV_PIX_FMT_NONE };\n    for (int i = 0; i < countof(ff_pix_map); i++)\n    {\n        if (ff_pix_map[i].ffpixfmt == pixfmt)\n        {\n            result = ff_pix_map[i];\n            break;\n        }\n    }\n\n    // use a heuristic if there was no perfect match\n    if (result.ffpixfmt == AV_PIX_FMT_NONE)\n    {\n        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pixfmt);\n        if (desc == nullptr)\n        {\n            result = def;\n        }\n        else\n        {\n            // RGB formats (or PAL)\n            if (desc->flags & (AV_PIX_FMT_FLAG_RGB | AV_PIX_FMT_FLAG_PAL))\n            {\n                if (desc->comp[0].depth > 8)\n                    result = {pixfmt, LAVPixFmt_RGB48, TRUE};\n                else\n                    result = {pixfmt, LAVPixFmt_RGB32, TRUE};\n            }\n            else\n            {\n                // 420 and 410 (and gray)\n                if ((desc->log2_chroma_w && desc->log2_chroma_h) || desc->nb_components == 1)\n                {\n                    if (desc->comp[0].depth > 8)\n                        result = {pixfmt, LAVPixFmt_YUV420bX, TRUE, desc->comp[0].depth};\n                    else\n                        result = {pixfmt, LAVPixFmt_YUV420, TRUE};\n                }\n                else if (desc->log2_chroma_w) // 422 and 411\n                {\n                    if (desc->comp[0].depth > 8)\n                        result = {pixfmt, LAVPixFmt_YUV422bX, TRUE, desc->comp[0].depth};\n                    else\n                        result = {pixfmt, LAVPixFmt_YUV422, TRUE};\n                }\n                else // 444 and others\n                {\n                    if (desc->comp[0].depth > 8)\n                        result = {pixfmt, LAVPixFmt_YUV444bX, TRUE, desc->comp[0].depth};\n                    else\n                        result = {pixfmt, LAVPixFmt_YUV444, TRUE};\n                }\n            }\n\n        }\n    }\n\n    if (result.lavpixfmt != LAVPixFmt_YUV420bX && result.lavpixfmt != LAVPixFmt_YUV422bX &&\n        result.lavpixfmt != LAVPixFmt_YUV444bX && result.lavpixfmt != LAVPixFmt_P016 &&\n        result.lavpixfmt != LAVPixFmt_Y216)\n        result.bpp = 8;\n\n    return result;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// AVCodec decoder implementation\n////////////////////////////////////////////////////////////////////////////////\n\nCDecAvcodec::CDecAvcodec(void)\n    : CDecBase()\n{\n}\n\nCDecAvcodec::~CDecAvcodec(void)\n{\n    DestroyDecoder();\n}\n\n// ILAVDecoder\nSTDMETHODIMP CDecAvcodec::Init()\n{\n#ifdef DEBUG\n    DbgSetModuleLevel(LOG_CUSTOM1, DWORD_MAX); // FFMPEG messages use custom1\n    av_log_set_callback(lavf_log_callback);\n#else\n    av_log_set_callback(nullptr);\n#endif\n    return S_OK;\n}\n\nSTDMETHODIMP CDecAvcodec::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)\n{\n    DestroyDecoder();\n    DbgLog((LOG_TRACE, 10, L\"Initializing ffmpeg for codec %S\", avcodec_get_name(codec)));\n\n    BITMAPINFOHEADER *pBMI = nullptr;\n    videoFormatTypeHandler((const BYTE *)pmt->Format(), pmt->FormatType(), &pBMI);\n\n    if (codec == AV_CODEC_ID_AV1 && IsHardwareAccelerator())\n    {\n        m_pAVCodec = avcodec_find_decoder_by_name(\"av1\");\n    }\n    else\n    {\n        m_pAVCodec = avcodec_find_decoder(codec);\n    }\n    CheckPointer(m_pAVCodec, VFW_E_UNSUPPORTED_VIDEO);\n\n    m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);\n    CheckPointer(m_pAVCtx, E_POINTER);\n\n    DWORD dwDecFlags = m_pCallback->GetDecodeFlags();\n\n    // Use parsing for mpeg1/2 at all times, or H264/HEVC when its not from LAV Splitter\n    if (codec == AV_CODEC_ID_MPEG1VIDEO || codec == AV_CODEC_ID_MPEG2VIDEO ||\n        (!(dwDecFlags & LAV_VIDEO_DEC_FLAG_LAVSPLITTER) &&\n         (pmt->subtype == MEDIASUBTYPE_H264 || pmt->subtype == MEDIASUBTYPE_h264 || pmt->subtype == MEDIASUBTYPE_X264 ||\n          pmt->subtype == MEDIASUBTYPE_x264 || pmt->subtype == MEDIASUBTYPE_H264_bis ||\n          pmt->subtype == MEDIASUBTYPE_HEVC || pmt->subtype == MEDIASUBTYPE_H265)))\n    {\n        m_pParser = av_parser_init(codec);\n    }\n\n    LONG biRealWidth = pBMI->biWidth, biRealHeight = pBMI->biHeight;\n    if (pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo)\n    {\n        VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)pmt->Format();\n        if (vih->rcTarget.right != 0 && vih->rcTarget.bottom != 0)\n        {\n            biRealWidth = vih->rcTarget.right;\n            biRealHeight = vih->rcTarget.bottom;\n        }\n    }\n    else if (pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2Video)\n    {\n        VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)pmt->Format();\n        if (vih2->rcTarget.right != 0 && vih2->rcTarget.bottom != 0)\n        {\n            biRealWidth = vih2->rcTarget.right;\n            biRealHeight = vih2->rcTarget.bottom;\n        }\n    }\n\n    m_pAVCtx->codec_id = codec;\n    m_pAVCtx->codec_tag = pBMI->biCompression;\n    m_pAVCtx->coded_width = pBMI->biWidth;\n    m_pAVCtx->coded_height = abs(pBMI->biHeight);\n    m_pAVCtx->bits_per_coded_sample = pBMI->biBitCount;\n    m_pAVCtx->err_recognition = 0;\n    m_pAVCtx->workaround_bugs = FF_BUG_AUTODETECT;\n\n    // Setup threading\n    // Thread Count. 0 = auto detect\n    int thread_count = m_pSettings->GetNumThreads();\n    if (thread_count == 0)\n    {\n        thread_count = av_cpu_count();\n    }\n    m_pAVCtx->thread_count = max(1, min(thread_count, AVCODEC_MAX_THREADS));\n\n    if (dwDecFlags & LAV_VIDEO_DEC_FLAG_NO_MT || codec == AV_CODEC_ID_MPEG4)\n    {\n        m_pAVCtx->thread_count = 1;\n    }\n\n    m_pFrame = av_frame_alloc();\n    CheckPointer(m_pFrame, E_POINTER);\n\n    // Process Extradata\n    size_t extralen = 0;\n    getExtraData(*pmt, nullptr, &extralen);\n\n    BOOL bH264avc = FALSE;\n    if (pmt->formattype == FORMAT_MPEG2Video && (m_pAVCtx->codec_tag == MAKEFOURCC('a', 'v', 'c', '1') ||\n                                                 m_pAVCtx->codec_tag == MAKEFOURCC('A', 'V', 'C', '1') ||\n                                                 m_pAVCtx->codec_tag == MAKEFOURCC('C', 'C', 'V', '1')))\n    {\n        // Reconstruct AVC1 extradata format\n        DbgLog((LOG_TRACE, 10, L\"-> Processing AVC1 extradata of %d bytes\", extralen));\n        MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)pmt->Format();\n        extralen += 7;\n        BYTE *extra = (uint8_t *)av_mallocz(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n        extra[0] = 1;\n        extra[1] = (BYTE)mp2vi->dwProfile;\n        extra[2] = 0;\n        extra[3] = (BYTE)mp2vi->dwLevel;\n        extra[4] = (BYTE)(mp2vi->dwFlags ? mp2vi->dwFlags : 4) - 1;\n\n        // only process extradata if available\n        uint8_t ps_count = 0;\n        if (extralen > 7)\n        {\n            // Actually copy the metadata into our new buffer\n            size_t actual_len;\n            getExtraData(*pmt, extra + 6, &actual_len);\n\n            // Count the number of SPS/PPS in them and set the length\n            // We'll put them all into one block and add a second block with 0 elements afterwards\n            // The parsing logic does not care what type they are, it just expects 2 blocks.\n            BYTE *p = extra + 6, *end = extra + 6 + actual_len;\n            BOOL bSPS = FALSE, bPPS = FALSE;\n            while (p + 1 < end)\n            {\n                unsigned len = (((unsigned)p[0] << 8) | p[1]) + 2;\n                if (p + len > end)\n                {\n                    break;\n                }\n                if ((p[2] & 0x1F) == 7)\n                    bSPS = TRUE;\n                if ((p[2] & 0x1F) == 8)\n                    bPPS = TRUE;\n                ps_count++;\n                p += len;\n            }\n        }\n        extra[5] = ps_count;\n        extra[extralen - 1] = 0;\n\n        bH264avc = TRUE;\n        m_pAVCtx->extradata = extra;\n        m_pAVCtx->extradata_size = (int)extralen;\n    }\n    else if (extralen > 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Processing extradata of %d bytes\", extralen));\n        BYTE *extra = nullptr;\n        if (pmt->subtype == MEDIASUBTYPE_LAV_RAWVIDEO)\n        {\n            if (extralen < sizeof(m_pAVCtx->pix_fmt))\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> LAV RAW Video extradata is missing..\"));\n            }\n            else\n            {\n                extra = (uint8_t *)av_mallocz(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n                getExtraData(*pmt, extra, nullptr);\n                m_pAVCtx->pix_fmt = *(AVPixelFormat *)extra;\n                extralen -= sizeof(AVPixelFormat);\n                memmove(extra, extra + sizeof(AVPixelFormat), extralen);\n            }\n        }\n        else if (codec == AV_CODEC_ID_VP9)\n        {\n            // read custom vpcC headers\n            if (extralen >= 16)\n            {\n                extra = (uint8_t *)av_mallocz(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n                getExtraData(*pmt, extra, nullptr);\n\n                if (AV_RB32(extra) == MKBETAG('v', 'p', 'c', 'C') && AV_RB8(extra + 4) == 1)\n                {\n                    m_pAVCtx->profile = AV_RB8(extra + 8);\n                    m_pAVCtx->color_primaries = (AVColorPrimaries)AV_RB8(extra + 11);\n                    m_pAVCtx->color_trc = (AVColorTransferCharacteristic)AV_RB8(extra + 12);\n                    m_pAVCtx->colorspace = (AVColorSpace)AV_RB8(extra + 13);\n\n                    int bitdepth = AV_RB8(extra + 10) >> 4;\n                    if (m_pAVCtx->profile == 2 && bitdepth == 10)\n                    {\n                        m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV420P10;\n                    }\n                    else if (m_pAVCtx->profile == 2 && bitdepth == 12)\n                    {\n                        m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV420P12;\n                    }\n                }\n\n                av_freep(&extra);\n                extralen = 0;\n            }\n        }\n        else if (codec == AV_CODEC_ID_AV1)\n        {\n            extra = (uint8_t *)av_mallocz(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n            getExtraData(*pmt, extra, nullptr);\n\n            // ISOBMFF start marker, invalid in OBU syntax\n            if (extralen >= 4 && extra[0] == 0x81)\n            {\n                CByteParser av1(extra, extralen);\n                av1.BitSkip(8);\n\n                m_pAVCtx->profile = av1.BitRead(3);\n                av1.BitSkip(5); // level idx\n\n                av1.BitSkip(1); // tier\n                int high_bitdepth = av1.BitRead(1);\n                int twelve_bit = av1.BitRead(1);\n                int monochrome = av1.BitRead(1);\n                int chroma_x = av1.BitRead(1);\n                int chroma_y = av1.BitRead(1);\n                av1.BitSkip(2); // chroma sample position\n\n                // determine pixel format\n                if (m_pAVCtx->profile == AV_PROFILE_AV1_MAIN)\n                {\n                    if (!monochrome)\n                    {\n                        if (chroma_x && chroma_y)\n                        {\n                            if (!high_bitdepth)\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV420P;\n                            else if (!twelve_bit)\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV420P10;\n                            else\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV420P12;\n                        }\n                        else if (chroma_x && !chroma_y)\n                        {\n                            if (!high_bitdepth)\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV422P;\n                            else if (!twelve_bit)\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV422P10;\n                            else\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV422P12;\n                        }\n                        else if (!chroma_x && !chroma_y)\n                        {\n                            if (!high_bitdepth)\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV444P;\n                            else if (!twelve_bit)\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV444P10;\n                            else\n                                m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV444P12;\n                        }\n                    }\n                    else\n                    {\n                        if (!high_bitdepth)\n                            m_pAVCtx->pix_fmt = AV_PIX_FMT_GRAY8;\n                        else if (!twelve_bit)\n                            m_pAVCtx->pix_fmt = AV_PIX_FMT_GRAY10;\n                        else\n                            m_pAVCtx->pix_fmt = AV_PIX_FMT_GRAY12;\n                    }\n                }\n            }\n        }\n        else\n        {\n            // Just copy extradata for other formats\n            extra = (uint8_t *)av_mallocz(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n            getExtraData(*pmt, extra, nullptr);\n        }\n        // Hack to discard invalid MP4 metadata with AnnexB style video\n        if (codec == AV_CODEC_ID_H264 && !bH264avc && extra && extra[0] == 1)\n        {\n            av_freep(&extra);\n            extralen = 0;\n        }\n        m_pAVCtx->extradata = extra;\n        m_pAVCtx->extradata_size = (int)extralen;\n    }\n    else\n    {\n        if (codec == AV_CODEC_ID_VP6 || codec == AV_CODEC_ID_VP6A || codec == AV_CODEC_ID_VP6F)\n        {\n            int cropH = pBMI->biWidth - biRealWidth;\n            int cropV = pBMI->biHeight - biRealHeight;\n            if (cropH >= 0 && cropH <= 0x0f && cropV >= 0 && cropV <= 0x0f)\n            {\n                m_pAVCtx->extradata = (uint8_t *)av_mallocz(1 + AV_INPUT_BUFFER_PADDING_SIZE);\n                m_pAVCtx->extradata_size = 1;\n                m_pAVCtx->extradata[0] = (cropH << 4) | cropV;\n            }\n        }\n    }\n\n    m_CurrentThread = 0;\n    m_rtStartCache = AV_NOPTS_VALUE;\n\n    LAVPinInfo lavPinInfo = {0};\n    BOOL bLAVInfoValid = SUCCEEDED(m_pCallback->GetLAVPinInfo(lavPinInfo));\n\n    m_bInputPadded = (dwDecFlags & LAV_VIDEO_DEC_FLAG_LAVSPLITTER);\n\n    // Setup codec-specific timing logic\n\n    // MPEG-4 with VideoInfo/2 is from AVI, and only DTS\n    if (codec == AV_CODEC_ID_MPEG4 && pmt->formattype != FORMAT_MPEG2Video)\n        dwDecFlags |= LAV_VIDEO_DEC_FLAG_ONLY_DTS;\n\n    // RealVideo is only DTS\n    if (codec == AV_CODEC_ID_RV10 || codec == AV_CODEC_ID_RV20 || codec == AV_CODEC_ID_RV30 ||\n        codec == AV_CODEC_ID_RV40)\n        dwDecFlags |= LAV_VIDEO_DEC_FLAG_ONLY_DTS;\n\n    // H.264 without B frames should use reordering for proper delay handling\n    if (codec == AV_CODEC_ID_H264 && bLAVInfoValid && lavPinInfo.has_b_frames == 0)\n    {\n        dwDecFlags &= ~LAV_VIDEO_DEC_FLAG_ONLY_DTS;\n    }\n\n    // Use ffmpegs logic to reorder timestamps\n    // This is required for all codecs which use frame re-ordering or frame-threaded decoding (unless they specifically\n    // use DTS timestamps, ie. H264 in AVI)\n    m_bFFReordering = !(dwDecFlags & LAV_VIDEO_DEC_FLAG_ONLY_DTS) &&\n                      (m_pAVCodec->capabilities & (AV_CODEC_CAP_DELAY | AV_CODEC_CAP_FRAME_THREADS));\n\n    // Stop time is unreliable, drop it and calculate it\n    m_bCalculateStopTime = (codec == AV_CODEC_ID_H264 || codec == AV_CODEC_ID_DIRAC ||\n                            (codec == AV_CODEC_ID_MPEG4 && pmt->formattype == FORMAT_MPEG2Video) ||\n                            (codec == AV_CODEC_ID_VC1 && !(dwDecFlags & LAV_VIDEO_DEC_FLAG_ONLY_DTS)));\n\n    // Real Video content has some odd timestamps\n    // LAV Splitter does them allright with RV30/RV40, everything else screws them up\n    m_bRVDropBFrameTimings = (codec == AV_CODEC_ID_RV10 || codec == AV_CODEC_ID_RV20 ||\n                              ((codec == AV_CODEC_ID_RV30 || codec == AV_CODEC_ID_RV40) &&\n                               (!(dwDecFlags & LAV_VIDEO_DEC_FLAG_LAVSPLITTER) ||\n                                (bLAVInfoValid && (lavPinInfo.flags & LAV_STREAM_FLAG_RV34_MKV)))));\n\n    // Enable B-Frame delay handling\n    m_bBFrameDelay = !m_bFFReordering && !m_bRVDropBFrameTimings;\n\n    m_bWaitingForKeyFrame = TRUE;\n    m_bResumeAtKeyFrame = codec == AV_CODEC_ID_MPEG2VIDEO || codec == AV_CODEC_ID_VC1 ||\n                          codec == AV_CODEC_ID_VC1IMAGE || codec == AV_CODEC_ID_WMV3 ||\n                          codec == AV_CODEC_ID_WMV3IMAGE || codec == AV_CODEC_ID_RV30 || codec == AV_CODEC_ID_RV40 ||\n                          codec == AV_CODEC_ID_VP3 || codec == AV_CODEC_ID_THEORA || codec == AV_CODEC_ID_MPEG4;\n\n    m_bHasPalette = m_pAVCtx->bits_per_coded_sample <= 8 && m_pAVCtx->extradata_size &&\n                    !(dwDecFlags & LAV_VIDEO_DEC_FLAG_LAVSPLITTER) &&\n                    (codec == AV_CODEC_ID_MSVIDEO1 || codec == AV_CODEC_ID_MSRLE || codec == AV_CODEC_ID_CINEPAK ||\n                     codec == AV_CODEC_ID_8BPS || codec == AV_CODEC_ID_QPEG || codec == AV_CODEC_ID_QTRLE ||\n                     codec == AV_CODEC_ID_TSCC);\n\n    if (FAILED(AdditionaDecoderInit()))\n    {\n        return E_FAIL;\n    }\n\n    if (bLAVInfoValid)\n    {\n        // Use strict decoding with LAV Splitter and non-live sources\n        if (codec == AV_CODEC_ID_H264 && !(dwDecFlags & LAV_VIDEO_DEC_FLAG_LIVE) && m_bFFReordering &&\n            !m_pAVCtx->hwaccel_context)\n        {\n            m_pAVCtx->strict_std_compliance = FF_COMPLIANCE_STRICT;\n        }\n        // Try to set the has_b_frames info if available\n        else if (lavPinInfo.has_b_frames >= 0)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Setting has_b_frames to %d\", lavPinInfo.has_b_frames));\n            m_pAVCtx->has_b_frames = lavPinInfo.has_b_frames;\n\n            // Set H264 to at least 2 B-Frames, which is the most common for broadcasts\n            if (codec == AV_CODEC_ID_H264 && m_pAVCtx->has_b_frames == 1)\n                m_pAVCtx->has_b_frames = 2;\n        }\n    }\n\n    // side data\n    if (pSideData && pSideData->side_data_elems > 0)\n    {\n        m_pAVCtx->coded_side_data =(AVPacketSideData *)av_calloc(pSideData->side_data_elems, sizeof(*pSideData->side_data));\n        if (m_pAVCtx->coded_side_data == nullptr)\n            return E_OUTOFMEMORY;\n\n        for (int i = 0; i < pSideData->side_data_elems; i++)\n        {\n            const AVPacketSideData *src_sd = &pSideData->side_data[i];\n            AVPacketSideData *dst_sd = &m_pAVCtx->coded_side_data[i];\n\n            dst_sd->data = (uint8_t *)av_memdup(src_sd->data, src_sd->size);\n            if (!dst_sd->data)\n                return E_OUTOFMEMORY;\n\n            dst_sd->type = src_sd->type;\n            dst_sd->size = src_sd->size;\n            m_pAVCtx->nb_coded_side_data++;\n        }\n    }\n\n    // codec-specific options\n    AVDictionary *options = nullptr;\n\n    // workaround for old/broken x264 streams\n    int nX264Build = m_pCallback->GetX264Build();\n    if (codec == AV_CODEC_ID_H264 && nX264Build != -1)\n    {\n        av_dict_set_int(&options, \"x264_build\", nX264Build, 0);\n    }\n\n    // Open the decoder\n    m_bInInit = TRUE;\n    int ret = avcodec_open2(m_pAVCtx, m_pAVCodec, &options);\n    m_bInInit = FALSE;\n\n    // the dict now contains all options that could not be applied\n    if (options)\n    {\n        av_dict_free(&options);\n    }\n\n    if (ret >= 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> ffmpeg codec opened successfully (ret: %d)\", ret));\n        m_nCodecId = codec;\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> ffmpeg codec failed to open (ret: %d)\", ret));\n        DestroyDecoder();\n        return VFW_E_UNSUPPORTED_VIDEO;\n    }\n\n    m_iInterlaced = 0;\n    for (int i = 0; i < countof(ff_interlace_capable); i++)\n    {\n        if (codec == ff_interlace_capable[i])\n        {\n            m_iInterlaced = -1;\n            break;\n        }\n    }\n\n    // Detect chroma and interlaced\n    if (m_pAVCtx->extradata && m_pAVCtx->extradata_size)\n    {\n        if (codec == AV_CODEC_ID_MPEG2VIDEO)\n        {\n            CMPEG2HeaderParser mpeg2Parser(m_pAVCtx->extradata, m_pAVCtx->extradata_size);\n            if (mpeg2Parser.hdr.valid)\n            {\n                if (mpeg2Parser.hdr.chroma < 2)\n                {\n                    m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV420P;\n                }\n                else if (mpeg2Parser.hdr.chroma == 2)\n                {\n                    m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV422P;\n                }\n                m_iInterlaced = mpeg2Parser.hdr.interlaced;\n            }\n        }\n        else if (codec == AV_CODEC_ID_H264)\n        {\n            CH264SequenceParser h264parser;\n            if (bH264avc)\n                h264parser.ParseNALs(m_pAVCtx->extradata + 6, m_pAVCtx->extradata_size - 6, 2);\n            else\n                h264parser.ParseNALs(m_pAVCtx->extradata, m_pAVCtx->extradata_size, 0);\n            if (h264parser.sps.valid)\n                m_iInterlaced = h264parser.sps.interlaced;\n        }\n        else if (codec == AV_CODEC_ID_VC1)\n        {\n            CVC1HeaderParser vc1parser(m_pAVCtx->extradata, m_pAVCtx->extradata_size);\n            if (vc1parser.hdr.valid)\n                m_iInterlaced = (vc1parser.hdr.interlaced ? -1 : 0);\n        }\n    }\n\n    if (codec == AV_CODEC_ID_DNXHD)\n        m_pAVCtx->pix_fmt = AV_PIX_FMT_YUV422P10;\n    else if (codec == AV_CODEC_ID_FRAPS)\n        m_pAVCtx->pix_fmt = AV_PIX_FMT_BGR24;\n\n    if (bLAVInfoValid && lavPinInfo.pix_fmt != AV_PIX_FMT_NONE && codec != AV_CODEC_ID_FRAPS)\n    {\n        if (m_pAVCtx->pix_fmt != AV_PIX_FMT_DXVA2_VLD && m_pAVCtx->pix_fmt != AV_PIX_FMT_D3D11)\n            m_pAVCtx->pix_fmt = lavPinInfo.pix_fmt;\n        if (m_pAVCtx->sw_pix_fmt == AV_PIX_FMT_NONE)\n            m_pAVCtx->sw_pix_fmt = lavPinInfo.pix_fmt;\n    }\n\n    // Ensure software pixfmt is set, so hardware accels can use it immediately\n    if (m_pAVCtx->sw_pix_fmt == AV_PIX_FMT_NONE && m_pAVCtx->pix_fmt != AV_PIX_FMT_DXVA2_VLD && m_pAVCtx->pix_fmt != AV_PIX_FMT_D3D11)\n        m_pAVCtx->sw_pix_fmt = m_pAVCtx->pix_fmt;\n\n\n    DbgLog((LOG_TRACE, 10, L\"AVCodec init successfull. interlaced: %d\", m_iInterlaced));\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecAvcodec::DestroyDecoder()\n{\n    m_pAVCodec = nullptr;\n\n    if (m_pParser)\n    {\n        av_parser_close(m_pParser);\n        m_pParser = nullptr;\n    }\n\n    if (m_pAVCtx)\n    {\n        if (m_pAVCtx->codec_id == AV_CODEC_ID_H264)\n        {\n            int64_t x264build = -1;\n            if (av_opt_get_int(m_pAVCtx->priv_data, \"x264_build\", 0, &x264build) >= 0)\n                m_pCallback->SetX264Build((int)x264build);\n        }\n\n        av_freep(&m_pAVCtx->hwaccel_context);\n        av_freep(&m_pAVCtx->extradata);\n        avcodec_free_context(&m_pAVCtx);\n    }\n    av_frame_free(&m_pFrame);\n\n    av_freep(&m_pFFBuffer);\n    m_nFFBufferSize = 0;\n\n    if (m_pSwsContext)\n    {\n        sws_freeContext(m_pSwsContext);\n        m_pSwsContext = nullptr;\n    }\n\n    m_nCodecId = AV_CODEC_ID_NONE;\n\n    return S_OK;\n}\n\nstatic void lav_avframe_free(LAVFrame *frame)\n{\n    ASSERT(frame->priv_data);\n    av_frame_free((AVFrame **)&frame->priv_data);\n}\n\nstatic void avpacket_mediasample_free(void *opaque, uint8_t *buffer)\n{\n    IMediaSample *pSample = (IMediaSample *)opaque;\n    SafeRelease(&pSample);\n}\n\nSTDMETHODIMP CDecAvcodec::FillAVPacketData(AVPacket *avpkt, const uint8_t *buffer, int buflen, IMediaSample *pSample,\n                                           bool bRefCounting)\n{\n    if (m_bInputPadded && (m_pParser == nullptr))\n    {\n        avpkt->data = (uint8_t *)buffer;\n        avpkt->size = buflen;\n\n        if (pSample && bRefCounting && m_pCallback->HasDynamicInputAllocator())\n        {\n            avpkt->buf =\n                av_buffer_create(avpkt->data, avpkt->size, avpacket_mediasample_free, pSample, AV_BUFFER_FLAG_READONLY);\n            if (!avpkt->buf)\n            {\n                return E_OUTOFMEMORY;\n            }\n            pSample->AddRef();\n        }\n    }\n    else\n    {\n        // create fresh packet\n        if (av_new_packet(avpkt, buflen) < 0)\n            return E_OUTOFMEMORY;\n\n        // copy data over\n        memcpy(avpkt->data, buffer, buflen);\n    }\n\n    // copy side-data from input sample\n    if (pSample)\n    {\n        IMediaSideData *pSideData = nullptr;\n        if (SUCCEEDED(pSample->QueryInterface(&pSideData)))\n        {\n            size_t nFFSideDataSize = 0;\n            const MediaSideDataFFMpeg *pFFSideData = nullptr;\n            if (FAILED(\n                    pSideData->GetSideData(IID_MediaSideDataFFMpeg, (const BYTE **)&pFFSideData, &nFFSideDataSize)) ||\n                nFFSideDataSize != sizeof(MediaSideDataFFMpeg))\n            {\n                pFFSideData = nullptr;\n            }\n\n            SafeRelease(&pSideData);\n            CopyMediaSideDataFF(avpkt, &pFFSideData);\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecAvcodec::Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStartIn, REFERENCE_TIME rtStopIn,\n                                 BOOL bSyncPoint, BOOL bDiscontinuity, IMediaSample *pSample)\n{\n    CheckPointer(m_pAVCtx, E_UNEXPECTED);\n\n    // Put timestamps into the buffers if appropriate\n    if (m_pAVCtx->active_thread_type & FF_THREAD_FRAME)\n    {\n        if (!m_bFFReordering)\n        {\n            m_tcThreadBuffer[m_CurrentThread].rtStart = rtStartIn;\n            m_tcThreadBuffer[m_CurrentThread].rtStop = rtStopIn;\n        }\n\n        m_CurrentThread = (m_CurrentThread + 1) % m_pAVCtx->thread_count;\n    }\n    else if (m_bBFrameDelay)\n    {\n        m_tcBFrameDelay[m_nBFramePos].rtStart = rtStartIn;\n        m_tcBFrameDelay[m_nBFramePos].rtStop = rtStopIn;\n        m_nBFramePos = !m_nBFramePos;\n    }\n\n    // if we have a parser, it'll handle calling the decode function\n    if (m_pParser)\n    {\n        return ParsePacket(buffer, buflen, rtStartIn, rtStopIn, pSample);\n    }\n    else\n    {\n        // Flush the decoder if appropriate\n        if (buffer == nullptr)\n        {\n            return DecodePacket(nullptr, AV_NOPTS_VALUE, AV_NOPTS_VALUE);\n        }\n\n        // build an AVPacket\n        AVPacket *avpkt = av_packet_alloc();\n\n        // set data pointers\n        if (FAILED(FillAVPacketData(avpkt, buffer, buflen, pSample, true)))\n        {\n            return E_OUTOFMEMORY;\n        }\n\n        // timestamps\n        avpkt->pts = rtStartIn;\n        if (rtStartIn != AV_NOPTS_VALUE && rtStopIn != AV_NOPTS_VALUE)\n            avpkt->duration = (int)(rtStopIn - rtStartIn);\n\n        // flags\n        avpkt->flags = bSyncPoint ? AV_PKT_FLAG_KEY : 0;\n\n        // perform decoding\n        HRESULT hr = DecodePacket(avpkt, rtStartIn, rtStopIn);\n\n        // free packet after\n        av_packet_free(&avpkt);\n\n        // forward decoding failures, should only happen when a hardware decoder fails\n        if (FAILED(hr))\n        {\n            return hr;\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecAvcodec::ParsePacket(const BYTE *buffer, int buflen, REFERENCE_TIME rtStartIn, REFERENCE_TIME rtStopIn,\n                                      IMediaSample *pSample)\n{\n    BOOL bFlush = (buffer == NULL);\n    int used_bytes = 0;\n    uint8_t *pDataBuffer = (uint8_t *)buffer;\n    HRESULT hr = S_OK;\n\n    // re-allocate with padding, if needed\n    if (m_bInputPadded == false && buflen > 0)\n    {\n        // re-allocate buffer to have enough space\n        BYTE *pBuf = (BYTE *)av_fast_realloc(m_pFFBuffer, &m_nFFBufferSize, buflen + AV_INPUT_BUFFER_PADDING_SIZE);\n        if (!pBuf)\n            return E_FAIL;\n\n        m_pFFBuffer = pBuf;\n\n        // copy data to buffer\n        memcpy(m_pFFBuffer, buffer, buflen);\n        memset(m_pFFBuffer + buflen, 0, AV_INPUT_BUFFER_PADDING_SIZE);\n        pDataBuffer = m_pFFBuffer;\n    }\n\n    // loop over the data buffer until the parser has consumed all data\n    while (buflen > 0 || bFlush)\n    {\n        REFERENCE_TIME rtStart = rtStartIn, rtStop = rtStopIn;\n\n        uint8_t *pOutBuffer = nullptr;\n        int pOutLen = 0;\n\n        used_bytes = av_parser_parse2(m_pParser, m_pAVCtx, &pOutBuffer, &pOutLen, pDataBuffer, buflen, AV_NOPTS_VALUE,\n                                      AV_NOPTS_VALUE, 0);\n\n        if (used_bytes == 0 && pOutLen == 0 && !bFlush)\n        {\n            DbgLog((LOG_TRACE, 50, L\"::Decode() - could not process buffer, starving?\"));\n            break;\n        }\n        else if (used_bytes > 0)\n        {\n            buflen -= used_bytes;\n            pDataBuffer += used_bytes;\n        }\n\n        // Update start time cache\n        // If more data was read then output, update the cache (incomplete frame)\n        // If output is bigger, a frame was completed, update the actual rtStart with the cached value, and then\n        // overwrite the cache\n        if (used_bytes > pOutLen)\n        {\n            if (rtStartIn != AV_NOPTS_VALUE)\n                m_rtStartCache = rtStartIn;\n        }\n        else if (used_bytes == pOutLen || ((used_bytes + 9) == pOutLen))\n        {\n            // Why +9 above?\n            // Well, apparently there are some broken MKV muxers that like to mux the MPEG-2 PICTURE_START_CODE block\n            // (which is 9 bytes) in the package with the previous frame This would cause the frame timestamps to be\n            // delayed by one frame exactly, and cause timestamp reordering to go wrong. So instead of failing on those\n            // samples, lets just assume that 9 bytes are that case exactly.\n            m_rtStartCache = rtStartIn = AV_NOPTS_VALUE;\n        }\n        else if (pOutLen > used_bytes)\n        {\n            rtStart = m_rtStartCache;\n            m_rtStartCache = rtStartIn;\n            // The value was used once, don't use it for multiple frames, that ends up in weird timings\n            rtStartIn = AV_NOPTS_VALUE;\n        }\n\n        // decode any parsed data\n        if (pOutLen > 0)\n        {\n            AVPacket *avpkt = av_packet_alloc();\n\n            // set data pointers\n            if (FAILED(FillAVPacketData(avpkt, pOutBuffer, pOutLen, pSample, false)))\n            {\n                return E_OUTOFMEMORY;\n            }\n\n            // timestamp\n            avpkt->pts = rtStart;\n\n            // decode the parsed packet\n            hr = DecodePacket(avpkt, rtStart, rtStop);\n\n            // and free it after\n            av_packet_free(&avpkt);\n\n            if (FAILED(hr))\n            {\n                return hr;\n            }\n        }\n        // or perform a flush at the end\n        else if (bFlush)\n        {\n            hr = DecodePacket(nullptr, AV_NOPTS_VALUE, AV_NOPTS_VALUE);\n            if (FAILED(hr))\n            {\n                return hr;\n            }\n            break;\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecAvcodec::DecodePacket(AVPacket *avpkt, REFERENCE_TIME rtStartIn, REFERENCE_TIME rtStopIn)\n{\n    int ret = 0;\n    BOOL bEndOfSequence = FALSE;\n    BOOL bDeliverFirst = FALSE;\n    REFERENCE_TIME rtStart = rtStartIn, rtStop = rtStopIn;\n\n    // packet pre-processing\n    if (avpkt)\n    {\n        // EOS/GOP detection for mpeg2 video streams\n        if (m_nCodecId == AV_CODEC_ID_MPEG2VIDEO)\n        {\n            int state = CheckForSequenceMarkers(m_nCodecId, avpkt->data, avpkt->size, &m_MpegParserState);\n            if (state & STATE_EOS_FOUND)\n            {\n                bEndOfSequence = TRUE;\n            }\n\n            if (state & STATE_GOP_FOUND && m_nCodecId == AV_CODEC_ID_MPEG2VIDEO)\n            {\n                m_bWaitingForKeyFrame = FALSE;\n            }\n        }\n\n        // Check for VP8 keyframes\n        if (m_nCodecId == AV_CODEC_ID_VP8 && m_bWaitingForKeyFrame)\n        {\n            if (!(avpkt->data[0] & 1))\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Decode(): Found VP8 key-frame, resuming decoding\"));\n                m_bWaitingForKeyFrame = FALSE;\n            }\n            else\n            {\n                return S_OK;\n            }\n        }\n        else if (m_nCodecId == AV_CODEC_ID_VP9 && m_bWaitingForKeyFrame)\n        {\n            CByteParser VP9Header(avpkt->data, avpkt->size);\n\n            // check vp9 frame marker\n            if (VP9Header.BitRead(2) != 0x2)\n                return E_FAIL;\n\n            int profile = VP9Header.BitRead(1) | (VP9Header.BitRead(1) << 1);\n            if (profile == 3)\n                profile += VP9Header.BitRead(1);\n            if (VP9Header.BitRead(1) == 0 && VP9Header.BitRead(1) == 0)\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Decode(): Found VP9 key-frame, resuming decoding\"));\n                m_bWaitingForKeyFrame = FALSE;\n            }\n            else\n            {\n                return S_OK;\n            }\n        }\n\n        // Add a palette from extradata, if any\n        if (m_bHasPalette)\n        {\n            m_bHasPalette = FALSE;\n            uint32_t *pal = (uint32_t *)av_packet_new_side_data(avpkt, AV_PKT_DATA_PALETTE, AVPALETTE_SIZE);\n            int pal_size = FFMIN((1 << m_pAVCtx->bits_per_coded_sample) << 2, m_pAVCtx->extradata_size);\n            uint8_t *pal_src = m_pAVCtx->extradata + m_pAVCtx->extradata_size - pal_size;\n\n            for (int i = 0; i < pal_size / 4; i++)\n                pal[i] = 0xFF << 24 | AV_RL32(pal_src + 4 * i);\n        }\n    }\n\nsend_packet:\n    // send packet to the decoder\n    ret = avcodec_send_packet(m_pAVCtx, avpkt);\n    if (ret < 0)\n    {\n        // Check if post-decoding checks failed\n        if (FAILED(PostDecode()))\n        {\n            return E_FAIL;\n        }\n\n        if (ret == AVERROR(EAGAIN))\n        {\n            if (bDeliverFirst)\n            {\n                DbgLog((LOG_ERROR, 10, L\"::Decode(): repeated packet submission to the decoder failed\"));\n                ASSERT(0);\n                return E_FAIL;\n            }\n            bDeliverFirst = TRUE;\n        }\n        else\n            return S_FALSE;\n    }\n    else\n    {\n        bDeliverFirst = FALSE;\n    }\n\n    // loop over available frames\n    while (1)\n    {\n        ret = avcodec_receive_frame(m_pAVCtx, m_pFrame);\n\n        if (FAILED(PostDecode()))\n        {\n            av_frame_unref(m_pFrame);\n            return E_FAIL;\n        }\n\n        // Decoding of this frame failed ... oh well!\n        if (ret < 0 && ret != AVERROR(EAGAIN))\n        {\n            av_frame_unref(m_pFrame);\n            return S_FALSE;\n        }\n\n        // Judge frame usability\n        // This determines if a frame is artifact free and can be delivered.\n        if (m_bResumeAtKeyFrame && m_bWaitingForKeyFrame && ret >= 0)\n        {\n            if (m_pFrame->flags & AV_FRAME_FLAG_KEY)\n            {\n                DbgLog((LOG_TRACE, 50, L\"::Decode() - Found Key-Frame, resuming decoding at %I64d\", m_pFrame->pts));\n                m_bWaitingForKeyFrame = FALSE;\n            }\n            else\n            {\n                ret = AVERROR(EAGAIN);\n            }\n        }\n\n        // Handle B-frame delay for frame threading codecs\n        if ((m_pAVCtx->active_thread_type & FF_THREAD_FRAME) && m_bBFrameDelay)\n        {\n            m_tcBFrameDelay[m_nBFramePos] = m_tcThreadBuffer[m_CurrentThread];\n            m_nBFramePos = !m_nBFramePos;\n        }\n\n        // no frame was decoded, bail out here\n        if (ret < 0 || !m_pFrame->data[0])\n        {\n            av_frame_unref(m_pFrame);\n            break;\n        }\n\n        ///////////////////////////////////////////////////////////////////////////////////////////////\n        // Determine the proper timestamps for the frame, based on different possible flags.\n        ///////////////////////////////////////////////////////////////////////////////////////////////\n        if (m_bFFReordering)\n        {\n            rtStart = m_pFrame->pts;\n            if (m_pFrame->duration)\n                rtStop = m_pFrame->pts + m_pFrame->duration;\n            else\n                rtStop = AV_NOPTS_VALUE;\n        }\n        else if (m_bBFrameDelay && m_pAVCtx->has_b_frames)\n        {\n            rtStart = m_tcBFrameDelay[m_nBFramePos].rtStart;\n            rtStop = m_tcBFrameDelay[m_nBFramePos].rtStop;\n        }\n        else if (m_pAVCtx->active_thread_type & FF_THREAD_FRAME)\n        {\n            unsigned index = m_CurrentThread;\n            rtStart = m_tcThreadBuffer[index].rtStart;\n            rtStop = m_tcThreadBuffer[index].rtStop;\n        }\n\n        if (m_bRVDropBFrameTimings && m_pFrame->pict_type == AV_PICTURE_TYPE_B)\n        {\n            rtStart = AV_NOPTS_VALUE;\n        }\n\n        if (m_bCalculateStopTime)\n            rtStop = AV_NOPTS_VALUE;\n\n        ///////////////////////////////////////////////////////////////////////////////////////////////\n        // All required values collected, deliver the frame\n        ///////////////////////////////////////////////////////////////////////////////////////////////\n        LAVFrame *pOutFrame = nullptr;\n        AllocateFrame(&pOutFrame);\n\n        AVRational display_aspect_ratio;\n        int64_t num = (int64_t)m_pFrame->sample_aspect_ratio.num * m_pFrame->width;\n        int64_t den = (int64_t)m_pFrame->sample_aspect_ratio.den * m_pFrame->height;\n        av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, num, den, INT_MAX);\n\n        pOutFrame->width = m_pFrame->width;\n        pOutFrame->height = m_pFrame->height;\n        pOutFrame->aspect_ratio = display_aspect_ratio;\n        pOutFrame->repeat = m_pFrame->repeat_pict;\n        pOutFrame->key_frame = !!(m_pFrame->flags & AV_FRAME_FLAG_KEY);\n        pOutFrame->frame_type = av_get_picture_type_char(m_pFrame->pict_type);\n        pOutFrame->ext_format = GetDXVA2ExtendedFlags(m_pFrame);\n\n        if ((m_nCodecId == AV_CODEC_ID_H264 || m_nCodecId == AV_CODEC_ID_MPEG2VIDEO) && m_pFrame->repeat_pict)\n            m_nSoftTelecine = 2;\n        else if (m_nSoftTelecine > 0)\n            m_nSoftTelecine--;\n\n        if ((m_pFrame->flags & AV_FRAME_FLAG_INTERLACED) || (!m_pAVCtx->progressive_sequence &&\n                                           (m_nCodecId == AV_CODEC_ID_H264 || m_nCodecId == AV_CODEC_ID_MPEG2VIDEO)))\n        {\n            if (!m_nSoftTelecine)\n                m_iInterlaced = 1;\n        }\n        else if (m_pAVCtx->progressive_sequence)\n            m_iInterlaced = 0;\n\n        // Don't apply aggressive deinterlacing to content that looks soft-telecined, as it would destroy the content\n        bool bAggressiveFlag =\n            (m_iInterlaced == 1 && m_pSettings->GetDeinterlacingMode() == DeintMode_Aggressive) && !m_nSoftTelecine;\n\n        pOutFrame->interlaced = ((m_pFrame->flags & AV_FRAME_FLAG_INTERLACED) || bAggressiveFlag ||\n                                 m_pSettings->GetDeinterlacingMode() == DeintMode_Force) &&\n            !(m_pSettings->GetDeinterlacingMode() == DeintMode_Disable);\n\n        LAVDeintFieldOrder fo = m_pSettings->GetDeintFieldOrder();\n        pOutFrame->tff =\n            (fo == DeintFieldOrder_Auto) ? !!(m_pFrame->flags & AV_FRAME_FLAG_TOP_FIELD_FIRST) : (fo == DeintFieldOrder_TopFieldFirst);\n\n        pOutFrame->rtStart = rtStart;\n        pOutFrame->rtStop = rtStop;\n\n        PixelFormatMapping map = getPixFmtMapping((AVPixelFormat)m_pFrame->format);\n        pOutFrame->format = map.lavpixfmt;\n        pOutFrame->sw_format = pOutFrame->format;\n        pOutFrame->bpp = map.bpp;\n\n        if (m_nCodecId == AV_CODEC_ID_MPEG2VIDEO || m_nCodecId == AV_CODEC_ID_MPEG1VIDEO)\n            pOutFrame->avgFrameDuration = GetFrameDuration();\n\n        AVFrameSideData *sdHDR = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA);\n        if (sdHDR)\n        {\n            if (sdHDR->size == sizeof(AVMasteringDisplayMetadata))\n            {\n                AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sdHDR->data;\n                MediaSideDataHDR *hdr =\n                    (MediaSideDataHDR *)AddLAVFrameSideData(pOutFrame, IID_MediaSideDataHDR, sizeof(MediaSideDataHDR));\n                processFFHDRData(hdr, metadata);\n            }\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Decode(): Found HDR data of an unexpected size (%d)\", sdHDR->size));\n            }\n        }\n\n        AVFrameSideData *sdHDRContentLightLevel = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_CONTENT_LIGHT_LEVEL);\n        if (sdHDRContentLightLevel)\n        {\n            if (sdHDRContentLightLevel->size == sizeof(AVContentLightMetadata))\n            {\n                AVContentLightMetadata *metadata = (AVContentLightMetadata *)sdHDRContentLightLevel->data;\n                MediaSideDataHDRContentLightLevel *hdr = (MediaSideDataHDRContentLightLevel *)AddLAVFrameSideData(\n                    pOutFrame, IID_MediaSideDataHDRContentLightLevel, sizeof(MediaSideDataHDRContentLightLevel));\n                hdr->MaxCLL = metadata->MaxCLL;\n                hdr->MaxFALL = metadata->MaxFALL;\n            }\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Decode(): Found HDR Light Level data of an unexpected size (%d)\",\n                        sdHDRContentLightLevel->size));\n            }\n        }\n\n        AVFrameSideData *sdHDR10Plus = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);\n        if (sdHDR10Plus)\n        {\n            if (sdHDR10Plus->size == sizeof(AVDynamicHDRPlus))\n            {\n                AVDynamicHDRPlus *metadata = (AVDynamicHDRPlus *)sdHDR10Plus->data;\n                MediaSideDataHDR10Plus *hdr = (MediaSideDataHDR10Plus *)AddLAVFrameSideData(\n                    pOutFrame, IID_MediaSideDataHDR10Plus, sizeof(MediaSideDataHDR10Plus));\n                processFFHDR10PlusData(hdr, metadata, m_pFrame->width, m_pFrame->height);\n            }\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\"::Decode(): Found HDR10+ data of an unexpected size (%d)\", sdHDR10Plus->size));\n            }\n        }\n\n        AVFrameSideData *sdDOVI = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_DOVI_METADATA);\n        if (sdDOVI)\n        {\n            AVDOVIMetadata *metadata = (AVDOVIMetadata *)sdDOVI->data;\n            MediaSideDataDOVIMetadata *hdr = (MediaSideDataDOVIMetadata *)AddLAVFrameSideData(\n                pOutFrame, IID_MediaSideDataDOVIMetadataV2, sizeof(MediaSideDataDOVIMetadata));\n            processFFDOVIData(hdr, metadata);\n\n            #pragma warning(push)\n            #pragma warning(disable: 4996)\n            // legacy format without extensions\n            BYTE *hdrLegacy = (BYTE *)AddLAVFrameSideData(\n                pOutFrame, IID_MediaSideDataDOVIMetadata, offsetof(MediaSideDataDOVIMetadata, Extensions));\n            memcpy(hdrLegacy, hdr, offsetof(MediaSideDataDOVIMetadata, Extensions));\n            #pragma warning(pop)\n        }\n\n        AVFrameSideData *sdDOVIRPU = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_DOVI_RPU_BUFFER);\n        if (sdDOVIRPU)\n        {\n            BYTE *pDVRPU = AddLAVFrameSideData(pOutFrame, IID_MediaSideDataDOVIRPU, sdDOVIRPU->size);\n            memcpy(pDVRPU, sdDOVIRPU->data, sdDOVIRPU->size);\n        }\n\n        AVFrameSideData *sdCC = av_frame_get_side_data(m_pFrame, AV_FRAME_DATA_A53_CC);\n        if (sdCC)\n        {\n            BYTE *CC = AddLAVFrameSideData(pOutFrame, IID_MediaSideDataEIA608CC, sdCC->size);\n            memcpy(CC, sdCC->data, sdCC->size);\n        }\n\n        if (map.conversion)\n        {\n            ConvertPixFmt(m_pFrame, pOutFrame);\n        }\n        else\n        {\n            AVFrame *pFrameRef = av_frame_alloc();\n            av_frame_ref(pFrameRef, m_pFrame);\n\n            for (int i = 0; i < 4; i++)\n            {\n                pOutFrame->data[i] = pFrameRef->data[i];\n                pOutFrame->stride[i] = pFrameRef->linesize[i];\n            }\n\n            pOutFrame->priv_data = pFrameRef;\n            pOutFrame->destruct = lav_avframe_free;\n\n            // Check alignment on rawvideo, which can be off depending on the source file\n            if (m_nCodecId == AV_CODEC_ID_RAWVIDEO)\n            {\n                for (int i = 0; i < 4; i++)\n                {\n                    if ((intptr_t)pOutFrame->data[i] % 16u || pOutFrame->stride[i] % 16u)\n                    {\n                        // copy the frame, its not aligned properly and would crash later\n                        CopyLAVFrameInPlace(pOutFrame);\n                        break;\n                    }\n                }\n            }\n        }\n\n        if (bEndOfSequence)\n            pOutFrame->flags |= LAV_FRAME_FLAG_END_OF_SEQUENCE;\n\n        if (pOutFrame->format == LAVPixFmt_DXVA2)\n        {\n            pOutFrame->data[0] = m_pFrame->data[4];\n            HandleDXVA2Frame(pOutFrame);\n        }\n        else if (pOutFrame->format == LAVPixFmt_D3D11)\n        {\n            HandleDXVA2Frame(pOutFrame);\n        }\n        else\n        {\n            Deliver(pOutFrame);\n        }\n\n        if (bEndOfSequence)\n        {\n            bEndOfSequence = FALSE;\n            if (pOutFrame->format == LAVPixFmt_DXVA2 || pOutFrame->format == LAVPixFmt_D3D11)\n            {\n                HandleDXVA2Frame(m_pCallback->GetFlushFrame());\n            }\n            else\n            {\n                Deliver(m_pCallback->GetFlushFrame());\n            }\n        }\n\n        // increase thread count when flushing\n        if (avpkt == nullptr)\n        {\n            m_CurrentThread = (m_CurrentThread + 1) % m_pAVCtx->thread_count;\n        }\n        av_frame_unref(m_pFrame);\n    }\n\n    // repeat sending the packet to the decoder if it failed first\n    if (bDeliverFirst)\n    {\n        goto send_packet;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecAvcodec::Flush()\n{\n    if (m_pAVCtx && avcodec_is_open(m_pAVCtx))\n    {\n        avcodec_flush_buffers(m_pAVCtx);\n    }\n\n    if (m_pParser)\n    {\n        av_parser_close(m_pParser);\n        m_pParser = av_parser_init(m_nCodecId);\n    }\n\n    m_CurrentThread = 0;\n    m_rtStartCache = AV_NOPTS_VALUE;\n    m_bWaitingForKeyFrame = TRUE;\n    m_nSoftTelecine = 0;\n\n    m_nBFramePos = 0;\n    m_tcBFrameDelay[0].rtStart = m_tcBFrameDelay[0].rtStop = AV_NOPTS_VALUE;\n    m_tcBFrameDelay[1].rtStart = m_tcBFrameDelay[1].rtStop = AV_NOPTS_VALUE;\n\n    if (!(m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD) &&\n        (m_nCodecId == AV_CODEC_ID_H264 || m_nCodecId == AV_CODEC_ID_MPEG2VIDEO))\n    {\n        CDecAvcodec::InitDecoder(m_nCodecId, &m_pCallback->GetInputMediaType(), nullptr);\n    }\n\n    return __super::Flush();\n}\n\nSTDMETHODIMP CDecAvcodec::EndOfStream()\n{\n    Decode(nullptr, 0, AV_NOPTS_VALUE, AV_NOPTS_VALUE, FALSE, FALSE, nullptr);\n    return S_OK;\n}\n\nSTDMETHODIMP CDecAvcodec::GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware)\n{\n    AVPixelFormat pixfmt = m_pAVCtx ? m_pAVCtx->pix_fmt : AV_PIX_FMT_NONE;\n    PixelFormatMapping mapping = getPixFmtMapping(pixfmt);\n    if (pPix)\n        *pPix = mapping.lavpixfmt;\n    if (pBpp)\n        *pBpp = mapping.bpp;\n    if (pPixSoftware)\n        *pPixSoftware = mapping.lavpixfmt;\n    return S_OK;\n}\n\nSTDMETHODIMP CDecAvcodec::ConvertPixFmt(AVFrame *pFrame, LAVFrame *pOutFrame)\n{\n    // Allocate the buffers to write into\n    HRESULT hr = AllocLAVFrameBuffers(pOutFrame);\n    if (FAILED(hr))\n        return hr;\n\n    // Map to swscale compatible format\n    AVPixelFormat dstFormat = getFFPixelFormatFromLAV(pOutFrame->format, pOutFrame->bpp);\n\n    // Get a context\n    m_pSwsContext = sws_getCachedContext(m_pSwsContext, pFrame->width, pFrame->height, (AVPixelFormat)pFrame->format,\n                                         pFrame->width, pFrame->height, dstFormat,\n                                         SWS_BILINEAR | SWS_FULL_CHR_H_INT | SWS_PRINT_INFO, nullptr, nullptr, nullptr);\n\n    ptrdiff_t linesize[4];\n    for (int i = 0; i < 4; i++)\n        linesize[i] = pFrame->linesize[i];\n\n    // Perform conversion\n    sws_scale2(m_pSwsContext, pFrame->data, linesize, 0, pFrame->height, pOutFrame->data, pOutFrame->stride);\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(REFERENCE_TIME) CDecAvcodec::GetFrameDuration()\n{\n    if (m_pAVCtx->framerate.den && m_pAVCtx->framerate.num)\n        return (REF_SECOND_MULT * m_pAVCtx->framerate.den / m_pAVCtx->framerate.num);\n\n    if (m_pAVCtx->time_base.den && m_pAVCtx->time_base.num)\n        return (REF_SECOND_MULT * m_pAVCtx->time_base.num / m_pAVCtx->time_base.den) *\n               ((m_pAVCtx->codec_descriptor && m_pAVCtx->codec_descriptor->props & AV_CODEC_PROP_FIELDS) ? 2 : 1);\n    return 0;\n}\n\nSTDMETHODIMP_(BOOL) CDecAvcodec::IsInterlaced(BOOL bAllowGuess)\n{\n    return (bAllowGuess && m_iInterlaced) || (m_iInterlaced > 0) ||\n           m_pSettings->GetDeinterlacingMode() == DeintMode_Force;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/avcodec.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"DecBase.h\"\n\n#include <map>\n\n#define AVCODEC_MAX_THREADS 32\n\ntypedef struct\n{\n    REFERENCE_TIME rtStart;\n    REFERENCE_TIME rtStop;\n} TimingCache;\n\nclass CDecAvcodec : public CDecBase\n{\n  public:\n    CDecAvcodec(void);\n    virtual ~CDecAvcodec(void);\n\n    // ILAVDecoder\n    STDMETHODIMP InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData);\n    STDMETHODIMP Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BOOL bSyncPoint,\n                        BOOL bDiscontinuity, IMediaSample *pSample);\n    STDMETHODIMP Flush();\n    STDMETHODIMP EndOfStream();\n    STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware);\n    STDMETHODIMP_(REFERENCE_TIME) GetFrameDuration();\n    STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess);\n    STDMETHODIMP_(const WCHAR *) GetDecoderName() { return L\"avcodec\"; }\n    STDMETHODIMP HasThreadSafeBuffers() { return S_OK; }\n\n    // CDecBase\n    STDMETHODIMP Init();\n\n  protected:\n    virtual HRESULT AdditionaDecoderInit() { return S_FALSE; }\n    virtual HRESULT PostDecode() { return S_FALSE; }\n    virtual HRESULT HandleDXVA2Frame(LAVFrame *pFrame) { return S_FALSE; }\n    virtual BOOL IsHardwareAccelerator() { return FALSE; }\n    STDMETHODIMP DestroyDecoder();\n\n    STDMETHODIMP FillAVPacketData(AVPacket *avpkt, const BYTE *buffer, int buflen, IMediaSample *pSample,\n                                  bool bRefCounting);\n    STDMETHODIMP DecodePacket(AVPacket *avpkt, REFERENCE_TIME rtStartIn, REFERENCE_TIME rtStopIn);\n    STDMETHODIMP ParsePacket(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,\n                             IMediaSample *pSample);\n\n  private:\n    STDMETHODIMP ConvertPixFmt(AVFrame *pFrame, LAVFrame *pOutFrame);\n\n  protected:\n    AVCodecContext *m_pAVCtx = nullptr;\n    AVFrame *m_pFrame = nullptr;\n    AVCodecID m_nCodecId = AV_CODEC_ID_NONE;\n    BOOL m_bInInit = FALSE;\n\n  private:\n    const AVCodec *m_pAVCodec = nullptr;\n    AVCodecParserContext *m_pParser = nullptr;\n\n    BYTE *m_pFFBuffer = nullptr;\n    unsigned int m_nFFBufferSize = 0;\n\n    SwsContext *m_pSwsContext = nullptr;\n\n    BOOL m_bHasPalette = FALSE;\n\n    // Timing settings\n    BOOL m_bFFReordering = FALSE;\n    BOOL m_bCalculateStopTime = FALSE;\n    BOOL m_bRVDropBFrameTimings = FALSE;\n    BOOL m_bInputPadded = FALSE;\n\n    BOOL m_bBFrameDelay = TRUE;\n    TimingCache m_tcBFrameDelay[2];\n    int m_nBFramePos = 0;\n\n    TimingCache m_tcThreadBuffer[AVCODEC_MAX_THREADS];\n    int m_CurrentThread = 0;\n\n    REFERENCE_TIME m_rtStartCache = AV_NOPTS_VALUE;\n    BOOL m_bResumeAtKeyFrame = FALSE;\n    BOOL m_bWaitingForKeyFrame = FALSE;\n    int m_iInterlaced = -1;\n    int m_nSoftTelecine = 0;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/cuvid/dynlink_cuda.h",
    "content": "/*\n * Copyright 1993-2015 NVIDIA Corporation.  All rights reserved.\n *\n * Please refer to the NVIDIA end user license agreement (EULA) associated\n * with this source code for terms and conditions that govern your use of\n * this software. Any use, reproduction, disclosure, or distribution of\n * this software and related documentation outside the terms of the EULA\n * is strictly prohibited.\n *\n */\n \n#ifndef __cuda_h__\n#define __cuda_h__\n\n/**\n* CUDA API version support\n*/\n\n#include \"dynlink_cuda_cuda.h\"\n\n#endif //__cuda_h__\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/cuvid/dynlink_cuda_cuda.h",
    "content": "/*\n * Copyright 1993-2015 NVIDIA Corporation.  All rights reserved.\n *\n * Please refer to the NVIDIA end user license agreement (EULA) associated\n * with this source code for terms and conditions that govern your use of\n * this software. Any use, reproduction, disclosure, or distribution of\n * this software and related documentation outside the terms of the EULA\n * is strictly prohibited.\n *\n */\n\n#ifndef __cuda_cuda_h__\n#define __cuda_cuda_h__\n\n#include <stdlib.h>\n\n#ifndef __CUDA_API_VERSION\n#define __CUDA_API_VERSION 4000\n#endif\n\n/**\n * \\defgroup CUDA_DRIVER CUDA Driver API\n *\n * This section describes the low-level CUDA driver application programming\n * interface.\n *\n * @{\n */\n\n/**\n * \\defgroup CUDA_TYPES Data types used by CUDA driver\n * @{\n */\n\n/**\n * CUDA API version number\n */\n#define CUDA_VERSION 4000 /* 4.0 */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * CUDA device pointer\n */\n#if __CUDA_API_VERSION >= 3020\n\n#if defined(__x86_64) || defined(AMD64) || defined(_M_AMD64) || defined(__aarch64__)\n    typedef unsigned long long CUdeviceptr;\n#else\n    typedef unsigned int CUdeviceptr;\n#endif\n\n#endif /* __CUDA_API_VERSION >= 3020 */\n\ntypedef int CUdevice;                                     /**< CUDA device */\ntypedef struct CUctx_st *CUcontext;                       /**< CUDA context */\ntypedef struct CUmod_st *CUmodule;                        /**< CUDA module */\ntypedef struct CUfunc_st *CUfunction;                     /**< CUDA function */\ntypedef struct CUarray_st *CUarray;                       /**< CUDA array */\ntypedef struct CUtexref_st *CUtexref;                     /**< CUDA texture reference */\ntypedef struct CUsurfref_st *CUsurfref;                   /**< CUDA surface reference */\ntypedef struct CUevent_st *CUevent;                       /**< CUDA event */\ntypedef struct CUstream_st *CUstream;                     /**< CUDA stream */\ntypedef struct CUgraphicsResource_st *CUgraphicsResource; /**< CUDA graphics interop resource */\n\ntypedef struct CUuuid_st                                  /**< CUDA definition of UUID */\n{\n    char bytes[16];\n} CUuuid;\n\n/**\n * Context creation flags\n */\ntypedef enum CUctx_flags_enum\n{\n    CU_CTX_SCHED_AUTO          = 0x00, /**< Automatic scheduling */\n    CU_CTX_SCHED_SPIN          = 0x01, /**< Set spin as default scheduling */\n    CU_CTX_SCHED_YIELD         = 0x02, /**< Set yield as default scheduling */\n    CU_CTX_SCHED_BLOCKING_SYNC = 0x04, /**< Set blocking synchronization as default scheduling */\n    CU_CTX_BLOCKING_SYNC       = 0x04, /**< Set blocking synchronization as default scheduling \\deprecated */\n    CU_CTX_MAP_HOST            = 0x08, /**< Support mapped pinned allocations */\n    CU_CTX_LMEM_RESIZE_TO_MAX  = 0x10, /**< Keep local memory allocation after launch */\n#if __CUDA_API_VERSION < 4000\n    CU_CTX_SCHED_MASK          = 0x03,\n    CU_CTX_FLAGS_MASK          = 0x1f\n#else\n    CU_CTX_SCHED_MASK          = 0x07,\n    CU_CTX_PRIMARY             = 0x20, /**< Initialize and return the primary context */\n    CU_CTX_FLAGS_MASK          = 0x3f\n#endif\n} CUctx_flags;\n\n/**\n * Event creation flags\n */\ntypedef enum CUevent_flags_enum\n{\n    CU_EVENT_DEFAULT        = 0, /**< Default event flag */\n    CU_EVENT_BLOCKING_SYNC  = 1, /**< Event uses blocking synchronization */\n    CU_EVENT_DISABLE_TIMING = 2  /**< Event will not record timing data */\n} CUevent_flags;\n\n/**\n * Array formats\n */\ntypedef enum CUarray_format_enum\n{\n    CU_AD_FORMAT_UNSIGNED_INT8  = 0x01, /**< Unsigned 8-bit integers */\n    CU_AD_FORMAT_UNSIGNED_INT16 = 0x02, /**< Unsigned 16-bit integers */\n    CU_AD_FORMAT_UNSIGNED_INT32 = 0x03, /**< Unsigned 32-bit integers */\n    CU_AD_FORMAT_SIGNED_INT8    = 0x08, /**< Signed 8-bit integers */\n    CU_AD_FORMAT_SIGNED_INT16   = 0x09, /**< Signed 16-bit integers */\n    CU_AD_FORMAT_SIGNED_INT32   = 0x0a, /**< Signed 32-bit integers */\n    CU_AD_FORMAT_HALF           = 0x10, /**< 16-bit floating point */\n    CU_AD_FORMAT_FLOAT          = 0x20  /**< 32-bit floating point */\n} CUarray_format;\n\n/**\n * Texture reference addressing modes\n */\ntypedef enum CUaddress_mode_enum\n{\n    CU_TR_ADDRESS_MODE_WRAP   = 0, /**< Wrapping address mode */\n    CU_TR_ADDRESS_MODE_CLAMP  = 1, /**< Clamp to edge address mode */\n    CU_TR_ADDRESS_MODE_MIRROR = 2, /**< Mirror address mode */\n    CU_TR_ADDRESS_MODE_BORDER = 3  /**< Border address mode */\n} CUaddress_mode;\n\n/**\n * Texture reference filtering modes\n */\ntypedef enum CUfilter_mode_enum\n{\n    CU_TR_FILTER_MODE_POINT  = 0, /**< Point filter mode */\n    CU_TR_FILTER_MODE_LINEAR = 1  /**< Linear filter mode */\n} CUfilter_mode;\n\n/**\n * Device properties\n */\ntypedef enum CUdevice_attribute_enum\n{\n    CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 1,              /**< Maximum number of threads per block */\n    CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_X = 2,                    /**< Maximum block dimension X */\n    CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Y = 3,                    /**< Maximum block dimension Y */\n    CU_DEVICE_ATTRIBUTE_MAX_BLOCK_DIM_Z = 4,                    /**< Maximum block dimension Z */\n    CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_X = 5,                     /**< Maximum grid dimension X */\n    CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Y = 6,                     /**< Maximum grid dimension Y */\n    CU_DEVICE_ATTRIBUTE_MAX_GRID_DIM_Z = 7,                     /**< Maximum grid dimension Z */\n    CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK = 8,        /**< Maximum shared memory available per block in bytes */\n    CU_DEVICE_ATTRIBUTE_SHARED_MEMORY_PER_BLOCK = 8,            /**< Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_SHARED_MEMORY_PER_BLOCK */\n    CU_DEVICE_ATTRIBUTE_TOTAL_CONSTANT_MEMORY = 9,              /**< Memory available on device for __constant__ variables in a CUDA C kernel in bytes */\n    CU_DEVICE_ATTRIBUTE_WARP_SIZE = 10,                         /**< Warp size in threads */\n    CU_DEVICE_ATTRIBUTE_MAX_PITCH = 11,                         /**< Maximum pitch in bytes allowed by memory copies */\n    CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK = 12,           /**< Maximum number of 32-bit registers available per block */\n    CU_DEVICE_ATTRIBUTE_REGISTERS_PER_BLOCK = 12,               /**< Deprecated, use CU_DEVICE_ATTRIBUTE_MAX_REGISTERS_PER_BLOCK */\n    CU_DEVICE_ATTRIBUTE_CLOCK_RATE = 13,                        /**< Peak clock frequency in kilohertz */\n    CU_DEVICE_ATTRIBUTE_TEXTURE_ALIGNMENT = 14,                 /**< Alignment requirement for textures */\n    CU_DEVICE_ATTRIBUTE_GPU_OVERLAP = 15,                       /**< Device can possibly copy memory and execute a kernel concurrently */\n    CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT = 16,              /**< Number of multiprocessors on device */\n    CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT = 17,               /**< Specifies whether there is a run time limit on kernels */\n    CU_DEVICE_ATTRIBUTE_INTEGRATED = 18,                        /**< Device is integrated with host memory */\n    CU_DEVICE_ATTRIBUTE_CAN_MAP_HOST_MEMORY = 19,               /**< Device can map host memory into CUDA address space */\n    CU_DEVICE_ATTRIBUTE_COMPUTE_MODE = 20,                      /**< Compute mode (See ::CUcomputemode for details) */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_WIDTH = 21,           /**< Maximum 1D texture width */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_WIDTH = 22,           /**< Maximum 2D texture width */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_HEIGHT = 23,          /**< Maximum 2D texture height */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_WIDTH = 24,           /**< Maximum 3D texture width */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_HEIGHT = 25,          /**< Maximum 3D texture height */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE3D_DEPTH = 26,           /**< Maximum 3D texture depth */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_WIDTH = 27,     /**< Maximum texture array width */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_HEIGHT = 28,    /**< Maximum texture array height */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE2D_ARRAY_NUMSLICES = 29, /**< Maximum slices in a texture array */\n    CU_DEVICE_ATTRIBUTE_SURFACE_ALIGNMENT = 30,                 /**< Alignment requirement for surfaces */\n    CU_DEVICE_ATTRIBUTE_CONCURRENT_KERNELS = 31,                /**< Device can possibly execute multiple kernels concurrently */\n    CU_DEVICE_ATTRIBUTE_ECC_ENABLED = 32,                       /**< Device has ECC support enabled */\n    CU_DEVICE_ATTRIBUTE_PCI_BUS_ID = 33,                        /**< PCI bus ID of the device */\n    CU_DEVICE_ATTRIBUTE_PCI_DEVICE_ID = 34,                     /**< PCI device ID of the device */\n    CU_DEVICE_ATTRIBUTE_TCC_DRIVER = 35                         /**< Device is using TCC driver model */\n#if __CUDA_API_VERSION >= 4000\n  , CU_DEVICE_ATTRIBUTE_MEMORY_CLOCK_RATE = 36,                 /**< Peak memory clock frequency in kilohertz */\n    CU_DEVICE_ATTRIBUTE_GLOBAL_MEMORY_BUS_WIDTH = 37,           /**< Global memory bus width in bits */\n    CU_DEVICE_ATTRIBUTE_L2_CACHE_SIZE = 38,                     /**< Size of L2 cache in bytes */\n    CU_DEVICE_ATTRIBUTE_MAX_THREADS_PER_MULTIPROCESSOR = 39,    /**< Maximum resident threads per multiprocessor */\n    CU_DEVICE_ATTRIBUTE_ASYNC_ENGINE_COUNT = 40,                /**< Number of asynchronous engines */\n    CU_DEVICE_ATTRIBUTE_UNIFIED_ADDRESSING = 41,                /**< Device uses shares a unified address space with the host */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_WIDTH = 42,   /**< Maximum 1D layered texture width */\n    CU_DEVICE_ATTRIBUTE_MAXIMUM_TEXTURE1D_LAYERED_LAYERS = 43   /**< Maximum layers in a 1D layered texture */\n#endif\n} CUdevice_attribute;\n\n/**\n * Legacy device properties\n */\ntypedef struct CUdevprop_st\n{\n    int maxThreadsPerBlock;     /**< Maximum number of threads per block */\n    int maxThreadsDim[3];       /**< Maximum size of each dimension of a block */\n    int maxGridSize[3];         /**< Maximum size of each dimension of a grid */\n    int sharedMemPerBlock;      /**< Shared memory available per block in bytes */\n    int totalConstantMemory;    /**< Constant memory available on device in bytes */\n    int SIMDWidth;              /**< Warp size in threads */\n    int memPitch;               /**< Maximum pitch in bytes allowed by memory copies */\n    int regsPerBlock;           /**< 32-bit registers available per block */\n    int clockRate;              /**< Clock frequency in kilohertz */\n    int textureAlign;           /**< Alignment requirement for textures */\n} CUdevprop;\n\n/**\n * Function properties\n */\ntypedef enum CUfunction_attribute_enum\n{\n    /**\n     * The maximum number of threads per block, beyond which a launch of the\n     * function would fail. This number depends on both the function and the\n     * device on which the function is currently loaded.\n     */\n    CU_FUNC_ATTRIBUTE_MAX_THREADS_PER_BLOCK = 0,\n\n    /**\n     * The size in bytes of statically-allocated shared memory required by\n     * this function. This does not include dynamically-allocated shared\n     * memory requested by the user at runtime.\n     */\n    CU_FUNC_ATTRIBUTE_SHARED_SIZE_BYTES = 1,\n\n    /**\n     * The size in bytes of user-allocated constant memory required by this\n     * function.\n     */\n    CU_FUNC_ATTRIBUTE_CONST_SIZE_BYTES = 2,\n\n    /**\n     * The size in bytes of local memory used by each thread of this function.\n     */\n    CU_FUNC_ATTRIBUTE_LOCAL_SIZE_BYTES = 3,\n\n    /**\n     * The number of registers used by each thread of this function.\n     */\n    CU_FUNC_ATTRIBUTE_NUM_REGS = 4,\n\n    /**\n     * The PTX virtual architecture version for which the function was\n     * compiled. This value is the major PTX version * 10 + the minor PTX\n     * version, so a PTX version 1.3 function would return the value 13.\n     * Note that this may return the undefined value of 0 for cubins\n     * compiled prior to CUDA 3.0.\n     */\n    CU_FUNC_ATTRIBUTE_PTX_VERSION = 5,\n\n    /**\n     * The binary architecture version for which the function was compiled.\n     * This value is the major binary version * 10 + the minor binary version,\n     * so a binary version 1.3 function would return the value 13. Note that\n     * this will return a value of 10 for legacy cubins that do not have a\n     * properly-encoded binary architecture version.\n     */\n    CU_FUNC_ATTRIBUTE_BINARY_VERSION = 6,\n\n    CU_FUNC_ATTRIBUTE_MAX\n} CUfunction_attribute;\n\n/**\n * Function cache configurations\n */\ntypedef enum CUfunc_cache_enum\n{\n    CU_FUNC_CACHE_PREFER_NONE    = 0x00, /**< no preference for shared memory or L1 (default) */\n    CU_FUNC_CACHE_PREFER_SHARED  = 0x01, /**< prefer larger shared memory and smaller L1 cache */\n    CU_FUNC_CACHE_PREFER_L1      = 0x02  /**< prefer larger L1 cache and smaller shared memory */\n} CUfunc_cache;\n\n/**\n * Memory types\n */\ntypedef enum CUmemorytype_enum\n{\n    CU_MEMORYTYPE_HOST    = 0x01,    /**< Host memory */\n    CU_MEMORYTYPE_DEVICE  = 0x02,    /**< Device memory */\n    CU_MEMORYTYPE_ARRAY   = 0x03     /**< Array memory */\n#if __CUDA_API_VERSION >= 4000\n  , CU_MEMORYTYPE_UNIFIED = 0x04     /**< Unified device or host memory */\n#endif\n} CUmemorytype;\n\n/**\n * Compute Modes\n */\ntypedef enum CUcomputemode_enum\n{\n    CU_COMPUTEMODE_DEFAULT           = 0,  /**< Default compute mode (Multiple contexts allowed per device) */\n    CU_COMPUTEMODE_EXCLUSIVE         = 1, /**< Compute-exclusive-thread mode (Only one context used by a single thread can be present on this device at a time) */\n    CU_COMPUTEMODE_PROHIBITED        = 2  /**< Compute-prohibited mode (No contexts can be created on this device at this time) */\n#if __CUDA_API_VERSION >= 4000\n  , CU_COMPUTEMODE_EXCLUSIVE_PROCESS = 3  /**< Compute-exclusive-process mode (Only one context used by a single process can be present on this device at a time) */\n#endif\n} CUcomputemode;\n\n/**\n * Online compiler options\n */\ntypedef enum CUjit_option_enum\n{\n    /**\n     * Max number of registers that a thread may use.\\n\n     * Option type: unsigned int\n     */\n    CU_JIT_MAX_REGISTERS = 0,\n\n    /**\n     * IN: Specifies minimum number of threads per block to target compilation\n     * for\\n\n     * OUT: Returns the number of threads the compiler actually targeted.\n     * This restricts the resource utilization fo the compiler (e.g. max\n     * registers) such that a block with the given number of threads should be\n     * able to launch based on register limitations. Note, this option does not\n     * currently take into account any other resource limitations, such as\n     * shared memory utilization.\\n\n     * Option type: unsigned int\n     */\n    CU_JIT_THREADS_PER_BLOCK,\n\n    /**\n     * Returns a float value in the option of the wall clock time, in\n     * milliseconds, spent creating the cubin\\n\n     * Option type: float\n     */\n    CU_JIT_WALL_TIME,\n\n    /**\n     * Pointer to a buffer in which to print any log messsages from PTXAS\n     * that are informational in nature (the buffer size is specified via\n     * option ::CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES) \\n\n     * Option type: char*\n     */\n    CU_JIT_INFO_LOG_BUFFER,\n\n    /**\n     * IN: Log buffer size in bytes.  Log messages will be capped at this size\n     * (including null terminator)\\n\n     * OUT: Amount of log buffer filled with messages\\n\n     * Option type: unsigned int\n     */\n    CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES,\n\n    /**\n     * Pointer to a buffer in which to print any log messages from PTXAS that\n     * reflect errors (the buffer size is specified via option\n     * ::CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES)\\n\n     * Option type: char*\n     */\n    CU_JIT_ERROR_LOG_BUFFER,\n\n    /**\n     * IN: Log buffer size in bytes.  Log messages will be capped at this size\n     * (including null terminator)\\n\n     * OUT: Amount of log buffer filled with messages\\n\n     * Option type: unsigned int\n     */\n    CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES,\n\n    /**\n     * Level of optimizations to apply to generated code (0 - 4), with 4\n     * being the default and highest level of optimizations.\\n\n     * Option type: unsigned int\n     */\n    CU_JIT_OPTIMIZATION_LEVEL,\n\n    /**\n     * No option value required. Determines the target based on the current\n     * attached context (default)\\n\n     * Option type: No option value needed\n     */\n    CU_JIT_TARGET_FROM_CUCONTEXT,\n\n    /**\n     * Target is chosen based on supplied ::CUjit_target_enum.\\n\n     * Option type: unsigned int for enumerated type ::CUjit_target_enum\n     */\n    CU_JIT_TARGET,\n\n    /**\n     * Specifies choice of fallback strategy if matching cubin is not found.\n     * Choice is based on supplied ::CUjit_fallback_enum.\\n\n     * Option type: unsigned int for enumerated type ::CUjit_fallback_enum\n     */\n    CU_JIT_FALLBACK_STRATEGY\n\n} CUjit_option;\n\n/**\n * Online compilation targets\n */\ntypedef enum CUjit_target_enum\n{\n    CU_TARGET_COMPUTE_10 = 0,   /**< Compute device class 1.0 */\n    CU_TARGET_COMPUTE_11,       /**< Compute device class 1.1 */\n    CU_TARGET_COMPUTE_12,       /**< Compute device class 1.2 */\n    CU_TARGET_COMPUTE_13,       /**< Compute device class 1.3 */\n    CU_TARGET_COMPUTE_20,       /**< Compute device class 2.0 */\n    CU_TARGET_COMPUTE_21        /**< Compute device class 2.1 */\n} CUjit_target;\n\n/**\n * Cubin matching fallback strategies\n */\ntypedef enum CUjit_fallback_enum\n{\n    CU_PREFER_PTX = 0,  /**< Prefer to compile ptx */\n\n    CU_PREFER_BINARY    /**< Prefer to fall back to compatible binary code */\n\n} CUjit_fallback;\n\n/**\n * Flags to register a graphics resource\n */\ntypedef enum CUgraphicsRegisterFlags_enum\n{\n    CU_GRAPHICS_REGISTER_FLAGS_NONE          = 0x00,\n    CU_GRAPHICS_REGISTER_FLAGS_READ_ONLY     = 0x01,\n    CU_GRAPHICS_REGISTER_FLAGS_WRITE_DISCARD = 0x02,\n    CU_GRAPHICS_REGISTER_FLAGS_SURFACE_LDST  = 0x04\n} CUgraphicsRegisterFlags;\n\n/**\n * Flags for mapping and unmapping interop resources\n */\ntypedef enum CUgraphicsMapResourceFlags_enum\n{\n    CU_GRAPHICS_MAP_RESOURCE_FLAGS_NONE          = 0x00,\n    CU_GRAPHICS_MAP_RESOURCE_FLAGS_READ_ONLY     = 0x01,\n    CU_GRAPHICS_MAP_RESOURCE_FLAGS_WRITE_DISCARD = 0x02\n} CUgraphicsMapResourceFlags;\n\n/**\n * Array indices for cube faces\n */\ntypedef enum CUarray_cubemap_face_enum\n{\n    CU_CUBEMAP_FACE_POSITIVE_X  = 0x00, /**< Positive X face of cubemap */\n    CU_CUBEMAP_FACE_NEGATIVE_X  = 0x01, /**< Negative X face of cubemap */\n    CU_CUBEMAP_FACE_POSITIVE_Y  = 0x02, /**< Positive Y face of cubemap */\n    CU_CUBEMAP_FACE_NEGATIVE_Y  = 0x03, /**< Negative Y face of cubemap */\n    CU_CUBEMAP_FACE_POSITIVE_Z  = 0x04, /**< Positive Z face of cubemap */\n    CU_CUBEMAP_FACE_NEGATIVE_Z  = 0x05  /**< Negative Z face of cubemap */\n} CUarray_cubemap_face;\n\n/**\n * Limits\n */\ntypedef enum CUlimit_enum\n{\n    CU_LIMIT_STACK_SIZE        = 0x00, /**< GPU thread stack size */\n    CU_LIMIT_PRINTF_FIFO_SIZE  = 0x01, /**< GPU printf FIFO size */\n    CU_LIMIT_MALLOC_HEAP_SIZE  = 0x02  /**< GPU malloc heap size */\n} CUlimit;\n\n/**\n * Error codes\n */\ntypedef enum cudaError_enum\n{\n    /**\n     * The API call returned with no errors. In the case of query calls, this\n     * can also mean that the operation being queried is complete (see\n     * ::cuEventQuery() and ::cuStreamQuery()).\n     */\n    CUDA_SUCCESS                              = 0,\n\n    /**\n     * This indicates that one or more of the parameters passed to the API call\n     * is not within an acceptable range of values.\n     */\n    CUDA_ERROR_INVALID_VALUE                  = 1,\n\n    /**\n     * The API call failed because it was unable to allocate enough memory to\n     * perform the requested operation.\n     */\n    CUDA_ERROR_OUT_OF_MEMORY                  = 2,\n\n    /**\n     * This indicates that the CUDA driver has not been initialized with\n     * ::cuInit() or that initialization has failed.\n     */\n    CUDA_ERROR_NOT_INITIALIZED                = 3,\n\n    /**\n     * This indicates that the CUDA driver is in the process of shutting down.\n     */\n    CUDA_ERROR_DEINITIALIZED                  = 4,\n\n    /**\n     * This indicates profiling APIs are called while application is running\n     * in visual profiler mode.\n    */\n    CUDA_ERROR_PROFILER_DISABLED           = 5,\n    /**\n     * This indicates profiling has not been initialized for this context.\n     * Call cuProfilerInitialize() to resolve this.\n    */\n    CUDA_ERROR_PROFILER_NOT_INITIALIZED       = 6,\n    /**\n     * This indicates profiler has already been started and probably\n     * cuProfilerStart() is incorrectly called.\n    */\n    CUDA_ERROR_PROFILER_ALREADY_STARTED       = 7,\n    /**\n     * This indicates profiler has already been stopped and probably\n     * cuProfilerStop() is incorrectly called.\n    */\n    CUDA_ERROR_PROFILER_ALREADY_STOPPED       = 8,\n    /**\n     * This indicates that no CUDA-capable devices were detected by the installed\n     * CUDA driver.\n     */\n    CUDA_ERROR_NO_DEVICE                      = 100,\n\n    /**\n     * This indicates that the device ordinal supplied by the user does not\n     * correspond to a valid CUDA device.\n     */\n    CUDA_ERROR_INVALID_DEVICE                 = 101,\n\n\n    /**\n     * This indicates that the device kernel image is invalid. This can also\n     * indicate an invalid CUDA module.\n     */\n    CUDA_ERROR_INVALID_IMAGE                  = 200,\n\n    /**\n     * This most frequently indicates that there is no context bound to the\n     * current thread. This can also be returned if the context passed to an\n     * API call is not a valid handle (such as a context that has had\n     * ::cuCtxDestroy() invoked on it). This can also be returned if a user\n     * mixes different API versions (i.e. 3010 context with 3020 API calls).\n     * See ::cuCtxGetApiVersion() for more details.\n     */\n    CUDA_ERROR_INVALID_CONTEXT                = 201,\n\n    /**\n     * This indicated that the context being supplied as a parameter to the\n     * API call was already the active context.\n     * \\deprecated\n     * This error return is deprecated as of CUDA 3.2. It is no longer an\n     * error to attempt to push the active context via ::cuCtxPushCurrent().\n     */\n    CUDA_ERROR_CONTEXT_ALREADY_CURRENT        = 202,\n\n    /**\n     * This indicates that a map or register operation has failed.\n     */\n    CUDA_ERROR_MAP_FAILED                     = 205,\n\n    /**\n     * This indicates that an unmap or unregister operation has failed.\n     */\n    CUDA_ERROR_UNMAP_FAILED                   = 206,\n\n    /**\n     * This indicates that the specified array is currently mapped and thus\n     * cannot be destroyed.\n     */\n    CUDA_ERROR_ARRAY_IS_MAPPED                = 207,\n\n    /**\n     * This indicates that the resource is already mapped.\n     */\n    CUDA_ERROR_ALREADY_MAPPED                 = 208,\n\n    /**\n     * This indicates that there is no kernel image available that is suitable\n     * for the device. This can occur when a user specifies code generation\n     * options for a particular CUDA source file that do not include the\n     * corresponding device configuration.\n     */\n    CUDA_ERROR_NO_BINARY_FOR_GPU              = 209,\n\n    /**\n     * This indicates that a resource has already been acquired.\n     */\n    CUDA_ERROR_ALREADY_ACQUIRED               = 210,\n\n    /**\n     * This indicates that a resource is not mapped.\n     */\n    CUDA_ERROR_NOT_MAPPED                     = 211,\n\n    /**\n     * This indicates that a mapped resource is not available for access as an\n     * array.\n     */\n    CUDA_ERROR_NOT_MAPPED_AS_ARRAY            = 212,\n\n    /**\n     * This indicates that a mapped resource is not available for access as a\n     * pointer.\n     */\n    CUDA_ERROR_NOT_MAPPED_AS_POINTER          = 213,\n\n    /**\n     * This indicates that an uncorrectable ECC error was detected during\n     * execution.\n     */\n    CUDA_ERROR_ECC_UNCORRECTABLE              = 214,\n\n    /**\n     * This indicates that the ::CUlimit passed to the API call is not\n     * supported by the active device.\n     */\n    CUDA_ERROR_UNSUPPORTED_LIMIT              = 215,\n\n    /**\n     * This indicates that the ::CUcontext passed to the API call can\n     * only be bound to a single CPU thread at a time but is already\n     * bound to a CPU thread.\n     */\n    CUDA_ERROR_CONTEXT_ALREADY_IN_USE         = 216,\n\n    /**\n     * This indicates that the device kernel source is invalid.\n     */\n    CUDA_ERROR_INVALID_SOURCE                 = 300,\n\n    /**\n     * This indicates that the file specified was not found.\n     */\n    CUDA_ERROR_FILE_NOT_FOUND                 = 301,\n\n    /**\n     * This indicates that a link to a shared object failed to resolve.\n     */\n    CUDA_ERROR_SHARED_OBJECT_SYMBOL_NOT_FOUND = 302,\n\n    /**\n     * This indicates that initialization of a shared object failed.\n     */\n    CUDA_ERROR_SHARED_OBJECT_INIT_FAILED      = 303,\n\n    /**\n     * This indicates that an OS call failed.\n     */\n    CUDA_ERROR_OPERATING_SYSTEM               = 304,\n\n\n    /**\n     * This indicates that a resource handle passed to the API call was not\n     * valid. Resource handles are opaque types like ::CUstream and ::CUevent.\n     */\n    CUDA_ERROR_INVALID_HANDLE                 = 400,\n\n\n    /**\n     * This indicates that a named symbol was not found. Examples of symbols\n     * are global/constant variable names, texture names, and surface names.\n     */\n    CUDA_ERROR_NOT_FOUND                      = 500,\n\n\n    /**\n     * This indicates that asynchronous operations issued previously have not\n     * completed yet. This result is not actually an error, but must be indicated\n     * differently than ::CUDA_SUCCESS (which indicates completion). Calls that\n     * may return this value include ::cuEventQuery() and ::cuStreamQuery().\n     */\n    CUDA_ERROR_NOT_READY                      = 600,\n\n\n    /**\n     * An exception occurred on the device while executing a kernel. Common\n     * causes include dereferencing an invalid device pointer and accessing\n     * out of bounds shared memory. The context cannot be used, so it must\n     * be destroyed (and a new one should be created). All existing device\n     * memory allocations from this context are invalid and must be\n     * reconstructed if the program is to continue using CUDA.\n     */\n    CUDA_ERROR_LAUNCH_FAILED                  = 700,\n\n    /**\n     * This indicates that a launch did not occur because it did not have\n     * appropriate resources. This error usually indicates that the user has\n     * attempted to pass too many arguments to the device kernel, or the\n     * kernel launch specifies too many threads for the kernel's register\n     * count. Passing arguments of the wrong size (i.e. a 64-bit pointer\n     * when a 32-bit int is expected) is equivalent to passing too many\n     * arguments and can also result in this error.\n     */\n    CUDA_ERROR_LAUNCH_OUT_OF_RESOURCES        = 701,\n\n    /**\n     * This indicates that the device kernel took too long to execute. This can\n     * only occur if timeouts are enabled - see the device attribute\n     * ::CU_DEVICE_ATTRIBUTE_KERNEL_EXEC_TIMEOUT for more information. The\n     * context cannot be used (and must be destroyed similar to\n     * ::CUDA_ERROR_LAUNCH_FAILED). All existing device memory allocations from\n     * this context are invalid and must be reconstructed if the program is to\n     * continue using CUDA.\n     */\n    CUDA_ERROR_LAUNCH_TIMEOUT                 = 702,\n\n    /**\n     * This error indicates a kernel launch that uses an incompatible texturing\n     * mode.\n     */\n    CUDA_ERROR_LAUNCH_INCOMPATIBLE_TEXTURING  = 703,\n\n    /**\n     * This error indicates that a call to ::cuCtxEnablePeerAccess() is\n     * trying to re-enable peer access to a context which has already\n     * had peer access to it enabled.\n     */\n    CUDA_ERROR_PEER_ACCESS_ALREADY_ENABLED = 704,\n\n    /**\n     * This error indicates that a call to ::cuMemPeerRegister is trying to\n     * register memory from a context which has not had peer access\n     * enabled yet via ::cuCtxEnablePeerAccess(), or that\n     * ::cuCtxDisablePeerAccess() is trying to disable peer access\n     * which has not been enabled yet.\n     */\n    CUDA_ERROR_PEER_ACCESS_NOT_ENABLED    = 705,\n\n    /**\n     * This error indicates that a call to ::cuMemPeerRegister is trying to\n     * register already-registered memory.\n     */\n    CUDA_ERROR_PEER_MEMORY_ALREADY_REGISTERED = 706,\n\n    /**\n     * This error indicates that a call to ::cuMemPeerUnregister is trying to\n     * unregister memory that has not been registered.\n     */\n    CUDA_ERROR_PEER_MEMORY_NOT_REGISTERED     = 707,\n\n    /**\n     * This error indicates that ::cuCtxCreate was called with the flag\n     * ::CU_CTX_PRIMARY on a device which already has initialized its\n     * primary context.\n     */\n    CUDA_ERROR_PRIMARY_CONTEXT_ACTIVE         = 708,\n\n    /**\n     * This error indicates that the context current to the calling thread\n     * has been destroyed using ::cuCtxDestroy, or is a primary context which\n     * has not yet been initialized.\n     */\n    CUDA_ERROR_CONTEXT_IS_DESTROYED           = 709,\n\n    /**\n     * This indicates that an unknown internal error has occurred.\n     */\n    CUDA_ERROR_UNKNOWN                        = 999\n} CUresult;\n\n#if __CUDA_API_VERSION >= 4000\n/**\n * If set, host memory is portable between CUDA contexts.\n * Flag for ::cuMemHostAlloc()\n */\n#define CU_MEMHOSTALLOC_PORTABLE        0x01\n\n/**\n * If set, host memory is mapped into CUDA address space and\n * ::cuMemHostGetDevicePointer() may be called on the host pointer.\n * Flag for ::cuMemHostAlloc()\n */\n#define CU_MEMHOSTALLOC_DEVICEMAP       0x02\n\n/**\n * If set, host memory is allocated as write-combined - fast to write,\n * faster to DMA, slow to read except via SSE4 streaming load instruction\n * (MOVNTDQA).\n * Flag for ::cuMemHostAlloc()\n */\n#define CU_MEMHOSTALLOC_WRITECOMBINED   0x04\n\n/**\n * If set, host memory is portable between CUDA contexts.\n * Flag for ::cuMemHostRegister()\n */\n#define CU_MEMHOSTREGISTER_PORTABLE     0x01\n\n/**\n * If set, host memory is mapped into CUDA address space and\n * ::cuMemHostGetDevicePointer() may be called on the host pointer.\n * Flag for ::cuMemHostRegister()\n */\n#define CU_MEMHOSTREGISTER_DEVICEMAP    0x02\n\n/**\n * If set, peer memory is mapped into CUDA address space and\n * ::cuMemPeerGetDevicePointer() may be called on the host pointer.\n * Flag for ::cuMemPeerRegister()\n */\n#define CU_MEMPEERREGISTER_DEVICEMAP    0x02\n#endif\n\n#if __CUDA_API_VERSION >= 3020\n/**\n * 2D memory copy parameters\n */\ntypedef struct CUDA_MEMCPY2D_st\n{\n    size_t srcXInBytes;         /**< Source X in bytes */\n    size_t srcY;                /**< Source Y */\n\n    CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */\n    const void *srcHost;        /**< Source host pointer */\n    CUdeviceptr srcDevice;      /**< Source device pointer */\n    CUarray srcArray;           /**< Source array reference */\n    size_t srcPitch;            /**< Source pitch (ignored when src is array) */\n\n    size_t dstXInBytes;         /**< Destination X in bytes */\n    size_t dstY;                /**< Destination Y */\n\n    CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */\n    void *dstHost;              /**< Destination host pointer */\n    CUdeviceptr dstDevice;      /**< Destination device pointer */\n    CUarray dstArray;           /**< Destination array reference */\n    size_t dstPitch;            /**< Destination pitch (ignored when dst is array) */\n\n    size_t WidthInBytes;        /**< Width of 2D memory copy in bytes */\n    size_t Height;              /**< Height of 2D memory copy */\n} CUDA_MEMCPY2D;\n\n/**\n * 3D memory copy parameters\n */\ntypedef struct CUDA_MEMCPY3D_st\n{\n    size_t srcXInBytes;         /**< Source X in bytes */\n    size_t srcY;                /**< Source Y */\n    size_t srcZ;                /**< Source Z */\n    size_t srcLOD;              /**< Source LOD */\n    CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */\n    const void *srcHost;        /**< Source host pointer */\n    CUdeviceptr srcDevice;      /**< Source device pointer */\n    CUarray srcArray;           /**< Source array reference */\n    void *reserved0;            /**< Must be NULL */\n    size_t srcPitch;            /**< Source pitch (ignored when src is array) */\n    size_t srcHeight;           /**< Source height (ignored when src is array; may be 0 if Depth==1) */\n\n    size_t dstXInBytes;         /**< Destination X in bytes */\n    size_t dstY;                /**< Destination Y */\n    size_t dstZ;                /**< Destination Z */\n    size_t dstLOD;              /**< Destination LOD */\n    CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */\n    void *dstHost;              /**< Destination host pointer */\n    CUdeviceptr dstDevice;      /**< Destination device pointer */\n    CUarray dstArray;           /**< Destination array reference */\n    void *reserved1;            /**< Must be NULL */\n    size_t dstPitch;            /**< Destination pitch (ignored when dst is array) */\n    size_t dstHeight;           /**< Destination height (ignored when dst is array; may be 0 if Depth==1) */\n\n    size_t WidthInBytes;        /**< Width of 3D memory copy in bytes */\n    size_t Height;              /**< Height of 3D memory copy */\n    size_t Depth;               /**< Depth of 3D memory copy */\n} CUDA_MEMCPY3D;\n\n/**\n * 3D memory cross-context copy parameters\n */\ntypedef struct CUDA_MEMCPY3D_PEER_st\n{\n    size_t srcXInBytes;         /**< Source X in bytes */\n    size_t srcY;                /**< Source Y */\n    size_t srcZ;                /**< Source Z */\n    size_t srcLOD;              /**< Source LOD */\n    CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */\n    const void *srcHost;        /**< Source host pointer */\n    CUdeviceptr srcDevice;      /**< Source device pointer */\n    CUarray srcArray;           /**< Source array reference */\n    CUcontext srcContext;       /**< Source context (ignored with srcMemoryType is ::CU_MEMORYTYPE_ARRAY) */\n    size_t srcPitch;            /**< Source pitch (ignored when src is array) */\n    size_t srcHeight;           /**< Source height (ignored when src is array; may be 0 if Depth==1) */\n\n    size_t dstXInBytes;         /**< Destination X in bytes */\n    size_t dstY;                /**< Destination Y */\n    size_t dstZ;                /**< Destination Z */\n    size_t dstLOD;              /**< Destination LOD */\n    CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */\n    void *dstHost;              /**< Destination host pointer */\n    CUdeviceptr dstDevice;      /**< Destination device pointer */\n    CUarray dstArray;           /**< Destination array reference */\n    CUcontext dstContext;       /**< Destination context (ignored with dstMemoryType is ::CU_MEMORYTYPE_ARRAY) */\n    size_t dstPitch;            /**< Destination pitch (ignored when dst is array) */\n    size_t dstHeight;           /**< Destination height (ignored when dst is array; may be 0 if Depth==1) */\n\n    size_t WidthInBytes;        /**< Width of 3D memory copy in bytes */\n    size_t Height;              /**< Height of 3D memory copy */\n    size_t Depth;               /**< Depth of 3D memory copy */\n} CUDA_MEMCPY3D_PEER;\n\n/**\n * Array descriptor\n */\ntypedef struct CUDA_ARRAY_DESCRIPTOR_st\n{\n    size_t Width;             /**< Width of array */\n    size_t Height;            /**< Height of array */\n\n    CUarray_format Format;    /**< Array format */\n    unsigned int NumChannels; /**< Channels per array element */\n} CUDA_ARRAY_DESCRIPTOR;\n\n/**\n * 3D array descriptor\n */\ntypedef struct CUDA_ARRAY3D_DESCRIPTOR_st\n{\n    size_t Width;             /**< Width of 3D array */\n    size_t Height;            /**< Height of 3D array */\n    size_t Depth;             /**< Depth of 3D array */\n\n    CUarray_format Format;    /**< Array format */\n    unsigned int NumChannels; /**< Channels per array element */\n    unsigned int Flags;       /**< Flags */\n} CUDA_ARRAY3D_DESCRIPTOR;\n\n#endif /* __CUDA_API_VERSION >= 3020 */\n\n/**\n * If set, the CUDA array is a collection of layers, where each layer is either a 1D\n * or a 2D array and the Depth member of CUDA_ARRAY3D_DESCRIPTOR specifies the number\n * of layers, not the depth of a 3D array.\n */\n#define CUDA_ARRAY3D_LAYERED        0x01\n\n/**\n * Deprecated, use CUDA_ARRAY3D_LAYERED\n */\n#define CUDA_ARRAY3D_2DARRAY        0x01\n\n/**\n * This flag must be set in order to bind a surface reference\n * to the CUDA array\n */\n#define CUDA_ARRAY3D_SURFACE_LDST   0x02\n\n/**\n * Override the texref format with a format inferred from the array.\n * Flag for ::cuTexRefSetArray()\n */\n#define CU_TRSA_OVERRIDE_FORMAT 0x01\n\n/**\n * Read the texture as integers rather than promoting the values to floats\n * in the range [0,1].\n * Flag for ::cuTexRefSetFlags()\n */\n#define CU_TRSF_READ_AS_INTEGER         0x01\n\n/**\n * Use normalized texture coordinates in the range [0,1) instead of [0,dim).\n * Flag for ::cuTexRefSetFlags()\n */\n#define CU_TRSF_NORMALIZED_COORDINATES  0x02\n\n/**\n * Perform sRGB->linear conversion during texture read.\n * Flag for ::cuTexRefSetFlags()\n */\n#define CU_TRSF_SRGB  0x10\n\n/**\n * End of array terminator for the \\p extra parameter to\n * ::cuLaunchKernel\n */\n#define CU_LAUNCH_PARAM_END            ((void*)0x00)\n\n/**\n * Indicator that the next value in the \\p extra parameter to\n * ::cuLaunchKernel will be a pointer to a buffer containing all kernel\n * parameters used for launching kernel \\p f.  This buffer needs to\n * honor all alignment/padding requirements of the individual parameters.\n * If ::CU_LAUNCH_PARAM_BUFFER_SIZE is not also specified in the\n * \\p extra array, then ::CU_LAUNCH_PARAM_BUFFER_POINTER will have no\n * effect.\n */\n#define CU_LAUNCH_PARAM_BUFFER_POINTER ((void*)0x01)\n\n/**\n * Indicator that the next value in the \\p extra parameter to\n * ::cuLaunchKernel will be a pointer to a size_t which contains the\n * size of the buffer specified with ::CU_LAUNCH_PARAM_BUFFER_POINTER.\n * It is required that ::CU_LAUNCH_PARAM_BUFFER_POINTER also be specified\n * in the \\p extra array if the value associated with\n * ::CU_LAUNCH_PARAM_BUFFER_SIZE is not zero.\n */\n#define CU_LAUNCH_PARAM_BUFFER_SIZE    ((void*)0x02)\n\n/**\n * For texture references loaded into the module, use default texunit from\n * texture reference.\n */\n#define CU_PARAM_TR_DEFAULT -1\n\n/**\n * CUDA API made obselete at API version 3020\n */\n#if defined(__CUDA_API_VERSION_INTERNAL)\n    #define CUdeviceptr                  CUdeviceptr_v1\n    #define CUDA_MEMCPY2D_st             CUDA_MEMCPY2D_v1_st\n    #define CUDA_MEMCPY2D                CUDA_MEMCPY2D_v1\n    #define CUDA_MEMCPY3D_st             CUDA_MEMCPY3D_v1_st\n    #define CUDA_MEMCPY3D                CUDA_MEMCPY3D_v1\n    #define CUDA_ARRAY_DESCRIPTOR_st     CUDA_ARRAY_DESCRIPTOR_v1_st\n    #define CUDA_ARRAY_DESCRIPTOR        CUDA_ARRAY_DESCRIPTOR_v1\n    #define CUDA_ARRAY3D_DESCRIPTOR_st   CUDA_ARRAY3D_DESCRIPTOR_v1_st\n    #define CUDA_ARRAY3D_DESCRIPTOR      CUDA_ARRAY3D_DESCRIPTOR_v1\n#endif /* CUDA_FORCE_LEGACY32_INTERNAL */\n\n#if defined(__CUDA_API_VERSION_INTERNAL) || __CUDA_API_VERSION < 3020\ntypedef unsigned int CUdeviceptr;\n\ntypedef struct CUDA_MEMCPY2D_st\n{\n    unsigned int srcXInBytes;   /**< Source X in bytes */\n    unsigned int srcY;          /**< Source Y */\n    CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */\n    const void *srcHost;        /**< Source host pointer */\n    CUdeviceptr srcDevice;      /**< Source device pointer */\n    CUarray srcArray;           /**< Source array reference */\n    unsigned int srcPitch;      /**< Source pitch (ignored when src is array) */\n\n    unsigned int dstXInBytes;   /**< Destination X in bytes */\n    unsigned int dstY;          /**< Destination Y */\n    CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */\n    void *dstHost;              /**< Destination host pointer */\n    CUdeviceptr dstDevice;      /**< Destination device pointer */\n    CUarray dstArray;           /**< Destination array reference */\n    unsigned int dstPitch;      /**< Destination pitch (ignored when dst is array) */\n\n    unsigned int WidthInBytes;  /**< Width of 2D memory copy in bytes */\n    unsigned int Height;        /**< Height of 2D memory copy */\n} CUDA_MEMCPY2D;\n\ntypedef struct CUDA_MEMCPY3D_st\n{\n    unsigned int srcXInBytes;   /**< Source X in bytes */\n    unsigned int srcY;          /**< Source Y */\n    unsigned int srcZ;          /**< Source Z */\n    unsigned int srcLOD;        /**< Source LOD */\n    CUmemorytype srcMemoryType; /**< Source memory type (host, device, array) */\n    const void *srcHost;        /**< Source host pointer */\n    CUdeviceptr srcDevice;      /**< Source device pointer */\n    CUarray srcArray;           /**< Source array reference */\n    void *reserved0;            /**< Must be NULL */\n    unsigned int srcPitch;      /**< Source pitch (ignored when src is array) */\n    unsigned int srcHeight;     /**< Source height (ignored when src is array; may be 0 if Depth==1) */\n\n    unsigned int dstXInBytes;   /**< Destination X in bytes */\n    unsigned int dstY;          /**< Destination Y */\n    unsigned int dstZ;          /**< Destination Z */\n    unsigned int dstLOD;        /**< Destination LOD */\n    CUmemorytype dstMemoryType; /**< Destination memory type (host, device, array) */\n    void *dstHost;              /**< Destination host pointer */\n    CUdeviceptr dstDevice;      /**< Destination device pointer */\n    CUarray dstArray;           /**< Destination array reference */\n    void *reserved1;            /**< Must be NULL */\n    unsigned int dstPitch;      /**< Destination pitch (ignored when dst is array) */\n    unsigned int dstHeight;     /**< Destination height (ignored when dst is array; may be 0 if Depth==1) */\n\n    unsigned int WidthInBytes;  /**< Width of 3D memory copy in bytes */\n    unsigned int Height;        /**< Height of 3D memory copy */\n    unsigned int Depth;         /**< Depth of 3D memory copy */\n} CUDA_MEMCPY3D;\n\ntypedef struct CUDA_ARRAY_DESCRIPTOR_st\n{\n    unsigned int Width;         /**< Width of array */\n    unsigned int Height;        /**< Height of array */\n\n    CUarray_format Format;      /**< Array format */\n    unsigned int NumChannels;   /**< Channels per array element */\n} CUDA_ARRAY_DESCRIPTOR;\n\ntypedef struct CUDA_ARRAY3D_DESCRIPTOR_st\n{\n    unsigned int Width;         /**< Width of 3D array */\n    unsigned int Height;        /**< Height of 3D array */\n    unsigned int Depth;         /**< Depth of 3D array */\n\n    CUarray_format Format;      /**< Array format */\n    unsigned int NumChannels;   /**< Channels per array element */\n    unsigned int Flags;         /**< Flags */\n} CUDA_ARRAY3D_DESCRIPTOR;\n\n#endif /* (__CUDA_API_VERSION_INTERNAL) || __CUDA_API_VERSION < 3020 */\n\n/*\n * If set, the CUDA array contains an array of 2D slices\n * and the Depth member of CUDA_ARRAY3D_DESCRIPTOR specifies\n * the number of slices, not the depth of a 3D array.\n */\n#define CUDA_ARRAY3D_2DARRAY        0x01\n\n/**\n * This flag must be set in order to bind a surface reference\n * to the CUDA array\n */\n#define CUDA_ARRAY3D_SURFACE_LDST   0x02\n\n/**\n * Override the texref format with a format inferred from the array.\n * Flag for ::cuTexRefSetArray()\n */\n#define CU_TRSA_OVERRIDE_FORMAT 0x01\n\n/**\n * Read the texture as integers rather than promoting the values to floats\n * in the range [0,1].\n * Flag for ::cuTexRefSetFlags()\n */\n#define CU_TRSF_READ_AS_INTEGER         0x01\n\n/**\n * Use normalized texture coordinates in the range [0,1) instead of [0,dim).\n * Flag for ::cuTexRefSetFlags()\n */\n#define CU_TRSF_NORMALIZED_COORDINATES  0x02\n\n/**\n * Perform sRGB->linear conversion during texture read.\n * Flag for ::cuTexRefSetFlags()\n */\n#define CU_TRSF_SRGB  0x10\n\n/**\n * For texture references loaded into the module, use default texunit from\n * texture reference.\n */\n#define CU_PARAM_TR_DEFAULT -1\n\n/** @} */ /* END CUDA_TYPES */\n\n#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)\n    #define CUDAAPI __stdcall\n#else\n    #define CUDAAPI\n#endif\n\n/**\n * \\defgroup CUDA_INITIALIZE Initialization\n *\n * This section describes the initialization functions of the low-level CUDA\n * driver application programming interface.\n *\n * @{\n */\n\n/*********************************\n ** Initialization\n *********************************/\ntypedef CUresult  CUDAAPI tcuInit(unsigned int Flags);\n\n/*********************************\n ** Driver Version Query\n *********************************/\ntypedef CUresult  CUDAAPI tcuDriverGetVersion(int *driverVersion);\n\n/************************************\n **\n **    Device management\n **\n ***********************************/\n\ntypedef CUresult  CUDAAPI tcuDeviceGet(CUdevice *device, int ordinal);\ntypedef CUresult  CUDAAPI tcuDeviceGetCount(int *count);\ntypedef CUresult  CUDAAPI tcuDeviceGetName(char *name, int len, CUdevice dev);\ntypedef CUresult  CUDAAPI tcuDeviceComputeCapability(int *major, int *minor, CUdevice dev);\n#if __CUDA_API_VERSION >= 3020\n    typedef CUresult  CUDAAPI tcuDeviceTotalMem(size_t *bytes, CUdevice dev);\n#else\n    typedef CUresult  CUDAAPI tcuDeviceTotalMem(unsigned int *bytes, CUdevice dev);\n#endif\n\ntypedef CUresult  CUDAAPI tcuDeviceGetProperties(CUdevprop *prop, CUdevice dev);\ntypedef CUresult  CUDAAPI tcuDeviceGetAttribute(int *pi, CUdevice_attribute attrib, CUdevice dev);\n\n/************************************\n **\n **    Context management\n **\n ***********************************/\ntypedef CUresult  CUDAAPI tcuCtxCreate(CUcontext *pctx, unsigned int flags, CUdevice dev);\ntypedef CUresult  CUDAAPI tcuCtxDestroy(CUcontext ctx);\ntypedef CUresult  CUDAAPI tcuCtxAttach(CUcontext *pctx, unsigned int flags);\ntypedef CUresult  CUDAAPI tcuCtxDetach(CUcontext ctx);\ntypedef CUresult  CUDAAPI tcuCtxPushCurrent(CUcontext ctx);\ntypedef CUresult  CUDAAPI tcuCtxPopCurrent(CUcontext *pctx);\n\ntypedef CUresult  CUDAAPI tcuCtxSetCurrent(CUcontext ctx);\ntypedef CUresult  CUDAAPI tcuCtxGetCurrent(CUcontext *pctx);\n\ntypedef CUresult  CUDAAPI tcuCtxGetDevice(CUdevice *device);\ntypedef CUresult  CUDAAPI tcuCtxSynchronize(void);\n\n\n/************************************\n **\n **    Module management\n **\n ***********************************/\ntypedef CUresult  CUDAAPI tcuModuleLoad(CUmodule *module, const char *fname);\ntypedef CUresult  CUDAAPI tcuModuleLoadData(CUmodule *module, const void *image);\ntypedef CUresult  CUDAAPI tcuModuleLoadDataEx(CUmodule *module, const void *image, unsigned int numOptions, CUjit_option *options, void **optionValues);\ntypedef CUresult  CUDAAPI tcuModuleLoadFatBinary(CUmodule *module, const void *fatCubin);\ntypedef CUresult  CUDAAPI tcuModuleUnload(CUmodule hmod);\ntypedef CUresult  CUDAAPI tcuModuleGetFunction(CUfunction *hfunc, CUmodule hmod, const char *name);\n\n#if __CUDA_API_VERSION >= 3020\n    typedef CUresult  CUDAAPI tcuModuleGetGlobal(CUdeviceptr *dptr, size_t *bytes, CUmodule hmod, const char *name);\n#else\n    typedef CUresult  CUDAAPI tcuModuleGetGlobal(CUdeviceptr *dptr, unsigned int *bytes, CUmodule hmod, const char *name);\n#endif\n\ntypedef CUresult  CUDAAPI tcuModuleGetTexRef(CUtexref *pTexRef, CUmodule hmod, const char *name);\ntypedef CUresult  CUDAAPI tcuModuleGetSurfRef(CUsurfref *pSurfRef, CUmodule hmod, const char *name);\n\n/************************************\n **\n **    Memory management\n **\n ***********************************/\n#if __CUDA_API_VERSION >= 3020\n    typedef CUresult CUDAAPI tcuMemGetInfo(size_t *free, size_t *total);\n    typedef CUresult CUDAAPI tcuMemAlloc(CUdeviceptr *dptr, size_t bytesize);\n    typedef CUresult CUDAAPI tcuMemGetAddressRange(CUdeviceptr *pbase, size_t *psize, CUdeviceptr dptr);\n    typedef CUresult CUDAAPI tcuMemAllocPitch(CUdeviceptr *dptr,\n                                              size_t *pPitch,\n                                              size_t WidthInBytes,\n                                              size_t Height,\n                                              // size of biggest r/w to be performed by kernels on this memory\n                                              // 4, 8 or 16 bytes\n                                              unsigned int ElementSizeBytes\n                                             );\n#else\n    typedef CUresult CUDAAPI tcuMemGetInfo(unsigned int *free, unsigned int *total);\n    typedef CUresult CUDAAPI tcuMemAlloc(CUdeviceptr *dptr, unsigned int bytesize);\n    typedef CUresult CUDAAPI tcuMemGetAddressRange(CUdeviceptr *pbase, unsigned int *psize, CUdeviceptr dptr);\n    typedef CUresult CUDAAPI tcuMemAllocPitch(CUdeviceptr *dptr,\n                                              unsigned int *pPitch,\n                                              unsigned int WidthInBytes,\n                                              unsigned int Height,\n                                              // size of biggest r/w to be performed by kernels on this memory\n                                              // 4, 8 or 16 bytes\n                                              unsigned int ElementSizeBytes\n                                             );\n#endif\n\ntypedef CUresult CUDAAPI tcuMemFree(CUdeviceptr dptr);\n\n#if __CUDA_API_VERSION >= 3020\n    typedef CUresult CUDAAPI tcuMemAllocHost(void **pp, size_t bytesize);\n#else\n    typedef CUresult CUDAAPI tcuMemAllocHost(void **pp, unsigned int bytesize);\n#endif\n\ntypedef CUresult CUDAAPI tcuMemFreeHost(void *p);\ntypedef CUresult CUDAAPI tcuMemHostAlloc(void **pp, size_t bytesize, unsigned int Flags);\n\ntypedef CUresult CUDAAPI tcuMemHostGetDevicePointer(CUdeviceptr *pdptr, void *p, unsigned int Flags);\ntypedef CUresult CUDAAPI tcuMemHostGetFlags(unsigned int *pFlags, void *p);\n\ntypedef CUresult CUDAAPI tcuMemHostRegister(void *p, size_t bytesize, unsigned int Flags);\ntypedef CUresult CUDAAPI tcuMemHostUnregister(void *p);;\ntypedef CUresult CUDAAPI tcuMemcpy(CUdeviceptr dst, CUdeviceptr src, size_t ByteCount);\ntypedef CUresult CUDAAPI tcuMemcpyPeer(CUdeviceptr dstDevice, CUcontext dstContext, CUdeviceptr srcDevice, CUcontext srcContext, size_t ByteCount);\n\n/************************************\n **\n **    Synchronous Memcpy\n **\n ** Intra-device memcpy's done with these functions may execute in parallel with the CPU,\n ** but if host memory is involved, they wait until the copy is done before returning.\n **\n ***********************************/\n// 1D functions\n#if __CUDA_API_VERSION >= 3020\n    // system <-> device memory\n    typedef CUresult  CUDAAPI tcuMemcpyHtoD(CUdeviceptr dstDevice, const void *srcHost, size_t ByteCount);\n    typedef CUresult  CUDAAPI tcuMemcpyDtoH(void *dstHost, CUdeviceptr srcDevice, size_t ByteCount);\n\n    // device <-> device memory\n    typedef CUresult  CUDAAPI tcuMemcpyDtoD(CUdeviceptr dstDevice, CUdeviceptr srcDevice, size_t ByteCount);\n\n    // device <-> array memory\n    typedef CUresult  CUDAAPI tcuMemcpyDtoA(CUarray dstArray, size_t dstOffset, CUdeviceptr srcDevice, size_t ByteCount);\n    typedef CUresult  CUDAAPI tcuMemcpyAtoD(CUdeviceptr dstDevice, CUarray srcArray, size_t srcOffset, size_t ByteCount);\n\n    // system <-> array memory\n    typedef CUresult  CUDAAPI tcuMemcpyHtoA(CUarray dstArray, size_t dstOffset, const void *srcHost, size_t ByteCount);\n    typedef CUresult  CUDAAPI tcuMemcpyAtoH(void *dstHost, CUarray srcArray, size_t srcOffset, size_t ByteCount);\n\n    // array <-> array memory\n    typedef CUresult  CUDAAPI tcuMemcpyAtoA(CUarray dstArray, size_t dstOffset, CUarray srcArray, size_t srcOffset, size_t ByteCount);\n#else\n    // system <-> device memory\n    typedef CUresult  CUDAAPI tcuMemcpyHtoD(CUdeviceptr dstDevice, const void *srcHost, unsigned int ByteCount);\n    typedef CUresult  CUDAAPI tcuMemcpyDtoH(void *dstHost, CUdeviceptr srcDevice, unsigned int ByteCount);\n\n    // device <-> device memory\n    typedef CUresult  CUDAAPI tcuMemcpyDtoD(CUdeviceptr dstDevice, CUdeviceptr srcDevice, unsigned int ByteCount);\n\n    // device <-> array memory\n    typedef CUresult  CUDAAPI tcuMemcpyDtoA(CUarray dstArray, unsigned int dstOffset, CUdeviceptr srcDevice, unsigned int ByteCount);\n    typedef CUresult  CUDAAPI tcuMemcpyAtoD(CUdeviceptr dstDevice, CUarray srcArray, unsigned int srcOffset, unsigned int ByteCount);\n\n    // system <-> array memory\n    typedef CUresult  CUDAAPI tcuMemcpyHtoA(CUarray dstArray, unsigned int dstOffset, const void *srcHost, unsigned int ByteCount);\n    typedef CUresult  CUDAAPI tcuMemcpyAtoH(void *dstHost, CUarray srcArray, unsigned int srcOffset, unsigned int ByteCount);\n\n    // array <-> array memory\n    typedef CUresult  CUDAAPI tcuMemcpyAtoA(CUarray dstArray, unsigned int dstOffset, CUarray srcArray, unsigned int srcOffset, unsigned int ByteCount);\n#endif\n\n// 2D memcpy\ntypedef CUresult  CUDAAPI tcuMemcpy2D(const CUDA_MEMCPY2D *pCopy);\ntypedef CUresult  CUDAAPI tcuMemcpy2DUnaligned(const CUDA_MEMCPY2D *pCopy);\n\n// 3D memcpy\ntypedef CUresult  CUDAAPI tcuMemcpy3D(const CUDA_MEMCPY3D *pCopy);\n\n/************************************\n **\n **    Asynchronous Memcpy\n **\n ** Any host memory involved must be DMA'able (e.g., allocated with cuMemAllocHost).\n ** memcpy's done with these functions execute in parallel with the CPU and, if\n ** the hardware is available, may execute in parallel with the GPU.\n ** Asynchronous memcpy must be accompanied by appropriate stream synchronization.\n **\n ***********************************/\n\n// 1D functions\n#if __CUDA_API_VERSION >= 3020\n    // system <-> device memory\n    typedef CUresult  CUDAAPI tcuMemcpyHtoDAsync(CUdeviceptr dstDevice,\n                                                 const void *srcHost, size_t ByteCount, CUstream hStream);\n    typedef CUresult  CUDAAPI tcuMemcpyDtoHAsync(void *dstHost,\n                                                 CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream);\n\n    // device <-> device memory\n    typedef CUresult  CUDAAPI tcuMemcpyDtoDAsync(CUdeviceptr dstDevice,\n                                                 CUdeviceptr srcDevice, size_t ByteCount, CUstream hStream);\n\n    // system <-> array memory\n    typedef CUresult  CUDAAPI tcuMemcpyHtoAAsync(CUarray dstArray, size_t dstOffset,\n                                                 const void *srcHost, size_t ByteCount, CUstream hStream);\n    typedef CUresult  CUDAAPI tcuMemcpyAtoHAsync(void *dstHost, CUarray srcArray, size_t srcOffset,\n                                                 size_t ByteCount, CUstream hStream);\n#else\n    // system <-> device memory\n    typedef CUresult  CUDAAPI tcuMemcpyHtoDAsync(CUdeviceptr dstDevice,\n                                                 const void *srcHost, unsigned int ByteCount, CUstream hStream);\n    typedef CUresult  CUDAAPI tcuMemcpyDtoHAsync(void *dstHost,\n                                                 CUdeviceptr srcDevice, unsigned int ByteCount, CUstream hStream);\n\n    // device <-> device memory\n    typedef CUresult  CUDAAPI tcuMemcpyDtoDAsync(CUdeviceptr dstDevice,\n                                                 CUdeviceptr srcDevice, unsigned int ByteCount, CUstream hStream);\n\n    // system <-> array memory\n    typedef CUresult  CUDAAPI tcuMemcpyHtoAAsync(CUarray dstArray, unsigned int dstOffset,\n                                                 const void *srcHost, unsigned int ByteCount, CUstream hStream);\n    typedef CUresult  CUDAAPI tcuMemcpyAtoHAsync(void *dstHost, CUarray srcArray, unsigned int srcOffset,\n                                                 unsigned int ByteCount, CUstream hStream);\n#endif\n\n// 2D memcpy\ntypedef CUresult  CUDAAPI tcuMemcpy2DAsync(const CUDA_MEMCPY2D *pCopy, CUstream hStream);\n\n// 3D memcpy\ntypedef CUresult  CUDAAPI tcuMemcpy3DAsync(const CUDA_MEMCPY3D *pCopy, CUstream hStream);\n\n/************************************\n **\n **    Memset\n **\n ***********************************/\n#if __CUDA_API_VERSION >= 3020\n    typedef CUresult  CUDAAPI tcuMemsetD8(CUdeviceptr dstDevice, unsigned char uc, size_t N);\n    typedef CUresult  CUDAAPI tcuMemsetD16(CUdeviceptr dstDevice, unsigned short us, size_t N);\n    typedef CUresult  CUDAAPI tcuMemsetD32(CUdeviceptr dstDevice, unsigned int ui, size_t N);\n    typedef CUresult  CUDAAPI tcuMemsetD2D8(CUdeviceptr dstDevice, unsigned int dstPitch, unsigned char uc, size_t Width, size_t Height);\n    typedef CUresult  CUDAAPI tcuMemsetD2D16(CUdeviceptr dstDevice, unsigned int dstPitch, unsigned short us, size_t Width, size_t Height);\n    typedef CUresult  CUDAAPI tcuMemsetD2D32(CUdeviceptr dstDevice, unsigned int dstPitch, unsigned int ui, size_t Width, size_t Height);\n#else\n    typedef CUresult  CUDAAPI tcuMemsetD8(CUdeviceptr dstDevice, unsigned char uc, unsigned int N);\n    typedef CUresult  CUDAAPI tcuMemsetD16(CUdeviceptr dstDevice, unsigned short us, unsigned int N);\n    typedef CUresult  CUDAAPI tcuMemsetD32(CUdeviceptr dstDevice, unsigned int ui, unsigned int N);\n    typedef CUresult  CUDAAPI tcuMemsetD2D8(CUdeviceptr dstDevice, unsigned int dstPitch, unsigned char uc, unsigned int Width, unsigned int Height);\n    typedef CUresult  CUDAAPI tcuMemsetD2D16(CUdeviceptr dstDevice, unsigned int dstPitch, unsigned short us, unsigned int Width, unsigned int Height);\n    typedef CUresult  CUDAAPI tcuMemsetD2D32(CUdeviceptr dstDevice, unsigned int dstPitch, unsigned int ui, unsigned int Width, unsigned int Height);\n#endif\n\n/************************************\n **\n **    Function management\n **\n ***********************************/\n\n\ntypedef CUresult CUDAAPI tcuFuncSetBlockShape(CUfunction hfunc, int x, int y, int z);\ntypedef CUresult CUDAAPI tcuFuncSetSharedSize(CUfunction hfunc, unsigned int bytes);\ntypedef CUresult CUDAAPI tcuFuncGetAttribute(int *pi, CUfunction_attribute attrib, CUfunction hfunc);\ntypedef CUresult CUDAAPI tcuFuncSetCacheConfig(CUfunction hfunc, CUfunc_cache config);\ntypedef CUresult CUDAAPI tcuLaunchKernel(CUfunction f,\n                                         unsigned int gridDimX,  unsigned int gridDimY,  unsigned int gridDimZ,\n                                         unsigned int blockDimX, unsigned int blockDimY, unsigned int blockDimZ,\n                                         unsigned int sharedMemBytes,\n                                         CUstream hStream, void **kernelParams, void **extra);\n\n/************************************\n **\n **    Array management\n **\n ***********************************/\n\ntypedef CUresult  CUDAAPI tcuArrayCreate(CUarray *pHandle, const CUDA_ARRAY_DESCRIPTOR *pAllocateArray);\ntypedef CUresult  CUDAAPI tcuArrayGetDescriptor(CUDA_ARRAY_DESCRIPTOR *pArrayDescriptor, CUarray hArray);\ntypedef CUresult  CUDAAPI tcuArrayDestroy(CUarray hArray);\n\ntypedef CUresult  CUDAAPI tcuArray3DCreate(CUarray *pHandle, const CUDA_ARRAY3D_DESCRIPTOR *pAllocateArray);\ntypedef CUresult  CUDAAPI tcuArray3DGetDescriptor(CUDA_ARRAY3D_DESCRIPTOR *pArrayDescriptor, CUarray hArray);\n\n\n/************************************\n **\n **    Texture reference management\n **\n ***********************************/\ntypedef CUresult  CUDAAPI tcuTexRefCreate(CUtexref *pTexRef);\ntypedef CUresult  CUDAAPI tcuTexRefDestroy(CUtexref hTexRef);\n\ntypedef CUresult  CUDAAPI tcuTexRefSetArray(CUtexref hTexRef, CUarray hArray, unsigned int Flags);\n\n#if __CUDA_API_VERSION >= 3020\n    typedef CUresult  CUDAAPI tcuTexRefSetAddress(size_t *ByteOffset, CUtexref hTexRef, CUdeviceptr dptr, size_t bytes);\n    typedef CUresult  CUDAAPI tcuTexRefSetAddress2D(CUtexref hTexRef, const CUDA_ARRAY_DESCRIPTOR *desc, CUdeviceptr dptr, size_t Pitch);\n#else\n    typedef CUresult  CUDAAPI tcuTexRefSetAddress(unsigned int *ByteOffset, CUtexref hTexRef, CUdeviceptr dptr, unsigned int bytes);\n    typedef CUresult  CUDAAPI tcuTexRefSetAddress2D(CUtexref hTexRef, const CUDA_ARRAY_DESCRIPTOR *desc, CUdeviceptr dptr, unsigned int Pitch);\n#endif\n\ntypedef CUresult  CUDAAPI tcuTexRefSetFormat(CUtexref hTexRef, CUarray_format fmt, int NumPackedComponents);\ntypedef CUresult  CUDAAPI tcuTexRefSetAddressMode(CUtexref hTexRef, int dim, CUaddress_mode am);\ntypedef CUresult  CUDAAPI tcuTexRefSetFilterMode(CUtexref hTexRef, CUfilter_mode fm);\ntypedef CUresult  CUDAAPI tcuTexRefSetFlags(CUtexref hTexRef, unsigned int Flags);\n\ntypedef CUresult  CUDAAPI tcuTexRefGetAddress(CUdeviceptr *pdptr, CUtexref hTexRef);\ntypedef CUresult  CUDAAPI tcuTexRefGetArray(CUarray *phArray, CUtexref hTexRef);\ntypedef CUresult  CUDAAPI tcuTexRefGetAddressMode(CUaddress_mode *pam, CUtexref hTexRef, int dim);\ntypedef CUresult  CUDAAPI tcuTexRefGetFilterMode(CUfilter_mode *pfm, CUtexref hTexRef);\ntypedef CUresult  CUDAAPI tcuTexRefGetFormat(CUarray_format *pFormat, int *pNumChannels, CUtexref hTexRef);\ntypedef CUresult  CUDAAPI tcuTexRefGetFlags(unsigned int *pFlags, CUtexref hTexRef);\n\n/************************************\n **\n **    Surface reference management\n **\n ***********************************/\ntypedef CUresult  CUDAAPI tcuSurfRefSetArray(CUsurfref hSurfRef, CUarray hArray, unsigned int Flags);\ntypedef CUresult  CUDAAPI tcuSurfRefGetArray(CUarray *phArray, CUsurfref hSurfRef);\n\n/************************************\n **\n **    Parameter management\n **\n ***********************************/\n\ntypedef CUresult  CUDAAPI tcuParamSetSize(CUfunction hfunc, unsigned int numbytes);\ntypedef CUresult  CUDAAPI tcuParamSeti(CUfunction hfunc, int offset, unsigned int value);\ntypedef CUresult  CUDAAPI tcuParamSetf(CUfunction hfunc, int offset, float value);\ntypedef CUresult  CUDAAPI tcuParamSetv(CUfunction hfunc, int offset, void *ptr, unsigned int numbytes);\ntypedef CUresult  CUDAAPI tcuParamSetTexRef(CUfunction hfunc, int texunit, CUtexref hTexRef);\n\n\n/************************************\n **\n **    Launch functions\n **\n ***********************************/\n\ntypedef CUresult CUDAAPI tcuLaunch(CUfunction f);\ntypedef CUresult CUDAAPI tcuLaunchGrid(CUfunction f, int grid_width, int grid_height);\ntypedef CUresult CUDAAPI tcuLaunchGridAsync(CUfunction f, int grid_width, int grid_height, CUstream hStream);\n\n/************************************\n **\n **    Events\n **\n ***********************************/\ntypedef CUresult CUDAAPI tcuEventCreate(CUevent *phEvent, unsigned int Flags);\ntypedef CUresult CUDAAPI tcuEventRecord(CUevent hEvent, CUstream hStream);\ntypedef CUresult CUDAAPI tcuEventQuery(CUevent hEvent);\ntypedef CUresult CUDAAPI tcuEventSynchronize(CUevent hEvent);\ntypedef CUresult CUDAAPI tcuEventDestroy(CUevent hEvent);\ntypedef CUresult CUDAAPI tcuEventElapsedTime(float *pMilliseconds, CUevent hStart, CUevent hEnd);\n\n/************************************\n **\n **    Streams\n **\n ***********************************/\ntypedef CUresult CUDAAPI  tcuStreamCreate(CUstream *phStream, unsigned int Flags);\ntypedef CUresult CUDAAPI  tcuStreamQuery(CUstream hStream);\ntypedef CUresult CUDAAPI  tcuStreamSynchronize(CUstream hStream);\ntypedef CUresult CUDAAPI  tcuStreamDestroy(CUstream hStream);\n\n/************************************\n **\n **    Graphics interop\n **\n ***********************************/\ntypedef CUresult CUDAAPI tcuGraphicsUnregisterResource(CUgraphicsResource resource);\ntypedef CUresult CUDAAPI tcuGraphicsSubResourceGetMappedArray(CUarray *pArray, CUgraphicsResource resource, unsigned int arrayIndex, unsigned int mipLevel);\n\n#if __CUDA_API_VERSION >= 3020\n    typedef CUresult CUDAAPI tcuGraphicsResourceGetMappedPointer(CUdeviceptr *pDevPtr, size_t *pSize, CUgraphicsResource resource);\n#else\n    typedef CUresult CUDAAPI tcuGraphicsResourceGetMappedPointer(CUdeviceptr *pDevPtr, unsigned int *pSize, CUgraphicsResource resource);\n#endif\n\ntypedef CUresult CUDAAPI tcuGraphicsResourceSetMapFlags(CUgraphicsResource resource, unsigned int flags);\ntypedef CUresult CUDAAPI tcuGraphicsMapResources(unsigned int count, CUgraphicsResource *resources, CUstream hStream);\ntypedef CUresult CUDAAPI tcuGraphicsUnmapResources(unsigned int count, CUgraphicsResource *resources, CUstream hStream);\n\n/************************************\n **\n **    Export tables\n **\n ***********************************/\ntypedef CUresult CUDAAPI tcuGetExportTable(const void **ppExportTable, const CUuuid *pExportTableId);\n\n/************************************\n **\n **    Limits\n **\n ***********************************/\n\ntypedef CUresult CUDAAPI tcuCtxSetLimit(CUlimit limit, size_t value);\ntypedef CUresult CUDAAPI tcuCtxGetLimit(size_t *pvalue, CUlimit limit);\n\n\nextern tcuDriverGetVersion             *cuDriverGetVersion;\nextern tcuDeviceGet                    *cuDeviceGet;\nextern tcuDeviceGetCount               *cuDeviceGetCount;\nextern tcuDeviceGetName                *cuDeviceGetName;\nextern tcuDeviceComputeCapability      *cuDeviceComputeCapability;\nextern tcuDeviceGetProperties          *cuDeviceGetProperties;\nextern tcuDeviceGetAttribute           *cuDeviceGetAttribute;\nextern tcuCtxDestroy                   *cuCtxDestroy;\nextern tcuCtxAttach                    *cuCtxAttach;\nextern tcuCtxDetach                    *cuCtxDetach;\nextern tcuCtxPushCurrent               *cuCtxPushCurrent;\nextern tcuCtxPopCurrent                *cuCtxPopCurrent;\n\nextern tcuCtxSetCurrent                *cuCtxSetCurrent;\nextern tcuCtxGetCurrent                *cuCtxGetCurrent;\n\nextern tcuCtxGetDevice                 *cuCtxGetDevice;\nextern tcuCtxSynchronize               *cuCtxSynchronize;\nextern tcuModuleLoad                   *cuModuleLoad;\nextern tcuModuleLoadData               *cuModuleLoadData;\nextern tcuModuleLoadDataEx             *cuModuleLoadDataEx;\nextern tcuModuleLoadFatBinary          *cuModuleLoadFatBinary;\nextern tcuModuleUnload                 *cuModuleUnload;\nextern tcuModuleGetFunction            *cuModuleGetFunction;\nextern tcuModuleGetTexRef              *cuModuleGetTexRef;\nextern tcuModuleGetSurfRef             *cuModuleGetSurfRef;\nextern tcuMemFreeHost                  *cuMemFreeHost;\nextern tcuMemHostAlloc                 *cuMemHostAlloc;\nextern tcuMemHostGetFlags              *cuMemHostGetFlags;\n\nextern tcuMemHostRegister              *cuMemHostRegister;\nextern tcuMemHostUnregister            *cuMemHostUnregister;\nextern tcuMemcpy                       *cuMemcpy;\nextern tcuMemcpyPeer                   *cuMemcpyPeer;\n\nextern tcuDeviceTotalMem               *cuDeviceTotalMem;\nextern tcuCtxCreate                    *cuCtxCreate;\nextern tcuModuleGetGlobal              *cuModuleGetGlobal;\nextern tcuMemGetInfo                   *cuMemGetInfo;\nextern tcuMemAlloc                     *cuMemAlloc;\nextern tcuMemAllocPitch                *cuMemAllocPitch;\nextern tcuMemFree                      *cuMemFree;\nextern tcuMemGetAddressRange           *cuMemGetAddressRange;\nextern tcuMemAllocHost                 *cuMemAllocHost;\nextern tcuMemHostGetDevicePointer      *cuMemHostGetDevicePointer;\nextern tcuFuncSetBlockShape            *cuFuncSetBlockShape;\nextern tcuFuncSetSharedSize            *cuFuncSetSharedSize;\nextern tcuFuncGetAttribute             *cuFuncGetAttribute;\nextern tcuFuncSetCacheConfig           *cuFuncSetCacheConfig;\nextern tcuLaunchKernel                 *cuLaunchKernel;\nextern tcuArrayDestroy                 *cuArrayDestroy;\nextern tcuTexRefCreate                 *cuTexRefCreate;\nextern tcuTexRefDestroy                *cuTexRefDestroy;\nextern tcuTexRefSetArray               *cuTexRefSetArray;\nextern tcuTexRefSetFormat              *cuTexRefSetFormat;\nextern tcuTexRefSetAddressMode         *cuTexRefSetAddressMode;\nextern tcuTexRefSetFilterMode          *cuTexRefSetFilterMode;\nextern tcuTexRefSetFlags               *cuTexRefSetFlags;\nextern tcuTexRefGetArray               *cuTexRefGetArray;\nextern tcuTexRefGetAddressMode         *cuTexRefGetAddressMode;\nextern tcuTexRefGetFilterMode          *cuTexRefGetFilterMode;\nextern tcuTexRefGetFormat              *cuTexRefGetFormat;\nextern tcuTexRefGetFlags               *cuTexRefGetFlags;\nextern tcuSurfRefSetArray              *cuSurfRefSetArray;\nextern tcuSurfRefGetArray              *cuSurfRefGetArray;\nextern tcuParamSetSize                 *cuParamSetSize;\nextern tcuParamSeti                    *cuParamSeti;\nextern tcuParamSetf                    *cuParamSetf;\nextern tcuParamSetv                    *cuParamSetv;\nextern tcuParamSetTexRef               *cuParamSetTexRef;\nextern tcuLaunch                       *cuLaunch;\nextern tcuLaunchGrid                   *cuLaunchGrid;\nextern tcuLaunchGridAsync              *cuLaunchGridAsync;\nextern tcuEventCreate                  *cuEventCreate;\nextern tcuEventRecord                  *cuEventRecord;\nextern tcuEventQuery                   *cuEventQuery;\nextern tcuEventSynchronize             *cuEventSynchronize;\nextern tcuEventDestroy                 *cuEventDestroy;\nextern tcuEventElapsedTime             *cuEventElapsedTime;\nextern tcuStreamCreate                 *cuStreamCreate;\nextern tcuStreamQuery                  *cuStreamQuery;\nextern tcuStreamSynchronize            *cuStreamSynchronize;\nextern tcuStreamDestroy                *cuStreamDestroy;\nextern tcuGraphicsUnregisterResource   *cuGraphicsUnregisterResource;\nextern tcuGraphicsSubResourceGetMappedArray  *cuGraphicsSubResourceGetMappedArray;\nextern tcuGraphicsResourceSetMapFlags  *cuGraphicsResourceSetMapFlags;\nextern tcuGraphicsMapResources         *cuGraphicsMapResources;\nextern tcuGraphicsUnmapResources       *cuGraphicsUnmapResources;\nextern tcuGetExportTable               *cuGetExportTable;\nextern tcuCtxSetLimit                  *cuCtxSetLimit;\nextern tcuCtxGetLimit                  *cuCtxGetLimit;\n\n// These functions could be using the CUDA 3.2 interface (_v2)\nextern tcuMemcpyHtoD                   *cuMemcpyHtoD;\nextern tcuMemcpyDtoH                   *cuMemcpyDtoH;\nextern tcuMemcpyDtoD                   *cuMemcpyDtoD;\nextern tcuMemcpyDtoA                   *cuMemcpyDtoA;\nextern tcuMemcpyAtoD                   *cuMemcpyAtoD;\nextern tcuMemcpyHtoA                   *cuMemcpyHtoA;\nextern tcuMemcpyAtoH                   *cuMemcpyAtoH;\nextern tcuMemcpyAtoA                   *cuMemcpyAtoA;\nextern tcuMemcpy2D                     *cuMemcpy2D;\nextern tcuMemcpy2DUnaligned            *cuMemcpy2DUnaligned;\nextern tcuMemcpy3D                     *cuMemcpy3D;\nextern tcuMemcpyHtoDAsync              *cuMemcpyHtoDAsync;\nextern tcuMemcpyDtoHAsync              *cuMemcpyDtoHAsync;\nextern tcuMemcpyDtoDAsync              *cuMemcpyDtoDAsync;\nextern tcuMemcpyHtoAAsync              *cuMemcpyHtoAAsync;\nextern tcuMemcpyAtoHAsync              *cuMemcpyAtoHAsync;\nextern tcuMemcpy2DAsync                *cuMemcpy2DAsync;\nextern tcuMemcpy3DAsync                *cuMemcpy3DAsync;\nextern tcuMemsetD8                     *cuMemsetD8;\nextern tcuMemsetD16                    *cuMemsetD16;\nextern tcuMemsetD32                    *cuMemsetD32;\nextern tcuMemsetD2D8                   *cuMemsetD2D8;\nextern tcuMemsetD2D16                  *cuMemsetD2D16;\nextern tcuMemsetD2D32                  *cuMemsetD2D32;\nextern tcuArrayCreate                  *cuArrayCreate;\nextern tcuArrayGetDescriptor           *cuArrayGetDescriptor;\nextern tcuArray3DCreate                *cuArray3DCreate;\nextern tcuArray3DGetDescriptor         *cuArray3DGetDescriptor;\nextern tcuTexRefSetAddress             *cuTexRefSetAddress;\nextern tcuTexRefSetAddress2D           *cuTexRefSetAddress2D;\nextern tcuTexRefGetAddress             *cuTexRefGetAddress;\nextern tcuGraphicsResourceGetMappedPointer   *cuGraphicsResourceGetMappedPointer;\n\n/************************************/\nCUresult CUDAAPI cuInit   (unsigned int, int cudaVersion, void *hHandleDriver);\n/************************************/\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif //__cuda_cuda_h__\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/cuvid/dynlink_cuda_d3d.h",
    "content": "/*\n * Copyright 1993-2015 NVIDIA Corporation.  All rights reserved.\n *\n * Please refer to the NVIDIA end user license agreement (EULA) associated\n * with this source code for terms and conditions that govern your use of\n * this software. Any use, reproduction, disclosure, or distribution of\n * this software and related documentation outside the terms of the EULA\n * is strictly prohibited.\n *\n */\n\n#ifndef __cuda_d3d_h__\n#define __cuda_d3d_h__\n\n#if defined(WIN32) || defined(_WIN32) || defined(WIN64) || defined(_WIN64)\n#pragma warning(disable: 4312)\n\n#if defined (CUDA_INIT_D3D9) || defined(CUDA_INIT_D3D10) || defined(CUDA_INIT_D3D11)\n#include <Windows.h>\n#include <mmsystem.h>\n#endif\n\n#ifdef CUDA_INIT_D3D9\n#pragma warning( disable : 4996 ) // disable deprecated warning \n#include <strsafe.h>\n#pragma warning( default : 4996 )\n\n/**\n * CUDA 2.x compatibility - Flags to register a D3D9 graphics resource\n */\ntypedef enum CUd3d9register_flags_enum\n{\n    CU_D3D9_REGISTER_FLAGS_NONE  = 0x00,\n    CU_D3D9_REGISTER_FLAGS_ARRAY = 0x01,\n} CUd3d9register_flags;\n\n/**\n * CUDA 2.x compatibility - Flags for D3D9 mapping and unmapping interop resources\n */\ntypedef enum CUd3d9map_flags_enum\n{\n    CU_D3D9_MAPRESOURCE_FLAGS_NONE         = 0x00,\n    CU_D3D9_MAPRESOURCE_FLAGS_READONLY     = 0x01,\n    CU_D3D9_MAPRESOURCE_FLAGS_WRITEDISCARD = 0x02,\n} CUd3d9map_flags;\n\n// D3D9/CUDA interop (CUDA 1.x compatible API). These functions are deprecated, please use the ones below\ntypedef CUresult CUDAAPI tcuD3D9Begin(IDirect3DDevice9 *pDevice);\ntypedef CUresult CUDAAPI tcuD3D9End(void);\ntypedef CUresult CUDAAPI tcuD3D9RegisterVertexBuffer(IDirect3DVertexBuffer9 *pVB);\ntypedef CUresult CUDAAPI tcuD3D9MapVertexBuffer(CUdeviceptr *pDevPtr, unsigned int *pSize, IDirect3DVertexBuffer9 *pVB);\ntypedef CUresult CUDAAPI tcuD3D9UnmapVertexBuffer(IDirect3DVertexBuffer9 *pVB);\ntypedef CUresult CUDAAPI tcuD3D9UnregisterVertexBuffer(IDirect3DVertexBuffer9 *pVB);\n\n// D3D9/CUDA interop (CUDA 2.x compatible)\ntypedef CUresult CUDAAPI tcuD3D9GetDirect3DDevice(IDirect3DDevice9 **ppD3DDevice);\ntypedef CUresult CUDAAPI tcuD3D9RegisterResource(IDirect3DResource9 *pResource, unsigned int Flags);\ntypedef CUresult CUDAAPI tcuD3D9UnregisterResource(IDirect3DResource9 *pResource);\n\ntypedef CUresult CUDAAPI tcuD3D9MapResources(unsigned int count, IDirect3DResource9 **ppResource);\ntypedef CUresult CUDAAPI tcuD3D9UnmapResources(unsigned int count, IDirect3DResource9 **ppResource);\ntypedef CUresult CUDAAPI tcuD3D9ResourceSetMapFlags(IDirect3DResource9 *pResource, unsigned int Flags);\n\ntypedef CUresult CUDAAPI tcuD3D9ResourceGetSurfaceDimensions(unsigned int *pWidth, unsigned int *pHeight, unsigned int *pDepth, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);\ntypedef CUresult CUDAAPI tcuD3D9ResourceGetMappedArray(CUarray *pArray, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);\ntypedef CUresult CUDAAPI tcuD3D9ResourceGetMappedPointer(CUdeviceptr *pDevPtr, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);\ntypedef CUresult CUDAAPI tcuD3D9ResourceGetMappedSize(unsigned int *pSize, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);\ntypedef CUresult CUDAAPI tcuD3D9ResourceGetMappedPitch(unsigned int *pPitch, unsigned int *pPitchSlice, IDirect3DResource9 *pResource, unsigned int Face, unsigned int Level);\n\n// D3D9/CUDA interop (CUDA 2.0+)\ntypedef CUresult CUDAAPI tcuD3D9GetDevice(CUdevice *pCudaDevice, const char *pszAdapterName);\ntypedef CUresult CUDAAPI tcuD3D9CtxCreate(CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, IDirect3DDevice9 *pD3DDevice);\ntypedef CUresult CUDAAPI tcuGraphicsD3D9RegisterResource(CUgraphicsResource *pCudaResource, IDirect3DResource9 *pD3DResource, unsigned int Flags);\n#endif\n\n#ifdef CUDA_INIT_D3D10\n#include <dxgi.h>\n#include <d3d10_1.h>\n#include <d3d10.h>\n\n#pragma warning( disable : 4996 ) // disable deprecated warning \n#include <strsafe.h>\n#pragma warning( default : 4996 )\n\n// D3D11/CUDA interop (CUDA 3.0)\ntypedef CUresult CUDAAPI tcuD3D10GetDevice(CUdevice *pCudaDevice, IDXGIAdapter *pAdapter);\ntypedef CUresult CUDAAPI tcuD3D10CtxCreate(CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, ID3D10Device *pD3DDevice);\ntypedef CUresult CUDAAPI tcuGraphicsD3D10RegisterResource(CUgraphicsResource *pCudaResource, ID3D10Resource *pD3DResource, unsigned int Flags);\n#endif // CUDA_INIT_D3D10\n\n#ifdef CUDA_INIT_D3D11\n#include <dxgi.h>\n#include <d3d11.h>\n\n#pragma warning( disable : 4996 ) // disable deprecated warning \n#include <strsafe.h>\n#pragma warning( default : 4996 )\n\n// D3D11/CUDA interop (CUDA 3.0)\ntypedef CUresult CUDAAPI tcuD3D11GetDevice(CUdevice *pCudaDevice, IDXGIAdapter *pAdapter);\ntypedef CUresult CUDAAPI tcuD3D11CtxCreate(CUcontext *pCtx, CUdevice *pCudaDevice, unsigned int Flags, ID3D11Device *pD3DDevice);\ntypedef CUresult CUDAAPI tcuGraphicsD3D11RegisterResource(CUgraphicsResource *pCudaResource, ID3D11Resource *pD3DResource, unsigned int Flags);\n#endif // CUDA_INIT_D3D11\n\n#endif // WIN32\n\n#endif // __cuda_d3d_h__\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/cuvid/dynlink_cuviddec.h",
    "content": "/*\n * This copyright notice applies to this header file only:\n *\n * Copyright (c) 2010-2024 NVIDIA Corporation\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the software, and to permit persons to whom the\n * software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/*****************************************************************************************************/\n//! \\file cuviddec.h\n//! NVDECODE API provides video decoding interface to NVIDIA GPU devices.\n//! This file contains constants, structure definitions and function prototypes used for decoding.\n/*****************************************************************************************************/\n\n#if !defined(__CUDA_VIDEO_H__)\n#define __CUDA_VIDEO_H__\n\n#ifndef __dynlink_cuda_h__\n#include \"dynlink_cuda.h\"\n#endif // __dynlink_cuda_h__\n\n#if defined(_WIN64) || defined(__LP64__) || defined(__x86_64) || defined(AMD64) || defined(_M_AMD64)\n#if (CUDA_VERSION >= 3020) && (!defined(CUDA_FORCE_API_VERSION) || (CUDA_FORCE_API_VERSION >= 3020))\n#define __CUVID_DEVPTR64\n#endif\n#endif\n\n#if defined(__cplusplus)\nextern \"C\"\n{\n#endif /* __cplusplus */\n\n    typedef void *CUvideodecoder;\n    typedef struct _CUcontextlock_st *CUvideoctxlock;\n\n    /*********************************************************************************/\n    //! \\enum cudaVideoCodec\n    //! Video codec enums\n    //! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures\n    /*********************************************************************************/\n    typedef enum cudaVideoCodec_enum\n    {\n        cudaVideoCodec_MPEG1 = 0, /**<  MPEG1             */\n        cudaVideoCodec_MPEG2,     /**<  MPEG2             */\n        cudaVideoCodec_MPEG4,     /**<  MPEG4             */\n        cudaVideoCodec_VC1,       /**<  VC1               */\n        cudaVideoCodec_H264,      /**<  H264              */\n        cudaVideoCodec_JPEG,      /**<  JPEG              */\n        cudaVideoCodec_H264_SVC,  /**<  H264-SVC          */\n        cudaVideoCodec_H264_MVC,  /**<  H264-MVC          */\n        cudaVideoCodec_HEVC,      /**<  HEVC              */\n        cudaVideoCodec_VP8,       /**<  VP8               */\n        cudaVideoCodec_VP9,       /**<  VP9               */\n        cudaVideoCodec_AV1,       /**<  AV1               */\n        cudaVideoCodec_NumCodecs, /**<  Max codecs        */\n        // Uncompressed YUV\n        cudaVideoCodec_YUV420 = (('I' << 24) | ('Y' << 16) | ('U' << 8) | ('V')), /**< Y,U,V (4:2:0)      */\n        cudaVideoCodec_YV12 = (('Y' << 24) | ('V' << 16) | ('1' << 8) | ('2')),   /**< Y,V,U (4:2:0)      */\n        cudaVideoCodec_NV12 = (('N' << 24) | ('V' << 16) | ('1' << 8) | ('2')),   /**< Y,UV  (4:2:0)      */\n        cudaVideoCodec_YUYV = (('Y' << 24) | ('U' << 16) | ('Y' << 8) | ('V')),   /**< YUYV/YUY2 (4:2:2)  */\n        cudaVideoCodec_UYVY = (('U' << 24) | ('Y' << 16) | ('V' << 8) | ('Y'))    /**< UYVY (4:2:2)       */\n    } cudaVideoCodec;\n\n    /*********************************************************************************/\n    //! \\enum cudaVideoSurfaceFormat\n    //! Video surface format enums used for output format of decoded output\n    //! These enums are used in CUVIDDECODECREATEINFO structure\n    /*********************************************************************************/\n    typedef enum cudaVideoSurfaceFormat_enum\n    {\n        cudaVideoSurfaceFormat_NV12 = 0,         /**< Semi-Planar YUV [Y plane followed by interleaved UV plane]     */\n        cudaVideoSurfaceFormat_P016 = 1,         /**< 16 bit Semi-Planar YUV [Y plane followed by interleaved UV plane].\n                                                      Can be used for 10 bit(6LSB bits 0), 12 bit (4LSB bits 0)      */\n        cudaVideoSurfaceFormat_YUV444 = 2,       /**< Planar YUV [Y plane followed by U and V planes]                */\n        cudaVideoSurfaceFormat_YUV444_16Bit = 3, /**< 16 bit Planar YUV [Y plane followed by U and V planes].\n                                                      Can be used for 10 bit(6LSB bits 0), 12 bit (4LSB bits 0)      */\n    } cudaVideoSurfaceFormat;\n\n    /******************************************************************************************************************/\n    //! \\enum cudaVideoDeinterlaceMode\n    //! Deinterlacing mode enums\n    //! These enums are used in CUVIDDECODECREATEINFO structure\n    //! Use cudaVideoDeinterlaceMode_Weave for progressive content and for content that doesn't need deinterlacing\n    //! cudaVideoDeinterlaceMode_Adaptive needs more video memory than other DImodes\n    /******************************************************************************************************************/\n    typedef enum cudaVideoDeinterlaceMode_enum\n    {\n        cudaVideoDeinterlaceMode_Weave = 0, /**< Weave both fields (no deinterlacing) */\n        cudaVideoDeinterlaceMode_Bob,       /**< Drop one field                       */\n        cudaVideoDeinterlaceMode_Adaptive   /**< Adaptive deinterlacing               */\n    } cudaVideoDeinterlaceMode;\n\n    /**************************************************************************************************************/\n    //! \\enum cudaVideoChromaFormat\n    //! Chroma format enums\n    //! These enums are used in CUVIDDECODECREATEINFO and CUVIDDECODECAPS structures\n    /**************************************************************************************************************/\n    typedef enum cudaVideoChromaFormat_enum\n    {\n        cudaVideoChromaFormat_Monochrome = 0, /**< MonoChrome */\n        cudaVideoChromaFormat_420,            /**< YUV 4:2:0  */\n        cudaVideoChromaFormat_422,            /**< YUV 4:2:2  */\n        cudaVideoChromaFormat_444             /**< YUV 4:4:4  */\n    } cudaVideoChromaFormat;\n\n    /*************************************************************************************************************/\n    //! \\enum cudaVideoCreateFlags\n    //! Decoder flag enums to select preferred decode path\n    //! cudaVideoCreate_Default and cudaVideoCreate_PreferCUVID are most optimized, use these whenever possible\n    /*************************************************************************************************************/\n    typedef enum cudaVideoCreateFlags_enum\n    {\n        cudaVideoCreate_Default = 0x00, /**< Default operation mode: use dedicated video engines */\n        cudaVideoCreate_PreferCUDA =\n            0x01, /**< Use CUDA-based decoder (requires valid vidLock object for multi-threading) */\n        cudaVideoCreate_PreferDXVA = 0x02, /**< Go through DXVA internally if possible (requires D3D9 interop) */\n        cudaVideoCreate_PreferCUVID = 0x04 /**< Use dedicated video engines directly */\n    } cudaVideoCreateFlags;\n\n    /*************************************************************************/\n    //! \\enum cuvidDecodeStatus\n    //! Decode status enums\n    //! These enums are used in CUVIDGETDECODESTATUS structure\n    /*************************************************************************/\n    typedef enum cuvidDecodeStatus_enum\n    {\n        cuvidDecodeStatus_Invalid = 0,    // Decode status is not valid\n        cuvidDecodeStatus_InProgress = 1, // Decode is in progress\n        cuvidDecodeStatus_Success = 2,    // Decode is completed without any errors\n        // 3 to 7 enums are reserved for future use\n        cuvidDecodeStatus_Error = 8,           // Decode is completed with an error (error is not concealed)\n        cuvidDecodeStatus_Error_Concealed = 9, // Decode is completed with an error and error is concealed\n    } cuvidDecodeStatus;\n\n    /**************************************************************************************************************/\n    //! \\struct CUVIDDECODECAPS;\n    //! This structure is used in cuvidGetDecoderCaps API\n    /**************************************************************************************************************/\n    typedef struct _CUVIDDECODECAPS\n    {\n        cudaVideoCodec eCodecType;           /**< IN: cudaVideoCodec_XXX                                             */\n        cudaVideoChromaFormat eChromaFormat; /**< IN: cudaVideoChromaFormat_XXX                                      */\n        unsigned int nBitDepthMinus8;        /**< IN: The Value \"BitDepth minus 8\"                                   */\n        unsigned int reserved1[3];           /**< Reserved for future use - set to zero                              */\n\n        unsigned char bIsSupported;          /**< OUT: 1 if codec supported, 0 if not supported                      */\n        unsigned char nNumNVDECs;            /**< OUT: Number of NVDECs that can support IN params                   */\n        unsigned short nOutputFormatMask;    /**< OUT: each bit represents corresponding cudaVideoSurfaceFormat enum */\n        unsigned int nMaxWidth;              /**< OUT: Max supported coded width in pixels                           */\n        unsigned int nMaxHeight;             /**< OUT: Max supported coded height in pixels                          */\n        unsigned int nMaxMBCount;            /**< OUT: Max supported macroblock count\n                                                       CodedWidth*CodedHeight/256 must be <= nMaxMBCount             */\n        unsigned short nMinWidth;            /**< OUT: Min supported coded width in pixels                           */\n        unsigned short nMinHeight;           /**< OUT: Min supported coded height in pixels                          */\n        unsigned char bIsHistogramSupported; /**< OUT: 1 if Y component histogram output is supported, 0 if not\n                                                       Note: histogram is computed on original picture data before\n                                                       any post-processing like scaling, cropping, etc. is applied   */\n        unsigned char nCounterBitDepth;      /**< OUT: histogram counter bit depth                                   */\n        unsigned short nMaxHistogramBins;    /**< OUT: Max number of histogram bins                                  */\n        unsigned int reserved3[10];          /**< Reserved for future use - set to zero                              */\n    } CUVIDDECODECAPS;\n\n    /**************************************************************************************************************/\n    //! \\struct CUVIDDECODECREATEINFO\n    //! This structure is used in cuvidCreateDecoder API\n    /**************************************************************************************************************/\n    typedef struct _CUVIDDECODECREATEINFO\n    {\n        unsigned long ulWidth;  /**< IN: Coded sequence width in pixels                                             */\n        unsigned long ulHeight; /**< IN: Coded sequence height in pixels                                            */\n        unsigned long ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */\n        cudaVideoCodec CodecType; /**< IN: cudaVideoCodec_XXX                                                         */\n        cudaVideoChromaFormat ChromaFormat; /**< IN: cudaVideoChromaFormat_XXX */\n        unsigned long ulCreationFlags;      /**< IN: Decoder creation flags (cudaVideoCreateFlags_XXX)      */\n        unsigned long bitDepthMinus8;       /**< IN: The value \"BitDepth minus 8\"       */\n        unsigned long\n            ulIntraDecodeOnly;    /**< IN: Set 1 only if video has all intra frames (default value is 0). This will\n                                       optimize video memory for Intra frames only decoding. The support is limited\n                                       to specific codecs - H264, HEVC, VP9, the flag will be ignored for codecs which\n                                       are not supported. However decoding might fail if the flag is enabled in case\n                                       of supported codecs for regular bit streams having P and/or B frames.          */\n        unsigned long ulMaxWidth; /**< IN: Coded sequence max width in pixels used with reconfigure Decoder           */\n        unsigned long ulMaxHeight; /**< IN: Coded sequence max height in pixels used with reconfigure Decoder */\n        unsigned long Reserved1; /**< Reserved for future use - set to zero                                          */\n        /**\n         * IN: area of the frame that should be displayed\n         */\n        struct\n        {\n            short left;\n            short top;\n            short right;\n            short bottom;\n        } display_area;\n\n        cudaVideoSurfaceFormat OutputFormat; /**< IN: cudaVideoSurfaceFormat_XXX                                     */\n        cudaVideoDeinterlaceMode DeinterlaceMode; /**< IN: cudaVideoDeinterlaceMode_XXX */\n        unsigned long ulTargetWidth;       /**< IN: Post-processed output width (Should be aligned to 2)           */\n        unsigned long ulTargetHeight;      /**< IN: Post-processed output height (Should be aligned to 2)          */\n        unsigned long ulNumOutputSurfaces; /**< IN: Maximum number of output surfaces simultaneously mapped        */\n        CUvideoctxlock vidLock;            /**< IN: If non-NULL, context lock used for synchronizing ownership of\n                                                the cuda context. Needed for cudaVideoCreate_PreferCUDA decode     */\n        /**\n         * IN: target rectangle in the output frame (for aspect ratio conversion)\n         * if a null rectangle is specified, {0,0,ulTargetWidth,ulTargetHeight} will be used\n         */\n        struct\n        {\n            short left;\n            short top;\n            short right;\n            short bottom;\n        } target_rect;\n\n        unsigned long enableHistogram; /**< IN: enable histogram output, if supported */\n        unsigned long Reserved2[4];    /**< Reserved for future use - set to zero */\n    } CUVIDDECODECREATEINFO;\n\n    /*********************************************************/\n    //! \\struct CUVIDH264DPBENTRY\n    //! H.264 DPB entry\n    //! This structure is used in CUVIDH264PICPARAMS structure\n    /*********************************************************/\n    typedef struct _CUVIDH264DPBENTRY\n    {\n        int PicIdx;             /**< picture index of reference frame                                        */\n        int FrameIdx;           /**< frame_num(short-term) or LongTermFrameIdx(long-term)                    */\n        int is_long_term;       /**< 0=short term reference, 1=long term reference                           */\n        int not_existing;       /**< non-existing reference frame (corresponding PicIdx should be set to -1) */\n        int used_for_reference; /**< 0=unused, 1=top_field, 2=bottom_field, 3=both_fields                    */\n        int FieldOrderCnt[2];   /**< field order count of top and bottom fields                              */\n    } CUVIDH264DPBENTRY;\n\n    /************************************************************/\n    //! \\struct CUVIDH264MVCEXT\n    //! H.264 MVC picture parameters ext\n    //! This structure is used in CUVIDH264PICPARAMS structure\n    /************************************************************/\n    typedef struct _CUVIDH264MVCEXT\n    {\n        int num_views_minus1; /**< Max number of coded views minus 1 in video : Range - 0 to 1023              */\n        int view_id;          /**< view identifier                                                             */\n        unsigned char inter_view_flag;        /**< 1 if used for inter-view prediction, 0 if not        */\n        unsigned char num_inter_view_refs_l0; /**< number of inter-view ref pics in RefPicList0 */\n        unsigned char num_inter_view_refs_l1; /**< number of inter-view ref pics in RefPicList1 */\n        unsigned char MVCReserved8Bits;       /**< Reserved bits       */\n        int InterViewRefsL0[16]; /**< view id of the i-th view component for inter-view prediction in RefPicList0 */\n        int InterViewRefsL1[16]; /**< view id of the i-th view component for inter-view prediction in RefPicList1 */\n    } CUVIDH264MVCEXT;\n\n    /*********************************************************/\n    //! \\struct CUVIDH264SVCEXT\n    //! H.264 SVC picture parameters ext\n    //! This structure is used in CUVIDH264PICPARAMS structure\n    /*********************************************************/\n    typedef struct _CUVIDH264SVCEXT\n    {\n        unsigned char profile_idc;\n        unsigned char level_idc;\n        unsigned char DQId;\n        unsigned char DQIdMax;\n        unsigned char disable_inter_layer_deblocking_filter_idc;\n        unsigned char ref_layer_chroma_phase_y_plus1;\n        signed char inter_layer_slice_alpha_c0_offset_div2;\n        signed char inter_layer_slice_beta_offset_div2;\n\n        unsigned short DPBEntryValidFlag;\n        unsigned char inter_layer_deblocking_filter_control_present_flag;\n        unsigned char extended_spatial_scalability_idc;\n        unsigned char adaptive_tcoeff_level_prediction_flag;\n        unsigned char slice_header_restriction_flag;\n        unsigned char chroma_phase_x_plus1_flag;\n        unsigned char chroma_phase_y_plus1;\n\n        unsigned char tcoeff_level_prediction_flag;\n        unsigned char constrained_intra_resampling_flag;\n        unsigned char ref_layer_chroma_phase_x_plus1_flag;\n        unsigned char store_ref_base_pic_flag;\n        unsigned char Reserved8BitsA;\n        unsigned char Reserved8BitsB;\n\n        short scaled_ref_layer_left_offset;\n        short scaled_ref_layer_top_offset;\n        short scaled_ref_layer_right_offset;\n        short scaled_ref_layer_bottom_offset;\n        unsigned short Reserved16Bits;\n        struct _CUVIDPICPARAMS *pNextLayer; /**< Points to the picparams for the next layer to be decoded.\n                                                 Linked list ends at the target layer. */\n        int bRefBaseLayer;                  /**< whether to store ref base pic */\n    } CUVIDH264SVCEXT;\n\n    /******************************************************/\n    //! \\struct CUVIDH264PICPARAMS\n    //! H.264 picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /******************************************************/\n    typedef struct _CUVIDH264PICPARAMS\n    {\n        // SPS\n        int log2_max_frame_num_minus4;\n        int pic_order_cnt_type;\n        int log2_max_pic_order_cnt_lsb_minus4;\n        int delta_pic_order_always_zero_flag;\n        int frame_mbs_only_flag;\n        int direct_8x8_inference_flag;\n        int num_ref_frames; // NOTE: shall meet level 4.1 restrictions\n        unsigned char residual_colour_transform_flag;\n        unsigned char bit_depth_luma_minus8;   // Must be 0 (only 8-bit supported)\n        unsigned char bit_depth_chroma_minus8; // Must be 0 (only 8-bit supported)\n        unsigned char qpprime_y_zero_transform_bypass_flag;\n        // PPS\n        int entropy_coding_mode_flag;\n        int pic_order_present_flag;\n        int num_ref_idx_l0_active_minus1;\n        int num_ref_idx_l1_active_minus1;\n        int weighted_pred_flag;\n        int weighted_bipred_idc;\n        int pic_init_qp_minus26;\n        int deblocking_filter_control_present_flag;\n        int redundant_pic_cnt_present_flag;\n        int transform_8x8_mode_flag;\n        int MbaffFrameFlag;\n        int constrained_intra_pred_flag;\n        int chroma_qp_index_offset;\n        int second_chroma_qp_index_offset;\n        int ref_pic_flag;\n        int frame_num;\n        int CurrFieldOrderCnt[2];\n        // DPB\n        CUVIDH264DPBENTRY dpb[16]; // List of reference frames within the DPB\n        // Quantization Matrices (raster-order)\n        unsigned char WeightScale4x4[6][16];\n        unsigned char WeightScale8x8[2][64];\n        // FMO/ASO\n        unsigned char fmo_aso_enable;\n        unsigned char num_slice_groups_minus1;\n        unsigned char slice_group_map_type;\n        signed char pic_init_qs_minus26;\n        unsigned int slice_group_change_rate_minus1;\n        union {\n            unsigned long long slice_group_map_addr;\n            const unsigned char *pMb2SliceGroupMap;\n        } fmo;\n        unsigned int Reserved[12];\n        // SVC/MVC\n        union {\n            CUVIDH264MVCEXT mvcext;\n            CUVIDH264SVCEXT svcext;\n        };\n    } CUVIDH264PICPARAMS;\n\n    /********************************************************/\n    //! \\struct CUVIDMPEG2PICPARAMS\n    //! MPEG-2 picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /********************************************************/\n    typedef struct _CUVIDMPEG2PICPARAMS\n    {\n        int ForwardRefIdx;  // Picture index of forward reference (P/B-frames)\n        int BackwardRefIdx; // Picture index of backward reference (B-frames)\n        int picture_coding_type;\n        int full_pel_forward_vector;\n        int full_pel_backward_vector;\n        int f_code[2][2];\n        int intra_dc_precision;\n        int frame_pred_frame_dct;\n        int concealment_motion_vectors;\n        int q_scale_type;\n        int intra_vlc_format;\n        int alternate_scan;\n        int top_field_first;\n        // Quantization matrices (raster order)\n        unsigned char QuantMatrixIntra[64];\n        unsigned char QuantMatrixInter[64];\n    } CUVIDMPEG2PICPARAMS;\n\n// MPEG-4 has VOP types instead of Picture types\n#define I_VOP 0\n#define P_VOP 1\n#define B_VOP 2\n#define S_VOP 3\n\n    /*******************************************************/\n    //! \\struct CUVIDMPEG4PICPARAMS\n    //! MPEG-4 picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /*******************************************************/\n    typedef struct _CUVIDMPEG4PICPARAMS\n    {\n        int ForwardRefIdx;  // Picture index of forward reference (P/B-frames)\n        int BackwardRefIdx; // Picture index of backward reference (B-frames)\n        // VOL\n        int video_object_layer_width;\n        int video_object_layer_height;\n        int vop_time_increment_bitcount;\n        int top_field_first;\n        int resync_marker_disable;\n        int quant_type;\n        int quarter_sample;\n        int short_video_header;\n        int divx_flags;\n        // VOP\n        int vop_coding_type;\n        int vop_coded;\n        int vop_rounding_type;\n        int alternate_vertical_scan_flag;\n        int interlaced;\n        int vop_fcode_forward;\n        int vop_fcode_backward;\n        int trd[2];\n        int trb[2];\n        // Quantization matrices (raster order)\n        unsigned char QuantMatrixIntra[64];\n        unsigned char QuantMatrixInter[64];\n        int gmc_enabled;\n    } CUVIDMPEG4PICPARAMS;\n\n    /********************************************************/\n    //! \\struct CUVIDVC1PICPARAMS\n    //! VC1 picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /********************************************************/\n    typedef struct _CUVIDVC1PICPARAMS\n    {\n        int ForwardRefIdx;  /**< Picture index of forward reference (P/B-frames) */\n        int BackwardRefIdx; /**< Picture index of backward reference (B-frames)  */\n        int FrameWidth;     /**< Actual frame width                              */\n        int FrameHeight;    /**< Actual frame height                             */\n        // PICTURE\n        int intra_pic_flag;  /**< Set to 1 for I,BI frames */\n        int ref_pic_flag;    /**< Set to 1 for I,P frames  */\n        int progressive_fcm; /**< Progressive frame        */\n        // SEQUENCE\n        int profile;\n        int postprocflag;\n        int pulldown;\n        int interlace;\n        int tfcntrflag;\n        int finterpflag;\n        int psf;\n        int multires;\n        int syncmarker;\n        int rangered;\n        int maxbframes;\n        // ENTRYPOINT\n        int panscan_flag;\n        int refdist_flag;\n        int extended_mv;\n        int dquant;\n        int vstransform;\n        int loopfilter;\n        int fastuvmc;\n        int overlap;\n        int quantizer;\n        int extended_dmv;\n        int range_mapy_flag;\n        int range_mapy;\n        int range_mapuv_flag;\n        int range_mapuv;\n        int rangeredfrm; // range reduction state\n    } CUVIDVC1PICPARAMS;\n\n    /***********************************************************/\n    //! \\struct CUVIDJPEGPICPARAMS\n    //! JPEG picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /***********************************************************/\n    typedef struct _CUVIDJPEGPICPARAMS\n    {\n        int Reserved;\n    } CUVIDJPEGPICPARAMS;\n\n    /*******************************************************/\n    //! \\struct CUVIDHEVCPICPARAMS\n    //! HEVC picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /*******************************************************/\n    typedef struct _CUVIDHEVCPICPARAMS\n    {\n        // sps\n        int pic_width_in_luma_samples;\n        int pic_height_in_luma_samples;\n        unsigned char log2_min_luma_coding_block_size_minus3;\n        unsigned char log2_diff_max_min_luma_coding_block_size;\n        unsigned char log2_min_transform_block_size_minus2;\n        unsigned char log2_diff_max_min_transform_block_size;\n        unsigned char pcm_enabled_flag;\n        unsigned char log2_min_pcm_luma_coding_block_size_minus3;\n        unsigned char log2_diff_max_min_pcm_luma_coding_block_size;\n        unsigned char pcm_sample_bit_depth_luma_minus1;\n\n        unsigned char pcm_sample_bit_depth_chroma_minus1;\n        unsigned char pcm_loop_filter_disabled_flag;\n        unsigned char strong_intra_smoothing_enabled_flag;\n        unsigned char max_transform_hierarchy_depth_intra;\n        unsigned char max_transform_hierarchy_depth_inter;\n        unsigned char amp_enabled_flag;\n        unsigned char separate_colour_plane_flag;\n        unsigned char log2_max_pic_order_cnt_lsb_minus4;\n\n        unsigned char num_short_term_ref_pic_sets;\n        unsigned char long_term_ref_pics_present_flag;\n        unsigned char num_long_term_ref_pics_sps;\n        unsigned char sps_temporal_mvp_enabled_flag;\n        unsigned char sample_adaptive_offset_enabled_flag;\n        unsigned char scaling_list_enable_flag;\n        unsigned char IrapPicFlag;\n        unsigned char IdrPicFlag;\n\n        unsigned char bit_depth_luma_minus8;\n        unsigned char bit_depth_chroma_minus8;\n        // sps/pps extension fields\n        unsigned char log2_max_transform_skip_block_size_minus2;\n        unsigned char log2_sao_offset_scale_luma;\n        unsigned char log2_sao_offset_scale_chroma;\n        unsigned char high_precision_offsets_enabled_flag;\n        unsigned char reserved1[10];\n\n        // pps\n        unsigned char dependent_slice_segments_enabled_flag;\n        unsigned char slice_segment_header_extension_present_flag;\n        unsigned char sign_data_hiding_enabled_flag;\n        unsigned char cu_qp_delta_enabled_flag;\n        unsigned char diff_cu_qp_delta_depth;\n        signed char init_qp_minus26;\n        signed char pps_cb_qp_offset;\n        signed char pps_cr_qp_offset;\n\n        unsigned char constrained_intra_pred_flag;\n        unsigned char weighted_pred_flag;\n        unsigned char weighted_bipred_flag;\n        unsigned char transform_skip_enabled_flag;\n        unsigned char transquant_bypass_enabled_flag;\n        unsigned char entropy_coding_sync_enabled_flag;\n        unsigned char log2_parallel_merge_level_minus2;\n        unsigned char num_extra_slice_header_bits;\n\n        unsigned char loop_filter_across_tiles_enabled_flag;\n        unsigned char loop_filter_across_slices_enabled_flag;\n        unsigned char output_flag_present_flag;\n        unsigned char num_ref_idx_l0_default_active_minus1;\n        unsigned char num_ref_idx_l1_default_active_minus1;\n        unsigned char lists_modification_present_flag;\n        unsigned char cabac_init_present_flag;\n        unsigned char pps_slice_chroma_qp_offsets_present_flag;\n\n        unsigned char deblocking_filter_override_enabled_flag;\n        unsigned char pps_deblocking_filter_disabled_flag;\n        signed char pps_beta_offset_div2;\n        signed char pps_tc_offset_div2;\n        unsigned char tiles_enabled_flag;\n        unsigned char uniform_spacing_flag;\n        unsigned char num_tile_columns_minus1;\n        unsigned char num_tile_rows_minus1;\n\n        unsigned short column_width_minus1[21];\n        unsigned short row_height_minus1[21];\n\n        // sps and pps extension HEVC-main 444\n        unsigned char sps_range_extension_flag;\n        unsigned char transform_skip_rotation_enabled_flag;\n        unsigned char transform_skip_context_enabled_flag;\n        unsigned char implicit_rdpcm_enabled_flag;\n\n        unsigned char explicit_rdpcm_enabled_flag;\n        unsigned char extended_precision_processing_flag;\n        unsigned char intra_smoothing_disabled_flag;\n        unsigned char persistent_rice_adaptation_enabled_flag;\n\n        unsigned char cabac_bypass_alignment_enabled_flag;\n        unsigned char pps_range_extension_flag;\n        unsigned char cross_component_prediction_enabled_flag;\n        unsigned char chroma_qp_offset_list_enabled_flag;\n\n        unsigned char diff_cu_chroma_qp_offset_depth;\n        unsigned char chroma_qp_offset_list_len_minus1;\n        signed char cb_qp_offset_list[6];\n\n        signed char cr_qp_offset_list[6];\n        unsigned char reserved2[2];\n\n        unsigned int reserved3[8];\n\n        // RefPicSets\n        int NumBitsForShortTermRPSInSlice;\n        int NumDeltaPocsOfRefRpsIdx;\n        int NumPocTotalCurr;\n        int NumPocStCurrBefore;\n        int NumPocStCurrAfter;\n        int NumPocLtCurr;\n        int CurrPicOrderCntVal;\n        int RefPicIdx[16];            // [refpic] Indices of valid reference pictures (-1 if unused for reference)\n        int PicOrderCntVal[16];       // [refpic]\n        unsigned char IsLongTerm[16]; // [refpic] 0=not a long-term reference, 1=long-term reference\n        unsigned char RefPicSetStCurrBefore[8]; // [0..NumPocStCurrBefore-1] -> refpic (0..15)\n        unsigned char RefPicSetStCurrAfter[8];  // [0..NumPocStCurrAfter-1] -> refpic (0..15)\n        unsigned char RefPicSetLtCurr[8];       // [0..NumPocLtCurr-1] -> refpic (0..15)\n        unsigned char RefPicSetInterLayer0[8];\n        unsigned char RefPicSetInterLayer1[8];\n        unsigned int reserved4[12];\n\n        // scaling lists (diag order)\n        unsigned char ScalingList4x4[6][16];      // [matrixId][i]\n        unsigned char ScalingList8x8[6][64];      // [matrixId][i]\n        unsigned char ScalingList16x16[6][64];    // [matrixId][i]\n        unsigned char ScalingList32x32[2][64];    // [matrixId][i]\n        unsigned char ScalingListDCCoeff16x16[6]; // [matrixId]\n        unsigned char ScalingListDCCoeff32x32[2]; // [matrixId]\n    } CUVIDHEVCPICPARAMS;\n\n    /***********************************************************/\n    //! \\struct CUVIDVP8PICPARAMS\n    //! VP8 picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /***********************************************************/\n    typedef struct _CUVIDVP8PICPARAMS\n    {\n        int width;\n        int height;\n        unsigned int first_partition_size;\n        // Frame Indexes\n        unsigned char LastRefIdx;\n        unsigned char GoldenRefIdx;\n        unsigned char AltRefIdx;\n        union {\n            struct\n            {\n                unsigned char frame_type : 1; /**< 0 = KEYFRAME, 1 = INTERFRAME  */\n                unsigned char version : 3;\n                unsigned char show_frame : 1;\n                unsigned char update_mb_segmentation_data : 1; /**< Must be 0 if segmentation is not enabled */\n                unsigned char Reserved2Bits : 2;\n            } vp8_frame_tag;\n            unsigned char wFrameTagFlags;\n        };\n        unsigned char Reserved1[4];\n        unsigned int Reserved2[3];\n    } CUVIDVP8PICPARAMS;\n\n    /***********************************************************/\n    //! \\struct CUVIDVP9PICPARAMS\n    //! VP9 picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /***********************************************************/\n    typedef struct _CUVIDVP9PICPARAMS\n    {\n        unsigned int width;\n        unsigned int height;\n\n        // Frame Indices\n        unsigned char LastRefIdx;\n        unsigned char GoldenRefIdx;\n        unsigned char AltRefIdx;\n        unsigned char colorSpace;\n\n        unsigned short profile : 3;\n        unsigned short frameContextIdx : 2;\n        unsigned short frameType : 1;\n        unsigned short showFrame : 1;\n        unsigned short errorResilient : 1;\n        unsigned short frameParallelDecoding : 1;\n        unsigned short subSamplingX : 1;\n        unsigned short subSamplingY : 1;\n        unsigned short intraOnly : 1;\n        unsigned short allow_high_precision_mv : 1;\n        unsigned short refreshEntropyProbs : 1;\n        unsigned short reserved2Bits : 2;\n\n        unsigned short reserved16Bits;\n\n        unsigned char refFrameSignBias[4];\n\n        unsigned char bitDepthMinus8Luma;\n        unsigned char bitDepthMinus8Chroma;\n        unsigned char loopFilterLevel;\n        unsigned char loopFilterSharpness;\n\n        unsigned char modeRefLfEnabled;\n        unsigned char log2_tile_columns;\n        unsigned char log2_tile_rows;\n\n        unsigned char segmentEnabled : 1;\n        unsigned char segmentMapUpdate : 1;\n        unsigned char segmentMapTemporalUpdate : 1;\n        unsigned char segmentFeatureMode : 1;\n        unsigned char reserved4Bits : 4;\n\n        unsigned char segmentFeatureEnable[8][4];\n        short segmentFeatureData[8][4];\n        unsigned char mb_segment_tree_probs[7];\n        unsigned char segment_pred_probs[3];\n        unsigned char reservedSegment16Bits[2];\n\n        int qpYAc;\n        int qpYDc;\n        int qpChDc;\n        int qpChAc;\n\n        unsigned int activeRefIdx[3];\n        unsigned int resetFrameContext;\n        unsigned int mcomp_filter_type;\n        unsigned int mbRefLfDelta[4];\n        unsigned int mbModeLfDelta[2];\n        unsigned int frameTagSize;\n        unsigned int offsetToDctParts;\n        unsigned int reserved128Bits[4];\n\n    } CUVIDVP9PICPARAMS;\n\n    /***********************************************************/\n    //! \\struct CUVIDAV1PICPARAMS\n    //! AV1 picture parameters\n    //! This structure is used in CUVIDPICPARAMS structure\n    /***********************************************************/\n    typedef struct _CUVIDAV1PICPARAMS\n    {\n        unsigned int width;        // coded width, if superres enabled then it is upscaled width\n        unsigned int height;       // coded height\n        unsigned int frame_offset; // defined as order_hint in AV1 specification\n        int decodePicIdx; // decoded output pic index, if film grain enabled, it will keep decoded (without film grain)\n                          // output It can be used as reference frame for future frames\n\n        // sequence header\n        unsigned int profile : 3;                // 0 = profile0, 1 = profile1, 2 = profile2\n        unsigned int use_128x128_superblock : 1; // superblock size 0:64x64, 1: 128x128\n        unsigned int subsampling_x : 1;          // (subsampling_x, _y) 1,1 = 420, 1,0 = 422, 0,0 = 444\n        unsigned int subsampling_y : 1;\n        unsigned int mono_chrome : 1; // for monochrome content, mono_chrome = 1 and (subsampling_x, _y) should be 1,1\n        unsigned int bit_depth_minus8 : 4;           // bit depth minus 8\n        unsigned int enable_filter_intra : 1;        // tool enable in seq level, 0 : disable 1: frame header control\n        unsigned int enable_intra_edge_filter : 1;   // intra edge filtering process, 0 : disable 1: enabled\n        unsigned int enable_interintra_compound : 1; // interintra, 0 : not present 1: present\n        unsigned int enable_masked_compound : 1;     // 1: mode info for inter blocks may contain the syntax element\n                                                 // compound_type. 0: syntax element compound_type will not be present\n        unsigned int enable_dual_filter : 1;     // vertical and horiz filter selection, 1: enable and 0: disable\n        unsigned int enable_order_hint : 1;      // order hint, and related tools, 1: enable and 0: disable\n        unsigned int order_hint_bits_minus1 : 3; // is used to compute OrderHintBits\n        unsigned int enable_jnt_comp : 1;        // joint compound modes, 1: enable and 0: disable\n        unsigned int enable_superres : 1;        // superres in seq level, 0 : disable 1: frame level control\n        unsigned int enable_cdef : 1;            // cdef filtering in seq level, 0 : disable 1: frame level control\n        unsigned int\n            enable_restoration : 1;       // loop restoration filtering in seq level, 0 : disable 1: frame level control\n        unsigned int enable_fgs : 1;      // defined as film_grain_params_present in AV1 specification\n        unsigned int reserved0_7bits : 7; // reserved bits; must be set to 0\n\n        // frame header\n        unsigned int frame_type : 2; // 0:Key frame, 1:Inter frame, 2:intra only, 3:s-frame\n        unsigned int show_frame : 1; // show_frame = 1 implies that frame should be immediately output once decoded\n        unsigned int disable_cdf_update : 1;         // CDF update during symbol decoding, 1: disabled, 0: enabled\n        unsigned int allow_screen_content_tools : 1; // 1: intra blocks may use palette encoding, 0: palette encoding is\n                                                     // never used\n        unsigned int force_integer_mv : 1; // 1: motion vectors will always be integers, 0: can contain fractional bits\n        unsigned int coded_denom : 3;      // coded_denom of the superres scale as specified in AV1 specification\n        unsigned int allow_intrabc : 1;    // 1: intra block copy may be used, 0: intra block copy is not allowed\n        unsigned int allow_high_precision_mv : 1; // 1/8 precision mv enable\n        unsigned int interp_filter : 3; // interpolation filter. Refer to section 6.8.9 of the AV1 specification\n                                        // Version 1.0.0 with Errata 1\n        unsigned int switchable_motion_mode : 1; // defined as is_motion_mode_switchable in AV1 specification\n        unsigned int\n            use_ref_frame_mvs : 1; // 1: current frame can use the previous frame mv information, 0: will not use.\n        unsigned int disable_frame_end_update_cdf : 1; // 1: indicates that the end of frame CDF update is disabled\n        unsigned int delta_q_present : 1;              // quantizer index delta values are present in the block level\n        unsigned int delta_q_res : 2;    // left shift which should be applied to decoded quantizer index delta values\n        unsigned int using_qmatrix : 1;  // 1: quantizer matrix will be used to compute quantizers\n        unsigned int coded_lossless : 1; // 1: all segments use lossless coding\n        unsigned int use_superres : 1;   // 1: superres enabled for frame\n        unsigned int tx_mode : 2;        // 0: ONLY4x4,1:LARGEST,2:SELECT\n        unsigned int reference_mode : 1; // 0: SINGLE, 1: SELECT\n        unsigned int allow_warped_motion : 1; // 1: allow_warped_motion may be present, 0: allow_warped_motion will not\n                                              // be present\n        unsigned int reduced_tx_set : 1;  // 1: frame is restricted to subset of the full set of transform types, 0: no\n                                          // such restriction\n        unsigned int skip_mode : 1;       // 1: most of the mode info is skipped, 0: mode info is not skipped\n        unsigned int reserved1_3bits : 3; // reserved bits; must be set to 0\n\n        // tiling info\n        unsigned int num_tile_cols : 8;           // number of tiles across the frame., max is 64\n        unsigned int num_tile_rows : 8;           // number of tiles down the frame., max is 64\n        unsigned int context_update_tile_id : 16; // specifies which tile to use for the CDF update\n        unsigned short tile_widths[64];           // Width of each column in superblocks\n        unsigned short tile_heights[64];          // height of each row in superblocks\n\n        // CDEF - refer to section 6.10.14 of the AV1 specification Version 1.0.0 with Errata 1\n        unsigned char cdef_damping_minus_3 : 2; // controls the amount of damping in the deringing filter\n        unsigned char cdef_bits : 2;            // the number of bits needed to specify which CDEF filter to apply\n        unsigned char reserved2_4bits : 4;      // reserved bits; must be set to 0\n        unsigned char cdef_y_strength[8];       // 0-3 bits: y_pri_strength, 4-7 bits y_sec_strength\n        unsigned char cdef_uv_strength[8];      // 0-3 bits: uv_pri_strength, 4-7 bits uv_sec_strength\n\n        // SkipModeFrames\n        unsigned char\n            SkipModeFrame0 : 4; // specifies the frames to use for compound prediction when skip_mode is equal to 1.\n        unsigned char SkipModeFrame1 : 4;\n\n        // qp information - refer to section 6.8.11 of the AV1 specification Version 1.0.0 with Errata 1\n        unsigned char base_qindex; // indicates the base frame qindex. Defined as base_q_idx in AV1 specification\n        char qp_y_dc_delta_q;      // indicates the Y DC quantizer relative to base_q_idx. Defined as DeltaQYDc in AV1\n                                   // specification\n        char qp_u_dc_delta_q;      // indicates the U DC quantizer relative to base_q_idx. Defined as DeltaQUDc in AV1\n                                   // specification\n        char qp_v_dc_delta_q;      // indicates the V DC quantizer relative to base_q_idx. Defined as DeltaQVDc in AV1\n                                   // specification\n        char qp_u_ac_delta_q;      // indicates the U AC quantizer relative to base_q_idx. Defined as DeltaQUAc in AV1\n                                   // specification\n        char qp_v_ac_delta_q;      // indicates the V AC quantizer relative to base_q_idx. Defined as DeltaQVAc in AV1\n                                   // specification\n        unsigned char qm_y; // specifies the level in the quantizer matrix that should be used for luma plane decoding\n        unsigned char\n            qm_u; // specifies the level in the quantizer matrix that should be used for chroma U plane decoding\n        unsigned char\n            qm_v; // specifies the level in the quantizer matrix that should be used for chroma V plane decoding\n\n        // segmentation - refer to section 6.8.13 of the AV1 specification Version 1.0.0 with Errata 1\n        unsigned char segmentation_enabled : 1;    // 1 indicates that this frame makes use of the segmentation tool\n        unsigned char segmentation_update_map : 1; // 1 indicates that the segmentation map are updated during the\n                                                   // decoding of this frame\n        unsigned char\n            segmentation_update_data : 1; // 1 indicates that new parameters are about to be specified for each segment\n        unsigned char segmentation_temporal_update : 1; // 1 indicates that the updates to the segmentation map are\n                                                        // coded relative to the existing segmentation map\n        unsigned char reserved3_4bits : 4;              // reserved bits; must be set to 0\n        short segmentation_feature_data[8][8];          // specifies the feature data for a segment feature\n        unsigned char segmentation_feature_mask[8];     // indicates that the corresponding feature is unused or feature\n                                                        // value is coded\n\n        // loopfilter - refer to section 6.8.10 of the AV1 specification Version 1.0.0 with Errata 1\n        unsigned char loop_filter_level[2];  // contains loop filter strength values\n        unsigned char loop_filter_level_u;   // loop filter strength value of U plane\n        unsigned char loop_filter_level_v;   // loop filter strength value of V plane\n        unsigned char loop_filter_sharpness; // indicates the sharpness level\n        char loop_filter_ref_deltas[8];      // contains the adjustment needed for the filter level based on the chosen\n                                             // reference frame\n        char loop_filter_mode_deltas[2]; // contains the adjustment needed for the filter level based on the chosen mode\n        unsigned char loop_filter_delta_enabled : 1; // indicates that the filter level depends on the mode and\n                                                     // reference frame used to predict a block\n        unsigned char loop_filter_delta_update : 1;  // indicates that additional syntax elements are present that\n                                                    // specify which mode and reference frame deltas are to be updated\n        unsigned char delta_lf_present : 1; // specifies whether loop filter delta values are present in the block level\n        unsigned char delta_lf_res : 2;     // specifies the left shift to apply to the decoded loop filter values\n        unsigned char delta_lf_multi : 1;   // separate loop filter deltas for Hy,Vy,U,V edges\n        unsigned char reserved4_2bits : 2;  // reserved bits; must be set to 0\n\n        // restoration - refer to section 6.10.15 of the AV1 specification Version 1.0.0 with Errata 1\n        unsigned char lr_unit_size[3]; // specifies the size of loop restoration units: 0: 32, 1: 64, 2: 128, 3: 256\n        unsigned char lr_type[3];      // used to compute FrameRestorationType\n\n        // reference frames\n        unsigned char primary_ref_frame; // specifies which reference frame contains the CDF values and other state that\n                                         // should be loaded at the start of the frame\n        unsigned char ref_frame_map[8]; // frames in dpb that can be used as reference for current or future frames\n\n        unsigned char temporal_layer_id : 4; // temporal layer id\n        unsigned char spatial_layer_id : 4;  // spatial layer id\n\n        unsigned char reserved5_32bits[4]; // reserved bits; must be set to 0\n\n        // ref frame list\n        struct\n        {\n            unsigned int width;\n            unsigned int height;\n            unsigned char index;\n            unsigned char reserved24Bits[3]; // reserved bits; must be set to 0\n        } ref_frame[7];                      // frames used as reference frame for current frame.\n\n        // global motion\n        struct\n        {\n            unsigned char invalid : 1;\n            unsigned char wmtype : 2;        // defined as GmType in AV1 specification\n            unsigned char reserved5Bits : 5; // reserved bits; must be set to 0\n            char reserved24Bits[3];          // reserved bits; must be set to 0\n            int wmmat[6];                    // defined as gm_params[] in AV1 specification\n        } global_motion[7];                  // global motion params for reference frames\n\n        // film grain params - refer to section 6.8.20 of the AV1 specification Version 1.0.0 with Errata 1\n        unsigned short apply_grain : 1;\n        unsigned short overlap_flag : 1;\n        unsigned short scaling_shift_minus8 : 2;\n        unsigned short chroma_scaling_from_luma : 1;\n        unsigned short ar_coeff_lag : 2;\n        unsigned short ar_coeff_shift_minus6 : 2;\n        unsigned short grain_scale_shift : 2;\n        unsigned short clip_to_restricted_range : 1;\n        unsigned short reserved6_4bits : 4; // reserved bits; must be set to 0\n        unsigned char num_y_points;\n        unsigned char scaling_points_y[14][2];\n        unsigned char num_cb_points;\n        unsigned char scaling_points_cb[10][2];\n        unsigned char num_cr_points;\n        unsigned char scaling_points_cr[10][2];\n        unsigned char reserved7_8bits; // reserved bits; must be set to 0\n        unsigned short random_seed;\n        short ar_coeffs_y[24];\n        short ar_coeffs_cb[25];\n        short ar_coeffs_cr[25];\n        unsigned char cb_mult;\n        unsigned char cb_luma_mult;\n        short cb_offset;\n        unsigned char cr_mult;\n        unsigned char cr_luma_mult;\n        short cr_offset;\n\n        int reserved[7]; // reserved bits; must be set to 0\n    } CUVIDAV1PICPARAMS;\n\n    /******************************************************************************************/\n    //! \\struct CUVIDPICPARAMS\n    //! Picture parameters for decoding\n    //! This structure is used in cuvidDecodePicture API\n    //! IN  for cuvidDecodePicture\n    /******************************************************************************************/\n    typedef struct _CUVIDPICPARAMS\n    {\n        int PicWidthInMbs;     /**< IN: Coded frame size in macroblocks                           */\n        int FrameHeightInMbs;  /**< IN: Coded frame height in macroblocks                         */\n        int CurrPicIdx;        /**< IN: Output index of the current picture                       */\n        int field_pic_flag;    /**< IN: 0=frame picture, 1=field picture                          */\n        int bottom_field_flag; /**< IN: 0=top field, 1=bottom field (ignored if field_pic_flag=0) */\n        int second_field;      /**< IN: Second field of a complementary field pair                */\n        // Bitstream data\n        unsigned int nBitstreamDataLen;        /**< IN: Number of bytes in bitstream data buffer                  */\n        const unsigned char *pBitstreamData;   /**< IN: Ptr to bitstream data for this picture (slice-layer)      */\n        unsigned int nNumSlices;               /**< IN: Number of slices in this picture                          */\n        const unsigned int *pSliceDataOffsets; /**< IN: nNumSlices entries, contains offset of each slice within\n                                                            the bitstream data buffer                             */\n        int ref_pic_flag;                      /**< IN: This picture is a reference picture                       */\n        int intra_pic_flag;                    /**< IN: This picture is entirely intra coded                      */\n        unsigned int Reserved[30];             /**< Reserved for future use                                       */\n        // IN: Codec-specific data\n        union {\n            CUVIDMPEG2PICPARAMS mpeg2; /**< Also used for MPEG-1 */\n            CUVIDH264PICPARAMS h264;\n            CUVIDVC1PICPARAMS vc1;\n            CUVIDMPEG4PICPARAMS mpeg4;\n            CUVIDJPEGPICPARAMS jpeg;\n            CUVIDHEVCPICPARAMS hevc;\n            CUVIDVP8PICPARAMS vp8;\n            CUVIDVP9PICPARAMS vp9;\n            CUVIDAV1PICPARAMS av1;\n            unsigned int CodecReserved[1024];\n        } CodecSpecific;\n    } CUVIDPICPARAMS;\n\n    /******************************************************/\n    //! \\struct CUVIDPROCPARAMS\n    //! Picture parameters for postprocessing\n    //! This structure is used in cuvidMapVideoFrame API\n    /******************************************************/\n    typedef struct _CUVIDPROCPARAMS\n    {\n        int progressive_frame; /**< IN: Input is progressive (deinterlace_mode will be ignored)                */\n        int second_field;      /**< IN: Output the second field (ignored if deinterlace mode is Weave)         */\n        int top_field_first;   /**< IN: Input frame is top field first (1st field is top, 2nd field is bottom) */\n        int unpaired_field;    /**< IN: Input only contains one field (2nd field is invalid)                   */\n        // The fields below are used for raw YUV input\n        unsigned int reserved_flags; /**< Reserved for future use (set to zero)                                      */\n        unsigned int reserved_zero;  /**< Reserved (set to zero)                                                     */\n        unsigned long long raw_input_dptr; /**< IN: Input CUdeviceptr for raw YUV extensions */\n        unsigned int raw_input_pitch; /**< IN: pitch in bytes of raw YUV input (should be aligned appropriately)      */\n        unsigned int raw_input_format;      /**< IN: Input YUV format (cudaVideoCodec_enum)      */\n        unsigned long long raw_output_dptr; /**< IN: Output CUdeviceptr for raw YUV extensions */\n        unsigned int raw_output_pitch; /**< IN: pitch in bytes of raw YUV output (should be aligned appropriately) */\n        unsigned int Reserved1;    /**< Reserved for future use (set to zero)                                      */\n        CUstream output_stream;    /**< IN: stream object used by cuvidMapVideoFrame                               */\n        unsigned int Reserved[46]; /**< Reserved for future use (set to zero)                                      */\n        unsigned long long *histogram_dptr; /**< OUT: Output CUdeviceptr for histogram extensions */\n        void *Reserved2[1]; /**< Reserved for future use (set to zero)                                      */\n    } CUVIDPROCPARAMS;\n\n    /*********************************************************************************************************/\n    //! \\struct CUVIDGETDECODESTATUS\n    //! Struct for reporting decode status.\n    //! This structure is used in cuvidGetDecodeStatus API.\n    /*********************************************************************************************************/\n    typedef struct _CUVIDGETDECODESTATUS\n    {\n        cuvidDecodeStatus decodeStatus;\n        unsigned int reserved[31];\n        void *pReserved[8];\n    } CUVIDGETDECODESTATUS;\n\n    /****************************************************/\n    //! \\struct CUVIDRECONFIGUREDECODERINFO\n    //! Struct for decoder reset\n    //! This structure is used in cuvidReconfigureDecoder() API\n    /****************************************************/\n    typedef struct _CUVIDRECONFIGUREDECODERINFO\n    {\n        unsigned int\n            ulWidth; /**< IN: Coded sequence width in pixels, MUST be < = ulMaxWidth defined at CUVIDDECODECREATEINFO */\n        unsigned int ulHeight;            /**< IN: Coded sequence height in pixels, MUST be < = ulMaxHeight defined at\n                                             CUVIDDECODECREATEINFO  */\n        unsigned int ulTargetWidth;       /**< IN: Post processed output width */\n        unsigned int ulTargetHeight;      /**< IN: Post Processed output height */\n        unsigned int ulNumDecodeSurfaces; /**< IN: Maximum number of internal decode surfaces */\n        unsigned int reserved1[12];       /**< Reserved for future use. Set to Zero */\n        /**\n         * IN: Area of frame to be displayed. Use-case : Source Cropping\n         */\n        struct\n        {\n            short left;\n            short top;\n            short right;\n            short bottom;\n        } display_area;\n        /**\n         * IN: Target Rectangle in the OutputFrame. Use-case : Aspect ratio Conversion\n         */\n        struct\n        {\n            short left;\n            short top;\n            short right;\n            short bottom;\n        } target_rect;\n        unsigned int reserved2[11]; /**< Reserved for future use. Set to Zero */\n    } CUVIDRECONFIGUREDECODERINFO;\n\n    /***********************************************************************************************************/\n    //! VIDEO_DECODER\n    //!\n    //! In order to minimize decode latencies, there should be always at least 2 pictures in the decode\n    //! queue at any time, in order to make sure that all decode engines are always busy.\n    //!\n    //! Overall data flow:\n    //!  - cuvidGetDecoderCaps(...)\n    //!  - cuvidCreateDecoder(...)\n    //!  - For each picture:\n    //!    + cuvidDecodePicture(N)\n    //!    + cuvidMapVideoFrame(N-4)\n    //!    + do some processing in cuda\n    //!    + cuvidUnmapVideoFrame(N-4)\n    //!    + cuvidDecodePicture(N+1)\n    //!    + cuvidMapVideoFrame(N-3)\n    //!    + ...\n    //!  - cuvidDestroyDecoder(...)\n    //!\n    //! NOTE:\n    //! - When the cuda context is created from a D3D device, the D3D device must also be created\n    //!   with the D3DCREATE_MULTITHREADED flag.\n    //! - There is a limit to how many pictures can be mapped simultaneously (ulNumOutputSurfaces)\n    //! - cuvidDecodePicture may block the calling thread if there are too many pictures pending\n    //!   in the decode queue\n    /***********************************************************************************************************/\n\n    /**********************************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidGetDecoderCaps(CUVIDDECODECAPS *pdc)\n    //! Queries decode capabilities of NVDEC-HW based on CodecType, ChromaFormat and BitDepthMinus8 parameters.\n    //! 1. Application fills IN parameters CodecType, ChromaFormat and BitDepthMinus8 of CUVIDDECODECAPS structure\n    //! 2. On calling cuvidGetDecoderCaps, driver fills OUT parameters if the IN parameters are supported\n    //!    If IN parameters passed to the driver are not supported by NVDEC-HW, then all OUT params are set to 0.\n    //! E.g. on Geforce GTX 960:\n    //!   App fills - eCodecType = cudaVideoCodec_H264; eChromaFormat = cudaVideoChromaFormat_420; nBitDepthMinus8 = 0;\n    //!   Given IN parameters are supported, hence driver fills: bIsSupported = 1; nMinWidth   = 48; nMinHeight  = 16;\n    //!   nMaxWidth = 4096; nMaxHeight = 4096; nMaxMBCount = 65536;\n    //! CodedWidth*CodedHeight/256 must be less than or equal to nMaxMBCount\n    /**********************************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidGetDecoderCaps(CUVIDDECODECAPS *pdc);\n\n    /*****************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci)\n    //! Create the decoder object based on pdci. A handle to the created decoder is returned\n    /*****************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidCreateDecoder(CUvideodecoder *phDecoder, CUVIDDECODECREATEINFO *pdci);\n\n    /*****************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidDestroyDecoder(CUvideodecoder hDecoder)\n    //! Destroy the decoder object\n    /*****************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidDestroyDecoder(CUvideodecoder hDecoder);\n\n    /*****************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams)\n    //! Decode a single picture (field or frame)\n    //! Kicks off HW decoding\n    /*****************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidDecodePicture(CUvideodecoder hDecoder, CUVIDPICPARAMS *pPicParams);\n\n    /************************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx);\n    //! Get the decode status for frame corresponding to nPicIdx\n    //! API is supported for Maxwell and above generation GPUs.\n    //! API is currently supported for HEVC, H264 and JPEG codecs.\n    //! API returns CUDA_ERROR_NOT_SUPPORTED error code for unsupported GPU or codec.\n    /************************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidGetDecodeStatus(CUvideodecoder hDecoder, int nPicIdx,\n                                                   CUVIDGETDECODESTATUS *pDecodeStatus);\n\n    /*********************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidReconfigureDecoder(CUvideodecoder hDecoder, CUVIDRECONFIGUREDECODERINFO\n    //! *pDecReconfigParams) Used to reuse single decoder for multiple clips. Currently supports resolution change,\n    //! resize params, display area params, target area params change for same codec. Must be called during\n    //! CUVIDPARSERPARAMS::pfnSequenceCallback\n    /*********************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidReconfigureDecoder(CUvideodecoder hDecoder,\n                                                      CUVIDRECONFIGUREDECODERINFO *pDecReconfigParams);\n\n#if !defined(__CUVID_DEVPTR64) || defined(__CUVID_INTERNAL)\n    /************************************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr,\n    //!                                         unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);\n    //! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and\n    //! associated pitch of the video frame\n    /************************************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidMapVideoFrame(CUvideodecoder hDecoder, int nPicIdx, unsigned int *pDevPtr,\n                                                 unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);\n\n    /*****************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr)\n    //! Unmap a previously mapped video frame\n    /*****************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidUnmapVideoFrame(CUvideodecoder hDecoder, unsigned int DevPtr);\n#endif\n\n    /****************************************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,\n    //!                                           unsigned int * pPitch, CUVIDPROCPARAMS *pVPP);\n    //! Post-process and map video frame corresponding to nPicIdx for use in cuda. Returns cuda device pointer and\n    //! associated pitch of the video frame\n    /****************************************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidMapVideoFrame64(CUvideodecoder hDecoder, int nPicIdx, unsigned long long *pDevPtr,\n                                                   unsigned int *pPitch, CUVIDPROCPARAMS *pVPP);\n\n    /**************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);\n    //! Unmap a previously mapped video frame\n    /**************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidUnmapVideoFrame64(CUvideodecoder hDecoder, unsigned long long DevPtr);\n\n#if defined(__CUVID_DEVPTR64) && !defined(__CUVID_INTERNAL)\n#define tcuvidMapVideoFrame tcuvidMapVideoFrame64\n#define tcuvidUnmapVideoFrame tcuvidUnmapVideoFrame64\n#endif\n\n    /********************************************************************************************************************/\n    //!\n    //! Context-locking: to facilitate multi-threaded implementations, the following 4 functions\n    //! provide a simple mutex-style host synchronization. If a non-NULL context is specified\n    //! in CUVIDDECODECREATEINFO, the codec library will acquire the mutex associated with the given\n    //! context before making any cuda calls.\n    //! A multi-threaded application could create a lock associated with a context handle so that\n    //! multiple threads can safely share the same cuda context:\n    //!  - use cuCtxPopCurrent immediately after context creation in order to create a 'floating' context\n    //!    that can be passed to cuvidCtxLockCreate.\n    //!  - When using a floating context, all cuda calls should only be made within a cuvidCtxLock/cuvidCtxUnlock\n    //!  section.\n    //!\n    //! NOTE: This is a safer alternative to cuCtxPushCurrent and cuCtxPopCurrent, and is not related to video\n    //! decoder in any way (implemented as a critical section associated with cuCtx{Push|Pop}Current calls).\n    /********************************************************************************************************************/\n\n    /********************************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx)\n    //! This API is used to create CtxLock object\n    /********************************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidCtxLockCreate(CUvideoctxlock *pLock, CUcontext ctx);\n\n    /********************************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidCtxLockDestroy(CUvideoctxlock lck)\n    //! This API is used to free CtxLock object\n    /********************************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidCtxLockDestroy(CUvideoctxlock lck);\n\n    /********************************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags)\n    //! This API is used to acquire ctxlock\n    /********************************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidCtxLock(CUvideoctxlock lck, unsigned int reserved_flags);\n\n    /********************************************************************************************************************/\n    //! \\fn CUresult CUDAAPI cuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags)\n    //! This API is used to release ctxlock\n    /********************************************************************************************************************/\n    typedef CUresult CUDAAPI tcuvidCtxUnlock(CUvideoctxlock lck, unsigned int reserved_flags);\n\n    /**********************************************************************************************/\n\n#if defined(__cplusplus)\n}\n#endif /* __cplusplus */\n\n#endif // __CUDA_VIDEO_H__\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/cuvid/dynlink_nvcuvid.h",
    "content": "/*\n * This copyright notice applies to this header file only:\n *\n * Copyright (c) 2010-2024 NVIDIA Corporation\n *\n * Permission is hereby granted, free of charge, to any person\n * obtaining a copy of this software and associated documentation\n * files (the \"Software\"), to deal in the Software without\n * restriction, including without limitation the rights to use,\n * copy, modify, merge, publish, distribute, sublicense, and/or sell\n * copies of the software, and to permit persons to whom the\n * software is furnished to do so, subject to the following\n * conditions:\n *\n * The above copyright notice and this permission notice shall be\n * included in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\n * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES\n * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\n * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT\n * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,\n * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING\n * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR\n * OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/********************************************************************************************************************/\n//! \\file nvcuvid.h\n//!   NVDECODE API provides video decoding interface to NVIDIA GPU devices.\n//! \\date 2015-2024\n//!  This file contains the interface constants, structure definitions and function prototypes.\n/********************************************************************************************************************/\n\n#if !defined(__NVCUVID_H__)\n#define __NVCUVID_H__\n\n#include \"dynlink_cuviddec.h\"\n\n#if defined(__cplusplus)\nextern \"C\" {\n#endif /* __cplusplus */\n\n#define MAX_CLOCK_TS 3\n\n/***********************************************/\n//!\n//! High-level helper APIs for video sources\n//!\n/***********************************************/\n\ntypedef void *CUvideosource;\ntypedef void *CUvideoparser;\ntypedef long long CUvideotimestamp;\n\n\n/************************************************************************/\n//! \\enum cudaVideoState\n//! Video source state enums\n//! Used in cuvidSetVideoSourceState and cuvidGetVideoSourceState APIs\n/************************************************************************/\ntypedef enum {\n    cudaVideoState_Error   = -1,    /**< Error state (invalid source)                  */\n    cudaVideoState_Stopped = 0,     /**< Source is stopped (or reached end-of-stream)  */\n    cudaVideoState_Started = 1      /**< Source is running and delivering data         */\n} cudaVideoState;\n\n/************************************************************************/\n//! \\enum cudaAudioCodec\n//! Audio compression enums\n//! Used in CUAUDIOFORMAT structure\n/************************************************************************/\ntypedef enum {\n    cudaAudioCodec_MPEG1=0,         /**< MPEG-1 Audio               */\n    cudaAudioCodec_MPEG2,           /**< MPEG-2 Audio               */\n    cudaAudioCodec_MP3,             /**< MPEG-1 Layer III Audio     */\n    cudaAudioCodec_AC3,             /**< Dolby Digital (AC3) Audio  */\n    cudaAudioCodec_LPCM,            /**< PCM Audio                  */\n    cudaAudioCodec_AAC,             /**< AAC Audio                  */\n} cudaAudioCodec;\n\n/************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct TIMECODESET\n//! Used to store Time code set extracted from H264 and HEVC codecs\n/************************************************************************/\ntypedef struct _TIMECODESET\n{\n    unsigned int time_offset_value;\n    unsigned short n_frames;\n    unsigned char clock_timestamp_flag;\n    unsigned char units_field_based_flag;\n    unsigned char counting_type;\n    unsigned char full_timestamp_flag;\n    unsigned char discontinuity_flag;\n    unsigned char cnt_dropped_flag;\n    unsigned char seconds_value;\n    unsigned char minutes_value;\n    unsigned char hours_value;\n    unsigned char seconds_flag;\n    unsigned char minutes_flag;\n    unsigned char hours_flag;\n    unsigned char time_offset_length;\n    unsigned char reserved;\n} TIMECODESET;\n\n/************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct TIMECODE\n//! Used to extract Time code in H264 and HEVC codecs\n/************************************************************************/\ntypedef struct _TIMECODE\n{\n    TIMECODESET time_code_set[MAX_CLOCK_TS];\n    unsigned char num_clock_ts;\n} NVTIMECODE;\n\n/**********************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct SEIMASTERINGDISPLAYINFO\n//! Used to extract mastering display color volume SEI in H264 and HEVC codecs\n/**********************************************************************************/\ntypedef struct _SEIMASTERINGDISPLAYINFO\n{\n    unsigned short display_primaries_x[3];\n    unsigned short display_primaries_y[3];\n    unsigned short white_point_x;\n    unsigned short white_point_y;\n    unsigned int max_display_mastering_luminance;\n    unsigned int min_display_mastering_luminance;\n} SEIMASTERINGDISPLAYINFO;\n\n/**********************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct SEICONTENTLIGHTLEVELINFO\n//! Used to extract content light level info SEI in H264 and HEVC codecs\n/**********************************************************************************/\ntypedef struct _SEICONTENTLIGHTLEVELINFO\n{\n    unsigned short max_content_light_level;\n    unsigned short max_pic_average_light_level;\n    unsigned int reserved;\n} SEICONTENTLIGHTLEVELINFO;\n\n/**********************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct TIMECODEMPEG2\n//! Used to extract Time code in MPEG2 codec\n/**********************************************************************************/\ntypedef struct _TIMECODEMPEG2\n{\n    unsigned char drop_frame_flag;\n    unsigned char time_code_hours;\n    unsigned char time_code_minutes;\n    unsigned char marker_bit;\n    unsigned char time_code_seconds;\n    unsigned char time_code_pictures;\n} TIMECODEMPEG2;\n\n/**********************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct SEIALTERNATIVETRANSFERCHARACTERISTICS\n//! Used to extract alternative transfer characteristics SEI in H264 and HEVC codecs\n/**********************************************************************************/\ntypedef struct _SEIALTERNATIVETRANSFERCHARACTERISTICS\n{\n    unsigned char preferred_transfer_characteristics;\n} SEIALTERNATIVETRANSFERCHARACTERISTICS;\n\n/**********************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUSEIMESSAGE;\n//! Used in CUVIDSEIMESSAGEINFO structure\n/**********************************************************************************/\ntypedef struct _CUSEIMESSAGE\n{\n    unsigned char sei_message_type; /**< OUT: SEI Message Type      */\n    unsigned char reserved[3];\n    unsigned int sei_message_size;  /**< OUT: SEI Message Size      */\n} CUSEIMESSAGE;\n\n/************************************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDEOFORMAT\n//! Video format\n//! Used in cuvidGetSourceVideoFormat API\n/************************************************************************************************/\ntypedef struct\n{\n    cudaVideoCodec codec;                   /**< OUT: Compression format          */\n   /**\n    * OUT: frame rate = numerator / denominator (for example: 30000/1001)\n    */\n    struct {\n        /**< OUT: frame rate numerator   (0 = unspecified or variable frame rate) */\n        unsigned int numerator;\n        /**< OUT: frame rate denominator (0 = unspecified or variable frame rate) */\n        unsigned int denominator;\n    } frame_rate;\n    unsigned char progressive_sequence;     /**< OUT: 0=interlaced, 1=progressive                                      */\n    unsigned char bit_depth_luma_minus8;    /**< OUT: high bit depth luma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth   */\n    unsigned char bit_depth_chroma_minus8;  /**< OUT: high bit depth chroma. E.g, 2 for 10-bitdepth, 4 for 12-bitdepth */\n    unsigned char min_num_decode_surfaces;  /**< OUT: Minimum number of decode surfaces to be allocated for correct\n                                                      decoding. The client can send this value in ulNumDecodeSurfaces\n                                                      (in CUVIDDECODECREATEINFO structure).\n                                                      This guarantees correct functionality and optimal video memory\n                                                      usage but not necessarily the best performance, which depends on\n                                                      the design of the overall application. The optimal number of\n                                                      decode surfaces (in terms of performance and memory utilization)\n                                                      should be decided by experimentation for each application, but it\n                                                      cannot go below min_num_decode_surfaces.\n                                                      If this value is used for ulNumDecodeSurfaces then it must be\n                                                      returned to parser during sequence callback.                     */\n    unsigned int coded_width;               /**< OUT: coded frame width in pixels                                      */\n    unsigned int coded_height;              /**< OUT: coded frame height in pixels                                     */\n   /**\n    * area of the frame that should be displayed\n    * typical example:\n    * coded_width = 1920, coded_height = 1088\n    * display_area = { 0,0,1920,1080 }\n    */\n    struct {\n        int left;                           /**< OUT: left position of display rect    */\n        int top;                            /**< OUT: top position of display rect     */\n        int right;                          /**< OUT: right position of display rect   */\n        int bottom;                         /**< OUT: bottom position of display rect  */\n    } display_area;\n    cudaVideoChromaFormat chroma_format;    /**< OUT:  Chroma format                   */\n    unsigned int bitrate;                   /**< OUT: video bitrate (bps, 0=unknown)   */\n   /**\n    * OUT: Display Aspect Ratio = x:y (4:3, 16:9, etc)\n    */\n    struct {\n        int x;\n        int y;\n    } display_aspect_ratio;\n    /**\n    * Video Signal Description\n    * Refer section E.2.1 (VUI parameters semantics) of H264 spec file\n    */\n    struct {\n        unsigned char video_format          : 3; /**< OUT: 0-Component, 1-PAL, 2-NTSC, 3-SECAM, 4-MAC, 5-Unspecified     */\n        unsigned char video_full_range_flag : 1; /**< OUT: indicates the black level and luma and chroma range           */\n        unsigned char reserved_zero_bits    : 4; /**< Reserved bits                                                      */\n        unsigned char color_primaries;           /**< OUT: chromaticity coordinates of source primaries                  */\n        unsigned char transfer_characteristics;  /**< OUT: opto-electronic transfer characteristic of the source picture */\n        unsigned char matrix_coefficients;       /**< OUT: used in deriving luma and chroma signals from RGB primaries   */\n    } video_signal_description;\n    unsigned int seqhdr_data_length;             /**< OUT: Additional bytes following (CUVIDEOFORMATEX)                  */\n} CUVIDEOFORMAT;\n\n/****************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDOPERATINGPOINTINFO\n//! Operating point information of scalable bitstream\n/****************************************************************/\ntypedef struct\n{\n    cudaVideoCodec codec;\n    union\n    {\n        struct\n        {\n            unsigned char  operating_points_cnt;\n            unsigned char  reserved24_bits[3];\n            unsigned short operating_points_idc[32];\n        } av1;\n        unsigned char CodecReserved[1024];\n    };\n} CUVIDOPERATINGPOINTINFO;\n\n/**********************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDSEIMESSAGEINFO\n//! Used in cuvidParseVideoData API with PFNVIDSEIMSGCALLBACK pfnGetSEIMsg\n/**********************************************************************************/\ntypedef struct _CUVIDSEIMESSAGEINFO\n{\n    void *pSEIData;                 /**< OUT: SEI Message Data      */\n    CUSEIMESSAGE *pSEIMessage;      /**< OUT: SEI Message Info      */\n    unsigned int sei_message_count; /**< OUT: SEI Message Count     */\n    unsigned int picIdx;            /**< OUT: SEI Message Pic Index */\n} CUVIDSEIMESSAGEINFO;\n\n/****************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDAV1SEQHDR\n//! AV1 specific sequence header information\n/****************************************************************/\ntypedef struct {\n    unsigned int max_width;\n    unsigned int max_height;\n    unsigned char reserved[1016];\n} CUVIDAV1SEQHDR;\n\n/****************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDEOFORMATEX\n//! Video format including raw sequence header information\n//! Used in cuvidGetSourceVideoFormat API\n/****************************************************************/\ntypedef struct\n{\n    CUVIDEOFORMAT format;                 /**< OUT: CUVIDEOFORMAT structure */\n    union {\n        CUVIDAV1SEQHDR av1;\n        unsigned char raw_seqhdr_data[1024];  /**< OUT: Sequence header data    */\n    };\n} CUVIDEOFORMATEX;\n\n/****************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUAUDIOFORMAT\n//! Audio formats\n//! Used in cuvidGetSourceAudioFormat API\n/****************************************************************/\ntypedef struct\n{\n    cudaAudioCodec codec;       /**< OUT: Compression format                                              */\n    unsigned int channels;      /**< OUT: number of audio channels                                        */\n    unsigned int samplespersec; /**< OUT: sampling frequency                                              */\n    unsigned int bitrate;       /**< OUT: For uncompressed, can also be used to determine bits per sample */\n    unsigned int reserved1;     /**< Reserved for future use                                              */\n    unsigned int reserved2;     /**< Reserved for future use                                              */\n} CUAUDIOFORMAT;\n\n\n/***************************************************************/\n//! \\enum CUvideopacketflags\n//! Data packet flags\n//! Used in CUVIDSOURCEDATAPACKET structure\n/***************************************************************/\ntypedef enum {\n    CUVID_PKT_ENDOFSTREAM   = 0x01,   /**< Set when this is the last packet for this stream                              */\n    CUVID_PKT_TIMESTAMP     = 0x02,   /**< Timestamp is valid                                                            */\n    CUVID_PKT_DISCONTINUITY = 0x04,   /**< Set when a discontinuity has to be signalled                                  */\n    CUVID_PKT_ENDOFPICTURE  = 0x08,   /**< Set when the packet contains exactly one frame or one field                   */\n    CUVID_PKT_NOTIFY_EOS    = 0x10,   /**< If this flag is set along with CUVID_PKT_ENDOFSTREAM, an additional (dummy)\n                                           display callback will be invoked with null value of CUVIDPARSERDISPINFO which\n                                           should be interpreted as end of the stream.                                   */\n} CUvideopacketflags;\n\n/*****************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDSOURCEDATAPACKET\n//! Data Packet\n//! Used in cuvidParseVideoData API\n//! IN for cuvidParseVideoData\n/*****************************************************************************/\ntypedef struct _CUVIDSOURCEDATAPACKET\n{\n    unsigned long flags;            /**< IN: Combination of CUVID_PKT_XXX flags                              */\n    unsigned long payload_size;     /**< IN: number of bytes in the payload (may be zero if EOS flag is set) */\n    const unsigned char *payload;   /**< IN: Pointer to packet payload data (may be NULL if EOS flag is set) */\n    CUvideotimestamp timestamp;     /**< IN: Presentation time stamp (10MHz clock), only valid if\n                                             CUVID_PKT_TIMESTAMP flag is set                                 */\n} CUVIDSOURCEDATAPACKET;\n\n// Callback for packet delivery\ntypedef int (CUDAAPI *PFNVIDSOURCECALLBACK)(void *, CUVIDSOURCEDATAPACKET *);\n\n/**************************************************************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDSOURCEPARAMS\n//! Describes parameters needed in cuvidCreateVideoSource API\n//! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported\n//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed.\n/**************************************************************************************************************************/\ntypedef struct _CUVIDSOURCEPARAMS\n{\n    unsigned int ulClockRate;                   /**< IN: Time stamp units in Hz (0=default=10000000Hz)      */\n    unsigned int bAnnexb : 1;                   /**< IN: AV1 annexB stream                                  */\n    unsigned int uReserved : 31;                /**< Reserved for future use - set to zero                  */\n    unsigned int uReserved1[6];                 /**< Reserved for future use - set to zero                  */\n    void *pUserData;                            /**< IN: User private data passed in to the data handlers   */\n    PFNVIDSOURCECALLBACK pfnVideoDataHandler;   /**< IN: Called to deliver video packets                    */\n    PFNVIDSOURCECALLBACK pfnAudioDataHandler;   /**< IN: Called to deliver audio packets.                   */\n    void *pvReserved2[8];                       /**< Reserved for future use - set to NULL                  */\n} CUVIDSOURCEPARAMS;\n\n\n/**********************************************/\n//! \\ingroup ENUMS\n//! \\enum CUvideosourceformat_flags\n//! CUvideosourceformat_flags\n//! Used in cuvidGetSourceVideoFormat API\n/**********************************************/\ntypedef enum {\n    CUVID_FMT_EXTFORMATINFO = 0x100             /**< Return extended format structure (CUVIDEOFORMATEX) */\n} CUvideosourceformat_flags;\n\n#if !defined(__APPLE__)\n/***************************************************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams)\n//! Create CUvideosource object. CUvideosource spawns demultiplexer thread that provides two callbacks:\n//! pfnVideoDataHandler() and pfnAudioDataHandler()\n//! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported\n//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed.\n/***************************************************************************************************************************/\ntypedef CUresult CUDAAPI tcuvidCreateVideoSource(CUvideosource *pObj, const char *pszFileName, CUVIDSOURCEPARAMS *pParams);\n\n/***************************************************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams)\n//! Create video source\n/***************************************************************************************************************************/\ntypedef CUresult CUDAAPI tcuvidCreateVideoSourceW(CUvideosource *pObj, const wchar_t *pwszFileName, CUVIDSOURCEPARAMS *pParams);\n\n/********************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidDestroyVideoSource(CUvideosource obj)\n//! Destroy video source\n/********************************************************************/\ntypedef CUresult CUDAAPI tcuvidDestroyVideoSource(CUvideosource obj);\n\n/******************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state)\n//! Set video source state to:\n//! cudaVideoState_Started - to signal the source to run and deliver data\n//! cudaVideoState_Stopped - to stop the source from delivering the data\n//! cudaVideoState_Error   - invalid source\n/******************************************************************************************/\ntypedef CUresult CUDAAPI tcuvidSetVideoSourceState(CUvideosource obj, cudaVideoState state);\n\n/******************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn cudaVideoState CUDAAPI cuvidGetVideoSourceState(CUvideosource obj)\n//! Get video source state\n//! Returns:\n//! cudaVideoState_Started - if Source is running and delivering data\n//! cudaVideoState_Stopped - if Source is stopped or reached end-of-stream\n//! cudaVideoState_Error   - if Source is in error state\n/******************************************************************************************/\ntypedef cudaVideoState CUDAAPI tcuvidGetVideoSourceState(CUvideosource obj);\n\n/******************************************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags)\n//! Gets video source format in pvidfmt, flags is set to combination of CUvideosourceformat_flags as per requirement\n/******************************************************************************************************************/\ntypedef CUresult CUDAAPI tcuvidGetSourceVideoFormat(CUvideosource obj, CUVIDEOFORMAT *pvidfmt, unsigned int flags);\n\n/**************************************************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags)\n//! Get audio source format\n//! NVDECODE API is intended for HW accelerated video decoding so CUvideosource doesn't have audio demuxer for all supported\n//! containers. It's recommended to clients to use their own or third party demuxer if audio support is needed.\n/**************************************************************************************************************************/\ntypedef CUresult CUDAAPI tcuvidGetSourceAudioFormat(CUvideosource obj, CUAUDIOFORMAT *paudfmt, unsigned int flags);\n\n#endif\n/**********************************************************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDPARSERDISPINFO\n//! Used in cuvidParseVideoData API with PFNVIDDISPLAYCALLBACK pfnDisplayPicture\n/**********************************************************************************/\ntypedef struct _CUVIDPARSERDISPINFO\n{\n    int picture_index;          /**< OUT: Index of the current picture                                                         */\n    int progressive_frame;      /**< OUT: 1 if progressive frame; 0 otherwise                                                  */\n    int top_field_first;        /**< OUT: 1 if top field is displayed first; 0 otherwise                                       */\n    int repeat_first_field;     /**< OUT: Number of additional fields (1=ivtc, 2=frame doubling, 4=frame tripling,\n                                     -1=unpaired field)                                                                        */\n    CUvideotimestamp timestamp; /**< OUT: Presentation time stamp                                                              */\n} CUVIDPARSERDISPINFO;\n\n/***********************************************************************************************************************/\n//! Parser callbacks\n//! The parser will call these synchronously from within cuvidParseVideoData(), whenever there is sequence change or a picture\n//! is ready to be decoded and/or displayed. First argument in functions is \"void *pUserData\" member of structure CUVIDSOURCEPARAMS\n//! Return values from these callbacks are interpreted as below. If the callbacks return failure, it will be propagated by\n//! cuvidParseVideoData() to the application.\n//! Parser picks default operating point as 0 and outputAllLayers flag as 0 if PFNVIDOPPOINTCALLBACK is not set or return value is\n//! -1 or invalid operating point.\n//! PFNVIDSEQUENCECALLBACK : 0: fail, 1: succeeded, > 1: override dpb size of parser (set by CUVIDPARSERPARAMS::ulMaxNumDecodeSurfaces\n//! while creating parser)\n//! PFNVIDDECODECALLBACK   : 0: fail, >=1: succeeded\n//! PFNVIDDISPLAYCALLBACK  : 0: fail, >=1: succeeded\n//! PFNVIDOPPOINTCALLBACK  : <0: fail, >=0: succeeded (bit 0-9: OperatingPoint, bit 10-10: outputAllLayers, bit 11-30: reserved)\n//! PFNVIDSEIMSGCALLBACK   : 0: fail, >=1: succeeded\n/***********************************************************************************************************************/\ntypedef int (CUDAAPI *PFNVIDSEQUENCECALLBACK)(void *, CUVIDEOFORMAT *);\ntypedef int (CUDAAPI *PFNVIDDECODECALLBACK)(void *, CUVIDPICPARAMS *);\ntypedef int (CUDAAPI *PFNVIDDISPLAYCALLBACK)(void *, CUVIDPARSERDISPINFO *);\ntypedef int (CUDAAPI *PFNVIDOPPOINTCALLBACK)(void *, CUVIDOPERATINGPOINTINFO*);\ntypedef int (CUDAAPI *PFNVIDSEIMSGCALLBACK) (void *, CUVIDSEIMESSAGEINFO *);\n\n/**************************************/\n//! \\ingroup STRUCTS\n//! \\struct CUVIDPARSERPARAMS\n//! Used in cuvidCreateVideoParser API\n/**************************************/\ntypedef struct _CUVIDPARSERPARAMS\n{\n    cudaVideoCodec CodecType;                   /**< IN: cudaVideoCodec_XXX                                                  */\n    unsigned int ulMaxNumDecodeSurfaces;        /**< IN: Max # of decode surfaces (parser will cycle through these)          */\n    unsigned int ulClockRate;                   /**< IN: Timestamp units in Hz (0=default=10000000Hz)                        */\n    unsigned int ulErrorThreshold;              /**< IN: % Error threshold (0-100) for calling pfnDecodePicture (100=always\n                                                     IN: call pfnDecodePicture even if picture bitstream is fully corrupted) */\n    unsigned int ulMaxDisplayDelay;             /**< IN: Max display queue delay (improves pipelining of decode with display)\n                                                         0=no delay (recommended values: 2..4)                               */\n    unsigned int bAnnexb : 1;                   /**< IN: AV1 annexB stream                                                   */\n    unsigned int uReserved : 31;                /**< Reserved for future use - set to zero                                   */\n    unsigned int uReserved1[4];                 /**< IN: Reserved for future use - set to 0                                  */\n    void *pUserData;                            /**< IN: User data for callbacks                                             */\n    PFNVIDSEQUENCECALLBACK pfnSequenceCallback; /**< IN: Called before decoding frames and/or whenever there is a fmt change */\n    PFNVIDDECODECALLBACK pfnDecodePicture;      /**< IN: Called when a picture is ready to be decoded (decode order)         */\n    PFNVIDDISPLAYCALLBACK pfnDisplayPicture;    /**< IN: Called whenever a picture is ready to be displayed (display order)  */\n    PFNVIDOPPOINTCALLBACK pfnGetOperatingPoint; /**< IN: Called from AV1 sequence header to get operating point of a AV1\n                                                         scalable bitstream                                                  */\n    PFNVIDSEIMSGCALLBACK pfnGetSEIMsg;          /**< IN: Called when all SEI messages are parsed for particular frame        */\n    void *pvReserved2[5];                       /**< Reserved for future use - set to NULL                                   */\n    CUVIDEOFORMATEX *pExtVideoInfo;             /**< IN: [Optional] sequence header data from system layer                   */\n} CUVIDPARSERPARAMS;\n\n/************************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams)\n//! Create video parser object and initialize\n/************************************************************************************************/\ntypedef CUresult CUDAAPI tcuvidCreateVideoParser(CUvideoparser *pObj, CUVIDPARSERPARAMS *pParams);\n\n/************************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket)\n//! Parse the video data from source data packet in pPacket\n//! Extracts parameter sets like SPS, PPS, bitstream etc. from pPacket and\n//! calls back pfnDecodePicture with CUVIDPICPARAMS data for kicking of HW decoding\n//! calls back pfnSequenceCallback with CUVIDEOFORMAT data for initial sequence header or when\n//! the decoder encounters a video format change\n//! calls back pfnDisplayPicture with CUVIDPARSERDISPINFO data to display a video frame\n/************************************************************************************************/\ntypedef CUresult CUDAAPI tcuvidParseVideoData(CUvideoparser obj, CUVIDSOURCEDATAPACKET *pPacket);\n\n/************************************************************************************************/\n//! \\ingroup FUNCTS\n//! \\fn CUresult CUDAAPI cuvidDestroyVideoParser(CUvideoparser obj)\n//! Destroy the video parser\n/************************************************************************************************/\ntypedef CUresult CUDAAPI tcuvidDestroyVideoParser(CUvideoparser obj);\n\n/**********************************************************************************************/\n\n#if defined(__cplusplus)\n}\n#endif /* __cplusplus */\n\n#endif // __NVCUVID_H__\n\n\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/cuvid.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"cuvid.h\"\n\n#include \"moreuuids.h\"\n\n#include \"parsers/H264SequenceParser.h\"\n#include \"parsers/MPEG2HeaderParser.h\"\n#include \"parsers/VC1HeaderParser.h\"\n#include \"parsers/HEVCSequenceParser.h\"\n\n#include \"Media.h\"\n\n////////////////////////////////////////////////////////////////////////////////\n// Constructor\n////////////////////////////////////////////////////////////////////////////////\n\nILAVDecoder *CreateDecoderCUVID()\n{\n    return new CDecCuvid();\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// CUVID codec map\n////////////////////////////////////////////////////////////////////////////////\n\nstatic struct\n{\n    AVCodecID ffcodec;\n    cudaVideoCodec cudaCodec;\n} cuda_codecs[] = {\n    {AV_CODEC_ID_MPEG1VIDEO, cudaVideoCodec_MPEG1}, {AV_CODEC_ID_MPEG2VIDEO, cudaVideoCodec_MPEG2},\n    {AV_CODEC_ID_VC1, cudaVideoCodec_VC1},          {AV_CODEC_ID_H264, cudaVideoCodec_H264},\n    {AV_CODEC_ID_MPEG4, cudaVideoCodec_MPEG4},      {AV_CODEC_ID_HEVC, cudaVideoCodec_HEVC},\n    {AV_CODEC_ID_VP9, cudaVideoCodec_VP9},\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// Compatibility tables\n////////////////////////////////////////////////////////////////////////////////\n\n#define LEVEL_C_LOW_LIMIT 0x0A20\n\nstatic DWORD LevelCBlacklist[] = {\n    0x0A22, 0x0A67, // Geforce 315, no VDPAU at all\n    0x0A68, 0x0A69, // Geforce G105M, only B\n    0x0CA0, 0x0CA7, // Geforce GT 330, only A\n    0x0CAC,         // Geforce GT 220, no VDPAU\n    0x10C3          // Geforce 8400GS, only A\n};\n\nstatic DWORD LevelCWhitelist[] = {\n    0x06C0, // Geforce GTX 480\n    0x06C4, // Geforce GTX 465\n    0x06CA, // Geforce GTX 480M\n    0x06CD, // Geforce GTX 470\n    0x08A5, // Geforce 320M\n\n    0x06D8, 0x06DC, // Quadro 6000\n    0x06D9,         // Quadro 5000\n    0x06DA,         // Quadro 5000M\n    0x06DD,         // Quadro 4000\n\n    0x06D1, // Tesla C2050 / C2070\n    0x06D2, // Tesla M2070\n    0x06DE, // Tesla T20 Processor\n    0x06DF, // Tesla M2070-Q\n};\n\nstatic BOOL IsLevelC(DWORD deviceId)\n{\n    int idx = 0;\n    if (deviceId >= LEVEL_C_LOW_LIMIT)\n    {\n        for (idx = 0; idx < countof(LevelCBlacklist); idx++)\n        {\n            if (LevelCBlacklist[idx] == deviceId)\n                return FALSE;\n        }\n        return TRUE;\n    }\n    else\n    {\n        for (idx = 0; idx < countof(LevelCWhitelist); idx++)\n        {\n            if (LevelCWhitelist[idx] == deviceId)\n                return TRUE;\n        }\n        return FALSE;\n    }\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// CUVID decoder implementation\n////////////////////////////////////////////////////////////////////////////////\n\nCDecCuvid::CDecCuvid(void)\n    : CDecBase()\n{\n    ZeroMemory(&cuda, sizeof(cuda));\n    ZeroMemory(&m_VideoFormat, sizeof(m_VideoFormat));\n    ZeroMemory(&m_DXVAExtendedFormat, sizeof(m_DXVAExtendedFormat));\n    ZeroMemory(&m_VideoDecoderInfo, sizeof(m_VideoDecoderInfo));\n}\n\nCDecCuvid::~CDecCuvid(void)\n{\n    DestroyDecoder(true);\n}\n\nSTDMETHODIMP CDecCuvid::DestroyDecoder(bool bFull)\n{\n    if (m_cudaCtxLock)\n        cuda.cuvidCtxLock(m_cudaCtxLock, 0);\n\n    if (m_AnnexBConverter)\n    {\n        SAFE_DELETE(m_AnnexBConverter);\n    }\n\n    if (m_hDecoder)\n    {\n        cuda.cuvidDestroyDecoder(m_hDecoder);\n        m_hDecoder = 0;\n    }\n\n    if (m_hParser)\n    {\n        cuda.cuvidDestroyVideoParser(m_hParser);\n        m_hParser = 0;\n    }\n\n    if (m_pbRawNV12)\n    {\n        cuda.cuMemFreeHost(m_pbRawNV12);\n        m_pbRawNV12 = nullptr;\n        m_cRawNV12 = 0;\n    }\n\n    if (m_cudaCtxLock)\n        cuda.cuvidCtxUnlock(m_cudaCtxLock, 0);\n\n    if (bFull)\n    {\n        if (m_cudaCtxLock)\n        {\n            cuda.cuvidCtxLockDestroy(m_cudaCtxLock);\n            m_cudaCtxLock = 0;\n        }\n\n        if (m_cudaContext)\n        {\n            cuda.cuCtxDestroy(m_cudaContext);\n            m_cudaContext = 0;\n        }\n\n        SafeRelease(&m_pD3DDevice9);\n        SafeRelease(&m_pD3D9);\n\n        FreeLibrary(cuda.cudaLib);\n        FreeLibrary(cuda.cuvidLib);\n\n        ZeroMemory(&cuda, sizeof(cuda));\n    }\n\n    return S_OK;\n}\n\n#define STRINGIFY(X) #X\n\n#define GET_PROC_EX_OPT(name, lib) cuda.name = (t##name *)GetProcAddress(lib, #name);\n\n#define GET_PROC_EX(name, lib)                                                      \\\n    GET_PROC_EX_OPT(name, lib)                                                      \\\n    if (cuda.name == nullptr)                                                       \\\n    {                                                                               \\\n        DbgLog((LOG_ERROR, 10, L\"-> Failed to load function \\\"%s\\\"\", TEXT(#name))); \\\n        return E_FAIL;                                                              \\\n    }\n\n#define GET_PROC_EX_OPT_V2(name, lib) cuda.name = (t##name *)GetProcAddress(lib, STRINGIFY(name##_v2));\n\n#define GET_PROC_EX_V2(name, lib)                                                                  \\\n    GET_PROC_EX_OPT_V2(name, lib)                                                                  \\\n    if (cuda.name == nullptr)                                                                      \\\n    {                                                                                              \\\n        DbgLog((LOG_ERROR, 10, L\"-> Failed to load function \\\"%s\\\"\", TEXT(STRINGIFY(name##_v2)))); \\\n        return E_FAIL;                                                                             \\\n    }\n\n#define GET_PROC_CUDA(name) GET_PROC_EX(name, cuda.cudaLib)\n#define GET_PROC_CUDA_V2(name) GET_PROC_EX_V2(name, cuda.cudaLib)\n#define GET_PROC_CUVID(name) GET_PROC_EX(name, cuda.cuvidLib)\n#define GET_PROC_CUVID_V2(name) GET_PROC_EX_V2(name, cuda.cuvidLib)\n\nSTDMETHODIMP CDecCuvid::LoadCUDAFuncRefs()\n{\n    // Load CUDA functions\n    cuda.cudaLib = LoadLibrary(L\"nvcuda.dll\");\n    if (cuda.cudaLib == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Loading nvcuda.dll failed\"));\n        return E_FAIL;\n    }\n\n    GET_PROC_CUDA(cuInit);\n    GET_PROC_CUDA_V2(cuCtxCreate);\n    GET_PROC_CUDA_V2(cuCtxDestroy);\n    GET_PROC_CUDA_V2(cuCtxPushCurrent);\n    GET_PROC_CUDA_V2(cuCtxPopCurrent);\n    GET_PROC_CUDA_V2(cuD3D9CtxCreate);\n    GET_PROC_CUDA_V2(cuMemAllocHost);\n    GET_PROC_CUDA(cuMemFreeHost);\n    GET_PROC_CUDA_V2(cuMemcpyDtoH);\n    GET_PROC_CUDA(cuDeviceGetCount);\n    GET_PROC_CUDA(cuDriverGetVersion);\n    GET_PROC_CUDA(cuDeviceGetName);\n    GET_PROC_CUDA(cuDeviceComputeCapability);\n    GET_PROC_CUDA(cuDeviceGetAttribute);\n\n    // Load CUVID function\n    cuda.cuvidLib = LoadLibrary(L\"nvcuvid.dll\");\n    if (cuda.cuvidLib == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Loading nvcuvid.dll failed\"));\n        return E_FAIL;\n    }\n\n    GET_PROC_CUVID(cuvidCtxLockCreate);\n    GET_PROC_CUVID(cuvidCtxLockDestroy);\n    GET_PROC_CUVID(cuvidCtxLock);\n    GET_PROC_CUVID(cuvidCtxUnlock);\n    GET_PROC_CUVID(cuvidCreateVideoParser);\n    GET_PROC_CUVID(cuvidParseVideoData);\n    GET_PROC_CUVID(cuvidDestroyVideoParser);\n    GET_PROC_CUVID(cuvidCreateDecoder);\n    GET_PROC_CUVID(cuvidDecodePicture);\n    GET_PROC_CUVID(cuvidDestroyDecoder);\n#ifdef _M_AMD64\n    GET_PROC_CUVID(cuvidMapVideoFrame64);\n    GET_PROC_CUVID(cuvidUnmapVideoFrame64);\n    cuda.cuvidMapVideoFrame = cuda.cuvidMapVideoFrame64;\n    cuda.cuvidUnmapVideoFrame = cuda.cuvidUnmapVideoFrame64;\n#else\n    GET_PROC_CUVID(cuvidMapVideoFrame);\n    GET_PROC_CUVID(cuvidUnmapVideoFrame);\n#endif\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecCuvid::FlushParser()\n{\n    CUVIDSOURCEDATAPACKET pCuvidPacket;\n    memset(&pCuvidPacket, 0, sizeof(pCuvidPacket));\n\n    pCuvidPacket.flags |= CUVID_PKT_ENDOFSTREAM;\n    CUresult result = CUDA_SUCCESS;\n\n    cuda.cuvidCtxLock(m_cudaCtxLock, 0);\n    __try\n    {\n        result = cuda.cuvidParseVideoData(m_hParser, &pCuvidPacket);\n    }\n    __except (1)\n    {\n        DbgLog((LOG_ERROR, 10, L\"cuvidFlushParser(): cuvidParseVideoData threw an exception\"));\n        result = CUDA_ERROR_UNKNOWN;\n    }\n    cuda.cuvidCtxUnlock(m_cudaCtxLock, 0);\n\n    return result;\n}\n\n// Beginning of GPU Architecture definitions\nstatic int _ConvertSMVer2CoresDrvApi(int major, int minor)\n{\n    // Defines for GPU Architecture types (using the SM version to determine the # of cores per SM\n    typedef struct\n    {\n        int SM; // 0xMm (hexadecimal notation), M = SM Major version, and m = SM minor version\n        int Cores;\n    } sSMtoCores;\n\n    sSMtoCores nGpuArchCoresPerSM[] = {{0x10, 8},   {0x11, 8},   {0x12, 8},   {0x13, 8},   {0x20, 32},\n                                       {0x21, 48},  {0x30, 192}, {0x32, 192}, {0x35, 192}, {0x37, 192},\n                                       {0x50, 128}, {0x52, 128}, {0x61, 128}, {0x70, 64} , {0x75, 64},\n                                       {0x80, 128}, {0x86, 128}, {0x89, 128},\n                                       {-1, -1}};\n\n    int index = 0;\n    while (nGpuArchCoresPerSM[index].SM != -1)\n    {\n        if (nGpuArchCoresPerSM[index].SM == ((major << 4) + minor))\n        {\n            return nGpuArchCoresPerSM[index].Cores;\n        }\n        index++;\n    }\n    DbgLog((LOG_ERROR, 10, L\"MapSMtoCores undefined SMversion %d.%d!\", major, minor));\n    return -1;\n}\n\nint CDecCuvid::GetMaxGflopsGraphicsDeviceId()\n{\n    CUdevice current_device = 0, max_perf_device = 0;\n    int device_count = 0, sm_per_multiproc = 0;\n    int best_SM_arch = 0;\n    int64_t max_compute_perf = 0;\n    int major = 0, minor = 0, multiProcessorCount, clockRate;\n    int bTCC = 0, version;\n    char deviceName[256];\n\n    cuda.cuDeviceGetCount(&device_count);\n    if (device_count <= 0)\n        return -1;\n\n    cuda.cuDriverGetVersion(&version);\n\n    // Find the best major SM Architecture GPU device that are graphics devices\n    while (current_device < device_count)\n    {\n        cuda.cuDeviceGetName(deviceName, 256, current_device);\n        cuda.cuDeviceComputeCapability(&major, &minor, current_device);\n\n        if (version >= 3020)\n        {\n            cuda.cuDeviceGetAttribute(&bTCC, CU_DEVICE_ATTRIBUTE_TCC_DRIVER, current_device);\n        }\n        else\n        {\n            // Assume a Tesla GPU is running in TCC if we are running CUDA 3.1\n            if (deviceName[0] == 'T')\n                bTCC = 1;\n        }\n        if (!bTCC)\n        {\n            if (major > 0 && major < 9999)\n            {\n                best_SM_arch = max(best_SM_arch, major);\n            }\n        }\n        current_device++;\n    }\n\n    // Find the best CUDA capable GPU device\n    current_device = 0;\n    while (current_device < device_count)\n    {\n        cuda.cuDeviceGetAttribute(&multiProcessorCount, CU_DEVICE_ATTRIBUTE_MULTIPROCESSOR_COUNT, current_device);\n        cuda.cuDeviceGetAttribute(&clockRate, CU_DEVICE_ATTRIBUTE_CLOCK_RATE, current_device);\n        cuda.cuDeviceComputeCapability(&major, &minor, current_device);\n\n        if (version >= 3020)\n        {\n            cuda.cuDeviceGetAttribute(&bTCC, CU_DEVICE_ATTRIBUTE_TCC_DRIVER, current_device);\n        }\n        else\n        {\n            // Assume a Tesla GPU is running in TCC if we are running CUDA 3.1\n            if (deviceName[0] == 'T')\n                bTCC = 1;\n        }\n\n        if (major == 9999 && minor == 9999)\n        {\n            sm_per_multiproc = 1;\n        }\n        else\n        {\n            sm_per_multiproc = _ConvertSMVer2CoresDrvApi(major, minor);\n        }\n\n        // If this is a Tesla based GPU and SM 2.0, and TCC is disabled, this is a contender\n        if (!bTCC) // Is this GPU running the TCC driver?  If so we pass on this\n        {\n            int64_t compute_perf = int64_t(multiProcessorCount * sm_per_multiproc) * clockRate;\n            if (compute_perf > max_compute_perf)\n            {\n                // If we find GPU with SM major > 2, search only these\n                if (best_SM_arch > 2)\n                {\n                    // If our device = dest_SM_arch, then we pick this one\n                    if (major == best_SM_arch)\n                    {\n                        max_compute_perf = compute_perf;\n                        max_perf_device = current_device;\n                    }\n                }\n                else\n                {\n                    max_compute_perf = compute_perf;\n                    max_perf_device = current_device;\n                }\n            }\n\n#ifdef DEBUG\n            cuda.cuDeviceGetName(deviceName, 256, current_device);\n            DbgLog((LOG_TRACE, 10, L\"CUDA Device (%d): %S, Compute: %d.%d, CUDA Cores: %d, Clock: %d MHz\",\n                    current_device, deviceName, major, minor, multiProcessorCount * sm_per_multiproc,\n                    clockRate / 1000));\n#endif\n        }\n        ++current_device;\n    }\n    return max_perf_device;\n}\n\n// ILAVDecoder\nSTDMETHODIMP CDecCuvid::Init()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecCuvid::Init(): Trying to open CUVID device\"));\n    HRESULT hr = S_OK;\n    CUresult cuStatus = CUDA_SUCCESS;\n\n    hr = LoadCUDAFuncRefs();\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Loading CUDA interfaces failed (hr: 0x%x)\", hr));\n        return hr;\n    }\n\n    cuStatus = cuda.cuInit(0);\n    if (cuStatus != CUDA_SUCCESS)\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> cuInit failed (status: %d)\", cuStatus));\n        return E_FAIL;\n    }\n\n    // TODO: select best device\n    int best_device = GetMaxGflopsGraphicsDeviceId();\n\n    DWORD dwDeviceIndex = m_pCallback->GetGPUDeviceIndex();\n    if (dwDeviceIndex != DWORD_MAX)\n    {\n        best_device = (int)dwDeviceIndex;\n    }\n\nselect_device:\n    hr = InitD3D9(best_device, dwDeviceIndex);\n\n    if (hr != S_OK)\n    {\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> No D3D device available, building non-D3D context on device %d\", best_device));\n        }\n        cuStatus = cuda.cuCtxCreate(&m_cudaContext, CU_CTX_SCHED_BLOCKING_SYNC, best_device);\n\n        if (cuStatus == CUDA_SUCCESS)\n        {\n            int major, minor;\n            cuda.cuDeviceComputeCapability(&major, &minor, best_device);\n            m_bVDPAULevelC = (major >= 2);\n            cuda.cuDeviceGetName(m_cudaDeviceName, sizeof(m_cudaDeviceName), best_device);\n            DbgLog((LOG_TRACE, 10, L\"InitCUDA(): pure CUDA context of device with compute %d.%d\", major, minor));\n        }\n    }\n\n    if (cuStatus == CUDA_ERROR_INVALID_DEVICE && dwDeviceIndex != DWORD_MAX)\n    {\n        DbgLog((LOG_TRACE, 10,\n                L\"-> Specific device was requested, but no match was found, re-trying automatic selection\"));\n        dwDeviceIndex = DWORD_MAX;\n        best_device = GetMaxGflopsGraphicsDeviceId();\n        goto select_device;\n    }\n\n    if (cuStatus == CUDA_SUCCESS)\n    {\n        // Switch to a floating context\n        CUcontext curr_ctx = nullptr;\n        cuStatus = cuda.cuCtxPopCurrent(&curr_ctx);\n        if (cuStatus != CUDA_SUCCESS)\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Storing context on the stack failed with error %d\", cuStatus));\n            return E_FAIL;\n        }\n        cuStatus = cuda.cuvidCtxLockCreate(&m_cudaCtxLock, m_cudaContext);\n        if (cuStatus != CUDA_SUCCESS)\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Creation of floating context failed with error %d\", cuStatus));\n            return E_FAIL;\n        }\n    }\n    else\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Creation of CUDA context failed with error %d\", cuStatus));\n        return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecCuvid::InitD3D9(int best_device, DWORD requested_device)\n{\n    HRESULT hr = S_OK;\n    CUresult cuStatus = CUDA_SUCCESS;\n    int device = 0;\n\n    if (IsWindows10OrNewer())\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> D3D9 CUVID interop is not supported on Windows 10\"));\n        return E_FAIL;\n    }\n\n    // Check if D3D mode is enabled/wanted\n    if (m_pSettings->GetHWAccelDeintHQ() == FALSE)\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> HQ mode is turned off, skipping D3D9 init\"));\n        return S_FALSE;\n    }\n\n    if (!m_pD3D9)\n        m_pD3D9 = Direct3DCreate9(D3D_SDK_VERSION);\n\n    if (!m_pD3D9)\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Failed to acquire IDirect3D9\"));\n        return E_FAIL;\n    }\n\n    D3DADAPTER_IDENTIFIER9 d3dId;\n    D3DPRESENT_PARAMETERS d3dpp;\n    D3DDISPLAYMODE d3ddm;\n    for (unsigned lAdapter = 0; lAdapter < m_pD3D9->GetAdapterCount(); lAdapter++)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Trying D3D Adapter %d..\", lAdapter));\n\n        ZeroMemory(&d3dpp, sizeof(d3dpp));\n        m_pD3D9->GetAdapterDisplayMode(lAdapter, &d3ddm);\n\n        d3dpp.Windowed = TRUE;\n        d3dpp.BackBufferWidth = 640;\n        d3dpp.BackBufferHeight = 480;\n        d3dpp.BackBufferCount = 1;\n        d3dpp.BackBufferFormat = d3ddm.Format;\n        d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;\n        d3dpp.Flags = D3DPRESENTFLAG_VIDEO;\n\n        IDirect3DDevice9 *pDev = nullptr;\n        CUcontext cudaCtx = 0;\n        hr = m_pD3D9->CreateDevice(\n            lAdapter, D3DDEVTYPE_HAL, GetShellWindow(),\n            D3DCREATE_HARDWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE, &d3dpp, &pDev);\n        if (SUCCEEDED(hr))\n        {\n            m_pD3D9->GetAdapterIdentifier(lAdapter, 0, &d3dId);\n            cuStatus = cuda.cuD3D9CtxCreate(&cudaCtx, &device, CU_CTX_SCHED_BLOCKING_SYNC, pDev);\n            if (cuStatus == CUDA_SUCCESS)\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> Created D3D Device on adapter %S (%d), using CUDA device %d\",\n                        d3dId.Description, lAdapter, device));\n\n                BOOL isLevelC = IsLevelC(d3dId.DeviceId);\n                DbgLog(\n                    (LOG_TRACE, 10, L\"InitCUDA(): D3D Device with Id 0x%x is level C: %d\", d3dId.DeviceId, isLevelC));\n\n                if (m_bVDPAULevelC && !isLevelC)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"InitCUDA(): We already had a Level C+ device, this one is not, skipping\"));\n                    cuda.cuCtxDestroy(cudaCtx);\n                    SafeRelease(&pDev);\n                    continue;\n                }\n\n                // Release old resources\n                SafeRelease(&m_pD3DDevice9);\n                if (m_cudaContext)\n                    cuda.cuCtxDestroy(m_cudaContext);\n\n                // Store resources\n                m_pD3DDevice9 = pDev;\n                m_cudaContext = cudaCtx;\n                m_bVDPAULevelC = isLevelC;\n                cuda.cuDeviceGetName(m_cudaDeviceName, sizeof(m_cudaDeviceName), best_device);\n                // Is this the one we want?\n                if (device == best_device)\n                    break;\n            }\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> D3D Device on adapter %d is not CUDA capable\", lAdapter));\n                SafeRelease(&pDev);\n            }\n        }\n    }\n\n    if (requested_device != DWORD_MAX && device != best_device)\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> No D3D Device found matching the requested device\"));\n        SafeRelease(&m_pD3DDevice9);\n        SafeRelease(&m_pD3D9);\n        if (m_cudaContext)\n        {\n            cuda.cuCtxDestroy(m_cudaContext);\n            m_cudaContext = 0;\n        }\n\n        return E_FAIL;\n    }\n\n    if (!m_pD3DDevice9)\n    {\n        SafeRelease(&m_pD3D9);\n        return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecCuvid::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecCuvid::InitDecoder(): Initializing CUVID decoder\"));\n    HRESULT hr = S_OK;\n\n    if (!m_cudaContext)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> InitDecoder called without a cuda context\"));\n        return E_FAIL;\n    }\n\n    // Free old device\n    DestroyDecoder(false);\n\n    // Flush Display Queue\n    memset(&m_DisplayQueue, 0, sizeof(m_DisplayQueue));\n    for (int i = 0; i < DISPLAY_DELAY; i++)\n        m_DisplayQueue[i].picture_index = -1;\n    m_DisplayPos = 0;\n\n    m_DisplayDelay = DISPLAY_DELAY;\n\n    // Reduce display delay for DVD decoding for lower decode latency\n    if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD)\n        m_DisplayDelay /= 2;\n\n    cudaVideoCodec cudaCodec = (cudaVideoCodec)-1;\n    for (int i = 0; i < countof(cuda_codecs); i++)\n    {\n        if (cuda_codecs[i].ffcodec == codec)\n        {\n            cudaCodec = cuda_codecs[i].cudaCodec;\n            break;\n        }\n    }\n\n    if (cudaCodec == -1)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Codec id %d does not map to a CUVID codec\", codec));\n        return E_FAIL;\n    }\n\n    if (cudaCodec == cudaVideoCodec_MPEG4 && !m_bVDPAULevelC)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Device is not capable to decode this format (not >= Level C)\"));\n        return E_FAIL;\n    }\n\n    m_bUseTimestampQueue = (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_ONLY_DTS) ||\n                           (cudaCodec == cudaVideoCodec_MPEG4 && pmt->formattype != FORMAT_MPEG2Video) ||\n                           (cudaCodec == cudaVideoCodec_VP9);\n    m_bWaitForKeyframe = m_bUseTimestampQueue;\n    m_bInterlaced = TRUE;\n    m_bFormatIncompatible = FALSE;\n    m_bTFF = TRUE;\n    m_rtPrevDiff = AV_NOPTS_VALUE;\n    m_bARPresent = TRUE;\n\n    // Create the CUDA Video Parser\n    CUVIDPARSERPARAMS oVideoParserParameters;\n    ZeroMemory(&oVideoParserParameters, sizeof(CUVIDPARSERPARAMS));\n    oVideoParserParameters.CodecType = cudaCodec;\n    oVideoParserParameters.ulMaxNumDecodeSurfaces = MAX_DECODE_FRAMES;\n    oVideoParserParameters.ulMaxDisplayDelay = m_DisplayDelay;\n    oVideoParserParameters.pUserData = this;\n    oVideoParserParameters.pfnSequenceCallback =\n        CDecCuvid::HandleVideoSequence; // Called before decoding frames and/or whenever there is a format change\n    oVideoParserParameters.pfnDecodePicture =\n        CDecCuvid::HandlePictureDecode; // Called when a picture is ready to be decoded (decode order)\n    oVideoParserParameters.pfnDisplayPicture =\n        CDecCuvid::HandlePictureDisplay; // Called whenever a picture is ready to be displayed (display order)\n    oVideoParserParameters.ulErrorThreshold = m_bUseTimestampQueue ? 100 : 0;\n\n    memset(&m_VideoParserExInfo, 0, sizeof(CUVIDEOFORMATEX));\n\n    // Handle AnnexB conversion for H.264 and HEVC\n    if (pmt->formattype == FORMAT_MPEG2Video &&\n        (pmt->subtype == MEDIASUBTYPE_AVC1 || pmt->subtype == MEDIASUBTYPE_avc1 || pmt->subtype == MEDIASUBTYPE_CCV1 ||\n         pmt->subtype == MEDIASUBTYPE_HVC1))\n    {\n        MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)pmt->Format();\n        m_AnnexBConverter = new CAnnexBConverter();\n        m_AnnexBConverter->SetNALUSize(2);\n\n        BYTE *annexBextra = nullptr;\n        int size = 0;\n\n        if (cudaCodec == cudaVideoCodec_H264)\n        {\n            m_AnnexBConverter->Convert(&annexBextra, &size, (BYTE *)mp2vi->dwSequenceHeader, mp2vi->cbSequenceHeader);\n        }\n        else if (cudaCodec == cudaVideoCodec_HEVC && mp2vi->cbSequenceHeader >= 23)\n        {\n            BYTE *bHEVCHeader = (BYTE *)mp2vi->dwSequenceHeader;\n            int nal_len_size = (bHEVCHeader[21] & 3) + 1;\n            if (nal_len_size != mp2vi->dwFlags)\n            {\n                DbgLog((LOG_ERROR, 10, L\"hvcC nal length size doesn't match media type\"));\n            }\n            m_AnnexBConverter->ConvertHEVCExtradata(&annexBextra, &size, (BYTE *)mp2vi->dwSequenceHeader,\n                                                    mp2vi->cbSequenceHeader);\n        }\n\n        if (annexBextra && size)\n        {\n            size = min(size, sizeof(m_VideoParserExInfo.raw_seqhdr_data));\n            memcpy(m_VideoParserExInfo.raw_seqhdr_data, annexBextra, size);\n            m_VideoParserExInfo.format.seqhdr_data_length = size;\n            av_freep(&annexBextra);\n        }\n\n        m_AnnexBConverter->SetNALUSize(mp2vi->dwFlags);\n    }\n    else\n    {\n        size_t hdr_len = 0;\n        getExtraData(*pmt, nullptr, &hdr_len);\n        if (hdr_len <= 1024)\n        {\n            getExtraData(*pmt, m_VideoParserExInfo.raw_seqhdr_data, &hdr_len);\n            m_VideoParserExInfo.format.seqhdr_data_length = (unsigned int)hdr_len;\n        }\n    }\n\n    int bitdepth = 8;\n    m_bNeedSequenceCheck = FALSE;\n    if (m_VideoParserExInfo.format.seqhdr_data_length)\n    {\n        if (cudaCodec == cudaVideoCodec_H264)\n        {\n            hr = CheckH264Sequence(m_VideoParserExInfo.raw_seqhdr_data, m_VideoParserExInfo.format.seqhdr_data_length);\n            if (FAILED(hr))\n            {\n                return VFW_E_UNSUPPORTED_VIDEO;\n            }\n            else if (hr == S_FALSE)\n            {\n                m_bNeedSequenceCheck = TRUE;\n            }\n        }\n        else if (cudaCodec == cudaVideoCodec_MPEG2)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Scanning extradata for MPEG2 sequence header\"));\n            CMPEG2HeaderParser mpeg2parser(m_VideoParserExInfo.raw_seqhdr_data,\n                                           m_VideoParserExInfo.format.seqhdr_data_length);\n            if (mpeg2parser.hdr.valid)\n            {\n                if (mpeg2parser.hdr.chroma >= 2)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"  -> Sequence header indicates incompatible chroma sampling (chroma: %d)\",\n                            mpeg2parser.hdr.chroma));\n                    return VFW_E_UNSUPPORTED_VIDEO;\n                }\n                m_bInterlaced = mpeg2parser.hdr.interlaced;\n            }\n        }\n        else if (cudaCodec == cudaVideoCodec_VC1)\n        {\n            CVC1HeaderParser vc1Parser(m_VideoParserExInfo.raw_seqhdr_data,\n                                       m_VideoParserExInfo.format.seqhdr_data_length);\n            m_bInterlaced = vc1Parser.hdr.interlaced;\n        }\n        else if (cudaCodec == cudaVideoCodec_HEVC)\n        {\n            hr = CheckHEVCSequence(m_VideoParserExInfo.raw_seqhdr_data, m_VideoParserExInfo.format.seqhdr_data_length,\n                                   &bitdepth);\n            if (FAILED(hr))\n            {\n                return VFW_E_UNSUPPORTED_VIDEO;\n            }\n            else if (hr == S_FALSE)\n            {\n                m_bNeedSequenceCheck = TRUE;\n            }\n        }\n    }\n    else\n    {\n        m_bNeedSequenceCheck = (cudaCodec == cudaVideoCodec_H264 || cudaCodec == cudaVideoCodec_HEVC);\n    }\n\n    oVideoParserParameters.pExtVideoInfo = &m_VideoParserExInfo;\n    CUresult oResult = cuda.cuvidCreateVideoParser(&m_hParser, &oVideoParserParameters);\n    if (oResult != CUDA_SUCCESS)\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Creating parser for type %d failed with code %d\", cudaCodec, oResult));\n        return E_FAIL;\n    }\n\n    BITMAPINFOHEADER *bmi = nullptr;\n    videoFormatTypeHandler(pmt->Format(), pmt->FormatType(), &bmi);\n\n    {\n        hr = CreateCUVIDDecoder(cudaCodec, bmi->biWidth, bmi->biHeight, bitdepth, !m_bInterlaced);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Creating CUVID decoder failed\"));\n            return hr;\n        }\n    }\n\n    m_bForceSequenceUpdate = TRUE;\n\n    DecodeSequenceData();\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecCuvid::CreateCUVIDDecoder(cudaVideoCodec codec, DWORD dwWidth, DWORD dwHeight, int nBitdepth,\n                                           bool bProgressiveSequence)\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecCuvid::CreateCUVIDDecoder(): Creating CUVID decoder instance\"));\n    HRESULT hr = S_OK;\n    BOOL bDXVAMode = (m_pD3DDevice9 != nullptr);\n\n    cuda.cuvidCtxLock(m_cudaCtxLock, 0);\n    CUVIDDECODECREATEINFO *dci = &m_VideoDecoderInfo;\n\nretry:\n    if (m_hDecoder)\n    {\n        cuda.cuvidDestroyDecoder(m_hDecoder);\n        m_hDecoder = 0;\n    }\n    ZeroMemory(dci, sizeof(*dci));\n    dci->ulWidth = dwWidth;\n    dci->ulHeight = dwHeight;\n    dci->ulNumDecodeSurfaces = MAX_DECODE_FRAMES;\n    dci->CodecType = codec;\n    dci->bitDepthMinus8 = nBitdepth - 8;\n    dci->ChromaFormat = cudaVideoChromaFormat_420;\n    dci->OutputFormat = nBitdepth > 8 ? cudaVideoSurfaceFormat_P016 : cudaVideoSurfaceFormat_NV12;\n    dci->DeinterlaceMode = (bProgressiveSequence || (m_pSettings->GetDeinterlacingMode() == DeintMode_Disable))\n                               ? cudaVideoDeinterlaceMode_Weave\n                               : (cudaVideoDeinterlaceMode)m_pSettings->GetHWAccelDeintMode();\n    dci->ulNumOutputSurfaces = 1;\n\n    dci->ulTargetWidth = dwWidth;\n    dci->ulTargetHeight = dwHeight;\n\n    // can't provide the original values here, or the decoder starts doing weird things - scaling to the size and\n    // cropping afterwards\n    dci->display_area.right = (short)dwWidth;\n    dci->display_area.bottom = (short)dwHeight;\n\n    dci->ulCreationFlags = bDXVAMode ? cudaVideoCreate_PreferDXVA : cudaVideoCreate_PreferCUVID;\n    dci->vidLock = m_cudaCtxLock;\n\n    // create the decoder\n    CUresult oResult = cuda.cuvidCreateDecoder(&m_hDecoder, dci);\n    if (oResult != CUDA_SUCCESS)\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Creation of decoder for type %d failed with code %d\", dci->CodecType, oResult));\n        if (bDXVAMode)\n        {\n            DbgLog((LOG_ERROR, 10, L\"  -> Retrying in pure CUVID mode\"));\n            bDXVAMode = FALSE;\n            goto retry;\n        }\n        hr = E_FAIL;\n    }\n    cuda.cuvidCtxUnlock(m_cudaCtxLock, 0);\n\n    return hr;\n}\n\nSTDMETHODIMP CDecCuvid::DecodeSequenceData()\n{\n    CUresult oResult;\n\n    CUVIDSOURCEDATAPACKET pCuvidPacket;\n    ZeroMemory(&pCuvidPacket, sizeof(pCuvidPacket));\n\n    pCuvidPacket.payload = m_VideoParserExInfo.raw_seqhdr_data;\n    pCuvidPacket.payload_size = m_VideoParserExInfo.format.seqhdr_data_length;\n\n    if (pCuvidPacket.payload && pCuvidPacket.payload_size)\n    {\n        cuda.cuvidCtxLock(m_cudaCtxLock, 0);\n        oResult = cuda.cuvidParseVideoData(m_hParser, &pCuvidPacket);\n        cuda.cuvidCtxUnlock(m_cudaCtxLock, 0);\n    }\n\n    return S_OK;\n}\n\nCUVIDPARSERDISPINFO *CDecCuvid::GetNextFrame()\n{\n    int next = (m_DisplayPos + 1) % m_DisplayDelay;\n    return &m_DisplayQueue[next];\n}\n\nint CUDAAPI CDecCuvid::HandleVideoSequence(void *obj, CUVIDEOFORMAT *cuvidfmt)\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecCuvid::HandleVideoSequence(): New Video Sequence\"));\n    CDecCuvid *filter = static_cast<CDecCuvid *>(obj);\n\n    CUVIDDECODECREATEINFO *dci = &filter->m_VideoDecoderInfo;\n\n    // Check if we should be deinterlacing\n    bool bShouldDeinterlace =\n        (!cuvidfmt->progressive_sequence && filter->m_pSettings->GetDeinterlacingMode() != DeintMode_Disable &&\n         filter->m_pSettings->GetHWAccelDeintMode() != HWDeintMode_Weave);\n\n    // Re-initialize the decoder if needed\n    if ((cuvidfmt->codec != dci->CodecType) || (cuvidfmt->coded_width != dci->ulWidth) ||\n        (cuvidfmt->coded_height != dci->ulHeight) || (cuvidfmt->chroma_format != dci->ChromaFormat) ||\n        (cuvidfmt->bit_depth_luma_minus8 != dci->bitDepthMinus8) ||\n        (bShouldDeinterlace != (dci->DeinterlaceMode != cudaVideoDeinterlaceMode_Weave)) ||\n        filter->m_bForceSequenceUpdate)\n    {\n        filter->m_bForceSequenceUpdate = FALSE;\n        HRESULT hr =\n            filter->CreateCUVIDDecoder(cuvidfmt->codec, cuvidfmt->coded_width, cuvidfmt->coded_height,\n                                       cuvidfmt->bit_depth_luma_minus8 + 8, cuvidfmt->progressive_sequence != 0);\n        if (FAILED(hr))\n            filter->m_bFormatIncompatible = TRUE;\n    }\n\n    filter->m_bInterlaced = !cuvidfmt->progressive_sequence;\n    filter->m_bDoubleRateDeint =\n        bShouldDeinterlace && (filter->m_pSettings->GetHWAccelDeintOutput() == DeintOutput_FramePerField);\n    if (filter->m_bInterlaced && cuvidfmt->frame_rate.numerator && cuvidfmt->frame_rate.denominator)\n    {\n        double dFrameTime = 10000000.0 / ((double)cuvidfmt->frame_rate.numerator / cuvidfmt->frame_rate.denominator);\n        if (filter->m_bDoubleRateDeint && (int)(dFrameTime / 10000.0) == 41)\n        {\n            filter->m_bDoubleRateDeint = TRUE;\n        }\n        if (cuvidfmt->codec != cudaVideoCodec_MPEG4)\n            filter->m_rtAvgTimePerFrame = REFERENCE_TIME(dFrameTime + 0.5);\n        else\n            filter->m_rtAvgTimePerFrame = AV_NOPTS_VALUE; // TODO: base on media type\n    }\n    else\n    {\n        filter->m_rtAvgTimePerFrame = AV_NOPTS_VALUE;\n    }\n\n    // Adjust frame time for double-rate deint\n    if (filter->m_bDoubleRateDeint && filter->m_rtAvgTimePerFrame != AV_NOPTS_VALUE)\n        filter->m_rtAvgTimePerFrame /= 2;\n\n    filter->m_VideoFormat = *cuvidfmt;\n\n    if (cuvidfmt->chroma_format != cudaVideoChromaFormat_420)\n    {\n        DbgLog((LOG_TRACE, 10, L\"CDecCuvid::HandleVideoSequence(): Incompatible Chroma Format detected\"));\n        filter->m_bFormatIncompatible = TRUE;\n    }\n\n    fillDXVAExtFormat(filter->m_DXVAExtendedFormat,\n                      (filter->m_iFullRange > 0 || cuvidfmt->video_signal_description.video_full_range_flag),\n                      cuvidfmt->video_signal_description.color_primaries,\n                      cuvidfmt->video_signal_description.matrix_coefficients,\n                      cuvidfmt->video_signal_description.transfer_characteristics);\n\n    return TRUE;\n}\n\nint CUDAAPI CDecCuvid::HandlePictureDecode(void *obj, CUVIDPICPARAMS *cuvidpic)\n{\n    CDecCuvid *filter = reinterpret_cast<CDecCuvid *>(obj);\n\n    if (filter->m_bFlushing)\n        return FALSE;\n\n    if (filter->m_bWaitForKeyframe)\n    {\n        if (cuvidpic->intra_pic_flag)\n            filter->m_bWaitForKeyframe = FALSE;\n        else\n        {\n            // Pop timestamp from the queue, drop frame\n            if (!filter->m_timestampQueue.empty())\n            {\n                filter->m_timestampQueue.pop();\n            }\n            return FALSE;\n        }\n    }\n\n    int flush_pos = filter->m_DisplayPos;\n    for (;;)\n    {\n        bool frame_in_use = false;\n        for (int i = 0; i < filter->m_DisplayDelay; i++)\n        {\n            if (filter->m_DisplayQueue[i].picture_index == cuvidpic->CurrPicIdx)\n            {\n                frame_in_use = true;\n                break;\n            }\n        }\n        if (!frame_in_use)\n        {\n            // No problem: we're safe to use this frame\n            break;\n        }\n        // The target frame is still pending in the display queue:\n        // Flush the oldest entry from the display queue and repeat\n        if (filter->m_DisplayQueue[flush_pos].picture_index >= 0)\n        {\n            filter->Display(&filter->m_DisplayQueue[flush_pos]);\n            filter->m_DisplayQueue[flush_pos].picture_index = -1;\n        }\n        flush_pos = (flush_pos + 1) % filter->m_DisplayDelay;\n    }\n\n    filter->cuda.cuvidCtxLock(filter->m_cudaCtxLock, 0);\n    filter->m_PicParams[cuvidpic->CurrPicIdx] = *cuvidpic;\n    __try\n    {\n        CUresult cuStatus = filter->cuda.cuvidDecodePicture(filter->m_hDecoder, cuvidpic);\n#ifdef DEBUG\n        if (cuStatus != CUDA_SUCCESS)\n        {\n            DbgLog((LOG_ERROR, 10, L\"CDecCuvid::HandlePictureDecode(): cuvidDecodePicture returned error code %d\",\n                    cuStatus));\n        }\n#endif\n    }\n    __except (1)\n    {\n        DbgLog((LOG_ERROR, 10, L\"CDecCuvid::HandlePictureDecode(): cuvidDecodePicture threw an exception\"));\n    }\n    filter->cuda.cuvidCtxUnlock(filter->m_cudaCtxLock, 0);\n\n    return TRUE;\n}\n\nint CUDAAPI CDecCuvid::HandlePictureDisplay(void *obj, CUVIDPARSERDISPINFO *cuviddisp)\n{\n    CDecCuvid *filter = reinterpret_cast<CDecCuvid *>(obj);\n\n    if (filter->m_bFlushing)\n        return FALSE;\n\n    if (filter->m_bUseTimestampQueue)\n    {\n        if (filter->m_timestampQueue.empty())\n        {\n            cuviddisp->timestamp = AV_NOPTS_VALUE;\n        }\n        else\n        {\n            cuviddisp->timestamp = filter->m_timestampQueue.front();\n            filter->m_timestampQueue.pop();\n        }\n    }\n\n    // Drop samples with negative timestamps (preroll) or during flushing\n    if (cuviddisp->timestamp != AV_NOPTS_VALUE && cuviddisp->timestamp < 0)\n        return TRUE;\n\n    if (filter->m_DisplayQueue[filter->m_DisplayPos].picture_index >= 0)\n    {\n        filter->Display(&filter->m_DisplayQueue[filter->m_DisplayPos]);\n        filter->m_DisplayQueue[filter->m_DisplayPos].picture_index = -1;\n    }\n    filter->m_DisplayQueue[filter->m_DisplayPos] = *cuviddisp;\n    filter->m_DisplayPos = (filter->m_DisplayPos + 1) % filter->m_DisplayDelay;\n\n    return TRUE;\n}\n\nSTDMETHODIMP CDecCuvid::Display(CUVIDPARSERDISPINFO *cuviddisp)\n{\n    BOOL bTreatAsProgressive = m_pSettings->GetDeinterlacingMode() == DeintMode_Disable;\n\n    if (bTreatAsProgressive)\n    {\n        cuviddisp->progressive_frame = TRUE;\n        m_nSoftTelecine = FALSE;\n    }\n    else\n    {\n        if (m_VideoFormat.codec == cudaVideoCodec_MPEG2 || m_VideoFormat.codec == cudaVideoCodec_H264)\n        {\n            if (cuviddisp->repeat_first_field)\n            {\n                m_nSoftTelecine = 2;\n            }\n            else if (m_nSoftTelecine)\n            {\n                m_nSoftTelecine--;\n            }\n            if (!m_nSoftTelecine)\n                m_bTFF = cuviddisp->top_field_first;\n        }\n\n        cuviddisp->progressive_frame =\n            (cuviddisp->progressive_frame &&\n             !(m_bInterlaced && m_pSettings->GetDeinterlacingMode() == DeintMode_Aggressive &&\n               m_VideoFormat.codec != cudaVideoCodec_VC1 && !m_nSoftTelecine) &&\n             !(m_pSettings->GetDeinterlacingMode() == DeintMode_Force));\n    }\n\n    LAVDeintFieldOrder fo = m_pSettings->GetDeintFieldOrder();\n    cuviddisp->top_field_first = (fo == DeintFieldOrder_Auto) ? (m_nSoftTelecine ? m_bTFF : cuviddisp->top_field_first)\n                                                              : (fo == DeintFieldOrder_TopFieldFirst);\n\n    if (m_bDoubleRateDeint)\n    {\n        if (cuviddisp->progressive_frame || m_nSoftTelecine)\n        {\n            Deliver(cuviddisp, 2);\n        }\n        else\n        {\n            Deliver(cuviddisp, 0);\n            Deliver(cuviddisp, 1);\n        }\n    }\n    else\n    {\n        Deliver(cuviddisp);\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP CDecCuvid::Deliver(CUVIDPARSERDISPINFO *cuviddisp, int field)\n{\n    CUdeviceptr devPtr = 0;\n    unsigned int pitch = 0;\n    CUVIDPROCPARAMS vpp;\n    CUresult cuStatus = CUDA_SUCCESS;\n\n    memset(&vpp, 0, sizeof(vpp));\n    vpp.progressive_frame = !m_nSoftTelecine && cuviddisp->progressive_frame;\n    vpp.top_field_first = cuviddisp->top_field_first;\n    vpp.second_field = (field == 1);\n\n    cuda.cuvidCtxLock(m_cudaCtxLock, 0);\n    cuStatus = cuda.cuvidMapVideoFrame(m_hDecoder, cuviddisp->picture_index, &devPtr, &pitch, &vpp);\n    if (cuStatus != CUDA_SUCCESS)\n    {\n        DbgLog(\n            (LOG_CUSTOM1, 1, L\"CDecCuvid::Deliver(): cuvidMapVideoFrame failed on index %d\", cuviddisp->picture_index));\n        goto cuda_fail;\n    }\n\n    int size = pitch * m_VideoDecoderInfo.ulTargetHeight * 3 / 2;\n    if (!m_pbRawNV12 || size > m_cRawNV12)\n    {\n        if (m_pbRawNV12)\n        {\n            cuda.cuMemFreeHost(m_pbRawNV12);\n            m_pbRawNV12 = nullptr;\n            m_cRawNV12 = 0;\n        }\n        cuStatus = cuda.cuMemAllocHost((void **)&m_pbRawNV12, size);\n        if (cuStatus != CUDA_SUCCESS)\n        {\n            DbgLog((LOG_CUSTOM1, 1, L\"CDecCuvid::Deliver(): cuMemAllocHost failed to allocate %d bytes (%d)\", size,\n                    cuStatus));\n            goto cuda_fail;\n        }\n        m_cRawNV12 = size;\n    }\n    // Copy memory from the device into the staging area\n    if (m_pbRawNV12)\n    {\n        cuStatus = cuda.cuMemcpyDtoH(m_pbRawNV12, devPtr, size);\n        if (cuStatus != CUDA_SUCCESS)\n        {\n            DbgLog((LOG_ERROR, 10, L\"Memory Transfer failed (%d)\", cuStatus));\n            goto cuda_fail;\n        }\n    }\n    else\n    {\n        // If we don't have our memory, this is bad.\n        DbgLog((LOG_ERROR, 10, L\"No Valid Staging Memory - failing\"));\n        goto cuda_fail;\n    }\n    cuda.cuvidUnmapVideoFrame(m_hDecoder, devPtr);\n    cuda.cuvidCtxUnlock(m_cudaCtxLock, 0);\n\n    // Setup the LAVFrame\n    LAVFrame *pFrame = nullptr;\n    AllocateFrame(&pFrame);\n\n    if (m_rtAvgTimePerFrame != AV_NOPTS_VALUE)\n    {\n        pFrame->avgFrameDuration = m_rtAvgTimePerFrame;\n        if (m_bDoubleRateDeint && field == 2)\n            pFrame->avgFrameDuration *= 2;\n    }\n\n    REFERENCE_TIME rtStart = cuviddisp->timestamp, rtStop = AV_NOPTS_VALUE;\n    if (rtStart != AV_NOPTS_VALUE)\n    {\n        CUVIDPARSERDISPINFO *next = GetNextFrame();\n        if (next->picture_index != -1 && next->timestamp != AV_NOPTS_VALUE)\n        {\n            m_rtPrevDiff = next->timestamp - cuviddisp->timestamp;\n        }\n\n        if (m_rtPrevDiff != AV_NOPTS_VALUE)\n        {\n            REFERENCE_TIME rtHalfDiff = m_rtPrevDiff >> 1;\n            if (field == 1)\n                rtStart += rtHalfDiff;\n\n            rtStop = rtStart + rtHalfDiff;\n\n            if (field == 2 || !m_bDoubleRateDeint)\n                rtStop += rtHalfDiff;\n        }\n\n        // Sanity check in case the duration is null\n        if (rtStop <= rtStart)\n            rtStop = AV_NOPTS_VALUE;\n    }\n\n    pFrame->format = (m_VideoDecoderInfo.OutputFormat == cudaVideoSurfaceFormat_P016) ? LAVPixFmt_P016 : LAVPixFmt_NV12;\n    pFrame->sw_format = pFrame->format;\n    pFrame->bpp = m_VideoDecoderInfo.bitDepthMinus8 + 8;\n    pFrame->width = m_VideoFormat.display_area.right;\n    pFrame->height = m_VideoFormat.display_area.bottom;\n    pFrame->rtStart = rtStart;\n    pFrame->rtStop = rtStop;\n    pFrame->repeat = cuviddisp->repeat_first_field;\n    {\n        AVRational ar = {m_VideoFormat.display_aspect_ratio.x, m_VideoFormat.display_aspect_ratio.y};\n        AVRational arDim = {pFrame->width, pFrame->height};\n        if (m_bARPresent || av_cmp_q(ar, arDim) != 0)\n        {\n            pFrame->aspect_ratio = ar;\n        }\n    }\n    pFrame->ext_format = m_DXVAExtendedFormat;\n    pFrame->interlaced =\n        !cuviddisp->progressive_frame && m_VideoDecoderInfo.DeinterlaceMode == cudaVideoDeinterlaceMode_Weave;\n    pFrame->tff = cuviddisp->top_field_first;\n\n    // TODO: This may be wrong for H264 where B-Frames can be references\n    pFrame->frame_type = m_PicParams[cuviddisp->picture_index].intra_pic_flag\n                             ? 'I'\n                             : (m_PicParams[cuviddisp->picture_index].ref_pic_flag ? 'P' : 'B');\n\n    // Assign the buffer to the LAV Frame bufers\n    int Ysize = m_VideoDecoderInfo.ulTargetHeight * pitch;\n    pFrame->data[0] = m_pbRawNV12;\n    pFrame->data[1] = m_pbRawNV12 + Ysize;\n    pFrame->stride[0] = pFrame->stride[1] = pitch;\n    pFrame->flags |= LAV_FRAME_FLAG_BUFFER_MODIFY;\n\n    if (m_bEndOfSequence)\n        pFrame->flags |= LAV_FRAME_FLAG_END_OF_SEQUENCE;\n\n    m_pCallback->Deliver(pFrame);\n\n    return S_OK;\n\ncuda_fail:\n    cuda.cuvidUnmapVideoFrame(m_hDecoder, devPtr);\n    cuda.cuvidCtxUnlock(m_cudaCtxLock, 0);\n    return E_FAIL;\n}\n\nSTDMETHODIMP CDecCuvid::CheckH264Sequence(const BYTE *buffer, int buflen)\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecCuvid::CheckH264Sequence(): Checking H264 frame for SPS\"));\n    CH264SequenceParser h264parser;\n    h264parser.ParseNALs(buffer, buflen, 0);\n    if (h264parser.sps.valid)\n    {\n        m_bInterlaced = h264parser.sps.interlaced;\n        m_iFullRange = h264parser.sps.full_range;\n        m_bARPresent = h264parser.sps.ar_present;\n        DbgLog((LOG_TRACE, 10, L\"-> SPS found\"));\n        if (h264parser.sps.profile > 100 || h264parser.sps.chroma != 1 || h264parser.sps.luma_bitdepth != 8 ||\n            h264parser.sps.chroma_bitdepth != 8 || h264parser.sps.level >= 60)\n        {\n            DbgLog((LOG_TRACE, 10,\n                    L\"  -> SPS indicates video incompatible with CUVID, aborting (profile: %d, level: %d, chroma: %d, bitdepth: \"\n                    L\"%d/%d)\",\n                    h264parser.sps.profile, h264parser.sps.level, h264parser.sps.chroma, h264parser.sps.luma_bitdepth,\n                    h264parser.sps.chroma_bitdepth));\n            return E_FAIL;\n        }\n        DbgLog((LOG_TRACE, 10, L\"-> Video seems compatible with CUVID\"));\n        return S_OK;\n    }\n    return S_FALSE;\n}\n\nSTDMETHODIMP CDecCuvid::CheckHEVCSequence(const BYTE *buffer, int buflen, int *bitdepth)\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecCuvid::CheckHEVCSequence(): Checking HEVC frame for SPS\"));\n    CHEVCSequenceParser hevcParser;\n    hevcParser.ParseNALs(buffer, buflen, 0);\n    if (hevcParser.sps.valid)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> SPS found\"));\n        if (hevcParser.sps.chroma > 1 || hevcParser.sps.bitdepth > 12 ||\n            !(hevcParser.sps.profile <= AV_PROFILE_HEVC_MAIN_10 ||\n              (hevcParser.sps.profile == AV_PROFILE_HEVC_REXT &&\n               hevcParser.sps.rext_profile == HEVC_REXT_PROFILE_MAIN_12)))\n        {\n            DbgLog((LOG_TRACE, 10, L\"  -> SPS indicates video incompatible with CUVID, aborting (profile: %d)\",\n                    hevcParser.sps.profile));\n            return E_FAIL;\n        }\n        if (bitdepth)\n            *bitdepth = hevcParser.sps.bitdepth;\n        DbgLog((LOG_TRACE, 10, L\"-> Video seems compatible with CUVID\"));\n        return S_OK;\n    }\n    return S_FALSE;\n}\n\nSTDMETHODIMP CDecCuvid::Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,\n                               BOOL bSyncPoint, BOOL bDiscontinuity, IMediaSample *pSample)\n{\n    CUresult result;\n    HRESULT hr = S_OK;\n\n    CUVIDSOURCEDATAPACKET pCuvidPacket;\n    ZeroMemory(&pCuvidPacket, sizeof(pCuvidPacket));\n\n    BYTE *pBuffer = nullptr;\n    if (m_AnnexBConverter)\n    {\n        int size = 0;\n        hr = m_AnnexBConverter->Convert(&pBuffer, &size, buffer, buflen);\n        if (SUCCEEDED(hr))\n        {\n            pCuvidPacket.payload = pBuffer;\n            pCuvidPacket.payload_size = size;\n        }\n    }\n    else\n    {\n        pCuvidPacket.payload = buffer;\n        pCuvidPacket.payload_size = buflen;\n\n        if (m_VideoDecoderInfo.CodecType == cudaVideoCodec_MPEG2)\n        {\n            const uint8_t *eosmarker = nullptr;\n            const uint8_t *end = buffer + buflen;\n            int status =\n                CheckForSequenceMarkers(AV_CODEC_ID_MPEG2VIDEO, buffer, buflen, &m_MpegParserState, &eosmarker);\n\n            // If we found a EOS marker, but its not at the end of the packet, then split the packet\n            // to be able to individually decode the frame before the EOS, and then decode the remainder\n            if (status & STATE_EOS_FOUND && eosmarker && eosmarker != end)\n            {\n                Decode(buffer, (int)(eosmarker - buffer), rtStart, rtStop, bSyncPoint, bDiscontinuity, nullptr);\n\n                rtStart = rtStop = AV_NOPTS_VALUE;\n                pCuvidPacket.payload = eosmarker;\n                pCuvidPacket.payload_size = (int)(end - eosmarker);\n            }\n            else if (eosmarker)\n            {\n                m_bEndOfSequence = TRUE;\n            }\n        }\n    }\n\n    if (m_bNeedSequenceCheck)\n    {\n        if (m_VideoDecoderInfo.CodecType == cudaVideoCodec_H264)\n        {\n            hr = CheckH264Sequence(pCuvidPacket.payload, pCuvidPacket.payload_size);\n        }\n        else if (m_VideoDecoderInfo.CodecType == cudaVideoCodec_HEVC)\n        {\n            hr = CheckHEVCSequence(pCuvidPacket.payload, pCuvidPacket.payload_size, nullptr);\n        }\n        if (FAILED(hr))\n        {\n            m_bFormatIncompatible = TRUE;\n        }\n        else if (hr == S_OK)\n        {\n            m_bNeedSequenceCheck = FALSE;\n        }\n    }\n\n    if (rtStart != AV_NOPTS_VALUE)\n    {\n        pCuvidPacket.flags |= CUVID_PKT_TIMESTAMP;\n        pCuvidPacket.timestamp = rtStart;\n    }\n\n    if (bDiscontinuity)\n        pCuvidPacket.flags |= CUVID_PKT_DISCONTINUITY;\n\n    if (m_bUseTimestampQueue)\n        m_timestampQueue.push(rtStart);\n\n    cuda.cuvidCtxLock(m_cudaCtxLock, 0);\n    __try\n    {\n        result = cuda.cuvidParseVideoData(m_hParser, &pCuvidPacket);\n    }\n    __except (1)\n    {\n        DbgLog((LOG_ERROR, 10, L\"CDecCuvid::Decode(): cuvidParseVideoData threw an exception\"));\n    }\n    cuda.cuvidCtxUnlock(m_cudaCtxLock, 0);\n\n    av_freep(&pBuffer);\n\n    if (m_bEndOfSequence)\n    {\n        EndOfStream();\n        m_pCallback->Deliver(m_pCallback->GetFlushFrame());\n        m_bEndOfSequence = FALSE;\n    }\n\n    if (m_bFormatIncompatible)\n    {\n        DbgLog((LOG_ERROR, 10, L\"CDecCuvid::Decode(): Incompatible format detected, indicating failure...\"));\n        return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecCuvid::Flush()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecCuvid::Flush(): Flushing CUVID decoder\"));\n    m_bFlushing = TRUE;\n\n    FlushParser();\n\n    // Flush display queue\n    for (int i = 0; i < m_DisplayDelay; ++i)\n    {\n        if (m_DisplayQueue[m_DisplayPos].picture_index >= 0)\n        {\n            m_DisplayQueue[m_DisplayPos].picture_index = -1;\n        }\n        m_DisplayPos = (m_DisplayPos + 1) % m_DisplayDelay;\n    }\n\n    m_bFlushing = FALSE;\n    m_bWaitForKeyframe = m_bUseTimestampQueue;\n\n    // Re-init decoder after flush\n    DecodeSequenceData();\n\n    // Clear timestamp queue\n    std::queue<REFERENCE_TIME>().swap(m_timestampQueue);\n\n    m_nSoftTelecine = 0;\n\n    return __super::Flush();\n}\n\nSTDMETHODIMP CDecCuvid::EndOfStream()\n{\n    FlushParser();\n\n    // Display all frames left in the queue\n    for (int i = 0; i < m_DisplayDelay; ++i)\n    {\n        if (m_DisplayQueue[m_DisplayPos].picture_index >= 0)\n        {\n            Display(&m_DisplayQueue[m_DisplayPos]);\n            m_DisplayQueue[m_DisplayPos].picture_index = -1;\n        }\n        m_DisplayPos = (m_DisplayPos + 1) % m_DisplayDelay;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecCuvid::GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware)\n{\n    // Output is always NV12\n    if (pPix)\n        *pPix = (m_VideoDecoderInfo.OutputFormat == cudaVideoSurfaceFormat_P016) ? LAVPixFmt_P016 : LAVPixFmt_NV12;\n    if (pBpp)\n        *pBpp = m_VideoDecoderInfo.bitDepthMinus8 + 8;\n    if (pPixSoftware)\n        *pPixSoftware = (m_VideoDecoderInfo.OutputFormat == cudaVideoSurfaceFormat_P016) ? LAVPixFmt_P016 : LAVPixFmt_NV12;\n    return S_OK;\n}\n\nSTDMETHODIMP_(REFERENCE_TIME) CDecCuvid::GetFrameDuration()\n{\n    return 0;\n}\n\nSTDMETHODIMP_(BOOL) CDecCuvid::IsInterlaced(BOOL bAllowGuess)\n{\n    return (m_bInterlaced || m_pSettings->GetDeinterlacingMode() == DeintMode_Force) &&\n           (m_VideoDecoderInfo.DeinterlaceMode == cudaVideoDeinterlaceMode_Weave);\n}\n\nSTDMETHODIMP CDecCuvid::GetHWAccelActiveDevice(BSTR *pstrDeviceName)\n{\n    CheckPointer(pstrDeviceName, E_POINTER);\n\n    if (strlen(m_cudaDeviceName) == 0)\n        return E_UNEXPECTED;\n\n    int len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, m_cudaDeviceName, -1, nullptr, 0);\n    if (len == 0)\n        return E_FAIL;\n\n    *pstrDeviceName = SysAllocStringLen(nullptr, len);\n    MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, m_cudaDeviceName, -1, *pstrDeviceName, len);\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/cuvid.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n#include \"DecBase.h\"\n\n#define MAX_DECODE_FRAMES 20\n#define DISPLAY_DELAY 4\n#define MAX_PIC_INDEX 64\n\n#include \"cuvid/dynlink_cuda.h\"\n#include \"cuvid/dynlink_nvcuvid.h\"\n\n#define CUDA_INIT_D3D9\n#include \"cuvid/dynlink_cuda_d3d.h\"\n\n#include \"parsers/AnnexBConverter.h\"\n\n#include <queue>\n\n#define CUMETHOD(name) t##name *##name\n\nclass CDecCuvid : public CDecBase\n{\n  public:\n    CDecCuvid(void);\n    virtual ~CDecCuvid(void);\n\n    // ILAVDecoder\n    STDMETHODIMP InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData);\n    STDMETHODIMP Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BOOL bSyncPoint,\n                        BOOL bDiscontinuity, IMediaSample *pSample);\n    STDMETHODIMP Flush();\n    STDMETHODIMP EndOfStream();\n    STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware);\n    STDMETHODIMP_(REFERENCE_TIME) GetFrameDuration();\n    STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess);\n    STDMETHODIMP_(const WCHAR *) GetDecoderName() { return L\"cuvid\"; }\n    STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName);\n\n    // CDecBase\n    STDMETHODIMP Init();\n\n  private:\n    STDMETHODIMP LoadCUDAFuncRefs();\n    STDMETHODIMP DestroyDecoder(bool bFull);\n\n    STDMETHODIMP InitD3D9(int best_device, DWORD requested_device);\n\n    STDMETHODIMP CreateCUVIDDecoder(cudaVideoCodec codec, DWORD dwWidth, DWORD dwHeight, int nBitdepth,\n                                    bool bProgressiveSequence);\n    STDMETHODIMP DecodeSequenceData();\n\n    // CUDA Callbacks\n    static int CUDAAPI HandleVideoSequence(void *obj, CUVIDEOFORMAT *cuvidfmt);\n    static int CUDAAPI HandlePictureDecode(void *obj, CUVIDPICPARAMS *cuvidpic);\n    static int CUDAAPI HandlePictureDisplay(void *obj, CUVIDPARSERDISPINFO *cuviddisp);\n\n    STDMETHODIMP Display(CUVIDPARSERDISPINFO *cuviddisp);\n    STDMETHODIMP Deliver(CUVIDPARSERDISPINFO *cuviddisp, int field = 0);\n\n    CUVIDPARSERDISPINFO *GetNextFrame();\n\n    STDMETHODIMP FlushParser();\n\n    STDMETHODIMP CheckH264Sequence(const BYTE *buffer, int buflen);\n    STDMETHODIMP CheckHEVCSequence(const BYTE *buffer, int buflen, int *bitdepth);\n\n    int GetMaxGflopsGraphicsDeviceId();\n\n  private:\n    struct\n    {\n        HMODULE cudaLib;\n        CUMETHOD(cuInit);\n        CUMETHOD(cuCtxCreate);\n        CUMETHOD(cuCtxDestroy);\n        CUMETHOD(cuCtxPushCurrent);\n        CUMETHOD(cuCtxPopCurrent);\n        CUMETHOD(cuD3D9CtxCreate);\n        CUMETHOD(cuMemAllocHost);\n        CUMETHOD(cuMemFreeHost);\n        CUMETHOD(cuMemcpyDtoH);\n        CUMETHOD(cuDeviceGetCount);\n        CUMETHOD(cuDriverGetVersion);\n        CUMETHOD(cuDeviceGetName);\n        CUMETHOD(cuDeviceComputeCapability);\n        CUMETHOD(cuDeviceGetAttribute);\n\n        HMODULE cuvidLib;\n        CUMETHOD(cuvidCtxLockCreate);\n        CUMETHOD(cuvidCtxLockDestroy);\n        CUMETHOD(cuvidCtxLock);\n        CUMETHOD(cuvidCtxUnlock);\n        CUMETHOD(cuvidCreateVideoParser);\n        CUMETHOD(cuvidParseVideoData);\n        CUMETHOD(cuvidDestroyVideoParser);\n        CUMETHOD(cuvidCreateDecoder);\n        CUMETHOD(cuvidDecodePicture);\n        CUMETHOD(cuvidDestroyDecoder);\n        CUMETHOD(cuvidMapVideoFrame);\n        CUMETHOD(cuvidUnmapVideoFrame);\n#ifdef _M_AMD64\n        CUMETHOD(cuvidMapVideoFrame64);\n        CUMETHOD(cuvidUnmapVideoFrame64);\n#endif\n    } cuda;\n\n    IDirect3D9 *m_pD3D9 = nullptr;\n    IDirect3DDevice9 *m_pD3DDevice9 = nullptr;\n\n    CUcontext m_cudaContext = 0;\n    CUvideoctxlock m_cudaCtxLock = 0;\n\n    CUvideoparser m_hParser = 0;\n    CUVIDEOFORMATEX m_VideoParserExInfo;\n\n    CUvideodecoder m_hDecoder = 0;\n    CUVIDDECODECREATEINFO m_VideoDecoderInfo;\n\n    CUVIDEOFORMAT m_VideoFormat;\n\n    CUVIDPARSERDISPINFO m_DisplayQueue[DISPLAY_DELAY];\n    int m_DisplayPos = 0;\n\n    CUVIDPICPARAMS m_PicParams[MAX_PIC_INDEX];\n\n    BOOL m_bVDPAULevelC = FALSE;\n    char m_cudaDeviceName[256] = {0};\n\n    BOOL m_bForceSequenceUpdate = FALSE;\n    BOOL m_bInterlaced = FALSE;\n    BOOL m_bDoubleRateDeint = FALSE;\n    BOOL m_bFlushing = FALSE;\n    REFERENCE_TIME m_rtAvgTimePerFrame = AV_NOPTS_VALUE;\n    REFERENCE_TIME m_rtPrevDiff = AV_NOPTS_VALUE;\n    BOOL m_bWaitForKeyframe = FALSE;\n    int m_iFullRange = -1;\n\n    DXVA2_ExtendedFormat m_DXVAExtendedFormat;\n\n    BYTE *m_pbRawNV12 = nullptr;\n    int m_cRawNV12 = 0;\n\n    CAnnexBConverter *m_AnnexBConverter = nullptr;\n\n    BOOL m_bFormatIncompatible = FALSE;\n    BOOL m_bNeedSequenceCheck = FALSE;\n\n    BOOL m_bUseTimestampQueue = FALSE;\n    std::queue<REFERENCE_TIME> m_timestampQueue;\n\n    int m_nSoftTelecine = 0;\n    BOOL m_bTFF = TRUE;\n    BOOL m_bARPresent = TRUE;\n    BOOL m_bEndOfSequence = FALSE;\n\n    int m_DisplayDelay = DISPLAY_DELAY;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/d3d11/D3D11SurfaceAllocator.cpp",
    "content": "/*\n *      Copyright (C) 2019-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"D3D11SurfaceAllocator.h\"\n#include \"decoders/d3d11va.h\"\n\nextern \"C\"\n{\n#include \"libavutil/hwcontext.h\"\n}\n\nCD3D11MediaSample::CD3D11MediaSample(CD3D11SurfaceAllocator *pAllocator, AVFrame *pFrame, HRESULT *phr)\n    : CMediaSampleSideData(NAME(\"CD3D11MediaSample\"), (CBaseAllocator *)pAllocator, phr, nullptr, 0)\n    , m_pFrame(pFrame)\n{\n    ASSERT(m_pFrame && m_pFrame->format == AV_PIX_FMT_D3D11);\n    pAllocator->AddRef();\n\n    m_pAllocatorCookie = pAllocator->m_pFramesCtx;\n}\n\nCD3D11MediaSample::~CD3D11MediaSample()\n{\n    av_frame_free(&m_pFrame);\n    SafeRelease(&m_pAllocator);\n}\n\n// Note: CMediaSample does not derive from CUnknown, so we cannot use the\n//\t\tDECLARE_IUNKNOWN macro that is used by most of the filter classes.\n\nSTDMETHODIMP CD3D11MediaSample::QueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n\n    if (riid == __uuidof(IMediaSampleD3D11))\n    {\n        return GetInterface((IMediaSampleD3D11 *)this, ppv);\n    }\n    else\n    {\n        return __super::QueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP_(ULONG) CD3D11MediaSample::AddRef()\n{\n    return __super::AddRef();\n}\n\nSTDMETHODIMP_(ULONG) CD3D11MediaSample::Release()\n{\n    // Return a temporary variable for thread safety.\n    ULONG cRef = __super::Release();\n    return cRef;\n}\n\nSTDMETHODIMP CD3D11MediaSample::GetD3D11Texture(int nView, ID3D11Texture2D **ppTexture, UINT *pArraySlice)\n{\n    CheckPointer(ppTexture, E_POINTER);\n    CheckPointer(pArraySlice, E_POINTER);\n\n    // only view 0 is implemented at this time\n    if (nView != 0)\n        return E_INVALIDARG;\n\n    if (m_pFrame)\n    {\n        *ppTexture = (ID3D11Texture2D *)m_pFrame->data[0];\n        *pArraySlice = (UINT)(intptr_t)m_pFrame->data[1];\n\n        (*ppTexture)->AddRef();\n\n        return S_OK;\n    }\n\n    return E_FAIL;\n}\n\nstatic void bufref_release_sample(void *opaque, uint8_t *data)\n{\n    CD3D11MediaSample *pSample = (CD3D11MediaSample *)opaque;\n    pSample->Release();\n}\n\nSTDMETHODIMP CD3D11MediaSample::GetAVFrameBuffer(AVFrame *pFrame)\n{\n    CheckPointer(pFrame, E_POINTER);\n\n    // reference bufs\n    for (int i = 0; i < AV_NUM_DATA_POINTERS; i++)\n    {\n        // copy existing refs\n        if (m_pFrame->buf[i])\n        {\n            pFrame->buf[i] = av_buffer_ref(m_pFrame->buf[i]);\n            if (pFrame->buf[i] == 0)\n                return E_OUTOFMEMORY;\n        }\n        else\n        {\n            // and add a ref to this sample\n            pFrame->buf[i] = av_buffer_create((uint8_t *)this, 1, bufref_release_sample, this, 0);\n            if (pFrame->buf[i] == 0)\n                return E_OUTOFMEMORY;\n\n            AddRef();\n            break;\n        }\n    }\n\n    // ref the hwframes ctx\n    pFrame->hw_frames_ctx = av_buffer_ref(m_pFrame->hw_frames_ctx);\n\n    // copy data into the new frame\n    pFrame->data[0] = m_pFrame->data[0];\n    pFrame->data[1] = m_pFrame->data[1];\n    pFrame->data[3] = (uint8_t *)this;\n\n    pFrame->format = AV_PIX_FMT_D3D11;\n\n    return S_OK;\n}\n\nCD3D11SurfaceAllocator::CD3D11SurfaceAllocator(CDecD3D11 *pDec, HRESULT *phr)\n    : CBaseAllocator(NAME(\"CD3D11SurfaceAllocator\"), nullptr, phr)\n    , m_pDec(pDec)\n{\n}\n\nCD3D11SurfaceAllocator::~CD3D11SurfaceAllocator()\n{\n}\n\nHRESULT CD3D11SurfaceAllocator::Alloc(void)\n{\n    DbgLog((LOG_TRACE, 10, L\"CD3D11SurfaceAllocator::Alloc()\"));\n    HRESULT hr = S_OK;\n\n    CAutoLock cObjectLock(this);\n\n    if (m_pDec == nullptr)\n        return E_FAIL;\n\n    hr = __super::Alloc();\n    if (FAILED(hr))\n        return hr;\n\n    // free old resources\n    // m_pDec->FlushFromAllocator();\n    Free();\n\n    // get the frames context from the decoder\n    AVBufferRef *pDecoderFramesCtx = m_pDec->m_pFramesCtx;\n    if (pDecoderFramesCtx == nullptr)\n        return S_FALSE;\n\n    m_pFramesCtx = av_buffer_ref(pDecoderFramesCtx);\n    if (m_pFramesCtx == nullptr)\n        return E_FAIL;\n\n    // create samples\n    for (int i = 0; i < m_lCount; i++)\n    {\n        AVFrame *pFrame = av_frame_alloc();\n        int ret = av_hwframe_get_buffer(m_pFramesCtx, pFrame, 0);\n        if (ret < 0)\n        {\n            av_frame_free(&pFrame);\n            Free();\n            return E_FAIL;\n        }\n\n        CD3D11MediaSample *pSample = new CD3D11MediaSample(this, pFrame, &hr);\n        if (pSample == nullptr || FAILED(hr))\n        {\n            delete pSample;\n            Free();\n            return E_FAIL;\n        }\n\n        m_lFree.Add(pSample);\n    }\n\n    m_lAllocated = m_lCount;\n    m_bChanged = FALSE;\n\n    return S_OK;\n}\n\nvoid CD3D11SurfaceAllocator::Free(void)\n{\n    CAutoLock lock(this);\n    CMediaSample *pSample = nullptr;\n\n    do\n    {\n        pSample = m_lFree.RemoveHead();\n        if (pSample)\n        {\n            delete pSample;\n        }\n    } while (pSample);\n\n    m_lAllocated = 0;\n    av_buffer_unref(&m_pFramesCtx);\n}\n\nSTDMETHODIMP CD3D11SurfaceAllocator::ReleaseBuffer(IMediaSample *pSample)\n{\n    CD3D11MediaSample *pD3D11Sample = dynamic_cast<CD3D11MediaSample *>(pSample);\n    if (pD3D11Sample && pD3D11Sample->m_pAllocatorCookie != m_pFramesCtx)\n    {\n        DbgLog((LOG_TRACE, 10, L\"CD3D11SurfaceAllocator::ReleaseBuffer: Freeing late sample\"));\n        delete pD3D11Sample;\n        return S_OK;\n    }\n    else\n    {\n        return __super::ReleaseBuffer(pSample);\n    }\n}\n\nSTDMETHODIMP_(void) CD3D11SurfaceAllocator::ForceDecommit()\n{\n    {\n        CAutoLock lock(this);\n\n        if (m_bCommitted || !m_bDecommitInProgress)\n            return;\n\n        // actually free all the samples that are already back\n        Free();\n\n        // finish decommit, so that Alloc works again\n        m_bDecommitInProgress = FALSE;\n    }\n\n    if (m_pNotify)\n    {\n        m_pNotify->NotifyRelease();\n    }\n\n    // alloc holds one reference, we need free that here\n    Release();\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/d3d11/D3D11SurfaceAllocator.h",
    "content": "/*\n *      Copyright (C) 2019-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <d3d11.h>\n\n#include \"MediaSampleSideData.h\"\n#include \"ID3DVideoMemoryConfiguration.h\"\n\nclass CDecD3D11;\n\nclass CD3D11MediaSample\n    : public CMediaSampleSideData\n    , public IMediaSampleD3D11\n{\n    friend class CD3D11SurfaceAllocator;\n\n  public:\n    CD3D11MediaSample(CD3D11SurfaceAllocator *pAllocator, AVFrame *pFrame, HRESULT *phr);\n    virtual ~CD3D11MediaSample();\n\n    // IUnknown\n    STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) AddRef();\n    STDMETHODIMP_(ULONG) Release();\n\n    // IMediaSample\n    STDMETHODIMP GetPointer(BYTE **ppBuffer) { return E_NOTIMPL; }\n\n    // IMediaSampleD3D11\n    STDMETHODIMP GetD3D11Texture(int nView, ID3D11Texture2D **ppTexture, UINT *pArraySlice);\n\n    // LAV Interface\n    STDMETHODIMP GetAVFrameBuffer(AVFrame *pFrame);\n\n  private:\n    AVFrame *m_pFrame = nullptr;\n    void *m_pAllocatorCookie = nullptr;\n};\n\nclass CD3D11SurfaceAllocator : public CBaseAllocator\n{\n  public:\n    CD3D11SurfaceAllocator(CDecD3D11 *pDec, HRESULT *phr);\n    virtual ~CD3D11SurfaceAllocator();\n\n    STDMETHODIMP ReleaseBuffer(IMediaSample *pSample);\n\n    STDMETHODIMP_(BOOL) DecommitInProgress()\n    {\n        CAutoLock cal(this);\n        return m_bDecommitInProgress;\n    }\n    STDMETHODIMP_(BOOL) IsCommited()\n    {\n        CAutoLock cal(this);\n        return m_bCommitted;\n    }\n\n    STDMETHODIMP_(void) ForceDecommit();\n\n    // LAV interface\n    STDMETHODIMP_(void) DecoderDestruct()\n    {\n        CAutoLock cal(this);\n        m_pDec = nullptr;\n    }\n\n  protected:\n    virtual void Free(void);\n    virtual HRESULT Alloc(void);\n\n  private:\n    CDecD3D11 *m_pDec = nullptr;\n    AVBufferRef *m_pFramesCtx = nullptr;\n\n    friend class CD3D11MediaSample;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/d3d11va.cpp",
    "content": "/*\n *      Copyright (C) 2017-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"d3d11va.h\"\n#include \"ID3DVideoMemoryConfiguration.h\"\n#include \"dxva2/dxva_common.h\"\n#include \"moreuuids.h\"\n\n#include <d3d11_1.h>\n\n#define FF_DXVA2_WORKAROUND_NVIDIA_HEVC_420P12 4\n\nILAVDecoder *CreateDecoderD3D11()\n{\n    return new CDecD3D11();\n}\n\nHRESULT VerifyD3D11Device(DWORD &dwIndex, DWORD dwDeviceId)\n{\n    HRESULT hr = S_OK;\n    DXGI_ADAPTER_DESC desc;\n\n    HMODULE dxgi = LoadLibrary(L\"dxgi.dll\");\n    if (dxgi == nullptr)\n    {\n        hr = E_FAIL;\n        goto done;\n    }\n\n    PFN_CREATE_DXGI_FACTORY1 mCreateDXGIFactory1 = (PFN_CREATE_DXGI_FACTORY1)GetProcAddress(dxgi, \"CreateDXGIFactory1\");\n    if (mCreateDXGIFactory1 == nullptr)\n    {\n        hr = E_FAIL;\n        goto done;\n    }\n\n    IDXGIAdapter *pDXGIAdapter = nullptr;\n    IDXGIFactory1 *pDXGIFactory = nullptr;\n\n    hr = mCreateDXGIFactory1(IID_IDXGIFactory1, (void **)&pDXGIFactory);\n    if (FAILED(hr))\n        goto done;\n\n    // check the adapter specified by dwIndex\n    hr = pDXGIFactory->EnumAdapters(dwIndex, &pDXGIAdapter);\n    if (FAILED(hr))\n        goto done;\n\n    // if it matches the device id, then all is well and we're done\n    pDXGIAdapter->GetDesc(&desc);\n    if (desc.DeviceId == dwDeviceId)\n        goto done;\n\n    SafeRelease(&pDXGIAdapter);\n\n    // try to find a device that matches this device id\n    UINT i = 0;\n    while (SUCCEEDED(pDXGIFactory->EnumAdapters(i, &pDXGIAdapter)))\n    {\n        pDXGIAdapter->GetDesc(&desc);\n        SafeRelease(&pDXGIAdapter);\n\n        if (desc.DeviceId == dwDeviceId)\n        {\n            dwIndex = i;\n            goto done;\n        }\n        i++;\n    }\n\n    // if none is found, fail\n    hr = E_FAIL;\n\ndone:\n    SafeRelease(&pDXGIAdapter);\n    SafeRelease(&pDXGIFactory);\n    FreeLibrary(dxgi);\n    return hr;\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// D3D11 decoder implementation\n////////////////////////////////////////////////////////////////////////////////\n\nstatic const D3D_FEATURE_LEVEL s_D3D11Levels[] = {\n    D3D_FEATURE_LEVEL_12_1,\n    D3D_FEATURE_LEVEL_12_0,\n    D3D_FEATURE_LEVEL_11_1,\n    D3D_FEATURE_LEVEL_11_0,\n    D3D_FEATURE_LEVEL_10_1,\n    D3D_FEATURE_LEVEL_10_0,\n};\n\nstatic int s_GetD3D11FeatureLevels(int max_fl, const D3D_FEATURE_LEVEL **out)\n{\n    static const int levels_len = countof(s_D3D11Levels);\n\n    int start = 0;\n    for (; start < levels_len; start++)\n    {\n        if (s_D3D11Levels[start] <= max_fl)\n            break;\n    }\n    *out = &s_D3D11Levels[start];\n    return levels_len - start;\n}\n\nstatic DXGI_FORMAT d3d11va_map_sw_to_hw_format(enum AVPixelFormat pix_fmt)\n{\n    switch (pix_fmt)\n    {\n    case AV_PIX_FMT_YUV444P: return DXGI_FORMAT_AYUV;\n    case AV_PIX_FMT_YUV444P10: return DXGI_FORMAT_Y410;\n    case AV_PIX_FMT_YUV444P12:\n    case AV_PIX_FMT_YUV444P14:\n    case AV_PIX_FMT_YUV444P16: return DXGI_FORMAT_Y416;\n\n    case AV_PIX_FMT_YUV422P: return DXGI_FORMAT_YUY2;\n    case AV_PIX_FMT_YUV422P10: return DXGI_FORMAT_Y210;\n    case AV_PIX_FMT_YUV422P12:\n    case AV_PIX_FMT_YUV422P14:\n    case AV_PIX_FMT_YUV422P16: return DXGI_FORMAT_Y216;\n\n    case AV_PIX_FMT_YUV420P12:\n    case AV_PIX_FMT_YUV420P14:\n    case AV_PIX_FMT_YUV420P16:\n    case AV_PIX_FMT_P012:\n    case AV_PIX_FMT_P016: return DXGI_FORMAT_P016;\n    case AV_PIX_FMT_YUV420P10:\n    case AV_PIX_FMT_P010: return DXGI_FORMAT_P010;\n    case AV_PIX_FMT_NV12:\n    default: return DXGI_FORMAT_NV12;\n    }\n}\n\nstatic LAVPixelFormat d3d11va_map_hw_to_lav_format(DXGI_FORMAT dxgiFormat)\n{\n    switch (dxgiFormat)\n    {\n    case DXGI_FORMAT_AYUV: return LAVPixFmt_AYUV;\n    case DXGI_FORMAT_Y410: return LAVPixFmt_Y410;\n    case DXGI_FORMAT_Y416: return LAVPixFmt_Y416;\n\n    case DXGI_FORMAT_YUY2: return LAVPixFmt_YUY2;\n    case DXGI_FORMAT_Y210: return LAVPixFmt_Y216;\n    case DXGI_FORMAT_Y216: return LAVPixFmt_Y216;\n\n    case DXGI_FORMAT_P010: return LAVPixFmt_P016;\n    case DXGI_FORMAT_P016: return LAVPixFmt_P016;\n    case DXGI_FORMAT_NV12: return LAVPixFmt_NV12;\n    default: ASSERT(0); return LAVPixFmt_NV12;\n    }\n}\n\nCDecD3D11::CDecD3D11(void)\n    : CDecAvcodec()\n{\n    ZeroMemory(&m_FrameQueue, sizeof(m_FrameQueue));\n}\n\nCDecD3D11::~CDecD3D11(void)\n{\n    DestroyDecoder(true);\n\n    if (m_pAllocator)\n        m_pAllocator->DecoderDestruct();\n    SafeRelease(&m_pAllocator);\n}\n\nSTDMETHODIMP CDecD3D11::DestroyDecoder(bool bFull)\n{\n    for (int i = 0; i < D3D11_QUEUE_SURFACES; i++)\n    {\n        ReleaseFrame(&m_FrameQueue[i]);\n    }\n\n    if (m_pOutputViews)\n    {\n        for (int i = 0; i < m_nOutputViews; i++)\n        {\n            SafeRelease(&m_pOutputViews[i]);\n        }\n        av_freep(&m_pOutputViews);\n        m_nOutputViews = 0;\n    }\n\n    SafeRelease(&m_pDecoder);\n    SafeRelease(&m_pD3D11StagingTexture);\n    av_buffer_unref(&m_pFramesCtx);\n\n    CDecAvcodec::DestroyDecoder();\n\n    if (bFull)\n    {\n        av_buffer_unref(&m_pDevCtx);\n\n        if (dx.d3d11lib)\n        {\n            FreeLibrary(dx.d3d11lib);\n            dx.d3d11lib = nullptr;\n        }\n\n        if (dx.dxgilib)\n        {\n            FreeLibrary(dx.dxgilib);\n            dx.dxgilib = nullptr;\n        }\n    }\n\n    return S_OK;\n}\n\n// ILAVDecoder\nSTDMETHODIMP CDecD3D11::Init()\n{\n    // D3D11 decoding requires Windows 8 or newer\n    if (!IsWindows8OrNewer())\n        return E_NOINTERFACE;\n\n    dx.d3d11lib = LoadLibrary(L\"d3d11.dll\");\n    if (dx.d3d11lib == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"Cannot open d3d11.dll\"));\n        return E_FAIL;\n    }\n\n    dx.mD3D11CreateDevice = (PFN_D3D11_CREATE_DEVICE)GetProcAddress(dx.d3d11lib, \"D3D11CreateDevice\");\n    if (dx.mD3D11CreateDevice == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"D3D11CreateDevice not available\"));\n        return E_FAIL;\n    }\n\n    dx.dxgilib = LoadLibrary(L\"dxgi.dll\");\n    if (dx.dxgilib == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"Cannot open dxgi.dll\"));\n        return E_FAIL;\n    }\n\n    dx.mCreateDXGIFactory1 = (PFN_CREATE_DXGI_FACTORY1)GetProcAddress(dx.dxgilib, \"CreateDXGIFactory1\");\n    if (dx.mCreateDXGIFactory1 == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"CreateDXGIFactory1 not available\"));\n        return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecD3D11::Check()\n{\n    // attempt creating a hardware device with video support\n    // by passing nullptr to the device parameter, no actual device will be created and only support will be checked\n\n    // do probing agains level 11.1 only, to avoid complex checking logic here\n    const D3D_FEATURE_LEVEL *levels = NULL;\n    int level_count = s_GetD3D11FeatureLevels(D3D_FEATURE_LEVEL_11_1, &levels);\n\n    HRESULT hr =\n        dx.mD3D11CreateDevice(nullptr, D3D_DRIVER_TYPE_HARDWARE, nullptr, D3D11_CREATE_DEVICE_VIDEO_SUPPORT,\n                                       levels, level_count, D3D11_SDK_VERSION, nullptr, nullptr, nullptr);\n    return hr;\n}\n\nSTDMETHODIMP CDecD3D11::InitAllocator(IMemAllocator **ppAlloc)\n{\n    HRESULT hr = S_OK;\n    if (m_bReadBackFallback)\n        return E_NOTIMPL;\n\n    if (m_pAllocator == nullptr)\n    {\n        m_pAllocator = new CD3D11SurfaceAllocator(this, &hr);\n        if (!m_pAllocator)\n        {\n            return E_OUTOFMEMORY;\n        }\n        if (FAILED(hr))\n        {\n            SAFE_DELETE(m_pAllocator);\n            return hr;\n        }\n\n        // Hold a reference on the allocator\n        m_pAllocator->AddRef();\n    }\n\n    // return the proper interface\n    return m_pAllocator->QueryInterface(__uuidof(IMemAllocator), (void **)ppAlloc);\n}\n\nSTDMETHODIMP CDecD3D11::CreateD3D11Device(UINT nDeviceIndex, ID3D11Device **ppDevice, DXGI_ADAPTER_DESC *pDesc)\n{\n    ID3D11Device *pD3D11Device = nullptr;\n\n    // create DXGI factory\n    IDXGIAdapter *pDXGIAdapter = nullptr;\n    IDXGIFactory1 *pDXGIFactory = nullptr;\n    HRESULT hr = dx.mCreateDXGIFactory1(IID_IDXGIFactory1, (void **)&pDXGIFactory);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> DXGIFactory creation failed\"));\n        goto fail;\n    }\n\n    // find the adapter\nenum_adapter:\n    hr = pDXGIFactory->EnumAdapters(nDeviceIndex, &pDXGIAdapter);\n    if (FAILED(hr))\n    {\n        if (nDeviceIndex != 0)\n        {\n            DbgLog(\n                (LOG_ERROR, 10, L\"-> Requested DXGI device %d not available, falling back to default\", nDeviceIndex));\n            nDeviceIndex = 0;\n            hr = pDXGIFactory->EnumAdapters(0, &pDXGIAdapter);\n        }\n\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Failed to enumerate a valid DXGI device\"));\n            goto fail;\n        }\n    }\n\n    // Create a device with video support, and BGRA support for Direct2D interoperability (drawing UI, etc)\n    UINT nCreationFlags = D3D11_CREATE_DEVICE_VIDEO_SUPPORT | D3D11_CREATE_DEVICE_BGRA_SUPPORT;\n    D3D_FEATURE_LEVEL max_level = D3D_FEATURE_LEVEL_12_1;\n    D3D_FEATURE_LEVEL d3dFeatureLevel;\n\n    do\n    {\n        const D3D_FEATURE_LEVEL *levels = NULL;\n        int level_count = s_GetD3D11FeatureLevels(max_level, &levels);\n        hr = dx.mD3D11CreateDevice(pDXGIAdapter, D3D_DRIVER_TYPE_UNKNOWN, nullptr, nCreationFlags, levels, level_count,\n                                   D3D11_SDK_VERSION, &pD3D11Device, &d3dFeatureLevel, nullptr);\n\n        if (SUCCEEDED(hr))\n            break;\n\n        // 12.0+ devices fail on Windows 8.1, try without it\n        if (max_level >= D3D_FEATURE_LEVEL_12_0)\n        {\n            max_level = D3D_FEATURE_LEVEL_11_1;\n            continue;\n        }\n\n        break;\n    } while (true);\n\n    if (FAILED(hr))\n    {\n        if (nDeviceIndex != 0)\n        {\n            DbgLog((\n                LOG_ERROR, 10,\n                L\"-> Failed to create a D3D11 device with video support on requested device %d, re-trying with default\",\n                nDeviceIndex));\n            SafeRelease(&pDXGIAdapter);\n            nDeviceIndex = 0;\n            goto enum_adapter;\n        }\n\n        DbgLog((LOG_ERROR, 10, L\"-> Failed to create a D3D11 device with video support\"));\n        goto fail;\n    }\n\n    DbgLog((LOG_TRACE, 10, L\"-> Created D3D11 device with feature level %d.%d\", d3dFeatureLevel >> 12,\n            (d3dFeatureLevel >> 8) & 0xF));\n\n    // enable multithreaded protection\n    ID3D10Multithread *pMultithread = nullptr;\n    hr = pD3D11Device->QueryInterface(&pMultithread);\n    if (SUCCEEDED(hr))\n    {\n        pMultithread->SetMultithreadProtected(TRUE);\n        SafeRelease(&pMultithread);\n    }\n\n    // store adapter info\n    if (pDesc)\n    {\n        ZeroMemory(pDesc, sizeof(*pDesc));\n        pDXGIAdapter->GetDesc(pDesc);\n    }\n\n    // return device\n    *ppDevice = pD3D11Device;\n\nfail:\n    SafeRelease(&pDXGIFactory);\n    SafeRelease(&pDXGIAdapter);\n    return hr;\n}\n\nSTDMETHODIMP CDecD3D11::PostConnect(IPin *pPin)\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecD3D11::PostConnect()\"));\n    HRESULT hr = S_OK;\n\n    ID3D11DecoderConfiguration *pD3D11DecoderConfiguration = nullptr;\n    hr = pPin->QueryInterface(&pD3D11DecoderConfiguration);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> ID3D11DecoderConfiguration not available, using fallback mode\"));\n    }\n\n    // Release old D3D resources, we're about to re-init\n    m_pCallback->ReleaseAllDXVAResources();\n\n    // free the decoder to force a re-init down the line\n    SafeRelease(&m_pDecoder);\n\n    // and the old device\n    av_buffer_unref(&m_pDevCtx);\n\n    // device id\n    UINT nDevice = m_pSettings->GetHWAccelDeviceIndex(HWAccel_D3D11, nullptr);\n\n    // in automatic mode use the device the renderer gives us\n    if (nDevice == LAVHWACCEL_DEVICE_DEFAULT && pD3D11DecoderConfiguration)\n    {\n        nDevice = pD3D11DecoderConfiguration->GetD3D11AdapterIndex();\n    }\n    else\n    {\n        // if a device is specified manually, fallback to copy-back and use the selected device\n        SafeRelease(&pD3D11DecoderConfiguration);\n\n        // use the configured device\n        if (nDevice == LAVHWACCEL_DEVICE_DEFAULT)\n            nDevice = 0;\n    }\n\n    // create the device\n    ID3D11Device *pD3D11Device = nullptr;\n    hr = CreateD3D11Device(nDevice, &pD3D11Device, &m_AdapterDesc);\n    if (FAILED(hr))\n    {\n        goto fail;\n    }\n\n    // allocate and fill device context\n    m_pDevCtx = av_hwdevice_ctx_alloc(AV_HWDEVICE_TYPE_D3D11VA);\n    AVD3D11VADeviceContext *pDeviceContext = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)m_pDevCtx->data)->hwctx;\n    pDeviceContext->device = pD3D11Device;\n\n    // finalize the context\n    int ret = av_hwdevice_ctx_init(m_pDevCtx);\n    if (ret < 0)\n    {\n        av_buffer_unref(&m_pDevCtx);\n        goto fail;\n    }\n\n    // enable multithreaded protection\n    ID3D10Multithread *pMultithread = nullptr;\n    hr = pDeviceContext->device_context->QueryInterface(&pMultithread);\n    if (SUCCEEDED(hr))\n    {\n        pMultithread->SetMultithreadProtected(TRUE);\n        SafeRelease(&pMultithread);\n    }\n\n    // check if the connection supports native mode\n    if (pD3D11DecoderConfiguration)\n    {\n        CMediaType mt = m_pCallback->GetOutputMediaType();\n        if ((m_SurfaceFormat == DXGI_FORMAT_NV12 && mt.subtype != MEDIASUBTYPE_NV12) ||\n            (m_SurfaceFormat == DXGI_FORMAT_P010 && mt.subtype != MEDIASUBTYPE_P010) ||\n            (m_SurfaceFormat == DXGI_FORMAT_P016 && mt.subtype != MEDIASUBTYPE_P016) ||\n            (m_SurfaceFormat == DXGI_FORMAT_AYUV && mt.subtype != MEDIASUBTYPE_AYUV) ||\n            (m_SurfaceFormat == DXGI_FORMAT_Y410 && mt.subtype != MEDIASUBTYPE_Y410) ||\n            (m_SurfaceFormat == DXGI_FORMAT_Y416 && mt.subtype != MEDIASUBTYPE_Y416) ||\n            (m_SurfaceFormat == DXGI_FORMAT_YUY2 && mt.subtype != MEDIASUBTYPE_YUY2) ||\n            (m_SurfaceFormat == DXGI_FORMAT_Y210 && mt.subtype != MEDIASUBTYPE_Y210) ||\n            (m_SurfaceFormat == DXGI_FORMAT_Y216 && mt.subtype != MEDIASUBTYPE_Y216))\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Connection is not the appropriate pixel format for D3D11 Native\"));\n\n            SafeRelease(&pD3D11DecoderConfiguration);\n        }\n    }\n\n    // verify hardware support\n    {\n        int level = 0;\n        if (m_pAVCtx->codec_id == AV_CODEC_ID_HEVC)\n        {\n            int64_t value = 0;\n            if (av_opt_get_int(m_pAVCtx->priv_data, \"rext_profile\", 0, &value) >= 0)\n                level = (int)value;\n        }\n\n        GUID guidConversion = GUID_NULL;\n        hr = FindVideoServiceConversion(m_pAVCtx->codec_id, m_pAVCtx->profile, level, m_SurfaceFormat, &guidConversion);\n        if (FAILED(hr))\n        {\n            goto fail;\n        }\n\n        // get decoder configuration\n        D3D11_VIDEO_DECODER_DESC desc = {0};\n        desc.Guid = guidConversion;\n        desc.OutputFormat = m_SurfaceFormat;\n        desc.SampleWidth = m_pAVCtx->coded_width;\n        desc.SampleHeight = m_pAVCtx->coded_height;\n\n        D3D11_VIDEO_DECODER_CONFIG decoder_config = {0};\n        hr = FindDecoderConfiguration(&desc, &decoder_config);\n        if (FAILED(hr))\n        {\n            goto fail;\n        }\n\n        // test creating a texture\n        D3D11_TEXTURE2D_DESC texDesc = {0};\n        texDesc.Width = m_pAVCtx->coded_width;\n        texDesc.Height = m_pAVCtx->coded_height;\n        texDesc.MipLevels = 1;\n        texDesc.ArraySize = GetBufferCount();\n        texDesc.Format = m_SurfaceFormat;\n        texDesc.SampleDesc.Count = 1;\n        texDesc.Usage = D3D11_USAGE_DEFAULT;\n        texDesc.BindFlags = D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE;\n        texDesc.MiscFlags = D3D11_RESOURCE_MISC_SHARED;\n\n        hr = pD3D11Device->CreateTexture2D(&texDesc, nullptr, nullptr);\n        if (FAILED(hr))\n        {\n            goto fail;\n        }\n    }\n\n    // Notice the connected pin that we're sending D3D11 textures\n    if (pD3D11DecoderConfiguration)\n    {\n        hr = pD3D11DecoderConfiguration->ActivateD3D11Decoding(pDeviceContext->device, pDeviceContext->device_context,\n                                                               pDeviceContext->lock_ctx, 0);\n        SafeRelease(&pD3D11DecoderConfiguration);\n\n        m_bReadBackFallback = FAILED(hr);\n    }\n    else\n    {\n        m_bReadBackFallback = true;\n    }\n\n    return S_OK;\n\nfail:\n    SafeRelease(&pD3D11DecoderConfiguration);\n    return E_FAIL;\n}\n\nSTDMETHODIMP CDecD3D11::BreakConnect()\n{\n    if (m_bReadBackFallback)\n        return S_FALSE;\n\n    // release any resources held by the core\n    m_pCallback->ReleaseAllDXVAResources();\n\n    // flush all buffers out of the decoder to ensure the allocator can be properly de-allocated\n    if (m_pAVCtx && avcodec_is_open(m_pAVCtx))\n        avcodec_flush_buffers(m_pAVCtx);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecD3D11::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)\n{\n    HRESULT hr = S_OK;\n    DbgLog((LOG_TRACE, 10, L\"CDecD3D11::InitDecoder(): Initializing D3D11 decoder\"));\n\n    // Destroy old decoder\n    DestroyDecoder(false);\n\n    // reset stream compatibility\n    m_bFailHWDecode = false;\n\n    m_DisplayDelay = D3D11_QUEUE_SURFACES;\n\n    // Reduce display delay for DVD decoding for lower decode latency\n    if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD)\n        m_DisplayDelay /= 2;\n\n    // Initialize ffmpeg\n    hr = CDecAvcodec::InitDecoder(codec, pmt, pSideData);\n    if (FAILED(hr))\n        return hr;\n\n    if (check_dxva_codec_profile(m_pAVCtx, AV_PIX_FMT_D3D11))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Incompatible profile detected, falling back to software decoding\"));\n        return E_FAIL;\n    }\n\n    // initialize surface format to ensure the default media type is set properly\n    m_SurfaceFormat = d3d11va_map_sw_to_hw_format(m_pAVCtx->sw_pix_fmt);\n    m_dwSurfaceWidth = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_width);\n    m_dwSurfaceHeight = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_height);\n\n    return S_OK;\n}\n\nHRESULT CDecD3D11::AdditionaDecoderInit()\n{\n    AVD3D11VAContext *ctx = av_d3d11va_alloc_context();\n\n    if (m_pDecoder)\n    {\n        FillHWContext(ctx);\n    }\n\n    m_pAVCtx->thread_count = 1;\n    m_pAVCtx->thread_type = 0;\n    m_pAVCtx->hwaccel_context = ctx;\n    m_pAVCtx->get_format = get_d3d11_format;\n    m_pAVCtx->get_buffer2 = get_d3d11_buffer;\n    m_pAVCtx->opaque = this;\n\n    m_pAVCtx->slice_flags |= SLICE_FLAG_ALLOW_FIELD;\n\n    // disable error concealment in hwaccel mode, it doesn't work either way\n    m_pAVCtx->error_concealment = 0;\n    av_opt_set_int(m_pAVCtx, \"enable_er\", 0, AV_OPT_SEARCH_CHILDREN);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecD3D11::FillHWContext(AVD3D11VAContext *ctx)\n{\n    AVD3D11VADeviceContext *pDeviceContext = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)m_pDevCtx->data)->hwctx;\n\n    ctx->decoder = m_pDecoder;\n    ctx->video_context = pDeviceContext->video_context;\n    ctx->cfg = &m_DecoderConfig;\n    ctx->surface_count = m_nOutputViews;\n    ctx->surface = m_pOutputViews;\n\n    ctx->context_mutex = pDeviceContext->lock_ctx;\n\n    ctx->workaround = 0;\n\n    if (m_AdapterDesc.VendorId == VEND_ID_NVIDIA)\n        ctx->workaround = FF_DXVA2_WORKAROUND_NVIDIA_HEVC_420P12;\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(long) CDecD3D11::GetBufferCount(long *pMaxBuffers)\n{\n    long buffers = 0;\n\n    // Native decoding should use 16 buffers to enable seamless codec changes\n    if (!m_bReadBackFallback)\n        buffers = 16;\n    else\n    {\n        // Buffers based on max ref frames\n        if (m_nCodecId == AV_CODEC_ID_H264 || m_nCodecId == AV_CODEC_ID_HEVC)\n            buffers = 16;\n        else if (m_nCodecId == AV_CODEC_ID_VP9 || m_nCodecId == AV_CODEC_ID_AV1)\n            buffers = 8;\n        else\n            buffers = 2;\n    }\n\n    // 4 extra buffers for handling and safety\n    buffers += 4;\n\n    if (m_bReadBackFallback)\n    {\n        buffers += m_DisplayDelay;\n    }\n\n    if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD)\n    {\n        buffers += 4;\n    }\n\n    if (pMaxBuffers)\n    {\n        // cap at 127, because it needs to fit into the 7-bit DXVA structs\n        *pMaxBuffers = 127;\n\n        // VC-1 and VP9 decoding has stricter requirements (decoding flickers otherwise)\n        if (m_nCodecId == AV_CODEC_ID_VC1 || m_nCodecId == AV_CODEC_ID_VP9 || m_nCodecId == AV_CODEC_ID_AV1)\n            *pMaxBuffers = 32;\n    }\n\n    return buffers;\n}\n\nSTDMETHODIMP CDecD3D11::FlushDisplayQueue(BOOL bDeliver)\n{\n    for (int i = 0; i < m_DisplayDelay; ++i)\n    {\n        if (m_FrameQueue[m_FrameQueuePosition])\n        {\n            if (bDeliver)\n            {\n                DeliverD3D11Frame(m_FrameQueue[m_FrameQueuePosition]);\n                m_FrameQueue[m_FrameQueuePosition] = nullptr;\n            }\n            else\n            {\n                ReleaseFrame(&m_FrameQueue[m_FrameQueuePosition]);\n            }\n        }\n        m_FrameQueuePosition = (m_FrameQueuePosition + 1) % m_DisplayDelay;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecD3D11::Flush()\n{\n    CDecAvcodec::Flush();\n\n    // Flush display queue\n    FlushDisplayQueue(FALSE);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecD3D11::EndOfStream()\n{\n    CDecAvcodec::EndOfStream();\n\n    // Flush display queue\n    FlushDisplayQueue(TRUE);\n\n    return S_OK;\n}\n\nHRESULT CDecD3D11::PostDecode()\n{\n    if (m_bFailHWDecode)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::PostDecode(): HW Decoder failed, falling back to software decoding\"));\n        return E_FAIL;\n    }\n    return S_OK;\n}\n\nenum AVPixelFormat CDecD3D11::get_d3d11_format(struct AVCodecContext *s, const enum AVPixelFormat *pix_fmts)\n{\n    CDecD3D11 *pDec = (CDecD3D11 *)s->opaque;\n    const enum AVPixelFormat *p;\n    for (p = pix_fmts; *p != -1; p++)\n    {\n        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p);\n\n        if (!desc || !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))\n            break;\n\n        if (*p == AV_PIX_FMT_D3D11)\n        {\n            HRESULT hr = pDec->ReInitD3D11Decoder(s);\n            if (FAILED(hr))\n            {\n                pDec->m_bFailHWDecode = TRUE;\n                continue;\n            }\n            else\n            {\n                break;\n            }\n        }\n    }\n    return *p;\n}\n\nint CDecD3D11::get_d3d11_buffer(struct AVCodecContext *c, AVFrame *frame, int flags)\n{\n    CDecD3D11 *pDec = (CDecD3D11 *)c->opaque;\n    HRESULT hr = S_OK;\n\n    if (frame->format != AV_PIX_FMT_D3D11)\n    {\n        DbgLog((LOG_ERROR, 10, L\"D3D11 buffer request, but not D3D11 pixfmt\"));\n        pDec->m_bFailHWDecode = TRUE;\n        return -1;\n    }\n\n    hr = pDec->ReInitD3D11Decoder(c);\n    if (FAILED(hr))\n    {\n        pDec->m_bFailHWDecode = TRUE;\n        return -1;\n    }\n\n    if (pDec->m_bReadBackFallback && pDec->m_pFramesCtx)\n    {\n        int ret = av_hwframe_get_buffer(pDec->m_pFramesCtx, frame, 0);\n        frame->width = c->coded_width;\n        frame->height = c->coded_height;\n        return ret;\n    }\n    else if (pDec->m_bReadBackFallback == false && pDec->m_pAllocator)\n    {\n        IMediaSample *pSample = nullptr;\n        hr = pDec->m_pAllocator->GetBuffer(&pSample, nullptr, nullptr, 0);\n        if (SUCCEEDED(hr))\n        {\n            CD3D11MediaSample *pD3D11Sample = dynamic_cast<CD3D11MediaSample *>(pSample);\n\n            // fill the frame from the sample, including a reference to the sample\n            if (FAILED(pD3D11Sample->GetAVFrameBuffer(frame)))\n            {\n                pD3D11Sample->Release();\n                return -1;\n            }\n\n            frame->width = c->coded_width;\n            frame->height = c->coded_height;\n\n            // the frame holds the sample now, can release the direct interface\n            pD3D11Sample->Release();\n            return 0;\n        }\n    }\n\n    return -1;\n}\n\nSTDMETHODIMP CDecD3D11::ReInitD3D11Decoder(AVCodecContext *c)\n{\n    HRESULT hr = S_OK;\n\n    // Don't allow decoder creation during first init\n    if (m_bInInit)\n        return S_FALSE;\n\n    // sanity check that we have a device\n    if (m_pDevCtx == nullptr)\n        return E_FAIL;\n\n    // we need an allocator at this point\n    if (m_bReadBackFallback == false && m_pAllocator == nullptr)\n        return E_FAIL;\n\n    DXGI_FORMAT surfaceFormatToTest = d3d11va_map_sw_to_hw_format(c->sw_pix_fmt);\n    if (surfaceFormatToTest == DXGI_FORMAT_P016 && m_bP016ToP010Fallback)\n        surfaceFormatToTest = DXGI_FORMAT_P010;\n\n    if (m_pDecoder == nullptr || m_dwSurfaceWidth != dxva_align_dimensions(c->codec_id, c->coded_width) ||\n        m_dwSurfaceHeight != dxva_align_dimensions(c->codec_id, c->coded_height) ||\n        m_SurfaceFormat != surfaceFormatToTest)\n    {\n        AVD3D11VADeviceContext *pDeviceContext =\n            (AVD3D11VADeviceContext *)((AVHWDeviceContext *)m_pDevCtx->data)->hwctx;\n        DbgLog((LOG_TRACE, 10, L\"No D3D11 Decoder or image dimensions changed -> Re-Allocating resources\"));\n\n        // if we're not in readback mode, we need to flush all the frames\n        if (m_bReadBackFallback == false)\n            if (m_pDecoder)\n                avcodec_flush_buffers(c);\n            else\n                FlushDisplayQueue(TRUE);\n\n        pDeviceContext->lock(pDeviceContext->lock_ctx);\n        hr = CreateD3D11Decoder();\n        pDeviceContext->unlock(pDeviceContext->lock_ctx);\n        if (FAILED(hr))\n            return hr;\n\n        // Update the frames context in the allocator\n        if (m_bReadBackFallback == false)\n        {\n            // decommit the allocator\n            m_pAllocator->Decommit();\n\n            // verify we were able to decommit all its resources\n            if (m_pAllocator->DecommitInProgress())\n            {\n                DbgLog((LOG_TRACE, 10, L\"WARNING! D3D11 Allocator is still busy, trying to flush downstream\"));\n                m_pCallback->ReleaseAllDXVAResources();\n                m_pCallback->GetOutputPin()->GetConnected()->BeginFlush();\n                m_pCallback->GetOutputPin()->GetConnected()->EndFlush();\n                if (m_pAllocator->DecommitInProgress())\n                {\n                    DbgLog(\n                        (LOG_TRACE, 10, L\"WARNING! Flush had no effect, decommit of the allocator still not complete\"));\n                    m_pAllocator->ForceDecommit();\n                }\n                else\n                {\n                    DbgLog((LOG_TRACE, 10, L\"Flush was successful, decommit completed!\"));\n                }\n            }\n\n            // re-commit it to update its frame reference\n            m_pAllocator->Commit();\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecD3D11::FindVideoServiceConversion(AVCodecID codec, int profile, int level, DXGI_FORMAT &surface_format,\n                                                   GUID *input)\n{\n    AVD3D11VADeviceContext *pDeviceContext = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)m_pDevCtx->data)->hwctx;\n    HRESULT hr = S_OK;\n\n    UINT nProfiles = pDeviceContext->video_device->GetVideoDecoderProfileCount();\n    GUID *guid_list = (GUID *)av_malloc_array(nProfiles, sizeof(*guid_list));\n\n    m_bP016ToP010Fallback = false;\n\n    DbgLog((LOG_TRACE, 10, L\"-> Enumerating supported D3D11 modes (count: %d)\", nProfiles));\n    for (UINT i = 0; i < nProfiles; i++)\n    {\n        hr = pDeviceContext->video_device->GetVideoDecoderProfile(i, &guid_list[i]);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"Error retrieving decoder profile\"));\n            av_free(guid_list);\n            return hr;\n        }\n\n#ifdef DEBUG\n        const dxva_mode_t *mode = get_dxva_mode_from_guid(&guid_list[i]);\n        if (mode)\n        {\n            DbgLog((LOG_TRACE, 10, L\"  -> %S\", mode->name));\n        }\n        else\n        {\n            DbgLog((LOG_TRACE, 10, L\"  -> Unknown GUID (%s)\", WStringFromGUID(guid_list[i]).c_str()));\n        }\n#endif\n    }\n\n    /* Iterate over our priority list */\n    for (unsigned i = 0; dxva_modes[i].name; i++)\n    {\n        const dxva_mode_t *mode = &dxva_modes[i];\n        if (!check_dxva_mode_compatibility(mode, codec, profile, level, (surface_format == DXGI_FORMAT_NV12)))\n            continue;\n\n        BOOL supported = FALSE;\n        for (UINT g = 0; !supported && g < nProfiles; g++)\n        {\n            supported = IsEqualGUID(*mode->guid, guid_list[g]);\n        }\n        if (!supported)\n            continue;\n\n        DbgLog((LOG_TRACE, 10, L\"-> Trying to use '%S'\", mode->name));\n        hr = pDeviceContext->video_device->CheckVideoDecoderFormat(mode->guid, surface_format, &supported);\n        // some high bitdepth decoders only accept P010, despite the memory layout otherwise being identical\n        if (SUCCEEDED(hr) && !supported && surface_format == DXGI_FORMAT_P016)\n        {\n            hr = pDeviceContext->video_device->CheckVideoDecoderFormat(mode->guid, DXGI_FORMAT_P010, &supported);\n\n            if (SUCCEEDED(hr) && supported)\n            {\n                surface_format = DXGI_FORMAT_P010;\n                m_bP016ToP010Fallback = true;\n            }\n        }\n        if (SUCCEEDED(hr) && supported)\n        {\n            *input = *mode->guid;\n\n            av_free(guid_list);\n            return S_OK;\n        }\n    }\n\n    av_free(guid_list);\n    return E_FAIL;\n}\n\nSTDMETHODIMP CDecD3D11::FindDecoderConfiguration(const D3D11_VIDEO_DECODER_DESC *desc,\n                                                 D3D11_VIDEO_DECODER_CONFIG *pConfig)\n{\n    AVD3D11VADeviceContext *pDeviceContext = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)m_pDevCtx->data)->hwctx;\n    HRESULT hr = S_OK;\n\n    UINT nConfig = 0;\n    hr = pDeviceContext->video_device->GetVideoDecoderConfigCount(desc, &nConfig);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"Unable to retrieve decoder configuration count\"));\n        return E_FAIL;\n    }\n\n    int best_score = -1;\n    D3D11_VIDEO_DECODER_CONFIG best_config;\n    for (UINT i = 0; i < nConfig; i++)\n    {\n        D3D11_VIDEO_DECODER_CONFIG config = {0};\n        hr = pDeviceContext->video_device->GetVideoDecoderConfig(desc, i, &config);\n        if (FAILED(hr))\n            continue;\n\n        DbgLog((LOG_ERROR, 10, \"-> Configuration Record %d: ConfigBitstreamRaw = %d\", i, config.ConfigBitstreamRaw));\n\n        int score;\n        if (config.ConfigBitstreamRaw == 1)\n            score = 1;\n        else if (m_pAVCtx->codec_id == AV_CODEC_ID_H264 && config.ConfigBitstreamRaw == 2)\n            score = 2;\n        else if (m_pAVCtx->codec_id == AV_CODEC_ID_VP9) // hack for broken AMD drivers\n            score = 0;\n        else\n            continue;\n        if (IsEqualGUID(config.guidConfigBitstreamEncryption, DXVA2_NoEncrypt))\n            score += 16;\n        if (score > best_score)\n        {\n            best_score = score;\n            best_config = config;\n        }\n    }\n\n    if (best_score < 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> No matching configuration available\"));\n        return E_FAIL;\n    }\n\n    *pConfig = best_config;\n    return S_OK;\n}\n\nSTDMETHODIMP CDecD3D11::CreateD3D11Decoder()\n{\n    HRESULT hr = S_OK;\n    AVD3D11VADeviceContext *pDeviceContext = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)m_pDevCtx->data)->hwctx;\n\n    // release the old decoder, it needs to be re-created\n    SafeRelease(&m_pDecoder);\n\n    // find a decoder configuration\n    GUID profileGUID = GUID_NULL;\n    DXGI_FORMAT surface_format = d3d11va_map_sw_to_hw_format(m_pAVCtx->sw_pix_fmt);\n\n    // codec sub-level\n    int level = 0;\n    if (m_pAVCtx->codec_id == AV_CODEC_ID_HEVC)\n    {\n        int64_t value = 0;\n        if (av_opt_get_int(m_pAVCtx->priv_data, \"rext_profile\", 0, &value) >= 0)\n            level = (int)value;\n    }\n\n    hr = FindVideoServiceConversion(m_pAVCtx->codec_id, m_pAVCtx->profile, level, surface_format, &profileGUID);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> No video service profile found\"));\n        return hr;\n    }\n\n    // get decoder configuration\n    D3D11_VIDEO_DECODER_DESC desc = {0};\n    desc.Guid = profileGUID;\n    desc.OutputFormat = surface_format;\n    desc.SampleWidth = m_pAVCtx->coded_width;\n    desc.SampleHeight = m_pAVCtx->coded_height;\n\n    D3D11_VIDEO_DECODER_CONFIG decoder_config = {0};\n    hr = FindDecoderConfiguration(&desc, &decoder_config);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> No valid video decoder configuration found\"));\n        return hr;\n    }\n\n    m_DecoderConfig = decoder_config;\n\n    // update surface properties\n    m_dwSurfaceWidth = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_width);\n    m_dwSurfaceHeight = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_height);\n    m_SurfaceFormat = surface_format;\n\n    if (m_bReadBackFallback == false && m_pAllocator)\n    {\n        ALLOCATOR_PROPERTIES properties;\n        hr = m_pAllocator->GetProperties(&properties);\n        if (FAILED(hr))\n            return hr;\n\n        m_dwSurfaceCount = properties.cBuffers;\n    }\n    else\n    {\n        m_dwSurfaceCount = GetBufferCount();\n    }\n\n    // allocate a new frames context for the dimensions and format\n    hr = AllocateFramesContext(m_dwSurfaceWidth, m_dwSurfaceHeight, m_SurfaceFormat, m_dwSurfaceCount,\n                               &m_pFramesCtx);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Error allocating frames context\"));\n        return hr;\n    }\n\n    // release any old output views and allocate memory for the new ones\n    if (m_pOutputViews)\n    {\n        for (int i = 0; i < m_nOutputViews; i++)\n        {\n            SafeRelease(&m_pOutputViews[i]);\n        }\n        av_freep(&m_pOutputViews);\n    }\n\n    m_pOutputViews = (ID3D11VideoDecoderOutputView **)av_calloc(m_dwSurfaceCount, sizeof(*m_pOutputViews));\n    m_nOutputViews = m_dwSurfaceCount;\n\n    // allocate output views for the frames\n    AVD3D11VAFramesContext *pFramesContext = (AVD3D11VAFramesContext *)((AVHWFramesContext *)m_pFramesCtx->data)->hwctx;\n    for (int i = 0; i < m_nOutputViews; i++)\n    {\n        D3D11_VIDEO_DECODER_OUTPUT_VIEW_DESC viewDesc = {0};\n        viewDesc.DecodeProfile = profileGUID;\n        viewDesc.ViewDimension = D3D11_VDOV_DIMENSION_TEXTURE2D;\n        viewDesc.Texture2D.ArraySlice = i;\n\n        hr = pDeviceContext->video_device->CreateVideoDecoderOutputView(pFramesContext->texture, &viewDesc,\n                                                                        &m_pOutputViews[i]);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Failed to create video decoder output views\"));\n            return E_FAIL;\n        }\n    }\n\n    // flush textures to black\n    if (surface_format == DXGI_FORMAT_NV12 || surface_format == DXGI_FORMAT_P010 || surface_format == DXGI_FORMAT_P016)\n    {\n        D3D11_FEATURE_DATA_D3D11_OPTIONS d3d11Options{};\n        pDeviceContext->device->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &d3d11Options,\n                                                    sizeof(D3D11_FEATURE_DATA_D3D11_OPTIONS));\n\n        // XXX: The ClearView path does not function properly on Intel GPUs for P010\n        // Investigation has shown that contrary to the documentation, Intel transforms the color information,\n        // instead of treating the values like integral floats, as required.\n        ID3D11DeviceContext1 *pDeviceContext1 = nullptr;\n        if (m_AdapterDesc.VendorId != VEND_ID_INTEL && d3d11Options.ClearView &&\n            SUCCEEDED(hr = pDeviceContext->device_context->QueryInterface(&pDeviceContext1)))\n        {\n            for (int i = 0; i < m_nOutputViews; i++)\n            {\n                // clear the Luma channel to zero and Chroma channel to half\n                // for both P010/P016, the full 16-bit range value needs to be used due to the nature of their memory layout\n                float fChromaBlack = (surface_format == DXGI_FORMAT_NV12) ? 128.0f : 32768.0f;\n                const FLOAT ClearYUV[4] = {0.0f, fChromaBlack, fChromaBlack, 0.0f};\n                pDeviceContext1->ClearView(m_pOutputViews[i], ClearYUV, nullptr, 0);\n            }\n            SafeRelease(&pDeviceContext1);\n        }\n        else\n        {\n            D3D11_TEXTURE2D_DESC FlushTexDesc{};\n            FlushTexDesc.Width = m_dwSurfaceWidth;\n            FlushTexDesc.Height = m_dwSurfaceHeight;\n            FlushTexDesc.MipLevels = 1;\n            FlushTexDesc.ArraySize = 1;\n            FlushTexDesc.Format = surface_format;\n            FlushTexDesc.SampleDesc.Count = 1;\n            FlushTexDesc.Usage = D3D11_USAGE_DEFAULT;\n            FlushTexDesc.BindFlags = D3D11_BIND_RENDER_TARGET;\n            FlushTexDesc.CPUAccessFlags = 0;\n            FlushTexDesc.MiscFlags = 0;\n\n            ID3D11Texture2D *pFlushTexture = NULL;\n            if (SUCCEEDED(pDeviceContext->device->CreateTexture2D(&FlushTexDesc, NULL, &pFlushTexture)))\n            {\n                D3D11_RENDER_TARGET_VIEW_DESC rtvDesc{};\n                rtvDesc.ViewDimension = D3D11_RTV_DIMENSION_TEXTURE2D;\n                rtvDesc.Format = surface_format;\n\n                ID3D11RenderTargetView *pRTV = nullptr;\n\n                // clear the Luma channel to zero\n                rtvDesc.Format = (surface_format == DXGI_FORMAT_NV12) ? DXGI_FORMAT_R8_UNORM : DXGI_FORMAT_R16_UNORM;\n                if (SUCCEEDED(hr = pDeviceContext->device->CreateRenderTargetView(pFlushTexture, &rtvDesc, &pRTV)))\n                {\n                    const FLOAT ClearYUV[4] = { 0.0f };\n                    pDeviceContext->device_context->ClearRenderTargetView(pRTV, ClearYUV);\n                    SafeRelease(&pRTV);\n                }\n\n                // clear the Chroma channel to half\n                rtvDesc.Format = (surface_format == DXGI_FORMAT_NV12) ? DXGI_FORMAT_R8G8_UNORM : DXGI_FORMAT_R16G16_UNORM;\n                if (SUCCEEDED(hr = pDeviceContext->device->CreateRenderTargetView(pFlushTexture, &rtvDesc, &pRTV)))\n                {\n                    const FLOAT ClearYUV[4] = { 0.5f, 0.5f, 0.0f, 0.0f };\n                    pDeviceContext->device_context->ClearRenderTargetView(pRTV, ClearYUV);\n                    SafeRelease(&pRTV);\n                }\n\n                // update all surfaces with the flush color\n                for (unsigned i = 0; i < m_dwSurfaceCount; i++)\n                {\n                    pDeviceContext->device_context->CopySubresourceRegion(pFramesContext->texture, i, 0, 0, 0,\n                                                                          pFlushTexture, 0, NULL);\n                }\n                SafeRelease(&pFlushTexture);\n            }\n        }\n\n        // flush all pending work\n        pDeviceContext->device_context->Flush();\n    }\n\n    // create the decoder\n    hr = pDeviceContext->video_device->CreateVideoDecoder(&desc, &decoder_config, &m_pDecoder);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Failed to create video decoder object\"));\n        return E_FAIL;\n    }\n\n    FillHWContext((AVD3D11VAContext *)m_pAVCtx->hwaccel_context);\n\n    return S_OK;\n}\n\nstatic AVPixelFormat s_GetAVD3D11PixelFormat(DXGI_FORMAT format)\n{\n    switch (format)\n    {\n    case DXGI_FORMAT_NV12: return AV_PIX_FMT_NV12;\n    case DXGI_FORMAT_P010: return AV_PIX_FMT_P010;\n    case DXGI_FORMAT_P016: return AV_PIX_FMT_P016;\n\n    case DXGI_FORMAT_YUY2: return AV_PIX_FMT_YUYV422;\n    case DXGI_FORMAT_Y210: return AV_PIX_FMT_Y210;\n    case DXGI_FORMAT_Y216: return AV_PIX_FMT_Y216;\n\n    case DXGI_FORMAT_AYUV: return AV_PIX_FMT_VUYX;\n    case DXGI_FORMAT_Y410: return AV_PIX_FMT_XV30;\n    case DXGI_FORMAT_Y416: return AV_PIX_FMT_XV48;\n    }\n\n    ASSERT(0);\n    return AV_PIX_FMT_NV12;\n}\n\nSTDMETHODIMP CDecD3D11::AllocateFramesContext(int width, int height, DXGI_FORMAT format, int nSurfaces,\n                                              AVBufferRef **ppFramesCtx)\n{\n    ASSERT(m_pAVCtx);\n    ASSERT(m_pDevCtx);\n    ASSERT(ppFramesCtx);\n\n    // unref any old buffer\n    av_buffer_unref(ppFramesCtx);\n    SafeRelease(&m_pD3D11StagingTexture);\n\n    // allocate a new frames context for the device context\n    *ppFramesCtx = av_hwframe_ctx_alloc(m_pDevCtx);\n    if (*ppFramesCtx == nullptr)\n        return E_OUTOFMEMORY;\n\n    AVHWFramesContext *pFrames = (AVHWFramesContext *)(*ppFramesCtx)->data;\n    pFrames->format = AV_PIX_FMT_D3D11;\n    pFrames->sw_format = s_GetAVD3D11PixelFormat(format);\n    pFrames->width = width;\n    pFrames->height = height;\n    pFrames->initial_pool_size = nSurfaces;\n\n    AVD3D11VAFramesContext *pFramesHWContext = (AVD3D11VAFramesContext *)pFrames->hwctx;\n    pFramesHWContext->BindFlags |= D3D11_BIND_DECODER | D3D11_BIND_SHADER_RESOURCE;\n    pFramesHWContext->MiscFlags |= D3D11_RESOURCE_MISC_SHARED;\n\n    int ret = av_hwframe_ctx_init(*ppFramesCtx);\n    if (ret < 0)\n    {\n        av_buffer_unref(ppFramesCtx);\n        return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nHRESULT CDecD3D11::HandleDXVA2Frame(LAVFrame *pFrame)\n{\n    if (pFrame->flags & LAV_FRAME_FLAG_FLUSH)\n    {\n        if (m_bReadBackFallback)\n        {\n            FlushDisplayQueue(TRUE);\n        }\n        Deliver(pFrame);\n        return S_OK;\n    }\n\n    ASSERT(pFrame->format == LAVPixFmt_D3D11);\n\n    if (m_bReadBackFallback == false || m_DisplayDelay == 0)\n    {\n        DeliverD3D11Frame(pFrame);\n    }\n    else\n    {\n        LAVFrame *pQueuedFrame = m_FrameQueue[m_FrameQueuePosition];\n        m_FrameQueue[m_FrameQueuePosition] = pFrame;\n\n        m_FrameQueuePosition = (m_FrameQueuePosition + 1) % m_DisplayDelay;\n\n        if (pQueuedFrame)\n        {\n            DeliverD3D11Frame(pQueuedFrame);\n        }\n    }\n\n    return S_OK;\n}\n\nHRESULT CDecD3D11::DeliverD3D11Frame(LAVFrame *pFrame)\n{\n    if (m_bReadBackFallback)\n    {\n        if (m_bDirect)\n            DeliverD3D11ReadbackDirect(pFrame);\n        else\n            DeliverD3D11Readback(pFrame);\n    }\n    else\n    {\n        AVFrame *pAVFrame = (AVFrame *)pFrame->priv_data;\n        pFrame->data[0] = pAVFrame->data[3];\n        pFrame->data[1] = pFrame->data[2] = pFrame->data[3] = nullptr;\n\n        GetPixelFormat(&pFrame->format, &pFrame->bpp, &pFrame->sw_format);\n\n        Deliver(pFrame);\n    }\n\n    return S_OK;\n}\n\nHRESULT CDecD3D11::DeliverD3D11Readback(LAVFrame *pFrame)\n{\n    AVFrame *src = (AVFrame *)pFrame->priv_data;\n    AVFrame *dst = av_frame_alloc();\n\n    int ret = av_hwframe_transfer_data(dst, src, 0);\n    if (ret < 0)\n    {\n        ReleaseFrame(&pFrame);\n        av_frame_free(&dst);\n        return E_FAIL;\n    }\n\n    // free the source frame\n    av_frame_free(&src);\n\n    // and store the dst frame in LAVFrame\n    pFrame->priv_data = dst;\n    GetPixelFormat(&pFrame->format, &pFrame->bpp, &pFrame->sw_format);\n\n    ASSERT(getFFPixelFormatFromLAV(pFrame->format, pFrame->bpp) == dst->format);\n\n    for (int i = 0; i < 4; i++)\n    {\n        pFrame->data[i] = dst->data[i];\n        pFrame->stride[i] = dst->linesize[i];\n    }\n\n    return Deliver(pFrame);\n}\n\nstruct D3D11DirectPrivate\n{\n    AVBufferRef *pDeviceContex;\n    ID3D11Texture2D *pStagingTexture;\n};\n\nstatic bool d3d11_direct_lock(LAVFrame *pFrame, LAVDirectBuffer *pBuffer)\n{\n    D3D11DirectPrivate *c = (D3D11DirectPrivate *)pFrame->priv_data;\n    AVD3D11VADeviceContext *pDeviceContext =\n        (AVD3D11VADeviceContext *)((AVHWDeviceContext *)c->pDeviceContex->data)->hwctx;\n    D3D11_TEXTURE2D_DESC desc;\n    D3D11_MAPPED_SUBRESOURCE map;\n\n    ASSERT(pFrame && pBuffer);\n\n    // lock the device context\n    pDeviceContext->lock(pDeviceContext->lock_ctx);\n\n    c->pStagingTexture->GetDesc(&desc);\n\n    // map\n    HRESULT hr = pDeviceContext->device_context->Map(c->pStagingTexture, 0, D3D11_MAP_READ, 0, &map);\n    if (FAILED(hr))\n    {\n        pDeviceContext->unlock(pDeviceContext->lock_ctx);\n        return false;\n    }\n\n    pBuffer->Width = desc.Width;\n    pBuffer->Height = desc.Height;\n\n    pBuffer->data[0] = (BYTE *)map.pData;\n    pBuffer->stride[0] = map.RowPitch;\n\n    // semi-packed formats have a second plane\n    if (desc.Format == DXGI_FORMAT_NV12 || desc.Format == DXGI_FORMAT_P010 || desc.Format == DXGI_FORMAT_P016)\n    {\n        pBuffer->data[1] = pBuffer->data[0] + desc.Height * map.RowPitch;\n        pBuffer->stride[1] = map.RowPitch;\n    }\n\n    return true;\n}\n\nstatic void d3d11_direct_unlock(LAVFrame *pFrame)\n{\n    D3D11DirectPrivate *c = (D3D11DirectPrivate *)pFrame->priv_data;\n    AVD3D11VADeviceContext *pDeviceContext =\n        (AVD3D11VADeviceContext *)((AVHWDeviceContext *)c->pDeviceContex->data)->hwctx;\n\n    pDeviceContext->device_context->Unmap(c->pStagingTexture, 0);\n    pDeviceContext->unlock(pDeviceContext->lock_ctx);\n}\n\nstatic void d3d11_direct_free(LAVFrame *pFrame)\n{\n    D3D11DirectPrivate *c = (D3D11DirectPrivate *)pFrame->priv_data;\n    av_buffer_unref(&c->pDeviceContex);\n    c->pStagingTexture->Release();\n    delete c;\n}\n\nHRESULT CDecD3D11::DeliverD3D11ReadbackDirect(LAVFrame *pFrame)\n{\n    AVD3D11VADeviceContext *pDeviceContext = (AVD3D11VADeviceContext *)((AVHWDeviceContext *)m_pDevCtx->data)->hwctx;\n    AVFrame *src = (AVFrame *)pFrame->priv_data;\n\n    D3D11_TEXTURE2D_DESC videoTexDesc{};\n    ((ID3D11Texture2D *)src->data[0])->GetDesc(&videoTexDesc);\n\n    // validate the properties of the staging texture to match the video texture, re-create if needed\n    if (m_pD3D11StagingTexture)\n    {\n        D3D11_TEXTURE2D_DESC stagingTexDesc{};\n        m_pD3D11StagingTexture->GetDesc(&stagingTexDesc);\n\n        if (stagingTexDesc.Width != videoTexDesc.Width || stagingTexDesc.Height != videoTexDesc.Height ||\n            stagingTexDesc.Format != videoTexDesc.Format)\n            SafeRelease(&m_pD3D11StagingTexture);\n    }\n\n    // (re-)create the staging texture\n    if (m_pD3D11StagingTexture == nullptr)\n    {\n        D3D11_TEXTURE2D_DESC stagingTexDesc = videoTexDesc;\n\n        stagingTexDesc.ArraySize = 1;\n        stagingTexDesc.Usage = D3D11_USAGE_STAGING;\n        stagingTexDesc.BindFlags = 0;\n        stagingTexDesc.CPUAccessFlags = D3D11_CPU_ACCESS_READ;\n        stagingTexDesc.MiscFlags = 0;\n\n        HRESULT hr = pDeviceContext->device->CreateTexture2D(&stagingTexDesc, nullptr, &m_pD3D11StagingTexture);\n        if (FAILED(hr))\n        {\n            ReleaseFrame(&pFrame);\n            return E_FAIL;\n        }\n    }\n\n    pDeviceContext->lock(pDeviceContext->lock_ctx);\n    pDeviceContext->device_context->CopySubresourceRegion(\n        m_pD3D11StagingTexture, 0, 0, 0, 0, (ID3D11Texture2D *)src->data[0], (UINT)(intptr_t)src->data[1], nullptr);\n    pDeviceContext->unlock(pDeviceContext->lock_ctx);\n\n    av_frame_free(&src);\n\n    D3D11DirectPrivate *c = new D3D11DirectPrivate;\n    c->pDeviceContex = av_buffer_ref(m_pDevCtx);\n    c->pStagingTexture = m_pD3D11StagingTexture;\n    m_pD3D11StagingTexture->AddRef();\n\n    pFrame->priv_data = c;\n    pFrame->destruct = d3d11_direct_free;\n\n    GetPixelFormat(&pFrame->format, &pFrame->bpp, &pFrame->sw_format);\n\n    pFrame->direct = true;\n    pFrame->direct_lock = d3d11_direct_lock;\n    pFrame->direct_unlock = d3d11_direct_unlock;\n\n    return Deliver(pFrame);\n}\n\nSTDMETHODIMP CDecD3D11::GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware)\n{\n    // Output is always NV12 or P010\n    if (pPix)\n        *pPix = m_bReadBackFallback == false ? LAVPixFmt_D3D11 : d3d11va_map_hw_to_lav_format(m_SurfaceFormat);\n\n    if (pBpp)\n        *pBpp = (m_SurfaceFormat == DXGI_FORMAT_NV12 || m_SurfaceFormat == DXGI_FORMAT_YUY2 ||\n                 m_SurfaceFormat == DXGI_FORMAT_AYUV)\n                    ? 8\n                : (m_SurfaceFormat == DXGI_FORMAT_P010 || m_SurfaceFormat == DXGI_FORMAT_Y210 ||\n                   m_SurfaceFormat == DXGI_FORMAT_Y410)\n                    ? 10\n                : (m_SurfaceFormat == DXGI_FORMAT_P016 || m_SurfaceFormat == DXGI_FORMAT_Y216 ||\n                   m_SurfaceFormat == DXGI_FORMAT_Y416)\n                    ? 16\n                    : 8;\n\n    if (pPixSoftware)\n        *pPixSoftware = d3d11va_map_hw_to_lav_format(m_SurfaceFormat);\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(DWORD) CDecD3D11::GetHWAccelNumDevices()\n{\n    DWORD nDevices = 0;\n    UINT i = 0;\n    IDXGIAdapter *pDXGIAdapter = nullptr;\n    IDXGIFactory1 *pDXGIFactory = nullptr;\n\n    HRESULT hr = dx.mCreateDXGIFactory1(IID_IDXGIFactory1, (void **)&pDXGIFactory);\n    if (FAILED(hr))\n        goto fail;\n\n    DXGI_ADAPTER_DESC desc;\n    while (SUCCEEDED(pDXGIFactory->EnumAdapters(i, &pDXGIAdapter)))\n    {\n        pDXGIAdapter->GetDesc(&desc);\n        SafeRelease(&pDXGIAdapter);\n\n        // stop when we hit the MS software device\n        if (desc.VendorId == 0x1414 && desc.DeviceId == 0x8c)\n            break;\n\n        i++;\n    }\n\n    nDevices = i;\n\nfail:\n    SafeRelease(&pDXGIFactory);\n    return nDevices;\n}\n\nSTDMETHODIMP CDecD3D11::GetHWAccelDeviceInfo(DWORD dwIndex, BSTR *pstrDeviceName, DWORD *dwDeviceIdentifier)\n{\n    IDXGIAdapter *pDXGIAdapter = nullptr;\n    IDXGIFactory1 *pDXGIFactory = nullptr;\n\n    HRESULT hr = dx.mCreateDXGIFactory1(IID_IDXGIFactory1, (void **)&pDXGIFactory);\n    if (FAILED(hr))\n        goto fail;\n\n    hr = pDXGIFactory->EnumAdapters(dwIndex, &pDXGIAdapter);\n    if (FAILED(hr))\n        goto fail;\n\n    DXGI_ADAPTER_DESC desc;\n    pDXGIAdapter->GetDesc(&desc);\n\n    // stop when we hit the MS software device\n    if (desc.VendorId == 0x1414 && desc.DeviceId == 0x8c)\n    {\n        hr = E_INVALIDARG;\n        goto fail;\n    }\n\n    if (pstrDeviceName)\n        *pstrDeviceName = SysAllocString(desc.Description);\n\n    if (dwDeviceIdentifier)\n        *dwDeviceIdentifier = desc.DeviceId;\n\nfail:\n    SafeRelease(&pDXGIFactory);\n    SafeRelease(&pDXGIAdapter);\n    return hr;\n}\n\nSTDMETHODIMP CDecD3D11::GetHWAccelActiveDevice(BSTR *pstrDeviceName)\n{\n    CheckPointer(pstrDeviceName, E_POINTER);\n\n    if (m_AdapterDesc.Description[0] == 0)\n        return E_UNEXPECTED;\n\n    *pstrDeviceName = SysAllocString(m_AdapterDesc.Description);\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/d3d11va.h",
    "content": "/*\n *      Copyright (C) 2017-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n#include \"DecBase.h\"\n#include \"avcodec.h\"\n\n#include <d3d11.h>\n#include <dxgi.h>\n\n#include \"d3d11/D3D11SurfaceAllocator.h\"\n\nextern \"C\"\n{\n#include \"libavutil/hwcontext.h\"\n#include \"libavutil/hwcontext_d3d11va.h\"\n#include \"libavcodec/d3d11va.h\"\n#include \"libavcodec/h265_rext_profiles.h\"\n}\n\n#define D3D11_QUEUE_SURFACES 4\n\ntypedef HRESULT(WINAPI *PFN_CREATE_DXGI_FACTORY1)(REFIID riid, void **ppFactory);\n\nclass CDecD3D11 : public CDecAvcodec\n{\n  public:\n    CDecD3D11(void);\n    virtual ~CDecD3D11(void);\n\n    // ILAVDecoder\n    STDMETHODIMP Check();\n    STDMETHODIMP InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData);\n    STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware);\n    STDMETHODIMP Flush();\n    STDMETHODIMP EndOfStream();\n\n    STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc);\n    STDMETHODIMP PostConnect(IPin *pPin);\n    STDMETHODIMP BreakConnect();\n    STDMETHODIMP_(long) GetBufferCount(long *pMaxBuffers = nullptr);\n    STDMETHODIMP_(const WCHAR *) GetDecoderName()\n    {\n        return m_bReadBackFallback ? (m_bDirect ? L\"d3d11 cb direct\" : L\"d3d11 cb\") : L\"d3d11 native\";\n    }\n    STDMETHODIMP HasThreadSafeBuffers() { return S_FALSE; }\n    STDMETHODIMP SetDirectOutput(BOOL bDirect)\n    {\n        m_bDirect = bDirect;\n        return S_OK;\n    }\n    STDMETHODIMP_(DWORD) GetHWAccelNumDevices();\n    STDMETHODIMP GetHWAccelDeviceInfo(DWORD dwIndex, BSTR *pstrDeviceName, DWORD *dwDeviceIdentifier);\n    STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName);\n\n    // CDecBase\n    STDMETHODIMP Init();\n\n  protected:\n    HRESULT AdditionaDecoderInit();\n    HRESULT PostDecode();\n\n    HRESULT HandleDXVA2Frame(LAVFrame *pFrame);\n    HRESULT DeliverD3D11Frame(LAVFrame *pFrame);\n    HRESULT DeliverD3D11Readback(LAVFrame *pFrame);\n    HRESULT DeliverD3D11ReadbackDirect(LAVFrame *pFrame);\n\n    BOOL IsHardwareAccelerator() { return TRUE; }\n\n  private:\n    STDMETHODIMP DestroyDecoder(bool bFull);\n\n    STDMETHODIMP ReInitD3D11Decoder(AVCodecContext *c);\n\n    STDMETHODIMP CreateD3D11Device(UINT nDeviceIndex, ID3D11Device **ppDevice, DXGI_ADAPTER_DESC *pDesc);\n    STDMETHODIMP CreateD3D11Decoder();\n    STDMETHODIMP AllocateFramesContext(int width, int height, DXGI_FORMAT format, int nSurfaces,\n                                       AVBufferRef **pFramesCtx);\n\n    STDMETHODIMP FindVideoServiceConversion(AVCodecID codec, int profile, int level, DXGI_FORMAT &surface_format, GUID *input);\n    STDMETHODIMP FindDecoderConfiguration(const D3D11_VIDEO_DECODER_DESC *desc, D3D11_VIDEO_DECODER_CONFIG *pConfig);\n\n    STDMETHODIMP FillHWContext(AVD3D11VAContext *ctx);\n\n    STDMETHODIMP FlushDisplayQueue(BOOL bDeliver);\n\n    static enum AVPixelFormat get_d3d11_format(struct AVCodecContext *s, const enum AVPixelFormat *pix_fmts);\n    static int get_d3d11_buffer(struct AVCodecContext *c, AVFrame *pic, int flags);\n\n  private:\n    CD3D11SurfaceAllocator *m_pAllocator = nullptr;\n\n    AVBufferRef *m_pDevCtx = nullptr;\n    AVBufferRef *m_pFramesCtx = nullptr;\n\n    D3D11_VIDEO_DECODER_CONFIG m_DecoderConfig;\n    ID3D11VideoDecoder *m_pDecoder = nullptr;\n\n    int m_nOutputViews = 0;\n    ID3D11VideoDecoderOutputView **m_pOutputViews = nullptr;\n\n    DWORD m_dwSurfaceWidth = 0;\n    DWORD m_dwSurfaceHeight = 0;\n    DWORD m_dwSurfaceCount = 0;\n    DXGI_FORMAT m_SurfaceFormat = DXGI_FORMAT_UNKNOWN;\n\n    BOOL m_bReadBackFallback = FALSE;\n    BOOL m_bDirect = FALSE;\n    BOOL m_bFailHWDecode = FALSE;\n\n    BOOL m_bP016ToP010Fallback = FALSE;\n\n    ID3D11Texture2D *m_pD3D11StagingTexture = nullptr;\n\n    LAVFrame *m_FrameQueue[D3D11_QUEUE_SURFACES];\n    int m_FrameQueuePosition = 0;\n    int m_DisplayDelay = D3D11_QUEUE_SURFACES;\n\n    struct\n    {\n        HMODULE d3d11lib;\n        PFN_D3D11_CREATE_DEVICE mD3D11CreateDevice;\n\n        HMODULE dxgilib;\n        PFN_CREATE_DXGI_FACTORY1 mCreateDXGIFactory1;\n    } dx = {0};\n\n    DXGI_ADAPTER_DESC m_AdapterDesc = {0};\n\n    friend class CD3D11SurfaceAllocator;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/dxva2/DXVA2SurfaceAllocator.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial Design and Concept taken from MPC-HC, licensed under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"decoders/dxva2dec.h\"\n#include \"DXVA2SurfaceAllocator.h\"\n\n#include \"moreuuids.h\"\n#include <evr.h>\n#include <Mferror.h>\n\nCDXVA2Sample::CDXVA2Sample(CDXVA2SurfaceAllocator *pAlloc, HRESULT *phr)\n    : CMediaSampleSideData(NAME(\"CDXVA2Sample\"), (CBaseAllocator *)pAlloc, phr, nullptr, 0)\n{\n}\n\nCDXVA2Sample::~CDXVA2Sample()\n{\n    SafeRelease(&m_pSurface);\n}\n\n// Note: CMediaSample does not derive from CUnknown, so we cannot use the\n//\t\tDECLARE_IUNKNOWN macro that is used by most of the filter classes.\n\nSTDMETHODIMP CDXVA2Sample::QueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n    ValidateReadWritePtr(ppv, sizeof(PVOID));\n\n    if (riid == __uuidof(IMFGetService))\n    {\n        return GetInterface((IMFGetService *)this, ppv);\n    }\n    else if (riid == __uuidof(ILAVDXVA2Sample))\n    {\n        return GetInterface((ILAVDXVA2Sample *)this, ppv);\n    }\n    else\n    {\n        return __super::QueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP_(ULONG) CDXVA2Sample::AddRef()\n{\n    return __super::AddRef();\n}\n\nSTDMETHODIMP_(ULONG) CDXVA2Sample::Release()\n{\n    // Return a temporary variable for thread safety.\n    ULONG cRef = __super::Release();\n    return cRef;\n}\n\n// IMFGetService::GetService\nSTDMETHODIMP CDXVA2Sample::GetService(REFGUID guidService, REFIID riid, LPVOID *ppv)\n{\n    if (guidService != MR_BUFFER_SERVICE)\n    {\n        return MF_E_UNSUPPORTED_SERVICE;\n    }\n    else if (m_pSurface == nullptr)\n    {\n        return E_NOINTERFACE;\n    }\n    else\n    {\n        return m_pSurface->QueryInterface(riid, ppv);\n    }\n}\n\n// Override GetPointer because this class does not manage a system memory buffer.\n// The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.\nSTDMETHODIMP CDXVA2Sample::GetPointer(BYTE **ppBuffer)\n{\n    return E_NOTIMPL;\n}\n\n// Sets the pointer to the Direct3D surface.\nvoid CDXVA2Sample::SetSurface(DWORD surfaceId, IDirect3DSurface9 *pSurf)\n{\n    SafeRelease(&m_pSurface);\n    m_pSurface = pSurf;\n    m_dwSurfaceId = surfaceId;\n    if (m_pSurface)\n        m_pSurface->AddRef();\n}\n\nSTDMETHODIMP_(int) CDXVA2Sample::GetDXSurfaceId()\n{\n    return m_dwSurfaceId;\n}\n\nCDXVA2SurfaceAllocator::CDXVA2SurfaceAllocator(CDecDXVA2 *m_pDXVA2Dec, HRESULT *phr)\n    : CBaseAllocator(NAME(\"CDXVA2SurfaceAllocator\"), nullptr, phr)\n    , m_pDec(m_pDXVA2Dec)\n{\n}\n\nCDXVA2SurfaceAllocator::~CDXVA2SurfaceAllocator(void)\n{\n    if (m_pDec && m_pDec->m_pDXVA2Allocator == this)\n        m_pDec->m_pDXVA2Allocator = nullptr;\n}\n\n// IUnknown\nSTDMETHODIMP CDXVA2SurfaceAllocator::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    *ppv = nullptr;\n\n    return QI(ILAVDXVA2SurfaceAllocator) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\nHRESULT CDXVA2SurfaceAllocator::Alloc()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDXVA2SurfaceAllocator::Alloc()\"));\n    HRESULT hr = S_OK;\n    IDirectXVideoDecoderService *pDXVA2Service = nullptr;\n\n    if (!m_pDec)\n        return E_FAIL;\n\n    CheckPointer(m_pDec->m_pD3DDevMngr, E_UNEXPECTED);\n    hr = m_pDec->m_pD3DDevMngr->GetVideoService(m_pDec->m_hDevice, IID_IDirectXVideoDecoderService,\n                                                (void **)&pDXVA2Service);\n    CheckPointer(pDXVA2Service, E_UNEXPECTED);\n    CAutoLock lock(this);\n\n    hr = __super::Alloc();\n\n    if (SUCCEEDED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Releasing old resources\"));\n        // Free the old resources.\n        m_pDec->FlushFromAllocator();\n        Free();\n\n        m_nSurfaceArrayCount = m_lCount;\n\n        // Allocate a new array of pointers.\n        m_ppRTSurfaceArray = new IDirect3DSurface9 *[m_lCount];\n        if (m_ppRTSurfaceArray == nullptr)\n        {\n            hr = E_OUTOFMEMORY;\n        }\n        else\n        {\n            ZeroMemory(m_ppRTSurfaceArray, sizeof(IDirect3DSurface9 *) * m_lCount);\n        }\n    }\n\n    // Allocate the surfaces.\n    if (SUCCEEDED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Allocating surfaces\"));\n        hr = pDXVA2Service->CreateSurface(m_pDec->m_dwSurfaceWidth, m_pDec->m_dwSurfaceHeight, m_lCount - 1,\n                                          m_pDec->m_eSurfaceFormat, D3DPOOL_DEFAULT, 0, DXVA2_VideoDecoderRenderTarget,\n                                          m_ppRTSurfaceArray, nullptr);\n    }\n\n    if (SUCCEEDED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Creating samples\"));\n        // Important : create samples in reverse order !\n        for (int i = m_lCount - 1; i >= 0; i--)\n        {\n            CDXVA2Sample *pSample = new CDXVA2Sample(this, &hr);\n            if (pSample == nullptr)\n            {\n                hr = E_OUTOFMEMORY;\n                break;\n            }\n            if (FAILED(hr))\n            {\n                break;\n            }\n            // Assign the Direct3D surface pointer and the index.\n            pSample->SetSurface(i, m_ppRTSurfaceArray[i]);\n\n            // Add to the sample list.\n            m_lFree.Add(pSample);\n        }\n\n        hr = m_pDec->CreateDXVA2Decoder(m_lCount, m_ppRTSurfaceArray);\n        if (FAILED(hr))\n        {\n            Free();\n        }\n    }\n\n    m_lAllocated = m_lCount;\n\n    if (SUCCEEDED(hr))\n    {\n        m_bChanged = FALSE;\n    }\n    SafeRelease(&pDXVA2Service);\n    return hr;\n}\n\nvoid CDXVA2SurfaceAllocator::Free()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDXVA2SurfaceAllocator::Free()\"));\n    CMediaSample *pSample = nullptr;\n\n    CAutoLock lock(this);\n\n    do\n    {\n        pSample = m_lFree.RemoveHead();\n        if (pSample)\n        {\n            delete pSample;\n        }\n    } while (pSample);\n\n    if (m_ppRTSurfaceArray)\n    {\n        for (UINT i = 0; i < m_nSurfaceArrayCount; i++)\n        {\n            if (m_ppRTSurfaceArray[i] != nullptr)\n            {\n                m_ppRTSurfaceArray[i]->Release();\n            }\n        }\n\n        delete[] m_ppRTSurfaceArray;\n        m_ppRTSurfaceArray = nullptr;\n    }\n    m_lAllocated = 0;\n    m_nSurfaceArrayCount = 0;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/dxva2/DXVA2SurfaceAllocator.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial Design and Concept taken from MPC-HC, licensed under GPLv2\n */\n\n#pragma once\n\n#include <Mfidl.h>\n#include \"MediaSampleSideData.h\"\n\nclass CDecDXVA2;\n\ninterface __declspec(uuid(\"50A8A9A1-FF44-45C1-9DC2-79066ED1E576\")) ILAVDXVA2Sample : public IUnknown\n{\n    STDMETHOD_(int, GetDXSurfaceId()) = 0;\n};\n\nclass CDXVA2Sample\n    : public CMediaSampleSideData\n    , public IMFGetService\n    , public ILAVDXVA2Sample\n{\n    friend class CDXVA2SurfaceAllocator;\n\n  public:\n    CDXVA2Sample(CDXVA2SurfaceAllocator *pAlloc, HRESULT *phr);\n    virtual ~CDXVA2Sample();\n\n    STDMETHODIMP QueryInterface(REFIID riid, __deref_out void **ppv);\n    STDMETHODIMP_(ULONG) AddRef();\n    STDMETHODIMP_(ULONG) Release();\n\n    // IMFGetService::GetService\n    STDMETHODIMP GetService(REFGUID guidService, REFIID riid, LPVOID *ppv);\n\n    // ILAVDXVA2Sample\n    STDMETHODIMP_(int) GetDXSurfaceId();\n\n    // Override GetPointer because this class does not manage a system memory buffer.\n    // The EVR uses the MR_BUFFER_SERVICE service to get the Direct3D surface.\n    STDMETHODIMP GetPointer(BYTE **ppBuffer);\n\n  private:\n    // Sets the pointer to the Direct3D surface.\n    void SetSurface(DWORD surfaceId, IDirect3DSurface9 *pSurf);\n\n    IDirect3DSurface9 *m_pSurface = nullptr;\n    DWORD m_dwSurfaceId = 0;\n};\n\ninterface __declspec(uuid(\"23F80BD8-2654-4F74-B7CC-621868D0A850\")) ILAVDXVA2SurfaceAllocator : public IUnknown\n{\n    STDMETHOD_(void, DecoderDestruct)() = 0;\n};\n\nclass CDXVA2SurfaceAllocator\n    : public CBaseAllocator\n    , public ILAVDXVA2SurfaceAllocator\n{\n  public:\n    CDXVA2SurfaceAllocator(CDecDXVA2 *m_pDXVA2Dec, HRESULT *phr);\n    virtual ~CDXVA2SurfaceAllocator(void);\n\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    HRESULT Alloc();\n    void Free();\n    STDMETHODIMP_(BOOL) DecommitInProgress()\n    {\n        CAutoLock cal(this);\n        return m_bDecommitInProgress;\n    }\n    STDMETHODIMP_(BOOL) IsCommited()\n    {\n        CAutoLock cal(this);\n        return m_bCommitted;\n    }\n\n    STDMETHODIMP_(void) DecoderDestruct() { m_pDec = nullptr; }\n\n  private:\n    CDecDXVA2 *m_pDec = nullptr;\n\n    IDirect3DSurface9 **m_ppRTSurfaceArray = nullptr;\n    UINT m_nSurfaceArrayCount = 0;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/dxva2/dxva_common.cpp",
    "content": "/*\n*      Copyright (C) 2011-2021 Hendrik Leppkes\n*      http://www.1f0.de\n*\n*  This program is free software; you can redistribute it and/or modify\n*  it under the terms of the GNU General Public License as published by\n*  the Free Software Foundation; either version 2 of the License, or\n*  (at your option) any later version.\n*\n*  This program is distributed in the hope that it will be useful,\n*  but WITHOUT ANY WARRANTY; without even the implied warranty of\n*  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n*  GNU General Public License for more details.\n*\n*  You should have received a copy of the GNU General Public License along\n*  with this program; if not, write to the Free Software Foundation, Inc.,\n*  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n*/\n\n#include \"stdafx.h\"\n#include \"dxva_common.h\"\n#include \"moreuuids.h\"\n\nextern \"C\"\n{\n#include \"libavcodec/h265_rext_profiles.h\"\n};\n\n#define DXVA_SURFACE_BASE_ALIGN 16\n\nDWORD dxva_align_dimensions(AVCodecID codec, DWORD dim)\n{\n  int align = DXVA_SURFACE_BASE_ALIGN;\n\n  // MPEG-2 needs higher alignment on Intel cards, and it doesn't seem to harm anything to do it for all cards.\n  if (codec == AV_CODEC_ID_MPEG2VIDEO)\n    align <<= 1;\n  else if (codec == AV_CODEC_ID_HEVC || codec == AV_CODEC_ID_AV1)\n    align = 128;\n\n  return FFALIGN(dim, align);\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Codec Maps\n////////////////////////////////////////////////////////////////////////////////\n\n/*\nDXVA2 Codec Mappings, as defined by VLC\n*/\n\nstatic const int prof_mpeg2_main[] = { AV_PROFILE_MPEG2_SIMPLE, AV_PROFILE_MPEG2_MAIN, AV_PROFILE_UNKNOWN };\nstatic const int prof_h264_high[] = { AV_PROFILE_H264_CONSTRAINED_BASELINE, AV_PROFILE_H264_MAIN, AV_PROFILE_H264_HIGH, AV_PROFILE_UNKNOWN };\nstatic const int prof_hevc_main[] = { AV_PROFILE_HEVC_MAIN, AV_PROFILE_UNKNOWN };\nstatic const int prof_hevc_main10[] = { AV_PROFILE_HEVC_MAIN_10, AV_PROFILE_UNKNOWN };\nstatic const int prof_hevc_rext[] = {AV_PROFILE_HEVC_REXT, AV_PROFILE_UNKNOWN};\nstatic const int prof_vp9_0[] = { AV_PROFILE_VP9_0, AV_PROFILE_UNKNOWN };\nstatic const int prof_vp9_2_10bit[] = { AV_PROFILE_VP9_2, AV_PROFILE_UNKNOWN };\nstatic const int prof_av1_0[] = {AV_PROFILE_AV1_MAIN, AV_PROFILE_UNKNOWN};\nstatic const int prof_av1_1[] = {AV_PROFILE_AV1_HIGH, AV_PROFILE_UNKNOWN};\nstatic const int prof_av1_2[] = {AV_PROFILE_AV1_PROFESSIONAL, AV_PROFILE_UNKNOWN};\n\n/* XXX Preferred modes must come first */\n// clang-format off\nconst dxva_mode_t dxva_modes[] = {\n  /* MPEG-1/2 */\n  { \"MPEG-2 variable-length decoder\",                                               &DXVA2_ModeMPEG2_VLD,                   AV_CODEC_ID_MPEG2VIDEO, prof_mpeg2_main },\n  { \"MPEG-2 & MPEG-1 variable-length decoder\",                                      &DXVA2_ModeMPEG2and1_VLD,               AV_CODEC_ID_MPEG2VIDEO, prof_mpeg2_main },\n  { \"MPEG-2 motion compensation\",                                                   &DXVA2_ModeMPEG2_MoComp,                0 },\n  { \"MPEG-2 inverse discrete cosine transform\",                                     &DXVA2_ModeMPEG2_IDCT,                  0 },\n\n  { \"MPEG-1 variable-length decoder\",                                               &DXVA2_ModeMPEG1_VLD,                   0 },\n\n  /* H.264 */\n  { \"H.264 variable-length decoder, film grain technology\",                         &DXVA2_ModeH264_F,                      AV_CODEC_ID_H264, prof_h264_high },\n  { \"H.264 variable-length decoder, no film grain technology\",                      &DXVA2_ModeH264_E,                      AV_CODEC_ID_H264, prof_h264_high },\n  { \"H.264 variable-length decoder, no film grain technology, FMO/ASO\",             &DXVA_ModeH264_VLD_WithFMOASO_NoFGT,    AV_CODEC_ID_H264, prof_h264_high },\n  { \"H.264 variable-length decoder, no film grain technology, Flash\",               &DXVA_ModeH264_VLD_NoFGT_Flash,         AV_CODEC_ID_H264, prof_h264_high },\n\n  { \"H.264 inverse discrete cosine transform, film grain technology\",               &DXVA2_ModeH264_D,                      0 },\n  { \"H.264 inverse discrete cosine transform, no film grain technology\",            &DXVA2_ModeH264_C,                      0 },\n\n  { \"H.264 motion compensation, film grain technology\",                             &DXVA2_ModeH264_B,                      0 },\n  { \"H.264 motion compensation, no film grain technology\",                          &DXVA2_ModeH264_A,                      0 },\n\n  /* WMV */\n  { \"Windows Media Video 8 motion compensation\",                                    &DXVA2_ModeWMV8_B,                      0 },\n  { \"Windows Media Video 8 post processing\",                                        &DXVA2_ModeWMV8_A,                      0 },\n\n  { \"Windows Media Video 9 IDCT\",                                                   &DXVA2_ModeWMV9_C,                      0 },\n  { \"Windows Media Video 9 motion compensation\",                                    &DXVA2_ModeWMV9_B,                      0 },\n  { \"Windows Media Video 9 post processing\",                                        &DXVA2_ModeWMV9_A,                      0 },\n\n  /* VC-1 */\n  { \"VC-1 variable-length decoder (2010)\",                                          &DXVA2_ModeVC1_D2010,                   AV_CODEC_ID_VC1 },\n  { \"VC-1 variable-length decoder (2010)\",                                          &DXVA2_ModeVC1_D2010,                   AV_CODEC_ID_WMV3 },\n  { \"VC-1 variable-length decoder\",                                                 &DXVA2_ModeVC1_D,                       AV_CODEC_ID_VC1 },\n  { \"VC-1 variable-length decoder\",                                                 &DXVA2_ModeVC1_D,                       AV_CODEC_ID_WMV3 },\n\n  { \"VC-1 inverse discrete cosine transform\",                                       &DXVA2_ModeVC1_C,                       0 },\n  { \"VC-1 motion compensation\",                                                     &DXVA2_ModeVC1_B,                       0 },\n  { \"VC-1 post processing\",                                                         &DXVA2_ModeVC1_A,                       0 },\n\n  /* MPEG4-ASP */\n  { \"MPEG-4 Part 2 nVidia bitstream decoder\",                                       &DXVA_nVidia_MPEG4_ASP,                 0 },\n  { \"MPEG-4 Part 2 variable-length decoder, Simple Profile\",                        &DXVA_ModeMPEG4pt2_VLD_Simple,          0 },\n  { \"MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, no GMC\",       &DXVA_ModeMPEG4pt2_VLD_AdvSimple_NoGMC, 0 },\n  { \"MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, GMC\",          &DXVA_ModeMPEG4pt2_VLD_AdvSimple_GMC,   0 },\n  { \"MPEG-4 Part 2 variable-length decoder, Simple&Advanced Profile, Avivo\",        &DXVA_ModeMPEG4pt2_VLD_AdvSimple_Avivo, 0 },\n\n  /* H.264 MVC */\n  { \"H.264 MVC variable-length decoder, stereo, progressive\",                       &DXVA_ModeH264_VLD_Stereo_Progressive_NoFGT, 0 },\n  { \"H.264 MVC variable-length decoder, stereo\",                                    &DXVA_ModeH264_VLD_Stereo_NoFGT,             0 },\n  { \"H.264 MVC variable-length decoder, multiview\",                                 &DXVA_ModeH264_VLD_Multiview_NoFGT,          0 },\n\n  /* H.264 SVC */\n  { \"H.264 SVC variable-length decoder, baseline\",                                  &DXVA_ModeH264_VLD_SVC_Scalable_Baseline,                    0 },\n  { \"H.264 SVC variable-length decoder, constrained baseline\",                      &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_Baseline,         0 },\n  { \"H.264 SVC variable-length decoder, high\",                                      &DXVA_ModeH264_VLD_SVC_Scalable_High,                        0 },\n  { \"H.264 SVC variable-length decoder, constrained high progressive\",              &DXVA_ModeH264_VLD_SVC_Restricted_Scalable_High_Progressive, 0 },\n\n  /* HEVC / H.265 */\n  { \"HEVC / H.265 variable-length decoder, main\",                                   &DXVA_ModeHEVC_VLD_Main,                AV_CODEC_ID_HEVC, prof_hevc_main },\n  { \"HEVC / H.265 variable-length decoder, main10\",                                 &DXVA_ModeHEVC_VLD_Main10,              AV_CODEC_ID_HEVC, prof_hevc_main10 },\n  { \"HEVC / H.265 variable-length decoder, main12\",                                 &DXVA_ModeHEVC_VLD_Main12,              AV_CODEC_ID_HEVC, prof_hevc_rext, FF_HEVC_REXT_PROFILE_MAIN_12 },\n  { \"HEVC / H.265 variable-length decoder, main10 422\",                             &DXVA_ModeHEVC_VLD_Main10_422,          AV_CODEC_ID_HEVC, prof_hevc_rext, FF_HEVC_REXT_PROFILE_MAIN422_10 },\n  { \"HEVC / H.265 variable-length decoder, main12 422\",                             &DXVA_ModeHEVC_VLD_Main12_422,          AV_CODEC_ID_HEVC, prof_hevc_rext, FF_HEVC_REXT_PROFILE_MAIN422_12 },\n  { \"HEVC / H.265 variable-length decoder, main 444\",                               &DXVA_ModeHEVC_VLD_Main_444,            AV_CODEC_ID_HEVC, prof_hevc_rext, FF_HEVC_REXT_PROFILE_MAIN444 },\n  { \"HEVC / H.265 variable-length decoder, main10 extended\",                        &DXVA_ModeHEVC_VLD_Main10_Ext,          0 },\n  { \"HEVC / H.265 variable-length decoder, main10 444\",                             &DXVA_ModeHEVC_VLD_Main10_444,          AV_CODEC_ID_HEVC, prof_hevc_rext, FF_HEVC_REXT_PROFILE_MAIN444_10 },\n  { \"HEVC / H.265 variable-length decoder, main12 444\",                             &DXVA_ModeHEVC_VLD_Main12_444,          AV_CODEC_ID_HEVC, prof_hevc_rext, FF_HEVC_REXT_PROFILE_MAIN444_12 },\n  { \"HEVC / H.265 variable-length decoder, main16\",                                 &DXVA_ModeHEVC_VLD_Main16,              AV_CODEC_ID_HEVC, prof_hevc_rext, FF_HEVC_REXT_PROFILE_MAIN444_16 },\n  { \"HEVC / H.265 variable-length decoder, monochrome\",                             &DXVA_ModeHEVC_VLD_Monochrome,          0 },\n  { \"HEVC / H.265 variable-length decoder, monochrome10\",                           &DXVA_ModeHEVC_VLD_Monochrome10,        0 },\n\n  /* VP8/9 */\n  { \"VP9 variable-length decoder, profile 0\",                                       &DXVA_ModeVP9_VLD_Profile0,             AV_CODEC_ID_VP9, prof_vp9_0 },\n  { \"VP9 variable-length decoder, 10bit, profile 2\",                                &DXVA_ModeVP9_VLD_10bit_Profile2,       AV_CODEC_ID_VP9, prof_vp9_2_10bit },\n  { \"VP8 variable-length decoder\",                                                  &DXVA_ModeVP8_VLD,                      0 },\n\n  /* AV1 */\n  { \"AV1 variable-length decoder, profile 0\",                                       &DXVA_ModeAV1_VLD_Profile0,             AV_CODEC_ID_AV1, prof_av1_0 },\n  { \"AV1 variable-length decoder, profile 1\",                                       &DXVA_ModeAV1_VLD_Profile1,             0 },\n  { \"AV1 variable-length decoder, profile 2\",                                       &DXVA_ModeAV1_VLD_Profile2,             0 },\n  { \"AV1 variable-length decoder, profile 2 12-bit\",                                &DXVA_ModeAV1_VLD_12bit_Profile2,       0 },\n  { \"AV1 variable-length decoder, profile 2 12-bit 4:2:0\",                          &DXVA_ModeAV1_VLD_12bit_Profile2_420,   0 },\n\n  /* Intel specific modes (only useful on older GPUs) */\n  { \"H.264 variable-length decoder, no film grain technology (Intel ClearVideo)\",   &DXVADDI_Intel_ModeH264_E,              AV_CODEC_ID_H264, prof_h264_high },\n  { \"H.264 inverse discrete cosine transform, no film grain technology (Intel)\",    &DXVADDI_Intel_ModeH264_C,              0 },\n  { \"H.264 motion compensation, no film grain technology (Intel)\",                  &DXVADDI_Intel_ModeH264_A,              0 },\n  { \"VC-1 variable-length decoder 2 (Intel)\",                                       &DXVA_Intel_VC1_ClearVideo_2,           0 },\n  { \"VC-1 variable-length decoder (Intel)\",                                         &DXVA_Intel_VC1_ClearVideo,             0 },\n\n  { nullptr, nullptr, 0 }\n};\n// clang-format on\n\nconst dxva_mode_t *get_dxva_mode_from_guid(const GUID *guid)\n{\n  for (unsigned i = 0; dxva_modes[i].name; i++) {\n    if (IsEqualGUID(*dxva_modes[i].guid, *guid))\n      return &dxva_modes[i];\n  }\n  return nullptr;\n}\n\nint check_dxva_mode_compatibility(const dxva_mode_t *mode, int codec, int profile, int level, bool b8Bit)\n{\n  if (mode->codec != codec)\n    return 0;\n\n  if (mode->profiles && profile != AV_PROFILE_UNKNOWN)\n  {\n    for (int i = 0; mode->profiles[i] != AV_PROFILE_UNKNOWN; i++)\n    {\n        if (mode->profiles[i] == profile && (mode->level == 0 || mode->level == level))\n            return 1;\n    }\n\n    /* hevc main and main10 are very similar, and in some cases streams can be flagged as main10, but actually contain 8-bit content */\n    if (codec == AV_CODEC_ID_HEVC && mode->profiles[0] == AV_PROFILE_HEVC_MAIN && profile == AV_PROFILE_HEVC_MAIN_10 && b8Bit)\n        return 1;\n\n    return 0;\n  }\n\n  return 1;\n}\n\n#define H264_MAX_REF_DPB(ctx, dpbsize, dpblimit, mbcount) (min(dpblimit, (dpbsize) / (mbcount)))\n\nint check_dxva_codec_profile(const AVCodecContext *ctx, int hwpixfmt)\n{\n    AVCodecID codec = ctx->codec_id;\n    AVPixelFormat pix_fmt = ctx->pix_fmt;\n    int profile = ctx->profile;\n    int level = ctx->level;\n\n    // check mpeg2 pixfmt\n    if (codec == AV_CODEC_ID_MPEG2VIDEO && pix_fmt != AV_PIX_FMT_YUV420P && pix_fmt != AV_PIX_FMT_YUVJ420P && pix_fmt != hwpixfmt && pix_fmt != AV_PIX_FMT_NONE)\n        return 1;\n\n    // check h264 pixfmt\n    if (codec == AV_CODEC_ID_H264 && pix_fmt != AV_PIX_FMT_YUV420P && pix_fmt != AV_PIX_FMT_YUVJ420P && pix_fmt != hwpixfmt && pix_fmt != AV_PIX_FMT_NONE)\n        return 1;\n\n    // check h264 profile\n    if (codec == AV_CODEC_ID_H264 && profile != AV_PROFILE_UNKNOWN && !H264_CHECK_PROFILE(profile))\n        return 1;\n\n    // H.264 Level 5.1 ref frame limits\n    const int h264mb_count = (ctx->coded_width / 16) * (ctx->coded_height / 16);\n    if (codec == AV_CODEC_ID_H264 && h264mb_count > 0 && ctx->refs > H264_MAX_REF_DPB(ctx, 184320, 16, h264mb_count))\n        return 1;\n\n    // check wmv/vc1 profile\n    if ((codec == AV_CODEC_ID_WMV3 || codec == AV_CODEC_ID_VC1) && profile == AV_PROFILE_VC1_COMPLEX)\n        return 1;\n\n    // check vp9 profile/pixfmt\n    if (codec == AV_CODEC_ID_VP9 && (!VP9_CHECK_PROFILE(profile) || (pix_fmt != AV_PIX_FMT_YUV420P && pix_fmt != AV_PIX_FMT_YUV420P10 && pix_fmt != hwpixfmt && pix_fmt != AV_PIX_FMT_NONE)))\n        return 1;\n\n    // check av1 profile/pixfmt\n    if (codec == AV_CODEC_ID_AV1 && (profile != AV_PROFILE_AV1_MAIN || (pix_fmt != AV_PIX_FMT_YUV420P  && pix_fmt != AV_PIX_FMT_YUV420P10 && pix_fmt != hwpixfmt && pix_fmt != AV_PIX_FMT_NONE)))\n        return 1;\n\n    return 0;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/dxva2/dxva_common.h",
    "content": "/*\n *      Copyright (C) 2011-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n/* Align dimensions for hardware and codec requirements */\nDWORD dxva_align_dimensions(AVCodecID codec, DWORD dim);\n\n#define VEND_ID_ATI 0x1002\n#define VEND_ID_NVIDIA 0x10DE\n#define VEND_ID_INTEL 0x8086\n\n/* hardware mode description */\ntypedef struct\n{\n    const char *name;\n    const GUID *guid;\n    int codec;\n    const int *profiles;\n    const int level;\n} dxva_mode_t;\n\nextern const dxva_mode_t dxva_modes[];\n\nconst dxva_mode_t *get_dxva_mode_from_guid(const GUID *guid);\nint check_dxva_mode_compatibility(const dxva_mode_t *mode, int codec, int profile, int level, bool b8Bit);\n\nint check_dxva_codec_profile(const AVCodecContext *ctx, int hwpixfmt);\n\n#define H264_CHECK_PROFILE(profile) (((profile) & ~AV_PROFILE_H264_CONSTRAINED) <= AV_PROFILE_H264_HIGH)\n#define HEVC_CHECK_PROFILE(profile) ((profile) <= AV_PROFILE_HEVC_MAIN_10)\n#define VP9_CHECK_PROFILE(profile) ((profile) == AV_PROFILE_VP9_0 || (profile) == AV_PROFILE_VP9_2)\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/dxva2dec.cpp",
    "content": "/*\n *      Copyright (C) 2011-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Basic concept based on VLC DXVA2 decoder, licensed under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"dxva2dec.h\"\n#include \"dxva2/dxva_common.h\"\n#include \"dxva2/DXVA2SurfaceAllocator.h\"\n#include \"moreuuids.h\"\n#include \"Media.h\"\n\n#include <Shlwapi.h>\n\n#include <dxva2api.h>\n#include <evr.h>\n#include \"libavcodec/dxva2.h\"\n\nextern \"C\"\n{\n    #include \"libavutil/imgutils.h\"\n    #define FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG 1\n    #define FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO 2\n    #define FF_DXVA2_WORKAROUND_NVIDIA_HEVC_420P12 4\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Constructor\n////////////////////////////////////////////////////////////////////////////////\n\nILAVDecoder *CreateDecoderDXVA2()\n{\n    return new CDecDXVA2();\n}\n\nILAVDecoder *CreateDecoderDXVA2Native()\n{\n    CDecDXVA2 *dec = new CDecDXVA2();\n    dec->SetNativeMode(TRUE);\n    return dec;\n}\n\nHRESULT VerifyD3D9Device(DWORD &dwIndex, DWORD dwDeviceId)\n{\n    HRESULT hr = S_OK;\n\n    IDirect3D9 *pD3D = Direct3DCreate9(D3D_SDK_VERSION);\n    if (!pD3D)\n        return E_FAIL;\n\n    D3DADAPTER_IDENTIFIER9 d3dai = {0};\n\n    // Check the combination of adapter and device id\n    hr = pD3D->GetAdapterIdentifier(dwIndex, 0, &d3dai);\n    if (hr == D3D_OK && d3dai.DeviceId == dwDeviceId)\n        goto done;\n\n    // find an adapter with the specified device id\n    for (UINT i = 0; i < pD3D->GetAdapterCount(); i++)\n    {\n        hr = pD3D->GetAdapterIdentifier(i, 0, &d3dai);\n        if (hr == D3D_OK && d3dai.DeviceId == dwDeviceId)\n        {\n            dwIndex = i;\n            goto done;\n        }\n    }\n\n    // fail otherwise\n    hr = E_FAIL;\n\ndone:\n    SafeRelease(&pD3D);\n    return hr;\n}\n\n// List of PCI Device ID of ATI cards with UVD or UVD+ decoding block.\nstatic DWORD UVDDeviceID[] = {0x94C7, // ATI Radeon HD 2350\n                              0x94C1, // ATI Radeon HD 2400 XT\n                              0x94CC, // ATI Radeon HD 2400 Series\n                              0x958A, // ATI Radeon HD 2600 X2 Series\n                              0x9588, // ATI Radeon HD 2600 XT\n                              0x9405, // ATI Radeon HD 2900 GT\n                              0x9400, // ATI Radeon HD 2900 XT\n                              0x9611, // ATI Radeon 3100 Graphics\n                              0x9610, // ATI Radeon HD 3200 Graphics\n                              0x9614, // ATI Radeon HD 3300 Graphics\n                              0x95C0, // ATI Radeon HD 3400 Series (and others)\n                              0x95C5, // ATI Radeon HD 3400 Series (and others)\n                              0x95C4, // ATI Radeon HD 3400 Series (and others)\n                              0x94C3, // ATI Radeon HD 3410\n                              0x9589, // ATI Radeon HD 3600 Series (and others)\n                              0x9598, // ATI Radeon HD 3600 Series (and others)\n                              0x9591, // ATI Radeon HD 3600 Series (and others)\n                              0x9501, // ATI Radeon HD 3800 Series (and others)\n                              0x9505, // ATI Radeon HD 3800 Series (and others)\n                              0x9507, // ATI Radeon HD 3830\n                              0x9513, // ATI Radeon HD 3850 X2\n                              0x950F, // ATI Radeon HD 3850 X2\n                              0x0000};\n\nstatic int IsAMDUVD(DWORD dwDeviceId)\n{\n    for (int i = 0; UVDDeviceID[i] != 0; i++)\n    {\n        if (UVDDeviceID[i] == dwDeviceId)\n            return 1;\n    }\n    return 0;\n}\n\nstatic D3DFORMAT get_dxva_surface_format(AVCodecContext *ctx)\n{\n    if (ctx->sw_pix_fmt == AV_PIX_FMT_YUV420P || ctx->sw_pix_fmt == AV_PIX_FMT_YUVJ420P || ctx->sw_pix_fmt == AV_PIX_FMT_NV12)\n        return (D3DFORMAT)FOURCC_NV12;\n    else if (ctx->sw_pix_fmt == AV_PIX_FMT_YUV420P10 || ctx->sw_pix_fmt == AV_PIX_FMT_P010)\n        return (D3DFORMAT)FOURCC_P010;\n\n    ASSERT(ctx->sw_pix_fmt == AV_PIX_FMT_NONE);\n    return (D3DFORMAT)FOURCC_NV12;\n}\n\n\n////////////////////////////////////////////////////////////////////////////////\n// DXVA2 decoder implementation\n////////////////////////////////////////////////////////////////////////////////\n\nCDecDXVA2::CDecDXVA2(void)\n    : CDecAvcodec()\n{\n    ZeroMemory(&dx, sizeof(dx));\n    ZeroMemory(&m_pSurfaces, sizeof(m_pSurfaces));\n    ZeroMemory(&m_pRawSurface, sizeof(m_pRawSurface));\n    ZeroMemory(&m_FrameQueue, sizeof(m_FrameQueue));\n    ZeroMemory(&m_DXVAVideoDecoderConfig, sizeof(m_DXVAVideoDecoderConfig));\n}\n\nCDecDXVA2::~CDecDXVA2(void)\n{\n    DestroyDecoder(true);\n    if (m_pDXVA2Allocator)\n        m_pDXVA2Allocator->DecoderDestruct();\n}\n\nSTDMETHODIMP CDecDXVA2::DestroyDecoder(bool bFull, bool bNoAVCodec)\n{\n    for (int i = 0; i < DXVA2_QUEUE_SURFACES; i++)\n    {\n        ReleaseFrame(&m_FrameQueue[i]);\n    }\n\n    m_pCallback->ReleaseAllDXVAResources();\n    for (int i = 0; i < m_NumSurfaces; i++)\n    {\n        SafeRelease(&m_pSurfaces[i].d3d);\n    }\n    m_NumSurfaces = 0;\n\n    SafeRelease(&m_pDecoder);\n\n    if (!bNoAVCodec)\n    {\n        CDecAvcodec::DestroyDecoder();\n    }\n\n    if (bFull)\n    {\n        FreeD3DResources();\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::FreeD3DResources()\n{\n    SafeRelease(&m_pDXVADecoderService);\n    if (m_pD3DDevMngr && m_hDevice != INVALID_HANDLE_VALUE)\n        m_pD3DDevMngr->CloseDeviceHandle(m_hDevice);\n    m_hDevice = INVALID_HANDLE_VALUE;\n    SafeRelease(&m_pD3DDevMngr);\n    SafeRelease(&m_pD3DDev);\n    SafeRelease(&m_pD3D);\n\n    if (dx.d3dlib)\n    {\n        FreeLibrary(dx.d3dlib);\n        dx.d3dlib = nullptr;\n    }\n\n    if (dx.dxva2lib)\n    {\n        FreeLibrary(dx.dxva2lib);\n        dx.dxva2lib = nullptr;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::InitAllocator(IMemAllocator **ppAlloc)\n{\n    HRESULT hr = S_OK;\n    if (!m_bNative)\n        return E_NOTIMPL;\n\n    m_pDXVA2Allocator = new CDXVA2SurfaceAllocator(this, &hr);\n    if (!m_pDXVA2Allocator)\n    {\n        return E_OUTOFMEMORY;\n    }\n    if (FAILED(hr))\n    {\n        SAFE_DELETE(m_pDXVA2Allocator);\n        return hr;\n    }\n\n    return m_pDXVA2Allocator->QueryInterface(__uuidof(IMemAllocator), (void **)ppAlloc);\n}\n\nSTDMETHODIMP CDecDXVA2::PostConnect(IPin *pPin)\n{\n    HRESULT hr = S_OK;\n\n    if (!m_bNative && m_pD3DDevMngr)\n        return S_OK;\n\n    DbgLog((LOG_TRACE, 10, L\"CDecDXVA2::PostConnect()\"));\n\n    IMFGetService *pGetService = nullptr;\n    hr = pPin->QueryInterface(__uuidof(IMFGetService), (void **)&pGetService);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> IMFGetService not available\"));\n        goto done;\n    }\n\n    // Release old D3D resources, we're about to re-init\n    m_pCallback->ReleaseAllDXVAResources();\n    FreeD3DResources();\n\n    // Get the Direct3D device manager.\n    hr = pGetService->GetService(MR_VIDEO_ACCELERATION_SERVICE, __uuidof(IDirect3DDeviceManager9),\n                                 (void **)&m_pD3DDevMngr);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> D3D Device Manager not available\"));\n        goto done;\n    }\n\n    hr = SetD3DDeviceManager(m_pD3DDevMngr);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Setting D3D Device Manager failed\"));\n        goto done;\n    }\n\n    if (m_bNative)\n    {\n        if (!m_pDecoder)\n        {\n            // If this is the first call, re-align surfaces, as the requirements may only be known now\n            m_dwSurfaceWidth = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_width);\n            m_dwSurfaceHeight = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_height);\n        }\n\n        CMediaType mt = m_pCallback->GetOutputMediaType();\n        if ((m_eSurfaceFormat == FOURCC_NV12 && mt.subtype != MEDIASUBTYPE_NV12) ||\n            (m_eSurfaceFormat == FOURCC_P010 && mt.subtype != MEDIASUBTYPE_P010) ||\n            (m_eSurfaceFormat == FOURCC_P016 && mt.subtype != MEDIASUBTYPE_P016))\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Connection is not the appropriate pixel format for DXVA2 Native\"));\n            hr = E_FAIL;\n            goto done;\n        }\n        hr = DXVA2NotifyEVR();\n    }\n\ndone:\n    SafeRelease(&pGetService);\n    if (FAILED(hr))\n    {\n        FreeD3DResources();\n    }\n    return hr;\n}\n\nHRESULT CDecDXVA2::DXVA2NotifyEVR()\n{\n    HRESULT hr = S_OK;\n    IMFGetService *pGetService = nullptr;\n    IDirectXVideoMemoryConfiguration *pVideoConfig = nullptr;\n\n    hr = m_pCallback->GetOutputPin()->GetConnected()->QueryInterface(&pGetService);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> IMFGetService not available\"));\n        goto done;\n    }\n\n    // Configure EVR for receiving DXVA2 samples\n    hr = pGetService->GetService(MR_VIDEO_ACCELERATION_SERVICE, __uuidof(IDirectXVideoMemoryConfiguration),\n                                 (void **)&pVideoConfig);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> IDirectXVideoMemoryConfiguration not available\"));\n        goto done;\n    }\n\n    // Notify the EVR about the format we're sending\n    DXVA2_SurfaceType surfaceType;\n    for (DWORD iTypeIndex = 0;; iTypeIndex++)\n    {\n        hr = pVideoConfig->GetAvailableSurfaceTypeByIndex(iTypeIndex, &surfaceType);\n        if (FAILED(hr))\n        {\n            hr = S_OK;\n            break;\n        }\n\n        if (surfaceType == DXVA2_SurfaceType_DecoderRenderTarget)\n        {\n            hr = pVideoConfig->SetSurfaceType(DXVA2_SurfaceType_DecoderRenderTarget);\n            break;\n        }\n    }\ndone:\n    SafeRelease(&pGetService);\n    SafeRelease(&pVideoConfig);\n    return hr;\n}\n\nSTDMETHODIMP CDecDXVA2::LoadDXVA2Functions()\n{\n    // Load D3D9 library\n    dx.d3dlib = LoadLibrary(L\"d3d9.dll\");\n    if (dx.d3dlib == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Loading d3d9.dll failed\"));\n        return E_FAIL;\n    }\n\n    dx.direct3DCreate9Ex = (pDirect3DCreate9Ex *)GetProcAddress(dx.d3dlib, \"Direct3DCreate9Ex\");\n\n    // Load DXVA2 library\n    dx.dxva2lib = LoadLibrary(L\"dxva2.dll\");\n    if (dx.dxva2lib == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Loading dxva2.dll failed\"));\n        return E_FAIL;\n    }\n\n    dx.createDeviceManager = (pCreateDeviceManager9 *)GetProcAddress(dx.dxva2lib, \"DXVA2CreateDirect3DDeviceManager9\");\n    if (dx.createDeviceManager == nullptr)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> DXVA2CreateDirect3DDeviceManager9 unavailable\"));\n        return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nstatic const struct\n{\n    unsigned id;\n    char name[32];\n} vendors[] = {{VEND_ID_ATI, \"ATI\"}, {VEND_ID_NVIDIA, \"NVIDIA\"}, {VEND_ID_INTEL, \"Intel\"}, {0, \"\"}};\n\nHRESULT CDecDXVA2::CreateD3DDeviceManager(IDirect3DDevice9 *pDevice, UINT *pReset, IDirect3DDeviceManager9 **ppManager)\n{\n    UINT resetToken = 0;\n    IDirect3DDeviceManager9 *pD3DManager = nullptr;\n    HRESULT hr = dx.createDeviceManager(&resetToken, &pD3DManager);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> DXVA2CreateDirect3DDeviceManager9 failed\"));\n        goto done;\n    }\n\n    hr = pD3DManager->ResetDevice(pDevice, resetToken);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> ResetDevice failed\"));\n        goto done;\n    }\n\n    *ppManager = pD3DManager;\n    (*ppManager)->AddRef();\n\n    *pReset = resetToken;\ndone:\n    SafeRelease(&pD3DManager);\n    return hr;\n}\n\nHRESULT CDecDXVA2::CreateDXVAVideoService(IDirect3DDeviceManager9 *pManager, IDirectXVideoDecoderService **ppService)\n{\n    HRESULT hr = S_OK;\n\n    IDirectXVideoDecoderService *pService = nullptr;\n\n    hr = pManager->OpenDeviceHandle(&m_hDevice);\n    if (FAILED(hr))\n    {\n        m_hDevice = INVALID_HANDLE_VALUE;\n        DbgLog((LOG_ERROR, 10, L\"-> OpenDeviceHandle failed\"));\n        goto done;\n    }\n\n    hr = pManager->GetVideoService(m_hDevice, IID_IDirectXVideoDecoderService, (void **)&pService);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Acquiring VideoDecoderService failed\"));\n        goto done;\n    }\n\n    (*ppService) = pService;\n\ndone:\n    return hr;\n}\n\nHRESULT CDecDXVA2::FindVideoServiceConversion(AVCodecID codec, int profile, D3DFORMAT suggestedOutput, GUID *input, D3DFORMAT *output)\n{\n    HRESULT hr = S_OK;\n\n    UINT count = 0;\n    GUID *input_list = nullptr;\n\n    /* Gather the format supported by the decoder */\n    hr = m_pDXVADecoderService->GetDecoderDeviceGuids(&count, &input_list);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> GetDecoderDeviceGuids failed with hr: %X\", hr));\n        goto done;\n    }\n\n    DbgLog((LOG_TRACE, 10, L\"-> Enumerating supported DXVA2 modes (count: %d)\", count));\n    for (unsigned i = 0; i < count; i++)\n    {\n        const GUID *g = &input_list[i];\n        const dxva_mode_t *mode = get_dxva_mode_from_guid(g);\n        if (mode)\n        {\n            DbgLog((LOG_TRACE, 10, L\"  -> %S\", mode->name));\n        }\n        else\n        {\n            DbgLog((LOG_TRACE, 10, L\"  -> Unknown GUID (%s)\", WStringFromGUID(*g).c_str()));\n        }\n    }\n\n    /* Iterate over our priority list */\n    for (unsigned i = 0; dxva_modes[i].name; i++)\n    {\n        const dxva_mode_t *mode = &dxva_modes[i];\n        if (!check_dxva_mode_compatibility(mode, codec, profile, 0, (suggestedOutput == FOURCC_NV12)))\n            continue;\n\n        BOOL supported = FALSE;\n        for (const GUID *g = &input_list[0]; !supported && g < &input_list[count]; g++)\n        {\n            supported = IsEqualGUID(*mode->guid, *g);\n        }\n        if (!supported)\n            continue;\n\n        DbgLog((LOG_TRACE, 10, L\"-> Trying to use '%S'\", mode->name));\n        UINT out_count = 0;\n        D3DFORMAT *out_list = nullptr;\n        hr = m_pDXVADecoderService->GetDecoderRenderTargets(*mode->guid, &out_count, &out_list);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Retrieving render targets failed with hr: %X\", hr));\n            continue;\n        }\n\n        BOOL matchingFormat = FALSE;\n        D3DFORMAT format = D3DFMT_UNKNOWN;\n        DbgLog((LOG_TRACE, 10, L\"-> Enumerating render targets (count: %d)\", out_count));\n        for (unsigned j = 0; j < out_count; j++)\n        {\n            const D3DFORMAT f = out_list[j];\n            DbgLog((LOG_TRACE, 10, L\"  -> %d is supported (%4.4S)\", f, (const char *)&f));\n            if (suggestedOutput == f || (suggestedOutput == FOURCC_P010 && f == FOURCC_P016))\n            {\n                matchingFormat = TRUE;\n                format = f;\n            }\n        }\n        if (matchingFormat)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Found matching output format, finished setup with render target %d (%4.4S)\", format, (const char *)&format));\n            *input = *mode->guid;\n            *output = format;\n\n            SAFE_CO_FREE(out_list);\n            SAFE_CO_FREE(input_list);\n\n            return S_OK;\n        }\n\n        SAFE_CO_FREE(out_list);\n    }\n\ndone:\n    SAFE_CO_FREE(input_list);\n    return E_FAIL;\n}\n\nHRESULT CDecDXVA2::InitD3DAdapterIdentifier(UINT lAdapter)\n{\n    ASSERT(m_pD3D);\n\n    D3DADAPTER_IDENTIFIER9 d3dai = {0};\n    HRESULT hr = m_pD3D->GetAdapterIdentifier(lAdapter, 0, &d3dai);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Querying of adapter identifier %d failed with hr: %X\", lAdapter, hr));\n        return E_FAIL;\n    }\n\n    const char *vendor = \"Unknown\";\n    for (int i = 0; vendors[i].id != 0; i++)\n    {\n        if (vendors[i].id == d3dai.VendorId)\n        {\n            vendor = vendors[i].name;\n            break;\n        }\n    }\n\n    DbgLog((LOG_TRACE, 10, L\"-> Running on adapter %d, %S, vendor 0x%04X(%S), device 0x%04X\", lAdapter,\n            d3dai.Description, d3dai.VendorId, vendor, d3dai.DeviceId));\n    m_dwVendorId = d3dai.VendorId;\n    m_dwDeviceId = d3dai.DeviceId;\n\n    return S_OK;\n}\n\n/**\n * This function is only called in non-native mode\n * Its responsibility is to initialize D3D, create a device and a device manager\n * and call SetD3DDeviceManager with it.\n */\nHRESULT CDecDXVA2::InitD3D(UINT lAdapter)\n{\n    HRESULT hr = S_OK;\n\n    m_pD3D = Direct3DCreate9(D3D_SDK_VERSION);\n    if (!m_pD3D)\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Failed to acquire IDirect3D9\"));\n        return E_FAIL;\n    }\n\n    // populate the adapter identifier values\n    hr = InitD3DAdapterIdentifier(lAdapter);\n\n    // if the requested adapter failed, try again\n    if (FAILED(hr) && lAdapter != D3DADAPTER_DEFAULT)\n    {\n        lAdapter = D3DADAPTER_DEFAULT;\n        hr = InitD3DAdapterIdentifier(lAdapter);\n    }\n\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    D3DPRESENT_PARAMETERS d3dpp = {0};\n    D3DDISPLAYMODE d3ddm = {0};\n\n    m_pD3D->GetAdapterDisplayMode(lAdapter, &d3ddm);\n\n    d3dpp.Windowed = TRUE;\n    d3dpp.BackBufferWidth = 640;\n    d3dpp.BackBufferHeight = 480;\n    d3dpp.BackBufferCount = 0;\n    d3dpp.BackBufferFormat = d3ddm.Format;\n    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;\n    d3dpp.Flags = D3DPRESENTFLAG_VIDEO;\n\n    hr = m_pD3D->CreateDevice(lAdapter, D3DDEVTYPE_HAL, GetShellWindow(),\n                              D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,\n                              &d3dpp, &m_pD3DDev);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Creation of device failed with hr: %X\", hr));\n        return E_FAIL;\n    }\n\n    return S_OK;\n}\n\nHRESULT CDecDXVA2::InitD3DEx(UINT lAdapter)\n{\n    HRESULT hr = S_OK;\n\n    if (dx.direct3DCreate9Ex == nullptr)\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Direct3DCreate9Ex not available\"));\n        return E_NOINTERFACE;\n    }\n\n    IDirect3D9Ex *pD3D9Ex = nullptr;\n    hr = dx.direct3DCreate9Ex(D3D_SDK_VERSION, &pD3D9Ex);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"-> Failed to acquire IDirect3D9Ex\"));\n        return E_NOINTERFACE;\n    }\n    m_pD3D = dynamic_cast<IDirect3D9 *>(pD3D9Ex);\n\n    // populate the adapter identifier values\n    hr = InitD3DAdapterIdentifier(lAdapter);\n\n    // if the requested adapter failed, try again\n    if (FAILED(hr) && lAdapter != D3DADAPTER_DEFAULT)\n    {\n        lAdapter = D3DADAPTER_DEFAULT;\n        hr = InitD3DAdapterIdentifier(lAdapter);\n    }\n\n    if (FAILED(hr))\n    {\n        SafeRelease(&m_pD3D);\n        return hr;\n    }\n\n    D3DPRESENT_PARAMETERS d3dpp = {0};\n    D3DDISPLAYMODEEX d3ddm = {0};\n    d3ddm.Size = sizeof(D3DDISPLAYMODEEX);\n\n    pD3D9Ex->GetAdapterDisplayModeEx(lAdapter, &d3ddm, NULL);\n\n    d3dpp.Windowed = TRUE;\n    d3dpp.BackBufferWidth = 640;\n    d3dpp.BackBufferHeight = 480;\n    d3dpp.BackBufferCount = 0;\n    d3dpp.BackBufferFormat = d3ddm.Format;\n    d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;\n    d3dpp.Flags = D3DPRESENTFLAG_VIDEO;\n\n    IDirect3DDevice9Ex *pD3D9DeviceEx = nullptr;\n    hr = pD3D9Ex->CreateDeviceEx(lAdapter, D3DDEVTYPE_HAL, GetShellWindow(),\n                                 D3DCREATE_SOFTWARE_VERTEXPROCESSING | D3DCREATE_MULTITHREADED | D3DCREATE_FPU_PRESERVE,\n                                 &d3dpp, NULL, &pD3D9DeviceEx);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Creation of device failed with hr: %X\", hr));\n        SafeRelease(&m_pD3D);\n        return E_FAIL;\n    }\n    m_pD3DDev = dynamic_cast<IDirect3DDevice9 *>(pD3D9DeviceEx);\n\n    return S_OK;\n}\n\nHRESULT CDecDXVA2::RetrieveVendorId(IDirect3DDeviceManager9 *pDevManager)\n{\n    HANDLE hDevice = 0;\n    IDirect3D9 *pD3D = nullptr;\n    IDirect3DDevice9 *pDevice = nullptr;\n\n    HRESULT hr = pDevManager->OpenDeviceHandle(&hDevice);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to open device handle with hr: %X\", hr));\n        goto done;\n    }\n\n    hr = pDevManager->LockDevice(hDevice, &pDevice, TRUE);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to lock device with hr: %X\", hr));\n        goto done;\n    }\n\n    hr = pDevice->GetDirect3D(&pD3D);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to get D3D object hr: %X\", hr));\n        goto done;\n    }\n\n    D3DDEVICE_CREATION_PARAMETERS devParams;\n    hr = pDevice->GetCreationParameters(&devParams);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to get device creation params hr: %X\", hr));\n        goto done;\n    }\n\n    D3DADAPTER_IDENTIFIER9 adIdentifier;\n    hr = pD3D->GetAdapterIdentifier(devParams.AdapterOrdinal, 0, &adIdentifier);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to get adapter identified hr: %X\", hr));\n        goto done;\n    }\n\n    m_dwVendorId = adIdentifier.VendorId;\n    m_dwDeviceId = adIdentifier.DeviceId;\n    memcpy(m_cDeviceName, adIdentifier.Description, sizeof(m_cDeviceName));\n\ndone:\n    SafeRelease(&pD3D);\n    SafeRelease(&pDevice);\n    if (hDevice && hDevice != INVALID_HANDLE_VALUE)\n    {\n        pDevManager->UnlockDevice(hDevice, FALSE);\n        pDevManager->CloseDeviceHandle(hDevice);\n    }\n    return hr;\n}\n\nHRESULT CDecDXVA2::CheckHWCompatConditions(GUID decoderGuid)\n{\n    if (m_dwSurfaceWidth == 0 || m_dwSurfaceHeight == 0)\n        return E_UNEXPECTED;\n\n    int width_mbs = m_dwSurfaceWidth / 16;\n    int height_mbs = m_dwSurfaceHeight / 16;\n    int max_ref_frames_dpb41 = min(11, 32768 / (width_mbs * height_mbs));\n    if (m_dwVendorId == VEND_ID_ATI)\n    {\n        if (IsAMDUVD(m_dwDeviceId))\n        {\n            if (m_pAVCtx->codec_id == AV_CODEC_ID_H264 && m_pAVCtx->refs > max_ref_frames_dpb41)\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> Too many reference frames for AMD UVD/UVD+ H.264 decoder\"));\n                return E_FAIL;\n            }\n            else if ((m_pAVCtx->codec_id == AV_CODEC_ID_VC1 || m_pAVCtx->codec_id == AV_CODEC_ID_MPEG2VIDEO) &&\n                     (m_dwSurfaceWidth > 1920 || m_dwSurfaceHeight > 1200))\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> VC-1 Resolutions above FullHD are not supported by the UVD/UVD+ decoder\"));\n                return E_FAIL;\n            }\n            else if (m_pAVCtx->codec_id == AV_CODEC_ID_WMV3)\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> AMD UVD/UVD+ is currently not compatible with WMV3\"));\n                return E_FAIL;\n            }\n        }\n    }\n    else if (m_dwVendorId == VEND_ID_INTEL)\n    {\n        if (decoderGuid == DXVADDI_Intel_ModeH264_E && m_pAVCtx->codec_id == AV_CODEC_ID_H264 &&\n            m_pAVCtx->refs > max_ref_frames_dpb41)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Too many reference frames for Intel H.264 decoder implementation\"));\n            return E_FAIL;\n        }\n    }\n    return S_OK;\n}\n\n/**\n * Called from both native and non-native mode\n * Initialize all the common DXVA2 interfaces and device handles\n */\nHRESULT CDecDXVA2::SetD3DDeviceManager(IDirect3DDeviceManager9 *pDevManager)\n{\n    HRESULT hr = S_OK;\n    ASSERT(pDevManager);\n\n    m_pD3DDevMngr = pDevManager;\n\n    RetrieveVendorId(pDevManager);\n\n    // This should really be null here, but since we're overwriting it, make sure its actually released\n    SafeRelease(&m_pDXVADecoderService);\n\n    hr = CreateDXVAVideoService(m_pD3DDevMngr, &m_pDXVADecoderService);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Creation of DXVA2 Decoder Service failed with hr: %X\", hr));\n        goto done;\n    }\n\n    // If the decoder was initialized already, check if we can use this device\n    if (m_pAVCtx)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Checking hardware for format support...\"));\n\n        GUID input = GUID_NULL;\n        D3DFORMAT output;\n        hr = FindVideoServiceConversion(m_pAVCtx->codec_id, m_pAVCtx->profile, get_dxva_surface_format(m_pAVCtx), &input, &output);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> No decoder device available that can decode codec '%S' to a matching output\",\n                    avcodec_get_name(m_pAVCtx->codec_id)));\n            goto done;\n        }\n\n        m_eSurfaceFormat = output;\n\n        if (FAILED(CheckHWCompatConditions(input)))\n        {\n            hr = E_FAIL;\n            goto done;\n        }\n\n        DXVA2_VideoDesc desc;\n        ZeroMemory(&desc, sizeof(desc));\n        desc.SampleWidth = m_dwSurfaceWidth;\n        desc.SampleHeight = m_dwSurfaceHeight;\n        desc.Format = output;\n\n        DXVA2_ConfigPictureDecode config;\n        hr = FindDecoderConfiguration(input, &desc, &config);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> No decoder configuration available for codec '%S'\",\n                    avcodec_get_name(m_pAVCtx->codec_id)));\n            goto done;\n        }\n\n        LPDIRECT3DSURFACE9 pSurfaces[DXVA2_MAX_SURFACES] = {0};\n        UINT numSurfaces = max(config.ConfigMinRenderTargetBuffCount, 1);\n        hr = m_pDXVADecoderService->CreateSurface(m_dwSurfaceWidth, m_dwSurfaceHeight, numSurfaces, output,\n                                                  D3DPOOL_DEFAULT, 0, DXVA2_VideoDecoderRenderTarget, pSurfaces,\n                                                  nullptr);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Creation of surfaces failed with hr: %X\", hr));\n            goto done;\n        }\n\n        IDirectXVideoDecoder *decoder = nullptr;\n        hr = m_pDXVADecoderService->CreateVideoDecoder(input, &desc, &config, pSurfaces, numSurfaces, &decoder);\n\n        // Release resources, decoder and surfaces\n        SafeRelease(&decoder);\n        int i = DXVA2_MAX_SURFACES;\n        while (i > 0)\n        {\n            SafeRelease(&pSurfaces[--i]);\n        }\n\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Creation of decoder failed with hr: %X\", hr));\n            goto done;\n        }\n    }\n\ndone:\n    return hr;\n}\n\n// ILAVDecoder\nSTDMETHODIMP CDecDXVA2::Init()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecDXVA2::Init(): Trying to open DXVA2 decoder\"));\n    HRESULT hr = S_OK;\n\n    // Initialize all D3D interfaces in non-native mode\n    if (!m_bNative)\n    {\n        // load DLLs and functions\n        if (FAILED(hr = LoadDXVA2Functions()))\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Failed to load DXVA2 DLL functions\"));\n            return E_FAIL;\n        }\n\n        // determin the adapter the user requested\n        UINT lAdapter = m_pSettings->GetHWAccelDeviceIndex(HWAccel_DXVA2CopyBack, nullptr);\n        if (lAdapter == LAVHWACCEL_DEVICE_DEFAULT)\n            lAdapter = D3DADAPTER_DEFAULT;\n\n        DWORD dwDeviceIndex = m_pCallback->GetGPUDeviceIndex();\n        if (dwDeviceIndex != DWORD_MAX)\n        {\n            lAdapter = (UINT)dwDeviceIndex;\n        }\n\n        // initialize D3D\n        hr = InitD3DEx(lAdapter);\n        if (hr == E_NOINTERFACE)\n        {\n            // D3D9Ex failed, try plain D3D\n            hr = InitD3D(lAdapter);\n        }\n\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> D3D Initialization failed with hr: %X\", hr));\n            return hr;\n        }\n\n        // create device manager for the device\n        hr = CreateD3DDeviceManager(m_pD3DDev, &m_pD3DResetToken, &m_pD3DDevMngr);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Creation of Device manager failed with hr: %X\", hr));\n            return E_FAIL;\n        }\n\n        // set it as the active device manager\n        hr = SetD3DDeviceManager(m_pD3DDevMngr);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> SetD3DDeviceManager failed with hr: %X\", hr));\n            return E_FAIL;\n        }\n    }\n\n    // Init the ffmpeg parts\n    // This is our main software decoder, unable to fail!\n    CDecAvcodec::Init();\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)\n{\n    HRESULT hr = S_OK;\n    DbgLog((LOG_TRACE, 10, L\"CDecDXVA2::InitDecoder(): Initializing DXVA2 decoder\"));\n\n    // Hack-ish check to avoid re-creating the full decoder when only the aspect ratio changes.\n    // Re-creating the DXVA2 decoder can lead to issues like missing frames or a several second delay\n    if (m_pDecoder)\n    {\n        CMediaType mediaTypeCheck = m_MediaType;\n        if (mediaTypeCheck.formattype == FORMAT_VideoInfo2 && pmt->formattype == FORMAT_VideoInfo2)\n        {\n            VIDEOINFOHEADER2 *vih2Old = (VIDEOINFOHEADER2 *)mediaTypeCheck.Format();\n            VIDEOINFOHEADER2 *vih2New = (VIDEOINFOHEADER2 *)pmt->Format();\n\n            vih2Old->dwPictAspectRatioX = vih2New->dwPictAspectRatioX;\n            vih2Old->dwPictAspectRatioY = vih2New->dwPictAspectRatioY;\n\n            if (mediaTypeCheck == *pmt)\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> Skipping re-init because media type is unchanged.\"));\n                m_MediaType = *pmt;\n\n                // flush the decoder so we can resume decoding properly (before a re-init, EndOfStream would be called,\n                // making this necessary)\n                avcodec_flush_buffers(m_pAVCtx);\n                return S_OK;\n            }\n        }\n    }\n\n    DestroyDecoder(false);\n\n    m_DisplayDelay = DXVA2_QUEUE_SURFACES;\n\n    // Intel GPUs don't like the display and performance goes way down, so disable it.\n    if (m_dwVendorId == VEND_ID_INTEL)\n        m_DisplayDelay = 0;\n\n    // Reduce display delay for DVD decoding for lower decode latency\n    if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD)\n        m_DisplayDelay /= 2;\n\n    m_bFailHWDecode = FALSE;\n\n    DbgLog((LOG_TRACE, 10, L\"-> Creation of DXVA2 decoder successful, initializing ffmpeg\"));\n    hr = CDecAvcodec::InitDecoder(codec, pmt, pSideData);\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    if (check_dxva_codec_profile(m_pAVCtx, AV_PIX_FMT_DXVA2_VLD))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Incompatible profile detected, falling back to software decoding\"));\n        return E_FAIL;\n    }\n\n    // If we have a DXVA Decoder, check if its capable\n    // If we don't have one yet, it may be handed to us later, and compat is checked at that point\n    GUID input = GUID_NULL;\n    D3DFORMAT output = D3DFMT_UNKNOWN;\n    if (m_pDXVADecoderService)\n    {\n        hr = FindVideoServiceConversion(codec, m_pAVCtx->profile, get_dxva_surface_format(m_pAVCtx), &input, &output);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> No decoder device available that can decode codec '%S' to a matching output\",\n                    avcodec_get_name(codec)));\n            return E_FAIL;\n        }\n    }\n    else\n    {\n        output = get_dxva_surface_format(m_pAVCtx);\n    }\n\n    m_dwSurfaceWidth = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_width);\n    m_dwSurfaceHeight = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_height);\n    m_eSurfaceFormat = output;\n    m_DecoderPixelFormat = m_pAVCtx->sw_pix_fmt;\n\n    if (FAILED(CheckHWCompatConditions(input)))\n    {\n        return E_FAIL;\n    }\n\n    m_MediaType = *pmt;\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(long) CDecDXVA2::GetBufferCount(long *pMaxBuffers)\n{\n    long buffers = 0;\n\n    // Native decoding should use 16 buffers to enable seamless codec changes\n    if (m_bNative)\n        buffers = 16;\n    else\n    {\n        // Buffers based on max ref frames\n        if (m_nCodecId == AV_CODEC_ID_H264 || m_nCodecId == AV_CODEC_ID_HEVC)\n            buffers = 16;\n        else if (m_nCodecId == AV_CODEC_ID_VP9 || m_nCodecId == AV_CODEC_ID_AV1)\n            buffers = 8;\n        else\n            buffers = 2;\n    }\n\n    // 4 extra buffers for handling and safety\n    buffers += 4;\n\n    if (!m_bNative)\n    {\n        buffers += m_DisplayDelay;\n    }\n    if (m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_DVD)\n    {\n        buffers += 4;\n    }\n\n    if (pMaxBuffers)\n    {\n        // cap at 127, because it needs to fit into the 7-bit DXVA structs\n        *pMaxBuffers = 127;\n\n        // VC-1 and VP9 decoding has stricter requirements (decoding flickers otherwise)\n        if (m_nCodecId == AV_CODEC_ID_VC1 || m_nCodecId == AV_CODEC_ID_VP9 || m_nCodecId == AV_CODEC_ID_AV1)\n            *pMaxBuffers = 32;\n    }\n\n    return buffers;\n}\n\nHRESULT CDecDXVA2::FindDecoderConfiguration(const GUID &input, const DXVA2_VideoDesc *pDesc,\n                                            DXVA2_ConfigPictureDecode *pConfig)\n{\n    CheckPointer(pConfig, E_INVALIDARG);\n    CheckPointer(pDesc, E_INVALIDARG);\n    HRESULT hr = S_OK;\n    UINT cfg_count = 0;\n    DXVA2_ConfigPictureDecode *cfg_list = nullptr;\n    hr = m_pDXVADecoderService->GetDecoderConfigurations(input, pDesc, nullptr, &cfg_count, &cfg_list);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> GetDecoderConfigurations failed with hr: %X\", hr));\n        return E_FAIL;\n    }\n\n    DbgLog((LOG_TRACE, 10, L\"-> We got %d decoder configurations\", cfg_count));\n    int best_score = -1;\n    DXVA2_ConfigPictureDecode best_cfg;\n    for (unsigned i = 0; i < cfg_count; i++)\n    {\n        DXVA2_ConfigPictureDecode *cfg = &cfg_list[i];\n\n        DbgLog((LOG_ERROR, 10, \"-> Configuration Record %d: ConfigBitstreamRaw = %d\", i, cfg->ConfigBitstreamRaw));\n\n        int score;\n        if (cfg->ConfigBitstreamRaw == 1)\n            score = 1;\n        else if (m_pAVCtx->codec_id == AV_CODEC_ID_H264 && cfg->ConfigBitstreamRaw == 2)\n            score = 2;\n        else if (m_pAVCtx->codec_id == AV_CODEC_ID_VP9) // hack for broken AMD drivers\n            score = 0;\n        else\n            continue;\n        if (IsEqualGUID(cfg->guidConfigBitstreamEncryption, DXVA2_NoEncrypt))\n            score += 16;\n        if (score > best_score)\n        {\n            best_score = score;\n            best_cfg = *cfg;\n        }\n    }\n    SAFE_CO_FREE(cfg_list);\n    if (best_score < 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> No matching configuration available\"));\n        return E_FAIL;\n    }\n\n    *pConfig = best_cfg;\n    return S_OK;\n}\n\nHRESULT CDecDXVA2::CreateDXVA2Decoder(int nSurfaces, IDirect3DSurface9 **ppSurfaces)\n{\n    DbgLog((LOG_TRACE, 10, L\"-> CDecDXVA2::CreateDXVA2Decoder\"));\n    HRESULT hr = S_OK;\n    LPDIRECT3DSURFACE9 pSurfaces[DXVA2_MAX_SURFACES];\n\n    if (!m_pDXVADecoderService)\n        return E_FAIL;\n\n    DestroyDecoder(false, true);\n\n    GUID input = GUID_NULL;\n    D3DFORMAT output;\n    FindVideoServiceConversion(m_pAVCtx->codec_id, m_pAVCtx->profile, get_dxva_surface_format(m_pAVCtx),&input, &output);\n\n    if (!nSurfaces)\n    {\n        m_dwSurfaceWidth = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_width);\n        m_dwSurfaceHeight = dxva_align_dimensions(m_pAVCtx->codec_id, m_pAVCtx->coded_height);\n        m_eSurfaceFormat = output;\n        m_DecoderPixelFormat = m_pAVCtx->sw_pix_fmt;\n\n        m_NumSurfaces = GetBufferCount();\n        hr = m_pDXVADecoderService->CreateSurface(m_dwSurfaceWidth, m_dwSurfaceHeight, m_NumSurfaces - 1, output,\n                                                  D3DPOOL_DEFAULT, 0, DXVA2_VideoDecoderRenderTarget, pSurfaces,\n                                                  nullptr);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Creation of surfaces failed with hr: %X\", hr));\n            m_NumSurfaces = 0;\n            return E_FAIL;\n        }\n        ppSurfaces = pSurfaces;\n    }\n    else\n    {\n        m_NumSurfaces = nSurfaces;\n        for (int i = 0; i < m_NumSurfaces; i++)\n        {\n            ppSurfaces[i]->AddRef();\n        }\n    }\n\n    if (m_NumSurfaces <= 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> No surfaces? No good!\"));\n        return E_FAIL;\n    }\n\n    // get the device, for ColorFill() to init the surfaces in black\n    IDirect3DDevice9 *pDev = nullptr;\n    ppSurfaces[0]->GetDevice(&pDev);\n\n    for (int i = 0; i < m_NumSurfaces; i++)\n    {\n        m_pSurfaces[i].index = i;\n        m_pSurfaces[i].d3d = ppSurfaces[i];\n        m_pSurfaces[i].age = UINT64_MAX;\n        m_pSurfaces[i].used = false;\n\n        // fill the surface in black, to avoid the \"green screen\" in case the first frame fails to decode.\n        if (pDev)\n            pDev->ColorFill(ppSurfaces[i], NULL, D3DCOLOR_XYUV(0, 128, 128));\n    }\n\n    // and done with the device\n    SafeRelease(&pDev);\n\n    DbgLog((LOG_TRACE, 10, L\"-> Successfully created %d surfaces (%dx%d)\", m_NumSurfaces, m_dwSurfaceWidth,\n            m_dwSurfaceHeight));\n\n    DXVA2_VideoDesc desc;\n    ZeroMemory(&desc, sizeof(desc));\n    desc.SampleWidth = m_dwSurfaceWidth;\n    desc.SampleHeight = m_dwSurfaceHeight;\n    desc.Format = output;\n\n    hr = FindDecoderConfiguration(input, &desc, &m_DXVAVideoDecoderConfig);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> FindDecoderConfiguration failed with hr: %X\", hr));\n        return hr;\n    }\n\n    IDirectXVideoDecoder *decoder = nullptr;\n    hr = m_pDXVADecoderService->CreateVideoDecoder(input, &desc, &m_DXVAVideoDecoderConfig, ppSurfaces, m_NumSurfaces,\n                                                   &decoder);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> CreateVideoDecoder failed with hr: %X\", hr));\n        return E_FAIL;\n    }\n    m_pDecoder = decoder;\n    m_guidDecoderDevice = input;\n\n    /* fill hwaccel_context */\n    FillHWContext((dxva_context *)m_pAVCtx->hwaccel_context);\n\n    memset(m_pRawSurface, 0, sizeof(m_pRawSurface));\n    for (int i = 0; i < m_NumSurfaces; i++)\n    {\n        m_pRawSurface[i] = m_pSurfaces[i].d3d;\n    }\n\n    return S_OK;\n}\n\nHRESULT CDecDXVA2::FillHWContext(dxva_context *ctx)\n{\n    ctx->cfg = &m_DXVAVideoDecoderConfig;\n    ctx->decoder = m_pDecoder;\n    ctx->surface = m_pRawSurface;\n    ctx->surface_count = m_NumSurfaces;\n\n    if (m_dwVendorId == VEND_ID_INTEL && m_guidDecoderDevice == DXVADDI_Intel_ModeH264_E)\n        ctx->workaround = FF_DXVA2_WORKAROUND_INTEL_CLEARVIDEO;\n    else if (m_dwVendorId == VEND_ID_ATI && IsAMDUVD(m_dwDeviceId))\n        ctx->workaround = FF_DXVA2_WORKAROUND_SCALING_LIST_ZIGZAG;\n    else\n        ctx->workaround = 0;\n\n    return S_OK;\n}\n\nenum AVPixelFormat CDecDXVA2::get_dxva2_format(struct AVCodecContext *c, const enum AVPixelFormat *pix_fmts)\n{\n    CDecDXVA2 *pDec = (CDecDXVA2 *)c->opaque;\n    const enum AVPixelFormat *p;\n    for (p = pix_fmts; *p != -1; p++)\n    {\n        const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(*p);\n\n        if (!desc || !(desc->flags & AV_PIX_FMT_FLAG_HWACCEL))\n            break;\n\n        if (*p == AV_PIX_FMT_DXVA2_VLD)\n        {\n            HRESULT hr = pDec->ReInitDXVA2Decoder(c);\n            if (FAILED(hr))\n            {\n                pDec->m_bFailHWDecode = TRUE;\n                continue;\n            }\n            else\n            {\n                break;\n            }\n        }\n    }\n    return *p;\n}\n\ntypedef struct SurfaceWrapper\n{\n    LPDIRECT3DSURFACE9 surface;\n    IMediaSample *sample;\n    CDecDXVA2 *pDec;\n    IDirectXVideoDecoder *pDXDecoder;\n} SurfaceWrapper;\n\nvoid CDecDXVA2::free_dxva2_buffer(void *opaque, uint8_t *data)\n{\n    SurfaceWrapper *sw = (SurfaceWrapper *)opaque;\n    CDecDXVA2 *pDec = sw->pDec;\n\n    LPDIRECT3DSURFACE9 pSurface = sw->surface;\n    for (int i = 0; i < pDec->m_NumSurfaces; i++)\n    {\n        if (pDec->m_pSurfaces[i].d3d == pSurface)\n        {\n            pDec->m_pSurfaces[i].used = false;\n            break;\n        }\n    }\n    SafeRelease(&pSurface);\n    SafeRelease(&sw->pDXDecoder);\n    SafeRelease(&sw->sample);\n    delete sw;\n}\n\nHRESULT CDecDXVA2::ReInitDXVA2Decoder(AVCodecContext *c)\n{\n    HRESULT hr = S_OK;\n\n    // Don't allow decoder creation during first init\n    if (m_bInInit)\n        return S_FALSE;\n\n    if (!m_pDecoder || dxva_align_dimensions(c->codec_id, c->coded_width) != m_dwSurfaceWidth ||\n        dxva_align_dimensions(c->codec_id, c->coded_height) != m_dwSurfaceHeight ||\n        m_DecoderPixelFormat != c->sw_pix_fmt)\n    {\n        DbgLog((LOG_TRACE, 10, L\"No DXVA2 Decoder or image dimensions changed -> Re-Allocating resources\"));\n        if (!m_pDecoder && m_bNative && !m_pDXVA2Allocator)\n        {\n            ASSERT(0);\n            hr = E_FAIL;\n        }\n        else if (m_bNative)\n        {\n            // shortcut to update only the Decoder Pixel Format if needed\n            if (m_pDecoder && m_DecoderPixelFormat == AV_PIX_FMT_NONE && m_DecoderPixelFormat != c->sw_pix_fmt)\n            {\n                GUID input;\n                D3DFORMAT output;\n                FindVideoServiceConversion(c->codec_id, c->profile, get_dxva_surface_format(m_pAVCtx), &input, &output);\n\n                if (output == m_eSurfaceFormat)\n                {\n                    m_DecoderPixelFormat = c->sw_pix_fmt;\n                    return ReInitDXVA2Decoder(c);\n                }\n            }\n\n            avcodec_flush_buffers(c);\n\n            m_dwSurfaceWidth = dxva_align_dimensions(c->codec_id, c->coded_width);\n            m_dwSurfaceHeight = dxva_align_dimensions(c->codec_id, c->coded_height);\n            m_DecoderPixelFormat = c->sw_pix_fmt;\n\n            GUID input;\n            FindVideoServiceConversion(c->codec_id, c->profile, get_dxva_surface_format(m_pAVCtx), &input, &m_eSurfaceFormat);\n\n            // Re-Commit the allocator (creates surfaces and new decoder)\n            hr = m_pDXVA2Allocator->Decommit();\n            if (m_pDXVA2Allocator->DecommitInProgress())\n            {\n                DbgLog((LOG_TRACE, 10, L\"WARNING! DXVA2 Allocator is still busy, trying to flush downstream\"));\n                m_pCallback->ReleaseAllDXVAResources();\n                m_pCallback->GetOutputPin()->GetConnected()->BeginFlush();\n                m_pCallback->GetOutputPin()->GetConnected()->EndFlush();\n                if (m_pDXVA2Allocator->DecommitInProgress())\n                {\n                    DbgLog(\n                        (LOG_TRACE, 10, L\"WARNING! Flush had no effect, decommit of the allocator still not complete\"));\n                }\n                else\n                {\n                    DbgLog((LOG_TRACE, 10, L\"Flush was successful, decommit completed!\"));\n                }\n            }\n            hr = m_pDXVA2Allocator->Commit();\n        }\n        else if (!m_bNative)\n        {\n            FlushDisplayQueue(TRUE);\n            hr = CreateDXVA2Decoder();\n        }\n    }\n\n    return hr;\n}\n\nint CDecDXVA2::get_dxva2_buffer(struct AVCodecContext *c, AVFrame *pic, int flags)\n{\n    CDecDXVA2 *pDec = (CDecDXVA2 *)c->opaque;\n    IMediaSample *pSample = nullptr;\n\n    HRESULT hr = S_OK;\n\n    if (pic->format != AV_PIX_FMT_DXVA2_VLD || (c->codec_id == AV_CODEC_ID_H264 && !H264_CHECK_PROFILE(c->profile)) ||\n        (c->codec_id == AV_CODEC_ID_HEVC && !HEVC_CHECK_PROFILE(c->profile)) ||\n        (c->codec_id == AV_CODEC_ID_VP9 && !VP9_CHECK_PROFILE(c->profile)))\n    {\n        DbgLog((LOG_ERROR, 10, L\"DXVA2 buffer request, but not dxva2 pixfmt or unsupported profile\"));\n        pDec->m_bFailHWDecode = TRUE;\n        return -1;\n    }\n\n    hr = pDec->ReInitDXVA2Decoder(c);\n    if (FAILED(hr))\n    {\n        pDec->m_bFailHWDecode = TRUE;\n        return -1;\n    }\n\n    if (FAILED(pDec->m_pD3DDevMngr->TestDevice(pDec->m_hDevice)))\n    {\n        DbgLog((LOG_ERROR, 10, L\"Device Lost\"));\n    }\n\n    int i;\n    if (pDec->m_bNative)\n    {\n        if (!pDec->m_pDXVA2Allocator)\n            return -1;\n\n        hr = pDec->m_pDXVA2Allocator->GetBuffer(&pSample, nullptr, nullptr, 0);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"DXVA2Allocator returned error, hr: 0x%x\", hr));\n            return -1;\n        }\n\n        ILAVDXVA2Sample *pLavDXVA2 = nullptr;\n        hr = pSample->QueryInterface(&pLavDXVA2);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"Sample is no LAV DXVA2 sample?????\"));\n            SafeRelease(&pSample);\n            return -1;\n        }\n        i = pLavDXVA2->GetDXSurfaceId();\n        SafeRelease(&pLavDXVA2);\n    }\n    else\n    {\n        int old, old_unused;\n        for (i = 0, old = 0, old_unused = -1; i < pDec->m_NumSurfaces; i++)\n        {\n            d3d_surface_t *surface = &pDec->m_pSurfaces[i];\n            if (!surface->used && (old_unused == -1 || surface->age < pDec->m_pSurfaces[old_unused].age))\n                old_unused = i;\n            if (surface->age < pDec->m_pSurfaces[old].age)\n                old = i;\n        }\n        if (old_unused == -1)\n        {\n            DbgLog((LOG_TRACE, 10, L\"No free surface, using oldest\"));\n            i = old;\n        }\n        else\n        {\n            i = old_unused;\n        }\n    }\n\n    LPDIRECT3DSURFACE9 pSurface = pDec->m_pSurfaces[i].d3d;\n    if (!pSurface)\n    {\n        DbgLog((LOG_ERROR, 10, L\"There is a sample, but no D3D Surace? WTF?\"));\n        SafeRelease(&pSample);\n        return -1;\n    }\n\n    pDec->m_pSurfaces[i].age = pDec->m_CurrentSurfaceAge++;\n    pDec->m_pSurfaces[i].used = true;\n\n    memset(pic->data, 0, sizeof(pic->data));\n    memset(pic->linesize, 0, sizeof(pic->linesize));\n    memset(pic->buf, 0, sizeof(pic->buf));\n\n    pic->data[0] = pic->data[3] = (uint8_t *)pSurface;\n    pic->data[4] = (uint8_t *)pSample;\n\n    SurfaceWrapper *surfaceWrapper = new SurfaceWrapper();\n    surfaceWrapper->pDec = pDec;\n    surfaceWrapper->sample = pSample;\n    surfaceWrapper->surface = pSurface;\n    surfaceWrapper->surface->AddRef();\n    surfaceWrapper->pDXDecoder = pDec->m_pDecoder;\n    surfaceWrapper->pDXDecoder->AddRef();\n\n    pic->buf[0] = av_buffer_create(nullptr, 0, free_dxva2_buffer, surfaceWrapper, 0);\n\n    return 0;\n}\n\nHRESULT CDecDXVA2::AdditionaDecoderInit()\n{\n    /* Create ffmpeg dxva_context, but only fill it if we have a decoder already. */\n    dxva_context *ctx = (dxva_context *)av_mallocz(sizeof(dxva_context));\n\n    if (m_pDecoder)\n    {\n        FillHWContext(ctx);\n    }\n\n    m_pAVCtx->thread_count = 1;\n    m_pAVCtx->thread_type = 0;\n    m_pAVCtx->hwaccel_context = ctx;\n    m_pAVCtx->get_format = get_dxva2_format;\n    m_pAVCtx->get_buffer2 = get_dxva2_buffer;\n    m_pAVCtx->opaque = this;\n\n    m_pAVCtx->slice_flags |= SLICE_FLAG_ALLOW_FIELD;\n\n    // disable error conealment in hwaccel mode, it doesn't work either way\n    m_pAVCtx->error_concealment = 0;\n    av_opt_set_int(m_pAVCtx, \"enable_er\", 0, AV_OPT_SEARCH_CHILDREN);\n\n    return S_OK;\n}\n\nHRESULT CDecDXVA2::PostDecode()\n{\n    if (m_bFailHWDecode)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::PostDecode(): HW Decoder failed, falling back to software decoding\"));\n        return E_FAIL;\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::FlushFromAllocator()\n{\n    if (m_pAVCtx && avcodec_is_open(m_pAVCtx))\n        avcodec_flush_buffers(m_pAVCtx);\n    FlushDisplayQueue(FALSE);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::Flush()\n{\n    CDecAvcodec::Flush();\n    FlushDisplayQueue(FALSE);\n\n#ifdef DEBUG\n    int used = 0;\n    for (int i = 0; i < m_NumSurfaces; i++)\n    {\n        d3d_surface_t *s = &m_pSurfaces[i];\n        if (s->used)\n        {\n            used++;\n        }\n    }\n    if (used > 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"WARNING! %d frames still in use after flush\", used));\n    }\n#endif\n\n    // This solves an issue with corruption after seeks on AMD systems, see JIRA LAV-5\n    if (m_dwVendorId == VEND_ID_ATI && m_nCodecId == AV_CODEC_ID_H264 && m_pDecoder)\n    {\n        if (m_bNative && m_pDXVA2Allocator)\n        {\n            // The allocator needs to be locked because flushes can happen async to other graph events\n            // and in the worst case the allocator is decommited while we're using it.\n            CAutoLock allocatorLock(m_pDXVA2Allocator);\n            if (m_pDXVA2Allocator->IsCommited())\n                CreateDXVA2Decoder(m_NumSurfaces, m_pRawSurface);\n        }\n        else if (!m_bNative)\n            CreateDXVA2Decoder();\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::FlushDisplayQueue(BOOL bDeliver)\n{\n    for (int i = 0; i < m_DisplayDelay; ++i)\n    {\n        if (m_FrameQueue[m_FrameQueuePosition])\n        {\n            if (bDeliver)\n            {\n                DeliverDXVA2Frame(m_FrameQueue[m_FrameQueuePosition]);\n                m_FrameQueue[m_FrameQueuePosition] = nullptr;\n            }\n            else\n            {\n                ReleaseFrame(&m_FrameQueue[m_FrameQueuePosition]);\n            }\n        }\n        m_FrameQueuePosition = (m_FrameQueuePosition + 1) % m_DisplayDelay;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::EndOfStream()\n{\n    CDecAvcodec::EndOfStream();\n\n    // Flush display queue\n    FlushDisplayQueue(TRUE);\n\n    return S_OK;\n}\n\nHRESULT CDecDXVA2::HandleDXVA2Frame(LAVFrame *pFrame)\n{\n    if (pFrame->flags & LAV_FRAME_FLAG_FLUSH)\n    {\n        if (!m_bNative)\n        {\n            FlushDisplayQueue(TRUE);\n        }\n        Deliver(pFrame);\n        return S_OK;\n    }\n    if (m_bNative || m_DisplayDelay == 0)\n    {\n        DeliverDXVA2Frame(pFrame);\n    }\n    else\n    {\n        LAVFrame *pQueuedFrame = m_FrameQueue[m_FrameQueuePosition];\n        m_FrameQueue[m_FrameQueuePosition] = pFrame;\n\n        m_FrameQueuePosition = (m_FrameQueuePosition + 1) % m_DisplayDelay;\n\n        if (pQueuedFrame)\n        {\n            DeliverDXVA2Frame(pQueuedFrame);\n        }\n    }\n\n    return S_OK;\n}\n\nHRESULT CDecDXVA2::DeliverDXVA2Frame(LAVFrame *pFrame)\n{\n    if (m_bNative)\n    {\n        if (!pFrame->data[0] || !pFrame->data[3])\n        {\n            DbgLog((LOG_ERROR, 10, L\"No sample or surface for DXVA2 frame?!?!\"));\n            ReleaseFrame(&pFrame);\n            return S_FALSE;\n        }\n\n        GetPixelFormat(&pFrame->format, &pFrame->bpp, &pFrame->sw_format);\n        Deliver(pFrame);\n    }\n    else\n    {\n        if (m_bDirect)\n        {\n            DeliverDirect(pFrame);\n        }\n        else\n        {\n            if (CopyFrame(pFrame))\n                Deliver(pFrame);\n            else\n                ReleaseFrame(&pFrame);\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware)\n{\n    // Output is always NV12 or P010\n    if (pPix)\n    {\n        if (m_bNative)\n            *pPix = LAVPixFmt_DXVA2;\n        else\n            *pPix =\n                (m_eSurfaceFormat == FOURCC_P010 || m_eSurfaceFormat == FOURCC_P016) ? LAVPixFmt_P016 : LAVPixFmt_NV12;\n    }\n    if (pBpp)\n        *pBpp = (m_eSurfaceFormat == FOURCC_P016) ? 16 : ((m_eSurfaceFormat == FOURCC_P010) ? 10 : 8);\n    if (pPixSoftware)\n        *pPixSoftware =\n            (m_eSurfaceFormat == FOURCC_P010 || m_eSurfaceFormat == FOURCC_P016) ? LAVPixFmt_P016 : LAVPixFmt_NV12;\n    return S_OK;\n}\n\n__forceinline bool CDecDXVA2::CopyFrame(LAVFrame *pFrame)\n{\n    HRESULT hr;\n    LPDIRECT3DSURFACE9 pSurface = (LPDIRECT3DSURFACE9)pFrame->data[3];\n    GetPixelFormat(&pFrame->format, &pFrame->bpp, &pFrame->sw_format);\n\n    D3DSURFACE_DESC surfaceDesc;\n    pSurface->GetDesc(&surfaceDesc);\n\n    D3DLOCKED_RECT LockedRect;\n    hr = pSurface->LockRect(&LockedRect, nullptr, D3DLOCK_READONLY);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"pSurface->LockRect failed (hr: %X)\", hr));\n        return false;\n    }\n\n    // Store AVFrame-based buffers, and reset pFrame\n    LAVFrame tmpFrame = *pFrame;\n    pFrame->destruct = nullptr;\n    pFrame->priv_data = nullptr;\n\n    // side-data shall not be copied to tmpFrame\n    tmpFrame.side_data = nullptr;\n    tmpFrame.side_data_count = 0;\n\n    // Allocate memory buffers\n    hr = AllocLAVFrameBuffers(pFrame, (pFrame->format == LAVPixFmt_P016) ? (LockedRect.Pitch >> 1) : LockedRect.Pitch);\n    if (FAILED(hr))\n    {\n        pSurface->UnlockRect();\n        *pFrame = tmpFrame;\n        return false;\n    }\n\n    // Copy surface onto memory buffers\n\n    const uint8_t *src[4] = {(const uint8_t *)LockedRect.pBits, ((const uint8_t *)LockedRect.pBits) + (LockedRect.Pitch * surfaceDesc.Height), 0, 0};\n    const ptrdiff_t src_pitch[4] = {LockedRect.Pitch, LockedRect.Pitch, 0, 0};\n    av_image_copy_uc_from(pFrame->data, pFrame->stride, src, src_pitch, (pFrame->format == LAVPixFmt_P016) ? AV_PIX_FMT_P010 : AV_PIX_FMT_NV12, pFrame->width, pFrame->height);\n\n    pSurface->UnlockRect();\n\n    // Free AVFrame based buffers, now that we're done\n    FreeLAVFrameBuffers(&tmpFrame);\n\n    return true;\n}\n\nstatic bool direct_lock(LAVFrame *pFrame, LAVDirectBuffer *pBuffer)\n{\n    ASSERT(pFrame && pBuffer);\n\n    HRESULT hr;\n    LPDIRECT3DSURFACE9 pSurface = (LPDIRECT3DSURFACE9)pFrame->data[3];\n\n    D3DSURFACE_DESC surfaceDesc;\n    pSurface->GetDesc(&surfaceDesc);\n\n    D3DLOCKED_RECT LockedRect;\n    hr = pSurface->LockRect(&LockedRect, nullptr, D3DLOCK_READONLY);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"pSurface->LockRect failed (hr: %X)\", hr));\n        return false;\n    }\n\n    memset(pBuffer, 0, sizeof(*pBuffer));\n\n    pBuffer->Width = surfaceDesc.Width;\n    pBuffer->Height = surfaceDesc.Height;\n\n    pBuffer->data[0] = (BYTE *)LockedRect.pBits;\n    pBuffer->data[1] = pBuffer->data[0] + surfaceDesc.Height * LockedRect.Pitch;\n\n    pBuffer->stride[0] = LockedRect.Pitch;\n    pBuffer->stride[1] = LockedRect.Pitch;\n    return true;\n}\n\nstatic void direct_unlock(LAVFrame *pFrame)\n{\n    ASSERT(pFrame);\n    LPDIRECT3DSURFACE9 pSurface = (LPDIRECT3DSURFACE9)pFrame->data[3];\n    pSurface->UnlockRect();\n}\n\nbool CDecDXVA2::DeliverDirect(LAVFrame *pFrame)\n{\n    GetPixelFormat(&pFrame->format, &pFrame->bpp, &pFrame->sw_format);\n    pFrame->direct = true;\n    pFrame->direct_lock = direct_lock;\n    pFrame->direct_unlock = direct_unlock;\n\n    Deliver(pFrame);\n\n    return true;\n}\n\nSTDMETHODIMP_(DWORD) CDecDXVA2::GetHWAccelNumDevices()\n{\n    if (m_bNative)\n        return 0;\n\n    if (!m_pD3D)\n        return 0;\n\n    return m_pD3D->GetAdapterCount();\n}\n\nSTDMETHODIMP CDecDXVA2::GetHWAccelDeviceInfo(DWORD dwIndex, BSTR *pstrDeviceName, DWORD *dwDeviceIdentifier)\n{\n    if (m_bNative)\n        return E_UNEXPECTED;\n\n    if (!m_pD3D)\n        return E_NOINTERFACE;\n\n    D3DADAPTER_IDENTIFIER9 d3dai = {0};\n    HRESULT err = m_pD3D->GetAdapterIdentifier(dwIndex, 0, &d3dai);\n    if (err != D3D_OK)\n        return E_INVALIDARG;\n\n    if (pstrDeviceName)\n    {\n        int len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, d3dai.Description, -1, nullptr, 0);\n        if (len == 0)\n            return E_FAIL;\n\n        *pstrDeviceName = SysAllocStringLen(nullptr, len);\n        MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, d3dai.Description, -1, *pstrDeviceName, len);\n    }\n\n    if (dwDeviceIdentifier)\n        *dwDeviceIdentifier = d3dai.DeviceId;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecDXVA2::GetHWAccelActiveDevice(BSTR *pstrDeviceName)\n{\n    CheckPointer(pstrDeviceName, E_POINTER);\n\n    if (strlen(m_cDeviceName) == 0)\n        return E_UNEXPECTED;\n\n    int len = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, m_cDeviceName, -1, nullptr, 0);\n    if (len == 0)\n        return E_FAIL;\n\n    *pstrDeviceName = SysAllocStringLen(nullptr, len);\n    MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, m_cDeviceName, -1, *pstrDeviceName, len);\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/dxva2dec.h",
    "content": "/*\n *      Copyright (C) 2011-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n#include \"DecBase.h\"\n#include \"avcodec.h\"\n#include \"libavcodec/dxva2.h\"\n\n#define DXVA2_MAX_SURFACES 64\n#define DXVA2_QUEUE_SURFACES 4\n\ntypedef HRESULT WINAPI pDirect3DCreate9Ex(UINT, IDirect3D9Ex **);\ntypedef HRESULT WINAPI pCreateDeviceManager9(UINT *pResetToken, IDirect3DDeviceManager9 **);\n\ntypedef struct\n{\n    int index;\n    bool used;\n    LPDIRECT3DSURFACE9 d3d;\n    uint64_t age;\n} d3d_surface_t;\n\nclass CDXVA2SurfaceAllocator;\n\nclass CDecDXVA2 : public CDecAvcodec\n{\n  public:\n    CDecDXVA2(void);\n    virtual ~CDecDXVA2(void);\n\n    // ILAVDecoder\n    STDMETHODIMP InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData);\n    STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware);\n    STDMETHODIMP Flush();\n    STDMETHODIMP EndOfStream();\n\n    STDMETHODIMP InitAllocator(IMemAllocator **ppAlloc);\n    STDMETHODIMP PostConnect(IPin *pPin);\n    STDMETHODIMP_(long) GetBufferCount(long *pMaxBuffers = nullptr);\n    STDMETHODIMP_(const WCHAR *) GetDecoderName()\n    {\n        return m_bNative ? L\"dxva2n\" : (m_bDirect ? L\"dxva2cb direct\" : L\"dxva2cb\");\n    }\n    STDMETHODIMP HasThreadSafeBuffers() { return m_bNative ? S_FALSE : S_OK; }\n    STDMETHODIMP SetDirectOutput(BOOL bDirect)\n    {\n        m_bDirect = bDirect;\n        return S_OK;\n    }\n    STDMETHODIMP_(DWORD) GetHWAccelNumDevices();\n    STDMETHODIMP GetHWAccelDeviceInfo(DWORD dwIndex, BSTR *pstrDeviceName, DWORD *dwDeviceIdentifier);\n    STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName);\n\n    // CDecBase\n    STDMETHODIMP Init();\n\n    HRESULT SetNativeMode(BOOL bNative)\n    {\n        m_bNative = bNative;\n        return S_OK;\n    }\n\n  protected:\n    HRESULT AdditionaDecoderInit();\n    HRESULT PostDecode();\n    HRESULT HandleDXVA2Frame(LAVFrame *pFrame);\n    HRESULT DeliverDXVA2Frame(LAVFrame *pFrame);\n    BOOL IsHardwareAccelerator() { return TRUE; }\n\n    bool CopyFrame(LAVFrame *pFrame);\n    bool DeliverDirect(LAVFrame *pFrame);\n\n  private:\n    HRESULT InitD3D(UINT lAdapter);\n    HRESULT InitD3DEx(UINT lAdapter);\n    HRESULT InitD3DAdapterIdentifier(UINT lAdapter);\n    STDMETHODIMP DestroyDecoder(bool bFull, bool bNoAVCodec = false);\n    STDMETHODIMP FreeD3DResources();\n    STDMETHODIMP LoadDXVA2Functions();\n\n    HRESULT CreateD3DDeviceManager(IDirect3DDevice9 *pDevice, UINT *pReset, IDirect3DDeviceManager9 **ppManager);\n    HRESULT CreateDXVAVideoService(IDirect3DDeviceManager9 *pManager, IDirectXVideoDecoderService **ppService);\n    HRESULT FindVideoServiceConversion(AVCodecID codec, int profile, D3DFORMAT suggestedOutput, GUID *input,\n                                       D3DFORMAT *output);\n    HRESULT FindDecoderConfiguration(const GUID &input, const DXVA2_VideoDesc *pDesc,\n                                     DXVA2_ConfigPictureDecode *pConfig);\n\n    HRESULT CreateDXVA2Decoder(int nSurfaces = 0, IDirect3DSurface9 **ppSurfaces = nullptr);\n    HRESULT SetD3DDeviceManager(IDirect3DDeviceManager9 *pDevManager);\n    HRESULT DXVA2NotifyEVR();\n    HRESULT RetrieveVendorId(IDirect3DDeviceManager9 *pDevManager);\n    HRESULT CheckHWCompatConditions(GUID decoderGuid);\n    HRESULT FillHWContext(dxva_context *ctx);\n\n    HRESULT ReInitDXVA2Decoder(AVCodecContext *c);\n\n    static enum AVPixelFormat get_dxva2_format(struct AVCodecContext *s, const enum AVPixelFormat *pix_fmts);\n    static int get_dxva2_buffer(struct AVCodecContext *c, AVFrame *pic, int flags);\n    static void free_dxva2_buffer(void *opaque, uint8_t *data);\n\n    STDMETHODIMP FlushDisplayQueue(BOOL bDeliver);\n    STDMETHODIMP FlushFromAllocator();\n\n  private:\n    friend class CDXVA2SurfaceAllocator;\n    BOOL m_bNative = FALSE;\n    BOOL m_bDirect = FALSE;\n    CDXVA2SurfaceAllocator *m_pDXVA2Allocator = nullptr;\n\n    struct\n    {\n        HMODULE d3dlib;\n        pDirect3DCreate9Ex *direct3DCreate9Ex;\n\n        HMODULE dxva2lib;\n        pCreateDeviceManager9 *createDeviceManager;\n    } dx;\n\n    IDirect3D9 *m_pD3D = nullptr;\n    IDirect3DDevice9 *m_pD3DDev = nullptr;\n    IDirect3DDeviceManager9 *m_pD3DDevMngr = nullptr;\n    UINT m_pD3DResetToken = 0;\n    HANDLE m_hDevice = INVALID_HANDLE_VALUE;\n\n    IDirectXVideoDecoderService *m_pDXVADecoderService = nullptr;\n    IDirectXVideoDecoder *m_pDecoder = nullptr;\n    DXVA2_ConfigPictureDecode m_DXVAVideoDecoderConfig;\n\n    int m_NumSurfaces = 0;\n    d3d_surface_t m_pSurfaces[DXVA2_MAX_SURFACES];\n    uint64_t m_CurrentSurfaceAge = 1;\n\n    LPDIRECT3DSURFACE9 m_pRawSurface[DXVA2_MAX_SURFACES];\n\n    BOOL m_bFailHWDecode = FALSE;\n\n    LAVFrame *m_FrameQueue[DXVA2_QUEUE_SURFACES];\n    int m_FrameQueuePosition = 0;\n\n    AVPixelFormat m_DecoderPixelFormat = AV_PIX_FMT_NONE;\n    DWORD m_dwSurfaceWidth = 0;\n    DWORD m_dwSurfaceHeight = 0;\n    D3DFORMAT m_eSurfaceFormat = D3DFMT_UNKNOWN;\n    DWORD m_dwVendorId = 0;\n    DWORD m_dwDeviceId = 0;\n    char m_cDeviceName[512] = {0};\n    GUID m_guidDecoderDevice = GUID_NULL;\n    int m_DisplayDelay = DXVA2_QUEUE_SURFACES;\n\n    CMediaType m_MediaType;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/msdk_mvc.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"msdk_mvc.h\"\n#include \"moreuuids.h\"\n#include \"ByteParser.h\"\n#include \"H264Nalu.h\"\n\n////////////////////////////////////////////////////////////////////////////////\n// Constructor\n////////////////////////////////////////////////////////////////////////////////\n\nILAVDecoder *CreateDecoderMSDKMVC()\n{\n    return new CDecMSDKMVC();\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Bitstream buffering\n////////////////////////////////////////////////////////////////////////////////\n\nclass CBitstreamBuffer\n{\n  public:\n    CBitstreamBuffer(GrowableArray<BYTE> *arrStorage)\n        : m_pStorage(arrStorage)\n    {\n    }\n\n    ~CBitstreamBuffer()\n    {\n        ASSERT(m_nConsumed <= m_pStorage->GetCount());\n        if (m_nConsumed < m_pStorage->GetCount())\n        {\n            BYTE *p = m_pStorage->Ptr();\n            memmove(p, p + m_nConsumed, m_pStorage->GetCount() - m_nConsumed);\n            m_pStorage->SetSize(DWORD(m_pStorage->GetCount() - m_nConsumed));\n        }\n        else\n        {\n            m_pStorage->Clear();\n        }\n    }\n\n    void Allocate(size_t size) { m_pStorage->Allocate((DWORD)size); }\n\n    void Append(const BYTE *buffer, size_t size) { m_pStorage->Append(buffer, DWORD(size)); }\n\n    void Consume(size_t count) { m_nConsumed += min(count, GetBufferSize()); }\n\n    void Clear() { m_nConsumed += GetBufferSize(); }\n\n    BYTE *GetBuffer() { return m_pStorage->Ptr() + m_nConsumed; }\n\n    size_t GetBufferSize() { return m_pStorage->GetCount() - m_nConsumed; }\n\n  private:\n    GrowableArray<BYTE> *m_pStorage = nullptr;\n    size_t m_nConsumed = 0;\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// MSDK MVC decoder implementation\n////////////////////////////////////////////////////////////////////////////////\n\nCDecMSDKMVC::CDecMSDKMVC()\n{\n}\n\nCDecMSDKMVC::~CDecMSDKMVC()\n{\n    DestroyDecoder(true);\n}\n\nSTDMETHODIMP CDecMSDKMVC::Init()\n{\n    mfxIMPL impls[] = {MFX_IMPL_AUTO_ANY, MFX_IMPL_SOFTWARE};\n    mfxVersion version = {8, 1};\n\n    // Check if HWAccel is allowed\n    if (!m_pSettings->GetHWAccelCodec(HWCodec_H264MVC))\n        impls[0] = MFX_IMPL_SOFTWARE;\n\n    for (int i = 0; i < countof(impls); i++)\n    {\n        mfxStatus sts = MFXInit(impls[i], &version, &m_mfxSession);\n        if (sts != MFX_ERR_NONE)\n        {\n            DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Init(): MSDK not available\"));\n            return E_NOINTERFACE;\n        }\n\n        // query actual API version\n        MFXQueryVersion(m_mfxSession, &m_mfxVersion);\n\n        mfxIMPL impl = 0;\n        MFXQueryIMPL(m_mfxSession, &impl);\n        DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Init(): MSDK Initialized, version %d.%d, impl 0x%04x\", m_mfxVersion.Major,\n                m_mfxVersion.Minor, impl));\n\n        if ((impl & MFX_IMPL_VIA_MASK) == MFX_IMPL_VIA_D3D11 && !IsWindows8OrNewer())\n        {\n            DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Init(): Skipping D3D11 acceleration on pre-Windows 8 system\"));\n            MFXClose(m_mfxSession);\n            m_mfxSession = nullptr;\n            continue;\n        }\n\n        m_mfxImpl = impl;\n\n        break;\n    }\n\n    return S_OK;\n}\n\nvoid CDecMSDKMVC::DestroyDecoder(bool bFull)\n{\n    if (m_bDecodeReady)\n    {\n        MFXVideoDECODE_Close(m_mfxSession);\n        m_bDecodeReady = FALSE;\n    }\n\n    {\n        CAutoLock lock(&m_BufferCritSec);\n        for (int i = 0; i < ASYNC_QUEUE_SIZE; i++)\n        {\n            ReleaseBuffer(&m_pOutputQueue[i]->surface);\n        }\n        memset(m_pOutputQueue, 0, sizeof(m_pOutputQueue));\n\n        for (auto it = m_BufferQueue.begin(); it != m_BufferQueue.end(); it++)\n        {\n            if (!(*it)->queued)\n            {\n                av_freep(&(*it)->surface.Data.Y);\n                delete (*it);\n            }\n        }\n        m_BufferQueue.clear();\n    }\n\n    // delete MVC sequence buffers\n    SAFE_DELETE(m_mfxExtMVCSeq.View);\n    SAFE_DELETE(m_mfxExtMVCSeq.ViewId);\n    SAFE_DELETE(m_mfxExtMVCSeq.OP);\n\n    m_nMP4NALUSize = 0;\n\n    if (bFull)\n    {\n        if (m_mfxSession)\n        {\n            MFXClose(m_mfxSession);\n            m_mfxSession = nullptr;\n        }\n    }\n}\n\nSTDMETHODIMP CDecMSDKMVC::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)\n{\n    if (codec != AV_CODEC_ID_H264_MVC)\n        return E_UNEXPECTED;\n\n    if (*pmt->FormatType() != FORMAT_MPEG2Video)\n        return E_UNEXPECTED;\n\n    DestroyDecoder(false);\n\n    // Init and reset video param arrays\n    memset(&m_mfxVideoParams, 0, sizeof(m_mfxVideoParams));\n    m_mfxVideoParams.mfx.CodecId = MFX_CODEC_AVC;\n\n    memset(&m_mfxExtMVCSeq, 0, sizeof(m_mfxExtMVCSeq));\n    m_mfxExtMVCSeq.Header.BufferId = MFX_EXTBUFF_MVC_SEQ_DESC;\n    m_mfxExtMVCSeq.Header.BufferSz = sizeof(m_mfxExtMVCSeq);\n    m_mfxExtParam[0] = (mfxExtBuffer *)&m_mfxExtMVCSeq;\n\n    // Attach ext params to VideoParams\n    m_mfxVideoParams.ExtParam = m_mfxExtParam;\n    m_mfxVideoParams.NumExtParam = 1;\n\n    MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)pmt->Format();\n\n    if (*pmt->Subtype() == MEDIASUBTYPE_MVC1)\n    {\n        m_nMP4NALUSize = 2;\n\n        // Decode sequence header from the media type\n        if (mp2vi->cbSequenceHeader)\n        {\n            HRESULT hr = Decode((const BYTE *)mp2vi->dwSequenceHeader, mp2vi->cbSequenceHeader, AV_NOPTS_VALUE,\n                                AV_NOPTS_VALUE, TRUE, TRUE, nullptr);\n            if (FAILED(hr))\n                return hr;\n        }\n\n        m_nMP4NALUSize = mp2vi->dwFlags;\n    }\n    else if (*pmt->Subtype() == MEDIASUBTYPE_AMVC)\n    {\n        // Decode sequence header from the media type\n        if (mp2vi->cbSequenceHeader)\n        {\n            HRESULT hr = Decode((const BYTE *)mp2vi->dwSequenceHeader, mp2vi->cbSequenceHeader, AV_NOPTS_VALUE,\n                                AV_NOPTS_VALUE, TRUE, TRUE, nullptr);\n            if (FAILED(hr))\n                return hr;\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecMSDKMVC::AllocateMVCExtBuffers()\n{\n    mfxU32 i;\n    SAFE_DELETE(m_mfxExtMVCSeq.View);\n    SAFE_DELETE(m_mfxExtMVCSeq.ViewId);\n    SAFE_DELETE(m_mfxExtMVCSeq.OP);\n\n    m_mfxExtMVCSeq.View = new mfxMVCViewDependency[m_mfxExtMVCSeq.NumView];\n    CheckPointer(m_mfxExtMVCSeq.View, E_OUTOFMEMORY);\n    for (i = 0; i < m_mfxExtMVCSeq.NumView; ++i)\n    {\n        memset(&m_mfxExtMVCSeq.View[i], 0, sizeof(m_mfxExtMVCSeq.View[i]));\n    }\n    m_mfxExtMVCSeq.NumViewAlloc = m_mfxExtMVCSeq.NumView;\n\n    m_mfxExtMVCSeq.ViewId = new mfxU16[m_mfxExtMVCSeq.NumViewId];\n    CheckPointer(m_mfxExtMVCSeq.ViewId, E_OUTOFMEMORY);\n    for (i = 0; i < m_mfxExtMVCSeq.NumViewId; ++i)\n    {\n        memset(&m_mfxExtMVCSeq.ViewId[i], 0, sizeof(m_mfxExtMVCSeq.ViewId[i]));\n    }\n    m_mfxExtMVCSeq.NumViewIdAlloc = m_mfxExtMVCSeq.NumViewId;\n\n    m_mfxExtMVCSeq.OP = new mfxMVCOperationPoint[m_mfxExtMVCSeq.NumOP];\n    CheckPointer(m_mfxExtMVCSeq.OP, E_OUTOFMEMORY);\n    for (i = 0; i < m_mfxExtMVCSeq.NumOP; ++i)\n    {\n        memset(&m_mfxExtMVCSeq.OP[i], 0, sizeof(m_mfxExtMVCSeq.OP[i]));\n    }\n    m_mfxExtMVCSeq.NumOPAlloc = m_mfxExtMVCSeq.NumOP;\n\n    return S_OK;\n}\n\nMVCBuffer *CDecMSDKMVC::GetBuffer()\n{\n    CAutoLock lock(&m_BufferCritSec);\n    MVCBuffer *pBuffer = nullptr;\n    for (auto it = m_BufferQueue.begin(); it != m_BufferQueue.end(); it++)\n    {\n        if (!(*it)->surface.Data.Locked && !(*it)->queued)\n        {\n            pBuffer = *it;\n            break;\n        }\n    }\n\n    if (!pBuffer)\n    {\n        pBuffer = new MVCBuffer();\n\n        pBuffer->surface.Info = m_mfxVideoParams.mfx.FrameInfo;\n        pBuffer->surface.Info.FourCC = MFX_FOURCC_NV12;\n\n        pBuffer->surface.Data.PitchLow = FFALIGN(m_mfxVideoParams.mfx.FrameInfo.Width, 64);\n        pBuffer->surface.Data.Y = (mfxU8 *)av_malloc(pBuffer->surface.Data.PitchLow *\n                                                     FFALIGN(m_mfxVideoParams.mfx.FrameInfo.Height, 64) * 3 / 2);\n        if (pBuffer->surface.Data.Y == nullptr)\n        {\n            delete pBuffer;\n            return nullptr;\n        }\n        pBuffer->surface.Data.UV = pBuffer->surface.Data.Y + (pBuffer->surface.Data.PitchLow *\n                                                              FFALIGN(m_mfxVideoParams.mfx.FrameInfo.Height, 64));\n\n        m_BufferQueue.push_back(pBuffer);\n        DbgLog((LOG_TRACE, 10, L\"Allocated new MSDK MVC buffer (%d total)\", m_BufferQueue.size()));\n    }\n\n    return pBuffer;\n}\n\nMVCBuffer *CDecMSDKMVC::FindBuffer(mfxFrameSurface1 *pSurface)\n{\n    CAutoLock lock(&m_BufferCritSec);\n    bool bFound = false;\n    for (auto it = m_BufferQueue.begin(); it != m_BufferQueue.end(); it++)\n    {\n        if (&(*it)->surface == pSurface)\n        {\n            return *it;\n        }\n    }\n\n    return nullptr;\n}\n\nvoid CDecMSDKMVC::ReleaseBuffer(mfxFrameSurface1 *pSurface)\n{\n    if (!pSurface)\n        return;\n\n    CAutoLock lock(&m_BufferCritSec);\n    MVCBuffer *pBuffer = FindBuffer(pSurface);\n\n    if (pBuffer)\n    {\n        pBuffer->queued = 0;\n        pBuffer->sync = nullptr;\n    }\n}\n\nstatic const BYTE s_AnnexBStartCode3[3] = {0x00, 0x00, 0x01};\nstatic const BYTE s_AnnexBStartCode4[4] = {0x00, 0x00, 0x00, 0x01};\n\nSTDMETHODIMP CDecMSDKMVC::Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,\n                                 BOOL bSyncPoint, BOOL bDiscontinuity, IMediaSample *pSample)\n{\n    if (!m_mfxSession)\n        return E_UNEXPECTED;\n\n    HRESULT hr = S_OK;\n    CBitstreamBuffer bsBuffer(&m_buff);\n    mfxStatus sts = MFX_ERR_NONE;\n    mfxBitstream bs = {0};\n    BOOL bFlush = (buffer == nullptr);\n\n    if (rtStart >= -TIMESTAMP_OFFSET && rtStart != AV_NOPTS_VALUE)\n        bs.TimeStamp = rtStart + TIMESTAMP_OFFSET;\n    else\n        bs.TimeStamp = MFX_TIMESTAMP_UNKNOWN;\n\n    bs.DecodeTimeStamp = MFX_TIMESTAMP_UNKNOWN;\n\n    if (!bFlush)\n    {\n        bsBuffer.Allocate(bsBuffer.GetBufferSize() + buflen);\n\n        // Check the buffer for SEI NALU, and some unwanted NALUs that need filtering\n        // MSDK's SEI reading functionality is slightly buggy\n        CH264Nalu nalu;\n        nalu.SetBuffer(buffer, buflen, m_nMP4NALUSize);\n        BOOL bNeedFilter = FALSE;\n        while (nalu.ReadNext())\n        {\n            // Don't include End-of-Sequence or AUD NALUs\n            if (nalu.GetType() == NALU_TYPE_EOSEQ || nalu.GetType() == NALU_TYPE_AUD)\n                continue;\n\n            if (nalu.GetType() == NALU_TYPE_SEI)\n            {\n                CH264NALUnescape seiNalu(nalu.GetDataBuffer() + 1, nalu.GetDataLength() - 1);\n                ParseSEI(seiNalu.GetBuffer(), seiNalu.GetSize(), bs.TimeStamp);\n            }\n\n            // copy filtered NALs into the data buffer\n            if (m_nMP4NALUSize)\n            {\n                // write annex b nal\n                if (nalu.GetNALPos() == 0 || nalu.GetType() == NALU_TYPE_SPS || nalu.GetType() == NALU_TYPE_PPS)\n                    bsBuffer.Append(s_AnnexBStartCode4, 4);\n                else\n                    bsBuffer.Append(s_AnnexBStartCode3, 3);\n\n                // append nal data\n                bsBuffer.Append(nalu.GetDataBuffer(), nalu.GetDataLength());\n            }\n            else\n            {\n                bsBuffer.Append(nalu.GetNALBuffer(), nalu.GetLength());\n            }\n        }\n\n        bs.Data = bsBuffer.GetBuffer();\n        bs.DataLength = mfxU32(bsBuffer.GetBufferSize());\n        bs.MaxLength = bs.DataLength;\n\n        AddFrameToGOP(bs.TimeStamp);\n    }\n\n    if (!m_bDecodeReady)\n    {\n        sts = MFXVideoDECODE_DecodeHeader(m_mfxSession, &bs, &m_mfxVideoParams);\n        if (sts == MFX_ERR_NOT_ENOUGH_BUFFER)\n        {\n            hr = AllocateMVCExtBuffers();\n            if (FAILED(hr))\n                return hr;\n\n            sts = MFXVideoDECODE_DecodeHeader(m_mfxSession, &bs, &m_mfxVideoParams);\n        }\n\n        if (sts == MFX_ERR_NONE)\n        {\n            m_mfxVideoParams.IOPattern = MFX_IOPATTERN_OUT_SYSTEM_MEMORY;\n            m_mfxVideoParams.AsyncDepth = ASYNC_DEPTH;\n\n            sts = MFXVideoDECODE_Init(m_mfxSession, &m_mfxVideoParams);\n            if (sts != MFX_ERR_NONE)\n            {\n                DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Decode(): Error initializing the MSDK decoder (%d)\", sts));\n                return E_FAIL;\n            }\n\n            if (m_mfxExtMVCSeq.NumView != 2)\n            {\n                DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Decode(): Only MVC with two views is supported\"));\n                return E_FAIL;\n            }\n\n            DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Decode(): Initialized MVC with View Ids %d, %d\",\n                    m_mfxExtMVCSeq.View[0].ViewId, m_mfxExtMVCSeq.View[1].ViewId));\n\n            m_bDecodeReady = TRUE;\n        }\n    }\n\n    if (!m_bDecodeReady)\n        return S_FALSE;\n\n    mfxSyncPoint sync = nullptr;\n\n    // Loop over the decoder to ensure all data is being consumed\n    while (1)\n    {\n        MVCBuffer *pInputBuffer = GetBuffer();\n        if (pInputBuffer == nullptr)\n            return E_OUTOFMEMORY;\n\n        mfxFrameSurface1 *outsurf = nullptr;\n        sts = MFXVideoDECODE_DecodeFrameAsync(m_mfxSession, bFlush ? nullptr : &bs, &pInputBuffer->surface, &outsurf,\n                                              &sync);\n\n        if (sts == MFX_ERR_INCOMPATIBLE_VIDEO_PARAM)\n        {\n            DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Decode(): Incompatible video parameters detected, flushing decoder\"));\n            bsBuffer.Clear();\n            bFlush = TRUE;\n            m_bDecodeReady = FALSE;\n            continue;\n        }\n\n        if (sync)\n        {\n            MVCBuffer *pOutputBuffer = FindBuffer(outsurf);\n            pOutputBuffer->queued = 1;\n            pOutputBuffer->sync = sync;\n            HandleOutput(pOutputBuffer);\n            continue;\n        }\n\n        if (sts != MFX_ERR_MORE_SURFACE && sts < 0)\n            break;\n    }\n\n    if (!bs.DataOffset && !sync && !bFlush)\n    {\n        DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Decode(): Decoder did not consume any data, discarding\"));\n        bs.DataOffset = mfxU32(bsBuffer.GetBufferSize());\n    }\n\n    bsBuffer.Consume(bs.DataOffset);\n\n    if (sts != MFX_ERR_MORE_DATA && sts < 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::Decode(): Error from Decode call (%d)\", sts));\n        return S_FALSE;\n    }\n\n    return S_OK;\n}\n\nHRESULT CDecMSDKMVC::ParseSEI(const BYTE *buffer, size_t size, mfxU64 timestamp)\n{\n    CByteParser seiParser(buffer, size);\n    while (seiParser.RemainingBits() > 16 && seiParser.BitRead(16, true))\n    {\n        int type = 0;\n        unsigned size = 0;\n\n        do\n        {\n            if (seiParser.RemainingBits() < 8)\n                return E_FAIL;\n            type += seiParser.BitRead(8, true);\n        } while (seiParser.BitRead(8) == 0xFF);\n\n        do\n        {\n            if (seiParser.RemainingBits() < 8)\n                return E_FAIL;\n            size += seiParser.BitRead(8, true);\n        } while (seiParser.BitRead(8) == 0xFF);\n\n        if (size > seiParser.Remaining())\n        {\n            DbgLog((LOG_TRACE, 10, L\"CDecMSDKMVC::ParseSEI(): SEI type %d size %d truncated, available: %d\", type, size,\n                    seiParser.Remaining()));\n            return E_FAIL;\n        }\n\n        switch (type)\n        {\n        case 5: ParseUnregUserDataSEI(buffer + seiParser.Pos(), size, timestamp); break;\n        case 37: ParseMVCNestedSEI(buffer + seiParser.Pos(), size, timestamp); break;\n        }\n\n        seiParser.BitSkip(size * 8);\n    }\n\n    return S_OK;\n}\n\nHRESULT CDecMSDKMVC::ParseMVCNestedSEI(const BYTE *buffer, size_t size, mfxU64 timestamp)\n{\n    CByteParser seiParser(buffer, size);\n\n    // Parse the MVC Scalable Nesting SEI first\n    int op_flag = seiParser.BitRead(1);\n    if (!op_flag)\n    {\n        int all_views_in_au = seiParser.BitRead(1);\n        if (!all_views_in_au)\n        {\n            int num_views_min1 = seiParser.UExpGolombRead();\n            for (int i = 0; i <= num_views_min1; i++)\n            {\n                seiParser.BitRead(10); // sei_view_id[i]\n            }\n        }\n    }\n    else\n    {\n        int num_views_min1 = seiParser.UExpGolombRead();\n        for (int i = 0; i <= num_views_min1; i++)\n        {\n            seiParser.BitRead(10); // sei_op_view_id[i]\n        }\n        seiParser.BitRead(3); // sei_op_temporal_id\n    }\n    seiParser.BitByteAlign();\n\n    // Parse nested SEI\n    ParseSEI(buffer + seiParser.Pos(), seiParser.Remaining(), timestamp);\n\n    return S_OK;\n}\n\nstatic const uint8_t uuid_iso_iec_11578[16] = {0x17, 0xee, 0x8c, 0x60, 0xf8, 0x4d, 0x11, 0xd9,\n                                               0x8c, 0xd6, 0x08, 0x00, 0x20, 0x0c, 0x9a, 0x66};\n\nHRESULT CDecMSDKMVC::ParseUnregUserDataSEI(const BYTE *buffer, size_t size, mfxU64 timestamp)\n{\n    if (size < 20)\n        return E_FAIL;\n\n    if (memcmp(buffer, uuid_iso_iec_11578, 16) != 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"CDecMSDKMVC::ParseUnregUserDataSEI(): Unknown User Data GUID\"));\n        return S_FALSE;\n    }\n\n    uint32_t type = AV_RB32(buffer + 16);\n\n    // Offset metadata\n    if (type == 0x4F464D44)\n    {\n        return ParseOffsetMetadata(buffer + 20, size - 20, timestamp);\n    }\n\n    return S_FALSE;\n}\n\nHRESULT CDecMSDKMVC::ParseOffsetMetadata(const BYTE *buffer, size_t size, mfxU64 timestamp)\n{\n    if (size < 10)\n        return E_FAIL;\n\n    // Skip PTS part, its not used. Start parsing at first marker bit after the PTS\n    CByteParser offset(buffer + 6, size - 6);\n    offset.BitSkip(2); // Skip marker and re served\n\n    unsigned int nOffsets = offset.BitRead(6);\n    unsigned int nFrames = offset.BitRead(8);\n    DbgLog((LOG_CUSTOM2, 10,\n            L\"CDecMSDKMVC::ParseOffsetMetadata(): offset_metadata with %d offsets and %d frames for time %I64u\",\n            nOffsets, nFrames, timestamp));\n\n    if (nOffsets > 32)\n    {\n        DbgLog((LOG_TRACE, 10, L\"CDecMSDKMVC::ParseOffsetMetadata(): > 32 offsets is not supported\"));\n        return E_FAIL;\n    }\n\n    offset.BitSkip(16); // Skip marker and reserved\n    if (nOffsets * nFrames > (size - 10))\n    {\n        DbgLog((LOG_TRACE, 10,\n                L\"CDecMSDKMVC::ParseOffsetMetadata(): not enough data for all offsets (need %d, have %d)\",\n                nOffsets * nFrames, size - 4));\n        return E_FAIL;\n    }\n\n    MVCGOP GOP;\n\n    for (unsigned int o = 0; o < nOffsets; o++)\n    {\n        for (unsigned int f = 0; f < nFrames; f++)\n        {\n            if (o == 0)\n            {\n                MediaSideData3DOffset off = {(int)nOffsets};\n                GOP.offsets.push_back(off);\n            }\n\n            int direction_flag = offset.BitRead(1);\n            int value = offset.BitRead(7);\n\n            if (direction_flag)\n                value = -value;\n\n            GOP.offsets[f].offset[o] = value;\n        }\n    }\n\n    m_GOPs.push_back(GOP);\n\n    return S_OK;\n}\n\nvoid CDecMSDKMVC::AddFrameToGOP(mfxU64 timestamp)\n{\n    if (m_GOPs.size() > 0)\n        m_GOPs.back().timestamps.push_back(timestamp);\n}\n\nBOOL CDecMSDKMVC::RemoveFrameFromGOP(MVCGOP *pGOP, mfxU64 timestamp)\n{\n    if (pGOP->timestamps.empty() || pGOP->offsets.empty())\n        return FALSE;\n\n    auto e = std::find(pGOP->timestamps.begin(), pGOP->timestamps.end(), timestamp);\n    if (e != pGOP->timestamps.end())\n    {\n        pGOP->timestamps.erase(e);\n        return TRUE;\n    }\n\n    return FALSE;\n}\n\nvoid CDecMSDKMVC::GetOffsetSideData(LAVFrame *pFrame, mfxU64 timestamp)\n{\n    MediaSideData3DOffset offset = {255};\n\n    // Go over all stored GOPs and find an entry for our timestamp\n    // In general it should be found in the first GOP, unless we lost frames in between or something else went wrong.\n    for (auto it = m_GOPs.begin(); it != m_GOPs.end(); it++)\n    {\n        if (RemoveFrameFromGOP(&(*it), timestamp))\n        {\n            offset = it->offsets.front();\n            it->offsets.pop_front();\n\n            // Erase previous GOPs when we start accessing a new one\n            if (it != m_GOPs.begin())\n            {\n#ifdef DEBUG\n                // Check that all to-be-erased GOPs are empty\n                for (auto itd = m_GOPs.begin(); itd < it; itd++)\n                {\n                    if (!itd->offsets.empty())\n                    {\n                        DbgLog((LOG_TRACE, 10,\n                                L\"CDecMSDKMVC::GetOffsetSideData(): Switched to next GOP at %I64u with %Iu entries \"\n                                L\"remaining\",\n                                timestamp, itd->offsets.size()));\n                    }\n                }\n#endif\n                m_GOPs.erase(m_GOPs.begin(), it);\n            }\n            break;\n        }\n    }\n\n    if (offset.offset_count == 255)\n    {\n        DbgLog((LOG_TRACE, 10, L\"CDecMSDKMVC::GetOffsetSideData():No offset for frame at %I64u\", timestamp));\n        offset = m_PrevOffset;\n    }\n\n    m_PrevOffset = offset;\n\n    // Only set the offset when data is present\n    if (offset.offset_count > 0)\n    {\n        MediaSideData3DOffset *FrameOffset = (MediaSideData3DOffset *)AddLAVFrameSideData(\n            pFrame, IID_MediaSideData3DOffset, sizeof(MediaSideData3DOffset));\n        if (FrameOffset)\n            *FrameOffset = offset;\n    }\n}\n\nHRESULT CDecMSDKMVC::HandleOutput(MVCBuffer *pOutputBuffer)\n{\n    int nCur = m_nOutputQueuePosition, nNext = (m_nOutputQueuePosition + 1) % ASYNC_QUEUE_SIZE;\n    if (m_pOutputQueue[nCur] && m_pOutputQueue[nNext])\n    {\n        DeliverOutput(m_pOutputQueue[nCur], m_pOutputQueue[nNext]);\n\n        m_pOutputQueue[nCur] = nullptr;\n        m_pOutputQueue[nNext] = nullptr;\n    }\n    else if (m_pOutputQueue[nCur])\n    {\n        DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::HandleOutput(): Dropping unpaired frame\"));\n\n        ReleaseBuffer(&m_pOutputQueue[nCur]->surface);\n        m_pOutputQueue[nCur]->sync = nullptr;\n        m_pOutputQueue[nCur] = nullptr;\n    }\n\n    m_pOutputQueue[nCur] = pOutputBuffer;\n    m_nOutputQueuePosition = nNext;\n\n    return S_OK;\n}\n\nHRESULT CDecMSDKMVC::DeliverOutput(MVCBuffer *pBaseView, MVCBuffer *pExtraView)\n{\n    mfxStatus sts = MFX_ERR_NONE;\n\n    ASSERT(pBaseView->surface.Info.FrameId.ViewId == 0 && pExtraView->surface.Info.FrameId.ViewId > 0);\n    ASSERT(pBaseView->surface.Data.FrameOrder == pExtraView->surface.Data.FrameOrder);\n\n    // Sync base view\n    do\n    {\n        sts = MFXVideoCORE_SyncOperation(m_mfxSession, pBaseView->sync, 1000);\n    } while (sts == MFX_WRN_IN_EXECUTION);\n    pBaseView->sync = nullptr;\n\n    // Sync extra view\n    do\n    {\n        sts = MFXVideoCORE_SyncOperation(m_mfxSession, pExtraView->sync, 1000);\n    } while (sts == MFX_WRN_IN_EXECUTION);\n    pExtraView->sync = nullptr;\n\n    LAVFrame *pFrame = nullptr;\n    AllocateFrame(&pFrame);\n\n    pFrame->width = pBaseView->surface.Info.CropW;\n    pFrame->height = pBaseView->surface.Info.CropH;\n\n    pFrame->data[0] = pBaseView->surface.Data.Y;\n    pFrame->data[1] = pBaseView->surface.Data.UV;\n    pFrame->stereo[0] = pExtraView->surface.Data.Y;\n    pFrame->stereo[1] = pExtraView->surface.Data.UV;\n    pFrame->data[2] = (uint8_t *)pBaseView;\n    pFrame->data[3] = (uint8_t *)pExtraView;\n    pFrame->stride[0] = pBaseView->surface.Data.PitchLow;\n    pFrame->stride[1] = pBaseView->surface.Data.PitchLow;\n\n    pFrame->format = LAVPixFmt_NV12;\n    pFrame->sw_format = pFrame->format;\n    pFrame->bpp = 8;\n    pFrame->flags |= LAV_FRAME_FLAG_MVC;\n\n    if (!(pBaseView->surface.Data.DataFlag & MFX_FRAMEDATA_ORIGINAL_TIMESTAMP))\n        pBaseView->surface.Data.TimeStamp = MFX_TIMESTAMP_UNKNOWN;\n\n    if (pBaseView->surface.Data.TimeStamp != MFX_TIMESTAMP_UNKNOWN)\n    {\n        pFrame->rtStart = pBaseView->surface.Data.TimeStamp;\n        pFrame->rtStart -= TIMESTAMP_OFFSET;\n    }\n    else\n    {\n        pFrame->rtStart = AV_NOPTS_VALUE;\n    }\n\n    int64_t num = (int64_t)pBaseView->surface.Info.AspectRatioW * pFrame->width;\n    int64_t den = (int64_t)pBaseView->surface.Info.AspectRatioH * pFrame->height;\n    av_reduce(&pFrame->aspect_ratio.num, &pFrame->aspect_ratio.den, num, den, INT_MAX);\n\n    pFrame->destruct = msdk_buffer_destruct;\n    pFrame->priv_data = this;\n\n    GetOffsetSideData(pFrame, pBaseView->surface.Data.TimeStamp);\n\n    return Deliver(pFrame);\n}\n\nvoid CDecMSDKMVC::msdk_buffer_destruct(LAVFrame *pFrame)\n{\n    CDecMSDKMVC *pDec = (CDecMSDKMVC *)pFrame->priv_data;\n    CAutoLock lock(&pDec->m_BufferCritSec);\n\n    MVCBuffer *pBaseBuffer = (MVCBuffer *)pFrame->data[2];\n    MVCBuffer *pStoredBuffer = pDec->FindBuffer(&pBaseBuffer->surface);\n    if (pStoredBuffer)\n    {\n        pDec->ReleaseBuffer(&pBaseBuffer->surface);\n    }\n    else\n    {\n        av_free(pBaseBuffer->surface.Data.Y);\n        SAFE_DELETE(pBaseBuffer);\n    }\n\n    MVCBuffer *pExtraBuffer = (MVCBuffer *)pFrame->data[3];\n    pStoredBuffer = pDec->FindBuffer(&pExtraBuffer->surface);\n    if (pStoredBuffer)\n    {\n        pDec->ReleaseBuffer(&pExtraBuffer->surface);\n    }\n    else\n    {\n        av_free(pExtraBuffer->surface.Data.Y);\n        SAFE_DELETE(pExtraBuffer);\n    }\n}\n\nSTDMETHODIMP CDecMSDKMVC::Flush()\n{\n    m_buff.Clear();\n\n    if (m_mfxSession)\n    {\n        if (m_bDecodeReady)\n            MFXVideoDECODE_Reset(m_mfxSession, &m_mfxVideoParams);\n        // TODO: decode sequence data\n\n        for (int i = 0; i < ASYNC_QUEUE_SIZE; i++)\n        {\n            ReleaseBuffer(&m_pOutputQueue[i]->surface);\n        }\n        memset(m_pOutputQueue, 0, sizeof(m_pOutputQueue));\n    }\n\n    m_GOPs.clear();\n    memset(&m_PrevOffset, 0, sizeof(m_PrevOffset));\n\n    return __super::Flush();\n}\n\nSTDMETHODIMP CDecMSDKMVC::EndOfStream()\n{\n    if (!m_bDecodeReady)\n        return S_FALSE;\n\n    // Flush frames out of the decoder\n    Decode(nullptr, 0, AV_NOPTS_VALUE, AV_NOPTS_VALUE, FALSE, FALSE, nullptr);\n\n    // Process all remaining frames in the queue\n    for (int i = 0; i < ASYNC_QUEUE_SIZE; i++)\n    {\n        int nCur = (m_nOutputQueuePosition + i) % ASYNC_QUEUE_SIZE,\n            nNext = (m_nOutputQueuePosition + i + 1) % ASYNC_QUEUE_SIZE;\n        if (m_pOutputQueue[nCur] && m_pOutputQueue[nNext])\n        {\n            DeliverOutput(m_pOutputQueue[nCur], m_pOutputQueue[nNext]);\n\n            m_pOutputQueue[nCur] = nullptr;\n            m_pOutputQueue[nNext] = nullptr;\n\n            i++;\n        }\n        else if (m_pOutputQueue[nCur])\n        {\n            DbgLog((LOG_TRACE, 10, L\"CDevMSDKMVC::EndOfStream(): Dropping unpaired frame\"));\n\n            ReleaseBuffer(&m_pOutputQueue[nCur]->surface);\n            m_pOutputQueue[nCur] = nullptr;\n        }\n    }\n    m_nOutputQueuePosition = 0;\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/msdk_mvc.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n#include \"DecBase.h\"\n#include \"IMediaSideData.h\"\n\n#include \"mfxvideo.h\"\n#include \"mfxmvc.h\"\n\n#include <deque>\n#include <vector>\n\n#define ASYNC_DEPTH 8\n#define ASYNC_QUEUE_SIZE (ASYNC_DEPTH + 2)\n\n// 10s timestamp offset to avoid negative timestamps\n#define TIMESTAMP_OFFSET 100000000i64\n\n#define MFX_IMPL_VIA_MASK 0x0F00\n\ntypedef struct _MVCBuffer\n{\n    mfxFrameSurface1 surface = {0};\n    bool queued = false;\n    mfxSyncPoint sync = nullptr;\n} MVCBuffer;\n\ntypedef struct _MVCGOP\n{\n    std::deque<mfxU64> timestamps;\n    std::deque<MediaSideData3DOffset> offsets;\n} MVCGOP;\n\nclass CDecMSDKMVC : public CDecBase\n{\n  public:\n    CDecMSDKMVC();\n    virtual ~CDecMSDKMVC();\n\n    // ILAVDecoder\n    STDMETHODIMP InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData);\n    STDMETHODIMP Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BOOL bSyncPoint,\n                        BOOL bDiscontinuity, IMediaSample *pSample);\n    STDMETHODIMP Flush();\n    STDMETHODIMP EndOfStream();\n    STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware)\n    {\n        if (pPix)\n            *pPix = LAVPixFmt_NV12;\n        if (pBpp)\n            *pBpp = 8;\n        if (pPixSoftware)\n            *pPixSoftware = LAVPixFmt_NV12;\n        return S_OK;\n    }\n    STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess) { return FALSE; }\n    STDMETHODIMP_(const WCHAR *) GetDecoderName()\n    {\n        return (m_mfxImpl != MFX_IMPL_SOFTWARE) ? L\"msdk mvc hw\" : L\"msdk mvc\";\n    }\n    STDMETHODIMP HasThreadSafeBuffers() { return S_OK; }\n\n    // CDecBase\n    STDMETHODIMP Init();\n\n  private:\n    void DestroyDecoder(bool bFull);\n    STDMETHODIMP AllocateMVCExtBuffers();\n\n    MVCBuffer *GetBuffer();\n    MVCBuffer *FindBuffer(mfxFrameSurface1 *pSurface);\n    void ReleaseBuffer(mfxFrameSurface1 *pSurface);\n\n    HRESULT HandleOutput(MVCBuffer *pOutputBuffer);\n    HRESULT DeliverOutput(MVCBuffer *pBaseView, MVCBuffer *pExtraView);\n\n    HRESULT ParseSEI(const BYTE *buffer, size_t size, mfxU64 timestamp);\n    HRESULT ParseMVCNestedSEI(const BYTE *buffer, size_t size, mfxU64 timestamp);\n    HRESULT ParseUnregUserDataSEI(const BYTE *buffer, size_t size, mfxU64 timestamp);\n    HRESULT ParseOffsetMetadata(const BYTE *buffer, size_t size, mfxU64 timestamp);\n\n    void AddFrameToGOP(mfxU64 timestamp);\n    BOOL RemoveFrameFromGOP(MVCGOP *pGOP, mfxU64 timestamp);\n    void GetOffsetSideData(LAVFrame *pFrame, mfxU64 timestamp);\n\n    static void msdk_buffer_destruct(LAVFrame *pFrame);\n\n  private:\n    mfxSession m_mfxSession = nullptr;\n    mfxVersion m_mfxVersion = {0};\n    mfxIMPL m_mfxImpl = 0;\n\n    BOOL m_bDecodeReady = FALSE;\n    mfxVideoParam m_mfxVideoParams = {0};\n\n    mfxExtBuffer *m_mfxExtParam[1] = {0};\n    mfxExtMVCSeqDesc m_mfxExtMVCSeq = {0};\n\n    CCritSec m_BufferCritSec;\n    std::vector<MVCBuffer *> m_BufferQueue;\n\n    GrowableArray<BYTE> m_buff;\n    int m_nMP4NALUSize = 0;\n\n    MVCBuffer *m_pOutputQueue[ASYNC_QUEUE_SIZE] = {0};\n    int m_nOutputQueuePosition = 0;\n\n    std::deque<MVCGOP> m_GOPs;\n    MediaSideData3DOffset m_PrevOffset;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/mvc/include/mfxcommon.h",
    "content": "/*******************************************************************************\n\nCopyright (C) 2013-2018 Intel Corporation.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n- Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n- Neither the name of Intel Corporation nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY INTEL CORPORATION \"AS IS\" AND ANY EXPRESS OR\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\nIN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nFile Name: mfxcommon.h\n\n*******************************************************************************/\n#ifndef __MFXCOMMON_H__\n#define __MFXCOMMON_H__\n#include \"mfxdefs.h\"\n\n#if !defined (__GNUC__)\n#pragma warning(disable: 4201)\n#endif\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif /* __cplusplus */\n\n#define MFX_MAKEFOURCC(A,B,C,D)    ((((int)A))+(((int)B)<<8)+(((int)C)<<16)+(((int)D)<<24))\n\n/* Extended Configuration Header Structure */\ntypedef struct {\n    mfxU32  BufferId;\n    mfxU32  BufferSz;\n} mfxExtBuffer;\n\n/* Library initialization and deinitialization */\ntypedef mfxI32 mfxIMPL;\n#define MFX_IMPL_BASETYPE(x) (0x00ff & (x))\n\nenum  {\n    MFX_IMPL_AUTO         = 0x0000,  /* Auto Selection/In or Not Supported/Out */\n    MFX_IMPL_SOFTWARE     = 0x0001,  /* Pure Software Implementation */\n    MFX_IMPL_HARDWARE     = 0x0002,  /* Hardware Accelerated Implementation (default device) */\n    MFX_IMPL_AUTO_ANY     = 0x0003,  /* Auto selection of any hardware/software implementation */\n    MFX_IMPL_HARDWARE_ANY = 0x0004,  /* Auto selection of any hardware implementation */\n    MFX_IMPL_HARDWARE2    = 0x0005,  /* Hardware accelerated implementation (2nd device) */\n    MFX_IMPL_HARDWARE3    = 0x0006,  /* Hardware accelerated implementation (3rd device) */\n    MFX_IMPL_HARDWARE4    = 0x0007,  /* Hardware accelerated implementation (4th device) */\n    MFX_IMPL_RUNTIME      = 0x0008,\n    MFX_IMPL_VIA_ANY      = 0x0100,\n    MFX_IMPL_VIA_D3D9     = 0x0200,\n    MFX_IMPL_VIA_D3D11    = 0x0300,\n    MFX_IMPL_VIA_VAAPI    = 0x0400,\n\n    MFX_IMPL_AUDIO                     = 0x8000,\n\n    MFX_IMPL_UNSUPPORTED  = 0x0000  /* One of the MFXQueryIMPL returns */\n};\n\n/* Version Info */\ntypedef union {\n    struct {\n        mfxU16  Minor;\n        mfxU16  Major;\n    };\n    mfxU32  Version;\n} mfxVersion;\n\n/* session priority */\ntypedef enum\n{\n    MFX_PRIORITY_LOW = 0,\n    MFX_PRIORITY_NORMAL = 1,\n    MFX_PRIORITY_HIGH = 2\n\n} mfxPriority;\n\ntypedef struct _mfxEncryptedData mfxEncryptedData;\ntypedef struct {\n     union {\n        struct {\n            mfxEncryptedData* EncryptedData;\n            mfxExtBuffer **ExtParam;\n            mfxU16  NumExtParam;\n        };\n         mfxU32  reserved[6];\n     };\n    mfxI64  DecodeTimeStamp;\n    mfxU64  TimeStamp;\n    mfxU8*  Data;\n    mfxU32  DataOffset;\n    mfxU32  DataLength;\n    mfxU32  MaxLength;\n\n    mfxU16  PicStruct;\n    mfxU16  FrameType;\n    mfxU16  DataFlag;\n    mfxU16  reserved2;\n} mfxBitstream;\n\ntypedef struct _mfxSyncPoint *mfxSyncPoint;\n\n/* GPUCopy */\nenum {\n    MFX_GPUCOPY_DEFAULT = 0,\n    MFX_GPUCOPY_ON      = 1,\n    MFX_GPUCOPY_OFF     = 2\n};\n\ntypedef struct {\n    mfxIMPL     Implementation;\n    mfxVersion  Version;\n    mfxU16      ExternalThreads;\n    union {\n        struct {\n            mfxExtBuffer **ExtParam;\n            mfxU16  NumExtParam;\n        };\n        mfxU16  reserved2[5];\n    };\n    mfxU16      GPUCopy;\n    mfxU16      reserved[21];\n} mfxInitParam;\n\nenum {\n    MFX_EXTBUFF_THREADS_PARAM = MFX_MAKEFOURCC('T','H','D','P')\n};\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16       NumThread;\n    mfxI32       SchedulingType;\n    mfxI32       Priority;\n    mfxU16       reserved[55];\n} mfxExtThreadsParam;\n\n/* PlatformCodeName */\nenum {\n    MFX_PLATFORM_UNKNOWN        = 0,\n    MFX_PLATFORM_SANDYBRIDGE    = 1,\n    MFX_PLATFORM_IVYBRIDGE      = 2,\n    MFX_PLATFORM_HASWELL        = 3,\n    MFX_PLATFORM_BAYTRAIL       = 4,\n    MFX_PLATFORM_BROADWELL      = 5,\n    MFX_PLATFORM_CHERRYTRAIL    = 6,\n    MFX_PLATFORM_SKYLAKE        = 7,\n    MFX_PLATFORM_APOLLOLAKE     = 8,\n    MFX_PLATFORM_KABYLAKE       = 9,\n    MFX_PLATFORM_GEMINILAKE     = 10,\n    MFX_PLATFORM_COFFEELAKE     = 11,\n    MFX_PLATFORM_CANNONLAKE     = 20,\n    MFX_PLATFORM_ICELAKE = 30,\n};\n\ntypedef struct {\n    mfxU16 CodeName;\n    mfxU16 DeviceId;\n    mfxU16 reserved[14];\n} mfxPlatform;\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/mvc/include/mfxdefs.h",
    "content": "/* ****************************************************************************** *\\\n\nCopyright (C) 2007-2018 Intel Corporation.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n- Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n- Neither the name of Intel Corporation nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY INTEL CORPORATION \"AS IS\" AND ANY EXPRESS OR\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\nIN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nFile Name: mfxdefs.h\n\n\\* ****************************************************************************** */\n#ifndef __MFXDEFS_H__\n#define __MFXDEFS_H__\n\n#define MFX_VERSION_MAJOR 1\n#define MFX_VERSION_MINOR 27\n\n#define MFX_VERSION_NEXT 1028\n\n#ifndef MFX_VERSION\n#define MFX_VERSION (MFX_VERSION_MAJOR * 1000 + MFX_VERSION_MINOR)\n#endif\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif /* __cplusplus */\n\n\n#if (defined( _WIN32 ) || defined ( _WIN64 )) && !defined (__GNUC__)\n  #define __INT64   __int64\n  #define __UINT64  unsigned __int64\n#else\n  #define __INT64   long long\n  #define __UINT64  unsigned long long\n#endif\n\n#ifdef _WIN32\n    #define MFX_CDECL __cdecl\n    #define MFX_STDCALL __stdcall\n#else\n    #define MFX_CDECL\n    #define MFX_STDCALL\n#endif /* _WIN32 */\n\n#define MFX_INFINITE 0xFFFFFFFF\n\ntypedef unsigned char       mfxU8;\ntypedef char                mfxI8;\ntypedef short               mfxI16;\ntypedef unsigned short      mfxU16;\ntypedef unsigned int        mfxU32;\ntypedef int                 mfxI32;\n#if defined( _WIN32 ) || defined ( _WIN64 )\ntypedef unsigned long       mfxUL32;\ntypedef long                mfxL32;\n#else\ntypedef unsigned int        mfxUL32;\ntypedef int                 mfxL32;\n#endif\ntypedef float               mfxF32;\ntypedef double              mfxF64;\ntypedef __UINT64            mfxU64;\ntypedef __INT64             mfxI64;\ntypedef void*               mfxHDL;\ntypedef mfxHDL              mfxMemId;\ntypedef void*               mfxThreadTask;\ntypedef char                mfxChar;\n\ntypedef struct {\n    mfxI16  x;\n    mfxI16  y;\n} mfxI16Pair;\n\ntypedef struct {\n    mfxHDL first;\n    mfxHDL second;\n} mfxHDLPair;\n\n\n/*********************************************************************************\\\nError message\n\\*********************************************************************************/\ntypedef enum\n{\n    /* no error */\n    MFX_ERR_NONE                        = 0,    /* no error */\n\n    /* reserved for unexpected errors */\n    MFX_ERR_UNKNOWN                     = -1,   /* unknown error. */\n\n    /* error codes <0 */\n    MFX_ERR_NULL_PTR                    = -2,   /* null pointer */\n    MFX_ERR_UNSUPPORTED                 = -3,   /* undeveloped feature */\n    MFX_ERR_MEMORY_ALLOC                = -4,   /* failed to allocate memory */\n    MFX_ERR_NOT_ENOUGH_BUFFER           = -5,   /* insufficient buffer at input/output */\n    MFX_ERR_INVALID_HANDLE              = -6,   /* invalid handle */\n    MFX_ERR_LOCK_MEMORY                 = -7,   /* failed to lock the memory block */\n    MFX_ERR_NOT_INITIALIZED             = -8,   /* member function called before initialization */\n    MFX_ERR_NOT_FOUND                   = -9,   /* the specified object is not found */\n    MFX_ERR_MORE_DATA                   = -10,  /* expect more data at input */\n    MFX_ERR_MORE_SURFACE                = -11,  /* expect more surface at output */\n    MFX_ERR_ABORTED                     = -12,  /* operation aborted */\n    MFX_ERR_DEVICE_LOST                 = -13,  /* lose the HW acceleration device */\n    MFX_ERR_INCOMPATIBLE_VIDEO_PARAM    = -14,  /* incompatible video parameters */\n    MFX_ERR_INVALID_VIDEO_PARAM         = -15,  /* invalid video parameters */\n    MFX_ERR_UNDEFINED_BEHAVIOR          = -16,  /* undefined behavior */\n    MFX_ERR_DEVICE_FAILED               = -17,  /* device operation failure */\n    MFX_ERR_MORE_BITSTREAM              = -18,  /* expect more bitstream buffers at output */\n    MFX_ERR_INCOMPATIBLE_AUDIO_PARAM    = -19,  /* incompatible audio parameters */\n    MFX_ERR_INVALID_AUDIO_PARAM         = -20,  /* invalid audio parameters */\n    MFX_ERR_GPU_HANG                    = -21,  /* device operation failure caused by GPU hang */\n    MFX_ERR_REALLOC_SURFACE             = -22,  /* bigger output surface required */\n\n    /* warnings >0 */\n    MFX_WRN_IN_EXECUTION                = 1,    /* the previous asynchronous operation is in execution */\n    MFX_WRN_DEVICE_BUSY                 = 2,    /* the HW acceleration device is busy */\n    MFX_WRN_VIDEO_PARAM_CHANGED         = 3,    /* the video parameters are changed during decoding */\n    MFX_WRN_PARTIAL_ACCELERATION        = 4,    /* SW is used */\n    MFX_WRN_INCOMPATIBLE_VIDEO_PARAM    = 5,    /* incompatible video parameters */\n    MFX_WRN_VALUE_NOT_CHANGED           = 6,    /* the value is saturated based on its valid range */\n    MFX_WRN_OUT_OF_RANGE                = 7,    /* the value is out of valid range */\n    MFX_WRN_FILTER_SKIPPED              = 10,   /* one of requested filters has been skipped */\n    MFX_WRN_INCOMPATIBLE_AUDIO_PARAM    = 11,   /* incompatible audio parameters */\n\n    /* threading statuses */\n    MFX_TASK_DONE = MFX_ERR_NONE,               /* task has been completed */\n    MFX_TASK_WORKING                    = 8,    /* there is some more work to do */\n    MFX_TASK_BUSY                       = 9,    /* task is waiting for resources */\n\n    /* plug-in statuses */\n    MFX_ERR_MORE_DATA_SUBMIT_TASK       = -10000, /* return MFX_ERR_MORE_DATA but submit internal asynchronous task */\n\n} mfxStatus;\n\n\n// Application\n#if defined(MFX_DISPATCHER_EXPOSED_PREFIX)\n\n#include \"mfxdispatcherprefixedfunctions.h\"\n\n#endif // MFX_DISPATCHER_EXPOSED_PREFIX\n\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* __MFXDEFS_H__ */\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/mvc/include/mfxmvc.h",
    "content": "/******************************************************************************* *\\\n\nCopyright (C) 2010-2013 Intel Corporation.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n- Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n- Neither the name of Intel Corporation nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY INTEL CORPORATION \"AS IS\" AND ANY EXPRESS OR\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\nIN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nFile Name: mfxmvc.h\n\n*******************************************************************************/\n#ifndef __MFXMVC_H__\n#define __MFXMVC_H__\n\n#include \"mfxdefs.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* CodecProfile, CodecLevel */\nenum {\n    /* MVC profiles */\n    MFX_PROFILE_AVC_MULTIVIEW_HIGH =118,\n    MFX_PROFILE_AVC_STEREO_HIGH    =128\n};\n\n/* Extended Buffer Ids */\nenum {\n    MFX_EXTBUFF_MVC_SEQ_DESC =   MFX_MAKEFOURCC('M','V','C','D'),\n    MFX_EXTBUFF_MVC_TARGET_VIEWS    =   MFX_MAKEFOURCC('M','V','C','T')\n};\n\ntypedef struct  {\n    mfxU16 ViewId;\n\n    mfxU16 NumAnchorRefsL0;\n    mfxU16 NumAnchorRefsL1;\n    mfxU16 AnchorRefL0[16];\n    mfxU16 AnchorRefL1[16];\n\n    mfxU16 NumNonAnchorRefsL0;\n    mfxU16 NumNonAnchorRefsL1;\n    mfxU16 NonAnchorRefL0[16];\n    mfxU16 NonAnchorRefL1[16];\n} mfxMVCViewDependency;\n\ntypedef struct {\n    mfxU16 TemporalId;\n    mfxU16 LevelIdc;\n\n    mfxU16 NumViews;\n    mfxU16 NumTargetViews;\n    mfxU16 *TargetViewId;\n} mfxMVCOperationPoint;\n\ntypedef struct  {\n    mfxExtBuffer Header;\n\n    mfxU32 NumView;\n    mfxU32 NumViewAlloc;\n    mfxMVCViewDependency *View;\n\n    mfxU32 NumViewId;\n    mfxU32 NumViewIdAlloc;\n    mfxU16 *ViewId;\n\n    mfxU32 NumOP;\n    mfxU32 NumOPAlloc;\n    mfxMVCOperationPoint *OP;\n\n    mfxU16 NumRefsTotal;\n    mfxU32 Reserved[16];\n\n} mfxExtMVCSeqDesc;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    mfxU16 TemporalId;\n    mfxU32 NumView;\n    mfxU16 ViewId[1024];\n} mfxExtMVCTargetViews ;\n\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif\n\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/mvc/include/mfxsession.h",
    "content": "/*******************************************************************************\n\nCopyright (C) 2013 Intel Corporation.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n- Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n- Neither the name of Intel Corporation nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY INTEL CORPORATION \"AS IS\" AND ANY EXPRESS OR\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\nIN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nFile Name: mfxsession.h\n\n*******************************************************************************/\n#ifndef __MFXSESSION_H__\n#define __MFXSESSION_H__\n#include \"mfxcommon.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif /* __cplusplus */\n\n/* Global Functions */\ntypedef struct _mfxSession *mfxSession;\nmfxStatus MFX_CDECL MFXInit(mfxIMPL impl, mfxVersion *ver, mfxSession *session);\nmfxStatus MFX_CDECL MFXInitEx(mfxInitParam par, mfxSession *session);\nmfxStatus MFX_CDECL MFXClose(mfxSession session);\n\nmfxStatus MFX_CDECL MFXQueryIMPL(mfxSession session, mfxIMPL *impl);\nmfxStatus MFX_CDECL MFXQueryVersion(mfxSession session, mfxVersion *version);\n\nmfxStatus MFX_CDECL MFXJoinSession(mfxSession session, mfxSession child);\nmfxStatus MFX_CDECL MFXDisjoinSession(mfxSession session);\nmfxStatus MFX_CDECL MFXCloneSession(mfxSession session, mfxSession *clone);\nmfxStatus MFX_CDECL MFXSetPriority(mfxSession session, mfxPriority priority);\nmfxStatus MFX_CDECL MFXGetPriority(mfxSession session, mfxPriority *priority);\nmfxStatus MFX_CDECL MFXDoWork(mfxSession session);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif\n\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/mvc/include/mfxstructures.h",
    "content": "/******************************************************************************* *\\\n\nCopyright (C) 2007-2018 Intel Corporation.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n- Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n- Neither the name of Intel Corporation nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY INTEL CORPORATION \"AS IS\" AND ANY EXPRESS OR\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\nIN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nFile Name: mfxstructures.h\n\n*******************************************************************************/\n#ifndef __MFXSTRUCTURES_H__\n#define __MFXSTRUCTURES_H__\n#include \"mfxcommon.h\"\n\n#if !defined (__GNUC__)\n#pragma warning(disable: 4201)\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/* Frame ID for SVC and MVC */\ntypedef struct {\n    mfxU16      TemporalId;\n    mfxU16      PriorityId;\n    union {\n        struct {\n            mfxU16  DependencyId;\n            mfxU16  QualityId;\n        };\n        struct {\n            mfxU16  ViewId;\n        };\n    };\n} mfxFrameId;\n\n#pragma pack(push, 4)\n/* Frame Info */\ntypedef struct {\n    mfxU32  reserved[4];\n    mfxU16  reserved4;\n    mfxU16  BitDepthLuma;\n    mfxU16  BitDepthChroma;\n    mfxU16  Shift;\n\n    mfxFrameId FrameId;\n\n    mfxU32  FourCC;\n    union {\n        struct { /* Frame parameters */\n            mfxU16  Width;\n            mfxU16  Height;\n\n            mfxU16  CropX;\n            mfxU16  CropY;\n            mfxU16  CropW;\n            mfxU16  CropH;\n        };\n        struct { /* Buffer parameters (for plain formats like P8) */\n            mfxU64 BufferSize;\n            mfxU32 reserved5;\n        };\n    };\n\n    mfxU32  FrameRateExtN;\n    mfxU32  FrameRateExtD;\n    mfxU16  reserved3;\n\n    mfxU16  AspectRatioW;\n    mfxU16  AspectRatioH;\n\n    mfxU16  PicStruct;\n    mfxU16  ChromaFormat;\n    mfxU16  reserved2;\n} mfxFrameInfo;\n#pragma pack(pop)\n\n/* FourCC */\nenum {\n    MFX_FOURCC_NV12         = MFX_MAKEFOURCC('N','V','1','2'),   /* Native Format */\n    MFX_FOURCC_YV12         = MFX_MAKEFOURCC('Y','V','1','2'),\n    MFX_FOURCC_NV16         = MFX_MAKEFOURCC('N','V','1','6'),\n    MFX_FOURCC_YUY2         = MFX_MAKEFOURCC('Y','U','Y','2'),\n    MFX_FOURCC_RGB3         = MFX_MAKEFOURCC('R','G','B','3'),   /* deprecated */\n    MFX_FOURCC_RGB4         = MFX_MAKEFOURCC('R','G','B','4'),   /* ARGB in that order, A channel is 8 MSBs */\n    MFX_FOURCC_P8           = 41,                                /*  D3DFMT_P8   */\n    MFX_FOURCC_P8_TEXTURE   = MFX_MAKEFOURCC('P','8','M','B'),\n    MFX_FOURCC_P010         = MFX_MAKEFOURCC('P','0','1','0'),\n    MFX_FOURCC_P210         = MFX_MAKEFOURCC('P','2','1','0'),\n    MFX_FOURCC_BGR4         = MFX_MAKEFOURCC('B','G','R','4'),   /* ABGR in that order, A channel is 8 MSBs */\n    MFX_FOURCC_A2RGB10      = MFX_MAKEFOURCC('R','G','1','0'),   /* ARGB in that order, A channel is two MSBs */\n    MFX_FOURCC_ARGB16       = MFX_MAKEFOURCC('R','G','1','6'),   /* ARGB in that order, 64 bits, A channel is 16 MSBs */\n    MFX_FOURCC_ABGR16       = MFX_MAKEFOURCC('B','G','1','6'),   /* ABGR in that order, 64 bits, A channel is 16 MSBs */\n    MFX_FOURCC_R16          = MFX_MAKEFOURCC('R','1','6','U'),\n    MFX_FOURCC_AYUV         = MFX_MAKEFOURCC('A','Y','U','V'),   /* YUV 4:4:4, AYUV in that order, A channel is 8 MSBs */\n    MFX_FOURCC_AYUV_RGB4    = MFX_MAKEFOURCC('A','V','U','Y'),   /* ARGB in that order, A channel is 8 MSBs stored in AYUV surface*/\n    MFX_FOURCC_UYVY         = MFX_MAKEFOURCC('U','Y','V','Y'),\n    MFX_FOURCC_Y210         = MFX_MAKEFOURCC('Y','2','1','0'),\n    MFX_FOURCC_Y410         = MFX_MAKEFOURCC('Y','4','1','0'),\n};\n\n/* PicStruct */\nenum {\n    MFX_PICSTRUCT_UNKNOWN       =0x00,\n    MFX_PICSTRUCT_PROGRESSIVE   =0x01,\n    MFX_PICSTRUCT_FIELD_TFF     =0x02,\n    MFX_PICSTRUCT_FIELD_BFF     =0x04,\n\n    MFX_PICSTRUCT_FIELD_REPEATED=0x10,  /* first field repeated, pic_struct=5 or 6 in H.264 */\n    MFX_PICSTRUCT_FRAME_DOUBLING=0x20,  /* pic_struct=7 in H.264 */\n    MFX_PICSTRUCT_FRAME_TRIPLING=0x40,  /* pic_struct=8 in H.264 */\n\n    MFX_PICSTRUCT_FIELD_SINGLE      =0x100,\n    MFX_PICSTRUCT_FIELD_TOP         =MFX_PICSTRUCT_FIELD_SINGLE | MFX_PICSTRUCT_FIELD_TFF,\n    MFX_PICSTRUCT_FIELD_BOTTOM      =MFX_PICSTRUCT_FIELD_SINGLE | MFX_PICSTRUCT_FIELD_BFF,\n    MFX_PICSTRUCT_FIELD_PAIRED_PREV =0x200,\n    MFX_PICSTRUCT_FIELD_PAIRED_NEXT =0x400,\n};\n\n/* ColorFormat */\nenum {\n    MFX_CHROMAFORMAT_MONOCHROME =0,\n    MFX_CHROMAFORMAT_YUV420     =1,\n    MFX_CHROMAFORMAT_YUV422     =2,\n    MFX_CHROMAFORMAT_YUV444     =3,\n    MFX_CHROMAFORMAT_YUV400     = MFX_CHROMAFORMAT_MONOCHROME,\n    MFX_CHROMAFORMAT_YUV411     = 4,\n    MFX_CHROMAFORMAT_YUV422H    = MFX_CHROMAFORMAT_YUV422,\n    MFX_CHROMAFORMAT_YUV422V    = 5,\n    MFX_CHROMAFORMAT_RESERVED1  = 6\n};\n\nenum {\n    MFX_TIMESTAMP_UNKNOWN = -1\n};\n\nenum {\n    MFX_FRAMEORDER_UNKNOWN = -1\n};\n\n/* DataFlag in mfxFrameData */\nenum {\n    MFX_FRAMEDATA_ORIGINAL_TIMESTAMP = 0x0001\n};\n\n/* Corrupted in mfxFrameData */\nenum {\n    MFX_CORRUPTION_MINOR           = 0x0001,\n    MFX_CORRUPTION_MAJOR           = 0x0002,\n    MFX_CORRUPTION_ABSENT_TOP_FIELD           = 0x0004,\n    MFX_CORRUPTION_ABSENT_BOTTOM_FIELD           = 0x0008,\n    MFX_CORRUPTION_REFERENCE_FRAME = 0x0010,\n    MFX_CORRUPTION_REFERENCE_LIST  = 0x0020\n};\n\n#pragma pack(push, 4)\ntypedef struct\n{\n    mfxU32 U : 10;\n    mfxU32 Y : 10;\n    mfxU32 V : 10;\n    mfxU32 A :  2;\n} mfxY410;\n#pragma pack(pop)\n\n#pragma pack(push, 4)\ntypedef struct\n{\n    mfxU32 B : 10;\n    mfxU32 G : 10;\n    mfxU32 R : 10;\n    mfxU32 A :  2;\n} mfxA2RGB10;\n#pragma pack(pop)\n\n\n/* Frame Data Info */\ntypedef struct {\n    union {\n        mfxExtBuffer **ExtParam;\n        mfxU64       reserved2;\n    };\n    mfxU16  NumExtParam;\n\n    mfxU16      reserved[9];\n    mfxU16      MemType;\n    mfxU16      PitchHigh;\n\n    mfxU64      TimeStamp;\n    mfxU32      FrameOrder;\n    mfxU16      Locked;\n    union{\n        mfxU16  Pitch;\n        mfxU16  PitchLow;\n    };\n\n    /* color planes */\n    union {\n        mfxU8   *Y;\n        mfxU16  *Y16;\n        mfxU8   *R;\n    };\n    union {\n        mfxU8   *UV;            /* for UV merged formats */\n        mfxU8   *VU;            /* for VU merged formats */\n        mfxU8   *CbCr;          /* for CbCr merged formats */\n        mfxU8   *CrCb;          /* for CrCb merged formats */\n        mfxU8   *Cb;\n        mfxU8   *U;\n        mfxU16  *U16;\n        mfxU8   *G;\n        mfxY410 *Y410;          /* for Y410 format (merged AVYU) */\n    };\n    union {\n        mfxU8   *Cr;\n        mfxU8   *V;\n        mfxU16  *V16;\n        mfxU8   *B;\n        mfxA2RGB10 *A2RGB10;    /* for A2RGB10 format (merged ARGB) */\n    };\n    mfxU8       *A;\n    mfxMemId    MemId;\n\n    /* Additional Flags */\n    mfxU16  Corrupted;\n    mfxU16  DataFlag;\n} mfxFrameData;\n\n/* Frame Surface */\ntypedef struct {\n    mfxU32  reserved[4];\n    mfxFrameInfo    Info;\n    mfxFrameData    Data;\n} mfxFrameSurface1;\n\nenum {\n    MFX_TIMESTAMPCALC_UNKNOWN = 0,\n    MFX_TIMESTAMPCALC_TELECINE = 1,\n};\n\n/* Transcoding Info */\ntypedef struct {\n    mfxU32  reserved[7];\n\n    mfxU16  LowPower;\n    mfxU16  BRCParamMultiplier;\n\n    mfxFrameInfo    FrameInfo;\n    mfxU32  CodecId;\n    mfxU16  CodecProfile;\n    mfxU16  CodecLevel;\n    mfxU16  NumThread;\n\n    union {\n        struct {   /* Encoding Options */\n            mfxU16  TargetUsage;\n\n            mfxU16  GopPicSize;\n            mfxU16  GopRefDist;\n            mfxU16  GopOptFlag;\n            mfxU16  IdrInterval;\n\n            mfxU16  RateControlMethod;\n            union {\n                mfxU16  InitialDelayInKB;\n                mfxU16  QPI;\n                mfxU16  Accuracy;\n            };\n            mfxU16  BufferSizeInKB;\n            union {\n                mfxU16  TargetKbps;\n                mfxU16  QPP;\n                mfxU16  ICQQuality;\n            };\n            union {\n                mfxU16  MaxKbps;\n                mfxU16  QPB;\n                mfxU16  Convergence;\n            };\n\n            mfxU16  NumSlice;\n            mfxU16  NumRefFrame;\n            mfxU16  EncodedOrder;\n        };\n        struct {   /* Decoding Options */\n            mfxU16  DecodedOrder;\n            mfxU16  ExtendedPicStruct;\n            mfxU16  TimeStampCalc;\n            mfxU16  SliceGroupsPresent;\n            mfxU16  MaxDecFrameBuffering;\n            mfxU16  EnableReallocRequest;\n            mfxU16  reserved2[7];\n        };\n        struct {   /* JPEG Decoding Options */\n            mfxU16  JPEGChromaFormat;\n            mfxU16  Rotation;\n            mfxU16  JPEGColorFormat;\n            mfxU16  InterleavedDec;\n            mfxU8   SamplingFactorH[4];\n            mfxU8   SamplingFactorV[4];\n            mfxU16  reserved3[5];\n        };\n        struct {   /* JPEG Encoding Options */\n            mfxU16  Interleaved;\n            mfxU16  Quality;\n            mfxU16  RestartInterval;\n            mfxU16  reserved5[10];\n        };\n    };\n} mfxInfoMFX;\n\ntypedef struct {\n    mfxU32  reserved[8];\n    mfxFrameInfo    In;\n    mfxFrameInfo    Out;\n} mfxInfoVPP;\n\ntypedef struct {\n    mfxU32  AllocId;\n    mfxU32  reserved[2];\n    mfxU16  reserved3;\n    mfxU16  AsyncDepth;\n\n    union {\n        mfxInfoMFX  mfx;\n        mfxInfoVPP  vpp;\n    };\n    mfxU16  Protected;\n    mfxU16  IOPattern;\n    mfxExtBuffer** ExtParam;\n    mfxU16  NumExtParam;\n    mfxU16  reserved2;\n} mfxVideoParam;\n\n/* IOPattern */\nenum {\n    MFX_IOPATTERN_IN_VIDEO_MEMORY   = 0x01,\n    MFX_IOPATTERN_IN_SYSTEM_MEMORY  = 0x02,\n    MFX_IOPATTERN_IN_OPAQUE_MEMORY  = 0x04,\n    MFX_IOPATTERN_OUT_VIDEO_MEMORY  = 0x10,\n    MFX_IOPATTERN_OUT_SYSTEM_MEMORY = 0x20,\n    MFX_IOPATTERN_OUT_OPAQUE_MEMORY = 0x40\n};\n\n/* CodecId */\nenum {\n    MFX_CODEC_AVC         =MFX_MAKEFOURCC('A','V','C',' '),\n    MFX_CODEC_HEVC        =MFX_MAKEFOURCC('H','E','V','C'),\n    MFX_CODEC_MPEG2       =MFX_MAKEFOURCC('M','P','G','2'),\n    MFX_CODEC_VC1         =MFX_MAKEFOURCC('V','C','1',' '),\n    MFX_CODEC_CAPTURE     =MFX_MAKEFOURCC('C','A','P','T'),\n    MFX_CODEC_VP9         =MFX_MAKEFOURCC('V','P','9',' '),\n    MFX_CODEC_AV1         =MFX_MAKEFOURCC('A','V','1',' ')\n};\n\n/* CodecProfile, CodecLevel */\nenum {\n    MFX_PROFILE_UNKNOWN                     =0,\n    MFX_LEVEL_UNKNOWN                       =0,\n\n    /* AVC Profiles & Levels */\n    MFX_PROFILE_AVC_CONSTRAINT_SET0     = (0x100 << 0),\n    MFX_PROFILE_AVC_CONSTRAINT_SET1     = (0x100 << 1),\n    MFX_PROFILE_AVC_CONSTRAINT_SET2     = (0x100 << 2),\n    MFX_PROFILE_AVC_CONSTRAINT_SET3     = (0x100 << 3),\n    MFX_PROFILE_AVC_CONSTRAINT_SET4     = (0x100 << 4),\n    MFX_PROFILE_AVC_CONSTRAINT_SET5     = (0x100 << 5),\n\n    MFX_PROFILE_AVC_BASELINE                =66,\n    MFX_PROFILE_AVC_MAIN                    =77,\n    MFX_PROFILE_AVC_EXTENDED                =88,\n    MFX_PROFILE_AVC_HIGH                    =100,\n    MFX_PROFILE_AVC_HIGH_422                =122,\n    MFX_PROFILE_AVC_CONSTRAINED_BASELINE    =MFX_PROFILE_AVC_BASELINE + MFX_PROFILE_AVC_CONSTRAINT_SET1,\n    MFX_PROFILE_AVC_CONSTRAINED_HIGH        =MFX_PROFILE_AVC_HIGH     + MFX_PROFILE_AVC_CONSTRAINT_SET4\n                                                                      + MFX_PROFILE_AVC_CONSTRAINT_SET5,\n    MFX_PROFILE_AVC_PROGRESSIVE_HIGH        =MFX_PROFILE_AVC_HIGH     + MFX_PROFILE_AVC_CONSTRAINT_SET4,\n\n    MFX_LEVEL_AVC_1                         =10,\n    MFX_LEVEL_AVC_1b                        =9,\n    MFX_LEVEL_AVC_11                        =11,\n    MFX_LEVEL_AVC_12                        =12,\n    MFX_LEVEL_AVC_13                        =13,\n    MFX_LEVEL_AVC_2                         =20,\n    MFX_LEVEL_AVC_21                        =21,\n    MFX_LEVEL_AVC_22                        =22,\n    MFX_LEVEL_AVC_3                         =30,\n    MFX_LEVEL_AVC_31                        =31,\n    MFX_LEVEL_AVC_32                        =32,\n    MFX_LEVEL_AVC_4                         =40,\n    MFX_LEVEL_AVC_41                        =41,\n    MFX_LEVEL_AVC_42                        =42,\n    MFX_LEVEL_AVC_5                         =50,\n    MFX_LEVEL_AVC_51                        =51,\n    MFX_LEVEL_AVC_52                        =52,\n\n    /* MPEG-2 Profiles & Levels */\n    MFX_PROFILE_MPEG2_SIMPLE                =0x50,\n    MFX_PROFILE_MPEG2_MAIN                  =0x40,\n    MFX_PROFILE_MPEG2_HIGH                  =0x10,\n\n    MFX_LEVEL_MPEG2_LOW                     =0xA,\n    MFX_LEVEL_MPEG2_MAIN                    =0x8,\n    MFX_LEVEL_MPEG2_HIGH                    =0x4,\n    MFX_LEVEL_MPEG2_HIGH1440                =0x6,\n\n    /* VC1 Profiles & Levels */\n    MFX_PROFILE_VC1_SIMPLE                  =(0+1),\n    MFX_PROFILE_VC1_MAIN                    =(4+1),\n    MFX_PROFILE_VC1_ADVANCED                =(12+1),\n\n    /* VC1 levels for simple & main profiles */\n    MFX_LEVEL_VC1_LOW                       =(0+1),\n    MFX_LEVEL_VC1_MEDIAN                    =(2+1),\n    MFX_LEVEL_VC1_HIGH                      =(4+1),\n\n    /* VC1 levels for the advanced profile */\n    MFX_LEVEL_VC1_0                         =(0x00+1),\n    MFX_LEVEL_VC1_1                         =(0x01+1),\n    MFX_LEVEL_VC1_2                         =(0x02+1),\n    MFX_LEVEL_VC1_3                         =(0x03+1),\n    MFX_LEVEL_VC1_4                         =(0x04+1),\n\n    /* HEVC Profiles & Levels & Tiers */\n    MFX_PROFILE_HEVC_MAIN             =1,\n    MFX_PROFILE_HEVC_MAIN10           =2,\n    MFX_PROFILE_HEVC_MAINSP           =3,\n    MFX_PROFILE_HEVC_REXT             =4,\n\n    MFX_LEVEL_HEVC_1   = 10,\n    MFX_LEVEL_HEVC_2   = 20,\n    MFX_LEVEL_HEVC_21  = 21,\n    MFX_LEVEL_HEVC_3   = 30,\n    MFX_LEVEL_HEVC_31  = 31,\n    MFX_LEVEL_HEVC_4   = 40,\n    MFX_LEVEL_HEVC_41  = 41,\n    MFX_LEVEL_HEVC_5   = 50,\n    MFX_LEVEL_HEVC_51  = 51,\n    MFX_LEVEL_HEVC_52  = 52,\n    MFX_LEVEL_HEVC_6   = 60,\n    MFX_LEVEL_HEVC_61  = 61,\n    MFX_LEVEL_HEVC_62  = 62,\n\n    MFX_TIER_HEVC_MAIN  = 0,\n    MFX_TIER_HEVC_HIGH  = 0x100,\n\n    /* VP9 Profiles */\n    MFX_PROFILE_VP9_0                       = 1,\n    MFX_PROFILE_VP9_1                       = 2,\n    MFX_PROFILE_VP9_2                       = 3,\n    MFX_PROFILE_VP9_3                       = 4,\n\n};\n\n/* GopOptFlag */\nenum {\n    MFX_GOP_CLOSED          =1,\n    MFX_GOP_STRICT          =2\n};\n\n/* TargetUsages: from 1 to 7 inclusive */\nenum {\n    MFX_TARGETUSAGE_1    =1,\n    MFX_TARGETUSAGE_2    =2,\n    MFX_TARGETUSAGE_3    =3,\n    MFX_TARGETUSAGE_4    =4,\n    MFX_TARGETUSAGE_5    =5,\n    MFX_TARGETUSAGE_6    =6,\n    MFX_TARGETUSAGE_7    =7,\n\n    MFX_TARGETUSAGE_UNKNOWN         =0,\n    MFX_TARGETUSAGE_BEST_QUALITY    =MFX_TARGETUSAGE_1,\n    MFX_TARGETUSAGE_BALANCED        =MFX_TARGETUSAGE_4,\n    MFX_TARGETUSAGE_BEST_SPEED      =MFX_TARGETUSAGE_7\n};\n\n/* RateControlMethod */\nenum {\n    MFX_RATECONTROL_CBR       =1,\n    MFX_RATECONTROL_VBR       =2,\n    MFX_RATECONTROL_CQP       =3,\n    MFX_RATECONTROL_AVBR      =4,\n    MFX_RATECONTROL_RESERVED1 =5,\n    MFX_RATECONTROL_RESERVED2 =6,\n    MFX_RATECONTROL_RESERVED3 =100,\n    MFX_RATECONTROL_RESERVED4 =7,\n    MFX_RATECONTROL_LA        =8,\n    MFX_RATECONTROL_ICQ       =9,\n    MFX_RATECONTROL_VCM       =10,\n    MFX_RATECONTROL_LA_ICQ    =11,\n    MFX_RATECONTROL_LA_EXT    =12,\n    MFX_RATECONTROL_LA_HRD    =13,\n    MFX_RATECONTROL_QVBR      =14,\n};\n\n/* Trellis control*/\nenum {\n    MFX_TRELLIS_UNKNOWN =0,\n    MFX_TRELLIS_OFF     =0x01,\n    MFX_TRELLIS_I       =0x02,\n    MFX_TRELLIS_P       =0x04,\n    MFX_TRELLIS_B       =0x08\n};\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16      reserved1;\n    mfxU16      RateDistortionOpt;      /* tri-state option */\n    mfxU16      MECostType;\n    mfxU16      MESearchType;\n    mfxI16Pair  MVSearchWindow;\n    mfxU16      EndOfSequence;          /* tri-state option */\n    mfxU16      FramePicture;           /* tri-state option */\n\n    mfxU16      CAVLC;                  /* tri-state option */\n    mfxU16      reserved2[2];\n    mfxU16      RecoveryPointSEI;       /* tri-state option */\n    mfxU16      ViewOutput;             /* tri-state option */\n    mfxU16      NalHrdConformance;      /* tri-state option */\n    mfxU16      SingleSeiNalUnit;       /* tri-state option */\n    mfxU16      VuiVclHrdParameters;    /* tri-state option */\n\n    mfxU16      RefPicListReordering;   /* tri-state option */\n    mfxU16      ResetRefList;           /* tri-state option */\n    mfxU16      RefPicMarkRep;          /* tri-state option */\n    mfxU16      FieldOutput;            /* tri-state option */\n\n    mfxU16      IntraPredBlockSize;\n    mfxU16      InterPredBlockSize;\n    mfxU16      MVPrecision;\n    mfxU16      MaxDecFrameBuffering;\n\n    mfxU16      AUDelimiter;            /* tri-state option */\n    mfxU16      EndOfStream;            /* tri-state option */\n    mfxU16      PicTimingSEI;           /* tri-state option */\n    mfxU16      VuiNalHrdParameters;    /* tri-state option */\n} mfxExtCodingOption;\n\nenum {\n    MFX_B_REF_UNKNOWN = 0,\n    MFX_B_REF_OFF     = 1,\n    MFX_B_REF_PYRAMID = 2\n};\n\nenum {\n    MFX_LOOKAHEAD_DS_UNKNOWN = 0,\n    MFX_LOOKAHEAD_DS_OFF     = 1,\n    MFX_LOOKAHEAD_DS_2x      = 2,\n    MFX_LOOKAHEAD_DS_4x      = 3\n};\n\nenum {\n    MFX_BPSEI_DEFAULT = 0x00,\n    MFX_BPSEI_IFRAME  = 0x01\n};\n\nenum {\n    MFX_SKIPFRAME_NO_SKIP         = 0,\n    MFX_SKIPFRAME_INSERT_DUMMY    = 1,\n    MFX_SKIPFRAME_INSERT_NOTHING  = 2,\n    MFX_SKIPFRAME_BRC_ONLY        = 3,\n};\n\n/* Intra refresh types */\nenum {\n        MFX_REFRESH_NO             = 0,\n        MFX_REFRESH_VERTICAL       = 1,\n        MFX_REFRESH_HORIZONTAL     = 2,\n        MFX_REFRESH_SLICE          = 3\n};\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16      IntRefType;\n    mfxU16      IntRefCycleSize;\n    mfxI16      IntRefQPDelta;\n\n    mfxU32      MaxFrameSize;\n    mfxU32      MaxSliceSize;\n\n    mfxU16      BitrateLimit;           /* tri-state option */\n    mfxU16      MBBRC;                  /* tri-state option */\n    mfxU16      ExtBRC;                 /* tri-state option */\n    mfxU16      LookAheadDepth;\n    mfxU16      Trellis;\n    mfxU16      RepeatPPS;              /* tri-state option */\n    mfxU16      BRefType;\n    mfxU16      AdaptiveI;              /* tri-state option */\n    mfxU16      AdaptiveB;              /* tri-state option */\n    mfxU16      LookAheadDS;\n    mfxU16      NumMbPerSlice;\n    mfxU16      SkipFrame;\n    mfxU8       MinQPI;                 /* 1..51, 0 = default */\n    mfxU8       MaxQPI;                 /* 1..51, 0 = default */\n    mfxU8       MinQPP;                 /* 1..51, 0 = default */\n    mfxU8       MaxQPP;                 /* 1..51, 0 = default */\n    mfxU8       MinQPB;                 /* 1..51, 0 = default */\n    mfxU8       MaxQPB;                 /* 1..51, 0 = default */\n    mfxU16      FixedFrameRate;         /* tri-state option */\n    mfxU16      DisableDeblockingIdc;\n    mfxU16      DisableVUI;\n    mfxU16      BufferingPeriodSEI;\n    mfxU16      EnableMAD;              /* tri-state option */\n    mfxU16      UseRawRef;              /* tri-state option */\n} mfxExtCodingOption2;\n\n/* WeightedPred */\nenum {\n    MFX_WEIGHTED_PRED_UNKNOWN  = 0,\n    MFX_WEIGHTED_PRED_DEFAULT  = 1,\n    MFX_WEIGHTED_PRED_EXPLICIT = 2,\n    MFX_WEIGHTED_PRED_IMPLICIT = 3\n};\n\n/* ScenarioInfo */\nenum {\n    MFX_SCENARIO_UNKNOWN             = 0,\n    MFX_SCENARIO_DISPLAY_REMOTING    = 1,\n    MFX_SCENARIO_VIDEO_CONFERENCE    = 2,\n    MFX_SCENARIO_ARCHIVE             = 3,\n    MFX_SCENARIO_LIVE_STREAMING      = 4,\n    MFX_SCENARIO_CAMERA_CAPTURE      = 5\n};\n\n/* ContentInfo */\nenum {\n    MFX_CONTENT_UNKNOWN              = 0,\n    MFX_CONTENT_FULL_SCREEN_VIDEO    = 1,\n    MFX_CONTENT_NON_VIDEO_SCREEN     = 2\n};\n\n/* PRefType */\nenum {\n    MFX_P_REF_DEFAULT = 0,\n    MFX_P_REF_SIMPLE  = 1,\n    MFX_P_REF_PYRAMID = 2\n};\n\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16      NumSliceI;\n    mfxU16      NumSliceP;\n    mfxU16      NumSliceB;\n\n    mfxU16      WinBRCMaxAvgKbps;\n    mfxU16      WinBRCSize;\n\n    mfxU16      QVBRQuality;\n    mfxU16      EnableMBQP;\n    mfxU16      IntRefCycleDist;\n    mfxU16      DirectBiasAdjustment;          /* tri-state option */\n    mfxU16      GlobalMotionBiasAdjustment;    /* tri-state option */\n    mfxU16      MVCostScalingFactor;\n    mfxU16      MBDisableSkipMap;              /* tri-state option */\n\n    mfxU16      WeightedPred;\n    mfxU16      WeightedBiPred;\n\n    mfxU16      AspectRatioInfoPresent;         /* tri-state option */\n    mfxU16      OverscanInfoPresent;            /* tri-state option */\n    mfxU16      OverscanAppropriate;            /* tri-state option */\n    mfxU16      TimingInfoPresent;              /* tri-state option */\n    mfxU16      BitstreamRestriction;           /* tri-state option */\n    mfxU16      LowDelayHrd;                    /* tri-state option */\n    mfxU16      MotionVectorsOverPicBoundaries; /* tri-state option */\n    mfxU16      reserved1[2];\n\n    mfxU16      ScenarioInfo;\n    mfxU16      ContentInfo;\n\n    mfxU16      PRefType;\n    mfxU16      FadeDetection;            /* tri-state option */\n    mfxU16      reserved2[2];\n    mfxU16      GPB;                      /* tri-state option */\n\n    mfxU32      MaxFrameSizeI;\n    mfxU32      MaxFrameSizeP;\n    mfxU32      reserved3[3];\n\n    mfxU16      EnableQPOffset;           /* tri-state option */\n    mfxI16      QPOffset[8];              /* FrameQP = QPX + QPOffset[pyramid_layer]; QPX = QPB for B-pyramid, QPP for P-pyramid */\n\n    mfxU16      NumRefActiveP[8];\n    mfxU16      NumRefActiveBL0[8];\n    mfxU16      NumRefActiveBL1[8];\n\n    mfxU16      reserved6;\n    mfxU16      TransformSkip;  /* tri-state option; HEVC transform_skip_enabled_flag */\n    mfxU16      TargetChromaFormatPlus1;   /* Minus 1 specifies target encoding chroma format (see ColorFormat enum). May differ from input one. */\n    mfxU16      TargetBitDepthLuma;        /* Target encoding bit depth for luma samples. May differ from input one. */\n    mfxU16      TargetBitDepthChroma;      /* Target encoding bit depth for chroma samples. May differ from input one. */\n    mfxU16      BRCPanicMode;              /* tri-state option */\n\n    mfxU16      LowDelayBRC;               /* tri-state option */\n    mfxU16      EnableMBForceIntra;        /* tri-state option */\n    mfxU16      AdaptiveMaxFrameSize;      /* tri-state option */\n\n    mfxU16      RepartitionCheckEnable;    /* tri-state option */\n    mfxU16      reserved5[3];\n    mfxU16      EncodedUnitsInfo;          /* tri-state option */\n    mfxU16      EnableNalUnitType;         /* tri-state option */\n    mfxU16      ExtBrcAdaptiveLTR;         /* tri-state option for ExtBRC */\n    mfxU16      reserved[163];\n} mfxExtCodingOption3;\n\n/* IntraPredBlockSize/InterPredBlockSize */\nenum {\n    MFX_BLOCKSIZE_UNKNOWN   = 0,\n    MFX_BLOCKSIZE_MIN_16X16 = 1, /* 16x16              */\n    MFX_BLOCKSIZE_MIN_8X8   = 2, /* 16x16, 8x8         */\n    MFX_BLOCKSIZE_MIN_4X4   = 3  /* 16x16, 8x8, 4x4    */\n};\n\n/* MVPrecision */\nenum {\n    MFX_MVPRECISION_UNKNOWN    = 0,\n    MFX_MVPRECISION_INTEGER    = (1 << 0),\n    MFX_MVPRECISION_HALFPEL    = (1 << 1),\n    MFX_MVPRECISION_QUARTERPEL = (1 << 2)\n};\n\nenum {\n    MFX_CODINGOPTION_UNKNOWN    =0,\n    MFX_CODINGOPTION_ON         =0x10,\n    MFX_CODINGOPTION_OFF        =0x20,\n    MFX_CODINGOPTION_ADAPTIVE   =0x30\n};\n\n/* Data Flag for mfxBitstream*/\nenum {\n    MFX_BITSTREAM_COMPLETE_FRAME    = 0x0001,        /* the bitstream contains a complete frame or field pair of data */\n    MFX_BITSTREAM_EOS               = 0x0002\n};\n/* Extended Buffer Ids */\nenum {\n    MFX_EXTBUFF_CODING_OPTION                   = MFX_MAKEFOURCC('C','D','O','P'),\n    MFX_EXTBUFF_CODING_OPTION_SPSPPS            = MFX_MAKEFOURCC('C','O','S','P'),\n    MFX_EXTBUFF_VPP_DONOTUSE                    = MFX_MAKEFOURCC('N','U','S','E'),\n    MFX_EXTBUFF_VPP_AUXDATA                     = MFX_MAKEFOURCC('A','U','X','D'),\n    MFX_EXTBUFF_VPP_DENOISE                     = MFX_MAKEFOURCC('D','N','I','S'),\n    MFX_EXTBUFF_VPP_SCENE_ANALYSIS              = MFX_MAKEFOURCC('S','C','L','Y'),\n    MFX_EXTBUFF_VPP_SCENE_CHANGE                = MFX_EXTBUFF_VPP_SCENE_ANALYSIS,\n    MFX_EXTBUFF_VPP_PROCAMP                     = MFX_MAKEFOURCC('P','A','M','P'),\n    MFX_EXTBUFF_VPP_DETAIL                      = MFX_MAKEFOURCC('D','E','T',' '),\n    MFX_EXTBUFF_VIDEO_SIGNAL_INFO               = MFX_MAKEFOURCC('V','S','I','N'),\n    MFX_EXTBUFF_VPP_DOUSE                       = MFX_MAKEFOURCC('D','U','S','E'),\n    MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION       = MFX_MAKEFOURCC('O','P','Q','S'),\n    MFX_EXTBUFF_AVC_REFLIST_CTRL                = MFX_MAKEFOURCC('R','L','S','T'),\n    MFX_EXTBUFF_VPP_FRAME_RATE_CONVERSION       = MFX_MAKEFOURCC('F','R','C',' '),\n    MFX_EXTBUFF_PICTURE_TIMING_SEI              = MFX_MAKEFOURCC('P','T','S','E'),\n    MFX_EXTBUFF_AVC_TEMPORAL_LAYERS             = MFX_MAKEFOURCC('A','T','M','L'),\n    MFX_EXTBUFF_CODING_OPTION2                  = MFX_MAKEFOURCC('C','D','O','2'),\n    MFX_EXTBUFF_VPP_IMAGE_STABILIZATION         = MFX_MAKEFOURCC('I','S','T','B'),\n    MFX_EXTBUFF_VPP_PICSTRUCT_DETECTION         = MFX_MAKEFOURCC('I','D','E','T'),\n    MFX_EXTBUFF_ENCODER_CAPABILITY              = MFX_MAKEFOURCC('E','N','C','P'),\n    MFX_EXTBUFF_ENCODER_RESET_OPTION            = MFX_MAKEFOURCC('E','N','R','O'),\n    MFX_EXTBUFF_ENCODED_FRAME_INFO              = MFX_MAKEFOURCC('E','N','F','I'),\n    MFX_EXTBUFF_VPP_COMPOSITE                   = MFX_MAKEFOURCC('V','C','M','P'),\n    MFX_EXTBUFF_VPP_VIDEO_SIGNAL_INFO           = MFX_MAKEFOURCC('V','V','S','I'),\n    MFX_EXTBUFF_ENCODER_ROI                     = MFX_MAKEFOURCC('E','R','O','I'),\n    MFX_EXTBUFF_VPP_DEINTERLACING               = MFX_MAKEFOURCC('V','P','D','I'),\n    MFX_EXTBUFF_AVC_REFLISTS                    = MFX_MAKEFOURCC('R','L','T','S'),\n    MFX_EXTBUFF_DEC_VIDEO_PROCESSING            = MFX_MAKEFOURCC('D','E','C','V'),\n    MFX_EXTBUFF_VPP_FIELD_PROCESSING            = MFX_MAKEFOURCC('F','P','R','O'),\n    MFX_EXTBUFF_CODING_OPTION3                  = MFX_MAKEFOURCC('C','D','O','3'),\n    MFX_EXTBUFF_CHROMA_LOC_INFO                 = MFX_MAKEFOURCC('C','L','I','N'),\n    MFX_EXTBUFF_MBQP                            = MFX_MAKEFOURCC('M','B','Q','P'),\n    MFX_EXTBUFF_MB_FORCE_INTRA                  = MFX_MAKEFOURCC('M','B','F','I'),\n    MFX_EXTBUFF_HEVC_TILES                      = MFX_MAKEFOURCC('2','6','5','T'),\n    MFX_EXTBUFF_MB_DISABLE_SKIP_MAP             = MFX_MAKEFOURCC('M','D','S','M'),\n    MFX_EXTBUFF_HEVC_PARAM                      = MFX_MAKEFOURCC('2','6','5','P'),\n    MFX_EXTBUFF_DECODED_FRAME_INFO              = MFX_MAKEFOURCC('D','E','F','I'),\n    MFX_EXTBUFF_TIME_CODE                       = MFX_MAKEFOURCC('T','M','C','D'),\n    MFX_EXTBUFF_HEVC_REGION                     = MFX_MAKEFOURCC('2','6','5','R'),\n    MFX_EXTBUFF_PRED_WEIGHT_TABLE               = MFX_MAKEFOURCC('E','P','W','T'),\n    MFX_EXTBUFF_DIRTY_RECTANGLES                = MFX_MAKEFOURCC('D','R','O','I'),\n    MFX_EXTBUFF_MOVING_RECTANGLES               = MFX_MAKEFOURCC('M','R','O','I'),\n    MFX_EXTBUFF_CODING_OPTION_VPS               = MFX_MAKEFOURCC('C','O','V','P'),\n    MFX_EXTBUFF_VPP_ROTATION                    = MFX_MAKEFOURCC('R','O','T',' '),\n    MFX_EXTBUFF_ENCODED_SLICES_INFO             = MFX_MAKEFOURCC('E','N','S','I'),\n    MFX_EXTBUFF_VPP_SCALING                     = MFX_MAKEFOURCC('V','S','C','L'),\n    MFX_EXTBUFF_HEVC_REFLIST_CTRL               = MFX_EXTBUFF_AVC_REFLIST_CTRL,\n    MFX_EXTBUFF_HEVC_REFLISTS                   = MFX_EXTBUFF_AVC_REFLISTS,\n    MFX_EXTBUFF_HEVC_TEMPORAL_LAYERS            = MFX_EXTBUFF_AVC_TEMPORAL_LAYERS,\n    MFX_EXTBUFF_VPP_MIRRORING                   = MFX_MAKEFOURCC('M','I','R','R'),\n    MFX_EXTBUFF_MV_OVER_PIC_BOUNDARIES          = MFX_MAKEFOURCC('M','V','P','B'),\n    MFX_EXTBUFF_VPP_COLORFILL                   = MFX_MAKEFOURCC('V','C','L','F'),\n    MFX_EXTBUFF_DECODE_ERROR_REPORT             = MFX_MAKEFOURCC('D', 'E', 'R', 'R'),\n    MFX_EXTBUFF_VPP_COLOR_CONVERSION            = MFX_MAKEFOURCC('V', 'C', 'S', 'C'),\n    MFX_EXTBUFF_CONTENT_LIGHT_LEVEL_INFO        = MFX_MAKEFOURCC('L', 'L', 'I', 'S'),\n    MFX_EXTBUFF_MASTERING_DISPLAY_COLOUR_VOLUME = MFX_MAKEFOURCC('D', 'C', 'V', 'S'),\n    MFX_EXTBUFF_MULTI_FRAME_PARAM               = MFX_MAKEFOURCC('M', 'F', 'R', 'P'),\n    MFX_EXTBUFF_MULTI_FRAME_CONTROL             = MFX_MAKEFOURCC('M', 'F', 'R', 'C'),\n    MFX_EXTBUFF_ENCODED_UNITS_INFO              = MFX_MAKEFOURCC('E', 'N', 'U', 'I'),\n    MFX_EXTBUFF_VPP_MCTF                        = MFX_MAKEFOURCC('M', 'C', 'T', 'F'),\n    MFX_EXTBUFF_VP9_SEGMENTATION                = MFX_MAKEFOURCC('9', 'S', 'E', 'G'),\n    MFX_EXTBUFF_VP9_TEMPORAL_LAYERS             = MFX_MAKEFOURCC('9', 'T', 'M', 'L'),\n    MFX_EXTBUFF_VP9_PARAM                       = MFX_MAKEFOURCC('9', 'P', 'A', 'R'),\n    MFX_EXTBUFF_AVC_ROUNDING_OFFSET             = MFX_MAKEFOURCC('R','N','D','O'),\n};\n\n/* VPP Conf: Do not use certain algorithms  */\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU32          NumAlg;\n    mfxU32*         AlgList;\n} mfxExtVPPDoNotUse;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16  DenoiseFactor;\n} mfxExtVPPDenoise;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16  DetailFactor;\n} mfxExtVPPDetail;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxF64   Brightness;\n    mfxF64   Contrast;\n    mfxF64   Hue;\n    mfxF64   Saturation;\n} mfxExtVPPProcAmp;\n\n/* statistics collected for decode, encode and vpp */\ntypedef struct {\n    mfxU32  reserved[16];\n    mfxU32  NumFrame;\n    mfxU64  NumBit;\n    mfxU32  NumCachedFrame;\n} mfxEncodeStat;\n\ntypedef struct {\n    mfxU32  reserved[16];\n    mfxU32  NumFrame;\n    mfxU32  NumSkippedFrame;\n    mfxU32  NumError;\n    mfxU32  NumCachedFrame;\n} mfxDecodeStat;\n\ntypedef struct {\n    mfxU32  reserved[16];\n    mfxU32  NumFrame;\n    mfxU32  NumCachedFrame;\n} mfxVPPStat;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    union{\n        struct{\n            mfxU32  SpatialComplexity;\n            mfxU32  TemporalComplexity;\n        };\n        struct{\n            mfxU16  PicStruct;\n            mfxU16  reserved[3];\n        };\n    };\n    mfxU16          SceneChangeRate;\n    mfxU16          RepeatedFrame;\n} mfxExtVppAuxData;\n\n/* CtrlFlags */\nenum {\n    MFX_PAYLOAD_CTRL_SUFFIX = 0x00000001 /* HEVC suffix SEI */\n};\n\ntypedef struct {\n    mfxU32      CtrlFlags;\n    mfxU32      reserved[3];\n    mfxU8       *Data;      /* buffer pointer */\n    mfxU32      NumBit;     /* number of bits */\n    mfxU16      Type;       /* SEI message type in H.264 or user data start_code in MPEG-2 */\n    mfxU16      BufSize;    /* payload buffer size in bytes */\n} mfxPayload;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU32  reserved[4];\n    mfxU16  reserved1;\n    mfxU16  MfxNalUnitType;\n    mfxU16  SkipFrame;\n\n    mfxU16  QP; /* per frame QP */\n\n    mfxU16  FrameType;\n    mfxU16  NumExtParam;\n    mfxU16  NumPayload;     /* MPEG-2 user data or H.264 SEI message(s) */\n    mfxU16  reserved2;\n\n    mfxExtBuffer    **ExtParam;\n    mfxPayload      **Payload;      /* for field pair, first field uses even payloads and second field uses odd payloads */\n} mfxEncodeCtrl;\n\n/* Buffer Memory Types */\nenum {\n    /* Buffer types */\n    MFX_MEMTYPE_PERSISTENT_MEMORY   =0x0002\n};\n\n/* Frame Memory Types */\n#define MFX_MEMTYPE_BASE(x) (0x90ff & (x))\n\nenum {\n    MFX_MEMTYPE_DXVA2_DECODER_TARGET       =0x0010,\n    MFX_MEMTYPE_DXVA2_PROCESSOR_TARGET     =0x0020,\n    MFX_MEMTYPE_VIDEO_MEMORY_DECODER_TARGET   = MFX_MEMTYPE_DXVA2_DECODER_TARGET,\n    MFX_MEMTYPE_VIDEO_MEMORY_PROCESSOR_TARGET = MFX_MEMTYPE_DXVA2_PROCESSOR_TARGET,\n    MFX_MEMTYPE_SYSTEM_MEMORY              =0x0040,\n    MFX_MEMTYPE_RESERVED1                  =0x0080,\n\n    MFX_MEMTYPE_FROM_ENCODE     = 0x0100,\n    MFX_MEMTYPE_FROM_DECODE     = 0x0200,\n    MFX_MEMTYPE_FROM_VPPIN      = 0x0400,\n    MFX_MEMTYPE_FROM_VPPOUT     = 0x0800,\n    MFX_MEMTYPE_FROM_ENC        = 0x2000,\n    MFX_MEMTYPE_FROM_PAK        = 0x4000, //reserved\n\n    MFX_MEMTYPE_INTERNAL_FRAME  = 0x0001,\n    MFX_MEMTYPE_EXTERNAL_FRAME  = 0x0002,\n    MFX_MEMTYPE_OPAQUE_FRAME    = 0x0004,\n    MFX_MEMTYPE_EXPORT_FRAME    = 0x0008,\n    MFX_MEMTYPE_SHARED_RESOURCE = MFX_MEMTYPE_EXPORT_FRAME,\n    MFX_MEMTYPE_VIDEO_MEMORY_ENCODER_TARGET = 0x1000\n};\n\ntypedef struct {\n    union {\n        mfxU32  AllocId;\n        mfxU32  reserved[1];\n    };\n    mfxU32  reserved3[3];\n    mfxFrameInfo    Info;\n    mfxU16  Type;   /* decoder or processor render targets */\n    mfxU16  NumFrameMin;\n    mfxU16  NumFrameSuggested;\n    mfxU16  reserved2;\n} mfxFrameAllocRequest;\n\ntypedef struct {\n    mfxU32      AllocId;\n    mfxU32      reserved[3];\n    mfxMemId    *mids;      /* the array allocated by application */\n    mfxU16      NumFrameActual;\n    mfxU16      reserved2;\n} mfxFrameAllocResponse;\n\n/* FrameType */\nenum {\n    MFX_FRAMETYPE_UNKNOWN       =0x0000,\n\n    MFX_FRAMETYPE_I             =0x0001,\n    MFX_FRAMETYPE_P             =0x0002,\n    MFX_FRAMETYPE_B             =0x0004,\n    MFX_FRAMETYPE_S             =0x0008,\n\n    MFX_FRAMETYPE_REF           =0x0040,\n    MFX_FRAMETYPE_IDR           =0x0080,\n\n    MFX_FRAMETYPE_xI            =0x0100,\n    MFX_FRAMETYPE_xP            =0x0200,\n    MFX_FRAMETYPE_xB            =0x0400,\n    MFX_FRAMETYPE_xS            =0x0800,\n\n    MFX_FRAMETYPE_xREF          =0x4000,\n    MFX_FRAMETYPE_xIDR          =0x8000\n};\n\nenum {\n    MFX_HEVC_NALU_TYPE_UNKNOWN    =      0,\n    MFX_HEVC_NALU_TYPE_TRAIL_N    = ( 0+1),\n    MFX_HEVC_NALU_TYPE_TRAIL_R    = ( 1+1),\n    MFX_HEVC_NALU_TYPE_RADL_N     = ( 6+1),\n    MFX_HEVC_NALU_TYPE_RADL_R     = ( 7+1),\n    MFX_HEVC_NALU_TYPE_RASL_N     = ( 8+1),\n    MFX_HEVC_NALU_TYPE_RASL_R     = ( 9+1),\n    MFX_HEVC_NALU_TYPE_IDR_W_RADL = (19+1),\n    MFX_HEVC_NALU_TYPE_IDR_N_LP   = (20+1),\n    MFX_HEVC_NALU_TYPE_CRA_NUT    = (21+1)\n};\n\ntypedef enum {\n    MFX_HANDLE_DIRECT3D_DEVICE_MANAGER9         =1,      /* IDirect3DDeviceManager9      */\n    MFX_HANDLE_D3D9_DEVICE_MANAGER              = MFX_HANDLE_DIRECT3D_DEVICE_MANAGER9,\n    MFX_HANDLE_RESERVED1                        = 2,\n    MFX_HANDLE_D3D11_DEVICE                     = 3,\n    MFX_HANDLE_VA_DISPLAY                       = 4,\n    MFX_HANDLE_RESERVED3                        = 5,\n} mfxHandleType;\n\ntypedef enum {\n    MFX_SKIPMODE_NOSKIP=0,\n    MFX_SKIPMODE_MORE=1,\n    MFX_SKIPMODE_LESS=2\n} mfxSkipMode;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU8           *SPSBuffer;\n    mfxU8           *PPSBuffer;\n    mfxU16          SPSBufSize;\n    mfxU16          PPSBufSize;\n    mfxU16          SPSId;\n    mfxU16          PPSId;\n} mfxExtCodingOptionSPSPPS;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    union {\n        mfxU8       *VPSBuffer;\n        mfxU64      reserved1;\n    };\n    mfxU16          VPSBufSize;\n    mfxU16          VPSId;\n\n    mfxU16          reserved[6];\n} mfxExtCodingOptionVPS;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16          VideoFormat;\n    mfxU16          VideoFullRange;\n    mfxU16          ColourDescriptionPresent;\n    mfxU16          ColourPrimaries;\n    mfxU16          TransferCharacteristics;\n    mfxU16          MatrixCoefficients;\n} mfxExtVideoSignalInfo;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU32          NumAlg;\n    mfxU32          *AlgList;\n} mfxExtVPPDoUse;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU32      reserved1[2];\n    struct {\n        mfxFrameSurface1 **Surfaces;\n        mfxU32  reserved2[5];\n        mfxU16  Type;\n        mfxU16  NumSurface;\n    } In, Out;\n} mfxExtOpaqueSurfaceAlloc;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16          NumRefIdxL0Active;\n    mfxU16          NumRefIdxL1Active;\n\n    struct {\n        mfxU32      FrameOrder;\n        mfxU16      PicStruct;\n        mfxU16      ViewId;\n        mfxU16      LongTermIdx;\n        mfxU16      reserved[3];\n    } PreferredRefList[32], RejectedRefList[16], LongTermRefList[16];\n\n    mfxU16      ApplyLongTermIdx;\n    mfxU16      reserved[15];\n} mfxExtAVCRefListCtrl;\n\nenum {\n    MFX_FRCALGM_PRESERVE_TIMESTAMP    = 0x0001,\n    MFX_FRCALGM_DISTRIBUTED_TIMESTAMP = 0x0002,\n    MFX_FRCALGM_FRAME_INTERPOLATION   = 0x0004\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16      Algorithm;\n    mfxU16      reserved;\n    mfxU32      reserved2[15];\n} mfxExtVPPFrameRateConversion;\n\nenum {\n    MFX_IMAGESTAB_MODE_UPSCALE = 0x0001,\n    MFX_IMAGESTAB_MODE_BOXING  = 0x0002\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16  Mode;\n    mfxU16  reserved[11];\n} mfxExtVPPImageStab;\n\n\nenum {\n    MFX_PAYLOAD_OFF = 0,\n    MFX_PAYLOAD_IDR = 1\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16      reserved[15];\n\n    mfxU16 InsertPayloadToggle;\n    mfxU16 DisplayPrimariesX[3];\n    mfxU16 DisplayPrimariesY[3];\n    mfxU16 WhitePointX;\n    mfxU16 WhitePointY;\n    mfxU32 MaxDisplayMasteringLuminance;\n    mfxU32 MinDisplayMasteringLuminance;\n} mfxExtMasteringDisplayColourVolume;\n\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16      reserved[9];\n\n    mfxU16 InsertPayloadToggle;\n    mfxU16 MaxContentLightLevel;\n    mfxU16 MaxPicAverageLightLevel;\n} mfxExtContentLightLevelInfo;\n\n\ntypedef struct {\n  mfxExtBuffer    Header;\n  mfxU32      reserved[14];\n\n  struct {\n      mfxU16    ClockTimestampFlag;\n      mfxU16    CtType;\n      mfxU16    NuitFieldBasedFlag;\n      mfxU16    CountingType;\n      mfxU16    FullTimestampFlag;\n      mfxU16    DiscontinuityFlag;\n      mfxU16    CntDroppedFlag;\n      mfxU16    NFrames;\n      mfxU16    SecondsFlag;\n      mfxU16    MinutesFlag;\n      mfxU16    HoursFlag;\n      mfxU16    SecondsValue;\n      mfxU16    MinutesValue;\n      mfxU16    HoursValue;\n      mfxU32    TimeOffset;\n  } TimeStamp[3];\n} mfxExtPictureTimingSEI;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU32          reserved1[4];\n    mfxU16          reserved2;\n    mfxU16          BaseLayerPID;\n\n    struct {\n        mfxU16 Scale;\n        mfxU16 reserved[3];\n    }Layer[8];\n} mfxExtAvcTemporalLayers;\n\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU32      MBPerSec;\n    mfxU16      reserved[58];\n} mfxExtEncoderCapability;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16      StartNewSequence;\n    mfxU16      reserved[11];\n} mfxExtEncoderResetOption;\n\n/*LongTermIdx*/\nenum {\n    MFX_LONGTERM_IDX_NO_IDX = 0xFFFF\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    mfxU32          FrameOrder;\n    mfxU16          PicStruct;\n    mfxU16          LongTermIdx;\n    mfxU32          MAD;\n    mfxU16          BRCPanicMode;\n    mfxU16          QP;\n    mfxU32          SecondFieldOffset;\n    mfxU16          reserved[2];\n\n    struct {\n        mfxU32      FrameOrder;\n        mfxU16      PicStruct;\n        mfxU16      LongTermIdx;\n        mfxU16      reserved[4];\n    } UsedRefListL0[32], UsedRefListL1[32];\n} mfxExtAVCEncodedFrameInfo;\n\ntypedef struct mfxVPPCompInputStream {\n    mfxU32  DstX;\n    mfxU32  DstY;\n    mfxU32  DstW;\n    mfxU32  DstH;\n\n    mfxU16  LumaKeyEnable;\n    mfxU16  LumaKeyMin;\n    mfxU16  LumaKeyMax;\n\n    mfxU16  GlobalAlphaEnable;\n    mfxU16  GlobalAlpha;\n    mfxU16  PixelAlphaEnable;\n\n    mfxU16  TileId;\n\n    mfxU16  reserved2[17];\n} mfxVPPCompInputStream;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    /* background color*/\n    union {\n        mfxU16   Y;\n        mfxU16   R;\n    };\n    union {\n        mfxU16   U;\n        mfxU16   G;\n    };\n    union {\n        mfxU16   V;\n        mfxU16   B;\n    };\n    mfxU16       NumTiles;\n    mfxU16       reserved1[23];\n\n    mfxU16       NumInputStream;\n    mfxVPPCompInputStream *InputStream;\n} mfxExtVPPComposite;\n\n/* TransferMatrix */\nenum {\n    MFX_TRANSFERMATRIX_UNKNOWN = 0,\n    MFX_TRANSFERMATRIX_BT709   = 1,\n    MFX_TRANSFERMATRIX_BT601   = 2\n};\n\n/* NominalRange */\nenum {\n    MFX_NOMINALRANGE_UNKNOWN   = 0,\n    MFX_NOMINALRANGE_0_255     = 1,\n    MFX_NOMINALRANGE_16_235    = 2\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16          reserved1[4];\n\n    union {\n        struct { // Init\n            struct  {\n                mfxU16  TransferMatrix;\n                mfxU16  NominalRange;\n                mfxU16  reserved2[6];\n            } In, Out;\n        };\n        struct { // Runtime\n            mfxU16  TransferMatrix;\n            mfxU16  NominalRange;\n            mfxU16  reserved3[14];\n        };\n    };\n} mfxExtVPPVideoSignalInfo;\n\n/* ROI encoding mode */\nenum {\n    MFX_ROI_MODE_PRIORITY =  0,\n    MFX_ROI_MODE_QP_DELTA =  1\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    mfxU16  NumROI;\n    mfxU16  ROIMode;\n    mfxU16  reserved1[10];\n\n    struct  {\n        mfxU32  Left;\n        mfxU32  Top;\n        mfxU32  Right;\n        mfxU32  Bottom;\n        union {\n            mfxI16  Priority;\n            mfxI16  DeltaQP;\n        };\n        mfxU16  reserved2[7];\n    } ROI[256];\n} mfxExtEncoderROI;\n\n/*Deinterlacing Mode*/\nenum {\n    MFX_DEINTERLACING_BOB                    =  1,\n    MFX_DEINTERLACING_ADVANCED               =  2,\n    MFX_DEINTERLACING_AUTO_DOUBLE            =  3,\n    MFX_DEINTERLACING_AUTO_SINGLE            =  4,\n    MFX_DEINTERLACING_FULL_FR_OUT            =  5,\n    MFX_DEINTERLACING_HALF_FR_OUT            =  6,\n    MFX_DEINTERLACING_24FPS_OUT              =  7,\n    MFX_DEINTERLACING_FIXED_TELECINE_PATTERN =  8,\n    MFX_DEINTERLACING_30FPS_OUT              =  9,\n    MFX_DEINTERLACING_DETECT_INTERLACE       = 10,\n    MFX_DEINTERLACING_ADVANCED_NOREF         = 11,\n    MFX_DEINTERLACING_ADVANCED_SCD           = 12,\n    MFX_DEINTERLACING_FIELD_WEAVING          = 13\n};\n\n/*TelecinePattern*/\nenum {\n    MFX_TELECINE_PATTERN_32           = 0,\n    MFX_TELECINE_PATTERN_2332         = 1,\n    MFX_TELECINE_PATTERN_FRAME_REPEAT = 2,\n    MFX_TELECINE_PATTERN_41           = 3,\n    MFX_TELECINE_POSITION_PROVIDED    = 4\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16  Mode;\n    mfxU16  TelecinePattern;\n    mfxU16  TelecineLocation;\n    mfxU16  reserved[9];\n} mfxExtVPPDeinterlacing;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n    mfxU16          NumRefIdxL0Active;\n    mfxU16          NumRefIdxL1Active;\n    mfxU16          reserved[2];\n\n    struct mfxRefPic{\n        mfxU32      FrameOrder;\n        mfxU16      PicStruct;\n        mfxU16      reserved[5];\n    } RefPicList0[32], RefPicList1[32];\n\n}mfxExtAVCRefLists;\n\nenum {\n    MFX_VPP_COPY_FRAME      =0x01,\n    MFX_VPP_COPY_FIELD      =0x02,\n    MFX_VPP_SWAP_FIELDS     =0x03\n};\n\n/*PicType*/\nenum {\n    MFX_PICTYPE_UNKNOWN     =0x00,\n    MFX_PICTYPE_FRAME       =0x01,\n    MFX_PICTYPE_TOPFIELD    =0x02,\n    MFX_PICTYPE_BOTTOMFIELD =0x04\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    mfxU16          Mode;\n    mfxU16          InField;\n    mfxU16          OutField;\n    mfxU16          reserved[25];\n} mfxExtVPPFieldProcessing;\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    struct mfxIn{\n        mfxU16  CropX;\n        mfxU16  CropY;\n        mfxU16  CropW;\n        mfxU16  CropH;\n        mfxU16  reserved[12];\n    }In;\n\n    struct mfxOut{\n        mfxU32  FourCC;\n        mfxU16  ChromaFormat;\n        mfxU16  reserved1;\n\n        mfxU16  Width;\n        mfxU16  Height;\n\n        mfxU16  CropX;\n        mfxU16  CropY;\n        mfxU16  CropW;\n        mfxU16  CropH;\n        mfxU16  reserved[22];\n    }Out;\n\n    mfxU16  reserved[13];\n} mfxExtDecVideoProcessing;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16       ChromaLocInfoPresentFlag;\n    mfxU16       ChromaSampleLocTypeTopField;\n    mfxU16       ChromaSampleLocTypeBottomField;\n    mfxU16       reserved[9];\n} mfxExtChromaLocInfo;\n\n/* MBQPMode */\nenum {\n    MFX_MBQP_MODE_QP_VALUE = 0, // supported in CQP mode only\n    MFX_MBQP_MODE_QP_DELTA = 1\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    mfxU32 reserved[10];\n    mfxU16 Mode;        // see MBQPMode enum\n    mfxU16 BlockSize;   // QP block size, valid for HEVC only during Init and Runtime\n    mfxU32 NumQPAlloc;  // Size of allocated by application QP or DeltaQP array\n    union {\n        mfxU8  *QP;         // Block QP value. Valid when Mode = MFX_MBQP_MODE_QP_VALUE\n        mfxI8  *DeltaQP;    // For block i: QP[i] = BrcQP[i] + DeltaQP[i]. Valid when Mode = MFX_MBQP_MODE_QP_DELTA\n        mfxU64 reserved2;\n    };\n} mfxExtMBQP;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU32 reserved[11];\n    mfxU32 MapSize;\n    union {\n        mfxU8  *Map;\n        mfxU64  reserved2;\n    };\n} mfxExtMBForceIntra;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16 NumTileRows;\n    mfxU16 NumTileColumns;\n    mfxU16 reserved[74];\n}mfxExtHEVCTiles;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU32 reserved[11];\n    mfxU32 MapSize;\n    union {\n        mfxU8  *Map;\n        mfxU64  reserved2;\n    };\n} mfxExtMBDisableSkipMap;\n\n\n/*GeneralConstraintFlags*/\nenum {\n    /* REXT Profile constraint flags*/\n    MFX_HEVC_CONSTR_REXT_MAX_12BIT          = (1 << 0),\n    MFX_HEVC_CONSTR_REXT_MAX_10BIT          = (1 << 1),\n    MFX_HEVC_CONSTR_REXT_MAX_8BIT           = (1 << 2),\n    MFX_HEVC_CONSTR_REXT_MAX_422CHROMA      = (1 << 3),\n    MFX_HEVC_CONSTR_REXT_MAX_420CHROMA      = (1 << 4),\n    MFX_HEVC_CONSTR_REXT_MAX_MONOCHROME     = (1 << 5),\n    MFX_HEVC_CONSTR_REXT_INTRA              = (1 << 6),\n    MFX_HEVC_CONSTR_REXT_ONE_PICTURE_ONLY   = (1 << 7),\n    MFX_HEVC_CONSTR_REXT_LOWER_BIT_RATE     = (1 << 8)\n};\n\n\n/* SampleAdaptiveOffset */\nenum {\n    MFX_SAO_UNKNOWN       = 0x00,\n    MFX_SAO_DISABLE       = 0x01,\n    MFX_SAO_ENABLE_LUMA   = 0x02,\n    MFX_SAO_ENABLE_CHROMA = 0x04\n};\n\n\n#pragma pack(push, 4)\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    mfxU16          PicWidthInLumaSamples;\n    mfxU16          PicHeightInLumaSamples;\n    mfxU64          GeneralConstraintFlags;\n    mfxU16          SampleAdaptiveOffset;   /* see enum SampleAdaptiveOffset, valid during Init and Runtime */\n    mfxU16          LCUSize;\n    mfxU16          reserved[116];\n} mfxExtHEVCParam;\n#pragma pack(pop)\n\n/*ErrorTypes in mfxExtDecodeErrorReport*/\nenum {\n    MFX_ERROR_PPS           = (1 << 0),\n    MFX_ERROR_SPS           = (1 << 1),\n    MFX_ERROR_SLICEHEADER   = (1 << 2),\n    MFX_ERROR_SLICEDATA     = (1 << 3),\n    MFX_ERROR_FRAME_GAP     = (1 << 4),\n};\n\ntypedef struct {\n    mfxExtBuffer    Header;\n\n    mfxU32          ErrorTypes;\n    mfxU16          reserved[10];\n} mfxExtDecodeErrorReport;\n\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16       FrameType;\n    mfxU16       reserved[59];\n} mfxExtDecodedFrameInfo;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16       DropFrameFlag;\n    mfxU16       TimeCodeHours;\n    mfxU16       TimeCodeMinutes;\n    mfxU16       TimeCodeSeconds;\n    mfxU16       TimeCodePictures;\n    mfxU16       reserved[7];\n} mfxExtTimeCode;\n\n/*RegionType*/\nenum {\n    MFX_HEVC_REGION_SLICE = 0\n};\n\n/*RegionEncoding*/\nenum {\n    MFX_HEVC_REGION_ENCODING_ON  = 0,\n    MFX_HEVC_REGION_ENCODING_OFF = 1\n};\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU32       RegionId;\n    mfxU16       RegionType;\n    mfxU16       RegionEncoding;\n    mfxU16       reserved[24];\n} mfxExtHEVCRegion;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16       LumaLog2WeightDenom;       // 0..7\n    mfxU16       ChromaLog2WeightDenom;     // 0..7\n    mfxU16       LumaWeightFlag[2][32];     // [list] 0,1\n    mfxU16       ChromaWeightFlag[2][32];   // [list] 0,1\n    mfxI16       Weights[2][32][3][2];      // [list][list entry][Y, Cb, Cr][weight, offset]\n    mfxU16       reserved[58];\n} mfxExtPredWeightTable;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16       EnableRoundingIntra;       // tri-state option\n    mfxU16       RoundingOffsetIntra;       // valid value [0,7]\n    mfxU16       EnableRoundingInter;       // tri-state option\n    mfxU16       RoundingOffsetInter;       // valid value [0,7]\n\n    mfxU16       reserved[24];\n} mfxExtAVCRoundingOffset;\n\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16  NumRect;\n    mfxU16  reserved1[11];\n\n    struct {\n        mfxU32  Left;\n        mfxU32  Top;\n        mfxU32  Right;\n        mfxU32  Bottom;\n\n        mfxU16  reserved2[8];\n    } Rect[256];\n} mfxExtDirtyRect;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16  NumRect;\n    mfxU16  reserved1[11];\n\n    struct {\n        mfxU32  DestLeft;\n        mfxU32  DestTop;\n        mfxU32  DestRight;\n        mfxU32  DestBottom;\n\n        mfxU32  SourceLeft;\n        mfxU32  SourceTop;\n        mfxU16  reserved2[4];\n    } Rect[256];\n} mfxExtMoveRect;\n\n\n/* Angle */\nenum {\n    MFX_ANGLE_0     =   0,\n    MFX_ANGLE_90    =  90,\n    MFX_ANGLE_180   = 180,\n    MFX_ANGLE_270   = 270\n};\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16 Angle;\n    mfxU16 reserved[11];\n} mfxExtVPPRotation;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16  SliceSizeOverflow;\n    mfxU16  NumSliceNonCopliant;\n    mfxU16  NumEncodedSlice;\n    mfxU16  NumSliceSizeAlloc;\n    union {\n        mfxU16  *SliceSize;\n        mfxU64  reserved1;\n    };\n\n    mfxU16 reserved[20];\n} mfxExtEncodedSlicesInfo;\n\n/* ScalingMode */\nenum {\n    MFX_SCALING_MODE_DEFAULT    = 0,\n    MFX_SCALING_MODE_LOWPOWER   = 1,\n    MFX_SCALING_MODE_QUALITY    = 2\n};\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16 ScalingMode;\n    mfxU16 reserved[11];\n} mfxExtVPPScaling;\n\n\ntypedef mfxExtAVCRefListCtrl mfxExtHEVCRefListCtrl;\ntypedef mfxExtAVCRefLists mfxExtHEVCRefLists;\ntypedef mfxExtAvcTemporalLayers mfxExtHEVCTemporalLayers;\n\n/* MirroringType */\nenum\n{\n    MFX_MIRRORING_DISABLED   = 0,\n    MFX_MIRRORING_HORIZONTAL = 1,\n    MFX_MIRRORING_VERTICAL   = 2\n};\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16 Type;\n    mfxU16 reserved[11];\n} mfxExtVPPMirroring;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16 StickTop;     /* tri-state option */\n    mfxU16 StickBottom;  /* tri-state option */\n    mfxU16 StickLeft;    /* tri-state option */\n    mfxU16 StickRight;   /* tri-state option */\n    mfxU16 reserved[8];\n} mfxExtMVOverPicBoundaries;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16 Enable;        /* tri-state option */\n    mfxU16 reserved[11];\n} mfxExtVPPColorFill;\n\n\n/* ChromaSiting */\nenum {\n    MFX_CHROMA_SITING_UNKNOWN             = 0x0000,\n    MFX_CHROMA_SITING_VERTICAL_TOP        = 0x0001, /* Chroma samples are co-sited vertically on the top with the luma samples. */\n    MFX_CHROMA_SITING_VERTICAL_CENTER     = 0x0002, /* Chroma samples are not co-sited vertically with the luma samples. */\n    MFX_CHROMA_SITING_VERTICAL_BOTTOM     = 0x0004, /* Chroma samples are co-sited vertically on the bottom with the luma samples. */\n    MFX_CHROMA_SITING_HORIZONTAL_LEFT     = 0x0010, /* Chroma samples are co-sited horizontally on the left with the luma samples. */\n    MFX_CHROMA_SITING_HORIZONTAL_CENTER   = 0x0020  /* Chroma samples are not co-sited horizontally with the luma samples. */\n};\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16 ChromaSiting;\n    mfxU16 reserved[27];\n} mfxExtColorConversion;\n\n\n/* VP9ReferenceFrame */\nenum {\n    MFX_VP9_REF_INTRA   = 0,\n    MFX_VP9_REF_LAST    = 1,\n    MFX_VP9_REF_GOLDEN  = 2,\n    MFX_VP9_REF_ALTREF  = 3\n};\n\n/* SegmentIdBlockSize */\nenum {\n    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_UNKNOWN =  0,\n    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_8x8     =  8,\n    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_16x16   = 16,\n    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_32x32   = 32,\n    MFX_VP9_SEGMENT_ID_BLOCK_SIZE_64x64   = 64,\n};\n\n/* SegmentFeature */\nenum {\n    MFX_VP9_SEGMENT_FEATURE_QINDEX      = 0x0001,\n    MFX_VP9_SEGMENT_FEATURE_LOOP_FILTER = 0x0002,\n    MFX_VP9_SEGMENT_FEATURE_REFERENCE   = 0x0004,\n    MFX_VP9_SEGMENT_FEATURE_SKIP        = 0x0008 /* (0,0) MV, no residual */\n};\n\ntypedef struct {\n    mfxU16  FeatureEnabled;         /* see enum SegmentFeature */\n    mfxI16  QIndexDelta;\n    mfxI16  LoopFilterLevelDelta;\n    mfxU16  ReferenceFrame;        /* see enum VP9ReferenceFrame */\n    mfxU16  reserved[12];\n} mfxVP9SegmentParam;\n\ntypedef struct {\n    mfxExtBuffer        Header;\n    mfxU16              NumSegments;            /* 0..8 */\n    mfxVP9SegmentParam  Segment[8];\n    mfxU16              SegmentIdBlockSize;     /* see enum SegmentIdBlockSize */\n    mfxU32              NumSegmentIdAlloc;      /* >= (Ceil(Width / SegmentIdBlockSize) * Ceil(Height / SegmentIdBlockSize)) */\n    union {\n        mfxU8           *SegmentId;             /*[NumSegmentIdAlloc] = 0..7, index in Segment array, blocks of SegmentIdBlockSize map */\n        mfxU64          reserved1;\n    };\n    mfxU16  reserved[52];\n} mfxExtVP9Segmentation;\n\ntypedef struct {\n    mfxU16 FrameRateScale;  /* Layer[n].FrameRateScale = Layer[n - 1].FrameRateScale * (uint)m */\n    mfxU16 TargetKbps;      /* affected by BRCParamMultiplier, Layer[n].TargetKbps > Layer[n - 1].TargetKbps */\n    mfxU16 reserved[14];\n} mfxVP9TemporalLayer;\n\ntypedef struct {\n    mfxExtBuffer        Header;\n    mfxVP9TemporalLayer Layer[8];\n    mfxU16              reserved[60];\n} mfxExtVP9TemporalLayers;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16  FrameWidth;\n    mfxU16  FrameHeight;\n\n    mfxU16  WriteIVFHeaders;        /* tri-state option */\n\n    mfxI16  reserved1[6];\n    mfxI16  QIndexDeltaLumaDC;\n    mfxI16  QIndexDeltaChromaAC;\n    mfxI16  QIndexDeltaChromaDC;\n    mfxU16  reserved[112];\n} mfxExtVP9Param;\n\n\n/* Multi-Frame Mode */\nenum {\n    MFX_MF_DEFAULT = 0,\n    MFX_MF_DISABLED = 1,\n    MFX_MF_AUTO = 2,\n    MFX_MF_MANUAL = 3\n};\n\n/* Multi-Frame Initialization parameters */\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU16      MFMode;\n    mfxU16      MaxNumFrames;\n\n    mfxU16      reserved[58];\n} mfxExtMultiFrameParam;\n\n/* Multi-Frame Run-time controls */\ntypedef struct {\n    mfxExtBuffer Header;\n\n    mfxU32      Timeout;      /* timeout in millisecond */\n    mfxU16      Flush;        /* Flush internal frame buffer, e.g. submit all collected frames. */\n\n    mfxU16      reserved[57];\n} mfxExtMultiFrameControl;\n\ntypedef struct {\n    mfxU16 Type;\n    mfxU16 reserved1;\n    mfxU32 Offset;\n    mfxU32 Size;\n    mfxU32 reserved[5];\n} mfxEncodedUnitInfo;\n\ntypedef struct {\n    mfxExtBuffer Header;\n\n    union {\n        mfxEncodedUnitInfo *UnitInfo;\n        mfxU64  reserved1;\n    };\n    mfxU16 NumUnitsAlloc;\n    mfxU16 NumUnitsEncoded;\n\n    mfxU16 reserved[22];\n} mfxExtEncodedUnitsInfo;\n\n\n\n/* MCTF initialization & runtime */\ntypedef struct {\n    mfxExtBuffer Header;\n    mfxU16       FilterStrength;\n    mfxU16       reserved[27];\n} mfxExtVppMctf;\n\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/mvc/include/mfxvideo.h",
    "content": "/* ****************************************************************************** *\\\n\nCopyright (C) 2007-2017 Intel Corporation.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n- Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n- Neither the name of Intel Corporation nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY INTEL CORPORATION \"AS IS\" AND ANY EXPRESS OR\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\nIN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nFile Name: mfxvideo.h\n\n\\* ****************************************************************************** */\n#ifndef __MFXVIDEO_H__\n#define __MFXVIDEO_H__\n#include \"mfxsession.h\"\n#include \"mfxvstructures.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/* MFXVideoCORE */\ntypedef struct {\n    mfxU32      reserved[4];\n    mfxHDL      pthis;\n    mfxStatus  (MFX_CDECL *Alloc)    (mfxHDL pthis, mfxU32 nbytes, mfxU16 type, mfxMemId *mid);\n    mfxStatus  (MFX_CDECL *Lock)     (mfxHDL pthis, mfxMemId mid, mfxU8 **ptr);\n    mfxStatus  (MFX_CDECL *Unlock)   (mfxHDL pthis, mfxMemId mid);\n    mfxStatus  (MFX_CDECL *Free)     (mfxHDL pthis, mfxMemId mid);\n} mfxBufferAllocator;\n\ntypedef struct {\n    mfxU32      reserved[4];\n    mfxHDL      pthis;\n\n    mfxStatus  (MFX_CDECL  *Alloc)    (mfxHDL pthis, mfxFrameAllocRequest *request, mfxFrameAllocResponse *response);\n    mfxStatus  (MFX_CDECL  *Lock)     (mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr);\n    mfxStatus  (MFX_CDECL  *Unlock)   (mfxHDL pthis, mfxMemId mid, mfxFrameData *ptr);\n    mfxStatus  (MFX_CDECL  *GetHDL)   (mfxHDL pthis, mfxMemId mid, mfxHDL *handle);\n    mfxStatus  (MFX_CDECL  *Free)     (mfxHDL pthis, mfxFrameAllocResponse *response);\n} mfxFrameAllocator;\n\n/* VideoCORE */\nmfxStatus MFX_CDECL MFXVideoCORE_SetBufferAllocator(mfxSession session, mfxBufferAllocator *allocator);\nmfxStatus MFX_CDECL MFXVideoCORE_SetFrameAllocator(mfxSession session, mfxFrameAllocator *allocator);\nmfxStatus MFX_CDECL MFXVideoCORE_SetHandle(mfxSession session, mfxHandleType type, mfxHDL hdl);\nmfxStatus MFX_CDECL MFXVideoCORE_GetHandle(mfxSession session, mfxHandleType type, mfxHDL *hdl);\nmfxStatus MFX_CDECL MFXVideoCORE_QueryPlatform(mfxSession session, mfxPlatform* platform);\nmfxStatus MFX_CDECL MFXVideoCORE_SyncOperation(mfxSession session, mfxSyncPoint syncp, mfxU32 wait);\n\n/* VideoENCODE */\nmfxStatus MFX_CDECL MFXVideoENCODE_Query(mfxSession session, mfxVideoParam *in, mfxVideoParam *out);\nmfxStatus MFX_CDECL MFXVideoENCODE_QueryIOSurf(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest *request);\nmfxStatus MFX_CDECL MFXVideoENCODE_Init(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoENCODE_Reset(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoENCODE_Close(mfxSession session);\n\nmfxStatus MFX_CDECL MFXVideoENCODE_GetVideoParam(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoENCODE_GetEncodeStat(mfxSession session, mfxEncodeStat *stat);\nmfxStatus MFX_CDECL MFXVideoENCODE_EncodeFrameAsync(mfxSession session, mfxEncodeCtrl *ctrl, mfxFrameSurface1 *surface, mfxBitstream *bs, mfxSyncPoint *syncp);\n\n/* VideoDECODE */\nmfxStatus MFX_CDECL MFXVideoDECODE_Query(mfxSession session, mfxVideoParam *in, mfxVideoParam *out);\nmfxStatus MFX_CDECL MFXVideoDECODE_DecodeHeader(mfxSession session, mfxBitstream *bs, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoDECODE_QueryIOSurf(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest *request);\nmfxStatus MFX_CDECL MFXVideoDECODE_Init(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoDECODE_Reset(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoDECODE_Close(mfxSession session);\n\nmfxStatus MFX_CDECL MFXVideoDECODE_GetVideoParam(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoDECODE_GetDecodeStat(mfxSession session, mfxDecodeStat *stat);\nmfxStatus MFX_CDECL MFXVideoDECODE_SetSkipMode(mfxSession session, mfxSkipMode mode);\nmfxStatus MFX_CDECL MFXVideoDECODE_GetPayload(mfxSession session, mfxU64 *ts, mfxPayload *payload);\nmfxStatus MFX_CDECL MFXVideoDECODE_DecodeFrameAsync(mfxSession session, mfxBitstream *bs, mfxFrameSurface1 *surface_work, mfxFrameSurface1 **surface_out, mfxSyncPoint *syncp);\n\n/* VideoVPP */\nmfxStatus MFX_CDECL MFXVideoVPP_Query(mfxSession session, mfxVideoParam *in, mfxVideoParam *out);\nmfxStatus MFX_CDECL MFXVideoVPP_QueryIOSurf(mfxSession session, mfxVideoParam *par, mfxFrameAllocRequest request[2]);\nmfxStatus MFX_CDECL MFXVideoVPP_Init(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoVPP_Reset(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoVPP_Close(mfxSession session);\n\nmfxStatus MFX_CDECL MFXVideoVPP_GetVideoParam(mfxSession session, mfxVideoParam *par);\nmfxStatus MFX_CDECL MFXVideoVPP_GetVPPStat(mfxSession session, mfxVPPStat *stat);\nmfxStatus MFX_CDECL MFXVideoVPP_RunFrameVPPAsync(mfxSession session, mfxFrameSurface1 *in, mfxFrameSurface1 *out, mfxExtVppAuxData *aux, mfxSyncPoint *syncp);\nmfxStatus MFX_CDECL MFXVideoVPP_RunFrameVPPAsyncEx(mfxSession session, mfxFrameSurface1 *in, mfxFrameSurface1 *surface_work, mfxFrameSurface1 **surface_out, mfxSyncPoint *syncp);\n\n#ifdef __cplusplus\n} // extern \"C\"\n#endif\n\n#endif\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/mvc/include/mfxvstructures.h",
    "content": "/*******************************************************************************\n\nCopyright (C) 2013 Intel Corporation.  All rights reserved.\n\nRedistribution and use in source and binary forms, with or without\nmodification, are permitted provided that the following conditions are met:\n- Redistributions of source code must retain the above copyright notice,\nthis list of conditions and the following disclaimer.\n- Redistributions in binary form must reproduce the above copyright notice,\nthis list of conditions and the following disclaimer in the documentation\nand/or other materials provided with the distribution.\n- Neither the name of Intel Corporation nor the names of its contributors\nmay be used to endorse or promote products derived from this software\nwithout specific prior written permission.\n\nTHIS SOFTWARE IS PROVIDED BY INTEL CORPORATION \"AS IS\" AND ANY EXPRESS OR\nIMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES\nOF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.\nIN NO EVENT SHALL INTEL CORPORATION BE LIABLE FOR ANY DIRECT, INDIRECT,\nINCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT\nNOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,\nDATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY\nTHEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF\nTHIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\nFile Name: mfxvstructures.h\n\n*******************************************************************************/\n#include \"mfxstructures.h\"\n\n\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/pixfmt.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"ILAVDecoder.h\"\n\nstatic LAVPixFmtDesc lav_pixfmt_desc[] = {\n    {1, 3, {1, 2, 2}, {1, 2, 2}}, ///< LAVPixFmt_YUV420\n    {2, 3, {1, 2, 2}, {1, 2, 2}}, ///< LAVPixFmt_YUV420bX\n    {1, 3, {1, 2, 2}, {1, 1, 1}}, ///< LAVPixFmt_YUV422\n    {2, 3, {1, 2, 2}, {1, 1, 1}}, ///< LAVPixFmt_YUV422bX\n    {1, 3, {1, 1, 1}, {1, 1, 1}}, ///< LAVPixFmt_YUV444\n    {2, 3, {1, 1, 1}, {1, 1, 1}}, ///< LAVPixFmt_YUV444bX\n    {1, 2, {1, 1}, {1, 2}},       ///< LAVPixFmt_NV12\n    {2, 1, {1}, {1}},             ///< LAVPixFmt_YUY2\n    {2, 2, {1, 1}, {1, 2}},       ///< LAVPixFmt_P016\n    {3, 1, {1}, {1}},             ///< LAVPixFmt_RGB24\n    {4, 1, {1}, {1}},             ///< LAVPixFmt_RGB32\n    {4, 1, {1}, {1}},             ///< LAVPixFmt_ARGB32\n    {6, 1, {1}, {1}},             ///< LAVPixFmt_RGB48\n    {4, 1, {1}, {1}},             ///< LAVPixFmt_AYUV\n    {4, 1, {1}, {1}},             ///< LAVPixFmt_Y410\n    {8, 1, {1}, {1}},             ///< LAVPixFmt_Y416\n    {4, 1, {1}, {1}},             ///< LAVPixFmt_Y216\n};\n\nLAVPixFmtDesc getPixelFormatDesc(LAVPixelFormat pixFmt)\n{\n    return lav_pixfmt_desc[pixFmt];\n}\n\nstatic struct\n{\n    LAVPixelFormat pixfmt;\n    AVPixelFormat ffpixfmt;\n} lav_ff_pixfmt_map[] = {\n    {LAVPixFmt_YUV420, AV_PIX_FMT_YUV420P}, {LAVPixFmt_YUV422, AV_PIX_FMT_YUV422P},\n    {LAVPixFmt_YUV444, AV_PIX_FMT_YUV444P}, {LAVPixFmt_NV12, AV_PIX_FMT_NV12},\n    {LAVPixFmt_YUY2, AV_PIX_FMT_YUYV422},   {LAVPixFmt_RGB24, AV_PIX_FMT_BGR24},\n    {LAVPixFmt_RGB32, AV_PIX_FMT_BGRA},     {LAVPixFmt_ARGB32, AV_PIX_FMT_BGRA},\n    {LAVPixFmt_RGB48, AV_PIX_FMT_RGB48LE},  {LAVPixFmt_AYUV, AV_PIX_FMT_VUYX},\n    {LAVPixFmt_Y410, AV_PIX_FMT_XV30},      {LAVPixFmt_Y416, AV_PIX_FMT_XV48},\n};\n\nAVPixelFormat getFFPixelFormatFromLAV(LAVPixelFormat pixFmt, int bpp)\n{\n    AVPixelFormat fmt = AV_PIX_FMT_NONE;\n    for (int i = 0; i < countof(lav_ff_pixfmt_map); i++)\n    {\n        if (lav_ff_pixfmt_map[i].pixfmt == pixFmt)\n        {\n            fmt = lav_ff_pixfmt_map[i].ffpixfmt;\n            break;\n        }\n    }\n    if (fmt == AV_PIX_FMT_NONE)\n    {\n        switch (pixFmt)\n        {\n        case LAVPixFmt_YUV420bX:\n            fmt = (bpp == 9)\n                      ? AV_PIX_FMT_YUV420P9LE\n                      : ((bpp == 10) ? AV_PIX_FMT_YUV420P10LE\n                                     : ((bpp == 12) ? AV_PIX_FMT_YUV420P12LE\n                                                    : ((bpp == 14) ? AV_PIX_FMT_YUV420P14LE : AV_PIX_FMT_YUV420P16LE)));\n            break;\n        case LAVPixFmt_YUV422bX:\n            fmt = (bpp == 9)\n                      ? AV_PIX_FMT_YUV422P9LE\n                      : ((bpp == 10) ? AV_PIX_FMT_YUV422P10LE\n                                     : ((bpp == 12) ? AV_PIX_FMT_YUV422P12LE\n                                                    : ((bpp == 14) ? AV_PIX_FMT_YUV422P14LE : AV_PIX_FMT_YUV422P16LE)));\n            break;\n        case LAVPixFmt_YUV444bX:\n            fmt = (bpp == 9)\n                      ? AV_PIX_FMT_YUV444P9LE\n                      : ((bpp == 10) ? AV_PIX_FMT_YUV444P10LE\n                                     : ((bpp == 12) ? AV_PIX_FMT_YUV444P12LE\n                                                    : ((bpp == 14) ? AV_PIX_FMT_YUV444P14LE : AV_PIX_FMT_YUV444P16LE)));\n            break;\n        case LAVPixFmt_P016: fmt = (bpp <= 10) ? AV_PIX_FMT_P010LE : AV_PIX_FMT_P016LE; break;\n        case LAVPixFmt_Y216: fmt = (bpp <= 10) ? AV_PIX_FMT_Y210 : AV_PIX_FMT_Y216; break;\n        default: ASSERT(0);\n        }\n    }\n    return fmt;\n}\n\nstatic void free_buffers(struct LAVFrame *pFrame)\n{\n    _aligned_free(pFrame->data[0]);\n    _aligned_free(pFrame->data[1]);\n    _aligned_free(pFrame->data[2]);\n    _aligned_free(pFrame->data[3]);\n    memset(pFrame->data, 0, sizeof(pFrame->data));\n\n    _aligned_free(pFrame->stereo[0]);\n    _aligned_free(pFrame->stereo[1]);\n    _aligned_free(pFrame->stereo[2]);\n    _aligned_free(pFrame->stereo[3]);\n    memset(pFrame->stereo, 0, sizeof(pFrame->stereo));\n}\n\nHRESULT AllocLAVFrameBuffers(LAVFrame *pFrame, ptrdiff_t stride)\n{\n    LAVPixFmtDesc desc = getPixelFormatDesc(pFrame->format);\n\n    if (stride < pFrame->width)\n    {\n        // Ensure alignment of at least 32 on all planes\n        stride = FFALIGN(pFrame->width, 64);\n    }\n\n    stride *= desc.codedbytes;\n\n    int alignedHeight = FFALIGN(pFrame->height, 2);\n\n    memset(pFrame->data, 0, sizeof(pFrame->data));\n    memset(pFrame->stereo, 0, sizeof(pFrame->stereo));\n    memset(pFrame->stride, 0, sizeof(pFrame->stride));\n    for (int plane = 0; plane < desc.planes; plane++)\n    {\n        ptrdiff_t planeStride = stride / desc.planeWidth[plane];\n        size_t size = planeStride * (alignedHeight / desc.planeHeight[plane]);\n        pFrame->data[plane] = (BYTE *)_aligned_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE, 64);\n        if (pFrame->data[plane] == nullptr)\n        {\n            free_buffers(pFrame);\n            return E_OUTOFMEMORY;\n        }\n        pFrame->stride[plane] = planeStride;\n    }\n\n    if (pFrame->flags & LAV_FRAME_FLAG_MVC)\n    {\n        for (int plane = 0; plane < desc.planes; plane++)\n        {\n            size_t size = pFrame->stride[plane] * (alignedHeight / desc.planeHeight[plane]);\n            pFrame->stereo[plane] = (BYTE *)_aligned_malloc(size + AV_INPUT_BUFFER_PADDING_SIZE, 64);\n            if (pFrame->stereo[plane] == nullptr)\n            {\n                free_buffers(pFrame);\n                return E_OUTOFMEMORY;\n            }\n        }\n    }\n\n    pFrame->destruct = &free_buffers;\n    pFrame->flags |= LAV_FRAME_FLAG_BUFFER_MODIFY;\n\n    return S_OK;\n}\n\nHRESULT FreeLAVFrameBuffers(LAVFrame *pFrame)\n{\n    CheckPointer(pFrame, E_POINTER);\n\n    if (pFrame->destruct)\n    {\n        pFrame->destruct(pFrame);\n        pFrame->destruct = nullptr;\n        pFrame->priv_data = nullptr;\n    }\n    memset(pFrame->data, 0, sizeof(pFrame->data));\n    memset(pFrame->stereo, 0, sizeof(pFrame->stereo));\n    memset(pFrame->stride, 0, sizeof(pFrame->stride));\n\n    for (int i = 0; i < pFrame->side_data_count; i++)\n    {\n        SAFE_CO_FREE(pFrame->side_data[i].data);\n    }\n    SAFE_CO_FREE(pFrame->side_data);\n    pFrame->side_data_count = 0;\n\n    return S_OK;\n}\n\nHRESULT CopyLAVFrame(LAVFrame *pSrc, LAVFrame **ppDst)\n{\n    ASSERT(pSrc->format != LAVPixFmt_DXVA2 && pSrc->format != LAVPixFmt_D3D11);\n    *ppDst = (LAVFrame *)CoTaskMemAlloc(sizeof(LAVFrame));\n    if (!*ppDst)\n        return E_OUTOFMEMORY;\n    **ppDst = *pSrc;\n\n    (*ppDst)->destruct = nullptr;\n    (*ppDst)->priv_data = nullptr;\n\n    HRESULT hr = AllocLAVFrameBuffers(*ppDst);\n    if (FAILED(hr))\n        return hr;\n\n    LAVPixFmtDesc desc = getPixelFormatDesc(pSrc->format);\n    for (int plane = 0; plane < desc.planes; plane++)\n    {\n        size_t linesize = (pSrc->width / desc.planeWidth[plane]) * desc.codedbytes;\n        BYTE *dst = (*ppDst)->data[plane];\n        BYTE *src = pSrc->data[plane];\n        if (!dst || !src)\n            return E_FAIL;\n        for (int i = 0; i < (pSrc->height / desc.planeHeight[plane]); i++)\n        {\n            memcpy(dst, src, linesize);\n            dst += (*ppDst)->stride[plane];\n            src += pSrc->stride[plane];\n        }\n\n        if (pSrc->flags & LAV_FRAME_FLAG_MVC)\n        {\n            dst = (*ppDst)->stereo[plane];\n            src = pSrc->stereo[plane];\n            if (!dst || !src)\n                return E_FAIL;\n            for (int i = 0; i < (pSrc->height / desc.planeHeight[plane]); i++)\n            {\n                memcpy(dst, src, linesize);\n                dst += (*ppDst)->stride[plane];\n                src += pSrc->stride[plane];\n            }\n        }\n    }\n\n    (*ppDst)->side_data = nullptr;\n    (*ppDst)->side_data_count = 0;\n    for (int i = 0; i < pSrc->side_data_count; i++)\n    {\n        BYTE *p = AddLAVFrameSideData(*ppDst, pSrc->side_data[i].guidType, pSrc->side_data[i].size);\n        if (p)\n            memcpy(p, pSrc->side_data[i].data, pSrc->side_data[i].size);\n    }\n\n    return S_OK;\n}\n\nHRESULT CopyLAVFrameInPlace(LAVFrame *pFrame)\n{\n    LAVFrame *tmpFrame = nullptr;\n    CopyLAVFrame(pFrame, &tmpFrame);\n    FreeLAVFrameBuffers(pFrame);\n    *pFrame = *tmpFrame;\n    SAFE_CO_FREE(tmpFrame);\n    return S_OK;\n}\n\nBYTE *AddLAVFrameSideData(LAVFrame *pFrame, GUID guidType, size_t size)\n{\n    BYTE *ptr = (BYTE *)CoTaskMemRealloc(pFrame->side_data, sizeof(LAVFrameSideData) * (pFrame->side_data_count + 1));\n    if (!ptr)\n        return NULL;\n\n    pFrame->side_data = (LAVFrameSideData *)ptr;\n    pFrame->side_data[pFrame->side_data_count].guidType = guidType;\n    pFrame->side_data[pFrame->side_data_count].data = (BYTE *)CoTaskMemAlloc(size);\n    pFrame->side_data[pFrame->side_data_count].size = size;\n\n    if (!pFrame->side_data[pFrame->side_data_count].data)\n        return NULL;\n\n    memset(pFrame->side_data[pFrame->side_data_count].data, 0, size);\n\n    pFrame->side_data_count++;\n\n    return pFrame->side_data[pFrame->side_data_count - 1].data;\n}\n\nBYTE *GetLAVFrameSideData(LAVFrame *pFrame, GUID guidType, size_t *pSize)\n{\n    if (!pFrame || pFrame->side_data_count == 0)\n        return NULL;\n\n    ASSERT(pSize);\n\n    for (int i = 0; i < pFrame->side_data_count; i++)\n    {\n        if (pFrame->side_data[i].guidType == guidType)\n        {\n            *pSize = pFrame->side_data[i].size;\n            return pFrame->side_data[i].data;\n        }\n    }\n\n    return NULL;\n}\n\nbool ValidateLAVFrameBuffers(LAVFrame* pFrame)\n{\n    if (pFrame->format >= LAVPixFmt_HWFormats)\n        return true;\n\n    if (pFrame->format <= LAVPixFmt_None)\n        return false;\n\n    // direct doesn't use the pointers, but will provide them through callbacks\n    if (pFrame->direct)\n        return true;\n\n    LAVPixFmtDesc desc = getPixelFormatDesc(pFrame->format);\n    for (int i = 0; i < desc.planes; i++)\n    {\n        if (pFrame->data[i] == nullptr)\n            return false;\n\n        ptrdiff_t min_linesize = (pFrame->width / desc.planeWidth[i]) * desc.codedbytes;\n        if (abs(pFrame->stride[i]) < min_linesize)\n            return false;\n    }\n\n    return true;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/quicksync.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"quicksync.h\"\n\n#include \"moreuuids.h\"\n\n#include \"parsers/H264SequenceParser.h\"\n#include \"parsers/MPEG2HeaderParser.h\"\n#include \"parsers/VC1HeaderParser.h\"\n\n#include \"Media.h\"\n\n#include <Shlwapi.h>\n#include <dxva2api.h>\n#include <evr.h>\n\n// Timestamp padding to avoid an issue with negative timestamps\n// 10 hours should be enough padding to take care of all eventualities\n#define RTPADDING 360000000000i64\n\n////////////////////////////////////////////////////////////////////////////////\n// Constructor\n////////////////////////////////////////////////////////////////////////////////\n\nILAVDecoder *CreateDecoderQuickSync()\n{\n    return new CDecQuickSync();\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// Codec FourCC map\n////////////////////////////////////////////////////////////////////////////////\n\nstatic const FOURCC FourCC_MPG1 = mmioFOURCC('M', 'P', 'G', '1');\nstatic const FOURCC FourCC_MPG2 = mmioFOURCC('M', 'P', 'G', '2');\nstatic const FOURCC FourCC_VC1 = mmioFOURCC('W', 'V', 'C', '1');\nstatic const FOURCC FourCC_WMV3 = mmioFOURCC('W', 'M', 'V', '3');\nstatic const FOURCC FourCC_H264 = mmioFOURCC('H', '2', '6', '4');\nstatic const FOURCC FourCC_AVC1 = mmioFOURCC('A', 'V', 'C', '1');\n\nstatic struct\n{\n    AVCodecID ffcodec;\n    FOURCC fourCC;\n} quicksync_codecs[] = {\n    {AV_CODEC_ID_MPEG2VIDEO, FourCC_MPG2},\n    {AV_CODEC_ID_VC1, FourCC_VC1},\n    {AV_CODEC_ID_WMV3, FourCC_WMV3},\n    {AV_CODEC_ID_H264, FourCC_H264},\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// CQSMediaSample Implementation\n////////////////////////////////////////////////////////////////////////////////\n\nclass CQSMediaSample : public IMediaSample\n{\n  public:\n    CQSMediaSample(BYTE *pBuffer, long len)\n        : m_pBuffer(pBuffer)\n        , m_lLen(len)\n        , m_lActualLen(len)\n    {\n    }\n\n    // IUnknown\n    STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject)\n    {\n        if (riid == IID_IUnknown)\n        {\n            AddRef();\n            *ppvObject = (IUnknown *)this;\n        }\n        else if (riid == IID_IMediaSample)\n        {\n            AddRef();\n            *ppvObject = (IMediaSample *)this;\n        }\n        else\n        {\n            return E_NOINTERFACE;\n        }\n        return S_OK;\n    }\n    STDMETHODIMP_(ULONG) AddRef()\n    {\n        LONG lRef = InterlockedIncrement(&m_cRef);\n        return max(ULONG(lRef), 1ul);\n    }\n    STDMETHODIMP_(ULONG) Release()\n    {\n        LONG lRef = InterlockedDecrement(&m_cRef);\n        if (lRef == 0)\n        {\n            m_cRef++;\n            delete this;\n            return 0;\n        }\n        return max(ULONG(lRef), 1ul);\n    }\n\n    // IMediaSample\n    STDMETHODIMP GetPointer(BYTE **ppBuffer)\n    {\n        CheckPointer(ppBuffer, E_POINTER);\n        *ppBuffer = m_pBuffer;\n        return S_OK;\n    }\n    STDMETHODIMP_(long) GetSize(void) { return m_lLen; }\n    STDMETHODIMP GetTime(REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)\n    {\n        CheckPointer(pTimeStart, E_POINTER);\n        CheckPointer(pTimeEnd, E_POINTER);\n\n        if (m_rtStart != AV_NOPTS_VALUE)\n        {\n            *pTimeStart = m_rtStart;\n            if (m_rtStop != AV_NOPTS_VALUE)\n            {\n                *pTimeEnd = m_rtStop;\n                return S_OK;\n            }\n            *pTimeEnd = m_rtStart + 1;\n            return VFW_S_NO_STOP_TIME;\n        }\n        return VFW_E_SAMPLE_TIME_NOT_SET;\n    }\n\n    STDMETHODIMP SetTime(REFERENCE_TIME *pTimeStart, REFERENCE_TIME *pTimeEnd)\n    {\n        if (!pTimeStart)\n        {\n            m_rtStart = m_rtStop = AV_NOPTS_VALUE;\n        }\n        else\n        {\n            m_rtStart = *pTimeStart;\n            if (!pTimeEnd)\n                m_rtStop = AV_NOPTS_VALUE;\n            else\n                m_rtStop = *pTimeEnd;\n        }\n        return S_OK;\n    }\n\n    STDMETHODIMP IsSyncPoint(void) { return m_bSyncPoint ? S_OK : S_FALSE; }\n    STDMETHODIMP SetSyncPoint(BOOL bIsSyncPoint)\n    {\n        m_bSyncPoint = bIsSyncPoint;\n        return S_OK;\n    }\n    STDMETHODIMP IsPreroll(void) { return E_NOTIMPL; }\n    STDMETHODIMP SetPreroll(BOOL bIsPreroll) { return E_NOTIMPL; }\n    STDMETHODIMP_(long) GetActualDataLength(void) { return m_lActualLen; }\n    STDMETHODIMP SetActualDataLength(long length)\n    {\n        m_lActualLen = length;\n        return S_OK;\n    }\n    STDMETHODIMP GetMediaType(AM_MEDIA_TYPE **ppMediaType) { return S_FALSE; }\n    STDMETHODIMP SetMediaType(AM_MEDIA_TYPE *pMediaType) { return E_NOTIMPL; }\n    STDMETHODIMP IsDiscontinuity(void) { return m_bDiscontinuity ? S_OK : S_FALSE; }\n    STDMETHODIMP SetDiscontinuity(BOOL bDiscontinuity)\n    {\n        m_bDiscontinuity = bDiscontinuity;\n        return S_OK;\n    }\n    STDMETHODIMP GetMediaTime(LONGLONG *pTimeStart, LONGLONG *pTimeEnd) { return E_NOTIMPL; }\n    STDMETHODIMP SetMediaTime(LONGLONG *pTimeStart, LONGLONG *pTimeEnd) { return E_NOTIMPL; }\n\n  private:\n    BYTE *m_pBuffer = nullptr;\n    long m_lLen = 0;\n    long m_lActualLen = 0;\n    REFERENCE_TIME m_rtStart = AV_NOPTS_VALUE;\n    REFERENCE_TIME m_rtStop = AV_NOPTS_VALUE;\n\n    BOOL m_bSyncPoint = FALSE;\n    BOOL m_bDiscontinuity = FALSE;\n\n    ULONG m_cRef = 1;\n};\n\nclass CIDirect3DDeviceManager9Proxy : public IDirect3DDeviceManager9\n{\n  public:\n    CIDirect3DDeviceManager9Proxy(IPin *pPin)\n        : m_pPin(pPin)\n    {\n    }\n    ~CIDirect3DDeviceManager9Proxy() { SafeRelease(&m_D3DManager); }\n\n#define CREATE_DEVICE                      \\\n    if (!m_D3DManager)                     \\\n    {                                      \\\n        if (FAILED(CreateDeviceManager())) \\\n            return E_FAIL;                 \\\n    }\n\n    // IUnknown\n    HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, void **ppvObject)\n    {\n        CREATE_DEVICE;\n        return m_D3DManager->QueryInterface(riid, ppvObject);\n    }\n    ULONG STDMETHODCALLTYPE AddRef(void)\n    {\n        ULONG lRef = InterlockedIncrement(&m_cRef);\n        return max(ULONG(lRef), 1ul);\n    }\n    ULONG STDMETHODCALLTYPE Release(void)\n    {\n        ULONG lRef = InterlockedDecrement(&m_cRef);\n        if (lRef == 0)\n        {\n            m_cRef++;\n            delete this;\n            return 0;\n        }\n        return max(ULONG(lRef), 1ul);\n    }\n\n    // IDirect3DDeviceManager9\n    HRESULT STDMETHODCALLTYPE ResetDevice(IDirect3DDevice9 *pDevice, UINT resetToken)\n    {\n        CREATE_DEVICE;\n        return m_D3DManager->ResetDevice(pDevice, resetToken);\n    }\n    HRESULT STDMETHODCALLTYPE OpenDeviceHandle(HANDLE *phDevice)\n    {\n        CREATE_DEVICE;\n        return m_D3DManager->OpenDeviceHandle(phDevice);\n    }\n    HRESULT STDMETHODCALLTYPE CloseDeviceHandle(HANDLE hDevice)\n    {\n        CREATE_DEVICE;\n        return m_D3DManager->CloseDeviceHandle(hDevice);\n    }\n    HRESULT STDMETHODCALLTYPE TestDevice(HANDLE hDevice)\n    {\n        CREATE_DEVICE;\n        return m_D3DManager->TestDevice(hDevice);\n    }\n    HRESULT STDMETHODCALLTYPE LockDevice(HANDLE hDevice, IDirect3DDevice9 **ppDevice, BOOL fBlock)\n    {\n        CREATE_DEVICE;\n        return m_D3DManager->LockDevice(hDevice, ppDevice, fBlock);\n    }\n    HRESULT STDMETHODCALLTYPE UnlockDevice(HANDLE hDevice, BOOL fSaveState)\n    {\n        CREATE_DEVICE;\n        return m_D3DManager->UnlockDevice(hDevice, fSaveState);\n    }\n    HRESULT STDMETHODCALLTYPE GetVideoService(HANDLE hDevice, REFIID riid, void **ppService)\n    {\n        CREATE_DEVICE;\n        return m_D3DManager->GetVideoService(hDevice, riid, ppService);\n    }\n\n  private:\n    HRESULT STDMETHODCALLTYPE CreateDeviceManager()\n    {\n        DbgLog((LOG_TRACE, 10, L\"CIDirect3DDeviceManager9Proxy::CreateDeviceManager()\"));\n        HRESULT hr = S_OK;\n        IMFGetService *pGetService = nullptr;\n        hr = m_pPin->QueryInterface(__uuidof(IMFGetService), (void **)&pGetService);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> IMFGetService not available\"));\n            goto done;\n        }\n\n        // Get the Direct3D device manager.\n        IDirect3DDeviceManager9 *pDevMgr = nullptr;\n        hr = pGetService->GetService(MR_VIDEO_ACCELERATION_SERVICE, __uuidof(IDirect3DDeviceManager9),\n                                     (void **)&pDevMgr);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> D3D Device Manager not available\"));\n            goto done;\n        }\n\n        m_D3DManager = pDevMgr;\n    done:\n        SafeRelease(&pGetService);\n        return hr;\n    }\n\n  private:\n    IDirect3DDeviceManager9 *m_D3DManager = nullptr;\n    IPin *m_pPin = nullptr;\n    ULONG m_cRef = 1;\n};\n\n////////////////////////////////////////////////////////////////////////////////\n// QuickSync decoder implementation\n////////////////////////////////////////////////////////////////////////////////\n\nCDecQuickSync::CDecQuickSync(void)\n    : CDecBase()\n{\n    ZeroMemory(&qs, sizeof(qs));\n    ZeroMemory(&m_DXVAExtendedFormat, sizeof(m_DXVAExtendedFormat));\n}\n\nCDecQuickSync::~CDecQuickSync(void)\n{\n    DestroyDecoder(true);\n}\n\nSTDMETHODIMP CDecQuickSync::DestroyDecoder(bool bFull)\n{\n    if (m_pDecoder)\n    {\n        qs.destroy(m_pDecoder);\n        m_pDecoder = nullptr;\n    }\n\n    if (bFull)\n    {\n        SafeRelease(&m_pD3DDevMngr);\n        FreeLibrary(qs.quickSyncLib);\n    }\n\n    return S_OK;\n}\n\n// ILAVDecoder\nSTDMETHODIMP CDecQuickSync::Init()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecQuickSync::Init(): Trying to open QuickSync decoder\"));\n\n    int flags = av_get_cpu_flags();\n    if (!(flags & AV_CPU_FLAG_SSE4))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> CPU is not SSE 4.1 capable, this is not even worth a try....\"));\n        return E_FAIL;\n    }\n\n    if (!qs.quickSyncLib)\n    {\n        WCHAR wModuleFile[1024];\n        GetModuleFileName(g_hInst, wModuleFile, 1024);\n        PathRemoveFileSpecW(wModuleFile);\n        wcscat_s(wModuleFile, TEXT(\"\\\\\") TEXT(QS_DEC_DLL_NAME));\n\n        qs.quickSyncLib = LoadLibrary(wModuleFile);\n        if (qs.quickSyncLib == nullptr)\n        {\n            DWORD dwError = GetLastError();\n            DbgLog((LOG_ERROR, 10, L\"-> Loading of \" TEXT(QS_DEC_DLL_NAME) L\" failed (%d)\", dwError));\n            return E_FAIL;\n        }\n\n        qs.create = (pcreateQuickSync *)GetProcAddress(qs.quickSyncLib, \"createQuickSync\");\n        if (qs.create == nullptr)\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Failed to load function \\\"createQuickSync\\\"\"));\n            return E_FAIL;\n        }\n        qs.destroy = (pdestroyQuickSync *)GetProcAddress(qs.quickSyncLib, \"destroyQuickSync\");\n        if (qs.destroy == nullptr)\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Failed to load function \\\"destroyQuickSync\\\"\"));\n            return E_FAIL;\n        }\n        qs.check = (pcheck *)GetProcAddress(qs.quickSyncLib, \"check\");\n        if (qs.check == nullptr)\n        {\n            DbgLog((LOG_ERROR, 10, L\"-> Failed to load function \\\"check\\\"\"));\n            return E_FAIL;\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecQuickSync::PostConnect(IPin *pPin)\n{\n    HRESULT hr = S_OK;\n    DbgLog((LOG_TRACE, 10, L\"CDecQuickSync::PostConnect()\"));\n\n    // Release the previous manager (if any)\n    SafeRelease(&m_pD3DDevMngr);\n\n    // Create our proxy object\n    m_pD3DDevMngr = new CIDirect3DDeviceManager9Proxy(pPin);\n\n    // Tell the QuickSync decoder about it\n    m_pDecoder->SetD3DDeviceManager(m_pD3DDevMngr);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecQuickSync::Check()\n{\n    if (!qs.check)\n        return E_FAIL;\n\n    DWORD qsflags = qs.check();\n    if (qsflags & QS_CAP_HW_ACCELERATION)\n    {\n        return S_OK;\n    }\n\n    DbgLog((LOG_TRACE, 10, L\"-> Decoder records no HW acceleration\"));\n    return E_FAIL;\n}\n\nSTDMETHODIMP CDecQuickSync::CheckH264Sequence(const BYTE *buffer, size_t buflen, int nal_size, int *pRefFrames,\n                                              int *pProfile, int *pLevel)\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecQuickSync::CheckH264Sequence(): Checking H264 frame for SPS\"));\n    CH264SequenceParser h264parser;\n    h264parser.ParseNALs(buffer, buflen, nal_size);\n    if (h264parser.sps.valid)\n    {\n        m_bInterlaced = h264parser.sps.interlaced;\n        fillDXVAExtFormat(m_DXVAExtendedFormat, h264parser.sps.full_range, h264parser.sps.primaries,\n                          h264parser.sps.colorspace, h264parser.sps.trc);\n        if (pRefFrames)\n            *pRefFrames = h264parser.sps.ref_frames;\n        if (pProfile)\n            *pProfile = h264parser.sps.profile;\n        if (pLevel)\n            *pLevel = h264parser.sps.level;\n        DbgLog((LOG_TRACE, 10, L\"-> SPS found\"));\n        if (h264parser.sps.profile > 100 || h264parser.sps.chroma != 1 || h264parser.sps.luma_bitdepth != 8 ||\n            h264parser.sps.chroma_bitdepth != 8)\n        {\n            DbgLog((LOG_TRACE, 10,\n                    L\"  -> SPS indicates video incompatible with QuickSync, aborting (profile: %d, chroma: %d, \"\n                    L\"bitdepth: %d/%d)\",\n                    h264parser.sps.profile, h264parser.sps.chroma, h264parser.sps.luma_bitdepth,\n                    h264parser.sps.chroma_bitdepth));\n            return E_FAIL;\n        }\n        DbgLog((LOG_TRACE, 10, L\"-> Video seems compatible with QuickSync\"));\n        return S_OK;\n    }\n    return S_FALSE;\n}\n\nSTDMETHODIMP CDecQuickSync::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)\n{\n    HRESULT hr = S_OK;\n    DbgLog((LOG_TRACE, 10, L\"CDecQuickSync::InitDecoder(): Initializing QuickSync decoder\"));\n\n    DestroyDecoder(false);\n\n    FOURCC fourCC = (FOURCC)0;\n    for (int i = 0; i < countof(quicksync_codecs); i++)\n    {\n        if (quicksync_codecs[i].ffcodec == codec)\n        {\n            fourCC = quicksync_codecs[i].fourCC;\n            break;\n        }\n    }\n\n    if (fourCC == 0)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Codec id %d does not map to a QuickSync FourCC codec\", codec));\n        return E_FAIL;\n    }\n\n    m_pDecoder = qs.create();\n    if (!m_pDecoder || !m_pDecoder->getOK())\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Decoder creation failed\"));\n        return E_FAIL;\n    }\n    m_pDecoder->SetDeliverSurfaceCallback(this, &QS_DeliverSurfaceCallback);\n\n    m_nAVCNalSize = 0;\n    if (pmt->subtype == MEDIASUBTYPE_AVC1 || pmt->subtype == MEDIASUBTYPE_avc1 || pmt->subtype == MEDIASUBTYPE_CCV1)\n    {\n        if (pmt->formattype == FORMAT_MPEG2Video)\n        {\n            MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)pmt->pbFormat;\n            fourCC = FourCC_AVC1;\n            m_bAVC1 = TRUE;\n            m_nAVCNalSize = mp2vi->dwFlags;\n        }\n        else\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> AVC1 without MPEG2VIDEOINFO not supported\"));\n            return E_FAIL;\n        }\n    }\n\n    BYTE *extradata = nullptr;\n    size_t extralen = 0;\n    getExtraData(*pmt, nullptr, &extralen);\n    if (extralen > 0)\n    {\n        extradata = (BYTE *)av_malloc(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n        if (extradata == nullptr)\n            return E_OUTOFMEMORY;\n        getExtraData(*pmt, extradata, nullptr);\n    }\n\n    m_bNeedSequenceCheck = FALSE;\n    m_bInterlaced = TRUE;\n    m_bUseTimestampQueue = m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_ONLY_DTS;\n\n    int ref_frames = 0;\n    int profile = 0;\n    int level = 0;\n\n    if (extralen > 0)\n    {\n        if (fourCC == FourCC_AVC1 || fourCC == FourCC_H264)\n        {\n            hr = CheckH264Sequence(extradata, extralen, m_bAVC1 ? 2 : 0, &ref_frames, &profile, &level);\n            if (FAILED(hr))\n            {\n                return VFW_E_UNSUPPORTED_VIDEO;\n            }\n            else if (hr == S_FALSE)\n            {\n                m_bNeedSequenceCheck = TRUE;\n            }\n        }\n        else if (fourCC == FourCC_MPG2)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Scanning extradata for MPEG2 sequence header\"));\n            CMPEG2HeaderParser mpeg2parser(extradata, extralen);\n            if (mpeg2parser.hdr.valid)\n            {\n                if (mpeg2parser.hdr.chroma >= 2)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"  -> Sequence header indicates incompatible chroma sampling (chroma: %d)\",\n                            mpeg2parser.hdr.chroma));\n                    return VFW_E_UNSUPPORTED_VIDEO;\n                }\n                m_bInterlaced = mpeg2parser.hdr.interlaced;\n            }\n        }\n        else if (fourCC == FourCC_VC1)\n        {\n            CVC1HeaderParser vc1Parser(extradata, extralen);\n            m_bInterlaced = vc1Parser.hdr.interlaced;\n        }\n    }\n    else\n    {\n        m_bNeedSequenceCheck = (fourCC == FourCC_H264);\n    }\n\n    // Done with the extradata\n    if (extradata)\n        av_freep(&extradata);\n\n    // Configure QuickSync decoder\n    CQsConfig qsConfig;\n    m_pDecoder->GetConfig(&qsConfig);\n\n    // Timestamp correction is only used for VC-1 codecs which send PTS\n    // because this is not handled properly by the API (it expects DTS)\n    qsConfig.bTimeStampCorrection =\n        1; //(codec == AV_CODEC_ID_VC1 && !(m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_ONLY_DTS));\n\n    // Configure number of buffers (dependant on ref_frames)\n    // MPEG2 and VC1 always use \"low latency\" mode\n    if (ref_frames > 8 || qsConfig.bTimeStampCorrection)\n        qsConfig.nOutputQueueLength = 8;\n    else\n        qsConfig.nOutputQueueLength = 0;\n\n    // Disallow software fallback\n    qsConfig.bEnableSwEmulation = false;\n\n    // Enable DVD support\n    qsConfig.bEnableDvdDecoding = true;\n\n    // We want the pure image, no mod-16 padding\n    qsConfig.bMod16Width = false;\n\n    // Configure threading\n    qsConfig.bEnableMultithreading = true;\n    qsConfig.bEnableMtCopy = true;\n\n    // Configure video processing\n    qsConfig.vpp = 0;\n\n    m_bDI = m_pSettings->GetHWAccelDeintMode() == HWDeintMode_Hardware && !m_pSettings->GetDeintTreatAsProgressive();\n    qsConfig.bEnableVideoProcessing = m_bDI ? true : false;\n    qsConfig.bVppEnableDeinterlacing = m_bDI ? true : false;\n    qsConfig.bVppEnableFullRateDI = m_pSettings->GetHWAccelDeintOutput() == DeintOutput_FramePerField;\n    qsConfig.bVppEnableDITimeStampsInterpolation = true;\n    qsConfig.bVppEnableForcedDeinterlacing =\n        m_bDI && ((m_bInterlaced && m_pSettings->GetDeinterlacingMode() == DeintMode_Aggressive) ||\n                  m_pSettings->GetDeinterlacingMode() == DeintMode_Force);\n\n    qsConfig.bForceFieldOrder = m_pSettings->GetDeintFieldOrder() != DeintFieldOrder_Auto;\n    qsConfig.eFieldOrder = (QsFieldOrder)m_pSettings->GetDeintFieldOrder();\n\n    // Save!\n    m_pDecoder->SetConfig(&qsConfig);\n\n    CMediaType mt = *pmt;\n\n    // Fixup media type - the QuickSync decoder is a bit picky about this.\n    // We usually do not trust the media type information and instead scan the bitstream.\n    // This ensures that we only ever send valid and supported data to the decoder,\n    // so with this we try to circumvent the checks in the QuickSync decoder\n    mt.SetType(&MEDIATYPE_Video);\n    MPEG2VIDEOINFO *mp2vi = (*mt.FormatType() == FORMAT_MPEG2Video) ? (MPEG2VIDEOINFO *)mt.Format() : nullptr;\n    BITMAPINFOHEADER *bmi = nullptr;\n    videoFormatTypeHandler(mt.Format(), mt.FormatType(), &bmi);\n    switch (fourCC)\n    {\n    case FourCC_MPG2:\n        mt.SetSubtype(&MEDIASUBTYPE_MPEG2_VIDEO);\n        if (mp2vi)\n            mp2vi->dwProfile = 4;\n        break;\n    case FourCC_AVC1:\n    case FourCC_H264:\n        if (mp2vi)\n        {\n            mp2vi->dwProfile = profile ? profile : 100;\n            mp2vi->dwLevel = level ? level : 41;\n        }\n        break;\n    case FourCC_VC1:\n        if (mp2vi)\n            mp2vi->dwProfile = 3;\n        bmi->biCompression = fourCC;\n        break;\n    case FourCC_WMV3:\n        mt.SetSubtype(&MEDIASUBTYPE_WMV3);\n        if (mp2vi)\n            mp2vi->dwProfile = 0;\n        bmi->biCompression = fourCC;\n        break;\n    }\n\n    hr = m_pDecoder->TestMediaType(&mt, fourCC);\n    if (hr != S_OK)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> TestMediaType failed\"));\n        return E_FAIL;\n    }\n\n    hr = m_pDecoder->InitDecoder(&mt, fourCC);\n    if (hr != S_OK)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> InitDecoder failed\"));\n        return E_FAIL;\n    }\n\n    m_Codec = fourCC;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecQuickSync::Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,\n                                   BOOL bSyncPoint, BOOL bDiscontinuity, IMediaSample *pMediaSample)\n{\n    HRESULT hr;\n\n    if (m_bNeedSequenceCheck && (m_Codec == FourCC_H264 || m_Codec == FourCC_AVC1))\n    {\n        hr = CheckH264Sequence(buffer, buflen, m_nAVCNalSize);\n        if (FAILED(hr))\n        {\n            return E_FAIL;\n        }\n        else if (hr == S_OK)\n        {\n            m_bNeedSequenceCheck = FALSE;\n        }\n    }\n\n    if (m_Codec == FourCC_MPG2)\n    {\n        const uint8_t *eosmarker = nullptr;\n        const uint8_t *end = buffer + buflen;\n        int status = CheckForSequenceMarkers(AV_CODEC_ID_MPEG2VIDEO, buffer, buflen, &m_MpegParserState, &eosmarker);\n        // If we found a EOS marker, but its not at the end of the packet, then split the packet\n        // to be able to individually decode the frame before the EOS, and then decode the remainder\n        if (status & STATE_EOS_FOUND && eosmarker && eosmarker != end)\n        {\n            Decode(buffer, (int)(eosmarker - buffer), rtStart, rtStop, bSyncPoint, bDiscontinuity, nullptr);\n\n            rtStart = rtStop = AV_NOPTS_VALUE;\n            buffer = eosmarker;\n            buflen = (int)(end - eosmarker);\n        }\n        else if (eosmarker)\n        {\n            m_bEndOfSequence = TRUE;\n        }\n    }\n\n    if (rtStart != AV_NOPTS_VALUE)\n    {\n        rtStart += RTPADDING;\n        if (rtStart < 0)\n            rtStart = 0;\n        if (rtStop != AV_NOPTS_VALUE)\n        {\n            rtStop += RTPADDING;\n            if (rtStop < 0)\n                rtStop = AV_NOPTS_VALUE;\n        }\n    }\n\n    if (m_bUseTimestampQueue)\n    {\n        m_timestampQueue.push(rtStart);\n    }\n\n    IMediaSample *pSample = new CQSMediaSample(const_cast<BYTE *>(buffer), buflen);\n    pSample->SetTime(&rtStart, &rtStop);\n    pSample->SetDiscontinuity(bDiscontinuity);\n    pSample->SetSyncPoint(bSyncPoint);\n\n    hr = m_pDecoder->Decode(pSample);\n\n    SafeRelease(&pSample);\n\n    if (m_bEndOfSequence)\n    {\n        m_bEndOfSequence = FALSE;\n        EndOfStream();\n        Deliver(m_pCallback->GetFlushFrame());\n    }\n\n    return hr;\n}\n\nHRESULT CDecQuickSync::QS_DeliverSurfaceCallback(void *obj, QsFrameData *data)\n{\n    CDecQuickSync *filter = (CDecQuickSync *)obj;\n\n    if (filter->m_bUseTimestampQueue)\n    {\n        if (filter->m_timestampQueue.empty())\n        {\n            data->rtStart = AV_NOPTS_VALUE;\n        }\n        else\n        {\n            data->rtStart = filter->m_timestampQueue.front();\n            filter->m_timestampQueue.pop();\n        }\n        data->rtStop = AV_NOPTS_VALUE;\n    }\n\n    if (data->rtStart != AV_NOPTS_VALUE && data->rtStart > 0)\n    {\n        data->rtStart -= RTPADDING;\n        if (data->rtStop != AV_NOPTS_VALUE)\n            data->rtStop -= RTPADDING;\n    }\n    else\n    {\n        data->rtStop = AV_NOPTS_VALUE;\n    }\n    filter->HandleFrame(data);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecQuickSync::HandleFrame(QsFrameData *data)\n{\n    // Setup the LAVFrame\n    LAVFrame *pFrame = nullptr;\n    AllocateFrame(&pFrame);\n\n    pFrame->format = LAVPixFmt_NV12;\n    pFrame->sw_format = pFrame->format;\n    pFrame->width = data->rcClip.right - data->rcClip.left + 1;\n    pFrame->height = data->rcClip.bottom - data->rcClip.top + 1;\n    pFrame->rtStart = data->rtStart;\n    pFrame->rtStop = (data->rtStop - 1 > data->rtStart) ? data->rtStop : AV_NOPTS_VALUE;\n    pFrame->repeat = !!(data->dwInterlaceFlags & AM_VIDEO_FLAG_REPEAT_FIELD);\n    pFrame->aspect_ratio.num = data->dwPictAspectRatioX;\n    pFrame->aspect_ratio.den = data->dwPictAspectRatioY;\n    pFrame->ext_format = m_DXVAExtendedFormat;\n    pFrame->interlaced = !(data->dwInterlaceFlags & AM_VIDEO_FLAG_WEAVE);\n    pFrame->avgFrameDuration = GetFrameDuration();\n\n    LAVDeintFieldOrder fo = m_pSettings->GetDeintFieldOrder();\n    pFrame->tff = (fo == DeintFieldOrder_Auto) ? !!(data->dwInterlaceFlags & AM_VIDEO_FLAG_FIELD1FIRST)\n                                               : (fo == DeintFieldOrder_TopFieldFirst);\n\n    // Assign the buffer to the LAV Frame bufers\n    pFrame->data[0] = data->y;\n    pFrame->data[1] = data->u;\n    pFrame->stride[0] = pFrame->stride[1] = data->dwStride;\n\n    if (!m_bInterlaced && pFrame->interlaced)\n        m_bInterlaced = TRUE;\n\n    pFrame->interlaced =\n        (pFrame->interlaced || (m_bInterlaced && m_pSettings->GetDeinterlacingMode() == DeintMode_Aggressive) ||\n         m_pSettings->GetDeinterlacingMode() == DeintMode_Force) &&\n        !(m_pSettings->GetDeinterlacingMode() == DeintMode_Disable) && !m_bDI;\n\n    if (m_bEndOfSequence)\n        pFrame->flags |= LAV_FRAME_FLAG_END_OF_SEQUENCE;\n\n    m_pCallback->Deliver(pFrame);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecQuickSync::Flush()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecQuickSync::Flush(): Flushing QuickSync decoder\"));\n\n    m_pDecoder->BeginFlush();\n    m_pDecoder->OnSeek(0);\n    m_pDecoder->EndFlush();\n\n    // Clear timestamp queue\n    std::queue<REFERENCE_TIME>().swap(m_timestampQueue);\n\n    return __super::Flush();\n}\n\nSTDMETHODIMP CDecQuickSync::EndOfStream()\n{\n    m_pDecoder->Flush(true);\n    m_pDecoder->OnSeek(0);\n    return S_OK;\n}\n\nSTDMETHODIMP CDecQuickSync::GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware)\n{\n    // Output is always NV12\n    if (pPix)\n        *pPix = LAVPixFmt_NV12;\n    if (pBpp)\n        *pBpp = 8;\n    if (pPixSoftware)\n        *pPixSoftware = LAVPixFmt_NV12;\n    return S_OK;\n}\n\nSTDMETHODIMP_(REFERENCE_TIME) CDecQuickSync::GetFrameDuration()\n{\n    CMediaType &mt = m_pCallback->GetInputMediaType();\n    REFERENCE_TIME rtDuration = 0;\n    videoFormatTypeHandler(mt.Format(), mt.FormatType(), nullptr, &rtDuration, nullptr, nullptr);\n    return (m_bInterlaced && m_bDI && m_pSettings->GetHWAccelDeintOutput() == DeintOutput_FramePerField)\n               ? rtDuration / 2\n               : rtDuration;\n}\n\nSTDMETHODIMP_(BOOL) CDecQuickSync::IsInterlaced(BOOL bAllowGuess)\n{\n    return (m_bInterlaced || m_pSettings->GetDeinterlacingMode() == DeintMode_Force) && !m_bDI;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/quicksync.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n#include \"DecBase.h\"\n\n#include \"IQuickSyncDecoder.h\"\n\ntypedef IQuickSyncDecoder *__stdcall pcreateQuickSync();\ntypedef void __stdcall pdestroyQuickSync(IQuickSyncDecoder *);\ntypedef DWORD __stdcall pcheck();\n\n#include <queue>\n\nclass CDecQuickSync : public CDecBase\n{\n  public:\n    CDecQuickSync(void);\n    virtual ~CDecQuickSync(void);\n\n    // ILAVDecoder\n    STDMETHODIMP Check();\n    STDMETHODIMP InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData);\n    STDMETHODIMP Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BOOL bSyncPoint,\n                        BOOL bDiscontinuity, IMediaSample *pSample);\n    STDMETHODIMP Flush();\n    STDMETHODIMP EndOfStream();\n    STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware);\n    STDMETHODIMP_(REFERENCE_TIME) GetFrameDuration();\n    STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess);\n    STDMETHODIMP_(const WCHAR *) GetDecoderName() { return L\"quicksync\"; }\n\n    STDMETHODIMP PostConnect(IPin *pPin);\n\n    STDMETHODIMP GetHWAccelActiveDevice(BSTR *pstrDeviceName)\n    {\n        CheckPointer(pstrDeviceName, E_POINTER);\n        *pstrDeviceName = SysAllocString(L\"Intel\\xae QuickSync\");\n        if (!*pstrDeviceName)\n            return E_OUTOFMEMORY;\n        return S_OK;\n    }\n\n    // CDecBase\n    STDMETHODIMP Init();\n\n  private:\n    STDMETHODIMP DestroyDecoder(bool bFull);\n\n    static HRESULT QS_DeliverSurfaceCallback(void *obj, QsFrameData *data);\n    STDMETHODIMP HandleFrame(QsFrameData *data);\n\n    STDMETHODIMP CheckH264Sequence(const BYTE *buffer, size_t buflen, int nal_size, int *pRefFrames = nullptr,\n                                   int *pProfile = nullptr, int *pLevel = nullptr);\n\n  private:\n    struct\n    {\n        HMODULE quickSyncLib;\n\n        pcreateQuickSync *create;\n        pdestroyQuickSync *destroy;\n        pcheck *check;\n    } qs;\n\n    IQuickSyncDecoder *m_pDecoder = nullptr;\n\n    BOOL m_bNeedSequenceCheck = FALSE;\n    BOOL m_bInterlaced = TRUE;\n    BOOL m_bDI = FALSE;\n    BOOL m_bAVC1 = FALSE;\n    int m_nAVCNalSize = 0;\n    BOOL m_bEndOfSequence = FALSE;\n\n    BOOL m_bUseTimestampQueue;\n    std::queue<REFERENCE_TIME> m_timestampQueue;\n\n    DXVA2_ExtendedFormat m_DXVAExtendedFormat;\n\n    FOURCC m_Codec = 0;\n\n    IDirect3DDeviceManager9 *m_pD3DDevMngr = nullptr;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/wmv9mft.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"wmv9mft.h\"\n\n#include <mfapi.h>\n#include <mferror.h>\n\n#include <wmcodecdsp.h>\n\n#include <propvarutil.h>\n\n#include \"parsers/VC1HeaderParser.h\"\n\nEXTERN_GUID(CLSID_CWMVDecMediaObject, 0x82d353df, 0x90bd, 0x4382, 0x8b, 0xc2, 0x3f, 0x61, 0x92, 0xb7, 0x6e, 0x34);\n\n////////////////////////////////////////////////////////////////////////////////\n// Constructor\n////////////////////////////////////////////////////////////////////////////////\n\nILAVDecoder *CreateDecoderWMV9MFT()\n{\n    return new CDecWMV9MFT();\n}\n\n////////////////////////////////////////////////////////////////////////////////\n// WMV9 MFT decoder implementation\n////////////////////////////////////////////////////////////////////////////////\n\nCDecWMV9MFT::CDecWMV9MFT(void)\n    : CDecBase()\n{\n    memset(&MF, 0, sizeof(MF));\n}\n\nCDecWMV9MFT::~CDecWMV9MFT(void)\n{\n    DestroyDecoder(true);\n}\n\nSTDMETHODIMP CDecWMV9MFT::DestroyDecoder(bool bFull)\n{\n    SAFE_DELETE(m_vc1Header);\n    {\n        CAutoLock lock(&m_BufferCritSec);\n        for (auto it = m_BufferQueue.begin(); it != m_BufferQueue.end(); it++)\n        {\n            SafeRelease(&(*it)->pBuffer);\n            delete (*it);\n        }\n        m_BufferQueue.clear();\n    }\n\n    if (bFull)\n    {\n        SafeRelease(&m_pMFT);\n        if (MF.Shutdown)\n            MF.Shutdown();\n        FreeLibrary(MF.mfplat);\n    }\n    return S_OK;\n}\n\n#define GET_PROC_MF(name)                                                                      \\\n    MF.name = (tMF##name *)GetProcAddress(MF.mfplat, \"MF\" #name);                              \\\n    if (MF.name == nullptr)                                                                    \\\n    {                                                                                          \\\n        DbgLog((LOG_ERROR, 10, L\"-> Failed to load function \\\"%s\\\"\", TEXT(\"MF\") TEXT(#name))); \\\n        return E_FAIL;                                                                         \\\n    }\n\n// ILAVDecoder\nSTDMETHODIMP CDecWMV9MFT::Init()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecWMV9MFT::Init(): Trying to open WMV9 MFT decoder\"));\n    HRESULT hr = S_OK;\n\n    MF.mfplat = LoadLibrary(L\"mfplat.dll\");\n    if (!MF.mfplat)\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to load mfplat.dll\"));\n        return E_FAIL;\n    }\n\n    GET_PROC_MF(Startup);\n    GET_PROC_MF(Shutdown);\n    GET_PROC_MF(CreateMediaType);\n    GET_PROC_MF(CreateSample);\n    GET_PROC_MF(CreateAlignedMemoryBuffer);\n    GET_PROC_MF(AverageTimePerFrameToFrameRate);\n\n    MF.Startup(MF_VERSION, MFSTARTUP_LITE);\n\n    hr = CoCreateInstance(CLSID_CWMVDecMediaObject, nullptr, CLSCTX_INPROC_SERVER, IID_IMFTransform, (void **)&m_pMFT);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to create MFT object\"));\n        return hr;\n    }\n\n    // Force decoder deinterlacing, dxva and FI to off\n    IPropertyStore *pProp = nullptr;\n    hr = m_pMFT->QueryInterface(&pProp);\n    if (SUCCEEDED(hr))\n    {\n        PROPVARIANT variant;\n        InitPropVariantFromBoolean(FALSE, &variant);\n        pProp->SetValue(MFPKEY_DECODER_DEINTERLACING, variant);\n        pProp->SetValue(MFPKEY_DXVA_ENABLED, variant);\n        pProp->SetValue(MFPKEY_FI_ENABLED, variant);\n        SafeRelease(&pProp);\n    }\n\n    return S_OK;\n}\n\nstatic GUID VerifySubtype(AVCodecID codec, GUID subtype)\n{\n    if (codec == AV_CODEC_ID_WMV3)\n    {\n        return MEDIASUBTYPE_WMV3;\n    }\n    else\n    {\n        if (subtype == MEDIASUBTYPE_WVC1 || subtype == MEDIASUBTYPE_wvc1)\n            return MEDIASUBTYPE_WVC1;\n        else if (subtype == MEDIASUBTYPE_WMVA || subtype == MEDIASUBTYPE_wmva)\n            return MEDIASUBTYPE_WMVA;\n        else // fallback\n            return MEDIASUBTYPE_WVC1;\n    }\n}\n\nSTDMETHODIMP CDecWMV9MFT::InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData)\n{\n    HRESULT hr = S_OK;\n    DbgLog((LOG_TRACE, 10, L\"CDecWMV9MFT::InitDecoder(): Initializing WMV9 MFT decoder\"));\n\n    DestroyDecoder(false);\n\n    BITMAPINFOHEADER *pBMI = nullptr;\n    REFERENCE_TIME rtAvg = 0;\n    DWORD dwARX = 0, dwARY = 0;\n    videoFormatTypeHandler(*pmt, &pBMI, &rtAvg, &dwARX, &dwARY);\n\n    size_t extralen = 0;\n    BYTE *extra = nullptr;\n    getExtraData(*pmt, nullptr, &extralen);\n    if (extralen > 0)\n    {\n        extra = (BYTE *)av_mallocz(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n        getExtraData(*pmt, extra, &extralen);\n    }\n\n    if (codec == AV_CODEC_ID_VC1 && extralen)\n    {\n        size_t i = 0;\n        for (i = 0; i < (extralen - 4); i++)\n        {\n            uint32_t code = AV_RB32(extra + i);\n            if ((code & ~0xFF) == 0x00000100)\n                break;\n        }\n        if (i == 0)\n        {\n            memmove(extra + 1, extra, extralen);\n            *extra = 0;\n            extralen++;\n        }\n        else if (i > 1)\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> VC-1 Header at position %u (should be 0 or 1)\", i));\n        }\n    }\n\n    if (extralen > 0)\n    {\n        m_vc1Header = new CVC1HeaderParser(extra, extralen, codec);\n    }\n\n    /* Create input type */\n    m_nCodecId = codec;\n\n    IMFMediaType *pMTIn = nullptr;\n    MF.CreateMediaType(&pMTIn);\n\n    pMTIn->SetUINT32(MF_MT_COMPRESSED, TRUE);\n    pMTIn->SetUINT32(MF_MT_ALL_SAMPLES_INDEPENDENT, FALSE);\n    pMTIn->SetUINT32(MF_MT_FIXED_SIZE_SAMPLES, FALSE);\n\n    pMTIn->SetGUID(MF_MT_MAJOR_TYPE, MFMediaType_Video);\n    pMTIn->SetGUID(MF_MT_SUBTYPE, VerifySubtype(codec, pmt->subtype));\n\n    MFSetAttributeSize(pMTIn, MF_MT_FRAME_SIZE, pBMI->biWidth, pBMI->biHeight);\n\n    UINT32 rateNum = 0, rateDen = 0;\n    MF.AverageTimePerFrameToFrameRate(rtAvg, &rateNum, &rateDen);\n    MFSetAttributeRatio(pMTIn, MF_MT_FRAME_RATE, rateNum, rateDen);\n\n    if (dwARX != 0 && dwARY != 0)\n    {\n        int uParX = 1, uParY = 1;\n        av_reduce(&uParX, &uParY, dwARX * pBMI->biHeight, dwARY * pBMI->biWidth, INT_MAX);\n        MFSetAttributeRatio(pMTIn, MF_MT_PIXEL_ASPECT_RATIO, uParX, uParY);\n    }\n\n    pMTIn->SetBlob(MF_MT_USER_DATA, extra, (UINT32)extralen);\n    av_freep(&extra);\n\n    hr = m_pMFT->SetInputType(0, pMTIn, 0);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to set input type on MFT\"));\n        return hr;\n    }\n\n    /* Create output type */\n    hr = SelectOutputType();\n    SafeRelease(&pMTIn);\n\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> Failed to set output type on MFT\"));\n        return hr;\n    }\n\n    IMFMediaType *pMTOut = nullptr;\n    m_pMFT->GetOutputCurrentType(0, &pMTOut);\n    m_bInterlaced =\n        MFGetAttributeUINT32(pMTOut, MF_MT_INTERLACE_MODE, MFVideoInterlace_Unknown) > MFVideoInterlace_Progressive;\n    SafeRelease(&pMTOut);\n\n    m_bManualReorder = (codec == AV_CODEC_ID_VC1) && !(m_pCallback->GetDecodeFlags() & LAV_VIDEO_DEC_FLAG_ONLY_DTS);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CDecWMV9MFT::SelectOutputType()\n{\n    HRESULT hr = S_OK;\n    int idx = 0;\n\n    m_OutPixFmt = LAVPixFmt_None;\n    IMFMediaType *pMTOut = nullptr;\n    while (SUCCEEDED(hr = m_pMFT->GetOutputAvailableType(0, idx++, &pMTOut)) && m_OutPixFmt == LAVPixFmt_None)\n    {\n        GUID outSubtype;\n        if (SUCCEEDED(pMTOut->GetGUID(MF_MT_SUBTYPE, &outSubtype)))\n        {\n            if (outSubtype == MEDIASUBTYPE_NV12)\n            {\n                hr = m_pMFT->SetOutputType(0, pMTOut, 0);\n                m_OutPixFmt = LAVPixFmt_NV12;\n                break;\n            }\n            else if (outSubtype == MEDIASUBTYPE_YV12)\n            {\n                hr = m_pMFT->SetOutputType(0, pMTOut, 0);\n                m_OutPixFmt = LAVPixFmt_YUV420;\n                break;\n            }\n        }\n        SafeRelease(&pMTOut);\n    }\n\n    return hr;\n}\n\nIMFMediaBuffer *CDecWMV9MFT::CreateMediaBuffer(const BYTE *pData, DWORD dwDataLen)\n{\n    HRESULT hr;\n    IMFMediaBuffer *pBuffer = nullptr;\n    hr = MF.CreateAlignedMemoryBuffer(dwDataLen, MF_16_BYTE_ALIGNMENT, &pBuffer);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"Unable to allocate MF Media Buffer, hr: 0x%x\", hr));\n        goto done;\n    }\n\n    BYTE *pOutBuffer = nullptr;\n    hr = pBuffer->Lock(&pOutBuffer, NULL, NULL);\n    if (FAILED(hr))\n    {\n        SafeRelease(&pBuffer);\n        DbgLog((LOG_ERROR, 10, L\"Unable to lock MF Media Buffer, hr: 0x%x\", hr));\n        goto done;\n    }\n\n    memcpy(pOutBuffer, pData, dwDataLen);\n\n    pBuffer->Unlock();\n    pBuffer->SetCurrentLength(dwDataLen);\n\ndone:\n    return pBuffer;\n}\n\nSTDMETHODIMP CDecWMV9MFT::Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop,\n                                 BOOL bSyncPoint, BOOL bDiscontinuity, IMediaSample *pMediaSample)\n{\n    HRESULT hr = S_OK;\n    DWORD dwStatus = 0;\n\n    hr = m_pMFT->GetInputStatus(0, &dwStatus);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> GetInputStatus() failed with hr: 0x%x\", hr));\n        return S_FALSE;\n    }\n    if (!(dwStatus & MFT_INPUT_STATUS_ACCEPT_DATA))\n        return S_FALSE;\n\n    if (m_vc1Header && (m_bManualReorder || m_bNeedKeyFrame))\n    {\n        AVPictureType pictype = m_vc1Header->ParseVC1PictureType(buffer, buflen);\n        if (m_bManualReorder)\n        {\n            if (pictype == AV_PICTURE_TYPE_I || pictype == AV_PICTURE_TYPE_P)\n            {\n                if (m_bReorderBufferValid)\n                    m_timestampQueue.push(m_rtReorderBuffer);\n                m_rtReorderBuffer = rtStart;\n                m_bReorderBufferValid = TRUE;\n            }\n            else\n            {\n                m_timestampQueue.push(rtStart);\n            }\n        }\n\n        if (m_bNeedKeyFrame)\n        {\n            if (pictype != AV_PICTURE_TYPE_I)\n            {\n                if (m_bManualReorder)\n                    m_timestampQueue.pop();\n                return S_OK;\n            }\n            else\n            {\n                m_bNeedKeyFrame = FALSE;\n                bSyncPoint = TRUE;\n            }\n        }\n    }\n\n    IMFSample *pSample = nullptr;\n    hr = MF.CreateSample(&pSample);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_ERROR, 10, L\"Unable to allocate MF Sample, hr: 0x%x\", hr));\n        return E_FAIL;\n    }\n\n    IMFMediaBuffer *pMFBuffer = CreateMediaBuffer(buffer, buflen);\n    if (!pMFBuffer)\n    {\n        DbgLog((LOG_TRACE, 10, L\"Unable to allocate media buffer\"));\n        SafeRelease(&pSample);\n        return E_FAIL;\n    }\n\n    pSample->AddBuffer(pMFBuffer);\n\n    if (rtStart != AV_NOPTS_VALUE)\n    {\n        pSample->SetSampleTime(rtStart);\n        if (rtStop != AV_NOPTS_VALUE && rtStop > (rtStart - 1))\n            pSample->SetSampleDuration(rtStop - rtStart);\n    }\n\n    pSample->SetUINT32(MFSampleExtension_CleanPoint, bSyncPoint);\n    pSample->SetUINT32(MFSampleExtension_Discontinuity, bDiscontinuity);\n\n    hr = m_pMFT->ProcessInput(0, pSample, 0);\n\n    if (hr == MF_E_NOTACCEPTING)\n    {\n        // Not accepting data right now, try to process output and try again\n        ProcessOutput();\n        hr = m_pMFT->ProcessInput(0, pSample, 0);\n    }\n\n    SafeRelease(&pMFBuffer);\n    SafeRelease(&pSample);\n\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> ProcessInput failed with hr: 0x%x\", hr));\n        return E_FAIL;\n    }\n\n    return ProcessOutput();\n}\n\nstatic inline void memcpy_plane(BYTE *dst, const BYTE *src, ptrdiff_t width, ptrdiff_t stride, int height)\n{\n    for (int i = 0; i < height; i++)\n    {\n        memcpy(dst, src, width);\n        dst += stride;\n        src += width;\n    }\n}\n\nIMFMediaBuffer *CDecWMV9MFT::GetBuffer(DWORD dwRequiredSize)\n{\n    CAutoLock lock(&m_BufferCritSec);\n    HRESULT hr;\n\n    Buffer *buffer = nullptr;\n    for (auto it = m_BufferQueue.begin(); it != m_BufferQueue.end(); it++)\n    {\n        if (!(*it)->used)\n        {\n            buffer = *it;\n            break;\n        }\n    }\n    if (buffer)\n    {\n        // Validate Size\n        if (buffer->size < dwRequiredSize || !buffer->pBuffer)\n        {\n            SafeRelease(&buffer->pBuffer);\n            hr = MF.CreateAlignedMemoryBuffer(dwRequiredSize, MF_32_BYTE_ALIGNMENT, &buffer->pBuffer);\n            if (FAILED(hr))\n                return nullptr;\n            buffer->size = dwRequiredSize;\n        }\n    }\n    else\n    {\n        // Create a new buffer\n        DbgLog((LOG_TRACE, 10, L\"Allocating new buffer for WMV9 MFT\"));\n        buffer = new Buffer();\n        hr = MF.CreateAlignedMemoryBuffer(dwRequiredSize, MF_32_BYTE_ALIGNMENT, &buffer->pBuffer);\n        if (FAILED(hr))\n        {\n            delete buffer;\n            return nullptr;\n        }\n        buffer->size = dwRequiredSize;\n        m_BufferQueue.push_back(buffer);\n    }\n    buffer->used = 1;\n    buffer->pBuffer->AddRef();\n    buffer->pBuffer->SetCurrentLength(0);\n    return buffer->pBuffer;\n}\n\nvoid CDecWMV9MFT::ReleaseBuffer(IMFMediaBuffer *pBuffer)\n{\n    CAutoLock lock(&m_BufferCritSec);\n    Buffer *buffer = nullptr;\n    for (auto it = m_BufferQueue.begin(); it != m_BufferQueue.end(); it++)\n    {\n        if ((*it)->pBuffer == pBuffer)\n        {\n            (*it)->used = 0;\n            break;\n        }\n    }\n    pBuffer->Release();\n}\n\nvoid CDecWMV9MFT::wmv9_buffer_destruct(LAVFrame *pFrame)\n{\n    CDecWMV9MFT *pDec = (CDecWMV9MFT *)pFrame->priv_data;\n    IMFMediaBuffer *pMFBuffer = (IMFMediaBuffer *)pFrame->data[3];\n    pMFBuffer->Unlock();\n    pDec->ReleaseBuffer(pMFBuffer);\n}\n\nSTDMETHODIMP CDecWMV9MFT::ProcessOutput()\n{\n    HRESULT hr = S_OK;\n    DWORD dwStatus = 0;\n\n    MFT_OUTPUT_STREAM_INFO outputInfo = {0};\n    m_pMFT->GetOutputStreamInfo(0, &outputInfo);\n\n    IMFMediaBuffer *pMFBuffer = nullptr;\n    ASSERT(!(outputInfo.dwFlags & MFT_OUTPUT_STREAM_PROVIDES_SAMPLES));\n\n    MFT_OUTPUT_DATA_BUFFER OutputBuffer = {0};\n    if (!(outputInfo.dwFlags & MFT_OUTPUT_STREAM_PROVIDES_SAMPLES))\n    {\n        pMFBuffer = GetBuffer(outputInfo.cbSize);\n        if (!pMFBuffer)\n        {\n            DbgLog((LOG_TRACE, 10, L\"Unable to allocate media buffere\"));\n            return E_FAIL;\n        }\n\n        IMFSample *pSampleOut = nullptr;\n        hr = MF.CreateSample(&pSampleOut);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"Unable to allocate MF sample, hr: 0x%x\", hr));\n            ReleaseBuffer(pMFBuffer);\n            return E_FAIL;\n        }\n\n        pSampleOut->AddBuffer(pMFBuffer);\n        OutputBuffer.pSample = pSampleOut;\n    }\n    hr = m_pMFT->ProcessOutput(0, 1, &OutputBuffer, &dwStatus);\n\n    // We don't process events, just release them\n    SafeRelease(&OutputBuffer.pEvents);\n\n    // handle stream format changes\n    if (hr == MF_E_TRANSFORM_STREAM_CHANGE || OutputBuffer.dwStatus == MFT_OUTPUT_DATA_BUFFER_FORMAT_CHANGE)\n    {\n        SafeRelease(&OutputBuffer.pSample);\n        ReleaseBuffer(pMFBuffer);\n        hr = SelectOutputType();\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> Failed to handle stream change, hr: %x\", hr));\n            return E_FAIL;\n        }\n        // try again with the new type, it should work now!\n        return ProcessOutput();\n    }\n\n    // the MFT generated no output, discard the sample and return\n    if (hr == MF_E_TRANSFORM_NEED_MORE_INPUT || OutputBuffer.dwStatus == MFT_OUTPUT_DATA_BUFFER_NO_SAMPLE)\n    {\n        SafeRelease(&OutputBuffer.pSample);\n        ReleaseBuffer(pMFBuffer);\n        return S_FALSE;\n    }\n\n    // unknown error condition\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"-> ProcessOutput failed with hr: %x\", hr));\n        SafeRelease(&OutputBuffer.pSample);\n        ReleaseBuffer(pMFBuffer);\n        return E_FAIL;\n    }\n\n    LAVFrame *pFrame = nullptr;\n    AllocateFrame(&pFrame);\n\n    IMFMediaType *pMTOut = nullptr;\n    m_pMFT->GetOutputCurrentType(0, &pMTOut);\n\n    MFGetAttributeSize(pMTOut, MF_MT_FRAME_SIZE, (UINT32 *)&pFrame->width, (UINT32 *)&pFrame->height);\n    pFrame->format = m_OutPixFmt;\n    pFrame->sw_format = pFrame->format;\n\n    AVRational pixel_aspect_ratio = {1, 1};\n    MFGetAttributeRatio(pMTOut, MF_MT_PIXEL_ASPECT_RATIO, (UINT32 *)&pixel_aspect_ratio.num,\n                        (UINT32 *)&pixel_aspect_ratio.den);\n\n    AVRational display_aspect_ratio = {0, 0};\n    av_reduce(&display_aspect_ratio.num, &display_aspect_ratio.den, (int64_t)pixel_aspect_ratio.num * pFrame->width,\n              (int64_t)pixel_aspect_ratio.den * pFrame->height, INT_MAX);\n    pFrame->aspect_ratio = display_aspect_ratio;\n\n    pFrame->interlaced = MFGetAttributeUINT32(OutputBuffer.pSample, MFSampleExtension_Interlaced, FALSE);\n    pFrame->repeat = MFGetAttributeUINT32(OutputBuffer.pSample, MFSampleExtension_RepeatFirstField, FALSE);\n\n    LAVDeintFieldOrder fo = m_pSettings->GetDeintFieldOrder();\n    pFrame->tff = (fo == DeintFieldOrder_Auto)\n                      ? !MFGetAttributeUINT32(OutputBuffer.pSample, MFSampleExtension_BottomFieldFirst, FALSE)\n                      : (fo == DeintFieldOrder_TopFieldFirst);\n\n    if (pFrame->interlaced && !m_bInterlaced)\n        m_bInterlaced = TRUE;\n\n    pFrame->interlaced =\n        (pFrame->interlaced || (m_bInterlaced && m_pSettings->GetDeinterlacingMode() == DeintMode_Aggressive) ||\n         m_pSettings->GetDeinterlacingMode() == DeintMode_Force) &&\n        !(m_pSettings->GetDeinterlacingMode() == DeintMode_Disable);\n\n    pFrame->ext_format.VideoPrimaries = MFGetAttributeUINT32(pMTOut, MF_MT_VIDEO_PRIMARIES, MFVideoPrimaries_Unknown);\n    pFrame->ext_format.VideoTransferFunction =\n        MFGetAttributeUINT32(pMTOut, MF_MT_TRANSFER_FUNCTION, MFVideoTransFunc_Unknown);\n    pFrame->ext_format.VideoTransferMatrix =\n        MFGetAttributeUINT32(pMTOut, MF_MT_YUV_MATRIX, MFVideoTransferMatrix_Unknown);\n    pFrame->ext_format.VideoChromaSubsampling =\n        MFGetAttributeUINT32(pMTOut, MF_MT_VIDEO_CHROMA_SITING, MFVideoChromaSubsampling_Unknown);\n    pFrame->ext_format.NominalRange = MFGetAttributeUINT32(pMTOut, MF_MT_VIDEO_NOMINAL_RANGE, MFNominalRange_Unknown);\n\n    // HACK: don't flag range=limited if its the only value set, since its also the implied default, this helps to avoid\n    // a reconnect The MFT always sets this value, even if the bitstream says nothing about it, causing a reconnect on\n    // every vc1/wmv3 file\n    if (pFrame->ext_format.value == 0x2000)\n        pFrame->ext_format.value = 0;\n\n    // Timestamps\n    if (m_bManualReorder)\n    {\n        if (!m_timestampQueue.empty())\n        {\n            pFrame->rtStart = m_timestampQueue.front();\n            m_timestampQueue.pop();\n\n            LONGLONG llDuration = 0;\n            hr = OutputBuffer.pSample->GetSampleDuration(&llDuration);\n            if (SUCCEEDED(hr) && llDuration > 0)\n            {\n                pFrame->rtStop = pFrame->rtStart + llDuration;\n            }\n        }\n    }\n    else\n    {\n        LONGLONG llTimestamp = 0;\n        hr = OutputBuffer.pSample->GetSampleTime(&llTimestamp);\n        if (SUCCEEDED(hr))\n        {\n            pFrame->rtStart = llTimestamp;\n\n            LONGLONG llDuration = 0;\n            hr = OutputBuffer.pSample->GetSampleDuration(&llDuration);\n            if (SUCCEEDED(hr) && llDuration > 0)\n            {\n                pFrame->rtStop = pFrame->rtStart + llDuration;\n            }\n        }\n    }\n\n    SafeRelease(&pMTOut);\n\n    // Lock memory in the buffer\n    BYTE *pBuffer = nullptr;\n    pMFBuffer->Lock(&pBuffer, NULL, NULL);\n\n    // Check alignment\n    // If not properly aligned, we need to make the data aligned.\n    int alignment = (m_OutPixFmt == LAVPixFmt_NV12) ? 16 : 32;\n    if ((pFrame->width % alignment) != 0)\n    {\n        hr = AllocLAVFrameBuffers(pFrame);\n        if (FAILED(hr))\n        {\n            pMFBuffer->Unlock();\n            ReleaseBuffer(pMFBuffer);\n            SafeRelease(&OutputBuffer.pSample);\n            return hr;\n        }\n        size_t ySize = pFrame->width * pFrame->height;\n\n        memcpy_plane(pFrame->data[0], pBuffer, pFrame->width, pFrame->stride[0], pFrame->height);\n        if (m_OutPixFmt == LAVPixFmt_NV12)\n        {\n            memcpy_plane(pFrame->data[1], pBuffer + ySize, pFrame->width, pFrame->stride[1], pFrame->height / 2);\n        }\n        else if (m_OutPixFmt == LAVPixFmt_YUV420)\n        {\n            size_t uvSize = ySize / 4;\n            memcpy_plane(pFrame->data[2], pBuffer + ySize, pFrame->width / 2, pFrame->stride[2], pFrame->height / 2);\n            memcpy_plane(pFrame->data[1], pBuffer + ySize + uvSize, pFrame->width / 2, pFrame->stride[1],\n                         pFrame->height / 2);\n        }\n        pMFBuffer->Unlock();\n        ReleaseBuffer(pMFBuffer);\n    }\n    else\n    {\n        if (m_OutPixFmt == LAVPixFmt_NV12)\n        {\n            pFrame->data[0] = pBuffer;\n            pFrame->data[1] = pBuffer + pFrame->width * pFrame->height;\n            pFrame->stride[0] = pFrame->stride[1] = pFrame->width;\n        }\n        else if (m_OutPixFmt == LAVPixFmt_YUV420)\n        {\n            pFrame->data[0] = pBuffer;\n            pFrame->data[2] = pBuffer + pFrame->width * pFrame->height;\n            pFrame->data[1] = pFrame->data[2] + (pFrame->width / 2) * (pFrame->height / 2);\n            pFrame->stride[0] = pFrame->width;\n            pFrame->stride[1] = pFrame->stride[2] = pFrame->width / 2;\n        }\n        pFrame->data[3] = (BYTE *)pMFBuffer;\n        pFrame->destruct = wmv9_buffer_destruct;\n        pFrame->priv_data = this;\n    }\n    pFrame->flags |= LAV_FRAME_FLAG_BUFFER_MODIFY;\n    Deliver(pFrame);\n\n    SafeRelease(&OutputBuffer.pSample);\n\n    if (OutputBuffer.dwStatus == MFT_OUTPUT_DATA_BUFFER_INCOMPLETE)\n        return ProcessOutput();\n    return hr;\n}\n\nSTDMETHODIMP CDecWMV9MFT::Flush()\n{\n    DbgLog((LOG_TRACE, 10, L\"CDecWMV9MFT::Flush(): Flushing WMV9 decoder\"));\n    m_pMFT->ProcessMessage(MFT_MESSAGE_COMMAND_FLUSH, 0);\n\n    std::queue<REFERENCE_TIME>().swap(m_timestampQueue);\n    m_rtReorderBuffer = AV_NOPTS_VALUE;\n    m_bReorderBufferValid = FALSE;\n    m_bNeedKeyFrame = TRUE;\n\n    return __super::Flush();\n}\n\nSTDMETHODIMP CDecWMV9MFT::EndOfStream()\n{\n    if (m_bReorderBufferValid)\n        m_timestampQueue.push(m_rtReorderBuffer);\n    m_bReorderBufferValid = FALSE;\n    m_rtReorderBuffer = AV_NOPTS_VALUE;\n\n    m_pMFT->ProcessMessage(MFT_MESSAGE_COMMAND_DRAIN, 0);\n    ProcessOutput();\n    return S_OK;\n}\n\nSTDMETHODIMP CDecWMV9MFT::GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware)\n{\n    if (pPix)\n        *pPix = (m_OutPixFmt != LAVPixFmt_None) ? m_OutPixFmt : LAVPixFmt_NV12;\n    if (pBpp)\n        *pBpp = 8;\n    if (pPixSoftware)\n        *pPixSoftware = (m_OutPixFmt != LAVPixFmt_None) ? m_OutPixFmt : LAVPixFmt_NV12;\n    return S_OK;\n}\n\nSTDMETHODIMP_(BOOL) CDecWMV9MFT::IsInterlaced(BOOL bAllowGuess)\n{\n    return (m_bInterlaced || m_pSettings->GetDeinterlacingMode() == DeintMode_Force);\n}\n"
  },
  {
    "path": "decoder/LAVVideo/decoders/wmv9mft.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n#include \"DecBase.h\"\n\n#include <mfidl.h>\n\n#include <vector>\n#include <queue>\n\n////////////////////////////////////////////////////////////////////////////////\n// Dynlink types\n////////////////////////////////////////////////////////////////////////////////\ntypedef HRESULT STDAPICALLTYPE tMFStartup(ULONG Version, DWORD dwFlags);\ntypedef HRESULT STDAPICALLTYPE tMFShutdown();\n\ntypedef HRESULT STDAPICALLTYPE tMFCreateMediaType(IMFMediaType **ppMFType);\ntypedef HRESULT STDAPICALLTYPE tMFCreateSample(IMFSample **ppIMFSample);\ntypedef HRESULT STDAPICALLTYPE tMFCreateAlignedMemoryBuffer(DWORD cbMaxLength, DWORD cbAligment,\n                                                            IMFMediaBuffer **ppBuffer);\n\ntypedef HRESULT STDAPICALLTYPE tMFAverageTimePerFrameToFrameRate(UINT64 unAverageTimePerFrame, UINT32 *punNumerator,\n                                                                 UINT32 *punDenominator);\n\n#define MFMETHOD(name) tMF##name *##name\n\n////////////////////////////////////////////////////////////////////////////////\n// Class\n////////////////////////////////////////////////////////////////////////////////\n\nclass CVC1HeaderParser;\n\nclass CDecWMV9MFT : public CDecBase\n{\n    typedef struct _Buffer\n    {\n        IMFMediaBuffer *pBuffer = nullptr;\n        DWORD size = 0;\n        bool used = false;\n    } Buffer;\n\n  public:\n    CDecWMV9MFT(void);\n    virtual ~CDecWMV9MFT(void);\n\n    // ILAVDecoder\n    STDMETHODIMP InitDecoder(AVCodecID codec, const CMediaType *pmt, const MediaSideDataFFMpeg *pSideData);\n    STDMETHODIMP Decode(const BYTE *buffer, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop, BOOL bSyncPoint,\n                        BOOL bDiscontinuity, IMediaSample *pSample);\n    STDMETHODIMP Flush();\n    STDMETHODIMP EndOfStream();\n    STDMETHODIMP GetPixelFormat(LAVPixelFormat *pPix, int *pBpp, LAVPixelFormat *pPixSoftware);\n    STDMETHODIMP_(BOOL) IsInterlaced(BOOL bAllowGuess);\n    STDMETHODIMP_(const WCHAR *) GetDecoderName() { return L\"wmv9 mft\"; }\n    STDMETHODIMP HasThreadSafeBuffers() { return S_OK; }\n\n    // CDecBase\n    STDMETHODIMP Init();\n\n  private:\n    STDMETHODIMP DestroyDecoder(bool bFull);\n    STDMETHODIMP ProcessOutput();\n    STDMETHODIMP SelectOutputType();\n\n    IMFMediaBuffer *CreateMediaBuffer(const BYTE *pData, DWORD dwDataLen);\n\n    static void wmv9_buffer_destruct(LAVFrame *pFrame);\n\n    IMFMediaBuffer *GetBuffer(DWORD dwRequiredSize);\n    void ReleaseBuffer(IMFMediaBuffer *pBuffer);\n\n  private:\n    IMFTransform *m_pMFT = nullptr;\n\n    BOOL m_bInterlaced = TRUE;\n\n    LAVPixelFormat m_OutPixFmt = LAVPixFmt_None;\n    AVCodecID m_nCodecId = AV_CODEC_ID_NONE;\n\n    CCritSec m_BufferCritSec;\n    std::vector<Buffer *> m_BufferQueue;\n\n    BOOL m_bNeedKeyFrame = TRUE;\n    BOOL m_bManualReorder = FALSE;\n    BOOL m_bReorderBufferValid = FALSE;\n    REFERENCE_TIME m_rtReorderBuffer = AV_NOPTS_VALUE;\n    std::queue<REFERENCE_TIME> m_timestampQueue;\n\n    CVC1HeaderParser *m_vc1Header = nullptr;\n\n    struct\n    {\n        HMODULE mfplat = NULL;\n        MFMETHOD(Startup);\n        MFMETHOD(Shutdown);\n        MFMETHOD(CreateAlignedMemoryBuffer);\n        MFMETHOD(CreateSample);\n        MFMETHOD(CreateMediaType);\n        MFMETHOD(AverageTimePerFrameToFrameRate);\n    } MF;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/dllmain.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n// Based on the SampleParser Template by GDCL\n// --------------------------------------------------------------------------------\n// Copyright (c) GDCL 2004. All Rights Reserved.\n// You are free to re-use this as the basis for your own filter development,\n// provided you retain this copyright notice in the source.\n// http://www.gdcl.co.uk\n// --------------------------------------------------------------------------------\n\n#include \"stdafx.h\"\n\n// Initialize the GUIDs\n#include <InitGuid.h>\n\n#include <qnetwork.h>\n#include <dxva2api.h>\n#include \"LAVVideo.h\"\n#include \"VideoSettingsProp.h\"\n#include \"moreuuids.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n\n#include \"registry.h\"\n\n// --- COM factory table and registration code --------------\n\nconst AMOVIESETUP_PIN sudpPinsVideoDec[] = {{L\"Input\", FALSE, FALSE, FALSE, FALSE, &CLSID_NULL, nullptr,\n                                             CLAVVideo::sudPinTypesInCount, CLAVVideo::sudPinTypesIn},\n                                            {L\"Output\", FALSE, TRUE, FALSE, FALSE, &CLSID_NULL, nullptr,\n                                             CLAVVideo::sudPinTypesOutCount, CLAVVideo::sudPinTypesOut}};\n\nconst AMOVIESETUP_FILTER sudFilterReg = {&__uuidof(CLAVVideo), // filter clsid\n                                         L\"LAV Video Decoder\", // filter name\n                                         MERIT_PREFERRED + 3,  // merit\n                                         countof(sudpPinsVideoDec), sudpPinsVideoDec, CLSID_LegacyAmFilterCategory};\n\n// --- COM factory table and registration code --------------\n\n// DirectShow base class COM factory requires this table,\n// declaring all the COM objects in this DLL\nCFactoryTemplate g_Templates[] = {\n    // one entry for each CoCreate-able object\n    {sudFilterReg.strName, sudFilterReg.clsID, CreateInstance<CLAVVideo>, nullptr, &sudFilterReg},\n    // This entry is for the property page.\n    {L\"LAV Video Properties\", &CLSID_LAVVideoSettingsProp, CreateInstance<CLAVVideoSettingsProp>, nullptr, nullptr},\n    {L\"LAV Video Format Settings\", &CLSID_LAVVideoFormatsProp, CreateInstance<CLAVVideoFormatsProp>, nullptr, nullptr}};\nint g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);\n\n// self-registration entrypoint\nSTDAPI DllRegisterServer()\n{\n    // base classes will handle registration using the factory template table\n    return AMovieDllRegisterServer2(true);\n}\n\nSTDAPI DllUnregisterServer()\n{\n    // base classes will handle de-registration using the factory template table\n    return AMovieDllRegisterServer2(false);\n}\n\n// if we declare the correct C runtime entrypoint and then forward it to the DShow base\n// classes we will be sure that both the C/C++ runtimes and the base classes are initialized\n// correctly\nextern \"C\" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);\nBOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpReserved)\n{\n    return DllEntryPoint(reinterpret_cast<HINSTANCE>(hDllHandle), dwReason, lpReserved);\n}\n\nvoid CALLBACK OpenConfiguration(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)\n{\n    HRESULT hr = S_OK;\n    CUnknown *pInstance = CreateInstance<CLAVVideo>(nullptr, &hr);\n    IBaseFilter *pFilter = nullptr;\n    pInstance->NonDelegatingQueryInterface(IID_IBaseFilter, (void **)&pFilter);\n    if (pFilter)\n    {\n        pFilter->AddRef();\n        CBaseDSPropPage::ShowPropPageDialog(pFilter);\n    }\n    delete pInstance;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/AnnexBConverter.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"AnnexBConverter.h\"\n\n#include \"libavutil/intreadwrite.h\"\n\nCAnnexBConverter::CAnnexBConverter(void)\n{\n}\n\nCAnnexBConverter::~CAnnexBConverter(void)\n{\n}\n\nstatic HRESULT alloc_and_copy(uint8_t **poutbuf, int *poutbuf_size, const uint8_t *in, uint32_t in_size)\n{\n    uint32_t offset = *poutbuf_size;\n    uint8_t nal_header_size = offset ? 3 : 4;\n    void *tmp;\n\n    *poutbuf_size += in_size + nal_header_size;\n    tmp = av_realloc(*poutbuf, *poutbuf_size);\n    if (!tmp)\n        return E_OUTOFMEMORY;\n    *poutbuf = (uint8_t *)tmp;\n    memcpy(*poutbuf + nal_header_size + offset, in, in_size);\n    if (!offset)\n    {\n        AV_WB32(*poutbuf, 1);\n    }\n    else\n    {\n        (*poutbuf + offset)[0] = (*poutbuf + offset)[1] = 0;\n        (*poutbuf + offset)[2] = 1;\n    }\n\n    return S_OK;\n}\n\nHRESULT CAnnexBConverter::Convert(BYTE **poutbuf, int *poutbuf_size, const BYTE *buf, int buf_size)\n{\n    int32_t nal_size;\n    const uint8_t *buf_end = buf + buf_size;\n\n    *poutbuf_size = 0;\n\n    do\n    {\n        if (buf + m_NaluSize > buf_end)\n            goto fail;\n\n        if (m_NaluSize == 1)\n        {\n            nal_size = buf[0];\n        }\n        else if (m_NaluSize == 2)\n        {\n            nal_size = AV_RB16(buf);\n        }\n        else\n        {\n            nal_size = AV_RB32(buf);\n            if (m_NaluSize == 3)\n                nal_size >>= 8;\n        }\n\n        buf += m_NaluSize;\n\n        if (buf + nal_size > buf_end || nal_size < 0)\n            goto fail;\n\n        if (FAILED(alloc_and_copy(poutbuf, poutbuf_size, buf, nal_size)))\n            goto fail;\n\n        buf += nal_size;\n        buf_size -= (nal_size + m_NaluSize);\n    } while (buf_size > 0);\n\n    return S_OK;\nfail:\n    av_freep(poutbuf);\n    return E_FAIL;\n}\n\nHRESULT CAnnexBConverter::ConvertHEVCExtradata(BYTE **poutbuf, int *poutbuf_size, const BYTE *buf, int buf_size)\n{\n    if (buf_size < 23)\n        return E_INVALIDARG;\n\n    SetNALUSize(2);\n\n    *poutbuf = nullptr;\n    *poutbuf_size = 0;\n\n    int num_arrays = buf[22];\n    int remaining_size = buf_size - 23;\n    buf += 23;\n    for (int i = 0; i < num_arrays; i++)\n    {\n        if (remaining_size < 3)\n            break;\n        int cnt = AV_RB16(buf + 1);\n        buf += 3;\n        remaining_size -= 3;\n        for (int j = 0; j < cnt; j++)\n        {\n            if (remaining_size < 2)\n                break;\n            int len = AV_RB16(buf) + 2;\n            if (remaining_size < len)\n                break;\n            alloc_and_copy(poutbuf, poutbuf_size, buf + 2, len - 2);\n            buf += len;\n            remaining_size -= len;\n        }\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/AnnexBConverter.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nclass CAnnexBConverter\n{\n  public:\n    CAnnexBConverter(void);\n    ~CAnnexBConverter(void);\n\n    HRESULT SetNALUSize(int nalusize)\n    {\n        m_NaluSize = nalusize;\n        return S_OK;\n    }\n    HRESULT Convert(BYTE **poutbuf, int *poutbuf_size, const BYTE *buf, int buf_size);\n\n    HRESULT ConvertHEVCExtradata(BYTE **poutbuf, int *poutbuf_size, const BYTE *buf, int buf_size);\n\n  private:\n    int m_NaluSize = 0;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/H264SequenceParser.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"H264SequenceParser.h\"\n\n#include \"ByteParser.h\"\n#include \"H264Nalu.h\"\n\nCH264SequenceParser::CH264SequenceParser(void)\n{\n    ZeroMemory(&sps, sizeof(sps));\n    ZeroMemory(&pps, sizeof(pps));\n}\n\nCH264SequenceParser::~CH264SequenceParser(void)\n{\n}\n\nHRESULT CH264SequenceParser::ParseNALs(const BYTE *buffer, size_t buflen, int nal_size)\n{\n    CH264Nalu nalu;\n    nalu.SetBuffer(buffer, buflen, nal_size);\n\n    while (nalu.ReadNext())\n    {\n        const BYTE *data = nalu.GetDataBuffer() + 1;\n        const size_t len = nalu.GetDataLength() - 1;\n        if (nalu.GetType() == NALU_TYPE_SPS)\n        {\n            ParseSPS(data, len);\n            break;\n        }\n    }\n\n    return S_OK;\n}\n\nstatic void SPSDecodeScalingList(CByteParser &parser, int size)\n{\n    int i, last = 8, next = 8;\n    int matrix = parser.BitRead(1);\n    if (matrix)\n    {\n        for (i = 0; i < size; i++)\n        {\n            if (next)\n                next = (last + parser.SExpGolombRead()) & 0xff;\n            if (!i && !next)\n            { /* matrix not written */\n                break;\n            }\n            last = next ? next : last;\n        }\n    }\n}\n\nHRESULT CH264SequenceParser::ParseSPS(const BYTE *buffer, size_t buflen)\n{\n    CByteParser parser(buffer, buflen);\n    int i;\n\n    ZeroMemory(&sps, sizeof(sps));\n    // Defaults\n    sps.valid = 1;\n    sps.primaries = AVCOL_PRI_UNSPECIFIED;\n    sps.trc = AVCOL_TRC_UNSPECIFIED;\n    sps.colorspace = AVCOL_SPC_UNSPECIFIED;\n    sps.full_range = -1;\n\n    // Parse\n    sps.profile = parser.BitRead(8);\n    parser.BitRead(4); // constraint flags\n    parser.BitRead(4); // reserved\n    sps.level = parser.BitRead(8);\n    parser.UExpGolombRead(); // sps id\n\n    if (sps.profile == 100 || sps.profile == 110 || sps.profile == 122 || sps.profile == 244 || sps.profile == 44 ||\n        sps.profile == 83 || sps.profile == 86 || sps.profile == 118 || sps.profile == 128 || sps.profile == 144)\n    {\n        sps.chroma = (int)parser.UExpGolombRead();\n        if (sps.chroma == 3)\n            parser.BitRead(1);\n        sps.luma_bitdepth = (int)parser.UExpGolombRead() + 8;\n        sps.chroma_bitdepth = (int)parser.UExpGolombRead() + 8;\n        parser.BitRead(1); // transform_bypass\n\n        // decode scaling matrices\n        int scaling = parser.BitRead(1);\n        if (scaling)\n        {\n            // Decode scaling lists\n            SPSDecodeScalingList(parser, 16); // Intra, Y\n            SPSDecodeScalingList(parser, 16); // Intra, Cr\n            SPSDecodeScalingList(parser, 16); // Intra, Cb\n            SPSDecodeScalingList(parser, 16); // Inter, Y\n            SPSDecodeScalingList(parser, 16); // Inter, Cr\n            SPSDecodeScalingList(parser, 16); // Inter, Cb\n\n            SPSDecodeScalingList(parser, 64); // Intra, Y\n            SPSDecodeScalingList(parser, 64); // Inter, Y\n            if (sps.chroma == 3)\n            {\n                SPSDecodeScalingList(parser, 64); // Intra, Cr\n                SPSDecodeScalingList(parser, 64); // Inter, Cr\n                SPSDecodeScalingList(parser, 64); // Intra, Cb\n                SPSDecodeScalingList(parser, 64); // Inter, Cb\n            }\n        }\n    }\n    else\n    {\n        sps.chroma = 1;\n        sps.luma_bitdepth = 8;\n        sps.chroma_bitdepth = 8;\n    }\n\n    parser.UExpGolombRead();                     // log2_max_frame_num\n    int poc_type = (int)parser.UExpGolombRead(); // poc_type\n    if (poc_type == 0)\n        parser.UExpGolombRead(); // log2_max_poc_lsb\n    else if (poc_type == 1)\n    {\n        parser.BitRead(1);                         // delta_pic_order_always_zero_flag\n        parser.SExpGolombRead();                   // offset_for_non_ref_pic\n        parser.SExpGolombRead();                   // offset_for_top_to_bottom_field\n        int cyclen = (int)parser.UExpGolombRead(); // poc_cycle_length\n        for (i = 0; i < cyclen; i++)\n            parser.SExpGolombRead(); // offset_for_ref_frame[i]\n    }\n\n    sps.ref_frames = parser.UExpGolombRead(); // ref_frame_count\n    parser.BitRead(1);                        // gaps_in_frame_num_allowed_flag\n    parser.UExpGolombRead();                  // mb_width\n    parser.UExpGolombRead();                  // mb_height\n    sps.interlaced = !parser.BitRead(1);      // frame_mbs_only_flag\n    if (sps.interlaced)\n        parser.BitRead(1); // mb_aff\n\n    parser.BitRead(1);            // direct_8x8_inference_flag\n    int crop = parser.BitRead(1); // crop\n    if (crop)\n    {\n        parser.UExpGolombRead(); // crop_left\n        parser.UExpGolombRead(); // crop_right\n        parser.UExpGolombRead(); // crop_top\n        parser.UExpGolombRead(); // crop_bottom\n    }\n\n    int vui_present = parser.BitRead(1); // vui_parameters_present_flag\n    if (vui_present)\n    {\n        sps.ar_present = parser.BitRead(1); // aspect_ratio_info_present_flag\n        if (sps.ar_present)\n        {\n            int ar_idc = parser.BitRead(8); // aspect_ratio_idc\n            if (ar_idc == 255)\n            {\n                parser.BitRead(16); // sar.num\n                parser.BitRead(16); // sar.den\n            }\n        }\n\n        int overscan = parser.BitRead(1); // overscan_info_present_flag\n        if (overscan)\n            parser.BitRead(1); // overscan_appropriate_flag\n\n        int vid_sig_type = parser.BitRead(1); // video_signal_type_present_flag\n        if (vid_sig_type)\n        {\n            parser.BitRead(3);                  // video_format\n            sps.full_range = parser.BitRead(1); // video_full_range_flag\n\n            int colorinfo = parser.BitRead(1); // colour_description_present_flag\n            if (colorinfo)\n            {\n                sps.primaries = parser.BitRead(8);\n                sps.trc = parser.BitRead(8);\n                sps.colorspace = parser.BitRead(8);\n            }\n        }\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/H264SequenceParser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nclass CH264SequenceParser\n{\n  public:\n    CH264SequenceParser(void);\n    virtual ~CH264SequenceParser(void);\n\n    HRESULT ParseNALs(const BYTE *buffer, size_t buflen, int nal_size);\n\n  public:\n    struct\n    {\n        int valid;\n\n        int profile;\n        int level;\n        int chroma;\n        int luma_bitdepth;\n        int chroma_bitdepth;\n        int ref_frames;\n        int interlaced;\n        int ar_present;\n\n        int full_range;\n        int primaries;\n        int trc;\n        int colorspace;\n    } sps;\n\n    struct\n    {\n        int valid;\n    } pps;\n\n  private:\n    HRESULT ParseSPS(const BYTE *buffer, size_t buflen);\n};\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/HEVCSequenceParser.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"HEVCSequenceParser.h\"\n\n#include \"H264Nalu.h\"\n\n#define HEVC_NAL_VPS 32\n#define HEVC_NAL_SPS 33\n#define HEVC_NAL_PPS 34\n\nCHEVCSequenceParser::CHEVCSequenceParser()\n{\n    ZeroMemory(&sps, sizeof(sps));\n    sps.bitdepth = 8;\n}\n\nCHEVCSequenceParser::~CHEVCSequenceParser()\n{\n}\n\nHRESULT CHEVCSequenceParser::ParseNALs(const BYTE *buffer, size_t buflen, int nal_size)\n{\n    CH265Nalu nalu;\n    nalu.SetBuffer(buffer, buflen, nal_size);\n\n    while (nalu.ReadNext())\n    {\n        const BYTE *data = nalu.GetDataBuffer() + 2;\n        const size_t len = nalu.GetDataLength() - 2;\n        if (nalu.GetType() == HEVC_NAL_SPS)\n        {\n            CH264NALUnescape unescapedNAL(data, len);\n            ParseSPS(unescapedNAL.GetBuffer(), unescapedNAL.GetSize());\n            break;\n        }\n    }\n\n    return S_OK;\n}\n\nHRESULT CHEVCSequenceParser::ParseSPS(const BYTE *buffer, size_t buflen)\n{\n    CByteParser parser(buffer, buflen);\n    int i;\n\n    ZeroMemory(&sps, sizeof(sps));\n    sps.valid = 1;\n\n    struct\n    {\n        int profile_present;\n        int level_present;\n    } Sublayers[7];\n\n    parser.BitSkip(4);                      // sps_video_parameter_set_id\n    int max_sub_layers = parser.BitRead(3); // sps_max_sub_layers_minus1\n    parser.BitSkip(1);                      // sps_temporal_id_nesting_flag\n\n    // profile tier level\n    parser.BitSkip(2);               // general_profile_space\n    parser.BitSkip(1);               // general_tier_flag\n    sps.profile = parser.BitRead(5); // general_profile_idc\n\n    for (i = 0; i < 32; i++)\n    {\n        int flag = parser.BitRead(1);\n        if (sps.profile == 0 && i > 0 && flag)\n            sps.profile = i;\n    }\n    parser.BitSkip(1); // general_progressive_source_flag\n    parser.BitSkip(1); // general_interlaced_source_flag\n    parser.BitSkip(1); // general_non_packed_constraint_flag\n    parser.BitSkip(1); // general_frame_only_constraint_flag\n    if (sps.profile == 4)\n    {\n        sps.rext_profile = parser.BitRead(8); // 8 constraint flags\n\n        parser.BitSkip(1);  // general_lower_bit_rate_constraint_flag\n        parser.BitSkip(17); // general_reserved_zero_34bits\n        parser.BitSkip(17); // general_reserved_zero_34bits\n    }\n    else\n    {\n        parser.BitSkip(21); // general_reserved_zero_43bits\n        parser.BitSkip(22); // general_reserved_zero_43bits\n    }\n    parser.BitSkip(1);             // general_reserved_zero_bit\n    sps.level = parser.BitRead(8); // general_level_idc\n\n    if (max_sub_layers > 7)\n        return E_FAIL;\n\n    for (i = 0; i < max_sub_layers; i++)\n    {\n        Sublayers[i].profile_present = parser.BitRead(1); // sub_layer_profile_present_flag\n        Sublayers[i].level_present = parser.BitRead(1);   // sub_layer_level_present_flag\n    }\n\n    if (max_sub_layers > 0)\n    {\n        for (i = max_sub_layers; i < 8; i++)\n            parser.BitSkip(2); // reserved_zero_2bits\n    }\n\n    for (i = 0; i < max_sub_layers; i++)\n    {\n        if (Sublayers[i].profile_present)\n        {\n            parser.BitSkip(2); // general_profile_space\n            parser.BitSkip(1); // general_tier_flag\n            parser.BitSkip(5); // general_profile_idc\n\n            parser.BitSkip(32); // profile_compatibility_flag[32]\n            parser.BitSkip(1);  // progressive_source_flag\n            parser.BitSkip(1);  // interlaced_source_flag\n            parser.BitSkip(1);  // non_packed_constraint_flag\n            parser.BitSkip(1);  // frame_only_constraint_flag\n            parser.BitSkip(22); // reserved_zero_44bits\n            parser.BitSkip(22); // reserved_zero_44bits\n        }\n        if (Sublayers[i].level_present)\n        {\n            parser.BitSkip(8); // level_idc\n        }\n    }\n\n    parser.UExpGolombRead();              // sps_id\n    sps.chroma = parser.UExpGolombRead(); // chroma_format_idc\n    if (sps.chroma == 3)\n        parser.BitRead(1); // separate_color_plane_flag\n\n    parser.UExpGolombRead(); // width\n    parser.UExpGolombRead(); // height\n\n    if (parser.BitRead(1))\n    {                            // conformance_window_flag\n        parser.UExpGolombRead(); // left offset\n        parser.UExpGolombRead(); // right offset\n        parser.UExpGolombRead(); // top offset\n        parser.UExpGolombRead(); // bottom offset\n    }\n\n    sps.bitdepth = parser.UExpGolombRead() + 8; // bit_depth_luma_minus8\n    parser.UExpGolombRead();                    // bit_depth_chroma_minus8\n\n    /*int log2_max_pic_order_count = parser.UExpGolombRead() + 4; // log2_max_pic_order_cnt_lsb_minus4\n\n    for (i = (parser.BitRead(1) ? 0 : max_sub_layers); i <= max_sub_layers; i++) {\n      parser.UExpGolombRead(); // sps_max_dec_pic_buffering_minus1\n      parser.UExpGolombRead(); // sps_max_num_reorder_pics\n      parser.UExpGolombRead(); // sps_max_latency_increase_plus1\n    }\n\n    parser.UExpGolombRead(); // log2_min_luma_coding_block_size_minus3\n    parser.UExpGolombRead(); // log2_diff_max_min_luma_coding_block_size\n    parser.UExpGolombRead(); // log2_min_luma_transform_block_size_minus2\n    parser.UExpGolombRead(); // log2_diff_max_min_luma_transform_block_size\n    parser.UExpGolombRead(); // max_transform_hierarchy_depth_inter\n    parser.UExpGolombRead(); // max_transform_hierarchy_depth_intra\n\n    // scaling list\n    if (parser.BitRead(1)) { // scaling_list_enabled_flag\n      if (parser.BitRead(1)) { // sps_scaling_list_data_present_flag\n        for (int sizeId = 0; sizeId < 4; sizeId++) {\n          for (int matrixId = 0; matrixId < 6; matrixId += ((sizeId == 3) ? 3 : 1)) {\n            if (!parser.BitRead(1)) { // scaling_list_pred_mode_flag\n              parser.UExpGolombRead(); // scaling_list_pred_matrix_id_delta\n            }\n            else {\n              if (sizeId > 1)\n                parser.SExpGolombRead();\n\n              int coefNum = min(64, 1 << (4 + (sizeId << 1)));\n              for (i = 0; i < coefNum; i++)\n                parser.SExpGolombRead(); // scaling_list_delta_coef\n            }\n          }\n        }\n      }\n    }\n\n    parser.BitSkip(1); // amp_enabled_flag\n    parser.BitSkip(1); // sao_enabled_flag\n    if (parser.BitRead(1)) { // pcm_enabled_flag\n      parser.BitSkip(4); // pcm_sample_bit_depth_luma_minus1\n      parser.BitSkip(4); // pcm_sample_bit_depth_chroma_minus1\n      parser.UExpGolombRead(); // log2_min_pcm_luma_coding_block_size_minus3\n      parser.UExpGolombRead(); // log2_diff_max_min_pcm_luma_coding_block_size\n      parser.BitSkip(1); // pcm_loop_filter_disabled_flag\n    }\n\n    int num_short_term_ref_pic_set = parser.UExpGolombRead();\n    if (num_short_term_ref_pic_set > 64)\n      return E_FAIL;\n\n    // st_ref_pic_set\n    for (i = 0; i < num_short_term_ref_pic_set; i++) {\n      if (i > 0 && parser.BitRead(1)) { // inter_ref_pic_set_prediction_flag\n        if (i == num_short_term_ref_pic_set) // only in slice header?\n          parser.UExpGolombRead(); // delta_idx_minus1\n\n        parser.BitSkip(1); // delta_rps_sign\n        parser.UExpGolombRead(); // abs_delta_rps_minus1\n        for (j = 0; j <= ShortTermRPS[i - 1].NumDeltaPocs; j++) {\n          if (!parser.BitRead(1)) // used_by_curr_pic_flag\n            parser.BitRead(1); // use_delta_flag\n        }\n      }\n      else {\n        int num_negative = parser.UExpGolombRead();\n        int num_positive = parser.UExpGolombRead();\n        ShortTermRPS[i].NumDeltaPocs = num_negative + num_positive;\n\n        for (j = 0; j < num_negative; j++) {\n          parser.UExpGolombRead(); // delta_poc_s0_minus1\n          parser.BitSkip(1); // used_by_curr_pic_s0_flag\n        }\n\n        for (j = 0; j < num_positive; j++) {\n          parser.UExpGolombRead(); // delta_poc_s0_minus1\n          parser.BitSkip(1); // used_by_curr_pic_s0_flag\n        }\n      }\n    }\n\n    if (parser.BitRead(1)) { // long_term_ref_pics_present_flag\n      int num_long_term = parser.UExpGolombRead();\n      for (i = 0; i < num_long_term; i++) {\n        parser.BitSkip(log2_max_pic_order_count);\n        parser.BitSkip(1);\n      }\n    }\n\n    parser.BitSkip(1); // sps_temporal_mvp_enabled_flag\n    parser.BitSkip(1); // strong_intra_smoothing_enabled_flag\n\n    // VUI\n    if (parser.BitRead(1)) { // vui_parameters_present_flag\n      if (parser.BitRead(1)) { // aspect_ratio_info_present_flag\n        if (parser.BitRead(8) == 255) { // aspect_ratio_idc\n          parser.BitSkip(16); // sar_width\n          parser.BitSkip(16); // sar_height\n        }\n      }\n\n      if (parser.BitRead(1)) // overscan_info_present_flag\n        parser.BitSkip(1); // overscan_appropriate_flag\n\n      if (parser.BitRead(1)) { // video_signal_type_present_flag\n        parser.BitSkip(3); // video_format\n        parser.BitSkip(1); // video_full_range_flag\n\n        if (parser.BitRead(1)) { // colour_description_present_flag\n          parser.BitSkip(8); // colour_primaries\n          parser.BitSkip(8); // transfer_characteristics\n          parser.BitSkip(8); // matrix_coeffs\n        }\n      }\n\n      if (parser.BitRead(1)) { // chroma_loc_info_present_flag\n        parser.UExpGolombRead(); // chroma_sample_loc_type_top_field\n        parser.UExpGolombRead(); // chroma_sample_loc_type_bottom_field\n      }\n\n      parser.BitSkip(1); // neutral_chroma_indication_flag\n      parser.BitSkip(1); // field_seq_flag\n      parser.BitSkip(1); // frame_field_info_present_flag\n\n      if (parser.BitRead(1)) { // default_display_window_flag\n        parser.UExpGolombRead(); // def_disp_win_left_offset\n        parser.UExpGolombRead(); // def_disp_win_right_offset\n        parser.UExpGolombRead(); // def_disp_win_top_offset\n        parser.UExpGolombRead(); // def_disp_win_bottom_offset\n      }\n\n      if (parser.BitRead(1)) { // vui_timing_info_present_flag\n        parser.BitSkip(32); // vui_num_units_in_tick\n        parser.BitSkip(32); // vui_time_scale\n\n        if (parser.BitRead(1)) // vui_poc_proportional_to_timing_flag\n          parser.UExpGolombRead(); // vui_num_ticks_poc_diff_one_minus1\n\n        // hrd parameters\n        if (parser.BitRead(1)) { // vui_hrd_parameters_present_flag\n          int nal_hrd_parameters_present = parser.BitRead(1);\n          int vcl_hrd_parameters_present = parser.BitRead(1);\n          int sub_hrd_parameters_present = 0;\n\n          if (nal_hrd_parameters_present || vcl_hrd_parameters_present) {\n            sub_hrd_parameters_present = parser.BitRead(1);\n            if (sub_hrd_parameters_present) {\n              parser.BitSkip(8); // tick_divisor_minus2\n              parser.BitSkip(5); // du_cpb_removal_delay_increment_length_minus1\n              parser.BitSkip(1); // sub_pic_cpb_params_in_pic_timing_sei_flag\n              parser.BitSkip(5); // dpb_output_delay_du_length_minus1\n            }\n            parser.BitSkip(4); // bit_rate_scale\n            parser.BitSkip(4); // cbp_size_scale\n            if (sub_hrd_parameters_present)\n              parser.BitSkip(4); // cbp_size_du_scale\n\n            parser.BitSkip(5); // initial_cpb_removal_delay_length_minus1\n            parser.BitSkip(5); // au_cpb_removal_delay_length_minus1\n            parser.BitSkip(5); // dpb_output_delay_length_minus1\n          }\n\n          for (i = 0; i <= max_sub_layers; i++) {\n            int fixed_pic_rate_flag = parser.BitRead(1);\n            int fixed_pic_rate_in_cvs_flag = 1, low_delay_hrd = 0;\n\n            if (!fixed_pic_rate_flag)\n              fixed_pic_rate_in_cvs_flag = parser.BitRead(1);\n\n            if (fixed_pic_rate_in_cvs_flag)\n              parser.UExpGolombRead();\n            else\n              low_delay_hrd = parser.BitRead(1);\n\n            int cpb_count = 0;\n            if (!low_delay_hrd)\n              cpb_count = parser.UExpGolombRead();\n\n            if (nal_hrd_parameters_present) {\n              for (j = 0; j <= cpb_count; j++) {\n                parser.UExpGolombRead(); // bit_rate_value_minus1\n                parser.UExpGolombRead(); // cpb_size_value_minus1\n\n                if (sub_hrd_parameters_present) {\n                  parser.UExpGolombRead(); // bit_rate_du_value_minus1\n                  parser.UExpGolombRead(); // cpb_size_du_value_minus1\n                }\n\n                parser.BitSkip(1);\n              }\n            }\n            if (vcl_hrd_parameters_present) {\n              for (j = 0; j <= cpb_count; j++) {\n                parser.UExpGolombRead(); // bit_rate_value_minus1\n                parser.UExpGolombRead(); // cpb_size_value_minus1\n\n                if (sub_hrd_parameters_present) {\n                  parser.UExpGolombRead(); // bit_rate_du_value_minus1\n                  parser.UExpGolombRead(); // cpb_size_du_value_minus1\n                }\n\n                parser.BitSkip(1);\n              }\n            }\n          }\n        }\n\n\n      }\n    }\n\n    int sps_range_extension_present = 0;\n    if (parser.BitRead(1)) { // sps_extension_present_flag\n      sps_range_extension_present = parser.BitRead(1);\n      parser.BitSkip(1); // sps_multilayer_extension_flag\n      parser.BitSkip(1); // sps_3d_extension_flag\n      parser.BitSkip(5); // sps_extension_5bits\n    }\n\n    if (sps_range_extension_present) {\n      sps.range_extension_flags = parser.BitRead(9);\n    }*/\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/HEVCSequenceParser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"ByteParser.h\"\n\n#define HEVC_REXT_PROFILE_MAIN_12 0x98\n\nclass CHEVCSequenceParser\n{\n  public:\n    CHEVCSequenceParser();\n    ~CHEVCSequenceParser();\n\n    HRESULT ParseNALs(const BYTE *buffer, size_t buflen, int nal_size);\n\n  public:\n    struct\n    {\n        int valid;\n\n        int profile;\n        int rext_profile;\n        int level;\n        int chroma;\n        int bitdepth;\n    } sps;\n\n  private:\n    HRESULT ParseSPS(const BYTE *buffer, size_t buflen);\n};\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/MPEG2HeaderParser.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"MPEG2HeaderParser.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4101)\n#pragma warning(disable : 5033)\n#define AVCODEC_X86_MATHOPS_H\n#include \"libavcodec/get_bits.h\"\n#pragma warning(pop)\n\n#define SEQ_START_CODE 0x000001b3\n#define EXT_START_CODE 0x000001b5\n\nstatic inline const uint8_t *find_next_marker(const uint8_t *src, const uint8_t *end)\n{\n    uint32_t mrk = 0xFFFFFFFF;\n\n    if (end - src < 4)\n        return end;\n    while (src < end)\n    {\n        mrk = (mrk << 8) | *src++;\n        if ((mrk & ~0xFF) == 0x00000100)\n            return src - 4;\n    }\n    return end;\n}\n\nCMPEG2HeaderParser::CMPEG2HeaderParser(const BYTE *pData, size_t length)\n{\n    memset(&hdr, 0, sizeof(hdr));\n    ParseMPEG2Header(pData, length);\n}\n\nCMPEG2HeaderParser::~CMPEG2HeaderParser(void)\n{\n}\n\nvoid CMPEG2HeaderParser::ParseMPEG2Header(const BYTE *pData, size_t length)\n{\n    if (length < 16)\n        return;\n\n    GetBitContext gb;\n\n    const uint8_t *start = pData;\n    const uint8_t *end = start + length;\n    const uint8_t *next = nullptr;\n\n    int size;\n\n    start = find_next_marker(start, end);\n    next = start;\n\n    for (; next < end; start = next)\n    {\n        next = find_next_marker(start + 4, end);\n        size = (int)(next - start - 4);\n        if (size <= 0)\n            continue;\n\n        init_get_bits(&gb, start + 4, (size - 4) * 8);\n\n        switch (AV_RB32(start))\n        {\n        case SEQ_START_CODE: MPEG2ParseSequenceHeader(&gb); break;\n        case EXT_START_CODE: MPEG2ParseExtHeader(&gb); break;\n        }\n    }\n}\n\nvoid CMPEG2HeaderParser::MPEG2ParseSequenceHeader(GetBitContext *gb)\n{\n}\n\nvoid CMPEG2HeaderParser::MPEG2ParseExtHeader(GetBitContext *gb)\n{\n    int startcode = get_bits(gb, 4); // Start Code\n    if (startcode == 1)\n    {\n        hdr.valid = 1;\n\n        skip_bits(gb, 1); // profile and level esc\n        hdr.profile = get_bits(gb, 3);\n        hdr.level = get_bits(gb, 4);\n\n        hdr.interlaced = !get_bits1(gb);\n        hdr.chroma = get_bits(gb, 2);\n\n        // TODO: Fill in other fields, if needed\n    }\n}\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/MPEG2HeaderParser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nstruct GetBitContext;\n\nclass CMPEG2HeaderParser\n{\n  public:\n    CMPEG2HeaderParser(const BYTE *pData, size_t length);\n    ~CMPEG2HeaderParser(void);\n\n  public:\n    struct\n    {\n        int valid;\n\n        int profile;\n        int level;\n\n        int interlaced;\n        int chroma;\n    } hdr;\n\n  private:\n    void ParseMPEG2Header(const BYTE *pData, size_t length);\n    void MPEG2ParseSequenceHeader(GetBitContext *gb);\n    void MPEG2ParseExtHeader(GetBitContext *gb);\n};\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/VC1HeaderParser.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"VC1HeaderParser.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4101)\n#pragma warning(disable : 5033)\nextern \"C\"\n{\n#define AVCODEC_X86_MATHOPS_H\n#include \"libavcodec/get_bits.h\"\n#include \"libavcodec/unary.h\"\n    extern __declspec(dllimport) const AVRational ff_vc1_pixel_aspect[16];\n};\n#pragma warning(pop)\n\n/** Markers used in VC-1 AP frame data */\n//@{\nenum VC1Code\n{\n    VC1_CODE_RES0 = 0x00000100,\n    VC1_CODE_ENDOFSEQ = 0x0000010A,\n    VC1_CODE_SLICE,\n    VC1_CODE_FIELD,\n    VC1_CODE_FRAME,\n    VC1_CODE_ENTRYPOINT,\n    VC1_CODE_SEQHDR,\n};\n//@}\n\n/** Available Profiles */\n//@{\nenum Profile\n{\n    PROFILE_SIMPLE,\n    PROFILE_MAIN,\n    PROFILE_COMPLEX, ///< TODO: WMV9 specific\n    PROFILE_ADVANCED\n};\n//@}\n\nenum FrameCodingMode\n{\n    PROGRESSIVE = 0, ///<  in the bitstream is reported as 00b\n    ILACE_FRAME,     ///<  in the bitstream is reported as 10b\n    ILACE_FIELD      ///<  in the bitstream is reported as 11b\n};\n\n#define IS_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)\n\n/** Find VC-1 marker in buffer\n * @return position where next marker starts or end of buffer if no marker found\n */\nstatic inline const uint8_t *find_next_marker(const uint8_t *src, const uint8_t *end)\n{\n    uint32_t mrk = 0xFFFFFFFF;\n\n    if (end - src < 4)\n        return end;\n    while (src < end)\n    {\n        mrk = (mrk << 8) | *src++;\n        if (IS_MARKER(mrk))\n            return src - 4;\n    }\n    return end;\n}\n\nstatic inline int vc1_unescape_buffer(const uint8_t *src, int size, uint8_t *dst)\n{\n    int dsize = 0, i;\n\n    if (size < 4)\n    {\n        for (dsize = 0; dsize < size; dsize++)\n            *dst++ = *src++;\n        return size;\n    }\n    for (i = 0; i < size; i++, src++)\n    {\n        if (src[0] == 3 && i >= 2 && !src[-1] && !src[-2] && i < size - 1 && src[1] < 4)\n        {\n            dst[dsize++] = src[1];\n            src++;\n            i++;\n        }\n        else\n            dst[dsize++] = *src;\n    }\n    return dsize;\n}\n\nCVC1HeaderParser::CVC1HeaderParser(const BYTE *pData, size_t length, AVCodecID codec)\n{\n    memset(&hdr, 0, sizeof(hdr));\n    ParseVC1Header(pData, length, codec);\n}\n\nCVC1HeaderParser::~CVC1HeaderParser(void)\n{\n}\n\nvoid CVC1HeaderParser::ParseVC1Header(const BYTE *pData, size_t length, AVCodecID codec)\n{\n    GetBitContext gb;\n    if (codec == AV_CODEC_ID_VC1)\n    {\n        if (length < 16)\n            return;\n\n        const uint8_t *start = pData;\n        const uint8_t *end = start + length;\n        const uint8_t *next = nullptr;\n\n        int size, buf2_size;\n        uint8_t *buf2;\n\n        buf2 = (uint8_t *)av_mallocz(length + AV_INPUT_BUFFER_PADDING_SIZE);\n\n        start = find_next_marker(start, end);\n        next = start;\n\n        for (; next < end; start = next)\n        {\n            next = find_next_marker(start + 4, end);\n            size = (int)(next - start - 4);\n            if (size <= 0)\n                continue;\n            buf2_size = vc1_unescape_buffer(start + 4, size, buf2);\n\n            init_get_bits(&gb, buf2, buf2_size * 8);\n\n            switch (AV_RB32(start))\n            {\n            case VC1_CODE_SEQHDR: VC1ParseSequenceHeader(&gb); break;\n            }\n        }\n        av_freep(&buf2);\n    }\n    else if (codec == AV_CODEC_ID_WMV3)\n    {\n        if (length < 4)\n            return;\n        init_get_bits8(&gb, pData, (int)length);\n        VC1ParseSequenceHeader(&gb);\n    }\n}\n\nvoid CVC1HeaderParser::VC1ParseSequenceHeader(GetBitContext *gb)\n{\n    hdr.profile = get_bits(gb, 2);\n\n    if (hdr.profile == PROFILE_ADVANCED)\n    {\n        hdr.valid = 1;\n\n        hdr.level = get_bits(gb, 3);\n        skip_bits(gb, 2); // Chroma Format, only 1 should be set for 4:2:0\n        skip_bits(gb, 3); // frmrtq_postproc\n        skip_bits(gb, 5); // bitrtq_postproc\n        skip_bits1(gb);   // postprocflag\n\n        hdr.width = (get_bits(gb, 12) + 1) << 1;\n        hdr.height = (get_bits(gb, 12) + 1) << 1;\n\n        hdr.broadcast = get_bits1(gb);  // broadcast\n        hdr.interlaced = get_bits1(gb); // interlaced\n\n        skip_bits1(gb); // tfcntrflag\n        skip_bits1(gb); // finterpflag\n        skip_bits1(gb); // reserved\n        skip_bits1(gb); // psf\n\n        if (get_bits1(gb))\n        { // Display Info\n            int w, h, ar = 0;\n            w = get_bits(gb, 14) + 1;\n            h = get_bits(gb, 14) + 1;\n            if (get_bits1(gb))\n                ar = get_bits(gb, 4);\n            if (ar && ar < 14)\n            {\n                hdr.ar = ff_vc1_pixel_aspect[ar];\n            }\n            else if (ar == 15)\n            {\n                w = get_bits(gb, 8) + 1;\n                h = get_bits(gb, 8) + 1;\n                hdr.ar.num = w;\n                hdr.ar.den = h;\n            }\n            else\n            {\n                av_reduce(&hdr.ar.num, &hdr.ar.den, (int64_t)hdr.height * w, (int64_t)hdr.width * h, INT_MAX);\n            }\n        }\n\n        // TODO: add other fields\n    }\n    else\n    {\n        hdr.valid = 1;\n        hdr.old_interlaced = get_bits1(gb); // res_y411\n        skip_bits1(gb);                     // res_sprite\n\n        skip_bits(gb, 3); // frmrtq_postproc\n        skip_bits(gb, 5); // bitrtq_postproc\n        skip_bits1(gb);   // loop_filter\n        skip_bits1(gb);   // res_x8\n        skip_bits1(gb);   // multires\n        skip_bits1(gb);   // rest_fasttx\n        skip_bits1(gb);   // fastuvmc\n        skip_bits1(gb);   // extended_mv\n        skip_bits(gb, 2); // dquant\n        skip_bits1(gb);   // vstransform\n        skip_bits1(gb);   // res_transtab\n        skip_bits1(gb);   // overlap\n        skip_bits1(gb);   // resync marker\n        hdr.rangered = get_bits1(gb);\n        hdr.bframes = get_bits(gb, 3);\n        skip_bits(gb, 2); // quant mode\n        hdr.finterp = get_bits1(gb);\n    }\n}\n\nAVPictureType CVC1HeaderParser::ParseVC1PictureType(const uint8_t *buf, int buflen)\n{\n    AVPictureType pictype = AV_PICTURE_TYPE_NONE;\n    int skipped = 0;\n    const BYTE *framestart = buf;\n    if (IS_MARKER(AV_RB32(buf)))\n    {\n        framestart = nullptr;\n        const BYTE *start, *end, *next;\n        next = buf;\n        for (start = buf, end = buf + buflen; next < end; start = next)\n        {\n            if (AV_RB32(start) == VC1_CODE_FRAME)\n            {\n                framestart = start + 4;\n                break;\n            }\n            next = find_next_marker(start + 4, end);\n        }\n    }\n    if (framestart)\n    {\n        GetBitContext gb;\n        init_get_bits8(&gb, framestart, (int)(buflen - (framestart - buf)));\n        if (hdr.profile == PROFILE_ADVANCED)\n        {\n            int fcm = PROGRESSIVE;\n            if (hdr.interlaced)\n                fcm = decode012(&gb);\n            if (fcm == ILACE_FIELD)\n            {\n                int fptype = get_bits(&gb, 3);\n                pictype = (fptype & 2) ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;\n                if (fptype & 4) // B-picture\n                    pictype = (fptype & 2) ? AV_PICTURE_TYPE_BI : AV_PICTURE_TYPE_B;\n            }\n            else\n            {\n                switch (get_unary(&gb, 0, 4))\n                {\n                case 0: pictype = AV_PICTURE_TYPE_P; break;\n                case 1: pictype = AV_PICTURE_TYPE_B; break;\n                case 2: pictype = AV_PICTURE_TYPE_I; break;\n                case 3: pictype = AV_PICTURE_TYPE_BI; break;\n                case 4:\n                    pictype = AV_PICTURE_TYPE_P; // skipped pic\n                    skipped = 1;\n                    break;\n                }\n            }\n        }\n        else\n        {\n            if (hdr.finterp)\n                skip_bits1(&gb);\n            skip_bits(&gb, 2); // framecnt\n            if (hdr.rangered)\n                skip_bits1(&gb);\n            int pic = get_bits1(&gb);\n            if (hdr.bframes)\n            {\n                if (!pic)\n                {\n                    if (get_bits1(&gb))\n                    {\n                        pictype = AV_PICTURE_TYPE_I;\n                    }\n                    else\n                    {\n                        pictype = AV_PICTURE_TYPE_B;\n                    }\n                }\n                else\n                {\n                    pictype = AV_PICTURE_TYPE_P;\n                }\n            }\n            else\n            {\n                pictype = pic ? AV_PICTURE_TYPE_P : AV_PICTURE_TYPE_I;\n            }\n        }\n    }\n    return pictype;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/parsers/VC1HeaderParser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nstruct GetBitContext;\n\nclass CVC1HeaderParser\n{\n  public:\n    CVC1HeaderParser(const BYTE *pData, size_t length, AVCodecID codec = AV_CODEC_ID_VC1);\n    ~CVC1HeaderParser(void);\n\n    AVPictureType ParseVC1PictureType(const uint8_t *buf, int buflen);\n\n  public:\n    struct\n    {\n        int valid;\n\n        int profile;\n        int level;\n\n        int width;\n        int height;\n\n        int broadcast;\n        int interlaced;\n\n        AVRational ar;\n\n        int old_interlaced;\n        int bframes;\n        int finterp;\n        int rangered;\n    } hdr;\n\n  private:\n    void ParseVC1Header(const BYTE *pData, size_t length, AVCodecID codec);\n    void VC1ParseSequenceHeader(GetBitContext *gb);\n};\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/convert_direct.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <emmintrin.h>\n\n#include \"pixconv_internal.h\"\n#include \"pixconv_sse2_templates.h\"\n\n// This function is only designed for NV12-like pixel formats, like NV12, P010, P016, ...\nDECLARE_CONV_FUNC_IMPL(plane_copy_direct_nv12_sse4)\n{\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n    const ptrdiff_t chromaHeight = (height >> 1);\n\n    const ptrdiff_t byteWidth =\n        (outputFormat == LAVOutPixFmt_P010 || outputFormat == LAVOutPixFmt_P016) ? width << 1 : width;\n    const ptrdiff_t stride = min(FFALIGN(byteWidth, 64), min(inStride, outStride));\n\n    __m128i xmm0, xmm1, xmm2, xmm3;\n\n    _mm_sfence();\n\n    ptrdiff_t line, i;\n\n    for (line = 0; line < height; line++)\n    {\n        const uint8_t *y = (src[0] + line * inStride);\n        uint8_t *dy = (dst[0] + line * outStride);\n        for (i = 0; i < (stride - 63); i += 64)\n        {\n            PIXCONV_STREAM_LOAD(xmm0, y + i + 0);\n            PIXCONV_STREAM_LOAD(xmm1, y + i + 16);\n            PIXCONV_STREAM_LOAD(xmm2, y + i + 32);\n            PIXCONV_STREAM_LOAD(xmm3, y + i + 48);\n\n            _ReadWriteBarrier();\n\n            PIXCONV_PUT_STREAM(dy + i + 0, xmm0);\n            PIXCONV_PUT_STREAM(dy + i + 16, xmm1);\n            PIXCONV_PUT_STREAM(dy + i + 32, xmm2);\n            PIXCONV_PUT_STREAM(dy + i + 48, xmm3);\n        }\n\n        for (; i < byteWidth; i += 16)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, y + i);\n            PIXCONV_PUT_STREAM(dy + i, xmm0);\n        }\n    }\n\n    for (line = 0; line < chromaHeight; line++)\n    {\n        const uint8_t *uv = (src[1] + line * inStride);\n        uint8_t *duv = (dst[1] + line * outStride);\n        for (i = 0; i < (stride - 63); i += 64)\n        {\n            PIXCONV_STREAM_LOAD(xmm0, uv + i + 0);\n            PIXCONV_STREAM_LOAD(xmm1, uv + i + 16);\n            PIXCONV_STREAM_LOAD(xmm2, uv + i + 32);\n            PIXCONV_STREAM_LOAD(xmm3, uv + i + 48);\n\n            _ReadWriteBarrier();\n\n            PIXCONV_PUT_STREAM(duv + i + 0, xmm0);\n            PIXCONV_PUT_STREAM(duv + i + 16, xmm1);\n            PIXCONV_PUT_STREAM(duv + i + 32, xmm2);\n            PIXCONV_PUT_STREAM(duv + i + 48, xmm3);\n        }\n\n        for (; i < byteWidth; i += 16)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, uv + i);\n            PIXCONV_PUT_STREAM(duv + i, xmm0);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(plane_copy_direct_sse4)\n{\n    LAVOutPixFmtDesc desc = lav_pixfmt_desc[outputFormat];\n\n    const int widthBytes = width * desc.codedbytes;\n    const int planes = max(desc.planes, 1);\n\n    ptrdiff_t line, plane;\n\n    for (plane = 0; plane < planes; plane++)\n    {\n        const int planeWidth = widthBytes / desc.planeWidth[plane];\n        const int planeHeight = height / desc.planeHeight[plane];\n        const ptrdiff_t srcPlaneStride = srcStride[plane];\n        const ptrdiff_t dstPlaneStride = dstStride[plane];\n        const uint8_t *const srcBuf = src[plane];\n        uint8_t *const dstBuf = dst[plane];\n\n        for (line = 0; line < planeHeight; ++line)\n        {\n            const uint8_t *const srcLinePtr = srcBuf + line * srcPlaneStride;\n            uint8_t *const dstLinePtr = dstBuf + line * dstPlaneStride;\n            __m128i r1, r2, r3, r4;\n            ptrdiff_t i;\n            for (i = 0; i < (planeWidth - 63); i += 64)\n            {\n                PIXCONV_STREAM_LOAD(r1, srcLinePtr + i + 0)\n                PIXCONV_STREAM_LOAD(r2, srcLinePtr + i + 16);\n                PIXCONV_STREAM_LOAD(r3, srcLinePtr + i + 32);\n                PIXCONV_STREAM_LOAD(r4, srcLinePtr + i + 48);\n\n                _ReadWriteBarrier();\n\n                PIXCONV_PUT_STREAM(dstLinePtr + i + 0, r1);\n                PIXCONV_PUT_STREAM(dstLinePtr + i + 16, r2);\n                PIXCONV_PUT_STREAM(dstLinePtr + i + 32, r3);\n                PIXCONV_PUT_STREAM(dstLinePtr + i + 48, r4);\n            }\n            for (; i < planeWidth; i += 16)\n            {\n                PIXCONV_STREAM_LOAD(r1, srcLinePtr + i);\n                PIXCONV_PUT_STREAM(dstLinePtr + i, r1);\n            }\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_nv12_yv12_direct_sse4)\n{\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n    const ptrdiff_t outChromaStride = dstStride[1];\n    const ptrdiff_t chromaHeight = (height >> 1);\n\n    const ptrdiff_t stride = min(FFALIGN(width, 64), min(inStride, outStride));\n\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm7;\n    xmm7 = _mm_set1_epi16(0x00FF);\n\n    _mm_sfence();\n\n    ptrdiff_t line, i;\n\n    for (line = 0; line < height; line++)\n    {\n        const uint8_t *y = (src[0] + line * inStride);\n        uint8_t *dy = (dst[0] + line * outStride);\n        for (i = 0; i < (stride - 63); i += 64)\n        {\n            PIXCONV_STREAM_LOAD(xmm0, y + i + 0);\n            PIXCONV_STREAM_LOAD(xmm1, y + i + 16);\n            PIXCONV_STREAM_LOAD(xmm2, y + i + 32);\n            PIXCONV_STREAM_LOAD(xmm3, y + i + 48);\n\n            _ReadWriteBarrier();\n\n            PIXCONV_PUT_STREAM(dy + i + 0, xmm0);\n            PIXCONV_PUT_STREAM(dy + i + 16, xmm1);\n            PIXCONV_PUT_STREAM(dy + i + 32, xmm2);\n            PIXCONV_PUT_STREAM(dy + i + 48, xmm3);\n        }\n\n        for (; i < width; i += 16)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, y + i);\n            PIXCONV_PUT_STREAM(dy + i, xmm0);\n        }\n    }\n\n    for (line = 0; line < chromaHeight; line++)\n    {\n        const uint8_t *uv = (src[1] + line * inStride);\n        uint8_t *dv = (dst[1] + line * outChromaStride);\n        uint8_t *du = (dst[2] + line * outChromaStride);\n        for (i = 0; i < (stride - 63); i += 64)\n        {\n            PIXCONV_STREAM_LOAD(xmm0, uv + i + 0);\n            PIXCONV_STREAM_LOAD(xmm1, uv + i + 16);\n            PIXCONV_STREAM_LOAD(xmm2, uv + i + 32);\n            PIXCONV_STREAM_LOAD(xmm3, uv + i + 48);\n\n            _ReadWriteBarrier();\n\n            // process first pair\n            xmm4 = _mm_srli_epi16(xmm0, 8);\n            xmm5 = _mm_srli_epi16(xmm1, 8);\n            xmm0 = _mm_and_si128(xmm0, xmm7);\n            xmm1 = _mm_and_si128(xmm1, xmm7);\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);\n            xmm4 = _mm_packus_epi16(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(du + (i >> 1) + 0, xmm0);\n            PIXCONV_PUT_STREAM(dv + (i >> 1) + 0, xmm4);\n\n            // and second pair\n            xmm4 = _mm_srli_epi16(xmm2, 8);\n            xmm5 = _mm_srli_epi16(xmm3, 8);\n            xmm2 = _mm_and_si128(xmm2, xmm7);\n            xmm3 = _mm_and_si128(xmm3, xmm7);\n            xmm2 = _mm_packus_epi16(xmm2, xmm3);\n            xmm4 = _mm_packus_epi16(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(du + (i >> 1) + 16, xmm2);\n            PIXCONV_PUT_STREAM(dv + (i >> 1) + 16, xmm4);\n        }\n\n        for (; i < width; i += 32)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, uv + i + 0);\n            PIXCONV_LOAD_ALIGNED(xmm1, uv + i + 16);\n\n            xmm4 = _mm_srli_epi16(xmm0, 8);\n            xmm5 = _mm_srli_epi16(xmm1, 8);\n            xmm0 = _mm_and_si128(xmm0, xmm7);\n            xmm1 = _mm_and_si128(xmm1, xmm7);\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);\n            xmm4 = _mm_packus_epi16(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(du + (i >> 1), xmm0);\n            PIXCONV_PUT_STREAM(dv + (i >> 1), xmm4);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_p010_nv12_direct_sse4)\n{\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n    const ptrdiff_t chromaHeight = (height >> 1);\n\n    const ptrdiff_t byteWidth = width << 1;\n    const ptrdiff_t stride = min(FFALIGN(byteWidth, 64), min(inStride, outStride << 1));\n\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers = GetRandomDitherCoeffs(height, 4, 8, 0);\n    if (dithers == nullptr)\n        ditherMode = LAVDither_Ordered;\n\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n\n    _mm_sfence();\n\n    ptrdiff_t line, i;\n\n    for (line = 0; line < height; line++)\n    {\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm4 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 0));\n            xmm5 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 8));\n            xmm6 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 16));\n            xmm7 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 24));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm7, line, 8, dithers);\n            xmm4 = xmm5 = xmm6 = xmm7;\n        }\n\n        const uint8_t *y = (src[0] + line * inStride);\n        uint8_t *dy = (dst[0] + line * outStride);\n\n        for (i = 0; i < (stride - 63); i += 64)\n        {\n            PIXCONV_STREAM_LOAD(xmm0, y + i + 0);\n            PIXCONV_STREAM_LOAD(xmm1, y + i + 16);\n            PIXCONV_STREAM_LOAD(xmm2, y + i + 32);\n            PIXCONV_STREAM_LOAD(xmm3, y + i + 48);\n\n            _ReadWriteBarrier();\n\n            // apply dithering coeffs\n            xmm0 = _mm_adds_epu16(xmm0, xmm4);\n            xmm1 = _mm_adds_epu16(xmm1, xmm5);\n            xmm2 = _mm_adds_epu16(xmm2, xmm6);\n            xmm3 = _mm_adds_epu16(xmm3, xmm7);\n\n            // shift and pack to 8-bit\n            xmm0 = _mm_packus_epi16(_mm_srli_epi16(xmm0, 8), _mm_srli_epi16(xmm1, 8));\n            xmm2 = _mm_packus_epi16(_mm_srli_epi16(xmm2, 8), _mm_srli_epi16(xmm3, 8));\n\n            PIXCONV_PUT_STREAM(dy + (i >> 1) + 0, xmm0);\n            PIXCONV_PUT_STREAM(dy + (i >> 1) + 16, xmm2);\n        }\n\n        for (; i < byteWidth; i += 32)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, y + i + 0);\n            PIXCONV_LOAD_ALIGNED(xmm1, y + i + 16);\n\n            // apply dithering coeffs\n            xmm0 = _mm_adds_epu16(xmm0, xmm4);\n            xmm1 = _mm_adds_epu16(xmm1, xmm5);\n\n            // shift and pack to 8-bit\n            xmm0 = _mm_packus_epi16(_mm_srli_epi16(xmm0, 8), _mm_srli_epi16(xmm1, 8));\n\n            PIXCONV_PUT_STREAM(dy + (i >> 1), xmm0);\n        }\n    }\n\n    for (line = 0; line < chromaHeight; line++)\n    {\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm4 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 0));\n            xmm5 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 8));\n            xmm6 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 16));\n            xmm7 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 24));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm7, line, 8, dithers);\n            xmm4 = xmm5 = xmm6 = xmm7;\n        }\n\n        const uint8_t *uv = (src[1] + line * inStride);\n        uint8_t *duv = (dst[1] + line * outStride);\n\n        for (i = 0; i < (stride - 63); i += 64)\n        {\n            PIXCONV_STREAM_LOAD(xmm0, uv + i + 0);\n            PIXCONV_STREAM_LOAD(xmm1, uv + i + 16);\n            PIXCONV_STREAM_LOAD(xmm2, uv + i + 32);\n            PIXCONV_STREAM_LOAD(xmm3, uv + i + 48);\n\n            _ReadWriteBarrier();\n\n            // apply dithering coeffs\n            xmm0 = _mm_adds_epu16(xmm0, xmm4);\n            xmm1 = _mm_adds_epu16(xmm1, xmm5);\n            xmm2 = _mm_adds_epu16(xmm2, xmm6);\n            xmm3 = _mm_adds_epu16(xmm3, xmm7);\n\n            // shift and pack to 8-bit\n            xmm0 = _mm_packus_epi16(_mm_srli_epi16(xmm0, 8), _mm_srli_epi16(xmm1, 8));\n            xmm2 = _mm_packus_epi16(_mm_srli_epi16(xmm2, 8), _mm_srli_epi16(xmm3, 8));\n\n            PIXCONV_PUT_STREAM(duv + (i >> 1) + 0, xmm0);\n            PIXCONV_PUT_STREAM(duv + (i >> 1) + 16, xmm2);\n        }\n\n        for (; i < byteWidth; i += 32)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, uv + i + 0);\n            PIXCONV_LOAD_ALIGNED(xmm1, uv + i + 16);\n\n            // apply dithering coeffs\n            xmm0 = _mm_adds_epu16(xmm0, xmm4);\n            xmm1 = _mm_adds_epu16(xmm1, xmm5);\n\n            // shift and pack to 8-bit\n            xmm0 = _mm_packus_epi16(_mm_srli_epi16(xmm0, 8), _mm_srli_epi16(xmm1, 8));\n\n            PIXCONV_PUT_STREAM(duv + (i >> 1), xmm0);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_y210_p210_direct_sse4)\n{\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n\n    const ptrdiff_t byteWidth = width << 2;\n    const ptrdiff_t stride = min(FFALIGN(byteWidth, 64), min(inStride, outStride << 1));\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n    xmm7 = _mm_set1_epi32(0x0000FFFF);\n\n    for (line = 0; line < height; line++)\n    {\n        const uint8_t *srcLine = src[0] + line * inStride;\n        uint8_t *dstY = dst[0] + line * dstStride[0];\n        uint8_t *dstUV = dst[1] + line * dstStride[1];\n        for (i = 0; i < (stride - 63); i += 64)\n        {\n            PIXCONV_STREAM_LOAD(xmm0, srcLine + i + 0); // Y0 U Y1 V\n            PIXCONV_STREAM_LOAD(xmm1, srcLine + i + 16);\n            PIXCONV_STREAM_LOAD(xmm2, srcLine + i + 32);\n            PIXCONV_STREAM_LOAD(xmm3, srcLine + i + 48);\n\n            // extract Y\n            xmm4 = _mm_and_si128(xmm0, xmm7);\n            xmm5 = _mm_and_si128(xmm1, xmm7);\n            xmm6 = _mm_packus_epi32(xmm4, xmm5);\n\n            xmm4 = _mm_and_si128(xmm2, xmm7);\n            xmm5 = _mm_and_si128(xmm3, xmm7);\n            xmm4 = _mm_packus_epi32(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(dstY + (i >> 1) + 0, xmm6);\n            PIXCONV_PUT_STREAM(dstY + (i >> 1) + 16, xmm4);\n\n            // extract UV\n            xmm4 = _mm_srli_epi32(xmm0, 16);\n            xmm5 = _mm_srli_epi32(xmm1, 16);\n            xmm6 = _mm_packus_epi32(xmm4, xmm5);\n\n            xmm4 = _mm_srli_epi32(xmm2, 16);\n            xmm5 = _mm_srli_epi32(xmm3, 16);\n            xmm4 = _mm_packus_epi32(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(dstUV + (i >> 1) + 0, xmm6);\n            PIXCONV_PUT_STREAM(dstUV + (i >> 1) + 16, xmm4);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_yuy2_yv16_direct_sse4)\n{\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n\n    const ptrdiff_t byteWidth = width << 1;\n    const ptrdiff_t stride = min(FFALIGN(byteWidth, 64), min(inStride, outStride << 1));\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n    xmm7 = _mm_set1_epi16(0x00FF);\n\n    for (line = 0; line < height; line++)\n    {\n        const uint8_t *srcLine = src[0] + line * inStride;\n        uint8_t *dstY = dst[0] + line * dstStride[0];\n        uint8_t *dstV = dst[1] + line * dstStride[1];\n        uint8_t *dstU = dst[2] + line * dstStride[2];\n        for (i = 0; i < (stride - 63); i += 64)\n        {\n            PIXCONV_STREAM_LOAD(xmm0, srcLine + i + 0); // Y0 U Y1 V\n            PIXCONV_STREAM_LOAD(xmm1, srcLine + i + 16);\n            PIXCONV_STREAM_LOAD(xmm2, srcLine + i + 32);\n            PIXCONV_STREAM_LOAD(xmm3, srcLine + i + 48);\n\n            _ReadWriteBarrier();\n\n            // extract Y\n            xmm4 = _mm_and_si128(xmm0, xmm7);\n            xmm5 = _mm_and_si128(xmm1, xmm7);\n            xmm6 = _mm_packus_epi16(xmm4, xmm5);\n\n            xmm4 = _mm_and_si128(xmm2, xmm7);\n            xmm5 = _mm_and_si128(xmm3, xmm7);\n            xmm4 = _mm_packus_epi16(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(dstY + (i >> 1) + 0, xmm6);\n            PIXCONV_PUT_STREAM(dstY + (i >> 1) + 16, xmm4);\n\n            // extract UV\n            xmm4 = _mm_srli_epi16(xmm0, 8);\n            xmm5 = _mm_srli_epi16(xmm1, 8);\n            xmm0 = _mm_packus_epi16(xmm4, xmm5);\n\n            xmm4 = _mm_srli_epi16(xmm2, 8);\n            xmm5 = _mm_srli_epi16(xmm3, 8);\n            xmm1 = _mm_packus_epi16(xmm4, xmm5);\n\n            // split into U/V\n            xmm4 = _mm_srli_epi16(xmm0, 8);\n            xmm5 = _mm_srli_epi16(xmm1, 8);\n            xmm0 = _mm_and_si128(xmm0, xmm7);\n            xmm1 = _mm_and_si128(xmm1, xmm7);\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);\n            xmm4 = _mm_packus_epi16(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(dstU + (i >> 2), xmm0);\n            PIXCONV_PUT_STREAM(dstV + (i >> 2), xmm4);\n        }\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/convert_generic.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"pixconv_internal.h\"\n\nextern \"C\"\n{\n#include \"libavutil/intreadwrite.h\"\n};\n\n#define ALIGN(x, a) (((x) + (a)-1UL) & ~((a)-1UL))\n\nDECLARE_CONV_FUNC_IMPL(convert_generic)\n{\n    HRESULT hr = S_OK;\n\n    AVPixelFormat inputFmt = GetFFInput();\n\n    switch (m_OutputPixFmt)\n    {\n    case LAVOutPixFmt_YV12:\n        hr = swscale_scale(inputFmt, AV_PIX_FMT_YUV420P, src, srcStride, dst, width, height, dstStride,\n                           lav_pixfmt_desc[m_OutputPixFmt], true);\n        break;\n    case LAVOutPixFmt_NV12:\n        hr = swscale_scale(inputFmt, AV_PIX_FMT_NV12, src, srcStride, dst, width, height, dstStride,\n                           lav_pixfmt_desc[m_OutputPixFmt]);\n        break;\n    case LAVOutPixFmt_YUY2: hr = ConvertTo422Packed(src, srcStride, dst, width, height, dstStride); break;\n    case LAVOutPixFmt_UYVY: hr = ConvertTo422Packed(src, srcStride, dst, width, height, dstStride); break;\n    case LAVOutPixFmt_AYUV: hr = ConvertToAYUV(src, srcStride, dst, width, height, dstStride); break;\n    case LAVOutPixFmt_P010: hr = ConvertToPX1X(src, srcStride, dst, width, height, dstStride, 2); break;\n    case LAVOutPixFmt_P016: hr = ConvertToPX1X(src, srcStride, dst, width, height, dstStride, 2); break;\n    case LAVOutPixFmt_P210: hr = ConvertToPX1X(src, srcStride, dst, width, height, dstStride, 1); break;\n    case LAVOutPixFmt_P216: hr = ConvertToPX1X(src, srcStride, dst, width, height, dstStride, 1); break;\n    case LAVOutPixFmt_Y410: hr = ConvertToY410(src, srcStride, dst, width, height, dstStride); break;\n    case LAVOutPixFmt_Y416: hr = ConvertToY416(src, srcStride, dst, width, height, dstStride); break;\n    case LAVOutPixFmt_RGB32:\n        hr = swscale_scale(inputFmt, AV_PIX_FMT_BGRA, src, srcStride, dst, width, height, dstStride,\n                           lav_pixfmt_desc[m_OutputPixFmt]);\n        break;\n    case LAVOutPixFmt_RGB24:\n        hr = swscale_scale(inputFmt, AV_PIX_FMT_BGR24, src, srcStride, dst, width, height, dstStride,\n                           lav_pixfmt_desc[m_OutputPixFmt]);\n        break;\n    case LAVOutPixFmt_v210: hr = ConvertTov210(src, srcStride, dst, width, height, dstStride); break;\n    case LAVOutPixFmt_v410: hr = ConvertTov410(src, srcStride, dst, width, height, dstStride); break;\n    case LAVOutPixFmt_YV16:\n        hr = swscale_scale(inputFmt, AV_PIX_FMT_YUV422P, src, srcStride, dst, width, height, dstStride,\n                           lav_pixfmt_desc[m_OutputPixFmt], true);\n        break;\n    case LAVOutPixFmt_YV24:\n        hr = swscale_scale(inputFmt, AV_PIX_FMT_YUV444P, src, srcStride, dst, width, height, dstStride,\n                           lav_pixfmt_desc[m_OutputPixFmt], true);\n        break;\n    case LAVOutPixFmt_RGB48:\n        hr = swscale_scale(inputFmt, AV_PIX_FMT_RGB48LE, src, srcStride, dst, width, height, dstStride,\n                           lav_pixfmt_desc[m_OutputPixFmt]);\n        break;\n    default:\n        ASSERT(0);\n        hr = E_FAIL;\n        break;\n    }\n\n    return S_OK;\n}\n\ninline SwsContext *CLAVPixFmtConverter::GetSWSContext(int width, int height, enum AVPixelFormat srcPix,\n                                                      enum AVPixelFormat dstPix, int flags)\n{\n    if (!m_pSwsContext || swsWidth != width || swsHeight != height)\n    {\n        // Get context\n        m_pSwsContext = sws_getCachedContext(m_pSwsContext, width, height, srcPix, width, height, dstPix,\n                                             flags | SWS_PRINT_INFO, nullptr, nullptr, nullptr);\n\n        int *inv_tbl = nullptr, *tbl = nullptr;\n        int srcRange, dstRange, brightness, contrast, saturation;\n        int ret = sws_getColorspaceDetails(m_pSwsContext, &inv_tbl, &srcRange, &tbl, &dstRange, &brightness, &contrast,\n                                           &saturation);\n        if (ret >= 0)\n        {\n            const int *rgbTbl = nullptr;\n            if (m_ColorProps.VideoTransferMatrix != DXVA2_VideoTransferMatrix_Unknown)\n            {\n                int colorspace = SWS_CS_ITU709;\n                switch (m_ColorProps.VideoTransferMatrix)\n                {\n                case DXVA2_VideoTransferMatrix_BT709: colorspace = SWS_CS_ITU709; break;\n                case DXVA2_VideoTransferMatrix_BT601: colorspace = SWS_CS_ITU601; break;\n                case DXVA2_VideoTransferMatrix_SMPTE240M: colorspace = SWS_CS_SMPTE240M; break;\n                }\n                rgbTbl = sws_getCoefficients(colorspace);\n            }\n            else\n            {\n                BOOL isHD = (height >= 720 || width >= 1280);\n                rgbTbl = sws_getCoefficients(isHD ? SWS_CS_ITU709 : SWS_CS_ITU601);\n            }\n            srcRange = dstRange = (m_ColorProps.NominalRange == DXVA2_NominalRange_0_255);\n            sws_setColorspaceDetails(m_pSwsContext, rgbTbl, srcRange, rgbTbl, dstRange, brightness, contrast,\n                                     saturation);\n        }\n        swsWidth = width;\n        swsHeight = height;\n    }\n    return m_pSwsContext;\n}\n\nHRESULT CLAVPixFmtConverter::swscale_scale(enum AVPixelFormat srcPix, enum AVPixelFormat dstPix,\n                                           const uint8_t *const src[], const ptrdiff_t srcStride[], uint8_t *dst[],\n                                           int width, int height, const ptrdiff_t dstStride[],\n                                           LAVOutPixFmtDesc pixFmtDesc, bool swapPlanes12)\n{\n    int ret;\n\n    SwsContext *ctx = GetSWSContext(width, height, srcPix, dstPix, SWS_BILINEAR);\n    CheckPointer(m_pSwsContext, E_POINTER);\n\n    if (swapPlanes12)\n    {\n        uint8_t *tmp = dst[1];\n        dst[1] = dst[2];\n        dst[2] = tmp;\n    }\n\n    ret = sws_scale2(ctx, src, srcStride, 0, height, dst, dstStride);\n\n    return S_OK;\n}\n\nHRESULT CLAVPixFmtConverter::ConvertTo422Packed(const uint8_t *const src[4], const ptrdiff_t srcStride[4],\n                                                uint8_t *dst[], int width, int height, const ptrdiff_t dstStride[])\n{\n    const BYTE *y = nullptr;\n    const BYTE *u = nullptr;\n    const BYTE *v = nullptr;\n    ptrdiff_t line, i;\n    ptrdiff_t sourceStride = 0;\n    BYTE *pTmpBuffer = nullptr;\n\n    if (m_InputPixFmt != LAVPixFmt_YUV422)\n    {\n        uint8_t *tmp[4] = {nullptr};\n        ptrdiff_t tmpStride[4] = {0};\n        ptrdiff_t scaleStride = FFALIGN(width, 32);\n\n        pTmpBuffer = (BYTE *)av_malloc(height * scaleStride * 2);\n        if (pTmpBuffer == nullptr)\n            return E_OUTOFMEMORY;\n\n        tmp[0] = pTmpBuffer;\n        tmp[1] = tmp[0] + (height * scaleStride);\n        tmp[2] = tmp[1] + (height * scaleStride / 2);\n        tmp[3] = nullptr;\n\n        tmpStride[0] = scaleStride;\n        tmpStride[1] = scaleStride / 2;\n        tmpStride[2] = scaleStride / 2;\n        tmpStride[3] = 0;\n\n        SwsContext *ctx = GetSWSContext(width, height, GetFFInput(), AV_PIX_FMT_YUV422P, SWS_BILINEAR);\n        sws_scale2(ctx, src, srcStride, 0, height, tmp, tmpStride);\n\n        y = tmp[0];\n        u = tmp[1];\n        v = tmp[2];\n        sourceStride = scaleStride;\n    }\n    else\n    {\n        y = src[0];\n        u = src[1];\n        v = src[2];\n        sourceStride = srcStride[0];\n    }\n\n#define YUV422_PACK_YUY2(offset) \\\n    *idst++ = y[(i + offset) * 2] | (u[i + offset] << 8) | (y[(i + offset) * 2 + 1] << 16) | (v[i + offset] << 24);\n#define YUV422_PACK_UYVY(offset) \\\n    *idst++ = u[i + offset] | (y[(i + offset) * 2] << 8) | (v[i + offset] << 16) | (y[(i + offset) * 2 + 1] << 24);\n\n    uint8_t *out = dst[0];\n    int halfwidth = width >> 1;\n    ptrdiff_t halfstride = sourceStride >> 1;\n\n    if (m_OutputPixFmt == LAVOutPixFmt_YUY2)\n    {\n        for (line = 0; line < height; ++line)\n        {\n            uint32_t *idst = (uint32_t *)out;\n            for (i = 0; i < (halfwidth - 7); i += 8)\n            {\n                YUV422_PACK_YUY2(0)\n                YUV422_PACK_YUY2(1)\n                YUV422_PACK_YUY2(2)\n                YUV422_PACK_YUY2(3)\n                YUV422_PACK_YUY2(4)\n                YUV422_PACK_YUY2(5)\n                YUV422_PACK_YUY2(6)\n                YUV422_PACK_YUY2(7)\n            }\n            for (; i < halfwidth; ++i)\n            {\n                YUV422_PACK_YUY2(0)\n            }\n            y += sourceStride;\n            u += halfstride;\n            v += halfstride;\n            out += dstStride[0];\n        }\n    }\n    else\n    {\n        for (line = 0; line < height; ++line)\n        {\n            uint32_t *idst = (uint32_t *)out;\n            for (i = 0; i < (halfwidth - 7); i += 8)\n            {\n                YUV422_PACK_UYVY(0)\n                YUV422_PACK_UYVY(1)\n                YUV422_PACK_UYVY(2)\n                YUV422_PACK_UYVY(3)\n                YUV422_PACK_UYVY(4)\n                YUV422_PACK_UYVY(5)\n                YUV422_PACK_UYVY(6)\n                YUV422_PACK_UYVY(7)\n            }\n            for (; i < halfwidth; ++i)\n            {\n                YUV422_PACK_UYVY(0)\n            }\n            y += sourceStride;\n            u += halfstride;\n            v += halfstride;\n            out += dstStride[0];\n        }\n    }\n\n    av_freep(&pTmpBuffer);\n\n    return S_OK;\n}\n\nHRESULT CLAVPixFmtConverter::ConvertToAYUV(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[],\n                                           int width, int height, const ptrdiff_t dstStride[])\n{\n    const BYTE *y = nullptr;\n    const BYTE *u = nullptr;\n    const BYTE *v = nullptr;\n    ptrdiff_t line, i = 0;\n    ptrdiff_t sourceStride = 0;\n    BYTE *pTmpBuffer = nullptr;\n\n    if (m_InputPixFmt != LAVPixFmt_YUV444)\n    {\n        uint8_t *tmp[4] = {nullptr};\n        ptrdiff_t tmpStride[4] = {0};\n        ptrdiff_t scaleStride = FFALIGN(width, 32);\n\n        pTmpBuffer = (BYTE *)av_malloc(height * scaleStride * 3);\n        if (pTmpBuffer == nullptr)\n            return E_OUTOFMEMORY;\n\n        tmp[0] = pTmpBuffer;\n        tmp[1] = tmp[0] + (height * scaleStride);\n        tmp[2] = tmp[1] + (height * scaleStride);\n        tmp[3] = nullptr;\n        tmpStride[0] = scaleStride;\n        tmpStride[1] = scaleStride;\n        tmpStride[2] = scaleStride;\n        tmpStride[3] = 0;\n\n        SwsContext *ctx = GetSWSContext(width, height, GetFFInput(), AV_PIX_FMT_YUV444P, SWS_BILINEAR);\n        sws_scale2(ctx, src, srcStride, 0, height, tmp, tmpStride);\n\n        y = tmp[0];\n        u = tmp[1];\n        v = tmp[2];\n        sourceStride = scaleStride;\n    }\n    else\n    {\n        y = src[0];\n        u = src[1];\n        v = src[2];\n        sourceStride = srcStride[0];\n    }\n\n#define YUV444_PACK_AYUV(offset) *idst++ = v[i + offset] | (u[i + offset] << 8) | (y[i + offset] << 16) | (0xff << 24);\n\n    BYTE *out = dst[0];\n    for (line = 0; line < height; ++line)\n    {\n        uint32_t *idst = (uint32_t *)out;\n        for (i = 0; i < (width - 7); i += 8)\n        {\n            YUV444_PACK_AYUV(0)\n            YUV444_PACK_AYUV(1)\n            YUV444_PACK_AYUV(2)\n            YUV444_PACK_AYUV(3)\n            YUV444_PACK_AYUV(4)\n            YUV444_PACK_AYUV(5)\n            YUV444_PACK_AYUV(6)\n            YUV444_PACK_AYUV(7)\n        }\n        for (; i < width; ++i)\n        {\n            YUV444_PACK_AYUV(0)\n        }\n        y += sourceStride;\n        u += sourceStride;\n        v += sourceStride;\n        out += dstStride[0];\n    }\n\n    av_freep(&pTmpBuffer);\n\n    return S_OK;\n}\n\nHRESULT CLAVPixFmtConverter::ConvertToPX1X(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[],\n                                           int width, int height, const ptrdiff_t dstStride[], int chromaVertical)\n{\n    const BYTE *y = nullptr;\n    const BYTE *u = nullptr;\n    const BYTE *v = nullptr;\n    ptrdiff_t line, i = 0;\n    ptrdiff_t sourceStride = 0;\n\n    int shift = 0;\n\n    BYTE *pTmpBuffer = nullptr;\n\n    if ((chromaVertical == 1 && m_InputPixFmt != LAVPixFmt_YUV422bX) ||\n        (chromaVertical == 2 && m_InputPixFmt != LAVPixFmt_YUV420bX))\n    {\n        uint8_t *tmp[4] = {nullptr};\n        ptrdiff_t tmpStride[4] = {0};\n        ptrdiff_t scaleStride = FFALIGN(width, 32) * 2;\n\n        pTmpBuffer = (BYTE *)av_malloc(height * scaleStride * 2);\n        if (pTmpBuffer == nullptr)\n            return E_OUTOFMEMORY;\n\n        tmp[0] = pTmpBuffer;\n        tmp[1] = tmp[0] + (height * scaleStride);\n        tmp[2] = tmp[1] + ((height / chromaVertical) * (scaleStride / 2));\n        tmp[3] = nullptr;\n        tmpStride[0] = scaleStride;\n        tmpStride[1] = scaleStride / 2;\n        tmpStride[2] = scaleStride / 2;\n        tmpStride[3] = 0;\n\n        SwsContext *ctx =\n            GetSWSContext(width, height, GetFFInput(),\n                          chromaVertical == 1 ? AV_PIX_FMT_YUV422P16LE : AV_PIX_FMT_YUV420P16LE, SWS_BILINEAR);\n        sws_scale2(ctx, src, srcStride, 0, height, tmp, tmpStride);\n\n        y = tmp[0];\n        u = tmp[1];\n        v = tmp[2];\n        sourceStride = scaleStride;\n    }\n    else\n    {\n        y = src[0];\n        u = src[1];\n        v = src[2];\n        sourceStride = srcStride[0];\n\n        shift = (16 - m_InBpp);\n    }\n\n    // copy Y\n    BYTE *pLineOut = dst[0];\n    const BYTE *pLineIn = y;\n    for (line = 0; line < height; ++line)\n    {\n        if (shift == 0)\n        {\n            memcpy(pLineOut, pLineIn, width * 2);\n        }\n        else\n        {\n            const uint16_t *yc = (uint16_t *)pLineIn;\n            uint16_t *idst = (uint16_t *)pLineOut;\n            for (i = 0; i < width; ++i)\n            {\n                uint16_t yv = AV_RL16(yc + i);\n                if (shift)\n                    yv <<= shift;\n                *idst++ = yv;\n            }\n        }\n        pLineOut += dstStride[0];\n        pLineIn += sourceStride;\n    }\n\n    sourceStride >>= 2;\n\n    // Merge U/V\n    BYTE *out = dst[1];\n    const uint16_t *uc = (uint16_t *)u;\n    const uint16_t *vc = (uint16_t *)v;\n    for (line = 0; line < height / chromaVertical; ++line)\n    {\n        uint32_t *idst = (uint32_t *)out;\n        for (i = 0; i < width / 2; ++i)\n        {\n            uint16_t uv = AV_RL16(uc + i);\n            uint16_t vv = AV_RL16(vc + i);\n            if (shift)\n            {\n                uv <<= shift;\n                vv <<= shift;\n            }\n            *idst++ = uv | (vv << 16);\n        }\n        uc += sourceStride;\n        vc += sourceStride;\n        out += dstStride[1];\n    }\n\n    av_freep(&pTmpBuffer);\n\n    return S_OK;\n}\n\n#define YUV444_PACKED_LOOP_HEAD(width, height, y, u, v, out) \\\n    for (int line = 0; line < height; ++line)                \\\n    {                                                        \\\n        uint32_t *idst = (uint32_t *)out;                    \\\n        for (int i = 0; i < width; ++i)                      \\\n        {                                                    \\\n            uint32_t yv, uv, vv;\n\n#define YUV444_PACKED_LOOP_HEAD_LE(width, height, y, u, v, out) \\\n    YUV444_PACKED_LOOP_HEAD(width, height, y, u, v, out)        \\\n    yv = AV_RL16(y + i);                                        \\\n    uv = AV_RL16(u + i);                                        \\\n    vv = AV_RL16(v + i);\n\n#define YUV444_PACKED_LOOP_END(y, u, v, out, srcStride, dstStride) \\\n    }                                                              \\\n    y += srcStride;                                                \\\n    u += srcStride;                                                \\\n    v += srcStride;                                                \\\n    out += dstStride;                                              \\\n    }\n\nHRESULT CLAVPixFmtConverter::ConvertToY410(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[],\n                                           int width, int height, const ptrdiff_t dstStride[])\n{\n    const uint16_t *y = nullptr;\n    const uint16_t *u = nullptr;\n    const uint16_t *v = nullptr;\n    ptrdiff_t sourceStride = 0;\n    bool b9Bit = false;\n\n    BYTE *pTmpBuffer = nullptr;\n\n    if (m_InputPixFmt != LAVPixFmt_YUV444bX || m_InBpp > 10)\n    {\n        uint8_t *tmp[4] = {nullptr};\n        ptrdiff_t tmpStride[4] = {0};\n        ptrdiff_t scaleStride = FFALIGN(width, 32);\n\n        pTmpBuffer = (BYTE *)av_malloc(height * scaleStride * 6);\n        if (pTmpBuffer == nullptr)\n            return E_OUTOFMEMORY;\n\n        tmp[0] = pTmpBuffer;\n        tmp[1] = tmp[0] + (height * scaleStride * 2);\n        tmp[2] = tmp[1] + (height * scaleStride * 2);\n        tmp[3] = nullptr;\n        tmpStride[0] = scaleStride * 2;\n        tmpStride[1] = scaleStride * 2;\n        tmpStride[2] = scaleStride * 2;\n        tmpStride[3] = 0;\n\n        SwsContext *ctx = GetSWSContext(width, height, GetFFInput(), AV_PIX_FMT_YUV444P10LE, SWS_BILINEAR);\n        sws_scale2(ctx, src, srcStride, 0, height, tmp, tmpStride);\n\n        y = (uint16_t *)tmp[0];\n        u = (uint16_t *)tmp[1];\n        v = (uint16_t *)tmp[2];\n        sourceStride = scaleStride;\n    }\n    else\n    {\n        y = (uint16_t *)src[0];\n        u = (uint16_t *)src[1];\n        v = (uint16_t *)src[2];\n        sourceStride = srcStride[0] / 2;\n\n        b9Bit = (m_InBpp == 9);\n    }\n\n#define YUV444_Y410_PACK *idst++ = (uv & 0x3FF) | ((yv & 0x3FF) << 10) | ((vv & 0x3FF) << 20) | (3 << 30);\n\n    BYTE *out = dst[0];\n    YUV444_PACKED_LOOP_HEAD_LE(width, height, y, u, v, out)\n    if (b9Bit)\n    {\n        yv <<= 1;\n        uv <<= 1;\n        vv <<= 1;\n    }\n    YUV444_Y410_PACK\n    YUV444_PACKED_LOOP_END(y, u, v, out, sourceStride, dstStride[0])\n\n    av_freep(&pTmpBuffer);\n\n    return S_OK;\n}\n\nHRESULT CLAVPixFmtConverter::ConvertToY416(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[],\n                                           int width, int height, const ptrdiff_t dstStride[])\n{\n    const uint16_t *y = nullptr;\n    const uint16_t *u = nullptr;\n    const uint16_t *v = nullptr;\n    ptrdiff_t sourceStride = 0;\n\n    BYTE *pTmpBuffer = nullptr;\n\n    int shift = (16 - m_InBpp);\n    if (m_InputPixFmt != LAVPixFmt_YUV444bX)\n    {\n        uint8_t *tmp[4] = {nullptr};\n        ptrdiff_t tmpStride[4] = {0};\n        ptrdiff_t scaleStride = FFALIGN(width, 32);\n\n        pTmpBuffer = (BYTE *)av_malloc(height * scaleStride * 6);\n        if (pTmpBuffer == nullptr)\n            return E_OUTOFMEMORY;\n\n        tmp[0] = pTmpBuffer;\n        tmp[1] = tmp[0] + (height * scaleStride * 2);\n        tmp[2] = tmp[1] + (height * scaleStride * 2);\n        tmp[3] = nullptr;\n        tmpStride[0] = scaleStride * 2;\n        tmpStride[1] = scaleStride * 2;\n        tmpStride[2] = scaleStride * 2;\n        tmpStride[3] = 0;\n\n        SwsContext *ctx = GetSWSContext(width, height, GetFFInput(), AV_PIX_FMT_YUV444P16LE, SWS_BILINEAR);\n        sws_scale2(ctx, src, srcStride, 0, height, tmp, tmpStride);\n\n        y = (uint16_t *)tmp[0];\n        u = (uint16_t *)tmp[1];\n        v = (uint16_t *)tmp[2];\n        sourceStride = scaleStride;\n        shift = 0;\n    }\n    else\n    {\n        y = (uint16_t *)src[0];\n        u = (uint16_t *)src[1];\n        v = (uint16_t *)src[2];\n        sourceStride = srcStride[0] / 2;\n    }\n\n    BYTE *out = dst[0];\n    YUV444_PACKED_LOOP_HEAD_LE(width, height, y, u, v, out)\n    uint16_t *p = (uint16_t *)idst;\n    p[0] = (uv << shift);\n    p[1] = (yv << shift);\n    p[2] = (vv << shift);\n    p[3] = 0xFFFF;\n\n    idst += 2;\n    YUV444_PACKED_LOOP_END(y, u, v, out, sourceStride, dstStride[0])\n\n    av_freep(&pTmpBuffer);\n\n    return S_OK;\n}\n\nHRESULT CLAVPixFmtConverter::ConvertTov210(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[],\n                                           int width, int height, const ptrdiff_t dstStride[])\n{\n    const uint16_t *y = nullptr;\n    const uint16_t *u = nullptr;\n    const uint16_t *v = nullptr;\n    ptrdiff_t srcyStride = 0;\n    ptrdiff_t srcuvStride = 0;\n\n    BYTE *pTmpBuffer = nullptr;\n\n    if (m_InputPixFmt != LAVPixFmt_YUV422bX || m_InBpp != 10)\n    {\n        uint8_t *tmp[4] = {nullptr};\n        ptrdiff_t tmpStride[4] = {0};\n        ptrdiff_t scaleStride = FFALIGN(width, 32);\n\n        pTmpBuffer = (BYTE *)av_malloc(height * scaleStride * 6);\n        if (pTmpBuffer == nullptr)\n            return E_OUTOFMEMORY;\n\n        tmp[0] = pTmpBuffer;\n        tmp[1] = tmp[0] + (height * scaleStride * 2);\n        tmp[2] = tmp[1] + (height * scaleStride * 2);\n        tmp[3] = nullptr;\n        tmpStride[0] = scaleStride * 2;\n        tmpStride[1] = scaleStride;\n        tmpStride[2] = scaleStride;\n        tmpStride[3] = 0;\n\n        SwsContext *ctx = GetSWSContext(width, height, GetFFInput(), AV_PIX_FMT_YUV422P10LE, SWS_BILINEAR);\n        sws_scale2(ctx, src, srcStride, 0, height, tmp, tmpStride);\n\n        y = (uint16_t *)tmp[0];\n        u = (uint16_t *)tmp[1];\n        v = (uint16_t *)tmp[2];\n        srcyStride = scaleStride;\n        srcuvStride = scaleStride >> 1;\n    }\n    else\n    {\n        y = (uint16_t *)src[0];\n        u = (uint16_t *)src[1];\n        v = (uint16_t *)src[2];\n        srcyStride = srcStride[0] >> 1;\n        srcuvStride = srcStride[1] >> 1;\n    }\n\n    // Calculate v210 stride\n    ptrdiff_t outStride = (((dstStride[0] >> 2) + 47) / 48) * 128;\n\n    // Align width to an even number for processing\n    // This may read into the source stride, but otherwise the algorithm won't work.\n    width = FFALIGN(width, 2);\n\n    BYTE *pdst = dst[0];\n    uint32_t *p = (uint32_t *)pdst;\n    int w;\n\n//#define CLIP(v) av_clip(v, 4, 1019)\n#define CLIP(v) (v & 0x03FF)\n#define WRITE_PIXELS(a, b, c)                           \\\n    do                                                  \\\n    {                                                   \\\n        val = CLIP(*a++);                               \\\n        val |= (CLIP(*b++) << 10) | (CLIP(*c++) << 20); \\\n        *p++ = val;                                     \\\n    } while (0)\n\n    for (int h = 0; h < height; h++)\n    {\n        uint32_t val;\n        for (w = 0; w < width - 5; w += 6)\n        {\n            WRITE_PIXELS(u, y, v);\n            WRITE_PIXELS(y, u, y);\n            WRITE_PIXELS(v, y, u);\n            WRITE_PIXELS(y, v, y);\n        }\n        if (w < width - 1)\n        {\n            WRITE_PIXELS(u, y, v);\n\n            val = CLIP(*y++);\n            if (w == width - 2)\n                *p++ = val;\n            if (w < width - 3)\n            {\n                val |= (CLIP(*u++) << 10) | (CLIP(*y++) << 20);\n                *p++ = val;\n\n                val = CLIP(*v++) | (CLIP(*y++) << 10);\n                *p++ = val;\n            }\n        }\n\n        pdst += outStride;\n        memset(p, 0, pdst - (BYTE *)p);\n        p = (uint32_t *)pdst;\n        y += srcyStride - width;\n        u += srcuvStride - (width >> 1);\n        v += srcuvStride - (width >> 1);\n    }\n    av_freep(&pTmpBuffer);\n\n    return S_OK;\n}\n\nHRESULT CLAVPixFmtConverter::ConvertTov410(const uint8_t *const src[4], const ptrdiff_t srcStride[4], uint8_t *dst[],\n                                           int width, int height, const ptrdiff_t dstStride[])\n{\n    const uint16_t *y = nullptr;\n    const uint16_t *u = nullptr;\n    const uint16_t *v = nullptr;\n    ptrdiff_t sourceStride = 0;\n    bool b9Bit = false;\n\n    BYTE *pTmpBuffer = nullptr;\n\n    if (m_InputPixFmt != LAVPixFmt_YUV444bX || m_InBpp > 10)\n    {\n        uint8_t *tmp[4] = {nullptr};\n        ptrdiff_t tmpStride[4] = {0};\n        ptrdiff_t scaleStride = FFALIGN(width, 32);\n\n        pTmpBuffer = (BYTE *)av_malloc(height * scaleStride * 6);\n        if (pTmpBuffer == nullptr)\n            return E_OUTOFMEMORY;\n\n        tmp[0] = pTmpBuffer;\n        tmp[1] = tmp[0] + (height * scaleStride * 2);\n        tmp[2] = tmp[1] + (height * scaleStride * 2);\n        tmp[3] = nullptr;\n        tmpStride[0] = scaleStride * 2;\n        tmpStride[1] = scaleStride * 2;\n        tmpStride[2] = scaleStride * 2;\n        tmpStride[3] = 0;\n\n        SwsContext *ctx = GetSWSContext(width, height, GetFFInput(), AV_PIX_FMT_YUV444P10LE, SWS_BILINEAR);\n        sws_scale2(ctx, src, srcStride, 0, height, tmp, tmpStride);\n\n        y = (uint16_t *)tmp[0];\n        u = (uint16_t *)tmp[1];\n        v = (uint16_t *)tmp[2];\n        sourceStride = scaleStride;\n    }\n    else\n    {\n        y = (uint16_t *)src[0];\n        u = (uint16_t *)src[1];\n        v = (uint16_t *)src[2];\n        sourceStride = srcStride[0] / 2;\n\n        b9Bit = (m_InBpp == 9);\n    }\n\n#define YUV444_v410_PACK *idst++ = ((uv & 0x3FF) << 2) | ((yv & 0x3FF) << 12) | ((vv & 0x3FF) << 22);\n\n    BYTE *out = dst[0];\n    YUV444_PACKED_LOOP_HEAD_LE(width, height, y, u, v, out)\n    if (b9Bit)\n    {\n        yv <<= 1;\n        uv <<= 1;\n        vv <<= 1;\n    }\n    YUV444_v410_PACK YUV444_PACKED_LOOP_END(y, u, v, out, sourceStride, dstStride[0])\n\n        av_freep(&pTmpBuffer);\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/interleave.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <emmintrin.h>\n\n#include \"pixconv_internal.h\"\n#include \"pixconv_sse2_templates.h\"\n\nDECLARE_CONV_FUNC_IMPL(convert_yuv444_y410)\n{\n    const uint16_t *y = (const uint16_t *)src[0];\n    const uint16_t *u = (const uint16_t *)src[1];\n    const uint16_t *v = (const uint16_t *)src[2];\n\n    const ptrdiff_t inStride = srcStride[0] >> 1;\n    const ptrdiff_t outStride = dstStride[0];\n    int shift = 10 - bpp;\n\n    ptrdiff_t line, i;\n\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n\n    xmm7 = _mm_set1_epi32(0xC0000000);\n    xmm6 = _mm_setzero_si128();\n\n    _mm_sfence();\n\n    for (line = 0; line < height; ++line)\n    {\n        __m128i *dst128 = (__m128i *)(dst[0] + line * outStride);\n\n        for (i = 0; i < width; i += 8)\n        {\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm0, (y + i));\n            xmm0 = _mm_slli_epi16(xmm0, shift);\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm1, (u + i));\n            xmm1 = _mm_slli_epi16(xmm1, shift);\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm2, (v + i));\n            xmm2 = _mm_slli_epi16(xmm2, shift + 4); // +4 so its directly aligned properly (data from bit 14 to bit 4)\n\n            xmm3 = _mm_unpacklo_epi16(xmm1, xmm2); // 0VVVVV00000UUUUU\n            xmm4 = _mm_unpackhi_epi16(xmm1, xmm2); // 0VVVVV00000UUUUU\n            xmm3 = _mm_or_si128(xmm3, xmm7);       // AVVVVV00000UUUUU\n            xmm4 = _mm_or_si128(xmm4, xmm7);       // AVVVVV00000UUUUU\n\n            xmm5 = _mm_unpacklo_epi16(xmm0, xmm6); // 00000000000YYYYY\n            xmm2 = _mm_unpackhi_epi16(xmm0, xmm6); // 00000000000YYYYY\n            xmm5 = _mm_slli_epi32(xmm5, 10);       // 000000YYYYY00000\n            xmm2 = _mm_slli_epi32(xmm2, 10);       // 000000YYYYY00000\n\n            xmm3 = _mm_or_si128(xmm3, xmm5); // AVVVVVYYYYYUUUUU\n            xmm4 = _mm_or_si128(xmm4, xmm2); // AVVVVVYYYYYUUUUU\n\n            // Write data back\n            _mm_stream_si128(dst128++, xmm3);\n            _mm_stream_si128(dst128++, xmm4);\n        }\n\n        y += inStride;\n        u += inStride;\n        v += inStride;\n    }\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/pixconv.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"pixconv_internal.h\"\n#include \"pixconv_sse2_templates.h\"\n\n// 8x8 Bayes ordered dithering table, scaled to the 0-255 range for 16->8 conversion\n// stored as 16-bit unsigned for optimized SIMD access\n// clang-format off\n__declspec(align(16)) const uint16_t dither_8x8_256[8][8] = {\n  {   0, 192,  48, 240,  12, 204,  60, 252 },\n  { 128,  64, 176, 112, 140,  76, 188, 124 },\n  {  32, 224,  16, 208,  44, 236,  28, 220 },\n  { 160,  96, 144,  80, 172, 108, 156,  92 },\n  {   8, 200,  56, 248,   4, 196,  52, 244 },\n  { 136,  72, 184, 120, 132,  68, 180, 116 },\n  {  40, 232,  24, 216,  36, 228,  20, 212 },\n  { 168, 104, 152,  88, 164, 100, 148,  84 }\n};\n// clang-format on\n\nDECLARE_CONV_FUNC_IMPL(plane_copy)\n{\n    LAVOutPixFmtDesc desc = lav_pixfmt_desc[outputFormat];\n\n    const int widthBytes = width * desc.codedbytes;\n    const int planes = max(desc.planes, 1);\n\n    ptrdiff_t line, plane;\n\n    for (plane = 0; plane < planes; plane++)\n    {\n        const int planeWidth = widthBytes / desc.planeWidth[plane];\n        const int planeHeight = height / desc.planeHeight[plane];\n        const ptrdiff_t srcPlaneStride = srcStride[plane];\n        const ptrdiff_t dstPlaneStride = dstStride[plane];\n        const uint8_t *const srcBuf = src[plane];\n        uint8_t *const dstBuf = dst[plane];\n\n        for (line = 0; line < planeHeight; ++line)\n        {\n            memcpy(dstBuf + line * dstPlaneStride, srcBuf + line * srcPlaneStride, planeWidth);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(plane_copy_sse2)\n{\n    LAVOutPixFmtDesc desc = lav_pixfmt_desc[outputFormat];\n\n    const int widthBytes = width * desc.codedbytes;\n    const int planes = max(desc.planes, 1);\n\n    ptrdiff_t line, plane;\n\n    for (plane = 0; plane < planes; plane++)\n    {\n        const int planeWidth = widthBytes / desc.planeWidth[plane];\n        const int planeHeight = height / desc.planeHeight[plane];\n        const ptrdiff_t srcPlaneStride = srcStride[plane];\n        const ptrdiff_t dstPlaneStride = dstStride[plane];\n        const uint8_t *const srcBuf = src[plane];\n        uint8_t *const dstBuf = dst[plane];\n\n        if ((dstPlaneStride % 16) == 0 && ((intptr_t)dstBuf % 16u) == 0)\n        {\n            for (line = 0; line < planeHeight; ++line)\n            {\n                PIXCONV_MEMCPY_ALIGNED(dstBuf + line * dstPlaneStride, srcBuf + line * srcPlaneStride, planeWidth);\n            }\n        }\n        else\n        {\n            for (line = 0; line < planeHeight; ++line)\n            {\n                memcpy(dstBuf + line * dstPlaneStride, srcBuf + line * srcPlaneStride, planeWidth);\n            }\n        }\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/pixconv_internal.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"LAVPixFmtConverter.h\"\n#include <emmintrin.h>\n#include \"timer.h\"\n#include \"Media.h\"\n\nextern __declspec(align(16)) const uint16_t dither_8x8_256[8][8];\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/pixconv_sse2_templates.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <emmintrin.h>\n#include <smmintrin.h>\n\n// Load the dithering coefficients for this line\n// reg   - register to load coefficients into\n// line  - index of line to process (0 based)\n// bits  - number of bits to dither (for 10 -> 8, set to 2)\n#define PIXCONV_LOAD_DITHER_COEFFS(reg, line, bits, name) \\\n    const uint16_t *name = dither_8x8_256[(line) % 8];    \\\n    reg = _mm_load_si128((const __m128i *)name);          \\\n    reg = _mm_srli_epi16(reg, 8 - bits); /* shift to the required dithering strength */\n\n// Load 8 16-bit pixels into a register, using aligned memory access\n// reg   - register to store pixels in\n// src   - memory pointer of the source\n// bpp   - bit depth of the pixels\n#define PIXCONV_LOAD_PIXEL16(reg, src, bpp)                            \\\n    reg = _mm_load_si128((const __m128i *)(src)); /* load (aligned) */ \\\n    reg = _mm_slli_epi16(reg, 16 - bpp);          /* shift to 16-bit */\n\n// Load 2x8 16-bit pixels into registers, using aligned memory access\n// reg1   - register to store pixels in\n// reg2   - register to store pixels in\n// src1   - memory pointer of the source\n// src2   - memory pointer of the source\n// bpp   - bit depth of the pixels\n#define PIXCONV_LOAD_PIXEL16X2(reg1, reg2, src1, src2, bpp) \\\n    {                                                       \\\n        const __m128i shift = _mm_cvtsi32_si128(16 - bpp);  \\\n        reg1 = _mm_load_si128((const __m128i *)(src1));     \\\n        reg2 = _mm_load_si128((const __m128i *)(src2));     \\\n        reg1 = _mm_sll_epi16(reg1, shift);                  \\\n        reg2 = _mm_sll_epi16(reg2, shift);                  \\\n    }\n\n// Load 8 16-bit pixels into a register, and dither them to 8 bit\n// The 8-bit pixels will be in the high-bytes of the 8 16-bit parts\n// NOTE: the low-bytes are clobbered, and not empty.\n// reg   - register to store pixels in\n// dreg  - register with dithering coefficients\n// src   - memory pointer of the source\n// bpp   - bit depth of the pixels\n#define PIXCONV_LOAD_PIXEL16_DITHER_HIGH(reg, dreg, src, bpp) \\\n    PIXCONV_LOAD_PIXEL16(reg, src, bpp)                       \\\n    reg = _mm_adds_epu16(reg, dreg); /* dither */\n\n// Load 8 16-bit pixels into a register, and dither them to 8 bit\n// The 8-bit pixels will be in the low-bytes of the 8 16-bit parts\n// reg   - register to store pixels in\n// dreg  - register with dithering coefficients\n// src   - memory pointer of the source\n// bpp   - bit depth of the pixels\n#define PIXCONV_LOAD_PIXEL16_DITHER(reg, dreg, src, bpp)  \\\n    PIXCONV_LOAD_PIXEL16_DITHER_HIGH(reg, dreg, src, bpp) \\\n    reg = _mm_srli_epi16(reg, 8); /* shift to 8-bit */\n\n// Load 8 16-bit pixels into a register, and dither them to 8 bit\n// The 8-bit pixels will be in the 8 low-bytes in the register\n// reg   - register to store pixels in\n// dreg  - register with dithering coefficients\n// src   - memory pointer of the source\n// bpp   - bit depth of the pixels\n#define PIXCONV_LOAD_PIXEL16_DITHER_PACKED(reg, dreg, zero, src, bpp)    \\\n    PIXCONV_LOAD_PIXEL16_DITHER(reg, dreg, src, bpp) /* load unpacked */ \\\n    reg = _mm_packus_epi16(reg, zero);               /* pack */\n\n// Load 16 8-bit pixels into a register\n// reg   - register to store pixels in\n// src   - memory pointer of the source\n#define PIXCONV_LOAD_PIXEL8(reg, src) reg = _mm_loadu_si128((const __m128i *)(src)); /* load (unaligned) */\n\n// Load 128-bit into a register, using aligned memory access\n// reg   - register to store pixels in\n// src   - memory pointer of the source\n#define PIXCONV_LOAD_ALIGNED(reg, src) reg = _mm_load_si128((const __m128i *)(src)); /* load (aligned) */\n\n// Load 128-bit into a register, using streaming  memory access\n// reg   - register to store pixels in\n// src   - memory pointer of the source\n#define PIXCONV_STREAM_LOAD(reg, src) reg = _mm_stream_load_si128((__m128i *)(src)); /* load (streaming) */\n\n#define PIXCONV_LOAD_PIXEL8_ALIGNED PIXCONV_LOAD_ALIGNED\n\n// Put 128-bit into memory, using streaming write\n#define PIXCONV_PUT_STREAM(dst, reg) _mm_stream_si128((__m128i *)(dst), reg); /* streaming write */\n\n// Load 4 8-bit pixels into the register\n// reg     - register to store pixels in\n// src     - source memory\n#define PIXCONV_LOAD_4PIXEL8(reg, src) reg = _mm_cvtsi32_si128(*(const int *)(src)); /* load 32-bit (4 pixel) */\n\n// Load 4 16-bit pixels into the register\n// reg     - register to store pixels in\n// src     - source memory\n#define PIXCONV_LOAD_4PIXEL16(reg, src) reg = _mm_loadl_epi64((const __m128i *)(src)); /* load 64-bit (4 pixel) */\n\n// SSE2 Aligned memcpy\n// dst - memory destination\n// src - memory source\n// len - size in bytes\n#define PIXCONV_MEMCPY_ALIGNED(dst, src, len)              \\\n    {                                                      \\\n        const uint8_t *const srcLinePtr = (src);           \\\n        uint8_t *const dstLinePtr = (dst);                 \\\n        __m128i r1, r2, r3, r4;                            \\\n        ptrdiff_t i;                                       \\\n        for (i = 0; i < (len - 63); i += 64)               \\\n        {                                                  \\\n            PIXCONV_LOAD_ALIGNED(r1, srcLinePtr + i + 0)   \\\n            PIXCONV_LOAD_ALIGNED(r2, srcLinePtr + i + 16); \\\n            PIXCONV_LOAD_ALIGNED(r3, srcLinePtr + i + 32); \\\n            PIXCONV_LOAD_ALIGNED(r4, srcLinePtr + i + 48); \\\n            PIXCONV_PUT_STREAM(dstLinePtr + i + 0, r1);    \\\n            PIXCONV_PUT_STREAM(dstLinePtr + i + 16, r2);   \\\n            PIXCONV_PUT_STREAM(dstLinePtr + i + 32, r3);   \\\n            PIXCONV_PUT_STREAM(dstLinePtr + i + 48, r4);   \\\n        }                                                  \\\n        for (; i < len; i += 16)                           \\\n        {                                                  \\\n            PIXCONV_LOAD_ALIGNED(r1, srcLinePtr + i);      \\\n            PIXCONV_PUT_STREAM(dstLinePtr + i, r1);        \\\n        }                                                  \\\n    }\n\n// SSE2 Aligned memcpy\n// Copys the same size from two source into two destinations at the same time\n// dst1 - memory destination\n// src1 - memory source\n// dst2 - memory destination\n// src2 - memory source\n// len  - size in bytes\n#define PIXCONV_MEMCPY_ALIGNED_TWO(dst1, src1, dst2, src2, len) \\\n    {                                                           \\\n        const uint8_t *const src1LinePtr = (src1);              \\\n        const uint8_t *const src2LinePtr = (src2);              \\\n        uint8_t *const dst1LinePtr = (dst1);                    \\\n        uint8_t *const dst2LinePtr = (dst2);                    \\\n        __m128i r1, r2, r3, r4, r5, r6, r7, r8;                 \\\n        ptrdiff_t i;                                            \\\n        for (i = 0; i < (len - 63); i += 64)                    \\\n        {                                                       \\\n            PIXCONV_LOAD_ALIGNED(r1, src1LinePtr + i + 0);      \\\n            PIXCONV_LOAD_ALIGNED(r2, src1LinePtr + i + 16);     \\\n            PIXCONV_LOAD_ALIGNED(r3, src1LinePtr + i + 32);     \\\n            PIXCONV_LOAD_ALIGNED(r4, src1LinePtr + i + 48);     \\\n            PIXCONV_LOAD_ALIGNED(r5, src2LinePtr + i + 0);      \\\n            PIXCONV_LOAD_ALIGNED(r6, src2LinePtr + i + 16);     \\\n            PIXCONV_LOAD_ALIGNED(r7, src2LinePtr + i + 32);     \\\n            PIXCONV_LOAD_ALIGNED(r8, src2LinePtr + i + 48);     \\\n            PIXCONV_PUT_STREAM(dst1LinePtr + i + 0, r1);        \\\n            PIXCONV_PUT_STREAM(dst1LinePtr + i + 16, r2);       \\\n            PIXCONV_PUT_STREAM(dst1LinePtr + i + 32, r3);       \\\n            PIXCONV_PUT_STREAM(dst1LinePtr + i + 48, r4);       \\\n            PIXCONV_PUT_STREAM(dst2LinePtr + i + 0, r5);        \\\n            PIXCONV_PUT_STREAM(dst2LinePtr + i + 16, r6);       \\\n            PIXCONV_PUT_STREAM(dst2LinePtr + i + 32, r7);       \\\n            PIXCONV_PUT_STREAM(dst2LinePtr + i + 48, r8);       \\\n        }                                                       \\\n        for (; i < len; i += 16)                                \\\n        {                                                       \\\n            PIXCONV_LOAD_ALIGNED(r1, src1LinePtr + i);          \\\n            PIXCONV_LOAD_ALIGNED(r2, src2LinePtr + i);          \\\n            PIXCONV_PUT_STREAM(dst1LinePtr + i, r1);            \\\n            PIXCONV_PUT_STREAM(dst2LinePtr + i, r2);            \\\n        }                                                       \\\n    }\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/rgb2rgb_unscaled.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <emmintrin.h>\n\n#include \"pixconv_internal.h\"\n#include \"pixconv_sse2_templates.h\"\n\nDECLARE_CONV_FUNC_IMPL(convert_rgb48_rgb32_ssse3)\n{\n    const uint16_t *rgb = (const uint16_t *)src[0];\n    const ptrdiff_t inStride = srcStride[0] >> 1;\n    const ptrdiff_t outStride = dstStride[0];\n    ptrdiff_t line, i;\n\n    int processWidth = width * 3;\n\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers = GetRandomDitherCoeffs(height, 4, 8, 0);\n    if (dithers == nullptr)\n        ditherMode = LAVDither_Ordered;\n\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n    __m128i mask = _mm_setr_epi8(4, 5, 2, 3, 0, 1, -1, -1, 10, 11, 8, 9, 6, 7, -1, -1);\n\n    _mm_sfence();\n    for (line = 0; line < height; line++)\n    {\n        __m128i *dst128 = (__m128i *)(dst[0] + line * outStride);\n\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm5 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 0));\n            xmm6 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 8));\n            xmm7 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 16));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm7, line, 8, dithers);\n            xmm5 = xmm6 = xmm7;\n        }\n        for (i = 0; i < processWidth; i += 24)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, (rgb + i)); /* load */\n            PIXCONV_LOAD_ALIGNED(xmm1, (rgb + i + 8));\n            PIXCONV_LOAD_ALIGNED(xmm2, (rgb + i + 16));\n            xmm0 = _mm_adds_epu16(xmm0, xmm5); /* apply dithering coefficients */\n            xmm1 = _mm_adds_epu16(xmm1, xmm6);\n            xmm2 = _mm_adds_epu16(xmm2, xmm7);\n            xmm0 = _mm_srli_epi16(xmm0, 8); /* shift to 8-bit */\n            xmm1 = _mm_srli_epi16(xmm1, 8);\n            xmm2 = _mm_srli_epi16(xmm2, 8);\n\n            xmm3 = _mm_shuffle_epi8(xmm0, mask);\n            xmm4 = _mm_shuffle_epi8(_mm_alignr_epi8(xmm1, xmm0, 12), mask);\n            xmm0 = _mm_shuffle_epi8(_mm_alignr_epi8(xmm2, xmm1, 8), mask);\n            xmm1 = _mm_shuffle_epi8(_mm_alignr_epi8(xmm2, xmm2, 4), mask);\n\n            xmm3 = _mm_packus_epi16(xmm3, xmm4);\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);\n\n            _mm_stream_si128(dst128++, xmm3);\n            _mm_stream_si128(dst128++, xmm0);\n        }\n\n        rgb += inStride;\n    }\n\n    return S_OK;\n}\n\ntemplate <int out32> DECLARE_CONV_FUNC_IMPL(convert_rgb48_rgb)\n{\n    // Byte Swap to BGR layout\n    uint8_t *dstBS[4] = {nullptr};\n    dstBS[0] = (BYTE *)av_malloc(height * srcStride[0]);\n    if (dstBS[0] == nullptr)\n        return E_OUTOFMEMORY;\n\n    SwsContext *ctx = GetSWSContext(width, height, GetFFInput(), AV_PIX_FMT_BGR48LE, SWS_POINT);\n    sws_scale2(ctx, src, srcStride, 0, height, dstBS, srcStride);\n\n    // Dither to RGB24/32 with SSE2\n    const uint16_t *rgb = (const uint16_t *)dstBS[0];\n    const ptrdiff_t inStride = srcStride[0] >> 1;\n    const ptrdiff_t outStride = dstStride[0];\n    ptrdiff_t line, i;\n    int processWidth = width * 3;\n\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers = GetRandomDitherCoeffs(height, 2, 8, 0);\n    if (dithers == nullptr)\n        ditherMode = LAVDither_Ordered;\n\n    __m128i xmm0, xmm1, xmm6, xmm7;\n\n    uint8_t *rgb24buffer = nullptr;\n    if (out32)\n    {\n        rgb24buffer = (uint8_t *)av_malloc(outStride + AV_INPUT_BUFFER_PADDING_SIZE);\n        if (rgb24buffer == nullptr)\n        {\n            av_freep(&dstBS[0]);\n            return E_OUTOFMEMORY;\n        }\n    }\n\n    _mm_sfence();\n    for (line = 0; line < height; line++)\n    {\n        __m128i *dst128 = nullptr;\n        if (out32)\n        {\n            dst128 = (__m128i *)rgb24buffer;\n        }\n        else\n        {\n            dst128 = (__m128i *)(dst[0] + line * outStride);\n        }\n\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm6 = _mm_load_si128((const __m128i *)(dithers + (line << 4) + 0));\n            xmm7 = _mm_load_si128((const __m128i *)(dithers + (line << 4) + 8));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm7, line, 8, dithers);\n            xmm6 = xmm7;\n        }\n        for (i = 0; i < processWidth; i += 16)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, (rgb + i)); /* load */\n            PIXCONV_LOAD_ALIGNED(xmm1, (rgb + i + 8));\n            xmm0 = _mm_adds_epu16(xmm0, xmm6); /* apply dithering coefficients */\n            xmm1 = _mm_adds_epu16(xmm1, xmm7);\n            xmm0 = _mm_srli_epi16(xmm0, 8); /* shift to 8-bit */\n            xmm1 = _mm_srli_epi16(xmm1, 8);\n\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);\n            _mm_stream_si128(dst128++, xmm0);\n        }\n\n        rgb += inStride;\n        if (out32)\n        {\n            uint32_t *src24 = (uint32_t *)rgb24buffer;\n            uint32_t *dst32 = (uint32_t *)(dst[0] + line * outStride);\n            for (i = 0; i < width; i += 4)\n            {\n                uint32_t sa = src24[0];\n                uint32_t sb = src24[1];\n                uint32_t sc = src24[2];\n\n                dst32[i + 0] = sa;\n                dst32[i + 1] = (sa >> 24) | (sb << 8);\n                dst32[i + 2] = (sb >> 16) | (sc << 16);\n                dst32[i + 3] = sc >> 8;\n\n                src24 += 3;\n            }\n        }\n    }\n\n    if (out32)\n        av_freep(&rgb24buffer);\n    av_freep(&dstBS[0]);\n\n    return S_OK;\n}\n\ntemplate HRESULT CLAVPixFmtConverter::convert_rgb48_rgb<0> CONV_FUNC_PARAMS;\ntemplate HRESULT CLAVPixFmtConverter::convert_rgb48_rgb<1> CONV_FUNC_PARAMS;\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/yuv2rgb.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <emmintrin.h>\n#include <ppl.h>\n\n#include \"pixconv_internal.h\"\n#include \"pixconv_sse2_templates.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4556)\n\n#define DITHER_STEPS 3\n\n// This function converts 4x2 pixels from the source into 4x2 RGB pixels in the destination\ntemplate <LAVPixelFormat inputFormat, int shift, int outFmt, int right_edge, int dithertype, int ycgco>\n__forceinline static int yuv2rgb_convert_pixels(const uint8_t *&srcY, const uint8_t *&srcU, const uint8_t *&srcV,\n                                                uint8_t *&dst, ptrdiff_t srcStrideY, ptrdiff_t srcStrideUV,\n                                                ptrdiff_t dstStride, ptrdiff_t line, const RGBCoeffs *coeffs,\n                                                const uint16_t *&dithers, ptrdiff_t pos)\n{\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n    xmm7 = _mm_setzero_si128();\n\n    // Shift > 0 is for 9/10 bit formats\n    if (inputFormat == LAVPixFmt_P016)\n    {\n        // Load 2 32-bit macro pixels from each line, which contain 4 UV at 16-bit each samples\n        PIXCONV_LOAD_PIXEL8(xmm0, srcU);\n        PIXCONV_LOAD_PIXEL8(xmm2, srcU + srcStrideUV);\n    }\n    else if (shift > 0)\n    {\n        // Load 4 U/V values from line 0/1 into registers\n        PIXCONV_LOAD_4PIXEL16(xmm1, srcU);\n        PIXCONV_LOAD_4PIXEL16(xmm3, srcU + srcStrideUV);\n        PIXCONV_LOAD_4PIXEL16(xmm0, srcV);\n        PIXCONV_LOAD_4PIXEL16(xmm2, srcV + srcStrideUV);\n\n        // Interleave U and V\n        xmm0 = _mm_unpacklo_epi16(xmm1, xmm0); /* 0V0U0V0U */\n        xmm2 = _mm_unpacklo_epi16(xmm3, xmm2); /* 0V0U0V0U */\n    }\n    else if (inputFormat == LAVPixFmt_NV12)\n    {\n        // Load 4 16-bit macro pixels, which contain 4 UV samples\n        PIXCONV_LOAD_4PIXEL16(xmm0, srcU);\n        PIXCONV_LOAD_4PIXEL16(xmm2, srcU + srcStrideUV);\n\n        // Expand to 16-bit\n        xmm0 = _mm_unpacklo_epi8(xmm0, xmm7); /* 0V0U0V0U */\n        xmm2 = _mm_unpacklo_epi8(xmm2, xmm7); /* 0V0U0V0U */\n    }\n    else\n    {\n        PIXCONV_LOAD_4PIXEL8(xmm1, srcU);\n        PIXCONV_LOAD_4PIXEL8(xmm3, srcU + srcStrideUV);\n        PIXCONV_LOAD_4PIXEL8(xmm0, srcV);\n        PIXCONV_LOAD_4PIXEL8(xmm2, srcV + srcStrideUV);\n\n        // Interleave U and V\n        xmm0 = _mm_unpacklo_epi8(xmm1, xmm0); /* VUVU0000 */\n        xmm2 = _mm_unpacklo_epi8(xmm3, xmm2); /* VUVU0000 */\n\n        // Expand to 16-bit\n        xmm0 = _mm_unpacklo_epi8(xmm0, xmm7); /* 0V0U0V0U */\n        xmm2 = _mm_unpacklo_epi8(xmm2, xmm7); /* 0V0U0V0U */\n    }\n\n    // xmm0/xmm2 contain 4 interleaved U/V samples from two lines each in the 16bit parts, still in their native\n    // bitdepth\n\n    // Chroma upsampling required\n    if (inputFormat == LAVPixFmt_YUV420 || inputFormat == LAVPixFmt_NV12 || inputFormat == LAVPixFmt_YUV422 ||\n        inputFormat == LAVPixFmt_P016)\n    {\n        if (inputFormat == LAVPixFmt_P016)\n        {\n            srcU += 8;\n            srcV += 8;\n        }\n        else if (shift > 0 || inputFormat == LAVPixFmt_NV12)\n        {\n            srcU += 4;\n            srcV += 4;\n        }\n        else\n        {\n            srcU += 2;\n            srcV += 2;\n        }\n\n        // Cut off the over-read into the stride and replace it with the last valid pixel\n        if (right_edge)\n        {\n            xmm6 = _mm_set_epi32(0, 0xffffffff, 0, 0);\n\n            // First line\n            xmm1 = xmm0;\n            xmm1 = _mm_slli_si128(xmm1, 4);\n            xmm1 = _mm_and_si128(xmm1, xmm6);\n            xmm0 = _mm_andnot_si128(xmm6, xmm0);\n            xmm0 = _mm_or_si128(xmm0, xmm1);\n\n            // Second line\n            xmm3 = xmm2;\n            xmm3 = _mm_slli_si128(xmm3, 4);\n            xmm3 = _mm_and_si128(xmm3, xmm6);\n            xmm2 = _mm_andnot_si128(xmm6, xmm2);\n            xmm2 = _mm_or_si128(xmm2, xmm3);\n        }\n\n        // 4:2:0 - upsample to 4:2:2 using 75:25\n        if (inputFormat == LAVPixFmt_YUV420 || inputFormat == LAVPixFmt_NV12 || inputFormat == LAVPixFmt_P016)\n        {\n            // Too high bitdepth, shift down to 14-bit\n            if (shift >= 7)\n            {\n                xmm0 = _mm_srli_epi16(xmm0, shift - 6);\n                xmm2 = _mm_srli_epi16(xmm2, shift - 6);\n            }\n            xmm1 = xmm0;\n            xmm1 = _mm_add_epi16(xmm1, xmm0); /* 2x line 0 */\n            xmm1 = _mm_add_epi16(xmm1, xmm0); /* 3x line 0 */\n            xmm1 = _mm_add_epi16(xmm1, xmm2); /* 3x line 0 + line 1 (10bit) */\n\n            xmm3 = xmm2;\n            xmm3 = _mm_add_epi16(xmm3, xmm2); /* 2x line 1 */\n            xmm3 = _mm_add_epi16(xmm3, xmm2); /* 3x line 1 */\n            xmm3 = _mm_add_epi16(xmm3, xmm0); /* 3x line 1 + line 0 (10bit) */\n\n            // If the bit depth is too high, we need to reduce it here (max 15bit)\n            // 14-16 bits need the reduction, because they all result in a 16-bit result\n            if (shift >= 6)\n            {\n                xmm1 = _mm_srli_epi16(xmm1, 1);\n                xmm3 = _mm_srli_epi16(xmm3, 1);\n            }\n        }\n        else\n        {\n            xmm1 = xmm0;\n            xmm3 = xmm2;\n\n            // Shift to maximum of 15-bit, if required\n            if (shift >= 8)\n            {\n                xmm1 = _mm_srli_epi16(xmm1, 1);\n                xmm3 = _mm_srli_epi16(xmm3, 1);\n            }\n        }\n        // After this step, xmm1 and xmm3 contain 8 16-bit values, V and U interleaved. For 4:2:2, filling 8 to 15 bits\n        // (original bit depth). For 4:2:0, filling input+2 bits (10 to 15).\n\n        // Upsample to 4:4:4 using 100:0, 50:50, 0:100 scheme (MPEG2 chroma siting)\n        // TODO: MPEG1 chroma siting, use 75:25\n\n        xmm0 = xmm1;                           /* UV UV UV UV */\n        xmm0 = _mm_unpacklo_epi32(xmm0, xmm7); /* UV 00 UV 00 */\n        xmm1 = _mm_srli_si128(xmm1, 4);        /* UV UV UV 00 */\n        xmm1 = _mm_unpacklo_epi32(xmm7, xmm1); /* 00 UV 00 UV */\n\n        xmm1 = _mm_add_epi16(xmm1, xmm0); /*  UV  UV  UV  UV */\n        xmm1 = _mm_add_epi16(xmm1, xmm0); /* 2UV  UV 2UV  UV */\n\n        xmm0 = _mm_slli_si128(xmm0, 4);   /*  00  UV  00  UV */\n        xmm1 = _mm_add_epi16(xmm1, xmm0); /* 2UV 2UV 2UV 2UV */\n\n        // Same for the second row\n        xmm2 = xmm3;                           /* UV UV UV UV */\n        xmm2 = _mm_unpacklo_epi32(xmm2, xmm7); /* UV 00 UV 00 */\n        xmm3 = _mm_srli_si128(xmm3, 4);        /* UV UV UV 00 */\n        xmm3 = _mm_unpacklo_epi32(xmm7, xmm3); /* 00 UV 00 UV */\n\n        xmm3 = _mm_add_epi16(xmm3, xmm2); /*  UV  UV  UV  UV */\n        xmm3 = _mm_add_epi16(xmm3, xmm2); /* 2UV  UV 2UV  UV */\n\n        xmm2 = _mm_slli_si128(xmm2, 4);   /*  00  UV  00  UV */\n        xmm3 = _mm_add_epi16(xmm3, xmm2); /* 2UV 2UV 2UV 2UV */\n\n        // Shift the result to 12 bit\n        // For 10-bit input, we need to shift one bit off, or we exceed the allowed processing depth\n        // For 8-bit, we need to add one bit\n        if ((inputFormat == LAVPixFmt_YUV420 && shift > 1) || inputFormat == LAVPixFmt_P016)\n        {\n            if (shift >= 5)\n            {\n                xmm1 = _mm_srli_epi16(xmm1, 4);\n                xmm3 = _mm_srli_epi16(xmm3, 4);\n            }\n            else\n            {\n                xmm1 = _mm_srli_epi16(xmm1, shift - 1);\n                xmm3 = _mm_srli_epi16(xmm3, shift - 1);\n            }\n        }\n        else if (inputFormat == LAVPixFmt_YUV422)\n        {\n            if (shift >= 7)\n            {\n                xmm1 = _mm_srli_epi16(xmm1, 4);\n                xmm3 = _mm_srli_epi16(xmm3, 4);\n            }\n            else if (shift > 3)\n            {\n                xmm1 = _mm_srli_epi16(xmm1, shift - 3);\n                xmm3 = _mm_srli_epi16(xmm3, shift - 3);\n            }\n            else if (shift < 3)\n            {\n                xmm1 = _mm_slli_epi16(xmm1, 3 - shift);\n                xmm3 = _mm_slli_epi16(xmm3, 3 - shift);\n            }\n        }\n        else if ((inputFormat == LAVPixFmt_YUV420 && shift == 0) || inputFormat == LAVPixFmt_NV12)\n        {\n            xmm1 = _mm_slli_epi16(xmm1, 1);\n            xmm3 = _mm_slli_epi16(xmm3, 1);\n        }\n\n        // 12-bit result, xmm1 & xmm3 with 4 UV combinations each\n    }\n    else if (inputFormat == LAVPixFmt_YUV444)\n    {\n        if (shift > 0)\n        {\n            srcU += 8;\n            srcV += 8;\n        }\n        else\n        {\n            srcU += 4;\n            srcV += 4;\n        }\n        // Shift to 12 bit\n        if (shift > 4)\n        {\n            xmm1 = _mm_srli_epi16(xmm0, shift - 4);\n            xmm3 = _mm_srli_epi16(xmm2, shift - 4);\n        }\n        else if (shift < 4)\n        {\n            xmm1 = _mm_slli_epi16(xmm0, 4 - shift);\n            xmm3 = _mm_slli_epi16(xmm2, 4 - shift);\n        }\n        else\n        {\n            xmm1 = xmm0;\n            xmm3 = xmm2;\n        }\n    }\n\n    // Load Y\n    if (shift > 0)\n    {\n        // Load 4 Y values from line 0/1 into registers\n        PIXCONV_LOAD_4PIXEL16(xmm5, srcY);\n        PIXCONV_LOAD_4PIXEL16(xmm0, srcY + srcStrideY);\n\n        srcY += 8;\n    }\n    else\n    {\n        PIXCONV_LOAD_4PIXEL8(xmm5, srcY);\n        PIXCONV_LOAD_4PIXEL8(xmm0, srcY + srcStrideY);\n        srcY += 4;\n\n        xmm5 = _mm_unpacklo_epi8(xmm5, xmm7); /* YYYY0000 (16-bit fields) */\n        xmm0 = _mm_unpacklo_epi8(xmm0, xmm7); /* YYYY0000 (16-bit fields)*/\n    }\n\n    xmm0 = _mm_unpacklo_epi64(xmm0, xmm5); /* YYYYYYYY */\n\n    // After this step, xmm1 & xmm3 contain 4 UV pairs, each in a 16-bit value, filling 12-bit.\n    if (!ycgco)\n    {\n        // YCbCr conversion\n        // Shift Y to 14 bits\n        if (shift < 6)\n        {\n            xmm0 = _mm_slli_epi16(xmm0, 6 - shift);\n        }\n        else if (shift > 6)\n        {\n            xmm0 = _mm_srli_epi16(xmm0, shift - 6);\n        }\n        xmm0 = _mm_subs_epu16(xmm0, coeffs->Ysub); /* Y-16 (in case of range expansion) */\n        xmm0 =\n            _mm_mulhi_epi16(xmm0, coeffs->cy); /* Y*cy (result is 28 bits, with 12 high-bits packed into the result) */\n        xmm0 = _mm_add_epi16(xmm0, coeffs->rgb_add); /* Y*cy + 16 (in case of range compression) */\n\n        xmm1 = _mm_subs_epi16(xmm1, coeffs->CbCr_center); /* move CbCr to proper range */\n        xmm3 = _mm_subs_epi16(xmm3, coeffs->CbCr_center);\n\n        xmm6 = xmm1;\n        xmm4 = xmm3;\n        xmm6 = _mm_madd_epi16(xmm6, coeffs->cR_Cr); /* Result is 25 bits (12 from chroma, 13 from coeff) */\n        xmm4 = _mm_madd_epi16(xmm4, coeffs->cR_Cr);\n        xmm6 = _mm_srai_epi32(xmm6, 13); /* Reduce to 12 bit */\n        xmm4 = _mm_srai_epi32(xmm4, 13);\n        xmm6 = _mm_packs_epi32(xmm6, xmm7); /* Pack back into 16 bit cells */\n        xmm4 = _mm_packs_epi32(xmm4, xmm7);\n        xmm6 = _mm_unpacklo_epi64(xmm4, xmm6); /* Interleave both parts */\n        xmm6 = _mm_add_epi16(xmm6, xmm0);      /* R (12bit) */\n\n        xmm5 = xmm1;\n        xmm4 = xmm3;\n        xmm5 = _mm_madd_epi16(xmm5, coeffs->cG_Cb_cG_Cr); /* Result is 25 bits (12 from chroma, 13 from coeff) */\n        xmm4 = _mm_madd_epi16(xmm4, coeffs->cG_Cb_cG_Cr);\n        xmm5 = _mm_srai_epi32(xmm5, 13); /* Reduce to 12 bit */\n        xmm4 = _mm_srai_epi32(xmm4, 13);\n        xmm5 = _mm_packs_epi32(xmm5, xmm7); /* Pack back into 16 bit cells */\n        xmm4 = _mm_packs_epi32(xmm4, xmm7);\n        xmm5 = _mm_unpacklo_epi64(xmm4, xmm5); /* Interleave both parts */\n        xmm5 = _mm_add_epi16(xmm5, xmm0);      /* G (12bit) */\n\n        xmm1 = _mm_madd_epi16(xmm1, coeffs->cB_Cb); /* Result is 25 bits (12 from chroma, 13 from coeff) */\n        xmm3 = _mm_madd_epi16(xmm3, coeffs->cB_Cb);\n        xmm1 = _mm_srai_epi32(xmm1, 13); /* Reduce to 12 bit */\n        xmm3 = _mm_srai_epi32(xmm3, 13);\n        xmm1 = _mm_packs_epi32(xmm1, xmm7); /* Pack back into 16 bit cells */\n        xmm3 = _mm_packs_epi32(xmm3, xmm7);\n        xmm1 = _mm_unpacklo_epi64(xmm3, xmm1); /* Interleave both parts */\n        xmm1 = _mm_add_epi16(xmm1, xmm0);      /* B (12bit) */\n    }\n    else\n    {\n        // YCgCo conversion\n        // Shift Y to 12 bits\n        if (shift < 4)\n        {\n            xmm0 = _mm_slli_epi16(xmm0, 4 - shift);\n        }\n        else if (shift > 4)\n        {\n            xmm0 = _mm_srli_epi16(xmm0, shift - 4);\n        }\n\n        xmm7 = _mm_set1_epi32(0x0000FFFF);\n        xmm2 = xmm1;\n        xmm4 = xmm3;\n\n        xmm1 = _mm_and_si128(xmm1, xmm7); /* null out the high-order bytes to get the Cg values */\n        xmm4 = _mm_and_si128(xmm4, xmm7);\n\n        xmm3 = _mm_srli_epi32(xmm3, 16); /* right shift the Co values */\n        xmm2 = _mm_srli_epi32(xmm2, 16);\n\n        xmm1 = _mm_packs_epi32(xmm4, xmm1); /* Pack Cg into xmm1 */\n        xmm3 = _mm_packs_epi32(xmm3, xmm2); /* Pack Co into xmm3 */\n\n        xmm2 = coeffs->CbCr_center; /* move CgCo to proper range */\n        xmm1 = _mm_subs_epi16(xmm1, xmm2);\n        xmm3 = _mm_subs_epi16(xmm3, xmm2);\n\n        xmm2 = xmm0;\n        xmm2 = _mm_subs_epi16(xmm2, xmm1); /* tmp = Y - Cg */\n        xmm6 = _mm_adds_epi16(xmm2, xmm3); /* R = tmp + Co */\n        xmm5 = _mm_adds_epi16(xmm0, xmm1); /* G = Y + Cg */\n        xmm1 = _mm_subs_epi16(xmm2, xmm3); /* B = tmp - Co */\n    }\n\n    // Dithering\n    if (dithertype == LAVDither_Random)\n    {\n        /* Load random dithering coeffs from the dithers buffer */\n        int offset = (pos % (DITHER_STEPS * 4 * 2)) * 6;\n        xmm2 = _mm_load_si128((const __m128i *)(dithers + 0 + offset));\n        xmm3 = _mm_load_si128((const __m128i *)(dithers + 8 + offset));\n        xmm4 = _mm_load_si128((const __m128i *)(dithers + 16 + offset));\n    }\n    else\n    {\n        /* Load dithering coeffs and combine them for two lines */\n        const uint16_t *d1 = dither_8x8_256[line % 8];\n        xmm2 = _mm_load_si128((const __m128i *)d1);\n        const uint16_t *d2 = dither_8x8_256[(line + 1) % 8];\n        xmm3 = _mm_load_si128((const __m128i *)d2);\n\n        xmm4 = xmm2;\n        xmm2 = _mm_unpacklo_epi64(xmm2, xmm3);\n        xmm4 = _mm_unpackhi_epi64(xmm4, xmm3);\n        xmm2 = _mm_srli_epi16(xmm2, 4);\n        xmm4 = _mm_srli_epi16(xmm4, 4);\n\n        xmm3 = xmm4;\n    }\n\n    xmm6 = _mm_adds_epu16(xmm6, xmm2); /* Apply coefficients to the RGB values */\n    xmm5 = _mm_adds_epu16(xmm5, xmm3);\n    xmm1 = _mm_adds_epu16(xmm1, xmm4);\n\n    xmm6 = _mm_srai_epi16(xmm6, 4); /* Shift to 8 bit */\n    xmm5 = _mm_srai_epi16(xmm5, 4);\n    xmm1 = _mm_srai_epi16(xmm1, 4);\n\n    xmm2 = _mm_cmpeq_epi8(xmm2, xmm2);   /* 0xffffffff,0xffffffff,0xffffffff,0xffffffff */\n    xmm6 = _mm_packus_epi16(xmm6, xmm7); /* R (lower 8bytes,8bit) * 8 */\n    xmm5 = _mm_packus_epi16(xmm5, xmm7); /* G (lower 8bytes,8bit) * 8 */\n    xmm1 = _mm_packus_epi16(xmm1, xmm7); /* B (lower 8bytes,8bit) * 8 */\n\n    xmm6 = _mm_unpacklo_epi8(xmm6, xmm2); // 0xff,R\n    xmm1 = _mm_unpacklo_epi8(xmm1, xmm5); // G,B\n    xmm2 = xmm1;\n\n    xmm1 = _mm_unpackhi_epi16(xmm1, xmm6); // 0xff,RGB * 4 (line 0)\n    xmm2 = _mm_unpacklo_epi16(xmm2, xmm6); // 0xff,RGB * 4 (line 1)\n\n    // TODO: RGB limiting\n\n    if (outFmt == 1)\n    {\n        _mm_stream_si128((__m128i *)(dst), xmm1);\n        _mm_stream_si128((__m128i *)(dst + dstStride), xmm2);\n        dst += 16;\n    }\n    else\n    {\n        // RGB 24 output is terribly inefficient due to the un-aligned size of 3 bytes per pixel\n        uint32_t eax;\n        __declspec(align(16)) uint8_t rgbbuf[32];\n        *(uint32_t *)rgbbuf = _mm_cvtsi128_si32(xmm1);\n        xmm1 = _mm_srli_si128(xmm1, 4);\n        *(uint32_t *)(rgbbuf + 3) = _mm_cvtsi128_si32(xmm1);\n        xmm1 = _mm_srli_si128(xmm1, 4);\n        *(uint32_t *)(rgbbuf + 6) = _mm_cvtsi128_si32(xmm1);\n        xmm1 = _mm_srli_si128(xmm1, 4);\n        *(uint32_t *)(rgbbuf + 9) = _mm_cvtsi128_si32(xmm1);\n\n        *(uint32_t *)(rgbbuf + 16) = _mm_cvtsi128_si32(xmm2);\n        xmm2 = _mm_srli_si128(xmm2, 4);\n        *(uint32_t *)(rgbbuf + 19) = _mm_cvtsi128_si32(xmm2);\n        xmm2 = _mm_srli_si128(xmm2, 4);\n        *(uint32_t *)(rgbbuf + 22) = _mm_cvtsi128_si32(xmm2);\n        xmm2 = _mm_srli_si128(xmm2, 4);\n        *(uint32_t *)(rgbbuf + 25) = _mm_cvtsi128_si32(xmm2);\n\n        xmm1 = _mm_loadl_epi64((const __m128i *)(rgbbuf));\n        xmm2 = _mm_loadl_epi64((const __m128i *)(rgbbuf + 16));\n\n        _mm_storel_epi64((__m128i *)(dst), xmm1);\n        eax = *(uint32_t *)(rgbbuf + 8);\n        *(uint32_t *)(dst + 8) = eax;\n\n        _mm_storel_epi64((__m128i *)(dst + dstStride), xmm2);\n        eax = *(uint32_t *)(rgbbuf + 24);\n        *(uint32_t *)(dst + dstStride + 8) = eax;\n\n        dst += 12;\n    }\n\n    return 0;\n}\n\ntemplate <LAVPixelFormat inputFormat, int shift, int outFmt, int dithertype, int ycgco>\nstatic int __stdcall yuv2rgb_convert(const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV, uint8_t *dst,\n                                     int width, int height, ptrdiff_t srcStrideY, ptrdiff_t srcStrideUV,\n                                     ptrdiff_t dstStride, ptrdiff_t sliceYStart, ptrdiff_t sliceYEnd,\n                                     const RGBCoeffs *coeffs, const uint16_t *dithers)\n{\n    const uint8_t *y = srcY;\n    const uint8_t *u = srcU;\n    const uint8_t *v = srcV;\n    uint8_t *rgb = dst;\n\n    ptrdiff_t line = sliceYStart;\n    ptrdiff_t lastLine = sliceYEnd;\n    bool lastLineInOddHeight = false;\n\n    const ptrdiff_t endx = width - 4;\n\n    const uint16_t *lineDither = dithers;\n\n    _mm_sfence();\n\n    // 4:2:0 needs special handling for the first and the last line\n    if (inputFormat == LAVPixFmt_YUV420 || inputFormat == LAVPixFmt_NV12 || inputFormat == LAVPixFmt_P016)\n    {\n        if (line == 0)\n        {\n            for (ptrdiff_t i = 0; i < endx; i += 4)\n            {\n                yuv2rgb_convert_pixels<inputFormat, shift, outFmt, 0, dithertype, ycgco>(y, u, v, rgb, 0, 0, 0, line,\n                                                                                         coeffs, lineDither, i);\n            }\n            yuv2rgb_convert_pixels<inputFormat, shift, outFmt, 1, dithertype, ycgco>(y, u, v, rgb, 0, 0, 0, line,\n                                                                                     coeffs, lineDither, 0);\n\n            line = 1;\n        }\n        if (lastLine == height)\n            lastLine--;\n    }\n    else if (lastLine == height && (lastLine & 1))\n    {\n        lastLine--;\n        lastLineInOddHeight = true;\n    }\n\n    for (; line < lastLine; line += 2)\n    {\n        if (dithertype == LAVDither_Random)\n            lineDither = dithers + (line * 24 * DITHER_STEPS);\n        y = srcY + line * srcStrideY;\n\n        if (inputFormat == LAVPixFmt_YUV420 || inputFormat == LAVPixFmt_NV12 || inputFormat == LAVPixFmt_P016)\n        {\n            u = srcU + (line >> 1) * srcStrideUV;\n            v = srcV + (line >> 1) * srcStrideUV;\n        }\n        else\n        {\n            u = srcU + line * srcStrideUV;\n            v = srcV + line * srcStrideUV;\n        }\n\n        rgb = dst + line * dstStride;\n\n        for (ptrdiff_t i = 0; i < endx; i += 4)\n        {\n            yuv2rgb_convert_pixels<inputFormat, shift, outFmt, 0, dithertype, ycgco>(\n                y, u, v, rgb, srcStrideY, srcStrideUV, dstStride, line, coeffs, lineDither, i);\n        }\n        yuv2rgb_convert_pixels<inputFormat, shift, outFmt, 1, dithertype, ycgco>(\n            y, u, v, rgb, srcStrideY, srcStrideUV, dstStride, line, coeffs, lineDither, 0);\n    }\n\n    if (inputFormat == LAVPixFmt_YUV420 || inputFormat == LAVPixFmt_NV12 || inputFormat == LAVPixFmt_P016 ||\n        lastLineInOddHeight)\n    {\n        if (sliceYEnd == height)\n        {\n            if (dithertype == LAVDither_Random)\n                lineDither = dithers + ((height - 2) * 24 * DITHER_STEPS);\n            y = srcY + (height - 1) * srcStrideY;\n            if (inputFormat == LAVPixFmt_YUV420 || inputFormat == LAVPixFmt_NV12 || inputFormat == LAVPixFmt_P016)\n            {\n                u = srcU + ((height >> 1) - 1) * srcStrideUV;\n                v = srcV + ((height >> 1) - 1) * srcStrideUV;\n            }\n            else\n            {\n                u = srcU + (height - 1) * srcStrideUV;\n                v = srcV + (height - 1) * srcStrideUV;\n            }\n            rgb = dst + (height - 1) * dstStride;\n\n            for (ptrdiff_t i = 0; i < endx; i += 4)\n            {\n                yuv2rgb_convert_pixels<inputFormat, shift, outFmt, 0, dithertype, ycgco>(y, u, v, rgb, 0, 0, 0, line,\n                                                                                         coeffs, lineDither, i);\n            }\n            yuv2rgb_convert_pixels<inputFormat, shift, outFmt, 1, dithertype, ycgco>(y, u, v, rgb, 0, 0, 0, line,\n                                                                                     coeffs, lineDither, 0);\n        }\n    }\n    return 0;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_yuv_rgb)\n{\n    const RGBCoeffs *coeffs = getRGBCoeffs(width, height);\n    if (coeffs == nullptr)\n        return E_OUTOFMEMORY;\n\n    if (!m_bRGBConvInit)\n    {\n        m_bRGBConvInit = TRUE;\n        InitRGBConvDispatcher();\n    }\n\n    BOOL bYCgCo = (m_ColorProps.VideoTransferMatrix == 7);\n    int shift = max(bpp - 8, 0);\n    ASSERT(shift >= 0 && shift <= 8);\n\n    int outFmt = -1;\n    switch (outputFormat)\n    {\n    case LAVOutPixFmt_RGB24: outFmt = 0; break;\n    case LAVOutPixFmt_RGB32: outFmt = 1; break;\n    default: ASSERT(0);\n    }\n\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers =\n        (ditherMode == LAVDither_Random) ? GetRandomDitherCoeffs(height, DITHER_STEPS * 3, 4, 0) : nullptr;\n    if (ditherMode == LAVDither_Random && dithers == nullptr)\n    {\n        ditherMode = LAVDither_Ordered;\n    }\n\n    // Map the bX formats to their normal counter part, the shift parameter controls this now\n    if (inputFormat == LAVPixFmt_YUV420bX || inputFormat == LAVPixFmt_YUV422bX || inputFormat == LAVPixFmt_YUV444bX)\n        inputFormat = (LAVPixelFormat)(inputFormat - 1);\n\n    // P010 has the data in the high bits, so set shift appropriately\n    if (inputFormat == LAVPixFmt_P016)\n        shift = 8;\n\n    YUVRGBConversionFunc convFn = m_RGBConvFuncs[outFmt][ditherMode][bYCgCo][inputFormat][shift];\n    if (convFn == nullptr)\n    {\n        ASSERT(0);\n        return E_FAIL;\n    }\n\n    // run conversion, threaded\n    if (m_NumThreads <= 1)\n    {\n        convFn(src[0], src[1], src[2], dst[0], width, height, srcStride[0], srcStride[1], dstStride[0], 0, height,\n               coeffs, dithers);\n    }\n    else\n    {\n        const int is_odd =\n            (inputFormat == LAVPixFmt_YUV420 || inputFormat == LAVPixFmt_NV12 || inputFormat == LAVPixFmt_P016);\n        const ptrdiff_t lines_per_thread = (height / m_NumThreads) & ~1;\n\n        Concurrency::parallel_for(0, m_NumThreads, [&](int i) {\n            const ptrdiff_t starty = (i * lines_per_thread);\n            const ptrdiff_t endy = (i == (m_NumThreads - 1)) ? height : starty + lines_per_thread + is_odd;\n            convFn(src[0], src[1], src[2], dst[0], width, height, srcStride[0], srcStride[1], dstStride[0],\n                   starty + (i ? is_odd : 0), endy, coeffs, dithers);\n        });\n    }\n\n    return S_OK;\n}\n\n#define CONV_FUNC_INT2(out32, dither, ycgco, format, shift) \\\n    m_RGBConvFuncs[out32][dither][ycgco][format][shift] = yuv2rgb_convert<format, shift, out32, dither, ycgco>;\n\n#define CONV_FUNC_INT(dither, ycgco, format, shift) \\\n    CONV_FUNC_INT2(0, dither, ycgco, format, shift) \\\n    CONV_FUNC_INT2(1, dither, ycgco, format, shift)\n\n#define CONV_FUNC(format, shift)                       \\\n    CONV_FUNC_INT(LAVDither_Ordered, 0, format, shift) \\\n    CONV_FUNC_INT(LAVDither_Random, 0, format, shift)  \\\n    CONV_FUNC_INT(LAVDither_Ordered, 1, format, shift) \\\n    CONV_FUNC_INT(LAVDither_Random, 1, format, shift)\n\n#define CONV_FUNCX(format)     \\\n    CONV_FUNC(format, 0)       \\\n    CONV_FUNC(format, 1)       \\\n    CONV_FUNC(format, 2)       \\\n    /* CONV_FUNC(format, 3) */ \\\n    CONV_FUNC(format, 4)       \\\n    /* CONV_FUNC(format, 5) */ \\\n    CONV_FUNC(format, 6)       \\\n    /* CONV_FUNC(format, 7) */ \\\n    CONV_FUNC(format, 8)\n\nvoid CLAVPixFmtConverter::InitRGBConvDispatcher()\n{\n    ZeroMemory(&m_RGBConvFuncs, sizeof(m_RGBConvFuncs));\n\n    CONV_FUNC(LAVPixFmt_NV12, 0);\n    CONV_FUNC(LAVPixFmt_P016, 8);\n\n    CONV_FUNCX(LAVPixFmt_YUV420);\n    CONV_FUNCX(LAVPixFmt_YUV422);\n    CONV_FUNCX(LAVPixFmt_YUV444);\n}\n\nconst RGBCoeffs *CLAVPixFmtConverter::getRGBCoeffs(int width, int height)\n{\n    if (!m_rgbCoeffs || width != swsWidth || height != swsHeight)\n    {\n        swsWidth = width;\n        swsHeight = height;\n\n        if (!m_rgbCoeffs)\n        {\n            m_rgbCoeffs = (RGBCoeffs *)_aligned_malloc(sizeof(RGBCoeffs), 16);\n            if (m_rgbCoeffs == nullptr)\n                return nullptr;\n        }\n\n        DXVA2_VideoTransferMatrix matrix = (DXVA2_VideoTransferMatrix)m_ColorProps.VideoTransferMatrix;\n        if (matrix == DXVA2_VideoTransferMatrix_Unknown)\n        {\n            matrix = (swsHeight > 576 || swsWidth > 1024) ? DXVA2_VideoTransferMatrix_BT709\n                                                          : DXVA2_VideoTransferMatrix_BT601;\n        }\n\n        BOOL inFullRange = (m_ColorProps.NominalRange == DXVA2_NominalRange_0_255);\n        BOOL outFullRange = (swsOutputRange == 0) ? inFullRange : (swsOutputRange == 2);\n\n        int inputWhite, inputBlack, inputChroma, outputWhite, outputBlack;\n        if (inFullRange)\n        {\n            inputWhite = 255;\n            inputBlack = 0;\n            inputChroma = 1;\n        }\n        else\n        {\n            inputWhite = 235;\n            inputBlack = 16;\n            inputChroma = 16;\n        }\n\n        if (outFullRange)\n        {\n            outputWhite = 255;\n            outputBlack = 0;\n        }\n        else\n        {\n            outputWhite = 235;\n            outputBlack = 16;\n        }\n\n        double Kr, Kg, Kb;\n        switch (matrix)\n        {\n        case DXVA2_VideoTransferMatrix_BT601:\n            Kr = 0.299;\n            Kg = 0.587;\n            Kb = 0.114;\n            break;\n        case DXVA2_VideoTransferMatrix_SMPTE240M:\n            Kr = 0.2120;\n            Kg = 0.7010;\n            Kb = 0.0870;\n            break;\n        case 6: // FCC\n            Kr = 0.300;\n            Kg = 0.590;\n            Kb = 0.110;\n            break;\n        case 4: // BT.2020\n            Kr = 0.2627;\n            Kg = 0.6780;\n            Kb = 0.0593;\n            break;\n        default: DbgLog((LOG_TRACE, 10, L\"::getRGBCoeffs(): Unknown color space: %d - defaulting to BT709\", matrix));\n        case DXVA2_VideoTransferMatrix_BT709:\n            Kr = 0.2126;\n            Kg = 0.7152;\n            Kb = 0.0722;\n            break;\n        }\n\n        double in_y_range = inputWhite - inputBlack;\n        double chr_range = 128 - inputChroma;\n\n        double cspOptionsRGBrange = outputWhite - outputBlack;\n\n        double y_mul, vr_mul, ug_mul, vg_mul, ub_mul;\n        y_mul = cspOptionsRGBrange / in_y_range;\n        vr_mul = (cspOptionsRGBrange / chr_range) * (1.0 - Kr);\n        ug_mul = (cspOptionsRGBrange / chr_range) * (1.0 - Kb) * Kb / Kg;\n        vg_mul = (cspOptionsRGBrange / chr_range) * (1.0 - Kr) * Kr / Kg;\n        ub_mul = (cspOptionsRGBrange / chr_range) * (1.0 - Kb);\n        short sub = min(outputBlack, inputBlack);\n        short Ysub = inputBlack - sub;\n        short RGB_add1 = outputBlack - sub;\n\n        short cy = short(y_mul * 16384 + 0.5);\n        short crv = short(vr_mul * 8192 + 0.5);\n        short cgu = short(-ug_mul * 8192 - 0.5);\n        short cgv = short(-vg_mul * 8192 - 0.5);\n        short cbu = short(ub_mul * 8192 + 0.5);\n\n        m_rgbCoeffs->Ysub = _mm_set1_epi16(Ysub << 6);\n        m_rgbCoeffs->cy = _mm_set1_epi16(cy);\n        m_rgbCoeffs->CbCr_center = _mm_set1_epi16(128 << 4);\n\n        m_rgbCoeffs->cR_Cr = _mm_set1_epi32(crv << 16);               // R\n        m_rgbCoeffs->cG_Cb_cG_Cr = _mm_set1_epi32((cgv << 16) + cgu); // G\n        m_rgbCoeffs->cB_Cb = _mm_set1_epi32(cbu);                     // B\n\n        m_rgbCoeffs->rgb_add = _mm_set1_epi16(RGB_add1 << 4);\n\n        // YCgCo\n        if (matrix == 7)\n        {\n            m_rgbCoeffs->CbCr_center = _mm_set1_epi16(0x0800);\n            // Other Coeffs are not used in YCgCo\n        }\n    }\n    return m_rgbCoeffs;\n}\n\n#pragma warning(pop)\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/yuv2yuv_unscaled.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <emmintrin.h>\n\n#include \"pixconv_internal.h\"\n#include \"pixconv_sse2_templates.h\"\n\ntemplate <int nv12> DECLARE_CONV_FUNC_IMPL(convert_yuv_yv_nv12_dither_le)\n{\n    const ptrdiff_t inYStride = srcStride[0];\n    const ptrdiff_t inUVStride = srcStride[1];\n\n    const ptrdiff_t outYStride = dstStride[0];\n    const ptrdiff_t outUVStride = dstStride[1];\n\n    ptrdiff_t chromaWidth = width;\n    ptrdiff_t chromaHeight = height;\n\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers = GetRandomDitherCoeffs(height, 4, 8, 0);\n    if (dithers == nullptr)\n        ditherMode = LAVDither_Ordered;\n\n    if (inputFormat == LAVPixFmt_YUV420bX)\n        chromaHeight = chromaHeight >> 1;\n    if (inputFormat == LAVPixFmt_YUV420bX || inputFormat == LAVPixFmt_YUV422bX)\n        chromaWidth = (chromaWidth + 1) >> 1;\n\n    ptrdiff_t line, i;\n\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n\n    _mm_sfence();\n\n    // Process Y\n    for (line = 0; line < height; ++line)\n    {\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm4 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 0));\n            xmm5 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 8));\n            xmm6 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 16));\n            xmm7 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 24));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm7, line, 8, dithers);\n            xmm4 = xmm5 = xmm6 = xmm7;\n        }\n\n        const uint16_t *const y = (const uint16_t *)(src[0] + line * inYStride);\n        uint16_t *const dy = (uint16_t *)(dst[0] + line * outYStride);\n\n        for (i = 0; i < width; i += 32)\n        {\n            // Load pixels into registers, and apply dithering\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm0, xmm4, (y + i + 0), bpp);  /* Y0Y0Y0Y0 */\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm1, xmm5, (y + i + 8), bpp);  /* Y0Y0Y0Y0 */\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm2, xmm6, (y + i + 16), bpp); /* Y0Y0Y0Y0 */\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm3, xmm7, (y + i + 24), bpp); /* Y0Y0Y0Y0 */\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);                        /* YYYYYYYY */\n            xmm2 = _mm_packus_epi16(xmm2, xmm3);                        /* YYYYYYYY */\n\n            // Write data back\n            PIXCONV_PUT_STREAM(dy + (i >> 1) + 0, xmm0);\n            PIXCONV_PUT_STREAM(dy + (i >> 1) + 8, xmm2);\n        }\n\n        // Process U/V for chromaHeight lines\n        if (line < chromaHeight)\n        {\n            const uint16_t *const u = (const uint16_t *)(src[1] + line * inUVStride);\n            const uint16_t *const v = (const uint16_t *)(src[2] + line * inUVStride);\n\n            uint8_t *const duv = (uint8_t *)(dst[1] + line * outUVStride);\n            uint8_t *const du = (uint8_t *)(dst[2] + line * outUVStride);\n            uint8_t *const dv = (uint8_t *)(dst[1] + line * outUVStride);\n\n            for (i = 0; i < chromaWidth; i += 16)\n            {\n                PIXCONV_LOAD_PIXEL16_DITHER(xmm0, xmm4, (u + i + 0), bpp); /* U0U0U0U0 */\n                PIXCONV_LOAD_PIXEL16_DITHER(xmm1, xmm5, (u + i + 8), bpp); /* U0U0U0U0 */\n                PIXCONV_LOAD_PIXEL16_DITHER(xmm2, xmm6, (v + i + 0), bpp); /* V0V0V0V0 */\n                PIXCONV_LOAD_PIXEL16_DITHER(xmm3, xmm7, (v + i + 8), bpp); /* V0V0V0V0 */\n\n                xmm0 = _mm_packus_epi16(xmm0, xmm1); /* UUUUUUUU */\n                xmm2 = _mm_packus_epi16(xmm2, xmm3); /* VVVVVVVV */\n                if (nv12)\n                {\n                    xmm1 = xmm0;\n                    xmm0 = _mm_unpacklo_epi8(xmm0, xmm2);\n                    xmm1 = _mm_unpackhi_epi8(xmm1, xmm2);\n\n                    PIXCONV_PUT_STREAM(duv + (i << 1) + 0, xmm0);\n                    PIXCONV_PUT_STREAM(duv + (i << 1) + 16, xmm1);\n                }\n                else\n                {\n                    PIXCONV_PUT_STREAM(du + i, xmm0);\n                    PIXCONV_PUT_STREAM(dv + i, xmm2);\n                }\n            }\n        }\n    }\n\n    return S_OK;\n}\n\n// Force creation of these two variants\ntemplate HRESULT CLAVPixFmtConverter::convert_yuv_yv_nv12_dither_le<0> CONV_FUNC_PARAMS;\ntemplate HRESULT CLAVPixFmtConverter::convert_yuv_yv_nv12_dither_le<1> CONV_FUNC_PARAMS;\n\nDECLARE_CONV_FUNC_IMPL(convert_yuv420_px1x_le)\n{\n    const ptrdiff_t inYStride = srcStride[0];\n    const ptrdiff_t inUVStride = srcStride[1];\n    const ptrdiff_t outYStride = dstStride[0];\n    const ptrdiff_t outUVStride = dstStride[1];\n    const ptrdiff_t uvHeight =\n        (outputFormat == LAVOutPixFmt_P010 || outputFormat == LAVOutPixFmt_P016) ? (height >> 1) : height;\n    const ptrdiff_t uvWidth = (width + 1) >> 1;\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2;\n\n    _mm_sfence();\n\n    // Process Y\n    for (line = 0; line < height; ++line)\n    {\n        const uint16_t *const y = (const uint16_t *)(src[0] + line * inYStride);\n        uint16_t *const d = (uint16_t *)(dst[0] + line * outYStride);\n\n        for (i = 0; i < width; i += 16)\n        {\n            // Load 2x8 pixels into registers\n            PIXCONV_LOAD_PIXEL16X2(xmm0, xmm1, (y + i + 0), (y + i + 8), bpp);\n            // and write them out\n            PIXCONV_PUT_STREAM(d + i + 0, xmm0);\n            PIXCONV_PUT_STREAM(d + i + 8, xmm1);\n        }\n    }\n\n    // Process UV\n    for (line = 0; line < uvHeight; ++line)\n    {\n        const uint16_t *const u = (const uint16_t *)(src[1] + line * inUVStride);\n        const uint16_t *const v = (const uint16_t *)(src[2] + line * inUVStride);\n        uint16_t *const d = (uint16_t *)(dst[1] + line * outUVStride);\n\n        for (i = 0; i < uvWidth; i += 8)\n        {\n            // Load 8 pixels into register\n            PIXCONV_LOAD_PIXEL16X2(xmm0, xmm1, (v + i), (u + i), bpp); // Load V and U\n\n            xmm2 = xmm0;\n            xmm0 = _mm_unpacklo_epi16(xmm1, xmm0); /* UVUV */\n            xmm2 = _mm_unpackhi_epi16(xmm1, xmm2); /* UVUV */\n\n            PIXCONV_PUT_STREAM(d + (i << 1) + 0, xmm0);\n            PIXCONV_PUT_STREAM(d + (i << 1) + 8, xmm2);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_yuv_yv)\n{\n    const uint8_t *y = src[0];\n    const uint8_t *u = src[1];\n    const uint8_t *v = src[2];\n\n    const ptrdiff_t inLumaStride = srcStride[0];\n    const ptrdiff_t inChromaStride = srcStride[1];\n\n    const ptrdiff_t outLumaStride = dstStride[0];\n    const ptrdiff_t outChromaStride = dstStride[1];\n\n    ptrdiff_t line;\n    ptrdiff_t chromaWidth = width;\n    ptrdiff_t chromaHeight = height;\n\n    if (inputFormat == LAVPixFmt_YUV420)\n        chromaHeight = chromaHeight >> 1;\n    if (inputFormat == LAVPixFmt_YUV420 || inputFormat == LAVPixFmt_YUV422)\n        chromaWidth = (chromaWidth + 1) >> 1;\n\n    // Copy planes\n\n    _mm_sfence();\n\n    // Y\n    if ((outLumaStride % 16) == 0 && ((intptr_t)dst[0] % 16u) == 0)\n    {\n        for (line = 0; line < height; ++line)\n        {\n            PIXCONV_MEMCPY_ALIGNED(dst[0] + outLumaStride * line, y + inLumaStride * line, width);\n        }\n    }\n    else\n    {\n        for (line = 0; line < height; ++line)\n        {\n            memcpy(dst[0] + outLumaStride * line, y + inLumaStride * line, width);\n        }\n    }\n\n    // U/V\n    if ((outChromaStride % 16) == 0 && ((intptr_t)dst[1] % 16u) == 0)\n    {\n        for (line = 0; line < chromaHeight; ++line)\n        {\n            PIXCONV_MEMCPY_ALIGNED_TWO(dst[2] + outChromaStride * line, u + inChromaStride * line,\n                                       dst[1] + outChromaStride * line, v + inChromaStride * line, chromaWidth);\n        }\n    }\n    else\n    {\n        for (line = 0; line < chromaHeight; ++line)\n        {\n            memcpy(dst[2] + outChromaStride * line, u + inChromaStride * line, chromaWidth);\n            memcpy(dst[1] + outChromaStride * line, v + inChromaStride * line, chromaWidth);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_yuv420_nv12)\n{\n    const ptrdiff_t inLumaStride = srcStride[0];\n    const ptrdiff_t inChromaStride = srcStride[1];\n\n    const ptrdiff_t outLumaStride = dstStride[0];\n    const ptrdiff_t outChromaStride = dstStride[1];\n\n    const ptrdiff_t chromaWidth = (width + 1) >> 1;\n    const ptrdiff_t chromaHeight = height >> 1;\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4;\n\n    _mm_sfence();\n\n    // Y\n    for (line = 0; line < height; ++line)\n    {\n        PIXCONV_MEMCPY_ALIGNED(dst[0] + outLumaStride * line, src[0] + inLumaStride * line, width);\n    }\n\n    // U/V\n    for (line = 0; line < chromaHeight; ++line)\n    {\n        const uint8_t *const u = src[1] + line * inChromaStride;\n        const uint8_t *const v = src[2] + line * inChromaStride;\n        uint8_t *const d = dst[1] + line * outChromaStride;\n\n        for (i = 0; i < (chromaWidth - 31); i += 32)\n        {\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm0, v + i);\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm1, u + i);\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm2, v + i + 16);\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm3, u + i + 16);\n\n            xmm4 = xmm0;\n            xmm0 = _mm_unpacklo_epi8(xmm1, xmm0);\n            xmm4 = _mm_unpackhi_epi8(xmm1, xmm4);\n\n            xmm1 = xmm2;\n            xmm2 = _mm_unpacklo_epi8(xmm3, xmm2);\n            xmm1 = _mm_unpackhi_epi8(xmm3, xmm1);\n\n            PIXCONV_PUT_STREAM(d + (i << 1) + 0, xmm0);\n            PIXCONV_PUT_STREAM(d + (i << 1) + 16, xmm4);\n            PIXCONV_PUT_STREAM(d + (i << 1) + 32, xmm2);\n            PIXCONV_PUT_STREAM(d + (i << 1) + 48, xmm1);\n        }\n        for (; i < chromaWidth; i += 16)\n        {\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm0, v + i);\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm1, u + i);\n\n            xmm2 = xmm0;\n            xmm0 = _mm_unpacklo_epi8(xmm1, xmm0);\n            xmm2 = _mm_unpackhi_epi8(xmm1, xmm2);\n\n            PIXCONV_PUT_STREAM(d + (i << 1) + 0, xmm0);\n            PIXCONV_PUT_STREAM(d + (i << 1) + 16, xmm2);\n        }\n    }\n\n    return S_OK;\n}\n\ntemplate <int uyvy> DECLARE_CONV_FUNC_IMPL(convert_yuv422_yuy2_uyvy)\n{\n    const ptrdiff_t inLumaStride = srcStride[0];\n    const ptrdiff_t inChromaStride = srcStride[1];\n\n    const ptrdiff_t outStride = dstStride[0];\n\n    const ptrdiff_t chromaWidth = (width + 1) >> 1;\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5;\n\n    _mm_sfence();\n\n    for (line = 0; line < height; ++line)\n    {\n        const uint8_t *const y = src[0] + line * inLumaStride;\n        const uint8_t *const u = src[1] + line * inChromaStride;\n        const uint8_t *const v = src[2] + line * inChromaStride;\n        uint8_t *const d = dst[0] + line * outStride;\n\n        for (i = 0; i < chromaWidth; i += 16)\n        {\n            // Load pixels\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm0, (y + (i << 1) + 0));  /* YYYY */\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm1, (y + (i << 1) + 16)); /* YYYY */\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm2, (u + i));             /* UUUU */\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm3, (v + i));             /* VVVV */\n\n            // Interleave Us and Vs\n            xmm4 = xmm2;\n            xmm4 = _mm_unpacklo_epi8(xmm4, xmm3);\n            xmm2 = _mm_unpackhi_epi8(xmm2, xmm3);\n\n            // Interlave those with the Ys\n            if (uyvy)\n            {\n                xmm3 = xmm4;\n                xmm3 = _mm_unpacklo_epi8(xmm3, xmm0);\n                xmm4 = _mm_unpackhi_epi8(xmm4, xmm0);\n\n                xmm5 = xmm2;\n                xmm5 = _mm_unpacklo_epi8(xmm5, xmm1);\n                xmm2 = _mm_unpackhi_epi8(xmm2, xmm1);\n            }\n            else\n            {\n                xmm3 = xmm0;\n                xmm3 = _mm_unpacklo_epi8(xmm3, xmm4);\n                xmm4 = _mm_unpackhi_epi8(xmm0, xmm4);\n\n                xmm5 = xmm1;\n                xmm5 = _mm_unpacklo_epi8(xmm5, xmm2);\n                xmm2 = _mm_unpackhi_epi8(xmm1, xmm2);\n            }\n\n            PIXCONV_PUT_STREAM(d + (i << 2) + 0, xmm3);\n            PIXCONV_PUT_STREAM(d + (i << 2) + 16, xmm4);\n            PIXCONV_PUT_STREAM(d + (i << 2) + 32, xmm5);\n            PIXCONV_PUT_STREAM(d + (i << 2) + 48, xmm2);\n        }\n    }\n\n    return S_OK;\n}\n\n// Force creation of these two variants\ntemplate HRESULT CLAVPixFmtConverter::convert_yuv422_yuy2_uyvy<0> CONV_FUNC_PARAMS;\ntemplate HRESULT CLAVPixFmtConverter::convert_yuv422_yuy2_uyvy<1> CONV_FUNC_PARAMS;\n\ntemplate <int uyvy> DECLARE_CONV_FUNC_IMPL(convert_yuv422_yuy2_uyvy_dither_le)\n{\n    const ptrdiff_t inLumaStride = srcStride[0];\n    const ptrdiff_t inChromaStride = srcStride[1];\n    const ptrdiff_t outStride = dstStride[0];\n    const ptrdiff_t chromaWidth = (width + 1) >> 1;\n\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers = GetRandomDitherCoeffs(height, 4, 8, 0);\n    if (dithers == nullptr)\n        ditherMode = LAVDither_Ordered;\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n\n    _mm_sfence();\n\n    for (line = 0; line < height; ++line)\n    {\n        const uint16_t *const y = (const uint16_t *)(src[0] + line * inLumaStride);\n        const uint16_t *const u = (const uint16_t *)(src[1] + line * inChromaStride);\n        const uint16_t *const v = (const uint16_t *)(src[2] + line * inChromaStride);\n        uint16_t *const d = (uint16_t *)(dst[0] + line * outStride);\n\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm4 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 0));\n            xmm5 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 8));\n            xmm6 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 16));\n            xmm7 = _mm_load_si128((const __m128i *)(dithers + (line << 5) + 24));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm7, line, 8, dithers);\n            xmm4 = xmm5 = xmm6 = xmm7;\n        }\n\n        for (i = 0; i < chromaWidth; i += 8)\n        {\n            // Load pixels\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm0, xmm4, (y + (i * 2) + 0), bpp); /* YYYY */\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm1, xmm5, (y + (i * 2) + 8), bpp); /* YYYY */\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm2, xmm6, (u + i), bpp);           /* UUUU */\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm3, xmm7, (v + i), bpp);           /* VVVV */\n\n            // Pack Ys\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);\n\n            // Interleave Us and Vs\n            xmm2 = _mm_packus_epi16(xmm2, xmm2);\n            xmm3 = _mm_packus_epi16(xmm3, xmm3);\n            xmm2 = _mm_unpacklo_epi8(xmm2, xmm3);\n\n            // Interlave those with the Ys\n            if (uyvy)\n            {\n                xmm3 = xmm2;\n                xmm3 = _mm_unpacklo_epi8(xmm3, xmm0);\n                xmm2 = _mm_unpackhi_epi8(xmm2, xmm0);\n            }\n            else\n            {\n                xmm3 = xmm0;\n                xmm3 = _mm_unpacklo_epi8(xmm3, xmm2);\n                xmm2 = _mm_unpackhi_epi8(xmm0, xmm2);\n            }\n\n            PIXCONV_PUT_STREAM(d + (i << 1) + 0, xmm3);\n            PIXCONV_PUT_STREAM(d + (i << 1) + 8, xmm2);\n        }\n    }\n\n    return S_OK;\n}\n\n// Force creation of these two variants\ntemplate HRESULT CLAVPixFmtConverter::convert_yuv422_yuy2_uyvy_dither_le<0> CONV_FUNC_PARAMS;\ntemplate HRESULT CLAVPixFmtConverter::convert_yuv422_yuy2_uyvy_dither_le<1> CONV_FUNC_PARAMS;\n\nDECLARE_CONV_FUNC_IMPL(convert_nv12_yv12)\n{\n    const ptrdiff_t inLumaStride = srcStride[0];\n    const ptrdiff_t inChromaStride = srcStride[1];\n    const ptrdiff_t outLumaStride = dstStride[0];\n    const ptrdiff_t outChromaStride = dstStride[1];\n    const ptrdiff_t chromaHeight = height >> 1;\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm7;\n\n    xmm7 = _mm_set1_epi16(0x00FF);\n\n    _mm_sfence();\n\n    // Copy the y\n    for (line = 0; line < height; line++)\n    {\n        PIXCONV_MEMCPY_ALIGNED(dst[0] + outLumaStride * line, src[0] + inLumaStride * line, width);\n    }\n\n    for (line = 0; line < chromaHeight; line++)\n    {\n        const uint8_t *const uv = src[1] + line * inChromaStride;\n        uint8_t *const dv = dst[1] + outChromaStride * line;\n        uint8_t *const du = dst[2] + outChromaStride * line;\n\n        for (i = 0; i < width; i += 32)\n        {\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm0, uv + i + 0);\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm1, uv + i + 16);\n            xmm2 = xmm0;\n            xmm3 = xmm1;\n\n            // null out the high-order bytes to get the U values\n            xmm0 = _mm_and_si128(xmm0, xmm7);\n            xmm1 = _mm_and_si128(xmm1, xmm7);\n            // right shift the V values\n            xmm2 = _mm_srli_epi16(xmm2, 8);\n            xmm3 = _mm_srli_epi16(xmm3, 8);\n            // unpack the values\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);\n            xmm2 = _mm_packus_epi16(xmm2, xmm3);\n\n            PIXCONV_PUT_STREAM(du + (i >> 1), xmm0);\n            PIXCONV_PUT_STREAM(dv + (i >> 1), xmm2);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_p010_nv12_sse2)\n{\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n    const ptrdiff_t chromaHeight = (height >> 1);\n\n    const ptrdiff_t byteWidth = width << 1;\n\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers = GetRandomDitherCoeffs(height, 2, 8, 0);\n    if (dithers == nullptr)\n        ditherMode = LAVDither_Ordered;\n\n    __m128i xmm0, xmm1, xmm2, xmm3;\n\n    _mm_sfence();\n\n    ptrdiff_t line, i;\n\n    for (line = 0; line < height; line++)\n    {\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm2 = _mm_load_si128((const __m128i *)(dithers + (line << 4) + 0));\n            xmm3 = _mm_load_si128((const __m128i *)(dithers + (line << 4) + 8));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm2, line, 8, dithers);\n            xmm3 = xmm2;\n        }\n\n        const uint8_t *y = (src[0] + line * inStride);\n        uint8_t *dy = (dst[0] + line * outStride);\n\n        for (i = 0; i < byteWidth; i += 32)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, y + i + 0);\n            PIXCONV_LOAD_ALIGNED(xmm1, y + i + 16);\n\n            // apply dithering coeffs\n            xmm0 = _mm_adds_epu16(xmm0, xmm2);\n            xmm1 = _mm_adds_epu16(xmm1, xmm3);\n\n            // shift and pack to 8-bit\n            xmm0 = _mm_packus_epi16(_mm_srli_epi16(xmm0, 8), _mm_srli_epi16(xmm1, 8));\n\n            PIXCONV_PUT_STREAM(dy + (i >> 1), xmm0);\n        }\n    }\n\n    for (line = 0; line < chromaHeight; line++)\n    {\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm2 = _mm_load_si128((const __m128i *)(dithers + (line << 4) + 0));\n            xmm3 = _mm_load_si128((const __m128i *)(dithers + (line << 4) + 8));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm2, line, 8, dithers);\n            xmm3 = xmm2;\n        }\n\n        const uint8_t *uv = (src[1] + line * inStride);\n        uint8_t *duv = (dst[1] + line * outStride);\n\n        for (i = 0; i < byteWidth; i += 32)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, uv + i + 0);\n            PIXCONV_LOAD_ALIGNED(xmm1, uv + i + 16);\n\n            // apply dithering coeffs\n            xmm0 = _mm_adds_epu16(xmm0, xmm2);\n            xmm1 = _mm_adds_epu16(xmm1, xmm3);\n\n            // shift and pack to 8-bit\n            xmm0 = _mm_packus_epi16(_mm_srli_epi16(xmm0, 8), _mm_srli_epi16(xmm1, 8));\n\n            PIXCONV_PUT_STREAM(duv + (i >> 1), xmm0);\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_y210_p210_sse4)\n{\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n\n    const ptrdiff_t byteWidth = width << 2;\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n    xmm7 = _mm_set1_epi32(0x0000FFFF);\n\n    for (line = 0; line < height; line++)\n    {\n        const uint8_t *srcLine = src[0] + line * inStride;\n        uint8_t *dstY = dst[0] + line * dstStride[0];\n        uint8_t *dstUV = dst[1] + line * dstStride[1];\n        for (i = 0; i < (byteWidth - 63); i += 64)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, srcLine + i + 0); // Y0 U Y1 V\n            PIXCONV_LOAD_ALIGNED(xmm1, srcLine + i + 16);\n            PIXCONV_LOAD_ALIGNED(xmm2, srcLine + i + 32);\n            PIXCONV_LOAD_ALIGNED(xmm3, srcLine + i + 48);\n\n            // extract Y\n            xmm4 = _mm_and_si128(xmm0, xmm7);\n            xmm5 = _mm_and_si128(xmm1, xmm7);\n            xmm6 = _mm_packus_epi32(xmm4, xmm5);\n\n            xmm4 = _mm_and_si128(xmm2, xmm7);\n            xmm5 = _mm_and_si128(xmm3, xmm7);\n            xmm4 = _mm_packus_epi32(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(dstY + (i >> 1) + 0, xmm6);\n            PIXCONV_PUT_STREAM(dstY + (i >> 1) + 16, xmm4);\n\n            // extract UV\n            xmm4 = _mm_srli_epi32(xmm0, 16);\n            xmm5 = _mm_srli_epi32(xmm1, 16);\n            xmm6 = _mm_packus_epi32(xmm4, xmm5);\n\n            xmm4 = _mm_srli_epi32(xmm2, 16);\n            xmm5 = _mm_srli_epi32(xmm3, 16);\n            xmm4 = _mm_packus_epi32(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(dstUV + (i >> 1) + 0, xmm6);\n            PIXCONV_PUT_STREAM(dstUV + (i >> 1) + 16, xmm4);\n        }\n\n        // process left-over pixel\n        for (; i < (byteWidth - 7); i += 8)\n        {\n            const uint16_t *pixel = (const uint16_t *)(srcLine + i);\n            uint16_t *out_y = (uint16_t *)(dstY + (i >> 1));\n            uint16_t *out_uv = (uint16_t *)(dstUV + (i >> 1));\n\n            out_y [0] = pixel[0];\n            out_uv[0] = pixel[1];\n            out_y [1] = pixel[2];\n            out_uv[1] = pixel[3];\n        }\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_yuy2_yv16_sse2)\n{\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n\n    const ptrdiff_t byteWidth = width << 1;\n\n    ptrdiff_t line, i;\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n    xmm7 = _mm_set1_epi16(0x00FF);\n\n    for (line = 0; line < height; line++)\n    {\n        const uint8_t *srcLine = src[0] + line * inStride;\n        uint8_t *dstY = dst[0] + line * dstStride[0];\n        uint8_t *dstV = dst[1] + line * dstStride[1];\n        uint8_t *dstU = dst[2] + line * dstStride[2];\n        for (i = 0; i < (byteWidth - 63); i += 64)\n        {\n            PIXCONV_LOAD_ALIGNED(xmm0, srcLine + i + 0); // Y0 U Y1 V\n            PIXCONV_LOAD_ALIGNED(xmm1, srcLine + i + 16);\n            PIXCONV_LOAD_ALIGNED(xmm2, srcLine + i + 32);\n            PIXCONV_LOAD_ALIGNED(xmm3, srcLine + i + 48);\n\n            // extract Y\n            xmm4 = _mm_and_si128(xmm0, xmm7);\n            xmm5 = _mm_and_si128(xmm1, xmm7);\n            xmm6 = _mm_packus_epi16(xmm4, xmm5);\n\n            xmm4 = _mm_and_si128(xmm2, xmm7);\n            xmm5 = _mm_and_si128(xmm3, xmm7);\n            xmm4 = _mm_packus_epi16(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(dstY + (i >> 1) + 0, xmm6);\n            PIXCONV_PUT_STREAM(dstY + (i >> 1) + 16, xmm4);\n\n            // extract UV\n            xmm4 = _mm_srli_epi16(xmm0, 8);\n            xmm5 = _mm_srli_epi16(xmm1, 8);\n            xmm0 = _mm_packus_epi16(xmm4, xmm5);\n\n            xmm4 = _mm_srli_epi16(xmm2, 8);\n            xmm5 = _mm_srli_epi16(xmm3, 8);\n            xmm1 = _mm_packus_epi16(xmm4, xmm5);\n\n            // split into U/V\n            xmm4 = _mm_srli_epi16(xmm0, 8);\n            xmm5 = _mm_srli_epi16(xmm1, 8);\n            xmm0 = _mm_and_si128(xmm0, xmm7);\n            xmm1 = _mm_and_si128(xmm1, xmm7);\n            xmm0 = _mm_packus_epi16(xmm0, xmm1);\n            xmm4 = _mm_packus_epi16(xmm4, xmm5);\n\n            PIXCONV_PUT_STREAM(dstU + (i >> 2), xmm0);\n            PIXCONV_PUT_STREAM(dstV + (i >> 2), xmm4);\n        }\n\n        // process left-over pixel\n        for (; i < (byteWidth - 3); i += 4)\n        {\n            const uint8_t *pixel = (const uint8_t *)(srcLine + i);\n            uint8_t *out_y = (uint8_t *)(dstY + (i >> 1));\n            uint8_t *out_u = (uint8_t *)(dstU + (i >> 2));\n            uint8_t *out_v = (uint8_t *)(dstV + (i >> 2));\n\n            out_y[0] = pixel[0];\n            out_u[0] = pixel[1];\n            out_y[1] = pixel[2];\n            out_v[0] = pixel[3];\n        }\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/yuv420_yuy2.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <emmintrin.h>\n#include <ppl.h>\n\n#include \"pixconv_internal.h\"\n#include \"pixconv_sse2_templates.h\"\n\n#define DITHER_STEPS 2\n\n// This function converts 8x2 pixels from the source into 8x2 YUY2 pixels in the destination\ntemplate <LAVPixelFormat inputFormat, int shift, int uyvy, int dithertype>\n__forceinline static int yuv420yuy2_convert_pixels(const uint8_t *&srcY, const uint8_t *&srcU, const uint8_t *&srcV,\n                                                   uint8_t *&dst, ptrdiff_t srcStrideY, ptrdiff_t srcStrideUV,\n                                                   ptrdiff_t dstStride, ptrdiff_t line, const uint16_t *&dithers,\n                                                   ptrdiff_t pos)\n{\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n    xmm7 = _mm_setzero_si128();\n\n    // Shift > 0 is for 9/10 bit formats\n    if (shift > 0)\n    {\n        // Load 4 U/V values from line 0/1 into registers\n        PIXCONV_LOAD_4PIXEL16(xmm1, srcU);\n        PIXCONV_LOAD_4PIXEL16(xmm3, srcU + srcStrideUV);\n        PIXCONV_LOAD_4PIXEL16(xmm0, srcV);\n        PIXCONV_LOAD_4PIXEL16(xmm2, srcV + srcStrideUV);\n\n        // Interleave U and V\n        xmm0 = _mm_unpacklo_epi16(xmm1, xmm0); /* 0V0U0V0U */\n        xmm2 = _mm_unpacklo_epi16(xmm3, xmm2); /* 0V0U0V0U */\n    }\n    else if (inputFormat == LAVPixFmt_NV12)\n    {\n        // Load 4 16-bit macro pixels, which contain 4 UV samples\n        PIXCONV_LOAD_4PIXEL16(xmm0, srcU);\n        PIXCONV_LOAD_4PIXEL16(xmm2, srcU + srcStrideUV);\n\n        // Expand to 16-bit\n        xmm0 = _mm_unpacklo_epi8(xmm0, xmm7); /* 0V0U0V0U */\n        xmm2 = _mm_unpacklo_epi8(xmm2, xmm7); /* 0V0U0V0U */\n    }\n    else\n    {\n        PIXCONV_LOAD_4PIXEL8(xmm1, srcU);\n        PIXCONV_LOAD_4PIXEL8(xmm3, srcU + srcStrideUV);\n        PIXCONV_LOAD_4PIXEL8(xmm0, srcV);\n        PIXCONV_LOAD_4PIXEL8(xmm2, srcV + srcStrideUV);\n\n        // Interleave U and V\n        xmm0 = _mm_unpacklo_epi8(xmm1, xmm0); /* VUVU0000 */\n        xmm2 = _mm_unpacklo_epi8(xmm3, xmm2); /* VUVU0000 */\n\n        // Expand to 16-bit\n        xmm0 = _mm_unpacklo_epi8(xmm0, xmm7); /* 0V0U0V0U */\n        xmm2 = _mm_unpacklo_epi8(xmm2, xmm7); /* 0V0U0V0U */\n    }\n\n    // xmm0/xmm2 contain 4 interleaved U/V samples from two lines each in the 16bit parts, still in their native\n    // bitdepth\n\n    // Chroma upsampling\n    if (shift > 0 || inputFormat == LAVPixFmt_NV12)\n    {\n        srcU += 8;\n        srcV += 8;\n    }\n    else\n    {\n        srcU += 4;\n        srcV += 4;\n    }\n\n    xmm1 = xmm0;\n    xmm1 = _mm_add_epi16(xmm1, xmm0); /* 2x line 0 */\n    xmm1 = _mm_add_epi16(xmm1, xmm0); /* 3x line 0 */\n    xmm1 = _mm_add_epi16(xmm1, xmm2); /* 3x line 0 + line 1 (10bit) */\n\n    xmm3 = xmm2;\n    xmm3 = _mm_add_epi16(xmm3, xmm2); /* 2x line 1 */\n    xmm3 = _mm_add_epi16(xmm3, xmm2); /* 3x line 1 */\n    xmm3 = _mm_add_epi16(xmm3, xmm0); /* 3x line 1 + line 0 (10bit) */\n\n    // After this step, xmm1 and xmm3 contain 8 16-bit values, V and U interleaved. For 4:2:0, filling input+2 bits (10,\n    // 11, 12). Load Y\n    if (shift > 0)\n    {\n        // Load 8 Y values from line 0/1 into registers\n        PIXCONV_LOAD_PIXEL8_ALIGNED(xmm0, srcY);\n        PIXCONV_LOAD_PIXEL8_ALIGNED(xmm5, srcY + srcStrideY);\n\n        srcY += 16;\n    }\n    else\n    {\n        PIXCONV_LOAD_4PIXEL16(xmm0, srcY);\n        PIXCONV_LOAD_4PIXEL16(xmm5, srcY + srcStrideY);\n        srcY += 8;\n\n        xmm0 = _mm_unpacklo_epi8(xmm0, xmm7); /* YYYYYYYY (16-bit fields)*/\n        xmm5 = _mm_unpacklo_epi8(xmm5, xmm7); /* YYYYYYYY (16-bit fields) */\n    }\n\n    // Dither everything to 8-bit\n\n    // Dithering\n    if (dithertype == LAVDither_Random)\n    {\n        /* Load random dithering coeffs from the dithers buffer */\n        int offset = (pos % (DITHER_STEPS * 8 * 2)) * 2;\n        xmm6 = _mm_load_si128((const __m128i *)(dithers + 0 + offset));\n        xmm7 = _mm_load_si128((const __m128i *)(dithers + 8 + offset));\n    }\n    else\n    {\n        PIXCONV_LOAD_DITHER_COEFFS(xmm6, line + 0, shift + 2, odithers);\n        PIXCONV_LOAD_DITHER_COEFFS(xmm7, line + 1, shift + 2, odithers2);\n    }\n\n    // Dither UV\n    xmm1 = _mm_adds_epu16(xmm1, xmm6);\n    xmm3 = _mm_adds_epu16(xmm3, xmm7);\n    xmm1 = _mm_srai_epi16(xmm1, shift + 2);\n    xmm3 = _mm_srai_epi16(xmm3, shift + 2);\n\n    if (shift)\n    {                                   /* Y only needs to be dithered if it was > 8 bit */\n        xmm6 = _mm_srli_epi16(xmm6, 2); /* Shift dithering coeffs to proper strength */\n        xmm7 = _mm_srli_epi16(xmm6, 2);\n\n        xmm0 = _mm_adds_epu16(xmm0, xmm6);  /* Apply dithering coeffs */\n        xmm0 = _mm_srai_epi16(xmm0, shift); /* Shift to 8 bit */\n\n        xmm5 = _mm_adds_epu16(xmm5, xmm7);  /* Apply dithering coeffs */\n        xmm5 = _mm_srai_epi16(xmm5, shift); /* Shift to 8 bit */\n    }\n\n    // Pack into 8-bit containers\n    xmm0 = _mm_packus_epi16(xmm0, xmm5);\n    xmm1 = _mm_packus_epi16(xmm1, xmm3);\n\n    // Interleave U/V with Y\n    if (uyvy)\n    {\n        xmm3 = xmm1;\n        xmm3 = _mm_unpacklo_epi8(xmm3, xmm0);\n        xmm4 = _mm_unpackhi_epi8(xmm1, xmm0);\n    }\n    else\n    {\n        xmm3 = xmm0;\n        xmm3 = _mm_unpacklo_epi8(xmm3, xmm1);\n        xmm4 = _mm_unpackhi_epi8(xmm0, xmm1);\n    }\n\n    // Write back into the target memory\n    _mm_stream_si128((__m128i *)(dst), xmm3);\n    _mm_stream_si128((__m128i *)(dst + dstStride), xmm4);\n\n    dst += 16;\n\n    return 0;\n}\n\ntemplate <LAVPixelFormat inputFormat, int shift, int uyvy, int dithertype>\nstatic int __stdcall yuv420yuy2_process_lines(const uint8_t *srcY, const uint8_t *srcU, const uint8_t *srcV,\n                                              uint8_t *dst, int width, int height, ptrdiff_t srcStrideY,\n                                              ptrdiff_t srcStrideUV, ptrdiff_t dstStride, const uint16_t *dithers)\n{\n    const uint8_t *y = srcY;\n    const uint8_t *u = srcU;\n    const uint8_t *v = srcV;\n    uint8_t *yuy2 = dst;\n\n    // Processing starts at line 1, and ends at height - 1. The first and last line have special handling\n    ptrdiff_t line = 1;\n    const ptrdiff_t lastLine = height - 1;\n\n    const uint16_t *lineDither = dithers;\n\n    _mm_sfence();\n\n    // Process first line\n    // This needs special handling because of the chroma offset of YUV420\n    for (ptrdiff_t i = 0; i < width; i += 8)\n    {\n        yuv420yuy2_convert_pixels<inputFormat, shift, uyvy, dithertype>(y, u, v, yuy2, 0, 0, 0, 0, lineDither, i);\n    }\n\n    for (; line < lastLine; line += 2)\n    {\n        if (dithertype == LAVDither_Random)\n            lineDither = dithers + (line * 16 * DITHER_STEPS);\n\n        y = srcY + line * srcStrideY;\n\n        u = srcU + (line >> 1) * srcStrideUV;\n        v = srcV + (line >> 1) * srcStrideUV;\n\n        yuy2 = dst + line * dstStride;\n\n        for (int i = 0; i < width; i += 8)\n        {\n            yuv420yuy2_convert_pixels<inputFormat, shift, uyvy, dithertype>(y, u, v, yuy2, srcStrideY, srcStrideUV,\n                                                                            dstStride, line, lineDither, i);\n        }\n    }\n\n    // Process last line\n    // This needs special handling because of the chroma offset of YUV420\n    if (dithertype == LAVDither_Random)\n        lineDither = dithers + ((height - 2) * 16 * DITHER_STEPS);\n\n    y = srcY + (height - 1) * srcStrideY;\n    u = srcU + ((height >> 1) - 1) * srcStrideUV;\n    v = srcV + ((height >> 1) - 1) * srcStrideUV;\n    yuy2 = dst + (height - 1) * dstStride;\n\n    for (ptrdiff_t i = 0; i < width; i += 8)\n    {\n        yuv420yuy2_convert_pixels<inputFormat, shift, uyvy, dithertype>(y, u, v, yuy2, 0, 0, 0, line, lineDither, i);\n    }\n    return 0;\n}\n\ntemplate <int uyvy, int dithertype>\nstatic int __stdcall yuv420yuy2_dispatch(LAVPixelFormat inputFormat, int bpp, const uint8_t *srcY, const uint8_t *srcU,\n                                         const uint8_t *srcV, uint8_t *dst, int width, int height, ptrdiff_t srcStrideY,\n                                         ptrdiff_t srcStrideUV, ptrdiff_t dstStride, const uint16_t *dithers)\n{\n    // Wrap the input format into template args\n    switch (inputFormat)\n    {\n    case LAVPixFmt_YUV420:\n        return yuv420yuy2_process_lines<LAVPixFmt_YUV420, 0, uyvy, dithertype>(\n            srcY, srcU, srcV, dst, width, height, srcStrideY, srcStrideUV, dstStride, dithers);\n    case LAVPixFmt_NV12:\n        return yuv420yuy2_process_lines<LAVPixFmt_NV12, 0, uyvy, dithertype>(\n            srcY, srcU, srcV, dst, width, height, srcStrideY, srcStrideUV, dstStride, dithers);\n    case LAVPixFmt_YUV420bX:\n        if (bpp == 9)\n            return yuv420yuy2_process_lines<LAVPixFmt_YUV420, 1, uyvy, dithertype>(\n                srcY, srcU, srcV, dst, width, height, srcStrideY, srcStrideUV, dstStride, dithers);\n        else if (bpp == 10)\n            return yuv420yuy2_process_lines<LAVPixFmt_YUV420, 2, uyvy, dithertype>(\n                srcY, srcU, srcV, dst, width, height, srcStrideY, srcStrideUV, dstStride, dithers);\n        /*else if (bpp == 11)\n          return yuv420yuy2_process_lines<LAVPixFmt_YUV420, 3, uyvy, dithertype>(srcY, srcU, srcV, dst, width, height,\n          srcStrideY, srcStrideUV, dstStride, dithers);*/\n        else if (bpp == 12)\n            return yuv420yuy2_process_lines<LAVPixFmt_YUV420, 4, uyvy, dithertype>(\n                srcY, srcU, srcV, dst, width, height, srcStrideY, srcStrideUV, dstStride, dithers);\n        /*else if (bpp == 13)\n          return yuv420yuy2_process_lines<LAVPixFmt_YUV420, 5, uyvy, dithertype>(srcY, srcU, srcV, dst, width, height,\n          srcStrideY, srcStrideUV, dstStride, dithers);*/\n        else if (bpp == 14)\n            return yuv420yuy2_process_lines<LAVPixFmt_YUV420, 6, uyvy, dithertype>(\n                srcY, srcU, srcV, dst, width, height, srcStrideY, srcStrideUV, dstStride, dithers);\n        else\n            ASSERT(0);\n        break;\n    default: ASSERT(0);\n    }\n    return 0;\n}\n\ntemplate <int uyvy> DECLARE_CONV_FUNC_IMPL(convert_yuv420_yuy2)\n{\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers =\n        (ditherMode == LAVDither_Random) ? GetRandomDitherCoeffs(height, DITHER_STEPS * 2, bpp - 8 + 2, 0) : nullptr;\n    if (ditherMode == LAVDither_Random && dithers != nullptr)\n    {\n        yuv420yuy2_dispatch<uyvy, 1>(inputFormat, bpp, src[0], src[1], src[2], dst[0], width, height, srcStride[0],\n                                     srcStride[1], dstStride[0], dithers);\n    }\n    else\n    {\n        yuv420yuy2_dispatch<uyvy, 0>(inputFormat, bpp, src[0], src[1], src[2], dst[0], width, height, srcStride[0],\n                                     srcStride[1], dstStride[0], nullptr);\n    }\n\n    return S_OK;\n}\n\n// Force creation of these two variants\ntemplate HRESULT CLAVPixFmtConverter::convert_yuv420_yuy2<0> CONV_FUNC_PARAMS;\ntemplate HRESULT CLAVPixFmtConverter::convert_yuv420_yuy2<1> CONV_FUNC_PARAMS;\n"
  },
  {
    "path": "decoder/LAVVideo/pixconv/yuv444_ayuv.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <emmintrin.h>\n\n#include \"pixconv_internal.h\"\n#include \"pixconv_sse2_templates.h\"\n\n#define PIXCONV_INTERLEAVE_AYUV(regY, regU, regV, regA, regOut1, regOut2) \\\n    regY = _mm_unpacklo_epi8(regY, regA);     /* YAYAYAYA */              \\\n    regV = _mm_unpacklo_epi8(regV, regU);     /* VUVUVUVU */              \\\n    regOut1 = _mm_unpacklo_epi16(regV, regY); /* VUYAVUYA */              \\\n    regOut2 = _mm_unpackhi_epi16(regV, regY); /* VUYAVUYA */\n\n#define YUV444_PACK_AYUV(dst) *idst++ = v[i] | (u[i] << 8) | (y[i] << 16) | (0xff << 24);\n\nDECLARE_CONV_FUNC_IMPL(convert_yuv444_ayuv)\n{\n    const uint8_t *y = (const uint8_t *)src[0];\n    const uint8_t *u = (const uint8_t *)src[1];\n    const uint8_t *v = (const uint8_t *)src[2];\n\n    const ptrdiff_t inStride = srcStride[0];\n    const ptrdiff_t outStride = dstStride[0];\n\n    ptrdiff_t line, i;\n\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6;\n\n    xmm6 = _mm_set1_epi32(-1);\n\n    _mm_sfence();\n\n    for (line = 0; line < height; ++line)\n    {\n        __m128i *dst128 = (__m128i *)(dst[0] + line * outStride);\n\n        for (i = 0; i < width; i += 16)\n        {\n            // Load pixels into registers\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm0, (y + i)); /* YYYYYYYY */\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm1, (u + i)); /* UUUUUUUU */\n            PIXCONV_LOAD_PIXEL8_ALIGNED(xmm2, (v + i)); /* VVVVVVVV */\n\n            // Interlave into AYUV\n            xmm4 = xmm0;\n            xmm0 = _mm_unpacklo_epi8(xmm0, xmm6); /* YAYAYAYA */\n            xmm4 = _mm_unpackhi_epi8(xmm4, xmm6); /* YAYAYAYA */\n\n            xmm5 = xmm2;\n            xmm2 = _mm_unpacklo_epi8(xmm2, xmm1); /* VUVUVUVU */\n            xmm5 = _mm_unpackhi_epi8(xmm5, xmm1); /* VUVUVUVU */\n\n            xmm1 = _mm_unpacklo_epi16(xmm2, xmm0); /* VUYAVUYA */\n            xmm2 = _mm_unpackhi_epi16(xmm2, xmm0); /* VUYAVUYA */\n\n            xmm0 = _mm_unpacklo_epi16(xmm5, xmm4); /* VUYAVUYA */\n            xmm3 = _mm_unpackhi_epi16(xmm5, xmm4); /* VUYAVUYA */\n\n            // Write data back\n            _mm_stream_si128(dst128++, xmm1);\n            _mm_stream_si128(dst128++, xmm2);\n            _mm_stream_si128(dst128++, xmm0);\n            _mm_stream_si128(dst128++, xmm3);\n        }\n\n        y += inStride;\n        u += inStride;\n        v += inStride;\n    }\n\n    return S_OK;\n}\n\nDECLARE_CONV_FUNC_IMPL(convert_yuv444_ayuv_dither_le)\n{\n    const uint16_t *y = (const uint16_t *)src[0];\n    const uint16_t *u = (const uint16_t *)src[1];\n    const uint16_t *v = (const uint16_t *)src[2];\n\n    const ptrdiff_t inStride = srcStride[0] >> 1;\n    const ptrdiff_t outStride = dstStride[0];\n\n    LAVDitherMode ditherMode = m_pSettings->GetDitherMode();\n    const uint16_t *dithers = GetRandomDitherCoeffs(height, 3, 8, 0);\n    if (dithers == nullptr)\n        ditherMode = LAVDither_Ordered;\n\n    ptrdiff_t line, i;\n\n    __m128i xmm0, xmm1, xmm2, xmm3, xmm4, xmm5, xmm6, xmm7;\n\n    xmm7 = _mm_set1_epi16(-256); /* 0xFF00 - 0A0A0A0A */\n\n    _mm_sfence();\n\n    for (line = 0; line < height; ++line)\n    {\n        // Load dithering coefficients for this line\n        if (ditherMode == LAVDither_Random)\n        {\n            xmm4 = _mm_load_si128((const __m128i *)(dithers + (line * 24) + 0));\n            xmm5 = _mm_load_si128((const __m128i *)(dithers + (line * 24) + 8));\n            xmm6 = _mm_load_si128((const __m128i *)(dithers + (line * 24) + 16));\n        }\n        else\n        {\n            PIXCONV_LOAD_DITHER_COEFFS(xmm6, line, 8, dithers);\n            xmm4 = xmm5 = xmm6;\n        }\n\n        __m128i *dst128 = (__m128i *)(dst[0] + line * outStride);\n\n        for (i = 0; i < width; i += 8)\n        {\n            // Load pixels into registers, and apply dithering\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm0, xmm4, (y + i), bpp);      /* Y0Y0Y0Y0 */\n            PIXCONV_LOAD_PIXEL16_DITHER_HIGH(xmm1, xmm5, (u + i), bpp); /* U0U0U0U0 */\n            PIXCONV_LOAD_PIXEL16_DITHER(xmm2, xmm6, (v + i), bpp);      /* V0V0V0V0 */\n\n            // Interlave into AYUV\n            xmm0 = _mm_or_si128(xmm0, xmm7);  /* YAYAYAYA */\n            xmm1 = _mm_and_si128(xmm1, xmm7); /* clear out clobbered low-bytes */\n            xmm2 = _mm_or_si128(xmm2, xmm1);  /* VUVUVUVU */\n\n            xmm3 = xmm2;\n            xmm2 = _mm_unpacklo_epi16(xmm2, xmm0); /* VUYAVUYA */\n            xmm3 = _mm_unpackhi_epi16(xmm3, xmm0); /* VUYAVUYA */\n\n            // Write data back\n            _mm_stream_si128(dst128++, xmm2);\n            _mm_stream_si128(dst128++, xmm3);\n        }\n\n        y += inStride;\n        u += inStride;\n        v += inStride;\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/resource.h",
    "content": "//{{NO_DEPENDENCIES}}\n// Microsoft Visual C++ generated include file.\n// Used by LAVVideo.rc\n//\n#define IDD_PROPPAGE_VIDEO_SETTINGS     9\n#define IDD_PROPPAGE_FORMATS            10\n#define IDS_SETTINGS                    101\n#define IDS_FORMATS                     102\n#define IDI_ICON1                       103\n#define IDS_FIELDORDER_AUTO             104\n#define IDS_FIELDORDER_TOP              105\n#define IDS_FIELDORDER_BOTTOM           106\n#define IDS_DEINTMODE_AUTO              107\n#define IDS_DEINTMODE_AGGRESSIVE        108\n#define IDS_DEINTMODE_FORCE             109\n#define IDS_DEINTMODE_DISABLE           110\n#define IDC_CODECS                      1001\n#define IDC_LAVVIDEO_FOOTER             1002\n#define IDC_VIDEO_SETTINGS              1003\n#define IDC_STREAMAR                    1004\n#define IDC_THREADS                     1005\n#define IDC_LBL_MULTITHREAD             1006\n#define IDC_OUTPUT_FORMATS              1008\n#define IDC_OUT_YV12                    1009\n#define IDC_OUT_NV12                    1010\n#define IDC_OUT_P010                    1011\n#define IDC_OUT_P016                    1012\n#define IDC_OUT_YUY2                    1013\n#define IDC_OUT_P210                    1014\n#define IDC_OUT_P216                    1015\n#define IDC_OUT_AYUV                    1016\n#define IDC_OUT_Y410                    1017\n#define IDC_OUT_Y416                    1018\n#define IDC_OUT_RGB32                   1019\n#define IDC_OUT_RGB24                   1020\n#define IDC_OUT_420                     1021\n#define IDC_OUT_422                     1022\n#define IDC_OUT_444                     1023\n#define IDC_OUT_RGB                     1024\n#define IDC_OUT_8BIT                    1025\n#define IDC_OUT_10BIT                   1026\n#define IDC_OUT_16BIT                   1027\n#define IDC_OUT_UYVY                    1028\n#define IDC_OUT_RGB48                   1029\n#define IDC_LBL_RGBOUT                  1030\n#define IDC_RGBOUT_AUTO                 1031\n#define IDC_RGBOUT_TV                   1032\n#define IDC_RGBOUT_PC                   1033\n#define IDC_HWACCEL_SETTINGS            1034\n#define IDC_LBL_HWACCEL                 1035\n#define IDC_HWACCEL                     1036\n#define IDC_LBL_HWCODECS                1037\n#define IDC_HWACCEL_H264                1038\n#define IDC_HWACCEL_VC1                 1039\n#define IDC_HWACCEL_MPEG2               1040\n#define IDC_HW_DEINT                    1041\n#define IDC_LBL_HWDEINT_MODE            1046\n#define IDC_HWDEINT_OUT_VIDEO           1047\n#define IDC_HWDEINT_OUT_FILM            1048\n#define IDC_LBL_DEINT_FIELDORDER        1049\n#define IDC_DEINT_FIELDORDER            1050\n#define IDC_LBL_DEINT_MODE              1051\n#define IDC_HWACCEL_AVAIL               1053\n#define IDC_DEINT_SETTINGS              1054\n#define IDC_DEINT_MODE                  1055\n#define IDC_SWDEINT_MODE                1056\n#define IDC_SWDEINT                     1057\n#define IDC_LBL_SWDEINT_MODE            1058\n#define IDC_SWDEINT_OUT_FILM            1059\n#define IDC_SWDEINT_OUT_VIDEO           1060\n#define IDC_OUT_V210                    1062\n#define IDC_OUT_V410                    1063\n#define IDC_HWACCEL_MPEG4               1064\n#define IDC_LBL_FORMATS                 1065\n#define IDC_DITHER_ORDERED              1066\n#define IDC_DITHER_RANDOM               1067\n#define IDC_CODECS_MSWMVDMO             1068\n#define IDC_ACTIVE_DECODER              1069\n#define IDC_OUT_YV24                    1070\n#define IDC_DVD_VIDEO                   1071\n#define IDC_GROUP_HWDEINT               1072\n#define IDC_HWDEINT_ENABLE              1073\n#define IDC_LBL_HWRESOLUTIONS           1074\n#define IDC_HWRES_SD                    1075\n#define IDC_HWRES_HD                    1076\n#define IDC_HWRES_UHD                   1077\n#define IDC_TRAYICON                    1079\n#define IDC_HWACCEL_HEVC                1080\n#define IDC_HWACCEL_VP9                 1081\n#define IDC_LBL_SWDEINT_ALGO            1082\n#define IDC_LBL_HWACCEL_DEVICE          1083\n#define IDC_HWACCEL_DEVICE              1084\n#define IDC_HWACCEL_DEVICE_SELECT       1085\n#define IDC_LBL_HWACCEL_DEVICE_SELECT   1086\n#define IDC_LBL_HWACCEL_DEVICE_HINT     1087\n#define IDC_HWACCEL_CUVID_DXVA          1088\n#define IDC_HWACCEL_H264MVC             1089\n#define IDC_HWACCEL_AV1                 1090\n\n// Next default values for new objects\n// \n#ifdef APSTUDIO_INVOKED\n#ifndef APSTUDIO_READONLY_SYMBOLS\n#define _APS_NEXT_RESOURCE_VALUE        111\n#define _APS_NEXT_COMMAND_VALUE         40001\n#define _APS_NEXT_CONTROL_VALUE         1091\n#define _APS_NEXT_SYMED_VALUE           101\n#endif\n#endif\n"
  },
  {
    "path": "decoder/LAVVideo/stdafx.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n// Pre-compiled header\n#include \"stdafx.h\"\n"
  },
  {
    "path": "decoder/LAVVideo/stdafx.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n// pre-compiled header\n\n#pragma once\n\n// Support for Version 6.0 styles\n#pragma comment( \\\n    linker,      \\\n    \"\\\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\\\"\")\n\n#include \"common_defines.h\"\n\n// include headers\n#include <Windows.h>\n#include <Commctrl.h>\n\n#include <atlbase.h>\n#include <atlconv.h>\n\n#include <d3d9.h>\n#include <dxva2api.h>\n#include <dvdmedia.h>\n\n#pragma warning(push)\n#pragma warning(disable : 4244)\nextern \"C\"\n{\n#define __STDC_CONSTANT_MACROS\n#include \"libavcodec/avcodec.h\"\n#include \"libswscale/swscale.h\"\n#include \"libavfilter/avfilter.h\"\n#include \"libavfilter/buffersink.h\"\n#include \"libavfilter/buffersrc.h\"\n#include \"libavutil/cpu.h\"\n#include \"libavutil/intreadwrite.h\"\n#include \"libavutil/pixdesc.h\"\n#include \"libavutil/opt.h\"\n}\n#pragma warning(pop)\n\n#include \"streams.h\"\n\n#include \"DShowUtil.h\"\n#include \"growarray.h\"\n\n#include \"SubRenderIntf.h\"\n\n#define REF_SECOND_MULT 10000000LL\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/LAVSubtitleConsumer.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVSubtitleConsumer.h\"\n#include \"LAVVideo.h\"\n#include \"Media.h\"\n#include \"version.h\"\n\n#define OFFSET(x) offsetof(LAVSubtitleConsumerContext, x)\n// clang-format off\nstatic const SubRenderOption options[] = {\n  { \"name\",              OFFSET(name),              SROPT_TYPE_STRING, SROPT_FLAG_READONLY },\n  { \"version\",           OFFSET(version),           SROPT_TYPE_STRING, SROPT_FLAG_READONLY },\n  { \"originalVideoSize\", OFFSET(originalVideoSize), SROPT_TYPE_SIZE,   SROPT_FLAG_READONLY },\n  { 0 }\n};\n// clang-format on\n\n#define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)\n\nCLAVSubtitleConsumer::CLAVSubtitleConsumer(CLAVVideo *pLAVVideo)\n    : CSubRenderOptionsImpl(::options, &context)\n    , CUnknown(L\"CLAVSubtitleConsumer\", nullptr)\n    , m_pLAVVideo(pLAVVideo)\n{\n    ZeroMemory(&context, sizeof(context));\n    context.name = TEXT(LAV_VIDEO);\n    context.version = TEXT(LAV_VERSION_STR);\n    m_evFrame.Reset();\n}\n\nCLAVSubtitleConsumer::~CLAVSubtitleConsumer(void)\n{\n    if (m_pProvider)\n    {\n        m_pProvider->Disconnect();\n    }\n    Disconnect();\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    *ppv = nullptr;\n\n    return QI(ISubRenderConsumer) QI(ISubRenderConsumer2) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::Connect(ISubRenderProvider *subtitleRenderer)\n{\n    SafeRelease(&m_pProvider);\n    m_pProvider = subtitleRenderer;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::Disconnect(void)\n{\n    SafeRelease(&m_pProvider);\n    if (m_pSwsContext)\n    {\n        sws_freeContext(m_pSwsContext);\n        m_pSwsContext = nullptr;\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::DeliverFrame(REFERENCE_TIME start, REFERENCE_TIME stop, LPVOID context,\n                                                ISubRenderFrame *subtitleFrame)\n{\n    ASSERT(m_SubtitleFrame == nullptr);\n    if (subtitleFrame)\n        subtitleFrame->AddRef();\n    m_SubtitleFrame = subtitleFrame;\n    m_evFrame.Set();\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::Clear(REFERENCE_TIME clearNewerThan)\n{\n    m_pLAVVideo->RedrawStillImage();\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::RequestFrame(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)\n{\n    CheckPointer(m_pProvider, E_FAIL);\n    return m_pProvider->RequestFrame(rtStart, rtStop, nullptr);\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::ProcessFrame(LAVFrame *pFrame)\n{\n    CheckPointer(m_pProvider, E_FAIL);\n    HRESULT hr = S_OK;\n    LPDIRECT3DSURFACE9 pSurface = nullptr;\n\n    // Wait for the requested frame\n    m_evFrame.Wait();\n\n    if (m_SubtitleFrame != nullptr)\n    {\n        int count = 0;\n        if (FAILED(m_SubtitleFrame->GetBitmapCount(&count)))\n        {\n            count = 0;\n        }\n\n        if (count == 0)\n        {\n            SafeRelease(&m_SubtitleFrame);\n            return S_FALSE;\n        }\n\n        BYTE *data[4] = {0};\n        ptrdiff_t stride[4] = {0};\n        LAVPixelFormat format = pFrame->format;\n        int bpp = pFrame->bpp;\n\n        if (pFrame->format == LAVPixFmt_DXVA2)\n        {\n            SafeRelease(&m_SubtitleFrame);\n            return E_FAIL;\n        }\n        else if (pFrame->format == LAVPixFmt_D3D11)\n        {\n            SafeRelease(&m_SubtitleFrame);\n            return E_FAIL;\n        }\n        else\n        {\n            if (!(pFrame->flags & LAV_FRAME_FLAG_BUFFER_MODIFY))\n            {\n                CopyLAVFrameInPlace(pFrame);\n            }\n            memcpy(&data, &pFrame->data, sizeof(pFrame->data));\n            memcpy(&stride, &pFrame->stride, sizeof(pFrame->stride));\n        }\n\n        RECT videoRect;\n        ::SetRect(&videoRect, 0, 0, pFrame->width, pFrame->height);\n\n        RECT subRect;\n        m_SubtitleFrame->GetOutputRect(&subRect);\n\n        ULONGLONG id;\n        POINT position;\n        SIZE size;\n        const uint8_t *rgbData;\n        int pitch;\n        for (int i = 0; i < count; i++)\n        {\n            if (FAILED(m_SubtitleFrame->GetBitmap(i, &id, &position, &size, (LPCVOID *)&rgbData, &pitch)))\n            {\n                DbgLog((LOG_TRACE, 10, L\"GetBitmap() failed on index %d\", i));\n                break;\n            }\n            ProcessSubtitleBitmap(format, bpp, videoRect, data, stride, subRect, position, size, rgbData, pitch);\n        }\n\n        if (pSurface)\n            pSurface->UnlockRect();\n\n        SafeRelease(&m_SubtitleFrame);\n        return S_OK;\n    }\n\n    return S_FALSE;\n}\n\nstatic struct\n{\n    LAVPixelFormat pixfmt;\n    AVPixelFormat ffpixfmt;\n} lav_ff_subtitle_pixfmt_map[] = {\n    {LAVPixFmt_YUV420, AV_PIX_FMT_YUVA420P}, {LAVPixFmt_YUV420bX, AV_PIX_FMT_YUVA420P},\n    {LAVPixFmt_YUV422, AV_PIX_FMT_YUVA422P}, {LAVPixFmt_YUV422bX, AV_PIX_FMT_YUVA422P},\n    {LAVPixFmt_YUV444, AV_PIX_FMT_YUVA444P}, {LAVPixFmt_YUV444bX, AV_PIX_FMT_YUVA444P},\n    {LAVPixFmt_NV12, AV_PIX_FMT_YUVA420P},   {LAVPixFmt_P016, AV_PIX_FMT_YUVA420P},\n    {LAVPixFmt_YUY2, AV_PIX_FMT_YUVA422P},   {LAVPixFmt_RGB24, AV_PIX_FMT_BGRA},\n    {LAVPixFmt_RGB32, AV_PIX_FMT_BGRA},      {LAVPixFmt_ARGB32, AV_PIX_FMT_BGRA},\n};\n\nstatic LAVPixFmtDesc ff_sub_pixfmt_desc[] = {\n    {1, 4, {1, 2, 2, 1}, {1, 2, 2, 1}}, ///< PIX_FMT_YUVA420P\n    {1, 4, {1, 2, 2, 1}, {1, 1, 1, 1}}, ///< PIX_FMT_YUVA422P\n    {1, 4, {1, 1, 1, 1}, {1, 1, 1, 1}}, ///< PIX_FMT_YUVA444P\n    {4, 1, {1}, {1}},                   ///< PIX_FMT_BGRA\n};\n\nstatic LAVPixFmtDesc getFFSubPixelFormatDesc(AVPixelFormat pixFmt)\n{\n    int index = 0;\n    switch (pixFmt)\n    {\n    case AV_PIX_FMT_YUVA420P: index = 0; break;\n    case AV_PIX_FMT_YUVA422P: index = 1; break;\n    case AV_PIX_FMT_YUVA444P: index = 2; break;\n    case AV_PIX_FMT_BGRA: index = 3; break;\n    default: ASSERT(0);\n    }\n    return ff_sub_pixfmt_desc[index];\n}\n\nstatic AVPixelFormat getFFPixFmtForSubtitle(LAVPixelFormat pixFmt)\n{\n    AVPixelFormat fmt = AV_PIX_FMT_NONE;\n    for (int i = 0; i < countof(lav_ff_subtitle_pixfmt_map); i++)\n    {\n        if (lav_ff_subtitle_pixfmt_map[i].pixfmt == pixFmt)\n        {\n            return lav_ff_subtitle_pixfmt_map[i].ffpixfmt;\n        }\n    }\n    ASSERT(0);\n    return AV_PIX_FMT_NONE;\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::SelectBlendFunction()\n{\n    switch (m_PixFmt)\n    {\n    case LAVPixFmt_RGB32:\n    case LAVPixFmt_RGB24: blend = &CLAVSubtitleConsumer::blend_rgb_c; break;\n    case LAVPixFmt_NV12: blend = &CLAVSubtitleConsumer::blend_yuv_c<uint8_t, 1>; break;\n    case LAVPixFmt_P016: blend = &CLAVSubtitleConsumer::blend_yuv_c<uint16_t, 1>; break;\n    case LAVPixFmt_YUV420:\n    case LAVPixFmt_YUV422:\n    case LAVPixFmt_YUV444: blend = &CLAVSubtitleConsumer::blend_yuv_c<uint8_t, 0>; break;\n    case LAVPixFmt_YUV420bX:\n    case LAVPixFmt_YUV422bX:\n    case LAVPixFmt_YUV444bX: blend = &CLAVSubtitleConsumer::blend_yuv_c<uint16_t, 0>; break;\n    default: DbgLog((LOG_ERROR, 10, L\"ProcessSubtitleBitmap(): No Blend function available\")); blend = nullptr;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleConsumer::ProcessSubtitleBitmap(LAVPixelFormat pixFmt, int bpp, RECT videoRect,\n                                                         BYTE *videoData[4], ptrdiff_t videoStride[4], RECT subRect,\n                                                         POINT subPosition, SIZE subSize, const uint8_t *rgbData,\n                                                         ptrdiff_t pitch)\n{\n    if (subRect.left != 0 || subRect.top != 0)\n    {\n        DbgLog((LOG_ERROR, 10, L\"ProcessSubtitleBitmap(): Left/Top in SubRect non-zero\"));\n    }\n\n    BOOL bNeedScaling = FALSE;\n\n    // We need scaling if the width is not the same, or the subtitle rect is higher then the video rect\n    if (subRect.right != videoRect.right || subRect.bottom > videoRect.bottom)\n    {\n        bNeedScaling = TRUE;\n    }\n\n    if (pixFmt != LAVPixFmt_RGB32 && pixFmt != LAVPixFmt_RGB24)\n    {\n        bNeedScaling = TRUE;\n    }\n\n    if (m_PixFmt != pixFmt)\n    {\n        m_PixFmt = pixFmt;\n        SelectBlendFunction();\n    }\n\n    // P010/P016 is always handled like its 16 bpp to compensate for having the data in the high bits\n    if (pixFmt == LAVPixFmt_P016)\n        bpp = 16;\n\n    BYTE *subData[4] = {nullptr, nullptr, nullptr, nullptr};\n    ptrdiff_t subStride[4] = {0, 0, 0, 0};\n\n    // If we need scaling (either scaling or pixel conversion), do it here before starting the blend process\n    if (bNeedScaling)\n    {\n        uint8_t *tmpBuf = nullptr;\n        const AVPixelFormat avPixFmt = getFFPixFmtForSubtitle(pixFmt);\n\n        // Calculate scaled size\n        // We must ensure that the scaled subs still fit into the video\n\n        // HACK: Scale to video size. In the future, we should take AR and the likes into account\n        RECT newRect = videoRect;\n        /*\n        float subAR = (float)subRect.right / (float)subRect.bottom;\n        if (newRect.right != videoRect.right) {\n          newRect.right = videoRect.right;\n          newRect.bottom = (LONG)(newRect.right / subAR);\n        }\n        if (newRect.bottom > videoRect.bottom) {\n          newRect.bottom = videoRect.bottom;\n          newRect.right = (LONG)(newRect.bottom * subAR);\n        }*/\n\n        SIZE newSize;\n        newSize.cx = (LONG)av_rescale(subSize.cx, newRect.right, subRect.right);\n        newSize.cy = (LONG)av_rescale(subSize.cy, newRect.bottom, subRect.bottom);\n\n        // And scaled position\n        subPosition.x = (LONG)av_rescale(subPosition.x, newSize.cx, subSize.cx);\n        subPosition.y = (LONG)av_rescale(subPosition.y, newSize.cy, subSize.cy);\n\n        m_pSwsContext =\n            sws_getCachedContext(m_pSwsContext, subSize.cx, subSize.cy, AV_PIX_FMT_BGRA, newSize.cx, newSize.cy,\n                                 avPixFmt, SWS_BILINEAR | SWS_FULL_CHR_H_INP, nullptr, nullptr, nullptr);\n\n        const uint8_t *src[4] = {(const uint8_t *)rgbData, nullptr, nullptr, nullptr};\n        const ptrdiff_t srcStride[4] = {pitch, 0, 0, 0};\n\n        const LAVPixFmtDesc desc = getFFSubPixelFormatDesc(avPixFmt);\n        const ptrdiff_t stride = FFALIGN(newSize.cx, 64) * desc.codedbytes;\n\n        for (int plane = 0; plane < desc.planes; plane++)\n        {\n            subStride[plane] = stride / desc.planeWidth[plane];\n            const size_t size = subStride[plane] * FFALIGN(newSize.cy, 2) / desc.planeHeight[plane];\n            subData[plane] = (BYTE *)av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE);\n            if (subData[plane] == nullptr)\n                goto fail;\n        }\n\n        // Un-pre-multiply alpha for YUV formats\n        // TODO: Can we SIMD this? See ARGBUnattenuateRow_C/SSE2 in libyuv\n        if (avPixFmt != AV_PIX_FMT_BGRA)\n        {\n            tmpBuf = (uint8_t *)av_malloc(pitch * subSize.cy);\n            if (tmpBuf == nullptr)\n                goto fail;\n\n            memcpy(tmpBuf, rgbData, pitch * subSize.cy);\n            for (int line = 0; line < subSize.cy; line++)\n            {\n                uint8_t *p = tmpBuf + line * pitch;\n                for (int col = 0; col < subSize.cx; col++)\n                {\n                    if (p[3] != 0 && p[3] != 255)\n                    {\n                        p[0] = av_clip_uint8(p[0] * 255 / p[3]);\n                        p[1] = av_clip_uint8(p[1] * 255 / p[3]);\n                        p[2] = av_clip_uint8(p[2] * 255 / p[3]);\n                    }\n                    p += 4;\n                }\n            }\n            src[0] = tmpBuf;\n        }\n\n        int ret = sws_scale2(m_pSwsContext, src, srcStride, 0, subSize.cy, subData, subStride);\n        subSize = newSize;\n\n        if (tmpBuf)\n            av_free(tmpBuf);\n    }\n    else\n    {\n        subData[0] = (BYTE *)rgbData;\n        subStride[0] = pitch;\n    }\n\n    ASSERT((subPosition.x + subSize.cx) <= videoRect.right);\n    ASSERT((subPosition.y + subSize.cy) <= videoRect.bottom);\n\n    if (blend)\n        (this->*blend)(videoData, videoStride, videoRect, subData, subStride, subPosition, subSize, pixFmt, bpp);\n\n    if (bNeedScaling)\n    {\n        for (int i = 0; i < 4; i++)\n        {\n            av_freep(&subData[i]);\n        }\n    }\n\n    return S_OK;\n\nfail:\n    for (int i = 0; i < 4; i++)\n    {\n        av_freep(&subData[i]);\n    }\n    return E_OUTOFMEMORY;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/LAVSubtitleConsumer.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"SubRenderOptionsImpl.h\"\n#include \"LAVSubtitleFrame.h\"\n\n#include \"../decoders/ILAVDecoder.h\"\n\n#define BLEND_FUNC_PARAMS                                                                                \\\n    (BYTE * video[4], ptrdiff_t videoStride[4], RECT vidRect, BYTE * subData[4], ptrdiff_t subStride[4], \\\n     POINT position, SIZE size, LAVPixelFormat pixFmt, int bpp)\n\n#define DECLARE_BLEND_FUNC(name) HRESULT name BLEND_FUNC_PARAMS\n\n#define DECLARE_BLEND_FUNC_IMPL(name) DECLARE_BLEND_FUNC(CLAVSubtitleConsumer::name)\n\ntypedef struct LAVSubtitleConsumerContext\n{\n    LPWSTR name;            ///< name of the Consumer\n    LPWSTR version;         ///< Version of the Consumer\n    SIZE originalVideoSize; ///< Size of the video\n} LAVSubtitleConsumerContext;\n\nclass CLAVVideo;\n\nclass CLAVSubtitleConsumer\n    : public ISubRenderConsumer2\n    , public CSubRenderOptionsImpl\n    , public CUnknown\n{\n  public:\n    CLAVSubtitleConsumer(CLAVVideo *pLAVVideo);\n    virtual ~CLAVSubtitleConsumer(void);\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    DECLARE_ISUBRENDEROPTIONS;\n\n    // ISubRenderConsumer2\n    STDMETHODIMP GetMerit(ULONG *merit)\n    {\n        CheckPointer(merit, E_POINTER);\n        *merit = 0x00010000;\n        return S_OK;\n    }\n    STDMETHODIMP Connect(ISubRenderProvider *subtitleRenderer);\n    STDMETHODIMP Disconnect(void);\n    STDMETHODIMP DeliverFrame(REFERENCE_TIME start, REFERENCE_TIME stop, LPVOID context,\n                              ISubRenderFrame *subtitleFrame);\n    STDMETHODIMP Clear(REFERENCE_TIME clearNewerThan = 0);\n\n    // LAV Internal methods\n    STDMETHODIMP RequestFrame(REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);\n    STDMETHODIMP ProcessFrame(LAVFrame *pFrame);\n\n    STDMETHODIMP DisconnectProvider()\n    {\n        if (m_pProvider)\n            m_pProvider->Disconnect();\n        SafeRelease(&m_pProvider);\n        return S_OK;\n    }\n\n    BOOL HasProvider() const { return m_pProvider != nullptr; }\n\n    void SetVideoSize(LONG w, LONG h)\n    {\n        context.originalVideoSize.cx = w;\n        context.originalVideoSize.cy = h;\n    }\n\n  private:\n    STDMETHODIMP ProcessSubtitleBitmap(LAVPixelFormat pixFmt, int bpp, RECT videoRect, BYTE *videoData[4],\n                                       ptrdiff_t videoStride[4], RECT subRect, POINT subPosition, SIZE subSize,\n                                       const uint8_t *rgbData, ptrdiff_t pitch);\n\n    STDMETHODIMP SelectBlendFunction();\n    typedef HRESULT(CLAVSubtitleConsumer::*BlendFn) BLEND_FUNC_PARAMS;\n    BlendFn blend = nullptr;\n\n    DECLARE_BLEND_FUNC(blend_rgb_c);\n    template <class pixT, int nv12> DECLARE_BLEND_FUNC(blend_yuv_c);\n\n  private:\n    ISubRenderProvider *m_pProvider = nullptr;\n    ISubRenderFrame *m_SubtitleFrame = nullptr;\n    CAMEvent m_evFrame{FALSE};\n\n    SwsContext *m_pSwsContext = nullptr;\n    LAVPixelFormat m_PixFmt = LAVPixFmt_None;\n\n    LAVSubtitleConsumerContext context;\n\n    CLAVVideo *m_pLAVVideo = nullptr;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/LAVSubtitleFrame.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVSubtitleFrame.h\"\n\nCLAVSubtitleFrame::CLAVSubtitleFrame(void)\n    : CUnknown(L\"CLAVSubtitleFrame\", nullptr)\n{\n    ZeroMemory(&m_outputRect, sizeof(m_outputRect));\n    ZeroMemory(&m_clipRect, sizeof(m_clipRect));\n}\n\nCLAVSubtitleFrame::~CLAVSubtitleFrame(void)\n{\n    for (int i = 0; i < m_NumBitmaps; i++)\n    {\n        m_Bitmaps[i]->Release();\n    }\n    SAFE_CO_FREE(m_Bitmaps);\n}\n\nSTDMETHODIMP CLAVSubtitleFrame::SetOutputRect(RECT outputRect)\n{\n    m_outputRect = m_clipRect = outputRect;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleFrame::SetClipRect(RECT clipRect)\n{\n    m_clipRect = clipRect;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleFrame::AddBitmap(CLAVSubRect *subRect)\n{\n    // Allocate memory for the new block\n    void *mem = CoTaskMemRealloc(m_Bitmaps, sizeof(*m_Bitmaps) * (m_NumBitmaps + 1));\n    if (!mem)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    m_Bitmaps = (CLAVSubRect **)mem;\n    m_Bitmaps[m_NumBitmaps] = subRect;\n    m_NumBitmaps++;\n\n    // Hold reference on the subtitle rect\n    subRect->AddRef();\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleFrame::GetOutputRect(RECT *outputRect)\n{\n    CheckPointer(outputRect, E_POINTER);\n    *outputRect = m_outputRect;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleFrame::GetClipRect(RECT *clipRect)\n{\n    CheckPointer(clipRect, E_POINTER);\n    *clipRect = m_clipRect;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleFrame::GetBitmapCount(int *count)\n{\n    CheckPointer(count, E_POINTER);\n    *count = m_NumBitmaps;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleFrame::GetBitmap(int index, ULONGLONG *id, POINT *position, SIZE *size, LPCVOID *pixels,\n                                          int *pitch)\n{\n    if (index < 0 || index >= m_NumBitmaps)\n        return E_INVALIDARG;\n    CheckPointer(id, E_POINTER);\n    CheckPointer(position, E_POINTER);\n    CheckPointer(size, E_POINTER);\n    CheckPointer(pixels, E_POINTER);\n    CheckPointer(pitch, E_POINTER);\n\n    *id = m_Bitmaps[index]->id;\n    *position = m_Bitmaps[index]->position;\n    *size = m_Bitmaps[index]->size;\n    *pixels = m_Bitmaps[index]->pixels;\n    *pitch = m_Bitmaps[index]->pitch * 4;\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/LAVSubtitleFrame.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nclass CLAVSubRect : public IUnknown\n{\n  public:\n    CLAVSubRect()\n    {\n        memset(&position, 0, sizeof(position));\n        memset(&size, 0, sizeof(size));\n    }\n    ~CLAVSubRect()\n    {\n        SAFE_CO_FREE(pixels);\n        SAFE_CO_FREE(pixelsPal);\n    }\n\n    // IUnknown\n    STDMETHODIMP QueryInterface(REFIID riid, void **ppvObject)\n    {\n        if (riid == IID_IUnknown)\n        {\n            AddRef();\n            *ppvObject = (IUnknown *)this;\n        }\n        else\n        {\n            return E_NOINTERFACE;\n        }\n        return S_OK;\n    }\n    STDMETHODIMP_(ULONG) AddRef()\n    {\n        ULONG lRef = InterlockedIncrement(&m_cRef);\n        return max(ULONG(lRef), 1ul);\n    }\n    STDMETHODIMP_(ULONG) Release()\n    {\n        ULONG lRef = InterlockedDecrement(&m_cRef);\n        if (lRef == 0)\n        {\n            m_cRef++;\n            delete this;\n            return 0;\n        }\n        return max(ULONG(lRef), 1ul);\n    }\n\n    // Reset the reference count to 0, can be used after a copy-constructor\n    STDMETHODIMP ResetRefCount()\n    {\n        m_cRef = 0ul;\n        return S_OK;\n    }\n\n  public:\n    REFERENCE_TIME rtStart = AV_NOPTS_VALUE; ///< Start Time\n    REFERENCE_TIME rtStop = AV_NOPTS_VALUE;  ///< Stop time\n    ULONGLONG id = 0;                        ///< Unique Identifier (same ID = same subtitle)\n    POINT position;                          ///< Position (relative to outputRect)\n    SIZE size;                               ///< Size\n    LPVOID pixels = nullptr;                 ///< Pixel Data\n    LPVOID pixelsPal = nullptr;              ///< Pixel Data (in paletted form, required by dvd HLI)\n    int pitch = 0;                           ///< Pitch of the subtitle lines\n    bool forced = false;                     ///< Forced/Menu\n\n    bool freePixels = false; ///< If true, pixel data is free'ed upon destroy\n\n  private:\n    ULONG m_cRef = 0;\n};\n\nclass CLAVSubtitleFrame\n    : public ISubRenderFrame\n    , public CUnknown\n{\n  public:\n    CLAVSubtitleFrame(void);\n    virtual ~CLAVSubtitleFrame(void);\n    DECLARE_IUNKNOWN;\n\n    // ISubRenderFrame\n    STDMETHODIMP GetOutputRect(RECT *outputRect);\n    STDMETHODIMP GetClipRect(RECT *clipRect);\n    STDMETHODIMP GetBitmapCount(int *count);\n    STDMETHODIMP GetBitmap(int index, ULONGLONG *id, POINT *position, SIZE *size, LPCVOID *pixels, int *pitch);\n\n    STDMETHODIMP SetOutputRect(RECT outputRect);\n    STDMETHODIMP SetClipRect(RECT clipRect);\n    STDMETHODIMP AddBitmap(CLAVSubRect *subRect);\n\n    BOOL Empty() const { return m_NumBitmaps == 0; };\n\n  private:\n    RECT m_outputRect;\n    RECT m_clipRect;\n\n    CLAVSubRect **m_Bitmaps = nullptr;\n    int m_NumBitmaps = 0;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/LAVSubtitleProvider.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVSubtitleProvider.h\"\n\n#include \"moreuuids.h\"\n#include \"libavutil/colorspace.h\"\n\n#include \"LAVVideo.h\"\n\n#include \"version.h\"\n\n#define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)\n#define SUBTITLE_PTS_TIMEOUT (AV_NOPTS_VALUE + 1)\n\n#define OFFSET(x) offsetof(LAVSubtitleProviderContext, x)\n// clang-format off\nstatic const SubRenderOption options[] = {\n  { \"name\",           OFFSET(name),            SROPT_TYPE_STRING, SROPT_FLAG_READONLY },\n  { \"version\",        OFFSET(version),         SROPT_TYPE_STRING, SROPT_FLAG_READONLY },\n  { \"yuvMatrix\",      OFFSET(yuvMatrix),       SROPT_TYPE_STRING, SROPT_FLAG_READONLY },\n  { \"outputLevels\",   OFFSET(outputLevels),    SROPT_TYPE_STRING, SROPT_FLAG_READONLY },\n  { \"colorPrimaries\", OFFSET(primaries),       SROPT_TYPE_STRING, SROPT_FLAG_READONLY },\n  { \"isBitmap\",       OFFSET(isBitmap),        SROPT_TYPE_BOOL,   SROPT_FLAG_READONLY },\n  { \"isMovable\",      OFFSET(isMovable),       SROPT_TYPE_BOOL,   SROPT_FLAG_READONLY },\n  { \"combineBitmaps\", OFFSET(combineBitmaps),  SROPT_TYPE_BOOL,   0                   },\n  { 0 }\n};\n// clang-format on\n\n#define COLOR_PRIM_NTSC _T(\"601_525\")\n#define COLOR_PRIM_PAL  _T(\"601_625\")\n\nCLAVSubtitleProvider::CLAVSubtitleProvider(CLAVVideo *pLAVVideo, ISubRenderConsumer *pConsumer)\n  : CSubRenderOptionsImpl(::options, &context)\n  , CUnknown(L\"CLAVSubtitleProvider\", nullptr)\n  , m_pLAVVideo(pLAVVideo)\n{\n  m_ControlThread = new CLAVSubtitleProviderControlThread();\n\n  ASSERT(pConsumer);\n  ZeroMemory(&context, sizeof(context));\n  context.name = TEXT(LAV_VIDEO);\n  context.version = TEXT(LAV_VERSION_STR);\n  context.yuvMatrix = _T(\"None\");\n  context.outputLevels = _T(\"PC\");\n  context.primaries = COLOR_PRIM_NTSC;\n  context.isBitmap = true;\n  context.isMovable = true;\n  AddRef();\n\n  SetConsumer(pConsumer);\n}\n\nCLAVSubtitleProvider::~CLAVSubtitleProvider(void)\n{\n  Flush();\n  CloseDecoder();\n  DisconnectConsumer();\n  SAFE_DELETE(m_ControlThread);\n}\n\nvoid CLAVSubtitleProvider::CloseDecoder()\n{\n  CAutoLock lock(this);\n  m_pAVCodec = nullptr;\n  if (m_pAVCtx) {\n    if (m_pAVCtx->extradata)\n      av_freep(&m_pAVCtx->extradata);\n    avcodec_free_context(&m_pAVCtx);\n  }\n  if (m_pParser) {\n    av_parser_close(m_pParser);\n    m_pParser = nullptr;\n  }\n\n  av_packet_free(&m_pSubtitlePacket);\n}\n\nSTDMETHODIMP CLAVSubtitleProvider::SetConsumer(ISubRenderConsumer *pConsumer)\n{\n  CAutoLock lock(this);\n  if (m_pConsumer)\n    DisconnectConsumer();\n\n  CheckPointer(pConsumer, E_FAIL);\n\n  m_pConsumer = pConsumer;\n  m_pConsumer->AddRef();\n  m_pConsumer->Connect(this);\n\n  if (FAILED(m_pConsumer->QueryInterface(&m_pConsumer2)))\n    m_pConsumer2 = nullptr;\n\n  m_ControlThread->SetConsumer2(m_pConsumer2);\n\n  return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleProvider::DisconnectConsumer(void)\n{\n  CAutoLock lock(this);\n  CheckPointer(m_pConsumer, S_FALSE);\n  m_ControlThread->SetConsumer2(nullptr);\n  m_pConsumer->Disconnect();\n  SafeRelease(&m_pConsumer);\n  SafeRelease(&m_pConsumer2);\n\n  return S_OK;\n}\n\n#define PTS2RT(pts) (10000i64 * pts / 90)\n\nSTDMETHODIMP CLAVSubtitleProvider::RequestFrame(REFERENCE_TIME start, REFERENCE_TIME stop, LPVOID context)\n{\n  ASSERT(m_pConsumer);\n\n  // Create a new frame\n  CLAVSubtitleFrame *subtitleFrame = new CLAVSubtitleFrame();\n  subtitleFrame->AddRef();\n\n  if (m_pAVCtx->width == 720 && m_pAVCtx->height == 480) {\n    SIZE videoSize;\n    m_pConsumer->GetSize(\"originalVideoSize\", &videoSize);\n    if (videoSize.cx == 720) {\n      m_pAVCtx->height = videoSize.cy;\n    }\n  }\n\n  // update primaries based on the video dimensions\n  if (m_pAVCtx->height == 480)\n      this->context.primaries = COLOR_PRIM_NTSC;\n  else if (m_pAVCtx->height == 576)\n      this->context.primaries = COLOR_PRIM_PAL;\n\n  RECT outputRect;\n  ::SetRect(&outputRect, 0, 0, m_pAVCtx->width, m_pAVCtx->height);\n  subtitleFrame->SetOutputRect(outputRect);\n\n  REFERENCE_TIME mid = start + ((stop-start) >> 1);\n\n  // Scope this so we limit the provider-lock to the part where its needed\n  {\n    CAutoLock lock(this);\n    for (auto it = m_SubFrames.begin(); it != m_SubFrames.end(); it++) {\n      CLAVSubRect *pRect = *it;\n      if ((pRect->rtStart == AV_NOPTS_VALUE || pRect->rtStart <= mid)\n        && (pRect->rtStop == AV_NOPTS_VALUE || pRect->rtStop > mid)\n        && (m_bComposit || pRect->forced)) {\n\n        if (m_pHLI && PTS2RT(m_pHLI->StartPTM) <= mid && PTS2RT(m_pHLI->EndPTM) >= mid) {\n          pRect = ProcessDVDHLI(pRect);\n        }\n        subtitleFrame->AddBitmap(pRect);\n      }\n    }\n\n    m_rtLastFrame = start;\n  }\n\n  if (subtitleFrame->Empty()) {\n    SafeRelease(&subtitleFrame);\n  }\n\n  // Deliver Frame\n  m_pConsumer->DeliverFrame(start, stop, context, subtitleFrame);\n  SafeRelease(&subtitleFrame);\n\n  TimeoutSubtitleRects(stop);\n\n  return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleProvider::Disconnect(void)\n{\n  SafeRelease(&m_pConsumer);\n  return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleProvider::InitDecoder(const CMediaType *pmt, AVCodecID codecId)\n{\n  CAutoLock lock(this);\n  m_pAVCodec = avcodec_find_decoder(codecId);\n  CheckPointer(m_pAVCodec, VFW_E_TYPE_NOT_ACCEPTED);\n\n  m_pAVCtx = avcodec_alloc_context3(m_pAVCodec);\n  CheckPointer(m_pAVCtx, E_POINTER);\n\n  m_pParser = av_parser_init(codecId);\n\n  size_t extralen = 0;\n  getExtraData((const BYTE *)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), nullptr, &extralen);\n\n  if (extralen > 0) {\n    // Just copy extradata\n    BYTE *extra = (uint8_t *)av_mallocz(extralen + AV_INPUT_BUFFER_PADDING_SIZE);\n    getExtraData((const BYTE *)pmt->Format(), pmt->FormatType(), pmt->FormatLength(), extra, nullptr);\n\n    m_pAVCtx->extradata = extra;\n    m_pAVCtx->extradata_size = (int)extralen;\n  }\n\n  if (pmt->formattype == FORMAT_SubtitleInfo) {\n    // Not much info in here\n  } else {\n    // Try video info\n    BITMAPINFOHEADER *bmi = nullptr;\n    videoFormatTypeHandler(*pmt, &bmi, nullptr, nullptr, nullptr);\n    m_pAVCtx->width = bmi->biWidth;\n    m_pAVCtx->height = bmi->biHeight;\n  }\n\n  int ret = avcodec_open2(m_pAVCtx, m_pAVCodec, nullptr);\n  if (ret < 0) {\n    DbgLog((LOG_TRACE, 10, L\"CLAVSubtitleProvider::InitDecoder(): avocdec_open2 failed with %d\", ret));\n    CloseDecoder();\n    return VFW_E_TYPE_NOT_ACCEPTED;\n  }\n\n  return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleProvider::Flush()\n{\n  CAutoLock lock(this);\n  ClearSubtitleRects();\n  SAFE_DELETE(m_pHLI);\n\n  m_rtLastFrame = AV_NOPTS_VALUE;\n  context.isMovable = true;\n  m_pLAVVideo->SetInDVDMenu(false);\n\n  av_packet_free(&m_pSubtitlePacket);\n\n  return S_OK;\n}\n\nvoid CLAVSubtitleProvider::ClearSubtitleRects()\n{\n  CAutoLock lock(this);\n  for (auto it = m_SubFrames.begin(); it != m_SubFrames.end(); it++) {\n    (*it)->Release();\n  }\n  m_SubFrames.clear();\n}\n\nvoid CLAVSubtitleProvider::TimeoutSubtitleRects(REFERENCE_TIME rt)\n{\n  CAutoLock lock(this);\n  REFERENCE_TIME timestamp = rt - 10 * 10000000; // Timeout all subs 10 seconds in the past\n  auto it = m_SubFrames.begin();\n  while (it != m_SubFrames.end()) {\n    if ((*it)->rtStop != AV_NOPTS_VALUE && (*it)->rtStop < timestamp) {\n      DbgLog((LOG_TRACE, 10, L\"Timed out subtitle at %I64d\", (*it)->rtStart));\n      (*it)->Release();\n      it = m_SubFrames.erase(it);\n    } else {\n      it++;\n    }\n  }\n}\n\nSTDMETHODIMP CLAVSubtitleProvider::Decode(BYTE *buf, int buflen, REFERENCE_TIME rtStartIn, REFERENCE_TIME rtStopIn)\n{\n  ASSERT(m_pAVCtx);\n\n  if (m_pSubtitlePacket == nullptr)\n      m_pSubtitlePacket = av_packet_alloc();\n\n  AVSubtitle sub;\n  memset(&sub, 0, sizeof(sub));\n\n  if (!buflen || !buf) {\n    return S_OK;\n  }\n\n  while (buflen > 0) {\n    REFERENCE_TIME rtStart = rtStartIn, rtStop = rtStopIn;\n    int used_bytes = 0;\n    int got_sub = 0;\n    if (m_pParser) {\n      uint8_t *pOut = nullptr;\n      int pOut_size = 0;\n      used_bytes = av_parser_parse2(m_pParser, m_pAVCtx, &pOut, &pOut_size, buf, buflen, AV_NOPTS_VALUE, AV_NOPTS_VALUE, 0);\n      if (used_bytes == 0 && pOut_size == 0) {\n        DbgLog((LOG_TRACE, 50, L\"CLAVSubtitleProvider::Decode - could not process buffer\"));\n        break;\n      }\n\n      if (used_bytes > pOut_size) {\n        if (rtStartIn != AV_NOPTS_VALUE)\n          m_rtStartCache = rtStartIn;\n      } else if (used_bytes == pOut_size) {\n        m_rtStartCache = rtStartIn = AV_NOPTS_VALUE;\n      } else if (pOut_size > used_bytes) {\n        rtStart = m_rtStartCache;\n        m_rtStartCache = rtStartIn;\n        // The value was used once, don't use it for multiple frames, that ends up in weird timings\n        rtStartIn = AV_NOPTS_VALUE;\n      }\n\n      if (pOut_size > 0) {\n        m_pSubtitlePacket->data = pOut;\n        m_pSubtitlePacket->size = pOut_size;\n        m_pSubtitlePacket->pts = rtStart;\n        m_pSubtitlePacket->duration = 0;\n\n        int ret = avcodec_decode_subtitle2(m_pAVCtx, &sub, &got_sub, m_pSubtitlePacket);\n        if (ret < 0) {\n          DbgLog((LOG_TRACE, 50, L\"CLAVSubtitleProvider::Decode - decoding failed despite successful parsing\"));\n          got_sub = 0;\n        }\n      } else {\n        got_sub = 0;\n      }\n    }\n\n    if (used_bytes < 0) {\n      return S_OK;\n    }\n\n    if (!m_pParser && (!got_sub && used_bytes == 0)) {\n      buflen = 0;\n    } else {\n      buf += used_bytes;\n      buflen -= used_bytes;\n    }\n\n    if (got_sub) {\n      ProcessSubtitleFrame(&sub, rtStart);\n    }\n\n    avsubtitle_free(&sub);\n  }\n\n  return S_OK;\n}\n\nvoid CLAVSubtitleProvider::ProcessSubtitleFrame(AVSubtitle *sub, REFERENCE_TIME rtStart)\n{\n  DbgLog((LOG_TRACE, 10, L\"Decoded Sub: rtStart: %I64d, start_display_time: %d, end_display_time: %d, num_rects: %u, num_dvd_palette: %d\", rtStart, sub->start_display_time, sub->end_display_time, sub->num_rects, sub->num_dvd_palette));\n  if (sub->num_rects > 0) {\n    if (m_pAVCtx->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {\n      CAutoLock lock(this);\n\n      // DVD subs have the limitation that only one subtitle can be shown at a given time,\n      // so we need to timeout unlimited subs when a new one appears, as well as limit the duration of timed subs\n      // to prevent overlapping subtitles\n      REFERENCE_TIME rtSubTimeout = (rtStart != AV_NOPTS_VALUE) ? rtStart - 1 : SUBTITLE_PTS_TIMEOUT;\n      for (auto it = m_SubFrames.begin(); it != m_SubFrames.end(); it++) {\n        if ((*it)->rtStop == AV_NOPTS_VALUE || rtStart == AV_NOPTS_VALUE || (*it)->rtStop > rtStart) {\n          (*it)->rtStop = rtSubTimeout;\n        }\n      }\n\n      // Override subtitle timestamps if we have a timeout, and are not in a menu\n      if (rtStart == AV_NOPTS_VALUE && sub->end_display_time > 0 && !(sub->rects[0]->flags & AV_SUBTITLE_FLAG_FORCED)) {\n        DbgLog((LOG_TRACE, 10, L\" -> Overriding subtitle timestamp to %I64d\", m_rtLastFrame));\n        rtStart = m_rtLastFrame;\n      }\n    }\n\n    REFERENCE_TIME rtStop = AV_NOPTS_VALUE;\n    if (rtStart != AV_NOPTS_VALUE) {\n      if (sub->end_display_time > 0) {\n        rtStop = rtStart + (sub->end_display_time * 10000i64);\n      }\n      rtStart += sub->start_display_time * 10000i64;\n    }\n\n    for (unsigned i = 0; i < sub->num_rects; i++) {\n      if (sub->num_dvd_palette > 1 && rtStart != AV_NOPTS_VALUE) {\n        REFERENCE_TIME rtStartRect = rtStart - (sub->start_display_time * 10000i64);\n        REFERENCE_TIME rtStopRect = rtStart;\n        for (unsigned k = 0; k < sub->num_dvd_palette; k++) {\n          // Start is the stop of the previous part\n          rtStartRect = rtStopRect;\n\n          // Stop is either the start of the next part, or the final stop\n          if (k < (sub->num_dvd_palette-1))\n            rtStopRect = rtStart + (sub->dvd_palette[k+1]->start_display_time * 10000i64);\n          else\n            rtStopRect = rtStop;\n\n          // Update palette with new alpha values\n          for (unsigned j = 0; j < 4; j++)\n            sub->rects[i]->data[1][(j << 2) + 3] = sub->dvd_palette[k]->alpha[j] * 17;\n\n          ProcessSubtitleRect(sub->rects[i], rtStartRect, rtStopRect);\n        }\n      } else {\n        ProcessSubtitleRect(sub->rects[i], rtStart, rtStop);\n      }\n    }\n  }\n}\n\nvoid CLAVSubtitleProvider::ProcessSubtitleRect(AVSubtitleRect *rect, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop)\n{\n  DbgLog((LOG_TRACE, 10, L\"Subtitle Rect, start: %I64d, stop: %I64d\", rtStart, rtStop));\n  // Skip zero-length subs\n  if (rtStart != AV_NOPTS_VALUE && rtStart == rtStop) return;\n\n  int hpad = rect->x & 1;\n  int vpad = rect->y & 1;\n\n  int width = rect->w + hpad;\n  if (width & 1) width++;\n\n  int height = rect->h + vpad;\n  if (height & 1) height++;\n\n  int rgbStride = FFALIGN(width, 16);\n\n  BYTE *rgbSub = (BYTE *)CoTaskMemAlloc(rgbStride * height * 4);\n  if (!rgbSub) return;\n  BYTE *rgbSubStart = rgbSub;\n  const BYTE *palSub = rect->data[0];\n  const BYTE *palette = rect->data[1];\n\n  memset(rgbSub, 0, rgbStride * height * 4);\n\n  rgbSub += (rgbStride * vpad + hpad) * 4;\n\n  for (int y = 0; y < rect->h; y++) {\n    for (int x = 0; x < rect->w; x++) {\n      // Read paletted value\n      int idx = palSub[x];\n\n      // Skip invalid values\n      if (idx >= rect->nb_colors)\n        continue;\n\n      // Read RGB values from palette\n      BYTE b = palette[(idx << 2) + 0];\n      BYTE g = palette[(idx << 2) + 1];\n      BYTE r = palette[(idx << 2) + 2];\n      BYTE a = palette[(idx << 2) + 3];\n      // Store as RGBA pixel, pre-multiplied\n      rgbSub[(x << 2) + 0] = FAST_DIV255(b * a);\n      rgbSub[(x << 2) + 1] = FAST_DIV255(g * a);\n      rgbSub[(x << 2) + 2] = FAST_DIV255(r * a);\n      rgbSub[(x << 2) + 3] = a;\n    }\n    palSub += rect->linesize[0];\n    rgbSub += rgbStride * 4;\n  }\n\n  // Store the rect\n  POINT position = { rect->x - hpad, rect->y - vpad };\n  SIZE size = { width, height };\n  CLAVSubRect *lavRect = new CLAVSubRect();\n  if (!lavRect) return;\n  lavRect->id       = m_SubPicId++;\n  lavRect->pitch    = rgbStride;\n  lavRect->pixels   = rgbSubStart;\n  lavRect->position = position;\n  lavRect->size     = size;\n  lavRect->rtStart  = rtStart;\n  lavRect->rtStop   = rtStop;\n  lavRect->forced   = rect->flags & AV_SUBTITLE_FLAG_FORCED;\n\n  if (m_pAVCtx->codec_id == AV_CODEC_ID_DVD_SUBTITLE) {\n    lavRect->pixelsPal = CoTaskMemAlloc(lavRect->pitch * lavRect->size.cy);\n    if (!lavRect->pixelsPal) return;\n\n    int paletteTransparent = 0;\n    for (int i = 0; i < rect->nb_colors; i++) {\n      if (palette[(i << 2) + 3] == 0) {\n        paletteTransparent = i;\n        break;\n      }\n    }\n    memset(lavRect->pixelsPal, paletteTransparent, lavRect->pitch * lavRect->size.cy);\n    BYTE *palPixels = (BYTE *)lavRect->pixelsPal;\n    palSub = rect->data[0];\n\n    palPixels += lavRect->pitch * vpad + hpad;\n    for (int y = 0; y < rect->h; y++) {\n      memcpy(palPixels, palSub, rect->w);\n      palPixels += lavRect->pitch;\n      palSub += rect->linesize[0];\n    }\n  }\n\n  // Ensure the width/height in avctx are valid\n  m_pAVCtx->width  = FFMAX(m_pAVCtx->width,  position.x + size.cx);\n  m_pAVCtx->height = FFMAX(m_pAVCtx->height, position.y + size.cy);\n\n  // HACK: Since we're only dealing with DVDs so far, do some trickery here\n  if (m_pAVCtx->height > 480 && m_pAVCtx->height < 576)\n    m_pAVCtx->height = 576;\n\n  AddSubtitleRect(lavRect);\n}\n\nvoid CLAVSubtitleProvider::AddSubtitleRect(CLAVSubRect *rect)\n{\n  CAutoLock lock(this);\n  rect->AddRef();\n  m_SubFrames.push_back(rect);\n}\n\ntypedef struct DVDSubContext\n{\n  AVClass *avclass;\n  uint32_t palette[16];\n  char    *palette_str;\n  char    *ifo_str;\n  int      has_palette;\n  uint8_t  colormap[4];\n  uint8_t  alpha[256];\n  uint8_t  buf[0x10000];\n  int      buf_size;\n  int      forced_subs_only;\n} DVDSubContext;\n\n#define MAX_NEG_CROP 1024\nextern \"C\" __declspec(dllimport) uint8_t ff_crop_tab[256 + 2 * MAX_NEG_CROP];\n\nSTDMETHODIMP CLAVSubtitleProvider::SetDVDPalette(AM_PROPERTY_SPPAL *pPal)\n{\n  DbgLog((LOG_TRACE, 10, L\"CLAVSubtitleProvider(): Setting new DVD Palette\"));\n  CAutoLock lock(this);\n  if (!m_pAVCtx || m_pAVCtx->codec_id != AV_CODEC_ID_DVD_SUBTITLE || !pPal) {\n    return E_FAIL;\n  }\n\n  DVDSubContext *ctx = (DVDSubContext *)m_pAVCtx->priv_data;\n  ctx->has_palette = 1;\n\n  uint8_t r,g,b;\n  int i, y, cb, cr;\n  int r_add, g_add, b_add;\n  uint8_t *cm = ff_crop_tab + MAX_NEG_CROP;\n  for (i = 0; i < 16; i++) {\n    y  = pPal->sppal[i].Y;\n    cb = pPal->sppal[i].V;\n    cr = pPal->sppal[i].U;\n    YUV_TO_RGB1_CCIR(cb, cr);\n    YUV_TO_RGB2_CCIR(r, g, b, y);\n    ctx->palette[i] = (0xFF << 24) | (r << 16) | (g << 8) | b;\n  }\n\n  return S_OK;\n}\n\nSTDMETHODIMP CLAVSubtitleProvider::SetDVDHLI(struct _AM_PROPERTY_SPHLI *pHLI)\n{\n  bool redraw = false;\n\n  // Scoped lock so the lock is lifted when the redraw is issued\n  // Otherwise we can deadlock in the decoder - this one holding the provider lock, the decoder holding the decoder lock...\n  {\n    CAutoLock lock(this);\n    if (pHLI) {\n  #define DHLI(var) (pHLI->var != m_pHLI->var)\n      if (!m_pHLI || DHLI(StartX) || DHLI(StopX) || DHLI(StartY) || DHLI(StopY) || memcmp(&pHLI->ColCon, &m_pHLI->ColCon, sizeof(pHLI->ColCon)) != 0) {\n        DbgLog((LOG_TRACE, 10, L\"CLAVSubtitleProvider(): DVD HLI event. HLISS: %u, x: %u->%u, y: %u->%u, StartPTM: %u, EndPTM: %u\", pHLI->HLISS, pHLI->StartX, pHLI->StopX, pHLI->StartY, pHLI->StopY, pHLI->StartPTM, pHLI->EndPTM));\n        SAFE_DELETE(m_pHLI);\n        m_pHLI = new AM_PROPERTY_SPHLI(*pHLI);\n        redraw = true;\n      }\n      context.isMovable = false;\n      m_pLAVVideo->SetInDVDMenu(true);\n    } else {\n      SAFE_DELETE(m_pHLI);\n    }\n  }\n\n  if (redraw)\n    ControlCmd(CNTRL_FLUSH);\n\n  return S_OK;\n}\n\nCLAVSubRect* CLAVSubtitleProvider::ProcessDVDHLI(CLAVSubRect *rect)\n{\n  DVDSubContext *ctx = (DVDSubContext *)m_pAVCtx->priv_data;\n  if (!m_pHLI || !rect->pixelsPal || !ctx->has_palette)\n    return rect;\n\n  LPVOID newPixels = CoTaskMemAlloc(rect->pitch * rect->size.cy * 4);\n  if (!newPixels) return rect;\n\n  // copy pixels before modification\n  memcpy(newPixels, rect->pixels, rect->pitch * rect->size.cy * 4);\n\n  uint8_t *originalPalPixels = (uint8_t *)rect->pixelsPal;\n\n  // create new object\n  rect = new CLAVSubRect(*rect);\n  rect->ResetRefCount();\n  rect->pixels = newPixels;\n  rect->pixelsPal = nullptr;\n\n  // Need to assign a new Id since we're modifying it here..\n  rect->id = m_SubPicId++;\n\n  uint8_t *palette   = (uint8_t *)ctx->palette;\n  for (int y = 0; y < rect->size.cy; y++) {\n    if (y+rect->position.y < m_pHLI->StartY || y+rect->position.y > m_pHLI->StopY)\n      continue;\n    uint8_t *pixelsPal = originalPalPixels + rect->pitch * y;\n    uint8_t *pixels = ((uint8_t *)rect->pixels) + rect->pitch * y * 4;\n    for (int x = 0; x < rect->size.cx; x++) {\n      if (x+rect->position.x < m_pHLI->StartX || x+rect->position.x > m_pHLI->StopX)\n        continue;\n      uint8_t idx = pixelsPal[x];\n      uint8_t alpha = 0;\n      switch (idx) {\n      case 0:\n        idx = m_pHLI->ColCon.backcol;\n        alpha = m_pHLI->ColCon.backcon;\n        break;\n      case 1:\n        idx = m_pHLI->ColCon.patcol;\n        alpha = m_pHLI->ColCon.patcon;\n        break;\n      case 2:\n        idx = m_pHLI->ColCon.emph1col;\n        alpha = m_pHLI->ColCon.emph1con;\n        break;\n      case 3:\n        idx = m_pHLI->ColCon.emph2col;\n        alpha = m_pHLI->ColCon.emph2con;\n        break;\n      }\n      // Read RGB values from palette\n      BYTE b = palette[(idx << 2) + 0];\n      BYTE g = palette[(idx << 2) + 1];\n      BYTE r = palette[(idx << 2) + 2];\n      BYTE a = alpha << 4;\n      // Store as RGBA pixel, pre-multiplied\n      pixels[(x << 2) + 0] = FAST_DIV255(b * a);\n      pixels[(x << 2) + 1] = FAST_DIV255(g * a);\n      pixels[(x << 2) + 2] = FAST_DIV255(r * a);\n      pixels[(x << 2) + 3] = a;\n    }\n  }\n  return rect;\n}\n\nSTDMETHODIMP CLAVSubtitleProvider::SetDVDComposit(BOOL bComposit)\n{\n  CAutoLock lock(this);\n  m_bComposit = bComposit;\n  return S_OK;\n}\n\nCLAVSubtitleProviderControlThread::CLAVSubtitleProviderControlThread()\n  : CAMThread()\n{\n  Create();\n}\n\nCLAVSubtitleProviderControlThread::~CLAVSubtitleProviderControlThread()\n{\n  CallWorker(CLAVSubtitleProvider::CNTRL_EXIT);\n  Close();\n}\n\nvoid CLAVSubtitleProviderControlThread::SetConsumer2(ISubRenderConsumer2 * pConsumer2)\n{\n  CAutoLock lock(this);\n  m_pConsumer2 = pConsumer2;\n}\n\nDWORD CLAVSubtitleProviderControlThread::ThreadProc()\n{\n  SetThreadName(-1, \"LAV Subtitle Control Thread\");\n  DWORD cmd;\n  while (1) {\n    cmd = GetRequest();\n    switch (cmd) {\n    case CLAVSubtitleProvider::CNTRL_EXIT:\n      Reply(S_OK);\n      return 0;\n    case CLAVSubtitleProvider::CNTRL_FLUSH:\n      Reply(S_OK);\n      {\n        CAutoLock lock(this);\n        if (m_pConsumer2)\n          m_pConsumer2->Clear();\n      }\n      break;\n    }\n  }\n  return 1;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/LAVSubtitleProvider.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"SubRenderOptionsImpl.h\"\n#include \"LAVSubtitleFrame.h\"\n\nclass CLAVVideo;\n\ntypedef struct LAVSubtitleProviderContext\n{\n    LPWSTR name;      ///< name of the Provider\n    LPWSTR version;   ///< Version of the Provider\n    LPWSTR yuvMatrix; ///< YUV Matrix\n    LPWSTR outputLevels; ///< RGB output levels\n    LPWSTR primaries; ///< Color Primaries\n\n    bool combineBitmaps; ///< Control if the provider combines all bitmaps into one\n    bool isBitmap;\n    bool isMovable;\n} LAVSubtitleProviderContext;\n\nstruct _AM_PROPERTY_SPPAL;\nstruct _AM_PROPERTY_SPHLI;\n\nclass CLAVSubtitleProviderControlThread\n    : public CAMThread\n    , protected CCritSec\n{\n  public:\n    CLAVSubtitleProviderControlThread();\n    ~CLAVSubtitleProviderControlThread();\n\n    void SetConsumer2(ISubRenderConsumer2 *pConsumer2);\n\n  protected:\n    DWORD ThreadProc();\n\n  private:\n    ISubRenderConsumer2 *m_pConsumer2 = nullptr;\n};\n\nclass CLAVSubtitleProvider\n    : public ISubRenderProvider\n    , public CSubRenderOptionsImpl\n    , public CUnknown\n    , private CCritSec\n{\n  public:\n    CLAVSubtitleProvider(CLAVVideo *pLAVVideo, ISubRenderConsumer *pConsumer);\n    ~CLAVSubtitleProvider(void);\n    DECLARE_IUNKNOWN;\n    DECLARE_ISUBRENDEROPTIONS;\n\n    // ISubRenderProvider\n    STDMETHODIMP RequestFrame(REFERENCE_TIME start, REFERENCE_TIME stop, LPVOID context);\n    STDMETHODIMP Disconnect(void);\n\n    // CLAVSubtitleProvider public\n    STDMETHODIMP SetConsumer(ISubRenderConsumer *pConsumer);\n    STDMETHODIMP DisconnectConsumer(void);\n\n    STDMETHODIMP InitDecoder(const CMediaType *pmt, AVCodecID codecId);\n    STDMETHODIMP Decode(BYTE *buf, int buflen, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);\n\n    STDMETHODIMP Flush();\n\n    STDMETHODIMP SetDVDPalette(struct _AM_PROPERTY_SPPAL *pPal);\n    STDMETHODIMP SetDVDHLI(struct _AM_PROPERTY_SPHLI *pHLI);\n    STDMETHODIMP SetDVDComposit(BOOL bComposit);\n\n  private:\n    void CloseDecoder();\n\n    void ProcessSubtitleFrame(AVSubtitle *sub, REFERENCE_TIME rtStart);\n    void ProcessSubtitleRect(AVSubtitleRect *rect, REFERENCE_TIME rtStart, REFERENCE_TIME rtStop);\n    void AddSubtitleRect(CLAVSubRect *rect);\n    CLAVSubRect *ProcessDVDHLI(CLAVSubRect *rect);\n    void ClearSubtitleRects();\n    void TimeoutSubtitleRects(REFERENCE_TIME rtStop);\n\n    enum\n    {\n        CNTRL_EXIT,\n        CNTRL_FLUSH\n    };\n    HRESULT ControlCmd(DWORD cmd) { return m_ControlThread->CallWorker(cmd); }\n\n  private:\n    friend class CLAVSubtitleProviderControlThread;\n    LAVSubtitleProviderContext context;\n    CLAVVideo *m_pLAVVideo = nullptr;\n\n    ISubRenderConsumer *m_pConsumer = nullptr;\n    ISubRenderConsumer2 *m_pConsumer2 = nullptr;\n\n    const AVCodec *m_pAVCodec = nullptr;\n    AVCodecContext *m_pAVCtx = nullptr;\n    AVCodecParserContext *m_pParser = nullptr;\n\n    REFERENCE_TIME m_rtLastFrame = AV_NOPTS_VALUE;\n    REFERENCE_TIME m_rtStartCache = AV_NOPTS_VALUE;\n    ULONGLONG m_SubPicId = 0;\n    BOOL m_bComposit = TRUE;\n\n    AVPacket *m_pSubtitlePacket = nullptr;\n\n    std::list<CLAVSubRect *> m_SubFrames;\n\n    struct _AM_PROPERTY_SPHLI *m_pHLI = nullptr;\n\n    CLAVSubtitleProviderControlThread *m_ControlThread = nullptr;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVVideoSubtitleInputPin.h\"\n#include \"LAVVideo.h\"\n\n#include \"moreuuids.h\"\n\ntypedef struct\n{\n    const CLSID *clsMajorType;\n    const CLSID *clsMinorType;\n    const enum AVCodecID nFFCodec;\n} LAV_TYPE_MAP;\n\nstatic const LAV_TYPE_MAP lav_subtitle_codecs[] = {\n    {&MEDIATYPE_DVD_ENCRYPTED_PACK, &MEDIASUBTYPE_DVD_SUBPICTURE, AV_CODEC_ID_DVD_SUBTITLE},\n    {&MEDIATYPE_MPEG2_PACK, &MEDIASUBTYPE_DVD_SUBPICTURE, AV_CODEC_ID_DVD_SUBTITLE},\n    {&MEDIATYPE_MPEG2_PES, &MEDIASUBTYPE_DVD_SUBPICTURE, AV_CODEC_ID_DVD_SUBTITLE},\n    {&MEDIATYPE_Video, &MEDIASUBTYPE_DVD_SUBPICTURE, AV_CODEC_ID_DVD_SUBTITLE}};\n\nCLAVVideoSubtitleInputPin::CLAVVideoSubtitleInputPin(TCHAR *pObjectName, CLAVVideo *pFilter, CCritSec *pcsFilter,\n                                                     HRESULT *phr, LPWSTR pName)\n    : CBaseInputPin(pObjectName, pFilter, pcsFilter, phr, pName)\n    , m_pLAVVideo(pFilter)\n    , CDeCSSPinHelper()\n{\n}\n\nCLAVVideoSubtitleInputPin::~CLAVVideoSubtitleInputPin(void)\n{\n    SafeRelease(&m_pConsumer);\n    SafeRelease(&m_pProvider);\n}\n\nSTDMETHODIMP CLAVVideoSubtitleInputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    return QI(IKsPropertySet) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\nHRESULT CLAVVideoSubtitleInputPin::CheckMediaType(const CMediaType *mtIn)\n{\n    for (int i = 0; i < countof(lav_subtitle_codecs); i++)\n    {\n        if (*lav_subtitle_codecs[i].clsMajorType == mtIn->majortype &&\n            *lav_subtitle_codecs[i].clsMinorType == mtIn->subtype &&\n            (mtIn->formattype == FORMAT_SubtitleInfo || mtIn->formattype == FORMAT_MPEG2_VIDEO))\n        {\n            return S_OK;\n        }\n    }\n    return VFW_E_TYPE_NOT_ACCEPTED;\n}\n\nHRESULT CLAVVideoSubtitleInputPin::SetMediaType(const CMediaType *pmt)\n{\n    CAutoLock lock(&m_csReceive);\n    SetCSSMediaType(pmt);\n\n    ASSERT(m_pConsumer);\n    SafeRelease(&m_pProvider);\n\n    AVCodecID codecId = AV_CODEC_ID_NONE;\n    for (int i = 0; i < countof(lav_subtitle_codecs); i++)\n    {\n        if (*lav_subtitle_codecs[i].clsMajorType == pmt->majortype &&\n            *lav_subtitle_codecs[i].clsMinorType == pmt->subtype)\n        {\n            codecId = lav_subtitle_codecs[i].nFFCodec;\n        }\n    }\n\n    if (codecId == AV_CODEC_ID_NONE)\n        return VFW_E_TYPE_NOT_ACCEPTED;\n\n    m_pProvider = new CLAVSubtitleProvider(m_pLAVVideo, m_pConsumer);\n    m_pProvider->AddRef();\n    HRESULT hr = m_pProvider->InitDecoder(pmt, codecId);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"Subtitle Decoder Init failed....\"));\n        return hr;\n    }\n    return __super::SetMediaType(pmt);\n}\n\nHRESULT CLAVVideoSubtitleInputPin::BreakConnect()\n{\n    if (m_pProvider)\n    {\n        m_pProvider->DisconnectConsumer();\n        SafeRelease(&m_pProvider);\n    }\n    return __super::BreakConnect();\n}\n\nSTDMETHODIMP CLAVVideoSubtitleInputPin::BeginFlush()\n{\n    return __super::BeginFlush();\n}\n\nSTDMETHODIMP CLAVVideoSubtitleInputPin::EndFlush()\n{\n    CAutoLock lock(&m_csReceive);\n    DbgLog((LOG_TRACE, 10, L\"CLAVVideoSubtitleInputPin::EndFlush()\"));\n    if (m_pProvider)\n    {\n        m_pProvider->Flush();\n    }\n    return __super::EndFlush();\n}\n\nHRESULT CLAVVideoSubtitleInputPin::SetSubtitleConsumer(ISubRenderConsumer *pConsumer)\n{\n    if (pConsumer == m_pConsumer)\n        return S_OK;\n\n    SafeRelease(&m_pConsumer);\n    m_pConsumer = pConsumer;\n    m_pConsumer->AddRef();\n\n    if (m_pProvider)\n    {\n        m_pProvider->DisconnectConsumer();\n        m_pProvider->SetConsumer(pConsumer);\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideoSubtitleInputPin::Receive(IMediaSample *pSample)\n{\n    CAutoLock lock(&m_csReceive);\n    HRESULT hr = S_OK;\n    Decrypt(pSample);\n\n    ASSERT(m_pProvider);\n\n    hr = CBaseInputPin::Receive(pSample);\n    if (hr == S_OK)\n    {\n        long len = pSample->GetActualDataLength();\n        BYTE *pBuffer = nullptr;\n        if (FAILED(hr = pSample->GetPointer(&pBuffer)))\n        {\n            DbgLog((LOG_TRACE, 10, L\"CLAVVideoSubtitleInputPin::Receive() GetPointer failed\"));\n            return S_OK;\n        }\n\n        StripPacket(pBuffer, len);\n\n        REFERENCE_TIME rtStart, rtStop;\n        hr = pSample->GetTime(&rtStart, &rtStop);\n        if (hr == VFW_S_NO_STOP_TIME)\n        {\n            rtStop = AV_NOPTS_VALUE;\n        }\n        else if (FAILED(hr))\n        {\n            rtStart = rtStop = AV_NOPTS_VALUE;\n        }\n\n        m_pProvider->Decode(pBuffer, len, rtStart, rtStop);\n    }\n\n    return S_OK;\n}\n\n// IKsPropertySet\nSTDMETHODIMP CLAVVideoSubtitleInputPin::Set(REFGUID PropSet, ULONG Id, LPVOID pInstanceData, ULONG InstanceLength,\n                                            LPVOID pPropertyData, ULONG DataLength)\n{\n    if (PropSet != AM_KSPROPSETID_DvdSubPic)\n    {\n        return __super::Set(PropSet, Id, pInstanceData, InstanceLength, pPropertyData, DataLength);\n    }\n\n    switch (Id)\n    {\n    case AM_PROPERTY_DVDSUBPIC_PALETTE: {\n        AM_PROPERTY_SPPAL *pSPPAL = (AM_PROPERTY_SPPAL *)pPropertyData;\n        if (m_pProvider)\n        {\n            m_pProvider->SetDVDPalette(pSPPAL);\n        }\n    }\n    break;\n    case AM_PROPERTY_DVDSUBPIC_HLI: {\n        AM_PROPERTY_SPHLI *pSPHLI = (AM_PROPERTY_SPHLI *)pPropertyData;\n        if (pSPHLI->HLISS)\n        {\n            if (m_pProvider)\n            {\n                m_pProvider->SetDVDHLI(pSPHLI);\n            }\n        }\n        else\n        {\n            if (m_pProvider)\n            {\n                m_pProvider->SetDVDHLI(nullptr);\n            }\n        }\n    }\n    break;\n    case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON: {\n        AM_PROPERTY_COMPOSIT_ON *pCompositOn = (AM_PROPERTY_COMPOSIT_ON *)pPropertyData;\n        DbgLog((LOG_TRACE, 10, L\"Composit Event - on: %d\", *pCompositOn));\n        m_pProvider->SetDVDComposit(*pCompositOn);\n    }\n    break;\n    default: return E_PROP_ID_UNSUPPORTED;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVVideoSubtitleInputPin::QuerySupported(REFGUID PropSet, ULONG Id, ULONG *pTypeSupport)\n{\n    if (PropSet != AM_KSPROPSETID_DvdSubPic)\n    {\n        return __super::QuerySupported(PropSet, Id, pTypeSupport);\n    }\n\n    switch (Id)\n    {\n    case AM_PROPERTY_DVDSUBPIC_PALETTE: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    case AM_PROPERTY_DVDSUBPIC_HLI: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    case AM_PROPERTY_DVDSUBPIC_COMPOSIT_ON: *pTypeSupport = KSPROPERTY_SUPPORT_SET; break;\n    default: return E_PROP_ID_UNSUPPORTED;\n    }\n\n    return S_OK;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/LAVVideoSubtitleInputPin.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"DeCSS/DeCSSInputPin.h\"\n#include \"SubRenderIntf.h\"\n\n#include \"LAVSubtitleProvider.h\"\n\nclass CLAVVideo;\n\nclass CLAVVideoSubtitleInputPin\n    : public CBaseInputPin\n    , public CDeCSSPinHelper\n{\n  public:\n    CLAVVideoSubtitleInputPin(TCHAR *pObjectName, CLAVVideo *pFilter, CCritSec *pcsFilter, HRESULT *phr, LPWSTR pName);\n    virtual ~CLAVVideoSubtitleInputPin(void);\n\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // IMemInputPin\n    STDMETHODIMP Receive(IMediaSample *pSample);\n\n    // CBasePin\n    HRESULT CheckMediaType(const CMediaType *mtIn);\n    HRESULT SetMediaType(const CMediaType *pmt);\n    HRESULT BreakConnect();\n    STDMETHODIMP BeginFlush();\n    STDMETHODIMP EndFlush();\n\n    HRESULT SetSubtitleConsumer(ISubRenderConsumer *pConsumer);\n\n    // KsPropertySet\n    STDMETHODIMP Set(REFGUID PropSet, ULONG Id, LPVOID InstanceData, ULONG InstanceLength, LPVOID PropertyData,\n                     ULONG DataLength);\n    STDMETHODIMP QuerySupported(REFGUID PropSet, ULONG Id, ULONG *pTypeSupport);\n\n  protected:\n    CCritSec m_csReceive;\n\n    ISubRenderConsumer *m_pConsumer = nullptr;\n    CLAVSubtitleProvider *m_pProvider = nullptr;\n    CLAVVideo *m_pLAVVideo = nullptr;\n};\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/SubRenderOptionsImpl.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"SubRenderOptionsImpl.h\"\n\nstatic const SubRenderOption *sropt_next(const SubRenderOption *options, const SubRenderOption *last)\n{\n    if (!last && options[0].name)\n        return options;\n    if (last && last[1].name)\n        return ++last;\n    return nullptr;\n}\n\nstatic const SubRenderOption *sropt_find_option(const SubRenderOption *options, LPCSTR name, int flags)\n{\n    const SubRenderOption *o = nullptr;\n    while (o = sropt_next(options, o))\n    {\n        if (!_stricmp(o->name, name) && !(o->flags & flags))\n        {\n            return o;\n        }\n    }\n    return nullptr;\n}\n\n#define GET_OPT_AND_VALIDATE(t)                                      \\\n    const SubRenderOption *o = sropt_find_option(options, field, 0); \\\n    CheckPointer(value, E_POINTER);                                  \\\n    CheckPointer(o, E_INVALIDARG);                                   \\\n    if (o->type != t)                                                \\\n        return E_INVALIDARG;\n\n#define GET_VALUE memcpy(value, ((uint8_t *)context) + o->offset, sizeof(*value));\n\n#define SET_OPT_AND_VALIDATE(t)                                                        \\\n    const SubRenderOption *o = sropt_find_option(options, field, SROPT_FLAG_READONLY); \\\n    CheckPointer(o, E_INVALIDARG);                                                     \\\n    if (o->type != t)                                                                  \\\n        return E_INVALIDARG;\n\n#define SET_VALUE                                                    \\\n    memcpy(((uint8_t *)context) + o->offset, &value, sizeof(value)); \\\n    OnSubOptionSet(field);\n\nSTDMETHODIMP CSubRenderOptionsImpl::GetBool(LPCSTR field, bool *value)\n{\n    GET_OPT_AND_VALIDATE(SROPT_TYPE_BOOL)\n    GET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::GetInt(LPCSTR field, int *value)\n{\n    GET_OPT_AND_VALIDATE(SROPT_TYPE_INT)\n    GET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::GetSize(LPCSTR field, SIZE *value)\n{\n    GET_OPT_AND_VALIDATE(SROPT_TYPE_SIZE)\n    GET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::GetRect(LPCSTR field, RECT *value)\n{\n    GET_OPT_AND_VALIDATE(SROPT_TYPE_RECT)\n    GET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::GetUlonglong(LPCSTR field, ULONGLONG *value)\n{\n    GET_OPT_AND_VALIDATE(SROPT_TYPE_ULONGLONG)\n    GET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::GetDouble(LPCSTR field, double *value)\n{\n    GET_OPT_AND_VALIDATE(SROPT_TYPE_DOUBLE)\n    GET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::GetString(LPCSTR field, LPWSTR *value, int *chars)\n{\n    GET_OPT_AND_VALIDATE(SROPT_TYPE_STRING)\n    CheckPointer(chars, E_POINTER);\n\n    const LPWSTR string = *(LPWSTR *)(((uint8_t *)context) + o->offset);\n    if (!string)\n    {\n        *value = nullptr;\n        *chars = 0;\n        return S_OK;\n    }\n\n    *chars = (int)wcslen(string);\n    *value = (LPWSTR)LocalAlloc(0, sizeof(WCHAR) * (*chars + 1));\n    CheckPointer(*value, E_OUTOFMEMORY);\n    wcscpy_s(*value, *chars + 1, string);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::GetBin(LPCSTR field, LPVOID *value, int *size)\n{\n    GET_OPT_AND_VALIDATE(SROPT_TYPE_BIN)\n    CheckPointer(size, E_POINTER);\n    return E_NOTIMPL;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::SetBool(LPCSTR field, bool value)\n{\n    SET_OPT_AND_VALIDATE(SROPT_TYPE_BOOL)\n    SET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::SetInt(LPCSTR field, int value)\n{\n    SET_OPT_AND_VALIDATE(SROPT_TYPE_INT)\n    SET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::SetSize(LPCSTR field, SIZE value)\n{\n    SET_OPT_AND_VALIDATE(SROPT_TYPE_SIZE)\n    SET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::SetRect(LPCSTR field, RECT value)\n{\n    SET_OPT_AND_VALIDATE(SROPT_TYPE_RECT)\n    SET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::SetUlonglong(LPCSTR field, ULONGLONG value)\n{\n    SET_OPT_AND_VALIDATE(SROPT_TYPE_ULONGLONG)\n    SET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::SetDouble(LPCSTR field, double value)\n{\n    SET_OPT_AND_VALIDATE(SROPT_TYPE_DOUBLE)\n    SET_VALUE\n    return S_OK;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::SetString(LPCSTR field, LPWSTR value, int chars)\n{\n    SET_OPT_AND_VALIDATE(SROPT_TYPE_STRING)\n    return E_NOTIMPL;\n}\n\nSTDMETHODIMP CSubRenderOptionsImpl::SetBin(LPCSTR field, LPVOID value, int size)\n{\n    SET_OPT_AND_VALIDATE(SROPT_TYPE_BIN)\n    return E_NOTIMPL;\n}\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/SubRenderOptionsImpl.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n/** Enum for the different types */\nenum SubRenderOptionType\n{\n    SROPT_TYPE_BOOL,\n    SROPT_TYPE_INT,\n    SROPT_TYPE_SIZE,\n    SROPT_TYPE_RECT,\n    SROPT_TYPE_ULONGLONG,\n    SROPT_TYPE_DOUBLE,\n    SROPT_TYPE_STRING,\n    SROPT_TYPE_BIN\n};\n\ntypedef struct SubRenderOption\n{\n    /**\n     * Name of the field\n     */\n    LPCSTR name;\n\n    /**\n     * The offset relative to the options structure\n     */\n    int offset;\n\n    /**\n     * The type of the options\n     */\n    enum SubRenderOptionType type;\n\n    /**\n     * Flags\n     */\n    int flags;\n#define SROPT_FLAG_READONLY 1\n} SubRenderOption;\n\nclass CSubRenderOptionsImpl : public ISubRenderOptions\n{\n  public:\n    CSubRenderOptionsImpl(const struct SubRenderOption *options, void *context)\n        : options(options)\n        , context(context){};\n    virtual ~CSubRenderOptionsImpl(void){};\n\n    // ISubRenderOptions\n    STDMETHODIMP GetBool(LPCSTR field, bool *value);\n    STDMETHODIMP GetInt(LPCSTR field, int *value);\n    STDMETHODIMP GetSize(LPCSTR field, SIZE *value);\n    STDMETHODIMP GetRect(LPCSTR field, RECT *value);\n    STDMETHODIMP GetUlonglong(LPCSTR field, ULONGLONG *value);\n    STDMETHODIMP GetDouble(LPCSTR field, double *value);\n    STDMETHODIMP GetString(LPCSTR field, LPWSTR *value, int *chars);\n    STDMETHODIMP GetBin(LPCSTR field, LPVOID *value, int *size);\n\n    STDMETHODIMP SetBool(LPCSTR field, bool value);\n    STDMETHODIMP SetInt(LPCSTR field, int value);\n    STDMETHODIMP SetSize(LPCSTR field, SIZE value);\n    STDMETHODIMP SetRect(LPCSTR field, RECT value);\n    STDMETHODIMP SetUlonglong(LPCSTR field, ULONGLONG value);\n    STDMETHODIMP SetDouble(LPCSTR field, double value);\n    STDMETHODIMP SetString(LPCSTR field, LPWSTR value, int chars);\n    STDMETHODIMP SetBin(LPCSTR field, LPVOID value, int size);\n\n    virtual STDMETHODIMP OnSubOptionSet(LPCSTR field) { return E_NOTIMPL; }\n\n  private:\n    const SubRenderOption *options = nullptr;\n    void *context = nullptr;\n};\n\n#define DECLARE_ISUBRENDEROPTIONS                                                                                  \\\n    STDMETHODIMP GetBool(LPCSTR field, bool *value) { return CSubRenderOptionsImpl::GetBool(field, value); }       \\\n    STDMETHODIMP GetInt(LPCSTR field, int *value) { return CSubRenderOptionsImpl::GetInt(field, value); }          \\\n    STDMETHODIMP GetSize(LPCSTR field, SIZE *value) { return CSubRenderOptionsImpl::GetSize(field, value); }       \\\n    STDMETHODIMP GetRect(LPCSTR field, RECT *value) { return CSubRenderOptionsImpl::GetRect(field, value); }       \\\n    STDMETHODIMP GetUlonglong(LPCSTR field, ULONGLONG *value)                                                      \\\n    {                                                                                                              \\\n        return CSubRenderOptionsImpl::GetUlonglong(field, value);                                                  \\\n    }                                                                                                              \\\n    STDMETHODIMP GetDouble(LPCSTR field, double *value) { return CSubRenderOptionsImpl::GetDouble(field, value); } \\\n    STDMETHODIMP GetString(LPCSTR field, LPWSTR *value, int *chars)                                                \\\n    {                                                                                                              \\\n        return CSubRenderOptionsImpl::GetString(field, value, chars);                                              \\\n    }                                                                                                              \\\n    STDMETHODIMP GetBin(LPCSTR field, LPVOID *value, int *size)                                                    \\\n    {                                                                                                              \\\n        return CSubRenderOptionsImpl::GetBin(field, value, size);                                                  \\\n    }                                                                                                              \\\n                                                                                                                   \\\n    STDMETHODIMP SetBool(LPCSTR field, bool value) { return CSubRenderOptionsImpl::SetBool(field, value); }        \\\n    STDMETHODIMP SetInt(LPCSTR field, int value) { return CSubRenderOptionsImpl::SetInt(field, value); }           \\\n    STDMETHODIMP SetSize(LPCSTR field, SIZE value) { return CSubRenderOptionsImpl::SetSize(field, value); }        \\\n    STDMETHODIMP SetRect(LPCSTR field, RECT value) { return CSubRenderOptionsImpl::SetRect(field, value); }        \\\n    STDMETHODIMP SetUlonglong(LPCSTR field, ULONGLONG value)                                                       \\\n    {                                                                                                              \\\n        return CSubRenderOptionsImpl::SetUlonglong(field, value);                                                  \\\n    }                                                                                                              \\\n    STDMETHODIMP SetDouble(LPCSTR field, double value) { return CSubRenderOptionsImpl::SetDouble(field, value); }  \\\n    STDMETHODIMP SetString(LPCSTR field, LPWSTR value, int chars)                                                  \\\n    {                                                                                                              \\\n        return CSubRenderOptionsImpl::SetString(field, value, chars);                                              \\\n    }                                                                                                              \\\n    STDMETHODIMP SetBin(LPCSTR field, LPVOID value, int size)                                                      \\\n    {                                                                                                              \\\n        return CSubRenderOptionsImpl::SetBin(field, value, size);                                                  \\\n    }\n"
  },
  {
    "path": "decoder/LAVVideo/subtitles/blend/blend_generic.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"../LAVSubtitleConsumer.h\"\n\n#define FAST_DIV255(x) ((((x) + 128) * 257) >> 16)\n\nDECLARE_BLEND_FUNC_IMPL(blend_rgb_c)\n{\n    ASSERT(pixFmt == LAVPixFmt_RGB32 || pixFmt == LAVPixFmt_RGB24);\n\n    BYTE *rgbOut = video[0];\n    const BYTE *subIn = subData[0];\n\n    const ptrdiff_t outStride = videoStride[0];\n    const ptrdiff_t inStride = subStride[0];\n\n    const ptrdiff_t dstep = (pixFmt == LAVPixFmt_RGB24) ? 3 : 4;\n\n    for (int y = 0; y < size.cy; y++)\n    {\n        BYTE *dstLine = rgbOut + ((y + position.y) * outStride) + (position.x * dstep);\n        const BYTE *srcLine = subIn + (y * inStride);\n        for (int x = 0; x < size.cx; x++)\n        {\n            const BYTE a = srcLine[3];\n            switch (a)\n            {\n            case 0: break;\n            case 255:\n                dstLine[0] = srcLine[0];\n                dstLine[1] = srcLine[1];\n                dstLine[2] = srcLine[2];\n                break;\n            default:\n                dstLine[0] = av_clip_uint8(FAST_DIV255(dstLine[0] * (255 - a)) + srcLine[0]);\n                dstLine[1] = av_clip_uint8(FAST_DIV255(dstLine[1] * (255 - a)) + srcLine[1]);\n                dstLine[2] = av_clip_uint8(FAST_DIV255(dstLine[2] * (255 - a)) + srcLine[2]);\n                break;\n            }\n            dstLine += dstep;\n            srcLine += 4;\n        }\n    }\n\n    return S_OK;\n}\n\ntemplate <class pixT, int nv12> DECLARE_BLEND_FUNC_IMPL(blend_yuv_c)\n{\n    ASSERT(pixFmt == LAVPixFmt_YUV420 || pixFmt == LAVPixFmt_NV12 || pixFmt == LAVPixFmt_YUV422 ||\n           pixFmt == LAVPixFmt_YUV444 || pixFmt == LAVPixFmt_YUV420bX || pixFmt == LAVPixFmt_YUV422bX ||\n           pixFmt == LAVPixFmt_YUV444bX || pixFmt == LAVPixFmt_P016);\n\n    BYTE *y = video[0];\n    BYTE *u = video[1];\n    BYTE *v = video[2];\n\n    const BYTE *subY = subData[0];\n    const BYTE *subU = subData[1];\n    const BYTE *subV = subData[2];\n    const BYTE *subA = subData[3];\n\n    const ptrdiff_t outStride = videoStride[0];\n    const ptrdiff_t outStrideUV = videoStride[1];\n    const ptrdiff_t inStride = subStride[0];\n    const ptrdiff_t inStrideUV = subStride[1];\n\n    int line, col;\n    int w = size.cx, h = size.cy;\n    int yPos = position.y;\n    int xPos = position.x;\n\n    const int hsub = nv12 || (pixFmt == LAVPixFmt_YUV420 || pixFmt == LAVPixFmt_YUV420bX || pixFmt == LAVPixFmt_NV12);\n    const int vsub = nv12 || (pixFmt != LAVPixFmt_YUV444 && pixFmt != LAVPixFmt_YUV444bX);\n    const int shift = sizeof(pixT) > 1 ? bpp - 8 : 0;\n\n    for (line = 0; line < h; line++)\n    {\n        pixT *dstY = (pixT *)(y + ((line + yPos) * outStride)) + xPos;\n        const BYTE *srcY = subY + (line * inStride);\n        const BYTE *srcA = subA + (line * inStride);\n        for (col = 0; col < w; col++)\n        {\n            switch (srcA[col])\n            {\n            case 0: break;\n            case 255: dstY[col] = srcY[col] << shift; break;\n            default: dstY[col] = FAST_DIV255(dstY[col] * (255 - srcA[col]) + (srcY[col] << shift) * srcA[col]); break;\n            }\n        }\n    }\n\n    if (hsub)\n    {\n        w >>= 1;\n        xPos >>= 1;\n    }\n    if (vsub)\n    {\n        h >>= 1;\n        yPos >>= 1;\n    }\n\n    for (line = 0; line < h; line++)\n    {\n        pixT *dstUV = (pixT *)(u + (line + yPos) * outStrideUV) + (xPos << 1);\n\n        pixT *dstU = (pixT *)(u + (line + yPos) * outStrideUV) + xPos;\n        const BYTE *srcU = subU + line * inStrideUV;\n\n        pixT *dstV = (pixT *)(v + (line + yPos) * outStrideUV) + xPos;\n        const BYTE *srcV = subV + line * inStrideUV;\n\n        const BYTE *srcA = subA + (line * inStride * (ptrdiff_t(1) << hsub));\n        for (col = 0; col < w; col++)\n        {\n            // Average Alpha\n            int alpha;\n            if (hsub && vsub && col + 1 < w && line + 1 < h)\n            {\n                alpha = (srcA[0] + srcA[inStride] + srcA[1] + srcA[inStride + 1]) >> 2;\n            }\n            else if (hsub || vsub)\n            {\n                int alpha_h = hsub && col + 1 < w ? (srcA[0] + srcA[1]) >> 1 : srcA[0];\n                int alpha_v = vsub && line + 1 < h ? (srcA[0] + srcA[inStride]) >> 1 : srcA[0];\n                alpha = (alpha_h + alpha_v) >> 1;\n            }\n            else\n            {\n                alpha = srcA[0];\n            }\n            if (nv12)\n            {\n                switch (alpha)\n                {\n                case 0: break;\n                case 255:\n                    dstUV[(col << 1) + 0] = srcU[col] << shift;\n                    dstUV[(col << 1) + 1] = srcV[col] << shift;\n                    break;\n                default:\n                    dstUV[(col << 1) + 0] =\n                        FAST_DIV255(dstUV[(col << 1) + 0] * (255 - alpha) + (srcU[col] << shift) * alpha);\n                    dstUV[(col << 1) + 1] =\n                        FAST_DIV255(dstUV[(col << 1) + 1] * (255 - alpha) + (srcV[col] << shift) * alpha);\n                    break;\n                }\n            }\n            else\n            {\n                switch (alpha)\n                {\n                case 0: break;\n                case 255:\n                    dstU[col] = srcU[col] << shift;\n                    dstV[col] = srcV[col] << shift;\n                    break;\n                default:\n                    dstU[col] = FAST_DIV255(dstU[col] * (255 - alpha) + (srcU[col] << shift) * alpha);\n                    dstV[col] = FAST_DIV255(dstV[col] * (255 - alpha) + (srcV[col] << shift) * alpha);\n                    break;\n                }\n            }\n            srcA += ptrdiff_t(1) << vsub;\n        }\n    }\n\n    return S_OK;\n}\n\ntemplate HRESULT CLAVSubtitleConsumer::blend_yuv_c<uint8_t, 1> BLEND_FUNC_PARAMS;\ntemplate HRESULT CLAVSubtitleConsumer::blend_yuv_c<uint8_t, 0> BLEND_FUNC_PARAMS;\ntemplate HRESULT CLAVSubtitleConsumer::blend_yuv_c<uint16_t, 0> BLEND_FUNC_PARAMS;\ntemplate HRESULT CLAVSubtitleConsumer::blend_yuv_c<uint16_t, 1> BLEND_FUNC_PARAMS;\n"
  },
  {
    "path": "demuxer/Demuxers/BDDemuxer.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"BDDemuxer.h\"\n#include \"libbluray/bdnav/mpls_data.h\"\n\nextern \"C\"\n{\n#include \"libavutil/avstring.h\"\n};\n\n#define BD_READ_BUFFER_SIZE (6144 * 20)\n\nint CBDDemuxer::BDByteStreamRead(void *opaque, uint8_t *buf, int buf_size)\n{\n    CBDDemuxer *demux = (CBDDemuxer *)opaque;\n    int ret = bd_read(demux->m_pBD, buf, buf_size);\n    return (ret != 0) ? ret : AVERROR_EOF;\n}\n\nint64_t CBDDemuxer::BDByteStreamSeek(void *opaque, int64_t offset, int whence)\n{\n    CBDDemuxer *demux = (CBDDemuxer *)opaque;\n    BLURAY *bd = demux->m_pBD;\n\n    int64_t pos = 0;\n    if (whence == SEEK_SET)\n    {\n        pos = offset;\n    }\n    else if (whence == SEEK_CUR)\n    {\n        if (offset == 0)\n            return bd_tell(bd);\n        pos = bd_tell(bd) + offset;\n    }\n    else if (whence == SEEK_END)\n    {\n        pos = bd_get_title_size(bd) - offset;\n    }\n    else if (whence == AVSEEK_SIZE)\n    {\n        return bd_get_title_size(bd);\n    }\n    else\n        return -1;\n    if (pos < 0)\n        pos = 0;\n    int64_t achieved = bd_seek(bd, pos);\n    if (pos > achieved)\n    {\n        offset = pos - achieved;\n        DbgLog((LOG_TRACE, 10, L\"BD Seek to %I64d, achieved %I64d, correcting target by %I64d\", pos, achieved, offset));\n        uint8_t *dump_buffer = (uint8_t *)CoTaskMemAlloc(6144);\n        while (offset > 0)\n        {\n            int to_read = (int)min(offset, 6144);\n            int did_read = bd_read(bd, dump_buffer, to_read);\n            offset -= did_read;\n            if (did_read < to_read)\n            {\n                DbgLog((LOG_TRACE, 10, L\"Reached EOF with %I64d offset remaining\", offset));\n                break;\n            }\n        }\n        CoTaskMemFree(dump_buffer);\n        achieved = bd_tell(bd);\n    }\n\n    demux->ProcessBDEvents();\n    return achieved;\n}\n\nstatic inline REFERENCE_TIME Convert90KhzToDSTime(int64_t timestamp)\n{\n    return av_rescale(timestamp, 1000, 9);\n}\n\nstatic inline int64_t ConvertDSTimeTo90Khz(REFERENCE_TIME timestamp)\n{\n    return av_rescale(timestamp, 9, 1000);\n}\n\n#ifdef DEBUG\nstatic void bd_log(const char *log)\n{\n    const char *path = __FILE__;\n    const char *subpath = \"libbluray\\\\src\\\\\";\n    // skip the path these two have in common\n    while (*log == *path)\n    {\n        log++;\n        path++;\n    }\n    while (*log == *subpath)\n    {\n        log++;\n        subpath++;\n    }\n    wchar_t line[4096] = {0};\n    size_t len = strlen(log);\n    if (log[len - 1] == '\\n')\n    {\n        len--;\n    }\n    SafeMultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, log, (int)len, line, 4096);\n    DbgLog((LOG_TRACE, 40, L\"[BD] %s\", line));\n}\n#endif\n\nCBDDemuxer::CBDDemuxer(CCritSec *pLock, ILAVFSettingsInternal *pSettings)\n    : CBaseDemuxer(L\"bluray demuxer\", pLock)\n    , m_pSettings(pSettings)\n{\n#ifdef DEBUG\n    bd_set_debug_mask(DBG_FILE | DBG_BLURAY | DBG_DIR | DBG_NAV | DBG_CRIT);\n    bd_set_debug_handler(&bd_log);\n#else\n    bd_set_debug_mask(0);\n#endif\n}\n\nCBDDemuxer::~CBDDemuxer(void)\n{\n    CloseMVCExtensionDemuxer();\n\n    if (m_pTitle)\n    {\n        bd_free_title_info(m_pTitle);\n        m_pTitle = nullptr;\n    }\n\n    if (m_pBD)\n    {\n        bd_close(m_pBD);\n        m_pBD = nullptr;\n    }\n\n    if (m_pb)\n    {\n        av_free(m_pb->buffer);\n        av_free(m_pb);\n    }\n\n    SafeRelease(&m_lavfDemuxer);\n    SAFE_CO_FREE(m_StreamClip);\n    SAFE_CO_FREE(m_rtOffset);\n}\n\nSTDMETHODIMP CBDDemuxer::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    *ppv = nullptr;\n\n    if (m_lavfDemuxer &&\n        (riid == __uuidof(IKeyFrameInfo) || riid == __uuidof(ITrackInfo) || riid == __uuidof(IPropertyBag)))\n    {\n        return m_lavfDemuxer->QueryInterface(riid, ppv);\n    }\n\n    return QI2(IAMExtendedSeeking) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// Demuxer Functions\nSTDMETHODIMP CBDDemuxer::Open(LPCOLESTR pszFileName, LPCOLESTR pszUserAgent, LPCOLESTR pszReferrer)\n{\n    CAutoLock lock(m_pLock);\n    HRESULT hr = S_OK;\n\n    int ret; // return code from C functions\n\n    // Convert the filename from wchar to char for libbluray\n    char fileName[4096];\n    ret = SafeWideCharToMultiByte(CP_UTF8, 0, pszFileName, -1, fileName, 4096, nullptr, nullptr);\n\n    int iPlaylist = -1;\n\n    DbgLog((LOG_TRACE, 10, L\"Initializing BluRay Demuxer; Entry Point: %s\", pszFileName));\n\n    size_t len = strlen(fileName);\n    if (len > 16)\n    {\n        char *bd_path = fileName;\n        if (_strcmpi(bd_path + strlen(bd_path) - 16, \"\\\\BDMV\\\\index.bdmv\") == 0)\n        {\n            bd_path[strlen(bd_path) - 15] = 0;\n        }\n        else if (len > 22 && _strcmpi(bd_path + strlen(bd_path) - 22, \"\\\\BDMV\\\\MovieObject.bdmv\") == 0)\n        {\n            bd_path[strlen(bd_path) - 21] = 0;\n        }\n        else if (len > 25 && _strnicmp(bd_path + strlen(bd_path) - 25, \"\\\\BDMV\\\\PLAYLIST\\\\\", 15) == 0)\n        {\n            char *playlist = &bd_path[strlen(bd_path) - 10];\n            bd_path[strlen(bd_path) - 24] = 0;\n\n            playlist[5] = 0;\n            iPlaylist = atoi(playlist);\n        }\n        else\n        {\n            return E_FAIL;\n        }\n        // Open BluRay\n        BLURAY *bd = bd_open(bd_path, nullptr);\n        if (!bd)\n        {\n            return E_FAIL;\n        }\n        m_pBD = bd;\n        strcpy_s(m_cBDRootPath, bd_path);\n\n        uint32_t timelimit = (iPlaylist != -1) ? 0 : 180;\n        uint8_t flags = (iPlaylist != -1) ? TITLES_ALL : TITLES_RELEVANT;\n\n        // Fetch titles\n    fetchtitles:\n        m_nTitleCount = bd_get_titles(bd, flags, timelimit);\n\n        if (m_nTitleCount <= 0)\n        {\n            if (timelimit > 0)\n            {\n                timelimit = 0;\n                goto fetchtitles;\n            }\n            if (flags != TITLES_ALL)\n            {\n                flags = TITLES_ALL;\n                goto fetchtitles;\n            }\n            return E_FAIL;\n        }\n\n        DbgLog((LOG_TRACE, 20, L\"Found %d titles\", m_nTitleCount));\n        DbgLog((LOG_TRACE, 20, L\" ------ Begin Title Listing ------\"));\n\n        uint64_t longest_duration = 0;\n        uint32_t title_id = 0;\n        boolean found = false;\n        for (uint32_t i = 0; i < m_nTitleCount; i++)\n        {\n            BLURAY_TITLE_INFO *info = bd_get_title_info(bd, i, 0);\n            if (info)\n            {\n                DbgLog((LOG_TRACE, 20, L\"Title %u, Playlist %u (%u clips, %u chapters), Duration %I64u (%I64u seconds)\",\n                        i, info->playlist, info->clip_count, info->chapter_count, info->duration,\n                        Convert90KhzToDSTime(info->duration) / DSHOW_TIME_BASE));\n                if (iPlaylist != -1 && info->playlist == iPlaylist)\n                {\n                    title_id = i;\n                    found = true;\n                }\n                else if (iPlaylist == -1 && info->duration > longest_duration)\n                {\n                    title_id = i;\n                    longest_duration = info->duration;\n                }\n                bd_free_title_info(info);\n            }\n            if (found)\n                break;\n        }\n        DbgLog((LOG_TRACE, 20, L\" ------ End Title Listing ------\"));\n\n        hr = SetTitle(title_id);\n    }\n\n    return hr;\n}\n\nSTDMETHODIMP CBDDemuxer::Start()\n{\n    HRESULT hr = m_lavfDemuxer->Start();\n    if (m_MVCPlayback && !m_lavfDemuxer->m_bH264MVCCombine)\n    {\n        CloseMVCExtensionDemuxer();\n        m_MVCPlayback = FALSE;\n    }\n\n    return hr;\n}\n\nREFERENCE_TIME CBDDemuxer::GetDuration() const\n{\n    if (m_pTitle)\n    {\n        return av_rescale(m_pTitle->duration, 1000, 9);\n    }\n    return m_lavfDemuxer->GetDuration();\n}\n\nvoid CBDDemuxer::ProcessBDEvents()\n{\n    // Check for clip change\n    BD_EVENT event;\n    while (bd_get_event(m_pBD, &event))\n    {\n        if (event.event == BD_EVENT_PLAYITEM)\n        {\n            uint64_t clip_start, clip_in, bytepos;\n            int ret = bd_get_clip_infos(m_pBD, event.param, &clip_start, &clip_in, &bytepos, nullptr);\n            if (ret && m_lavfDemuxer->GetStartTime() != AV_NOPTS_VALUE)\n            {\n                m_rtNewOffset = Convert90KhzToDSTime(clip_start - clip_in) + m_lavfDemuxer->GetStartTime();\n                m_bNewOffsetPos = bytepos - 4;\n                m_NewClip = event.param;\n                DbgLog((LOG_TRACE, 10, L\"New clip! offset: %I64d bytepos: %I64u\", m_rtNewOffset, bytepos));\n            }\n            m_EndOfStreamPacketFlushProtection = FALSE;\n        }\n        else if (event.event == BD_EVENT_END_OF_TITLE)\n        {\n            m_EndOfStreamPacketFlushProtection = TRUE;\n        }\n        else if (event.event == BD_EVENT_SEEK)\n        {\n            m_EndOfStreamPacketFlushProtection = FALSE;\n        }\n    }\n}\n\nSTDMETHODIMP CBDDemuxer::ProcessPacket(Packet *pPacket)\n{\n    ProcessBDEvents();\n\n    if (pPacket && pPacket->rtStart != Packet::INVALID_TIME)\n    {\n        REFERENCE_TIME rtOffset = m_rtOffset[pPacket->StreamId];\n        if (m_StreamClip[pPacket->StreamId] != m_NewClip && pPacket->bPosition != -1 &&\n            pPacket->bPosition >= m_bNewOffsetPos)\n        {\n            DbgLog((LOG_TRACE, 10,\n                    L\"Actual clip change detected in stream %d; time: %I64d, old offset: %I64d, new offset: %I64d\",\n                    pPacket->StreamId, pPacket->rtStart, rtOffset, m_rtNewOffset));\n            rtOffset = m_rtOffset[pPacket->StreamId] = m_rtNewOffset;\n            m_StreamClip[pPacket->StreamId] = m_NewClip;\n\n            // Flush MVC extensions on stream change, it'll re-fill automatically\n            if (m_MVCPlayback && pPacket->StreamId == m_lavfDemuxer->m_nH264MVCBaseStream &&\n                m_MVCExtensionClip != m_NewClip)\n            {\n                m_lavfDemuxer->FlushMVCExtensionQueue();\n                CloseMVCExtensionDemuxer();\n                OpenMVCExtensionDemuxer(m_NewClip);\n            }\n        }\n        // DbgLog((LOG_TRACE, 10, L\"Frame: stream: %d, start: %I64d, corrected: %I64d, bytepos: %I64d\",\n        // pPacket->StreamId, pPacket->rtStart, pPacket->rtStart + rtOffset, pPacket->bPosition));\n        pPacket->rtStart += rtOffset;\n        pPacket->rtStop += rtOffset;\n    }\n\n    if (m_EndOfStreamPacketFlushProtection && pPacket && pPacket->bPosition != -1)\n    {\n        if (pPacket->bPosition < m_bNewOffsetPos)\n        {\n            DbgLog((\n                LOG_TRACE, 10,\n                L\"Dropping packet from a previous segment (pos %I64d, segment started at %I64d) at EOS, from stream %d\",\n                pPacket->bPosition, m_bNewOffsetPos, pPacket->StreamId));\n            return S_FALSE;\n        }\n    }\n\n    return S_OK;\n}\n\nvoid CBDDemuxer::CloseMVCExtensionDemuxer()\n{\n    if (m_MVCFormatContext)\n        avformat_close_input(&m_MVCFormatContext);\n\n    m_MVCExtensionClip = -1;\n}\n\nSTDMETHODIMP CBDDemuxer::OpenMVCExtensionDemuxer(int playItem)\n{\n    int ret;\n    MPLS_PL *pl = bd_get_title_mpls(m_pBD);\n    if (!pl)\n        return E_FAIL;\n\n    const char *clip_id = pl->ext_sub_path[m_MVCExtensionSubPathIndex].sub_play_item[playItem].clip->clip_id;\n    char *fileName = av_asprintf(\"%sBDMV\\\\STREAM\\\\%s.m2ts\", m_cBDRootPath, clip_id);\n\n    DbgLog((LOG_TRACE, 10, \"CBDDemuxer::OpenMVCExtensionDemuxer(): Opening MVC extension stream at %s\", fileName));\n\n    // Try to open the MVC stream\n    const AVInputFormat *format = av_find_input_format(\"mpegts\");\n    ret = avformat_open_input(&m_MVCFormatContext, fileName, format, nullptr);\n    if (ret < 0)\n    {\n        DbgLog((LOG_TRACE, 10, \"-> Opening MVC demuxing context failed (%d)\", ret));\n        goto fail;\n    }\n\n    av_opt_set_int(m_MVCFormatContext, \"correct_ts_overflow\", 0, 0);\n\n    // Find the streams\n    ret = avformat_find_stream_info(m_MVCFormatContext, nullptr);\n    if (ret < 0)\n    {\n        DbgLog((LOG_TRACE, 10, \"-> avformat_find_stream_info failed (%d)\", ret));\n        goto fail;\n    }\n\n    // Find and select our MVC stream\n    DbgLog((LOG_TRACE, 10, \"-> MVC m2ts has %d streams\", m_MVCFormatContext->nb_streams));\n    for (unsigned i = 0; i < m_MVCFormatContext->nb_streams; i++)\n    {\n        if (m_MVCFormatContext->streams[i]->codecpar->codec_id == AV_CODEC_ID_H264_MVC &&\n            m_MVCFormatContext->streams[i]->codecpar->extradata_size > 0)\n        {\n            m_MVCStreamIndex = i;\n            break;\n        }\n        else\n        {\n            m_MVCFormatContext->streams[i]->discard = AVDISCARD_ALL;\n        }\n    }\n\n    if (m_MVCStreamIndex < 0)\n    {\n        DbgLog((LOG_TRACE, 10, \"-> MVC Stream not found\"));\n        goto fail;\n    }\n\n    m_MVCExtensionClip = playItem;\n\n    return S_OK;\nfail:\n    CloseMVCExtensionDemuxer();\n    return E_FAIL;\n}\n\n#define MVC_DEMUX_COUNT 100\nSTDMETHODIMP CBDDemuxer::FillMVCExtensionQueue(REFERENCE_TIME rtBase)\n{\n    if (!m_MVCFormatContext)\n        return E_FAIL;\n\n    int ret, count = 0;\n    bool found = (rtBase == Packet::INVALID_TIME);\n\n    AVPacket *pMVCPacket = av_packet_alloc();\n\n    while (count < MVC_DEMUX_COUNT)\n    {\n        av_packet_unref(pMVCPacket);\n        ret = av_read_frame(m_MVCFormatContext, pMVCPacket);\n\n        if (ret == AVERROR(EINTR) || ret == AVERROR(EAGAIN))\n        {\n            continue;\n        }\n        else if (ret == AVERROR_EOF)\n        {\n            DbgLog((LOG_TRACE, 10, L\"EOF reading MVC extension data\"));\n            break;\n        }\n        else if (pMVCPacket->size <= 0 || pMVCPacket->stream_index != m_MVCStreamIndex)\n        {\n            continue;\n        }\n        else\n        {\n            AVStream *stream = m_MVCFormatContext->streams[pMVCPacket->stream_index];\n\n            REFERENCE_TIME rtDTS =\n                m_lavfDemuxer->ConvertTimestampToRT(pMVCPacket->dts, stream->time_base.num, stream->time_base.den);\n            REFERENCE_TIME rtPTS =\n                m_lavfDemuxer->ConvertTimestampToRT(pMVCPacket->pts, stream->time_base.num, stream->time_base.den);\n\n            if (rtBase == Packet::INVALID_TIME || rtDTS == Packet::INVALID_TIME)\n            {\n                // do nothing, can't compare timestamps when they are not set\n            }\n            else if (rtDTS < rtBase)\n            {\n                DbgLog((LOG_TRACE, 10,\n                        L\"CBDDemuxer::FillMVCExtensionQueue(): Dropping MVC extension at %I64d, base is %I64d\", rtDTS,\n                        rtBase));\n                continue;\n            }\n            else if (rtDTS == rtBase)\n            {\n                found = true;\n            }\n\n            Packet *pPacket = new Packet();\n            if (!pPacket)\n            {\n                av_packet_free(&pMVCPacket);\n                return E_OUTOFMEMORY;\n            }\n\n            pPacket->SetPacket(pMVCPacket);\n            pPacket->rtDTS = rtDTS;\n            pPacket->rtPTS = rtPTS;\n\n            m_lavfDemuxer->QueueMVCExtension(pPacket);\n\n            count++;\n        }\n    };\n\n    av_packet_free(&pMVCPacket);\n\n    if (found)\n        return S_OK;\n    else if (count > 0)\n        return S_FALSE;\n    else\n        return E_FAIL;\n}\n\nSTDMETHODIMP CBDDemuxer::SetTitle(int idx)\n{\n    HRESULT hr = S_OK;\n    int ret; // return values\n    if (m_pTitle)\n    {\n        bd_free_title_info(m_pTitle);\n    }\n\n    // Init Event Queue\n    bd_get_event(m_pBD, nullptr);\n\n    // Select title\n    m_pTitle = bd_get_title_info(m_pBD, idx, 0);\n    ret = bd_select_title(m_pBD, idx);\n    if (ret == 0)\n    {\n        return E_FAIL;\n    }\n\n    MPLS_PL *mpls = bd_get_title_mpls(m_pBD);\n    if (mpls)\n    {\n        for (int i = 0; i < mpls->ext_sub_count; i++)\n        {\n            if (mpls->ext_sub_path[i].type == 8 && mpls->ext_sub_path[i].sub_playitem_count == mpls->list_count)\n            {\n                DbgLog((LOG_TRACE, 20, L\"CBDDemuxer::SetTitle(): Enabling BD3D MVC demuxing\"));\n                DbgLog((LOG_TRACE, 20, L\" -> MVC_Base_view_R_flag: %d\", m_pTitle->mvc_base_view_r_flag));\n                m_MVCPlayback = TRUE;\n                m_MVCExtensionSubPathIndex = i;\n                break;\n            }\n        }\n    }\n\n    CloseMVCExtensionDemuxer();\n\n    if (m_pb)\n    {\n        av_free(m_pb->buffer);\n        av_free(m_pb);\n    }\n\n    uint8_t *buffer = (uint8_t *)av_mallocz(BD_READ_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);\n    m_pb = avio_alloc_context(buffer, BD_READ_BUFFER_SIZE, 0, this, BDByteStreamRead, nullptr, BDByteStreamSeek);\n\n    SafeRelease(&m_lavfDemuxer);\n    SAFE_CO_FREE(m_StreamClip);\n    SAFE_CO_FREE(m_rtOffset);\n\n    m_lavfDemuxer = new CLAVFDemuxer(m_pLock, m_pSettings);\n    m_lavfDemuxer->AddRef();\n    m_lavfDemuxer->SetBluRay(this);\n    if (FAILED(hr = m_lavfDemuxer->OpenInputStream(m_pb, nullptr, \"mpegts\", TRUE)))\n    {\n        SafeRelease(&m_lavfDemuxer);\n        return hr;\n    }\n\n    if (m_MVCPlayback && !m_lavfDemuxer->m_bH264MVCCombine)\n    {\n        DbgLog((LOG_TRACE, 10,\n                L\"CBDDemuxer::SetTitle(): MVC demuxing was requested, but main demuxer did not activate MVC mode, \"\n                L\"disabling.\"));\n        CloseMVCExtensionDemuxer();\n        m_MVCPlayback = FALSE;\n    }\n\n    m_lavfDemuxer->SeekByte(0, 0);\n\n    // Process any events that occurred during opening\n    ProcessBDEvents();\n\n    // Reset EOS protection\n    m_EndOfStreamPacketFlushProtection = FALSE;\n\n    // space for storing stream offsets\n    m_StreamClip = (uint16_t *)CoTaskMemAlloc(sizeof(*m_StreamClip) * m_lavfDemuxer->GetNumStreams());\n    if (!m_StreamClip)\n        return E_OUTOFMEMORY;\n    memset(m_StreamClip, -1, sizeof(*m_StreamClip) * m_lavfDemuxer->GetNumStreams());\n\n    m_rtOffset = (REFERENCE_TIME *)CoTaskMemAlloc(sizeof(*m_rtOffset) * m_lavfDemuxer->GetNumStreams());\n    if (!m_rtOffset)\n        return E_OUTOFMEMORY;\n    memset(m_rtOffset, 0, sizeof(*m_rtOffset) * m_lavfDemuxer->GetNumStreams());\n\n    DbgLog((LOG_TRACE, 20, L\"Opened BD title with %d clips and %d chapters\", m_pTitle->clip_count,\n            m_pTitle->chapter_count));\n    return S_OK;\n}\n\nvoid CBDDemuxer::ProcessBluRayMetadata()\n{\n    if (m_MVCPlayback)\n    {\n        HRESULT hr = OpenMVCExtensionDemuxer(m_NewClip);\n        if (SUCCEEDED(hr))\n        {\n            AVStream *mvcStream = m_MVCFormatContext->streams[m_MVCStreamIndex];\n\n            // Create a fake stream and set the appropriate properties\n            m_lavfDemuxer->AddMPEGTSStream(mvcStream->id, 0x20);\n            AVStream *avstream = m_lavfDemuxer->GetAVStreamByPID(mvcStream->id);\n            if (avstream)\n            {\n                avstream->codecpar->codec_id = AV_CODEC_ID_H264_MVC;\n                avstream->codecpar->extradata =\n                    (BYTE *)av_mallocz(mvcStream->codecpar->extradata_size + AV_INPUT_BUFFER_PADDING_SIZE);\n                avstream->codecpar->extradata_size = mvcStream->codecpar->extradata_size;\n                memcpy(avstream->codecpar->extradata, mvcStream->codecpar->extradata,\n                       mvcStream->codecpar->extradata_size);\n            }\n        }\n        else\n        {\n            m_MVCPlayback = FALSE;\n        }\n    }\n\n    ASSERT(m_pTitle->clip_count >= 1 && m_pTitle->clips);\n    int64_t max_clip_duration = 0;\n    for (uint32_t i = 0; i < m_pTitle->clip_count; ++i)\n    {\n        int64_t clip_duration = (m_pTitle->clips[i].out_time - m_pTitle->clips[i].in_time);\n        bool overwrite_info = false;\n        if (clip_duration > max_clip_duration)\n        {\n            overwrite_info = true;\n            max_clip_duration = clip_duration;\n        }\n        CLPI_CL *clpi = bd_get_clpi(m_pBD, i);\n        ProcessClipInfo(clpi, overwrite_info);\n        bd_free_clpi(clpi);\n    }\n\n    MPLS_PL *mpls = bd_get_title_mpls(m_pBD);\n    if (mpls)\n    {\n        // Read the PG offsets and store them as metadata\n        std::list<uint8_t> pg_sequences;\n        for (int i = 0; i < mpls->play_item[0].stn.num_pg; i++)\n        {\n            AVStream *avstream = m_lavfDemuxer->GetAVStreamByPID(mpls->play_item[0].stn.pg[i].pid);\n            if (mpls->play_item[0].stn.pg[i].ss_offset_sequence_id != 0xFF)\n            {\n                pg_sequences.push_back(mpls->play_item[0].stn.pg[i].ss_offset_sequence_id);\n                if (avstream)\n                {\n                    char offset[4];\n                    _itoa_s(mpls->play_item[0].stn.pg[i].ss_offset_sequence_id, offset, 10);\n                    av_dict_set(&avstream->metadata, \"3d-plane\", offset, 0);\n                }\n            }\n        }\n\n        // export the list of pg sequences\n        if (pg_sequences.size() > 0)\n        {\n            // strip duplicate entries\n            pg_sequences.sort();\n            pg_sequences.unique();\n\n            size_t size = pg_sequences.size() * 4;\n            char *offsets = new char[size];\n            offsets[0] = 0;\n\n            // Append all offsets to the string\n            for (auto it = pg_sequences.begin(); it != pg_sequences.end(); it++)\n            {\n                size_t len = strlen(offsets);\n                if (len > 0)\n                {\n                    offsets[len] = ',';\n                    len++;\n                }\n                _itoa_s(*it, offsets + len, size - len, 10);\n            }\n\n            av_dict_set(&m_lavfDemuxer->m_avFormat->metadata, \"pg_offset_sequences\", offsets, 0);\n            delete[] offsets;\n        }\n\n        // Export a list of all IG offsets\n        if (mpls->play_item[0].stn.num_ig > 0)\n        {\n            std::list<uint8_t> ig_sequences;\n            for (int i = 0; i < mpls->play_item[0].stn.num_ig; i++)\n            {\n                if (mpls->play_item[0].stn.ig[i].ss_offset_sequence_id != 0xFF)\n                {\n                    ig_sequences.push_back(mpls->play_item[0].stn.ig[i].ss_offset_sequence_id);\n                }\n            }\n\n            if (ig_sequences.size() > 0)\n            {\n                // strip duplicate entries\n                ig_sequences.unique();\n\n                size_t size = ig_sequences.size() * 4;\n                char *offsets = new char[size];\n                offsets[0] = 0;\n\n                // Append all offsets to the string\n                for (auto it = ig_sequences.begin(); it != ig_sequences.end(); it++)\n                {\n                    size_t len = strlen(offsets);\n                    if (len > 0)\n                    {\n                        offsets[len] = ',';\n                        len++;\n                    }\n                    _itoa_s(*it, offsets + len, size - len, 10);\n                }\n\n                av_dict_set(&m_lavfDemuxer->m_avFormat->metadata, \"ig_offset_sequences\", offsets, 0);\n                delete[] offsets;\n            }\n        }\n    }\n}\n\n/*STDMETHODIMP_(int) CBDDemuxer::GetNumTitles()\n{\n  return m_nTitleCount;\n}\n\nSTDMETHODIMP CBDDemuxer::GetTitleInfo(int idx, REFERENCE_TIME *rtDuration, WCHAR **ppszName)\n{\n  if (idx >= m_nTitleCount) { return E_FAIL; }\n\n  BLURAY_TITLE_INFO *info = bd_get_title_info(m_pBD, idx, 0);\n  if (info) {\n    if (rtDuration) {\n      *rtDuration = Convert90KhzToDSTime(info->duration);\n    }\n    if (ppszName) {\n      WCHAR buffer[80];\n      swprintf_s(buffer, L\"Title %d\", idx + 1);\n      size_t size = (wcslen(buffer) + 1) * sizeof(WCHAR);\n      *ppszName = (WCHAR *)CoTaskMemAlloc(size);\n      if (*ppszName)\n        memcpy(*ppszName, buffer, size);\n    }\n\n    return S_OK;\n  }\n\n  return E_FAIL;\n}*/\n\nvoid CBDDemuxer::ProcessClipInfo(CLPI_CL *clpi, bool overwrite)\n{\n    if (!clpi)\n    {\n        return;\n    }\n    for (int k = 0; k < clpi->program.num_prog; k++)\n    {\n        for (int i = 0; i < clpi->program.progs[k].num_streams; i++)\n        {\n            CLPI_PROG_STREAM *stream = &clpi->program.progs[k].streams[i];\n            AVStream *avstream = m_lavfDemuxer->GetAVStreamByPID(stream->pid);\n            if (!avstream)\n            {\n                DbgLog((LOG_TRACE, 10,\n                        \"CBDDemuxer::ProcessStreams(): Stream with PID 0x%04x not found, trying to add it..\",\n                        stream->pid));\n                m_lavfDemuxer->AddMPEGTSStream(stream->pid, stream->coding_type);\n                avstream = m_lavfDemuxer->GetAVStreamByPID(stream->pid);\n            }\n            if (avstream)\n            {\n                if (stream->lang[0] != 0)\n                    av_dict_set(&avstream->metadata, \"language\", (const char *)stream->lang,\n                                overwrite ? 0 : AV_DICT_DONT_OVERWRITE);\n                if (avstream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)\n                {\n                    if (avstream->codecpar->width == 0 || avstream->codecpar->height == 0)\n                    {\n                        switch (stream->format)\n                        {\n                        case BLURAY_VIDEO_FORMAT_480I:\n                        case BLURAY_VIDEO_FORMAT_480P:\n                            avstream->codecpar->width = 720;\n                            avstream->codecpar->height = 480;\n                            break;\n                        case BLURAY_VIDEO_FORMAT_576I:\n                        case BLURAY_VIDEO_FORMAT_576P:\n                            avstream->codecpar->width = 720;\n                            avstream->codecpar->height = 576;\n                            break;\n                        case BLURAY_VIDEO_FORMAT_720P:\n                            avstream->codecpar->width = 1280;\n                            avstream->codecpar->height = 720;\n                            break;\n                        case BLURAY_VIDEO_FORMAT_1080I:\n                        case BLURAY_VIDEO_FORMAT_1080P:\n                        default:\n                            avstream->codecpar->width = 1920;\n                            avstream->codecpar->height = 1080;\n                            break;\n                        case BLURAY_VIDEO_FORMAT_2160P:\n                            avstream->codecpar->width = 3840;\n                            avstream->codecpar->height = 2160;\n                            break;\n                        }\n                    }\n\n                    if (m_MVCPlayback && stream->coding_type == BLURAY_STREAM_TYPE_VIDEO_H264)\n                    {\n                        av_dict_set(&avstream->metadata, \"stereo_mode\",\n                                    m_pTitle->mvc_base_view_r_flag ? \"mvc_rl\" : \"mvc_lr\", 0);\n                    }\n                }\n                else if (avstream->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)\n                {\n                    if (avstream->codecpar->ch_layout.nb_channels == 0)\n                    {\n                        av_channel_layout_default(&avstream->codecpar->ch_layout,\n                                                  (stream->format == BLURAY_AUDIO_FORMAT_MONO)     ? 1\n                                                  : (stream->format == BLURAY_AUDIO_FORMAT_STEREO) ? 2\n                                                                                                   : 6);\n                        avstream->codecpar->sample_rate =\n                            (stream->rate == BLURAY_AUDIO_RATE_96 || stream->rate == BLURAY_AUDIO_RATE_96_COMBO)\n                                ? 96000\n                                : (stream->rate == BLURAY_AUDIO_RATE_192 || stream->rate == BLURAY_AUDIO_RATE_192_COMBO)\n                                      ? 192000\n                                      : 48000;\n                        if (avstream->codecpar->codec_id == AV_CODEC_ID_DTS)\n                        {\n                            if (stream->coding_type == BLURAY_STREAM_TYPE_AUDIO_DTSHD)\n                                avstream->codecpar->profile = AV_PROFILE_DTS_HD_HRA;\n                            else if (stream->coding_type == BLURAY_STREAM_TYPE_AUDIO_DTSHD_MASTER)\n                                avstream->codecpar->profile = AV_PROFILE_DTS_HD_MA;\n                        }\n                    }\n                }\n            }\n        }\n    }\n}\n\nSTDMETHODIMP CBDDemuxer::Seek(REFERENCE_TIME rTime)\n{\n    int64_t prev = bd_tell(m_pBD);\n\n    int64_t target = bd_find_seek_point(m_pBD, ConvertDSTimeTo90Khz(rTime));\n    m_EndOfStreamPacketFlushProtection = FALSE;\n\n    DbgLog((LOG_TRACE, 1, \"Seek Request: %I64u (time); %I64u (byte), %I64u (prev byte)\", rTime, target, prev));\n    HRESULT hr = m_lavfDemuxer->SeekByte(target + 4, AVSEEK_FLAG_BACKWARD);\n\n    if (m_MVCPlayback && m_MVCFormatContext)\n    {\n        // Re-open to switch clip if needed\n        CloseMVCExtensionDemuxer();\n        if (FAILED(OpenMVCExtensionDemuxer(m_NewClip)))\n            return E_FAIL;\n\n        // Adjust for clip offset\n        int64_t seek_pts = 0;\n        if (rTime > 0)\n        {\n            AVStream *stream = m_MVCFormatContext->streams[m_MVCStreamIndex];\n\n            rTime -= m_rtNewOffset;\n            rTime -=\n                10000000; // seek one second before the target to ensure the MVC queue isn't out of sync for too long\n            seek_pts = m_lavfDemuxer->ConvertRTToTimestamp(rTime, stream->time_base.num, stream->time_base.den);\n        }\n\n        if (seek_pts < 0)\n            seek_pts = 0;\n\n        av_seek_frame(m_MVCFormatContext, m_MVCStreamIndex, seek_pts, AVSEEK_FLAG_BACKWARD);\n    }\n    return hr;\n}\n\nconst char *CBDDemuxer::GetContainerFormat() const\n{\n    return \"mpegts\";\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// IAMExtendedSeeking\nSTDMETHODIMP CBDDemuxer::get_ExSeekCapabilities(long *pExCapabilities)\n{\n    CheckPointer(pExCapabilities, E_POINTER);\n    *pExCapabilities = AM_EXSEEK_CANSEEK;\n    if (m_pTitle && m_pTitle->chapter_count > 1)\n        *pExCapabilities |= AM_EXSEEK_MARKERSEEK;\n    return S_OK;\n}\n\nSTDMETHODIMP CBDDemuxer::get_MarkerCount(long *pMarkerCount)\n{\n    CheckPointer(pMarkerCount, E_POINTER);\n    CheckPointer(m_pTitle, E_UNEXPECTED);\n    *pMarkerCount = (long)m_pTitle->chapter_count;\n    return S_OK;\n}\n\nSTDMETHODIMP CBDDemuxer::get_CurrentMarker(long *pCurrentMarker)\n{\n    CheckPointer(pCurrentMarker, E_POINTER);\n    CheckPointer(m_pBD, E_UNEXPECTED);\n    *pCurrentMarker = bd_get_current_chapter(m_pBD) + 1;\n    return E_FAIL;\n}\n\nSTDMETHODIMP CBDDemuxer::GetMarkerTime(long MarkerNum, double *pMarkerTime)\n{\n    CheckPointer(pMarkerTime, E_POINTER);\n    // Chapters go by a 1-based index, doh\n    unsigned int index = MarkerNum - 1;\n    if (index >= m_pTitle->chapter_count)\n    {\n        return E_FAIL;\n    }\n\n    REFERENCE_TIME rt = Convert90KhzToDSTime(m_pTitle->chapters[index].start);\n    *pMarkerTime = (double)rt / DSHOW_TIME_BASE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CBDDemuxer::GetMarkerName(long MarkerNum, BSTR *pbstrMarkerName)\n{\n    CheckPointer(pbstrMarkerName, E_POINTER);\n    // Chapters go by a 1-based index, doh\n    unsigned int index = MarkerNum - 1;\n    if (index >= m_pTitle->chapter_count)\n    {\n        return E_FAIL;\n    }\n    // Get the title, or generate one\n    OLECHAR wTitle[128];\n    swprintf_s(wTitle, L\"Chapter %d\", MarkerNum);\n    *pbstrMarkerName = SysAllocString(wTitle);\n    return S_OK;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/BDDemuxer.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"BaseDemuxer.h\"\n#include \"LAVFDemuxer.h\"\n\nclass CBDDemuxer\n    : public CBaseDemuxer\n    , public IAMExtendedSeeking\n{\n  public:\n    CBDDemuxer(CCritSec *pLock, ILAVFSettingsInternal *pSettings);\n    ~CBDDemuxer(void);\n\n    // IUnknown\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // IDispatch\n    STDMETHODIMP GetTypeInfoCount(UINT *pctinfo) { return E_NOTIMPL; }\n    STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo) { return E_NOTIMPL; }\n    STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid)\n    {\n        return E_NOTIMPL;\n    }\n    STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams,\n                        VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr)\n    {\n        return E_NOTIMPL;\n    }\n\n    // CBaseDemuxer\n    STDMETHODIMP Open(LPCOLESTR pszFileName, LPCOLESTR pszUserAgent = NULL, LPCOLESTR pszReferrer = NULL);\n    STDMETHODIMP Start();\n    REFERENCE_TIME GetDuration() const;\n    STDMETHODIMP GetNextPacket(Packet **ppPacket) { return m_lavfDemuxer->GetNextPacket(ppPacket); }\n    STDMETHODIMP Seek(REFERENCE_TIME rTime);\n    STDMETHODIMP Reset() { return E_NOTIMPL; }\n    const char *GetContainerFormat() const;\n    virtual DWORD GetContainerFlags() { return LAVFMT_TS_DISCONT | LAVFMT_TS_DISCONT_NO_DOWNSTREAM; }\n\n    CStreamList *GetStreams(StreamType type)\n    {\n        if (m_lavfDemuxer)\n            return m_lavfDemuxer->GetStreams(type);\n        else\n            return __super::GetStreams(type);\n    }\n    HRESULT SetActiveStream(StreamType type, int pid)\n    {\n        if (m_lavfDemuxer)\n        {\n            m_lavfDemuxer->SetActiveStream(type, pid);\n            return S_OK;\n        }\n        else\n            return E_FAIL;\n    }\n\n    void SettingsChanged(ILAVFSettingsInternal *pSettings)\n    {\n        if (m_lavfDemuxer)\n            m_lavfDemuxer->SettingsChanged(pSettings);\n    }\n\n    STDMETHODIMP_(DWORD) GetStreamFlags(DWORD dwStream)\n    {\n        if (m_lavfDemuxer)\n            return m_lavfDemuxer->GetStreamFlags(dwStream);\n        return 0;\n    }\n    STDMETHODIMP_(int) GetPixelFormat(DWORD dwStream)\n    {\n        if (m_lavfDemuxer)\n            return m_lavfDemuxer->GetPixelFormat(dwStream);\n        return AV_PIX_FMT_NONE;\n    }\n    STDMETHODIMP_(int) GetHasBFrames(DWORD dwStream)\n    {\n        if (m_lavfDemuxer)\n            return m_lavfDemuxer->GetHasBFrames(dwStream);\n        return -1;\n    }\n\n    const stream *SelectVideoStream() { return m_lavfDemuxer->SelectVideoStream(); }\n    const stream *SelectAudioStream(std::list<std::string> prefLanguages)\n    {\n        return m_lavfDemuxer->SelectAudioStream(prefLanguages);\n    }\n    const stream *SelectSubtitleStream(std::list<CSubtitleSelector> subtitleSelectors, std::string audioLanguage)\n    {\n        return m_lavfDemuxer->SelectSubtitleStream(subtitleSelectors, audioLanguage);\n    }\n\n    STDMETHODIMP SetTitle(int idx);\n    /*STDMETHODIMP GetTitleInfo(int idx, REFERENCE_TIME *rtDuration, WCHAR **ppszName);\n    STDMETHODIMP GetNumTitles(int *count);*/\n\n    // IAMExtendedSeeking\n    STDMETHODIMP get_ExSeekCapabilities(long *pExCapabilities);\n    STDMETHODIMP get_MarkerCount(long *pMarkerCount);\n    STDMETHODIMP get_CurrentMarker(long *pCurrentMarker);\n    STDMETHODIMP GetMarkerTime(long MarkerNum, double *pMarkerTime);\n    STDMETHODIMP GetMarkerName(long MarkerNum, BSTR *pbstrMarkerName);\n    STDMETHODIMP put_PlaybackSpeed(double Speed) { return E_NOTIMPL; }\n    STDMETHODIMP get_PlaybackSpeed(double *pSpeed) { return E_NOTIMPL; }\n\n    void ProcessBluRayMetadata();\n    STDMETHODIMP ProcessPacket(Packet *pPacket);\n    STDMETHODIMP FillMVCExtensionQueue(REFERENCE_TIME rtBase);\n\n  private:\n    void ProcessClipInfo(struct clpi_cl *clpi, bool overwrite);\n    void ProcessBDEvents();\n\n    void CloseMVCExtensionDemuxer();\n    STDMETHODIMP OpenMVCExtensionDemuxer(int playItem);\n\n    static int BDByteStreamRead(void *opaque, uint8_t *buf, int buf_size);\n    static int64_t CBDDemuxer::BDByteStreamSeek(void *opaque, int64_t offset, int whence);\n\n  private:\n    BLURAY *m_pBD = nullptr;\n    AVIOContext *m_pb = nullptr;\n    char m_cBDRootPath[4096] = {0};\n\n    ILAVFSettingsInternal *m_pSettings = nullptr;\n    CLAVFDemuxer *m_lavfDemuxer = nullptr;\n\n    BLURAY_TITLE_INFO *m_pTitle = nullptr;\n    uint32_t m_nTitleCount = 0;\n\n    uint16_t *m_StreamClip = nullptr;\n    uint16_t m_NewClip = 0;\n    REFERENCE_TIME *m_rtOffset = nullptr;\n    REFERENCE_TIME m_rtNewOffset = 0;\n    int64_t m_bNewOffsetPos = 0;\n\n    BOOL m_MVCPlayback = FALSE;\n    int m_MVCExtensionSubPathIndex = 0;\n    int m_MVCExtensionClip = -1;\n\n    AVFormatContext *m_MVCFormatContext = nullptr;\n    int m_MVCStreamIndex = -1;\n\n    BOOL m_EndOfStreamPacketFlushProtection = FALSE;\n};\n"
  },
  {
    "path": "demuxer/Demuxers/BaseDemuxer.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"BaseDemuxer.h\"\n\n#include \"moreuuids.h\"\n\nCBaseDemuxer::CBaseDemuxer(LPCTSTR pName, CCritSec *pLock)\n    : CUnknown(pName, nullptr)\n    , m_pLock(pLock)\n{\n    for (int i = 0; i < unknown; ++i)\n    {\n        m_dActiveStreams[i] = -1;\n    }\n}\n\nvoid CBaseDemuxer::CreateNoSubtitleStream()\n{\n    stream s;\n    s.pid = NO_SUBTITLE_PID;\n    s.streamInfo = new CStreamInfo();\n    s.language = \"und\";\n    // Create the media type\n    CMediaType mtype;\n    mtype.majortype = MEDIATYPE_Subtitle;\n    mtype.subtype = MEDIASUBTYPE_UTF8;\n    mtype.formattype = FORMAT_SubtitleInfo;\n    SUBTITLEINFO *subInfo = (SUBTITLEINFO *)mtype.AllocFormatBuffer(sizeof(SUBTITLEINFO));\n    memset(subInfo, 0, mtype.FormatLength());\n    wcscpy_s(subInfo->TrackName, NO_SUB_STRING);\n    strcpy_s(subInfo->IsoLang, \"und\");\n    subInfo->dwOffset = sizeof(SUBTITLEINFO);\n    s.streamInfo->mtypes.push_back(mtype);\n    // Append it to the list\n    m_streams[subpic].push_back(s);\n}\n\nvoid CBaseDemuxer::CreatePGSForcedSubtitleStream()\n{\n    stream s;\n    s.pid = FORCED_SUBTITLE_PID;\n    s.streamInfo = new CStreamInfo();\n    s.language = \"und\";\n    // Create the media type\n    CMediaType mtype;\n    mtype.majortype = MEDIATYPE_Subtitle;\n    mtype.subtype = MEDIASUBTYPE_HDMVSUB;\n    mtype.formattype = FORMAT_SubtitleInfo;\n    SUBTITLEINFO *subInfo = (SUBTITLEINFO *)mtype.AllocFormatBuffer(sizeof(SUBTITLEINFO));\n    memset(subInfo, 0, mtype.FormatLength());\n    wcscpy_s(subInfo->TrackName, FORCED_SUB_STRING);\n    subInfo->dwOffset = sizeof(SUBTITLEINFO);\n    s.streamInfo->mtypes.push_back(mtype);\n    // Append it to the list\n    m_streams[subpic].push_back(s);\n}\n\n// CStreamList\nconst WCHAR *CBaseDemuxer::CStreamList::ToStringW(int type)\n{\n    return type == video ? L\"Video\" : type == audio ? L\"Audio\" : type == subpic ? L\"Subtitle\" : L\"Unknown\";\n}\n\nconst CHAR *CBaseDemuxer::CStreamList::ToString(int type)\n{\n    return type == video ? \"Video\" : type == audio ? \"Audio\" : type == subpic ? \"Subtitle\" : \"Unknown\";\n}\n\nCBaseDemuxer::stream *CBaseDemuxer::CStreamList::FindStream(DWORD pid)\n{\n    std::deque<stream>::iterator it;\n    for (it = begin(); it != end(); ++it)\n    {\n        if ((*it).pid == pid)\n        {\n            return &(*it);\n        }\n    }\n\n    return nullptr;\n}\n\nvoid CBaseDemuxer::CStreamList::Clear()\n{\n    std::deque<stream>::iterator it;\n    for (it = begin(); it != end(); ++it)\n    {\n        delete (*it).streamInfo;\n    }\n    __super::clear();\n}\n\nCBaseDemuxer::stream *CBaseDemuxer::FindStream(DWORD pid)\n{\n    for (int i = 0; i < StreamType::unknown; i++)\n    {\n        stream *pStream = m_streams[i].FindStream(pid);\n        if (pStream)\n            return pStream;\n    }\n    return nullptr;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/BaseDemuxer.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <deque>\n\n#include \"StreamInfo.h\"\n#include \"Packet.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n\n#define DSHOW_TIME_BASE 10000000 // DirectShow times are in 100ns units\n#define NO_SUBTITLE_PID DWORD_MAX\n#define FORCED_SUBTITLE_PID (NO_SUBTITLE_PID - 1)\n\n#define NO_SUB_STRING L\"No subtitles\"\n#define FORCED_SUB_STRING L\"Forced Subtitles (auto)\"\n\nstruct ILAVFSettingsInternal;\n\ntypedef struct CSubtitleSelector\n{\n    std::string audioLanguage;\n    std::string subtitleLanguage;\n    std::string subtitleTrackName;\n\n#define SUBTITLE_FLAG_DEFAULT 0x0001\n#define SUBTITLE_FLAG_FORCED 0x0002\n#define SUBTITLE_FLAG_NORMAL 0x0004\n#define SUBTITLE_FLAG_IMPAIRED 0x0008\n#define SUBTITLE_FLAG_VIRTUAL 0x0080\n\n// Values above 0xFF are special\n#define SUBTITLE_FLAG_PGS 0x8000\n    DWORD dwFlagsSet;\n    DWORD dwFlagsNot;\n} CSubtitleSelector;\n\nclass CBaseDemuxer : public CUnknown\n{\n  public:\n    enum StreamType\n    {\n        video,\n        audio,\n        subpic,\n        unknown\n    };\n\n    typedef struct stream\n    {\n        CStreamInfo *streamInfo;\n        DWORD pid;\n        std::string language;\n        std::string trackName;\n        LCID lcid;\n        MediaSideDataFFMpeg SideData;\n        struct stream()\n        {\n            streamInfo = nullptr;\n            pid = 0;\n            lcid = 0;\n            memset(&SideData, 0, sizeof(SideData));\n        }\n        operator DWORD() const { return pid; }\n        bool operator==(const struct stream &s) const { return (DWORD) * this == (DWORD)s; }\n    } stream;\n\n    DECLARE_IUNKNOWN\n\n    // Demuxing Methods (pure virtual)\n\n    // Open the file\n    virtual STDMETHODIMP Open(LPCOLESTR pszFileName, LPCOLESTR pszUserAgent = NULL, LPCOLESTR pszReferrer = NULL) = 0;\n    // Start the demuxer\n    virtual STDMETHODIMP Start() { return E_NOTIMPL; }\n    // Abort opening the file\n    virtual STDMETHODIMP AbortOpening(int mode = 1, int timeout = 0) { return E_NOTIMPL; }\n    // Get Duration\n    virtual REFERENCE_TIME GetDuration() const = 0;\n    // Get the next packet from the file\n    virtual STDMETHODIMP GetNextPacket(Packet **ppPacket) = 0;\n    // Seek to the given position\n    virtual STDMETHODIMP Seek(REFERENCE_TIME rTime) = 0;\n    // Reset the demuxer, start reading at position 0\n    virtual STDMETHODIMP Reset() = 0;\n    // Get the container format\n    virtual const char *GetContainerFormat() const = 0;\n    // Get Container Flags\n#define LAVFMT_TS_DISCONT 0x0001\n#define LAVFMT_TS_DISCONT_NO_DOWNSTREAM 0x0002\n    virtual DWORD GetContainerFlags() { return 0; }\n    // Select the active title\n    virtual STDMETHODIMP SetTitle(int idx) { return E_NOTIMPL; }\n    // Query the active title\n    virtual STDMETHODIMP_(int) GetTitle() { return 0; }\n    // Get Title Info\n    virtual STDMETHODIMP GetTitleInfo(int idx, REFERENCE_TIME *rtDuration, WCHAR **ppszName) { return E_NOTIMPL; }\n    // Title count\n    virtual STDMETHODIMP_(int) GetNumTitles() { return 0; }\n\n    // Set the currently active stream of one type\n    // The demuxers can use this to filter packets before returning back to the caller on GetNextPacket\n    // This functionality is optional however, so the caller should not rely on only receiving packets\n    // for active streams.\n    virtual HRESULT SetActiveStream(StreamType type, int pid)\n    {\n        m_dActiveStreams[type] = pid;\n        return S_OK;\n    }\n\n    // Called when the settings of the splitter change\n    virtual void SettingsChanged(ILAVFSettingsInternal *pSettings){};\n\n    virtual STDMETHODIMP_(DWORD) GetStreamFlags(DWORD dwStream) { return 0; }\n    virtual STDMETHODIMP_(int) GetPixelFormat(DWORD dwStream) { return AV_PIX_FMT_NONE; }\n    virtual STDMETHODIMP_(int) GetHasBFrames(DWORD dwStream) { return -1; }\n    virtual STDMETHODIMP GetSideData(DWORD dwStream, GUID guidType, const BYTE **pData, size_t *pSize)\n    {\n        return E_NOTIMPL;\n    }\n\n  public:\n    class CStreamList : public std::deque<stream>\n    {\n      public:\n        ~CStreamList() { Clear(); }\n        static const WCHAR *ToStringW(int type);\n        static const CHAR *ToString(int type);\n        stream *FindStream(DWORD pid);\n        void Clear();\n    };\n\n    stream *FindStream(DWORD pid);\n\n  protected:\n    CBaseDemuxer(LPCTSTR pName, CCritSec *pLock);\n    void CreateNoSubtitleStream();\n    void CreatePGSForcedSubtitleStream();\n\n  public:\n    // Get the StreamList of the corresponding type\n    virtual CStreamList *GetStreams(StreamType type) { return &m_streams[type]; }\n\n    // Select the best video stream\n    virtual const stream *SelectVideoStream() = 0;\n\n    // Select the best audio stream\n    virtual const stream *SelectAudioStream(std::list<std::string> prefLanguages) = 0;\n\n    // Select the best subtitle stream\n    virtual const stream *SelectSubtitleStream(std::list<CSubtitleSelector> subtitleSelectors,\n                                               std::string audioLanguage) = 0;\n\n  protected:\n    CCritSec *m_pLock = nullptr;\n    CStreamList m_streams[unknown];\n    int m_dActiveStreams[unknown];\n};\n"
  },
  {
    "path": "demuxer/Demuxers/Demuxers.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{E2012DB5-33CB-44A7-B521-04287F6D0D80}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n    <RootNamespace>Demuxers</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <Import Project=\"$(SolutionDir)common\\platform.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\" Label=\"Configuration\">\n    <ConfigurationType>StaticLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Import Project=\"$(SolutionDir)common\\common.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <TargetName>demuxersd</TargetName>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n    <TargetName>demuxers</TargetName>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Release'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n    </ClCompile>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClInclude Include=\"BaseDemuxer.h\" />\n    <ClInclude Include=\"BDDemuxer.h\" />\n    <ClInclude Include=\"ExtradataParser.h\" />\n    <ClInclude Include=\"LAVFAudioHelper.h\" />\n    <ClInclude Include=\"LAVFDemuxer.h\" />\n    <ClInclude Include=\"LAVFVideoHelper.h\" />\n    <ClInclude Include=\"LAVFStreamInfo.h\" />\n    <ClInclude Include=\"LAVFUtils.h\" />\n    <ClInclude Include=\"Packet.h\" />\n    <ClInclude Include=\"stdafx.h\" />\n    <ClInclude Include=\"StreamInfo.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"BaseDemuxer.cpp\" />\n    <ClCompile Include=\"BDDemuxer.cpp\" />\n    <ClCompile Include=\"ExtradataParser.cpp\" />\n    <ClCompile Include=\"LAVFAudioHelper.cpp\" />\n    <ClCompile Include=\"LAVFDemuxer.cpp\" />\n    <ClCompile Include=\"LAVFInputFormats.cpp\" />\n    <ClCompile Include=\"LAVFVideoHelper.cpp\" />\n    <ClCompile Include=\"LAVFStreamInfo.cpp\" />\n    <ClCompile Include=\"LAVFUtils.cpp\" />\n    <ClCompile Include=\"Packet.cpp\" />\n    <ClCompile Include=\"stdafx.cpp\">\n      <PrecompiledHeader>Create</PrecompiledHeader>\n    </ClCompile>\n    <ClCompile Include=\"StreamInfo.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\..\\common\\baseclasses\\baseclasses.vcxproj\">\n      <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>\n    </ProjectReference>\n    <ProjectReference Include=\"..\\..\\common\\DSUtilLite\\DSUtilLite.vcxproj\">\n      <Project>{0a058024-41f4-4509-97d2-803a1806ce86}</Project>\n    </ProjectReference>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>\n"
  },
  {
    "path": "demuxer/Demuxers/Demuxers.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"stdafx.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"BaseDemuxer.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVFDemuxer.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVFUtils.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVFStreamInfo.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"StreamInfo.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"ExtradataParser.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVFVideoHelper.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVFAudioHelper.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"BDDemuxer.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"Packet.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"stdafx.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"BaseDemuxer.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVFDemuxer.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVFUtils.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVFStreamInfo.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"StreamInfo.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"ExtradataParser.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVFAudioHelper.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVFVideoHelper.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"BDDemuxer.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVFInputFormats.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"Packet.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "demuxer/Demuxers/ExtradataParser.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"ExtradataParser.h\"\n\n#define MARKER           \\\n    if (BitRead(1) != 1) \\\n    {                    \\\n        ASSERT(0);       \\\n        return 0;        \\\n    }\n\nCExtradataParser::CExtradataParser(BYTE *pExtradata, size_t extra_len)\n    : CByteParser(pExtradata, extra_len)\n{\n}\n\nCExtradataParser::~CExtradataParser()\n{\n}\n\nbool CExtradataParser::NextMPEGStartCode(BYTE &code)\n{\n    BitByteAlign();\n    DWORD dw = (DWORD)-1;\n    do\n    {\n        if (!Remaining())\n            return false;\n        dw = (dw << 8) | (BYTE)BitRead(8);\n    } while ((dw & 0xffffff00) != 0x00000100);\n    code = (BYTE)(dw & 0xff);\n    return true;\n}\n\nsize_t CExtradataParser::ParseMPEGSequenceHeader(BYTE *pTarget)\n{\n    BYTE id = 0;\n    while (Remaining() && id != 0xb3)\n    {\n        if (!NextMPEGStartCode(id))\n        {\n            return 0;\n        }\n    }\n\n    if (id != 0xb3)\n    {\n        return 0;\n    }\n\n    size_t shpos = Pos() - 4;\n    BitRead(12); // Width\n    BitRead(12); // Height\n    BitRead(4);  // AR\n    BitRead(4);  // FPS\n    BitRead(18); // Bitrate\n    MARKER;\n    BitRead(10); // VBV\n    BitRead(1);  // Constrained Flag\n    // intra quantisizer matrix\n    if (BitRead(1))\n    {\n        for (uint8_t i = 0; i < 64; i++)\n        {\n            BitRead(8);\n        }\n    }\n    // non-intra quantisizer matrix\n    if (BitRead(1))\n    {\n        for (uint8_t i = 0; i < 64; i++)\n        {\n            BitRead(8);\n        }\n    }\n\n    size_t shlen = Pos() - shpos;\n\n    size_t shextpos = 0;\n    size_t shextlen = 0;\n\n    if (NextMPEGStartCode(id) && id == 0xb5)\n    { // sequence header ext\n        shextpos = Pos() - 4;\n\n        int startcode = BitRead(4); // Start Code Id; TODO: DIfferent start code ids mean different length of da2a\n        ASSERT(startcode == 1);\n\n        BitRead(1);  // Profile Level Escape\n        BitRead(3);  // Profile\n        BitRead(4);  // Level\n        BitRead(1);  // Progressive\n        BitRead(2);  // Chroma\n        BitRead(2);  // Width Extension\n        BitRead(2);  // Height Extension\n        BitRead(12); // Bitrate Extension\n        MARKER;\n        BitRead(8); // VBV Buffer Size Extension\n        BitRead(1); // Low Delay\n        BitRead(2); // FPS Extension n\n        BitRead(5); // FPS Extension d\n\n        shextlen = Pos() - shextpos;\n    }\n\n    memcpy(pTarget, Start() + shpos, shlen);\n    if (shextpos)\n    {\n        memcpy(pTarget + shlen, Start() + shextpos, shextlen);\n    }\n    return shlen + shextlen;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/ExtradataParser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"byteparser.h\"\n\nclass CExtradataParser : protected CByteParser\n{\n  public:\n    CExtradataParser(BYTE *pExtradata, size_t extra_len);\n    ~CExtradataParser();\n\n    size_t ParseMPEGSequenceHeader(BYTE *pTarget);\n\n  private:\n    bool NextMPEGStartCode(BYTE &code);\n};\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFAudioHelper.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"moreuuids.h\"\n#include \"BaseDemuxer.h\"\n#include \"LAVFAudioHelper.h\"\n#include \"LAVFUtils.h\"\n\n#include \"ExtradataParser.h\"\n\n#include <vector>\n\nCLAVFAudioHelper g_AudioHelper;\n\n// Map codec ids to media subtypes\n// clang-format off\nstatic FormatMapping audio_map[] = {\n  { AV_CODEC_ID_AC3,        &MEDIASUBTYPE_DOLBY_AC3,         WAVE_FORMAT_DOLBY_AC3,  nullptr },\n  { AV_CODEC_ID_AAC,        &MEDIASUBTYPE_AAC,               WAVE_FORMAT_AAC,        nullptr },\n  { AV_CODEC_ID_AAC_LATM,   &MEDIASUBTYPE_LATM_AAC,          WAVE_FORMAT_LATM_AAC,   nullptr },\n  { AV_CODEC_ID_DTS,        &MEDIASUBTYPE_WAVE_DTS,          0,                      nullptr },\n  { AV_CODEC_ID_EAC3,       &MEDIASUBTYPE_DOLBY_DDPLUS,      0,                      nullptr },\n  { AV_CODEC_ID_TRUEHD,     &MEDIASUBTYPE_DOLBY_TRUEHD,      0,                      nullptr },\n  { AV_CODEC_ID_MLP,        &MEDIASUBTYPE_MLP,               WAVE_FORMAT_MLP,        nullptr },\n  { AV_CODEC_ID_VORBIS,     &MEDIASUBTYPE_Vorbis2,           0,                      &FORMAT_VorbisFormat2 },\n  { AV_CODEC_ID_MP1,        &MEDIASUBTYPE_MPEG1AudioPayload, WAVE_FORMAT_MPEG,       nullptr },\n  { AV_CODEC_ID_MP2,        &MEDIASUBTYPE_MPEG2_AUDIO,       WAVE_FORMAT_MPEG,       nullptr },\n  { AV_CODEC_ID_MP3,        &MEDIASUBTYPE_MP3,               WAVE_FORMAT_MPEGLAYER3, nullptr },\n  { AV_CODEC_ID_PCM_BLURAY, &MEDIASUBTYPE_BD_LPCM_AUDIO,     0,                      nullptr },\n  { AV_CODEC_ID_PCM_DVD,    &MEDIASUBTYPE_DVD_LPCM_AUDIO,    0,                      nullptr },\n  { AV_CODEC_ID_PCM_S16LE,  &MEDIASUBTYPE_PCM,               WAVE_FORMAT_PCM,        nullptr },\n  { AV_CODEC_ID_PCM_S24LE,  &MEDIASUBTYPE_PCM,               WAVE_FORMAT_PCM,        nullptr },\n  { AV_CODEC_ID_PCM_S32LE,  &MEDIASUBTYPE_PCM,               WAVE_FORMAT_PCM,        nullptr },\n  { AV_CODEC_ID_PCM_F32LE,  &MEDIASUBTYPE_IEEE_FLOAT,        WAVE_FORMAT_IEEE_FLOAT, nullptr },\n  { AV_CODEC_ID_PCM_S16LE_PLANAR, &MEDIASUBTYPE_PCM,         WAVE_FORMAT_PCM,        nullptr },\n  { AV_CODEC_ID_PCM_S24LE_PLANAR, &MEDIASUBTYPE_PCM,         WAVE_FORMAT_PCM,        nullptr },\n  { AV_CODEC_ID_PCM_S32LE_PLANAR, &MEDIASUBTYPE_PCM,         WAVE_FORMAT_PCM,        nullptr },\n  { AV_CODEC_ID_WMAV1,      &MEDIASUBTYPE_MSAUDIO1,          WAVE_FORMAT_MSAUDIO1,   nullptr },\n  { AV_CODEC_ID_WMAV2,      &MEDIASUBTYPE_WMAUDIO2,          WAVE_FORMAT_WMAUDIO2,   nullptr },\n  { AV_CODEC_ID_WMAPRO,     &MEDIASUBTYPE_WMAUDIO3,          WAVE_FORMAT_WMAUDIO3,   nullptr },\n  { AV_CODEC_ID_ADPCM_IMA_AMV, &MEDIASUBTYPE_IMA_AMV,        0,                      nullptr },\n  { AV_CODEC_ID_FLAC,       &MEDIASUBTYPE_FLAC_FRAMED,       WAVE_FORMAT_FLAC,       nullptr },\n  { AV_CODEC_ID_COOK,       &MEDIASUBTYPE_COOK,              WAVE_FORMAT_COOK,       nullptr },\n  { AV_CODEC_ID_SIPR,       &MEDIASUBTYPE_SIPR,              WAVE_FORMAT_SIPR,       nullptr },\n  { AV_CODEC_ID_RA_288,     &MEDIASUBTYPE_28_8,              WAVE_FORMAT_28_8,       nullptr },\n  { AV_CODEC_ID_RA_144,     &MEDIASUBTYPE_14_4,              WAVE_FORMAT_14_4,       nullptr },\n  { AV_CODEC_ID_RALF,       &MEDIASUBTYPE_RALF,              WAVE_FORMAT_RALF,       nullptr },\n  { AV_CODEC_ID_ALAC,       &MEDIASUBTYPE_ALAC,              0,                      nullptr },\n  { AV_CODEC_ID_MP4ALS,     &MEDIASUBTYPE_ALS,               0,                      nullptr },\n  { AV_CODEC_ID_OPUS,       &MEDIASUBTYPE_OPUS,              WAVE_FORMAT_OPUS,       nullptr },\n  { AV_CODEC_ID_NELLYMOSER, &MEDIASUBTYPE_NELLYMOSER,        0,                      nullptr },\n  { AV_CODEC_ID_PCM_ALAW,   &MEDIASUBTYPE_ALAW,              WAVE_FORMAT_ALAW,       nullptr },\n  { AV_CODEC_ID_PCM_MULAW,  &MEDIASUBTYPE_MULAW,             WAVE_FORMAT_MULAW,      nullptr },\n  { AV_CODEC_ID_GSM_MS,     &MEDIASUBTYPE_MSGSM610,          WAVE_FORMAT_GSM610,     nullptr },\n  { AV_CODEC_ID_ADPCM_MS,   &MEDIASUBTYPE_ADPCM_MS,          WAVE_FORMAT_ADPCM,      nullptr },\n  { AV_CODEC_ID_TRUESPEECH, &MEDIASUBTYPE_TRUESPEECH,        WAVE_FORMAT_DSPGROUP_TRUESPEECH, nullptr },\n  { AV_CODEC_ID_TAK,        &MEDIASUBTYPE_TAK,               0,                      nullptr },\n  { AV_CODEC_ID_S302M,      &MEDIASUBTYPE_AES3,              0,                      nullptr },\n  { AV_CODEC_ID_PCM_S16BE,  &MEDIASUBTYPE_PCM_TWOS,          0,                      nullptr },\n  { AV_CODEC_ID_PCM_S16BE_PLANAR, &MEDIASUBTYPE_PCM_TWOS,    0,                      nullptr },\n  { AV_CODEC_ID_PCM_S24BE,  &MEDIASUBTYPE_PCM_IN24,          0,                      nullptr },\n  { AV_CODEC_ID_PCM_S32BE,  &MEDIASUBTYPE_PCM_IN32,          0,                      nullptr },\n  { AV_CODEC_ID_QDM2,       &MEDIASUBTYPE_QDM2,              WAVE_FORMAT_QDESIGN_MUSIC, nullptr },\n  { AV_CODEC_ID_ATRAC1,     &MEDIASUBTYPE_ATRC,              WAVE_FORMAT_ATRC,       nullptr },\n  { AV_CODEC_ID_ATRAC3,     &MEDIASUBTYPE_ATRC,              WAVE_FORMAT_ATRC,       nullptr },\n  { AV_CODEC_ID_ATRAC3P,    &MEDIASUBTYPE_ATRAC3P,           WAVE_FORMAT_ATRAC3P,    nullptr },\n  { AV_CODEC_ID_DSD_LSBF,   &MEDIASUBTYPE_DSDL,              0,                      nullptr },\n  { AV_CODEC_ID_DSD_MSBF,   &MEDIASUBTYPE_DSDM,              0,                      nullptr },\n  { AV_CODEC_ID_DSD_LSBF_PLANAR, &MEDIASUBTYPE_DSD1,         0,                      nullptr },\n  { AV_CODEC_ID_DSD_MSBF_PLANAR, &MEDIASUBTYPE_DSD8,         0,                      nullptr },\n};\n// clang-format on\n\nCMediaType CLAVFAudioHelper::initAudioType(AVCodecParameters *codecpar, unsigned int &codecTag, std::string container)\n{\n    CMediaType mediaType;\n    mediaType.InitMediaType();\n    mediaType.majortype = MEDIATYPE_Audio;\n    mediaType.subtype = FOURCCMap(codecTag);\n    mediaType.formattype = FORMAT_WaveFormatEx; // default value\n    mediaType.SetSampleSize(256000);\n\n    // Check against values from the map above\n    for (unsigned i = 0; i < countof(audio_map); ++i)\n    {\n        if (audio_map[i].codec == codecpar->codec_id)\n        {\n            if (audio_map[i].subtype)\n                mediaType.subtype = *audio_map[i].subtype;\n            if (audio_map[i].codecTag)\n                codecTag = audio_map[i].codecTag;\n            if (audio_map[i].format)\n                mediaType.formattype = *audio_map[i].format;\n            break;\n        }\n    }\n\n    // special cases\n    switch (codecpar->codec_id)\n    {\n    case AV_CODEC_ID_PCM_F64LE:\n        // Qt PCM\n        if (codecTag == MKTAG('f', 'l', '6', '4'))\n            mediaType.subtype = MEDIASUBTYPE_PCM_FL64_le;\n        break;\n    }\n    return mediaType;\n}\n\nWAVEFORMATEX *CLAVFAudioHelper::CreateWVFMTEX(const AVStream *avstream, ULONG *size)\n{\n    WAVEFORMATEX *wvfmt = (WAVEFORMATEX *)CoTaskMemAlloc(sizeof(WAVEFORMATEX) + avstream->codecpar->extradata_size);\n    if (!wvfmt)\n        return nullptr;\n    memset(wvfmt, 0, sizeof(WAVEFORMATEX));\n\n    wvfmt->wFormatTag = avstream->codecpar->codec_tag;\n\n    wvfmt->nChannels = avstream->codecpar->ch_layout.nb_channels ? avstream->codecpar->ch_layout.nb_channels : 2;\n    wvfmt->nSamplesPerSec = avstream->codecpar->sample_rate ? avstream->codecpar->sample_rate : 48000;\n    wvfmt->nAvgBytesPerSec = (DWORD)(avstream->codecpar->bit_rate / 8);\n\n    if (avstream->codecpar->codec_id == AV_CODEC_ID_AAC || avstream->codecpar->codec_id == AV_CODEC_ID_AAC_LATM)\n    {\n        wvfmt->wBitsPerSample = 0;\n        wvfmt->nBlockAlign = 1;\n    }\n    else\n    {\n        wvfmt->wBitsPerSample = get_bits_per_sample(avstream->codecpar);\n\n        if (avstream->codecpar->block_align > 0)\n        {\n            wvfmt->nBlockAlign = avstream->codecpar->block_align;\n        }\n        else\n        {\n            if (wvfmt->wBitsPerSample == 0)\n            {\n                DbgOutString(L\"BitsPerSample is 0, no good!\");\n            }\n            wvfmt->nBlockAlign =\n                (WORD)(wvfmt->nChannels * av_get_bytes_per_sample((AVSampleFormat)avstream->codecpar->format));\n        }\n    }\n    if (!wvfmt->nAvgBytesPerSec)\n        wvfmt->nAvgBytesPerSec = (wvfmt->nSamplesPerSec * wvfmt->nChannels * wvfmt->wBitsPerSample) >> 3;\n\n    if (avstream->codecpar->extradata_size > 0)\n    {\n        wvfmt->cbSize = avstream->codecpar->extradata_size;\n        memcpy((BYTE *)wvfmt + sizeof(WAVEFORMATEX), avstream->codecpar->extradata, avstream->codecpar->extradata_size);\n    }\n\n    *size = sizeof(WAVEFORMATEX) + avstream->codecpar->extradata_size;\n    return wvfmt;\n}\n\nWAVEFORMATEXFFMPEG *CLAVFAudioHelper::CreateWVFMTEX_FF(const AVStream *avstream, ULONG *size)\n{\n    WAVEFORMATEX *wvfmt = CreateWVFMTEX(avstream, size);\n    if (!wvfmt)\n        return nullptr;\n\n    const size_t diff_size = sizeof(WAVEFORMATEXFFMPEG) - sizeof(WAVEFORMATEX);\n    WAVEFORMATEXFFMPEG *wfex_ff = (WAVEFORMATEXFFMPEG *)CoTaskMemAlloc(diff_size + *size);\n    if (!wfex_ff)\n        return nullptr;\n    memset(wfex_ff, 0, sizeof(WAVEFORMATEXFFMPEG));\n    memcpy(&wfex_ff->wfex, wvfmt, *size);\n\n    wfex_ff->nCodecId = avstream->codecpar->codec_id;\n    CoTaskMemFree(wvfmt);\n\n    *size = sizeof(WAVEFORMATEXFFMPEG) + wfex_ff->wfex.cbSize;\n    return wfex_ff;\n}\n\nWAVEFORMATEXFFMPEG *CLAVFAudioHelper::CreateWFMTEX_RAW_PCM_FF(const AVStream *avstream, ULONG *size, const GUID subtype, ULONG *samplesize)\n{\n    WAVEFORMATEXTENSIBLE *wvfmt = CreateWFMTEX_RAW_PCM(avstream, size, subtype, samplesize);\n    if (!wvfmt)\n        return nullptr;\n\n    const size_t diff_size = sizeof(WAVEFORMATEXFFMPEG) - sizeof(WAVEFORMATEX);\n    WAVEFORMATEXFFMPEG *wfex_ff = (WAVEFORMATEXFFMPEG *)CoTaskMemAlloc(diff_size + *size);\n    if (!wfex_ff)\n        return nullptr;\n    memset(wfex_ff, 0, sizeof(WAVEFORMATEXFFMPEG));\n    memcpy(&wfex_ff->wfex, wvfmt, *size);\n\n    wfex_ff->nCodecId = avstream->codecpar->codec_id;\n    CoTaskMemFree(wvfmt);\n\n    *size = sizeof(WAVEFORMATEXFFMPEG) + wfex_ff->wfex.cbSize;\n    return wfex_ff;\n}\n\nWAVEFORMATEX_HDMV_LPCM *CLAVFAudioHelper::CreateWVFMTEX_LPCM(const AVStream *avstream, ULONG *size)\n{\n    WAVEFORMATEX *wvfmt = CreateWVFMTEX(avstream, size);\n\n    WAVEFORMATEX_HDMV_LPCM *lpcm = (WAVEFORMATEX_HDMV_LPCM *)CoTaskMemAlloc(sizeof(WAVEFORMATEX_HDMV_LPCM));\n    memset(lpcm, 0, sizeof(WAVEFORMATEX_HDMV_LPCM));\n    memcpy(lpcm, wvfmt, sizeof(WAVEFORMATEX));\n\n    lpcm->cbSize = sizeof(WAVEFORMATEX_HDMV_LPCM) - sizeof(WAVEFORMATEX);\n    BYTE channel_conf = 0;\n    if (avstream->codecpar->ch_layout.order == AV_CHANNEL_ORDER_NATIVE)\n    {\n\n        switch (avstream->codecpar->ch_layout.u.mask)\n        {\n        case AV_CH_LAYOUT_MONO: channel_conf = 1; break;\n        case AV_CH_LAYOUT_STEREO: channel_conf = 3; break;\n        case AV_CH_LAYOUT_SURROUND: channel_conf = 4; break;\n        case AV_CH_LAYOUT_2_1: channel_conf = 5; break;\n        case AV_CH_LAYOUT_4POINT0: channel_conf = 6; break;\n        case AV_CH_LAYOUT_2_2: channel_conf = 7; break;\n        case AV_CH_LAYOUT_5POINT0: channel_conf = 8; break;\n        case AV_CH_LAYOUT_5POINT1: channel_conf = 9; break;\n        case AV_CH_LAYOUT_7POINT0: channel_conf = 10; break;\n        case AV_CH_LAYOUT_7POINT1: channel_conf = 11; break;\n        default: channel_conf = 0;\n        }\n    }\n    lpcm->channel_conf = channel_conf;\n\n    CoTaskMemFree(wvfmt);\n\n    *size = sizeof(WAVEFORMATEX_HDMV_LPCM);\n    return lpcm;\n}\n\nWAVEFORMATEXTENSIBLE *CLAVFAudioHelper::CreateWFMTEX_RAW_PCM(const AVStream *avstream, ULONG *size, const GUID subtype,\n                                                             ULONG *samplesize)\n{\n    WAVEFORMATEXTENSIBLE *wfex = (WAVEFORMATEXTENSIBLE *)CoTaskMemAlloc(sizeof(WAVEFORMATEXTENSIBLE));\n    if (!wfex)\n        return nullptr;\n    memset(wfex, 0, sizeof(*wfex));\n\n    WAVEFORMATEX *wfe = &wfex->Format;\n    wfe->wFormatTag = (WORD)subtype.Data1;\n    wfe->nChannels = avstream->codecpar->ch_layout.nb_channels;\n    wfe->nSamplesPerSec = avstream->codecpar->sample_rate;\n    if (avstream->codecpar->format == AV_SAMPLE_FMT_S32 && avstream->codecpar->bits_per_raw_sample > 0)\n    {\n        wfe->wBitsPerSample = avstream->codecpar->bits_per_raw_sample > 24\n                                  ? 32\n                                  : (avstream->codecpar->bits_per_raw_sample > 16 ? 24 : 16);\n    }\n    else\n    {\n        wfe->wBitsPerSample = av_get_bytes_per_sample((AVSampleFormat)avstream->codecpar->format) << 3;\n    }\n    wfe->nBlockAlign = wfe->nChannels * wfe->wBitsPerSample / 8;\n    wfe->nAvgBytesPerSec = wfe->nSamplesPerSec * wfe->nBlockAlign;\n\n    bool bUseExtensible = false;\n\n    DWORD dwChannelMask = 0;\n    if (wfe->nChannels > 2)\n    {\n        bUseExtensible = true;\n\n        if (avstream->codecpar->ch_layout.order == AV_CHANNEL_ORDER_NATIVE)\n            dwChannelMask = (DWORD)avstream->codecpar->ch_layout.u.mask;\n\n        if (!dwChannelMask)\n        {\n            AVChannelLayout Layout{};\n            av_channel_layout_default(&Layout, wfe->nChannels);\n            dwChannelMask = (DWORD)Layout.u.mask;\n        }\n\n        if (dwChannelMask && av_popcount(dwChannelMask) != wfe->nChannels)\n            dwChannelMask = 0;\n    }\n    else if ((wfe->wBitsPerSample > 16 || wfe->nSamplesPerSec > 48000) && wfe->nChannels <= 2)\n    {\n        bUseExtensible = true;\n        dwChannelMask = wfe->nChannels == 2 ? (SPEAKER_FRONT_LEFT | SPEAKER_FRONT_RIGHT) : SPEAKER_FRONT_CENTER;\n    }\n\n    if (bUseExtensible)\n    {\n        wfex->Format.wFormatTag = WAVE_FORMAT_EXTENSIBLE;\n        wfex->Format.cbSize = sizeof(*wfex) - sizeof(wfex->Format);\n        wfex->dwChannelMask = dwChannelMask;\n        if (avstream->codecpar->format == AV_SAMPLE_FMT_S32 && avstream->codecpar->bits_per_raw_sample > 0)\n        {\n            wfex->Samples.wValidBitsPerSample = avstream->codecpar->bits_per_raw_sample;\n        }\n        else\n        {\n            wfex->Samples.wValidBitsPerSample = wfex->Format.wBitsPerSample;\n        }\n        wfex->SubFormat = subtype;\n        *size = sizeof(WAVEFORMATEXTENSIBLE);\n    }\n    else\n    {\n        *size = sizeof(WAVEFORMATEX);\n    }\n\n    *samplesize = wfe->wBitsPerSample * wfe->nChannels / 8;\n\n    return wfex;\n}\n\nMPEG1WAVEFORMAT *CLAVFAudioHelper::CreateMP1WVFMT(const AVStream *avstream, ULONG *size)\n{\n    WAVEFORMATEX *wvfmt = CreateWVFMTEX(avstream, size);\n    if (!wvfmt)\n        return nullptr;\n\n    MPEG1WAVEFORMAT *mpwvfmt = (MPEG1WAVEFORMAT *)CoTaskMemAlloc(sizeof(MPEG1WAVEFORMAT));\n    if (!mpwvfmt)\n        return nullptr;\n    memset(mpwvfmt, 0, sizeof(MPEG1WAVEFORMAT));\n    memcpy(&mpwvfmt->wfx, wvfmt, sizeof(WAVEFORMATEX));\n\n    mpwvfmt->dwHeadBitrate = (DWORD)avstream->codecpar->bit_rate;\n    mpwvfmt->fwHeadMode = avstream->codecpar->ch_layout.nb_channels == 1 ? ACM_MPEG_SINGLECHANNEL : ACM_MPEG_DUALCHANNEL;\n    mpwvfmt->fwHeadLayer = (avstream->codecpar->codec_id == AV_CODEC_ID_MP1) ? ACM_MPEG_LAYER1 : ACM_MPEG_LAYER2;\n\n    if (avstream->codecpar->sample_rate == 0)\n    {\n        avstream->codecpar->sample_rate = 48000;\n    }\n    mpwvfmt->wfx.wFormatTag = WAVE_FORMAT_MPEG;\n    mpwvfmt->wfx.nBlockAlign = WORD((avstream->codecpar->codec_id == AV_CODEC_ID_MP1)\n                                        ? (12 * avstream->codecpar->bit_rate / avstream->codecpar->sample_rate) * 4\n                                        : 144 * avstream->codecpar->bit_rate / avstream->codecpar->sample_rate);\n\n    mpwvfmt->wfx.cbSize = sizeof(MPEG1WAVEFORMAT) - sizeof(WAVEFORMATEX);\n\n    CoTaskMemFree(wvfmt);\n\n    *size = sizeof(MPEG1WAVEFORMAT);\n    return mpwvfmt;\n}\n\nVORBISFORMAT *CLAVFAudioHelper::CreateVorbis(const AVStream *avstream, ULONG *size)\n{\n    VORBISFORMAT *vfmt = (VORBISFORMAT *)CoTaskMemAlloc(sizeof(VORBISFORMAT));\n    if (!vfmt)\n        return nullptr;\n    memset(vfmt, 0, sizeof(VORBISFORMAT));\n\n    vfmt->nChannels = avstream->codecpar->ch_layout.nb_channels;\n    vfmt->nSamplesPerSec = avstream->codecpar->sample_rate;\n    vfmt->nAvgBitsPerSec = (DWORD)avstream->codecpar->bit_rate;\n    vfmt->nMinBitsPerSec = vfmt->nMaxBitsPerSec = (DWORD)-1;\n\n    *size = sizeof(VORBISFORMAT);\n    return vfmt;\n}\n\nVORBISFORMAT2 *CLAVFAudioHelper::CreateVorbis2(const AVStream *avstream, ULONG *size)\n{\n    BYTE *p = avstream->codecpar->extradata;\n    std::vector<int> sizes;\n    // read the number of blocks, and then the sizes of the individual blocks\n    for (BYTE n = *p++; n > 0; n--)\n    {\n        int size = 0;\n        // Xiph Lacing\n        do\n        {\n            size += *p;\n        } while (*p++ == 0xFF);\n        sizes.push_back(size);\n    }\n\n    int totalsize = 0;\n    for (unsigned int i = 0; i < sizes.size(); i++)\n        totalsize += sizes[i];\n\n    // Get the size of the last block\n    sizes.push_back(avstream->codecpar->extradata_size - (int)(p - avstream->codecpar->extradata) - totalsize);\n    totalsize += sizes[sizes.size() - 1];\n\n    // 3 blocks is the currently valid Vorbis format\n    if (sizes.size() == 3)\n    {\n        VORBISFORMAT2 *pvf2 = (VORBISFORMAT2 *)CoTaskMemAlloc(sizeof(VORBISFORMAT2) + totalsize);\n        if (!pvf2)\n            return nullptr;\n        memset(pvf2, 0, sizeof(VORBISFORMAT2));\n\n        pvf2->Channels = avstream->codecpar->ch_layout.nb_channels;\n        pvf2->SamplesPerSec = avstream->codecpar->sample_rate;\n        pvf2->BitsPerSample = get_bits_per_sample(avstream->codecpar);\n\n        BYTE *p2 = (BYTE *)pvf2 + sizeof(VORBISFORMAT2);\n        for (unsigned int i = 0; i < sizes.size(); p += sizes[i], p2 += sizes[i], i++)\n        {\n            memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);\n        }\n\n        *size = sizeof(VORBISFORMAT2) + totalsize;\n        return pvf2;\n    }\n    *size = 0;\n    return nullptr;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFAudioHelper.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#pragma once\n\n#include \"dvdmedia.h\"\n#include \"moreuuids.h\"\n\n// clang-format off\nconst AVCodecTag mp_wav_tags[] = {\n  { AV_CODEC_ID_WAVPACK,           0x5756 },\n  { AV_CODEC_ID_TTA,               0x77A1 },\n  { AV_CODEC_ID_ADPCM_4XM,         MKTAG('4', 'X', 'M', 'A')},\n  { AV_CODEC_ID_ADPCM_ADX,         MKTAG('S', 'a', 'd', 'x')},\n  { AV_CODEC_ID_ADPCM_EA,          MKTAG('A', 'D', 'E', 'A')},\n  { AV_CODEC_ID_ADPCM_EA_MAXIS_XA, MKTAG('A', 'D', 'X', 'A')},\n  { AV_CODEC_ID_ADPCM_IMA_WS,      MKTAG('A', 'I', 'W', 'S')},\n  { AV_CODEC_ID_ADPCM_THP,         MKTAG('T', 'H', 'P', 'A')},\n  { AV_CODEC_ID_ADPCM_XA,          MKTAG('P', 'S', 'X', 'A')},\n  { AV_CODEC_ID_AMR_NB,            MKTAG('n', 'b',   0,   0)},\n  { AV_CODEC_ID_BINKAUDIO_DCT,     MKTAG('B', 'A', 'U', '1')},\n  { AV_CODEC_ID_BINKAUDIO_RDFT,    MKTAG('B', 'A', 'U', '2')},\n  { AV_CODEC_ID_COOK,              MKTAG('c', 'o', 'o', 'k')},\n  { AV_CODEC_ID_DSICINAUDIO,       MKTAG('D', 'C', 'I', 'A')},\n  { AV_CODEC_ID_EAC3,              MKTAG('E', 'A', 'C', '3')},\n  { AV_CODEC_ID_INTERPLAY_DPCM,    MKTAG('I', 'N', 'P', 'A')},\n  { AV_CODEC_ID_MLP,               MKTAG('M', 'L', 'P', ' ')},\n  { AV_CODEC_ID_MP1,               0x50},\n  { AV_CODEC_ID_MP4ALS,            MKTAG('A', 'L', 'S', ' ')},\n  { AV_CODEC_ID_MUSEPACK7,         MKTAG('M', 'P', 'C', ' ')},\n  { AV_CODEC_ID_MUSEPACK8,         MKTAG('M', 'P', 'C', '8')},\n  { AV_CODEC_ID_NELLYMOSER,        MKTAG('N', 'E', 'L', 'L')},\n  { AV_CODEC_ID_QCELP,             MKTAG('Q', 'c', 'l', 'p')},\n  { AV_CODEC_ID_QDM2,              MKTAG('Q', 'D', 'M', '2')},\n  { AV_CODEC_ID_RA_144,            MKTAG('1', '4', '_', '4')},\n  { AV_CODEC_ID_RA_288,            MKTAG('2', '8', '_', '8')},\n  { AV_CODEC_ID_ROQ_DPCM,          MKTAG('R', 'o', 'Q', 'A')},\n  { AV_CODEC_ID_SHORTEN,           MKTAG('s', 'h', 'r', 'n')},\n  { AV_CODEC_ID_SPEEX,             MKTAG('s', 'p', 'x', ' ')},\n  { AV_CODEC_ID_TWINVQ,            MKTAG('T', 'W', 'I', '2')},\n  { AV_CODEC_ID_WESTWOOD_SND1,     MKTAG('S', 'N', 'D', '1')},\n  { AV_CODEC_ID_XAN_DPCM,          MKTAG('A', 'x', 'a', 'n')},\n  { AV_CODEC_ID_MP4ALS,            MKTAG('A', 'L', 'S', ' ')},\n  { AV_CODEC_ID_NONE,              0}\n};\n// clang-format on\n\nconst struct AVCodecTag *const mp_wav_taglists[] = {avformat_get_riff_audio_tags(), mp_wav_tags, 0};\n\nclass CLAVFAudioHelper\n{\n  public:\n    CLAVFAudioHelper(){};\n    CMediaType initAudioType(AVCodecParameters *codecpar, unsigned int &codecTag, std::string container);\n\n    WAVEFORMATEX *CreateWVFMTEX(const AVStream *avstream, ULONG *size);\n    WAVEFORMATEXFFMPEG *CreateWVFMTEX_FF(const AVStream *avstream, ULONG *size);\n    WAVEFORMATEX_HDMV_LPCM *CreateWVFMTEX_LPCM(const AVStream *avstream, ULONG *size);\n    WAVEFORMATEXTENSIBLE *CreateWFMTEX_RAW_PCM(const AVStream *avstream, ULONG *size, const GUID subtype,\n                                               ULONG *samplesize);\n    WAVEFORMATEXFFMPEG *CreateWFMTEX_RAW_PCM_FF(const AVStream *avstream, ULONG *size,\n                                                const GUID subtype, ULONG *samplesize);\n    MPEG1WAVEFORMAT *CreateMP1WVFMT(const AVStream *avstream, ULONG *size);\n    VORBISFORMAT *CreateVorbis(const AVStream *avstream, ULONG *size);\n    VORBISFORMAT2 *CreateVorbis2(const AVStream *avstream, ULONG *size);\n};\n\nextern CLAVFAudioHelper g_AudioHelper;\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFDemuxer.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVFDemuxer.h\"\n#include \"LAVFUtils.h\"\n#include \"LAVFStreamInfo.h\"\n#include \"ILAVPinInfo.h\"\n#include \"LAVFVideoHelper.h\"\n#include \"ExtradataParser.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n\n#include \"LAVSplitterSettingsInternal.h\"\n\n#include \"moreuuids.h\"\n\nextern \"C\"\n{\n    typedef struct CodecMime\n    {\n        char str[32];\n        enum AVCodecID id;\n    } CodecMime;\n#include \"libavformat/mpegts.h\"\n#include \"libavformat/matroska.h\"\n#include \"libavutil/avstring.h\"\n\n    enum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);\n#include \"libavformat/isom.h\"\n#include \"libavformat/demux.h\"\n}\n\n#ifdef DEBUG\n#include \"lavf_log.h\"\n#endif\n\n#include \"BDDemuxer.h\"\n#include \"CueSheet.h\"\n\n#define AVFORMAT_OPEN_TIMEOUT 20\n\nextern void lavf_get_iformat_infos(const AVInputFormat *pFormat, const char **pszName, const char **pszDescription);\n\nstatic const AVRational AV_RATIONAL_TIMEBASE = {1, AV_TIME_BASE};\n\nstd::set<FormatInfo> CLAVFDemuxer::GetFormatList()\n{\n    std::set<FormatInfo> formats;\n    const AVInputFormat *f = nullptr;\n    void *state = NULL;\n\n    while (f = av_demuxer_iterate(&state))\n    {\n        FormatInfo format;\n        lavf_get_iformat_infos(f, &format.strName, &format.strDescription);\n        if (format.strName)\n            formats.insert(format);\n    }\n    return formats;\n}\n\nCLAVFDemuxer::CLAVFDemuxer(CCritSec *pLock, ILAVFSettingsInternal *settings)\n    : CBaseDemuxer(L\"lavf demuxer\", pLock)\n{\n#ifdef DEBUG\n    DbgSetModuleLevel(LOG_CUSTOM1, DWORD_MAX); // FFMPEG messages use custom1\n    av_log_set_callback(lavf_log_callback);\n#else\n    av_log_set_callback(nullptr);\n#endif\n\n    m_bSubStreams = settings->GetSubstreamsEnabled();\n\n    m_pSettings = settings;\n\n    WCHAR fileName[1024];\n    GetModuleFileName(nullptr, fileName, 1024);\n    const WCHAR *file = PathFindFileName(fileName);\n\n    if (_wcsicmp(file, L\"zplayer.exe\") == 0)\n    {\n        m_bEnableTrackInfo = FALSE;\n\n        // TrackInfo is only properly handled in ZoomPlayer 8.0.0.74 and above\n        DWORD dwVersionSize = GetFileVersionInfoSize(fileName, nullptr);\n        if (dwVersionSize > 0)\n        {\n            void *versionInfo = CoTaskMemAlloc(dwVersionSize);\n            if (!versionInfo)\n                return;\n            GetFileVersionInfo(fileName, 0, dwVersionSize, versionInfo);\n            VS_FIXEDFILEINFO *info;\n            unsigned cbInfo;\n            BOOL bInfoPresent = VerQueryValue(versionInfo, TEXT(\"\\\\\"), (LPVOID *)&info, &cbInfo);\n            if (bInfoPresent)\n            {\n                bInfoPresent = bInfoPresent;\n                uint64_t version = info->dwFileVersionMS;\n                version <<= 32;\n                version += info->dwFileVersionLS;\n                if (version >= 0x000800000000004A)\n                    m_bEnableTrackInfo = TRUE;\n            }\n            CoTaskMemFree(versionInfo);\n        }\n    }\n}\n\nCLAVFDemuxer::~CLAVFDemuxer()\n{\n    CleanupAVFormat();\n    SAFE_DELETE(m_pFontInstaller);\n}\n\nSTDMETHODIMP CLAVFDemuxer::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    *ppv = nullptr;\n\n    return QI(IKeyFrameInfo) m_bEnableTrackInfo &&\n           QI(ITrackInfo) QI2(IAMExtendedSeeking) QI2(IAMMediaContent) QI(IPropertyBag)\n               QI(IDSMResourceBag) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// Demuxer Functions\nSTDMETHODIMP CLAVFDemuxer::Open(LPCOLESTR pszFileName, LPCOLESTR pszUserAgent, LPCOLESTR pszReferrer)\n{\n    return OpenInputStream(nullptr, pszFileName, nullptr, TRUE, false, pszUserAgent, pszReferrer);\n}\n\nSTDMETHODIMP CLAVFDemuxer::Start()\n{\n    if (m_bH264MVCCombine)\n    {\n        CMediaType *pmt = m_pSettings->GetOutputMediatype(m_nH264MVCBaseStream);\n        if (pmt)\n        {\n            if (pmt->subtype != MEDIASUBTYPE_AMVC && pmt->subtype != MEDIASUBTYPE_MVC1)\n            {\n                DbgLog(\n                    (LOG_TRACE, 10,\n                     L\"CLAVFDemuxer::Start(): Disabling MVC demuxing, downstream did not select an appropriate type\"));\n                m_bH264MVCCombine = FALSE;\n                m_nH264MVCBaseStream = -1;\n                m_nH264MVCExtensionStream = -1;\n            }\n        }\n    }\n\n    if (m_avFormat)\n        av_read_play(m_avFormat);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::AbortOpening(int mode, int timeout)\n{\n    m_Abort = mode;\n    m_timeAbort = timeout ? time(nullptr) + timeout : 0;\n    return S_OK;\n}\n\nint CLAVFDemuxer::avio_interrupt_cb(void *opaque)\n{\n    CLAVFDemuxer *demux = (CLAVFDemuxer *)opaque;\n\n    // Check for file opening timeout\n    time_t now = time(nullptr);\n    if (demux->m_timeOpening && now > (demux->m_timeOpening + AVFORMAT_OPEN_TIMEOUT))\n        return 1;\n\n    if (demux->m_Abort && now > demux->m_timeAbort)\n        return 1;\n\n    return 0;\n}\n\nstatic LPCWSTR wszImageExtensions[] = {\n    L\".png\",  L\".mng\",  L\".pns\", // PNG\n    L\".tif\",  L\".tiff\",          // TIFF\n    L\".jpeg\", L\".jpg\",  L\".jps\", // JPEG\n    L\".tga\",                     // TGA\n    L\".bmp\",                     // BMP\n    L\".j2c\",                     // JPEG2000\n    L\".webp\",                    // WebP\n};\n\nstatic LPCWSTR wszBlockedExtensions[] = {L\".ifo\", L\".bup\"};\n\nstatic std::pair<const char *, const char *> rtmpParametersTranslate[] = {\n    std::make_pair(\"app\", \"rtmp_app\"),\n    std::make_pair(\"buffer\", \"rtmp_buffer\"),\n    std::make_pair(\"conn\", \"rtmp_conn\"),\n    std::make_pair(\"flashVer\", \"rtmp_flashver\"),\n    std::make_pair(\"rtmp_flush_interval\", \"rtmp_flush_interval\"),\n    std::make_pair(\"live\", \"rtmp_live\"),\n    std::make_pair(\"pageUrl\", \"rtmp_pageurl\"),\n    std::make_pair(\"playpath\", \"rtmp_playpath\"),\n    std::make_pair(\"subscribe\", \"rtmp_subscribe\"),\n    std::make_pair(\"swfHash\", \"rtmp_swfhash\"),\n    std::make_pair(\"swfSize\", \"rtmp_swfsize\"),\n    std::make_pair(\"swfUrl\", \"rtmp_swfurl\"),\n    std::make_pair(\"swfVfy\", \"rtmp_swfverify\"),\n    std::make_pair(\"tcUrl\", \"rtmp_tcurl\")};\n\nSTDMETHODIMP CLAVFDemuxer::OpenInputStream(AVIOContext *byteContext, LPCOLESTR pszFileName, const char *format,\n                                           BOOL bForce, BOOL bFileSource, LPCOLESTR pszUserAgent,\n                                           LPCOLESTR pszReferrer)\n{\n    CAutoLock lock(m_pLock);\n    HRESULT hr = S_OK;\n\n    int ret; // return code from avformat functions\n\n    // Convert the filename from wchar to char for avformat\n    char *fileName = NULL;\n    if (pszFileName)\n        fileName = CoTaskGetMultiByteFromWideChar(CP_UTF8, 0, pszFileName, -1);\n\n    if (fileName == NULL)\n    {\n        fileName = (char *)CoTaskMemAlloc(1);\n        *fileName = 0;\n    }\n\n    // handle pipe, we only support stdin pipes\n    if (_strnicmp(\"pipe://\", fileName, 7) == 0)\n    {\n        // convert pipe://stdin to pipe:0\n        fileName[5] = '0';\n        fileName[6] = 0;\n    }\n\n    if (_strnicmp(\"mms:\", fileName, 4) == 0)\n    {\n        memmove(fileName + 1, fileName, strlen(fileName));\n        memcpy(fileName, \"mmsh\", 4);\n    }\n\n    // replace \"icyx\" protocol by http\n    if (_strnicmp(\"icyx:\", fileName, 5) == 0)\n    {\n        memcpy(fileName, \"http\", 4);\n    }\n\n    char *rtmp_prameters = nullptr;\n    const char *rtsp_transport = nullptr;\n    // check for rtsp transport protocol options\n    if (_strnicmp(\"rtsp\", fileName, 4) == 0)\n    {\n        if (_strnicmp(\"rtspu:\", fileName, 6) == 0)\n        {\n            rtsp_transport = \"udp\";\n        }\n        else if (_strnicmp(\"rtspm:\", fileName, 6) == 0)\n        {\n            rtsp_transport = \"udp_multicast\";\n        }\n        else if (_strnicmp(\"rtspt:\", fileName, 6) == 0)\n        {\n            rtsp_transport = \"tcp\";\n        }\n        else if (_strnicmp(\"rtsph:\", fileName, 6) == 0)\n        {\n            rtsp_transport = \"http\";\n        }\n\n        // replace \"rtsp[u|m|t|h]\" protocol by rtsp\n        if (rtsp_transport != nullptr)\n        {\n            memmove(fileName + 4, fileName + 5, strlen(fileName) - 4);\n        }\n    }\n    else if (_strnicmp(\"rtmp\", fileName, 4) == 0)\n    {\n        rtmp_prameters = strchr(fileName, ' ');\n        if (rtmp_prameters)\n        {\n            *rtmp_prameters = '\\0'; // Trim not supported part form fileName\n        }\n    }\n\n    AVIOInterruptCB cb = {avio_interrupt_cb, this};\n\ntrynoformat:\n    // Create the avformat_context\n    m_avFormat = avformat_alloc_context();\n    m_avFormat->pb = byteContext;\n    m_avFormat->interrupt_callback = cb;\n\n    if (m_avFormat->pb)\n        m_avFormat->flags |= AVFMT_FLAG_CUSTOM_IO;\n\n    LPWSTR extension = pszFileName ? PathFindExtensionW(pszFileName) : nullptr;\n\n    const AVInputFormat *inputFormat = nullptr;\n    if (format)\n    {\n        inputFormat = av_find_input_format(format);\n    }\n    else if (pszFileName)\n    {\n        LPWSTR extension = PathFindExtensionW(pszFileName);\n        for (int i = 0; i < countof(wszImageExtensions); i++)\n        {\n            if (_wcsicmp(extension, wszImageExtensions[i]) == 0)\n            {\n                if (byteContext)\n                {\n                    inputFormat = av_find_input_format(\"image2pipe\");\n                }\n                else\n                {\n                    inputFormat = av_find_input_format(\"image2\");\n                }\n                break;\n            }\n        }\n\n        if (byteContext == nullptr || bFileSource)\n        {\n            for (int i = 0; i < countof(wszBlockedExtensions); i++)\n            {\n                if (_wcsicmp(extension, wszBlockedExtensions[i]) == 0)\n                {\n                    goto done;\n                }\n            }\n        }\n    }\n\n    // Disable loading of external mkv segments, if required\n    if (!m_pSettings->GetLoadMatroskaExternalSegments())\n        m_avFormat->flags |= AVFMT_FLAG_NOEXTERNAL;\n\n    // demuxer/protocol options\n    AVDictionary *options = nullptr;\n    av_dict_set(&options, \"icy\", \"1\", 0);               // request ICY metadata\n    av_dict_set(&options, \"advanced_editlist\", \"0\", 0); // disable broken mov editlist handling\n    av_dict_set(&options, \"reconnect\", \"1\", 0);         // for http, reconnect if we get disconnected\n    av_dict_set(&options, \"skip_clear\", \"1\", 0);        // mpegts program handling\n    av_dict_set(&options, \"max_reload\", \"7\", 0);        // playlist reloading for HLS\n    av_dict_set(&options, \"extension_picky\", \"0\", 0);   // less strict HLS parsing\n\n    if (pszUserAgent)\n    {\n        char *strUserAgent = CoTaskGetMultiByteFromWideChar(CP_UTF8, 0, pszUserAgent, -1);\n        if (strUserAgent && *strUserAgent) // if valid, and non-empty\n            av_dict_set(&options, \"user_agent\", strUserAgent, 0);\n\n        SAFE_CO_FREE(strUserAgent);\n    }\n\n    if (pszReferrer != NULL)\n    {\n        char *strReferrer = CoTaskGetMultiByteFromWideChar(CP_UTF8, 0, pszReferrer, -1);\n        if (strReferrer && *strReferrer) // if valid, and non-empty\n            av_dict_set(&options, \"referer\", strReferrer, 0);\n\n        SAFE_CO_FREE(strReferrer);\n    }\n    else\n    {\n        av_dict_set(&options, \"referer\", fileName, 0); // for http, send self as referer if none was specified explicitly\n    }\n\n    if (rtsp_transport != nullptr)\n    {\n        av_dict_set(&options, \"rtsp_transport\", rtsp_transport, 0);\n    }\n\n    if (rtmp_prameters != nullptr)\n    {\n        char buff[4100];\n        char *next_token = nullptr;\n        bool bSwfVerify = false;\n\n        strcpy_s(buff, rtmp_prameters + 1);\n        const char *token = strtok_s(buff, \" \", &next_token);\n        while (token)\n        {\n            for (size_t i = 0; i < _countof(rtmpParametersTranslate); i++)\n            {\n                const size_t len = strlen(rtmpParametersTranslate[i].first);\n                if (_strnicmp(token, rtmpParametersTranslate[i].first, len) == 0)\n                {\n                    if (strlen(token) > len + 1 && token[len] == '=')\n                    {\n                        if (_strnicmp(\"swfVfy\", rtmpParametersTranslate[i].first, len) == 0)\n                        {\n                            bSwfVerify = token[len + 1] == '1';\n                            continue;\n                        }\n                        else if (_strnicmp(\"live\", rtmpParametersTranslate[i].first, len) == 0)\n                        {\n                            if (token[len + 1] == '1')\n                            {\n                                av_dict_set(&options, rtmpParametersTranslate[i].second, \"live\", 0);\n                            }\n                            else if (token[len + 1] == '0')\n                            {\n                                av_dict_set(&options, rtmpParametersTranslate[i].second, \"recorded\", 0);\n                            }\n                            continue;\n                        }\n                        av_dict_set(&options, rtmpParametersTranslate[i].second, token + len + 1, 0);\n                    }\n                }\n            }\n            token = strtok_s(nullptr, \" \", &next_token);\n        }\n\n        if (bSwfVerify)\n        {\n            const AVDictionaryEntry *swfUrlEntry = av_dict_get(options, \"rtmp_swfurl\", nullptr, 0);\n            if (swfUrlEntry)\n            {\n                av_dict_set(&options, \"rtmp_swfverify\", swfUrlEntry->value, 0);\n            }\n        }\n    }\n\n    m_timeOpening = time(nullptr);\n    ret = avformat_open_input(&m_avFormat, fileName, inputFormat, &options);\n    av_dict_free(&options);\n    if (ret < 0)\n    {\n        DbgLog((LOG_ERROR, 0, TEXT(\"::OpenInputStream(): avformat_open_input failed (%d)\"), ret));\n        if (format)\n        {\n            DbgLog((LOG_ERROR, 0, TEXT(\" -> trying again without specific format\")));\n            format = nullptr;\n            avformat_close_input(&m_avFormat);\n            goto trynoformat;\n        }\n        goto done;\n    }\n    DbgLog((LOG_TRACE, 10,\n            TEXT(\"::OpenInputStream(): avformat_open_input opened file of type '%S' (took %I64d seconds)\"),\n            m_avFormat->iformat->name, time(nullptr) - m_timeOpening));\n    m_timeOpening = 0;\n\n    CHECK_HR(hr = InitAVFormat(pszFileName, bForce));\n\n    SAFE_CO_FREE(fileName);\n    return S_OK;\ndone:\n    CleanupAVFormat();\n    SAFE_CO_FREE(fileName);\n    return E_FAIL;\n}\n\nvoid CLAVFDemuxer::AddMPEGTSStream(int pid, uint32_t stream_type)\n{\n    if (m_avFormat)\n    {\n        int program = -1;\n        if (m_avFormat->nb_programs > 0)\n        {\n            unsigned nb_streams = 0;\n            for (unsigned i = 0; i < m_avFormat->nb_programs; i++)\n            {\n                if (m_avFormat->programs[i]->nb_stream_indexes > nb_streams)\n                    program = i;\n            }\n        }\n        avpriv_mpegts_add_stream(m_avFormat, pid, stream_type, program >= 0 ? m_avFormat->programs[program]->id : -1);\n    }\n}\n\nHRESULT CLAVFDemuxer::CheckBDM2TSCPLI(LPCOLESTR pszFileName)\n{\n    size_t len = wcslen(pszFileName);\n\n    if (len <= 23 || (_wcsnicmp(pszFileName + len - 23, L\"\\\\BDMV\\\\STREAM\\\\\", 13) != 0 &&\n                      (len <= 28 || _wcsnicmp(pszFileName + len - 28, L\"\\\\BDMV\\\\STREAM\\\\SSIF\\\\\", 18) != 0)))\n        return E_FAIL;\n\n    // Get the base file name (should be a number, like 00000)\n    const WCHAR *file = pszFileName + (len - 10);\n    WCHAR basename[6];\n    wcsncpy_s(basename, file, 5);\n    basename[5] = 0;\n\n    // Convert to UTF-8 path\n    size_t a_len = WideCharToMultiByte(CP_UTF8, 0, pszFileName, -1, nullptr, 0, nullptr, nullptr);\n    a_len += 2; // one extra char because CLIPINF is 7 chars and STREAM is 6, and one for the terminating-zero\n\n    char *path = (char *)CoTaskMemAlloc(a_len * sizeof(char));\n    if (!path)\n        return E_OUTOFMEMORY;\n    WideCharToMultiByte(CP_UTF8, 0, pszFileName, -1, path, (int)a_len, nullptr, nullptr);\n\n    // Remove file name itself\n    PathRemoveFileSpecA(path);\n\n    // Remove SSIF if appropriate\n    BOOL bSSIF = FALSE;\n    if (_strnicmp(path + strlen(path) - 5, \"\\\\SSIF\", 5) == 0)\n    {\n        bSSIF = TRUE;\n        PathRemoveFileSpecA(path);\n    }\n\n    // Remove STREAM folder\n    PathRemoveFileSpecA(path);\n\n    // Write new path\n    sprintf_s(path + strlen(path), a_len - strlen(path), \"\\\\CLIPINF\\\\%S.clpi\", basename);\n\n    CLPI_CL *cl = bd_read_clpi(path);\n    if (!cl)\n        return E_FAIL;\n\n    // Clip Info was found, add the language metadata to the AVStreams\n    for (unsigned i = 0; i < cl->program.num_prog; ++i)\n    {\n        CLPI_PROG *p = &cl->program.progs[i];\n        for (unsigned k = 0; k < p->num_streams; ++k)\n        {\n            CLPI_PROG_STREAM *s = &p->streams[k];\n            AVStream *avstream = GetAVStreamByPID(s->pid);\n            if (avstream)\n            {\n                if (s->lang[0] != 0)\n                    av_dict_set(&avstream->metadata, \"language\", (const char *)s->lang, 0);\n            }\n        }\n    }\n    // Free the clip\n    bd_free_clpi(cl);\n    cl = nullptr;\n\n    if (bSSIF)\n    {\n        uint32_t clip_id = _wtoi(basename);\n\n        // Remove filename\n        PathRemoveFileSpecA(path);\n\n        // Remove CLIPINF\n        PathRemoveFileSpecA(path);\n\n        // Remove BDMV\n        PathRemoveFileSpecA(path);\n\n        BLURAY *bd = bd_open(path, nullptr);\n        if (!bd)\n            return S_FALSE;\n\n        uint32_t nTitles = bd_get_titles(bd, TITLES_RELEVANT, 0);\n        BOOL found = FALSE;\n        for (uint32_t n = 0; n < nTitles && !found; n++)\n        {\n            BLURAY_TITLE_INFO *TitleInfo = bd_get_title_info(bd, n, 0);\n            if (TitleInfo)\n            {\n                for (uint32_t i = 0; i < TitleInfo->clip_count; i++)\n                {\n                    BLURAY_CLIP_INFO *Clip = &TitleInfo->clips[i];\n                    if (Clip->idx == clip_id)\n                    {\n                        AVStream *avstream = nullptr;\n                        for (uint8_t c = 0; c < Clip->video_stream_count && !avstream; c++)\n                        {\n                            if (Clip->video_streams[c].coding_type == BLURAY_STREAM_TYPE_VIDEO_H264)\n                                avstream = GetAVStreamByPID(Clip->video_streams[c].pid);\n                        }\n\n                        if (avstream)\n                            av_dict_set(&avstream->metadata, \"stereo_mode\",\n                                        TitleInfo->mvc_base_view_r_flag ? \"mvc_rl\" : \"mvc_lr\", 0);\n\n                        found = TRUE;\n                        break;\n                    }\n                }\n\n                bd_free_title_info(TitleInfo);\n            }\n        }\n\n        bd_close(bd);\n    }\n\n    return S_OK;\n}\n\ninline static int init_parser(AVFormatContext *s, AVStream *st)\n{\n    if (av_lav_stream_parser_get_needed(st) && !(s->flags & AVFMT_FLAG_NOPARSE))\n    {\n        av_lav_stream_parser_init(st);\n    }\n    return 0;\n}\n\nvoid CLAVFDemuxer::UpdateParserFlags(AVStream *st)\n{\n    int flags = av_lav_stream_parser_get_flags(st);\n    if ((st->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO || st->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO) &&\n        _stricmp(m_pszInputFormat, \"mpegvideo\") != 0)\n    {\n        flags |= PARSER_FLAG_NO_TIMESTAMP_MANGLING;\n    }\n    else if (st->codecpar->codec_id == AV_CODEC_ID_H264)\n    {\n        flags |= PARSER_FLAG_NO_TIMESTAMP_MANGLING;\n    }\n    else if (st->codecpar->codec_id == AV_CODEC_ID_VC1)\n    {\n        if (m_bVC1Correction)\n        {\n            flags &= ~PARSER_FLAG_NO_TIMESTAMP_MANGLING;\n        }\n        else\n        {\n            flags |= PARSER_FLAG_NO_TIMESTAMP_MANGLING;\n        }\n    }\n    av_lav_stream_parser_update_flags(st, flags);\n}\n\nstatic struct sCoverMimeTypes\n{\n    AVCodecID codec;\n    LPCWSTR mime;\n    LPCWSTR ext;\n} CoverMimeTypes[] = {\n    {AV_CODEC_ID_MJPEG, L\"image/jpeg\", L\".jpg\"}, {AV_CODEC_ID_PNG, L\"image/png\", L\".png\"},\n    {AV_CODEC_ID_GIF, L\"image/gif\", L\".gif\"},    {AV_CODEC_ID_BMP, L\"image/bmp\", L\".bmp\"},\n    {AV_CODEC_ID_TIFF, L\"image/tiff\", L\".tiff\"},\n};\n\nSTDMETHODIMP CLAVFDemuxer::InitAVFormat(LPCOLESTR pszFileName, BOOL bForce)\n{\n    HRESULT hr = S_OK;\n\n    const char *format = nullptr;\n    lavf_get_iformat_infos(m_avFormat->iformat, &format, nullptr);\n    if (!bForce && (!format || !m_pSettings->IsFormatEnabled(format)))\n    {\n        DbgLog((LOG_TRACE, 20, L\"::InitAVFormat() - format of type '%S' disabled, failing\",\n                format ? format : m_avFormat->iformat->name));\n        return E_FAIL;\n    }\n\n    m_pszInputFormat = format ? format : m_avFormat->iformat->name;\n\n    m_bVC1SeenTimestamp = FALSE;\n\n    LPWSTR extension = pszFileName ? PathFindExtensionW(pszFileName) : nullptr;\n\n    m_bMatroska = (_strnicmp(m_pszInputFormat, \"matroska\", 8) == 0);\n    m_bOgg = (_strnicmp(m_pszInputFormat, \"ogg\", 3) == 0);\n    m_bAVI = (_strnicmp(m_pszInputFormat, \"avi\", 3) == 0);\n    m_bMPEGTS = (_strnicmp(m_pszInputFormat, \"mpegts\", 6) == 0);\n    m_bMPEGPS = (_stricmp(m_pszInputFormat, \"mpeg\") == 0);\n    m_bRM = (_stricmp(m_pszInputFormat, \"rm\") == 0);\n    m_bPMP = (_stricmp(m_pszInputFormat, \"pmp\") == 0);\n    m_bMP4 = (_stricmp(m_pszInputFormat, \"mp4\") == 0);\n\n    m_bTSDiscont = (m_avFormat->iformat->flags & AVFMT_TS_DISCONT) || m_bRM || (_stricmp(m_pszInputFormat, \"dash\") == 0);\n\n    WCHAR szProt[24] = L\"file\";\n    if (pszFileName)\n    {\n        DWORD dwNumChars = 24;\n        hr = UrlGetPart(pszFileName, szProt, &dwNumChars, URL_PART_SCHEME, 0);\n        if (SUCCEEDED(hr) && dwNumChars && (_wcsicmp(szProt, L\"file\") != 0))\n        {\n            m_avFormat->flags |= AVFMT_FLAG_NETWORK;\n            DbgLog((LOG_TRACE, 10, TEXT(\"::InitAVFormat(): detected network protocol: %s\"), szProt));\n        }\n    }\n\n    // TODO: make both durations below configurable\n    // decrease analyze duration for network streams\n    if (m_avFormat->flags & AVFMT_FLAG_NETWORK ||\n        (m_avFormat->flags & AVFMT_FLAG_CUSTOM_IO && !m_avFormat->pb->seekable))\n    {\n        // require at least 0.2 seconds\n        av_opt_set_int(m_avFormat, \"analyzeduration\",\n                       max(m_pSettings->GetNetworkStreamAnalysisDuration() * 1000, 200000), 0);\n    }\n    else\n    {\n        av_opt_set_int(m_avFormat, \"analyzeduration\", 7500000, 0);\n        // And increase it for mpeg-ts/ps files\n        if (m_bMPEGTS || m_bMPEGPS)\n        {\n            av_opt_set_int(m_avFormat, \"analyzeduration\", 30000000, 0);\n            av_opt_set_int(m_avFormat, \"probesize\", 75000000, 0);\n        }\n    }\n\n    av_opt_set_int(m_avFormat, \"correct_ts_overflow\", !m_pBluRay, 0);\n\n    m_timeOpening = time(nullptr);\n    int ret = avformat_find_stream_info(m_avFormat, nullptr);\n    if (ret < 0)\n    {\n        DbgLog((LOG_ERROR, 0, TEXT(\"::InitAVFormat(): av_find_stream_info failed (%d)\"), ret));\n        goto done;\n    }\n    DbgLog((LOG_TRACE, 10, TEXT(\"::InitAVFormat(): avformat_find_stream_info finished, took %I64d seconds\"),\n            time(nullptr) - m_timeOpening));\n    m_timeOpening = 0;\n\n    // Check if this is a m2ts in a BD structure, and if it is, read some extra stream properties out of the CLPI files\n    if (m_pBluRay)\n    {\n        m_pBluRay->ProcessBluRayMetadata();\n    }\n    else if (pszFileName && m_bMPEGTS)\n    {\n        CheckBDM2TSCPLI(pszFileName);\n    }\n\n    char *icy_headers = nullptr;\n    if (av_opt_get(m_avFormat, \"icy_metadata_headers\", AV_OPT_SEARCH_CHILDREN, (uint8_t **)&icy_headers) >= 0 &&\n        icy_headers && strlen(icy_headers) > 0)\n    {\n        std::string icyHeaders(icy_headers);\n        std::stringstream icyHeaderStream(icyHeaders);\n\n        std::string line;\n        while (std::getline(icyHeaderStream, line))\n        {\n            size_t seperatorIdx = line.find_first_of(\":\");\n            std::string token = line.substr(0, seperatorIdx);\n            std::string value = line.substr(seperatorIdx + 1);\n            if (_stricmp(token.c_str(), \"icy-name\") == 0)\n            {\n                // not entirely correct, but this way it gets exported through IAMMediaContent\n                av_dict_set(&m_avFormat->metadata, \"artist\", value.c_str(), 0);\n            }\n            else if (_stricmp(token.c_str(), \"icy-description\") == 0)\n            {\n                av_dict_set(&m_avFormat->metadata, \"comment\", value.c_str(), 0);\n            }\n            else if (_stricmp(token.c_str(), \"icy-genre\") == 0)\n            {\n                av_dict_set(&m_avFormat->metadata, \"genre\", value.c_str(), 0);\n            }\n        }\n\n        ParseICYMetadataPacket();\n    }\n    av_freep(&icy_headers);\n\n    SAFE_CO_FREE(m_stOrigParser);\n    m_stOrigParser = (enum AVStreamParseType *)CoTaskMemAlloc(m_avFormat->nb_streams * sizeof(enum AVStreamParseType));\n    if (!m_stOrigParser)\n        return E_OUTOFMEMORY;\n\n    for (unsigned int idx = 0; idx < m_avFormat->nb_streams; ++idx)\n    {\n        AVStream *st = m_avFormat->streams[idx];\n\n        // Disable full stream parsing for these formats\n        if (av_lav_stream_parser_get_needed(st) == AVSTREAM_PARSE_FULL)\n        {\n            if (st->codecpar->codec_id == AV_CODEC_ID_DVB_SUBTITLE)\n            {\n                av_lav_stream_parser_set_needed(st, AVSTREAM_PARSE_NONE);\n            }\n        }\n\n        if (m_bOgg && st->codecpar->codec_id == AV_CODEC_ID_H264)\n        {\n            av_lav_stream_parser_set_needed(st, AVSTREAM_PARSE_FULL);\n        }\n\n        // Create the parsers with the appropriate flags\n        init_parser(m_avFormat, st);\n        UpdateParserFlags(st);\n\n#ifdef DEBUG\n        AVProgram *streamProg = av_find_program_from_stream(m_avFormat, nullptr, idx);\n        DbgLog((LOG_TRACE, 30, L\"Stream %d (pid %d) - program: %d, codec: %S; parsing: %S;\", idx, st->id,\n                streamProg ? streamProg->pmt_pid : -1, avcodec_get_name(st->codecpar->codec_id),\n                lavf_get_parsing_string(av_lav_stream_parser_get_needed(st))));\n#endif\n        m_stOrigParser[idx] = av_lav_stream_parser_get_needed(st);\n\n        if ((st->codecpar->codec_id == AV_CODEC_ID_DTS && st->codecpar->codec_tag == 0xA2) ||\n            (st->codecpar->codec_id == AV_CODEC_ID_EAC3 && st->codecpar->codec_tag == 0xA1))\n            st->disposition |= LAVF_DISPOSITION_SECONDARY_AUDIO;\n\n        UpdateSubStreams();\n\n        if (st->codecpar->codec_type == AVMEDIA_TYPE_ATTACHMENT)\n        {\n            const AVDictionaryEntry *attachFilename = av_dict_get(st->metadata, \"filename\", nullptr, 0);\n            const AVDictionaryEntry *attachMimeType = av_dict_get(st->metadata, \"mimetype\", nullptr, 0);\n            const AVDictionaryEntry *attachDescription = av_dict_get(st->metadata, \"comment\", nullptr, 0);\n\n            if (attachFilename && attachMimeType)\n            {\n                LPWSTR chFilename =\n                    CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, attachFilename->value, -1);\n                LPWSTR chMimetype =\n                    CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, attachMimeType->value, -1);\n                LPWSTR chDescription = nullptr;\n\n                if (attachDescription)\n                    chDescription =\n                        CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, attachDescription->value, -1);\n\n                if (chFilename && chMimetype)\n                    ResAppend(chFilename, chDescription, chMimetype, st->codecpar->extradata,\n                              (DWORD)st->codecpar->extradata_size);\n\n                SAFE_CO_FREE(chFilename);\n                SAFE_CO_FREE(chMimetype);\n                SAFE_CO_FREE(chDescription);\n            }\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\" -> Unknown attachment, missing filename or mimetype\"));\n            }\n\n            // Try to guess the codec id for fonts only listed by name\n            if (st->codecpar->codec_id == AV_CODEC_ID_NONE && attachFilename)\n            {\n                char *dot = strrchr(attachFilename->value, '.');\n                if (dot && !_stricmp(dot, \".ttf\"))\n                    st->codecpar->codec_id = AV_CODEC_ID_TTF;\n                else if (dot && !_stricmp(dot, \".otf\"))\n                    st->codecpar->codec_id = AV_CODEC_ID_OTF;\n            }\n\n            if (st->codecpar->codec_id == AV_CODEC_ID_TTF || st->codecpar->codec_id == AV_CODEC_ID_OTF)\n            {\n                if (!m_pFontInstaller)\n                {\n                    m_pFontInstaller = new CFontInstaller();\n                }\n                m_pFontInstaller->InstallFont(st->codecpar->extradata, st->codecpar->extradata_size);\n            }\n        }\n        else if (st->disposition & AV_DISPOSITION_ATTACHED_PIC && st->attached_pic.data && st->attached_pic.size > 0)\n        {\n            LPWSTR chFilename = nullptr;\n            LPWSTR chMimeType = nullptr;\n            LPWSTR chDescription = nullptr;\n\n            // gather a filename\n            const AVDictionaryEntry *attachFilename = av_dict_get(st->metadata, \"filename\", nullptr, 0);\n            if (attachFilename)\n                chFilename = CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, attachFilename->value, -1);\n\n            // gather a mimetype\n            const AVDictionaryEntry *attachMimeType = av_dict_get(st->metadata, \"mimetype\", nullptr, 0);\n            if (attachMimeType)\n                chMimeType = CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, attachMimeType->value, -1);\n\n            // gather description\n            const AVDictionaryEntry *attachDescription = av_dict_get(st->metadata, \"comment\", nullptr, 0);\n            if (attachDescription)\n                chDescription =\n                    CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, attachDescription->value, -1);\n\n            for (int c = 0; c < countof(CoverMimeTypes); c++)\n            {\n                if (CoverMimeTypes[c].codec == st->codecpar->codec_id)\n                {\n                    if (chFilename == nullptr)\n                    {\n                        size_t size = wcslen(CoverMimeTypes[c].ext) + 15;\n                        chFilename = (LPWSTR)CoTaskMemAlloc(size * sizeof(wchar_t));\n                        wcscpy_s(chFilename, size, L\"EmbeddedCover\");\n                        wcscat_s(chFilename, size, CoverMimeTypes[c].ext);\n                    }\n                    if (chMimeType == nullptr)\n                    {\n                        size_t size = wcslen(CoverMimeTypes[c].mime) + 1;\n                        chMimeType = (LPWSTR)CoTaskMemAlloc(size * sizeof(wchar_t));\n                        wcscpy_s(chMimeType, size, CoverMimeTypes[c].mime);\n                    }\n                    break;\n                }\n            }\n\n            // Export embedded cover-art through IDSMResourceBag interface\n            if (chFilename && chMimeType)\n            {\n                ResAppend(chFilename, chDescription, chMimeType, st->attached_pic.data, (DWORD)st->attached_pic.size);\n            }\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\" -> Unknown attachment, missing filename or mimetype\"));\n            }\n\n            SAFE_CO_FREE(chFilename);\n            SAFE_CO_FREE(chMimeType);\n            SAFE_CO_FREE(chDescription);\n        }\n    }\n\n    if (AVDictionaryEntry *cue = av_dict_get(m_avFormat->metadata, \"CUESHEET\", nullptr, 0))\n    {\n        CCueSheet cueSheet;\n        if (SUCCEEDED(cueSheet.Parse(cue->value)))\n        {\n            // Metadata\n            if (!cueSheet.m_Title.empty() && !av_dict_get(m_avFormat->metadata, \"title\", nullptr, 0))\n                av_dict_set(&m_avFormat->metadata, \"title\", cueSheet.m_Title.c_str(), 0);\n            if (!cueSheet.m_Performer.empty() && !av_dict_get(m_avFormat->metadata, \"artist\", nullptr, 0))\n                av_dict_set(&m_avFormat->metadata, \"artist\", cueSheet.m_Performer.c_str(), 0);\n            // Free old chapters\n            while (m_avFormat->nb_chapters--)\n            {\n                av_dict_free(&m_avFormat->chapters[m_avFormat->nb_chapters]->metadata);\n                av_freep(&m_avFormat->chapters[m_avFormat->nb_chapters]);\n            }\n            av_freep(&m_avFormat->chapters);\n            m_avFormat->nb_chapters = 0;\n            for (CCueSheet::Track track : cueSheet.m_Tracks)\n            {\n                avpriv_new_chapter(m_avFormat, track.index, AVRational{1, DSHOW_TIME_BASE}, track.Time, track.Time,\n                                   cueSheet.FormatTrack(track).c_str());\n            }\n        }\n    }\n\n    CHECK_HR(hr = CreateStreams());\n\n    return S_OK;\ndone:\n    CleanupAVFormat();\n    return E_FAIL;\n}\n\nvoid CLAVFDemuxer::CleanupAVFormat()\n{\n    FlushMVCExtensionQueue();\n    if (m_avFormat)\n    {\n        // Override abort timer to ensure the close function in network protocols can actually close the stream\n        AbortOpening(1, 5);\n        avformat_close_input(&m_avFormat);\n    }\n    SAFE_CO_FREE(m_stOrigParser);\n}\n\nAVStream *CLAVFDemuxer::GetAVStreamByPID(int pid)\n{\n    if (!m_avFormat)\n        return nullptr;\n\n    for (unsigned int idx = 0; idx < m_avFormat->nb_streams; ++idx)\n    {\n        if (m_avFormat->streams[idx]->id == pid &&\n            !(m_avFormat->streams[idx]->disposition & LAVF_DISPOSITION_SUB_STREAM))\n            return m_avFormat->streams[idx];\n    }\n\n    return nullptr;\n}\n\nHRESULT CLAVFDemuxer::SetActiveStream(StreamType type, int pid)\n{\n    HRESULT hr = S_OK;\n\n    if (type == audio)\n        UpdateForcedSubtitleStream(pid);\n\n    hr = __super::SetActiveStream(type, pid);\n\n    // Usually selecting an audio stream would set the forced substream (since it uses the audio stream language)\n    // but in case there is no audio stream, do a fallback selection of any PGS stream here.\n    if (type == subpic && pid == FORCED_SUBTITLE_PID && m_ForcedSubStream == -1)\n    {\n        std::list<CSubtitleSelector> selectors;\n        CSubtitleSelector selector;\n        selector.audioLanguage = \"*\";\n        selector.subtitleLanguage = \"*\";\n        selector.dwFlagsSet = SUBTITLE_FLAG_PGS;\n        selector.dwFlagsNot = 0;\n        selectors.push_back(selector);\n\n        const stream *subst = SelectSubtitleStream(selectors, \"\");\n        if (subst)\n            m_ForcedSubStream = subst->pid;\n    }\n\n    for (unsigned int idx = 0; idx < m_avFormat->nb_streams; ++idx)\n    {\n        AVStream *st = m_avFormat->streams[idx];\n        if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)\n        {\n            st->discard = (m_dActiveStreams[video] == idx) ? AVDISCARD_DEFAULT : AVDISCARD_ALL;\n\n            // don't discard h264 mvc streams\n            if (m_bH264MVCCombine && st->codecpar->codec_id == AV_CODEC_ID_H264_MVC)\n                st->discard = AVDISCARD_DEFAULT;\n        }\n        else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)\n        {\n            st->discard = (m_dActiveStreams[audio] == idx) ? AVDISCARD_DEFAULT : AVDISCARD_ALL;\n            // If the stream is a sub stream, make sure to activate the main stream as well\n            if (m_bMPEGTS && (st->disposition & LAVF_DISPOSITION_SUB_STREAM) && st->discard == AVDISCARD_DEFAULT)\n            {\n                for (unsigned int idx2 = 0; idx2 < m_avFormat->nb_streams; ++idx2)\n                {\n                    AVStream *mst = m_avFormat->streams[idx2];\n                    if (mst->id == st->id)\n                    {\n                        mst->discard = AVDISCARD_DEFAULT;\n                        break;\n                    }\n                }\n            }\n        }\n        else if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)\n        {\n            st->discard = (m_dActiveStreams[subpic] == idx ||\n                           (m_dActiveStreams[subpic] == FORCED_SUBTITLE_PID && m_ForcedSubStream == idx))\n                              ? AVDISCARD_DEFAULT\n                              : AVDISCARD_ALL;\n        }\n        else\n        {\n            st->discard = AVDISCARD_ALL;\n        }\n    }\n\n    return hr;\n}\n\nvoid CLAVFDemuxer::UpdateSubStreams()\n{\n    for (unsigned int idx = 0; idx < m_avFormat->nb_streams; ++idx)\n    {\n        AVStream *st = m_avFormat->streams[idx];\n        // Find and flag the AC-3 substream\n        if (m_bMPEGTS && st->codecpar->codec_id == AV_CODEC_ID_TRUEHD)\n        {\n            int id = st->id;\n            AVStream *sub_st = nullptr;\n\n            for (unsigned int i = 0; i < m_avFormat->nb_streams; ++i)\n            {\n                AVStream *sst = m_avFormat->streams[i];\n                if (idx != i && sst->id == id)\n                {\n                    sub_st = sst;\n                    break;\n                }\n            }\n            if (sub_st)\n            {\n                sub_st->disposition = st->disposition | LAVF_DISPOSITION_SUB_STREAM;\n                av_dict_copy(&sub_st->metadata, st->metadata, 0);\n            }\n        }\n    }\n}\n\nSTDMETHODIMP CLAVFDemuxer::SetTitle(int idx)\n{\n    if (!m_bMatroska)\n        return E_NOTIMPL;\n    av_mkv_set_next_edition(m_avFormat, idx);\n\n    // Update duration\n    AVEdition *editions = nullptr;\n    av_mkv_get_editions(m_avFormat, &editions);\n    m_avFormat->duration = editions[idx].duration;\n\n    return S_OK;\n}\n\nSTDMETHODIMP_(int) CLAVFDemuxer::GetTitle()\n{\n    if (!m_bMatroska)\n        return 0;\n    return av_mkv_get_edition(m_avFormat);\n}\n\nSTDMETHODIMP CLAVFDemuxer::GetTitleInfo(int idx, REFERENCE_TIME *rtDuration, WCHAR **ppszName)\n{\n    if (!m_bMatroska)\n        return E_NOTIMPL;\n\n    AVEdition *editions = nullptr;\n    av_mkv_get_editions(m_avFormat, &editions);\n\n    AVEdition *current_edition = &editions[idx];\n\n    if (rtDuration)\n        *rtDuration = av_rescale(current_edition->duration, DSHOW_TIME_BASE, AV_TIME_BASE);\n    if (ppszName)\n    {\n        char *title = nullptr;\n        int total_seconds = (int)(current_edition->duration / AV_TIME_BASE);\n        int seconds = total_seconds % 60;\n        int minutes = total_seconds / 60 % 60;\n        int hours = total_seconds / 3600;\n        if (current_edition->title)\n        {\n            title = av_asprintf(\"E: %s [%02d:%02d:%02d]\", current_edition->title, hours, minutes, seconds);\n        }\n        else\n        {\n            title = av_asprintf(\"E: Edition %d [%02d:%02d:%02d]\", idx + 1, hours, minutes, seconds);\n        }\n        *ppszName = CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, title, -1);\n        av_freep(&title);\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP_(int) CLAVFDemuxer::GetNumTitles()\n{\n    if (!m_bMatroska || !m_avFormat || !m_avFormat->priv_data || !m_avFormat->iformat || strcmp(m_avFormat->iformat->name, \"matroska\") != 0)\n        return 0;\n    return av_mkv_get_num_editions(m_avFormat);\n}\n\nvoid CLAVFDemuxer::SettingsChanged(ILAVFSettingsInternal *pSettings)\n{\n    int vc1Mode = pSettings->GetVC1TimestampMode();\n    if (vc1Mode == 1 || strcmp(m_pszInputFormat, \"rawvideo\") == 0)\n    {\n        m_bVC1Correction = true;\n    }\n    else if (vc1Mode == 2)\n    {\n        BOOL bReq = pSettings->IsVC1CorrectionRequired();\n        m_bVC1Correction = m_bMatroska ? !bReq : bReq;\n    }\n    else\n    {\n        m_bVC1Correction = false;\n    }\n\n    for (unsigned int idx = 0; idx < m_avFormat->nb_streams; ++idx)\n    {\n        AVStream *st = m_avFormat->streams[idx];\n        if (st->codecpar->codec_id == AV_CODEC_ID_VC1)\n        {\n            UpdateParserFlags(st);\n        }\n        else if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)\n        {\n            av_lav_stream_parser_set_needed(st, m_stOrigParser[idx]);\n        }\n    }\n\n    m_bPGSNoParsing = !pSettings->GetPGSOnlyForced();\n}\n\nREFERENCE_TIME CLAVFDemuxer::GetDuration() const\n{\n    int64_t iLength = 0;\n    if (m_avFormat->duration == (int64_t)AV_NOPTS_VALUE || m_avFormat->duration < 0LL)\n    {\n        // no duration is available for us\n        // try to calculate it\n        // TODO\n        /*if (m_rtCurrent != Packet::INVALID_TIME && m_avFormat->file_size > 0 && m_avFormat->pb && m_avFormat->pb->pos\n        > 0) { iLength = (((m_rtCurrent * m_avFormat->file_size) / m_avFormat->pb->pos) / 1000) & 0xFFFFFFFF;\n        }*/\n        // DbgLog((LOG_ERROR, 1, TEXT(\"duration is not available\")));\n        return -1;\n    }\n    else\n    {\n        iLength = m_avFormat->duration;\n    }\n    return ConvertTimestampToRT(iLength, 1, AV_TIME_BASE, 0);\n}\n\n#define VC1_CODE_RES0 0x00000100\n#define IS_VC1_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)\n\nSTDMETHODIMP CLAVFDemuxer::CreatePacketMediaType(Packet *pPacket, enum AVCodecID codec_id, BYTE *extradata,\n                                                 int extradata_size, BYTE *paramchange, int paramchange_size)\n{\n    CMediaType *pmt = m_pSettings->GetOutputMediatype(pPacket->StreamId);\n    if (pmt)\n    {\n        if (extradata && extradata_size)\n        {\n            if (codec_id == AV_CODEC_ID_H264)\n            {\n                MPEG2VIDEOINFO *mp2vi =\n                    (MPEG2VIDEOINFO *)pmt->ReallocFormatBuffer(sizeof(MPEG2VIDEOINFO) + extradata_size);\n                int ret = g_VideoHelper.ProcessH264Extradata(extradata, extradata_size, mp2vi, FALSE);\n                if (ret < 0)\n                {\n                    mp2vi->cbSequenceHeader = extradata_size;\n                    memcpy(&mp2vi->dwSequenceHeader[0], extradata, extradata_size);\n                }\n                else\n                {\n                    int mp2visize = SIZE_MPEG2VIDEOINFO(mp2vi);\n                    memset((BYTE *)mp2vi + mp2visize, 0, pmt->cbFormat - mp2visize);\n                }\n            }\n            else if (codec_id == AV_CODEC_ID_MPEG2VIDEO)\n            {\n                MPEG2VIDEOINFO *mp2vi =\n                    (MPEG2VIDEOINFO *)pmt->ReallocFormatBuffer(sizeof(MPEG2VIDEOINFO) + extradata_size);\n                CExtradataParser parser = CExtradataParser(extradata, extradata_size);\n                mp2vi->cbSequenceHeader = (DWORD)parser.ParseMPEGSequenceHeader((BYTE *)&mp2vi->dwSequenceHeader[0]);\n            }\n            else if (codec_id == AV_CODEC_ID_VC1)\n            {\n                VIDEOINFOHEADER2 *vih2 =\n                    (VIDEOINFOHEADER2 *)pmt->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + extradata_size + 1);\n                int i = 0;\n                for (i = 0; i < (extradata_size - 4); i++)\n                {\n                    uint32_t code = AV_RB32(extradata + i);\n                    if (IS_VC1_MARKER(code))\n                        break;\n                }\n                if (i == 0)\n                {\n                    *((BYTE *)vih2 + sizeof(VIDEOINFOHEADER2)) = 0;\n                    memcpy((BYTE *)vih2 + sizeof(VIDEOINFOHEADER2) + 1, extradata, extradata_size);\n                }\n                else\n                {\n                    memcpy((BYTE *)vih2 + sizeof(VIDEOINFOHEADER2), extradata, extradata_size);\n                }\n            }\n            else if (codec_id == AV_CODEC_ID_ASS)\n            {\n                SUBTITLEINFO *sif = (SUBTITLEINFO *)pmt->ReallocFormatBuffer(sizeof(SUBTITLEINFO) + extradata_size);\n                memcpy((BYTE *)sif + sizeof(SUBTITLEINFO), extradata, extradata_size);\n            }\n            else\n            {\n                if (pmt->formattype == FORMAT_VideoInfo)\n                {\n                    VIDEOINFOHEADER *vih =\n                        (VIDEOINFOHEADER *)pmt->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER) + extradata_size);\n                    vih->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + extradata_size;\n                    memcpy((BYTE *)vih + sizeof(VIDEOINFOHEADER), extradata, extradata_size);\n                }\n                else if (pmt->formattype == FORMAT_VideoInfo2)\n                {\n                    VIDEOINFOHEADER2 *vih2 =\n                        (VIDEOINFOHEADER2 *)pmt->ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + extradata_size);\n                    vih2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + extradata_size;\n                    memcpy((BYTE *)vih2 + sizeof(VIDEOINFOHEADER2), extradata, extradata_size);\n                }\n                else if (pmt->formattype == FORMAT_WaveFormatEx)\n                {\n                    WAVEFORMATEX *wfex =\n                        (WAVEFORMATEX *)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEX) + extradata_size);\n                    wfex->cbSize = extradata_size;\n                    memcpy((BYTE *)wfex + sizeof(WAVEFORMATEX), extradata, extradata_size);\n                }\n                else if (pmt->formattype == FORMAT_WaveFormatExFFMPEG)\n                {\n                    WAVEFORMATEXFFMPEG *wfex =\n                        (WAVEFORMATEXFFMPEG *)pmt->ReallocFormatBuffer(sizeof(WAVEFORMATEXFFMPEG) + extradata_size);\n                    wfex->wfex.cbSize = extradata_size;\n                    memcpy((BYTE *)wfex + sizeof(WAVEFORMATEXFFMPEG), extradata, extradata_size);\n                }\n                else if (pmt->formattype == FORMAT_VorbisFormat2)\n                {\n                    BYTE *p = extradata;\n                    std::vector<int> sizes;\n                    for (BYTE n = *p++; n > 0; n--)\n                    {\n                        int size = 0;\n                        // Xiph Lacing\n                        do\n                        {\n                            size += *p;\n                        } while (*p++ == 0xFF);\n                        sizes.push_back(size);\n                    }\n\n                    int totalsize = 0;\n                    for (size_t i = 0; i < sizes.size(); i++)\n                        totalsize += sizes[i];\n\n                    sizes.push_back(extradata_size - (int)(p - extradata) - totalsize);\n                    totalsize += sizes[sizes.size() - 1];\n\n                    // 3 blocks is the currently valid Vorbis format\n                    if (sizes.size() == 3)\n                    {\n                        VORBISFORMAT2 *pvf2 =\n                            (VORBISFORMAT2 *)pmt->ReallocFormatBuffer(sizeof(VORBISFORMAT2) + totalsize);\n                        BYTE *p2 = (BYTE *)pvf2 + sizeof(VORBISFORMAT2);\n                        for (unsigned int i = 0; i < sizes.size(); p += sizes[i], p2 += sizes[i], i++)\n                        {\n                            memcpy(p2, p, pvf2->HeaderSize[i] = sizes[i]);\n                        }\n                    }\n                }\n                else\n                {\n                    DbgLog((LOG_TRACE, 10, L\"::GetNextPacket() - Unsupported PMT change on codec %S\",\n                            avcodec_get_name(codec_id)));\n                }\n            }\n        }\n        if (paramchange)\n        {\n            uint32_t flags = AV_RL32(paramchange);\n            int channels = 0, sample_rate = 0, width = 0, height = 0, aspect_num = 0, aspect_den = 0;\n            paramchange += 4;\n            if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_COUNT)\n            {\n                channels = AV_RL32(paramchange);\n                paramchange += 4;\n            }\n            if (flags & AV_SIDE_DATA_PARAM_CHANGE_CHANNEL_LAYOUT)\n            {\n                paramchange += 8;\n            }\n            if (flags & AV_SIDE_DATA_PARAM_CHANGE_SAMPLE_RATE)\n            {\n                sample_rate = AV_RL32(paramchange);\n                paramchange += 4;\n            }\n            if (flags & AV_SIDE_DATA_PARAM_CHANGE_DIMENSIONS)\n            {\n                width = AV_RL32(paramchange);\n                height = AV_RL32(paramchange + 4);\n                paramchange += 8;\n            }\n            if (flags & AV_SIDE_DATA_PARAM_CHANGE_ASPECTRATIO)\n            {\n                aspect_num = AV_RL32(paramchange);\n                aspect_den = AV_RL32(paramchange + 4);\n                paramchange += 8;\n            }\n            if (pmt->majortype == MEDIATYPE_Video)\n            {\n                if ((pmt->formattype == FORMAT_VideoInfo || pmt->formattype == FORMAT_MPEGVideo) && width && height)\n                {\n                    VIDEOINFOHEADER *vih = (VIDEOINFOHEADER *)pmt->pbFormat;\n                    vih->bmiHeader.biWidth = width;\n                    vih->bmiHeader.biHeight = height;\n                    vih->rcTarget.right = vih->rcSource.right = width;\n                    vih->rcTarget.bottom = vih->rcSource.bottom = height;\n                }\n                else if ((pmt->formattype == FORMAT_VideoInfo2 || pmt->formattype == FORMAT_MPEG2Video) &&\n                         ((width && height) || (aspect_num && aspect_den)))\n                {\n                    VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)pmt->pbFormat;\n                    if (width && height)\n                    {\n                        vih2->bmiHeader.biWidth = width;\n                        vih2->bmiHeader.biHeight = height;\n                        vih2->rcTarget.right = vih2->rcSource.right = width;\n                        vih2->rcTarget.bottom = vih2->rcSource.bottom = height;\n                    }\n                    if (aspect_num && aspect_den)\n                    {\n                        int num = vih2->bmiHeader.biWidth, den = vih2->bmiHeader.biHeight;\n                        av_reduce(&num, &den, (int64_t)aspect_num * num, (int64_t)aspect_den * den, INT_MAX);\n                        vih2->dwPictAspectRatioX = num;\n                        vih2->dwPictAspectRatioY = den;\n                    }\n                }\n            }\n            else if (pmt->majortype == MEDIATYPE_Audio)\n            {\n                if ((pmt->formattype == FORMAT_WaveFormatEx || pmt->formattype == FORMAT_WaveFormatExFFMPEG) &&\n                    (channels || sample_rate))\n                {\n                    WAVEFORMATEX *wfex = nullptr;\n                    if (pmt->formattype == FORMAT_WaveFormatExFFMPEG)\n                    {\n                        WAVEFORMATEXFFMPEG *wfexff = (WAVEFORMATEXFFMPEG *)pmt->pbFormat;\n                        wfex = &wfexff->wfex;\n                    }\n                    else\n                    {\n                        wfex = (WAVEFORMATEX *)pmt->pbFormat;\n                    }\n                    if (channels)\n                        wfex->nChannels = channels;\n                    if (sample_rate)\n                        wfex->nSamplesPerSec = sample_rate;\n                }\n            }\n        }\n\n        if (pmt)\n        {\n            pPacket->pmt = CreateMediaType(pmt);\n            SAFE_DELETE(pmt);\n        }\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::ParseICYMetadataPacket()\n{\n    char *icy_data = nullptr;\n    if (av_opt_get(m_avFormat, \"icy_metadata_packet\", AV_OPT_SEARCH_CHILDREN, (uint8_t **)&icy_data) >= 0 && icy_data &&\n        strlen(icy_data) > 0)\n    {\n        std::string icyData(icy_data);\n        size_t idx = icyData.find(\"StreamTitle\");\n        if (idx != std::string::npos)\n        {\n            // strip StreamTitle token and =\n            std::string value = icyData.substr(idx + 12);\n            idx = value.find_first_of(\";\");\n            if (idx != std::string::npos)\n                value = value.substr(0, idx);\n            if (value[0] == '\\'' || value[0] == '\"')\n                value = value.substr(1);\n            if (value[value.length() - 1] == '\\'' || value[value.length() - 1] == '\"')\n                value = value.substr(0, value.length() - 1);\n            if (value.length() > 0)\n            {\n                av_dict_set(&m_avFormat->metadata, \"title\", value.c_str(), 0);\n            }\n        }\n        // clear value, and only read again when its send again\n        av_opt_set(m_avFormat, \"icy_metadata_packet\", \"\", AV_OPT_SEARCH_CHILDREN);\n    }\n    av_freep(&icy_data);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::GetNextPacket(Packet **ppPacket)\n{\n    CheckPointer(ppPacket, E_POINTER);\n\n    // If true, S_FALSE is returned, indicating a soft-failure\n    bool bReturnEmpty = false;\n\n    // Read packet\n    AVPacket pkt;\n    Packet *pPacket = nullptr;\n\n    // assume we are not eof\n    if (m_avFormat->pb)\n    {\n        m_avFormat->pb->eof_reached = 0;\n    }\n\n    int result = 0;\n    try\n    {\n        DBG_TIMING(\"av_read_frame\", 30, result = av_read_frame(m_avFormat, &pkt))\n    }\n    catch (...)\n    {\n        // ignore..\n    }\n\n    if (result == AVERROR(EINTR) || result == AVERROR(EAGAIN))\n    {\n        // timeout, probably no real error, return empty packet\n        bReturnEmpty = true;\n    }\n    else if (result == AVERROR_EOF)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::GetNextPacket(): End of File reached\"));\n    }\n    else if (result < 0)\n    {\n        // meh, fail\n    }\n    else if (pkt.size <= 0 || pkt.stream_index < 0 || (unsigned)pkt.stream_index >= m_avFormat->nb_streams)\n    {\n        // XXX, in some cases ffmpeg returns a zero or negative packet size\n        if (m_avFormat->pb && !m_avFormat->pb->eof_reached)\n        {\n            bReturnEmpty = true;\n        }\n        av_packet_unref(&pkt);\n    }\n    else\n    {\n        // Check right here if the stream is active, we can drop the package otherwise.\n        AVStream *stream = m_avFormat->streams[pkt.stream_index];\n        BOOL streamActive = FALSE;\n        BOOL forcedSubStream = FALSE;\n        for (int i = 0; i < unknown; ++i)\n        {\n            if (m_dActiveStreams[i] == pkt.stream_index)\n            {\n                streamActive = TRUE;\n                break;\n            }\n        }\n\n        // Accept it if its the forced subpic stream\n        if (m_dActiveStreams[subpic] == FORCED_SUBTITLE_PID && pkt.stream_index == m_ForcedSubStream)\n        {\n            forcedSubStream = streamActive = TRUE;\n        }\n\n        // Accept H264 MVC streams, as they get combined with the base stream later\n        if (m_bH264MVCCombine && stream->codecpar->codec_id == AV_CODEC_ID_H264_MVC)\n            streamActive = TRUE;\n\n        if (!streamActive)\n        {\n            av_packet_unref(&pkt);\n            return S_FALSE;\n        }\n\n        pPacket = new Packet();\n        if (!pPacket)\n            return E_OUTOFMEMORY;\n\n        // Convert timestamps to reference time and set them on the packet\n        REFERENCE_TIME pts = ConvertTimestampToRT(pkt.pts, stream->time_base.num, stream->time_base.den);\n        REFERENCE_TIME dts = ConvertTimestampToRT(pkt.dts, stream->time_base.num, stream->time_base.den);\n        REFERENCE_TIME duration = ConvertTimestampToRT(pkt.duration, stream->time_base.num, stream->time_base.den, 0);\n\n        pPacket->rtPTS = pts;\n        pPacket->rtDTS = dts;\n        pPacket->StreamId = (DWORD)pkt.stream_index;\n        pPacket->bPosition = pkt.pos;\n\n        if (stream->codecpar->codec_id == AV_CODEC_ID_H264)\n        {\n            if (m_bMatroska || m_bOgg)\n            {\n                if (!stream->codecpar->extradata_size || stream->codecpar->extradata[0] != 1 ||\n                    AV_RB32(pkt.data) == 0x00000001)\n                {\n                    pPacket->dwFlags |= LAV_PACKET_H264_ANNEXB;\n                }\n                else\n                { // No DTS for H264 in native format\n                    dts = Packet::INVALID_TIME;\n                }\n            }\n            else if (!m_bPMP && !m_bAVI)\n            { // For most formats, DTS timestamps for h.264 are no fun\n                dts = Packet::INVALID_TIME;\n            }\n        }\n\n        if (m_bAVI && stream->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)\n        {\n            // AVI's always have borked pts, specially if m_pFormatContext->flags includes\n            // AVFMT_FLAG_GENPTS so always use dts\n            pts = Packet::INVALID_TIME;\n        }\n\n        if (stream->codecpar->codec_id == AV_CODEC_ID_RV10 || stream->codecpar->codec_id == AV_CODEC_ID_RV20 ||\n            stream->codecpar->codec_id == AV_CODEC_ID_RV30 || stream->codecpar->codec_id == AV_CODEC_ID_RV40)\n        {\n            pts = Packet::INVALID_TIME;\n        }\n\n        // Never use DTS for these formats\n        if (!m_bAVI && (stream->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO ||\n                        stream->codecpar->codec_id == AV_CODEC_ID_MPEG1VIDEO))\n            dts = Packet::INVALID_TIME;\n\n        if (pkt.data)\n        {\n            result = pPacket->SetPacket(&pkt);\n            if (result < 0)\n            {\n                SAFE_DELETE(pPacket);\n                return E_OUTOFMEMORY;\n            }\n        }\n\n        // Select the appropriate timestamps\n        REFERENCE_TIME rt = Packet::INVALID_TIME;\n        // Try the different times set, pts first, dts when pts is not valid\n        if (pts != Packet::INVALID_TIME)\n        {\n            rt = pts;\n        }\n        else if (dts != Packet::INVALID_TIME)\n        {\n            rt = dts;\n        }\n\n        if (stream->codecpar->codec_id == AV_CODEC_ID_VC1)\n        {\n            if (m_bMatroska && m_bVC1Correction)\n            {\n                rt = pts;\n                if (!m_bVC1SeenTimestamp)\n                {\n                    if (rt == Packet::INVALID_TIME && dts != Packet::INVALID_TIME)\n                        rt = dts;\n                    m_bVC1SeenTimestamp = (pts != Packet::INVALID_TIME);\n                }\n            }\n            else if (m_bVC1Correction)\n            {\n                rt = dts;\n                pPacket->dwFlags |= LAV_PACKET_PARSED;\n            }\n        }\n        else if (stream->codecpar->codec_id == AV_CODEC_ID_MOV_TEXT)\n        {\n            pPacket->dwFlags |= LAV_PACKET_MOV_TEXT;\n        }\n\n        // Mark the packet as parsed, so the forced subtitle parser doesn't hit it\n        if (stream->codecpar->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE && m_bPGSNoParsing)\n        {\n            pPacket->dwFlags |= LAV_PACKET_PARSED;\n        }\n\n        pPacket->rtStart = pPacket->rtStop = rt;\n        if (rt != Packet::INVALID_TIME)\n        {\n            pPacket->rtStop += (duration > 0 || stream->codecpar->codec_id == AV_CODEC_ID_TRUEHD) ? duration : 1;\n        }\n\n        if (stream->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)\n        {\n            pPacket->bDiscontinuity = TRUE;\n\n            if (forcedSubStream)\n            {\n                pPacket->dwFlags |= LAV_PACKET_FORCED_SUBTITLE;\n                pPacket->dwFlags &= ~LAV_PACKET_PARSED;\n            }\n\n            if (stream->codecpar->codec_id == AV_CODEC_ID_SRT)\n            {\n                pPacket->dwFlags |= LAV_PACKET_SRT;\n            }\n        }\n\n        if (stream->codecpar->codec_id == AV_CODEC_ID_PCM_S16BE_PLANAR ||\n            stream->codecpar->codec_id == AV_CODEC_ID_PCM_S16LE_PLANAR ||\n            stream->codecpar->codec_id == AV_CODEC_ID_PCM_S24LE_PLANAR ||\n            stream->codecpar->codec_id == AV_CODEC_ID_PCM_S32LE_PLANAR)\n            pPacket->dwFlags |= LAV_PACKET_PLANAR_PCM;\n\n        if (stream->codecpar->codec_id == AV_CODEC_ID_WEBVTT)\n        {\n            size_t id_size = 0, settings_size = 0;\n            uint8_t *id = NULL, *settings = NULL;\n            id = av_packet_get_side_data(&pkt, AV_PKT_DATA_WEBVTT_IDENTIFIER, &id_size);\n            settings = av_packet_get_side_data(&pkt, AV_PKT_DATA_WEBVTT_SETTINGS, &settings_size);\n\n            int text_size = pPacket->GetDataSize();\n\n            // allocate size for id/settings\n            int pkt_size = text_size + (int)id_size + 2 + (int)settings_size + 2;\n            pPacket->SetDataSize(pkt_size);\n\n            uint8_t *data = pPacket->GetData();\n\n            // offset data\n            memmove(data + id_size + 2 + settings_size + 2, data, text_size);\n\n            // write id\n            if (id && id_size > 0)\n                memcpy(data, id, id_size);\n\n            data[id_size + 0] = '\\r';\n            data[id_size + 1] = '\\n';\n\n            // write settings\n            if (settings && settings_size > 0)\n                memcpy(data + id_size + 2, settings, settings_size);\n\n            data[id_size + 2 + settings_size + 0] = '\\r';\n            data[id_size + 2 + settings_size + 1] = '\\n';\n        }\n\n        // Update extradata and send new mediatype, when required\n        size_t sidedata_size = 0;\n        uint8_t *sidedata = av_packet_get_side_data(&pkt, AV_PKT_DATA_NEW_EXTRADATA, &sidedata_size);\n        size_t paramchange_size = 0;\n        uint8_t *paramchange = av_packet_get_side_data(&pkt, AV_PKT_DATA_PARAM_CHANGE, &paramchange_size);\n        if ((sidedata && sidedata_size) || (paramchange && paramchange_size))\n        {\n            CreatePacketMediaType(pPacket, stream->codecpar->codec_id, sidedata, (int)sidedata_size, paramchange,\n                                  (int)paramchange_size);\n        }\n\n        pPacket->bSyncPoint = pkt.flags & AV_PKT_FLAG_KEY;\n        pPacket->bDiscontinuity = !m_pBluRay && (pkt.flags & AV_PKT_FLAG_CORRUPT);\n#ifdef DEBUG\n        if (pkt.flags & AV_PKT_FLAG_CORRUPT)\n            DbgLog((LOG_TRACE, 10, L\"::GetNextPacket() - Signaling Discontinuinty because of corrupt package\"));\n#endif\n\n        if (pPacket->rtStart != AV_NOPTS_VALUE)\n            m_rtCurrent = pPacket->rtStart;\n\n        av_packet_unref(&pkt);\n    }\n\n    if (m_pBluRay && pPacket)\n    {\n        HRESULT hr = m_pBluRay->ProcessPacket(pPacket);\n        if (hr != S_OK)\n        {\n            SAFE_DELETE(pPacket);\n            bReturnEmpty = bReturnEmpty || hr == S_FALSE;\n        }\n    }\n\n    if (m_bH264MVCCombine && pPacket && pPacket->StreamId == m_nH264MVCExtensionStream)\n    {\n        if (FAILED(QueueMVCExtension(pPacket)))\n        {\n            SAFE_DELETE(pPacket);\n            return E_FAIL;\n        }\n\n        return S_FALSE;\n    }\n\n    if (m_bH264MVCCombine && pPacket && pPacket->StreamId == m_nH264MVCBaseStream)\n    {\n        HRESULT hr = CombineMVCBaseExtension(pPacket);\n        if (hr != S_OK)\n        {\n            SAFE_DELETE(pPacket);\n\n            // S_FALSE indicates a skipped packet, not a hard failure\n            if (hr == S_FALSE)\n                bReturnEmpty = true;\n        }\n    }\n\n    if (bReturnEmpty && !pPacket)\n    {\n        return S_FALSE;\n    }\n    if (!pPacket)\n    {\n        return E_FAIL;\n    }\n\n    ParseICYMetadataPacket();\n\n    *ppPacket = pPacket;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::QueueMVCExtension(Packet *pPacket)\n{\n    m_MVCExtensionQueue.push_back(pPacket);\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::FlushMVCExtensionQueue()\n{\n    for (auto it = m_MVCExtensionQueue.begin(); it != m_MVCExtensionQueue.end(); it++)\n    {\n        delete (*it);\n    }\n\n    m_MVCExtensionQueue.clear();\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::CombineMVCBaseExtension(Packet *pBasePacket)\n{\n    while (!m_MVCExtensionQueue.empty())\n    {\n        Packet *pExtensionPacket = m_MVCExtensionQueue.front();\n        if (pExtensionPacket->rtDTS == pBasePacket->rtDTS || pBasePacket->rtDTS == Packet::INVALID_TIME ||\n            pExtensionPacket->rtDTS == Packet::INVALID_TIME)\n        {\n            if (pBasePacket->Append(pExtensionPacket) < 0)\n                return E_FAIL;\n\n            m_MVCExtensionQueue.pop_front();\n            delete pExtensionPacket;\n            return S_OK;\n        }\n        else if (pExtensionPacket->rtDTS < pBasePacket->rtDTS)\n        {\n            DbgLog((LOG_TRACE, 10, L\"CLAVFDemuxer::CombineMVCBaseExtension(): Dropping extension %I64d, base is %I64d\",\n                    pExtensionPacket->rtDTS, pBasePacket->rtDTS));\n            m_MVCExtensionQueue.pop_front();\n            delete pExtensionPacket;\n        }\n        else if (pExtensionPacket->rtDTS > pBasePacket->rtDTS)\n        {\n            DbgLog((LOG_TRACE, 10,\n                    L\"CLAVFDemuxer::CombineMVCBaseExtension(): Dropping base %I64d, next extension is %I64d\",\n                    pBasePacket->rtDTS, pExtensionPacket->rtDTS));\n            return S_FALSE;\n        }\n    }\n\n    if (m_pBluRay && m_MVCExtensionQueue.empty())\n    {\n        HRESULT hr = m_pBluRay->FillMVCExtensionQueue(pBasePacket->rtDTS);\n        if (hr == S_OK)\n            return CombineMVCBaseExtension(pBasePacket);\n        else if (FAILED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"CLAVFDemuxer::CombineMVCBaseExtension(): Filling MVC extension queue failed\"));\n            return hr;\n        }\n    }\n\n    DbgLog((LOG_TRACE, 10, L\"CLAVFDemuxer::CombineMVCBaseExtension(): Ran out of extension packets for base %I64d\",\n            pBasePacket->rtDTS));\n    return S_FALSE;\n}\n\nSTDMETHODIMP CLAVFDemuxer::Seek(REFERENCE_TIME rTime)\n{\n    int seekStreamId = m_dActiveStreams[video];\n    int64_t seek_pts = 0;\nretry:\n    // If we have a video stream, seek on that one. If we don't, well, then don't!\n    if (rTime > 0)\n    {\n        if (seekStreamId != -1)\n        {\n            AVStream *stream = m_avFormat->streams[seekStreamId];\n            seek_pts = ConvertRTToTimestamp(rTime, stream->time_base.num, stream->time_base.den);\n        }\n        else\n        {\n            seek_pts = ConvertRTToTimestamp(rTime, 1, AV_TIME_BASE);\n        }\n    }\n\n    if (seek_pts < 0)\n        seek_pts = 0;\n\n    if (strcmp(m_pszInputFormat, \"rawvideo\") == 0 && seek_pts == 0)\n        return SeekByte(0, AVSEEK_FLAG_BACKWARD);\n\n    int flags = AVSEEK_FLAG_BACKWARD;\n\n    int ret = av_seek_frame(m_avFormat, seekStreamId, seek_pts, flags);\n    if (ret < 0)\n    {\n        DbgLog((LOG_CUSTOM1, 1, L\"::Seek() -- Key-Frame Seek failed\"));\n        ret = av_seek_frame(m_avFormat, seekStreamId, seek_pts, flags | AVSEEK_FLAG_ANY);\n        if (ret < 0)\n        {\n            DbgLog((LOG_ERROR, 1, L\"::Seek() -- Inaccurate Seek failed as well\"));\n            if (seekStreamId == m_dActiveStreams[video] && seekStreamId != -1 && m_dActiveStreams[audio] != -1)\n            {\n                DbgLog((LOG_ERROR, 1, L\"::Seek() -- retrying seek on audio stream\"));\n                seekStreamId = m_dActiveStreams[audio];\n                goto retry;\n            }\n            if (seek_pts == 0)\n            {\n                DbgLog((LOG_ERROR, 1, L\" -> attempting byte seek to position 0\"));\n                return SeekByte(0, AVSEEK_FLAG_BACKWARD);\n            }\n        }\n    }\n\n    for (unsigned i = 0; i < m_avFormat->nb_streams; i++)\n    {\n        init_parser(m_avFormat, m_avFormat->streams[i]);\n        UpdateParserFlags(m_avFormat->streams[i]);\n    }\n\n    m_bVC1SeenTimestamp = FALSE;\n\n    // Flush MVC extensions on seek (no-op if empty)\n    FlushMVCExtensionQueue();\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::SeekByte(int64_t pos, int flags)\n{\n    int ret = av_seek_frame(m_avFormat, -1, pos, flags | AVSEEK_FLAG_BYTE);\n    if (ret < 0)\n    {\n        DbgLog((LOG_ERROR, 1, L\"::SeekByte() -- Seek failed\"));\n    }\n\n    for (unsigned i = 0; i < m_avFormat->nb_streams; i++)\n    {\n        init_parser(m_avFormat, m_avFormat->streams[i]);\n        UpdateParserFlags(m_avFormat->streams[i]);\n    }\n\n    m_bVC1SeenTimestamp = FALSE;\n\n    // Flush MVC extensions on seek (no-op if empty)\n    FlushMVCExtensionQueue();\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::Reset()\n{\n    return SeekByte(0, AVSEEK_FLAG_ANY);\n}\n\nconst char *CLAVFDemuxer::GetContainerFormat() const\n{\n    return m_pszInputFormat;\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// IAMExtendedSeeking\nSTDMETHODIMP CLAVFDemuxer::get_ExSeekCapabilities(long *pExCapabilities)\n{\n    CheckPointer(pExCapabilities, E_POINTER);\n    *pExCapabilities = AM_EXSEEK_CANSEEK;\n    if (m_avFormat && m_avFormat->nb_chapters > 0)\n        *pExCapabilities |= AM_EXSEEK_MARKERSEEK;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::get_MarkerCount(long *pMarkerCount)\n{\n    CheckPointer(pMarkerCount, E_POINTER);\n    CheckPointer(m_avFormat, E_UNEXPECTED);\n    *pMarkerCount = (long)m_avFormat->nb_chapters;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::get_CurrentMarker(long *pCurrentMarker)\n{\n    CheckPointer(pCurrentMarker, E_POINTER);\n    CheckPointer(m_avFormat, E_UNEXPECTED);\n\n    *pCurrentMarker = 0;\n\n    REFERENCE_TIME rtCurrent = m_rtCurrent;\n    IFilterGraph *pGraph = m_pSettings->GetFilterGraph();\n    if (pGraph)\n    {\n        IMediaSeeking *pSeeking = nullptr;\n        if (SUCCEEDED(pGraph->QueryInterface(&pSeeking)))\n        {\n            if (FAILED(pSeeking->GetCurrentPosition(&rtCurrent)))\n            {\n                DbgLog((LOG_TRACE, 10, L\"get_CurrentMarker: Obtaining current playback position failed\"));\n                rtCurrent = m_rtCurrent;\n            }\n            SafeRelease(&pSeeking);\n        }\n        SafeRelease(&pGraph);\n    }\n\n    // Can the time_base change in between chapters?\n    // Anyhow, we do the calculation in the loop, just to be safe\n    for (unsigned int i = 0; i < m_avFormat->nb_chapters; ++i)\n    {\n        int64_t pts = ConvertRTToTimestamp(rtCurrent, m_avFormat->chapters[i]->time_base.num,\n                                           m_avFormat->chapters[i]->time_base.den);\n        // Check if the pts is in between the bounds of the chapter\n        if (pts >= m_avFormat->chapters[i]->start)\n        {\n            *pCurrentMarker = (i + 1);\n            // Many files only have chapter start points and no end times\n            if (pts <= m_avFormat->chapters[i]->end)\n                return S_OK;\n        }\n    }\n    return *pCurrentMarker > 0 ? S_OK : E_FAIL;\n}\n\nSTDMETHODIMP CLAVFDemuxer::GetMarkerTime(long MarkerNum, double *pMarkerTime)\n{\n    CheckPointer(pMarkerTime, E_POINTER);\n    // Chapters go by a 1-based index, doh\n    unsigned int index = MarkerNum - 1;\n    if (index >= m_avFormat->nb_chapters)\n    {\n        return E_FAIL;\n    }\n\n    REFERENCE_TIME rt =\n        ConvertTimestampToRT(m_avFormat->chapters[index]->start, m_avFormat->chapters[index]->time_base.num,\n                             m_avFormat->chapters[index]->time_base.den);\n    *pMarkerTime = (double)rt / DSHOW_TIME_BASE;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::GetMarkerName(long MarkerNum, BSTR *pbstrMarkerName)\n{\n    CheckPointer(pbstrMarkerName, E_POINTER);\n    // Chapters go by a 1-based index, doh\n    unsigned int index = MarkerNum - 1;\n    if (index >= m_avFormat->nb_chapters)\n    {\n        return E_FAIL;\n    }\n    // Get the title, or generate one\n    if (AVDictionaryEntry *dictEntry = av_dict_get(m_avFormat->chapters[index]->metadata, \"title\", nullptr, 0))\n    {\n        *pbstrMarkerName = ConvertCharToBSTR(dictEntry->value);\n    }\n    else\n    {\n        OLECHAR wTitle[128];\n        swprintf_s(wTitle, L\"Chapter %d\", MarkerNum);\n        *pbstrMarkerName = SysAllocString(wTitle);\n    }\n\n    return S_OK;\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// IKeyFrameInfo\nSTDMETHODIMP CLAVFDemuxer::GetKeyFrameCount(UINT &nKFs)\n{\n    if (m_dActiveStreams[video] < 0)\n    {\n        return E_NOTIMPL;\n    }\n\n    if (!m_bMatroska && !m_bAVI && !m_bMP4)\n    {\n        return E_FAIL;\n    }\n\n    // No reliable info for fragmented mp4 files\n    if (m_bMP4)\n    {\n        MOVContext *mov = (MOVContext *)m_avFormat->priv_data;\n        if (mov->frag_index.nb_items)\n            return S_FALSE;\n    }\n\n    nKFs = 0;\n\n    AVStream *stream = m_avFormat->streams[m_dActiveStreams[video]];\n    int nb_indexes = avformat_index_get_entries_count(stream);\n    for (int i = 0; i < nb_indexes; i++)\n    {\n        const AVIndexEntry *entry = avformat_index_get_entry(stream, i);\n        if (entry && (entry->flags & AVINDEX_KEYFRAME))\n            nKFs++;\n    }\n    return (nKFs == stream->nb_frames) ? S_FALSE : S_OK;\n}\n\nSTDMETHODIMP CLAVFDemuxer::GetKeyFrames(const GUID *pFormat, REFERENCE_TIME *pKFs, UINT &nKFs)\n{\n    CheckPointer(pFormat, E_POINTER);\n    CheckPointer(pKFs, E_POINTER);\n\n    if (m_dActiveStreams[video] < 0)\n    {\n        return E_NOTIMPL;\n    }\n\n    if (!m_bMatroska && !m_bAVI && !m_bMP4)\n    {\n        return E_FAIL;\n    }\n\n    // No reliable info for fragmented mp4 files\n    if (m_bMP4)\n    {\n        MOVContext *mov = (MOVContext *)m_avFormat->priv_data;\n        if (mov->frag_index.nb_items)\n            return S_FALSE;\n    }\n\n    if (*pFormat != TIME_FORMAT_MEDIA_TIME)\n        return E_INVALIDARG;\n\n    UINT nKFsMax = nKFs;\n    nKFs = 0;\n\n    // CTTS counter for MP4\n    int ctts_sample_counter = 0;\n    uint32_t ctts_index = 0;\n\n    AVStream *stream = m_avFormat->streams[m_dActiveStreams[video]];\n    int nb_indexes = avformat_index_get_entries_count(stream);\n    for (int i = 0; i < nb_indexes && nKFs < nKFsMax; i++)\n    {\n        const AVIndexEntry *entry = avformat_index_get_entry(stream, i);\n        if (entry && (entry->flags & AVINDEX_KEYFRAME))\n        {\n            int64_t timestamp = entry->timestamp;\n\n            // MP4 index timestamps are DTS, seeking expects PTS however, so offset them accordingly to ensure seeking\n            // works as expected\n            if (m_bMP4)\n            {\n                MOVStreamContext *sc = (MOVStreamContext *)stream->priv_data;\n                if (i < sc->sample_offsets_count)\n                    timestamp += (sc->sample_offsets[i] + sc->dts_shift);\n                else if (sc->tts_count)\n                {\n                    // find the next CTTS entry, if needed\n                    while (ctts_sample_counter <= i && ctts_index < sc->tts_count)\n                    {\n                        ctts_sample_counter += sc->tts_data[ctts_index++].count;\n                    }\n\n                    // apply the CTTS offset to the timestamp\n                    if (ctts_sample_counter > i)\n                        timestamp += (sc->tts_data[ctts_index - 1].offset + sc->dts_shift);\n                    else\n                        timestamp += (sc->min_corrected_pts + sc->dts_shift);\n                }\n                else\n                    timestamp += (sc->min_corrected_pts + sc->dts_shift);\n            }\n\n            pKFs[nKFs] = ConvertTimestampToRT(timestamp, stream->time_base.num, stream->time_base.den);\n            nKFs++;\n        }\n    }\n    return S_OK;\n}\n\nint CLAVFDemuxer::GetStreamIdxFromTotalIdx(size_t index) const\n{\n    const stream *st = GetStreamFromTotalIdx(index);\n    if (st)\n        return st->pid;\n    return -1;\n}\n\nconst CBaseDemuxer::stream *CLAVFDemuxer::GetStreamFromTotalIdx(size_t index) const\n{\n    int type = video;\n    size_t count_v = m_streams[video].size();\n    size_t count_a = m_streams[audio].size();\n    size_t count_s = m_streams[subpic].size();\n    if (index >= count_v)\n    {\n        index -= count_v;\n        type = audio;\n        if (index >= count_a)\n        {\n            index -= count_a;\n            type = subpic;\n            if (index >= count_s)\n                return nullptr;\n        }\n    }\n\n    return &m_streams[type][index];\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// ITrackInfo\nSTDMETHODIMP_(UINT) CLAVFDemuxer::GetTrackCount()\n{\n    if (!m_avFormat)\n        return 0;\n\n    size_t count = m_streams[video].size() + m_streams[audio].size() + m_streams[subpic].size();\n\n    return (UINT)count;\n}\n\n// \\param aTrackIdx the track index (from 0 to GetTrackCount()-1)\nSTDMETHODIMP_(BOOL) CLAVFDemuxer::GetTrackInfo(UINT aTrackIdx, struct TrackElement *pStructureToFill)\n{\n    DbgLog((LOG_TRACE, 20, L\"ITrackInfo::GetTrackInfo(): index %d, struct: %p\", aTrackIdx, pStructureToFill));\n\n    if (!m_avFormat || !pStructureToFill)\n        return FALSE;\n\n    ZeroMemory(pStructureToFill, sizeof(*pStructureToFill));\n    pStructureToFill->Size = sizeof(*pStructureToFill);\n\n    const stream *st = GetStreamFromTotalIdx(aTrackIdx);\n    if (!st || st->pid < 0 || st->pid == NO_SUBTITLE_PID)\n        return FALSE;\n\n    if (st->pid == FORCED_SUBTITLE_PID)\n    {\n        pStructureToFill->FlagDefault = 0;\n        pStructureToFill->FlagForced = 1;\n        pStructureToFill->Type = TypeSubtitle;\n        strcpy_s(pStructureToFill->Language, \"und\");\n    }\n    else\n    {\n        const AVStream *avst = m_avFormat->streams[st->pid];\n\n        // Fill structure\n        pStructureToFill->FlagDefault = (avst->disposition & AV_DISPOSITION_DEFAULT);\n        pStructureToFill->FlagForced = (avst->disposition & AV_DISPOSITION_FORCED);\n        strncpy_s(pStructureToFill->Language, st->language.c_str(), _TRUNCATE);\n        pStructureToFill->Language[3] = '\\0';\n\n        pStructureToFill->Type = (avst->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)\n                                     ? TypeVideo\n                                     : (avst->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)\n                                           ? TypeAudio\n                                           : (avst->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE) ? TypeSubtitle : 0;\n    }\n\n    // The following flags are not exported via avformat\n    pStructureToFill->FlagLacing = 0;\n    pStructureToFill->MaxCache = 0;\n    pStructureToFill->MinCache = 0;\n\n    return TRUE;\n}\n\n// Get an extended information struct relative to the track type\nSTDMETHODIMP_(BOOL) CLAVFDemuxer::GetTrackExtendedInfo(UINT aTrackIdx, void *pStructureToFill)\n{\n    if (!m_avFormat || !pStructureToFill)\n        return FALSE;\n\n    int id = GetStreamIdxFromTotalIdx(aTrackIdx);\n    if (id < 0 || (unsigned)id >= m_avFormat->nb_streams)\n        return FALSE;\n\n    const AVStream *st = m_avFormat->streams[id];\n\n    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)\n    {\n        TrackExtendedInfoVideo *pTEIV = (TrackExtendedInfoVideo *)pStructureToFill;\n\n        ZeroMemory(pTEIV, sizeof(*pTEIV));\n\n        pTEIV->Size = sizeof(*pTEIV);\n        pTEIV->DisplayUnit = 0; // always pixels\n        pTEIV->DisplayWidth = st->codecpar->width;\n        pTEIV->DisplayHeight = st->codecpar->height;\n\n        pTEIV->PixelWidth = st->codecpar->width;\n        pTEIV->PixelHeight = st->codecpar->height;\n\n        pTEIV->AspectRatioType = 0;\n        pTEIV->Interlaced = 0;\n    }\n    else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)\n    {\n        TrackExtendedInfoAudio *pTEIA = (TrackExtendedInfoAudio *)pStructureToFill;\n\n        ZeroMemory(pTEIA, sizeof(*pTEIA));\n\n        pTEIA->Size = sizeof(*pTEIA);\n        pTEIA->BitDepth = st->codecpar->bits_per_coded_sample;\n        pTEIA->Channels = st->codecpar->ch_layout.nb_channels;\n        pTEIA->OutputSamplingFrequency = (FLOAT)st->codecpar->sample_rate;\n        pTEIA->SamplingFreq = (FLOAT)st->codecpar->sample_rate;\n    }\n\n    return TRUE;\n}\n\nSTDMETHODIMP_(BSTR) CLAVFDemuxer::GetTrackName(UINT aTrackIdx)\n{\n\n    const stream *st = GetStreamFromTotalIdx(aTrackIdx);\n    if (!st)\n        return nullptr;\n\n    BSTR trackName = nullptr;\n    if (!st->trackName.empty())\n    {\n        trackName = ConvertCharToBSTR(st->trackName.c_str());\n    }\n\n    return trackName;\n}\n\nSTDMETHODIMP_(BSTR) CLAVFDemuxer::GetTrackCodecName(UINT aTrackIdx)\n{\n    if (!m_avFormat)\n        return nullptr;\n\n    int id = GetStreamIdxFromTotalIdx(aTrackIdx);\n    if (id < 0 || (unsigned)id >= m_avFormat->nb_streams)\n        return FALSE;\n\n    const AVStream *st = m_avFormat->streams[id];\n\n    BSTR codecName = nullptr;\n\n    std::string codec = get_codec_name(st->codecpar);\n    if (!codec.empty())\n    {\n        codecName = ConvertCharToBSTR(codec.c_str());\n    }\n\n    return codecName;\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// IPropertyBag\n\nstatic struct\n{\n    const char *original;\n    const char *map;\n    int stream; // 0 = none, 1 = video, 2 = audio, 3 = sub\n} mappedPropertys[] = {\n    {\"rotation\", \"rotate\", 1},\n    {\"rotate\", nullptr, 1},\n    {\"stereoscopic3dmode\", \"stereo_mode\", 1},\n    {\"stereo_mode\", nullptr, 1},\n    {\"stereo_subtitle_offset_id\", \"3d-plane\", 3},\n    {\"stereo_subtitle_offset_ids\", \"pg_offset_sequences\", 0},\n    {\"stereo_interactive_offset_ids\", \"ig_offset_sequences\", 0},\n};\n\nSTDMETHODIMP CLAVFDemuxer::Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog)\n{\n    CheckPointer(pszPropName, E_INVALIDARG);\n    CheckPointer(pVar, E_INVALIDARG);\n    int stream = -1;\n\n    // Verify type\n    if (pVar->vt != VT_EMPTY && pVar->vt != VT_BSTR)\n        return E_FAIL;\n\n    ATL::CW2A propNameConv(pszPropName);\n    const char *propName = propNameConv;\n\n    // Map property names\n    for (int i = 0; i < countof(mappedPropertys); i++)\n    {\n        if (_stricmp(propName, mappedPropertys[i].original) == 0)\n        {\n            if (mappedPropertys[i].map)\n                propName = mappedPropertys[i].map;\n            if (mappedPropertys[i].stream)\n            {\n                int nStreamType = mappedPropertys[i].stream - 1;\n                stream = m_dActiveStreams[nStreamType];\n                if (nStreamType == subpic && stream == FORCED_SUBTITLE_PID)\n                    stream = m_ForcedSubStream;\n            }\n            break;\n        }\n    }\n\n    BSTR bstrValue = nullptr;\n    HRESULT hr = GetBSTRMetadata(propName, &bstrValue, stream);\n    if (SUCCEEDED(hr))\n    {\n        VariantClear(pVar);\n        pVar->vt = VT_BSTR;\n        pVar->bstrVal = bstrValue;\n    }\n    return hr;\n}\n\nSTDMETHODIMP CLAVFDemuxer::Write(LPCOLESTR pszPropName, VARIANT *pVar)\n{\n    return E_NOTIMPL;\n}\n\n/////////////////////////////////////////////////////////////////////////////\n// Internal Functions\nSTDMETHODIMP CLAVFDemuxer::AddStream(int streamId)\n{\n    HRESULT hr = S_OK;\n    AVStream *pStream = m_avFormat->streams[streamId];\n\n    if (pStream->codecpar->codec_type == AVMEDIA_TYPE_UNKNOWN || pStream->discard == AVDISCARD_ALL ||\n        (pStream->codecpar->codec_id == AV_CODEC_ID_NONE && pStream->codecpar->codec_tag == 0) ||\n        (!m_bSubStreams && (pStream->disposition & LAVF_DISPOSITION_SUB_STREAM)) ||\n        (pStream->disposition & AV_DISPOSITION_ATTACHED_PIC))\n    {\n        pStream->discard = AVDISCARD_ALL;\n        return S_FALSE;\n    }\n\n    stream s;\n    s.pid = streamId;\n\n    // Extract language\n    const char *lang = nullptr;\n    if (AVDictionaryEntry *dictEntry = av_dict_get(pStream->metadata, \"language\", nullptr, 0))\n    {\n        lang = dictEntry->value;\n    }\n    if (lang)\n    {\n        s.language = ProbeForISO6392(lang);\n        s.lcid = ProbeLangForLCID(s.language.c_str());\n    }\n    else\n    {\n        s.language = \"und\";\n        s.lcid = 0;\n    }\n    const char *title = lavf_get_stream_title(pStream);\n    if (title)\n        s.trackName = title;\n    s.streamInfo = new CLAVFStreamInfo(m_avFormat, pStream, m_pszInputFormat, hr);\n\n    if (hr != S_OK)\n    {\n        delete s.streamInfo;\n        pStream->discard = AVDISCARD_ALL;\n        return hr;\n    }\n\n    switch (pStream->codecpar->codec_type)\n    {\n    case AVMEDIA_TYPE_VIDEO: m_streams[video].push_back(s); break;\n    case AVMEDIA_TYPE_AUDIO: m_streams[audio].push_back(s); break;\n    case AVMEDIA_TYPE_SUBTITLE: m_streams[subpic].push_back(s); break;\n    default:\n        // unsupported stream\n        // Normally this should be caught while creating the stream info already.\n        delete s.streamInfo;\n        return E_FAIL;\n    }\n    return S_OK;\n}\n\n// Pin creation\nSTDMETHODIMP CLAVFDemuxer::CreateStreams()\n{\n    DbgLog((LOG_TRACE, 10, L\"CLAVFDemuxer::CreateStreams()\"));\n    CAutoLock lock(m_pLock);\n\n    for (int i = 0; i < countof(m_streams); ++i)\n    {\n        m_streams[i].Clear();\n    }\n\n    m_program = UINT_MAX;\n\n    if (m_avFormat->nb_programs && !m_pBluRay)\n    {\n        DbgLog(\n            (LOG_TRACE, 10, L\" -> File has %d programs, trying to detect the correct one..\", m_avFormat->nb_programs));\n        // Use a scoring system to select the best available program\n        // A \"good\" program at least has a valid video and audio stream\n        // We'll try here to detect these streams and decide on the best program\n        // Every present stream gets one point, if it appears to be valid, it gets 4\n        // Every present video stream has also video resolution score: width x height.\n        // Valid video streams have a width and height, valid audio streams have a channel count.\n        // Total program bitrate is used as a tiebreaker.\n        // We search for \"good\" program with highest score.\n        DWORD dwScore = 0;                       // Stream found: 1, stream valid: 4\n        DWORD dwVideoResolutionProgramScore = 0; // Score = width x height\n        DWORD dwProgramBitrate = 0;              // Total bitrate of the program\n        for (unsigned int i = 0; i < m_avFormat->nb_programs; ++i)\n        {\n            AVProgram *program = m_avFormat->programs[i];\n            if (program->nb_stream_indexes > 0)\n            {\n                DWORD dwVideoScore = 0;\n                DWORD dwVideoResolutionScore = 0;\n                DWORD dwAudioScore = 0;\n                DWORD dwBitrate = 0;\n                for (unsigned k = 0; k < program->nb_stream_indexes; ++k)\n                {\n                    unsigned streamIdx = program->stream_index[k];\n                    AVStream *st = m_avFormat->streams[streamIdx];\n                    if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)\n                    {\n                        if (st->codecpar->width != 0 && st->codecpar->height != 0)\n                        {\n                            dwVideoScore = 4;\n                            DWORD dwResolutionScore = st->codecpar->width * st->codecpar->height;\n                            if (dwResolutionScore > dwVideoResolutionScore)\n                                dwVideoResolutionScore = dwResolutionScore;\n                        }\n                        else if (dwVideoScore == 0)\n                            dwVideoScore = 1;\n                    }\n                    else if (st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO && dwAudioScore < 4)\n                    {\n                        if (st->codecpar->ch_layout.nb_channels != 0)\n                            dwAudioScore = 4;\n                        else\n                            dwAudioScore = 1;\n                    }\n                }\n\n                AVDictionaryEntry *dict = av_dict_get(program->metadata, \"variant_bitrate\", nullptr, 0);\n                if (dict && dict->value)\n                    dwBitrate = atol(dict->value);\n\n                // Check the score of the previously found stream\n                // In addition, we always require a valid video stream (or none), a invalid one is not allowed.\n                DbgLog((LOG_TRACE, 10,\n                        L\"  -> Program %d with score: %ld (video), %ld (video resolution), %ld (audio), %ld (bitrate)\",\n                        i, dwVideoScore, dwVideoResolutionScore, dwAudioScore, dwBitrate));\n                DWORD dwVideoAndAudioScore = dwVideoScore + dwAudioScore;\n                if (dwVideoScore != 1 &&\n                    (dwVideoAndAudioScore > dwScore ||\n                     (dwVideoAndAudioScore == dwScore && dwVideoResolutionScore > dwVideoResolutionProgramScore) ||\n                     (dwVideoAndAudioScore == dwScore && dwVideoResolutionScore == dwVideoResolutionProgramScore &&\n                      dwBitrate > dwProgramBitrate)))\n                {\n                    dwScore = dwVideoAndAudioScore;\n                    dwVideoResolutionProgramScore = dwVideoResolutionScore;\n                    dwProgramBitrate = dwBitrate;\n                    m_program = i;\n                }\n            }\n        }\n        DbgLog((LOG_TRACE, 10, L\" -> Using Program %d\", m_program));\n    }\n\n    // File has programs\n    bool bProgram = (m_program < m_avFormat->nb_programs);\n\n    // Discard unwanted programs\n    if (bProgram)\n    {\n        for (unsigned int i = 0; i < m_avFormat->nb_programs; ++i)\n        {\n            if (i != m_program)\n                m_avFormat->programs[i]->discard = AVDISCARD_ALL;\n        }\n    }\n\n    // Re-compute the overall file duration based on video and audio durations\n    int64_t duration = INT64_MIN;\n    int64_t st_duration = 0;\n    int64_t start_time = INT64_MAX;\n    int64_t st_start_time = 0;\n\n    // Number of streams (either in file or in program)\n    unsigned int nbIndex = bProgram ? m_avFormat->programs[m_program]->nb_stream_indexes : m_avFormat->nb_streams;\n\n    // File has PGS streams\n    bool bHasPGS = false;\n\n    // add streams from selected program, or all streams if no program was selected\n    for (unsigned int i = 0; i < nbIndex; ++i)\n    {\n        int streamIdx = bProgram ? m_avFormat->programs[m_program]->stream_index[i] : i;\n        if (S_OK != AddStream(streamIdx))\n            continue;\n\n        AVStream *st = m_avFormat->streams[streamIdx];\n        if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO || st->codecpar->codec_type == AVMEDIA_TYPE_AUDIO)\n        {\n            if (st->duration != AV_NOPTS_VALUE)\n            {\n                st_duration = av_rescale_q(st->duration, st->time_base, AV_RATIONAL_TIMEBASE);\n                if (st_duration > duration)\n                    duration = st_duration;\n            }\n\n            if (st->start_time != AV_NOPTS_VALUE)\n            {\n                st_start_time = av_rescale_q(st->start_time, st->time_base, AV_RATIONAL_TIMEBASE);\n                if (st_start_time < start_time)\n                    start_time = st_start_time;\n            }\n        }\n        if (st->codecpar->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE)\n            bHasPGS = true;\n    }\n\n    if ((m_bTSDiscont || m_avFormat->duration == AV_NOPTS_VALUE) && duration != INT64_MIN)\n    {\n        DbgLog(\n            (LOG_TRACE, 10, L\" -> Changing duration to %I64d (from %I64d, diff %.3fs)\", duration, m_avFormat->duration,\n             m_avFormat->duration == AV_NOPTS_VALUE ? 0.0f\n                                                    : (float)(duration - m_avFormat->duration) / (float)AV_TIME_BASE));\n        m_avFormat->duration = duration;\n    }\n    if ((m_bTSDiscont || m_avFormat->start_time == AV_NOPTS_VALUE) && start_time != INT64_MAX)\n    {\n        DbgLog((LOG_TRACE, 10, L\" -> Changing start_time to %I64d (from %I64d, diff %.3fs)\", start_time,\n                m_avFormat->start_time,\n                m_avFormat->start_time == AV_NOPTS_VALUE\n                    ? 0.0f\n                    : (float)(start_time - m_avFormat->start_time) / (float)AV_TIME_BASE));\n        m_avFormat->start_time = start_time;\n    }\n\n    if (bHasPGS && m_pSettings->GetPGSForcedStream())\n    {\n        CreatePGSForcedSubtitleStream();\n    }\n\n    // Create fake subtitle pin\n    if (!m_streams[subpic].empty())\n    {\n        CreateNoSubtitleStream();\n    }\n\n    if (m_bMPEGTS)\n    {\n        m_bH264MVCCombine = GetH264MVCStreamIndices(m_avFormat, &m_nH264MVCBaseStream, &m_nH264MVCExtensionStream);\n    }\n\n    if (m_bMatroska)\n    {\n        std::list<std::string> pg_sequences;\n        for (unsigned i = 0; i < m_avFormat->nb_streams; i++)\n        {\n            if (m_avFormat->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE)\n            {\n                AVDictionaryEntry *e =\n                    av_dict_get(m_avFormat->streams[i]->metadata, \"3d-plane\", nullptr, AV_DICT_IGNORE_SUFFIX);\n                if (e && e->value)\n                {\n                    pg_sequences.push_back(std::string(e->value));\n                }\n            }\n        }\n\n        // export the list of pg sequences\n        if (pg_sequences.size() > 0)\n        {\n            // strip duplicate entries\n            pg_sequences.sort();\n            pg_sequences.unique();\n\n            size_t size = pg_sequences.size() * 4;\n            char *offsets = new char[size];\n            offsets[0] = 0;\n\n            // Append all offsets to the string\n            for (auto it = pg_sequences.begin(); it != pg_sequences.end(); it++)\n            {\n                size_t len = strlen(offsets);\n                if (len > 0)\n                {\n                    offsets[len] = ',';\n                    len++;\n                }\n                strcpy_s(offsets + len, size - len, it->c_str());\n            }\n\n            av_dict_set(&m_avFormat->metadata, \"pg_offset_sequences\", offsets, 0);\n            delete[] offsets;\n        }\n    }\n\n    return S_OK;\n}\n\nREFERENCE_TIME CLAVFDemuxer::GetStartTime() const\n{\n    return av_rescale(m_avFormat->start_time, DSHOW_TIME_BASE, AV_TIME_BASE);\n}\n\n// Converts the lavf pts timestamp to a DShow REFERENCE_TIME\n// Based on DVDDemuxFFMPEG\nREFERENCE_TIME CLAVFDemuxer::ConvertTimestampToRT(int64_t pts, int num, int den, int64_t starttime) const\n{\n    if (pts == (int64_t)AV_NOPTS_VALUE)\n    {\n        return Packet::INVALID_TIME;\n    }\n\n    if (starttime == AV_NOPTS_VALUE)\n    {\n        if (m_avFormat->start_time != AV_NOPTS_VALUE)\n        {\n            starttime = av_rescale(m_avFormat->start_time, den, (int64_t)AV_TIME_BASE * num);\n        }\n        else\n        {\n            starttime = 0;\n        }\n    }\n\n    if (starttime != 0)\n    {\n        pts -= starttime;\n    }\n\n    // Let av_rescale do the work, its smart enough to not overflow\n    REFERENCE_TIME timestamp = av_rescale(pts, (int64_t)num * DSHOW_TIME_BASE, den);\n\n    return timestamp;\n}\n\n// Converts the lavf pts timestamp to a DShow REFERENCE_TIME\n// Based on DVDDemuxFFMPEG\nint64_t CLAVFDemuxer::ConvertRTToTimestamp(REFERENCE_TIME timestamp, int num, int den, int64_t starttime) const\n{\n    if (timestamp == Packet::INVALID_TIME)\n    {\n        return (int64_t)AV_NOPTS_VALUE;\n    }\n\n    if (starttime == AV_NOPTS_VALUE)\n    {\n        if (m_avFormat->start_time != AV_NOPTS_VALUE)\n        {\n            starttime = av_rescale(m_avFormat->start_time, den, (int64_t)AV_TIME_BASE * num);\n        }\n        else\n        {\n            starttime = 0;\n        }\n    }\n\n    int64_t pts = av_rescale(timestamp, den, (int64_t)num * DSHOW_TIME_BASE);\n    if (starttime != 0)\n    {\n        pts += starttime;\n    }\n\n    return pts;\n}\n\nHRESULT CLAVFDemuxer::UpdateForcedSubtitleStream(unsigned audio_pid)\n{\n    if (!m_avFormat || audio_pid >= m_avFormat->nb_streams)\n        return E_UNEXPECTED;\n\n    stream *audiost = GetStreams(audio)->FindStream(audio_pid);\n    if (!audiost)\n        return E_FAIL;\n\n    // Build CSubtitleSelector for this special case\n    std::list<CSubtitleSelector> selectors;\n    CSubtitleSelector selector;\n    selector.audioLanguage = \"*\";\n    selector.subtitleLanguage = audiost->language;\n    selector.dwFlagsSet = SUBTITLE_FLAG_PGS;\n    selector.dwFlagsNot = 0;\n    selectors.push_back(selector);\n\n    selector.subtitleLanguage = \"*\";\n    selectors.push_back(selector);\n\n    const stream *subst = SelectSubtitleStream(selectors, audiost->language);\n    if (subst)\n    {\n        m_ForcedSubStream = subst->pid;\n\n        CStreamList *streams = GetStreams(subpic);\n        stream *forced = streams->FindStream(FORCED_SUBTITLE_PID);\n        if (forced)\n        {\n            CMediaType mtype = forced->streamInfo->mtypes.back();\n            forced->streamInfo->mtypes.pop_back();\n            forced->language = audiost->language;\n            forced->lcid = audiost->lcid;\n\n            SUBTITLEINFO *subInfo = (SUBTITLEINFO *)mtype.Format();\n            strncpy_s(subInfo->IsoLang, audiost->language.c_str(), 3);\n            subInfo->IsoLang[3] = 0;\n\n            forced->streamInfo->mtypes.push_back(mtype);\n        }\n    }\n\n    return subst ? S_OK : S_FALSE;\n}\n\n// Select the best video stream\nconst CBaseDemuxer::stream *CLAVFDemuxer::SelectVideoStream()\n{\n    const stream *best = nullptr;\n    CStreamList *streams = GetStreams(video);\n\n    std::deque<stream>::iterator it;\n    for (it = streams->begin(); it != streams->end(); ++it)\n    {\n        stream *check = &*it;\n\n        if (!best)\n        {\n            best = check;\n            continue;\n        }\n\n        // if the best stream is an unknown codec, prefer any other\n        if (m_avFormat->streams[best->pid]->codecpar->codec_id == AV_CODEC_ID_NONE &&\n            m_avFormat->streams[check->pid]->codecpar->codec_id != AV_CODEC_ID_NONE)\n        {\n            best = check;\n            continue;\n        }\n\n        // prefer default streams\n        bool checkDefault = m_avFormat->streams[check->pid]->disposition & AV_DISPOSITION_DEFAULT;\n        bool bestDefault = m_avFormat->streams[best->pid]->disposition & AV_DISPOSITION_DEFAULT;\n\n        if (checkDefault != bestDefault)\n        {\n            if (checkDefault)\n                best = check;\n            continue;\n        }\n\n        uint64_t bestPixels = (uint64_t)m_avFormat->streams[best->pid]->codecpar->width *\n                              m_avFormat->streams[best->pid]->codecpar->height;\n        uint64_t checkPixels = (uint64_t)m_avFormat->streams[check->pid]->codecpar->width *\n                               m_avFormat->streams[check->pid]->codecpar->height;\n\n        int check_nb_f = av_lav_stream_codec_info_nb_frames(m_avFormat->streams[check->pid]);\n        int best_nb_f = av_lav_stream_codec_info_nb_frames(m_avFormat->streams[best->pid]);\n        if (m_bRM && (check_nb_f > 0 && best_nb_f <= 0))\n        {\n            best = check;\n        }\n        else if (m_bMP4 && m_avFormat->streams[check->pid]->nb_frames == 1 && m_avFormat->streams[best->pid]->nb_frames > 1)\n        {\n            // avoid selecting a video stream with only one frame\n        }\n        else if (m_bMP4 && m_avFormat->streams[best->pid]->nb_frames == 1 && m_avFormat->streams[check->pid]->nb_frames > 1)\n        {\n            // prefer a stream with more then one frame, if available\n            best = check;\n        }\n        else if (!m_bRM || check_nb_f > 0)\n        {\n            if (checkPixels > bestPixels)\n            {\n                best = check;\n            }\n            else if (checkPixels == bestPixels)\n            {\n                int64_t best_rate = m_avFormat->streams[best->pid]->codecpar->bit_rate;\n                int64_t check_rate = m_avFormat->streams[check->pid]->codecpar->bit_rate;\n                if (best_rate && check_rate && check_rate > best_rate)\n                    best = check;\n            }\n        }\n    }\n\n    return best;\n}\n\nstatic int audio_codec_priority(const AVCodecParameters *par)\n{\n    int priority = 0;\n    const AVCodecDescriptor *desc = avcodec_descriptor_get(par->codec_id);\n\n    // lossless codecs have highest priority\n    if (desc && ((desc->props & (AV_CODEC_PROP_LOSSLESS | AV_CODEC_PROP_LOSSY)) == AV_CODEC_PROP_LOSSLESS))\n    {\n        priority = 10;\n    }\n    else if (desc && (desc->props & AV_CODEC_PROP_LOSSLESS))\n    {\n        priority = 8;\n\n        if (par->codec_id == AV_CODEC_ID_DTS)\n        {\n            priority = 7;\n\n            if (par->profile == AV_PROFILE_DTS_EXPRESS)\n            {\n                priority -= 1;\n            }\n            else if (par->profile == AV_PROFILE_DTS_HD_MA)\n            {\n                priority += 3;\n            }\n            else if (par->profile == AV_PROFILE_DTS_HD_HRA)\n            {\n                priority += 2;\n            }\n            else if (par->profile >= AV_PROFILE_DTS_ES)\n            {\n                priority += 1;\n            }\n        }\n    }\n    else\n    {\n        switch (par->codec_id)\n        {\n        case AV_CODEC_ID_EAC3: priority = 7; break;\n        case AV_CODEC_ID_AC3:\n        case AV_CODEC_ID_AAC:\n        case AV_CODEC_ID_AAC_LATM: priority = 5; break;\n        case AV_CODEC_ID_MP3: priority = 3; break;\n        }\n\n        // WAVE_FORMAT_EXTENSIBLE is multi-channel PCM, which doesn't have a proper tag otherwise\n        if (par->codec_tag == WAVE_FORMAT_EXTENSIBLE)\n        {\n            priority = 10;\n        }\n    }\n\n    // low priority for S302M with non-pcm content\n    if (par->codec_id == AV_CODEC_ID_S302M && par->codec_tag != -1)\n        priority = -1;\n\n    return priority;\n}\n\n// Select the best audio stream\nconst CBaseDemuxer::stream *CLAVFDemuxer::SelectAudioStream(std::list<std::string> prefLanguages)\n{\n    const stream *best = nullptr;\n    CStreamList *streams = GetStreams(audio);\n\n    std::deque<stream *> checkedStreams;\n\n    // Filter for language\n    if (!prefLanguages.empty())\n    {\n        std::list<std::string>::iterator it;\n        for (it = prefLanguages.begin(); it != prefLanguages.end(); ++it)\n        {\n            std::string checkLanguage = ProbeForISO6392(it->c_str());\n            std::deque<stream>::iterator sit;\n            for (sit = streams->begin(); sit != streams->end(); ++sit)\n            {\n                std::string language = sit->language;\n                // check if the language matches\n                if (language == checkLanguage)\n                {\n                    checkedStreams.push_back(&*sit);\n                }\n            }\n            // First language that has any streams is a match\n            if (!checkedStreams.empty())\n            {\n                break;\n            }\n        }\n    }\n\n    // If no language was set, or no matching streams were found\n    // Put all streams in there\n    if (checkedStreams.empty())\n    {\n        std::deque<stream>::iterator sit;\n        for (sit = streams->begin(); sit != streams->end(); ++sit)\n        {\n            checkedStreams.push_back(&*sit);\n        }\n    }\n\n    // Check for a stream with a default flag\n    // If in our current set is one, that one prevails\n    std::deque<stream *>::iterator sit;\n    for (sit = checkedStreams.begin(); sit != checkedStreams.end(); ++sit)\n    {\n        if (m_avFormat->streams[(*sit)->pid]->disposition & AV_DISPOSITION_DEFAULT)\n        {\n            best = *sit;\n            break;\n        }\n    }\n\n    BOOL bCheckQuality = m_pSettings->GetPreferHighQualityAudioStreams();\n    BOOL bImpaired = m_pSettings->GetUseAudioForHearingVisuallyImpaired();\n#define DISPO_IMPAIRED (AV_DISPOSITION_HEARING_IMPAIRED | AV_DISPOSITION_VISUAL_IMPAIRED)\n\n    if (!best && !checkedStreams.empty())\n    {\n        // If only one stream is left, just use that one\n        if (checkedStreams.size() == 1)\n        {\n            best = checkedStreams.at(0);\n        }\n        else\n        {\n            // Check for quality\n            std::deque<stream *>::iterator sit;\n            for (sit = checkedStreams.begin(); sit != checkedStreams.end(); ++sit)\n            {\n                if (!best)\n                {\n                    best = *sit;\n                    continue;\n                }\n                AVStream *old_stream = m_avFormat->streams[best->pid];\n                AVStream *new_stream = m_avFormat->streams[(*sit)->pid];\n\n                // ignore streams with an unknown codec or no decoder\n                if (new_stream->codecpar->codec_id == AV_CODEC_ID_NONE || avcodec_find_decoder(new_stream->codecpar->codec_id) == NULL)\n                    continue;\n                else if (old_stream->codecpar->codec_id == AV_CODEC_ID_NONE || avcodec_find_decoder(old_stream->codecpar->codec_id) == NULL)\n                {\n                    best = *sit;\n                    continue;\n                }\n\n                int check_nb_f = av_lav_stream_codec_info_nb_frames(new_stream);\n                int best_nb_f = av_lav_stream_codec_info_nb_frames(old_stream);\n                if (m_bRM && (check_nb_f > 0 && best_nb_f <= 0))\n                {\n                    best = *sit;\n                }\n                else if (!m_bRM || check_nb_f > 0)\n                {\n                    if (!(old_stream->disposition & DISPO_IMPAIRED) != !(new_stream->disposition & DISPO_IMPAIRED))\n                    {\n                        if ((bImpaired && !(old_stream->disposition & DISPO_IMPAIRED)) ||\n                            (!bImpaired && !(new_stream->disposition & DISPO_IMPAIRED)))\n                        {\n                            best = *sit;\n                        }\n                        continue;\n                    }\n                    if (!bCheckQuality)\n                        continue;\n\n                    // First, check number of channels\n                    int old_num_chans = old_stream->codecpar->ch_layout.nb_channels;\n                    int new_num_chans = new_stream->codecpar->ch_layout.nb_channels;\n                    if (new_num_chans > old_num_chans)\n                    {\n                        best = *sit;\n                    }\n                    else if (new_num_chans == old_num_chans)\n                    {\n                        // Same number of channels, check codec\n                        int old_priority = audio_codec_priority(old_stream->codecpar);\n                        int new_priority = audio_codec_priority(new_stream->codecpar);\n                        if (new_priority > old_priority)\n                        {\n                            best = *sit;\n                        }\n                    }\n                }\n            }\n        }\n    }\n\n    return best;\n}\n\nstatic inline bool does_language_match(std::string selector, std::string selectee)\n{\n    return (selector == \"*\" || selector == selectee);\n}\n\n// ugly hack to only convert ascii to lower case, as there is no proper unicode function for utf-8 in std::string\nstatic inline char asciitolower(char in)\n{\n    if (in <= 'Z' && in >= 'A')\n        return in - ('Z' - 'z');\n    return in;\n}\n\n// Select the best subtitle stream\nconst CBaseDemuxer::stream *CLAVFDemuxer::SelectSubtitleStream(std::list<CSubtitleSelector> subtitleSelectors,\n                                                               std::string audioLanguage)\n{\n    const stream *best = nullptr;\n    CStreamList *streams = GetStreams(subpic);\n\n    std::deque<stream *> checkedStreams;\n\n    std::list<CSubtitleSelector>::iterator it = subtitleSelectors.begin();\n    for (it = subtitleSelectors.begin(); it != subtitleSelectors.end() && checkedStreams.empty(); it++)\n    {\n\n        if (!does_language_match(it->audioLanguage, audioLanguage))\n            continue;\n\n        if (it->subtitleLanguage == \"off\")\n            break;\n\n        // lower-case version of the trackname query\n        std::string subtitleTrackNameQueryLower = it->subtitleTrackName;\n        if (subtitleTrackNameQueryLower.empty() == false)\n            std::transform(subtitleTrackNameQueryLower.begin(), subtitleTrackNameQueryLower.end(),\n                           subtitleTrackNameQueryLower.begin(), asciitolower);\n\n        std::deque<stream>::iterator sit;\n        for (sit = streams->begin(); sit != streams->end(); sit++)\n        {\n            if (sit->pid == NO_SUBTITLE_PID)\n                continue;\n\n\n\n            if (!subtitleTrackNameQueryLower.empty())\n            {\n                // create lowercase version of the track name\n                std::string trackNameLower = sit->trackName;\n                std::transform(trackNameLower.begin(), trackNameLower.end(), trackNameLower.begin(), asciitolower);\n\n                if (trackNameLower.find(subtitleTrackNameQueryLower) == std::string::npos)\n                    continue;\n            }\n\n            if (sit->pid == FORCED_SUBTITLE_PID)\n            {\n                if ((it->dwFlagsSet == 0 || it->dwFlagsSet & SUBTITLE_FLAG_VIRTUAL) &&\n                    does_language_match(it->subtitleLanguage, audioLanguage))\n                    checkedStreams.push_back(&*sit);\n                continue;\n            }\n\n            bool streamIsDefault = m_avFormat->streams[sit->pid]->disposition & AV_DISPOSITION_DEFAULT;\n            bool streamIsForced = m_avFormat->streams[sit->pid]->disposition & AV_DISPOSITION_FORCED;\n            bool streamIsImpaired = m_avFormat->streams[sit->pid]->disposition &\n                                    (AV_DISPOSITION_HEARING_IMPAIRED | AV_DISPOSITION_VISUAL_IMPAIRED);\n            bool streamIsNormal = !streamIsDefault && !streamIsForced && !streamIsImpaired;\n            bool streamIsPgsFormat =\n                (m_avFormat->streams[sit->pid]->codecpar->codec_id == AV_CODEC_ID_HDMV_PGS_SUBTITLE);\n\n            bool flagsSetMatch =\n                ((it->dwFlagsSet == 0) ||\n                 ((it->dwFlagsSet & SUBTITLE_FLAG_DEFAULT) && streamIsDefault) ||\n                 ((it->dwFlagsSet & SUBTITLE_FLAG_FORCED) && streamIsForced) ||\n                 ((it->dwFlagsSet & SUBTITLE_FLAG_IMPAIRED) && streamIsImpaired) ||\n                 ((it->dwFlagsSet & SUBTITLE_FLAG_PGS) && streamIsPgsFormat) ||\n                 ((it->dwFlagsSet & SUBTITLE_FLAG_NORMAL) && streamIsNormal)\n                );\n\n            bool flagsNotMatch =\n                (!((it->dwFlagsNot & SUBTITLE_FLAG_DEFAULT) && streamIsDefault) &&\n                 !((it->dwFlagsNot & SUBTITLE_FLAG_FORCED) && streamIsForced) &&\n                 !((it->dwFlagsNot & SUBTITLE_FLAG_IMPAIRED) && streamIsImpaired) &&\n                 !((it->dwFlagsNot & SUBTITLE_FLAG_NORMAL) && streamIsNormal)\n                );\n\n            if (flagsSetMatch && flagsNotMatch)\n            {\n                std::string streamLanguage = sit->language;\n                if (does_language_match(it->subtitleLanguage, streamLanguage))\n                    checkedStreams.push_back(&*sit);\n            }\n        }\n    }\n\n    if (!checkedStreams.empty())\n        best = streams->FindStream(checkedStreams.front()->pid);\n    else\n        best = streams->FindStream(NO_SUBTITLE_PID);\n\n    return best;\n}\n\n#include \"libavformat/isom.h\"\n\nSTDMETHODIMP_(DWORD) CLAVFDemuxer::GetStreamFlags(DWORD dwStream)\n{\n    if (!m_avFormat || dwStream >= m_avFormat->nb_streams)\n        return 0;\n\n    DWORD dwFlags = 0;\n    AVStream *st = m_avFormat->streams[dwStream];\n\n    if (strcmp(m_pszInputFormat, \"rawvideo\") == 0)\n        dwFlags |= LAV_STREAM_FLAG_ONLY_DTS;\n\n    if (st->codecpar->codec_id == AV_CODEC_ID_H264 &&\n        (m_bAVI || m_bPMP || (m_bMatroska && (!st->codecpar->extradata_size || st->codecpar->extradata[0] != 1)) ||\n         (m_bMP4 && st->priv_data && ((MOVStreamContext *)st->priv_data)->ctts_count == 0)))\n        dwFlags |= LAV_STREAM_FLAG_ONLY_DTS;\n\n    if (st->codecpar->codec_id == AV_CODEC_ID_HEVC &&\n        (m_bAVI || (m_bMP4 && st->priv_data && ((MOVStreamContext *)st->priv_data)->ctts_count == 0)))\n        dwFlags |= LAV_STREAM_FLAG_ONLY_DTS;\n\n    if (st->codecpar->codec_id == AV_CODEC_ID_VVC &&\n        (m_bAVI || (m_bMP4 && st->priv_data && ((MOVStreamContext *)st->priv_data)->ctts_count == 0)))\n        dwFlags |= LAV_STREAM_FLAG_ONLY_DTS;\n\n    if (m_bMatroska && (st->codecpar->codec_id == AV_CODEC_ID_RV30 || st->codecpar->codec_id == AV_CODEC_ID_RV40))\n        dwFlags |= LAV_STREAM_FLAG_RV34_MKV;\n\n    if (m_avFormat->flags & AVFMT_FLAG_NETWORK)\n        dwFlags |= LAV_STREAM_FLAG_LIVE;\n\n    return dwFlags;\n}\n\nSTDMETHODIMP_(int) CLAVFDemuxer::GetPixelFormat(DWORD dwStream)\n{\n    if (!m_avFormat || dwStream >= m_avFormat->nb_streams)\n        return AV_PIX_FMT_NONE;\n\n    return m_avFormat->streams[dwStream]->codecpar->format;\n}\n\nSTDMETHODIMP_(int) CLAVFDemuxer::GetHasBFrames(DWORD dwStream)\n{\n    if (!m_avFormat || dwStream >= m_avFormat->nb_streams)\n        return -1;\n\n    return m_avFormat->streams[dwStream]->codecpar->video_delay;\n}\n\nSTDMETHODIMP CLAVFDemuxer::GetSideData(DWORD dwStream, GUID guidType, const BYTE **pData, size_t *pSize)\n{\n    if (!m_avFormat || dwStream >= m_avFormat->nb_streams)\n        return E_INVALIDARG;\n\n    if (guidType == IID_MediaSideDataFFMpeg)\n    {\n        CBaseDemuxer::stream *pStream = FindStream(dwStream);\n        if (!pStream)\n            return E_FAIL;\n\n        pStream->SideData.side_data = m_avFormat->streams[dwStream]->codecpar->coded_side_data;\n        pStream->SideData.side_data_elems = m_avFormat->streams[dwStream]->codecpar->nb_coded_side_data;\n        *pData = (BYTE *)&pStream->SideData;\n        *pSize = sizeof(pStream->SideData);\n\n        return S_OK;\n    }\n\n    return E_INVALIDARG;\n}\n\nSTDMETHODIMP CLAVFDemuxer::GetBSTRMetadata(const char *key, BSTR *pbstrValue, int stream)\n{\n    if (!m_avFormat)\n        return VFW_E_NOT_FOUND;\n\n    if (stream >= (int)m_avFormat->nb_streams)\n        return E_INVALIDARG;\n\n    if (_stricmp(key, \"rotate\") == 0 && stream >= 0)\n    {\n        const AVPacketSideData *sd = av_packet_side_data_get(\n            m_avFormat->streams[stream]->codecpar->coded_side_data,\n            m_avFormat->streams[stream]->codecpar->nb_coded_side_data, AV_PKT_DATA_DISPLAYMATRIX);\n\n        if (sd && sd->size == (9*sizeof(int32_t)))\n        {\n            double dRotation = av_display_rotation_get((const int32_t *)sd->data);\n            int nRotation = -lrint(dRotation);\n\n            // normalize rotation to 0-360\n            while (nRotation < 0)\n                nRotation += 360;\n\n            while (nRotation >= 360)\n                nRotation -= 360;\n\n            char buf[34] = {0};\n            sprintf_s(buf, \"%d\", nRotation);\n            *pbstrValue = ConvertCharToBSTR(buf);\n            if (*pbstrValue == nullptr)\n                return E_OUTOFMEMORY;\n\n            return S_OK;\n        }\n    }\n\n    AVDictionaryEntry *entry = av_dict_get(stream >= 0 ? m_avFormat->streams[stream]->metadata : m_avFormat->metadata,\n                                           key, nullptr, AV_DICT_IGNORE_SUFFIX);\n    if (!entry || !entry->value || entry->value[0] == '\\0')\n        return VFW_E_NOT_FOUND;\n\n    *pbstrValue = ConvertCharToBSTR(entry->value);\n    if (*pbstrValue == nullptr)\n        return E_OUTOFMEMORY;\n\n    return S_OK;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFDemuxer.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <Qnetwork.h>\n#include <set>\n#include <algorithm>\n#include <sstream>\n\n#include \"BaseDemuxer.h\"\n#include \"IKeyFrameInfo.h\"\n#include \"ITrackInfo.h\"\n#include \"FontInstaller.h\"\n#include \"DSMResourceBag.h\"\n\n#define SUBMODE_FORCED_PGS_ONLY 0xFF\n\nclass FormatInfo;\nclass CBDDemuxer;\n\n#define FFMPEG_FILE_BUFFER_SIZE 32768 // default reading size for ffmpeg\nclass CLAVFDemuxer\n    : public CBaseDemuxer\n    , public CDSMResourceBag\n    , public IAMExtendedSeeking\n    , public IKeyFrameInfo\n    , public ITrackInfo\n    , public IAMMediaContent\n    , public IPropertyBag\n{\n  public:\n    CLAVFDemuxer(CCritSec *pLock, ILAVFSettingsInternal *settings);\n    ~CLAVFDemuxer();\n\n    static std::set<FormatInfo> GetFormatList();\n\n    // IUnknown\n    DECLARE_IUNKNOWN\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // IDispatch\n    STDMETHODIMP GetTypeInfoCount(UINT *pctinfo) { return E_NOTIMPL; }\n    STDMETHODIMP GetTypeInfo(UINT itinfo, LCID lcid, ITypeInfo **pptinfo) { return E_NOTIMPL; }\n    STDMETHODIMP GetIDsOfNames(REFIID riid, OLECHAR **rgszNames, UINT cNames, LCID lcid, DISPID *rgdispid)\n    {\n        return E_NOTIMPL;\n    }\n    STDMETHODIMP Invoke(DISPID dispidMember, REFIID riid, LCID lcid, WORD wFlags, DISPPARAMS *pdispparams,\n                        VARIANT *pvarResult, EXCEPINFO *pexcepinfo, UINT *puArgErr)\n    {\n        return E_NOTIMPL;\n    }\n\n    // CBaseDemuxer\n    STDMETHODIMP Open(LPCOLESTR pszFileName, LPCOLESTR pszUserAgent = NULL, LPCOLESTR pszReferrer = NULL);\n    STDMETHODIMP Start();\n    STDMETHODIMP AbortOpening(int mode = 1, int timeout = 0);\n    REFERENCE_TIME GetDuration() const;\n    STDMETHODIMP GetNextPacket(Packet **ppPacket);\n    STDMETHODIMP Seek(REFERENCE_TIME rTime);\n    STDMETHODIMP Reset();\n    const char *GetContainerFormat() const;\n    virtual DWORD GetContainerFlags() { return m_bTSDiscont ? LAVFMT_TS_DISCONT : 0; }\n\n    STDMETHODIMP SetTitle(int idx);\n    STDMETHODIMP_(int) GetTitle();\n    STDMETHODIMP GetTitleInfo(int idx, REFERENCE_TIME *rtDuration, WCHAR **ppszName);\n    STDMETHODIMP_(int) GetNumTitles();\n\n    void SettingsChanged(ILAVFSettingsInternal *pSettings);\n\n    // Select the best video stream\n    const stream *SelectVideoStream();\n    // Select the best audio stream\n    const stream *SelectAudioStream(std::list<std::string> prefLanguages);\n    // Select the best subtitle stream\n    const stream *SelectSubtitleStream(std::list<CSubtitleSelector> subtitleSelectors, std::string audioLanguage);\n\n    HRESULT SetActiveStream(StreamType type, int pid);\n\n    STDMETHODIMP_(DWORD) GetStreamFlags(DWORD dwStream);\n    STDMETHODIMP_(int) GetPixelFormat(DWORD dwStream);\n    STDMETHODIMP_(int) GetHasBFrames(DWORD dwStream);\n    STDMETHODIMP GetSideData(DWORD dwStream, GUID guidType, const BYTE **pData, size_t *pSize);\n\n    // IAMExtendedSeeking\n    STDMETHODIMP get_ExSeekCapabilities(long *pExCapabilities);\n    STDMETHODIMP get_MarkerCount(long *pMarkerCount);\n    STDMETHODIMP get_CurrentMarker(long *pCurrentMarker);\n    STDMETHODIMP GetMarkerTime(long MarkerNum, double *pMarkerTime);\n    STDMETHODIMP GetMarkerName(long MarkerNum, BSTR *pbstrMarkerName);\n    STDMETHODIMP put_PlaybackSpeed(double Speed) { return E_NOTIMPL; }\n    STDMETHODIMP get_PlaybackSpeed(double *pSpeed) { return E_NOTIMPL; }\n\n    // IKeyFrameInfo\n    STDMETHODIMP GetKeyFrameCount(UINT &nKFs);\n    STDMETHODIMP GetKeyFrames(const GUID *pFormat, REFERENCE_TIME *pKFs, UINT &nKFs);\n\n    // ITrackInfo\n    STDMETHODIMP_(UINT) GetTrackCount();\n\n    // \\param aTrackIdx the track index (from 0 to GetTrackCount()-1)\n    STDMETHODIMP_(BOOL) GetTrackInfo(UINT aTrackIdx, struct TrackElement *pStructureToFill);\n\n    // Get an extended information struct relative to the track type\n    STDMETHODIMP_(BOOL) GetTrackExtendedInfo(UINT aTrackIdx, void *pStructureToFill);\n\n    STDMETHODIMP_(BSTR) GetTrackCodecID(UINT aTrackIdx) { return nullptr; }\n    STDMETHODIMP_(BSTR) GetTrackName(UINT aTrackIdx);\n    STDMETHODIMP_(BSTR) GetTrackCodecName(UINT aTrackIdx);\n    STDMETHODIMP_(BSTR) GetTrackCodecInfoURL(UINT aTrackIdx) { return nullptr; }\n    STDMETHODIMP_(BSTR) GetTrackCodecDownloadURL(UINT aTrackIdx) { return nullptr; }\n\n    // IAMMediaContent\n    STDMETHODIMP get_AuthorName(BSTR *pbstrAuthorName) { return GetBSTRMetadata(\"artist\", pbstrAuthorName); }\n    STDMETHODIMP get_Title(BSTR *pbstrTitle) { return GetBSTRMetadata(\"title\", pbstrTitle); }\n    STDMETHODIMP get_Rating(BSTR *pbstrRating) { return E_NOTIMPL; }\n    STDMETHODIMP get_Description(BSTR *pbstrDescription)\n    {\n        HRESULT hr = GetBSTRMetadata(\"comment\", pbstrDescription);\n        if (hr == VFW_E_NOT_FOUND)\n            hr = GetBSTRMetadata(\"description\", pbstrDescription);\n        return hr;\n    }\n    STDMETHODIMP get_Copyright(BSTR *pbstrCopyright) { return GetBSTRMetadata(\"copyright\", pbstrCopyright); }\n    STDMETHODIMP get_BaseURL(BSTR *pbstrBaseURL) { return E_NOTIMPL; }\n    STDMETHODIMP get_LogoURL(BSTR *pbstrLogoURL) { return E_NOTIMPL; }\n    STDMETHODIMP get_LogoIconURL(BSTR *pbstrLogoURL) { return E_NOTIMPL; }\n    STDMETHODIMP get_WatermarkURL(BSTR *pbstrWatermarkURL) { return E_NOTIMPL; }\n    STDMETHODIMP get_MoreInfoURL(BSTR *pbstrMoreInfoURL) { return E_NOTIMPL; }\n    STDMETHODIMP get_MoreInfoBannerImage(BSTR *pbstrMoreInfoBannerImage) { return E_NOTIMPL; }\n    STDMETHODIMP get_MoreInfoBannerURL(BSTR *pbstrMoreInfoBannerURL) { return E_NOTIMPL; }\n    STDMETHODIMP get_MoreInfoText(BSTR *pbstrMoreInfoText) { return E_NOTIMPL; }\n\n    // IPropertyBag\n    STDMETHODIMP Read(LPCOLESTR pszPropName, VARIANT *pVar, IErrorLog *pErrorLog);\n    STDMETHODIMP Write(LPCOLESTR pszPropName, VARIANT *pVar);\n\n    STDMETHODIMP OpenInputStream(AVIOContext *byteContext, LPCOLESTR pszFileName = nullptr,\n                                 const char *format = nullptr, BOOL bForce = FALSE, BOOL bFileSource = FALSE,\n                                 LPCOLESTR pszUserAgent = NULL, LPCOLESTR pszReferrer = NULL);\n    STDMETHODIMP SeekByte(int64_t pos, int flags);\n\n    AVStream *GetAVStreamByPID(int pid);\n    void UpdateSubStreams();\n    unsigned int GetNumStreams() const { return m_avFormat->nb_streams; }\n\n    REFERENCE_TIME GetStartTime() const;\n    void SetBluRay(CBDDemuxer *pBluRay) { m_pBluRay = pBluRay; }\n\n    void AddMPEGTSStream(int pid, uint32_t stream_type);\n\n  private:\n    STDMETHODIMP AddStream(int streamId);\n    STDMETHODIMP CreateStreams();\n    STDMETHODIMP InitAVFormat(LPCOLESTR pszFileName, BOOL bForce);\n    void CleanupAVFormat();\n    void UpdateParserFlags(AVStream *st);\n\n    REFERENCE_TIME ConvertTimestampToRT(int64_t pts, int num, int den,\n                                        int64_t starttime = (int64_t)AV_NOPTS_VALUE) const;\n    int64_t ConvertRTToTimestamp(REFERENCE_TIME timestamp, int num, int den,\n                                 int64_t starttime = (int64_t)AV_NOPTS_VALUE) const;\n\n    int GetStreamIdxFromTotalIdx(size_t index) const;\n    const CBaseDemuxer::stream *GetStreamFromTotalIdx(size_t index) const;\n    HRESULT CheckBDM2TSCPLI(LPCOLESTR pszFileName);\n\n    HRESULT UpdateForcedSubtitleStream(unsigned audio_pid);\n\n    static int avio_interrupt_cb(void *opaque);\n\n    STDMETHODIMP GetBSTRMetadata(const char *key, BSTR *pbstrValue, int stream = -1);\n    STDMETHODIMP CreatePacketMediaType(Packet *pPacket, enum AVCodecID codec_id, BYTE *extradata, int extradata_size,\n                                       BYTE *paramchange, int paramchange_size);\n    STDMETHODIMP ParseICYMetadataPacket();\n\n    STDMETHODIMP QueueMVCExtension(Packet *pPacket);\n    STDMETHODIMP FlushMVCExtensionQueue();\n    STDMETHODIMP CombineMVCBaseExtension(Packet *pBasePacket);\n\n  private:\n    friend class CBDDemuxer;\n    AVFormatContext *m_avFormat = nullptr;\n    const char *m_pszInputFormat = nullptr;\n\n    BOOL m_bMatroska = FALSE;\n    BOOL m_bOgg = FALSE;\n    BOOL m_bAVI = FALSE;\n    BOOL m_bMPEGTS = FALSE;\n    BOOL m_bMPEGPS = FALSE;\n    BOOL m_bRM = FALSE;\n    BOOL m_bPMP = FALSE;\n    BOOL m_bMP4 = FALSE;\n\n    BOOL m_bTSDiscont = FALSE;\n    BOOL m_bSubStreams = FALSE;\n    BOOL m_bVC1Correction = FALSE;\n    BOOL m_bVC1SeenTimestamp = FALSE;\n    BOOL m_bPGSNoParsing = FALSE;\n\n    BOOL m_bH264MVCCombine = FALSE;\n    int m_nH264MVCBaseStream = -1;\n    int m_nH264MVCExtensionStream = -1;\n    std::deque<Packet *> m_MVCExtensionQueue;\n\n    int m_ForcedSubStream = -1;\n    unsigned int m_program = 0;\n\n    REFERENCE_TIME m_rtCurrent = 0;\n\n    AVStreamParseType *m_stOrigParser = nullptr;\n\n    CFontInstaller *m_pFontInstaller = nullptr;\n    ILAVFSettingsInternal *m_pSettings = nullptr;\n\n    BOOL m_bEnableTrackInfo = TRUE;\n\n    CBDDemuxer *m_pBluRay = nullptr;\n\n    int m_Abort = 0;\n    time_t m_timeAbort = 0;\n    time_t m_timeOpening = 0;\n};\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFInputFormats.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\nstatic const char *RAW_VIDEO = \"rawvideo\";\nstatic const char *RAW_VIDEO_DESC = \"raw video files\";\n\nstatic const char *RAW_AUDIO = \"rawaudio\";\nstatic const char *RAW_AUDIO_DESC = \"raw audio files\";\n\nstruct lavf_iformat_map\n{\n    const char *orig_format;\n    const char *new_format;\n    const char *new_description;\n} lavf_input_formats[] = {\n    // Shorten these formats\n    {\"matroska,webm\", \"matroska\", nullptr},\n    {\"mov,mp4,m4a,3gp,3g2,mj2\", \"mp4\", \"MPEG-4/QuickTime format\"},\n    {\"yuv4mpegpipe\", \"y4m\", \"YUV4MPEG\"},\n    {\"asf_o\", \"asf\", nullptr},\n\n    // Raw Video formats (grouped into \"rawvideo\")\n    {\"dirac\", RAW_VIDEO, RAW_VIDEO_DESC},\n    {\"dnxhd\", RAW_VIDEO, RAW_VIDEO_DESC},\n    {\"h261\", RAW_VIDEO, RAW_VIDEO_DESC},\n    {\"h263\", RAW_VIDEO, RAW_VIDEO_DESC},\n    {\"h264\", RAW_VIDEO, RAW_VIDEO_DESC},\n    {\"hevc\", RAW_VIDEO, RAW_VIDEO_DESC},\n    {\"ingenient\", RAW_VIDEO, RAW_VIDEO_DESC},\n    {\"mjpeg\", RAW_VIDEO, RAW_VIDEO_DESC},\n    {\"vc1\", RAW_VIDEO, RAW_VIDEO_DESC},\n\n    // Raw Audio Formats (grouped into \"rawaudio\")\n    {\"f32be\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"f32le\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"f64be\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"f64le\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"g722\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"gsm\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"s16be\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"s16le\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"s24be\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"s24le\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"s32be\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"s32le\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"s8\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"u16be\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"u16le\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"u24be\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"u24le\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"u32be\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"u32le\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"u8\", RAW_AUDIO, RAW_AUDIO_DESC},\n    {\"image2\", \"image2\", \"Image Files\"},\n    {\"image2pipe\", \"image2\", \"Image Files\"},\n\n    // Disabled Formats\n    {\"ffm\", nullptr, nullptr},\n    {\"ffmetadata\", nullptr, nullptr},\n    {\"mpegtsraw\", nullptr, nullptr},\n    {\"spdif\", nullptr, nullptr},\n    {\"tty\", nullptr, nullptr},\n    {\"vc1test\", nullptr, nullptr},\n};\n\nvoid lavf_get_iformat_infos(const AVInputFormat *pFormat, const char **pszName, const char **pszDescription)\n{\n    const char *name = pFormat->name;\n    const char *desc = pFormat->long_name;\n    for (int i = 0; i < countof(lavf_input_formats); ++i)\n    {\n        if (strcmp(lavf_input_formats[i].orig_format, name) == 0)\n        {\n            name = lavf_input_formats[i].new_format;\n            if (lavf_input_formats[i].new_description)\n                desc = lavf_input_formats[i].new_description;\n            break;\n        }\n    }\n\n    if (pszName)\n        *pszName = name;\n    if (pszDescription)\n        *pszDescription = desc;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFStreamInfo.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"LAVFStreamInfo.h\"\n#include \"LAVFVideoHelper.h\"\n#include \"LAVFAudioHelper.h\"\n#include \"LAVFUtils.h\"\n#include \"moreuuids.h\"\n#include \"H264Nalu.h\"\n\n#include <vector>\n#include <sstream>\n\nCLAVFStreamInfo::CLAVFStreamInfo(AVFormatContext *avctx, AVStream *avstream, const char *containerFormat, HRESULT &hr)\n    : CStreamInfo()\n    , m_containerFormat(containerFormat)\n{\n    switch (avstream->codecpar->codec_type)\n    {\n    case AVMEDIA_TYPE_AUDIO: hr = CreateAudioMediaType(avctx, avstream); break;\n    case AVMEDIA_TYPE_VIDEO: hr = CreateVideoMediaType(avctx, avstream); break;\n    case AVMEDIA_TYPE_SUBTITLE: hr = CreateSubtitleMediaType(avctx, avstream); break;\n    default: hr = E_FAIL; break;\n    }\n\n    codecInfo = lavf_get_stream_description(avstream);\n}\n\nCLAVFStreamInfo::~CLAVFStreamInfo()\n{\n}\n\nSTDMETHODIMP CLAVFStreamInfo::CreateAudioMediaType(AVFormatContext *avctx, AVStream *avstream)\n{\n    // if no codec tag is set, or the tag is set to PCM (which is often wrong), lookup a new tag\n    if (avstream->codecpar->codec_tag == 0 || avstream->codecpar->codec_tag == 1)\n    {\n        avstream->codecpar->codec_tag = av_codec_get_tag(mp_wav_taglists, avstream->codecpar->codec_id);\n    }\n\n    if (avstream->codecpar->ch_layout.nb_channels == 0 || avstream->codecpar->sample_rate == 0)\n    {\n        if (avstream->codecpar->codec_id == AV_CODEC_ID_AAC && avstream->codecpar->bit_rate)\n        {\n            if (!avstream->codecpar->ch_layout.nb_channels)\n            {\n                avstream->codecpar->ch_layout.order = AV_CHANNEL_ORDER_UNSPEC;\n                avstream->codecpar->ch_layout.nb_channels = 2;\n            }\n            if (!avstream->codecpar->sample_rate)\n                avstream->codecpar->sample_rate = 48000;\n        }\n        else\n            return E_FAIL;\n    }\n\n    // use the variant bitrate for the stream if only one stream is available (applies to some radio streams)\n    if (avstream->codecpar->bit_rate == 0 && avctx->nb_streams == 1)\n    {\n        AVDictionaryEntry *dict = av_dict_get(avstream->metadata, \"variant_bitrate\", nullptr, 0);\n        if (dict && dict->value)\n            avstream->codecpar->bit_rate = atoi(dict->value);\n    }\n\n    CMediaType mtype =\n        g_AudioHelper.initAudioType(avstream->codecpar, avstream->codecpar->codec_tag, m_containerFormat);\n\n    // The Raw PCM type is used for PCM streams which do not already have their own Extensible header\n    // If the codec_tag already equals extensible, it'll be used copied as-is and we assume a valid extensible header\n    // exists in extradata\n    bool bUseRawPCMType = (mtype.subtype == MEDIASUBTYPE_PCM || mtype.subtype == MEDIASUBTYPE_IEEE_FLOAT) &&\n                          (avstream->codecpar->codec_tag != WAVE_FORMAT_EXTENSIBLE || avstream->codecpar->extradata_size < 22);\n\n    if (mtype.formattype == FORMAT_WaveFormatEx)\n    {\n        // Special Logic for the MPEG1 Audio Formats (MP1, MP2)\n        if (mtype.subtype == MEDIASUBTYPE_MPEG1AudioPayload)\n        {\n            mtype.pbFormat = (BYTE *)g_AudioHelper.CreateMP1WVFMT(avstream, &mtype.cbFormat);\n        }\n        else if (mtype.subtype == MEDIASUBTYPE_BD_LPCM_AUDIO)\n        {\n            mtype.pbFormat = (BYTE *)g_AudioHelper.CreateWVFMTEX_LPCM(avstream, &mtype.cbFormat);\n            mtypes.push_back(mtype);\n            mtype.subtype = MEDIASUBTYPE_HDMV_LPCM_AUDIO;\n        }\n        else if (bUseRawPCMType)\n        {\n            // Create raw PCM media type\n            mtype.pbFormat = (BYTE *)g_AudioHelper.CreateWFMTEX_RAW_PCM(avstream, &mtype.cbFormat, mtype.subtype,\n                                                                        &mtype.lSampleSize);\n        }\n        else\n        {\n            WAVEFORMATEX *wvfmt = g_AudioHelper.CreateWVFMTEX(avstream, &mtype.cbFormat);\n\n            if (avstream->codecpar->codec_tag == WAVE_FORMAT_EXTENSIBLE && avstream->codecpar->extradata_size >= 22)\n            {\n                // The WAVEFORMATEXTENSIBLE GUID is not recognized by the audio renderers\n                // Set the actual subtype as GUID\n                WAVEFORMATEXTENSIBLE *wvfmtex = (WAVEFORMATEXTENSIBLE *)wvfmt;\n                mtype.subtype = wvfmtex->SubFormat;\n            }\n            mtype.pbFormat = (BYTE *)wvfmt;\n\n            if (avstream->codecpar->codec_id == AV_CODEC_ID_FLAC)\n            {\n                // These are required to block accidental connection to ReClock\n                wvfmt->nAvgBytesPerSec = (wvfmt->nSamplesPerSec * wvfmt->nChannels * wvfmt->wBitsPerSample) >> 3;\n                wvfmt->nBlockAlign = 1;\n                mtype.subtype = MEDIASUBTYPE_FLAC_FRAMED;\n                mtypes.push_back(mtype);\n                mtype.subtype = MEDIASUBTYPE_FLAC;\n            }\n            else if (avstream->codecpar->codec_id == AV_CODEC_ID_EAC3)\n            {\n                mtypes.push_back(mtype);\n                mtype.subtype = MEDIASUBTYPE_DOLBY_DDPLUS_ARCSOFT;\n            }\n            else if (avstream->codecpar->codec_id == AV_CODEC_ID_DTS)\n            {\n                wvfmt->wFormatTag = WAVE_FORMAT_DTS2;\n                if (avstream->codecpar->profile >= AV_PROFILE_DTS_HD_HRA)\n                {\n                    mtype.subtype = MEDIASUBTYPE_DTS_HD;\n                    mtypes.push_back(mtype);\n                }\n                mtype.subtype = MEDIASUBTYPE_WAVE_DTS;\n            }\n            else if (avstream->codecpar->codec_id == AV_CODEC_ID_TRUEHD)\n            {\n                // wvfmt->wFormatTag = (WORD)WAVE_FORMAT_TRUEHD;\n                mtypes.push_back(mtype);\n                mtype.subtype = MEDIASUBTYPE_DOLBY_TRUEHD_ARCSOFT;\n            }\n            else if (avstream->codecpar->codec_id == AV_CODEC_ID_AAC)\n            {\n                wvfmt->wFormatTag = (WORD)MEDIASUBTYPE_AAC_ADTS.Data1;\n\n                CMediaType adtsMtype = mtype;\n                adtsMtype.subtype = MEDIASUBTYPE_AAC_ADTS;\n                mtypes.push_back(adtsMtype);\n\n                // if we have extradata, use ordinary AAC type\n                if (avstream->codecpar->extradata_size)\n                {\n                    mtype.subtype = MEDIASUBTYPE_AAC;\n                }\n                else\n                {\n                    // else, use ADTS type\n                    mtype.subtype = MEDIASUBTYPE_MPEG_ADTS_AAC;\n                }\n                wvfmt->wFormatTag = (WORD)mtype.subtype.Data1;\n            }\n            else if (avstream->codecpar->codec_id == AV_CODEC_ID_AAC_LATM)\n            {\n                mtypes.push_back(mtype);\n                mtype.subtype = MEDIASUBTYPE_MPEG_LOAS;\n                wvfmt->wFormatTag = (WORD)mtype.subtype.Data1;\n            }\n            else if (avstream->codecpar->codec_id == AV_CODEC_ID_OPUS)\n            {\n                mtypes.push_back(mtype);\n                mtype.subtype = MEDIASUBTYPE_OPUS_OLD;\n                wvfmt->wFormatTag = (WORD)WAVE_FORMAT_OPUS_OLD;\n            }\n        }\n    }\n    else if (mtype.formattype == FORMAT_VorbisFormat2 && mtype.subtype == MEDIASUBTYPE_Vorbis2)\n    {\n        // With Matroska and Ogg we know how to split up the extradata\n        // and put it into a VorbisFormat2\n        if ((m_containerFormat == \"matroska\" || m_containerFormat == \"ogg\") && avstream->codecpar->extradata_size > 0)\n        {\n            BYTE *vorbis2 = (BYTE *)g_AudioHelper.CreateVorbis2(avstream, &mtype.cbFormat);\n            if (vorbis2)\n            {\n                mtype.pbFormat = vorbis2;\n                mtypes.push_back(mtype);\n            }\n        }\n        // Old vorbis header without extradata\n        mtype.subtype = MEDIASUBTYPE_Vorbis;\n        mtype.formattype = FORMAT_VorbisFormat;\n        mtype.pbFormat = (BYTE *)g_AudioHelper.CreateVorbis(avstream, &mtype.cbFormat);\n    }\n\n    mtypes.push_back(mtype);\n\n    // Create our special media type\n    CMediaType ff_mtype;\n    ff_mtype.InitMediaType();\n    ff_mtype.SetSampleSize(256000);\n    ff_mtype.majortype = MEDIATYPE_Audio;\n    ff_mtype.subtype = MEDIASUBTYPE_FFMPEG_AUDIO;\n    ff_mtype.formattype = FORMAT_WaveFormatExFFMPEG;\n    if (bUseRawPCMType)\n        ff_mtype.pbFormat = (BYTE *)g_AudioHelper.CreateWFMTEX_RAW_PCM_FF(avstream, &ff_mtype.cbFormat, mtype.subtype, &ff_mtype.lSampleSize);\n    else\n        ff_mtype.pbFormat = (BYTE *)g_AudioHelper.CreateWVFMTEX_FF(avstream, &ff_mtype.cbFormat);\n    mtypes.push_back(ff_mtype);\n\n    return S_OK;\n}\n\nstatic bool h264_is_annexb(std::string format, AVStream *avstream)\n{\n    ASSERT(avstream->codecpar->codec_id == AV_CODEC_ID_H264 || avstream->codecpar->codec_id == AV_CODEC_ID_H264_MVC);\n    if (avstream->codecpar->extradata_size < 4)\n        return true;\n    if (avstream->codecpar->extradata[0] == 1)\n        return false;\n    if (format == \"avi\")\n    {\n        BYTE *src = avstream->codecpar->extradata;\n        unsigned startcode = AV_RB32(src);\n        if (startcode == 0x00000001 || (startcode & 0xffffff00) == 0x00000100)\n            return true;\n        if (avstream->codecpar->codec_tag == MKTAG('A', 'V', 'C', '1') ||\n            avstream->codecpar->codec_tag == MKTAG('a', 'v', 'c', '1'))\n            return false;\n    }\n    return true;\n}\n\nstatic bool hevc_is_annexb(std::string format, AVStream *avstream)\n{\n    ASSERT(avstream->codecpar->codec_id == AV_CODEC_ID_HEVC);\n    if (avstream->codecpar->extradata_size < 23)\n        return true;\n    if (avstream->codecpar->extradata[0] || avstream->codecpar->extradata[1] || avstream->codecpar->extradata[2] > 1)\n        return false;\n    /*if (format == \"avi\") {\n      BYTE *src = avstream->codec->extradata;\n      unsigned startcode = AV_RB32(src);\n      if (startcode == 0x00000001 || (startcode & 0xffffff00) == 0x00000100)\n        return true;\n    }*/\n    return true;\n}\n\nstatic int get_vpcC_chroma(AVCodecParameters *codecpar)\n{\n    int chroma_w = 0, chroma_h = 0;\n    if (av_pix_fmt_get_chroma_sub_sample((AVPixelFormat)codecpar->format, &chroma_w, &chroma_h) == 0)\n    {\n        if (chroma_w == 1 && chroma_h == 1)\n        {\n            return (codecpar->chroma_location == AVCHROMA_LOC_LEFT) ? 0 : 1;\n        }\n        else if (chroma_w == 1 && chroma_h == 0)\n        {\n            return 2;\n        }\n        else if (chroma_w == 0 && chroma_h == 0)\n        {\n            return 3;\n        }\n    }\n    return 0;\n}\n\nstatic int get_pixel_bitdepth(AVPixelFormat pix_fmt)\n{\n    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);\n    if (desc == NULL)\n    {\n        DbgLog((LOG_TRACE, 10, \"Unknown pixel format\"));\n        return 8;\n    }\n    return desc->comp[0].depth;\n}\n\nstatic bool is_monochrome(AVPixelFormat pix_fmt)\n{\n    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);\n    if (desc == NULL)\n    {\n        DbgLog((LOG_TRACE, 10, \"Unknown pixel format\"));\n        return false;\n    }\n    return desc->nb_components == 1;\n}\n\nstatic int chroma_x(AVPixelFormat pix_fmt)\n{\n    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);\n    if (desc == NULL)\n    {\n        DbgLog((LOG_TRACE, 10, \"Unknown pixel format\"));\n        return 1;\n    }\n    return desc->log2_chroma_w;\n}\n\nstatic int chroma_y(AVPixelFormat pix_fmt)\n{\n    const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(pix_fmt);\n    if (desc == NULL)\n    {\n        DbgLog((LOG_TRACE, 10, \"Unknown pixel format\"));\n        return 1;\n    }\n    return desc->log2_chroma_h;\n}\n\nSTDMETHODIMP CLAVFStreamInfo::CreateVideoMediaType(AVFormatContext *avctx, AVStream *avstream)\n{\n    unsigned int origCodecTag = avstream->codecpar->codec_tag;\n    if (avstream->codecpar->codec_tag == 0 && avstream->codecpar->codec_id != AV_CODEC_ID_DVVIDEO)\n    {\n        avstream->codecpar->codec_tag = av_codec_get_tag(mp_bmp_taglists, avstream->codecpar->codec_id);\n    }\n\n    if (avstream->codecpar->codec_id == AV_CODEC_ID_H264_MVC)\n    {\n        // Don't create media types for MVC extension streams, they are handled specially\n        return S_FALSE;\n    }\n\n    if (avstream->codecpar->width == 0 || avstream->codecpar->height == 0)\n        return E_FAIL;\n\n    CMediaType mtype =\n        g_VideoHelper.initVideoType(avstream->codecpar->codec_id, avstream->codecpar->codec_tag, m_containerFormat);\n\n    mtype.SetTemporalCompression(TRUE);\n    mtype.SetVariableSize();\n\n    // Somewhat hackish to force VIH for AVI content.\n    // TODO: Figure out why exactly this is required\n    if (m_containerFormat == \"avi\" && avstream->codecpar->codec_id != AV_CODEC_ID_H264)\n    {\n        mtype.formattype = FORMAT_VideoInfo;\n    }\n\n    // Native MPEG4 in Matroska needs a special formattype\n    if (m_containerFormat == \"matroska\" && avstream->codecpar->codec_id == AV_CODEC_ID_MPEG4)\n    {\n        if (AVDictionaryEntry *mkvCodecId = av_dict_get(avstream->metadata, \"mkv-codec-id\", nullptr, 0))\n        {\n            if (strcmp(mkvCodecId->value, \"V_MS/VFW/FOURCC\") != 0)\n                mtype.formattype = FORMAT_MPEG2Video;\n        }\n    }\n\n    // If we need aspect info, we switch to VIH2\n    AVRational r = avstream->sample_aspect_ratio;\n    AVRational rc = avstream->codecpar->sample_aspect_ratio;\n    if (mtype.formattype == FORMAT_VideoInfo && ((r.den > 0 && r.num > 0 && (r.den > 1 || r.num > 1)) ||\n                                                 (rc.den > 0 && rc.num > 0 && (rc.den > 1 || rc.num > 1))))\n    {\n        mtype.formattype = FORMAT_VideoInfo2;\n    }\n\n    if (mtype.formattype == FORMAT_VideoInfo)\n    {\n        mtype.pbFormat = (BYTE *)g_VideoHelper.CreateVIH(avstream, &mtype.cbFormat, m_containerFormat);\n    }\n    else if (mtype.formattype == FORMAT_VideoInfo2)\n    {\n        mtype.pbFormat = (BYTE *)g_VideoHelper.CreateVIH2(avstream, &mtype.cbFormat, m_containerFormat);\n        if (mtype.subtype == MEDIASUBTYPE_WVC1)\n        {\n            // If we send the cyberlink subtype first, it'll work with it, and with ffdshow, dmo and mpc-hc internal\n            VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)mtype.pbFormat;\n            if (*((BYTE *)vih2 + sizeof(VIDEOINFOHEADER2)) == 0)\n            {\n                mtype.subtype = MEDIASUBTYPE_WVC1_CYBERLINK;\n                mtypes.push_back(mtype);\n                mtype.subtype = MEDIASUBTYPE_WVC1_ARCSOFT;\n                mtypes.push_back(mtype);\n            }\n            mtype.subtype = MEDIASUBTYPE_WVC1;\n        }\n        else if (mtype.subtype == MEDIASUBTYPE_WMVA)\n        {\n            mtypes.push_back(mtype);\n\n            mtype.subtype = MEDIASUBTYPE_WVC1;\n            VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)mtype.pbFormat;\n            vih2->bmiHeader.biCompression = mtype.subtype.Data1;\n        }\n        else if (mtype.subtype == MEDIASUBTYPE_VP90)\n        {\n            // generate extradata for VP9 streams\n            mtype.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + 16);\n            VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)mtype.pbFormat;\n            vih2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + 16;\n\n            BYTE *extra = mtype.pbFormat + sizeof(VIDEOINFOHEADER2);\n            AV_WB32(extra, MKBETAG('v', 'p', 'c', 'C'));\n            AV_WB8(extra + 4, 1);  // version\n            AV_WB24(extra + 5, 0); // flags\n            AV_WB8(extra + 8, avstream->codecpar->profile);\n            AV_WB8(extra + 9, avstream->codecpar->level == AV_LEVEL_UNKNOWN ? 0 : avstream->codecpar->level);\n            AV_WB8(extra + 10, get_pixel_bitdepth((AVPixelFormat)avstream->codecpar->format) << 4 |\n                                   get_vpcC_chroma(avstream->codecpar) << 1 |\n                                   (avstream->codecpar->color_range == AVCOL_RANGE_JPEG));\n            AV_WB8(extra + 11, avstream->codecpar->color_primaries);\n            AV_WB8(extra + 12, avstream->codecpar->color_trc);\n            AV_WB8(extra + 13, avstream->codecpar->color_space);\n            AV_WB16(extra + 14, 0); // no codec init data\n        }\n        else if (mtype.subtype == MEDIASUBTYPE_AV01)\n        {\n            VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)mtype.pbFormat;\n\n            // check if extradata is missing, and we have some basic information to share\n            if ((vih2->bmiHeader.biSize <= sizeof(BITMAPINFOHEADER) + 4 || ((mtype.pbFormat + sizeof(VIDEOINFOHEADER2))[0] != 0x81)) && avstream->codecpar->profile != AV_PROFILE_UNKNOWN)\n            {\n                // if not, generate some\n                mtype.ReallocFormatBuffer(sizeof(VIDEOINFOHEADER2) + 4);\n                vih2 = (VIDEOINFOHEADER2 *)mtype.pbFormat;\n                vih2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + 4;\n\n                BYTE *extra = mtype.pbFormat + sizeof(VIDEOINFOHEADER2);\n                AV_WB8(extra, 0x81);  // version\n                AV_WB8(extra + 1, (avstream->codecpar->profile == AV_PROFILE_UNKNOWN ? 0 : avstream->codecpar->profile) << 5 |\n                                      (avstream->codecpar->level == AV_LEVEL_UNKNOWN ? 0 : avstream->codecpar->level));\n\n                int bpp = get_pixel_bitdepth((AVPixelFormat)avstream->codecpar->format);\n                AV_WB8(extra + 2, (0 << 7) | // seq_tier\n                                  ((bpp > 8) << 6) | // high_bitdepth\n                                  ((bpp == 12) << 5) | // twelve bit\n                                  (is_monochrome((AVPixelFormat)avstream->codecpar->format) << 4) | // monochrome\n                                  (chroma_x((AVPixelFormat)avstream->codecpar->format) << 3) |\n                                  (chroma_y((AVPixelFormat)avstream->codecpar->format) << 2) |\n                                  (0 << 1) // chroma  sample position\n                    );\n\n                AV_WB8(extra + 3, 0); // reserved, unusued fields\n            }\n        }\n    }\n    else if (mtype.formattype == FORMAT_MPEGVideo)\n    {\n        mtype.pbFormat = (BYTE *)g_VideoHelper.CreateMPEG1VI(avstream, &mtype.cbFormat, m_containerFormat);\n    }\n    else if (mtype.formattype == FORMAT_MPEG2Video)\n    {\n        mtype.pbFormat = (BYTE *)g_VideoHelper.CreateMPEG2VI(avstream, &mtype.cbFormat, m_containerFormat, FALSE);\n        MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mtype.pbFormat;\n        if (avstream->codecpar->codec_id == AV_CODEC_ID_H264)\n        {\n            if (h264_is_annexb(m_containerFormat, avstream))\n            {\n                mtype.subtype = MEDIASUBTYPE_H264;\n            }\n            else\n            {\n                mtype.subtype = MEDIASUBTYPE_AVC1;\n                if (mp2vi->dwFlags == 0)\n                    mp2vi->dwFlags = 4;\n            }\n            mp2vi->hdr.bmiHeader.biCompression = mtype.subtype.Data1;\n\n            // Create a second AVC1 compat type for mpegts\n            // This should only ever be used by \"legacy\" decoders\n            if (mtype.subtype == MEDIASUBTYPE_H264 && m_containerFormat == \"mpegts\")\n            {\n                mtypes.push_back(mtype);\n                mtype.ResetFormatBuffer();\n                mtype.subtype = MEDIASUBTYPE_AVC1;\n                mtype.pbFormat =\n                    (BYTE *)g_VideoHelper.CreateMPEG2VI(avstream, &mtype.cbFormat, m_containerFormat, TRUE);\n                MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mtype.pbFormat;\n                mp2vi->hdr.bmiHeader.biCompression = mtype.subtype.Data1;\n            }\n        }\n        else if (avstream->codecpar->codec_id == AV_CODEC_ID_HEVC)\n        {\n            if (hevc_is_annexb(m_containerFormat, avstream))\n            {\n                mtype.subtype = MEDIASUBTYPE_HEVC;\n            }\n            else\n            {\n                mtype.subtype = MEDIASUBTYPE_HVC1;\n            }\n            mp2vi->hdr.bmiHeader.biCompression = mtype.subtype.Data1;\n        }\n    }\n\n    // Detect MVC extensions and adjust the type appropriately\n    if (avstream->codecpar->codec_id == AV_CODEC_ID_H264)\n    {\n        if (h264_is_annexb(m_containerFormat, avstream))\n        {\n            if (m_containerFormat == \"mpegts\")\n            {\n                int nBaseStream = -1, nExtensionStream = -1;\n                if (GetH264MVCStreamIndices(avctx, &nBaseStream, &nExtensionStream) && nBaseStream == avstream->index)\n                {\n                    CMediaType mvcType = mtypes.front();\n                    AVStream *mvcStream = avctx->streams[nExtensionStream];\n\n                    MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mvcType.ReallocFormatBuffer(\n                        sizeof(MPEG2VIDEOINFO) + avstream->codecpar->extradata_size +\n                        mvcStream->codecpar->extradata_size);\n\n                    size_t ExtradataSize = 0;\n\n                    // clear the extradata storage\n                    memset(&mp2vi->dwSequenceHeader[0], 0,\n                           avstream->codecpar->extradata_size + mvcStream->codecpar->extradata_size);\n\n                    // assemble the extradata in the correct order, first the SPS+SPS Subset, then any PPS\n                    CH264Nalu nalParser;\n\n                    // main SPS from the base stream\n                    nalParser.SetBuffer(avstream->codecpar->extradata, avstream->codecpar->extradata_size, 0);\n                    while (nalParser.ReadNext())\n                    {\n                        if (nalParser.GetType() == NALU_TYPE_SPS)\n                        {\n                            memcpy((BYTE *)&mp2vi->dwSequenceHeader[0] + ExtradataSize, nalParser.GetNALBuffer(),\n                                   nalParser.GetLength());\n                            ExtradataSize += nalParser.GetLength();\n                        }\n                    }\n\n                    // subset SPS from the extension stream\n                    nalParser.SetBuffer(mvcStream->codecpar->extradata, mvcStream->codecpar->extradata_size, 0);\n                    while (nalParser.ReadNext())\n                    {\n                        if (nalParser.GetType() == NALU_TYPE_SPS || nalParser.GetType() == NALU_TYPE_SPS_SUB)\n                        {\n                            memcpy((BYTE *)&mp2vi->dwSequenceHeader[0] + ExtradataSize, nalParser.GetNALBuffer(),\n                                   nalParser.GetLength());\n                            ExtradataSize += nalParser.GetLength();\n                        }\n\n                        // extract profile info from the subset SPS\n                        if (nalParser.GetType() == NALU_TYPE_SPS_SUB)\n                        {\n                            const BYTE *pData = nalParser.GetDataBuffer();\n                            mp2vi->dwProfile = avstream->codecpar->profile = pData[1];\n                            mp2vi->dwLevel = avstream->codecpar->level = pData[3];\n                        }\n                    }\n\n                    // PPS from the main stream\n                    nalParser.SetBuffer(avstream->codecpar->extradata, avstream->codecpar->extradata_size, 0);\n                    while (nalParser.ReadNext())\n                    {\n                        if (nalParser.GetType() == NALU_TYPE_PPS)\n                        {\n                            memcpy((BYTE *)&mp2vi->dwSequenceHeader[0] + ExtradataSize, nalParser.GetNALBuffer(),\n                                   nalParser.GetLength());\n                            ExtradataSize += nalParser.GetLength();\n                        }\n                    }\n\n                    // PPS from the extension stream\n                    nalParser.SetBuffer(mvcStream->codecpar->extradata, mvcStream->codecpar->extradata_size, 0);\n                    while (nalParser.ReadNext())\n                    {\n                        if (nalParser.GetType() == NALU_TYPE_PPS)\n                        {\n                            memcpy((BYTE *)&mp2vi->dwSequenceHeader[0] + ExtradataSize, nalParser.GetNALBuffer(),\n                                   nalParser.GetLength());\n                            ExtradataSize += nalParser.GetLength();\n                        }\n                    }\n\n                    // update mediatype\n                    mp2vi->cbSequenceHeader = (DWORD)ExtradataSize;\n                    mvcType.cbFormat = SIZE_MPEG2VIDEOINFO(mp2vi);\n                    mvcType.subtype = MEDIASUBTYPE_AMVC;\n                    mp2vi->hdr.bmiHeader.biCompression = mvcType.subtype.Data1;\n\n                    mtypes.push_front(mvcType);\n                }\n            }\n        }\n        else\n        {\n            CMediaType mvcType = mtype;\n\n            MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)mvcType.ReallocFormatBuffer(sizeof(MPEG2VIDEOINFO) +\n                                                                                  avstream->codecpar->extradata_size);\n            HRESULT hr = g_VideoHelper.ProcessH264MVCExtradata(avstream->codecpar->extradata,\n                                                               avstream->codecpar->extradata_size, mp2vi);\n            if (hr == S_OK)\n            {\n                mvcType.cbFormat = SIZE_MPEG2VIDEOINFO(mp2vi);\n                mvcType.subtype = MEDIASUBTYPE_MVC1;\n                mp2vi->hdr.bmiHeader.biCompression = mvcType.subtype.Data1;\n                mtypes.push_front(mvcType);\n\n                // update stream profile/level appropriately\n                if (mp2vi->dwProfile != 0)\n                    avstream->codecpar->profile = mp2vi->dwProfile;\n                if (mp2vi->dwLevel != 0)\n                    avstream->codecpar->level = mp2vi->dwLevel;\n            }\n        }\n    }\n\n    if (avstream->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO)\n    {\n        BITMAPINFOHEADER *pBMI = nullptr;\n        videoFormatTypeHandler(mtype.pbFormat, &mtype.formattype, &pBMI, nullptr, nullptr, nullptr);\n        mtype.bFixedSizeSamples = TRUE;\n        mtype.bTemporalCompression = FALSE;\n        mtype.lSampleSize = pBMI->biSizeImage;\n        if (!avstream->codecpar->codec_tag || avstream->codecpar->codec_tag == MKTAG('r', 'a', 'w', ' '))\n        {\n            switch (avstream->codecpar->format)\n            {\n            case AV_PIX_FMT_BGRA:\n                mtype.subtype = MEDIASUBTYPE_ARGB32;\n                mtypes.push_back(mtype);\n                mtype.subtype = MEDIASUBTYPE_RGB32;\n                break;\n            case AV_PIX_FMT_BGR24: mtype.subtype = MEDIASUBTYPE_RGB24; break;\n            default: DbgLog((LOG_TRACE, 10, L\"::CreateVideoMediaType(): Unsupported raw video pixel format\"));\n            }\n        }\n        else\n        {\n            switch (avstream->codecpar->codec_tag)\n            {\n            case MKTAG('B', 'G', 'R', 'A'): {\n                pBMI->biHeight = -pBMI->biHeight;\n                mtype.subtype = MEDIASUBTYPE_ARGB32;\n                mtypes.push_back(mtype);\n                mtype.subtype = MEDIASUBTYPE_RGB32;\n            }\n            break;\n            default: DbgLog((LOG_TRACE, 10, L\"::CreateVideoMediaType(): Unsupported raw video codec tag format\"));\n            }\n        }\n        mtypes.push_back(mtype);\n        mtype.subtype = MEDIASUBTYPE_LAV_RAWVIDEO;\n        size_t hdrsize = 0, extrasize = 0;\n        if (mtype.formattype == FORMAT_VideoInfo)\n        {\n            hdrsize = sizeof(VIDEOINFOHEADER);\n        }\n        else if (mtype.formattype == FORMAT_VideoInfo2)\n        {\n            hdrsize = sizeof(VIDEOINFOHEADER2);\n        }\n        else\n        {\n            ASSERT(0);\n        }\n        extrasize = mtype.cbFormat - hdrsize;\n        mtype.ReallocFormatBuffer((ULONG)(hdrsize + extrasize + sizeof(avstream->codecpar->format)));\n        if (extrasize)\n        {\n            memmove(mtype.pbFormat + hdrsize + sizeof(avstream->codecpar->format), mtype.pbFormat + hdrsize, extrasize);\n        }\n        *(int *)(mtype.pbFormat + hdrsize) = avstream->codecpar->format;\n        videoFormatTypeHandler(mtype.pbFormat, &mtype.formattype, &pBMI, nullptr, nullptr, nullptr);\n        pBMI->biSize = (DWORD)(sizeof(BITMAPINFOHEADER) + sizeof(avstream->codecpar->format) + extrasize);\n        mtypes.push_back(mtype);\n    }\n\n    if (avstream->codecpar->codec_id == AV_CODEC_ID_MJPEG)\n    {\n        BITMAPINFOHEADER *pBMI = nullptr;\n        videoFormatTypeHandler(mtype.pbFormat, &mtype.formattype, &pBMI, nullptr, nullptr, nullptr);\n\n        DWORD fourCC = MKTAG('M', 'J', 'P', 'G');\n\n        // If the original fourcc is different to MJPG, add this one\n        if (fourCC != pBMI->biCompression)\n        {\n            mtypes.push_back(mtype);\n\n            mtype.subtype = FOURCCMap(fourCC);\n            pBMI->biCompression = fourCC;\n        }\n    }\n\n    mtypes.push_back(mtype);\n    return S_OK;\n}\n\nenum AVCodecID ff_get_pcm_codec_id(int bps, int flt, int be, int sflags);\n#include \"libavformat/isom.h\"\n\nstatic std::string CreateVOBSubHeaderFromMP4(int vidW, int vidH, MOVStreamContext *context, const char *buffer,\n                                             int buf_size)\n{\n    std::ostringstream header;\n    if (buffer && buf_size)\n    {\n        int w = context && context->width ? context->width : vidW;\n        int h = context && context->height ? context->height : vidH;\n\n        header << \"# VobSub index file, v7 (do not modify this line!)\\n\";\n        // ffmpeg might provide us with the size already\n        if (strncmp(buffer, \"size:\", 5) != 0)\n        {\n            header << \"size: \" << w << \"x\" << h << \"\\n\";\n        }\n        header.write(buffer, buf_size);\n    }\n    return header.str();\n}\n\nstatic std::string GetDefaultVOBSubHeader(int w, int h)\n{\n    std::ostringstream header;\n    header << \"# VobSub index file, v7 (do not modify this line!)\\n\";\n    header << \"size: \" << w << \"x\" << h << \"\\n\";\n    header << \"palette: \";\n    // header << \"000000,f0f0f0,cccccc,999999,\";\n    header << \"000000,e0e0e0,808080,202020,\";\n    header << \"3333fa,1111bb,fa3333,bb1111,\";\n    header << \"33fa33,11bb11,fafa33,bbbb11,\";\n    header << \"fa33fa,bb11bb,33fafa,11bbbb\\n\";\n    return header.str();\n}\n\n// Map codec ids to media subtypes\n// clang-format off\nstatic FormatMapping subtitle_format_map[] = {\n    { AV_CODEC_ID_TEXT,                 &MEDIASUBTYPE_UTF8 },\n    { AV_CODEC_ID_SRT,                  &MEDIASUBTYPE_UTF8 },\n    { AV_CODEC_ID_SUBRIP,               &MEDIASUBTYPE_UTF8 },\n    { AV_CODEC_ID_MOV_TEXT,             &MEDIASUBTYPE_UTF8 },\n    { AV_CODEC_ID_ASS,                  &MEDIASUBTYPE_ASS  },\n    { AV_CODEC_ID_SSA,                  &MEDIASUBTYPE_ASS  },\n    { AV_CODEC_ID_HDMV_PGS_SUBTITLE,    &MEDIASUBTYPE_HDMVSUB },\n    { AV_CODEC_ID_DVD_SUBTITLE,         &MEDIASUBTYPE_VOBSUB },\n    { AV_CODEC_ID_DVB_SUBTITLE,         &MEDIASUBTYPE_DVB_SUBTITLES },\n    { AV_CODEC_ID_WEBVTT,               &MEDIASUBTYPE_WEBVTT },\n};\n// clang-format on\n\nSTDMETHODIMP CLAVFStreamInfo::CreateSubtitleMediaType(AVFormatContext *avctx, AVStream *avstream)\n{\n    CMediaType mtype;\n    mtype.majortype = MEDIATYPE_Subtitle;\n    mtype.formattype = FORMAT_SubtitleInfo;\n    mtype.subtype = MEDIASUBTYPE_NULL;\n\n    int extra = avstream->codecpar->extradata_size;\n\n    // parse flags from mov tx3g atom\n    if (avstream->codecpar->codec_id == AV_CODEC_ID_MOV_TEXT &&\n        avstream->codecpar->codec_tag == MKTAG('t', 'x', '3', 'g') && extra >= 4)\n    {\n        uint32_t flags = AV_RB32(avstream->codecpar->extradata);\n        if (flags & 0x80000000)\n            avstream->disposition |= AV_DISPOSITION_FORCED;\n    }\n\n    if (avstream->codecpar->codec_id == AV_CODEC_ID_MOV_TEXT || avstream->codecpar->codec_id == AV_CODEC_ID_TEXT ||\n        avstream->codecpar->codec_id == AV_CODEC_ID_SUBRIP)\n    {\n        extra = 0;\n    }\n\n    // create format info\n    SUBTITLEINFO *subInfo = (SUBTITLEINFO *)mtype.AllocFormatBuffer(sizeof(SUBTITLEINFO) + extra);\n    memset(subInfo, 0, mtype.FormatLength());\n\n    if (AVDictionaryEntry *dictEntry = av_dict_get(avstream->metadata, \"language\", nullptr, 0))\n    {\n        char *lang = dictEntry->value;\n        strncpy_s(subInfo->IsoLang, 4, lang, _TRUNCATE);\n    }\n    else\n    {\n        strncpy_s(subInfo->IsoLang, 4, \"und\", _TRUNCATE);\n    }\n\n    if (AVDictionaryEntry *dictEntry = av_dict_get(avstream->metadata, \"title\", nullptr, 0))\n    {\n        // read metadata\n        char *title = dictEntry->value;\n        // convert to wchar\n        SafeMultiByteToWideChar(CP_UTF8, 0, title, -1, subInfo->TrackName, 256);\n    }\n\n    subInfo->dwOffset = sizeof(SUBTITLEINFO);\n\n    // Find first video stream\n    AVStream *vidStream = nullptr;\n    for (unsigned i = 0; i < avctx->nb_streams; i++)\n    {\n        if (avctx->streams[i]->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)\n        {\n            vidStream = avctx->streams[i];\n            break;\n        }\n    }\n\n    // Extradata\n    if (m_containerFormat == \"mp4\" && avstream->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE)\n    {\n        std::string strVobSubHeader = CreateVOBSubHeaderFromMP4(\n            vidStream ? vidStream->codecpar->width : 720, vidStream ? vidStream->codecpar->height : 576,\n            (MOVStreamContext *)avstream->priv_data, (char *)avstream->codecpar->extradata, extra);\n        size_t len = strVobSubHeader.length();\n        mtype.ReallocFormatBuffer((ULONG)(sizeof(SUBTITLEINFO) + len));\n        memcpy(mtype.pbFormat + sizeof(SUBTITLEINFO), strVobSubHeader.c_str(), len);\n    }\n    else if (m_containerFormat == \"mpeg\" && avstream->codecpar->codec_id == AV_CODEC_ID_DVD_SUBTITLE)\n    {\n        // And a VobSub type\n        std::string strVobSubHeader = GetDefaultVOBSubHeader(vidStream ? vidStream->codecpar->width : 720,\n                                                             vidStream ? vidStream->codecpar->height : 576);\n        size_t len = strVobSubHeader.length();\n        mtype.ReallocFormatBuffer((ULONG)(sizeof(SUBTITLEINFO) + len));\n        memcpy(mtype.pbFormat + sizeof(SUBTITLEINFO), strVobSubHeader.c_str(), len);\n        mtype.subtype = MEDIASUBTYPE_VOBSUB;\n        mtypes.push_back(mtype);\n\n        // Offer the DVD subtype\n        CMediaType dvdmtype;\n        dvdmtype.majortype = MEDIATYPE_Video;\n        dvdmtype.subtype = MEDIASUBTYPE_DVD_SUBPICTURE;\n        dvdmtype.formattype = FORMAT_MPEG2_VIDEO;\n        MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)dvdmtype.AllocFormatBuffer(sizeof(MPEG2VIDEOINFO));\n        ZeroMemory(mp2vi, sizeof(MPEG2VIDEOINFO));\n        mp2vi->hdr.bmiHeader.biWidth = vidStream ? vidStream->codecpar->width : 720;\n        mp2vi->hdr.bmiHeader.biHeight = vidStream ? vidStream->codecpar->height : 576;\n        mtypes.push_back(dvdmtype);\n\n        return S_OK;\n    }\n    else if (avstream->codecpar->extradata && extra > 0)\n    {\n        memcpy(mtype.pbFormat + sizeof(SUBTITLEINFO), avstream->codecpar->extradata, extra);\n    }\n\n    // Check against values from the map above\n    for (unsigned i = 0; i < countof(subtitle_format_map); ++i)\n    {\n        if (subtitle_format_map[i].codec == avstream->codecpar->codec_id)\n        {\n            if (subtitle_format_map[i].subtype)\n                mtype.subtype = *subtitle_format_map[i].subtype;\n            break;\n        }\n    }\n\n    // not type found\n    if (mtype.subtype == MEDIASUBTYPE_NULL)\n        return E_FAIL;\n\n    mtypes.push_back(mtype);\n    return S_OK;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFStreamInfo.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#pragma once\n\n#include <string>\n#include \"StreamInfo.h\"\n\nclass CLAVFStreamInfo : public CStreamInfo\n{\n  public:\n    CLAVFStreamInfo(AVFormatContext *avctx, AVStream *avstream, const char *containerFormat, HRESULT &hr);\n    ~CLAVFStreamInfo();\n\n    STDMETHODIMP CreateAudioMediaType(AVFormatContext *avctx, AVStream *avstream);\n    STDMETHODIMP CreateVideoMediaType(AVFormatContext *avctx, AVStream *avstream);\n    STDMETHODIMP CreateSubtitleMediaType(AVFormatContext *avctx, AVStream *avstream);\n\n  private:\n    std::string m_containerFormat;\n};\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFUtils.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"lavfutils.h\"\n\n#include <sstream>\n\nstatic int64_t get_bit_rate(const AVCodecParameters *par)\n{\n    int64_t bit_rate;\n\n    switch (par->codec_type)\n    {\n    case AVMEDIA_TYPE_VIDEO:\n    case AVMEDIA_TYPE_DATA:\n    case AVMEDIA_TYPE_SUBTITLE:\n    case AVMEDIA_TYPE_ATTACHMENT: bit_rate = par->bit_rate; break;\n    case AVMEDIA_TYPE_AUDIO:\n        bit_rate =\n            par->bit_rate ? par->bit_rate : par->sample_rate * par->ch_layout.nb_channels * av_get_bits_per_sample(par->codec_id);\n        break;\n    default: bit_rate = 0; break;\n    }\n    return bit_rate;\n}\n\nconst char *get_stream_language(const AVStream *pStream)\n{\n    char *lang = nullptr;\n    if (AVDictionaryEntry *dictEntry = av_dict_get(pStream->metadata, \"language\", nullptr, 0))\n    {\n        lang = dictEntry->value;\n    }\n    // Don't bother with undetermined languages (fallback value in some containers)\n    if (lang && strncmp(lang, \"und\", 3))\n        return lang;\n    return nullptr;\n}\n\nstruct s_id_map\n{\n    int id;\n    const char *name;\n};\n\nstruct s_id_map nice_codec_names[] = {\n    // Video\n    {AV_CODEC_ID_H264, \"h264\"}, // XXX: Do not remove, required for custom profile/level formatting\n    {AV_CODEC_ID_HEVC, \"hevc\"}, // XXX: Do not remove, required for custom profile/level formatting\n    {AV_CODEC_ID_VC1, \"vc-1\"},  // XXX: Do not remove, required for custom profile/level formatting\n    {AV_CODEC_ID_MPEG2VIDEO, \"mpeg2\"},\n    // Audio\n    {AV_CODEC_ID_DTS, \"dts\"},\n    {AV_CODEC_ID_AAC_LATM, \"aac (latm)\"},\n    // Subs\n    {AV_CODEC_ID_TEXT, \"txt\"},\n    {AV_CODEC_ID_MOV_TEXT, \"tx3g\"},\n    {AV_CODEC_ID_SRT, \"srt\"},\n    {AV_CODEC_ID_HDMV_PGS_SUBTITLE, \"pgs\"},\n    {AV_CODEC_ID_DVD_SUBTITLE, \"vobsub\"},\n    {AV_CODEC_ID_DVB_SUBTITLE, \"dvbsub\"},\n    {AV_CODEC_ID_SSA, \"ssa/ass\"},\n    {AV_CODEC_ID_XSUB, \"xsub\"},\n};\n\n// Uppercase the given string\nstatic std::string tolower(const char *str)\n{\n    size_t len = strlen(str);\n    std::string ret(len, char());\n    for (size_t i = 0; i < len; ++i)\n    {\n        ret[i] = (str[i] <= 'Z' && str[i] >= 'A') ? str[i] + ('a' - 'A') : str[i];\n    }\n    return ret;\n}\n\nstd::string get_codec_name(const AVCodecParameters *par)\n{\n    AVCodecID id = par->codec_id;\n\n    // Grab the codec\n    const AVCodec *p = avcodec_find_decoder(id);\n    const AVCodecDescriptor *desc = avcodec_descriptor_get(id);\n    const char *profile = avcodec_profile_name(id, par->profile);\n\n    std::ostringstream codec_name;\n\n    const char *nice_name = nullptr;\n    for (int i = 0; i < countof(nice_codec_names); ++i)\n    {\n        if (nice_codec_names[i].id == id)\n        {\n            nice_name = nice_codec_names[i].name;\n            break;\n        }\n    }\n\n    if (id == AV_CODEC_ID_DTS && par->codec_tag == 0xA2)\n    {\n        profile = \"DTS Express\";\n    }\n    else if (id == AV_CODEC_ID_EAC3 && par->profile == AV_PROFILE_EAC3_DDP_ATMOS)\n    {\n        profile = \"atmos\";\n    }\n    else if (id == AV_CODEC_ID_TRUEHD && par->profile == AV_PROFILE_TRUEHD_ATMOS)\n    {\n        profile = \"atmos\";\n    }\n\n    if (id == AV_CODEC_ID_H264 && profile)\n    {\n        codec_name << nice_name << \" \" << tolower(profile);\n        if (par->level && par->level != AV_LEVEL_UNKNOWN && par->level < 1000)\n        {\n            char l_buf[5];\n            sprintf_s(l_buf, \"%.1f\", par->level / 10.0);\n            codec_name << \" L\" << l_buf;\n        }\n    }\n    else if (id == AV_CODEC_ID_HEVC && profile)\n    {\n        codec_name << nice_name << \" \" << tolower(profile);\n        if (par->level && par->level != AV_LEVEL_UNKNOWN && par->level < 1000)\n        {\n            char l_buf[5];\n            sprintf_s(l_buf, \"%.1f\", par->level / 30.0);\n            codec_name << \" L\" << l_buf;\n        }\n    }\n    else if (id == AV_CODEC_ID_VC1 && profile)\n    {\n        codec_name << nice_name << \" \" << tolower(profile);\n        if (par->level != AV_LEVEL_UNKNOWN)\n        {\n            codec_name << \" L\" << par->level;\n        }\n    }\n    else if (id == AV_CODEC_ID_DTS && profile)\n    {\n        codec_name << tolower(profile);\n    }\n    else if (id == AV_CODEC_ID_JPEG2000 && profile)\n    {\n        codec_name << tolower(profile);\n    }\n    else if (nice_name)\n    {\n        codec_name << nice_name;\n        if (profile)\n            codec_name << \" \" << tolower(profile);\n    }\n    else if (desc && desc->name)\n    {\n        codec_name << desc->name;\n        if (profile)\n            codec_name << \" \" << tolower(profile);\n    }\n    else if (p && p->name)\n    {\n        codec_name << p->name;\n        if (profile)\n            codec_name << \" \" << tolower(profile);\n    }\n    else\n    {\n        /* output avi tags */\n        char buf[AV_FOURCC_MAX_STRING_SIZE] = {0};\n        codec_name << av_fourcc_make_string(buf, par->codec_tag);\n        sprintf_s(buf, \"0x%04X\", par->codec_tag);\n        codec_name << \" / \" << buf;\n    }\n    return codec_name.str();\n}\n\n#define SUPPORTED_FLAGS                                                                 \\\n    (AV_DISPOSITION_FORCED | AV_DISPOSITION_DEFAULT | AV_DISPOSITION_HEARING_IMPAIRED | \\\n     AV_DISPOSITION_VISUAL_IMPAIRED | LAVF_DISPOSITION_SUB_STREAM | LAVF_DISPOSITION_SECONDARY_AUDIO)\n\nstatic std::string format_flags(int flags)\n{\n    std::ostringstream out;\n\n#define FLAG_TAG(f, s)  \\\n    if (flags & f)      \\\n    {                   \\\n        if (!first)     \\\n            out << \",\"; \\\n        out << s;       \\\n        first = false;  \\\n    }\n\n    if (flags & SUPPORTED_FLAGS)\n    {\n        bool first = true;\n        out << \" [\";\n        FLAG_TAG(AV_DISPOSITION_DEFAULT, \"default\");\n        FLAG_TAG(AV_DISPOSITION_FORCED, \"forced\");\n        FLAG_TAG(AV_DISPOSITION_HEARING_IMPAIRED, \"hearing impaired\");\n        FLAG_TAG(AV_DISPOSITION_VISUAL_IMPAIRED, \"visual impaired\");\n        FLAG_TAG(LAVF_DISPOSITION_SUB_STREAM, \"sub\");\n        FLAG_TAG(LAVF_DISPOSITION_SECONDARY_AUDIO, \"secondary\");\n        out << \"]\";\n    }\n    return out.str();\n}\n\nstatic bool show_sample_fmt(const AVCodecParameters *par)\n{\n    AVCodecID codec_id = par->codec_id;\n\n    // PCM Codecs\n    if (codec_id >= 0x10000 && codec_id < 0x12000)\n    {\n        return true;\n    }\n    // Lossless Codecs\n    if (codec_id == AV_CODEC_ID_MLP || codec_id == AV_CODEC_ID_TRUEHD || codec_id == AV_CODEC_ID_FLAC ||\n        codec_id == AV_CODEC_ID_WMALOSSLESS || codec_id == AV_CODEC_ID_WAVPACK || codec_id == AV_CODEC_ID_MP4ALS ||\n        codec_id == AV_CODEC_ID_ALAC)\n    {\n        return true;\n    }\n\n    // Lossless DTS\n    if (codec_id == AV_CODEC_ID_DTS && par->profile == AV_PROFILE_DTS_HD_MA)\n        return true;\n\n    return false;\n}\n\nconst char *lavf_get_stream_title(const AVStream *pStream)\n{\n    char *title = nullptr;\n    if (AVDictionaryEntry *dictEntry = av_dict_get(pStream->metadata, \"title\", nullptr, 0))\n    {\n        title = dictEntry->value;\n    }\n    else if (AVDictionaryEntry *dictEntry = av_dict_get(pStream->metadata, \"handler_name\", nullptr, 0))\n    {\n        title = dictEntry->value;\n        if (title && strstr(title, \"Handle\") != nullptr)\n            title = nullptr;\n    }\n\n    return title;\n}\n\nstd::string lavf_get_stream_description(const AVStream *pStream)\n{\n    AVCodecParameters *par = pStream->codecpar;\n\n    std::string codec_name = get_codec_name(par);\n\n    const char *lang = get_stream_language(pStream);\n    std::string sLanguage;\n\n    if (lang)\n    {\n        sLanguage = ProbeLangForLanguage(lang);\n        if (sLanguage.empty())\n        {\n            sLanguage = lang;\n        }\n    }\n\n    const char *title = lavf_get_stream_title(pStream);\n\n    // Empty titles are rather useless\n    if (title && strlen(title) == 0)\n        title = nullptr;\n\n    int64_t bitrate = get_bit_rate(par);\n\n    std::ostringstream buf;\n    switch (par->codec_type)\n    {\n    case AVMEDIA_TYPE_VIDEO:\n        buf << \"V: \";\n        // Title/Language\n        if (title && lang)\n        {\n            buf << title << \" [\" << lang << \"] (\";\n        }\n        else if (title)\n        {\n            // Print either title or lang\n            buf << title << \" (\";\n        }\n        else if (lang)\n        {\n            buf << sLanguage << \" [\" << lang << \"] (\";\n        }\n        // Codec\n        buf << codec_name;\n        // Pixel Format\n        if (const char *pix_fmt = av_get_pix_fmt_name((AVPixelFormat)par->format))\n        {\n            buf << \", \" << pix_fmt;\n        }\n        // Dimensions\n        if (par->width)\n        {\n            buf << \", \" << par->width << \"x\" << par->height;\n        }\n        // Bitrate\n        if (bitrate > 0)\n        {\n            buf << \", \" << (bitrate / 1000) << \" kb/s\";\n        }\n        if (par->codec_id == AV_CODEC_ID_H264 && par->profile == AV_PROFILE_H264_STEREO_HIGH)\n        {\n            AVDictionaryEntry *entry = av_dict_get(pStream->metadata, \"stereo_mode\", nullptr, 0);\n            if (entry && strcmp(entry->value, \"mvc_lr\") == 0)\n                buf << \", lr\";\n            else if (entry && strcmp(entry->value, \"mvc_rl\") == 0)\n                buf << \", rl\";\n        }\n        // Closing tag\n        if (title || lang)\n        {\n            buf << \")\";\n        }\n        buf << format_flags(pStream->disposition);\n        break;\n    case AVMEDIA_TYPE_AUDIO:\n        buf << \"A: \";\n        // Title/Language\n        if (title && lang)\n        {\n            buf << title << \" [\" << lang << \"] (\";\n        }\n        else if (title)\n        {\n            // Print either title or lang\n            buf << title << \" (\";\n        }\n        else if (lang)\n        {\n            buf << sLanguage << \" [\" << lang << \"] (\";\n        }\n        // Codec\n        buf << codec_name;\n        // Sample Rate\n        if (par->sample_rate)\n        {\n            buf << \", \" << par->sample_rate << \" Hz\";\n        }\n        if (par->ch_layout.nb_channels)\n        {\n            // Get channel layout\n            char channel[64] = {0};\n            av_channel_layout_describe(&par->ch_layout, channel, sizeof(channel));\n            buf << \", \" << channel;\n        }\n        // Sample Format\n        if (show_sample_fmt(par) && get_bits_per_sample(par, true))\n        {\n            if (par->format == AV_SAMPLE_FMT_FLT || par->format == AV_SAMPLE_FMT_DBL)\n            {\n                buf << \", fp\";\n            }\n            else\n            {\n                buf << \", s\";\n            }\n            buf << get_bits_per_sample(par, true);\n        }\n        // Bitrate\n        if (bitrate > 0)\n        {\n            buf << \", \" << (bitrate / 1000) << \" kb/s\";\n        }\n        // Closing tag\n        if (title || lang)\n        {\n            buf << \")\";\n        }\n        // Flags\n        buf << format_flags(pStream->disposition);\n        break;\n    case AVMEDIA_TYPE_SUBTITLE:\n        buf << \"S: \";\n        // Title/Language\n        if (title && lang)\n        {\n            buf << title << \" [\" << lang << \"] (\";\n        }\n        else if (title)\n        {\n            // Print either title or lang\n            buf << title << \" (\";\n        }\n        else if (lang)\n        {\n            buf << sLanguage << \" [\" << lang << \"] (\";\n        }\n        // Codec\n        buf << codec_name;\n        if (title || lang)\n        {\n            buf << \")\";\n        }\n        // Subtitle flags\n        buf << format_flags(pStream->disposition);\n        break;\n    default: buf << \"Unknown: Stream #\" << pStream->index; break;\n    }\n\n    return buf.str();\n}\n\nbool GetH264MVCStreamIndices(AVFormatContext *fmt, int *nBaseIndex, int *nExtensionIndex)\n{\n    bool bResult = true;\n    *nBaseIndex = -1;\n    *nExtensionIndex = -1;\n    for (unsigned int i = 0; i < fmt->nb_streams; i++)\n    {\n        AVStream *st = fmt->streams[i];\n\n        if (st->codecpar->codec_id == AV_CODEC_ID_H264_MVC && st->codecpar->extradata_size > 0)\n        {\n            if (*nExtensionIndex == -1)\n                *nExtensionIndex = i;\n            else\n            {\n                DbgLog((LOG_TRACE, 10, L\" -> Multiple H264 MVC extension streams, unsupported.\"));\n                bResult = false;\n            }\n        }\n        else if (st->codecpar->codec_id == AV_CODEC_ID_H264)\n        {\n            if ((st->codecpar->width == 1920 && st->codecpar->height == 1080) ||\n                (st->codecpar->width == 1280 && st->codecpar->height == 720))\n            {\n                if (*nBaseIndex == -1)\n                    *nBaseIndex = i;\n                else\n                {\n                    AVProgram *pBaseProgram = av_find_program_from_stream(fmt, nullptr, *nBaseIndex);\n                    AVProgram *pNewProgram = av_find_program_from_stream(fmt, nullptr, i);\n                    if (!pBaseProgram && pNewProgram)\n                    {\n                        *nBaseIndex = i;\n                        continue;\n                    }\n                    else if (!pNewProgram && pBaseProgram)\n                    {\n                        continue;\n                    }\n\n                    DbgLog((LOG_TRACE, 10, L\" -> Multiple H264 MVC base streams, unsupported.\"));\n                    bResult = false;\n                }\n            }\n        }\n    }\n\n    bResult = bResult && *nBaseIndex >= 0 && *nExtensionIndex >= 0;\n    return bResult;\n}\n\n#ifdef DEBUG\n\n#define LAVF_PARSE_TYPE(x) \\\n    case x: return #x;\nconst char *lavf_get_parsing_string(enum AVStreamParseType parsing)\n{\n    switch (parsing)\n    {\n        LAVF_PARSE_TYPE(AVSTREAM_PARSE_NONE);\n        LAVF_PARSE_TYPE(AVSTREAM_PARSE_FULL);\n        LAVF_PARSE_TYPE(AVSTREAM_PARSE_HEADERS);\n        LAVF_PARSE_TYPE(AVSTREAM_PARSE_TIMESTAMPS);\n        LAVF_PARSE_TYPE(AVSTREAM_PARSE_FULL_ONCE);\n    };\n    return \"unknown\";\n}\n#endif\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFUtils.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\nstruct FormatMapping\n{\n    AVCodecID codec;\n    const GUID *subtype;\n    unsigned codecTag;\n    const GUID *format;\n};\n\nconst char *get_stream_language(const AVStream *pStream);\nstd::string get_codec_name(const AVCodecParameters *par);\nconst char *lavf_get_stream_title(const AVStream *pStream);\nstd::string lavf_get_stream_description(const AVStream *pStream);\n\n#define LAVF_DISPOSITION_SUB_STREAM 0x10000\n#define LAVF_DISPOSITION_SECONDARY_AUDIO 0x20000\n\ninline int get_bits_per_sample(AVCodecParameters *par, bool bRaw = false)\n{\n    int bits = av_get_bits_per_sample(par->codec_id);\n    if (!bits || bRaw)\n    {\n        bits = par->bits_per_coded_sample;\n        if (!bits || bRaw)\n        {\n            if ((par->format == AV_SAMPLE_FMT_S32 || par->format == AV_SAMPLE_FMT_S32P) && par->bits_per_raw_sample)\n            {\n                bits = par->bits_per_raw_sample;\n            }\n            else\n            {\n                bits = av_get_bytes_per_sample((AVSampleFormat)par->format) << 3;\n            }\n        }\n    }\n    return bits;\n}\n\nbool GetH264MVCStreamIndices(AVFormatContext *fmt, int *nBaseIndex, int *nExtensionIndex);\n\n#ifdef DEBUG\nconst char *lavf_get_parsing_string(enum AVStreamParseType parsing);\n#endif\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFVideoHelper.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"LAVFUtils.h\"\n#include \"LAVFVideoHelper.h\"\n#include \"moreuuids.h\"\n#include \"BaseDemuxer.h\"\n\n#include \"ExtradataParser.h\"\n#include \"H264Nalu.h\"\n\n// 250fps is the highest we accept as \"sane\"\n#define MIN_TIME_PER_FRAME 40000\n// 8fps is the lowest that is \"sane\" in our definition\n#define MAX_TIME_PER_FRAME 1250000\n\nCLAVFVideoHelper g_VideoHelper;\n\n// Map codec ids to media subtypes\n// clang-format off\nstatic FormatMapping video_map[] = {\n  { AV_CODEC_ID_H263,       &MEDIASUBTYPE_H263,         0,                      nullptr },\n  { AV_CODEC_ID_H263I,      &MEDIASUBTYPE_I263,         0,                      nullptr },\n  { AV_CODEC_ID_H264,       &MEDIASUBTYPE_AVC1,         0,                      &FORMAT_MPEG2Video },\n  { AV_CODEC_ID_HEVC,       &MEDIASUBTYPE_HEVC,         0,                      &FORMAT_MPEG2Video },\n  { AV_CODEC_ID_MPEG1VIDEO, &MEDIASUBTYPE_MPEG1Payload, 0,                      &FORMAT_MPEGVideo  },\n  { AV_CODEC_ID_MPEG2VIDEO, &MEDIASUBTYPE_MPEG2_VIDEO,  0,                      &FORMAT_MPEG2Video },\n  { AV_CODEC_ID_RV10,       &MEDIASUBTYPE_RV10,         MKTAG('R','V','1','0'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_RV20,       &MEDIASUBTYPE_RV20,         MKTAG('R','V','2','0'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_RV30,       &MEDIASUBTYPE_RV30,         MKTAG('R','V','3','0'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_RV40,       &MEDIASUBTYPE_RV40,         MKTAG('R','V','4','0'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_AMV,        &MEDIASUBTYPE_AMVV,         MKTAG('A','M','V','V'), nullptr },\n  { AV_CODEC_ID_TIFF,       &MEDIASUBTYPE_TIFF,         MKTAG('T','I','F','F'), nullptr },\n  { AV_CODEC_ID_PNG,        &MEDIASUBTYPE_PNG,          MKTAG('P','N','G',' '), nullptr },\n  { AV_CODEC_ID_BMP,        &MEDIASUBTYPE_BMP,          MKTAG('B','M','P',' '), nullptr },\n  { AV_CODEC_ID_GIF,        &MEDIASUBTYPE_GIF,          MKTAG('G','I','F',' '), nullptr },\n  { AV_CODEC_ID_TARGA,      &MEDIASUBTYPE_TGA,          MKTAG('T','G','A',' '), nullptr },\n  { AV_CODEC_ID_VP8,        &MEDIASUBTYPE_VP80,         MKTAG('V','P','8','0'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_VP9,        &MEDIASUBTYPE_VP90,         MKTAG('V','P','9','0'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_AV1,        &MEDIASUBTYPE_AV01,         MKTAG('A','V','0','1'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_CFHD,       &MEDIASUBTYPE_CFHD,         MKTAG('C','F','H','D'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_VVC,        &MEDIASUBTYPE_VVC1,         MKTAG('V','V','C','1'), &FORMAT_MPEG2Video },\n  { AV_CODEC_ID_WEBP,       &MEDIASUBTYPE_WEBP,         MKTAG('W','E','B','P'), &FORMAT_VideoInfo2 },\n  { AV_CODEC_ID_APV,        &MEDIASUBTYPE_APV1,         MKTAG('A','P','V','1'), &FORMAT_VideoInfo2 },\n};\n// clang-format on\n\nCMediaType CLAVFVideoHelper::initVideoType(AVCodecID codecId, unsigned int &codecTag, std::string container)\n{\n    CMediaType mediaType;\n    mediaType.InitMediaType();\n    mediaType.majortype = MEDIATYPE_Video;\n    mediaType.subtype = FOURCCMap(codecTag);\n    mediaType.formattype = FORMAT_VideoInfo; // default value\n\n    // Check against values from the map above\n    for (unsigned i = 0; i < countof(video_map); ++i)\n    {\n        if (video_map[i].codec == codecId)\n        {\n            if (video_map[i].subtype)\n                mediaType.subtype = *video_map[i].subtype;\n            if (video_map[i].codecTag)\n                codecTag = video_map[i].codecTag;\n            if (video_map[i].format)\n                mediaType.formattype = *video_map[i].format;\n            break;\n        }\n    }\n\n    switch (codecId)\n    {\n    // All these codecs should use VideoInfo2\n    case AV_CODEC_ID_ASV1:\n    case AV_CODEC_ID_ASV2:\n    case AV_CODEC_ID_FLV1:\n    case AV_CODEC_ID_HUFFYUV:\n    case AV_CODEC_ID_WMV3: mediaType.formattype = FORMAT_VideoInfo2; break;\n    case AV_CODEC_ID_MPEG4:\n        if (container == \"mp4\")\n        {\n            mediaType.formattype = FORMAT_MPEG2Video;\n        }\n        else if (container == \"mpegts\")\n        {\n            mediaType.formattype = FORMAT_VideoInfo2;\n            mediaType.subtype = MEDIASUBTYPE_MP4V;\n        }\n        else\n        {\n            mediaType.formattype = FORMAT_VideoInfo2;\n        }\n        break;\n    case AV_CODEC_ID_VC1:\n        if (codecTag != MKTAG('W', 'M', 'V', 'A'))\n            codecTag = MKTAG('W', 'V', 'C', '1');\n        mediaType.formattype = FORMAT_VideoInfo2;\n        mediaType.subtype = FOURCCMap(codecTag);\n        break;\n    case AV_CODEC_ID_DVVIDEO:\n        if (codecTag == 0)\n            mediaType.subtype = MEDIASUBTYPE_DVCP;\n        break;\n    }\n\n    return mediaType;\n}\n\nDWORD avc_quant(BYTE *src, BYTE *dst, int extralen)\n{\n    DWORD cb = 0;\n    BYTE *src_end = (BYTE *)src + extralen;\n    BYTE *dst_end = (BYTE *)dst + extralen;\n    src += 5;\n    // Two runs, for sps and pps\n    for (int i = 0; i < 2; i++)\n    {\n        for (int n = *(src++) & 0x1f; n > 0; n--)\n        {\n            unsigned len = (((unsigned)src[0] << 8) | src[1]) + 2;\n            if (src + len > src_end || dst + len > dst_end)\n            {\n                ASSERT(0);\n                break;\n            }\n            memcpy(dst, src, len);\n            src += len;\n            dst += len;\n            cb += len;\n        }\n    }\n    return cb;\n}\n\nsize_t avc_parse_annexb(BYTE *extra, int extrasize, BYTE *dst)\n{\n    size_t dstSize = 0;\n\n    CH264Nalu Nalu;\n    Nalu.SetBuffer(extra, extrasize, 0);\n    while (Nalu.ReadNext())\n    {\n        if (Nalu.GetType() == NALU_TYPE_SPS || Nalu.GetType() == NALU_TYPE_PPS)\n        {\n            size_t len = Nalu.GetDataLength();\n            AV_WB16(dst + dstSize, (uint16_t)len);\n            dstSize += 2;\n            memcpy(dst + dstSize, Nalu.GetDataBuffer(), Nalu.GetDataLength());\n            dstSize += Nalu.GetDataLength();\n        }\n    }\n    return dstSize;\n}\n\nVIDEOINFOHEADER *CLAVFVideoHelper::CreateVIH(const AVStream *avstream, ULONG *size, std::string container)\n{\n    VIDEOINFOHEADER *pvi =\n        (VIDEOINFOHEADER *)CoTaskMemAlloc(ULONG(sizeof(VIDEOINFOHEADER) + avstream->codecpar->extradata_size));\n    if (!pvi)\n        return nullptr;\n    memset(pvi, 0, sizeof(VIDEOINFOHEADER));\n\n    REFERENCE_TIME r_avg = 0, avg_avg = 0, codec_avg = 0;\n    if (avstream->r_frame_rate.den > 0 && avstream->r_frame_rate.num > 0)\n    {\n        r_avg = av_rescale(DSHOW_TIME_BASE, avstream->r_frame_rate.den, avstream->r_frame_rate.num);\n    }\n    if (avstream->avg_frame_rate.den > 0 && avstream->avg_frame_rate.num > 0)\n    {\n        avg_avg = av_rescale(DSHOW_TIME_BASE, avstream->avg_frame_rate.den, avstream->avg_frame_rate.num);\n    }\n    if (avstream->codecpar->framerate.den > 0 && avstream->codecpar->framerate.num > 0)\n    {\n        codec_avg = av_rescale(DSHOW_TIME_BASE, avstream->codecpar->framerate.den, avstream->codecpar->framerate.num);\n    }\n\n    DbgLog((LOG_TRACE, 10, L\"CreateVIH: r_avg: %I64d, avg_avg: %I64d, tb_avg: %I64d\", r_avg, avg_avg, codec_avg));\n    if (avg_avg >= MIN_TIME_PER_FRAME && avg_avg <= MAX_TIME_PER_FRAME)\n    {\n        // prefer the more accurate r_avg when its close to the average\n        if (abs(r_avg - avg_avg) < 10000)\n            pvi->AvgTimePerFrame = r_avg;\n        else\n            pvi->AvgTimePerFrame = avg_avg;\n    }\n    else if (r_avg >= MIN_TIME_PER_FRAME && r_avg <= MAX_TIME_PER_FRAME)\n        pvi->AvgTimePerFrame = r_avg;\n    else if (codec_avg >= MIN_TIME_PER_FRAME && codec_avg <= MAX_TIME_PER_FRAME)\n        pvi->AvgTimePerFrame = codec_avg;\n    else\n        pvi->AvgTimePerFrame = r_avg;\n\n    if ((container == \"matroska\" || container == \"mp4\") && r_avg && codec_avg &&\n        (avstream->codecpar->codec_id == AV_CODEC_ID_H264 || avstream->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO))\n    {\n        float factor = (float)r_avg / (float)codec_avg;\n        if ((factor > 0.4 && factor < 0.6) || (factor > 1.9 && factor < 2.1))\n        {\n            pvi->AvgTimePerFrame = codec_avg;\n        }\n    }\n\n    pvi->dwBitErrorRate = 0;\n    pvi->dwBitRate = (DWORD)avstream->codecpar->bit_rate;\n    RECT empty_tagrect = {0, 0, 0, 0};\n    pvi->rcSource = empty_tagrect; // Some codecs like wmv are setting that value to the video current value\n    pvi->rcTarget = empty_tagrect;\n    pvi->rcTarget.right = pvi->rcSource.right = avstream->codecpar->width;\n    pvi->rcTarget.bottom = pvi->rcSource.bottom = avstream->codecpar->height;\n\n    memcpy((BYTE *)&pvi->bmiHeader + sizeof(BITMAPINFOHEADER), avstream->codecpar->extradata,\n           avstream->codecpar->extradata_size);\n    pvi->bmiHeader.biSize = ULONG(sizeof(BITMAPINFOHEADER) + avstream->codecpar->extradata_size);\n\n    pvi->bmiHeader.biWidth = avstream->codecpar->width;\n    pvi->bmiHeader.biHeight = avstream->codecpar->height;\n    pvi->bmiHeader.biBitCount = avstream->codecpar->bits_per_coded_sample;\n    // Validate biBitCount is set to something useful\n    if ((pvi->bmiHeader.biBitCount == 0 || avstream->codecpar->codec_id == AV_CODEC_ID_RAWVIDEO) &&\n        avstream->codecpar->format != AV_PIX_FMT_NONE)\n    {\n        const AVPixFmtDescriptor *pixdecs = av_pix_fmt_desc_get((AVPixelFormat)avstream->codecpar->format);\n        if (pixdecs)\n            pvi->bmiHeader.biBitCount = av_get_bits_per_pixel(pixdecs);\n    }\n    pvi->bmiHeader.biSizeImage = DIBSIZE(pvi->bmiHeader); // Calculating this value doesn't really make alot of sense,\n                                                          // but apparently some decoders freak out if its 0\n\n    pvi->bmiHeader.biCompression = avstream->codecpar->codec_tag;\n    // TOFIX The bitplanes is depending on the subtype\n    pvi->bmiHeader.biPlanes = 1;\n    pvi->bmiHeader.biClrUsed = 0;\n    pvi->bmiHeader.biClrImportant = 0;\n    pvi->bmiHeader.biYPelsPerMeter = 0;\n    pvi->bmiHeader.biXPelsPerMeter = 0;\n\n    *size = sizeof(VIDEOINFOHEADER) + avstream->codecpar->extradata_size;\n    return pvi;\n}\n\n#define VC1_CODE_RES0 0x00000100\n#define IS_VC1_MARKER(x) (((x) & ~0xFF) == VC1_CODE_RES0)\n\nVIDEOINFOHEADER2 *CLAVFVideoHelper::CreateVIH2(const AVStream *avstream, ULONG *size, std::string container)\n{\n    int extra = 0;\n    BYTE *extradata = nullptr;\n    BOOL bZeroPad = FALSE;\n    if (avstream->codecpar->codec_id == AV_CODEC_ID_VC1 && avstream->codecpar->extradata_size)\n    {\n        int i = 0;\n        for (i = 0; i < (avstream->codecpar->extradata_size - 4); i++)\n        {\n            uint32_t code = AV_RB32(avstream->codecpar->extradata + i);\n            if (IS_VC1_MARKER(code))\n                break;\n        }\n        if (i == 0)\n        {\n            bZeroPad = TRUE;\n        }\n        else if (i > 1)\n        {\n            DbgLog((LOG_TRACE, 10,\n                    L\"CLAVFVideoHelper::CreateVIH2(): VC-1 extradata does not start at position 0/1, but %d\", i));\n        }\n    }\n\n    // Create a VIH that we'll convert\n    VIDEOINFOHEADER *vih = CreateVIH(avstream, size, container);\n    if (!vih)\n        return nullptr;\n\n    if (avstream->codecpar->extradata_size > 0)\n    {\n        extra = avstream->codecpar->extradata_size;\n        // increase extra size by one, because VIH2 requires one 0 byte between header and extra data\n        if (bZeroPad)\n        {\n            extra++;\n        }\n\n        extradata = avstream->codecpar->extradata;\n    }\n\n    VIDEOINFOHEADER2 *vih2 = (VIDEOINFOHEADER2 *)CoTaskMemAlloc(sizeof(VIDEOINFOHEADER2) + extra);\n    if (!vih2)\n        return nullptr;\n    memset(vih2, 0, sizeof(VIDEOINFOHEADER2));\n\n    vih2->rcSource = vih->rcSource;\n    vih2->rcTarget = vih->rcTarget;\n    vih2->dwBitRate = vih->dwBitRate;\n    vih2->dwBitErrorRate = vih->dwBitErrorRate;\n    vih2->AvgTimePerFrame = vih->AvgTimePerFrame;\n\n    // Calculate aspect ratio\n    AVRational r = avstream->sample_aspect_ratio;\n    AVRational rc = avstream->codecpar->sample_aspect_ratio;\n    int num = vih->bmiHeader.biWidth, den = vih->bmiHeader.biHeight;\n    if (r.den > 0 && r.num > 0)\n    {\n        av_reduce(&num, &den, (int64_t)r.num * num, (int64_t)r.den * den, UINT16_MAX);\n    }\n    else if (rc.den > 0 && rc.num > 0)\n    {\n        av_reduce(&num, &den, (int64_t)rc.num * num, (int64_t)rc.den * den, UINT16_MAX);\n    }\n    else\n    {\n        av_reduce(&num, &den, num, den, num);\n    }\n    vih2->dwPictAspectRatioX = num;\n    vih2->dwPictAspectRatioY = den;\n\n    memcpy(&vih2->bmiHeader, &vih->bmiHeader, sizeof(BITMAPINFOHEADER));\n    vih2->bmiHeader.biSize = sizeof(BITMAPINFOHEADER) + extra;\n\n    vih2->dwInterlaceFlags = 0;\n    vih2->dwCopyProtectFlags = 0;\n    vih2->dwControlFlags = 0;\n    vih2->dwReserved2 = 0;\n\n    if (extra)\n    {\n        // The first byte after the infoheader has to be 0 in mpeg-ts\n        if (bZeroPad)\n        {\n            *((BYTE *)vih2 + sizeof(VIDEOINFOHEADER2)) = 0;\n            // after that, the extradata .. size reduced by one again\n            memcpy((BYTE *)vih2 + sizeof(VIDEOINFOHEADER2) + 1, extradata, extra - 1);\n        }\n        else\n        {\n            memcpy((BYTE *)vih2 + sizeof(VIDEOINFOHEADER2), extradata, extra);\n        }\n    }\n\n    // Free the VIH that we converted\n    CoTaskMemFree(vih);\n\n    *size = sizeof(VIDEOINFOHEADER2) + extra;\n    return vih2;\n}\n\nMPEG1VIDEOINFO *CLAVFVideoHelper::CreateMPEG1VI(const AVStream *avstream, ULONG *size, std::string container)\n{\n    int extra = 0;\n    BYTE *extradata = nullptr;\n\n    // Create a VIH that we'll convert\n    VIDEOINFOHEADER *vih = CreateVIH(avstream, size, container);\n    if (!vih)\n        return nullptr;\n\n    if (avstream->codecpar->extradata_size > 0)\n    {\n        extra = avstream->codecpar->extradata_size;\n        extradata = avstream->codecpar->extradata;\n    }\n\n    MPEG1VIDEOINFO *mp1vi = (MPEG1VIDEOINFO *)CoTaskMemAlloc(sizeof(MPEG1VIDEOINFO) + extra);\n    if (!mp1vi)\n        return nullptr;\n    memset(mp1vi, 0, sizeof(MPEG1VIDEOINFO));\n\n    // The MPEG1VI is a thin wrapper around a VIH, so its easy!\n    memcpy(&mp1vi->hdr, vih, sizeof(VIDEOINFOHEADER));\n    mp1vi->hdr.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);\n\n    mp1vi->dwStartTimeCode = 0; // is this not 0 anywhere..?\n    mp1vi->hdr.bmiHeader.biPlanes = 1;\n    mp1vi->hdr.bmiHeader.biCompression = 0;\n\n    // copy extradata over\n    if (extra)\n    {\n        CExtradataParser parser = CExtradataParser(extradata, extra);\n        mp1vi->cbSequenceHeader = (DWORD)parser.ParseMPEGSequenceHeader(mp1vi->bSequenceHeader);\n    }\n\n    // Free the VIH that we converted\n    CoTaskMemFree(vih);\n\n    *size = SIZE_MPEG1VIDEOINFO(mp1vi);\n    return mp1vi;\n}\n\nMPEG2VIDEOINFO *CLAVFVideoHelper::CreateMPEG2VI(const AVStream *avstream, ULONG *size, std::string container,\n                                                BOOL bConvertToAVC1)\n{\n    int extra = 0;\n    BYTE *extradata = nullptr;\n\n    // Create a VIH that we'll convert\n    VIDEOINFOHEADER2 *vih2 = CreateVIH2(avstream, size, container);\n    if (!vih2)\n        return nullptr;\n\n    if (avstream->codecpar->extradata_size > 0)\n    {\n        extra = avstream->codecpar->extradata_size;\n        extradata = avstream->codecpar->extradata;\n    }\n\n    MPEG2VIDEOINFO *mp2vi = (MPEG2VIDEOINFO *)CoTaskMemAlloc(sizeof(MPEG2VIDEOINFO) + max(extra - 4, 0));\n    if (!mp2vi)\n        return nullptr;\n    memset(mp2vi, 0, sizeof(MPEG2VIDEOINFO));\n    memcpy(&mp2vi->hdr, vih2, sizeof(VIDEOINFOHEADER2));\n    mp2vi->hdr.bmiHeader.biSize = sizeof(BITMAPINFOHEADER);\n\n    // Set profile/level if we know them\n    mp2vi->dwProfile = (avstream->codecpar->profile != AV_PROFILE_UNKNOWN) ? avstream->codecpar->profile : 0;\n    mp2vi->dwLevel = (avstream->codecpar->level != AV_LEVEL_UNKNOWN) ? avstream->codecpar->level : 0;\n    // mp2vi->dwFlags = 4; // where do we get flags otherwise..?\n\n    if (extra > 0)\n    {\n        BOOL bCopyUntouched = FALSE;\n        if (avstream->codecpar->codec_id == AV_CODEC_ID_H264)\n        {\n            int ret = ProcessH264Extradata(extradata, extra, mp2vi, bConvertToAVC1);\n            if (ret < 0)\n                bCopyUntouched = TRUE;\n        }\n        else if (avstream->codecpar->codec_id == AV_CODEC_ID_HEVC)\n        {\n            int ret = ProcessHEVCExtradata(extradata, extra, mp2vi);\n            if (ret < 0)\n                bCopyUntouched = TRUE;\n        }\n        else if (avstream->codecpar->codec_id == AV_CODEC_ID_VVC)\n        {\n            int ret = ProcessVVCExtradata(extradata, extra, mp2vi);\n            if (ret < 0)\n                bCopyUntouched = TRUE;\n        }\n        else if (avstream->codecpar->codec_id == AV_CODEC_ID_MPEG2VIDEO)\n        {\n            CExtradataParser parser = CExtradataParser(extradata, extra);\n            mp2vi->cbSequenceHeader = (DWORD)parser.ParseMPEGSequenceHeader((BYTE *)&mp2vi->dwSequenceHeader[0]);\n            mp2vi->hdr.bmiHeader.biPlanes = 1;\n            mp2vi->hdr.bmiHeader.biCompression = 0;\n        }\n        else\n        {\n            bCopyUntouched = TRUE;\n        }\n        if (bCopyUntouched)\n        {\n            mp2vi->cbSequenceHeader = extra;\n            memcpy(&mp2vi->dwSequenceHeader[0], extradata, extra);\n        }\n    }\n\n    // Free the VIH2 that we converted\n    CoTaskMemFree(vih2);\n\n    *size = SIZE_MPEG2VIDEOINFO(mp2vi);\n    return mp2vi;\n}\n\nHRESULT CLAVFVideoHelper::ProcessH264Extradata(BYTE *extradata, int extradata_size, MPEG2VIDEOINFO *mp2vi, BOOL bAnnexB)\n{\n    if (*(char *)extradata == 1)\n    {\n        if (extradata[1])\n            mp2vi->dwProfile = extradata[1];\n        if (extradata[3])\n            mp2vi->dwLevel = extradata[3];\n        mp2vi->dwFlags = (extradata[4] & 3) + 1;\n        mp2vi->cbSequenceHeader = avc_quant(extradata, (BYTE *)(&mp2vi->dwSequenceHeader[0]), extradata_size);\n    }\n    else\n    {\n        // MPEG-TS gets converted for improved compat.. for now!\n        if (bAnnexB)\n        {\n            mp2vi->dwFlags = 4;\n            mp2vi->cbSequenceHeader =\n                (DWORD)avc_parse_annexb(extradata, extradata_size, (BYTE *)(&mp2vi->dwSequenceHeader[0]));\n        }\n        else\n        {\n            return -1;\n        }\n    }\n    return 0;\n}\n\nHRESULT CLAVFVideoHelper::ProcessH264MVCExtradata(BYTE *extradata, int extradata_size, MPEG2VIDEOINFO *mp2vi)\n{\n    if (*(char *)extradata == 1)\n    {\n        // Find \"mvcC\" atom\n        uint32_t state = -1;\n        int i = 0;\n        for (; i < extradata_size; i++)\n        {\n            state = (state << 8) | extradata[i];\n            if (state == MKBETAG('m', 'v', 'c', 'C'))\n                break;\n        }\n\n        if (i == extradata_size || i < 8)\n            return E_FAIL;\n\n        // Update pointers to the start of the mvcC atom\n        extradata = extradata + i - 7;\n        extradata_size = extradata_size - i + 7;\n        int sizeAtom = AV_RB32(extradata);\n\n        // verify size atom and actual size\n        if ((sizeAtom + 4) > extradata_size || extradata_size < 14)\n            return E_FAIL;\n\n        // Skip atom headers\n        extradata += 8;\n        extradata_size -= 8;\n\n        // Process as a normal \"avcC\" record\n        ProcessH264Extradata(extradata, extradata_size, mp2vi, FALSE);\n\n        return S_OK;\n    }\n    return E_FAIL;\n}\n\nHRESULT CLAVFVideoHelper::ProcessHEVCExtradata(BYTE *extradata, int extradata_size, MPEG2VIDEOINFO *mp2vi)\n{\n    if (extradata[0] || extradata[1] || extradata[2] > 1 && extradata_size > 25)\n    {\n        mp2vi->dwFlags = (extradata[21] & 3) + 1;\n    }\n    return -1;\n}\n\nHRESULT CLAVFVideoHelper::ProcessVVCExtradata(BYTE *extradata, int extradata_size, MPEG2VIDEOINFO *mp2vi)\n{\n    if (extradata[0] || extradata[1] || extradata[2] > 1 && extradata_size > 25)\n    {\n        mp2vi->dwFlags = (extradata[21] & 3) + 1;\n    }\n    return -1;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/LAVFVideoHelper.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#pragma once\n\n#include \"dvdmedia.h\"\n\n// clang-format off\nconst AVCodecTag mp_bmp_tags[] = {\n  { AV_CODEC_ID_AMV,               MKTAG('A', 'M', 'V', 'V')},\n  { AV_CODEC_ID_BETHSOFTVID,       MKTAG('B', 'E', 'T', 'H')},\n  { AV_CODEC_ID_BFI,               MKTAG('B', 'F', 'I', 'V')},\n  { AV_CODEC_ID_C93,               MKTAG('C', '9', '3', 'V')},\n  { AV_CODEC_ID_CDGRAPHICS,        MKTAG('C', 'D', 'G', 'R')},\n  { AV_CODEC_ID_DNXHD,             MKTAG('A', 'V', 'd', 'n')},\n  { AV_CODEC_ID_DSICINVIDEO,       MKTAG('D', 'C', 'I', 'V')},\n  { AV_CODEC_ID_DXA,               MKTAG('D', 'X', 'A', '1')},\n  { AV_CODEC_ID_FLIC,              MKTAG('F', 'L', 'I', 'C')},\n  { AV_CODEC_ID_IDCIN,             MKTAG('I', 'D', 'C', 'I')},\n  { AV_CODEC_ID_INTERPLAY_VIDEO,   MKTAG('I', 'N', 'P', 'V')},\n  { AV_CODEC_ID_MDEC,              MKTAG('M', 'D', 'E', 'C')},\n  { AV_CODEC_ID_MOTIONPIXELS,      MKTAG('M', 'V', 'I', '1')},\n  { AV_CODEC_ID_NUV,               MKTAG('N', 'U', 'V', '1')},\n  { AV_CODEC_ID_RL2,               MKTAG('R', 'L', '2', 'V')},\n  { AV_CODEC_ID_ROQ,               MKTAG('R', 'o', 'Q', 'V')},\n  { AV_CODEC_ID_RV10,              MKTAG('R', 'V', '1', '0')},\n  { AV_CODEC_ID_RV20,              MKTAG('R', 'V', '2', '0')},\n  { AV_CODEC_ID_RV30,              MKTAG('R', 'V', '3', '0')},\n  { AV_CODEC_ID_RV40,              MKTAG('R', 'V', '4', '0')},\n  { AV_CODEC_ID_TGV,               MKTAG('f', 'V', 'G', 'T')},\n  { AV_CODEC_ID_THP,               MKTAG('T', 'H', 'P', 'V')},\n  { AV_CODEC_ID_TIERTEXSEQVIDEO,   MKTAG('T', 'S', 'E', 'Q')},\n  { AV_CODEC_ID_TXD,               MKTAG('T', 'X', 'D', 'V')},\n  { AV_CODEC_ID_VP6A,              MKTAG('V', 'P', '6', 'A')},\n  { AV_CODEC_ID_VMDVIDEO,          MKTAG('V', 'M', 'D', 'V')},\n  { AV_CODEC_ID_WS_VQA,            MKTAG('V', 'Q', 'A', 'V')},\n  { AV_CODEC_ID_XAN_WC3,           MKTAG('W', 'C', '3', 'V')},\n  { AV_CODEC_ID_WEBP,              MKTAG('W', 'E', 'B', 'P')},\n  { AV_CODEC_ID_NONE,              0}\n};\n// clang-format on\n\nconst struct AVCodecTag *const mp_bmp_taglists[] = {avformat_get_riff_video_tags(), mp_bmp_tags, 0};\n\nclass CLAVFVideoHelper\n{\n  public:\n    CLAVFVideoHelper(){};\n    CMediaType initVideoType(AVCodecID codecId, unsigned int &codecTag, std::string container);\n\n    VIDEOINFOHEADER *CreateVIH(const AVStream *avstream, ULONG *size, std::string container);\n    VIDEOINFOHEADER2 *CreateVIH2(const AVStream *avstream, ULONG *size, std::string container);\n    MPEG1VIDEOINFO *CreateMPEG1VI(const AVStream *avstream, ULONG *size, std::string container);\n    MPEG2VIDEOINFO *CreateMPEG2VI(const AVStream *avstream, ULONG *size, std::string container,\n                                  BOOL bConvertToAVC1 = FALSE);\n\n    HRESULT ProcessH264Extradata(BYTE *extradata, int extradata_size, MPEG2VIDEOINFO *mp2vi, BOOL bConvertToAVC1);\n    HRESULT ProcessH264MVCExtradata(BYTE *extradata, int extradata_size, MPEG2VIDEOINFO *mp2vi);\n    HRESULT ProcessHEVCExtradata(BYTE *extradata, int extradata_size, MPEG2VIDEOINFO *mp2vi);\n    HRESULT ProcessVVCExtradata(BYTE *extradata, int extradata_size, MPEG2VIDEOINFO *mp2vi);\n};\n\nextern CLAVFVideoHelper g_VideoHelper;\n"
  },
  {
    "path": "demuxer/Demuxers/Packet.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include <stdafx.h>\n#include \"Packet.h\"\n\nPacket::Packet()\n{\n}\n\nPacket::~Packet()\n{\n    DeleteMediaType(pmt);\n    av_packet_free(&m_Packet);\n}\n\nint Packet::SetDataSize(int len)\n{\n    if (len < 0)\n        return -1;\n\n    if (len <= GetDataSize())\n    {\n        av_shrink_packet(m_Packet, len);\n        return 0;\n    }\n\n    if (!m_Packet)\n    {\n        m_Packet = av_packet_alloc();\n        if (av_new_packet(m_Packet, len) < 0)\n            return -1;\n    }\n    else\n    {\n        if (av_grow_packet(m_Packet, (len - m_Packet->size)) < 0)\n            return -1;\n    }\n\n    return 0;\n}\n\nint Packet::SetData(const void *ptr, int len)\n{\n    if (!ptr || len < 0)\n        return -1;\n    int ret = SetDataSize(len);\n    if (ret < 0)\n        return ret;\n\n    memcpy(m_Packet->data, ptr, len);\n    return 0;\n}\n\nint Packet::SetPacket(AVPacket *pkt)\n{\n    ASSERT(!m_Packet);\n\n    m_Packet = av_packet_alloc();\n    if (!m_Packet)\n        return -1;\n\n    return av_packet_ref(m_Packet, pkt);\n}\n\nint Packet::Append(Packet *ptr)\n{\n    return AppendData(ptr->GetData(), ptr->GetDataSize());\n}\n\nint Packet::AppendData(const void *ptr, int len)\n{\n    int prevSize = GetDataSize();\n    int ret = SetDataSize(prevSize + len);\n    if (ret < 0)\n        return ret;\n    memcpy(m_Packet->data + prevSize, ptr, len);\n    return 0;\n}\n\nint Packet::RemoveHead(int count)\n{\n    m_Packet->data += count;\n    m_Packet->size -= (int)count;\n    return 0;\n}\n\nbool Packet::CopyProperties(const Packet *src)\n{\n    StreamId = src->StreamId;\n    bDiscontinuity = src->bDiscontinuity;\n    bSyncPoint = src->bSyncPoint;\n    bPosition = src->bPosition;\n    rtStart = src->rtStart;\n    rtStop = src->rtStop;\n    rtPTS = src->rtPTS;\n    rtDTS = src->rtDTS;\n    if (src->pmt)\n        pmt = CreateMediaType(src->pmt);\n    dwFlags = src->dwFlags;\n\n    return true;\n}\n"
  },
  {
    "path": "demuxer/Demuxers/Packet.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n// Data Packet for queue storage\nclass Packet\n{\n  public:\n    static const REFERENCE_TIME INVALID_TIME = _I64_MIN;\n\n    Packet();\n    ~Packet();\n\n    int GetDataSize() const { return m_Packet ? m_Packet->size : 0; }\n    BYTE *GetData() { return m_Packet ? m_Packet->data : nullptr; }\n\n    int GetNumSideData() const { return m_Packet ? m_Packet->side_data_elems : 0; }\n    AVPacketSideData *GetSideData() { return m_Packet ? m_Packet->side_data : nullptr; }\n\n    int SetDataSize(int len);\n    int SetData(const void *ptr, int len);\n    int SetPacket(AVPacket *pkt);\n\n    // Append the data of the package to our data buffer\n    int Append(Packet *ptr);\n    int AppendData(const void *ptr, int len);\n    // Remove count bytes from position index\n    int RemoveHead(int count);\n\n    bool CopyProperties(const Packet *src);\n\n  public:\n    DWORD StreamId = 0;\n    BOOL bDiscontinuity = FALSE;\n    BOOL bSyncPoint = FALSE;\n    LONGLONG bPosition = -1;\n\n    REFERENCE_TIME rtStart = INVALID_TIME;\n    REFERENCE_TIME rtStop = INVALID_TIME;\n\n    REFERENCE_TIME rtPTS = INVALID_TIME;\n    REFERENCE_TIME rtDTS = INVALID_TIME;\n\n    AM_MEDIA_TYPE *pmt = nullptr;\n\n#define LAV_PACKET_PARSED 0x0001\n#define LAV_PACKET_MOV_TEXT 0x0002\n#define LAV_PACKET_FORCED_SUBTITLE 0x0004\n#define LAV_PACKET_H264_ANNEXB 0x0008\n#define LAV_PACKET_SRT 0x0010\n#define LAV_PACKET_PLANAR_PCM 0x0020\n    DWORD dwFlags = 0;\n\n  private:\n    AVPacket *m_Packet = nullptr;\n};\n"
  },
  {
    "path": "demuxer/Demuxers/StreamInfo.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n#include \"stdafx.h\"\n#include \"StreamInfo.h\"\n\nCStreamInfo::CStreamInfo()\n{\n}\n\nCStreamInfo::~CStreamInfo()\n{\n}\n"
  },
  {
    "path": "demuxer/Demuxers/StreamInfo.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <deque>\n\nclass CStreamInfo\n{\n  public:\n    CStreamInfo();\n    virtual ~CStreamInfo();\n\n    std::deque<CMediaType> mtypes;\n    std::string codecInfo;\n};\n"
  },
  {
    "path": "demuxer/Demuxers/stdafx.cpp",
    "content": "// stdafx.cpp : source file that includes just the standard includes\n// Demuxers.pch will be the pre-compiled header\n// stdafx.obj will contain the pre-compiled type information\n\n#include \"stdafx.h\"\n\n// TODO: reference any additional headers you need in STDAFX.H\n// and not in this file\n"
  },
  {
    "path": "demuxer/Demuxers/stdafx.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"common_defines.h\"\n\n#include <atlbase.h>\n#include <atlconv.h>\n\n#include \"streams.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4244)\nextern \"C\"\n{\n#define __STDC_CONSTANT_MACROS\n#include \"libavcodec/avcodec.h\"\n#include \"libavformat/avformat.h\"\n#include \"libavutil/channel_layout.h\"\n#include \"libavutil/display.h\"\n#include \"libavutil/intreadwrite.h\"\n#include \"libavutil/pixdesc.h\"\n#include \"libavutil/opt.h\"\n\n#include \"libbluray/bluray.h\"\n#include \"libbluray/bdnav/clpi_parse.h\"\n}\n#pragma warning(pop)\n\n#define AVFORMAT_INTERNAL_H\ntypedef struct AVCodecTag\n{\n    enum AVCodecID id;\n    unsigned int tag;\n} AVCodecTag;\n\n#include \"util/log_control.h\"\n\n#include \"DShowUtil.h\"\n#include <MMReg.h>\n\n#include <Shlwapi.h>\n\n// TODO: reference additional headers your program requires here\n"
  },
  {
    "path": "demuxer/LAVSplitter/InputPin.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"InputPin.h\"\n\n#include \"LAVSplitter.h\"\n\n#define READ_BUFFER_SIZE 131072\n\nCLAVInputPin::CLAVInputPin(TCHAR *pName, CLAVSplitter *pFilter, CCritSec *pLock, HRESULT *phr)\n    : CBasePin(pName, pFilter, pLock, phr, L\"Input\", PINDIR_INPUT)\n{\n}\n\nCLAVInputPin::~CLAVInputPin(void)\n{\n    if (m_pAVIOContext)\n    {\n        av_free(m_pAVIOContext->buffer);\n        av_free(m_pAVIOContext);\n        m_pAVIOContext = nullptr;\n    }\n}\n\nSTDMETHODIMP CLAVInputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    return __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\nHRESULT CLAVInputPin::CheckMediaType(const CMediaType *pmt)\n{\n    // return pmt->majortype == MEDIATYPE_Stream ? S_OK : VFW_E_TYPE_NOT_ACCEPTED;\n    return S_OK;\n}\n\nHRESULT CLAVInputPin::CheckConnect(IPin *pPin)\n{\n    HRESULT hr;\n    if (FAILED(hr = __super::CheckConnect(pPin)))\n    {\n        return hr;\n    }\n\n    IAsyncReader *pReader = nullptr;\n    if (FAILED(hr = pPin->QueryInterface(&pReader)) || pReader == nullptr)\n    {\n        return E_FAIL;\n    }\n\n    SafeRelease(&pReader);\n\n    return S_OK;\n}\n\nHRESULT CLAVInputPin::BreakConnect()\n{\n    HRESULT hr;\n\n    if (FAILED(hr = __super::BreakConnect()))\n    {\n        return hr;\n    }\n\n    if (FAILED(hr = (static_cast<CLAVSplitter *>(m_pFilter))->BreakInputConnection()))\n    {\n        return hr;\n    }\n\n    SafeRelease(&m_pAsyncReader);\n    SafeRelease(&m_pStreamControl);\n\n    if (m_pAVIOContext)\n    {\n        av_free(m_pAVIOContext->buffer);\n        av_free(m_pAVIOContext);\n        m_pAVIOContext = nullptr;\n    }\n\n    return S_OK;\n}\n\nHRESULT CLAVInputPin::CompleteConnect(IPin *pPin)\n{\n    HRESULT hr;\n\n    if (FAILED(hr = __super::CompleteConnect(pPin)))\n    {\n        return hr;\n    }\n\n    CheckPointer(pPin, E_POINTER);\n    if (FAILED(hr = pPin->QueryInterface(&m_pAsyncReader)) || m_pAsyncReader == nullptr)\n    {\n        return E_FAIL;\n    }\n\n    m_llPos = 0;\n    m_bURLSource = false;\n\n    if (FAILED(pPin->QueryInterface(&m_pStreamControl)))\n        m_pStreamControl = nullptr;\n\n    PIN_INFO pinInfo = {0};\n    if (SUCCEEDED(pPin->QueryPinInfo(&pinInfo)) && pinInfo.pFilter)\n    {\n        CLSID clsidFilter = GUID_NULL;\n        if (SUCCEEDED(pinInfo.pFilter->GetClassID(&clsidFilter)))\n        {\n            m_bURLSource = (clsidFilter == CLSID_URLReader);\n        }\n\n        if (m_pStreamControl == nullptr)\n            if (FAILED(pinInfo.pFilter->QueryInterface(&m_pStreamControl)))\n                m_pStreamControl = nullptr;\n\n        SafeRelease(&(pinInfo.pFilter));\n    }\n\n    if (FAILED(hr = (static_cast<CLAVSplitter *>(m_pFilter))->CompleteInputConnection()))\n    {\n        return hr;\n    }\n\n    return S_OK;\n}\n\nint CLAVInputPin::Read(void *opaque, uint8_t *buf, int buf_size)\n{\n    CLAVInputPin *pin = static_cast<CLAVInputPin *>(opaque);\n    CAutoLock lock(pin);\n\n    // The URL source doesn't properly signal EOF in all cases, so make sure no stale data is in the buffer\n    if (pin->m_bURLSource)\n        memset(buf, 0, buf_size);\n\n    HRESULT hr = pin->m_pAsyncReader->SyncRead(pin->m_llPos, buf_size, buf);\n    if (FAILED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"Read failed at pos: %I64d, hr: 0x%X\", pin->m_llPos, hr));\n        return AVERROR_EOF;\n    }\n\n    // The URL source can return S_OK even on incomplete reads, so run the length logic by it at all times\n    if (hr == S_OK && pin->m_bURLSource)\n    {\n        LONGLONG total = 0, available = 0;\n        int read = buf_size;\n        if (S_OK == pin->m_pAsyncReader->Length(&total, &available) && total >= pin->m_llPos &&\n            total <= (pin->m_llPos + buf_size))\n        {\n            read = (int)(total - pin->m_llPos);\n            DbgLog((LOG_TRACE, 10, L\"At EOF, pos: %I64d, size: %I64d, remainder: %d\", pin->m_llPos, total, read));\n        }\n        pin->m_llPos += read;\n        return read > 0 ? read : AVERROR_EOF;\n    }\n\n    if (hr == S_FALSE)\n    {\n        LONGLONG total = 0, available = 0;\n        int read = 0;\n        if (S_OK == pin->m_pAsyncReader->Length(&total, &available) && total >= pin->m_llPos &&\n            total <= (pin->m_llPos + buf_size))\n        {\n            read = (int)(total - pin->m_llPos);\n            DbgLog((LOG_TRACE, 10, L\"At EOF, pos: %I64d, size: %I64d, remainder: %d\", pin->m_llPos, total, read));\n        }\n        else\n        {\n            DbgLog((LOG_TRACE, 10, L\"We're at EOF (pos: %I64d), but Length seems unreliable, trying reading manually\",\n                    pin->m_llPos));\n            do\n            {\n                hr = pin->m_pAsyncReader->SyncRead(pin->m_llPos, 1, buf + read);\n            } while (hr == S_OK && (++read) < buf_size);\n            DbgLog((LOG_TRACE, 10, L\"-> Read %d bytes\", read));\n        }\n        pin->m_llPos += read;\n        return read > 0 ? read : AVERROR_EOF;\n    }\n    pin->m_llPos += buf_size;\n    return buf_size;\n}\n\nint64_t CLAVInputPin::Seek(void *opaque, int64_t offset, int whence)\n{\n    CLAVInputPin *pin = static_cast<CLAVInputPin *>(opaque);\n    CAutoLock lock(pin);\n\n    LONGLONG total = 0;\n    LONGLONG available = 0;\n    pin->m_pAsyncReader->Length(&total, &available);\n\n    if (whence == SEEK_SET)\n    {\n        pin->m_llPos = offset;\n    }\n    else if (whence == SEEK_CUR)\n    {\n        pin->m_llPos += offset;\n    }\n    else if (whence == SEEK_END)\n    {\n        pin->m_llPos = total - offset;\n    }\n    else if (whence == AVSEEK_SIZE)\n    {\n        return total;\n    }\n    else\n        return -1;\n\n    if (pin->m_llPos > available)\n        pin->m_llPos = available;\n    else if (pin->m_llPos < 0)\n        pin->m_llPos = 0;\n\n    return pin->m_llPos;\n}\n\nHRESULT CLAVInputPin::GetAVIOContext(AVIOContext **ppContext)\n{\n    CheckPointer(m_pAsyncReader, E_UNEXPECTED);\n    CheckPointer(ppContext, E_POINTER);\n\n    if (!m_pAVIOContext)\n    {\n        uint8_t *buffer = (uint8_t *)av_mallocz(READ_BUFFER_SIZE + AV_INPUT_BUFFER_PADDING_SIZE);\n        m_pAVIOContext = avio_alloc_context(buffer, READ_BUFFER_SIZE, 0, this, Read, nullptr, Seek);\n\n        LONGLONG total = 0;\n        LONGLONG available = 0;\n        HRESULT hr = m_pAsyncReader->Length(&total, &available);\n        if (FAILED(hr) || total == 0)\n        {\n            DbgLog((LOG_TRACE, 10, L\"CLAVInputPin::GetAVIOContext(): getting file length failed, disabling seeking\"));\n            m_pAVIOContext->seekable = 0;\n            m_pAVIOContext->seek = nullptr;\n            m_pAVIOContext->buffer_size = READ_BUFFER_SIZE / 4;\n        }\n    }\n    *ppContext = m_pAVIOContext;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVInputPin::BeginFlush()\n{\n    return E_UNEXPECTED;\n}\n\nSTDMETHODIMP CLAVInputPin::EndFlush()\n{\n    return E_UNEXPECTED;\n}\n\nSTDMETHODIMP CLAVInputPin::SeekStream(REFERENCE_TIME rtPosition)\n{\n    CheckPointer(m_pStreamControl, E_NOTIMPL);\n    HRESULT hr = m_pStreamControl->SeekStream(rtPosition);\n    if (SUCCEEDED(hr))\n    {\n        // flush the avio context to remove any buffered data\n        if (m_pAVIOContext)\n        {\n            avio_flush(m_pAVIOContext);\n            m_pAVIOContext->pos = 0;\n        }\n    }\n\n    return hr;\n}\n"
  },
  {
    "path": "demuxer/LAVSplitter/InputPin.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"IStreamSourceControl.h\"\n\nclass CLAVSplitter;\n\nclass CLAVInputPin\n    : public CBasePin\n    , public CCritSec\n    , public IStreamSourceControl\n{\n  public:\n    CLAVInputPin(TCHAR *pName, CLAVSplitter *pFilter, CCritSec *pLock, HRESULT *phr);\n    ~CLAVInputPin(void);\n\n    HRESULT GetAVIOContext(AVIOContext **ppContext);\n\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    HRESULT CheckMediaType(const CMediaType *pmt);\n    HRESULT CheckConnect(IPin *pPin);\n    HRESULT BreakConnect();\n    HRESULT CompleteConnect(IPin *pPin);\n\n    STDMETHODIMP BeginFlush();\n    STDMETHODIMP EndFlush();\n\n    CMediaType &CurrentMediaType() { return m_mt; }\n\n    // IStreamSourceControl\n    STDMETHODIMP GetStreamDuration(REFERENCE_TIME *prtDuration)\n    {\n        CheckPointer(m_pStreamControl, E_NOTIMPL);\n        return m_pStreamControl->GetStreamDuration(prtDuration);\n    }\n    STDMETHODIMP SeekStream(REFERENCE_TIME rtPosition);\n\n  protected:\n    static int Read(void *opaque, uint8_t *buf, int buf_size);\n    static int64_t Seek(void *opaque, int64_t offset, int whence);\n\n    LONGLONG m_llPos = 0;\n\n  private:\n    IAsyncReader *m_pAsyncReader = nullptr;\n    AVIOContext *m_pAVIOContext = nullptr;\n\n    IStreamSourceControl *m_pStreamControl = nullptr;\n\n    BOOL m_bURLSource = false;\n};\n"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitter.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"LAVSplitter.h\"\n#include \"OutputPin.h\"\n#include \"InputPin.h\"\n\n#include \"BaseDemuxer.h\"\n#include \"LAVFDemuxer.h\"\n#include \"BDDemuxer.h\"\n\n#include <Shlwapi.h>\n#include <string>\n#include <regex>\n#include <algorithm>\n\n#include \"registry.h\"\n\n#include \"IGraphRebuildDelegate.h\"\n\nCLAVSplitter::CLAVSplitter(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseFilter(NAME(\"lavf dshow source filter\"), pUnk, this, __uuidof(this), phr)\n{\n    WCHAR fileName[1024];\n    GetModuleFileName(nullptr, fileName, 1024);\n    m_processName = PathFindFileName(fileName);\n\n    m_InputFormats.clear();\n\n    std::set<FormatInfo> lavf_formats = CLAVFDemuxer::GetFormatList();\n    m_InputFormats.insert(lavf_formats.begin(), lavf_formats.end());\n\n    LoadSettings();\n\n    m_pInput = new CLAVInputPin(NAME(\"LAV Input Pin\"), this, this, phr);\n\n    m_ePlaybackInit.Set();\n\n#ifdef DEBUG\n    DbgSetModuleLevel(LOG_TRACE, DWORD_MAX);\n    DbgSetModuleLevel(LOG_ERROR, DWORD_MAX);\n#endif\n}\n\nCLAVSplitter::~CLAVSplitter()\n{\n    SAFE_DELETE(m_pInput);\n    SAFE_DELETE(m_pTrayIcon);\n    Close();\n\n    // delete old pins\n    for (CLAVOutputPin *pPin : m_pRetiredPins)\n    {\n        delete pPin;\n    }\n    m_pRetiredPins.clear();\n\n    SafeRelease(&m_pSite);\n}\n\nSTDMETHODIMP CLAVSplitter::Close()\n{\n    CAutoLock cAutoLock(this);\n\n    AbortOperation();\n    CAMThread::CallWorker(CMD_EXIT);\n    CAMThread::Close();\n\n    m_State = State_Stopped;\n    DeleteOutputs();\n\n    SafeRelease(&m_pDemuxer);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::CreateTrayIcon()\n{\n    CAutoLock cObjectLock(m_pLock);\n    if (m_pTrayIcon)\n        return E_UNEXPECTED;\n    if (CBaseTrayIcon::ProcessBlackList())\n        return S_FALSE;\n    m_pTrayIcon = new CLAVSplitterTrayIcon(this, TEXT(LAV_SPLITTER), IDI_ICON1);\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName)\n{\n    CAutoLock cObjectLock(m_pLock);\n    HRESULT hr = __super::JoinFilterGraph(pGraph, pName);\n    if (pGraph && !m_pTrayIcon && m_settings.TrayIcon)\n    {\n        CreateTrayIcon();\n    }\n    else if (!pGraph && m_pTrayIcon)\n    {\n        SAFE_DELETE(m_pTrayIcon);\n    }\n    return hr;\n}\n\n// Default overrides for input formats\nstatic BOOL get_iformat_default(std::string name)\n{\n    return TRUE;\n}\n\nSTDMETHODIMP CLAVSplitter::LoadDefaults()\n{\n    m_settings.TrayIcon = FALSE;\n\n    m_settings.prefAudioLangs = L\"\";\n    m_settings.prefSubLangs = L\"\";\n    m_settings.subtitleAdvanced = L\"\";\n\n    m_settings.subtitleMode = LAVSubtitleMode_Default;\n    m_settings.PGSForcedStream = TRUE;\n    m_settings.PGSOnlyForced = FALSE;\n\n    m_settings.vc1Mode = 2;\n    m_settings.substreams = TRUE;\n\n    m_settings.MatroskaExternalSegments = TRUE;\n\n    m_settings.StreamSwitchReselectSubs = FALSE;\n    m_settings.StreamSwitchRemoveAudio = FALSE;\n    m_settings.ImpairedAudio = FALSE;\n    m_settings.PreferHighQualityAudio = TRUE;\n    m_settings.QueueMaxPackets = 350;\n    m_settings.QueueMaxMemSize = 256;\n    m_settings.NetworkAnalysisDuration = 1000;\n\n    for (const FormatInfo &fmt : m_InputFormats)\n    {\n        m_settings.formats[std::string(fmt.strName)] = get_iformat_default(fmt.strName);\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::LoadSettings()\n{\n    LoadDefaults();\n    if (m_bRuntimeConfig)\n        return S_FALSE;\n\n    ReadSettings(HKEY_LOCAL_MACHINE);\n    return ReadSettings(HKEY_CURRENT_USER);\n}\n\nSTDMETHODIMP CLAVSplitter::ReadSettings(HKEY rootKey)\n{\n    HRESULT hr;\n    DWORD dwVal;\n    BOOL bFlag;\n    std::wstring strVal;\n\n    CRegistry reg = CRegistry(rootKey, LAVF_REGISTRY_KEY, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        bFlag = reg.ReadBOOL(L\"TrayIcon\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.TrayIcon = bFlag;\n\n        // Language preferences\n        strVal = reg.ReadString(L\"prefAudioLangs\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.prefAudioLangs = strVal;\n\n        strVal = reg.ReadString(L\"prefSubLangs\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.prefSubLangs = strVal;\n\n        strVal = reg.ReadString(L\"subtitleAdvanced\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.subtitleAdvanced = strVal;\n\n        // Subtitle mode, defaults to all subtitles\n        dwVal = reg.ReadDWORD(L\"subtitleMode\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.subtitleMode = (LAVSubtitleMode)dwVal;\n\n        bFlag = reg.ReadBOOL(L\"PGSForcedStream\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.PGSForcedStream = bFlag;\n\n        bFlag = reg.ReadBOOL(L\"PGSOnlyForced\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.PGSOnlyForced = bFlag;\n\n        dwVal = reg.ReadDWORD(L\"vc1TimestampMode\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.vc1Mode = dwVal;\n\n        bFlag = reg.ReadDWORD(L\"substreams\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.substreams = bFlag;\n\n        bFlag = reg.ReadDWORD(L\"MatroskaExternalSegments\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.MatroskaExternalSegments = bFlag;\n\n        bFlag = reg.ReadDWORD(L\"StreamSwitchReselectSubs\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.StreamSwitchReselectSubs = bFlag;\n\n        bFlag = reg.ReadDWORD(L\"StreamSwitchRemoveAudio\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.StreamSwitchRemoveAudio = bFlag;\n\n        bFlag = reg.ReadDWORD(L\"PreferHighQualityAudio\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.PreferHighQualityAudio = bFlag;\n\n        bFlag = reg.ReadDWORD(L\"ImpairedAudio\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.ImpairedAudio = bFlag;\n\n        dwVal = reg.ReadDWORD(L\"QueueMaxSize\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.QueueMaxMemSize = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"NetworkAnalysisDuration\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.NetworkAnalysisDuration = dwVal;\n\n        dwVal = reg.ReadDWORD(L\"QueueMaxPackets\", hr);\n        if (SUCCEEDED(hr))\n            m_settings.QueueMaxPackets = dwVal;\n    }\n\n    CRegistry regF = CRegistry(rootKey, LAVF_REGISTRY_KEY_FORMATS, hr, TRUE);\n    if (SUCCEEDED(hr))\n    {\n        WCHAR wBuffer[80];\n        for (const FormatInfo &fmt : m_InputFormats)\n        {\n            SafeMultiByteToWideChar(CP_UTF8, 0, fmt.strName, -1, wBuffer, 80);\n            bFlag = regF.ReadBOOL(wBuffer, hr);\n            if (SUCCEEDED(hr))\n                m_settings.formats[std::string(fmt.strName)] = bFlag;\n        }\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::SaveSettings()\n{\n    if (m_bRuntimeConfig)\n    {\n        if (m_pDemuxer)\n            m_pDemuxer->SettingsChanged(static_cast<ILAVFSettingsInternal *>(this));\n        return S_FALSE;\n    }\n\n    HRESULT hr;\n    CreateRegistryKey(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY);\n    CRegistry reg = CRegistry(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY, hr);\n    if (SUCCEEDED(hr))\n    {\n        reg.WriteBOOL(L\"TrayIcon\", m_settings.TrayIcon);\n        reg.WriteString(L\"prefAudioLangs\", m_settings.prefAudioLangs.c_str());\n        reg.WriteString(L\"prefSubLangs\", m_settings.prefSubLangs.c_str());\n        reg.WriteString(L\"subtitleAdvanced\", m_settings.subtitleAdvanced.c_str());\n        reg.WriteDWORD(L\"subtitleMode\", m_settings.subtitleMode);\n        reg.WriteBOOL(L\"PGSForcedStream\", m_settings.PGSForcedStream);\n        reg.WriteBOOL(L\"PGSOnlyForced\", m_settings.PGSOnlyForced);\n        reg.WriteDWORD(L\"vc1TimestampMode\", m_settings.vc1Mode);\n        reg.WriteBOOL(L\"substreams\", m_settings.substreams);\n        reg.WriteBOOL(L\"MatroskaExternalSegments\", m_settings.MatroskaExternalSegments);\n        reg.WriteBOOL(L\"StreamSwitchReselectSubs\", m_settings.StreamSwitchReselectSubs);\n        reg.WriteBOOL(L\"StreamSwitchRemoveAudio\", m_settings.StreamSwitchRemoveAudio);\n        reg.WriteBOOL(L\"PreferHighQualityAudio\", m_settings.PreferHighQualityAudio);\n        reg.WriteBOOL(L\"ImpairedAudio\", m_settings.ImpairedAudio);\n        reg.WriteDWORD(L\"QueueMaxSize\", m_settings.QueueMaxMemSize);\n        reg.WriteDWORD(L\"NetworkAnalysisDuration\", m_settings.NetworkAnalysisDuration);\n        reg.WriteDWORD(L\"QueueMaxPackets\", m_settings.QueueMaxPackets);\n    }\n\n    CreateRegistryKey(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY_FORMATS);\n    CRegistry regF = CRegistry(HKEY_CURRENT_USER, LAVF_REGISTRY_KEY_FORMATS, hr);\n    if (SUCCEEDED(hr))\n    {\n        WCHAR wBuffer[80];\n        for (const FormatInfo &fmt : m_InputFormats)\n        {\n            SafeMultiByteToWideChar(CP_UTF8, 0, fmt.strName, -1, wBuffer, 80);\n            regF.WriteBOOL(wBuffer, m_settings.formats[std::string(fmt.strName)]);\n        }\n    }\n\n    if (m_pDemuxer)\n    {\n        m_pDemuxer->SettingsChanged(static_cast<ILAVFSettingsInternal *>(this));\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    *ppv = nullptr;\n\n    if (m_pDemuxer &&\n        (riid == __uuidof(IKeyFrameInfo) || riid == __uuidof(ITrackInfo) || riid == IID_IAMExtendedSeeking ||\n         riid == IID_IAMMediaContent || riid == IID_IPropertyBag || riid == __uuidof(IDSMResourceBag)))\n    {\n        return m_pDemuxer->QueryInterface(riid, ppv);\n    }\n\n    return QI(IMediaSeeking) QI(IAMStreamSelect) QI(ISpecifyPropertyPages) QI(ISpecifyPropertyPages2) QI2(ILAVFSettings)\n        QI2(ILAVFSettingsInternal) QI(IObjectWithSite) QI(IBufferInfo) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\n// ISpecifyPropertyPages2\nSTDMETHODIMP CLAVSplitter::GetPages(CAUUID *pPages)\n{\n    CheckPointer(pPages, E_POINTER);\n    pPages->cElems = 2;\n    pPages->pElems = (GUID *)CoTaskMemAlloc(sizeof(GUID) * pPages->cElems);\n    if (pPages->pElems == nullptr)\n    {\n        return E_OUTOFMEMORY;\n    }\n    pPages->pElems[0] = CLSID_LAVSplitterSettingsProp;\n    pPages->pElems[1] = CLSID_LAVSplitterFormatsProp;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::CreatePage(const GUID &guid, IPropertyPage **ppPage)\n{\n    CheckPointer(ppPage, E_POINTER);\n    HRESULT hr = S_OK;\n\n    if (*ppPage != nullptr)\n        return E_INVALIDARG;\n\n    if (guid == CLSID_LAVSplitterSettingsProp)\n        *ppPage = new CLAVSplitterSettingsProp(nullptr, &hr);\n    else if (guid == CLSID_LAVSplitterFormatsProp)\n        *ppPage = new CLAVSplitterFormatsProp(nullptr, &hr);\n\n    if (SUCCEEDED(hr) && *ppPage)\n    {\n        (*ppPage)->AddRef();\n        return S_OK;\n    }\n    else\n    {\n        SAFE_DELETE(*ppPage);\n        return E_FAIL;\n    }\n}\n\n// IObjectWithSite\nSTDMETHODIMP CLAVSplitter::SetSite(IUnknown *pUnkSite)\n{\n    // AddRef to store it for later\n    pUnkSite->AddRef();\n\n    // Release the old one\n    SafeRelease(&m_pSite);\n\n    // Store the new one\n    m_pSite = pUnkSite;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::GetSite(REFIID riid, void **ppvSite)\n{\n    CheckPointer(ppvSite, E_POINTER);\n    *ppvSite = nullptr;\n    if (!m_pSite)\n    {\n        return E_FAIL;\n    }\n\n    IUnknown *pSite = nullptr;\n    HRESULT hr = m_pSite->QueryInterface(riid, (void **)&pSite);\n    if (SUCCEEDED(hr) && pSite)\n    {\n        pSite->AddRef();\n        *ppvSite = pSite;\n        return S_OK;\n    }\n    return E_NOINTERFACE;\n}\n\n// IBufferInfo\nSTDMETHODIMP_(int) CLAVSplitter::GetCount()\n{\n    CAutoLock pinLock(&m_csPins);\n    return (int)m_pPins.size();\n}\n\nSTDMETHODIMP CLAVSplitter::GetStatus(int i, int &samples, int &size)\n{\n    CAutoLock pinLock(&m_csPins);\n    if ((size_t)i >= m_pPins.size())\n        return E_FAIL;\n\n    CLAVOutputPin *pPin = m_pPins.at(i);\n    if (!pPin)\n        return E_FAIL;\n    return pPin->GetQueueSize(samples, size);\n}\n\nSTDMETHODIMP_(DWORD) CLAVSplitter::GetPriority()\n{\n    return 0;\n}\n\n// IAMOpenProgress\n\nSTDMETHODIMP CLAVSplitter::QueryProgress(LONGLONG *pllTotal, LONGLONG *pllCurrent)\n{\n    return E_NOTIMPL;\n}\n\nSTDMETHODIMP CLAVSplitter::AbortOperation()\n{\n    if (m_pDemuxer)\n        return m_pDemuxer->AbortOpening();\n    else\n        return E_UNEXPECTED;\n}\n\n// CBaseSplitter\nint CLAVSplitter::GetPinCount()\n{\n    CAutoLock lock(&m_csPins);\n\n    int count = (int)m_pPins.size();\n    if (m_pInput)\n        count++;\n\n    return count;\n}\n\nCBasePin *CLAVSplitter::GetPin(int n)\n{\n    CAutoLock lock(&m_csPins);\n\n    if (n < 0 || n >= GetPinCount())\n        return nullptr;\n\n    if (m_pInput)\n    {\n        if (n == 0)\n            return m_pInput;\n        else\n            n--;\n    }\n\n    return m_pPins[n];\n}\n\nSTDMETHODIMP CLAVSplitter::GetClassID(CLSID *pClsID)\n{\n    CheckPointer(pClsID, E_POINTER);\n\n    if (m_bFakeASFReader)\n    {\n        *pClsID = CLSID_WMAsfReader;\n        return S_OK;\n    }\n    else\n    {\n        return __super::GetClassID(pClsID);\n    }\n}\n\nCLAVOutputPin *CLAVSplitter::GetOutputPin(DWORD streamId, BOOL bActiveOnly)\n{\n    CAutoLock lock(&m_csPins);\n\n    auto &vec = bActiveOnly ? m_pActivePins : m_pPins;\n    for (CLAVOutputPin *pPin : vec)\n    {\n        if (pPin->GetStreamId() == streamId)\n        {\n            return pPin;\n        }\n    }\n    return nullptr;\n}\n\nSTDMETHODIMP CLAVSplitter::CompleteInputConnection()\n{\n    HRESULT hr = S_OK;\n    BOOL bFileInput = FALSE;\n\n    // Check if blacklisted\n    if (!m_bRuntimeConfig && CheckApplicationBlackList(LAVF_REGISTRY_KEY L\"\\\\Blacklist\"))\n        return E_FAIL;\n\n    SAFE_DELETE(m_pDemuxer);\n\n    AVIOContext *pContext = nullptr;\n\n    if (FAILED(hr = m_pInput->GetAVIOContext(&pContext)))\n    {\n        return hr;\n    }\n\n    LPOLESTR pszFileName = nullptr;\n\n    PIN_INFO info;\n    hr = m_pInput->GetConnected()->QueryPinInfo(&info);\n    if (SUCCEEDED(hr) && info.pFilter)\n    {\n        IFileSourceFilter *pSource = nullptr;\n        if (SUCCEEDED(info.pFilter->QueryInterface(&pSource)) && pSource)\n        {\n            pSource->GetCurFile(&pszFileName, nullptr);\n            SafeRelease(&pSource);\n        }\n        CLSID inputCLSID;\n        if (SUCCEEDED(info.pFilter->GetClassID(&inputCLSID)))\n        {\n            bFileInput = (inputCLSID == CLSID_AsyncReader);\n        }\n        SafeRelease(&info.pFilter);\n    }\n\n    const char *format = nullptr;\n    if (m_pInput->CurrentMediaType().subtype == MEDIASUBTYPE_MPEG2_TRANSPORT)\n    {\n        format = \"mpegts\";\n    }\n\n    CLAVFDemuxer *pDemux = new CLAVFDemuxer(this, this);\n    if (FAILED(hr = pDemux->OpenInputStream(pContext, pszFileName, format, FALSE, bFileInput)))\n    {\n        SAFE_DELETE(pDemux);\n        return hr;\n    }\n    m_pDemuxer = pDemux;\n    m_pDemuxer->AddRef();\n\n    SAFE_CO_FREE(pszFileName);\n\n    return InitDemuxer();\n}\n\nSTDMETHODIMP CLAVSplitter::BreakInputConnection()\n{\n    return Close();\n}\n\n// IFileSourceFilter\nSTDMETHODIMP CLAVSplitter::Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt)\n{\n    return LoadURL(pszFileName, NULL, NULL);\n}\n\nSTDMETHODIMP CLAVSplitter::LoadURL(LPCOLESTR pszURL, LPCOLESTR pszUserAgent, LPCOLESTR pszReferrer)\n{\n    CheckPointer(pszURL, E_POINTER);\n    if (m_State != State_Stopped)\n        return E_UNEXPECTED;\n\n    // Check if blacklisted\n    if (!m_bRuntimeConfig && CheckApplicationBlackList(LAVF_REGISTRY_KEY L\"\\\\Blacklist\"))\n        return E_FAIL;\n\n    // Close, just in case we're being re-used\n    Close();\n\n    m_fileName = std::wstring(pszURL);\n\n    HRESULT hr = S_OK;\n    SAFE_DELETE(m_pDemuxer);\n    LPWSTR extension = PathFindExtensionW(pszURL);\n\n    DbgLog((LOG_TRACE, 10, L\"::Load(): Opening file '%s' (extension: %s)\", pszURL, extension));\n\n    // BDMV uses the BD demuxer, everything else LAVF\n    if (_wcsicmp(extension, L\".bdmv\") == 0 || _wcsicmp(extension, L\".mpls\") == 0)\n    {\n        m_pDemuxer = new CBDDemuxer(this, this);\n    }\n    else\n    {\n        m_pDemuxer = new CLAVFDemuxer(this, this);\n    }\n    if (FAILED(hr = m_pDemuxer->Open(pszURL, pszUserAgent, pszReferrer)))\n    {\n        SAFE_DELETE(m_pDemuxer);\n        return hr;\n    }\n    m_pDemuxer->AddRef();\n\n    return InitDemuxer();\n}\n\n// Get the currently loaded file\nSTDMETHODIMP CLAVSplitter::GetCurFile(LPOLESTR *ppszFileName, AM_MEDIA_TYPE *pmt)\n{\n    CheckPointer(ppszFileName, E_POINTER);\n\n    size_t strlen = m_fileName.length() + 1;\n    *ppszFileName = (LPOLESTR)CoTaskMemAlloc(sizeof(wchar_t) * strlen);\n\n    if (!(*ppszFileName))\n        return E_OUTOFMEMORY;\n\n    wcsncpy_s(*ppszFileName, strlen, m_fileName.c_str(), _TRUNCATE);\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::InitDemuxer()\n{\n    HRESULT hr = S_OK;\n\n    // Disable subtitles in applications known to fail with them (explorer thumbnail generator, power point, basically\n    // all applications using MCI)\n    bool bNoSubtitles =\n        _wcsicmp(m_processName.c_str(), L\"dllhost.exe\") == 0 || _wcsicmp(m_processName.c_str(), L\"explorer.exe\") == 0 ||\n        _wcsicmp(m_processName.c_str(), L\"powerpnt.exe\") == 0 || _wcsicmp(m_processName.c_str(), L\"pptview.exe\") == 0;\n\n    m_rtStart = m_rtNewStart = m_rtCurrent = 0;\n    m_rtStop = m_rtNewStop = m_pDemuxer->GetDuration();\n    m_bPlaybackStarted = FALSE;\n\n    const CBaseDemuxer::stream *videoStream = m_pDemuxer->SelectVideoStream();\n    if (videoStream)\n    {\n        CLAVOutputPin *pPin = new CLAVOutputPin(videoStream->streamInfo->mtypes,\n                                                CBaseDemuxer::CStreamList::ToStringW(CBaseDemuxer::video), this, this,\n                                                &hr, CBaseDemuxer::video, m_pDemuxer->GetContainerFormat());\n        if (SUCCEEDED(hr))\n        {\n            pPin->SetStreamId(videoStream->pid);\n            m_pPins.push_back(pPin);\n            m_pDemuxer->SetActiveStream(CBaseDemuxer::video, videoStream->pid);\n        }\n        else\n        {\n            delete pPin;\n        }\n    }\n\n    std::list<std::string> audioLangs = GetPreferredAudioLanguageList();\n    const CBaseDemuxer::stream *audioStream = m_pDemuxer->SelectAudioStream(audioLangs);\n    if (audioStream)\n    {\n        CLAVOutputPin *pPin = new CLAVOutputPin(audioStream->streamInfo->mtypes,\n                                                CBaseDemuxer::CStreamList::ToStringW(CBaseDemuxer::audio), this, this,\n                                                &hr, CBaseDemuxer::audio, m_pDemuxer->GetContainerFormat());\n        if (SUCCEEDED(hr))\n        {\n            pPin->SetStreamId(audioStream->pid);\n            m_pPins.push_back(pPin);\n            m_pDemuxer->SetActiveStream(CBaseDemuxer::audio, audioStream->pid);\n        }\n        else\n        {\n            delete pPin;\n        }\n    }\n\n    std::string audioLanguage = audioStream ? audioStream->language : std::string();\n\n    std::list<CSubtitleSelector> subtitleSelectors = GetSubtitleSelectors();\n    const CBaseDemuxer::stream *subtitleStream = m_pDemuxer->SelectSubtitleStream(subtitleSelectors, audioLanguage);\n    if (subtitleStream && !bNoSubtitles)\n    {\n        CLAVOutputPin *pPin = new CLAVOutputPin(subtitleStream->streamInfo->mtypes,\n                                                CBaseDemuxer::CStreamList::ToStringW(CBaseDemuxer::subpic), this, this,\n                                                &hr, CBaseDemuxer::subpic, m_pDemuxer->GetContainerFormat());\n        if (SUCCEEDED(hr))\n        {\n            pPin->SetStreamId(subtitleStream->pid);\n            m_pPins.push_back(pPin);\n            m_pDemuxer->SetActiveStream(CBaseDemuxer::subpic, subtitleStream->pid);\n        }\n        else\n        {\n            delete pPin;\n        }\n    }\n\n    if (SUCCEEDED(hr))\n    {\n        // If there are no pins, what good are we?\n        return !m_pPins.empty() ? S_OK : E_FAIL;\n    }\n    else\n    {\n        return hr;\n    }\n}\n\nSTDMETHODIMP CLAVSplitter::DeleteOutputs()\n{\n    CAutoLock lock(this);\n    if (m_State != State_Stopped)\n        return VFW_E_NOT_STOPPED;\n\n    CAutoLock pinLock(&m_csPins);\n    // Release pins\n    for (CLAVOutputPin *pPin : m_pPins)\n    {\n        if (IPin *pPinTo = pPin->GetConnected())\n            pPinTo->Disconnect();\n        pPin->Disconnect();\n        m_pRetiredPins.push_back(pPin);\n    }\n    m_pPins.clear();\n\n    return S_OK;\n}\n\nbool CLAVSplitter::IsAnyPinDrying()\n{\n    // MPC changes thread priority here\n    // TODO: Investigate if that is needed\n    for (CLAVOutputPin *pPin : m_pActivePins)\n    {\n        if (pPin->IsConnected() && !pPin->IsDiscontinuous() && pPin->QueueCount() < pPin->GetQueueLowLimit())\n        {\n            return true;\n        }\n    }\n    return false;\n}\n\n// Worker Thread\nDWORD CLAVSplitter::ThreadProc()\n{\n    std::vector<CLAVOutputPin *>::iterator pinIter;\n\n    CheckPointer(m_pDemuxer, 0);\n\n    SetThreadName(-1, \"CLAVSplitter Demux\");\n\n    m_pDemuxer->Start();\n\n    m_fFlushing = false;\n    m_eEndFlush.Set();\n    for (DWORD cmd = (DWORD)-1;; cmd = GetRequest())\n    {\n        if (cmd == CMD_EXIT)\n        {\n            Reply(S_OK);\n            m_ePlaybackInit.Set();\n            return 0;\n        }\n\n        m_ePlaybackInit.Reset();\n\n        m_rtStart = m_rtNewStart;\n        m_rtStop = m_rtNewStop;\n\n        if (m_bPlaybackStarted || m_rtStart != 0 || cmd == CMD_SEEK)\n        {\n            HRESULT hr = S_FALSE;\n            if (m_pInput)\n            {\n                hr = m_pInput->SeekStream(m_rtStart);\n                if (SUCCEEDED(hr))\n                    m_pDemuxer->Reset();\n            }\n            if (hr != S_OK)\n                DemuxSeek(m_rtStart);\n        }\n\n        if (cmd != (DWORD)-1)\n            Reply(S_OK);\n\n        // Wait for the end of any flush\n        m_eEndFlush.Wait();\n\n        m_pActivePins.clear();\n\n        for (pinIter = m_pPins.begin(); pinIter != m_pPins.end() && !m_fFlushing; ++pinIter)\n        {\n            if ((*pinIter)->IsConnected())\n            {\n                (*pinIter)->DeliverNewSegment(m_rtStart, m_rtStop, m_dRate);\n                m_pActivePins.push_back(*pinIter);\n            }\n        }\n        m_rtOffset = AV_NOPTS_VALUE;\n\n        m_bDiscontinuitySent.clear();\n\n        m_bPlaybackStarted = TRUE;\n        m_ePlaybackInit.Set();\n\n        HRESULT hr = S_OK;\n        while (SUCCEEDED(hr) && !CheckRequest(&cmd))\n        {\n            hr = DemuxNextPacket();\n        }\n\n        // If we didnt exit by request, deliver end-of-stream\n        if (!CheckRequest(&cmd))\n        {\n            for (pinIter = m_pActivePins.begin(); pinIter != m_pActivePins.end(); ++pinIter)\n            {\n                (*pinIter)->QueueEndOfStream();\n            }\n        }\n    }\n    ASSERT(0); // we should only exit via CMD_EXIT\n\n    return 0;\n}\n\n// Seek to the specified time stamp\n// Based on DVDDemuxFFMPEG\nHRESULT CLAVSplitter::DemuxSeek(REFERENCE_TIME rtStart)\n{\n    if (rtStart < 0)\n    {\n        rtStart = 0;\n    }\n\n    return m_pDemuxer->Seek(rtStart);\n}\n\n// Demux the next packet and deliver it to the output pins\n// Based on DVDDemuxFFMPEG\nHRESULT CLAVSplitter::DemuxNextPacket()\n{\n    Packet *pPacket;\n    HRESULT hr = S_OK;\n    hr = m_pDemuxer->GetNextPacket(&pPacket);\n    // Only S_OK indicates we have a proper packet\n    // S_FALSE is a \"soft error\", don't deliver the packet\n    if (hr != S_OK)\n    {\n        return hr;\n    }\n    return DeliverPacket(pPacket);\n}\n\nHRESULT CLAVSplitter::DeliverPacket(Packet *pPacket)\n{\n    HRESULT hr = S_FALSE;\n\n    if (pPacket->dwFlags & LAV_PACKET_FORCED_SUBTITLE)\n        pPacket->StreamId = FORCED_SUBTITLE_PID;\n\n    CLAVOutputPin *pPin = GetOutputPin(pPacket->StreamId, TRUE);\n    if (!pPin || !pPin->IsConnected())\n    {\n        delete pPacket;\n        return S_FALSE;\n    }\n\n    if (pPacket->rtStart != Packet::INVALID_TIME)\n    {\n        m_rtCurrent = pPacket->rtStop;\n\n        if (m_bStopValid && m_rtStop && pPacket->rtStart > m_rtStop)\n        {\n            DbgLog((LOG_TRACE, 10, L\"::DeliverPacket(): Reached the designated stop time of %I64d at %I64d\", m_rtStop,\n                    pPacket->rtStart));\n            delete pPacket;\n            return E_FAIL;\n        }\n\n        pPacket->rtStart -= m_rtStart;\n        pPacket->rtStop -= m_rtStart;\n\n        ASSERT(pPacket->rtStart <= pPacket->rtStop);\n\n        // Filter PTS values\n        // This will try to compensate for timestamp discontinuities in the stream\n        if (m_pDemuxer->GetContainerFlags() & LAVFMT_TS_DISCONT)\n        {\n            if (!pPin->IsSubtitlePin())\n            {\n                // Initialize on the first stream coming in\n                if (pPin->m_rtPrev == AV_NOPTS_VALUE && m_rtOffset == AV_NOPTS_VALUE)\n                {\n                    pPin->m_rtPrev = 0;\n                    m_rtOffset = 0;\n                }\n\n                REFERENCE_TIME rt = pPacket->rtStart + m_rtOffset;\n\n                if (pPin->m_rtPrev != AV_NOPTS_VALUE && _abs64(rt - pPin->m_rtPrev) > MAX_PTS_SHIFT)\n                {\n                    m_rtOffset += pPin->m_rtPrev - rt;\n                    if (!(m_pDemuxer->GetContainerFlags() & LAVFMT_TS_DISCONT_NO_DOWNSTREAM))\n                        m_bDiscontinuitySent.clear();\n                    DbgLog((LOG_TRACE, 10,\n                            L\"::DeliverPacket(): MPEG-TS/PS discontinuity detected, adjusting offset to %I64d (stream: \"\n                            L\"%d, prev: %I64d, now: %I64d)\",\n                            m_rtOffset, pPacket->StreamId, pPin->m_rtPrev, rt));\n                }\n            }\n            pPacket->rtStart += m_rtOffset;\n            pPacket->rtStop += m_rtOffset;\n\n            pPin->m_rtPrev = pPacket->rtStart;\n        }\n\n        pPacket->rtStart = (REFERENCE_TIME)(pPacket->rtStart / m_dRate);\n        pPacket->rtStop = (REFERENCE_TIME)(pPacket->rtStop / m_dRate);\n    }\n\n    if (m_bDiscontinuitySent.find(pPacket->StreamId) == m_bDiscontinuitySent.end())\n    {\n        pPacket->bDiscontinuity = TRUE;\n    }\n\n    BOOL bDiscontinuity = pPacket->bDiscontinuity;\n    DWORD streamId = pPacket->StreamId;\n\n    hr = pPin->QueuePacket(pPacket);\n\n    if (hr != S_OK)\n    {\n        // Find a iterator pointing to the pin\n        std::vector<CLAVOutputPin *>::iterator it = std::find(m_pActivePins.begin(), m_pActivePins.end(), pPin);\n        // Remove it from the vector\n        m_pActivePins.erase(it);\n\n        // Fail if no active pins remain, otherwise resume demuxing\n        return m_pActivePins.empty() ? E_FAIL : S_OK;\n    }\n\n    if (bDiscontinuity)\n    {\n        m_bDiscontinuitySent.insert(streamId);\n    }\n\n    return hr;\n}\n\nSTDMETHODIMP_(CMediaType *) CLAVSplitter::GetOutputMediatype(int stream)\n{\n    CLAVOutputPin *pPin = GetOutputPin(stream, FALSE);\n    if (!pPin || !pPin->IsConnected())\n        return nullptr;\n\n    CMediaType *pmt = new CMediaType(pPin->GetActiveMediaType());\n    return pmt;\n}\n\n// State Control\nSTDMETHODIMP CLAVSplitter::Stop()\n{\n    CAutoLock cAutoLock(this);\n\n    // Wait for playback to finish initializing\n    m_ePlaybackInit.Wait();\n\n    // Ask network operations to exit\n    if (m_pDemuxer)\n        m_pDemuxer->AbortOpening(1);\n\n    DeliverBeginFlush();\n    CAMThread::CallWorker(CMD_EXIT);\n    CAMThread::Close();\n    DeliverEndFlush();\n\n    if (m_pDemuxer)\n        m_pDemuxer->AbortOpening(0);\n\n    HRESULT hr;\n    if (FAILED(hr = __super::Stop()))\n    {\n        return hr;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::Pause()\n{\n    CAutoLock cAutoLock(this);\n    CheckPointer(m_pDemuxer, E_UNEXPECTED);\n\n    FILTER_STATE fs = m_State;\n\n    HRESULT hr;\n    if (FAILED(hr = __super::Pause()))\n    {\n        return hr;\n    }\n\n    // The filter graph will set us to pause before running\n    // So if we were stopped before, create the thread\n    // Note that the splitter will always be running,\n    // and even in pause mode fill up the buffers\n    if (fs == State_Stopped)\n    {\n        // At this point, the graph is hopefully finished, tell the demuxer about all the cool things\n        m_pDemuxer->SettingsChanged(static_cast<ILAVFSettingsInternal *>(this));\n\n        // Create demuxing thread\n        if (!ThreadExists())\n            m_ePlaybackInit.Reset();\n        Create();\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::Run(REFERENCE_TIME tStart)\n{\n    CAutoLock cAutoLock(this);\n\n    HRESULT hr;\n    if (FAILED(hr = __super::Run(tStart)))\n    {\n        return hr;\n    }\n\n    return S_OK;\n}\n\n// Flushing\nvoid CLAVSplitter::DeliverBeginFlush()\n{\n    m_fFlushing = true;\n\n    // flush all pins\n    for (CLAVOutputPin *pPin : m_pPins)\n    {\n        pPin->DeliverBeginFlush();\n    }\n}\n\nvoid CLAVSplitter::DeliverEndFlush()\n{\n    // flush all pins\n    for (CLAVOutputPin *pPin : m_pPins)\n    {\n        pPin->DeliverEndFlush();\n    }\n\n    m_fFlushing = false;\n    m_eEndFlush.Set();\n}\n\n// IMediaSeeking\nSTDMETHODIMP CLAVSplitter::GetCapabilities(DWORD *pCapabilities)\n{\n    CheckPointer(pCapabilities, E_POINTER);\n\n    *pCapabilities = AM_SEEKING_CanGetStopPos | AM_SEEKING_CanGetDuration | AM_SEEKING_CanSeekAbsolute |\n                     AM_SEEKING_CanSeekForwards | AM_SEEKING_CanSeekBackwards;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::CheckCapabilities(DWORD *pCapabilities)\n{\n    CheckPointer(pCapabilities, E_POINTER);\n    // capabilities is empty, all is good\n    if (*pCapabilities == 0)\n        return S_OK;\n    // read caps\n    DWORD caps;\n    GetCapabilities(&caps);\n\n    // Store the caps that we wanted\n    DWORD wantCaps = *pCapabilities;\n    // Update pCapabilities with what we have\n    *pCapabilities = caps & wantCaps;\n\n    // if nothing matches, its a disaster!\n    if (*pCapabilities == 0)\n        return E_FAIL;\n    // if all matches, its all good\n    if (*pCapabilities == wantCaps)\n        return S_OK;\n    // otherwise, a partial match\n    return S_FALSE;\n}\n\nSTDMETHODIMP CLAVSplitter::IsFormatSupported(const GUID *pFormat)\n{\n    return !pFormat ? E_POINTER : *pFormat == TIME_FORMAT_MEDIA_TIME ? S_OK : S_FALSE;\n}\nSTDMETHODIMP CLAVSplitter::QueryPreferredFormat(GUID *pFormat)\n{\n    return GetTimeFormat(pFormat);\n}\nSTDMETHODIMP CLAVSplitter::GetTimeFormat(GUID *pFormat)\n{\n    return pFormat ? *pFormat = TIME_FORMAT_MEDIA_TIME, S_OK : E_POINTER;\n}\nSTDMETHODIMP CLAVSplitter::IsUsingTimeFormat(const GUID *pFormat)\n{\n    return IsFormatSupported(pFormat);\n}\nSTDMETHODIMP CLAVSplitter::SetTimeFormat(const GUID *pFormat)\n{\n    return S_OK == IsFormatSupported(pFormat) ? S_OK : E_INVALIDARG;\n}\n\nSTDMETHODIMP CLAVSplitter::GetDuration(LONGLONG *pDuration)\n{\n    REFERENCE_TIME rtDuration = -1;\n    CheckPointer(pDuration, E_POINTER);\n    CheckPointer(m_pDemuxer, E_UNEXPECTED);\n\n    if (m_pInput)\n    {\n        if (FAILED(m_pInput->GetStreamDuration(&rtDuration)))\n            rtDuration = -1;\n    }\n\n    if (rtDuration < 0)\n        rtDuration = m_pDemuxer->GetDuration();\n\n    if (rtDuration < 0)\n        return E_FAIL;\n\n    *pDuration = rtDuration;\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::GetStopPosition(LONGLONG *pStop)\n{\n    return GetDuration(pStop);\n}\nSTDMETHODIMP CLAVSplitter::GetCurrentPosition(LONGLONG *pCurrent)\n{\n    return E_NOTIMPL;\n}\nSTDMETHODIMP CLAVSplitter::ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source,\n                                             const GUID *pSourceFormat)\n{\n    return E_NOTIMPL;\n}\nSTDMETHODIMP CLAVSplitter::SetPositions(LONGLONG *pCurrent, DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags)\n{\n    return SetPositionsInternal(this, pCurrent, dwCurrentFlags, pStop, dwStopFlags);\n}\nSTDMETHODIMP CLAVSplitter::SetPositionsInternal(void *caller, LONGLONG *pCurrent, DWORD dwCurrentFlags, LONGLONG *pStop,\n                                                DWORD dwStopFlags)\n{\n    DbgLog((LOG_TRACE, 20,\n            \"::SetPositions() - seek request; caller: %p, current: %I64d; start: %I64d; flags: 0x%x, stop: %I64d; \"\n            \"flags: 0x%x\",\n            caller, m_rtCurrent, pCurrent ? *pCurrent : -1, dwCurrentFlags, pStop ? *pStop : -1, dwStopFlags));\n    CAutoLock cAutoLock(this);\n\n    if (!pCurrent && !pStop || (dwCurrentFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning &&\n                                   (dwStopFlags & AM_SEEKING_PositioningBitsMask) == AM_SEEKING_NoPositioning)\n    {\n        return S_OK;\n    }\n\n    REFERENCE_TIME\n    rtCurrent = m_rtCurrent, rtStop = m_rtStop;\n\n    if (pCurrent)\n    {\n        switch (dwCurrentFlags & AM_SEEKING_PositioningBitsMask)\n        {\n        case AM_SEEKING_NoPositioning: break;\n        case AM_SEEKING_AbsolutePositioning: rtCurrent = *pCurrent; break;\n        case AM_SEEKING_RelativePositioning: rtCurrent = rtCurrent + *pCurrent; break;\n        case AM_SEEKING_IncrementalPositioning: rtCurrent = rtCurrent + *pCurrent; break;\n        }\n    }\n\n    if (pStop)\n    {\n        switch (dwStopFlags & AM_SEEKING_PositioningBitsMask)\n        {\n        case AM_SEEKING_NoPositioning: break;\n        case AM_SEEKING_AbsolutePositioning:\n            rtStop = *pStop;\n            m_bStopValid = TRUE;\n            break;\n        case AM_SEEKING_RelativePositioning:\n            rtStop += *pStop;\n            m_bStopValid = TRUE;\n            break;\n        case AM_SEEKING_IncrementalPositioning:\n            rtStop = rtCurrent + *pStop;\n            m_bStopValid = TRUE;\n            break;\n        }\n    }\n\n    if (m_rtLastStart == rtCurrent && m_rtLastStop == rtStop && m_LastSeekers.find(caller) == m_LastSeekers.end())\n    {\n        m_LastSeekers.insert(caller);\n        return S_OK;\n    }\n\n    m_rtLastStart = rtCurrent;\n    m_rtLastStop = rtStop;\n    m_LastSeekers.clear();\n    m_LastSeekers.insert(caller);\n\n    m_rtNewStart = m_rtCurrent = rtCurrent;\n    m_rtNewStop = rtStop;\n\n    DbgLog((LOG_TRACE, 20, \" -> Performing seek to %I64d\", m_rtNewStart));\n    if (ThreadExists())\n    {\n        DeliverBeginFlush();\n        CallWorker(CMD_SEEK);\n        DeliverEndFlush();\n    }\n    DbgLog((LOG_TRACE, 20, \" -> Seek finished\", m_rtNewStart));\n\n    return S_OK;\n}\nSTDMETHODIMP CLAVSplitter::GetPositions(LONGLONG *pCurrent, LONGLONG *pStop)\n{\n    if (pCurrent)\n        *pCurrent = m_rtCurrent;\n    if (pStop)\n        *pStop = m_rtStop;\n    return S_OK;\n}\nSTDMETHODIMP CLAVSplitter::GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest)\n{\n    if (pEarliest)\n        *pEarliest = 0;\n    return GetDuration(pLatest);\n}\nSTDMETHODIMP CLAVSplitter::SetRate(double dRate)\n{\n    return dRate > 0 ? m_dRate = dRate, S_OK : E_INVALIDARG;\n}\nSTDMETHODIMP CLAVSplitter::GetRate(double *pdRate)\n{\n    return pdRate ? *pdRate = m_dRate, S_OK : E_POINTER;\n}\nSTDMETHODIMP CLAVSplitter::GetPreroll(LONGLONG *pllPreroll)\n{\n    return pllPreroll ? *pllPreroll = 0, S_OK : E_POINTER;\n}\n\nSTDMETHODIMP CLAVSplitter::UpdateForcedSubtitleMediaType()\n{\n    CheckPointer(m_pDemuxer, E_UNEXPECTED);\n\n    CLAVOutputPin *pPin = GetOutputPin(FORCED_SUBTITLE_PID);\n    if (pPin)\n    {\n        CBaseDemuxer::CStreamList *streams = m_pDemuxer->GetStreams(CBaseDemuxer::subpic);\n        const CBaseDemuxer::stream *s = streams->FindStream(FORCED_SUBTITLE_PID);\n        CMediaType *mt = new CMediaType(s->streamInfo->mtypes.back());\n        pPin->SendMediaType(mt);\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::ReselectSubs(int streamId)\n{\n    CheckPointer(m_pDemuxer, E_UNEXPECTED);\n    CBaseDemuxer::stream *audioStream = m_pDemuxer->GetStreams(CBaseDemuxer::StreamType::audio)->FindStream(streamId);\n    std::string audioLanguage = audioStream ? audioStream->language : std::string();\n    std::list<CSubtitleSelector> subtitleSelectors = GetSubtitleSelectors();\n\n    const CBaseDemuxer::stream *subtitleStream = m_pDemuxer->SelectSubtitleStream(subtitleSelectors, audioLanguage);\n    if (subtitleStream)\n    {\n        long lIndex = (long)m_pDemuxer->GetStreams(CBaseDemuxer::StreamType::video)->size() +\n                      (long)m_pDemuxer->GetStreams(CBaseDemuxer::StreamType::audio)->size();\n\n        auto subpics = m_pDemuxer->GetStreams(CBaseDemuxer::StreamType::subpic);\n        for (int i = 0; i < subpics->size(); i++)\n        {\n            if (subpics->at(i).pid == subtitleStream->pid)\n            {\n                lIndex += i;\n                break;\n            }\n        }\n\n        Enable(lIndex, AMSTREAMSELECTENABLE_ENABLE);\n        return S_OK;\n    }\n\n    return E_FAIL;\n}\n\nstatic int QueryAcceptMediaTypes(IPin *pPin, std::deque<CMediaType> pmts)\n{\n    for (unsigned int i = 0; i < pmts.size(); i++)\n    {\n        if (S_OK == pPin->QueryAccept(&pmts[i]))\n        {\n            DbgLog((LOG_TRACE, 20, L\"QueryAcceptMediaTypes() - IPin:QueryAccept succeeded on index %d\", i));\n            return i;\n        }\n    }\n    return -1;\n}\n\nSTDMETHODIMP CLAVSplitter::RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDst, std::deque<CMediaType> pmts)\n{\n    CheckPointer(m_pDemuxer, E_UNEXPECTED);\n    if (TrackNumSrc == TrackNumDst)\n        return S_OK;\n\n    // WMP/WMC like to always enable the first track, overwriting any initial stream choice\n    // So instead block it from doing anything here.\n    if (!m_bPlaybackStarted && (m_processName == L\"wmplayer.exe\" || m_processName == L\"ehshell.exe\"))\n        return S_OK;\n\n    CLAVOutputPin *pPin = GetOutputPin(TrackNumSrc);\n\n    DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - Switching %s Stream %d to %d\",\n            CBaseDemuxer::CStreamList::ToStringW(pPin->GetPinType()), TrackNumSrc, TrackNumDst));\n    // Output Pin was found\n    // Stop the Graph, remove the old filter, render the graph again, start it up again\n    // This only works on pins that were connected before, or the filter graph could .. well, break\n    if (pPin && pPin->IsConnected())\n    {\n        bool reselectSubsAtEnd = false;\n\n        HRESULT hr = S_OK;\n\n        IMediaControl *pControl = nullptr;\n        hr = m_pGraph->QueryInterface(IID_IMediaControl, (void **)&pControl);\n\n        FILTER_STATE oldState;\n        // Get the graph state\n        // If the graph is in transition, we'll get the next state, not the previous\n        hr = pControl->GetState(10, (OAFilterState *)&oldState);\n        DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - IMediaControl::GetState returned %d (hr %x)\", oldState, hr));\n\n        // Stop the filter graph\n        hr = pControl->Stop();\n        DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - IMediaControl::Stop (hr %x)\", hr));\n\n        Lock();\n\n        // Update Output Pin\n        pPin->SetStreamId(TrackNumDst);\n        m_pDemuxer->SetActiveStream(pPin->GetPinType(), TrackNumDst);\n        pPin->SetNewMediaTypes(pmts);\n\n        // IGraphRebuildDelegate support\n        // Query our Site for the appropriate interface, and if its present, delegate graph building there\n        IGraphRebuildDelegate *pDelegate = nullptr;\n        if (SUCCEEDED(GetSite(IID_IGraphRebuildDelegate, (void **)&pDelegate)) && pDelegate)\n        {\n            hr = pDelegate->RebuildPin(m_pGraph, pPin);\n            if (hr == S_FALSE)\n            {\n                int mtIdx = QueryAcceptMediaTypes(pPin->GetConnected(), pmts);\n                if (mtIdx == -1)\n                {\n                    DbgLog((LOG_ERROR, 10, L\"::RenameOutputPin(): No matching media type after rebuild delegation\"));\n                    mtIdx = 0;\n                }\n                CMediaType *mt = new CMediaType(pmts[mtIdx]);\n                pPin->SendMediaType(mt);\n            }\n            SafeRelease(&pDelegate);\n\n            if (SUCCEEDED(hr))\n            {\n                goto resumegraph;\n            }\n            DbgLog((LOG_TRACE, 10, L\"::RenameOutputPin(): IGraphRebuildDelegate::RebuildPin failed\"));\n        }\n\n        // Audio Filters get their connected filter removed\n        // This way we make sure we reconnect to the proper filter\n        // Other filters just disconnect and try to reconnect later on\n        PIN_INFO pInfo;\n        hr = pPin->GetConnected()->QueryPinInfo(&pInfo);\n        if (FAILED(hr))\n        {\n            DbgLog((LOG_ERROR, 10, L\"::RenameOutputPin(): QueryPinInfo failed (hr %x)\", hr));\n        }\n\n        int mtIdx = QueryAcceptMediaTypes(pPin->GetConnected(), pmts);\n        BOOL bMediaTypeFound = (mtIdx >= 0);\n\n        if (!bMediaTypeFound)\n        {\n            DbgLog((LOG_TRACE, 10, L\"::RenameOutputPin() - Filter does not accept our media types!\"));\n            mtIdx = 0; // Fallback type\n        }\n        CMediaType *pmt = &pmts[mtIdx];\n\n        if (!pPin->IsVideoPin() && SUCCEEDED(hr) && pInfo.pFilter)\n        {\n            BOOL bRemoveFilter = m_settings.StreamSwitchRemoveAudio || !bMediaTypeFound;\n            if (bRemoveFilter && pPin->IsAudioPin())\n            {\n                hr = m_pGraph->RemoveFilter(pInfo.pFilter);\n#ifdef DEBUG\n                CLSID guidFilter;\n                pInfo.pFilter->GetClassID(&guidFilter);\n                DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - IFilterGraph::RemoveFilter - %s (hr %x)\",\n                        WStringFromGUID(guidFilter).c_str(), hr));\n#endif\n                // Use IGraphBuilder to rebuild the graph\n                IGraphBuilder *pGraphBuilder = nullptr;\n                if (SUCCEEDED(hr = m_pGraph->QueryInterface(__uuidof(IGraphBuilder), (void **)&pGraphBuilder)))\n                {\n                    // Instruct the GraphBuilder to connect us again\n                    hr = pGraphBuilder->Render(pPin);\n                    DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - IGraphBuilder::Render (hr %x)\", hr));\n                    pGraphBuilder->Release();\n                }\n            }\n            else\n            {\n                hr = ReconnectPin(pPin, pmt);\n                DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - ReconnectPin (hr %x)\", hr));\n            }\n\n            if (pPin->IsAudioPin() && m_settings.PGSForcedStream)\n                UpdateForcedSubtitleMediaType();\n\n            if (pPin->IsAudioPin() && m_settings.StreamSwitchReselectSubs)\n            {\n                reselectSubsAtEnd = true;\n            }\n        }\n        else\n        {\n            CMediaType *mt = new CMediaType(*pmt);\n            pPin->SendMediaType(mt);\n            DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - Sending new Media Type\"));\n        }\n        if (SUCCEEDED(hr) && pInfo.pFilter)\n        {\n            pInfo.pFilter->Release();\n        }\n\n    resumegraph:\n        Unlock();\n\n        // Re-start the graph\n        if (oldState == State_Paused)\n        {\n            hr = pControl->Pause();\n            DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - IMediaControl::Pause (hr %x)\", hr));\n        }\n        else if (oldState == State_Running)\n        {\n            hr = pControl->Run();\n            DbgLog((LOG_TRACE, 20, L\"::RenameOutputPin() - IMediaControl::Run (hr %x)\", hr));\n        }\n        pControl->Release();\n\n        if (reselectSubsAtEnd)\n        {\n            ReselectSubs(TrackNumDst);\n        }\n\n        return hr;\n    }\n    else if (pPin)\n    {\n        CAutoLock lock(this);\n        // In normal operations, this won't make much sense\n        // However, in graphstudio it is now possible to change the stream before connecting\n        pPin->SetStreamId(TrackNumDst);\n        m_pDemuxer->SetActiveStream(pPin->GetPinType(), TrackNumDst);\n        pPin->SetNewMediaTypes(pmts);\n\n        return S_OK;\n    }\n\n    return E_FAIL;\n}\n\n// IAMStreamSelect\nSTDMETHODIMP CLAVSplitter::Count(DWORD *pcStreams)\n{\n    CheckPointer(pcStreams, E_POINTER);\n    CheckPointer(m_pDemuxer, E_UNEXPECTED);\n\n    *pcStreams = 0;\n    for (int i = 0; i < CBaseDemuxer::unknown; i++)\n    {\n        CBaseDemuxer::CStreamList* pStreamList = m_pDemuxer->GetStreams((CBaseDemuxer::StreamType)i);\n        if (pStreamList)\n            *pcStreams += (DWORD)pStreamList->size();\n    }\n\n    int num_titles = m_pDemuxer->GetNumTitles();\n    if (num_titles > 1)\n        *pcStreams += num_titles;\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::Enable(long lIndex, DWORD dwFlags)\n{\n    CheckPointer(m_pDemuxer, E_UNEXPECTED);\n    if (!(dwFlags & AMSTREAMSELECTENABLE_ENABLE))\n    {\n        return E_NOTIMPL;\n    }\n\n    int i, j;\n    for (i = 0, j = 0; i < CBaseDemuxer::unknown; i++)\n    {\n        CBaseDemuxer::CStreamList *streams = m_pDemuxer->GetStreams((CBaseDemuxer::StreamType)i);\n        if (!streams)\n            continue;\n\n        int cnt = (int)streams->size();\n\n        if (lIndex >= j && lIndex < j + cnt)\n        {\n            long idx = (lIndex - j);\n\n            CBaseDemuxer::stream &to = streams->at(idx);\n\n            std::deque<CBaseDemuxer::stream>::iterator it;\n            for (it = streams->begin(); it != streams->end(); ++it)\n            {\n                if (!GetOutputPin(it->pid))\n                {\n                    continue;\n                }\n\n                HRESULT hr;\n                if (FAILED(hr = RenameOutputPin(*it, to, to.streamInfo->mtypes)))\n                {\n                    return hr;\n                }\n                return S_OK;\n            }\n            break;\n        }\n        j += cnt;\n    }\n    int idx = (lIndex - j);\n    int num_titles = m_pDemuxer->GetNumTitles();\n    if (num_titles > 1 && idx >= 0 && idx < num_titles)\n    {\n        DbgLog((LOG_TRACE, 10, L\"Setting title to %d\", idx));\n        HRESULT hr = m_pDemuxer->SetTitle(idx);\n        if (SUCCEEDED(hr))\n        {\n            // Perform a seek to the start of the new title\n            IMediaSeeking *pSeek = nullptr;\n            hr = m_pGraph->QueryInterface(&pSeek);\n            if (SUCCEEDED(hr))\n            {\n                LONGLONG current = 0;\n                pSeek->SetPositions(&current, AM_SEEKING_AbsolutePositioning, nullptr, AM_SEEKING_NoPositioning);\n                SafeRelease(&pSeek);\n            }\n            // Notify the player about the length change\n            DbgLog((LOG_TRACE, 10, L\"Title change complete, signaling player\"));\n            NotifyEvent(EC_LENGTH_CHANGED, 0, 0);\n        }\n    }\n    return S_FALSE;\n}\n\nSTDMETHODIMP CLAVSplitter::Info(long lIndex, AM_MEDIA_TYPE **ppmt, DWORD *pdwFlags, LCID *plcid, DWORD *pdwGroup,\n                                WCHAR **ppszName, IUnknown **ppObject, IUnknown **ppUnk)\n{\n    CheckPointer(m_pDemuxer, E_UNEXPECTED);\n    HRESULT hr = S_FALSE;\n    int i, j;\n    for (i = 0, j = 0; i < CBaseDemuxer::unknown; i++)\n    {\n        CBaseDemuxer::CStreamList *streams = m_pDemuxer->GetStreams((CBaseDemuxer::StreamType)i);\n        int cnt = (int)streams->size();\n\n        if (lIndex >= j && lIndex < j + cnt)\n        {\n            long idx = (lIndex - j);\n\n            CBaseDemuxer::stream &s = streams->at(idx);\n\n            if (ppmt)\n                *ppmt = CreateMediaType(&s.streamInfo->mtypes[0]);\n            if (pdwFlags)\n                *pdwFlags = GetOutputPin(s) ? (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE) : 0;\n            if (pdwGroup)\n                *pdwGroup = i;\n            if (ppObject)\n                *ppObject = nullptr;\n            if (ppUnk)\n                *ppUnk = nullptr;\n\n            // Special case for the \"no subtitles\" pin\n            if (s.pid == NO_SUBTITLE_PID)\n            {\n                if (plcid)\n                    *plcid = LCID_NOSUBTITLES;\n                if (ppszName)\n                {\n                    WCHAR str[] = L\"S: \" NO_SUB_STRING;\n                    size_t len = wcslen(str) + 1;\n                    *ppszName = (WCHAR *)CoTaskMemAlloc(len * sizeof(WCHAR));\n                    if (*ppszName)\n                        wcsncpy_s(*ppszName, len, str, _TRUNCATE);\n                }\n            }\n            else if (s.pid == FORCED_SUBTITLE_PID)\n            {\n                if (plcid)\n                {\n                    *plcid = s.lcid;\n                }\n                if (ppszName)\n                {\n                    WCHAR str[] = L\"S: \" FORCED_SUB_STRING;\n                    size_t len = wcslen(str) + 1;\n                    *ppszName = (WCHAR *)CoTaskMemAlloc(len * sizeof(WCHAR));\n                    if (*ppszName)\n                        wcsncpy_s(*ppszName, len, str, _TRUNCATE);\n                }\n            }\n            else\n            {\n                if (plcid)\n                {\n                    *plcid = s.lcid;\n                }\n                if (ppszName)\n                {\n                    std::string info = s.streamInfo->codecInfo;\n                    *ppszName = CoTaskGetWideCharFromMultiByte(CP_UTF8, MB_ERR_INVALID_CHARS, info.c_str(), -1);\n                }\n            }\n            hr = S_OK;\n            break;\n        }\n        j += cnt;\n    }\n\n    if (hr == S_FALSE)\n    {\n        int idx = (lIndex - j);\n        int num_titles = m_pDemuxer->GetNumTitles();\n        if (num_titles > 1 && idx >= 0 && idx < num_titles)\n        {\n            if (ppmt)\n                *ppmt = nullptr;\n            if (pdwFlags)\n                *pdwFlags =\n                    m_pDemuxer->GetTitle() == idx ? (AMSTREAMSELECTINFO_ENABLED | AMSTREAMSELECTINFO_EXCLUSIVE) : 0;\n            if (pdwGroup)\n                *pdwGroup = 18;\n            if (ppObject)\n                *ppObject = nullptr;\n            if (ppUnk)\n                *ppUnk = nullptr;\n            m_pDemuxer->GetTitleInfo(idx, nullptr, ppszName);\n\n            hr = S_OK;\n        }\n    }\n\n    return hr;\n}\n\n// setting helpers\nstd::list<std::string> CLAVSplitter::GetPreferredAudioLanguageList()\n{\n    std::list<std::string> list;\n\n    char *buffer = CoTaskGetMultiByteFromWideChar(CP_UTF8, 0, m_settings.prefAudioLangs.c_str(), -1);\n    if (!buffer)\n        return list;\n\n    split(std::string(buffer), std::string(\",; \"), list);\n    SAFE_CO_FREE(buffer);\n\n    return list;\n}\n\nstd::list<CSubtitleSelector> CLAVSplitter::GetSubtitleSelectors()\n{\n    std::list<CSubtitleSelector> selectorList;\n\n    std::string separators = \",; \";\n    std::list<std::string> tokenList;\n\n    if (m_settings.subtitleMode == LAVSubtitleMode_NoSubs)\n    {\n        // Do nothing\n    }\n    else if (m_settings.subtitleMode == LAVSubtitleMode_Default ||\n             m_settings.subtitleMode == LAVSubtitleMode_ForcedOnly)\n    {\n        // Convert to wide-char to utf8\n        char *buffer = CoTaskGetMultiByteFromWideChar(CP_UTF8, 0, m_settings.prefSubLangs.c_str(), -1);\n        if (!buffer)\n            return selectorList;\n\n        std::list<std::string> langList;\n        split(std::string(buffer), separators, langList);\n        SAFE_CO_FREE(buffer);\n\n        // If no languages have been set, prefer the forced/default streams as specified by the audio languages\n        bool bNoLanguage = false;\n        if (langList.empty())\n        {\n            langList = GetPreferredAudioLanguageList();\n            bNoLanguage = true;\n        }\n\n        for (const std::string &lang : langList)\n        {\n            std::string token = \"*:\" + lang;\n            if (m_settings.subtitleMode == LAVSubtitleMode_ForcedOnly || bNoLanguage)\n            {\n                if (m_settings.subtitleMode == LAVSubtitleMode_Default)\n                    tokenList.push_back(token + \"|d\");\n                tokenList.push_back(token + \"|f\");\n            }\n            else\n            {\n                tokenList.push_back(token + \"|d\");\n                tokenList.push_back(token + \"|!hf\");\n                tokenList.push_back(token + \"|f\");\n            }\n        }\n\n        // Add fallbacks (forced/default)\n        if (m_settings.subtitleMode == LAVSubtitleMode_Default)\n            tokenList.push_back(\"*:*|d\");\n        tokenList.push_back(\"*:*|f\");\n    }\n    else if (m_settings.subtitleMode == LAVSubtitleMode_Advanced)\n    {\n        // Convert to wide-char to utf8\n        char *buffer = CoTaskGetMultiByteFromWideChar(CP_UTF8, 0, m_settings.subtitleAdvanced.c_str(), -1);\n        if (!buffer)\n            return selectorList;\n\n        split(std::string(buffer), separators, tokenList);\n        SAFE_CO_FREE(buffer);\n    }\n\n    // Add the \"off\" termination element\n    tokenList.push_back(\"*:off\");\n\n    std::regex advRegex(\"(?:(\\\\*|[[:alpha:]]+):)?\" // audio language\n                        \"(\\\\*|[[:alpha:]]+)\"       // subtitle language\n                        \"(?:\\\\|([fdnh]*!?[fdnh]+))?\"    // flags\n                        \"(?:@([^\" +\n                        separators + \"]+))?\" // subtitle track name substring\n    );\n    for (const std::string &token : tokenList)\n    {\n        std::cmatch res;\n        bool found = std::regex_search(token.c_str(), res, advRegex);\n        if (found)\n        {\n            CSubtitleSelector selector;\n            selector.audioLanguage = res[1].str().empty() ? \"*\" : ProbeForISO6392(res[1].str().c_str());\n            selector.subtitleLanguage = ProbeForISO6392(res[2].str().c_str());\n            selector.dwFlagsSet = 0;\n            selector.dwFlagsNot = 0;\n\n            // Parse flags\n            std::string flags = res[3];\n            std::string flagsSet;\n            std::string flagsNot;\n            if (flags.find('!') != flags.npos)\n            {\n                flagsSet = flags.substr(0, flags.find('!'));\n                flagsNot = flags.substr(flags.find('!')+1);\n            }\n            else\n            {\n                flagsSet = flags;\n                flagsNot = \"\";\n            }\n            if (flagsSet.length() > 0)\n            {\n                if (flagsSet.find('d') != std::string::npos)\n                    selector.dwFlagsSet |= SUBTITLE_FLAG_DEFAULT;\n                if (flagsSet.find('f') != std::string::npos)\n                    selector.dwFlagsSet |= SUBTITLE_FLAG_FORCED;\n                if (flagsSet.find('n') != std::string::npos)\n                    selector.dwFlagsSet |= SUBTITLE_FLAG_NORMAL;\n                if (flagsSet.find('h') != std::string::npos)\n                    selector.dwFlagsSet |= SUBTITLE_FLAG_IMPAIRED;\n\n                if (m_settings.subtitleMode == LAVSubtitleMode_Default)\n                {\n                    if (selector.subtitleLanguage == \"*\" && (selector.dwFlagsSet & SUBTITLE_FLAG_DEFAULT))\n                        selector.dwFlagsSet |= SUBTITLE_FLAG_VIRTUAL;\n                }\n                else\n                {\n                    if (selector.dwFlagsSet & SUBTITLE_FLAG_FORCED)\n                        selector.dwFlagsSet |= SUBTITLE_FLAG_VIRTUAL;\n                }\n            }\n            if (flagsNot.length() > 0)\n            {\n                if (flagsNot.find('d') != std::string::npos)\n                    selector.dwFlagsNot |= SUBTITLE_FLAG_DEFAULT;\n                if (flagsNot.find('f') != std::string::npos)\n                    selector.dwFlagsNot |= SUBTITLE_FLAG_FORCED;\n                if (flagsNot.find('n') != std::string::npos)\n                    selector.dwFlagsNot |= SUBTITLE_FLAG_NORMAL;\n                if (flagsNot.find('h') != std::string::npos)\n                    selector.dwFlagsNot |= SUBTITLE_FLAG_IMPAIRED;\n            }\n\n            selector.subtitleTrackName = res[4];\n\n            selectorList.push_back(selector);\n            DbgLog((LOG_TRACE, 10,\n                    L\"::GetSubtitleSelectors(): Parsed selector \\\"%S\\\" to: %S -> %S (flagsSet: 0x%x, flagsNot: 0x%x, match: %S)\",\n                    token.c_str(), selector.audioLanguage.c_str(), selector.subtitleLanguage.c_str(),\n                    selector.dwFlagsSet, selector.dwFlagsNot,\n                    selector.subtitleTrackName.c_str()));\n        }\n        else\n        {\n            DbgLog((LOG_ERROR, 10, L\"::GetSubtitleSelectors(): Selector string \\\"%S\\\" could not be parsed\",\n                    token.c_str()));\n        }\n    }\n\n    return selectorList;\n}\n\n// Settings\n// ILAVAudioSettings\nHRESULT CLAVSplitter::SetRuntimeConfig(BOOL bRuntimeConfig)\n{\n    m_bRuntimeConfig = bRuntimeConfig;\n    LoadSettings();\n\n    // Tray Icon is disabled by default\n    SAFE_DELETE(m_pTrayIcon);\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::GetPreferredLanguages(LPWSTR *ppLanguages)\n{\n    CheckPointer(ppLanguages, E_POINTER);\n    size_t len = m_settings.prefAudioLangs.length() + 1;\n    if (len > 1)\n    {\n        *ppLanguages = (WCHAR *)CoTaskMemAlloc(sizeof(WCHAR) * len);\n        if (*ppLanguages)\n            wcsncpy_s(*ppLanguages, len, m_settings.prefAudioLangs.c_str(), _TRUNCATE);\n    }\n    else\n    {\n        *ppLanguages = nullptr;\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::SetPreferredLanguages(LPCWSTR pLanguages)\n{\n    m_settings.prefAudioLangs = std::wstring(pLanguages);\n    return SaveSettings();\n}\n\nSTDMETHODIMP CLAVSplitter::GetPreferredSubtitleLanguages(LPWSTR *ppLanguages)\n{\n    CheckPointer(ppLanguages, E_POINTER);\n    size_t len = m_settings.prefSubLangs.length() + 1;\n    if (len > 1)\n    {\n        *ppLanguages = (WCHAR *)CoTaskMemAlloc(sizeof(WCHAR) * len);\n        if (*ppLanguages)\n            wcsncpy_s(*ppLanguages, len, m_settings.prefSubLangs.c_str(), _TRUNCATE);\n    }\n    else\n    {\n        *ppLanguages = nullptr;\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::SetPreferredSubtitleLanguages(LPCWSTR pLanguages)\n{\n    m_settings.prefSubLangs = std::wstring(pLanguages);\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(LAVSubtitleMode) CLAVSplitter::GetSubtitleMode()\n{\n    return m_settings.subtitleMode;\n}\n\nSTDMETHODIMP CLAVSplitter::SetSubtitleMode(LAVSubtitleMode mode)\n{\n    m_settings.subtitleMode = mode;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetSubtitleMatchingLanguage()\n{\n    return FALSE;\n}\n\nSTDMETHODIMP CLAVSplitter::SetSubtitleMatchingLanguage(BOOL dwMode)\n{\n    return E_FAIL;\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetPGSForcedStream()\n{\n    return m_settings.PGSForcedStream;\n}\n\nSTDMETHODIMP CLAVSplitter::SetPGSForcedStream(BOOL bFlag)\n{\n    m_settings.PGSForcedStream = bFlag;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetPGSOnlyForced()\n{\n    return m_settings.PGSOnlyForced;\n}\n\nSTDMETHODIMP CLAVSplitter::SetPGSOnlyForced(BOOL bForced)\n{\n    m_settings.PGSOnlyForced = bForced;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(int) CLAVSplitter::GetVC1TimestampMode()\n{\n    return m_settings.vc1Mode;\n}\n\nSTDMETHODIMP CLAVSplitter::SetVC1TimestampMode(int iMode)\n{\n    m_settings.vc1Mode = iMode;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::IsVC1CorrectionRequired()\n{\n    return FilterInGraph(CLSID_LAVVideo, m_pGraph) ||\n           (FilterInGraph(CLSID_LAVCUVID, m_pGraph) &&\n            (_strnicmp(m_pDemuxer->GetContainerFormat(), \"matroska\", 8) == 0)) ||\n           FilterInGraph(CLSID_MPCVideoDec, m_pGraph) || FilterInGraph(CLSID_ffdshowDXVA, m_pGraph) ||\n           FilterInGraphWithInputSubtype(CLSID_madVR, m_pGraph, MEDIASUBTYPE_WVC1) ||\n           FilterInGraphWithInputSubtype(CLSID_DMOWrapperFilter, m_pGraph, MEDIASUBTYPE_WVC1);\n}\n\nSTDMETHODIMP CLAVSplitter::SetSubstreamsEnabled(BOOL bSubStreams)\n{\n    m_settings.substreams = bSubStreams;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetSubstreamsEnabled()\n{\n    return m_settings.substreams;\n}\n\nSTDMETHODIMP CLAVSplitter::SetVideoParsingEnabled(BOOL bEnabled)\n{\n    return E_FAIL;\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetVideoParsingEnabled()\n{\n    return TRUE;\n}\n\nSTDMETHODIMP CLAVSplitter::SetFixBrokenHDPVR(BOOL bEnabled)\n{\n    return E_FAIL;\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetFixBrokenHDPVR()\n{\n    return TRUE;\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::IsFormatEnabled(LPCSTR strFormat)\n{\n    std::string format(strFormat);\n    if (m_settings.formats.find(format) != m_settings.formats.end())\n    {\n        return m_settings.formats[format];\n    }\n    return FALSE;\n}\n\nSTDMETHODIMP_(HRESULT) CLAVSplitter::SetFormatEnabled(LPCSTR strFormat, BOOL bEnabled)\n{\n    std::string format(strFormat);\n    if (m_settings.formats.find(format) != m_settings.formats.end())\n    {\n        m_settings.formats[format] = bEnabled;\n        return SaveSettings();\n    }\n    return E_FAIL;\n}\n\nSTDMETHODIMP CLAVSplitter::SetStreamSwitchRemoveAudio(BOOL bEnabled)\n{\n    m_settings.StreamSwitchRemoveAudio = bEnabled;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetStreamSwitchRemoveAudio()\n{\n    return m_settings.StreamSwitchRemoveAudio;\n}\n\nSTDMETHODIMP CLAVSplitter::GetAdvancedSubtitleConfig(LPWSTR *ppAdvancedConfig)\n{\n    CheckPointer(ppAdvancedConfig, E_POINTER);\n    size_t len = m_settings.subtitleAdvanced.length() + 1;\n    if (len > 1)\n    {\n        *ppAdvancedConfig = (WCHAR *)CoTaskMemAlloc(sizeof(WCHAR) * len);\n        if (*ppAdvancedConfig)\n            wcsncpy_s(*ppAdvancedConfig, len, m_settings.subtitleAdvanced.c_str(), _TRUNCATE);\n    }\n    else\n    {\n        *ppAdvancedConfig = nullptr;\n    }\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::SetAdvancedSubtitleConfig(LPCWSTR pAdvancedConfig)\n{\n    m_settings.subtitleAdvanced = std::wstring(pAdvancedConfig);\n    return SaveSettings();\n}\n\nSTDMETHODIMP CLAVSplitter::SetUseAudioForHearingVisuallyImpaired(BOOL bEnabled)\n{\n    m_settings.ImpairedAudio = bEnabled;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetUseAudioForHearingVisuallyImpaired()\n{\n    return m_settings.ImpairedAudio;\n}\n\nSTDMETHODIMP CLAVSplitter::SetMaxQueueMemSize(DWORD dwMaxSize)\n{\n    m_settings.QueueMaxMemSize = dwMaxSize;\n    for (auto it = m_pPins.begin(); it != m_pPins.end(); it++)\n    {\n        (*it)->SetQueueSizes();\n    }\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(DWORD) CLAVSplitter::GetMaxQueueMemSize()\n{\n    return m_settings.QueueMaxMemSize;\n}\n\nSTDMETHODIMP CLAVSplitter::SetStreamSwitchReselectSubtitles(BOOL bEnabled)\n{\n    m_settings.StreamSwitchReselectSubs = bEnabled;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetStreamSwitchReselectSubtitles()\n{\n    return m_settings.StreamSwitchReselectSubs;\n}\n\nSTDMETHODIMP CLAVSplitter::SetTrayIcon(BOOL bEnabled)\n{\n    m_settings.TrayIcon = bEnabled;\n    // The tray icon is created if not yet done so, however its not removed on the fly\n    // Removing the icon on the fly can cause deadlocks if the config is changed from the icons thread\n    if (bEnabled && m_pGraph && !m_pTrayIcon)\n    {\n        CreateTrayIcon();\n    }\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetTrayIcon()\n{\n    return m_settings.TrayIcon;\n}\n\nSTDMETHODIMP CLAVSplitter::SetPreferHighQualityAudioStreams(BOOL bEnabled)\n{\n    m_settings.PreferHighQualityAudio = bEnabled;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetPreferHighQualityAudioStreams()\n{\n    return m_settings.PreferHighQualityAudio;\n}\n\nSTDMETHODIMP CLAVSplitter::SetLoadMatroskaExternalSegments(BOOL bEnabled)\n{\n    m_settings.MatroskaExternalSegments = bEnabled;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(BOOL) CLAVSplitter::GetLoadMatroskaExternalSegments()\n{\n    return m_settings.MatroskaExternalSegments;\n}\n\nSTDMETHODIMP CLAVSplitter::GetFormats(LPSTR **formats, UINT *nFormats)\n{\n    CheckPointer(formats, E_POINTER);\n    CheckPointer(nFormats, E_POINTER);\n\n    *nFormats = (UINT)m_InputFormats.size();\n\n    *formats = (LPSTR *)CoTaskMemAlloc(sizeof(LPSTR) * *nFormats);\n    CheckPointer(*formats, E_OUTOFMEMORY);\n\n    size_t i = 0;\n    for (auto it = m_InputFormats.begin(); it != m_InputFormats.end(); it++, i++)\n    {\n        size_t len = strlen(it->strName) + 1;\n        (*formats)[i] = (LPSTR)CoTaskMemAlloc(sizeof(CHAR) * len);\n        if (!(*formats)[i])\n        {\n            break;\n        }\n        strcpy_s((*formats)[i], len, it->strName);\n    }\n\n    if (i != *nFormats)\n    {\n        for (size_t j = 0; j < i; j++)\n        {\n            CoTaskMemFree((*formats)[i]);\n        }\n        CoTaskMemFree(*formats);\n        *formats = nullptr;\n\n        return E_OUTOFMEMORY;\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVSplitter::SetNetworkStreamAnalysisDuration(DWORD dwDuration)\n{\n    m_settings.NetworkAnalysisDuration = dwDuration;\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(DWORD) CLAVSplitter::GetNetworkStreamAnalysisDuration()\n{\n    return m_settings.NetworkAnalysisDuration;\n}\n\nSTDMETHODIMP CLAVSplitter::SetMaxQueueSize(DWORD dwMaxSize)\n{\n    m_settings.QueueMaxPackets = dwMaxSize;\n    for (auto it = m_pPins.begin(); it != m_pPins.end(); it++)\n    {\n        (*it)->SetQueueSizes();\n    }\n    return SaveSettings();\n}\n\nSTDMETHODIMP_(DWORD) CLAVSplitter::GetMaxQueueSize()\n{\n    return m_settings.QueueMaxPackets;\n}\n\nSTDMETHODIMP_(std::set<FormatInfo> &) CLAVSplitter::GetInputFormats()\n{\n    return m_InputFormats;\n}\n\nCLAVSplitterSource::CLAVSplitterSource(LPUNKNOWN pUnk, HRESULT *phr)\n    : CLAVSplitter(pUnk, phr)\n{\n    m_clsid = __uuidof(CLAVSplitterSource);\n    SAFE_DELETE(m_pInput);\n}\n\nCLAVSplitterSource::~CLAVSplitterSource()\n{\n}\n\nSTDMETHODIMP CLAVSplitterSource::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    *ppv = nullptr;\n\n    return QI(IFileSourceFilter) QI(IURLSourceFilterLAV) QI(IAMOpenProgress) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitter.def",
    "content": "; LAVFDShowSplitter.def ; declares the exports\n\nLIBRARY         \"LAVSplitter.ax\"\n\nEXPORTS\n                DllGetClassObject PRIVATE\n                DllCanUnloadNow PRIVATE\n                DllRegisterServer PRIVATE\n                DllUnregisterServer PRIVATE\n                OpenConfiguration PRIVATE\n"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitter.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#pragma once\n\n#include <string>\n#include <list>\n#include <set>\n#include <vector>\n#include <map>\n#include \"PacketQueue.h\"\n\n#include \"BaseDemuxer.h\"\n\n#include \"LAVSplitterSettingsInternal.h\"\n#include \"SettingsProp.h\"\n#include \"IBufferInfo.h\"\n#include \"IURLSourceFilterLAV.h\"\n\n#include \"ISpecifyPropertyPages2.h\"\n\n#include \"LAVSplitterTrayIcon.h\"\n\n#define LAVF_REGISTRY_KEY L\"Software\\\\LAV\\\\Splitter\"\n#define LAVF_REGISTRY_KEY_FORMATS LAVF_REGISTRY_KEY L\"\\\\Formats\"\n#define LAVF_LOG_FILE L\"LAVSplitter.txt\"\n\n#define MAX_PTS_SHIFT 50000000i64\n\nclass CLAVOutputPin;\nclass CLAVInputPin;\n\n#ifdef _MSC_VER\n#pragma warning(disable : 4355)\n#endif\n\nclass __declspec(uuid(\"171252A0-8820-4AFE-9DF8-5C92B2D66B04\")) CLAVSplitter\n    : public CBaseFilter\n    , public CCritSec\n    , protected CAMThread\n    , public IFileSourceFilter\n    , public IURLSourceFilterLAV\n    , public IMediaSeeking\n    , public IAMStreamSelect\n    , public IAMOpenProgress\n    , public ILAVFSettingsInternal\n    , public ISpecifyPropertyPages2\n    , public IObjectWithSite\n    , public IBufferInfo\n{\n  public:\n    CLAVSplitter(LPUNKNOWN pUnk, HRESULT *phr);\n    virtual ~CLAVSplitter();\n\n    // IUnknown\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // CBaseFilter methods\n    int GetPinCount();\n    CBasePin *GetPin(int n);\n    STDMETHODIMP GetClassID(CLSID *pClsID);\n\n    STDMETHODIMP Stop();\n    STDMETHODIMP Pause();\n    STDMETHODIMP Run(REFERENCE_TIME tStart);\n\n    STDMETHODIMP JoinFilterGraph(IFilterGraph *pGraph, LPCWSTR pName);\n\n    // IFileSourceFilter\n    STDMETHODIMP Load(LPCOLESTR pszFileName, const AM_MEDIA_TYPE *pmt);\n    STDMETHODIMP GetCurFile(LPOLESTR *ppszFileName, AM_MEDIA_TYPE *pmt);\n\n    // IURLSourceFilterLAV\n    STDMETHODIMP LoadURL(LPCOLESTR pszURL, LPCOLESTR pszUserAgent, LPCOLESTR pszReferrer);\n\n    // IMediaSeeking\n    STDMETHODIMP GetCapabilities(DWORD *pCapabilities);\n    STDMETHODIMP CheckCapabilities(DWORD *pCapabilities);\n    STDMETHODIMP IsFormatSupported(const GUID *pFormat);\n    STDMETHODIMP QueryPreferredFormat(GUID *pFormat);\n    STDMETHODIMP GetTimeFormat(GUID *pFormat);\n    STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);\n    STDMETHODIMP SetTimeFormat(const GUID *pFormat);\n    STDMETHODIMP GetDuration(LONGLONG *pDuration);\n    STDMETHODIMP GetStopPosition(LONGLONG *pStop);\n    STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent);\n    STDMETHODIMP ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source,\n                                   const GUID *pSourceFormat);\n    STDMETHODIMP SetPositions(LONGLONG *pCurrent, DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags);\n    STDMETHODIMP GetPositions(LONGLONG *pCurrent, LONGLONG *pStop);\n    STDMETHODIMP GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest);\n    STDMETHODIMP SetRate(double dRate);\n    STDMETHODIMP GetRate(double *pdRate);\n    STDMETHODIMP GetPreroll(LONGLONG *pllPreroll);\n\n    // IAMStreamSelect\n    STDMETHODIMP Count(DWORD *pcStreams);\n    STDMETHODIMP Enable(long lIndex, DWORD dwFlags);\n    STDMETHODIMP Info(long lIndex, AM_MEDIA_TYPE **ppmt, DWORD *pdwFlags, LCID *plcid, DWORD *pdwGroup,\n                      WCHAR **ppszName, IUnknown **ppObject, IUnknown **ppUnk);\n\n    // IAMOpenProgress\n    STDMETHODIMP QueryProgress(LONGLONG *pllTotal, LONGLONG *pllCurrent);\n    STDMETHODIMP AbortOperation();\n\n    // ISpecifyPropertyPages2\n    STDMETHODIMP GetPages(CAUUID *pPages);\n    STDMETHODIMP CreatePage(const GUID &guid, IPropertyPage **ppPage);\n\n    // IObjectWithSite\n    STDMETHODIMP SetSite(IUnknown *pUnkSite);\n    STDMETHODIMP GetSite(REFIID riid, void **ppvSite);\n\n    // IBufferInfo\n    STDMETHODIMP_(int) GetCount();\n    STDMETHODIMP GetStatus(int i, int &samples, int &size);\n    STDMETHODIMP_(DWORD) GetPriority();\n\n    // ILAVFSettings\n    STDMETHODIMP SetRuntimeConfig(BOOL bRuntimeConfig);\n    STDMETHODIMP GetPreferredLanguages(LPWSTR *ppLanguages);\n    STDMETHODIMP SetPreferredLanguages(LPCWSTR pLanguages);\n    STDMETHODIMP GetPreferredSubtitleLanguages(LPWSTR *ppLanguages);\n    STDMETHODIMP SetPreferredSubtitleLanguages(LPCWSTR pLanguages);\n    STDMETHODIMP_(LAVSubtitleMode) GetSubtitleMode();\n    STDMETHODIMP SetSubtitleMode(LAVSubtitleMode mode);\n    STDMETHODIMP_(BOOL) GetSubtitleMatchingLanguage();\n    STDMETHODIMP SetSubtitleMatchingLanguage(BOOL dwMode);\n    STDMETHODIMP_(BOOL) GetPGSForcedStream();\n    STDMETHODIMP SetPGSForcedStream(BOOL bFlag);\n    STDMETHODIMP_(BOOL) GetPGSOnlyForced();\n    STDMETHODIMP SetPGSOnlyForced(BOOL bForced);\n    STDMETHODIMP_(int) GetVC1TimestampMode();\n    STDMETHODIMP SetVC1TimestampMode(int iMode);\n    STDMETHODIMP SetSubstreamsEnabled(BOOL bSubStreams);\n    STDMETHODIMP_(BOOL) GetSubstreamsEnabled();\n    STDMETHODIMP SetVideoParsingEnabled(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetVideoParsingEnabled();\n    STDMETHODIMP SetFixBrokenHDPVR(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetFixBrokenHDPVR();\n    STDMETHODIMP_(HRESULT) SetFormatEnabled(LPCSTR strFormat, BOOL bEnabled);\n    STDMETHODIMP_(BOOL) IsFormatEnabled(LPCSTR strFormat);\n    STDMETHODIMP SetStreamSwitchRemoveAudio(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetStreamSwitchRemoveAudio();\n    STDMETHODIMP GetAdvancedSubtitleConfig(LPWSTR *ppAdvancedConfig);\n    STDMETHODIMP SetAdvancedSubtitleConfig(LPCWSTR pAdvancedConfig);\n    STDMETHODIMP SetUseAudioForHearingVisuallyImpaired(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetUseAudioForHearingVisuallyImpaired();\n    STDMETHODIMP SetMaxQueueMemSize(DWORD dwMaxSize);\n    STDMETHODIMP_(DWORD) GetMaxQueueMemSize();\n    STDMETHODIMP SetTrayIcon(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetTrayIcon();\n    STDMETHODIMP SetPreferHighQualityAudioStreams(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetPreferHighQualityAudioStreams();\n    STDMETHODIMP SetLoadMatroskaExternalSegments(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetLoadMatroskaExternalSegments();\n    STDMETHODIMP GetFormats(LPSTR **formats, UINT *nFormats);\n    STDMETHODIMP SetNetworkStreamAnalysisDuration(DWORD dwDuration);\n    STDMETHODIMP_(DWORD) GetNetworkStreamAnalysisDuration();\n    STDMETHODIMP SetMaxQueueSize(DWORD dwMaxSize);\n    STDMETHODIMP_(DWORD) GetMaxQueueSize();\n    STDMETHODIMP SetStreamSwitchReselectSubtitles(BOOL bEnabled);\n    STDMETHODIMP_(BOOL) GetStreamSwitchReselectSubtitles();\n\n    // ILAVSplitterSettingsInternal\n    STDMETHODIMP_(LPCSTR) GetInputFormat()\n    {\n        if (m_pDemuxer)\n            return m_pDemuxer->GetContainerFormat();\n        return nullptr;\n    }\n    STDMETHODIMP_(std::set<FormatInfo> &) GetInputFormats();\n    STDMETHODIMP_(BOOL) IsVC1CorrectionRequired();\n    STDMETHODIMP_(CMediaType *) GetOutputMediatype(int stream);\n    STDMETHODIMP_(IFilterGraph *) GetFilterGraph()\n    {\n        if (m_pGraph)\n        {\n            m_pGraph->AddRef();\n            return m_pGraph;\n        }\n        return nullptr;\n    }\n\n    STDMETHODIMP_(DWORD) GetStreamFlags(DWORD dwStream)\n    {\n        if (m_pDemuxer)\n            return m_pDemuxer->GetStreamFlags(dwStream);\n        return 0;\n    }\n    STDMETHODIMP_(int) GetPixelFormat(DWORD dwStream)\n    {\n        if (m_pDemuxer)\n            return m_pDemuxer->GetPixelFormat(dwStream);\n        return AV_PIX_FMT_NONE;\n    }\n    STDMETHODIMP_(int) GetHasBFrames(DWORD dwStream)\n    {\n        if (m_pDemuxer)\n            return m_pDemuxer->GetHasBFrames(dwStream);\n        return -1;\n    }\n    STDMETHODIMP GetSideData(DWORD dwStream, GUID guidType, const BYTE **pData, size_t *pSize)\n    {\n        if (m_pDemuxer)\n            return m_pDemuxer->GetSideData(dwStream, guidType, pData, pSize);\n        else\n            return E_FAIL;\n    }\n\n    // Settings helper\n    std::list<std::string> GetPreferredAudioLanguageList();\n    std::list<CSubtitleSelector> GetSubtitleSelectors();\n\n    bool IsAnyPinDrying();\n    void SetFakeASFReader(BOOL bFlag) { m_bFakeASFReader = bFlag; }\n\n  protected:\n    // CAMThread\n    enum\n    {\n        CMD_EXIT,\n        CMD_SEEK\n    };\n    DWORD ThreadProc();\n\n    HRESULT DemuxSeek(REFERENCE_TIME rtStart);\n    HRESULT DemuxNextPacket();\n    HRESULT DeliverPacket(Packet *pPacket);\n\n    void DeliverBeginFlush();\n    void DeliverEndFlush();\n\n    STDMETHODIMP Close();\n    STDMETHODIMP DeleteOutputs();\n\n    STDMETHODIMP InitDemuxer();\n\n    friend class CLAVOutputPin;\n    STDMETHODIMP SetPositionsInternal(void *caller, LONGLONG *pCurrent, DWORD dwCurrentFlags, LONGLONG *pStop,\n                                      DWORD dwStopFlags);\n\n  public:\n    CLAVOutputPin *GetOutputPin(DWORD streamId, BOOL bActiveOnly = FALSE);\n    STDMETHODIMP RenameOutputPin(DWORD TrackNumSrc, DWORD TrackNumDst, std::deque<CMediaType> pmts);\n    STDMETHODIMP UpdateForcedSubtitleMediaType();\n    STDMETHODIMP ReselectSubs(int pid);\n\n    STDMETHODIMP CompleteInputConnection();\n    STDMETHODIMP BreakInputConnection();\n\n  protected:\n    STDMETHODIMP LoadDefaults();\n    STDMETHODIMP ReadSettings(HKEY rootKey);\n    STDMETHODIMP LoadSettings();\n    STDMETHODIMP SaveSettings();\n\n    STDMETHODIMP CreateTrayIcon();\n\n  protected:\n    CLAVInputPin *m_pInput;\n\n  private:\n    CCritSec m_csPins;\n    std::vector<CLAVOutputPin *> m_pPins;\n    std::vector<CLAVOutputPin *> m_pActivePins;\n    std::vector<CLAVOutputPin *> m_pRetiredPins;\n    std::set<DWORD> m_bDiscontinuitySent;\n\n    std::wstring m_fileName;\n    std::wstring m_processName;\n\n    CBaseDemuxer *m_pDemuxer = nullptr;\n\n    BOOL m_bPlaybackStarted = FALSE;\n    BOOL m_bFakeASFReader = FALSE;\n\n    // Times\n    REFERENCE_TIME m_rtStart = 0;\n    REFERENCE_TIME m_rtStop = 0;\n    REFERENCE_TIME m_rtCurrent = 0;\n    REFERENCE_TIME m_rtNewStart = 0;\n    REFERENCE_TIME m_rtNewStop = 0;\n    REFERENCE_TIME m_rtOffset = AV_NOPTS_VALUE;\n    double m_dRate = 1.0;\n    BOOL m_bStopValid = FALSE;\n\n    // Seeking\n    REFERENCE_TIME m_rtLastStart = _I64_MIN;\n    REFERENCE_TIME m_rtLastStop = _I64_MIN;\n    std::set<void *> m_LastSeekers;\n\n    CAMEvent m_ePlaybackInit{TRUE};\n\n    // flushing\n    bool m_fFlushing = FALSE;\n    CAMEvent m_eEndFlush;\n\n    std::set<FormatInfo> m_InputFormats;\n\n    // Settings\n    struct Settings\n    {\n        BOOL TrayIcon;\n        std::wstring prefAudioLangs;\n        std::wstring prefSubLangs;\n        std::wstring subtitleAdvanced;\n        LAVSubtitleMode subtitleMode;\n        BOOL PGSForcedStream;\n        BOOL PGSOnlyForced;\n        int vc1Mode;\n        BOOL substreams;\n\n        BOOL MatroskaExternalSegments;\n\n        BOOL StreamSwitchReselectSubs;\n\n        BOOL StreamSwitchRemoveAudio;\n        BOOL ImpairedAudio;\n        BOOL PreferHighQualityAudio;\n        DWORD QueueMaxPackets;\n        DWORD QueueMaxMemSize;\n        DWORD NetworkAnalysisDuration;\n\n        std::map<std::string, BOOL> formats;\n    } m_settings;\n\n    BOOL m_bRuntimeConfig = FALSE;\n\n    IUnknown *m_pSite = nullptr;\n    CBaseTrayIcon *m_pTrayIcon = nullptr;\n};\n\nclass __declspec(uuid(\"B98D13E7-55DB-4385-A33D-09FD1BA26338\")) CLAVSplitterSource : public CLAVSplitter\n{\n  public:\n    // construct only via class factory\n    CLAVSplitterSource(LPUNKNOWN pUnk, HRESULT *phr);\n    virtual ~CLAVSplitterSource();\n\n    // IUnknown\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n};\n"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitter.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n  <dependency>\n    <dependentAssembly>\n      <assemblyIdentity type=\"win32\" name=\"LAVFilters.Dependencies\" version=\"1.0.0.0\" />\n    </dependentAssembly>\n  </dependency>\n</assembly>\n"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitter.rc",
    "content": "// Microsoft Visual C++ generated resource script.\n//\n#include \"resource.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"winres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (United States) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Icon\n//\n\n// Icon with lowest ID value placed first to ensure application icon\n// remains consistent on all systems.\nIDI_ICON1               ICON                    \"..\\\\..\\\\resources\\\\white.ico\"\n\n#ifdef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// TEXTINCLUDE\n//\n\n1 TEXTINCLUDE \nBEGIN\n    \"resource.h\\0\"\nEND\n\n2 TEXTINCLUDE \nBEGIN\n    \"#include \"\"winres.h\"\"\\r\\n\"\n    \"\\0\"\nEND\n\n3 TEXTINCLUDE \nBEGIN\n    \"#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\\r\\n\"\n    \"LANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\\r\\n\"\n    \"#pragma code_page(1252)\\r\\n\"\n    \"#include \"\"LAVSplitter.rc2\"\" // non-Microsoft Visual C++ edited resources\\r\\n\"\n    \"#endif\\r\\n\"\n    \"\\0\"\nEND\n\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Dialog\n//\n\nIDD_PROPPAGE_LAVFSETTINGS DIALOGEX 0, 0, 400, 274\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0\nBEGIN\n    LTEXT           \"Preferred Languages\\nEnter your preferred languages as their 3-letter language codes, comma separated. (Example: \"\"eng,ger,fre\"\")\",IDC_LBL_PREF_LANG,7,7,386,27\n    EDITTEXT        IDC_PREF_LANG,7,35,386,14,ES_AUTOHSCROLL\n    LTEXT           \"Audio:\",IDC_LBL_PREF_LANG_AUDIO,7,25,31,8\n    EDITTEXT        IDC_PREF_LANG_SUBS,7,65,386,14,ES_AUTOHSCROLL\n    LTEXT           \"Subtitles:\",IDC_LBL_PREF_LANG_SUBS,7,55,47,8\n    COMBOBOX        IDC_SUBTITLE_MODE,99,104,121,100,CBS_DROPDOWNLIST | WS_VSCROLL | WS_TABSTOP\n    LTEXT           \"Subtitle Selection Mode:\",IDC_LBL_SUBMODE,7,107,83,8\n    LTEXT           \"\",IDC_SUBTITLE_NOTE,7,83,386,19\n    GROUPBOX        \"Blu-ray Subtitles (PGS)\",IDC_BD_SUBS,7,124,199,40\n    CONTROL         \"Enable Automatic Forced Subtitle Stream\",IDC_BD_SEPARATE_FORCED_SUBS,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,137,146,10\n    CONTROL         \"Deliver only Forced Subtitles\",IDC_BD_ONLY_FORCED_SUBS,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,150,159,10\n    GROUPBOX        \"Demuxer Settings\",IDC_DEMUXER_SETTINGS,7,170,199,70\n    CONTROL         \"Demux sub-streams separately\",IDC_SUBSTREAMS,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,181,115,10\n    CONTROL         \"Remove Audio Decoder on Audio Stream Switch\",IDC_STREAM_SWITCH_REMOVE_AUDIO,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,195,168,10\n    CONTROL         \"Prefer Audio Stream with the Highest Quality\",IDC_SELECT_AUDIO_QUALITY,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,209,171,10\n    CONTROL         \"Prefer Audio Streams for the Hearing/Visually Impaired\",IDC_IMPAIRED_AUDIO,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,15,223,188,10\n    GROUPBOX        \"Queue Settings\",IDC_QUEUE_SETTINGS,214,124,179,44\n    LTEXT           \"Maximum Queue Memory (MB):\",IDC_LBL_QUEUE_MEM,220,138,102,8\n    EDITTEXT        IDC_QUEUE_MEM,323,136,54,13,ES_AUTOHSCROLL,WS_EX_RIGHT\n    CONTROL         \"\",IDC_QUEUE_MEM_SPIN,\"msctls_updown32\",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,375,136,11,13\n    LTEXT           \"Maximum Queue Packets:\",IDC_LBL_QUEUE_PACKETS,220,153,102,8\n    EDITTEXT        IDC_QUEUE_PACKETS,323,151,54,13,ES_AUTOHSCROLL,WS_EX_RIGHT\n    CONTROL         \"\",IDC_QUEUE_PACKETS_SPIN,\"msctls_updown32\",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,375,151,11,13\n    CONTROL         \"Enable System Tray Icon\",IDC_TRAYICON,\"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,7,257,192,10\n    LTEXT           \"LAV Splitter x.xx\",IDC_SPLITTER_FOOTER,285,259,108,8,0,WS_EX_RIGHT\n    GROUPBOX        \"Format Settings\",IDC_FMT_SETTINGS,214,173,179,42\n    CONTROL         \"Enable VC-1 Timestamp Correction\",IDC_VC1TIMESTAMP,\n                    \"Button\",BS_AUTO3STATE | WS_TABSTOP,221,185,126,10\n    CONTROL         \"Load Matroska Segments from external files\",IDC_MKV_EXTERNAL,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,221,199,156,10\n    GROUPBOX        \"Network Settings\",IDC_NETWORK_SETTINGS,214,217,179,35\n    LTEXT           \"Stream Analysis Duration:\",IDC_LBL_STREAM_BUFFER,220,231,102,8\n    EDITTEXT        IDC_STREAM_ANADUR,323,229,54,13,ES_AUTOHSCROLL,WS_EX_RIGHT\n    CONTROL         \"\",IDC_STREAM_ANADUR_SPIN,\"msctls_updown32\",UDS_SETBUDDYINT | UDS_ALIGNRIGHT | UDS_AUTOBUDDY | UDS_ARROWKEYS | UDS_NOTHOUSANDS | UDS_HOTTRACK,375,229,11,13\n    CONTROL         \"Reselect Subtitles on every Audio Switch\",IDC_STREAM_SWITCH_RESELECT_SUBS,\n                    \"Button\",BS_AUTOCHECKBOX | WS_TABSTOP,234,105,159,10\nEND\n\nIDD_PROPPAGE_FORMATS DIALOGEX 0, 0, 235, 283\nSTYLE DS_SETFONT | DS_FIXEDSYS | WS_CHILD\nFONT 8, \"MS Shell Dlg\", 400, 0, 0x0\nBEGIN\n    CONTROL         \"\",IDC_FORMATS,\"SysListView32\",LVS_REPORT | LVS_SINGLESEL | LVS_SHOWSELALWAYS | LVS_NOSORTHEADER | WS_BORDER | WS_TABSTOP,7,43,221,233\n    LTEXT           \"Current Input Format: \",IDC_LBL_INPUT,7,7,77,8\n    LTEXT           \"matroska\",IDC_CUR_INPUT,85,7,117,8\n    LTEXT           \"Select which formats LAV Splitter will demux.\\nNote: This has no effect when the file is opened directly by LAV, and only if LAV is loaded automatically in the graph!\",IDC_LBL_FORMATS,7,16,221,25\nEND\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// DESIGNINFO\n//\n\n#ifdef APSTUDIO_INVOKED\nGUIDELINES DESIGNINFO\nBEGIN\n    IDD_PROPPAGE_LAVFSETTINGS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 393\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 267\n    END\n\n    IDD_PROPPAGE_FORMATS, DIALOG\n    BEGIN\n        LEFTMARGIN, 7\n        RIGHTMARGIN, 228\n        TOPMARGIN, 7\n        BOTTOMMARGIN, 276\n    END\nEND\n#endif    // APSTUDIO_INVOKED\n\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// String Table\n//\n\nSTRINGTABLE\nBEGIN\n    IDS_PAGE_TITLE          \"LAV Splitter\"\n    IDS_SUBMODE_NO_SUBS     \"No Subtitles\"\n    IDS_SUBMODE_FORCED_SUBS \"Only Forced Subtitles\"\n    IDS_SUBMODE_DEFAULT     \"Default\"\n    IDS_SUBMODE_ADVANCED    \"Advanced\"\n    IDS_INPUT_FORMATS       \"Input Formats\"\nEND\n\n#endif    // English (United States) resources\n/////////////////////////////////////////////////////////////////////////////\n\n\n\n#ifndef APSTUDIO_INVOKED\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 3 resource.\n//\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n#include \"LAVSplitter.rc2\" // non-Microsoft Visual C++ edited resources\n#endif\n\n/////////////////////////////////////////////////////////////////////////////\n#endif    // not APSTUDIO_INVOKED\n\n"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitter.rc2",
    "content": "//\n// LAVSplitter.rc2 - resources Microsoft Visual C++ does not edit directly\n//\n\n#ifdef APSTUDIO_INVOKED\n#error This file is not editable by Microsoft Visual C++\n#endif //APSTUDIO_INVOKED\n\n/////////////////////////////////////////////////////////////////////////////\n// Add manually edited resources here...\n\n/////////////////////////////////////////////////////////////////////////////\n\n#include \"resource.h\"\n#include \"..\\..\\common\\includes\\version.h\"\n\n#define APSTUDIO_READONLY_SYMBOLS\n/////////////////////////////////////////////////////////////////////////////\n//\n// Generated from the TEXTINCLUDE 2 resource.\n//\n#include \"winres.h\"\n\n/////////////////////////////////////////////////////////////////////////////\n#undef APSTUDIO_READONLY_SYMBOLS\n\n/////////////////////////////////////////////////////////////////////////////\n// English (United States) resources\n\n/////////////////////////////////////////////////////////////////////////////\n// Neutral (Sys. Default) resources\n\n#if !defined(AFX_RESOURCE_DLL) || defined(AFX_TARG_ENU)\nLANGUAGE LANG_ENGLISH, SUBLANG_ENGLISH_US\n#pragma code_page(1252)\n\n/////////////////////////////////////////////////////////////////////////////\n//\n// Version\n//\n\nVS_VERSION_INFO VERSIONINFO\n FILEVERSION LAV_VERSION_TAG\n PRODUCTVERSION LAV_VERSION_TAG\n FILEFLAGSMASK 0x3fL\n#ifdef _DEBUG\n FILEFLAGS 0x1L\n#else\n FILEFLAGS 0x0L\n#endif\n FILEOS 0x40004L\n FILETYPE 0x2L\n FILESUBTYPE 0x0L\nBEGIN\n    BLOCK \"StringFileInfo\"\n    BEGIN\n        BLOCK \"040904b0\"\n        BEGIN\n            VALUE \"CompanyName\", \"1f0.de - Hendrik Leppkes\"\n            VALUE \"FileDescription\", \"LAV Splitter - DirectShow Media Splitter\"\n            VALUE \"FileVersion\", LAV_VERSION_STR\n            VALUE \"InternalName\", \"LAVSplitter.ax\"\n            VALUE \"LegalCopyright\", \"Copyright (C) 2010-2021 Hendrik Leppkes\"\n            VALUE \"OriginalFilename\", \"LAVSplitter.ax\"\n            VALUE \"ProductName\", \"LAV Splitter\"\n            VALUE \"ProductVersion\", LAV_VERSION_STR\n        END\n    END\n    BLOCK \"VarFileInfo\"\n    BEGIN\n        VALUE \"Translation\", 0x409, 1200\n    END\nEND\n\n#endif\n"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitter.vcxproj",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project DefaultTargets=\"Build\" ToolsVersion=\"Current\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup Label=\"ProjectConfigurations\">\n    <ProjectConfiguration Include=\"Debug|Win32\">\n      <Configuration>Debug</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Debug|x64\">\n      <Configuration>Debug</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|Win32\">\n      <Configuration>Release</Configuration>\n      <Platform>Win32</Platform>\n    </ProjectConfiguration>\n    <ProjectConfiguration Include=\"Release|x64\">\n      <Configuration>Release</Configuration>\n      <Platform>x64</Platform>\n    </ProjectConfiguration>\n  </ItemGroup>\n  <PropertyGroup Label=\"Globals\">\n    <ProjectGuid>{F475F86F-3F7F-4B1D-82A6-078339F599FD}</ProjectGuid>\n    <Keyword>Win32Proj</Keyword>\n    <RootNamespace>LAVSplitter</RootNamespace>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.Default.props\" />\n  <Import Project=\"$(SolutionDir)common\\platform.props\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>true</UseDebugLibraries>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\" Label=\"Configuration\">\n    <ConfigurationType>DynamicLibrary</ConfigurationType>\n    <UseDebugLibraries>false</UseDebugLibraries>\n    <WholeProgramOptimization>true</WholeProgramOptimization>\n    <CharacterSet>Unicode</CharacterSet>\n  </PropertyGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.props\" />\n  <Import Project=\"$(SolutionDir)common\\common.props\" />\n  <ImportGroup Label=\"ExtensionSettings\">\n  </ImportGroup>\n  <ImportGroup Label=\"PropertySheets\">\n    <Import Project=\"$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props\" Condition=\"exists('$(UserRootDir)\\Microsoft.Cpp.$(Platform).user.props')\" Label=\"LocalAppDataPlatform\" />\n  </ImportGroup>\n  <PropertyGroup Label=\"UserMacros\" />\n  <PropertyGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <TargetExt>.ax</TargetExt>\n    <OutDir>$(SolutionDir)bin_$(PlatformName)d\\</OutDir>\n  </PropertyGroup>\n  <PropertyGroup Condition=\"'$(Configuration)'=='Release'\">\n    <TargetExt>.ax</TargetExt>\n    <OutDir>$(SolutionDir)bin_$(PlatformName)\\$(ProjectName)\\</OutDir>\n    <CustomBuildAfterTargets>Build</CustomBuildAfterTargets>\n  </PropertyGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Debug'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;_DEBUG;_WINDOWS;_USRDLL;LAVSPLITTER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>..\\Demuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <AdditionalDependencies>advapi32.lib;ole32.lib;winmm.lib;user32.lib;oleaut32.lib;Comctl32.lib;shell32.lib;version.lib;Shlwapi.lib;avformat-lav.lib;avutil-lav.lib;avcodec-lav.lib</AdditionalDependencies>\n      <ModuleDefinitionFile>LAVSplitter.def</ModuleDefinitionFile>\n    </Link>\n    <Manifest>\n      <AdditionalManifestFiles>$(ProjectDir)\\$(ProjectName).manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>\n    </Manifest>\n  </ItemDefinitionGroup>\n  <ItemDefinitionGroup Condition=\"'$(Configuration)'=='Release'\">\n    <ClCompile>\n      <PreprocessorDefinitions>WIN32;NDEBUG;_WINDOWS;_USRDLL;LAVSPLITTER_EXPORTS;%(PreprocessorDefinitions)</PreprocessorDefinitions>\n      <AdditionalIncludeDirectories>..\\Demuxers;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>\n    </ClCompile>\n    <Link>\n      <AdditionalDependencies>advapi32.lib;ole32.lib;winmm.lib;user32.lib;oleaut32.lib;Comctl32.lib;shell32.lib;version.lib;Shlwapi.lib;avformat-lav.lib;avutil-lav.lib;avcodec-lav.lib</AdditionalDependencies>\n      <ModuleDefinitionFile>LAVSplitter.def</ModuleDefinitionFile>\n    </Link>\n    <CustomBuildStep>\n      <Command>copy \"$(TargetDir)\\$(TargetName)$(TargetExt)\" \"$(OutDir)..\"</Command>\n      <Outputs>$(OutDir)..\\$(TargetFileName)</Outputs>\n      <Inputs>$(TargetDir)\\$(TargetName)$(TargetExt)</Inputs>\n    </CustomBuildStep>\n    <Manifest>\n      <AdditionalManifestFiles>$(ProjectDir)\\$(ProjectName).manifest %(AdditionalManifestFiles)</AdditionalManifestFiles>\n    </Manifest>\n  </ItemDefinitionGroup>\n  <ItemGroup>\n    <ClCompile Include=\"dllmain.cpp\" />\n    <ClCompile Include=\"InputPin.cpp\" />\n    <ClCompile Include=\"LAVSplitterTrayIcon.cpp\" />\n    <ClCompile Include=\"PacketAllocator.cpp\" />\n    <ClCompile Include=\"SettingsProp.cpp\" />\n    <ClCompile Include=\"stdafx.cpp\">\n      <PrecompiledHeader>Create</PrecompiledHeader>\n    </ClCompile>\n    <ClCompile Include=\"PacketQueue.cpp\" />\n    <ClCompile Include=\"OutputPin.cpp\" />\n    <ClCompile Include=\"LAVSplitter.cpp\" />\n    <ClCompile Include=\"StreamParser.cpp\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"..\\..\\common\\includes\\common_defines.h\" />\n    <ClInclude Include=\"..\\..\\common\\includes\\LAVSplitterSettingsInternal.h\" />\n    <ClInclude Include=\"..\\..\\common\\includes\\moreuuids.h\" />\n    <ClInclude Include=\"..\\..\\common\\includes\\version.h\" />\n    <ClInclude Include=\"..\\..\\include\\IBitRateInfo.h\" />\n    <ClInclude Include=\"..\\..\\include\\IBufferInfo.h\" />\n    <ClInclude Include=\"..\\..\\include\\IDSMResourceBag.h\" />\n    <ClInclude Include=\"..\\..\\include\\IGraphRebuildDelegate.h\" />\n    <ClInclude Include=\"..\\..\\include\\IKeyFrameInfo.h\" />\n    <ClInclude Include=\"..\\..\\include\\ILAVDynamicAllocator.h\" />\n    <ClInclude Include=\"..\\..\\include\\IPinSegmentEx.h\" />\n    <ClInclude Include=\"..\\..\\include\\ISpecifyPropertyPages2.h\" />\n    <ClInclude Include=\"..\\..\\include\\IStreamSourceControl.h\" />\n    <ClInclude Include=\"..\\..\\include\\ITrackInfo.h\" />\n    <ClInclude Include=\"..\\..\\include\\LAVSplitterSettings.h\" />\n    <ClInclude Include=\"InputPin.h\" />\n    <ClInclude Include=\"LAVSplitterTrayIcon.h\" />\n    <ClInclude Include=\"PacketAllocator.h\" />\n    <ClInclude Include=\"SettingsProp.h\" />\n    <ClInclude Include=\"resource.h\" />\n    <ClInclude Include=\"stdafx.h\" />\n    <ClInclude Include=\"PacketQueue.h\" />\n    <ClInclude Include=\"OutputPin.h\" />\n    <ClInclude Include=\"LAVSplitter.h\" />\n    <ClInclude Include=\"StreamParser.h\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"LAVSplitter.rc\" />\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"..\\..\\resources\\white.ico\" />\n    <None Include=\"LAVSplitter.rc2\" />\n  </ItemGroup>\n  <ItemGroup>\n    <CustomBuild Include=\"..\\..\\resources\\LAVFilters.Dependencies.manifest\">\n      <Command>copy \"%(FullPath)\" \"$(IntermediateOutputPath)..\"</Command>\n      <Message>Copying Manifest file</Message>\n      <Outputs>$(IntermediateOutputPath)..\\%(Filename)%(Extension);%(Outputs)</Outputs>\n    </CustomBuild>\n    <Manifest Include=\"LAVSplitter.manifest\" />\n  </ItemGroup>\n  <ItemGroup>\n    <ProjectReference Include=\"..\\..\\common\\baseclasses\\baseclasses.vcxproj\">\n      <Project>{e8a3f6fa-ae1c-4c8e-a0b6-9c8480324eaa}</Project>\n    </ProjectReference>\n    <ProjectReference Include=\"..\\..\\common\\DSUtilLite\\DSUtilLite.vcxproj\">\n      <Project>{0a058024-41f4-4509-97d2-803a1806ce86}</Project>\n    </ProjectReference>\n    <ProjectReference Include=\"..\\..\\libbluray\\libbluray.vcxproj\">\n      <Project>{e1da1b95-71f1-4c21-a271-121176925062}</Project>\n    </ProjectReference>\n    <ProjectReference Include=\"..\\Demuxers\\Demuxers.vcxproj\">\n      <Project>{e2012db5-33cb-44a7-b521-04287f6d0d80}</Project>\n    </ProjectReference>\n  </ItemGroup>\n  <Import Project=\"$(VCTargetsPath)\\Microsoft.Cpp.targets\" />\n  <ImportGroup Label=\"ExtensionTargets\">\n  </ImportGroup>\n</Project>"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitter.vcxproj.filters",
    "content": "﻿<?xml version=\"1.0\" encoding=\"utf-8\"?>\n<Project ToolsVersion=\"12.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">\n  <ItemGroup>\n    <Filter Include=\"Source Files\">\n      <UniqueIdentifier>{4FC737F1-C7A5-4376-A066-2A32D752A2FF}</UniqueIdentifier>\n      <Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\">\n      <UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>\n      <Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>\n    </Filter>\n    <Filter Include=\"Resource Files\">\n      <UniqueIdentifier>{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}</UniqueIdentifier>\n      <Extensions>rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms</Extensions>\n    </Filter>\n    <Filter Include=\"Header Files\\common\">\n      <UniqueIdentifier>{31a9533d-6d33-49b2-929c-40167cb6f0e8}</UniqueIdentifier>\n    </Filter>\n  </ItemGroup>\n  <ItemGroup>\n    <ClCompile Include=\"stdafx.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"dllmain.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"PacketQueue.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"OutputPin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"SettingsProp.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVSplitter.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"StreamParser.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"InputPin.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"PacketAllocator.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n    <ClCompile Include=\"LAVSplitterTrayIcon.cpp\">\n      <Filter>Source Files</Filter>\n    </ClCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <ClInclude Include=\"stdafx.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"PacketQueue.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"resource.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"OutputPin.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"SettingsProp.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVSplitter.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\common\\includes\\moreuuids.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\common\\includes\\version.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"StreamParser.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"InputPin.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\common\\includes\\LAVSplitterSettingsInternal.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"PacketAllocator.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"LAVSplitterTrayIcon.h\">\n      <Filter>Header Files</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\common\\includes\\common_defines.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IBitRateInfo.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IBufferInfo.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IDSMResourceBag.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IGraphRebuildDelegate.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IKeyFrameInfo.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\ILAVDynamicAllocator.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IPinSegmentEx.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\ISpecifyPropertyPages2.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\IStreamSourceControl.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\ITrackInfo.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n    <ClInclude Include=\"..\\..\\include\\LAVSplitterSettings.h\">\n      <Filter>Header Files\\common</Filter>\n    </ClInclude>\n  </ItemGroup>\n  <ItemGroup>\n    <ResourceCompile Include=\"LAVSplitter.rc\">\n      <Filter>Resource Files</Filter>\n    </ResourceCompile>\n  </ItemGroup>\n  <ItemGroup>\n    <None Include=\"LAVSplitter.rc2\">\n      <Filter>Resource Files</Filter>\n    </None>\n    <None Include=\"..\\..\\resources\\white.ico\">\n      <Filter>Resource Files</Filter>\n    </None>\n    <Manifest Include=\"LAVSplitter.manifest\">\n      <Filter>Resource Files</Filter>\n    </Manifest>\n  </ItemGroup>\n  <ItemGroup>\n    <CustomBuild Include=\"..\\..\\resources\\LAVFilters.Dependencies.manifest\">\n      <Filter>Resource Files</Filter>\n    </CustomBuild>\n  </ItemGroup>\n</Project>"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitterTrayIcon.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"LAVSplitterTrayIcon.h\"\n#include \"PopupMenu.h\"\n\n#include <Qnetwork.h>\n\n#define STREAM_CMD_OFFSET 100\n#define CHAPTER_CMD_OFFSET 500\n\nCLAVSplitterTrayIcon::CLAVSplitterTrayIcon(IBaseFilter *pFilter, const WCHAR *wszName, int resIcon)\n    : CBaseTrayIcon(pFilter, wszName, resIcon)\n{\n}\n\nCLAVSplitterTrayIcon::~CLAVSplitterTrayIcon(void)\n{\n}\n\nHMENU CLAVSplitterTrayIcon::GetPopupMenu()\n{\n    CheckPointer(m_pFilter, nullptr);\n    CPopupMenu menu;\n\n    IAMStreamSelect *pStreamSelect = nullptr;\n    if (SUCCEEDED(m_pFilter->QueryInterface(&pStreamSelect)))\n    {\n        DWORD dwStreams = 0;\n        if (FAILED(pStreamSelect->Count(&dwStreams)))\n            dwStreams = 0;\n        DWORD dwLastGroup = DWORD_MAX;\n        for (DWORD i = 0; i < dwStreams; i++)\n        {\n            DWORD dwFlags = 0, dwGroup = 0;\n            LPWSTR pszName = nullptr;\n            if (FAILED(pStreamSelect->Info(i, nullptr, &dwFlags, nullptr, &dwGroup, &pszName, nullptr, nullptr)))\n                continue;\n\n            if (dwGroup != dwLastGroup)\n            {\n                switch (dwGroup)\n                {\n                case 0: menu.AddItem(dwGroup, L\"Video\", FALSE, FALSE); break;\n                case 1: menu.AddItem(dwGroup, L\"Audio\", FALSE, FALSE); break;\n                case 2: menu.AddItem(dwGroup, L\"Subtitles\", FALSE, FALSE); break;\n                case 18: menu.AddItem(dwGroup, L\"Editions\", FALSE, FALSE); break;\n                default: menu.AddSeparator(); break;\n                }\n                dwLastGroup = dwGroup;\n            }\n            menu.AddItem(STREAM_CMD_OFFSET + i, pszName, dwFlags & AMSTREAMSELECTINFO_ENABLED);\n            CoTaskMemFree(pszName);\n        }\n        if (dwStreams)\n            menu.AddSeparator();\n        m_NumStreams = dwStreams;\n        SafeRelease(&pStreamSelect);\n    }\n\n    // Chapters\n    IAMExtendedSeeking *pExSeeking = nullptr;\n    if (SUCCEEDED(m_pFilter->QueryInterface(IID_IAMExtendedSeeking, (void **)&pExSeeking)))\n    {\n        long count = 0, current = 0;\n        if (FAILED(pExSeeking->get_MarkerCount(&count)))\n            count = 0;\n\n        if (FAILED(pExSeeking->get_CurrentMarker(&current)))\n            current = 0;\n\n        CPopupMenu chapters;\n        for (long i = 1; i <= count; i++)\n        {\n            double markerTime;\n            if (FAILED(pExSeeking->GetMarkerTime(i, &markerTime)))\n                continue;\n\n            BSTR bstrName = nullptr;\n            if (FAILED(pExSeeking->GetMarkerName(i, &bstrName)))\n                continue;\n\n            // Create compound chapter name\n            int total_seconds = (int)(markerTime + 0.5);\n            int seconds = total_seconds % 60;\n            int minutes = total_seconds / 60 % 60;\n            int hours = total_seconds / 3600;\n            WCHAR chapterName[512];\n            _snwprintf_s(chapterName, _TRUNCATE, L\"%s\\t[%02d:%02d:%02d]\", bstrName, hours, minutes, seconds);\n\n            // Sanitize any tab chars in the chapter name (replace by space)\n            // More then one tab in the string messes with the popup menu rendering\n            WCHAR *nextMatch, *tabMatch = wcsstr(chapterName, L\"\\t\");\n            while (nextMatch = wcsstr(tabMatch + 1, L\"\\t\"))\n            {\n                *tabMatch = L' ';\n                tabMatch = nextMatch;\n            }\n\n            chapters.AddItem(CHAPTER_CMD_OFFSET + i, chapterName, i == current);\n            SysFreeString(bstrName);\n        }\n        if (count)\n        {\n            menu.AddSubmenu(chapters.Finish(), L\"Chapters\");\n            menu.AddSeparator();\n        }\n        m_NumChapters = count;\n        SafeRelease(&pExSeeking);\n    }\n\n    menu.AddItem(STREAM_CMD_OFFSET - 1, L\"Properties\");\n\n    HMENU hMenu = menu.Finish();\n    return hMenu;\n}\n\nHRESULT CLAVSplitterTrayIcon::ProcessMenuCommand(HMENU hMenu, int cmd)\n{\n    CheckPointer(m_pFilter, E_FAIL);\n    DbgLog((LOG_TRACE, 10, L\"Menu Command %d\", cmd));\n    if (cmd >= STREAM_CMD_OFFSET && cmd < m_NumStreams + STREAM_CMD_OFFSET)\n    {\n        IAMStreamSelect *pStreamSelect = nullptr;\n        if (SUCCEEDED(m_pFilter->QueryInterface(&pStreamSelect)))\n        {\n            pStreamSelect->Enable(cmd - STREAM_CMD_OFFSET, AMSTREAMSELECTENABLE_ENABLE);\n            SafeRelease(&pStreamSelect);\n        }\n    }\n    else if (cmd > CHAPTER_CMD_OFFSET && cmd <= m_NumChapters + CHAPTER_CMD_OFFSET)\n    {\n        IAMExtendedSeeking *pExSeeking = nullptr;\n        if (SUCCEEDED(m_pFilter->QueryInterface(IID_IAMExtendedSeeking, (void **)&pExSeeking)))\n        {\n            double markerTime;\n            if (FAILED(pExSeeking->GetMarkerTime(cmd - CHAPTER_CMD_OFFSET, &markerTime)))\n                goto failchapterseek;\n\n            REFERENCE_TIME rtMarkerTime = (REFERENCE_TIME)(markerTime * 10000000.0);\n\n            // Try to get the graph to seek on, its much safer than directly trying to seek on LAV\n            FILTER_INFO info;\n            if (FAILED(m_pFilter->QueryFilterInfo(&info)) || !info.pGraph)\n                goto failchapterseek;\n\n            IMediaSeeking *pSeeking = nullptr;\n            if (SUCCEEDED(info.pGraph->QueryInterface(&pSeeking)))\n            {\n                pSeeking->SetPositions(&rtMarkerTime, AM_SEEKING_AbsolutePositioning, nullptr,\n                                       AM_SEEKING_NoPositioning);\n                SafeRelease(&pSeeking);\n            }\n            SafeRelease(&info.pGraph);\n\n        failchapterseek:\n            SafeRelease(&pExSeeking);\n        }\n    }\n    else if (cmd == STREAM_CMD_OFFSET - 1)\n    {\n        OpenPropPage();\n    }\n    else\n    {\n        return E_UNEXPECTED;\n    }\n    return S_OK;\n}\n"
  },
  {
    "path": "demuxer/LAVSplitter/LAVSplitterTrayIcon.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"BaseTrayIcon.h\"\n\nclass CLAVSplitterTrayIcon : public CBaseTrayIcon\n{\n  public:\n    CLAVSplitterTrayIcon(IBaseFilter *pFilter, const WCHAR *wszName, int resIcon);\n    virtual ~CLAVSplitterTrayIcon(void);\n\n  protected:\n    HMENU GetPopupMenu();\n    HRESULT ProcessMenuCommand(HMENU hMenu, int cmd);\n\n  private:\n    int m_NumStreams = 0;\n    int m_NumChapters = 0;\n};\n"
  },
  {
    "path": "demuxer/LAVSplitter/OutputPin.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"BaseDemuxer.h\"\n#include \"OutputPin.h\"\n#include \"LAVSplitter.h\"\n#include \"moreuuids.h\"\n\n#include \"PacketAllocator.h\"\n\nCLAVOutputPin::CLAVOutputPin(std::deque<CMediaType> &mts, LPCWSTR pName, CBaseFilter *pFilter, CCritSec *pLock,\n                             HRESULT *phr, CBaseDemuxer::StreamType pinType, const char *container)\n    : CBaseOutputPin(NAME(\"lavf dshow output pin\"), pFilter, pLock, phr, pName)\n    , m_mts(mts)\n    , m_containerFormat(container)\n    , m_pinType(pinType)\n    , m_Parser(this, container)\n{\n    SetQueueSizes();\n}\n\nCLAVOutputPin::~CLAVOutputPin()\n{\n    CAMThread::CallWorker(CMD_EXIT);\n    CAMThread::Close();\n    SAFE_DELETE(m_newMT);\n}\n\nvoid CLAVOutputPin::SetQueueSizes()\n{\n    size_t factor = 1;\n\n    // Normalize common audio codecs to reach a base line of 20ms\n    if (m_mts.begin()->subtype == MEDIASUBTYPE_DOLBY_TRUEHD)\n    {\n        DbgLog((LOG_TRACE, 10, L\"Increasing Audio Queue size for TrueHD\"));\n        factor = 30;\n    }\n    else if (m_mts.begin()->subtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO ||\n             m_mts.begin()->subtype == MEDIASUBTYPE_BD_LPCM_AUDIO || m_mts.begin()->subtype == MEDIASUBTYPE_PCM)\n    {\n        factor = 4;\n    }\n    else if (m_mts.begin()->subtype == MEDIASUBTYPE_DTS || m_mts.begin()->subtype == MEDIASUBTYPE_WAVE_DTS)\n    {\n        factor = 2;\n    }\n\n    if (m_mts.begin()->majortype == MEDIATYPE_Audio)\n    {\n        factor *= 4;\n    }\n\n    m_nQueueLow = MIN_PACKETS_IN_QUEUE * factor;\n    m_nQueueHigh = (size_t)(static_cast<CLAVSplitter *>(m_pFilter))->GetMaxQueueSize() * factor;\n\n    m_nQueueMaxMem = (size_t)(static_cast<CLAVSplitter *>(m_pFilter))->GetMaxQueueMemSize() * 1024 * 1024;\n    if (!m_nQueueMaxMem)\n    {\n        m_nQueueMaxMem = 256 * 1024 * 1024;\n    }\n}\n\nHRESULT CLAVOutputPin::GetQueueSize(int &samples, int &size)\n{\n    CAutoLock lock(&m_queue);\n    samples = (int)m_queue.Size();\n    size = (int)m_queue.DataSize();\n    return S_OK;\n}\n\nSTDMETHODIMP CLAVOutputPin::NonDelegatingQueryInterface(REFIID riid, void **ppv)\n{\n    CheckPointer(ppv, E_POINTER);\n\n    return QI(IMediaSeeking) QI(ILAVPinInfo) QI(IBitRateInfo)\n        QI(IMediaSideData) __super::NonDelegatingQueryInterface(riid, ppv);\n}\n\nHRESULT CLAVOutputPin::DecideAllocator(IMemInputPin *pPin, IMemAllocator **ppAlloc)\n{\n    HRESULT hr = NOERROR;\n    *ppAlloc = nullptr;\n\n    // get downstream prop request\n    // the derived class may modify this in DecideBufferSize, but\n    // we assume that he will consistently modify it the same way,\n    // so we only get it once\n    ALLOCATOR_PROPERTIES prop;\n    ZeroMemory(&prop, sizeof(prop));\n\n    // whatever he returns, we assume prop is either all zeros\n    // or he has filled it out.\n    pPin->GetAllocatorRequirements(&prop);\n\n    // if he doesn't care about alignment, then set it to 1\n    if (prop.cbAlign == 0)\n    {\n        prop.cbAlign = 1;\n    }\n\n    *ppAlloc = new CPacketAllocator(NAME(\"CPacketAllocator\"), nullptr, &hr);\n    (*ppAlloc)->AddRef();\n    if (SUCCEEDED(hr))\n    {\n        DbgLog((LOG_TRACE, 10, L\"Trying to use our CPacketAllocator\"));\n        m_bPacketAllocator = TRUE;\n        hr = DecideBufferSize(*ppAlloc, &prop);\n        if (SUCCEEDED(hr))\n        {\n            DbgLog((LOG_TRACE, 10, L\"-> DecideBufferSize Success\"));\n            hr = pPin->NotifyAllocator(*ppAlloc, TRUE);\n            if (SUCCEEDED(hr))\n            {\n                DbgLog((LOG_TRACE, 10, L\"-> NotifyAllocator Success\"));\n                return NOERROR;\n            }\n        }\n    }\n\n    if (*ppAlloc)\n    {\n        (*ppAlloc)->Release();\n        *ppAlloc = nullptr;\n    }\n\n    m_bPacketAllocator = FALSE;\n\n    /* Try the allocator provided by the input pin */\n    hr = pPin->GetAllocator(ppAlloc);\n    if (SUCCEEDED(hr))\n    {\n\n        hr = DecideBufferSize(*ppAlloc, &prop);\n        if (SUCCEEDED(hr))\n        {\n            hr = pPin->NotifyAllocator(*ppAlloc, FALSE);\n            if (SUCCEEDED(hr))\n            {\n                return NOERROR;\n            }\n        }\n    }\n\n    /* If the GetAllocator failed we may not have an interface */\n    if (*ppAlloc)\n    {\n        (*ppAlloc)->Release();\n        *ppAlloc = nullptr;\n    }\n    return hr;\n}\n\nHRESULT CLAVOutputPin::DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProperties)\n{\n    CheckPointer(pAlloc, E_POINTER);\n    CheckPointer(pProperties, E_POINTER);\n\n    HRESULT hr = S_OK;\n\n    pProperties->cBuffers = max(pProperties->cBuffers, (m_bPacketAllocator ? 20 : m_nBuffers));\n    pProperties->cbBuffer = max(max(m_mt.lSampleSize, 256000), (ULONG)pProperties->cbBuffer);\n\n    // Vorbis requires at least 2 buffers\n    if (m_mt.subtype == MEDIASUBTYPE_Vorbis && m_mt.formattype == FORMAT_VorbisFormat)\n    {\n        pProperties->cBuffers = max(pProperties->cBuffers, 2);\n    }\n\n    // Sanity checks\n    ALLOCATOR_PROPERTIES Actual;\n    if (FAILED(hr = pAlloc->SetProperties(pProperties, &Actual)))\n        return hr;\n    if (Actual.cbBuffer < pProperties->cbBuffer)\n        return E_FAIL;\n    ASSERT(Actual.cBuffers >= pProperties->cBuffers);\n\n    return S_OK;\n}\n\nHRESULT CLAVOutputPin::CheckMediaType(const CMediaType *pmt)\n{\n    for (auto it = m_mts.begin(); it != m_mts.end(); ++it)\n    {\n        if (*pmt == *it)\n            return S_OK;\n    }\n\n    return E_INVALIDARG;\n}\n\nHRESULT CLAVOutputPin::GetMediaType(int iPosition, CMediaType *pmt)\n{\n    DbgLog((LOG_TRACE, 10, L\"CLAVOutputPin::GetMediaType(): %s, position: %d\",\n            CBaseDemuxer::CStreamList::ToStringW(m_pinType), iPosition));\n    CAutoLock cAutoLock(m_pLock);\n\n    if (iPosition < 0)\n        return E_INVALIDARG;\n    if ((size_t)iPosition >= m_mts.size())\n        return VFW_S_NO_MORE_ITEMS;\n\n    *pmt = m_mts[iPosition];\n\n    return S_OK;\n}\n\nHRESULT CLAVOutputPin::Active()\n{\n    DbgLog((LOG_TRACE, 30, L\"CLAVOutputPin::Active() - activated %s pin\",\n            CBaseDemuxer::CStreamList::ToStringW(m_pinType)));\n    CAutoLock cAutoLock(m_pLock);\n\n    if (m_Connected)\n        Create();\n\n    return __super::Active();\n}\n\nHRESULT CLAVOutputPin::Inactive()\n{\n    DbgLog((LOG_TRACE, 30, L\"CLAVOutputPin::Inactive() - de-activated %s pin\",\n            CBaseDemuxer::CStreamList::ToStringW(m_pinType)));\n    CAutoLock cAutoLock(m_pLock);\n\n    CAMThread::CallWorker(CMD_EXIT);\n    CAMThread::Close();\n\n    // Clear queue when we're going inactive\n    m_queue.Clear();\n\n    return __super::Inactive();\n}\n\nSTDMETHODIMP CLAVOutputPin::Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt)\n{\n    HRESULT hr;\n    PIN_INFO PinInfo;\n    GUID FilterClsid;\n\n    if (SUCCEEDED(pReceivePin->QueryPinInfo(&PinInfo)))\n    {\n        if (SUCCEEDED(PinInfo.pFilter->GetClassID(&FilterClsid)))\n        {\n            if (FilterClsid == CLSID_DMOWrapperFilter)\n            {\n                (static_cast<CLAVSplitter *>(m_pFilter))->SetFakeASFReader(TRUE);\n            }\n        }\n        PinInfo.pFilter->Release();\n    }\n\n    hr = __super::Connect(pReceivePin, pmt);\n    (static_cast<CLAVSplitter *>(m_pFilter))->SetFakeASFReader(FALSE);\n    return hr;\n}\n\nHRESULT CLAVOutputPin::CompleteConnect(IPin *pReceivePin)\n{\n    m_StreamMT = m_mt;\n    return __super::CompleteConnect(pReceivePin);\n}\n\nHRESULT CLAVOutputPin::DeliverBeginFlush()\n{\n    DbgLog((LOG_TRACE, 20, L\"::DeliverBeginFlush on %s Pin\", CBaseDemuxer::CStreamList::ToStringW(m_pinType)));\n    m_eEndFlush.Reset();\n    m_fFlushed = false;\n    m_fFlushing = true;\n    m_hrDeliver = S_FALSE;\n    m_queue.Clear();\n    HRESULT hr = IsConnected() ? GetConnected()->BeginFlush() : S_OK;\n    if (hr != S_OK)\n        m_eEndFlush.Set();\n    return hr;\n}\n\nHRESULT CLAVOutputPin::DeliverEndFlush()\n{\n    DbgLog((LOG_TRACE, 20, L\"::DeliverEndFlush on %s Pin\", CBaseDemuxer::CStreamList::ToStringW(m_pinType)));\n    HRESULT hr = IsConnected() ? GetConnected()->EndFlush() : S_OK;\n\n    m_Parser.Flush();\n\n    m_hrDeliver = S_OK;\n    m_fFlushing = false;\n    m_fFlushed = true;\n\n    m_eEndFlush.Set();\n    return hr;\n}\n\nHRESULT CLAVOutputPin::DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate)\n{\n    HRESULT hr = S_OK;\n    DbgLog((LOG_TRACE, 20, L\"::DeliverNewSegment on %s Pin (rtStart: %I64d; rtStop: %I64d)\",\n            CBaseDemuxer::CStreamList::ToStringW(m_pinType), tStart, tStop));\n    m_rtPrev = AV_NOPTS_VALUE;\n    if (m_fFlushing)\n        return S_FALSE;\n    if (!ThreadExists())\n        return S_FALSE;\n\n    m_BitRate.rtLastDeliverTime = Packet::INVALID_TIME;\n    hr = __super::DeliverNewSegment(tStart, tStop, dRate);\n    if (hr != S_OK)\n        return hr;\n\n    MakeISCRHappy();\n\n    return hr;\n}\n\nvoid CLAVOutputPin::MakeISCRHappy()\n{\n    if (IsSubtitlePin() && FilterInGraphSafe(this, CLSID_ISCR))\n    {\n        Packet *p = new Packet();\n        p->StreamId = m_streamId;\n        p->rtStart = -1;\n        p->rtStop = 0;\n        p->bSyncPoint = FALSE;\n        p->SetData(\" \", 2);\n        QueueFromParser(p);\n    }\n}\n\nsize_t CLAVOutputPin::QueueCount()\n{\n    return m_queue.Size();\n}\n\nHRESULT CLAVOutputPin::QueueEndOfStream()\n{\n    return QueuePacket(nullptr); // nullptr means EndOfStream\n}\n\nHRESULT CLAVOutputPin::QueuePacket(Packet *pPacket)\n{\n    if (!ThreadExists())\n    {\n        SAFE_DELETE(pPacket);\n        return S_FALSE;\n    }\n\n    CLAVSplitter *pSplitter = static_cast<CLAVSplitter *>(m_pFilter);\n\n    // While everything is good AND no pin is drying AND the queue is full .. sleep\n    // The queue has a \"soft\" limit of MAX_PACKETS_IN_QUEUE, and a hard limit of MAX_PACKETS_IN_QUEUE * 16 (and a memory limit)\n    // That means, even if one pin is drying, we'll never exceed MAX_PACKETS_IN_QUEUE * 16\n    while (S_OK == m_hrDeliver && (m_queue.DataSize() > m_nQueueMaxMem || m_queue.Size() > 16 * m_nQueueHigh ||\n                                   (m_queue.Size() > m_nQueueHigh && !pSplitter->IsAnyPinDrying())))\n        Sleep(10);\n\n    if (S_OK != m_hrDeliver)\n    {\n        SAFE_DELETE(pPacket);\n        return m_hrDeliver;\n    }\n\n    {\n        CAutoLock lock(&m_csMT);\n        if (m_newMT && pPacket)\n        {\n            DbgLog((LOG_TRACE, 10, L\"::QueuePacket() - Found new Media Type\"));\n            pPacket->pmt = CreateMediaType(m_newMT);\n            SetStreamMediaType(m_newMT);\n            SAFE_DELETE(m_newMT);\n        }\n    }\n\n    m_Parser.Parse(m_StreamMT.subtype, pPacket);\n\n    return m_hrDeliver;\n}\n\nbool CLAVOutputPin::IsDiscontinuous()\n{\n    return m_mt.majortype == MEDIATYPE_Text || m_mt.majortype == MEDIATYPE_ScriptCommand ||\n           m_mt.majortype == MEDIATYPE_Subtitle || m_mt.subtype == MEDIASUBTYPE_DVD_SUBPICTURE ||\n           m_mt.subtype == MEDIASUBTYPE_CVD_SUBPICTURE || m_mt.subtype == MEDIASUBTYPE_SVCD_SUBPICTURE;\n}\n\nDWORD CLAVOutputPin::ThreadProc()\n{\n    std::string name = \"CLAVOutputPin \" + std::string(CBaseDemuxer::CStreamList::ToString(m_pinType));\n    SetThreadName(-1, name.c_str());\n\n    m_hrDeliver = S_OK;\n    m_fFlushing = m_fFlushed = false;\n    m_eEndFlush.Set();\n    bool bFailFlush = false;\n\n    while (1)\n    {\n        Sleep(1);\n\n        DWORD cmd;\n        if (CheckRequest(&cmd))\n        {\n            cmd = GetRequest();\n            Reply(S_OK);\n            ASSERT(cmd == CMD_EXIT);\n            return 0;\n        }\n\n        size_t cnt = 0;\n        do\n        {\n            Packet *pPacket = nullptr;\n\n            // Get a packet from the queue (scoped for lock)\n            {\n                CAutoLock cAutoLock(&m_queue);\n                if ((cnt = m_queue.Size()) > 0)\n                {\n                    pPacket = m_queue.Get();\n                }\n            }\n\n            // We need to check cnt instead of pPacket, since it can be nullptr for EndOfStream\n            if (m_hrDeliver == S_OK && cnt > 0)\n            {\n                ASSERT(!m_fFlushing);\n                m_fFlushed = false;\n\n                // flushing can still start here, to release a blocked deliver call\n                HRESULT hr = pPacket ? DeliverPacket(pPacket) : DeliverEndOfStream();\n\n                // .. so, wait until flush finished\n                m_eEndFlush.Wait();\n\n                if (hr != S_OK && !m_fFlushed)\n                {\n                    DbgLog((LOG_TRACE, 10, L\"OutputPin::ThreadProc(): Delivery failed on %s pin, hr: %0#.8x\",\n                            CBaseDemuxer::CStreamList::ToStringW(GetPinType()), hr));\n                    if (!bFailFlush && hr == S_FALSE)\n                    {\n                        DbgLog((LOG_TRACE, 10, L\"OutputPin::ThreadProc(): Trying to revive it by flushing...\"));\n                        GetConnected()->BeginFlush();\n                        GetConnected()->EndFlush();\n                        bFailFlush = true;\n                    }\n                    else\n                    {\n                        m_hrDeliver = hr;\n                    }\n                    break;\n                }\n            }\n            else if (pPacket)\n            {\n                // in case of stream switches or other events, we may end up here\n                SAFE_DELETE(pPacket);\n            }\n        } while (cnt > 1 && m_hrDeliver == S_OK);\n    }\n    return 0;\n}\n\nHRESULT CLAVOutputPin::DeliverPacket(Packet *pPacket)\n{\n    HRESULT hr = S_OK;\n    IMediaSample *pSample = nullptr;\n\n    long nBytes = (long)pPacket->GetDataSize();\n\n    if (nBytes == 0)\n    {\n        goto done;\n    }\n\n    CHECK_HR(hr = GetDeliveryBuffer(&pSample, nullptr, nullptr, 0));\n\n    if (m_bPacketAllocator)\n    {\n        ILAVMediaSample *pLAVSample = nullptr;\n        CHECK_HR(hr = pSample->QueryInterface(&pLAVSample));\n        CHECK_HR(hr = pLAVSample->SetPacket(pPacket));\n        SafeRelease(&pLAVSample);\n    }\n    else\n    {\n        // Resize buffer if it is too small\n        // This can cause a playback hick-up, we should avoid this if possible by setting a big enough buffer size\n        if (nBytes > pSample->GetSize())\n        {\n            SafeRelease(&pSample);\n            ALLOCATOR_PROPERTIES props, actual;\n            CHECK_HR(hr = m_pAllocator->GetProperties(&props));\n            // Give us 2 times the requested size, so we don't resize every time\n            props.cbBuffer = nBytes * 2;\n            if (props.cBuffers > 1)\n            {\n                CHECK_HR(hr = __super::DeliverBeginFlush());\n                CHECK_HR(hr = __super::DeliverEndFlush());\n            }\n            CHECK_HR(hr = m_pAllocator->Decommit());\n            CHECK_HR(hr = m_pAllocator->SetProperties(&props, &actual));\n            CHECK_HR(hr = m_pAllocator->Commit());\n            CHECK_HR(hr = GetDeliveryBuffer(&pSample, nullptr, nullptr, 0));\n        }\n\n        // Fill the sample\n        BYTE *pData = nullptr;\n        if (FAILED(hr = pSample->GetPointer(&pData)) || !pData)\n            goto done;\n\n        memcpy(pData, pPacket->GetData(), nBytes);\n    }\n\n    if (pPacket->pmt)\n    {\n        DbgLog((LOG_TRACE, 10, L\"::DeliverPacket() - sending new media type to decoder\"));\n        pSample->SetMediaType(pPacket->pmt);\n        pPacket->bDiscontinuity = true;\n\n        CAutoLock cAutoLock(m_pLock);\n        CMediaType pmt = *(pPacket->pmt);\n        m_mts.clear();\n        m_mts.push_back(pmt);\n        pPacket->pmt = nullptr;\n\n        SetMediaType(&pmt);\n    }\n\n    bool fTimeValid = pPacket->rtStart != Packet::INVALID_TIME;\n\n    // IBitRateInfo\n    m_BitRate.nBytesSinceLastDeliverTime += nBytes;\n\n    if (fTimeValid)\n    {\n        if (m_BitRate.rtLastDeliverTime == Packet::INVALID_TIME)\n        {\n            m_BitRate.rtLastDeliverTime = pPacket->rtStart;\n            m_BitRate.nBytesSinceLastDeliverTime = 0;\n        }\n\n        if (m_BitRate.rtLastDeliverTime + 10000000 < pPacket->rtStart)\n        {\n            REFERENCE_TIME rtDiff = pPacket->rtStart - m_BitRate.rtLastDeliverTime;\n\n            double dSecs, dBits;\n\n            dSecs = rtDiff / 10000000.0;\n            dBits = 8.0 * m_BitRate.nBytesSinceLastDeliverTime;\n            m_BitRate.nCurrentBitRate = (DWORD)(dBits / dSecs);\n\n            m_BitRate.rtTotalTimeDelivered += rtDiff;\n            m_BitRate.nTotalBytesDelivered += m_BitRate.nBytesSinceLastDeliverTime;\n\n            dSecs = m_BitRate.rtTotalTimeDelivered / 10000000.0;\n            dBits = 8.0 * m_BitRate.nTotalBytesDelivered;\n            m_BitRate.nAverageBitRate = (DWORD)(dBits / dSecs);\n\n            m_BitRate.rtLastDeliverTime = pPacket->rtStart;\n            m_BitRate.nBytesSinceLastDeliverTime = 0;\n        }\n    }\n\n    CHECK_HR(hr = pSample->SetActualDataLength(nBytes));\n    CHECK_HR(hr = pSample->SetTime(fTimeValid ? &pPacket->rtStart : nullptr, fTimeValid ? &pPacket->rtStop : nullptr));\n    CHECK_HR(hr = pSample->SetMediaTime(nullptr, nullptr));\n    CHECK_HR(hr = pSample->SetDiscontinuity(pPacket->bDiscontinuity));\n    CHECK_HR(hr = pSample->SetSyncPoint(pPacket->bSyncPoint));\n    CHECK_HR(hr = pSample->SetPreroll(fTimeValid && pPacket->rtStart < 0));\n    // Deliver\n    CHECK_HR(hr = Deliver(pSample));\n\ndone:\n    if (!m_bPacketAllocator || !pSample)\n        SAFE_DELETE(pPacket);\n    SafeRelease(&pSample);\n    return hr;\n}\n\n// IMediaSeeking\nSTDMETHODIMP CLAVOutputPin::GetCapabilities(DWORD *pCapabilities)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetCapabilities(pCapabilities);\n}\nSTDMETHODIMP CLAVOutputPin::CheckCapabilities(DWORD *pCapabilities)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->CheckCapabilities(pCapabilities);\n}\nSTDMETHODIMP CLAVOutputPin::IsFormatSupported(const GUID *pFormat)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->IsFormatSupported(pFormat);\n}\nSTDMETHODIMP CLAVOutputPin::QueryPreferredFormat(GUID *pFormat)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->QueryPreferredFormat(pFormat);\n}\nSTDMETHODIMP CLAVOutputPin::GetTimeFormat(GUID *pFormat)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetTimeFormat(pFormat);\n}\nSTDMETHODIMP CLAVOutputPin::IsUsingTimeFormat(const GUID *pFormat)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->IsUsingTimeFormat(pFormat);\n}\nSTDMETHODIMP CLAVOutputPin::SetTimeFormat(const GUID *pFormat)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->SetTimeFormat(pFormat);\n}\nSTDMETHODIMP CLAVOutputPin::GetDuration(LONGLONG *pDuration)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetDuration(pDuration);\n}\nSTDMETHODIMP CLAVOutputPin::GetStopPosition(LONGLONG *pStop)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetStopPosition(pStop);\n}\nSTDMETHODIMP CLAVOutputPin::GetCurrentPosition(LONGLONG *pCurrent)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetCurrentPosition(pCurrent);\n}\nSTDMETHODIMP CLAVOutputPin::ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source,\n                                              const GUID *pSourceFormat)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->ConvertTimeFormat(pTarget, pTargetFormat, Source, pSourceFormat);\n}\nSTDMETHODIMP CLAVOutputPin::SetPositions(LONGLONG *pCurrent, DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))\n        ->SetPositionsInternal(this, pCurrent, dwCurrentFlags, pStop, dwStopFlags);\n}\nSTDMETHODIMP CLAVOutputPin::GetPositions(LONGLONG *pCurrent, LONGLONG *pStop)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetPositions(pCurrent, pStop);\n}\nSTDMETHODIMP CLAVOutputPin::GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetAvailable(pEarliest, pLatest);\n}\nSTDMETHODIMP CLAVOutputPin::SetRate(double dRate)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->SetRate(dRate);\n}\nSTDMETHODIMP CLAVOutputPin::GetRate(double *pdRate)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetRate(pdRate);\n}\nSTDMETHODIMP CLAVOutputPin::GetPreroll(LONGLONG *pllPreroll)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetPreroll(pllPreroll);\n}\n\nSTDMETHODIMP_(DWORD) CLAVOutputPin::GetStreamFlags()\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetStreamFlags(m_streamId);\n}\n\nSTDMETHODIMP_(int) CLAVOutputPin::GetPixelFormat()\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetPixelFormat(m_streamId);\n}\n\nSTDMETHODIMP_(int) CLAVOutputPin::GetHasBFrames()\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetHasBFrames(m_streamId);\n}\n\nSTDMETHODIMP CLAVOutputPin::GetSideData(GUID guidType, const BYTE **pData, size_t *pSize)\n{\n    return (static_cast<CLAVSplitter *>(m_pFilter))->GetSideData(m_streamId, guidType, pData, pSize);\n}"
  },
  {
    "path": "demuxer/LAVSplitter/OutputPin.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#pragma once\n\n#include <vector>\n#include <string>\n#include \"PacketQueue.h\"\n#include \"StreamParser.h\"\n\n#include \"moreuuids.h\"\n\n#include \"LAVSplitter.h\"\n#include \"ILAVPinInfo.h\"\n#include \"IBitRateInfo.h\"\n#include \"IMediaSideData.h\"\n\nclass CLAVOutputPin\n    : public CBaseOutputPin\n    , public ILAVPinInfo\n    , public IBitRateInfo\n    , public IMediaSideData\n    , IMediaSeeking\n    , protected CAMThread\n{\n  public:\n    CLAVOutputPin(std::deque<CMediaType> &mts, LPCWSTR pName, CBaseFilter *pFilter, CCritSec *pLock, HRESULT *phr,\n                  CBaseDemuxer::StreamType pinType = CBaseDemuxer::unknown, const char *container = \"\");\n    virtual ~CLAVOutputPin();\n\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // IQualityControl\n    STDMETHODIMP Notify(IBaseFilter *pSender, Quality q) { return E_NOTIMPL; }\n\n    // CBaseOutputPin\n    HRESULT DecideAllocator(IMemInputPin *pPin, IMemAllocator **pAlloc);\n    HRESULT DecideBufferSize(IMemAllocator *pAlloc, ALLOCATOR_PROPERTIES *pProperties);\n    HRESULT CheckMediaType(const CMediaType *pmt);\n    HRESULT GetMediaType(int iPosition, CMediaType *pmt);\n    HRESULT Active();\n    HRESULT Inactive();\n\n    STDMETHODIMP Connect(IPin *pReceivePin, const AM_MEDIA_TYPE *pmt);\n    HRESULT CompleteConnect(IPin *pReceivePin);\n\n    // IMediaSeeking\n    STDMETHODIMP GetCapabilities(DWORD *pCapabilities);\n    STDMETHODIMP CheckCapabilities(DWORD *pCapabilities);\n    STDMETHODIMP IsFormatSupported(const GUID *pFormat);\n    STDMETHODIMP QueryPreferredFormat(GUID *pFormat);\n    STDMETHODIMP GetTimeFormat(GUID *pFormat);\n    STDMETHODIMP IsUsingTimeFormat(const GUID *pFormat);\n    STDMETHODIMP SetTimeFormat(const GUID *pFormat);\n    STDMETHODIMP GetDuration(LONGLONG *pDuration);\n    STDMETHODIMP GetStopPosition(LONGLONG *pStop);\n    STDMETHODIMP GetCurrentPosition(LONGLONG *pCurrent);\n    STDMETHODIMP ConvertTimeFormat(LONGLONG *pTarget, const GUID *pTargetFormat, LONGLONG Source,\n                                   const GUID *pSourceFormat);\n    STDMETHODIMP SetPositions(LONGLONG *pCurrent, DWORD dwCurrentFlags, LONGLONG *pStop, DWORD dwStopFlags);\n    STDMETHODIMP GetPositions(LONGLONG *pCurrent, LONGLONG *pStop);\n    STDMETHODIMP GetAvailable(LONGLONG *pEarliest, LONGLONG *pLatest);\n    STDMETHODIMP SetRate(double dRate);\n    STDMETHODIMP GetRate(double *pdRate);\n    STDMETHODIMP GetPreroll(LONGLONG *pllPreroll);\n\n    // ILAVPinInfo\n    STDMETHODIMP_(DWORD) GetStreamFlags();\n    STDMETHODIMP_(int) GetPixelFormat();\n    STDMETHODIMP_(int) GetVersion() { return 1; }\n    STDMETHODIMP_(int) GetHasBFrames();\n\n    // IBitRateInfo\n    STDMETHODIMP_(DWORD) GetCurrentBitRate() { return m_BitRate.nCurrentBitRate; }\n    STDMETHODIMP_(DWORD) GetAverageBitRate() { return m_BitRate.nAverageBitRate; }\n\n    // IMediaSideData\n    STDMETHODIMP SetSideData(GUID guidType, const BYTE *pData, size_t size) { return E_NOTIMPL; }\n    STDMETHODIMP GetSideData(GUID guidType, const BYTE **pData, size_t *pSize);\n\n    size_t QueueCount();\n    HRESULT QueuePacket(Packet *pPacket);\n    HRESULT QueueEndOfStream();\n    bool IsDiscontinuous();\n    size_t GetQueueLowLimit() const { return m_nQueueLow; }\n\n    DWORD GetStreamId() { return m_streamId; };\n    void SetStreamId(DWORD newStreamId) { m_streamId = newStreamId; };\n\n    void SetNewMediaTypes(std::deque<CMediaType> pmts)\n    {\n        CAutoLock lock(&m_csMT);\n        m_mts = pmts;\n        SetQueueSizes();\n    }\n    void SendMediaType(CMediaType *mt)\n    {\n        CAutoLock lock(&m_csMT);\n        m_newMT = mt;\n    }\n    void SetStreamMediaType(CMediaType *mt)\n    {\n        CAutoLock lock(&m_csMT);\n        m_StreamMT = *mt;\n    }\n\n    CMediaType &GetActiveMediaType() { return m_mt; }\n\n    BOOL IsVideoPin() { return m_pinType == CBaseDemuxer::video; }\n    BOOL IsAudioPin() { return m_pinType == CBaseDemuxer::audio; }\n    BOOL IsSubtitlePin() { return m_pinType == CBaseDemuxer::subpic; }\n    CBaseDemuxer::StreamType GetPinType() { return m_pinType; }\n\n    HRESULT QueueFromParser(Packet *pPacket)\n    {\n        m_queue.Queue(pPacket);\n        return S_OK;\n    }\n\n    HRESULT GetQueueSize(int &samples, int &size);\n\n  public:\n    // Packet handling functions\n    virtual HRESULT DeliverBeginFlush();\n    virtual HRESULT DeliverEndFlush();\n\n    virtual HRESULT DeliverNewSegment(REFERENCE_TIME tStart, REFERENCE_TIME tStop, double dRate);\n\n    void SetQueueSizes();\n\n    REFERENCE_TIME m_rtPrev = AV_NOPTS_VALUE;\n\n  protected:\n    virtual HRESULT DeliverPacket(Packet *pPacket);\n\n  private:\n    enum\n    {\n        CMD_EXIT\n    };\n    DWORD ThreadProc();\n\n    void MakeISCRHappy();\n\n  private:\n    CCritSec m_csMT;\n    std::deque<CMediaType> m_mts;\n    CPacketQueue m_queue;\n    CMediaType m_StreamMT;\n\n    std::string m_containerFormat;\n\n    // Flush control\n    bool m_fFlushing = false;\n    bool m_fFlushed = false;\n    CAMEvent m_eEndFlush{TRUE};\n\n    HRESULT m_hrDeliver = S_OK;\n\n    int m_nBuffers = 1;\n    size_t m_nQueueLow = MIN_PACKETS_IN_QUEUE;\n    size_t m_nQueueHigh = 350;\n    size_t m_nQueueMaxMem = 256 * 1024 * 1024;\n\n    DWORD m_streamId = 0;\n    CMediaType *m_newMT = nullptr;\n\n    CBaseDemuxer::StreamType m_pinType;\n\n    CStreamParser m_Parser;\n    BOOL m_bPacketAllocator = FALSE;\n\n    // IBitRateInfo\n    struct BitRateInfo\n    {\n        UINT64 nTotalBytesDelivered = 0;\n        REFERENCE_TIME rtTotalTimeDelivered = 0;\n        UINT64 nBytesSinceLastDeliverTime = 0;\n        REFERENCE_TIME rtLastDeliverTime = Packet::INVALID_TIME;\n        DWORD nCurrentBitRate = 0;\n        DWORD nAverageBitRate = 0;\n    } m_BitRate;\n};\n"
  },
  {
    "path": "demuxer/LAVSplitter/PacketAllocator.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"PacketAllocator.h\"\n\nCMediaPacketSample::CMediaPacketSample(LPCTSTR pName, CBaseAllocator *pAllocator, HRESULT *phr)\n    : CMediaSample(pName, pAllocator, phr)\n{\n}\n\nSTDMETHODIMP CMediaPacketSample::QueryInterface(REFIID riid, void **ppv)\n{\n    if (riid == __uuidof(ILAVMediaSample))\n    {\n        return GetInterface((ILAVMediaSample *)this, ppv);\n    }\n    else if (riid == __uuidof(IMediaSideData))\n    {\n        return GetInterface((IMediaSideData *)this, ppv);\n    }\n    return CMediaSample::QueryInterface(riid, ppv);\n}\n\nSTDMETHODIMP_(ULONG) CMediaPacketSample::AddRef()\n{\n    return CMediaSample::AddRef();\n}\n\nSTDMETHODIMP_(ULONG) CMediaPacketSample::Release()\n{\n    /* Decrement our own private reference count */\n    LONG lRef;\n    if (m_cRef == 1)\n    {\n        lRef = 0;\n        m_cRef = 0;\n    }\n    else\n    {\n        lRef = InterlockedDecrement(&m_cRef);\n    }\n    ASSERT(lRef >= 0);\n\n    DbgLog((LOG_MEMORY, 3, TEXT(\"    Unknown %X ref-- = %d\"), this, m_cRef));\n\n    /* Did we release our final reference count */\n    if (lRef == 0)\n    {\n        /* Free all resources */\n        if (m_dwFlags & Sample_TypeChanged)\n        {\n            SetMediaType(nullptr);\n        }\n        ASSERT(m_pMediaType == nullptr);\n        m_dwFlags = 0;\n        m_dwTypeSpecificFlags = 0;\n        m_dwStreamId = AM_STREAM_MEDIA;\n\n        SAFE_DELETE(m_pPacket);\n        SetPointer(nullptr, 0);\n\n        SAFE_DELETE(m_pSideData);\n\n        /* This may cause us to be deleted */\n        // Our refcount is reliably 0 thus no-one will mess with us\n        m_pAllocator->ReleaseBuffer(this);\n    }\n    return (ULONG)lRef;\n}\n\nSTDMETHODIMP CMediaPacketSample::SetPacket(Packet *pPacket)\n{\n    SAFE_DELETE(m_pPacket);\n    m_pPacket = pPacket;\n    SetPointer(pPacket->GetData(), (LONG)pPacket->GetDataSize());\n\n    SAFE_DELETE(m_pSideData);\n\n    if (pPacket->GetNumSideData() > 0)\n    {\n        m_pSideData = new MediaSideDataFFMpeg();\n        m_pSideData->side_data = pPacket->GetSideData();\n        m_pSideData->side_data_elems = pPacket->GetNumSideData();\n    }\n\n    return S_OK;\n}\n\nSTDMETHODIMP CMediaPacketSample::SetSideData(GUID guidType, const BYTE *pData, size_t size)\n{\n    return E_NOTIMPL;\n}\n\nSTDMETHODIMP CMediaPacketSample::GetSideData(GUID guidType, const BYTE **pData, size_t *pSize)\n{\n    if (guidType == IID_MediaSideDataFFMpeg && m_pSideData)\n    {\n        *pData = (const BYTE *)m_pSideData;\n        *pSize = sizeof(MediaSideDataFFMpeg);\n\n        return S_OK;\n    }\n\n    return E_INVALIDARG;\n}\n\nCPacketAllocator::CPacketAllocator(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseAllocator(pName, pUnk, phr, TRUE, TRUE)\n{\n}\n\nCPacketAllocator::~CPacketAllocator(void)\n{\n    Decommit();\n    ReallyFree();\n}\n\nSTDMETHODIMP CPacketAllocator::NonDelegatingQueryInterface(REFIID riid, __deref_out void **ppv)\n{\n    if (riid == IID_ILAVDynamicAllocator)\n    {\n        return GetInterface((ILAVDynamicAllocator *)this, ppv);\n    }\n    else\n    {\n        return __super::NonDelegatingQueryInterface(riid, ppv);\n    }\n}\n\nSTDMETHODIMP CPacketAllocator::SetProperties(ALLOCATOR_PROPERTIES *pRequest, ALLOCATOR_PROPERTIES *pActual)\n{\n    CheckPointer(pActual, E_POINTER);\n    ValidateReadWritePtr(pActual, sizeof(ALLOCATOR_PROPERTIES));\n    CAutoLock cObjectLock(this);\n\n    ZeroMemory(pActual, sizeof(ALLOCATOR_PROPERTIES));\n\n    ASSERT(pRequest->cbBuffer > 0);\n\n    SYSTEM_INFO SysInfo;\n    GetSystemInfo(&SysInfo);\n\n    /*  Check the alignment request is a power of 2 */\n    if ((-pRequest->cbAlign & pRequest->cbAlign) != pRequest->cbAlign)\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"Alignment requested 0x%x not a power of 2!\"), pRequest->cbAlign));\n    }\n    /*  Check the alignment requested */\n    if (pRequest->cbAlign == 0 || (SysInfo.dwAllocationGranularity & (pRequest->cbAlign - 1)) != 0)\n    {\n        DbgLog((LOG_ERROR, 1, TEXT(\"Invalid alignment 0x%x requested - granularity = 0x%x\"), pRequest->cbAlign,\n                SysInfo.dwAllocationGranularity));\n        return VFW_E_BADALIGN;\n    }\n\n    /* Can't do this if already committed, there is an argument that says we\n    should not reject the SetProperties call if there are buffers still\n    active. However this is called by the source filter, which is the same\n    person who is holding the samples. Therefore it is not unreasonable\n    for them to free all their samples before changing the requirements */\n\n    if (m_bCommitted == TRUE)\n    {\n        return VFW_E_ALREADY_COMMITTED;\n    }\n\n    /* Must be no outstanding buffers */\n\n    if (m_lFree.GetCount() < m_lAllocated)\n    {\n        return VFW_E_BUFFERS_OUTSTANDING;\n    }\n\n    /* There isn't any real need to check the parameters as they\n    will just be rejected when the user finally calls Commit */\n\n    // round length up to alignment - remember that prefix is included in\n    // the alignment\n    LONG lSize = pRequest->cbBuffer + pRequest->cbPrefix;\n    LONG lRemainder = lSize % pRequest->cbAlign;\n    if (lRemainder != 0)\n    {\n        lSize = lSize - lRemainder + pRequest->cbAlign;\n    }\n    pActual->cbBuffer = m_lSize = (lSize - pRequest->cbPrefix);\n\n    pActual->cBuffers = m_lCount = pRequest->cBuffers;\n    pActual->cbAlign = m_lAlignment = pRequest->cbAlign;\n    pActual->cbPrefix = m_lPrefix = pRequest->cbPrefix;\n\n    m_bChanged = TRUE;\n    return NOERROR;\n}\n\nHRESULT CPacketAllocator::Alloc(void)\n{\n    CAutoLock lck(this);\n\n    /* Check he has called SetProperties */\n    HRESULT hr = CBaseAllocator::Alloc();\n    if (FAILED(hr))\n    {\n        return hr;\n    }\n\n    /* If the requirements haven't changed then don't reallocate */\n    if (hr == S_FALSE)\n    {\n        return NOERROR;\n    }\n    ASSERT(hr == S_OK); // we use this fact in the loop below\n\n    /* Free the old resources */\n    if (m_bAllocated)\n    {\n        ReallyFree();\n    }\n\n    /* Make sure we've got reasonable values */\n    if (m_lSize < 0 || m_lPrefix < 0 || m_lCount < 0)\n    {\n        return E_OUTOFMEMORY;\n    }\n\n    m_bAllocated = TRUE;\n\n    CMediaPacketSample *pSample = nullptr;\n\n    ASSERT(m_lAllocated == 0);\n\n    // Create the initial set of samples\n    for (; m_lAllocated < m_lCount; m_lAllocated++)\n    {\n        pSample = new CMediaPacketSample(NAME(\"LAV Package media sample\"), this, &hr);\n\n        ASSERT(SUCCEEDED(hr));\n        if (pSample == nullptr)\n        {\n            return E_OUTOFMEMORY;\n        }\n\n        // This CANNOT fail\n        m_lFree.Add(pSample);\n    }\n\n    m_bChanged = FALSE;\n    return NOERROR;\n}\n\n// get container for a sample. Blocking, synchronous call to get the\n// next free buffer (as represented by an IMediaSample interface).\n// on return, the time etc properties will be invalid, but the buffer\n// pointer and size will be correct.\n\nHRESULT CPacketAllocator::GetBuffer(__deref_out IMediaSample **ppBuffer, __in_opt REFERENCE_TIME *pStartTime,\n                                    __in_opt REFERENCE_TIME *pEndTime, DWORD dwFlags)\n{\n    UNREFERENCED_PARAMETER(pStartTime);\n    UNREFERENCED_PARAMETER(pEndTime);\n    UNREFERENCED_PARAMETER(dwFlags);\n    CMediaSample *pSample;\n\n    *ppBuffer = NULL;\n    for (;;)\n    {\n        { // scope for lock\n            CAutoLock cObjectLock(this);\n\n            /* Check we are committed */\n            if (!m_bCommitted)\n            {\n                return VFW_E_NOT_COMMITTED;\n            }\n            pSample = (CMediaSample *)m_lFree.RemoveHead();\n\n            /* if no sample was available, allocate a new one */\n            if (pSample == NULL)\n            {\n                HRESULT hr = S_OK;\n                pSample = new CMediaPacketSample(NAME(\"LAV Package media sample\"), this, &hr);\n                ASSERT(SUCCEEDED(hr));\n\n                if (pSample)\n                {\n                    m_lAllocated++;\n                    DbgLog((LOG_TRACE, 10, \"Allocated new sample, %d total\", m_lAllocated));\n                }\n            }\n        }\n\n        /* If we didn't get a sample then wait for the list to signal */\n\n        if (pSample)\n        {\n            break;\n        }\n        if (dwFlags & AM_GBF_NOWAIT)\n        {\n            return VFW_E_TIMEOUT;\n        }\n        ASSERT(m_hSem != NULL);\n        WaitForSingleObject(m_hSem, INFINITE);\n    }\n\n    /* Addref the buffer up to one. On release\n    back to zero instead of being deleted, it will requeue itself by\n    calling the ReleaseBuffer member function. NOTE the owner of a\n    media sample must always be derived from CBaseAllocator */\n\n    ASSERT(pSample->m_cRef == 0);\n    pSample->m_cRef = 1;\n    *ppBuffer = pSample;\n\n#ifdef DXMPERF\n    PERFLOG_GETBUFFER((IMemAllocator *)this, pSample);\n#endif // DXMPERF\n\n    return NOERROR;\n}\n\n// override this to free up any resources we have allocated.\n// called from the base class on Decommit when all buffers have been\n// returned to the free list.\n//\n// caller has already locked the object.\n\n// in our case, we keep the memory until we are deleted, so\n// we do nothing here. The memory is deleted in the destructor by\n// calling ReallyFree()\nvoid CPacketAllocator::Free(void)\n{\n    return;\n}\n\n// called from the destructor (and from Alloc if changing size/count) to\n// actually free up the memory\nvoid CPacketAllocator::ReallyFree(void)\n{\n    /* Should never be deleting this unless all buffers are freed */\n    ASSERT(m_lAllocated == m_lFree.GetCount());\n\n    /* Free up all the CMediaSamples */\n    CMediaSample *pSample;\n    for (;;)\n    {\n        pSample = m_lFree.RemoveHead();\n        if (pSample != nullptr)\n        {\n            delete pSample;\n        }\n        else\n        {\n            break;\n        }\n    }\n\n    m_lAllocated = 0;\n    m_bAllocated = FALSE;\n}\n"
  },
  {
    "path": "demuxer/LAVSplitter/PacketAllocator.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n *  Contributions by Ti-BEN from the XBMC DSPlayer Project, also under GPLv2\n */\n\n#pragma once\n\n#include \"Packet.h\"\n#include \"IMediaSideData.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n#include \"ILAVDynamicAllocator.h\"\n\ninterface __declspec(uuid(\"0B2EE323-0ED8-452D-B31E-B9B4DE2C0C39\")) ILAVMediaSample : public IUnknown\n{\n    STDMETHOD(SetPacket)(Packet * pPacket) PURE;\n};\n\nclass CMediaPacketSample\n    : public CMediaSample\n    , public ILAVMediaSample\n    , public IMediaSideData\n{\n  public:\n    CMediaPacketSample(LPCTSTR pName, CBaseAllocator *pAllocator, HRESULT *phr);\n\n    // IUnknown\n    STDMETHODIMP QueryInterface(REFIID riid, void **ppv);\n    STDMETHODIMP_(ULONG) AddRef();\n    STDMETHODIMP_(ULONG) Release();\n\n    // ILAVMediaSamples\n    STDMETHODIMP SetPacket(Packet *pPacket);\n\n    // IMediaSideData\n    STDMETHODIMP SetSideData(GUID guidType, const BYTE *pData, size_t size);\n    STDMETHODIMP GetSideData(GUID guidType, const BYTE **pData, size_t *pSize);\n\n  protected:\n    Packet *m_pPacket = nullptr;\n    MediaSideDataFFMpeg *m_pSideData = nullptr;\n};\n\nclass CPacketAllocator\n    : public CBaseAllocator\n    , public ILAVDynamicAllocator\n{\n  protected:\n    BOOL m_bAllocated = FALSE;\n\n    // override to free the memory when decommit completes\n    // - we actually do nothing, and save the memory until deletion.\n    void Free(void);\n\n    // called from the destructor (and from Alloc if changing size/count) to\n    // actually free up the memory\n    void ReallyFree(void);\n\n    // overridden to allocate the memory when commit called\n    HRESULT Alloc(void);\n\n  public:\n    CPacketAllocator(LPCTSTR pName, LPUNKNOWN pUnk, HRESULT *phr);\n    virtual ~CPacketAllocator(void);\n\n    // CUnknown support\n    DECLARE_IUNKNOWN;\n    STDMETHODIMP NonDelegatingQueryInterface(REFIID riid, void **ppv);\n\n    // CBaseAllocator overrides\n    STDMETHODIMP SetProperties(ALLOCATOR_PROPERTIES *pRequest, ALLOCATOR_PROPERTIES *pActual);\n    STDMETHODIMP GetBuffer(IMediaSample **ppBuffer, REFERENCE_TIME *pStartTime, REFERENCE_TIME *pEndTime,\n                           DWORD dwFlags);\n\n    // ILAVDynamicAllocator\n    STDMETHODIMP_(BOOL) IsDynamicAllocator() { return TRUE; }\n};\n"
  },
  {
    "path": "demuxer/LAVSplitter/PacketQueue.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n#include \"PacketQueue.h\"\n#include \"BaseDemuxer.h\"\n\n// Queue a new packet at the end of the list\nvoid CPacketQueue::Queue(Packet *pPacket)\n{\n    CAutoLock cAutoLock(this);\n\n    if (pPacket)\n        m_dataSize += (size_t)pPacket->GetDataSize();\n\n    m_queue.push_back(pPacket);\n}\n\n// Get a packet from the beginning of the list\nPacket *CPacketQueue::Get()\n{\n    CAutoLock cAutoLock(this);\n\n    if (m_queue.size() == 0)\n    {\n        return nullptr;\n    }\n    Packet *pPacket = m_queue.front();\n    m_queue.pop_front();\n\n    if (pPacket)\n        m_dataSize -= (size_t)pPacket->GetDataSize();\n\n    return pPacket;\n}\n\n// Get the size of the queue\nsize_t CPacketQueue::Size()\n{\n    CAutoLock cAutoLock(this);\n\n    return m_queue.size();\n}\n\n// Get the size of the queue\nsize_t CPacketQueue::DataSize()\n{\n    CAutoLock cAutoLock(this);\n\n    return m_dataSize;\n}\n\n// Clear the List (all elements are free'ed)\nvoid CPacketQueue::Clear()\n{\n    CAutoLock cAutoLock(this);\n\n    DbgLog((LOG_TRACE, 10, L\"CPacketQueue::Clear() - clearing queue with %d entries\", m_queue.size()));\n\n    std::deque<Packet *>::iterator it;\n    for (it = m_queue.begin(); it != m_queue.end(); ++it)\n    {\n        delete *it;\n    }\n    m_queue.clear();\n    m_dataSize = 0;\n}\n"
  },
  {
    "path": "demuxer/LAVSplitter/PacketQueue.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <deque>\n\n#define MIN_PACKETS_IN_QUEUE 50 // Below this is considered \"drying pin\"\n\nclass Packet;\n\n// FIFO Packet Queue\nclass CPacketQueue : public CCritSec\n{\n  public:\n    CPacketQueue(){};\n\n    // Queue a new packet at the end of the list\n    void Queue(Packet *pPacket);\n\n    // Get a packet from the beginning of the list\n    Packet *Get();\n\n    // Get the size of the queue\n    size_t Size();\n\n    // Get the size of the queue in bytes\n    size_t DataSize();\n\n    // Clear the List (all elements are free'ed)\n    void Clear();\n\n    // Get access to the internal queue\n    std::deque<Packet *> *GetQueue() { return &m_queue; }\n\n    bool IsEmpty()\n    {\n        CAutoLock cAutoLock(this);\n        return m_queue.empty();\n    }\n\n  private:\n    // The actual storage class\n    std::deque<Packet *> m_queue;\n    size_t m_dataSize = 0;\n\n#ifdef DEBUG\n    bool m_bWarnedFull = false;\n    bool m_bWarnedExtreme = false;\n#endif\n};\n"
  },
  {
    "path": "demuxer/LAVSplitter/SettingsProp.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#include \"stdafx.h\"\n\n#include <assert.h>\n#include <Commctrl.h>\n\n#include \"SettingsProp.h\"\n\n#include \"DShowUtil.h\"\n#include \"version.h\"\n\nCLAVSplitterSettingsProp::CLAVSplitterSettingsProp(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseDSPropPage(NAME(\"LAVF Settings\"), pUnk, IDD_PROPPAGE_LAVFSETTINGS, IDS_PAGE_TITLE)\n{\n}\n\nCLAVSplitterSettingsProp::~CLAVSplitterSettingsProp(void)\n{\n    SAFE_CO_FREE(m_pszPrefLang);\n    SAFE_CO_FREE(m_pszPrefSubLang);\n    SAFE_CO_FREE(m_pszAdvSubConfig);\n    SafeRelease(&m_pLAVF);\n}\n\nHRESULT CLAVSplitterSettingsProp::OnConnect(IUnknown *pUnk)\n{\n    if (pUnk == nullptr)\n    {\n        return E_POINTER;\n    }\n    ASSERT(m_pLAVF == nullptr);\n    return pUnk->QueryInterface(&m_pLAVF);\n}\n\nHRESULT CLAVSplitterSettingsProp::OnDisconnect()\n{\n    SafeRelease(&m_pLAVF);\n    return S_OK;\n}\n\nHRESULT CLAVSplitterSettingsProp::OnApplyChanges()\n{\n    ASSERT(m_pLAVF != nullptr);\n    HRESULT hr = S_OK;\n    DWORD dwVal;\n    BOOL bFlag;\n\n    WCHAR buffer[LANG_BUFFER_SIZE];\n    // Save audio language\n    SendDlgItemMessage(m_Dlg, IDC_PREF_LANG, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);\n    CHECK_HR(hr = m_pLAVF->SetPreferredLanguages(buffer));\n\n    // Save subtitle language\n    SendDlgItemMessage(m_Dlg, IDC_PREF_LANG_SUBS, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);\n\n    if (m_selectedSubMode == LAVSubtitleMode_Advanced)\n    {\n        CHECK_HR(hr = m_pLAVF->SetPreferredSubtitleLanguages(m_subLangBuffer));\n        CHECK_HR(hr = m_pLAVF->SetAdvancedSubtitleConfig(buffer));\n    }\n    else\n    {\n        CHECK_HR(hr = m_pLAVF->SetPreferredSubtitleLanguages(buffer));\n        CHECK_HR(hr = m_pLAVF->SetAdvancedSubtitleConfig(m_advSubBuffer));\n    }\n\n    // Save subtitle mode\n    dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_GETCURSEL, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetSubtitleMode((LAVSubtitleMode)dwVal));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BD_SEPARATE_FORCED_SUBS, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetPGSForcedStream(bFlag));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BD_ONLY_FORCED_SUBS, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetPGSOnlyForced(bFlag));\n\n    int vc1flag = (int)SendDlgItemMessage(m_Dlg, IDC_VC1TIMESTAMP, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetVC1TimestampMode(vc1flag));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_MKV_EXTERNAL, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetLoadMatroskaExternalSegments(bFlag));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SUBSTREAMS, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetSubstreamsEnabled(bFlag));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_REMOVE_AUDIO, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetStreamSwitchRemoveAudio(bFlag));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_RESELECT_SUBS, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetStreamSwitchReselectSubtitles(bFlag));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SELECT_AUDIO_QUALITY, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetPreferHighQualityAudioStreams(bFlag));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_IMPAIRED_AUDIO, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetUseAudioForHearingVisuallyImpaired(bFlag));\n\n    SendDlgItemMessage(m_Dlg, IDC_QUEUE_MEM, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);\n    int maxMem = _wtoi(buffer);\n    CHECK_HR(hr = m_pLAVF->SetMaxQueueMemSize(maxMem));\n\n    SendDlgItemMessage(m_Dlg, IDC_QUEUE_PACKETS, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);\n    int maxPackets = _wtoi(buffer);\n    CHECK_HR(hr = m_pLAVF->SetMaxQueueSize(maxPackets));\n\n    SendDlgItemMessage(m_Dlg, IDC_STREAM_ANADUR, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);\n    int duration = _wtoi(buffer);\n    CHECK_HR(hr = m_pLAVF->SetNetworkStreamAnalysisDuration(duration));\n\n    bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_GETCHECK, 0, 0);\n    CHECK_HR(hr = m_pLAVF->SetTrayIcon(bFlag));\n\n    LoadData();\n\ndone:\n    return hr;\n}\n\nvoid CLAVSplitterSettingsProp::UpdateSubtitleMode(LAVSubtitleMode mode)\n{\n    if (mode == LAVSubtitleMode_NoSubs)\n    {\n        WCHAR *note = L\"No subtitles: Subtitles are disabled and will not be loaded by default.\";\n        SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_NOTE, WM_SETTEXT, 0, (LPARAM)note);\n    }\n    else if (mode == LAVSubtitleMode_ForcedOnly)\n    {\n        WCHAR *note = L\"Only Forced Subtitles: Only subtitles marked as \\\"forced\\\" will be loaded.\";\n        SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_NOTE, WM_SETTEXT, 0, (LPARAM)note);\n    }\n    else if (mode == LAVSubtitleMode_Default)\n    {\n        WCHAR *note = L\"Default Mode: Subtitles matching the preferred languages, as well as \\\"default\\\" and \"\n                      L\"\\\"forced\\\" subtitles will be loaded.\";\n        SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_NOTE, WM_SETTEXT, 0, (LPARAM)note);\n    }\n    else if (mode == LAVSubtitleMode_Advanced)\n    {\n        WCHAR *note = L\"Advanced Mode: Refer to the README or the documentation on http://1f0.de for details.\";\n        SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_NOTE, WM_SETTEXT, 0, (LPARAM)note);\n    }\n    else\n    {\n        WCHAR *empty = L\"\";\n        SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_NOTE, WM_SETTEXT, 0, (LPARAM)empty);\n    }\n\n    LAVSubtitleMode oldMode = m_selectedSubMode;\n    m_selectedSubMode = mode;\n    // Switch away from advanced\n    if (oldMode != mode && oldMode == LAVSubtitleMode_Advanced)\n    {\n        SendDlgItemMessage(m_Dlg, IDC_PREF_LANG_SUBS, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&m_advSubBuffer);\n        SendDlgItemMessage(m_Dlg, IDC_PREF_LANG_SUBS, WM_SETTEXT, 0, (LPARAM)&m_subLangBuffer);\n        // Switch to advanced\n    }\n    else if (oldMode != mode && mode == LAVSubtitleMode_Advanced)\n    {\n        SendDlgItemMessage(m_Dlg, IDC_PREF_LANG_SUBS, WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&m_subLangBuffer);\n        SendDlgItemMessage(m_Dlg, IDC_PREF_LANG_SUBS, WM_SETTEXT, 0, (LPARAM)&m_advSubBuffer);\n    }\n}\n\nHRESULT CLAVSplitterSettingsProp::OnActivate()\n{\n    HRESULT hr = S_OK;\n    INITCOMMONCONTROLSEX icc;\n    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);\n    icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;\n    if (InitCommonControlsEx(&icc) == FALSE)\n    {\n        return E_FAIL;\n    }\n    ASSERT(m_pLAVF != nullptr);\n\n    const WCHAR *version = TEXT(LAV_SPLITTER) L\" \" TEXT(LAV_VERSION_STR);\n    SendDlgItemMessage(m_Dlg, IDC_SPLITTER_FOOTER, WM_SETTEXT, 0, (LPARAM)version);\n\n    hr = LoadData();\n    memset(m_subLangBuffer, 0, sizeof(m_advSubBuffer));\n    memset(m_advSubBuffer, 0, sizeof(m_advSubBuffer));\n\n    m_selectedSubMode = LAVSubtitleMode_Default;\n    if (m_pszAdvSubConfig)\n        wcsncpy_s(m_advSubBuffer, m_pszAdvSubConfig, _TRUNCATE);\n\n    // Notify the UI about those settings\n    SendDlgItemMessage(m_Dlg, IDC_PREF_LANG, WM_SETTEXT, 0, (LPARAM)m_pszPrefLang);\n    SendDlgItemMessage(m_Dlg, IDC_PREF_LANG_SUBS, WM_SETTEXT, 0, (LPARAM)m_pszPrefSubLang);\n\n    // Init the Combo Box\n    SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_RESETCONTENT, 0, 0);\n    WideStringFromResource(stringBuffer, IDS_SUBMODE_NO_SUBS);\n    SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    WideStringFromResource(stringBuffer, IDS_SUBMODE_FORCED_SUBS);\n    SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    WideStringFromResource(stringBuffer, IDS_SUBMODE_DEFAULT);\n    SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n    WideStringFromResource(stringBuffer, IDS_SUBMODE_ADVANCED);\n    SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_ADDSTRING, 0, (LPARAM)stringBuffer);\n\n    SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_SETCURSEL, m_subtitleMode, 0);\n    addHint(IDC_SUBTITLE_MODE, L\"Configure how subtitles are selected.\");\n\n    SendDlgItemMessage(m_Dlg, IDC_BD_SEPARATE_FORCED_SUBS, BM_SETCHECK, m_PGSForcedStream, 0);\n    addHint(IDC_BD_SEPARATE_FORCED_SUBS,\n            L\"Enabling this causes the creation of a new \\\"Forced Subtitles\\\" stream, which will try to always display \"\n            L\"forced subtitles matching your selected audio language.\\n\\nNOTE: This option may not work on all Blu-ray \"\n            L\"discs.\\nRequires restart to take effect.\");\n\n    SendDlgItemMessage(m_Dlg, IDC_BD_ONLY_FORCED_SUBS, BM_SETCHECK, m_PGSOnlyForced, 0);\n    addHint(IDC_BD_ONLY_FORCED_SUBS,\n            L\"When enabled, all Blu-ray (PGS) subtitles will be filtered, and only forced subtitles will be sent to \"\n            L\"the renderer.\\n\\nNOTE: When this option is active, you will not be able to get the \\\"full\\\" subtitles.\");\n\n    SendDlgItemMessage(m_Dlg, IDC_VC1TIMESTAMP, BM_SETCHECK, m_VC1Mode, 0);\n    addHint(IDC_VC1TIMESTAMP, L\"Checked - Frame timings will be corrected.\\nUnchecked - Frame timings will be sent \"\n                              L\"untouched.\\nIndeterminate (Auto) - Only enabled for decoders that rely on the splitter \"\n                              L\"doing the corrections.\\n\\nNOTE: Only for debugging, if unsure, set to \\\"Auto\\\".\");\n\n    SendDlgItemMessage(m_Dlg, IDC_MKV_EXTERNAL, BM_SETCHECK, m_MKVExternal, 0);\n\n    SendDlgItemMessage(m_Dlg, IDC_SUBSTREAMS, BM_SETCHECK, m_substreams, 0);\n    addHint(IDC_SUBSTREAMS,\n            L\"Controls if sub-streams should be exposed as a separate stream.\\nSub-streams are typically streams for \"\n            L\"backwards compatibility, for example the AC3 part of TrueHD streams on Blu-rays.\");\n\n    SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_REMOVE_AUDIO, BM_SETCHECK, m_StreamSwitchRemoveAudio, 0);\n    addHint(IDC_STREAM_SWITCH_REMOVE_AUDIO,\n            L\"Remove the old Audio Decoder from the Playback Chain before switching the audio stream, forcing \"\n            L\"DirectShow to select a new one.\\n\\nThis option ensures that the preferred decoder is always used, \"\n            L\"however it does not work properly with all players.\");\n\n    SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_RESELECT_SUBS, BM_SETCHECK, m_StreamSwitchReselectSubs, 0);\n    addHint(IDC_STREAM_SWITCH_RESELECT_SUBS,\n            L\"Reapply the subtitle-selection rules when the audio-stream has changed. This automatically adjusts the \"\n            L\"selected subtitle to the selected audio track.\\nThe subtitle track can still be changed manually, \"\n            L\"however it will be overridden again on the next audio track switch.\");\n\n    addHint(IDC_SELECT_AUDIO_QUALITY,\n            L\"Controls if the stream with the highest quality (matching your language preferences) should always be \"\n            L\"used.\\nIf disabled, the first stream is always used.\");\n    SendDlgItemMessage(m_Dlg, IDC_SELECT_AUDIO_QUALITY, BM_SETCHECK, m_PreferHighQualityAudio, 0);\n\n    SendDlgItemMessage(m_Dlg, IDC_IMPAIRED_AUDIO, BM_SETCHECK, m_ImpairedAudio, 0);\n\n    SendDlgItemMessage(m_Dlg, IDC_QUEUE_MEM_SPIN, UDM_SETRANGE32, 0, 2048);\n\n    addHint(IDC_QUEUE_MEM,\n            L\"Set the maximum memory a frame queue can use for buffering (in megabytes).\\nNote that this is the \"\n            L\"maximum value, only very high bitrate files will usually even reach the default maximum value.\");\n    addHint(IDC_QUEUE_MEM_SPIN,\n            L\"Set the maximum memory a frame queue can use for buffering (in megabytes).\\nNote that this is the \"\n            L\"maximum value, only very high bitrate files will usually even reach the default maximum value.\");\n\n    swprintf_s(stringBuffer, L\"%d\", m_QueueMaxMem);\n    SendDlgItemMessage(m_Dlg, IDC_QUEUE_MEM, WM_SETTEXT, 0, (LPARAM)stringBuffer);\n\n    SendDlgItemMessage(m_Dlg, IDC_QUEUE_PACKETS_SPIN, UDM_SETRANGE32, 100, 100000);\n\n    addHint(IDC_QUEUE_PACKETS, L\"Set the maximum numbers of packets to buffer in the frame queue.\\nNote that the frame \"\n                               L\"queue will never exceed the memory limited set above.\");\n    addHint(IDC_QUEUE_PACKETS_SPIN, L\"Set the maximum numbers of packets to buffer in the frame queue.\\nNote that the \"\n                                    L\"frame queue will never exceed the memory limited set above.\");\n\n    swprintf_s(stringBuffer, L\"%d\", m_QueueMaxPackets);\n    SendDlgItemMessage(m_Dlg, IDC_QUEUE_PACKETS, WM_SETTEXT, 0, (LPARAM)stringBuffer);\n\n    SendDlgItemMessage(m_Dlg, IDC_STREAM_ANADUR_SPIN, UDM_SETRANGE32, 200, 10000);\n\n    addHint(IDC_STREAM_ANADUR, L\"Set the duration (in milliseconds) a network stream is analyzed for before playback \"\n                               L\"starts.\\nA longer duration ensures the stream parameters are properly detected, \"\n                               L\"however it will delay playback start.\\n\\nDefault: 1000 (1 second)\");\n    addHint(IDC_STREAM_ANADUR_SPIN, L\"Set the duration (in milliseconds) a network stream is analyzed for before \"\n                                    L\"playback starts.\\nA longer duration ensures the stream parameters are properly \"\n                                    L\"detected, however it will delay playback start.\\n\\nDefault: 1000 (1 second)\");\n\n    swprintf_s(stringBuffer, L\"%d\", m_NetworkAnalysisDuration);\n    SendDlgItemMessage(m_Dlg, IDC_STREAM_ANADUR, WM_SETTEXT, 0, (LPARAM)stringBuffer);\n\n    UpdateSubtitleMode(m_subtitleMode);\n\n    SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_SETCHECK, m_TrayIcon, 0);\n\n    return hr;\n}\nHRESULT CLAVSplitterSettingsProp::LoadData()\n{\n    HRESULT hr = S_OK;\n\n    // Free old strings\n    SAFE_CO_FREE(m_pszPrefLang);\n    SAFE_CO_FREE(m_pszPrefSubLang);\n    SAFE_CO_FREE(m_pszAdvSubConfig);\n\n    // Query current settings\n    CHECK_HR(hr = m_pLAVF->GetPreferredLanguages(&m_pszPrefLang));\n    CHECK_HR(hr = m_pLAVF->GetPreferredSubtitleLanguages(&m_pszPrefSubLang));\n    CHECK_HR(hr = m_pLAVF->GetAdvancedSubtitleConfig(&m_pszAdvSubConfig));\n    m_subtitleMode = m_pLAVF->GetSubtitleMode();\n    m_PGSForcedStream = m_pLAVF->GetPGSForcedStream();\n    m_PGSOnlyForced = m_pLAVF->GetPGSOnlyForced();\n    m_VC1Mode = m_pLAVF->GetVC1TimestampMode();\n    m_substreams = m_pLAVF->GetSubstreamsEnabled();\n    m_MKVExternal = m_pLAVF->GetLoadMatroskaExternalSegments();\n\n    m_StreamSwitchReselectSubs = m_pLAVF->GetStreamSwitchReselectSubtitles();\n\n    m_StreamSwitchRemoveAudio = m_pLAVF->GetStreamSwitchRemoveAudio();\n    m_PreferHighQualityAudio = m_pLAVF->GetPreferHighQualityAudioStreams();\n    m_ImpairedAudio = m_pLAVF->GetUseAudioForHearingVisuallyImpaired();\n    m_QueueMaxMem = m_pLAVF->GetMaxQueueMemSize();\n    m_QueueMaxPackets = m_pLAVF->GetMaxQueueSize();\n    m_NetworkAnalysisDuration = m_pLAVF->GetNetworkStreamAnalysisDuration();\n\n    m_TrayIcon = m_pLAVF->GetTrayIcon();\n\ndone:\n    return hr;\n}\n\nINT_PTR CLAVSplitterSettingsProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    switch (uMsg)\n    {\n    case WM_COMMAND:\n        // Mark the page dirty if the text changed\n        if (HIWORD(wParam) == EN_CHANGE && (LOWORD(wParam) == IDC_PREF_LANG || LOWORD(wParam) == IDC_PREF_LANG_SUBS))\n        {\n\n            WCHAR buffer[LANG_BUFFER_SIZE];\n            SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, LANG_BUFFER_SIZE, (LPARAM)&buffer);\n\n            int dirty = 0;\n            WCHAR *source = nullptr;\n            if (LOWORD(wParam) == IDC_PREF_LANG)\n            {\n                source = m_pszPrefLang;\n            }\n            else\n            {\n                source = (m_selectedSubMode == LAVSubtitleMode_Advanced) ? m_pszAdvSubConfig : m_pszPrefSubLang;\n            }\n\n            if (source)\n            {\n                dirty = _wcsicmp(buffer, source);\n            }\n            else\n            {\n                dirty = (int)wcslen(buffer);\n            }\n\n            if (dirty != 0)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == CBN_SELCHANGE && LOWORD(wParam) == IDC_SUBTITLE_MODE)\n        {\n            DWORD dwVal = (DWORD)SendDlgItemMessage(m_Dlg, IDC_SUBTITLE_MODE, CB_GETCURSEL, 0, 0);\n            UpdateSubtitleMode((LAVSubtitleMode)dwVal);\n            if (dwVal != m_subtitleMode)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BD_SEPARATE_FORCED_SUBS)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BD_SEPARATE_FORCED_SUBS, BM_GETCHECK, 0, 0);\n            if (bFlag != m_PGSForcedStream)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_BD_ONLY_FORCED_SUBS)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_BD_ONLY_FORCED_SUBS, BM_GETCHECK, 0, 0);\n            if (bFlag != m_PGSOnlyForced)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_VC1TIMESTAMP)\n        {\n            int iFlag = (int)SendDlgItemMessage(m_Dlg, IDC_VC1TIMESTAMP, BM_GETCHECK, 0, 0);\n            if (iFlag != m_VC1Mode)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_MKV_EXTERNAL)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_MKV_EXTERNAL, BM_GETCHECK, 0, 0);\n            if (bFlag != m_MKVExternal)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_SUBSTREAMS)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SUBSTREAMS, BM_GETCHECK, 0, 0);\n            if (bFlag != m_substreams)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_STREAM_SWITCH_REMOVE_AUDIO)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_REMOVE_AUDIO, BM_GETCHECK, 0, 0);\n            if (bFlag != m_StreamSwitchRemoveAudio)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_STREAM_SWITCH_RESELECT_SUBS)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_STREAM_SWITCH_RESELECT_SUBS, BM_GETCHECK, 0, 0);\n            if (bFlag != m_StreamSwitchReselectSubs)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_SELECT_AUDIO_QUALITY)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_SELECT_AUDIO_QUALITY, BM_GETCHECK, 0, 0);\n            if (bFlag != m_PreferHighQualityAudio)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_IMPAIRED_AUDIO)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_IMPAIRED_AUDIO, BM_GETCHECK, 0, 0);\n            if (bFlag != m_ImpairedAudio)\n            {\n                SetDirty();\n            }\n        }\n        else if (HIWORD(wParam) == BN_CLICKED && LOWORD(wParam) == IDC_TRAYICON)\n        {\n            BOOL bFlag = (BOOL)SendDlgItemMessage(m_Dlg, IDC_TRAYICON, BM_GETCHECK, 0, 0);\n            if (bFlag != m_TrayIcon)\n            {\n                SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_QUEUE_MEM && HIWORD(wParam) == EN_CHANGE)\n        {\n            WCHAR buffer[100];\n            SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, 100, (LPARAM)&buffer);\n            int maxMem = _wtoi(buffer);\n            size_t len = wcslen(buffer);\n            if (maxMem == 0 && (buffer[0] != L'0' || len > 1))\n            {\n                SendDlgItemMessage(m_Dlg, LOWORD(wParam), EM_UNDO, 0, 0);\n            }\n            else\n            {\n                swprintf_s(buffer, L\"%d\", maxMem);\n                if (wcslen(buffer) != len)\n                    SendDlgItemMessage(m_Dlg, IDC_QUEUE_MEM, WM_SETTEXT, 0, (LPARAM)buffer);\n                if (maxMem != m_QueueMaxMem)\n                    SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_QUEUE_PACKETS && HIWORD(wParam) == EN_CHANGE)\n        {\n            WCHAR buffer[100];\n            SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, 100, (LPARAM)&buffer);\n            int maxMem = _wtoi(buffer);\n            size_t len = wcslen(buffer);\n            if (maxMem == 0 && (buffer[0] != L'0' || len > 1))\n            {\n                SendDlgItemMessage(m_Dlg, LOWORD(wParam), EM_UNDO, 0, 0);\n            }\n            else\n            {\n                swprintf_s(buffer, L\"%d\", maxMem);\n                if (wcslen(buffer) != len)\n                    SendDlgItemMessage(m_Dlg, IDC_QUEUE_PACKETS, WM_SETTEXT, 0, (LPARAM)buffer);\n                if (maxMem != m_QueueMaxPackets)\n                    SetDirty();\n            }\n        }\n        else if (LOWORD(wParam) == IDC_STREAM_ANADUR && HIWORD(wParam) == EN_CHANGE)\n        {\n            WCHAR buffer[100];\n            SendDlgItemMessage(m_Dlg, LOWORD(wParam), WM_GETTEXT, 100, (LPARAM)&buffer);\n            int duration = _wtoi(buffer);\n            size_t len = wcslen(buffer);\n            if (duration == 0 && (buffer[0] != L'0' || len > 1))\n            {\n                SendDlgItemMessage(m_Dlg, LOWORD(wParam), EM_UNDO, 0, 0);\n            }\n            else\n            {\n                swprintf_s(buffer, L\"%d\", duration);\n                if (wcslen(buffer) != len)\n                    SendDlgItemMessage(m_Dlg, IDC_STREAM_ANADUR, WM_SETTEXT, 0, (LPARAM)buffer);\n                if (duration != m_NetworkAnalysisDuration)\n                    SetDirty();\n            }\n        }\n        break;\n    }\n    // Let the parent class handle the message.\n    return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n\nCLAVSplitterFormatsProp::CLAVSplitterFormatsProp(LPUNKNOWN pUnk, HRESULT *phr)\n    : CBaseDSPropPage(NAME(\"LAVF Settings\"), pUnk, IDD_PROPPAGE_FORMATS, IDS_INPUT_FORMATS)\n{\n}\n\nCLAVSplitterFormatsProp::~CLAVSplitterFormatsProp(void)\n{\n    SAFE_CO_FREE(m_bFormats);\n    SafeRelease(&m_pLAVF);\n}\n\nHRESULT CLAVSplitterFormatsProp::OnConnect(IUnknown *pUnk)\n{\n    if (pUnk == nullptr)\n    {\n        return E_POINTER;\n    }\n    ASSERT(m_pLAVF == nullptr);\n    return pUnk->QueryInterface(&m_pLAVF);\n}\n\nHRESULT CLAVSplitterFormatsProp::OnDisconnect()\n{\n    SafeRelease(&m_pLAVF);\n    return S_OK;\n}\n\nHRESULT CLAVSplitterFormatsProp::OnApplyChanges()\n{\n    HRESULT hr = S_OK;\n    ASSERT(m_pLAVF != nullptr);\n\n    HWND hlv = GetDlgItem(m_Dlg, IDC_FORMATS);\n\n    int nItem = 0;\n    std::set<FormatInfo>::const_iterator it;\n    for (it = m_Formats.begin(); it != m_Formats.end(); ++it)\n    {\n        m_bFormats[nItem] = ListView_GetCheckState(hlv, nItem);\n        m_pLAVF->SetFormatEnabled(it->strName, m_bFormats[nItem]);\n\n        nItem++;\n    }\n\n    return hr;\n}\n\nHRESULT CLAVSplitterFormatsProp::OnActivate()\n{\n    HRESULT hr = S_OK;\n    INITCOMMONCONTROLSEX icc;\n    icc.dwSize = sizeof(INITCOMMONCONTROLSEX);\n    icc.dwICC = ICC_BAR_CLASSES | ICC_STANDARD_CLASSES;\n    if (InitCommonControlsEx(&icc) == FALSE)\n    {\n        return E_FAIL;\n    }\n    ASSERT(m_pLAVF != nullptr);\n\n    memset(stringBuffer, 0, sizeof(stringBuffer));\n\n    const char *pszInput = m_pLAVF->GetInputFormat();\n    if (pszInput)\n    {\n        _snwprintf_s(stringBuffer, _TRUNCATE, L\"%S\", pszInput);\n    }\n    SendDlgItemMessage(m_Dlg, IDC_CUR_INPUT, WM_SETTEXT, 0, (LPARAM)stringBuffer);\n\n    m_Formats = m_pLAVF->GetInputFormats();\n\n    // Setup ListView control for format configuration\n    SendDlgItemMessage(m_Dlg, IDC_FORMATS, CCM_DPISCALE, TRUE, 0);\n\n    HWND hlv = GetDlgItem(m_Dlg, IDC_FORMATS);\n    ListView_SetExtendedListViewStyle(hlv, LVS_EX_CHECKBOXES | LVS_EX_FULLROWSELECT | LVS_EX_GRIDLINES);\n\n    int nCol = 1;\n    LVCOLUMN lvc = {LVCF_WIDTH, 0, 20, 0};\n    ListView_InsertColumn(hlv, 0, &lvc);\n    ListView_AddCol(hlv, nCol, 75, L\"Format\", false);\n    ListView_AddCol(hlv, nCol, 210, L\"Description\", false);\n\n    ListView_DeleteAllItems(hlv);\n    ListView_SetItemCount(hlv, m_Formats.size());\n\n    SAFE_CO_FREE(m_bFormats);\n    m_bFormats = (BOOL *)CoTaskMemAlloc(sizeof(BOOL) * m_Formats.size());\n    if (!m_bFormats)\n        return E_OUTOFMEMORY;\n    memset(m_bFormats, 0, sizeof(BOOL) * m_Formats.size());\n\n    // Create entries for the formats\n    LVITEM lvi;\n    memset(&lvi, 0, sizeof(lvi));\n    lvi.mask = LVIF_TEXT | LVIF_PARAM;\n\n    int nItem = 0;\n    std::set<FormatInfo>::const_iterator it;\n    for (it = m_Formats.begin(); it != m_Formats.end(); ++it)\n    {\n        // Create main entry\n        lvi.iItem = nItem + 1;\n        ListView_InsertItem(hlv, &lvi);\n\n        // Set sub item texts\n        _snwprintf_s(stringBuffer, _TRUNCATE, L\"%S\", it->strName);\n        ListView_SetItemText(hlv, nItem, 1, (LPWSTR)stringBuffer);\n\n        _snwprintf_s(stringBuffer, _TRUNCATE, L\"%S\", it->strDescription);\n        ListView_SetItemText(hlv, nItem, 2, (LPWSTR)stringBuffer);\n\n        m_bFormats[nItem] = m_pLAVF->IsFormatEnabled(it->strName);\n        ListView_SetCheckState(hlv, nItem, m_bFormats[nItem]);\n\n        nItem++;\n    }\n\n    return hr;\n}\n\nINT_PTR CLAVSplitterFormatsProp::OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)\n{\n    switch (uMsg)\n    {\n    case WM_NOTIFY:\n        NMHDR *hdr = (LPNMHDR)lParam;\n        if (hdr->idFrom == IDC_FORMATS)\n        {\n            switch (hdr->code)\n            {\n            case LVN_ITEMCHANGED:\n                LPNMLISTVIEW nmlv = (LPNMLISTVIEW)lParam;\n                BOOL check = ListView_GetCheckState(hdr->hwndFrom, nmlv->iItem);\n                if (check != m_bFormats[nmlv->iItem])\n                {\n                    SetDirty();\n                }\n                return TRUE;\n            }\n        }\n        break;\n    }\n    // Let the parent class handle the message.\n    return __super::OnReceiveMessage(hwnd, uMsg, wParam, lParam);\n}\n"
  },
  {
    "path": "demuxer/LAVSplitter/SettingsProp.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include \"BaseDSPropPage.h\"\n#include \"LAVSplitterSettingsInternal.h\"\n\n// GUID: a19de2f2-2f74-4927-8436-61129d26c141\nDEFINE_GUID(CLSID_LAVSplitterSettingsProp, 0xa19de2f2, 0x2f74, 0x4927, 0x84, 0x36, 0x61, 0x12, 0x9d, 0x26, 0xc1, 0x41);\n\n// {56904B22-091C-4459-A2E6-B1F4F946B55F}\nDEFINE_GUID(CLSID_LAVSplitterFormatsProp, 0x56904b22, 0x91c, 0x4459, 0xa2, 0xe6, 0xb1, 0xf4, 0xf9, 0x46, 0xb5, 0x5f);\n\n#define LANG_BUFFER_SIZE 16384\n\nclass CLAVSplitterSettingsProp : public CBaseDSPropPage\n{\n  public:\n    CLAVSplitterSettingsProp(LPUNKNOWN pUnk, HRESULT *phr);\n    virtual ~CLAVSplitterSettingsProp(void);\n\n    HRESULT OnActivate();\n    HRESULT OnConnect(IUnknown *pUnk);\n    HRESULT OnDisconnect();\n    HRESULT OnApplyChanges();\n    INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    HRESULT LoadData();\n    void UpdateSubtitleMode(LAVSubtitleMode mode);\n\n    void SetDirty()\n    {\n        m_bDirty = TRUE;\n        if (m_pPageSite)\n        {\n            m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);\n        }\n    }\n\n  private:\n    ILAVFSettingsInternal *m_pLAVF = nullptr;\n\n    // Settings\n    WCHAR *m_pszPrefLang = nullptr;\n    WCHAR *m_pszPrefSubLang = nullptr;\n    WCHAR *m_pszAdvSubConfig = nullptr;\n\n    LAVSubtitleMode m_subtitleMode;\n    BOOL m_PGSForcedStream;\n    BOOL m_PGSOnlyForced;\n    int m_VC1Mode;\n    BOOL m_substreams;\n    BOOL m_MKVExternal;\n\n    BOOL m_StreamSwitchReselectSubs;\n\n    BOOL m_StreamSwitchRemoveAudio;\n    BOOL m_PreferHighQualityAudio;\n    BOOL m_ImpairedAudio;\n    DWORD m_QueueMaxMem;\n    DWORD m_QueueMaxPackets;\n    DWORD m_NetworkAnalysisDuration;\n\n    BOOL m_TrayIcon;\n\n    LAVSubtitleMode m_selectedSubMode;\n    WCHAR m_subLangBuffer[LANG_BUFFER_SIZE];\n    WCHAR m_advSubBuffer[LANG_BUFFER_SIZE];\n\n    WCHAR stringBuffer[256];\n};\n\nclass CLAVSplitterFormatsProp : public CBaseDSPropPage\n{\n  public:\n    CLAVSplitterFormatsProp(LPUNKNOWN pUnk, HRESULT *phr);\n    virtual ~CLAVSplitterFormatsProp(void);\n\n    HRESULT OnActivate();\n    HRESULT OnConnect(IUnknown *pUnk);\n    HRESULT OnDisconnect();\n    HRESULT OnApplyChanges();\n    INT_PTR OnReceiveMessage(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);\n\n  private:\n    void SetDirty()\n    {\n        m_bDirty = TRUE;\n        if (m_pPageSite)\n        {\n            m_pPageSite->OnStatusChange(PROPPAGESTATUS_DIRTY);\n        }\n    }\n\n  private:\n    ILAVFSettingsInternal *m_pLAVF = nullptr;\n\n    std::set<FormatInfo> m_Formats;\n    BOOL *m_bFormats = nullptr;\n\n    WCHAR stringBuffer[256];\n};\n"
  },
  {
    "path": "demuxer/LAVSplitter/StreamParser.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#include \"stdafx.h\"\n#include \"StreamParser.h\"\n\n#include \"OutputPin.h\"\n#include \"H264Nalu.h\"\n\n#pragma warning(push)\n#pragma warning(disable : 4101)\n#pragma warning(disable : 5033)\nextern \"C\"\n{\n#define AVCODEC_X86_MATHOPS_H\n#include \"libavcodec/get_bits.h\"\n}\n#pragma warning(pop)\n\n#define AAC_ADTS_HEADER_SIZE 7\n\n//#define DEBUG_PGS_PARSER\n\nCStreamParser::CStreamParser(CLAVOutputPin *pPin, const char *szContainer)\n    : m_pPin(pPin)\n    , m_strContainer(szContainer)\n{\n}\n\nCStreamParser::~CStreamParser()\n{\n    Flush();\n}\n\nHRESULT CStreamParser::Parse(const GUID &gSubtype, Packet *pPacket)\n{\n    if (gSubtype != m_gSubtype)\n    {\n        m_gSubtype = gSubtype;\n        Flush();\n    }\n\n    if (!pPacket || (pPacket->dwFlags & LAV_PACKET_PARSED))\n    {\n        Queue(pPacket);\n    }\n    else if (m_gSubtype == MEDIASUBTYPE_AVC1 &&\n             (m_strContainer == \"mpegts\" || pPacket->dwFlags & LAV_PACKET_H264_ANNEXB))\n    {\n        ParseH264AnnexB(pPacket);\n    }\n    else if (m_gSubtype == MEDIASUBTYPE_HDMVSUB)\n    {\n        ParsePGS(pPacket);\n    }\n    else if (m_gSubtype == MEDIASUBTYPE_HDMV_LPCM_AUDIO)\n    {\n        pPacket->RemoveHead(4);\n        Queue(pPacket);\n    }\n    else if (m_gSubtype == MEDIASUBTYPE_DVD_LPCM_AUDIO)\n    {\n        pPacket->RemoveHead(3);\n        Queue(pPacket);\n    }\n    else if (pPacket->dwFlags & LAV_PACKET_MOV_TEXT)\n    {\n        ParseMOVText(pPacket);\n    }\n    else if (m_gSubtype == MEDIASUBTYPE_AAC && (m_strContainer != \"matroska\" && m_strContainer != \"mp4\"))\n    {\n        ParseAAC(pPacket);\n    }\n    else if (m_gSubtype == MEDIASUBTYPE_UTF8 && (pPacket->dwFlags & LAV_PACKET_SRT))\n    {\n        ParseSRT(pPacket);\n    }\n    else if ((m_gSubtype == MEDIASUBTYPE_PCM || m_gSubtype == MEDIASUBTYPE_PCM_TWOS) &&\n             (pPacket->dwFlags & LAV_PACKET_PLANAR_PCM))\n    {\n        ParsePlanarPCM(pPacket);\n    }\n    else\n    {\n        Queue(pPacket);\n    }\n\n    return S_OK;\n}\n\nHRESULT CStreamParser::Flush()\n{\n    DbgLog((LOG_TRACE, 10, L\"CStreamParser::Flush()\"));\n    SAFE_DELETE(m_pPacketBuffer);\n    m_queue.Clear();\n    m_bPGSDropState = FALSE;\n    m_bHasAccessUnitDelimiters = false;\n\n    return S_OK;\n}\n\nHRESULT CStreamParser::Queue(Packet *pPacket) const\n{\n    return m_pPin->QueueFromParser(pPacket);\n}\n\nstatic Packet *InitPacket(Packet *pSource)\n{\n    Packet *pNew = nullptr;\n\n    pNew = new Packet();\n    pNew->StreamId = pSource->StreamId;\n    pNew->bDiscontinuity = pSource->bDiscontinuity;\n    pSource->bDiscontinuity = FALSE;\n\n    pNew->bSyncPoint = pSource->bSyncPoint;\n    pSource->bSyncPoint = FALSE;\n\n    pNew->rtStart = pSource->rtStart;\n    pSource->rtStart = Packet::INVALID_TIME;\n\n    pNew->rtStop = pSource->rtStop;\n    pSource->rtStop = Packet::INVALID_TIME;\n\n    pNew->pmt = pSource->pmt;\n    pSource->pmt = nullptr;\n\n    return pNew;\n}\n\n#define MOVE_TO_H264_START_CODE(b, e)                                                                  \\\n    while (b <= e - 4 && !((*(DWORD *)b == 0x01000000) || ((*(DWORD *)b & 0x00FFFFFF) == 0x00010000))) \\\n        b++;                                                                                           \\\n    if ((b <= e - 4) && *(DWORD *)b == 0x01000000)                                                     \\\n        b++;\n\nHRESULT CStreamParser::ParseH264AnnexB(Packet *pPacket)\n{\n    if (!m_pPacketBuffer)\n    {\n        m_pPacketBuffer = InitPacket(pPacket);\n    }\n\n    m_pPacketBuffer->Append(pPacket);\n\n    BYTE *start = m_pPacketBuffer->GetData();\n    BYTE *end = start + m_pPacketBuffer->GetDataSize();\n\n    MOVE_TO_H264_START_CODE(start, end);\n\n    while (start <= end - 4)\n    {\n        BYTE *next = start + 1;\n\n        MOVE_TO_H264_START_CODE(next, end);\n\n        // End of buffer reached\n        if (next >= end - 4)\n        {\n            break;\n        }\n\n        size_t size = next - start;\n\n        CH264Nalu Nalu;\n        Nalu.SetBuffer(start, (int)size, 0);\n\n        Packet *p2 = nullptr;\n\n        while (Nalu.ReadNext())\n        {\n            Packet *p3 = new Packet();\n            p3->SetDataSize((int)Nalu.GetDataLength() + 4);\n\n            // Write size of the NALU (Big Endian)\n            AV_WB32(p3->GetData(), (uint32_t)Nalu.GetDataLength());\n            memcpy(p3->GetData() + 4, Nalu.GetDataBuffer(), Nalu.GetDataLength());\n\n            if (!p2)\n            {\n                p2 = p3;\n            }\n            else\n            {\n                p2->Append(p3);\n                SAFE_DELETE(p3);\n            }\n        }\n\n        if (!p2)\n            break;\n\n        p2->StreamId = m_pPacketBuffer->StreamId;\n        p2->bDiscontinuity = m_pPacketBuffer->bDiscontinuity;\n        m_pPacketBuffer->bDiscontinuity = FALSE;\n\n        p2->bSyncPoint = m_pPacketBuffer->bSyncPoint;\n        m_pPacketBuffer->bSyncPoint = FALSE;\n\n        p2->rtStart = m_pPacketBuffer->rtStart;\n        m_pPacketBuffer->rtStart = Packet::INVALID_TIME;\n        p2->rtStop = m_pPacketBuffer->rtStop;\n        m_pPacketBuffer->rtStop = Packet::INVALID_TIME;\n\n        p2->pmt = m_pPacketBuffer->pmt;\n        m_pPacketBuffer->pmt = nullptr;\n\n        m_queue.Queue(p2);\n\n        if (pPacket->rtStart != Packet::INVALID_TIME)\n        {\n            m_pPacketBuffer->rtStart = pPacket->rtStart;\n            m_pPacketBuffer->rtStop = pPacket->rtStop;\n            pPacket->rtStart = Packet::INVALID_TIME;\n        }\n        if (pPacket->bDiscontinuity)\n        {\n            m_pPacketBuffer->bDiscontinuity = pPacket->bDiscontinuity;\n            pPacket->bDiscontinuity = FALSE;\n        }\n        if (pPacket->bSyncPoint)\n        {\n            m_pPacketBuffer->bSyncPoint = pPacket->bSyncPoint;\n            pPacket->bSyncPoint = FALSE;\n        }\n        if (m_pPacketBuffer->pmt)\n        {\n            DeleteMediaType(m_pPacketBuffer->pmt);\n        }\n\n        m_pPacketBuffer->pmt = pPacket->pmt;\n        pPacket->pmt = nullptr;\n\n        start = next;\n    }\n\n    if (start > m_pPacketBuffer->GetData())\n    {\n        m_pPacketBuffer->RemoveHead((int)(start - m_pPacketBuffer->GetData()));\n    }\n\n    SAFE_DELETE(pPacket);\n\n    do\n    {\n        pPacket = nullptr;\n\n        REFERENCE_TIME rtStart = Packet::INVALID_TIME, rtStop = rtStart = Packet::INVALID_TIME;\n\n        std::deque<Packet *>::iterator it;\n        for (it = m_queue.GetQueue()->begin(); it != m_queue.GetQueue()->end(); ++it)\n        {\n            // Skip the first\n            if (it == m_queue.GetQueue()->begin())\n            {\n                continue;\n            }\n\n            Packet *p = *it;\n            BYTE *pData = p->GetData();\n\n            if ((pData[4] & 0x1f) == 0x09)\n            {\n                m_bHasAccessUnitDelimiters = true;\n            }\n\n            if ((pData[4] & 0x1f) == 0x09 || (!m_bHasAccessUnitDelimiters && p->rtStart != Packet::INVALID_TIME))\n            {\n                pPacket = p;\n                if (p->rtStart == Packet::INVALID_TIME && rtStart != Packet::INVALID_TIME)\n                {\n                    p->rtStart = rtStart;\n                    p->rtStop = rtStop;\n                }\n                break;\n            }\n\n            if (rtStart == Packet::INVALID_TIME)\n            {\n                rtStart = p->rtStart;\n                rtStop = p->rtStop;\n            }\n        }\n\n        if (pPacket)\n        {\n            Packet *p = m_queue.Get();\n            Packet *p2 = nullptr;\n            while ((p2 = m_queue.Get()) != pPacket)\n            {\n                p->Append(p2);\n                SAFE_DELETE(p2);\n            }\n            // Return\n            m_queue.GetQueue()->push_front(pPacket);\n\n            Queue(p);\n        }\n    } while (pPacket != nullptr);\n\n    return S_OK;\n}\n\nHRESULT CStreamParser::ParsePGS(Packet *pPacket)\n{\n    const uint8_t *buf = pPacket->GetData();\n    const size_t buf_size = pPacket->GetDataSize();\n\n    const uint8_t *buf_end = buf + buf_size;\n    uint8_t segment_type;\n    size_t segment_length;\n\n    if (buf_size < 3)\n    {\n        DbgLog((LOG_TRACE, 30, L\"::ParsePGS(): Way too short PGS packet\"));\n        goto done;\n    }\n\n    m_pgsBuffer.SetSize(0);\n\n    while ((buf + 3) <= buf_end)\n    {\n        const uint8_t *segment_start = buf;\n        const size_t segment_buf_len = buf_end - buf;\n        segment_type = AV_RB8(buf);\n        segment_length = AV_RB16(buf + 1);\n\n        if (segment_length > (segment_buf_len - 3))\n        {\n            DbgLog((LOG_TRACE, 10, \"::ParsePGS(): segment_length bigger then input buffer: %d (buffer: %d)\",\n                    segment_length, segment_buf_len));\n            segment_length = segment_buf_len - 3;\n        }\n\n        buf += 3;\n\n#ifdef DEBUG_PGS_PARSER\n        DbgLog((LOG_TRACE, 50, L\"::ParsePGS(): segment_type: 0x%x, segment_length: %d\", segment_type, segment_length));\n#endif\n\n        // Presentation segment\n        if (segment_type == 0x16 && segment_length > 10)\n        {\n            // Segment Layout\n            // 2 bytes width\n            // 2 bytes height\n            // 1 unknown byte\n            // 2 bytes id\n            // 1 byte composition state (0x00 = normal, 0x40 = ACQU_POINT (?), 0x80 = epoch start (new frame), 0xC0 =\n            // epoch continue) 2 unknown bytes 1 byte object number\n            uint8_t objectNumber = buf[10];\n            // 2 bytes object ref id\n            if (objectNumber == 0)\n            {\n                m_bPGSDropState = FALSE;\n            }\n            else if (segment_length >= 0x13)\n            {\n                // 1 byte window_id\n                // 1 byte object_cropped_flag: 0x80, forced_on_flag = 0x040, 6bit reserved\n                uint8_t forced_flag = buf[14];\n                m_bPGSDropState = !(forced_flag & 0x40);\n                // 2 bytes x\n                // 2 bytes y\n                // total length = 19 bytes\n            }\n#ifdef DEBUG_PGS_PARSER\n            DbgLog((LOG_TRACE, 50, L\"::ParsePGS(): Presentation Segment! obj.num: %d; state: 0x%x; dropping: %d\",\n                    objectNumber, buf[7], m_bPGSDropState));\n#endif\n        }\n        if (!m_bPGSDropState)\n        {\n            m_pgsBuffer.Append(segment_start, (DWORD)(segment_length + 3));\n        }\n\n        buf += segment_length;\n    }\n\n    if (m_pgsBuffer.GetCount() > 0)\n    {\n        pPacket->SetData(m_pgsBuffer.Ptr(), m_pgsBuffer.GetCount());\n    }\n    else\n    {\n        delete pPacket;\n        return S_OK;\n    }\n\ndone:\n    return Queue(pPacket);\n}\n\nHRESULT CStreamParser::ParseMOVText(Packet *pPacket)\n{\n    size_t avail = pPacket->GetDataSize();\n    BYTE *ptr = pPacket->GetData();\n    if (avail > 2)\n    {\n        unsigned size = (ptr[0] << 8) | ptr[1];\n        if (size <= avail - 2)\n        {\n            pPacket->RemoveHead(2);\n            pPacket->SetDataSize(size);\n            return Queue(pPacket);\n        }\n    }\n    SAFE_DELETE(pPacket);\n    return S_FALSE;\n}\n\nHRESULT CStreamParser::ParseAAC(Packet *pPacket)\n{\n    BYTE *pData = pPacket->GetData();\n\n    GetBitContext gb;\n    init_get_bits(&gb, pData, AAC_ADTS_HEADER_SIZE * 8);\n    // Check if its really ADTS\n    if (get_bits(&gb, 12) == 0xfff)\n    {\n        skip_bits1(&gb);              /* id */\n        skip_bits(&gb, 2);            /* layer */\n        int crc_abs = get_bits1(&gb); /* protection_absent */\n\n        pPacket->RemoveHead(AAC_ADTS_HEADER_SIZE + 2 * !crc_abs);\n    }\n    return Queue(pPacket);\n}\n\nstatic const char *read_srt_ts(const char *buf, int *ts_start, int *ts_end, int *x1, int *y1, int *x2, int *y2)\n{\n    int i, hs, ms, ss, he, me, se;\n\n    for (i = 0; i < 2; i++)\n    {\n        /* try to read timestamps in either the first or second line */\n        int c = sscanf_s(buf,\n                         \"%d:%2d:%2d%*1[,.]%3d --> %d:%2d:%2d%*1[,.]%3d\"\n                         \"%*[ ]X1:%u X2:%u Y1:%u Y2:%u\",\n                         &hs, &ms, &ss, ts_start, &he, &me, &se, ts_end, x1, x2, y1, y2);\n        buf += strcspn(buf, \"\\n\") + 1;\n        if (c >= 8)\n        {\n            *ts_start = 100 * (ss + 60 * (ms + 60 * hs)) + *ts_start / 10;\n            *ts_end = 100 * (se + 60 * (me + 60 * he)) + *ts_end / 10;\n            return buf;\n        }\n    }\n    return nullptr;\n}\n\nHRESULT CStreamParser::ParseSRT(Packet *pPacket)\n{\n    int ts_start, ts_end, x1 = -1, y1 = -1, x2 = -1, y2 = -1;\n\n    const char *ptr = (const char *)pPacket->GetData();\n    const char *end = ptr + pPacket->GetDataSize();\n\n    if (pPacket->GetDataSize() == 0)\n        return S_FALSE;\n\n    while (ptr && end > ptr && *ptr)\n    {\n        // Read the embedded timestamp and find the start of the subtitle\n        ptr = read_srt_ts(ptr, &ts_start, &ts_end, &x1, &y1, &x2, &y2);\n        if (ptr)\n        {\n            const char *linestart = ptr;\n            while (end > ptr)\n            {\n                if (*ptr != ' ' && *ptr != '\\n' && *ptr != '\\r')\n                {\n                    ptr += strcspn(ptr, \"\\n\") + 1;\n                }\n                else\n                {\n                    if (*ptr++ == '\\n')\n                        break;\n                }\n            }\n            size_t size = ptr - linestart;\n\n            Packet *p = new Packet();\n            p->pmt = pPacket->pmt;\n            pPacket->pmt = nullptr;\n            p->bDiscontinuity = pPacket->bDiscontinuity;\n            p->bSyncPoint = pPacket->bSyncPoint;\n            p->StreamId = pPacket->StreamId;\n            p->rtStart = pPacket->rtStart;\n            p->rtStop = pPacket->rtStop;\n            p->AppendData(linestart, (int)size);\n            Queue(p);\n        }\n    }\n\n    SAFE_DELETE(pPacket);\n    return S_FALSE;\n}\n\nHRESULT CStreamParser::ParsePlanarPCM(Packet *pPacket)\n{\n    CMediaType mt = m_pPin->GetActiveMediaType();\n\n    WORD nChannels = 0, nBPS = 0, nBlockAlign = 0;\n    audioFormatTypeHandler(mt.Format(), mt.FormatType(), nullptr, &nChannels, &nBPS, &nBlockAlign, nullptr, nullptr);\n\n    // Mono needs no special handling\n    if (nChannels == 1)\n        return Queue(pPacket);\n\n    Packet *out = new Packet();\n    out->CopyProperties(pPacket);\n    out->SetDataSize(pPacket->GetDataSize());\n\n    int nBytesPerChannel = nBPS / 8;\n    int nAudioBlocks = pPacket->GetDataSize() / nChannels;\n    BYTE *out_data = out->GetData();\n    const BYTE *in_data = pPacket->GetData();\n\n    for (int i = 0; i < nAudioBlocks; i += nBytesPerChannel)\n    {\n        // interleave the channels into audio blocks\n        for (int c = 0; c < nChannels; c++)\n        {\n            memcpy(out_data + (c * nBytesPerChannel), in_data + (nAudioBlocks * c), nBytesPerChannel);\n        }\n        // Skip to the next output block\n        out_data += nChannels * nBytesPerChannel;\n\n        // skip to the next input sample\n        in_data += nBytesPerChannel;\n    }\n\n    return Queue(out);\n}\n"
  },
  {
    "path": "demuxer/LAVSplitter/StreamParser.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n *\n *  Initial design and concept by Gabest and the MPC-HC Team, copyright under GPLv2\n */\n\n#pragma once\n\n#include \"PacketQueue.h\"\n#include \"growarray.h\"\n\nclass CLAVOutputPin;\n\nclass CStreamParser\n{\n  public:\n    CStreamParser(CLAVOutputPin *pPin, const char *szContainer);\n    ~CStreamParser();\n\n    HRESULT Parse(const GUID &gSubtype, Packet *pPacket);\n    HRESULT Flush();\n\n  private:\n    HRESULT ParseH264AnnexB(Packet *pPacket);\n    HRESULT ParsePGS(Packet *pPacket);\n    HRESULT ParseMOVText(Packet *pPacket);\n    HRESULT ParseAAC(Packet *pPacket);\n    HRESULT ParseSRT(Packet *pPacket);\n    HRESULT ParsePlanarPCM(Packet *pPacket);\n\n    HRESULT Queue(Packet *pPacket) const;\n\n  private:\n    CLAVOutputPin *const m_pPin = nullptr;\n    std::string m_strContainer;\n\n    GUID m_gSubtype = GUID_NULL;\n\n    Packet *m_pPacketBuffer = nullptr;\n\n    BOOL m_bPGSDropState = FALSE;\n    GrowableArray<BYTE> m_pgsBuffer;\n\n    CPacketQueue m_queue;\n\n    bool m_bHasAccessUnitDelimiters = false;\n};\n"
  },
  {
    "path": "demuxer/LAVSplitter/dllmain.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n// Based on the SampleParser Template by GDCL\n// --------------------------------------------------------------------------------\n// Copyright (c) GDCL 2004. All Rights Reserved.\n// You are free to re-use this as the basis for your own filter development,\n// provided you retain this copyright notice in the source.\n// http://www.gdcl.co.uk\n// --------------------------------------------------------------------------------\n\n#include \"stdafx.h\"\n\n// Initialize the GUIDs\n#include <InitGuid.h>\n\n#include <qnetwork.h>\n#include \"LAVSplitter.h\"\n#include \"moreuuids.h\"\n\n#include \"registry.h\"\n#include \"IGraphRebuildDelegate.h\"\n#include \"IMediaSideDataFFmpeg.h\"\n#include \"ILAVDynamicAllocator.h\"\n\n// The GUID we use to register the splitter media types\nDEFINE_GUID(MEDIATYPE_LAVSplitter, 0x9c53931c, 0x7d5a, 0x4a75, 0xb2, 0x6f, 0x4e, 0x51, 0x65, 0x4d, 0xb2, 0xc0);\n\n// --- COM factory table and registration code --------------\n\nconst AMOVIESETUP_MEDIATYPE sudMediaTypes[] = {\n    {&MEDIATYPE_Stream, &MEDIASUBTYPE_NULL},\n};\n\nconst AMOVIESETUP_PIN sudOutputPins[] = {{\n                                             L\"Output\",   // pin name\n                                             FALSE,       // is rendered?\n                                             TRUE,        // is output?\n                                             FALSE,       // zero instances allowed?\n                                             TRUE,        // many instances allowed?\n                                             &CLSID_NULL, // connects to filter (for bridge pins)\n                                             nullptr,     // connects to pin (for bridge pins)\n                                             0,           // count of registered media types\n                                             nullptr      // list of registered media types\n                                         },\n                                         {\n                                             L\"Input\",         // pin name\n                                             FALSE,            // is rendered?\n                                             FALSE,            // is output?\n                                             FALSE,            // zero instances allowed?\n                                             FALSE,            // many instances allowed?\n                                             &CLSID_NULL,      // connects to filter (for bridge pins)\n                                             nullptr,          // connects to pin (for bridge pins)\n                                             1,                // count of registered media types\n                                             &sudMediaTypes[0] // list of registered media types\n                                         }};\n\nconst AMOVIESETUP_FILTER sudFilterReg = {&__uuidof(CLAVSplitter), // filter clsid\n                                         L\"LAV Splitter\",         // filter name\n                                         MERIT_PREFERRED + 4,     // merit\n                                         2,                       // count of registered pins\n                                         sudOutputPins,           // list of pins to register\n                                         CLSID_LegacyAmFilterCategory};\n\nconst AMOVIESETUP_FILTER sudFilterRegSource = {&__uuidof(CLAVSplitterSource), // filter clsid\n                                               L\"LAV Splitter Source\",        // filter name\n                                               MERIT_PREFERRED + 4,           // merit\n                                               1,                             // count of registered pins\n                                               sudOutputPins,                 // list of pins to register\n                                               CLSID_LegacyAmFilterCategory};\n\n// --- COM factory table and registration code --------------\n\n// DirectShow base class COM factory requires this table,\n// declaring all the COM objects in this DLL\nCFactoryTemplate g_Templates[] = {\n    // one entry for each CoCreate-able object\n    {sudFilterReg.strName, sudFilterReg.clsID, CreateInstance<CLAVSplitter>, nullptr, &sudFilterReg},\n    {sudFilterRegSource.strName, sudFilterRegSource.clsID, CreateInstance<CLAVSplitterSource>, nullptr,\n     &sudFilterRegSource},\n    // This entry is for the property page.\n    {L\"LAV Splitter Properties\", &CLSID_LAVSplitterSettingsProp, CreateInstance<CLAVSplitterSettingsProp>, nullptr,\n     nullptr},\n    {L\"LAV Splitter Input Formats\", &CLSID_LAVSplitterFormatsProp, CreateInstance<CLAVSplitterFormatsProp>, nullptr,\n     nullptr}};\nint g_cTemplates = sizeof(g_Templates) / sizeof(g_Templates[0]);\n\n// self-registration entrypoint\nSTDAPI DllRegisterServer()\n{\n    std::list<LPCWSTR> chkbytes;\n\n    // BluRay\n    chkbytes.clear();\n    chkbytes.push_back(L\"0,4,,494E4458\"); // INDX (index.bdmv)\n    chkbytes.push_back(L\"0,4,,4D4F424A\"); // MOBJ (MovieObject.bdmv)\n    chkbytes.push_back(L\"0,4,,4D504C53\"); // MPLS\n    RegisterSourceFilter(__uuidof(CLAVSplitterSource), MEDIASUBTYPE_LAVBluRay, chkbytes, nullptr);\n\n    // base classes will handle registration using the factory template table\n    return AMovieDllRegisterServer2(true);\n}\n\nSTDAPI DllUnregisterServer()\n{\n    UnRegisterSourceFilter(MEDIASUBTYPE_LAVBluRay);\n\n    // base classes will handle de-registration using the factory template table\n    return AMovieDllRegisterServer2(false);\n}\n\n// if we declare the correct C runtime entrypoint and then forward it to the DShow base\n// classes we will be sure that both the C/C++ runtimes and the base classes are initialized\n// correctly\nextern \"C\" BOOL WINAPI DllEntryPoint(HINSTANCE, ULONG, LPVOID);\nBOOL WINAPI DllMain(HANDLE hDllHandle, DWORD dwReason, LPVOID lpReserved)\n{\n    return DllEntryPoint(reinterpret_cast<HINSTANCE>(hDllHandle), dwReason, lpReserved);\n}\n\nvoid CALLBACK OpenConfiguration(HWND hwnd, HINSTANCE hinst, LPSTR lpszCmdLine, int nCmdShow)\n{\n    HRESULT hr = S_OK;\n    CUnknown *pInstance = CreateInstance<CLAVSplitter>(nullptr, &hr);\n    IBaseFilter *pFilter = nullptr;\n    pInstance->NonDelegatingQueryInterface(IID_IBaseFilter, (void **)&pFilter);\n    if (pFilter)\n    {\n        pFilter->AddRef();\n        CBaseDSPropPage::ShowPropPageDialog(pFilter);\n    }\n    delete pInstance;\n}\n"
  },
  {
    "path": "demuxer/LAVSplitter/resource.h",
    "content": "//{{NO_DEPENDENCIES}}\n// Microsoft Visual C++ generated include file.\n// Used by LAVSplitter.rc\n//\n#define IDD_PROPPAGE_LAVFSETTINGS       9\n#define IDD_PROPPAGE_FORMATS            10\n#define IDS_PAGE_TITLE                  101\n#define IDS_SUBMODE_NO_SUBS             102\n#define IDI_ICON1                       103\n#define IDS_SUBMODE_FORCED_SUBS         104\n#define IDS_SUBMODE_DEFAULT             105\n#define IDS_SUBMODE_ADVANCED            106\n#define IDS_INPUT_FORMATS               107\n#define IDC_LBL_PREF_LANG               1001\n#define IDC_PREF_LANG                   1002\n#define IDC_LBL_PREF_LANG_AUDIO         1003\n#define IDC_PREF_LANG_SUBS              1004\n#define IDC_LBL_PREF_LANG_SUBS          1005\n#define IDC_SUBTITLE_MODE               1006\n#define IDC_LBL_SUBMODE                 1007\n#define IDC_VC1TIMESTAMP                1009\n#define IDC_SUBSTREAMS                  1010\n#define IDC_DEMUXER_SETTINGS            1011\n#define IDC_SPLITTER_FOOTER             1012\n#define IDC_FORMATS                     1016\n#define IDC_LBL_INPUT                   1017\n#define IDC_CUR_INPUT                   1018\n#define IDC_LBL_FORMATS                 1019\n#define IDC_BD_SUBS                     1020\n#define IDC_BD_SEPARATE_FORCED_SUBS     1021\n#define IDC_BD_ONLY_FORCED_SUBS         1022\n#define IDC_STREAM_SWITCH_REMOVE_AUDIO  1024\n#define IDC_SUBTITLE_NOTE               1025\n#define IDC_IMPAIRED_AUDIO              1026\n#define IDC_QUEUE_SETTINGS              1027\n#define IDC_LBL_QUEUE_MEM               1028\n#define IDC_QUEUE_MEM                   1029\n#define IDC_QUEUE_MEM_SPIN              1030\n#define IDC_TRAYICON                    1031\n#define IDC_SELECT_AUDIO_QUALITY        1032\n#define IDC_FMT_SETTINGS                1033\n#define IDC_MKV_EXTERNAL                1034\n#define IDC_NETWORK_SETTINGS            1035\n#define IDC_LBL_STREAM_BUFFER           1036\n#define IDC_STREAM_ANADUR               1037\n#define IDC_STREAM_ANADUR_SPIN          1038\n#define IDC_LBL_QUEUE_PACKETS           1039\n#define IDC_QUEUE_PACKETS               1040\n#define IDC_QUEUE_PACKETS_SPIN          1041\n#define IDC_STREAM_SWITCH_RESELECT_SUBS 1042\n\n// Next default values for new objects\n// \n#ifdef APSTUDIO_INVOKED\n#ifndef APSTUDIO_READONLY_SYMBOLS\n#define _APS_NEXT_RESOURCE_VALUE        108\n#define _APS_NEXT_COMMAND_VALUE         40001\n#define _APS_NEXT_CONTROL_VALUE         1043\n#define _APS_NEXT_SYMED_VALUE           101\n#endif\n#endif\n"
  },
  {
    "path": "demuxer/LAVSplitter/stdafx.cpp",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n// Pre-compiled header\n#include \"stdafx.h\"\n"
  },
  {
    "path": "demuxer/LAVSplitter/stdafx.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n// pre-compiled header\n\n#pragma once\n\n// Support for Version 6.0 styles\n#pragma comment( \\\n    linker,      \\\n    \"\\\"/manifestdependency:type='win32' name='Microsoft.Windows.Common-Controls' version='6.0.0.0' processorArchitecture='*' publicKeyToken='6595b64144ccf1df' language='*'\\\"\")\n\n#include \"common_defines.h\"\n\n// include headers\n#include <Windows.h>\n#include <Commctrl.h>\n\n#pragma warning(push)\n#pragma warning(disable : 4244)\nextern \"C\"\n{\n#define __STDC_CONSTANT_MACROS\n#include \"libavformat/avformat.h\"\n#include \"libbluray/bluray.h\"\n#include \"libavutil/intreadwrite.h\"\n}\n#pragma warning(pop)\n\n#include \"streams.h\"\n#include \"DShowUtil.h\"\n\n#include \"resource.h\"\n"
  },
  {
    "path": "include/IBitRateInfo.h",
    "content": "/*\n * (C) 2003-2006 Gabest\n * (C) 2006-2013 MPC-HC Team\n *\n * This program is free software; you can redistribute it and/or modify\n * it under the terms of the GNU General Public License as published by\n * the Free Software Foundation; either version 3 of the License, or\n * (at your option) any later version.\n *\n * This Program is distributed in the hope that it will be useful,\n * but WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n * GNU General Public License for more details.\n *\n * You should have received a copy of the GNU General Public License\n * along with this program.  If not, see <http://www.gnu.org/licenses/>.\n *\n */\n\n#pragma once\n\ninterface __declspec(uuid(\"EB2CD9E6-BA08-4acb-AA0F-3D8D0DD521CA\"))\nIBitRateInfo :\npublic IUnknown {\n    STDMETHOD_(DWORD, GetCurrentBitRate)() PURE;\n    STDMETHOD_(DWORD, GetAverageBitRate)() PURE;\n};\n"
  },
  {
    "path": "include/IBufferInfo.h",
    "content": "/*\n * $Id: IBufferInfo.h 2786 2010-12-17 16:42:55Z XhmikosR $\n *\n * (C) 2003-2006 Gabest\n * (C) 2006-2010 see AUTHORS\n *\n *  This Program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2, or (at your option)\n *  any later version.\n *\n *  This Program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with GNU Make; see the file COPYING.  If not, write to\n *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.\n *  http://www.gnu.org/copyleft/gpl.html\n *\n */\n\n#pragma once\n\ninterface __declspec(uuid(\"46070104-1318-4A82-8822-E99AB7CD15C1\")) IBufferInfo : public IUnknown\n{\n    // Number of Buffers\n    STDMETHOD_(int, GetCount()) = 0;\n    // Get Info about Buffer \"i\" (0-based index up to count)\n    // samples: number of frames in the buffer\n    // size: total size in bytes of the buffer\n    STDMETHOD(GetStatus(int i, int &samples, int &size)) = 0;\n    // Get priority of the demuxing thread\n    STDMETHOD_(DWORD, GetPriority()) = 0;\n};\n"
  },
  {
    "path": "include/ID3DVideoMemoryConfiguration.h",
    "content": "// -----------------------------------------------------------------\n// ID3DVideoMemoryConfiguration interface and data structure definitions\n// -----------------------------------------------------------------\n#pragma once\n\n// -----------------------------------------------------------------\n// Control D3D11 Hardware Decoding between decoder and renderer\n// -----------------------------------------------------------------\n// A video renderer can implement this interface on its input pin\n// to signal to a decoder that its capable of accepting D3D11 texture\n// samples directly, without copying to system memory.\n//\n// The decoder will create the D3D11 device and a mutex to protect it,\n// and share it with the renderer in this interface.\n//\n// To facilitate dynamic switching of the adapter used for decoding, the\n// renderer should disconnect the decoder and re-connect it. At that\n// point the decoder should query GetD3D11AdapterIndex() again and\n// create a new decoder on the new device, as appropriate.\ninterface __declspec(uuid(\"2BB66002-46B7-4F13-9036-7053328742BE\")) ID3D11DecoderConfiguration : public IUnknown\n{\n    // Set the surface format the decoder is going to send.\n    // If the renderer is not ready to accept this format, an error will be returned.\n    virtual HRESULT STDMETHODCALLTYPE ActivateD3D11Decoding(ID3D11Device * pDevice, ID3D11DeviceContext * pContext,\n                                                            HANDLE hMutex, UINT nFlags) = 0;\n\n    // Get the currently preferred D3D11 adapter index (to be used with IDXGIFactory1::EnumAdapters1)\n    virtual UINT STDMETHODCALLTYPE GetD3D11AdapterIndex() = 0;\n};\n\n// -----------------------------------------------------------------\n// Media Sample to hold a D3D11 texture\n// -----------------------------------------------------------------\n// D3D11 textures used for decoding are typically array-textures,\n// a single ID3D11Texture2D object containing an array of textures\n// individually addressable by the ArraySlice index.\n//\n// The texture lifetime is bound to the media samples lifetime. The\n// media sample can only be released when the texture is no longer in\n// use, otherwise the texture will be re-used by the decoder.\n//\n// The texture is AddRef'ed when retrieved through this interface,\n// and should be Released when no longer needed.\ninterface __declspec(uuid(\"BC8753F5-0AC8-4806-8E5F-A12B2AFE153E\")) IMediaSampleD3D11 : public IUnknown\n{\n    // Get the D3D11 texture for the specified view.\n    // 2D images with only one view always use view 0. For 3D, view 0 specifies the base view, view 1 the extension\n    // view.\n    virtual HRESULT STDMETHODCALLTYPE GetD3D11Texture(int nView, ID3D11Texture2D **ppTexture, UINT *pArraySlice) = 0;\n};\n"
  },
  {
    "path": "include/IDSMResourceBag.h",
    "content": "/*\n *      Copyright (C) 2003-2006 Gabest\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n#pragma once\n\ninterface __declspec(uuid(\"EBAFBCBE-BDE0-489A-9789-05D5692E3A93\")) IDSMResourceBag : public IUnknown\n{\n    STDMETHOD_(DWORD, ResGetCount)() PURE;\n    STDMETHOD(ResGet)(DWORD iIndex, BSTR * ppName, BSTR * ppDesc, BSTR * ppMime, BYTE * *ppData, DWORD * pDataLen, DWORD_PTR * pTag) PURE;\n    STDMETHOD(ResSet)(DWORD iIndex, LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, const BYTE *pData, DWORD len, DWORD_PTR tag) PURE;\n    STDMETHOD(ResAppend)(LPCWSTR pName, LPCWSTR pDesc, LPCWSTR pMime, BYTE * pData, DWORD len, DWORD_PTR tag) PURE;\n    STDMETHOD(ResRemoveAt)(DWORD iIndex) PURE;\n    STDMETHOD(ResRemoveAll)(DWORD_PTR tag) PURE;\n};\n"
  },
  {
    "path": "include/IGraphRebuildDelegate.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n// {17989414-C927-4D73-AB6C-19DF37602AC4}\nDEFINE_GUID(IID_IGraphRebuildDelegate, 0x17989414, 0xc927, 0x4d73, 0xab, 0x6c, 0x19, 0xdf, 0x37, 0x60, 0x2a, 0xc4);\n\ninterface __declspec(uuid(\"17989414-C927-4D73-AB6C-19DF37602AC4\")) IGraphRebuildDelegate : public IUnknown\n{\n    // Called by the splitter to let the player know that a certain pin needs to be rebuild.\n    //\n    // This function is called on any stream or title changes that would cause the content of the pin to change.\n    // The Splitter will stop the graph prior to this call, and it will return the graph to its previous state\n    // afterwards.\n    //\n    // When this function is called, the pin will already have the new media types set, so the usual functions to query\n    // the media types can be used. EnmuMediaTypes is OK (or any wrappers of this in the base classes),\n    // ConnectionMediaType is not OK, for obvious reasons.\n    //\n    // Following return values are supported:\n    // S_OK    - The player took complete control over the rebuild, the splitter will do no further actions regarding\n    // the pin S_FALSE - The player may or may not have changed the pin, and the splitter is instructed to send a media\n    // type with the next packet. E_FAIL  - The player failed, and the splitter should try to rebuild the pin\n    STDMETHOD(RebuildPin)(IFilterGraph * pGraph, IPin * pPin) = 0;\n};\n"
  },
  {
    "path": "include/IKeyFrameInfo.h",
    "content": "/*\n *      Copyright (C) 2003-2006 Gabest\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\ninterface __declspec(uuid(\"01A5BBD3-FE71-487C-A2EC-F585918A8724\")) IKeyFrameInfo : public IUnknown\n{\n    // Get the number of (known) keyframes in the file\n    STDMETHOD(GetKeyFrameCount)(UINT & nKFs) = 0; // returns S_FALSE when every frame is a keyframe\n\n    // Get the times of the key frames, if available.\n    //\n    // pFormat: GUID of the time format (see http://msdn.microsoft.com/en-us/library/dd407205(v=vs.85).aspx, usually\n    // TIME_FORMAT_MEDIA_TIME) pKFs: Caller allocated memory for the timestamps of the keyframes (should be\n    // sizeof(REFERENCE_TIME) * nKFs at least!) nKF: Number of keyframes requested/returned - no more then nKFs key\n    // frames will be returned.\n    STDMETHOD(GetKeyFrames)(const GUID *pFormat, REFERENCE_TIME *pKFs, UINT &nKFs /* in, out*/) = 0;\n};"
  },
  {
    "path": "include/ILAVDynamicAllocator.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n// {8FBB906B-D1DB-4528-9498-563241CCD43D}\nDEFINE_GUID(IID_ILAVDynamicAllocator, 0x8fbb906b, 0xd1db, 0x4528, 0x94, 0x98, 0x56, 0x32, 0x41, 0xcc, 0xd4, 0x3d);\n\ninterface __declspec(uuid(\"8FBB906B-D1DB-4528-9498-563241CCD43D\")) ILAVDynamicAllocator : public IUnknown\n{\n    // Query wether this allocator is using dynamic allocation of samples and will not run out of samples\n    STDMETHOD_(BOOL, IsDynamicAllocator)() PURE;\n};\n"
  },
  {
    "path": "include/IMediaSample3D.h",
    "content": "// -----------------------------------------------------------------\n// IMediaSample3D interface and data structure definitions\n// -----------------------------------------------------------------\n\n#pragma once\n\ninterface __declspec(uuid(\"E92D790E-BF54-43C4-B394-8CA0A41BF9EC\")) IMediaSample3D : public IMediaSample2\n{\n  STDMETHOD(Enable3D)() = 0;\n  STDMETHOD(GetPointer3D)(BYTE **ppBuffer) = 0;\n};\n"
  },
  {
    "path": "include/IMediaSideData.h",
    "content": "// -----------------------------------------------------------------\n// IMediaSideData interface and data structure definitions\n// -----------------------------------------------------------------\n\n#pragma once\n\n#include <stdint.h>\n\n// -----------------------------------------------------------------\n// Interface to exchange binary side data\n// -----------------------------------------------------------------\n// This interface should be implemented in IMediaSample objects and accessed through IUnknown\n// It allows binary side data to be attached to the media samples and delivered with them\n// Restrictions: Only one side data per type can be attached\ninterface __declspec(uuid(\"F940AE7F-48EB-4377-806C-8FC48CAB2292\")) IMediaSideData : public IUnknown\n{\n    // Set the side data identified by guidType to the data provided\n    // The provided data will be copied and stored internally\n    STDMETHOD(SetSideData)(GUID guidType, const BYTE *pData, size_t size) PURE;\n\n    // Get the side data identified by guidType\n    // The caller receives pointers to the internal data, and the pointers shall stay\n    // valid for the lifetime of the object\n    STDMETHOD(GetSideData)(GUID guidType, const BYTE **pData, size_t *pSize) PURE;\n};\n\n// -----------------------------------------------------------------\n// High-Dynamic-Range (HDR) Side Data\n// -----------------------------------------------------------------\n\n// {53820DBC-A7B8-49C4-B17B-E511591A790C}\nDEFINE_GUID(IID_MediaSideDataHDR, 0x53820dbc, 0xa7b8, 0x49c4, 0xb1, 0x7b, 0xe5, 0x11, 0x59, 0x1a, 0x79, 0xc);\n\n#pragma pack(push, 1)\nstruct MediaSideDataHDR\n{\n    // coordinates of the primaries, in G-B-R order\n    double display_primaries_x[3];\n    double display_primaries_y[3];\n    // white point\n    double white_point_x;\n    double white_point_y;\n    // luminance\n    double max_display_mastering_luminance;\n    double min_display_mastering_luminance;\n};\n#pragma pack(pop)\n\n// {ED6AE576-7CBE-41A6-9DC3-07C35DC13EF9}\nDEFINE_GUID(IID_MediaSideDataHDRContentLightLevel, 0xed6ae576, 0x7cbe, 0x41a6, 0x9d, 0xc3, 0x7, 0xc3, 0x5d, 0xc1, 0x3e,\n            0xf9);\n\n#pragma pack(push, 1)\nstruct MediaSideDataHDRContentLightLevel\n{\n    // maximum content light level (cd/m2)\n    unsigned int MaxCLL;\n\n    // maximum frame average light level (cd/m2)\n    unsigned int MaxFALL;\n};\n#pragma pack(pop)\n\n// {183ED511-8910-4262-88F6-4946BC799C84}\nDEFINE_GUID(IID_MediaSideDataHDR10Plus, 0x183ed511, 0x8910, 0x4262, 0x88, 0xf6, 0x49, 0x46, 0xbc, 0x79, 0x9c, 0x84);\n\n#pragma pack(push, 1)\n// HDR10+ metadata according to SMPTE 2094-40\n// Refer to the specification for the meaning of the fields\n//\n// All pixel values are kept as-is, rational values are normalized as double-precision floating point\nstruct MediaSideDataHDR10Plus\n{\n    // number of windows (1-3)\n    unsigned int num_windows;\n\n    // processing windows\n    struct\n    {\n        unsigned int upper_left_corner_x;\n        unsigned int upper_left_corner_y;\n        unsigned int lower_right_corner_x;\n        unsigned int lower_right_corner_y;\n        unsigned int center_of_ellipse_x;\n        unsigned int center_of_ellipse_y;\n        unsigned int rotation_angle;\n        unsigned int semimajor_axis_internal_ellipse;\n        unsigned int semimajor_axis_external_ellipse;\n        unsigned int semiminor_axis_external_ellipse;\n        unsigned int overlap_process_option;\n\n        double maxscl[3];\n        double average_maxrgb;\n\n        unsigned int num_distribution_maxrgb_percentiles;\n        struct\n        {\n            unsigned int percentage;\n            double percentile;\n        } distribution_maxrgb_percentiles[15];\n\n        double fraction_bright_pixels;\n\n        unsigned int tone_mapping_flag;\n\n        double knee_point_x;\n        double knee_point_y;\n\n        unsigned int num_bezier_curve_anchors;\n        double bezier_curve_anchors[15];\n\n        unsigned int color_saturation_mapping_flag;\n        double color_saturation_weight;\n    } windows[3];\n\n    double targeted_system_display_maximum_luminance;\n\n    unsigned int targeted_system_display_actual_peak_luminance_flag;\n    unsigned int num_rows_targeted_system_display_actual_peak_luminance;\n    unsigned int num_cols_targeted_system_display_actual_peak_luminance;\n    double targeted_system_display_actual_peak_luminance[25][25];\n\n    unsigned int mastering_display_actual_peak_luminance_flag;\n    unsigned int num_rows_mastering_display_actual_peak_luminance;\n    unsigned int num_cols_mastering_display_actual_peak_luminance;\n    double mastering_display_actual_peak_luminance[25][25];\n};\n#pragma pack(pop)\n\n// {BAE40E6C-5B93-4170-90CC-5D5F02A29638}\nDEFINE_GUID(IID_MediaSideDataDOVIRPU, 0xbae40e6c, 0x5b93, 0x4170, 0x90, 0xcc, 0x5d, 0x5f, 0x2, 0xa2, 0x96, 0x38);\n\n// {277EE779-13F4-434E-BDEC-3D6F8C0E15D2}\nDEFINE_GUID([[deprecated]] IID_MediaSideDataDOVIMetadata, 0x277ee779, 0x13f4, 0x434e, 0xbd, 0xec, 0x3d, 0x6f, 0x8c, 0xe, 0x15, 0xd2);\n\n// {F1949F1C-7474-4F0F-B110-FB734C08851D}\nDEFINE_GUID(IID_MediaSideDataDOVIMetadataV2, 0xf1949f1c, 0x7474, 0x4f0f, 0xb1, 0x10, 0xfb, 0x73, 0x4c, 0x8, 0x85, 0x1d);\n\n#pragma pack(push, 1)\n// Dolby Vision metadata\n// Refer to the specification for the meaning of the fields\n// Note: This structure may be extended towards the end if needed, do not rely on a fixed size, but rather a minimum size\n// Version History\n//  - Version 1, Header/Mapping/ColorMetadata\n//  - Version 2, Extensions (ensure the V2 metadata GUID is used above for this to be valid)\nstruct MediaSideDataDOVIMetadata\n{\n    struct\n    {\n        uint8_t rpu_type;\n        uint16_t rpu_format;\n        uint8_t vdr_rpu_profile;\n        uint8_t vdr_rpu_level;\n        uint8_t chroma_resampling_explicit_filter_flag;\n        uint8_t coef_data_type; /* informative, lavc always converts to fixed */\n        uint8_t coef_log2_denom;\n        uint8_t vdr_rpu_normalized_idc;\n        uint8_t bl_video_full_range_flag;\n        uint8_t bl_bit_depth;  /* [8, 16] */\n        uint8_t el_bit_depth;  /* [8, 16] */\n        uint8_t vdr_bit_depth; /* [8, 16] */\n        uint8_t spatial_resampling_filter_flag;\n        uint8_t el_spatial_resampling_filter_flag;\n        uint8_t disable_residual_flag;\n    } Header;\n\n    struct\n    {\n        uint8_t vdr_rpu_id;\n        uint8_t mapping_color_space;\n        uint8_t mapping_chroma_format_idc;\n\n        struct\n        {\n#define LAV_DOVI_MAX_PIECES 8\n            uint8_t num_pivots;                       /* [2, 9] */\n            uint16_t pivots[LAV_DOVI_MAX_PIECES + 1]; /* sorted ascending */\n            uint8_t mapping_idc[LAV_DOVI_MAX_PIECES]; /* 0 polynomial, 1 mmr */\n\n            /* polynomial */\n            uint8_t poly_order[LAV_DOVI_MAX_PIECES];   /* [1, 2] */\n            int64_t poly_coef[LAV_DOVI_MAX_PIECES][3]; /* x^0, x^1, x^2 */\n\n            /* mmr */\n            uint8_t mmr_order[LAV_DOVI_MAX_PIECES]; /* [1, 3] */\n            int64_t mmr_constant[LAV_DOVI_MAX_PIECES];\n            int64_t mmr_coef[LAV_DOVI_MAX_PIECES][3 /* order - 1 */][7];\n        } curves[3]; /* per component */\n\n        /* Non-linear inverse quantization */\n        uint8_t nlq_method_idc; // -1 none, 0 linear dz\n        uint32_t num_x_partitions;\n        uint32_t num_y_partitions;\n        struct\n        {\n            uint16_t nlq_offset;\n            uint64_t vdr_in_max;\n\n            /* linear dz */\n            uint64_t linear_deadzone_slope;\n            uint64_t linear_deadzone_threshold;\n        } nlq[3]; /* per component */\n    } Mapping;\n\n    struct\n    {\n        uint8_t dm_metadata_id;\n        uint8_t scene_refresh_flag;\n\n        /**\n         * Coefficients of the custom Dolby Vision IPT-PQ matrices. These are to be\n         * used instead of the matrices indicated by the frame's colorspace tags.\n         * The output of rgb_to_lms_matrix is to be fed into a BT.2020 LMS->RGB\n         * matrix based on a Hunt-Pointer-Estevez transform, but without any\n         * crosstalk. (See the definition of the ICtCp colorspace for more\n         * information.)\n         */\n        double ycc_to_rgb_matrix[9]; /* before PQ linearization */\n        double ycc_to_rgb_offset[3]; /* input offset of neutral value */\n        double rgb_to_lms_matrix[9]; /* after PQ linearization */\n\n        /**\n         * Extra signal metadata (see Dolby patents for more info).\n         */\n        uint16_t signal_eotf;\n        uint16_t signal_eotf_param0;\n        uint16_t signal_eotf_param1;\n        uint32_t signal_eotf_param2;\n        uint8_t signal_bit_depth;\n        uint8_t signal_color_space;\n        uint8_t signal_chroma_format;\n        uint8_t signal_full_range_flag; /* [0, 3] */\n        uint16_t source_min_pq;\n        uint16_t source_max_pq;\n        uint16_t source_diagonal;\n    } ColorMetadata;\n\n    #define LAV_DOVI_MAX_EXTENSIONS 32\n    struct\n    {\n        uint8_t level;\n        union {\n            struct\n            {\n                /* L1 Per-frame brightness metadata */\n                uint16_t min_pq;\n                uint16_t max_pq;\n                uint16_t avg_pq;\n            } Level1;\n            struct\n            {\n                uint16_t target_max_pq;\n                uint16_t trim_slope;\n                uint16_t trim_offset;\n                uint16_t trim_power;\n                uint16_t trim_chroma_weight;\n                uint16_t trim_saturation_gain;\n                int16_t ms_weight;\n            } Level2;\n            struct\n            {\n                uint16_t min_pq_offset;\n                uint16_t max_pq_offset;\n                uint16_t avg_pq_offset;\n            } Level3;\n            struct\n            {\n                uint16_t anchor_pq;\n                uint16_t anchor_power;\n            } Level4;\n            struct\n            {\n                /* Active area definition */\n                uint16_t left_offset;\n                uint16_t right_offset;\n                uint16_t top_offset;\n                uint16_t bottom_offset;\n            } Level5;\n            struct\n            {\n                /* Static HDR10 metadata */\n                uint16_t max_luminance;\n                uint16_t min_luminance;\n                uint16_t max_cll;\n                uint16_t max_fall;\n            } Level6;\n            /* level 7 is currently unused */\n            struct\n            {\n                /* Extended version of level 2 */\n                uint8_t target_display_index;\n                uint16_t trim_slope;\n                uint16_t trim_offset;\n                uint16_t trim_power;\n                uint16_t trim_chroma_weight;\n                uint16_t trim_saturation_gain;\n                uint16_t ms_weight;\n                uint16_t target_mid_contrast;\n                uint16_t clip_trim;\n                uint8_t saturation_vector_field[6];\n                uint8_t hue_vector_field[6];\n            } Level8;\n            struct\n            {\n                /* Source display characteristics */\n                uint8_t source_primary_index;\n                double white_point_x;\n                double white_point_y;\n                /* primaries are in R-G-B order */\n                double display_primaries_x[3];\n                double display_primaries_y[3];\n            } Level9;\n            struct\n            {\n                /* Target display characteristics */\n                uint8_t target_display_index;\n                uint16_t target_max_pq;\n                uint16_t target_min_pq;\n                uint8_t target_primary_index;\n                double white_point_x;\n                double white_point_y;\n                /* primaries are in R-G-B order */\n                double display_primaries_x[3];\n                double display_primaries_y[3];\n            } Level10;\n            struct\n            {\n                uint8_t content_type;\n                uint8_t whitepoint;\n                uint8_t reference_mode_flag;\n            } Level11;\n            struct\n            {\n                /* DMv2 info block, always present in samples with DMv2 metadata */\n                uint8_t dm_mode;\n                uint8_t dm_version_index;\n            } Level254;\n            uint8_t Reserved[128]; /* reserve space for a fixed size of the extension block */\n        };\n    } Extensions[LAV_DOVI_MAX_EXTENSIONS];\n};\n#pragma pack(pop)\n\n// -----------------------------------------------------------------\n// 3D Plane Offset Side Data\n// -----------------------------------------------------------------\n\n// {F169B76C-75A3-49E6-A23A-14983EBF4370}\nDEFINE_GUID(IID_MediaSideData3DOffset, 0xf169b76c, 0x75a3, 0x49e6, 0xa2, 0x3a, 0x14, 0x98, 0x3e, 0xbf, 0x43, 0x70);\n\n#pragma pack(push, 1)\nstruct MediaSideData3DOffset\n{\n    // Number of valid offsets (up to 32)\n    int offset_count;\n\n    // Offset Value, can be positive or negative\n    // positive values offset closer to the viewer (move right on the left view, left on the right view)\n    // negative values offset further away from the viewer (move left on the left view, right on the right view)\n    int offset[32];\n};\n#pragma pack(pop)\n\n// -----------------------------------------------------------------\n// EIA-608/708 Closed Caption Data\n// -----------------------------------------------------------------\n\n// {40FEFD7F-85DD-4335-A804-8A33B0BF7B81}\nDEFINE_GUID(IID_MediaSideDataEIA608CC, 0x40fefd7f, 0x85dd, 0x4335, 0xa8, 0x4, 0x8a, 0x33, 0xb0, 0xbf, 0x7b, 0x81);\n\n// There is no struct definition. The data is supplied as a list of 3 byte CC data packets (control byte + cc_data1/2)\n\n// -----------------------------------------------------------------\n// Media Control Flags\n// -----------------------------------------------------------------\n\n// {B5411CE3-3B21-4FD6-80A8-CE682969F795}\nDEFINE_GUID(IID_MediaSideDataControlFlags, 0xb5411ce3, 0x3b21, 0x4fd6, 0x80, 0xa8, 0xce, 0x68, 0x29, 0x69, 0xf7, 0x95);\n\n// No struct definition, just a single DWORD for additional flags\nenum MediaSideDataControlFlags\n{\n    MediaSideDataControlFlags_EndOfSequence = (1 << 0),\n};\n"
  },
  {
    "path": "include/IPinSegmentEx.h",
    "content": "#pragma once\n\n// -----------------------------------------------------------------\n// IPin Segmenting Extension\n// -----------------------------------------------------------------\n// This extension allows upstream filters to cleanly terminate segments,\n// indicating to downstream components that any data should be flushed\n// to the renderer.\n// This call should be followed by a call to IPin::NewSegment to start a\n// new segment afterwards.\ninterface __declspec(uuid(\"8B81E022-52C7-4B89-9F11-ACFD063AABB4\")) IPinSegmentEx : public IUnknown\n{\n    virtual HRESULT STDMETHODCALLTYPE EndOfSegment(void) = 0;\n};\n"
  },
  {
    "path": "include/ISpecifyPropertyPages2.h",
    "content": "/*\n * (C) 2003-2006 Gabest\n * (C) 2006-2010 MPC-HC Authors\n *\n *  This Program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2, or (at your option)\n *  any later version.\n *\n *  This Program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License\n *  along with GNU Make; see the file COPYING.  If not, write to\n *  the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.\n *  http://www.gnu.org/copyleft/gpl.html\n *\n */\n\n#pragma once\n\n#include <OCIdl.h>\n\ninterface __declspec(uuid(\"03481710-D73E-4674-839F-03EDE2D60ED8\")) ISpecifyPropertyPages2 : public ISpecifyPropertyPages\n{\n    STDMETHOD(CreatePage)(const GUID &guid, IPropertyPage **ppPage) = 0;\n};\n"
  },
  {
    "path": "include/IStreamSourceControl.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n// NOTICE: This interface is still experimental and may change in the future. Do NOT use it yet unless you absolutely\n// know what you are doing.\n\n// Interface for high-level streaming source filters\n// The source can implement proper seeking and duration retrieval based on its underlying protocol.\n// This interface should be exposed on the output pin or the filter itself of the streaming source, similar to the\n// IAsyncReader interface\n\n// {C0BE9565-4C05-4644-9492-57547A4048DC}\nDEFINE_GUID(IID_IStreamSourceControl, 0xc0be9565, 0x4c05, 0x4644, 0x94, 0x92, 0x57, 0x54, 0x7a, 0x40, 0x48, 0xdc);\n\ninterface __declspec(uuid(\"C0BE9565-4C05-4644-9492-57547A4048DC\")) IStreamSourceControl : public IUnknown\n{\n    // Get the duration of the stream being played.\n    // Duration is in DirectShow reference time, 100ns units.\n    STDMETHOD(GetStreamDuration)(REFERENCE_TIME * prtDuration) PURE;\n\n    // Seek the stream to a specified time\n    //\n    // Position is in DirectShow reference time, 100ns units.\n    //\n    // If the source returns a failure code, the demuxer will do byte-based seeking itself (ie. when the stream supports\n    // this) On success, it'll re-open the stream and start reading from the start (byte position 0).\n    STDMETHOD(SeekStream)(REFERENCE_TIME rtPosition) PURE;\n};\n"
  },
  {
    "path": "include/ITrackInfo.h",
    "content": "/*\n *      Copyright (C) 2003-2006 Gabest\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\ntypedef enum TrackType\n{\n    TypeVideo = 1,\n    TypeAudio = 2,\n    TypeComplex = 3,\n    TypeLogo = 0x10,\n    TypeSubtitle = 0x11,\n    TypeControl = 0x20\n} TrackType;\n\n#pragma pack(push, 1)\n\nstruct TrackElement\n{\n    WORD Size;        // Size of this structure\n    BYTE Type;        // See TrackType\n    BOOL FlagDefault; // Set if the track is the default for its TrackType.\n    BOOL FlagForced;  // Set if that track MUST be used during playback.\n    BOOL FlagLacing;  // Set if the track may contain blocks using lacing.\n    UINT MinCache;    // The minimum number of frames a player should be able to cache during playback.\n    UINT MaxCache;    // The maximum cache size required to store referenced frames in and the current frame. 0 means no\n                      // cache is needed.\n    CHAR Language[4]; // Specifies the language of the track, in the ISO-639-2 form. (end with '\\0')\n};\n\nstruct TrackExtendedInfoVideo\n{\n    WORD Size;            // Size of this structure\n    BOOL Interlaced;      // Set if the video is interlaced.\n    UINT PixelWidth;      // Width of the encoded video frames in pixels.\n    UINT PixelHeight;     // Height of the encoded video frames in pixels.\n    UINT DisplayWidth;    // Width of the video frames to display.\n    UINT DisplayHeight;   // Height of the video frames to display.\n    BYTE DisplayUnit;     // Type of the unit for DisplayWidth/Height (0: pixels, 1: centimeters, 2: inches).\n    BYTE AspectRatioType; // Specify the possible modifications to the aspect ratio (0: free resizing, 1: keep aspect\n                          // ratio, 2: fixed).\n};\n\nstruct TrackExtendedInfoAudio\n{\n    WORD Size;                     // Size of this structure\n    FLOAT SamplingFreq;            // Sampling frequency in Hz.\n    FLOAT OutputSamplingFrequency; // Real output sampling frequency in Hz (used for SBR techniques).\n    UINT Channels;                 // Numbers of channels in the track.\n    UINT BitDepth;                 // Bits per sample, mostly used for PCM.\n};\n\n#pragma pack(pop)\n\ninterface __declspec(uuid(\"03E98D51-DDE7-43aa-B70C-42EF84A3A23D\")) ITrackInfo : public IUnknown\n{\n    STDMETHOD_(UINT, GetTrackCount)() = 0;\n\n    // \\param aTrackIdx the track index (from 0 to GetTrackCount()-1)\n    STDMETHOD_(BOOL, GetTrackInfo)(UINT aTrackIdx, struct TrackElement * pStructureToFill) = 0;\n\n    // Get an extended information struct relative to the track type\n    STDMETHOD_(BOOL, GetTrackExtendedInfo)(UINT aTrackIdx, void *pStructureToFill) = 0;\n\n    STDMETHOD_(BSTR, GetTrackCodecID)(UINT aTrackIdx) = 0;\n    STDMETHOD_(BSTR, GetTrackName)(UINT aTrackIdx) = 0;\n    STDMETHOD_(BSTR, GetTrackCodecName)(UINT aTrackIdx) = 0;\n    STDMETHOD_(BSTR, GetTrackCodecInfoURL)(UINT aTrackIdx) = 0;\n    STDMETHOD_(BSTR, GetTrackCodecDownloadURL)(UINT aTrackIdx) = 0;\n};\n"
  },
  {
    "path": "include/IURLSourceFilterLAV.h",
    "content": "/*\n *      Copyright (C) 2024 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\ninterface __declspec(uuid(\"C8FF17F9-5365-4F32-8AD5-6C550342C2F7\")) IURLSourceFilterLAV : public IUnknown\n{\n    // Load a URL with the specified user agent and referrer\n    // UserAgent and Referrer are optional, and either, both or none can be specified\n    STDMETHOD(LoadURL)(LPCOLESTR pszURL, LPCOLESTR pszUserAgent, LPCOLESTR pszReferrer) = 0;\n};\n"
  },
  {
    "path": "include/LAVAudioSettings.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n// {4158A22B-6553-45D0-8069-24716F8FF171}\nDEFINE_GUID(IID_ILAVAudioSettings, 0x4158a22b, 0x6553, 0x45d0, 0x80, 0x69, 0x24, 0x71, 0x6f, 0x8f, 0xf1, 0x71);\n\n// {A668B8F2-BA87-4F63-9D41-768F7DE9C50E}\nDEFINE_GUID(IID_ILAVAudioStatus, 0xa668b8f2, 0xba87, 0x4f63, 0x9d, 0x41, 0x76, 0x8f, 0x7d, 0xe9, 0xc5, 0xe);\n\n// Codecs supported in the LAV Audio configuration\n// Codecs not listed here cannot be turned off. You can request codecs to be added to this list, if you wish.\ntypedef enum LAVAudioCodec\n{\n    Codec_AAC,\n    Codec_AC3,\n    Codec_EAC3,\n    Codec_DTS,\n    Codec_MP2,\n    Codec_MP3,\n    Codec_TRUEHD,\n    Codec_FLAC,\n    Codec_VORBIS,\n    Codec_LPCM,\n    Codec_PCM,\n    Codec_WAVPACK,\n    Codec_TTA,\n    Codec_WMA2,\n    Codec_WMAPRO,\n    Codec_Cook,\n    Codec_RealAudio,\n    Codec_WMALL,\n    Codec_ALAC,\n    Codec_Opus,\n    Codec_AMR,\n    Codec_Nellymoser,\n    Codec_MSPCM,\n    Codec_Truespeech,\n    Codec_TAK,\n    Codec_ATRAC,\n    Codec_ADPCM,\n    Codec_IMC,\n\n    Codec_AudioNB // Number of entries (do not use when dynamically linking)\n} LAVAudioCodec;\n\n// Bitstreaming Codecs supported in LAV Audio\ntypedef enum LAVBitstreamCodec\n{\n    Bitstream_AC3,\n    Bitstream_EAC3,\n    Bitstream_TRUEHD,\n    Bitstream_DTS,\n    Bitstream_DTSHD,\n\n    Bitstream_NB // Number of entries (do not use when dynamically linking)\n} LAVBitstreamCodec;\n\n// Supported Sample Formats in LAV Audio\ntypedef enum LAVAudioSampleFormat\n{\n    SampleFormat_None = -1,\n    SampleFormat_16,\n    SampleFormat_24,\n    SampleFormat_32,\n    SampleFormat_U8,\n    SampleFormat_FP32,\n    SampleFormat_Bitstream,\n\n    SampleFormat_NB // Number of entries (do not use when dynamically linking)\n} LAVAudioSampleFormat;\n\ntypedef enum LAVAudioMixingMode\n{\n    MatrixEncoding_None,\n    MatrixEncoding_Dolby,\n    MatrixEncoding_DPLII,\n\n    MatrixEncoding_NB\n} LAVAudioMixingMode;\n\n// LAV Audio configuration interface\ninterface __declspec(uuid(\"4158A22B-6553-45D0-8069-24716F8FF171\")) ILAVAudioSettings : public IUnknown\n{\n    // Switch to Runtime Config mode. This will reset all settings to default, and no changes to the settings will be\n    // saved You can use this to programmatically configure LAV Audio without interfering with the users settings in the\n    // registry. Subsequent calls to this function will reset all settings back to defaults, even if the mode does not\n    // change.\n    //\n    // Note that calling this function during playback is not supported and may exhibit undocumented behaviour.\n    // For smooth operations, it must be called before LAV Audio is connected to other filters.\n    STDMETHOD(SetRuntimeConfig)(BOOL bRuntimeConfig) = 0;\n\n    // Dynamic Range Compression\n    // pbDRCEnabled: The state of DRC\n    // piDRCLevel:   The DRC strength (0-100, 100 is maximum)\n    STDMETHOD(GetDRC)(BOOL * pbDRCEnabled, int *piDRCLevel) = 0;\n    STDMETHOD(SetDRC)(BOOL bDRCEnabled, int iDRCLevel) = 0;\n\n    // Configure which codecs are enabled\n    // If aCodec is invalid (possibly a version difference), Get will return FALSE, and Set E_FAIL.\n    STDMETHOD_(BOOL, GetFormatConfiguration)(LAVAudioCodec aCodec) = 0;\n    STDMETHOD(SetFormatConfiguration)(LAVAudioCodec aCodec, BOOL bEnabled) = 0;\n\n    // Control Bitstreaming\n    // If bsCodec is invalid (possibly a version difference), Get will return FALSE, and Set E_FAIL.\n    STDMETHOD_(BOOL, GetBitstreamConfig)(LAVBitstreamCodec bsCodec) = 0;\n    STDMETHOD(SetBitstreamConfig)(LAVBitstreamCodec bsCodec, BOOL bEnabled) = 0;\n\n    // Should \"normal\" DTS frames be encapsulated in DTS-HD frames when bitstreaming?\n    STDMETHOD_(BOOL, GetDTSHDFraming)() = 0;\n    STDMETHOD(SetDTSHDFraming)(BOOL bHDFraming) = 0;\n\n    // Control Auto A/V syncing\n    STDMETHOD_(BOOL, GetAutoAVSync)() = 0;\n    STDMETHOD(SetAutoAVSync)(BOOL bAutoSync) = 0;\n\n    // Convert all Channel Layouts to standard layouts\n    // Standard are: Mono, Stereo, 5.1, 6.1, 7.1\n    STDMETHOD_(BOOL, GetOutputStandardLayout)() = 0;\n    STDMETHOD(SetOutputStandardLayout)(BOOL bStdLayout) = 0;\n\n    // Expand Mono to Stereo by simply doubling the audio\n    STDMETHOD_(BOOL, GetExpandMono)() = 0;\n    STDMETHOD(SetExpandMono)(BOOL bExpandMono) = 0;\n\n    // Expand 6.1 to 7.1 by doubling the back center\n    STDMETHOD_(BOOL, GetExpand61)() = 0;\n    STDMETHOD(SetExpand61)(BOOL bExpand61) = 0;\n\n    // Allow Raw PCM and SPDIF encoded input\n    STDMETHOD_(BOOL, GetAllowRawSPDIFInput)() = 0;\n    STDMETHOD(SetAllowRawSPDIFInput)(BOOL bAllow) = 0;\n\n    // Configure which sample formats are enabled\n    // Note: SampleFormat_Bitstream cannot be controlled by this\n    STDMETHOD_(BOOL, GetSampleFormat)(LAVAudioSampleFormat format) = 0;\n    STDMETHOD(SetSampleFormat)(LAVAudioSampleFormat format, BOOL bEnabled) = 0;\n\n    // Configure a delay for the audio\n    STDMETHOD(GetAudioDelay)(BOOL * pbEnabled, int *pDelay) = 0;\n    STDMETHOD(SetAudioDelay)(BOOL bEnabled, int delay) = 0;\n\n    // Enable/Disable Mixing\n    STDMETHOD(SetMixingEnabled)(BOOL bEnabled) = 0;\n    STDMETHOD_(BOOL, GetMixingEnabled)() = 0;\n\n    // Control Mixing Layout\n    STDMETHOD(SetMixingLayout)(DWORD dwLayout) = 0;\n    STDMETHOD_(DWORD, GetMixingLayout)() = 0;\n\n#define LAV_MIXING_FLAG_UNTOUCHED_STEREO 0x0001\n#define LAV_MIXING_FLAG_NORMALIZE_MATRIX 0x0002\n#define LAV_MIXING_FLAG_CLIP_PROTECTION 0x0004\n    // Set Mixing Flags\n    STDMETHOD(SetMixingFlags)(DWORD dwFlags) = 0;\n    STDMETHOD_(DWORD, GetMixingFlags)() = 0;\n\n    // Set Mixing Mode\n    STDMETHOD(SetMixingMode)(LAVAudioMixingMode mixingMode) = 0;\n    STDMETHOD_(LAVAudioMixingMode, GetMixingMode)() = 0;\n\n    // Set Mixing Levels\n    STDMETHOD(SetMixingLevels)(DWORD dwCenterLevel, DWORD dwSurroundLevel, DWORD dwLFELevel) = 0;\n    STDMETHOD(GetMixingLevels)(DWORD * dwCenterLevel, DWORD * dwSurroundLevel, DWORD * dwLFELevel) = 0;\n\n    // Toggle Tray Icon\n    STDMETHOD(SetTrayIcon)(BOOL bEnabled) = 0;\n    STDMETHOD_(BOOL, GetTrayIcon)() = 0;\n\n    // Toggle Dithering for sample format conversion\n    STDMETHOD(SetSampleConvertDithering)(BOOL bEnabled) = 0;\n    STDMETHOD_(BOOL, GetSampleConvertDithering)() = 0;\n\n    // Suppress sample format changes. This will allow channel count to increase, but not to reduce, instead adding\n    // empty channels This option is NOT persistent\n    STDMETHOD(SetSuppressFormatChanges)(BOOL bEnabled) = 0;\n    STDMETHOD_(BOOL, GetSuppressFormatChanges)() = 0;\n\n    // Use 5.1 legacy layout (using back channels instead of side)\n    STDMETHOD_(BOOL, GetOutput51LegacyLayout)() = 0;\n    STDMETHOD(SetOutput51LegacyLayout)(BOOL b51Legacy) = 0;\n\n    // Fallback to audio decoding if bitstreaming is not supported by the audio renderer/hardware\n    STDMETHOD_(BOOL, GetBitstreamingFallback)() = 0;\n    STDMETHOD(SetBitstreamingFallback)(BOOL bBitstreamingFallback) = 0;\n};\n\n// LAV Audio Status Interface\n// Get the current playback stats\ninterface __declspec(uuid(\"A668B8F2-BA87-4F63-9D41-768F7DE9C50E\")) ILAVAudioStatus : public IUnknown\n{\n    // Check if the given sample format is supported by the current playback chain\n    STDMETHOD_(BOOL, IsSampleFormatSupported)(LAVAudioSampleFormat sfCheck) = 0;\n\n    // Get details about the current decoding format\n    STDMETHOD(GetDecodeDetails)\n    (LPCSTR * pCodec, LPCSTR * pDecodeFormat, int *pnChannels, int *pSampleRate, DWORD *pChannelMask) = 0;\n\n    // Get details about the current output format\n    STDMETHOD(GetOutputDetails)(LPCSTR * pOutputFormat, int *pnChannels, int *pSampleRate, DWORD *pChannelMask) = 0;\n\n    // Enable Volume measurements\n    STDMETHOD(EnableVolumeStats)() = 0;\n\n    // Disable Volume measurements\n    STDMETHOD(DisableVolumeStats)() = 0;\n\n    // Get Volume Average for the given channel\n    STDMETHOD(GetChannelVolumeAverage)(WORD nChannel, float *pfDb) = 0;\n};\n"
  },
  {
    "path": "include/LAVSplitterSettings.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n#include <Unknwn.h> // IUnknown and GUID Macros\n\n// {774A919D-EA95-4A87-8A1E-F48ABE8499C7}\nDEFINE_GUID(IID_ILAVFSettings, 0x774a919d, 0xea95, 0x4a87, 0x8a, 0x1e, 0xf4, 0x8a, 0xbe, 0x84, 0x99, 0xc7);\n\ntypedef enum LAVSubtitleMode\n{\n    LAVSubtitleMode_NoSubs,\n    LAVSubtitleMode_ForcedOnly,\n    LAVSubtitleMode_Default,\n    LAVSubtitleMode_Advanced\n} LAVSubtitleMode;\n\ninterface __declspec(uuid(\"774A919D-EA95-4A87-8A1E-F48ABE8499C7\")) ILAVFSettings : public IUnknown\n{\n    // Switch to Runtime Config mode. This will reset all settings to default, and no changes to the settings will be\n    // saved You can use this to programmatically configure LAV Splitter without interfering with the users settings in\n    // the registry. Subsequent calls to this function will reset all settings back to defaults, even if the mode does\n    // not change.\n    //\n    // Note that calling this function during playback is not supported and may exhibit undocumented behaviour.\n    // For smooth operations, it must be called before LAV Splitter opens a file.\n    STDMETHOD(SetRuntimeConfig)(BOOL bRuntimeConfig) = 0;\n\n    // Retrieve the preferred languages as ISO 639-2 language codes, comma separated\n    // If the result is NULL, no language has been set\n    // Memory for the string will be allocated, and has to be free'ed by the caller with CoTaskMemFree\n    STDMETHOD(GetPreferredLanguages)(LPWSTR * ppLanguages) = 0;\n\n    // Set the preferred languages as ISO 639-2 language codes, comma separated\n    // To reset to no preferred language, pass NULL or the empty string\n    STDMETHOD(SetPreferredLanguages)(LPCWSTR pLanguages) = 0;\n\n    // Retrieve the preferred subtitle languages as ISO 639-2 language codes, comma separated\n    // If the result is NULL, no language has been set\n    // If no subtitle language is set, the main language preference is used.\n    // Memory for the string will be allocated, and has to be free'ed by the caller with CoTaskMemFree\n    STDMETHOD(GetPreferredSubtitleLanguages)(LPWSTR * ppLanguages) = 0;\n\n    // Set the preferred subtitle languages as ISO 639-2 language codes, comma separated\n    // To reset to no preferred language, pass NULL or the empty string\n    // If no subtitle language is set, the main language preference is used.\n    STDMETHOD(SetPreferredSubtitleLanguages)(LPCWSTR pLanguages) = 0;\n\n    // Get the current subtitle mode\n    // See enum for possible values\n    STDMETHOD_(LAVSubtitleMode, GetSubtitleMode)() = 0;\n\n    // Set the current subtitle mode\n    // See enum for possible values\n    STDMETHOD(SetSubtitleMode)(LAVSubtitleMode mode) = 0;\n\n    // Get the subtitle matching language flag\n    // TRUE = Only subtitles with a language in the preferred list will be used; FALSE = All subtitles will be used\n    // @deprecated - do not use anymore, deprecated and non-functional, replaced by advanced subtitle mode\n    STDMETHOD_(BOOL, GetSubtitleMatchingLanguage)() = 0;\n\n    // Set the subtitle matching language flag\n    // TRUE = Only subtitles with a language in the preferred list will be used; FALSE = All subtitles will be used\n    // @deprecated - do not use anymore, deprecated and non-functional, replaced by advanced subtitle mode\n    STDMETHOD(SetSubtitleMatchingLanguage)(BOOL dwMode) = 0;\n\n    // Control whether a special \"Forced Subtitles\" stream will be created for PGS subs\n    STDMETHOD_(BOOL, GetPGSForcedStream)() = 0;\n\n    // Control whether a special \"Forced Subtitles\" stream will be created for PGS subs\n    STDMETHOD(SetPGSForcedStream)(BOOL bFlag) = 0;\n\n    // Get the PGS forced subs config\n    // TRUE = only forced PGS frames will be shown, FALSE = all frames will be shown\n    STDMETHOD_(BOOL, GetPGSOnlyForced)() = 0;\n\n    // Set the PGS forced subs config\n    // TRUE = only forced PGS frames will be shown, FALSE = all frames will be shown\n    STDMETHOD(SetPGSOnlyForced)(BOOL bForced) = 0;\n\n    // Get the VC-1 Timestamp Processing mode\n    // 0 - No Timestamp Correction, 1 - Always Timestamp Correction, 2 - Auto (Correction for Decoders that need it)\n    STDMETHOD_(int, GetVC1TimestampMode)() = 0;\n\n    // Set the VC-1 Timestamp Processing mode\n    // 0 - No Timestamp Correction, 1 - Always Timestamp Correction, 2 - Auto (Correction for Decoders that need it)\n    STDMETHOD(SetVC1TimestampMode)(int iMode) = 0;\n\n    // Set whether substreams (AC3 in TrueHD, for example) should be shown as a separate stream\n    STDMETHOD(SetSubstreamsEnabled)(BOOL bSubStreams) = 0;\n\n    // Check whether substreams (AC3 in TrueHD, for example) should be shown as a separate stream\n    STDMETHOD_(BOOL, GetSubstreamsEnabled)() = 0;\n\n    // @deprecated - no longer required\n    STDMETHOD(SetVideoParsingEnabled)(BOOL bEnabled) = 0;\n\n    // @deprecated - no longer required\n    STDMETHOD_(BOOL, GetVideoParsingEnabled)() = 0;\n\n    // Set if LAV Splitter should try to fix broken HD-PVR streams\n    // @deprecated - no longer required\n    STDMETHOD(SetFixBrokenHDPVR)(BOOL bEnabled) = 0;\n\n    // Query if LAV Splitter should try to fix broken HD-PVR streams\n    // @deprecated - no longer required\n    STDMETHOD_(BOOL, GetFixBrokenHDPVR)() = 0;\n\n    // Control whether the given format is enabled\n    STDMETHOD_(HRESULT, SetFormatEnabled)(LPCSTR strFormat, BOOL bEnabled) = 0;\n\n    // Check if the given format is enabled\n    STDMETHOD_(BOOL, IsFormatEnabled)(LPCSTR strFormat) = 0;\n\n    // Set if LAV Splitter should always completely remove the filter connected to its Audio Pin when the audio stream\n    // is changed\n    STDMETHOD(SetStreamSwitchRemoveAudio)(BOOL bEnabled) = 0;\n\n    // Query if LAV Splitter should always completely remove the filter connected to its Audio Pin when the audio stream\n    // is changed\n    STDMETHOD_(BOOL, GetStreamSwitchRemoveAudio)() = 0;\n\n    // Advanced Subtitle configuration. Refer to the documentation for details.\n    // If no advanced config exists, will be NULL.\n    // Memory for the string will be allocated, and has to be free'ed by the caller with CoTaskMemFree\n    STDMETHOD(GetAdvancedSubtitleConfig)(LPWSTR * ppAdvancedConfig) = 0;\n\n    // Advanced Subtitle configuration. Refer to the documentation for details.\n    // To reset the config, pass NULL or the empty string.\n    // If no subtitle language is set, the main language preference is used.\n    STDMETHOD(SetAdvancedSubtitleConfig)(LPCWSTR pAdvancedConfig) = 0;\n\n    // Set if LAV Splitter should prefer audio streams for the hearing or visually impaired\n    STDMETHOD(SetUseAudioForHearingVisuallyImpaired)(BOOL bEnabled) = 0;\n\n    // Get if LAV Splitter should prefer audio streams for the hearing or visually impaired\n    STDMETHOD_(BOOL, GetUseAudioForHearingVisuallyImpaired)() = 0;\n\n    // Set the maximum queue size, in megabytes\n    STDMETHOD(SetMaxQueueMemSize)(DWORD dwMaxSize) = 0;\n\n    // Get the maximum queue size, in megabytes\n    STDMETHOD_(DWORD, GetMaxQueueMemSize)() = 0;\n\n    // Toggle Tray Icon\n    STDMETHOD(SetTrayIcon)(BOOL bEnabled) = 0;\n\n    // Get Tray Icon\n    STDMETHOD_(BOOL, GetTrayIcon)() = 0;\n\n    // Toggle whether higher quality audio streams are preferred\n    STDMETHOD(SetPreferHighQualityAudioStreams)(BOOL bEnabled) = 0;\n\n    // Toggle whether higher quality audio streams are preferred\n    STDMETHOD_(BOOL, GetPreferHighQualityAudioStreams)() = 0;\n\n    // Toggle whether Matroska Linked Segments should be loaded from other files\n    STDMETHOD(SetLoadMatroskaExternalSegments)(BOOL bEnabled) = 0;\n\n    // Get whether Matroska Linked Segments should be loaded from other files\n    STDMETHOD_(BOOL, GetLoadMatroskaExternalSegments)() = 0;\n\n    // Get the list of available formats\n    // Memory for the string array will be allocated, and has to be free'ed by the caller with CoTaskMemFree\n    STDMETHOD(GetFormats)(LPSTR * *formats, UINT * nFormats) = 0;\n\n    // Set the duration (in ms) of analysis for network streams (to find the streams and codec parameters)\n    STDMETHOD(SetNetworkStreamAnalysisDuration)(DWORD dwDuration) = 0;\n\n    // Get the duration (in ms) of analysis for network streams (to find the streams and codec parameters)\n    STDMETHOD_(DWORD, GetNetworkStreamAnalysisDuration)() = 0;\n\n    // Set the maximum queue size, in number of packets\n    STDMETHOD(SetMaxQueueSize)(DWORD dwMaxSize) = 0;\n\n    // Get the maximum queue size, in number of packets\n    STDMETHOD_(DWORD, GetMaxQueueSize)() = 0;\n\n    // Set if LAV Splitter should reselect subs based on given rules when audio stream is changed\n    STDMETHOD(SetStreamSwitchReselectSubtitles)(BOOL bEnabled) = 0;\n\n    // Query if LAV Splitter should reselect subs based on given rules when audio stream is changed\n    STDMETHOD_(BOOL, GetStreamSwitchReselectSubtitles)() = 0;\n};\n"
  },
  {
    "path": "include/LAVVideoSettings.h",
    "content": "/*\n *      Copyright (C) 2010-2021 Hendrik Leppkes\n *      http://www.1f0.de\n *\n *  This program is free software; you can redistribute it and/or modify\n *  it under the terms of the GNU General Public License as published by\n *  the Free Software Foundation; either version 2 of the License, or\n *  (at your option) any later version.\n *\n *  This program is distributed in the hope that it will be useful,\n *  but WITHOUT ANY WARRANTY; without even the implied warranty of\n *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n *  GNU General Public License for more details.\n *\n *  You should have received a copy of the GNU General Public License along\n *  with this program; if not, write to the Free Software Foundation, Inc.,\n *  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.\n */\n\n#pragma once\n\n// {FA40D6E9-4D38-4761-ADD2-71A9EC5FD32F}\nDEFINE_GUID(IID_ILAVVideoSettings, 0xfa40d6e9, 0x4d38, 0x4761, 0xad, 0xd2, 0x71, 0xa9, 0xec, 0x5f, 0xd3, 0x2f);\n\n// {1CC2385F-36FA-41B1-9942-5024CE0235DC}\nDEFINE_GUID(IID_ILAVVideoStatus, 0x1cc2385f, 0x36fa, 0x41b1, 0x99, 0x42, 0x50, 0x24, 0xce, 0x2, 0x35, 0xdc);\n\n// Codecs supported in the LAV Video configuration\n// Codecs not listed here cannot be turned off. You can request codecs to be added to this list, if you wish.\ntypedef enum LAVVideoCodec\n{\n    Codec_H264,\n    Codec_VC1,\n    Codec_MPEG1,\n    Codec_MPEG2,\n    Codec_MPEG4,\n    Codec_MSMPEG4,\n    Codec_VP8,\n    Codec_WMV3,\n    Codec_WMV12,\n    Codec_MJPEG,\n    Codec_Theora,\n    Codec_FLV1,\n    Codec_VP6,\n    Codec_SVQ,\n    Codec_H261,\n    Codec_H263,\n    Codec_Indeo,\n    Codec_TSCC,\n    Codec_Fraps,\n    Codec_HuffYUV,\n    Codec_QTRle,\n    Codec_DV,\n    Codec_Bink,\n    Codec_Smacker,\n    Codec_RV12,\n    Codec_RV34,\n    Codec_Lagarith,\n    Codec_Cinepak,\n    Codec_Camstudio,\n    Codec_QPEG,\n    Codec_ZLIB,\n    Codec_QTRpza,\n    Codec_PNG,\n    Codec_MSRLE,\n    Codec_ProRes,\n    Codec_UtVideo,\n    Codec_Dirac,\n    Codec_DNxHD,\n    Codec_MSVideo1,\n    Codec_8BPS,\n    Codec_LOCO,\n    Codec_ZMBV,\n    Codec_VCR1,\n    Codec_Snow,\n    Codec_FFV1,\n    Codec_v210,\n    Codec_JPEG2000,\n    Codec_VMNC,\n    Codec_FLIC,\n    Codec_G2M,\n    Codec_ICOD,\n    Codec_THP,\n    Codec_HEVC,\n    Codec_VP9,\n    Codec_TrueMotion,\n    Codec_VP7,\n    Codec_H264MVC,\n    Codec_CineformHD,\n    Codec_MagicYUV,\n    Codec_AV1,\n    Codec_VVC,\n    Codec_VP4,\n    Codec_FIC,\n    Codec_APV,\n\n    Codec_VideoNB // Number of entries (do not use when dynamically linking)\n} LAVVideoCodec;\n\n// Codecs with hardware acceleration\ntypedef enum LAVVideoHWCodec\n{\n    HWCodec_H264 = Codec_H264,\n    HWCodec_VC1 = Codec_VC1,\n    HWCodec_MPEG2 = Codec_MPEG2,\n    HWCodec_MPEG4 = Codec_MPEG4,\n    HWCodec_MPEG2DVD_Deprecated, // disabled, DVD video is no longer supported in hardware decoding due to issues with menus and general stability\n    HWCodec_HEVC,\n    HWCodec_VP9,\n    HWCodec_H264MVC,\n    HWCodec_AV1,\n\n    HWCodec_NB,\n} LAVVideoHWCodec;\n\n// Flags for HW Resolution support\n#define LAVHWResFlag_SD 0x0001\n#define LAVHWResFlag_HD 0x0002\n#define LAVHWResFlag_UHD 0x0004\n\n// Type of hardware accelerations\ntypedef enum LAVHWAccel\n{\n    HWAccel_None,\n    HWAccel_CUDA,\n    HWAccel_QuickSync,\n    HWAccel_DXVA2,\n    HWAccel_DXVA2CopyBack = HWAccel_DXVA2,\n    HWAccel_DXVA2Native,\n    HWAccel_D3D11,\n    HWAccel_NB, // Number of HWAccels\n} LAVHWAccel;\n\n// Deinterlace algorithms offered by the hardware decoders\ntypedef enum LAVHWDeintModes\n{\n    HWDeintMode_Weave,\n    HWDeintMode_BOB, // Deprecated\n    HWDeintMode_Hardware\n} LAVHWDeintModes;\n\n// Software deinterlacing algorithms\ntypedef enum LAVSWDeintModes\n{\n    SWDeintMode_None,\n    SWDeintMode_YADIF,\n    SWDeintMode_W3FDIF_Simple,\n    SWDeintMode_W3FDIF_Complex,\n    SWDeintMode_BWDIF,\n} LAVSWDeintModes;\n\n// Deinterlacing processing mode\ntypedef enum LAVDeintMode\n{\n    DeintMode_Auto,\n    DeintMode_Aggressive,\n    DeintMode_Force,\n    DeintMode_Disable\n} LAVDeintMode;\n\n// Type of deinterlacing to perform\n// - FramePerField re-constructs one frame from every field, resulting in 50/60 fps.\n// - FramePer2Field re-constructs one frame from every 2 fields, resulting in 25/30 fps.\n// Note: Weave will always use FramePer2Field\ntypedef enum LAVDeintOutput\n{\n    DeintOutput_FramePerField,\n    DeintOutput_FramePer2Field\n} LAVDeintOutput;\n\n// Control the field order of the deinterlacer\ntypedef enum LAVDeintFieldOrder\n{\n    DeintFieldOrder_Auto,\n    DeintFieldOrder_TopFieldFirst,\n    DeintFieldOrder_BottomFieldFirst,\n} LAVDeintFieldOrder;\n\n// Supported output pixel formats\ntypedef enum LAVOutPixFmts\n{\n    LAVOutPixFmt_None = -1,\n    LAVOutPixFmt_YV12,  // 4:2:0, 8bit, planar\n    LAVOutPixFmt_NV12,  // 4:2:0, 8bit, Y planar, U/V packed\n    LAVOutPixFmt_YUY2,  // 4:2:2, 8bit, packed\n    LAVOutPixFmt_UYVY,  // 4:2:2, 8bit, packed\n    LAVOutPixFmt_AYUV,  // 4:4:4, 8bit, packed\n    LAVOutPixFmt_P010,  // 4:2:0, 10bit, Y planar, U/V packed\n    LAVOutPixFmt_P210,  // 4:2:2, 10bit, Y planar, U/V packed\n    LAVOutPixFmt_Y410,  // 4:4:4, 10bit, packed\n    LAVOutPixFmt_P016,  // 4:2:0, 16bit, Y planar, U/V packed\n    LAVOutPixFmt_P216,  // 4:2:2, 16bit, Y planar, U/V packed\n    LAVOutPixFmt_Y416,  // 4:4:4, 16bit, packed\n    LAVOutPixFmt_RGB32, // 32-bit RGB (BGRA)\n    LAVOutPixFmt_RGB24, // 24-bit RGB (BGR)\n\n    LAVOutPixFmt_v210, // 4:2:2, 10bit, packed\n    LAVOutPixFmt_v410, // 4:4:4, 10bit, packed\n\n    LAVOutPixFmt_YV16, // 4:2:2, 8-bit, planar\n    LAVOutPixFmt_YV24, // 4:4:4, 8-bit, planar\n\n    LAVOutPixFmt_RGB48, // 48-bit RGB (16-bit per pixel, BGR)\n\n    LAVOutPixFmt_NB // Number of formats\n} LAVOutPixFmts;\n\ntypedef enum LAVDitherMode\n{\n    LAVDither_Ordered,\n    LAVDither_Random\n} LAVDitherMode;\n\n// LAV Video configuration interface\ninterface __declspec(uuid(\"FA40D6E9-4D38-4761-ADD2-71A9EC5FD32F\")) ILAVVideoSettings : public IUnknown\n{\n    // Switch to Runtime Config mode. This will reset all settings to default, and no changes to the settings will be\n    // saved You can use this to programmatically configure LAV Video without interfering with the users settings in the\n    // registry. Subsequent calls to this function will reset all settings back to defaults, even if the mode does not\n    // change.\n    //\n    // Note that calling this function during playback is not supported and may exhibit undocumented behaviour.\n    // For smooth operations, it must be called before LAV Video is connected to other filters.\n    STDMETHOD(SetRuntimeConfig)(BOOL bRuntimeConfig) = 0;\n\n    // Configure which codecs are enabled\n    // If vCodec is invalid (possibly a version difference), Get will return FALSE, and Set E_FAIL.\n    STDMETHOD_(BOOL, GetFormatConfiguration)(LAVVideoCodec vCodec) = 0;\n    STDMETHOD(SetFormatConfiguration)(LAVVideoCodec vCodec, BOOL bEnabled) = 0;\n\n    // Set the number of threads to use for Multi-Threaded decoding (where available)\n    //  0 = Auto Detect (based on number of CPU cores)\n    //  1 = 1 Thread -- No Multi-Threading\n    // >1 = Multi-Threading with the specified number of threads\n    STDMETHOD(SetNumThreads)(DWORD dwNum) = 0;\n\n    // Get the number of threads to use for Multi-Threaded decoding (where available)\n    //  0 = Auto Detect (based on number of CPU cores)\n    //  1 = 1 Thread -- No Multi-Threading\n    // >1 = Multi-Threading with the specified number of threads\n    STDMETHOD_(DWORD, GetNumThreads)() = 0;\n\n    // Set whether the aspect ratio encoded in the stream should be forwarded to the renderer,\n    // or the aspect ratio specified by the source filter should be kept.\n    // 0 = AR from the source filter\n    // 1 = AR from the Stream\n    // 2 = AR from stream if source is not reliable\n    STDMETHOD(SetStreamAR)(DWORD bStreamAR) = 0;\n\n    // Get whether the aspect ratio encoded in the stream should be forwarded to the renderer,\n    // or the aspect ratio specified by the source filter should be kept.\n    // 0 = AR from the source filter\n    // 1 = AR from the Stream\n    // 2 = AR from stream if source is not reliable\n    STDMETHOD_(DWORD, GetStreamAR)() = 0;\n\n    // Configure which pixel formats are enabled for output\n    // If pixFmt is invalid, Get will return FALSE and Set E_FAIL\n    STDMETHOD_(BOOL, GetPixelFormat)(LAVOutPixFmts pixFmt) = 0;\n    STDMETHOD(SetPixelFormat)(LAVOutPixFmts pixFmt, BOOL bEnabled) = 0;\n\n    // Set the RGB output range for the YUV->RGB conversion\n    // 0 = Auto (same as input), 1 = Limited (16-235), 2 = Full (0-255)\n    STDMETHOD(SetRGBOutputRange)(DWORD dwRange) = 0;\n\n    // Get the RGB output range for the YUV->RGB conversion\n    // 0 = Auto (same as input), 1 = Limited (16-235), 2 = Full (0-255)\n    STDMETHOD_(DWORD, GetRGBOutputRange)() = 0;\n\n    // Set the deinterlacing field order of the hardware decoder\n    STDMETHOD(SetDeintFieldOrder)(LAVDeintFieldOrder fieldOrder) = 0;\n\n    // get the deinterlacing field order of the hardware decoder\n    STDMETHOD_(LAVDeintFieldOrder, GetDeintFieldOrder)() = 0;\n\n    // DEPRECATED, use SetDeinterlacingMode\n    STDMETHOD(SetDeintAggressive)(BOOL bAggressive) = 0;\n\n    // DEPRECATED, use GetDeinterlacingMode\n    STDMETHOD_(BOOL, GetDeintAggressive)() = 0;\n\n    // DEPRECATED, use SetDeinterlacingMode\n    STDMETHOD(SetDeintForce)(BOOL bForce) = 0;\n\n    // DEPRECATED, use GetDeinterlacingMode\n    STDMETHOD_(BOOL, GetDeintForce)() = 0;\n\n    // Check if the specified HWAccel is supported\n    // Note: This will usually only check the availability of the required libraries (ie. for NVIDIA if a recent enough\n    // NVIDIA driver is installed) and not check actual hardware support Returns: 0 = Unsupported, 1 = Supported, 2 =\n    // Currently running\n    STDMETHOD_(DWORD, CheckHWAccelSupport)(LAVHWAccel hwAccel) = 0;\n\n    // Set which HW Accel method is used\n    // See LAVHWAccel for options.\n    STDMETHOD(SetHWAccel)(LAVHWAccel hwAccel) = 0;\n\n    // Get which HW Accel method is active\n    STDMETHOD_(LAVHWAccel, GetHWAccel)() = 0;\n\n    // Set which codecs should use HW Acceleration\n    STDMETHOD(SetHWAccelCodec)(LAVVideoHWCodec hwAccelCodec, BOOL bEnabled) = 0;\n\n    // Get which codecs should use HW Acceleration\n    STDMETHOD_(BOOL, GetHWAccelCodec)(LAVVideoHWCodec hwAccelCodec) = 0;\n\n    // Set the deinterlacing mode used by the hardware decoder\n    STDMETHOD(SetHWAccelDeintMode)(LAVHWDeintModes deintMode) = 0;\n\n    // Get the deinterlacing mode used by the hardware decoder\n    STDMETHOD_(LAVHWDeintModes, GetHWAccelDeintMode)() = 0;\n\n    // Set the deinterlacing output for the hardware decoder\n    STDMETHOD(SetHWAccelDeintOutput)(LAVDeintOutput deintOutput) = 0;\n\n    // Get the deinterlacing output for the hardware decoder\n    STDMETHOD_(LAVDeintOutput, GetHWAccelDeintOutput)() = 0;\n\n    // deprecated. HQ mode is only supported by NVIDIA CUVID/NVDEC and officially deprecated by NVIDIA\n    STDMETHOD(SetHWAccelDeintHQ)(BOOL bHQ) = 0;\n    STDMETHOD_(BOOL, GetHWAccelDeintHQ)() = 0;\n\n    // Set the software deinterlacing mode used\n    STDMETHOD(SetSWDeintMode)(LAVSWDeintModes deintMode) = 0;\n\n    // Get the software deinterlacing mode used\n    STDMETHOD_(LAVSWDeintModes, GetSWDeintMode)() = 0;\n\n    // Set the software deinterlacing output\n    STDMETHOD(SetSWDeintOutput)(LAVDeintOutput deintOutput) = 0;\n\n    // Get the software deinterlacing output\n    STDMETHOD_(LAVDeintOutput, GetSWDeintOutput)() = 0;\n\n    // DEPRECATED, use SetDeinterlacingMode\n    STDMETHOD(SetDeintTreatAsProgressive)(BOOL bEnabled) = 0;\n\n    // DEPRECATED, use GetDeinterlacingMode\n    STDMETHOD_(BOOL, GetDeintTreatAsProgressive)() = 0;\n\n    // Set the dithering mode used\n    STDMETHOD(SetDitherMode)(LAVDitherMode ditherMode) = 0;\n\n    // Get the dithering mode used\n    STDMETHOD_(LAVDitherMode, GetDitherMode)() = 0;\n\n    // Set if the MS WMV9 DMO Decoder should be used for VC-1/WMV3\n    STDMETHOD(SetUseMSWMV9Decoder)(BOOL bEnabled) = 0;\n\n    // Get if the MS WMV9 DMO Decoder should be used for VC-1/WMV3\n    STDMETHOD_(BOOL, GetUseMSWMV9Decoder)() = 0;\n\n    // Set if DVD Video support is enabled\n    STDMETHOD(SetDVDVideoSupport)(BOOL bEnabled) = 0;\n\n    // Get if DVD Video support is enabled\n    STDMETHOD_(BOOL, GetDVDVideoSupport)() = 0;\n\n    // Set the HW Accel Resolution Flags\n    // flags: bitmask of LAVHWResFlag flags\n    STDMETHOD(SetHWAccelResolutionFlags)(DWORD dwResFlags) = 0;\n\n    // Get the HW Accel Resolution Flags\n    // flags: bitmask of LAVHWResFlag flags\n    STDMETHOD_(DWORD, GetHWAccelResolutionFlags)() = 0;\n\n    // Toggle Tray Icon\n    STDMETHOD(SetTrayIcon)(BOOL bEnabled) = 0;\n\n    // Get Tray Icon\n    STDMETHOD_(BOOL, GetTrayIcon)() = 0;\n\n    // Set the Deint Mode\n    STDMETHOD(SetDeinterlacingMode)(LAVDeintMode deintMode) = 0;\n\n    // Get the Deint Mode\n    STDMETHOD_(LAVDeintMode, GetDeinterlacingMode)() = 0;\n\n    // Set the index of the GPU to be used for hardware decoding\n    // Only supported for CUVID and DXVA2 copy-back. If the device is not valid, it'll fallback to auto-detection\n    // Must be called before an input is connected to LAV Video, and the setting is non-persistent\n    // NOTE: For CUVID, the index defines the index of the CUDA capable device, while for DXVA2, the list includes all\n    // D3D9 devices\n    STDMETHOD(SetGPUDeviceIndex)(DWORD dwDevice) = 0;\n\n    // Get the number of available devices for the specified HWAccel\n    STDMETHOD_(DWORD, GetHWAccelNumDevices)(LAVHWAccel hwAccel) = 0;\n\n    // Get a list of available HWAccel devices for the specified HWAccel\n    STDMETHOD(GetHWAccelDeviceInfo)\n    (LAVHWAccel hwAccel, DWORD dwIndex, BSTR * pstrDeviceName, DWORD * pdwDeviceIdentifier) = 0;\n\n    // Get/Set the device for a specified HWAccel\n    // In contrast to SetGPUDeviceIndex, this setting is hwaccel-specific and persistent\n    // dwDeviceIdentifier is an optional parameter that identifies the selected device (ie. its device id), set to 0 if\n    // not used\n#define LAVHWACCEL_DEVICE_DEFAULT ((DWORD)-1)\n    STDMETHOD_(DWORD, GetHWAccelDeviceIndex)(LAVHWAccel hwAccel, DWORD * pdwDeviceIdentifier) = 0;\n    STDMETHOD(SetHWAccelDeviceIndex)(LAVHWAccel hwAccel, DWORD dwIndex, DWORD dwDeviceIdentifier) = 0;\n\n    // Temporary Override for players to disable H.264 MVC decoding\n    // This is not a permanent setting and not saved, but can be used by players to offer a \"Play in 2D\" option, or\n    // similar. A setting of FALSE disable MVC decoding temporarily Note that the override cannot force-enable the\n    // option if its turned off through SetFormatConfiguration\n    STDMETHOD(SetH264MVCDecodingOverride)(BOOL bEnabled) = 0;\n\n    //  Enable the creation of the Closed Caption output pin\n    STDMETHOD(SetEnableCCOutputPin)(BOOL bEnabled) = 0;\n};\n\n// LAV Video status interface\ninterface __declspec(uuid(\"1CC2385F-36FA-41B1-9942-5024CE0235DC\")) ILAVVideoStatus : public IUnknown\n{\n    // Get the name of the active decoder (can return NULL if none is active)\n    STDMETHOD_(LPCWSTR, GetActiveDecoderName)() = 0;\n\n    // Get the name of the currently active hwaccel device\n    STDMETHOD(GetHWAccelActiveDevice)(BSTR * pstrDeviceName) = 0;\n};\n"
  },
  {
    "path": "include/README.txt",
    "content": "This directory contains header files of non-standard Interfaces that LAV Filters support.\n---------------------------------------------------------------------------------------------\n\n----------------------------------------------\nIKeyFrameInfo - implemented by LAV Splitter\n---------------------------------------------\nIKeyFrameInfo allows players to query the position of keyframes, so they can redirect seeking\nrequests to those positions for very smooth seek events. Only fully supported on MKV files.\n\n----------------------------------------------\nITrackInfo - implemented by LAV Splitter\n---------------------------------------------\nITrackInfo is an interface to obtain additional information about the streams in a file.\nThe order to query the streams is the same as returned by IAMStreamSelect::Info\n\n----------------------------------------------\nIGraphRebuildDelegate\n---------------------------------------------\nIGraphRebuildDelegate is not an interface implemented by LAV Splitter itself.\nIt is designed to offer the ability to take over the graph-building process from the player's side.\nIt only exports one function which LAV Splitter will call when a stream change happens on the user's requests,\nand then the player can take care of the graph changes itself instead of relying on LAV Splitter to do it.\n\nTo use IGraphRebuildDelegate, the player needs to implement it, and share the implementing class with LAV Splitter\nthrough the \"IObjectWithSite\" interface, which is implemented by LAV Splitter.\n\n----------------------------------------------\nLAVSplitterSettings / LAVAudioSettings\n----------------------------------------------\nThese interfaces are used to configure LAV programmatically, so the player can do configuration changes.\n"
  },
  {
    "path": "resources/LAVFilters.Dependencies.manifest",
    "content": "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n<assembly xmlns=\"urn:schemas-microsoft-com:asm.v1\" manifestVersion=\"1.0\">\n  <assemblyIdentity type='win32' name='LAVFilters.Dependencies' version='1.0.0.0' />\n  <file name=\"avutil-lav-60.dll\" />\n  <file name=\"swresample-lav-6.dll\" />\n  <file name=\"avcodec-lav-62.dll\" />\n  <file name=\"avformat-lav-62.dll\" />\n  <file name=\"swscale-lav-9.dll\" />\n  <file name=\"avfilter-lav-11.dll\" />\n  <file name=\"libbluray.dll\" />\n</assembly>\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avisynth.h",
    "content": "// Avisynth v2.5.  Copyright 2002 Ben Rudiak-Gould et al.\n// Avisynth v2.6.  Copyright 2006 Klaus Post.\n// Avisynth v2.6.  Copyright 2009 Ian Brabham.\n// Avisynth+ project\n// 20160613: new 16 bit planar pixel_type constants go live!\n// 20160725: pixel_type constants 10-12-14 bit + planar RGB + BRG48/64\n// 20161005: Fallback of VideoInfo functions to defaults if no function exists\n// 20170117: global variables for VfW output OPT_xxxx\n// 20170310: new MT mode: MT_SPECIAL_MT\n// 20171103: (test with SIZETMOD define: Videoframe offsets to size_t, may affect x64)\n// 20171207: C++ Standard Conformance (no change for plugin writers)\n// 20180525: AVS_UNUSED define to supress parameter not used warnings\n// 2020xxxx: AVS_WINDOWS and AVS_POSIX option see avs/config.h\n// 20200305: ScriptEnvironment::VSprintf parameter (void *) changed back to va_list\n// 20200330: removed __stdcall from variadic argument functions (Sprintf)\n//           (remove test SIZETMOD define for clarity)\n//           Integrate Avisynth Neo structures and interface, PFunction, PDevice\n// 20200501: frame property support (NewVideoFrameP and other helpers) to legacy IScriptEnvironment.\n//           move some former IScriptEnvironment2 functions to IScriptEnvironment:\n//           GetEnvProperty (system prop), Allocate, Free (buffer pool)\n//           GetVarTry, GetVarBool/Int/String/Double/Long\n//           Invoke2, Invoke3, InvokeTry, Invoke2Try, Invoke3Try\n//           Interface Version to 8 (classic 2.6 = 6)\n// 20200527  Add IScriptEnvironment_Avs25, used internally\n// 20200607  AVS frame property enums to match existing Avisynth enum style\n// 202112xx  V9-MakePropertyWritable, IsPropertyWritable\n// 2023      V10\n//           prop_src parameter made as const in NewVideoFrameP (non-breaking cosmetics)\n//           Add all enums of public C++ API a name\n//           Add DEFAULT_PLANE as 0 to AvsPlane enum\n//           Made `VideoFrameBuffer` destructor public\n//           Introduce pixel_type to VideoFrame struct\n//           VideoFrame::GetPixelType,VideoFrame::AmendPixelType\n//           AVSValue::GetType\n//           Add enum AvsChannelMask::MASK_SPEAKER_xxx, AvsImageTypeFlags::IT_SPEAKER_xxx\n//           Audio channel mask support for VideoInfo: \n//           Use 20 bits in VideoInfo::image_type for channel mask mapping\n//           IsChannelMaskKnown, SetChannelMask, GetChannelMask in VideoInfo\n\n// http://www.avisynth.org\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making\n// a combined work based on Avisynth.  Thus, the terms and conditions of\n// the GNU General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate\n// with Avisynth solely through the interfaces defined in avisynth.h,\n// regardless of the license terms of these independent modules, and to\n// copy and distribute the resulting combined work under terms of your\n// choice, provided that every copy of the combined work is accompanied\n// by a complete copy of the source code of Avisynth (the version of\n// Avisynth used to produce the combined work), being distributed under\n// the terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based on\n// Avisynth, such as 3rd-party filters, import and export plugins, or\n// graphical user interfaces.\n\n\n#ifndef __AVISYNTH_10_H__\n#define __AVISYNTH_10_H__\n\n#include \"avs/config.h\"\n#include \"avs/capi.h\"\n#include \"avs/types.h\"\n\n#ifdef AVS_POSIX\n# include \"avs/posix.h\"\n#endif\n\n#if defined(AVS_POSIX)\n#if defined(AVS_HAIKU)\n#undef __stdcall\n#undef __cdecl\n#endif\n#define __stdcall\n#define __cdecl\n#endif\n\n// Important note on AVISYNTH_INTERFACE_VERSION V6->V8 change:\n// Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt.\n// Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h:\n//         Use the new frame property features adaptively after querying that at least v8 is supported\n//         AviSynth property support can be queried (cpp iface example):\n//           has_at_least_v8 = true;\n//           try { env->CheckVersion(8); } catch (const AvisynthError&) { has_at_least_v8 = false; }\n//         and use it:\n//           if (has_at_least_v8) dst = env->NewVideoFrameP(vi, &src); else dst = env->NewVideoFrame(vi);\n\nenum AvsVersion {\n  AVISYNTH_CLASSIC_INTERFACE_VERSION_25 = 3,\n  AVISYNTH_CLASSIC_INTERFACE_VERSION_26BETA = 5,\n  AVISYNTH_CLASSIC_INTERFACE_VERSION = 6,\n  AVISYNTH_INTERFACE_VERSION = 10,\n  AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION = 0 // reset to zero whenever the normal interface version bumps\n};\n\n/* Compiler-specific crap */\n\n// Tell MSVC to stop precompiling here\n#if defined(_MSC_VER) && !defined(__clang__)\n  #pragma hdrstop\n#endif\n\n// Set up debugging macros for MS compilers; for others, step down to the\n// standard <assert.h> interface\n#ifdef _MSC_VER\n  #include <crtdbg.h>\n#else\n  #undef _RPT0\n  #undef _RPT1\n  #undef _RPT2\n  #undef _RPT3\n  #undef _RPT4\n  #undef _RPT5\n  #define _RPT0(a,b) ((void)0)\n  #define _RPT1(a,b,c) ((void)0)\n  #define _RPT2(a,b,c,d) ((void)0)\n  #define _RPT3(a,b,c,d,e) ((void)0)\n  #define _RPT4(a,b,c,d,e,f) ((void)0)\n  #define _RPT5(a,b,c,d,e,f,g) ((void)0)\n\n  #include <cassert>\n  #undef _ASSERTE\n  #undef _ASSERT\n  #define _ASSERTE(x) assert(x)\n  #define _ASSERT(x) assert(x)\n#endif\n\n\n\n// I had problems with Premiere wanting 1-byte alignment for its structures,\n// so I now set the Avisynth struct alignment explicitly here.\n#pragma pack(push,8)\n\n// The VideoInfo struct holds global information about a clip (i.e.\n// information that does not depend on the frame number).  The GetVideoInfo\n// method in IClip returns this struct.\n\nenum AvsSampleType {\n  SAMPLE_INT8  = 1 << 0,\n  SAMPLE_INT16 = 1 << 1,\n  SAMPLE_INT24 = 1 << 2,  // Int24 is a very stupid thing to code, but it's supported by some hardware.\n  SAMPLE_INT32 = 1 << 3,\n  SAMPLE_FLOAT = 1 << 4\n};\n\nenum AvsPlane {\n  DEFAULT_PLANE = 0,\n  PLANAR_Y = 1 << 0,\n  PLANAR_U = 1 << 1,\n  PLANAR_V = 1 << 2,\n  PLANAR_ALIGNED = 1 << 3,\n  PLANAR_Y_ALIGNED = PLANAR_Y | PLANAR_ALIGNED,\n  PLANAR_U_ALIGNED = PLANAR_U | PLANAR_ALIGNED,\n  PLANAR_V_ALIGNED = PLANAR_V | PLANAR_ALIGNED,\n  PLANAR_A = 1 << 4,\n  PLANAR_R = 1 << 5,\n  PLANAR_G = 1 << 6,\n  PLANAR_B = 1 << 7,\n  PLANAR_A_ALIGNED = PLANAR_A | PLANAR_ALIGNED,\n  PLANAR_R_ALIGNED = PLANAR_R | PLANAR_ALIGNED,\n  PLANAR_G_ALIGNED = PLANAR_G | PLANAR_ALIGNED,\n  PLANAR_B_ALIGNED = PLANAR_B | PLANAR_ALIGNED,\n};\n\nclass AvisynthError /* exception */ {\npublic:\n  const char* const msg;\n  AvisynthError(const char* _msg) : msg(_msg) {}\n\n// Ensure AvisynthError cannot be publicly assigned!\nprivate:\n  AvisynthError& operator=(const AvisynthError&);\n}; // end class AvisynthError\n\nenum AvsDeviceType {\n  DEV_TYPE_NONE = 0,\n  DEV_TYPE_CPU = 1,\n  DEV_TYPE_CUDA = 2,\n  DEV_TYPE_ANY = 0xFFFF\n};\n\nenum AvsValueType {\n  VALUE_TYPE_UNDEFINED = 'v',\n  VALUE_TYPE_BOOL = 'b',\n  VALUE_TYPE_INT = 'i',\n  VALUE_TYPE_LONG = 'l',\n  VALUE_TYPE_FLOAT = 'f',\n  VALUE_TYPE_DOUBLE = 'd',\n  VALUE_TYPE_STRING = 's',\n  VALUE_TYPE_CLIP = 'c',\n  VALUE_TYPE_FUNCTION = 'n',\n  VALUE_TYPE_ARRAY = 'a'\n};\n\n/* Forward references */\n#if defined(MSVC)\n    #define SINGLE_INHERITANCE __single_inheritance\n#else\n    #define SINGLE_INHERITANCE\n#endif\nstruct SINGLE_INHERITANCE VideoInfo;\nclass SINGLE_INHERITANCE VideoFrameBuffer;\nclass SINGLE_INHERITANCE VideoFrame;\nclass IClip;\nclass SINGLE_INHERITANCE PClip;\nclass SINGLE_INHERITANCE PVideoFrame;\nclass IScriptEnvironment;\nclass SINGLE_INHERITANCE AVSValue;\nclass INeoEnv;\nclass IFunction;\nclass SINGLE_INHERITANCE PFunction;\nclass Device;\nclass SINGLE_INHERITANCE PDevice;\nclass AVSMap;\n\n\n\n/*\n * Avisynth C++ plugin API code function pointers.\n *\n * In order to maintain binary compatibility with\n * future version do not change the order of the\n * existing function pointers. It will be baked\n * into all existing plugins.\n *\n * Add new function pointers to the end of the\n * structure. The linkage macros generate some\n * protection code to ensure newer plugin do not\n * call non-existing functions in an older host.\n */\n\nstruct AVS_Linkage {\n\n  int Size;\n\n/**********************************************************************/\n\n// struct VideoInfo\n  bool    (VideoInfo::*HasVideo)() const;\n  bool    (VideoInfo::*HasAudio)() const;\n  bool    (VideoInfo::*IsRGB)() const;\n  bool    (VideoInfo::*IsRGB24)() const;\n  bool    (VideoInfo::*IsRGB32)() const;\n  bool    (VideoInfo::*IsYUV)() const;\n  bool    (VideoInfo::*IsYUY2)() const;\n  bool    (VideoInfo::*IsYV24)() const;\n  bool    (VideoInfo::*IsYV16)() const;\n  bool    (VideoInfo::*IsYV12)() const;\n  bool    (VideoInfo::*IsYV411)() const;\n  bool    (VideoInfo::*IsY8)() const;\n  bool    (VideoInfo::*IsColorSpace)(int c_space) const;\n  bool    (VideoInfo::*Is)(int property) const;\n  bool    (VideoInfo::*IsPlanar)() const;\n  bool    (VideoInfo::*IsFieldBased)() const;\n  bool    (VideoInfo::*IsParityKnown)() const;\n  bool    (VideoInfo::*IsBFF)() const;\n  bool    (VideoInfo::*IsTFF)() const;\n  bool    (VideoInfo::*IsVPlaneFirst)() const;\n  int     (VideoInfo::*BytesFromPixels)(int pixels) const;\n  int     (VideoInfo::*RowSize)(int plane) const;\n  int     (VideoInfo::*BMPSize)() const;\n  int64_t (VideoInfo::*AudioSamplesFromFrames)(int frames) const;\n  int     (VideoInfo::*FramesFromAudioSamples)(int64_t samples) const;\n  int64_t (VideoInfo::*AudioSamplesFromBytes)(int64_t bytes) const;\n  int64_t (VideoInfo::*BytesFromAudioSamples)(int64_t samples) const;\n  int     (VideoInfo::*AudioChannels)() const;\n  int     (VideoInfo::*SampleType)() const;\n  bool    (VideoInfo::*IsSampleType)(int testtype) const;\n  int     (VideoInfo::*SamplesPerSecond)() const;\n  int     (VideoInfo::*BytesPerAudioSample)() const;\n  void    (VideoInfo::*SetFieldBased)(bool isfieldbased);\n  void    (VideoInfo::*Set)(int property);\n  void    (VideoInfo::*Clear)(int property);\n  int     (VideoInfo::*GetPlaneWidthSubsampling)(int plane) const;\n  int     (VideoInfo::*GetPlaneHeightSubsampling)(int plane) const;\n  int     (VideoInfo::*BitsPerPixel)() const;\n  int     (VideoInfo::*BytesPerChannelSample)() const;\n  void    (VideoInfo::*SetFPS)(unsigned numerator, unsigned denominator);\n  void    (VideoInfo::*MulDivFPS)(unsigned multiplier, unsigned divisor);\n  bool    (VideoInfo::*IsSameColorspace)(const VideoInfo& vi) const;\n// end struct VideoInfo\n\n/**********************************************************************/\n\n// class VideoFrameBuffer\n  const BYTE* (VideoFrameBuffer::*VFBGetReadPtr)() const;\n  BYTE*       (VideoFrameBuffer::*VFBGetWritePtr)();\n  int         (VideoFrameBuffer::*GetDataSize)() const;\n  int         (VideoFrameBuffer::*GetSequenceNumber)() const;\n  int         (VideoFrameBuffer::*GetRefcount)() const;\n// end class VideoFrameBuffer\n\n/**********************************************************************/\n\n// class VideoFrame\n  int               (VideoFrame::*GetPitch)(int plane) const;\n  int               (VideoFrame::*GetRowSize)(int plane) const;\n  int               (VideoFrame::*GetHeight)(int plane) const;\n  VideoFrameBuffer* (VideoFrame::*GetFrameBuffer)() const;\n  int               (VideoFrame::*GetOffset)(int plane) const;\n  const BYTE*       (VideoFrame::*VFGetReadPtr)(int plane) const;\n  bool              (VideoFrame::*IsWritable)() const;\n  BYTE*             (VideoFrame::*VFGetWritePtr)(int plane) const;\n  void              (VideoFrame::*VideoFrame_DESTRUCTOR)();\n// end class VideoFrame\n\n/**********************************************************************/\n\n// class IClip\n  /* nothing */\n// end class IClip\n\n/**********************************************************************/\n\n// class PClip\n  void (PClip::*PClip_CONSTRUCTOR0)();\n  void (PClip::*PClip_CONSTRUCTOR1)(const PClip& x);\n  void (PClip::*PClip_CONSTRUCTOR2)(IClip* x);\n  void (PClip::*PClip_OPERATOR_ASSIGN0)(IClip* x);\n  void (PClip::*PClip_OPERATOR_ASSIGN1)(const PClip& x);\n  void (PClip::*PClip_DESTRUCTOR)();\n// end class PClip\n\n/**********************************************************************/\n\n// class PVideoFrame\n  void (PVideoFrame::*PVideoFrame_CONSTRUCTOR0)();\n  void (PVideoFrame::*PVideoFrame_CONSTRUCTOR1)(const PVideoFrame& x);\n  void (PVideoFrame::*PVideoFrame_CONSTRUCTOR2)(VideoFrame* x);\n  void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN0)(VideoFrame* x);\n  void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN1)(const PVideoFrame& x);\n  void (PVideoFrame::*PVideoFrame_DESTRUCTOR)();\n// end class PVideoFrame\n\n/**********************************************************************/\n\n// class AVSValue\n  void            (AVSValue::*AVSValue_CONSTRUCTOR0)();\n  void            (AVSValue::*AVSValue_CONSTRUCTOR1)(IClip* c);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR2)(const PClip& c);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR3)(bool b);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR4)(int i);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR5)(float f);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR6)(double f);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR7)(const char* s);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR8)(const AVSValue* a, int size);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR9)(const AVSValue& v);\n  void            (AVSValue::*AVSValue_DESTRUCTOR)();\n  AVSValue&       (AVSValue::*AVSValue_OPERATOR_ASSIGN)(const AVSValue& v);\n  const AVSValue& (AVSValue::*AVSValue_OPERATOR_INDEX)(int index) const;\n  bool            (AVSValue::*Defined)() const;\n  bool            (AVSValue::*IsClip)() const;\n  bool            (AVSValue::*IsBool)() const;\n  bool            (AVSValue::*IsInt)() const;\n  bool            (AVSValue::*IsFloat)() const;\n  bool            (AVSValue::*IsString)() const;\n  bool            (AVSValue::*IsArray)() const;\n  PClip           (AVSValue::*AsClip)() const;\n  bool            (AVSValue::*AsBool1)() const;\n  int             (AVSValue::*AsInt1)() const;\n  const char*     (AVSValue::*AsString1)() const;\n  double          (AVSValue::*AsFloat1)() const;\n  bool            (AVSValue::*AsBool2)(bool def) const;\n  int             (AVSValue::*AsInt2)(int def) const;\n  double          (AVSValue::*AsDblDef)(double def) const;\n  double          (AVSValue::*AsFloat2)(float def) const;\n  const char*     (AVSValue::*AsString2)(const char* def) const;\n  int             (AVSValue::*ArraySize)() const;\n// end class AVSValue\n\n/**********************************************************************/\n  // Reserve pointer space so that we can keep compatibility with Avs \"classic\" even if it adds functions on its own\n  void    (VideoInfo::*reserved[32])();\n/**********************************************************************/\n  // AviSynth+ additions\n  int     (VideoInfo::*NumComponents)() const;\n  int     (VideoInfo::*ComponentSize)() const;\n  int     (VideoInfo::*BitsPerComponent)() const;\n  bool    (VideoInfo::*Is444)() const;\n  bool    (VideoInfo::*Is422)() const;\n  bool    (VideoInfo::*Is420)() const;\n  bool    (VideoInfo::*IsY)() const;\n  bool    (VideoInfo::*IsRGB48)() const;\n  bool    (VideoInfo::*IsRGB64)() const;\n  bool    (VideoInfo::*IsYUVA)() const;\n  bool    (VideoInfo::*IsPlanarRGB)() const;\n  bool    (VideoInfo::*IsPlanarRGBA)() const;\n  /**********************************************************************/\n\n  // frame property access\n  AVSMap& (VideoFrame::* getProperties)();\n  const AVSMap& (VideoFrame::* getConstProperties)();\n  void (VideoFrame::* setProperties)(const AVSMap& properties);\n\n  // PFunction\n  void          (AVSValue::* AVSValue_CONSTRUCTOR11)(const PFunction& o);\n  bool          (AVSValue::* IsFunction)() const;\n  void          (PFunction::* PFunction_CONSTRUCTOR0)();\n  void          (PFunction::* PFunction_CONSTRUCTOR1)(IFunction* p);\n  void          (PFunction::* PFunction_CONSTRUCTOR2)(const PFunction& p);\n  PFunction&    (PFunction::* PFunction_OPERATOR_ASSIGN0)(IFunction* other);\n  PFunction&    (PFunction::* PFunction_OPERATOR_ASSIGN1)(const PFunction& other);\n  void          (PFunction::* PFunction_DESTRUCTOR)();\n  // end PFunction\n\n  // extra VideoFrame functions\n  int           (VideoFrame::* VideoFrame_CheckMemory)() const;\n  PDevice       (VideoFrame::* VideoFrame_GetDevice)() const;\n\n  // class PDevice, even if only CPU device\n  void          (PDevice::* PDevice_CONSTRUCTOR0)();\n  void          (PDevice::* PDevice_CONSTRUCTOR1)(Device* p);\n  void          (PDevice::* PDevice_CONSTRUCTOR2)(const PDevice& p);\n  PDevice&      (PDevice::* PDevice_OPERATOR_ASSIGN0)(Device* other);\n  PDevice&      (PDevice::* PDevice_OPERATOR_ASSIGN1)(const PDevice& other);\n  void          (PDevice::* PDevice_DESTRUCTOR)();\n  AvsDeviceType (PDevice::* PDevice_GetType)() const;\n  int           (PDevice::* PDevice_GetId)() const;\n  int           (PDevice::* PDevice_GetIndex)() const;\n  const char*   (PDevice::* PDevice_GetName)() const;\n  // end class PDevice\n\n  // V9: VideoFrame helper\n  bool          (VideoFrame::*IsPropertyWritable)() const;\n\n  // V10\n  int           (VideoFrame::*VideoFrame_GetPixelType)() const;\n  void          (VideoFrame::*VideoFrame_AmendPixelType)(int new_pixel_type);\n  void          (VideoFrameBuffer::*VideoFrameBuffer_DESTRUCTOR)();\n  AvsValueType  (AVSValue::*AVSValue_GetType)() const;\n\n  // V10.1\n  bool          (VideoInfo::* IsChannelMaskKnown)() const;\n  void          (VideoInfo::* SetChannelMask)(bool isChannelMaskKnown, unsigned int dwChannelMask);\n  unsigned int  (VideoInfo::* GetChannelMask)() const;\n\n  /**********************************************************************/\n  // Reserve pointer space for Avisynth+\n  void          (VideoInfo::* reserved2[64 - 31])();\n  /**********************************************************************/\n\n  // AviSynth Neo additions\n  INeoEnv*      (__stdcall *GetNeoEnv)(IScriptEnvironment* env);\n  // As of V8 most PDevice, PFunction linkage entries are moved to standard avs+ place.\n  /**********************************************************************/\n\n  // This part should be identical with AVS_Linkage entries in interface.cpp\n};\n\n#if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB)\n/* Macro resolution for code inside Avisynth.dll */\n# define AVS_BakedCode(arg) ;\n# define AVS_LinkCall(arg)\n# define AVS_LinkCallV(arg)\n# define AVS_LinkCallOpt(arg, argOpt) AVSLinkCall(arg)\n# define AVS_LinkCallOptDefault(arg, argDefaultValue) AVSLinkCall(arg())\n# define CALL_MEMBER_FN(object,ptrToMember)\n\n#else\n/* Macro resolution for code inside user plugin */\n# ifdef AVS_LINKAGE_DLLIMPORT\nextern __declspec(dllimport) const AVS_Linkage* const AVS_linkage;\n# else\nextern const AVS_Linkage* AVS_linkage;\n# endif\n\n# ifndef offsetof\n#  include <stddef.h>\n# endif\n\n# define AVS_BakedCode(arg) { arg ; }\n# define AVS_LinkCall(arg)  !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ?     0 : (this->*(AVS_linkage->arg))\n# define AVS_LinkCall_Void(arg)  !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ?     (void)0 : (this->*(AVS_linkage->arg))\n# define AVS_LinkCallV(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? *this : (this->*(AVS_linkage->arg))\n// Helper macros for fallback option when a function does not exists\n#define CALL_MEMBER_FN(object,ptrToMember)  ((object)->*(ptrToMember))\n#define AVS_LinkCallOpt(arg, argOpt)  !AVS_linkage ? 0 : \\\n                                      ( offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? \\\n                                        (offsetof(AVS_Linkage, argOpt) >= (size_t)AVS_linkage->Size ? 0 : CALL_MEMBER_FN(this, AVS_linkage->argOpt)() ) : \\\n                                        CALL_MEMBER_FN(this, AVS_linkage->arg)() )\n// AVS_LinkCallOptDefault puts automatically () only after arg\n# define AVS_LinkCallOptDefault(arg, argDefaultValue)  !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? (argDefaultValue) : ((this->*(AVS_linkage->arg))())\n\n#endif\n\nclass PDevice\n{\npublic:\n  PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR0)())\n    PDevice(Device* p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR1)(p))\n    PDevice(const PDevice& p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR2)(p))\n    PDevice& operator=(Device* p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN0)(p))\n    PDevice& operator=(const PDevice& p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN1)(p))\n    ~PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_DESTRUCTOR)())\n\n    int operator!() const { return !e; }\n  operator void*() const { return e; }\n  Device* operator->() const { return e; }\n\n  AvsDeviceType GetType() const AVS_BakedCode(return AVS_LinkCallOptDefault(PDevice_GetType, DEV_TYPE_NONE))\n    int GetId() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetId)())\n    int GetIndex() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetIndex)())\n    const char* GetName() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetName)())\n\nprivate:\n  Device * e;\n\n#ifdef BUILDING_AVSCORE\npublic:\n  void CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void CONSTRUCTOR1(Device* p);\n  void CONSTRUCTOR2(const PDevice& p);\n  PDevice& OPERATOR_ASSIGN0(Device* p);\n  PDevice& OPERATOR_ASSIGN1(const PDevice& p);\n  void DESTRUCTOR();\n#endif\n};\n\n// Unshifted channel mask constants like in WAVEFORMATEXTENSIBLE\n// in AvsImageTypeFlags they are shifted by 4 bits\nenum AvsChannelMask {\n  MASK_SPEAKER_FRONT_LEFT = 0x1,\n  MASK_SPEAKER_FRONT_RIGHT = 0x2,\n  MASK_SPEAKER_FRONT_CENTER = 0x4,\n  MASK_SPEAKER_LOW_FREQUENCY = 0x8,\n  MASK_SPEAKER_BACK_LEFT = 0x10,\n  MASK_SPEAKER_BACK_RIGHT = 0x20,\n  MASK_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40,\n  MASK_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80,\n  MASK_SPEAKER_BACK_CENTER = 0x100,\n  MASK_SPEAKER_SIDE_LEFT = 0x200,\n  MASK_SPEAKER_SIDE_RIGHT = 0x400,\n  MASK_SPEAKER_TOP_CENTER = 0x800,\n  MASK_SPEAKER_TOP_FRONT_LEFT = 0x1000,\n  MASK_SPEAKER_TOP_FRONT_CENTER = 0x2000,\n  MASK_SPEAKER_TOP_FRONT_RIGHT = 0x4000,\n  MASK_SPEAKER_TOP_BACK_LEFT = 0x8000,\n  MASK_SPEAKER_TOP_BACK_CENTER = 0x10000,\n  MASK_SPEAKER_TOP_BACK_RIGHT = 0x20000,\n  // Bit mask locations used up for the above positions\n  MASK_SPEAKER_DEFINED = 0x0003FFFF,\n  // Bit mask locations reserved for future use\n  MASK_SPEAKER_RESERVED = 0x7FFC0000,\n  // Used to specify that any possible permutation of speaker configurations\n  // Due to lack of available bits this one is put differently into image_type\n  MASK_SPEAKER_ALL = 0x80000000\n};\n\nstruct VideoInfo {\n  int width, height;    // width 0 means no video\n  unsigned fps_numerator, fps_denominator;\n  int num_frames;\n  // This is more extensible than previous versions. More properties can be added seamlessly.\n\n  // Colorspace properties.\n  /*\n    Planar match mask  1111.1000.0000.0111.0000.0111.0000.0111\n    Planar signature   10xx.1000.0000.00xx.0000.00xx.00xx.00xx ?\n    Planar signature   10xx.1000.0000.0xxx.0000.00xx.000x.x0xx ? *new\n    Planar filter mask 1111.1111.1111.1111.1111.1111.1110.0111 (typo from old header fixed)\n    \n    pixel_type mapping\n    ==================\n    pixel_type bit-map PIYB.Z000.0???.0SSS.0000.0???.????.????\n            planar YUV            CCC            HHH.000u.vWWW\n         planar RGB(A)            CCC                       AR\n             nonplanar            CCC            000.00wx xyAR\n    Legend\n    ======\n    Planar YUV:\n      Code Bits Remark\n      W    0-2  Planar Width Subsampling bits\n                Use (X+1) & 3 for GetPlaneWidthSubsampling\n                  000 => 1        YV12, YV16, YUV420, YUV422\n                  001 => 2        YV411, YUV9\n                  010 => reserved\n                  011 => 0        YV24, YUV444, RGBP\n                  1xx => reserved\n      v    3    VPlaneFirst YV12, YV16, YV24, YV411, YUV9\n      u    4    UPlaneFirst I420\n      H    7-9  Planar Height Subsampling bits\n                Use ((X>>8)+1) & 3 for GetPlaneHeightSubsampling\n                  000 => 1        YV12, YUV420\n                  001 => 2        YUV9\n                  010 => reserved\n                  011 => 0        YV16, YV24, YV411, YUV422, YUV444, RGBP\n                  1xx => reserved\n    \n    Planar RGB\n     Code Bits Remark\n       R   0   BGR,  (with SSS bits for 8/16 bit/sample or float)\n       A   1   BGRA, (with SSS bits for 8/16 bit/sample or float)\n    \n    \n    Not Planar, Interleaved (I flag)\n    Code Bits Remark\n      R   0   BGR24, and BGRx in future (with SSS bits for 8/16 bit/sample or float)\n      A   1   BGR32, and BGRAx in future (with SSS bits for 8/16 bit/sample or float)\n      y   2   YUY2\n      x   3-4 reserved\n      w   5   Raw32\n    \n    General\n    Code Bits Remark\n      S 16-18 Sample resolution bits\n              000 => 8\n              001 => 16\n              010 => 32 (float)\n              011,100 => reserved\n              101 => 10 bits\n              110 => 12 bits\n              111 => 14 bits\n    for packed RGB(A): only 8 and 16 bits are valid\n    \n    Other YV12 specific (will never be used)\n      C  20-23 Chroma Placement values 0-4; see CS_xxx_CHROMA_PLACEMENT\n    \n    Color family and layout\n                           Packed      Planar               Planar  Planar\n    Code Bits Remark       RGB/RGBA     YUV  YUY2  Y_Grey  RGB/RGBA  YUVA\n      R   0                  1/0         -    0      -       1/0       -\n      A   1                  0/1         -    0      -       0/1       -\n      y   2                   -          -    1      -        0        -\n      Z  27   YUVA            0          0    0      0        1        1\n      B  28   BGR             1          0    0      0        1*       0\n      Y  29   YUV             0          1    1      1        0        0\n      I  30   Interleaved     1          0    1      1        0        0\n      P  31   Planar          0          1    0      1        1        1\n    * Planar RGB plane order: G,B,R(,A)\n  */\n  enum AvsColorFormat {\n    CS_YUVA        = 1 << 27,\n    CS_BGR         = 1 << 28,\n    CS_YUV         = 1 << 29,\n    CS_INTERLEAVED = 1 << 30,\n    CS_PLANAR      = 1 << 31,\n\n    CS_Shift_Sub_Width   =  0,\n    CS_Shift_Sub_Height  =  8,\n    CS_Shift_Sample_Bits = 16,\n\n    CS_Sub_Width_Mask    = 7 << CS_Shift_Sub_Width,\n    CS_Sub_Width_1       = 3 << CS_Shift_Sub_Width, // YV24\n    CS_Sub_Width_2       = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16\n    CS_Sub_Width_4       = 1 << CS_Shift_Sub_Width, // YUV9, YV411\n\n    CS_VPlaneFirst       = 1 << 3, // YV12, YV16, YV24, YV411, YUV9\n    CS_UPlaneFirst       = 1 << 4, // I420\n\n    CS_Sub_Height_Mask   = 7 << CS_Shift_Sub_Height,\n    CS_Sub_Height_1      = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411\n    CS_Sub_Height_2      = 0 << CS_Shift_Sub_Height, // YV12, I420\n    CS_Sub_Height_4      = 1 << CS_Shift_Sub_Height, // YUV9\n\n    CS_Sample_Bits_Mask  = 7 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_8     = 0 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_10    = 5 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_12    = 6 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_14    = 7 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_16    = 1 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_32    = 2 << CS_Shift_Sample_Bits,\n\n    CS_PLANAR_MASK       = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_YUVA\n                           | CS_Sample_Bits_Mask | CS_Sub_Width_Mask | CS_Sub_Height_Mask,\n    CS_PLANAR_FILTER     = ~(CS_VPlaneFirst | CS_UPlaneFirst),\n\n    CS_RGB_TYPE  = 1 << 0,\n    CS_RGBA_TYPE = 1 << 1,\n\n    // Specific colorformats\n    CS_UNKNOWN = 0,\n\n    CS_BGR24 = CS_RGB_TYPE  | CS_BGR | CS_INTERLEAVED,\n    CS_BGR32 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED,\n    CS_YUY2  = 1 << 2 | CS_YUV | CS_INTERLEAVED,\n    //  CS_YV12  = 1 << 3  Reserved\n    //  CS_I420  = 1 << 4  Reserved\n    CS_RAW32 = 1 << 5 | CS_INTERLEAVED,\n\n    //  YV12 must be 0xA0000008. v2.5 Baked API will see all new planar as YV12.\n    //  I420 must be 0xA0000010.\n\n    CS_GENERIC_YUV444  = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_1 | CS_Sub_Height_1,  // 4:4:4 planar\n    CS_GENERIC_YUV422  = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_1,  // 4:2:2 planar\n    CS_GENERIC_YUV420  = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2,  // 4:2:0 planar\n    CS_GENERIC_Y       = CS_PLANAR | CS_INTERLEAVED | CS_YUV,                                     // Y only (4:0:0)\n    CS_GENERIC_RGBP    = CS_PLANAR | CS_BGR | CS_RGB_TYPE,                                        // planar RGB. Though name is RGB but plane order G,B,R\n    CS_GENERIC_RGBAP   = CS_PLANAR | CS_BGR | CS_RGBA_TYPE,                                       // planar RGBA\n    CS_GENERIC_YUVA444 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_1 | CS_Sub_Height_1, // 4:4:4:A planar\n    CS_GENERIC_YUVA422 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_1, // 4:2:2:A planar\n    CS_GENERIC_YUVA420 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2, // 4:2:0:A planar\n\n    CS_YV24  = CS_GENERIC_YUV444 | CS_Sample_Bits_8,  // YVU 4:4:4 planar\n    CS_YV16  = CS_GENERIC_YUV422 | CS_Sample_Bits_8,  // YVU 4:2:2 planar\n    CS_YV12  = CS_GENERIC_YUV420 | CS_Sample_Bits_8,  // YVU 4:2:0 planar\n    CS_I420  = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2,  // YUV 4:2:0 planar\n    CS_IYUV  = CS_I420,\n    CS_YUV9  = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Width_4 | CS_Sub_Height_4,  // YUV 4:1:0 planar\n    CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Width_4 | CS_Sub_Height_1,  // YUV 4:1:1 planar\n\n    CS_Y8    = CS_GENERIC_Y | CS_Sample_Bits_8,                                                            // Y   4:0:0 planar\n\n    //-------------------------\n    // AVS16: new planar constants go live! Experimental PF 160613\n    // 10-12-14 bit + planar RGB + BRG48/64 160725\n\n    CS_YUV444P10 = CS_GENERIC_YUV444 | CS_Sample_Bits_10, // YUV 4:4:4 10bit samples\n    CS_YUV422P10 = CS_GENERIC_YUV422 | CS_Sample_Bits_10, // YUV 4:2:2 10bit samples\n    CS_YUV420P10 = CS_GENERIC_YUV420 | CS_Sample_Bits_10, // YUV 4:2:0 10bit samples\n    CS_Y10 = CS_GENERIC_Y | CS_Sample_Bits_10,            // Y   4:0:0 10bit samples\n\n    CS_YUV444P12 = CS_GENERIC_YUV444 | CS_Sample_Bits_12, // YUV 4:4:4 12bit samples\n    CS_YUV422P12 = CS_GENERIC_YUV422 | CS_Sample_Bits_12, // YUV 4:2:2 12bit samples\n    CS_YUV420P12 = CS_GENERIC_YUV420 | CS_Sample_Bits_12, // YUV 4:2:0 12bit samples\n    CS_Y12 = CS_GENERIC_Y | CS_Sample_Bits_12,            // Y   4:0:0 12bit samples\n\n    CS_YUV444P14 = CS_GENERIC_YUV444 | CS_Sample_Bits_14, // YUV 4:4:4 14bit samples\n    CS_YUV422P14 = CS_GENERIC_YUV422 | CS_Sample_Bits_14, // YUV 4:2:2 14bit samples\n    CS_YUV420P14 = CS_GENERIC_YUV420 | CS_Sample_Bits_14, // YUV 4:2:0 14bit samples\n    CS_Y14 = CS_GENERIC_Y | CS_Sample_Bits_14,            // Y   4:0:0 14bit samples\n\n    CS_YUV444P16 = CS_GENERIC_YUV444 | CS_Sample_Bits_16, // YUV 4:4:4 16bit samples\n    CS_YUV422P16 = CS_GENERIC_YUV422 | CS_Sample_Bits_16, // YUV 4:2:2 16bit samples\n    CS_YUV420P16 = CS_GENERIC_YUV420 | CS_Sample_Bits_16, // YUV 4:2:0 16bit samples\n    CS_Y16 = CS_GENERIC_Y | CS_Sample_Bits_16,            // Y   4:0:0 16bit samples\n\n    // 32 bit samples (float)\n    CS_YUV444PS = CS_GENERIC_YUV444 | CS_Sample_Bits_32,  // YUV 4:4:4 32bit samples\n    CS_YUV422PS = CS_GENERIC_YUV422 | CS_Sample_Bits_32,  // YUV 4:2:2 32bit samples\n    CS_YUV420PS = CS_GENERIC_YUV420 | CS_Sample_Bits_32,  // YUV 4:2:0 32bit samples\n    CS_Y32 = CS_GENERIC_Y | CS_Sample_Bits_32,            // Y   4:0:0 32bit samples\n\n    // RGB packed\n    CS_BGR48 = CS_RGB_TYPE  | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 3x16 bit\n    CS_BGR64 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 4x16 bit\n    // no packed 32 bit (float) support for these legacy types\n\n    // RGB planar\n    CS_RGBP   = CS_GENERIC_RGBP | CS_Sample_Bits_8,  // Planar RGB 8 bit samples\n    CS_RGBP8  = CS_GENERIC_RGBP | CS_Sample_Bits_8,  // Planar RGB 8 bit samples\n    CS_RGBP10 = CS_GENERIC_RGBP | CS_Sample_Bits_10, // Planar RGB 10bit samples\n    CS_RGBP12 = CS_GENERIC_RGBP | CS_Sample_Bits_12, // Planar RGB 12bit samples\n    CS_RGBP14 = CS_GENERIC_RGBP | CS_Sample_Bits_14, // Planar RGB 14bit samples\n    CS_RGBP16 = CS_GENERIC_RGBP | CS_Sample_Bits_16, // Planar RGB 16bit samples\n    CS_RGBPS  = CS_GENERIC_RGBP | CS_Sample_Bits_32, // Planar RGB 32bit samples\n\n    // RGBA planar\n    CS_RGBAP   = CS_GENERIC_RGBAP | CS_Sample_Bits_8,  // Planar RGBA 8 bit samples\n    CS_RGBAP8  = CS_GENERIC_RGBAP | CS_Sample_Bits_8,  // Planar RGBA 8 bit samples\n    CS_RGBAP10 = CS_GENERIC_RGBAP | CS_Sample_Bits_10, // Planar RGBA 10bit samples\n    CS_RGBAP12 = CS_GENERIC_RGBAP | CS_Sample_Bits_12, // Planar RGBA 12bit samples\n    CS_RGBAP14 = CS_GENERIC_RGBAP | CS_Sample_Bits_14, // Planar RGBA 14bit samples\n    CS_RGBAP16 = CS_GENERIC_RGBAP | CS_Sample_Bits_16, // Planar RGBA 16bit samples\n    CS_RGBAPS  = CS_GENERIC_RGBAP | CS_Sample_Bits_32, // Planar RGBA 32bit samples\n\n    // Planar YUVA\n    CS_YUVA444    = CS_GENERIC_YUVA444 | CS_Sample_Bits_8,  // YUVA 4:4:4 8bit samples\n    CS_YUVA422    = CS_GENERIC_YUVA422 | CS_Sample_Bits_8,  // YUVA 4:2:2 8bit samples\n    CS_YUVA420    = CS_GENERIC_YUVA420 | CS_Sample_Bits_8,  // YUVA 4:2:0 8bit samples\n\n    CS_YUVA444P10 = CS_GENERIC_YUVA444 | CS_Sample_Bits_10, // YUVA 4:4:4 10bit samples\n    CS_YUVA422P10 = CS_GENERIC_YUVA422 | CS_Sample_Bits_10, // YUVA 4:2:2 10bit samples\n    CS_YUVA420P10 = CS_GENERIC_YUVA420 | CS_Sample_Bits_10, // YUVA 4:2:0 10bit samples\n\n    CS_YUVA444P12 = CS_GENERIC_YUVA444 | CS_Sample_Bits_12, // YUVA 4:4:4 12bit samples\n    CS_YUVA422P12 = CS_GENERIC_YUVA422 | CS_Sample_Bits_12, // YUVA 4:2:2 12bit samples\n    CS_YUVA420P12 = CS_GENERIC_YUVA420 | CS_Sample_Bits_12, // YUVA 4:2:0 12bit samples\n\n    CS_YUVA444P14 = CS_GENERIC_YUVA444 | CS_Sample_Bits_14, // YUVA 4:4:4 14bit samples\n    CS_YUVA422P14 = CS_GENERIC_YUVA422 | CS_Sample_Bits_14, // YUVA 4:2:2 14bit samples\n    CS_YUVA420P14 = CS_GENERIC_YUVA420 | CS_Sample_Bits_14, // YUVA 4:2:0 14bit samples\n\n    CS_YUVA444P16 = CS_GENERIC_YUVA444 | CS_Sample_Bits_16, // YUVA 4:4:4 16bit samples\n    CS_YUVA422P16 = CS_GENERIC_YUVA422 | CS_Sample_Bits_16, // YUVA 4:2:2 16bit samples\n    CS_YUVA420P16 = CS_GENERIC_YUVA420 | CS_Sample_Bits_16, // YUVA 4:2:0 16bit samples\n\n    CS_YUVA444PS  = CS_GENERIC_YUVA444 | CS_Sample_Bits_32,  // YUVA 4:4:4 32bit samples\n    CS_YUVA422PS  = CS_GENERIC_YUVA422 | CS_Sample_Bits_32,  // YUVA 4:2:2 32bit samples\n    CS_YUVA420PS  = CS_GENERIC_YUVA420 | CS_Sample_Bits_32,  // YUVA 4:2:0 32bit samples\n  };\n\n  int pixel_type;                // changed to int as of 2.5\n\n  int audio_samples_per_second;   // 0 means no audio\n  int sample_type;                // as of 2.5\n  int64_t num_audio_samples;      // changed as of 2.5\n  int nchannels;                  // as of 2.5\n\n  // BFF, TFF, FIELDBASED. Also used for storing Channel Mask\n  int image_type;\n\n  enum AvsImageTypeFlags {\n    IT_BFF = 1 << 0,\n    IT_TFF = 1 << 1,\n    IT_FIELDBASED = 1 << 2,\n\n    // Audio channel mask support\n    IT_HAS_CHANNELMASK = 1 << 3,\n    // shifted by 4 bits compared to WAVEFORMATEXTENSIBLE dwChannelMask\n    // otherwise same as AvsChannelMask\n    IT_SPEAKER_FRONT_LEFT = 0x1 << 4,\n    IT_SPEAKER_FRONT_RIGHT = 0x2 << 4,\n    IT_SPEAKER_FRONT_CENTER = 0x4 << 4,\n    IT_SPEAKER_LOW_FREQUENCY = 0x8 << 4,\n    IT_SPEAKER_BACK_LEFT = 0x10 << 4,\n    IT_SPEAKER_BACK_RIGHT = 0x20 << 4,\n    IT_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40 << 4,\n    IT_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80 << 4,\n    IT_SPEAKER_BACK_CENTER = 0x100 << 4,\n    IT_SPEAKER_SIDE_LEFT = 0x200 << 4,\n    IT_SPEAKER_SIDE_RIGHT = 0x400 << 4,\n    IT_SPEAKER_TOP_CENTER = 0x800 << 4,\n    IT_SPEAKER_TOP_FRONT_LEFT = 0x1000 << 4,\n    IT_SPEAKER_TOP_FRONT_CENTER = 0x2000 << 4,\n    IT_SPEAKER_TOP_FRONT_RIGHT = 0x4000 << 4,\n    IT_SPEAKER_TOP_BACK_LEFT = 0x8000 << 4,\n    IT_SPEAKER_TOP_BACK_CENTER = 0x10000 << 4,\n    IT_SPEAKER_TOP_BACK_RIGHT = 0x20000 << 4,\n    // End of officially defined speaker bits\n    // The next one is special, since cannot shift SPEAKER_ALL 0x80000000 further.\n    // Set mask and get mask handles it.\n    IT_SPEAKER_ALL = 0x40000 << 4,\n    // Mask for the defined 18 bits + SPEAKER_ALL\n    IT_SPEAKER_BITS_MASK = (AvsChannelMask::MASK_SPEAKER_DEFINED << 4) | IT_SPEAKER_ALL,\n    IT_NEXT_AVAILABLE = 1 << 23\n  };\n\n  // Chroma placement bits 20 -> 23  ::FIXME:: Really want a Class to support this\n  enum AvsChromaPlacement {\n    CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20,\n    CS_MPEG1_CHROMA_PLACEMENT   = 1 << 20,\n    CS_MPEG2_CHROMA_PLACEMENT   = 2 << 20,\n    CS_YUY2_CHROMA_PLACEMENT    = 3 << 20,\n    CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20\n  };\n\n  // useful functions of the above\n  bool HasVideo() const AVS_BakedCode(return AVS_LinkCall(HasVideo)())\n  bool HasAudio() const AVS_BakedCode(return AVS_LinkCall(HasAudio)())\n  bool IsRGB() const AVS_BakedCode(return AVS_LinkCall(IsRGB)())\n  bool IsRGB24() const AVS_BakedCode(return AVS_LinkCall(IsRGB24)())\n  bool IsRGB32() const AVS_BakedCode(return AVS_LinkCall(IsRGB32)())\n  bool IsYUV() const AVS_BakedCode(return AVS_LinkCall(IsYUV)())\n  bool IsYUY2() const AVS_BakedCode(return AVS_LinkCall(IsYUY2)())\n\n  bool IsYV24()  const AVS_BakedCode(return AVS_LinkCall(IsYV24)())\n  bool IsYV16()  const AVS_BakedCode(return AVS_LinkCall(IsYV16)())\n  bool IsYV12()  const AVS_BakedCode(return AVS_LinkCall(IsYV12)())\n  bool IsYV411() const AVS_BakedCode(return AVS_LinkCall(IsYV411)())\n  //bool IsYUV9()  const;\n  bool IsY8()    const AVS_BakedCode(return AVS_LinkCall(IsY8)())\n\n  bool IsColorSpace(int c_space) const AVS_BakedCode(return AVS_LinkCall(IsColorSpace)(c_space))\n\n  bool Is(int property) const AVS_BakedCode(return AVS_LinkCall(Is)(property))\n  bool IsPlanar() const AVS_BakedCode(return AVS_LinkCall(IsPlanar)())\n  bool IsFieldBased() const AVS_BakedCode(return AVS_LinkCall(IsFieldBased)())\n  bool IsParityKnown() const AVS_BakedCode(return AVS_LinkCall(IsParityKnown)())\n  bool IsBFF() const AVS_BakedCode(return AVS_LinkCall(IsBFF)())\n  bool IsTFF() const AVS_BakedCode(return AVS_LinkCall(IsTFF)())\n\n  bool IsVPlaneFirst() const AVS_BakedCode(return AVS_LinkCall(IsVPlaneFirst)())  // Don't use this\n  // Will not work on planar images, but will return only luma planes\n  int BytesFromPixels(int pixels) const AVS_BakedCode(return AVS_LinkCall(BytesFromPixels)(pixels))\n  int RowSize(int plane = DEFAULT_PLANE) const AVS_BakedCode(return AVS_LinkCall(RowSize)(plane))\n  int BMPSize() const AVS_BakedCode(return AVS_LinkCall(BMPSize)())\n\n  int64_t AudioSamplesFromFrames(int frames) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromFrames)(frames))\n  int FramesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(FramesFromAudioSamples)(samples))\n  int64_t AudioSamplesFromBytes(int64_t bytes) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromBytes)(bytes))\n  int64_t BytesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(BytesFromAudioSamples)(samples))\n  int AudioChannels() const AVS_BakedCode(return AVS_LinkCall(AudioChannels)())\n  int SampleType() const AVS_BakedCode(return AVS_LinkCall(SampleType)())\n  bool IsSampleType(int testtype) const AVS_BakedCode(return AVS_LinkCall(IsSampleType)(testtype))\n  int SamplesPerSecond() const AVS_BakedCode(return AVS_LinkCall(SamplesPerSecond)())\n  int BytesPerAudioSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerAudioSample)())\n  void SetFieldBased(bool isfieldbased) AVS_BakedCode(AVS_LinkCall_Void(SetFieldBased)(isfieldbased))\n  void Set(int property) AVS_BakedCode(AVS_LinkCall_Void(Set)(property))\n  void Clear(int property) AVS_BakedCode(AVS_LinkCall_Void(Clear)(property))\n  // Subsampling in bitshifts!\n  int GetPlaneWidthSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneWidthSubsampling)(plane))\n  int GetPlaneHeightSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneHeightSubsampling)(plane))\n  int BitsPerPixel() const AVS_BakedCode(return AVS_LinkCall(BitsPerPixel)())\n\n  int BytesPerChannelSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerChannelSample)())\n\n  // useful mutator\n  void SetFPS(unsigned numerator, unsigned denominator) AVS_BakedCode(AVS_LinkCall_Void(SetFPS)(numerator, denominator))\n\n  // Range protected multiply-divide of FPS\n  void MulDivFPS(unsigned multiplier, unsigned divisor) AVS_BakedCode(AVS_LinkCall_Void(MulDivFPS)(multiplier, divisor))\n\n  // Test for same colorspace\n  bool IsSameColorspace(const VideoInfo& vi) const AVS_BakedCode(return AVS_LinkCall(IsSameColorspace)(vi))\n\n  // AVS+ extensions\n  // 20161005:\n  //   Mapping of AVS+ extensions to classic 2.6 functions.\n  //   In order to use these extended AVS+ functions for plugins that should work\n  //   either with AVS+ or with Classic (8 bit) Avs 2.6 ans earlier AVS+ versions, there is an\n  //   automatic fallback mechanism.\n  //   From AVS+'s point of view these are not \"baked\" codes, the primary functions should exist.\n  //   Examples:\n  //   Is444() is mapped to IsYV24() for classic AVS2.6\n  //   ComponentSize() returns constant 1 (1 bytes per pixel component)\n  //   BitsPerComponent() returns constant 8 (Classic AVS2.6 is 8 bit only)\n\n  // Returns the number of color channels or planes in a frame\n  int NumComponents() const AVS_BakedCode(return AVS_LinkCallOptDefault(NumComponents, (((AVS_LinkCall(IsYUV)()) && !(AVS_LinkCall(IsY8)())) ? 3 : AVS_LinkCall(BytesFromPixels)(1)) ) )\n\n  // Returns the size in bytes of a single component of a pixel\n  int ComponentSize() const AVS_BakedCode(return AVS_LinkCallOptDefault(ComponentSize, 1))\n\n  // Returns the bit depth of a single component of a pixel\n  int BitsPerComponent() const AVS_BakedCode(return AVS_LinkCallOptDefault(BitsPerComponent, 8))\n\n  // like IsYV24, but bit-depth independent also for YUVA\n  bool Is444() const AVS_BakedCode(return AVS_LinkCallOpt(Is444, IsYV24) )\n\n  // like IsYV16, but bit-depth independent also for YUVA\n  bool Is422() const AVS_BakedCode(return AVS_LinkCallOpt(Is422, IsYV16) )\n\n  // like IsYV12, but bit-depth independent also for YUVA\n  bool Is420() const AVS_BakedCode( return AVS_LinkCallOpt(Is420, IsYV12) )\n\n  // like IsY8, but bit-depth independent\n  bool IsY()   const AVS_BakedCode( return AVS_LinkCallOpt(IsY, IsY8) )\n\n  // like IsRGB24 for 16 bit samples\n  bool IsRGB48() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB48, false) )\n\n  // like IsRGB32 for 16 bit samples\n  bool IsRGB64() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB64, false) )\n\n  // YUVA?\n  bool IsYUVA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsYUVA, false) )\n\n  // Planar RGB?\n  bool IsPlanarRGB() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGB, false) )\n\n  // Planar RGBA?\n  bool IsPlanarRGBA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGBA, false) )\n\n  // v10.1 interface: audio channel masks\n  bool IsChannelMaskKnown() const AVS_BakedCode(return AVS_LinkCallOptDefault(IsChannelMaskKnown, false) )\n  void SetChannelMask(bool isChannelMaskKnown, unsigned int dwChannelMask) AVS_BakedCode(AVS_LinkCall_Void(SetChannelMask)(isChannelMaskKnown, dwChannelMask))\n  unsigned int GetChannelMask() const AVS_BakedCode(return AVS_LinkCallOptDefault(GetChannelMask, 0) )\n\n}; // end struct VideoInfo\n\n\n\n\n// VideoFrameBuffer holds information about a memory block which is used\n// for video data.  For efficiency, instances of this class are not deleted\n// when the refcount reaches zero; instead they're stored in a linked list\n// to be reused.  The instances are deleted when the corresponding AVS\n// file is closed.\n\nclass VideoFrameBuffer {\n  BYTE* data;\n  int data_size;\n  // sequence_number is incremented every time the buffer is changed, so\n  // that stale views can tell they're no longer valid.\n  volatile long sequence_number;\n\n  friend class VideoFrame;\n  friend class Cache;\n  friend class ScriptEnvironment;\n  volatile long refcount;\n\n  // AVS+CUDA extension, does not break plugins if appended here\n  Device* device;\n\nprotected:\n  VideoFrameBuffer(int size, int margin, Device* device);\n  VideoFrameBuffer();\n\npublic:\n  ~VideoFrameBuffer() AVS_BakedCode(AVS_LinkCall_Void(VideoFrameBuffer_DESTRUCTOR)())\n\n  const BYTE* GetReadPtr() const AVS_BakedCode( return AVS_LinkCall(VFBGetReadPtr)() )\n  BYTE* GetWritePtr() AVS_BakedCode( return AVS_LinkCall(VFBGetWritePtr)() )\n  int GetDataSize() const AVS_BakedCode( return AVS_LinkCall(GetDataSize)() )\n  int GetSequenceNumber() const AVS_BakedCode( return AVS_LinkCall(GetSequenceNumber)() )\n  int GetRefcount() const AVS_BakedCode( return AVS_LinkCall(GetRefcount)() )\n\n// Ensure VideoFrameBuffer cannot be publicly assigned\nprivate:\n  VideoFrameBuffer& operator=(const VideoFrameBuffer&);\n\n#ifdef BUILDING_AVSCORE\npublic:\n    void DESTRUCTOR();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n#endif\n}; // end class VideoFrameBuffer\n\n\n// smart pointer to VideoFrame\nclass PVideoFrame {\n\n  VideoFrame* p;\n\n  void Init(VideoFrame* x);\n  void Set(VideoFrame* x);\n\npublic:\n  PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR0)())\n    PVideoFrame(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR1)(x))\n    PVideoFrame(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR2)(x))\n    void operator=(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN0)(x))\n    void operator=(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN1)(x))\n\n    VideoFrame* operator->() const { return p; }\n\n  // for conditional expressions\n  operator void*() const { return p; }\n  bool operator!() const { return !p; }\n\n  ~PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_DESTRUCTOR)())\n#ifdef BUILDING_AVSCORE\npublic:\n  void CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void CONSTRUCTOR1(const PVideoFrame& x);\n  void CONSTRUCTOR2(VideoFrame* x);\n  void OPERATOR_ASSIGN0(VideoFrame* x);\n  void OPERATOR_ASSIGN1(const PVideoFrame& x);\n  void DESTRUCTOR();\n#endif\n}; // end class PVideoFrame\n\n\n// VideoFrame holds a \"window\" into a VideoFrameBuffer.  Operator new\n// is overloaded to recycle class instances.\n\nclass VideoFrame {\n  volatile long refcount;\n  VideoFrameBuffer* vfb;\n\n  // Due to technical reasons these members are not const, but should be treated as such.\n  // That means do not modify them once the class has been constructed.\n  int offset;\n  int pitch, row_size, height;\n  int offsetU, offsetV;  // U&V offsets are from top of picture.\n  int pitchUV, row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane.\n                            // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable)\n                            // the decision on existance of UV is checked by zero pitch\n  // AVS+ extension, does not break plugins if appended here\n  int offsetA;\n  int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none\n\n  AVSMap *properties;\n\n  // this one is changable by AmendPixelType in rare cases\n  int pixel_type; // V10 - Copy from VideoInfo\n\n  friend class PVideoFrame;\n  void AddRef();\n  void Release();\n\n  friend class ScriptEnvironment;\n  friend class Cache;\n\n  VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _pixel_type);\n  VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _pixel_type);\n  // for Alpha\n  VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _offsetA, int _pixel_type);\n  void* operator new(size_t size);\n// TESTME: OFFSET U/V may be switched to what could be expected from AVI standard!\npublic:\n  int GetPitch(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetPitch)(plane) )\n  int GetRowSize(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetRowSize)(plane) )\n  int GetHeight(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetHeight)(plane) )\n\n  // generally you shouldn't use these three\n  VideoFrameBuffer* GetFrameBuffer() const AVS_BakedCode( return AVS_LinkCall(GetFrameBuffer)() )\n  int GetOffset(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetOffset)(plane) )\n\n  // in plugins use env->SubFrame() -- because implementation code is only available inside avisynth.dll. Doh!\n  VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height) const;\n  VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV) const;\n  // for Alpha\n  VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV, int rel_offsetA) const;\n\n  const BYTE* GetReadPtr(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(VFGetReadPtr)(plane) )\n  bool IsWritable() const AVS_BakedCode( return AVS_LinkCall(IsWritable)() )\n  BYTE* GetWritePtr(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(VFGetWritePtr)(plane) )\n\n  AVSMap& getProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getProperties, (AVSMap&)*(AVSMap*)0))\n  const AVSMap& getConstProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getConstProperties, (const AVSMap&)*(const AVSMap*)0))\n  void setProperties(const AVSMap & _properties) AVS_BakedCode(AVS_LinkCall_Void(setProperties)(_properties))\n\n  PDevice GetDevice() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetDevice)())\n\n  // 0: OK, 1: NG, -1: disabled or non CPU frame\n  int CheckMemory() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_CheckMemory)())\n\n  bool IsPropertyWritable() const AVS_BakedCode(return AVS_LinkCall(IsPropertyWritable)())\n\n  ~VideoFrame() AVS_BakedCode( AVS_LinkCall_Void(VideoFrame_DESTRUCTOR)() )\n\n  int GetPixelType() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetPixelType)())\n  // Changes the color format metadata on this frame. Using it on a frame that isn't writable leads\n  // to an inconsistent state, because other filters depend on it. So, use MakeWritable() before.\n  // Only for rare cases where a plugin makes frame bytes pose as another color format.\n  void AmendPixelType(int new_pixel_type) AVS_BakedCode(return AVS_LinkCall_Void(VideoFrame_AmendPixelType)(new_pixel_type))\n\n#ifdef BUILDING_AVSCORE\npublic:\n  void DESTRUCTOR();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n#endif\n\n// Ensure VideoFrame cannot be publicly assigned\nprivate:\n    VideoFrame& operator=(const VideoFrame&);\n\n}; // end class VideoFrame\n\nenum CachePolicyHint {\n  // Values 0 to 5 are reserved for old 2.5 plugins\n  // do not use them in new plugins\n\n  // New 2.6 explicitly defined cache hints.\n  CACHE_NOTHING = 10, // Do not cache video.\n  CACHE_WINDOW = 11, // Hard protect upto X frames within a range of X from the current frame N.\n  CACHE_GENERIC = 12, // LRU cache upto X frames.\n  CACHE_FORCE_GENERIC = 13, // LRU cache upto X frames, override any previous CACHE_WINDOW.\n\n  CACHE_GET_POLICY = 30, // Get the current policy.\n  CACHE_GET_WINDOW = 31, // Get the current window h_span.\n  CACHE_GET_RANGE = 32, // Get the current generic frame range.\n\n  // Set Audio cache mode and answers to CACHE_GETCHILD_AUDIO_MODE\n  CACHE_AUDIO = 50, // Explicitly cache audio, X byte cache.\n  CACHE_AUDIO_NOTHING = 51, // Explicitly do not cache audio.\n  CACHE_AUDIO_NONE = 52, // Audio cache off (auto mode), X byte initial cache.\n  CACHE_AUDIO_AUTO_START_OFF = 52, // synonym\n  CACHE_AUDIO_AUTO = 53, // Audio cache on (auto mode), X byte initial cache.\n  CACHE_AUDIO_AUTO_START_ON = 53, // synonym\n\n  // These just returns actual value if clip is cached\n  CACHE_GET_AUDIO_POLICY = 70, // Get the current audio policy.\n  CACHE_GET_AUDIO_SIZE = 71, // Get the current audio cache size.\n\n  CACHE_PREFETCH_FRAME = 100, // n/a Queue request to prefetch frame N.\n  CACHE_PREFETCH_GO = 101, // n/a Action video prefetches.\n\n  CACHE_PREFETCH_AUDIO_BEGIN = 120, // n/a Begin queue request transaction to prefetch audio (take critical section).\n  CACHE_PREFETCH_AUDIO_STARTLO = 121, // n/a Set low 32 bits of start.\n  CACHE_PREFETCH_AUDIO_STARTHI = 122, // n/a Set high 32 bits of start.\n  CACHE_PREFETCH_AUDIO_COUNT = 123, // n/a Set low 32 bits of length.\n  CACHE_PREFETCH_AUDIO_COMMIT = 124, // n/a Enqueue request transaction to prefetch audio (release critical section).\n  CACHE_PREFETCH_AUDIO_GO = 125, // n/a Action audio prefetches.\n\n  CACHE_GETCHILD_CACHE_MODE = 200, // n/a Cache ask Child for desired video cache mode.\n  CACHE_GETCHILD_CACHE_SIZE = 201, // n/a Cache ask Child for desired video cache size.\n\n  // Filters are queried about their desired audio cache mode.\n  // Child can answer them with CACHE_AUDIO_xxx\n  CACHE_GETCHILD_AUDIO_MODE = 202, // Cache ask Child for desired audio cache mode.\n  CACHE_GETCHILD_AUDIO_SIZE = 203, // Cache ask Child for desired audio cache size.\n\n  CACHE_GETCHILD_COST = 220, // n/a Cache ask Child for estimated processing cost.\n    CACHE_COST_ZERO = 221, // n/a Child response of zero cost (ptr arithmetic only).\n    CACHE_COST_UNIT = 222, // n/a Child response of unit cost (less than or equal 1 full frame blit).\n    CACHE_COST_LOW = 223, // n/a Child response of light cost. (Fast)\n    CACHE_COST_MED = 224, // n/a Child response of medium cost. (Real time)\n    CACHE_COST_HI = 225, // n/a Child response of heavy cost. (Slow)\n\n  CACHE_GETCHILD_THREAD_MODE = 240, // n/a Cache ask Child for thread safetyness.\n    CACHE_THREAD_UNSAFE = 241, // n/a Only 1 thread allowed for all instances. 2.5 filters default!\n    CACHE_THREAD_CLASS = 242, // n/a Only 1 thread allowed for each instance. 2.6 filters default!\n    CACHE_THREAD_SAFE = 243, // n/a Allow all threads in any instance.\n    CACHE_THREAD_OWN = 244, // n/a Safe but limit to 1 thread, internally threaded.\n\n  CACHE_GETCHILD_ACCESS_COST = 260, // n/a Cache ask Child for preferred access pattern.\n    CACHE_ACCESS_RAND = 261, // n/a Filter is access order agnostic.\n    CACHE_ACCESS_SEQ0 = 262, // n/a Filter prefers sequential access (low cost)\n    CACHE_ACCESS_SEQ1 = 263, // n/a Filter needs sequential access (high cost)\n\n  CACHE_AVSPLUS_CONSTANTS = 500,    // Smaller values are reserved for classic Avisynth\n\n  CACHE_DONT_CACHE_ME,              // Filters that don't need caching (eg. trim, cache etc.) should return 1 to this request\n  CACHE_SET_MIN_CAPACITY,\n  CACHE_SET_MAX_CAPACITY,\n  CACHE_GET_MIN_CAPACITY,\n  CACHE_GET_MAX_CAPACITY,\n  CACHE_GET_SIZE,\n  CACHE_GET_REQUESTED_CAP,\n  CACHE_GET_CAPACITY,\n  CACHE_GET_MTMODE,                 // Filters specify their desired MT mode, see enum MtMode\n\n  // By returning IS_CACHE_ANS to IS_CACHE_REQ, we tell the caller we are a cache\n  CACHE_IS_CACHE_REQ,\n  CACHE_IS_CACHE_ANS,\n  // By returning IS_MTGUARD_ANS to IS_MTGUARD_REQ, we tell the caller we are an mt guard\n  CACHE_IS_MTGUARD_REQ,\n  CACHE_IS_MTGUARD_ANS,\n\n  CACHE_AVSPLUS_CUDA_CONSTANTS = 600,\n\n  CACHE_GET_DEV_TYPE,          // Device types a filter can return\n  CACHE_GET_CHILD_DEV_TYPE,    // Device types a filter can receive\n\n  CACHE_USER_CONSTANTS = 1000       // Smaller values are reserved for the core\n};\n\n// Base class for all filters.\nclass IClip {\n  friend class PClip;\n  friend class AVSValue;\n  volatile long refcnt;\n  void AddRef();\n#if BUILDING_AVSCORE\npublic:\n#endif\n  void Release();\npublic:\n  IClip() : refcnt(0) {}\n  virtual int __stdcall GetVersion() { return AVISYNTH_INTERFACE_VERSION; }\n  virtual PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) = 0;\n  virtual bool __stdcall GetParity(int n) = 0;  // return field parity if field_based, else parity of first field in frame\n  virtual void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) = 0;  // start and count are in samples\n  /* Need to check GetVersion first, pre v5 will return random crap from EAX reg. */\n  virtual int __stdcall SetCacheHints(int cachehints,int frame_range) = 0 ;  // We do not pass cache requests upwards, only to the next filter.\n  virtual const VideoInfo& __stdcall GetVideoInfo() = 0;\n  virtual ~IClip() {}\n}; // end class IClip\n\n\n// smart pointer to IClip\nclass PClip {\n\n  IClip* p;\n\n  IClip* GetPointerWithAddRef() const;\n  friend class AVSValue;\n  friend class VideoFrame;\n\n  void Init(IClip* x);\n  void Set(IClip* x);\n\npublic:\n  PClip() AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR0)() )\n  PClip(const PClip& x) AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR1)(x) )\n  PClip(IClip* x) AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR2)(x) )\n  void operator=(IClip* x) AVS_BakedCode( AVS_LinkCall_Void(PClip_OPERATOR_ASSIGN0)(x) )\n  void operator=(const PClip& x) AVS_BakedCode( AVS_LinkCall_Void(PClip_OPERATOR_ASSIGN1)(x) )\n\n  IClip* operator->() const { return p; }\n\n  // useful in conditional expressions\n  operator void*() const { return p; }\n  bool operator!() const { return !p; }\n\n  ~PClip() AVS_BakedCode( AVS_LinkCall_Void(PClip_DESTRUCTOR)() )\n#ifdef BUILDING_AVSCORE\npublic:\n  void CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void CONSTRUCTOR1(const PClip& x);\n  void CONSTRUCTOR2(IClip* x);\n  void OPERATOR_ASSIGN0(IClip* x);\n  void OPERATOR_ASSIGN1(const PClip& x);\n  void DESTRUCTOR();\n#endif\n}; // end class PClip\n\n// enums for frame property functions\nenum AVSPropTypes {\n  PROPTYPE_UNSET = 'u', // ptUnset\n  PROPTYPE_INT = 'i', // peType\n  PROPTYPE_FLOAT = 'f', // ptFloat\n  PROPTYPE_DATA = 's', // ptData\n  PROPTYPE_CLIP = 'c', // ptClip\n  PROPTYPE_FRAME = 'v' // ptFrame\n  //  ptFunction = 'm'\n};\n\nenum AVSGetPropErrors {\n  GETPROPERROR_UNSET = 1, // peUnset\n  GETPROPERROR_TYPE = 2, // peType\n  GETPROPERROR_INDEX = 4 // peIndex\n};\n\nenum AVSPropAppendMode {\n  PROPAPPENDMODE_REPLACE = 0, // paReplace\n  PROPAPPENDMODE_APPEND = 1, // paAppend\n  PROPAPPENDMODE_TOUCH = 2 // paTouch\n};\n\n\nclass AVSValue {\npublic:\n\n  AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR0)() )\n  AVSValue(IClip* c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR1)(c) )\n  AVSValue(const PClip& c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR2)(c) )\n  AVSValue(bool b) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR3)(b) )\n  AVSValue(int i) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR4)(i) )\n//  AVSValue(int64_t l);\n  AVSValue(float f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR5)(f) )\n  AVSValue(double f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR6)(f) )\n  AVSValue(const char* s) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR7)(s) )\n  AVSValue(const AVSValue* a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(a, size) )\n  AVSValue(const AVSValue& a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(&a, size) )\n  AVSValue(const AVSValue& v) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR9)(v) )\n  AVSValue(const PFunction& n) AVS_BakedCode(AVS_LinkCall_Void(AVSValue_CONSTRUCTOR11)(n))\n\n  ~AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_DESTRUCTOR)() )\n  AVSValue& operator=(const AVSValue& v) AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_ASSIGN)(v) )\n\n  // Note that we transparently allow 'int' to be treated as 'float'.\n  // There are no int<->bool conversions, though.\n\n  bool Defined() const AVS_BakedCode( return AVS_LinkCall(Defined)() )\n  bool IsClip() const AVS_BakedCode( return AVS_LinkCall(IsClip)() )\n  bool IsBool() const AVS_BakedCode( return AVS_LinkCall(IsBool)() )\n  bool IsInt() const AVS_BakedCode( return AVS_LinkCall(IsInt)() )\n//  bool IsLong() const;\n  bool IsFloat() const AVS_BakedCode( return AVS_LinkCall(IsFloat)() )\n  bool IsString() const AVS_BakedCode( return AVS_LinkCall(IsString)() )\n  bool IsArray() const AVS_BakedCode( return AVS_LinkCall(IsArray)() )\n  bool IsFunction() const AVS_BakedCode( return AVS_LinkCall(IsFunction)() )\n\n  PClip AsClip() const AVS_BakedCode( return AVS_LinkCall(AsClip)() )\n  bool AsBool() const AVS_BakedCode( return AVS_LinkCall(AsBool1)() )\n  int AsInt() const AVS_BakedCode( return AVS_LinkCall(AsInt1)() )\n//  int AsLong() const;\n  const char* AsString() const AVS_BakedCode( return AVS_LinkCall(AsString1)() )\n  double AsFloat() const AVS_BakedCode( return AVS_LinkCall(AsFloat1)() )\n  float AsFloatf() const AVS_BakedCode( return float( AVS_LinkCall(AsFloat1)() ) )\n\n  bool AsBool(bool def) const AVS_BakedCode( return AVS_LinkCall(AsBool2)(def) )\n  int AsInt(int def) const AVS_BakedCode( return AVS_LinkCall(AsInt2)(def) )\n  double AsDblDef(double def) const AVS_BakedCode( return AVS_LinkCall(AsDblDef)(def) ) // Value is still a float\n  double AsFloat(float def) const AVS_BakedCode( return AVS_LinkCall(AsFloat2)(def) )\n  float AsFloatf(float def) const AVS_BakedCode( return float( AVS_LinkCall(AsFloat2)(def) ) )\n  const char* AsString(const char* def) const AVS_BakedCode( return AVS_LinkCall(AsString2)(def) )\n  PFunction AsFunction() const; // internal use only\n\n  int ArraySize() const AVS_BakedCode( return AVS_LinkCall(ArraySize)() )\n\n  const AVSValue& operator[](int index) const AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_INDEX)(index) )\n\nprivate:\n\n  short type;  // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, fu'n'ction, or RFU: 'l'ong ('d'ouble)\n  short array_size;\n  union {\n    IClip* clip;\n    bool boolean;\n    int integer;\n    float floating_pt;\n    const char* string;\n    const AVSValue* array;\n    IFunction* function;\n    #ifdef X86_64\n    // if ever, only x64 will support. It breaks struct size on 32 bit\n    int64_t longlong; // 8 bytes\n    double double_pt; // 8 bytes\n    #endif\n  };\n\n  void Assign(const AVSValue* src, bool init);\n\npublic:\n  AvsValueType GetType() const AVS_BakedCode( return AVS_LinkCallOptDefault(AVSValue_GetType, VALUE_TYPE_UNDEFINED) )\n\n#ifdef BUILDING_AVSCORE\npublic:\n  void            CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void            CONSTRUCTOR1(IClip* c);\n  void            CONSTRUCTOR2(const PClip& c);\n  void            CONSTRUCTOR3(bool b);\n  void            CONSTRUCTOR4(int i);\n  void            CONSTRUCTOR5(float f);\n  void            CONSTRUCTOR6(double f);\n  void            CONSTRUCTOR7(const char* s);\n  void            CONSTRUCTOR8(const AVSValue* a, int size);\n  void            CONSTRUCTOR9(const AVSValue& v);\n  void            CONSTRUCTOR11(const PFunction& n);\n  void            DESTRUCTOR();\n  AVSValue&       OPERATOR_ASSIGN(const AVSValue& v);\n  const AVSValue& OPERATOR_INDEX(int index) const;\n\n  bool            AsBool1() const;\n  int             AsInt1() const;\n  const char*     AsString1() const;\n  double          AsFloat1() const;\n\n  bool            AsBool2(bool def) const;\n  int             AsInt2(int def) const;\n  double          AsFloat2(float def) const;\n  const char*     AsString2(const char* def) const;\n\n  void            MarkArrayAsC(); // for C interface, no deep-copy and deep-free\n  void            CONSTRUCTOR10(const AVSValue& v, bool c_arrays);\n  AVSValue(const AVSValue& v, bool c_arrays);\n  void            Assign2(const AVSValue* src, bool init, bool c_arrays);\n\n#endif\n}; // end class AVSValue\n\n#define AVS_UNUSED(x) (void)(x)\n\n// instantiable null filter\nclass GenericVideoFilter : public IClip {\nprotected:\n  PClip child;\n  VideoInfo vi;\npublic:\n  GenericVideoFilter(PClip _child) : child(_child) { vi = child->GetVideoInfo(); }\n  PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) { return child->GetFrame(n, env); }\n  void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) { child->GetAudio(buf, start, count, env); }\n  const VideoInfo& __stdcall GetVideoInfo() { return vi; }\n  bool __stdcall GetParity(int n) { return child->GetParity(n); }\n  int __stdcall SetCacheHints(int cachehints, int frame_range) { AVS_UNUSED(cachehints); AVS_UNUSED(frame_range); return 0; }  // We do not pass cache requests upwards, only to the next filter.\n};\n\n\nclass PFunction\n{\npublic:\n  PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR0)())\n  PFunction(IFunction* p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR1)(p))\n  PFunction(const PFunction& p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR2)(p))\n  PFunction& operator=(IFunction* p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN0)(p))\n  PFunction& operator=(const PFunction& p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN1)(p))\n  ~PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_DESTRUCTOR)())\n\n  int operator!() const { return !e; }\n  operator void*() const { return e; }\n  IFunction* operator->() const { return e; }\n\nprivate:\n  IFunction * e;\n\n  friend class AVSValue;\n  IFunction * GetPointerWithAddRef() const;\n  void Init(IFunction* p);\n  void Set(IFunction* p);\n\n#ifdef BUILDING_AVSCORE\npublic:\n  void CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void CONSTRUCTOR1(IFunction* p);\n  void CONSTRUCTOR2(const PFunction& p);\n  PFunction& OPERATOR_ASSIGN0(IFunction* p);\n  PFunction& OPERATOR_ASSIGN1(const PFunction& p);\n  void DESTRUCTOR();\n#endif\n};\n\n\n#undef CALL_MEMBER_FN\n#undef AVS_LinkCallOptDefault\n#undef AVS_LinkCallOpt\n#undef AVS_LinkCallV\n#undef AVS_LinkCall\n#undef AVS_BakedCode\n\n\n#include \"avs/cpuid.h\"\n\n// IScriptEnvironment GetEnvProperty\nenum AvsEnvProperty {\n  AEP_PHYSICAL_CPUS = 1,\n  AEP_LOGICAL_CPUS = 2,\n  AEP_THREADPOOL_THREADS = 3,\n  AEP_FILTERCHAIN_THREADS = 4,\n  AEP_THREAD_ID = 5,\n  AEP_VERSION = 6,\n  AEP_HOST_SYSTEM_ENDIANNESS = 7,\n  AEP_INTERFACE_VERSION = 8,\n  AEP_INTERFACE_BUGFIX = 9,\n\n  // Neo additionals\n  AEP_NUM_DEVICES = 901,\n  AEP_FRAME_ALIGN = 902,\n  AEP_PLANE_ALIGN = 903,\n\n  AEP_SUPPRESS_THREAD = 921,\n  AEP_GETFRAME_RECURSIVE = 922,\n};\n\n// IScriptEnvironment::Allocate()\nenum AvsAllocType {\n  AVS_NORMAL_ALLOC = 1,\n  AVS_POOLED_ALLOC = 2\n};\n\n\n// Important note (Windows, MSVC): \n// When extending IScriptEnvironment, do not declare existing names again\n// with different parameters. Methods with the same name will be grouped \n// together in the vtable. This results in shifting all vtable method pointers\n// after such grouping and breaks all plugins who expect the old order.\n// E.g. ApplyMessage will be called instead of GetAVSLinkage.\n// As long as the declaration is compatible with COM interop, the order of \n// declaration is sequential. But if not, overloads in the same class are grouped\n// together in the vtable in the reverse order of declaration.\nclass IScriptEnvironment {\npublic:\n  virtual ~IScriptEnvironment() {}\n\n  virtual /*static*/ int __stdcall GetCPUFlags() = 0;\n\n  virtual char* __stdcall SaveString(const char* s, int length = -1) = 0;\n  virtual char* Sprintf(const char* fmt, ...) = 0;\n  // note: val is really a va_list; I hope everyone typedefs va_list to a pointer\n  // 20200305: (void *) changed back to va_list\n  virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0;\n\n#ifdef AVS_WINDOWS\n  __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0;\n#else\n  virtual void ThrowError(const char* fmt, ...) = 0;\n#endif\n\n  class NotFound /*exception*/ {};  // thrown by Invoke and GetVar\n\n  typedef AVSValue (__cdecl *ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env);\n\n  virtual void __stdcall AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0;\n  virtual bool __stdcall FunctionExists(const char* name) = 0;\n  virtual AVSValue __stdcall Invoke(const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  virtual AVSValue __stdcall GetVar(const char* name) = 0;\n  virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0;\n  virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0;\n\n  virtual void __stdcall PushContext(int level = 0) = 0;\n  virtual void __stdcall PopContext() = 0;\n\n  // note v8: use NewVideoFrameP is possible\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align = FRAME_ALIGN) = 0;\n\n  virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0;\n\n  virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0;\n\n  typedef void (__cdecl *ShutdownFunc)(void* user_data, IScriptEnvironment* env);\n  virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0;\n\n  virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0;\n\n  virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0;\n\n  virtual int __stdcall SetMemoryMax(int mem) = 0;\n\n  virtual int __stdcall SetWorkingDir(const char * newdir) = 0;\n\n  virtual void* __stdcall ManageCache(int key, void* data) = 0;\n\n  enum PlanarChromaAlignmentMode {\n    PlanarChromaAlignmentOff,\n    PlanarChromaAlignmentOn,\n    PlanarChromaAlignmentTest\n  };\n\n  virtual bool __stdcall PlanarChromaAlignment(PlanarChromaAlignmentMode key) = 0;\n\n  virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n                                               int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0;\n\n  // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta\n  virtual void __stdcall DeleteScriptEnvironment() = 0;\n\n  virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,\n                                     int textcolor, int halocolor, int bgcolor) = 0;\n\n  virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0;\n\n  // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6\n  // noThrow version of GetVar\n  virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0;\n\n  // **** AVISYNTH_INTERFACE_VERSION 8 **** AviSynth+ 3.6.0-\n  virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n    int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0;\n\n  virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0;\n  virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0;\n  virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0;\n\n  virtual int __stdcall propNumKeys(const AVSMap* map) = 0;\n\n  virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0;\n  virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0;\n  virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0;\n\n  virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0;\n\n  virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0;\n\n  virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0;\n  virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0;\n  virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0;\n  virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0;\n  virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0;\n\n  virtual const int64_t* __stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0;\n  virtual const double* __stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0;\n  virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0;\n  virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0;\n\n  virtual AVSMap* __stdcall createMap() = 0;\n  virtual void __stdcall freeMap(AVSMap* map) = 0;\n  virtual void __stdcall clearMap(AVSMap* map) = 0;\n\n  // NewVideoFrame with frame property source.\n  virtual PVideoFrame __stdcall NewVideoFrameP(const VideoInfo& vi, const PVideoFrame* prop_src, int align = FRAME_ALIGN) = 0;\n\n  // Generic query to ask for various system properties\n  virtual size_t  __stdcall GetEnvProperty(AvsEnvProperty prop) = 0;\n\n  // Support functions\n  virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0;\n  virtual void __stdcall Free(void* ptr) = 0;\n\n  // these GetVar versions (renamed differently) were moved from IScriptEnvironment2\n\n  // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'.\n  virtual bool  __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; // ex virtual bool  __stdcall GetVar(const char* name, AVSValue* val) const = 0;\n  // Return the value of the requested variable.\n  // If the variable was not found or had the wrong type,\n  // return the supplied default value.\n  virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0;\n  virtual int  __stdcall GetVarInt(const char* name, int def) const = 0;\n  virtual double  __stdcall GetVarDouble(const char* name, double def) const = 0;\n  virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0;\n  // brand new in v8 - though no real int64 support yet\n  virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0;\n\n  // 'Invoke' functions moved here from internal ScriptEnvironments are renamed in order to keep vtable order\n  // Invoke functions with 'Try' will return false instead of throwing NotFound().\n  // ex-IScriptEnvironment2\n  virtual bool __stdcall InvokeTry(AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0;\n  // Since V8\n  virtual AVSValue __stdcall Invoke2(const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  // Ex-INeo\n  virtual bool __stdcall Invoke2Try(AVSValue* result, const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual AVSValue __stdcall Invoke3(const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual bool __stdcall Invoke3Try(AVSValue* result, const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  // V9\n  virtual bool __stdcall MakePropertyWritable(PVideoFrame* pvf) = 0;\n\n}; // end class IScriptEnvironment. Order is important. Avoid overloads with the same name.\n\n// used internally\nclass IScriptEnvironment_Avs25 {\npublic:\n  virtual ~IScriptEnvironment_Avs25() {}\n\n  virtual /*static*/ int __stdcall GetCPUFlags() = 0;\n\n  virtual char* __stdcall SaveString(const char* s, int length = -1) = 0;\n  virtual char* Sprintf(const char* fmt, ...) = 0;\n  virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0;\n\n#ifdef AVS_WINDOWS\n  __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0;\n#else\n  virtual void ThrowError(const char* fmt, ...) = 0;\n#endif\n\n  class NotFound /*exception*/ {};  // thrown by Invoke and GetVar\n\n  typedef AVSValue(__cdecl* ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env);\n\n  virtual void __stdcall AddFunction25(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0;\n  virtual bool __stdcall FunctionExists(const char* name) = 0;\n  virtual AVSValue __stdcall Invoke25(const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  virtual AVSValue __stdcall GetVar(const char* name) = 0;\n  virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0;\n  virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0;\n\n  virtual void __stdcall PushContext(int level = 0) = 0;\n  virtual void __stdcall PopContext() = 0;\n\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align = FRAME_ALIGN) = 0;\n\n  virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0;\n\n  virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0;\n\n  typedef void(__cdecl* ShutdownFunc)(void* user_data, IScriptEnvironment* env);\n  virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0;\n\n  virtual void __stdcall CheckVersion(int version = AVISYNTH_CLASSIC_INTERFACE_VERSION_25) = 0;\n\n  virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0;\n\n  virtual int __stdcall SetMemoryMax(int mem) = 0;\n\n  virtual int __stdcall SetWorkingDir(const char* newdir) = 0;\n\n  // specially returns 1 for key MC_QueryAvs25 to check if called from AVS2.5 interface\n  virtual void* __stdcall ManageCache25(int key, void* data) = 0;\n\n  enum PlanarChromaAlignmentMode {\n    PlanarChromaAlignmentOff,\n    PlanarChromaAlignmentOn,\n    PlanarChromaAlignmentTest\n  };\n\n  virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0;\n\n  virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n    int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0;\n\n  // Despite the name, we provide entries up to V6 in case someone requests\n  // a V3 interface and still wants to use V5-V6 functions\n\n  // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta\n  virtual void __stdcall DeleteScriptEnvironment() = 0;\n\n  virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,\n    int textcolor, int halocolor, int bgcolor) = 0;\n\n  virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0;\n\n  // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6\n  // noThrow version of GetVar\n  virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0;\n\n}; // end class IScriptEnvironment_Avs25. Order is important.\n\n\nenum MtMode {\n  MT_INVALID = 0,\n  MT_NICE_FILTER = 1,\n  MT_MULTI_INSTANCE = 2,\n  MT_SERIALIZED = 3,\n  MT_SPECIAL_MT = 4,\n  MT_MODE_COUNT = 5\n};\n\nclass IJobCompletion\n{\npublic:\n\n  virtual ~IJobCompletion() {}\n  virtual void __stdcall Wait() = 0;\n  virtual AVSValue __stdcall Get(size_t i) = 0;\n  virtual size_t __stdcall Size() const = 0;\n  virtual size_t __stdcall Capacity() const = 0;\n  virtual void __stdcall Reset() = 0;\n  virtual void __stdcall Destroy() = 0;\n};\n\nclass IScriptEnvironment2;\nclass Prefetcher;\ntypedef AVSValue (*ThreadWorkerFuncPtr)(IScriptEnvironment2* env, void* data);\n\n\n/* -----------------------------------------------------------------------------\n   Note to plugin authors: The interface in IScriptEnvironment2 is\n      preliminary / under construction / only for testing / non-final etc.!\n      As long as you see this note here, IScriptEnvironment2 might still change,\n      in which case your plugin WILL break. This also means that you are welcome\n      to test it and give your feedback about any ideas, improvements, or issues\n      you might have.\n   ----------------------------------------------------------------------------- */\nclass IScriptEnvironment2 : public IScriptEnvironment{\npublic:\n  virtual ~IScriptEnvironment2() {}\n\n  // V8: SubframePlanarA, GetEnvProperty, GetVar versions, Allocate, Free, no-throw Invoke moved to IScriptEnvironment\n\n  // Plugin functions\n  virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0;\n  virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0;\n  virtual void __stdcall ClearAutoloadDirs() = 0;\n  virtual void __stdcall AutoloadPlugins() = 0;\n  virtual void __stdcall AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0;\n  virtual bool __stdcall InternalFunctionExists(const char* name) = 0;\n\n  // Threading\n  virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0; // If filter is \"DEFAULT_MT_MODE\", sets the default MT mode\n  virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0;\n  virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0;\n\n  // These lines are needed so that we can overload the older functions from IScriptEnvironment.\n  using IScriptEnvironment::Invoke;\n  using IScriptEnvironment::AddFunction;\n\n}; // end class IScriptEnvironment2\n\n\n// To allow Avisynth+ add functions to IScriptEnvironment2,\n// Neo defines another new interface, INeoEnv.\n// INeoEnv and the legacy interfaces (IScriptEnvironment/IScriptEnvironment2)\n// share the same ScriptEnvironment instance. The function with the same signature\n// is exactly identical and there is no limitation to switch interfaces.\n// You can use any interface you like.\n// Note to plugin authors : The interface is not stable, see comments in IScriptEnvironment2\nclass INeoEnv {\npublic:\n  virtual ~INeoEnv() {}\n\n  typedef IScriptEnvironment::NotFound NotFound;\n  typedef IScriptEnvironment::ApplyFunc ApplyFunc;\n  typedef IScriptEnvironment::ShutdownFunc ShutdownFunc;\n\n  virtual void __stdcall DeleteScriptEnvironment() = 0;\n\n  virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0;\n\n  // Get legacy interface (Avisynth+)\n  virtual IScriptEnvironment2* __stdcall GetEnv2() = 0;\n  // Get compatibility interface for AVS CPP 2.5 plugins\n  virtual IScriptEnvironment_Avs25* __stdcall GetEnv25() = 0;\n\n  // Generic system to ask for various properties\n  virtual size_t  __stdcall GetEnvProperty(AvsEnvProperty prop) = 0;\n  virtual int __stdcall GetCPUFlags() = 0;\n\n  // Plugin functions\n  virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0;\n  virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0;\n  virtual void __stdcall ClearAutoloadDirs() = 0;\n  virtual void __stdcall AutoloadPlugins() = 0;\n\n  virtual void __stdcall AddFunction(\n    const char* name, const char* params, ApplyFunc apply, void* user_data) = 0;\n  virtual void __stdcall AddFunction(\n    const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0;\n  virtual bool __stdcall FunctionExists(const char* name) = 0;\n  virtual bool __stdcall InternalFunctionExists(const char* name) = 0;\n\n  // Invoke function. Throws NotFound exception when the specified function does not exist.\n  virtual AVSValue __stdcall Invoke(\n    const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual AVSValue __stdcall Invoke2(\n    const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual AVSValue __stdcall Invoke3(\n    const AVSValue& implicit_last,\n    const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  // These versions of Invoke will return false instead of throwing NotFound().\n  virtual bool __stdcall InvokeTry(\n    AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0;\n  virtual bool __stdcall Invoke2Try(\n    AVSValue* result, const AVSValue& implicit_last,\n    const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual bool __stdcall Invoke3Try(\n    AVSValue* result, const AVSValue& implicit_last,\n    const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  // V9\n  virtual bool __stdcall MakePropertyWritable(PVideoFrame* pvf) = 0;\n\n  // Throws exception when the requested variable is not found.\n  virtual AVSValue __stdcall GetVar(const char* name) = 0;\n\n  // noThrow version of GetVar\n  virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0;\n\n  // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'.\n  virtual bool  __stdcall GetVarTry(const char* name, AVSValue* val) const = 0;\n\n  // Return the value of the requested variable.\n  // If the variable was not found or had the wrong type,\n  // return the supplied default value.\n  virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0;\n  virtual int  __stdcall GetVarInt(const char* name, int def) const = 0;\n  virtual double  __stdcall GetVarDouble(const char* name, double def) const = 0;\n  virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0;\n  virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0;\n\n  virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0;\n  virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0;\n\n  // Switch local variables\n  virtual void __stdcall PushContext(int level = 0) = 0;\n  virtual void __stdcall PopContext() = 0;\n\n  // Global variable frame support\n  virtual void __stdcall PushContextGlobal() = 0;\n  virtual void __stdcall PopContextGlobal() = 0;\n\n  // Allocate new video frame\n  // in PNeoEnv: align parameter is no longer supported\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi) = 0; // current device is used\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device) = 0;\n  // as above but with property sources\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PVideoFrame *prop_src) = 0; // current device is used + frame property source\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device, const PVideoFrame* prop_src) = 0; // current device is used + frame property source\n\n  // Frame related operations\n  virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0;\n  virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0;\n\n  virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0;\n  virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n    int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0;\n  virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n    int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0;\n\n  // frame properties support\n  virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0;\n  virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0;\n  virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0;\n\n  virtual int __stdcall propNumKeys(const AVSMap* map) = 0;\n  virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0;\n  virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0;\n  virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0;\n\n  virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0;\n\n  virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0;\n\n  virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0;\n  virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0;\n  virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0;\n  virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0;\n  virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0;\n\n  virtual const int64_t *__stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0;\n  virtual const double *__stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0;\n  virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0;\n  virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0;\n\n  virtual AVSMap* __stdcall createMap() = 0;\n  virtual void __stdcall freeMap(AVSMap* map) = 0;\n  virtual void __stdcall clearMap(AVSMap* map) = 0;\n\n  // Support functions\n  virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0;\n  virtual void __stdcall Free(void* ptr) = 0;\n\n  virtual char* __stdcall SaveString(const char* s, int length = -1) = 0;\n  virtual char* __stdcall SaveString(const char* s, int length, bool escape) = 0;\n  virtual char* Sprintf(const char* fmt, ...) = 0;\n  virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0;\n\n  __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0;\n\n  virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,\n    int textcolor, int halocolor, int bgcolor) = 0;\n\n  // Setting\n  virtual int __stdcall SetMemoryMax(int mem) = 0;\n  virtual int __stdcall SetMemoryMax(AvsDeviceType type, int index, int mem) = 0;\n\n  virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0;\n  virtual int __stdcall SetWorkingDir(const char * newdir) = 0;\n  virtual void* __stdcall ManageCache(int key, void* data) = 0;\n\n  virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0;\n  virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0;\n\n  // Threading\n  virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0;\n  virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0;\n  virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0;\n\n  // CUDA Support\n  virtual PDevice __stdcall GetDevice(AvsDeviceType dev_type, int dev_index) const = 0;\n  virtual PDevice __stdcall GetDevice() const = 0; // get current device\n  virtual AvsDeviceType __stdcall GetDeviceType() const = 0;\n  virtual int __stdcall GetDeviceId() const  = 0;\n  virtual int __stdcall GetDeviceIndex() const  = 0;\n  virtual void* __stdcall GetDeviceStream() const = 0;\n  virtual void __stdcall DeviceAddCallback(void(*cb)(void*), void* user_data) = 0;\n\n  virtual PVideoFrame __stdcall GetFrame(PClip c, int n, const PDevice& device) = 0;\n\n};\n\n// support interface conversion\nstruct PNeoEnv {\n  INeoEnv* p;\n  PNeoEnv() : p() { }\n  PNeoEnv(IScriptEnvironment* env)\n#if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB)\n    ;\n#else\n  : p(!AVS_linkage || offsetof(AVS_Linkage, GetNeoEnv) >= (size_t)AVS_linkage->Size ? 0 : AVS_linkage->GetNeoEnv(env)) { }\n#endif\n\n  int operator!() const { return !p; }\n  operator void*() const { return p; }\n  INeoEnv* operator->() const { return p; }\n#ifdef BUILDING_AVSCORE\n  inline operator IScriptEnvironment2*();\n  inline operator IScriptEnvironment_Avs25* ();\n#else\n  operator IScriptEnvironment2*() { return p->GetEnv2(); }\n  operator IScriptEnvironment_Avs25* () { return p->GetEnv25(); }\n#endif\n};\n\n\n// avisynth.dll exports this; it's a way to use it as a library, without\n// writing an AVS script or without going through AVIFile.\nAVSC_API(IScriptEnvironment*, CreateScriptEnvironment)(int version = AVISYNTH_INTERFACE_VERSION);\n\n\n// These are some global variables you can set in your script to change AviSynth's behavior.\n#define VARNAME_AllowFloatAudio   \"OPT_AllowFloatAudio\"   // Allow WAVE_FORMAT_IEEE_FLOAT audio output\n#define VARNAME_VDubPlanarHack    \"OPT_VDubPlanarHack\"    // Hack YV16 and YV24 chroma plane order for old VDub's\n#define VARNAME_AVIPadScanlines   \"OPT_AVIPadScanlines\"   // Have scanlines mod4 padded in all pixel formats\n#define VARNAME_UseWaveExtensible \"OPT_UseWaveExtensible\" // Use WAVEFORMATEXTENSIBLE when describing audio to Windows\n#define VARNAME_dwChannelMask     \"OPT_dwChannelMask\"     // Integer audio channel mask. See description of WAVEFORMATEXTENSIBLE for more info.\n#define VARNAME_Enable_V210       \"OPT_Enable_V210\"       // AVS+ use V210 instead of P210 (VfW)\n#define VARNAME_Enable_Y3_10_10   \"OPT_Enable_Y3_10_10\"   // AVS+ use Y3[10][10] instead of P210 (VfW)\n#define VARNAME_Enable_Y3_10_16   \"OPT_Enable_Y3_10_16\"   // AVS+ use Y3[10][16] instead of P216 (VfW)\n#define VARNAME_Enable_b64a       \"OPT_Enable_b64a\"       // AVS+ use b64a instead of BRA[64] (VfW)\n#define VARNAME_Enable_PlanarToPackedRGB \"OPT_Enable_PlanarToPackedRGB\" // AVS+ convert Planar RGB to packed RGB (VfW)\n\n// C exports\n#include \"avs/capi.h\"\nAVSC_API(IScriptEnvironment2*, CreateScriptEnvironment2)(int version = AVISYNTH_INTERFACE_VERSION);\n\n#ifndef BUILDING_AVSCORE\n#undef AVS_UNUSED\n#endif\n\n#pragma pack(pop)\n\n#endif //__AVISYNTH_10_H__\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avisynth_c.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// Copyright 2020 AviSynth+ project\n// Actual C Interface version follows the global Avisynth+ IF version numbers.\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n// MA 02110-1301 USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n// NOTE: this is a partial update of the Avisynth C interface to recognize\n// new color spaces and interface elements added in Avisynth 2.60 and AviSynth+.\n// This interface is not 100% Avisynth+ CPP interface equivalent.\n\n// 170103: added new CPU constants (FMA4, AVX512xx)\n// 171102: define SIZETMOD. do not use yet, experimental. Offsets are size_t instead of int. Affects x64.\n// 171106: avs_get_row_size calls into avs_get_row_size_p, instead of direct field access\n// 171106: avs_get_height calls into avs_get_row_size_p, instead of direct field access\n// 180524: AVSC_EXPORT to dllexport in capi.h for avisynth_c_plugin_init\n// 180524: avs_is_same_colorspace VideoInfo parameters to const\n// 181230: Readability: functions regrouped to mix less AVSC_API and AVSC_INLINE, put together Avisynth+ specific stuff\n// 181230: use #ifndef AVSC_NO_DECLSPEC for AVSC_INLINE functions which are calling API functions\n// 181230: comments on avs_load_library (helper for loading API entries dynamically into a struct using AVSC_NO_DECLSPEC define)\n// 181230: define alias AVS_FRAME_ALIGN as FRAME_ALIGN\n// 181230: remove unused form of avs_get_rowsize and avs_get_height (kept earlier for reference)\n// 190104: avs_load_library: smart fallback mechanism for Avisynth+ specific functions:\n//         if they are not loadable, they will work in a classic Avisynth compatible mode\n//         Example#1: e.g. avs_is_444 will call the existing avs_is_yv24 instead\n//         Example#2: avs_bits_per_component will return 8 for all colorspaces (Classic Avisynth supports only 8 bits/pixel)\n//         Thus the Avisynth+ specific API functions are safely callable even when connected to classic Avisynth DLL\n// 2002xx  non-Windows friendly additions\n// 200305  avs_vsprintf parameter type change: (void *) to va_list\n// 200330: (remove test SIZETMOD define for clarity)\n// 200513: user must use explicite #define AVS26_FALLBACK_SIMULATION for having fallback helpers in dynamic loaded library section\n// 200513: Follow AviSynth+ V8 interface additions\n//         AVS_VideoFrame struct extended with placeholder for frame property pointer\n//         avs_subframe_planar_a\n//         avs_copy_frame_props\n//         avs_get_frame_props_ro, avs_get_frame_props_rw\n//         avs_prop_num_keys, avs_prop_get_key, avs_prop_num_elements, avs_prop_get_type, avs_prop_get_data_size\n//         avs_prop_get_int, avs_prop_get_float, avs_prop_get_data, avs_prop_get_clip, avs_prop_get_frame, avs_prop_get_int_array, avs_prop_get_float_array\n//         avs_prop_set_int, avs_prop_set_float, avs_prop_set_data, avs_prop_set_clip, avs_prop_set_frame, avs_prop_set_int_array, avs_prop_set_float_array\n//         avs_prop_delete_key, avs_clear_map\n//         avs_new_video_frame_p, avs_new_video_frame_p_a\n//         avs_get_env_property (internal system properties), AVS_AEP_xxx (AvsEnvProperty) enums\n//         avs_get_var_try, avs_get_var_bool, avs_get_var_int, avs_get_var_double, avs_get_var_string, avs_get_var_long\n//         avs_pool_allocate, avs_pool_free\n// 2021:   Follow AviSynth+ V9 interface additions\n//         avs_is_property_writable, avs_make_property_writable\n//         Add enum AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION (AVISYNTH_INTERFACE_VERSION still exists)\n//         Add enum AVS_AEP_HOST_SYSTEM_ENDIANNESS to system property request types (avs_get_env_property)\n//         Add enums AVS_AEP_INTERFACE_VERSION and AVS_AEP_INTERFACE_BUGFIX for direct interface version system property request types (avs_get_env_property)\n//         Bugfix 9.1: fix avs_prop_get_data\n// 2023:   Follow AviSynth+ V10 interface additions\n//         Add enum AVS_DEFAULT_PLANE (as 0) to plane constants \n//         prop_src argument now const in avs_new_video_frame_p and avs_new_video_frame_p_a (no change in use)\n//         Add pixel_type to struct AVS_VideoFrame\n//         Add avs_video_frame_get_pixel_type and avs_video_frame_amend_pixel_type for getting and setting AVS_VideoFrame pixel_type\n//         Additional AviSynth+ V10 interface additions:\n//         Add enum AVS_SPEAKER_xxx, AVS_IT_SPEAKER_xxx\n//         audio channel mask support avs_is_channel_mask_known, avs_set_channel_mask, avs_get_channel_mask\n\n#ifndef __AVISYNTH_C__\n#define __AVISYNTH_C__\n\n#include \"avs/config.h\"\n#include \"avs/capi.h\"\n#include \"avs/types.h\"\n\n#define AVS_FRAME_ALIGN FRAME_ALIGN\n/////////////////////////////////////////////////////////////////////\n//\n// Constants\n//\n\n#ifndef __AVISYNTH_10_H__\nenum {\n  AVISYNTH_INTERFACE_CLASSIC_VERSION = 6,\n  AVISYNTH_INTERFACE_VERSION = 10,\n  AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION = 0 // reset to zero whenever the normal interface version bumps\n};\n#endif\n\nenum {\n  AVS_SAMPLE_INT8  = 1 << 0,\n  AVS_SAMPLE_INT16 = 1 << 1,\n  AVS_SAMPLE_INT24 = 1 << 2,\n  AVS_SAMPLE_INT32 = 1 << 3,\n  AVS_SAMPLE_FLOAT = 1 << 4\n};\n\nenum {\n  AVS_DEFAULT_PLANE = 0,\n  AVS_PLANAR_Y = 1 << 0,\n  AVS_PLANAR_U = 1 << 1,\n  AVS_PLANAR_V = 1 << 2,\n  AVS_PLANAR_ALIGNED = 1 << 3,\n  AVS_PLANAR_Y_ALIGNED = AVS_PLANAR_Y | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_U_ALIGNED = AVS_PLANAR_U | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_V_ALIGNED = AVS_PLANAR_V | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_A = 1 << 4,\n  AVS_PLANAR_R = 1 << 5,\n  AVS_PLANAR_G = 1 << 6,\n  AVS_PLANAR_B = 1 << 7,\n  AVS_PLANAR_A_ALIGNED = AVS_PLANAR_A | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_R_ALIGNED = AVS_PLANAR_R | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_G_ALIGNED = AVS_PLANAR_G | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_B_ALIGNED = AVS_PLANAR_B | AVS_PLANAR_ALIGNED\n};\n\n// Colorspace properties.\nenum {\n  AVS_CS_YUVA = 1 << 27,\n  AVS_CS_BGR = 1 << 28,\n  AVS_CS_YUV = 1 << 29,\n  AVS_CS_INTERLEAVED = 1 << 30,\n  AVS_CS_PLANAR = 1 << 31,\n\n  AVS_CS_SHIFT_SUB_WIDTH = 0,\n  AVS_CS_SHIFT_SUB_HEIGHT = 8,\n  AVS_CS_SHIFT_SAMPLE_BITS = 16,\n\n  AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH,\n  AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24\n  AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16\n  AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411\n\n  AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9\n  AVS_CS_UPLANEFIRST = 1 << 4, // I420\n\n  AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT,\n  AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411\n  AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420\n  AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9\n\n  AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_12 = 6 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_14 = 7 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS,\n\n  AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_YUVA\n                       | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_WIDTH_MASK | AVS_CS_SUB_HEIGHT_MASK,\n  AVS_CS_PLANAR_FILTER = ~(AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST),\n\n  AVS_CS_RGB_TYPE  = 1 << 0,\n  AVS_CS_RGBA_TYPE = 1 << 1,\n\n  AVS_CS_GENERIC_YUV444  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_1 | AVS_CS_SUB_HEIGHT_1,  // 4:4:4 planar\n  AVS_CS_GENERIC_YUV422  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_1,  // 4:2:2 planar\n  AVS_CS_GENERIC_YUV420  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2,  // 4:2:0 planar\n  AVS_CS_GENERIC_Y       = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV,                                             // Y only (4:0:0)\n  AVS_CS_GENERIC_RGBP    = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGB_TYPE,                                                // planar RGB\n  AVS_CS_GENERIC_RGBAP   = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGBA_TYPE,                                               // planar RGBA\n  AVS_CS_GENERIC_YUVA444 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_1 | AVS_CS_SUB_HEIGHT_1, // 4:4:4:A planar\n  AVS_CS_GENERIC_YUVA422 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_1, // 4:2:2:A planar\n  AVS_CS_GENERIC_YUVA420 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2  // 4:2:0:A planar\n};\n\n// Specific color formats\nenum {\n  AVS_CS_UNKNOWN = 0,\n  AVS_CS_BGR24 = AVS_CS_RGB_TYPE  | AVS_CS_BGR | AVS_CS_INTERLEAVED,\n  AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED,\n  AVS_CS_YUY2 = 1 << 2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,\n  // AVS_CS_YV12 = 1 << 3   Reserved\n  // AVS_CS_I420 = 1 << 4   Reserved\n  AVS_CS_RAW32 = 1 << 5 | AVS_CS_INTERLEAVED,\n\n  AVS_CS_YV24  = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8,  // YUV 4:4:4 planar\n  AVS_CS_YV16  = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8,  // YUV 4:2:2 planar\n  AVS_CS_YV12  = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8,  // YUV 4:2:0 planar\n  AVS_CS_I420  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2,  // YUV 4:2:0 planar\n  AVS_CS_IYUV  = AVS_CS_I420,\n  AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_4 | AVS_CS_SUB_HEIGHT_1,  // YUV 4:1:1 planar\n  AVS_CS_YUV9  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_4 | AVS_CS_SUB_HEIGHT_4,  // YUV 4:1:0 planar\n  AVS_CS_Y8    = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_8,       // Y   4:0:0 planar\n\n  //-------------------------\n  // AVS16: new planar constants go live! Experimental PF 160613\n  // 10-12-14-16 bit + planar RGB + BGR48/64 160725\n  AVS_CS_YUV444P10 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_10, // YUV 4:4:4 10bit samples\n  AVS_CS_YUV422P10 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:2 10bit samples\n  AVS_CS_YUV420P10 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:0 10bit samples\n  AVS_CS_Y10       = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10,      // Y   4:0:0 10bit samples\n\n  AVS_CS_YUV444P12 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_12, // YUV 4:4:4 12bit samples\n  AVS_CS_YUV422P12 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:2 12bit samples\n  AVS_CS_YUV420P12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:0 12bit samples\n  AVS_CS_Y12       = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12,      // Y   4:0:0 12bit samples\n\n  AVS_CS_YUV444P14 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_14, // YUV 4:4:4 14bit samples\n  AVS_CS_YUV422P14 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:2 14bit samples\n  AVS_CS_YUV420P14 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:0 14bit samples\n  AVS_CS_Y14       = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14,      // Y   4:0:0 14bit samples\n\n  AVS_CS_YUV444P16 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_16, // YUV 4:4:4 16bit samples\n  AVS_CS_YUV422P16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:2 16bit samples\n  AVS_CS_YUV420P16 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:0 16bit samples\n  AVS_CS_Y16       = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16,      // Y   4:0:0 16bit samples\n\n  // 32 bit samples (float)\n  AVS_CS_YUV444PS = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_32,  // YUV 4:4:4 32bit samples\n  AVS_CS_YUV422PS = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_32,  // YUV 4:2:2 32bit samples\n  AVS_CS_YUV420PS = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_32,  // YUV 4:2:0 32bit samples\n  AVS_CS_Y32      = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32,       // Y   4:0:0 32bit samples\n\n  // RGB packed\n  AVS_CS_BGR48 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16,    // BGR 3x16 bit\n  AVS_CS_BGR64 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16,    // BGR 4x16 bit\n  // no packed 32 bit (float) support for these legacy types\n\n  // RGB planar\n  AVS_CS_RGBP   = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8,  // Planar RGB 8 bit samples\n  AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples\n  AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples\n  AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples\n  AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples\n  AVS_CS_RGBPS  = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples\n\n  // RGBA planar\n  AVS_CS_RGBAP   = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8,  // Planar RGBA 8 bit samples\n  AVS_CS_RGBAP10 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_10, // Planar RGBA 10bit samples\n  AVS_CS_RGBAP12 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_12, // Planar RGBA 12bit samples\n  AVS_CS_RGBAP14 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_14, // Planar RGBA 14bit samples\n  AVS_CS_RGBAP16 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_16, // Planar RGBA 16bit samples\n  AVS_CS_RGBAPS  = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples\n\n  // Planar YUVA\n  AVS_CS_YUVA444    = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_8,  // YUVA 4:4:4 8bit samples\n  AVS_CS_YUVA422    = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_8,  // YUVA 4:2:2 8bit samples\n  AVS_CS_YUVA420    = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_8,  // YUVA 4:2:0 8bit samples\n\n  AVS_CS_YUVA444P10 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:4:4 10bit samples\n  AVS_CS_YUVA422P10 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:2 10bit samples\n  AVS_CS_YUVA420P10 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:0 10bit samples\n\n  AVS_CS_YUVA444P12 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:4:4 12bit samples\n  AVS_CS_YUVA422P12 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:2 12bit samples\n  AVS_CS_YUVA420P12 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:0 12bit samples\n\n  AVS_CS_YUVA444P14 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:4:4 14bit samples\n  AVS_CS_YUVA422P14 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:2 14bit samples\n  AVS_CS_YUVA420P14 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:0 14bit samples\n\n  AVS_CS_YUVA444P16 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:4:4 16bit samples\n  AVS_CS_YUVA422P16 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:2 16bit samples\n  AVS_CS_YUVA420P16 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:0 16bit samples\n\n  AVS_CS_YUVA444PS  = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_32,  // YUVA 4:4:4 32bit samples\n  AVS_CS_YUVA422PS  = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_32,  // YUVA 4:2:2 32bit samples\n  AVS_CS_YUVA420PS  = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_32,  // YUVA 4:2:0 32bit samples\n};\n\n// AvsChannelMask enum: Unshifted channel mask constants like in WAVEFORMATEXTENSIBLE\n// in AvsImageTypeFlags they are shifted by 4 bits\nenum {\n  AVS_MASK_SPEAKER_FRONT_LEFT = 0x1,\n  AVS_MASK_SPEAKER_FRONT_RIGHT = 0x2,\n  AVS_MASK_SPEAKER_FRONT_CENTER = 0x4,\n  AVS_MASK_SPEAKER_LOW_FREQUENCY = 0x8,\n  AVS_MASK_SPEAKER_BACK_LEFT = 0x10,\n  AVS_MASK_SPEAKER_BACK_RIGHT = 0x20,\n  AVS_MASK_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40,\n  AVS_MASK_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80,\n  AVS_MASK_SPEAKER_BACK_CENTER = 0x100,\n  AVS_MASK_SPEAKER_SIDE_LEFT = 0x200,\n  AVS_MASK_SPEAKER_SIDE_RIGHT = 0x400,\n  AVS_MASK_SPEAKER_TOP_CENTER = 0x800,\n  AVS_MASK_SPEAKER_TOP_FRONT_LEFT = 0x1000,\n  AVS_MASK_SPEAKER_TOP_FRONT_CENTER = 0x2000,\n  AVS_MASK_SPEAKER_TOP_FRONT_RIGHT = 0x4000,\n  AVS_MASK_SPEAKER_TOP_BACK_LEFT = 0x8000,\n  AVS_MASK_SPEAKER_TOP_BACK_CENTER = 0x10000,\n  AVS_MASK_SPEAKER_TOP_BACK_RIGHT = 0x20000,\n  // Bit mask locations used up for the above positions\n  AVS_MASK_SPEAKER_DEFINED = 0x0003FFFF,\n  // Bit mask locations reserved for future use\n  AVS_MASK_SPEAKER_RESERVED = 0x7FFC0000,\n  // Used to specify that any possible permutation of speaker configurations\n  // Due to lack of available bits this one is put differently into image_type\n  AVS_MASK_SPEAKER_ALL = 0x80000000\n};\n\n// AvsImageTypeFlags\nenum {\n  AVS_IT_BFF = 1 << 0,\n  AVS_IT_TFF = 1 << 1,\n  AVS_IT_FIELDBASED = 1 << 2,\n\n  // Audio channel mask support\n  AVS_IT_HAS_CHANNELMASK = 1 << 3,\n  // shifted by 4 bits compared to WAVEFORMATEXTENSIBLE dwChannelMask\n  // otherwise same as AvsChannelMask\n  AVS_IT_SPEAKER_FRONT_LEFT = 0x1 << 4,\n  AVS_IT_SPEAKER_FRONT_RIGHT = 0x2 << 4,\n  AVS_IT_SPEAKER_FRONT_CENTER = 0x4 << 4,\n  AVS_IT_SPEAKER_LOW_FREQUENCY = 0x8 << 4,\n  AVS_IT_SPEAKER_BACK_LEFT = 0x10 << 4,\n  AVS_IT_SPEAKER_BACK_RIGHT = 0x20 << 4,\n  AVS_IT_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40 << 4,\n  AVS_IT_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80 << 4,\n  AVS_IT_SPEAKER_BACK_CENTER = 0x100 << 4,\n  AVS_IT_SPEAKER_SIDE_LEFT = 0x200 << 4,\n  AVS_IT_SPEAKER_SIDE_RIGHT = 0x400 << 4,\n  AVS_IT_SPEAKER_TOP_CENTER = 0x800 << 4,\n  AVS_IT_SPEAKER_TOP_FRONT_LEFT = 0x1000 << 4,\n  AVS_IT_SPEAKER_TOP_FRONT_CENTER = 0x2000 << 4,\n  AVS_IT_SPEAKER_TOP_FRONT_RIGHT = 0x4000 << 4,\n  AVS_IT_SPEAKER_TOP_BACK_LEFT = 0x8000 << 4,\n  AVS_IT_SPEAKER_TOP_BACK_CENTER = 0x10000 << 4,\n  AVS_IT_SPEAKER_TOP_BACK_RIGHT = 0x20000 << 4,\n  // End of officially defined speaker bits\n  // The next one is special, since cannot shift SPEAKER_ALL 0x80000000 further.\n  // Set mask and get mask handles it.\n  AVS_IT_SPEAKER_ALL = 0x40000 << 4,\n  // Mask for the defined 18 bits + SPEAKER_ALL\n  AVS_IT_SPEAKER_BITS_MASK = (AVS_MASK_SPEAKER_DEFINED << 4) | AVS_IT_SPEAKER_ALL,\n  AVS_IT_NEXT_AVAILABLE = 1 << 23\n};\n\nenum {\n  AVS_FILTER_TYPE = 1,\n  AVS_FILTER_INPUT_COLORSPACE = 2,\n  AVS_FILTER_OUTPUT_TYPE = 9,\n  AVS_FILTER_NAME = 4,\n  AVS_FILTER_AUTHOR = 5,\n  AVS_FILTER_VERSION = 6,\n  AVS_FILTER_ARGS = 7,\n  AVS_FILTER_ARGS_INFO = 8,\n  AVS_FILTER_ARGS_DESCRIPTION = 10,\n  AVS_FILTER_DESCRIPTION = 11\n};\n\nenum {  // SUBTYPES\n  AVS_FILTER_TYPE_AUDIO = 1,\n  AVS_FILTER_TYPE_VIDEO = 2,\n  AVS_FILTER_OUTPUT_TYPE_SAME = 3,\n  AVS_FILTER_OUTPUT_TYPE_DIFFERENT = 4\n};\n\nenum {\n  // New 2.6 explicitly defined cache hints.\n  AVS_CACHE_NOTHING = 10, // Do not cache video.\n  AVS_CACHE_WINDOW = 11, // Hard protect up to X frames within a range of X from the current frame N.\n  AVS_CACHE_GENERIC = 12, // LRU cache up to X frames.\n  AVS_CACHE_FORCE_GENERIC = 13, // LRU cache up to X frames, override any previous CACHE_WINDOW.\n\n  AVS_CACHE_GET_POLICY = 30, // Get the current policy.\n  AVS_CACHE_GET_WINDOW = 31, // Get the current window h_span.\n  AVS_CACHE_GET_RANGE = 32, // Get the current generic frame range.\n\n  // Set Audio cache mode and answers to CACHE_GETCHILD_AUDIO_MODE\n  AVS_CACHE_AUDIO = 50, // Explicitly do cache audio, X byte cache.\n  AVS_CACHE_AUDIO_NOTHING = 51, // Explicitly do not cache audio.\n  AVS_CACHE_AUDIO_NONE = 52, // Audio cache off (auto mode), X byte initial cache.\n  AVS_CACHE_AUDIO_AUTO_START_OFF = 52, // synonym\n  AVS_CACHE_AUDIO_AUTO = 53, // Audio cache on (auto mode), X byte initial cache.\n  AVS_CACHE_AUDIO_AUTO_START_ON = 53, // synonym\n\n  // These just returns actual value if clip is cached\n  AVS_CACHE_GET_AUDIO_POLICY = 70, // Get the current audio policy.\n  AVS_CACHE_GET_AUDIO_SIZE = 71, // Get the current audio cache size.\n\n  AVS_CACHE_PREFETCH_FRAME = 100, // n/a Queue request to prefetch frame N.\n  AVS_CACHE_PREFETCH_GO = 101, // n/a Action video prefetches.\n\n  AVS_CACHE_PREFETCH_AUDIO_BEGIN = 120, // n/a Begin queue request transaction to prefetch audio (take critical section).\n  AVS_CACHE_PREFETCH_AUDIO_STARTLO = 121, // n/a Set low 32 bits of start.\n  AVS_CACHE_PREFETCH_AUDIO_STARTHI = 122, // n/a Set high 32 bits of start.\n  AVS_CACHE_PREFETCH_AUDIO_COUNT = 123, // n/a Set low 32 bits of length.\n  AVS_CACHE_PREFETCH_AUDIO_COMMIT = 124, // n/a Enqueue request transaction to prefetch audio (release critical section).\n  AVS_CACHE_PREFETCH_AUDIO_GO = 125, // n/a Action audio prefetches.\n\n  AVS_CACHE_GETCHILD_CACHE_MODE = 200, // n/a Cache ask Child for desired video cache mode.\n  AVS_CACHE_GETCHILD_CACHE_SIZE = 201, // n/a Cache ask Child for desired video cache size.\n\n  // Filters are queried about their desired audio cache mode.\n  // Child can answer them with CACHE_AUDIO_xxx\n  AVS_CACHE_GETCHILD_AUDIO_MODE = 202, // Cache ask Child for desired audio cache mode.\n  AVS_CACHE_GETCHILD_AUDIO_SIZE = 203, // Cache ask Child for desired audio cache size.\n\n  AVS_CACHE_GETCHILD_COST = 220, // n/a Cache ask Child for estimated processing cost.\n  AVS_CACHE_COST_ZERO = 221, // n/a Child response of zero cost (ptr arithmetic only).\n  AVS_CACHE_COST_UNIT = 222, // n/a Child response of unit cost (less than or equal 1 full frame blit).\n  AVS_CACHE_COST_LOW = 223, // n/a Child response of light cost. (Fast)\n  AVS_CACHE_COST_MED = 224, // n/a Child response of medium cost. (Real time)\n  AVS_CACHE_COST_HI = 225, // n/a Child response of heavy cost. (Slow)\n\n  AVS_CACHE_GETCHILD_THREAD_MODE = 240, // n/a Cache ask Child for thread safety.\n  AVS_CACHE_THREAD_UNSAFE = 241, // n/a Only 1 thread allowed for all instances. 2.5 filters default!\n  AVS_CACHE_THREAD_CLASS = 242, // n/a Only 1 thread allowed for each instance. 2.6 filters default!\n  AVS_CACHE_THREAD_SAFE = 243, // n/a Allow all threads in any instance.\n  AVS_CACHE_THREAD_OWN = 244, // n/a Safe but limit to 1 thread, internally threaded.\n\n  AVS_CACHE_GETCHILD_ACCESS_COST = 260, // Cache ask Child for preferred access pattern.\n  AVS_CACHE_ACCESS_RAND = 261, // Filter is access order agnostic.\n  AVS_CACHE_ACCESS_SEQ0 = 262, // Filter prefers sequential access (low cost)\n  AVS_CACHE_ACCESS_SEQ1 = 263, // Filter needs sequential access (high cost)\n\n  AVS_CACHE_AVSPLUS_CONSTANTS = 500,    // Smaller values are reserved for classic Avisynth\n\n  AVS_CACHE_DONT_CACHE_ME = 501,              // Filters that don't need caching (eg. trim, cache etc.) should return 1 to this request\n  AVS_CACHE_SET_MIN_CAPACITY = 502,\n  AVS_CACHE_SET_MAX_CAPACITY = 503,\n  AVS_CACHE_GET_MIN_CAPACITY = 504,\n  AVS_CACHE_GET_MAX_CAPACITY = 505,\n  AVS_CACHE_GET_SIZE = 506,\n  AVS_CACHE_GET_REQUESTED_CAP = 507,\n  AVS_CACHE_GET_CAPACITY = 508,\n  AVS_CACHE_GET_MTMODE = 509,                 // Filters specify their desired MT mode, see enum MtMode\n\n  // By returning IS_CACHE_ANS to IS_CACHE_REQ, we tell the caller we are a cache\n  AVS_CACHE_IS_CACHE_REQ = 510,\n  AVS_CACHE_IS_CACHE_ANS = 511,\n  // By returning IS_MTGUARD_ANS to IS_MTGUARD_REQ, we tell the caller we are an mt guard\n  AVS_CACHE_IS_MTGUARD_REQ = 512,\n  AVS_CACHE_IS_MTGUARD_ANS = 513,\n\n  AVS_CACHE_AVSPLUS_CUDA_CONSTANTS = 600,\n\n  AVS_CACHE_GET_DEV_TYPE = 601,          // Device types a filter can return\n  AVS_CACHE_GET_CHILD_DEV_TYPE = 602,    // Device types a fitler can receive\n\n  AVS_CACHE_USER_CONSTANTS = 1000       // Smaller values are reserved for the core\n};\n\n\n\n// enums for frame property functions\n// AVSPropTypes\nenum {\n  AVS_PROPTYPE_UNSET = 'u',\n  AVS_PROPTYPE_INT = 'i',\n  AVS_PROPTYPE_FLOAT = 'f',\n  AVS_PROPTYPE_DATA = 's',\n  AVS_PROPTYPE_CLIP = 'c',\n  AVS_PROPTYPE_FRAME = 'v'\n};\n\n// AVSGetPropErrors for avs_prop_get_...\nenum {\n  AVS_GETPROPERROR_UNSET = 1,\n  AVS_GETPROPERROR_TYPE = 2,\n  AVS_GETPROPERROR_INDEX = 4\n};\n\n// AVSPropAppendMode for avs_prop_set_...\nenum {\n  AVS_PROPAPPENDMODE_REPLACE = 0,\n  AVS_PROPAPPENDMODE_APPEND = 1,\n  AVS_PROPAPPENDMODE_TOUCH = 2\n};\n\n// AvsEnvProperty for avs_get_env_property\nenum {\n  AVS_AEP_PHYSICAL_CPUS = 1,\n  AVS_AEP_LOGICAL_CPUS = 2,\n  AVS_AEP_THREADPOOL_THREADS = 3,\n  AVS_AEP_FILTERCHAIN_THREADS = 4,\n  AVS_AEP_THREAD_ID = 5,\n  AVS_AEP_VERSION = 6,\n  AVS_AEP_HOST_SYSTEM_ENDIANNESS = 7,\n  AVS_AEP_INTERFACE_VERSION = 8,\n  AVS_AEP_INTERFACE_BUGFIX = 9,\n\n  // Neo additionals\n  AVS_AEP_NUM_DEVICES = 901,\n  AVS_AEP_FRAME_ALIGN = 902,\n  AVS_AEP_PLANE_ALIGN = 903,\n\n  AVS_AEP_SUPPRESS_THREAD = 921,\n  AVS_AEP_GETFRAME_RECURSIVE = 922\n};\n\n// enum AvsAllocType for avs_allocate\nenum {\n  AVS_ALLOCTYPE_NORMAL_ALLOC = 1,\n  AVS_ALLOCTYPE_POOLED_ALLOC = 2\n};\n\n#ifdef BUILDING_AVSCORE\nAVSValue create_c_video_filter(AVSValue args, void * user_data, IScriptEnvironment * e0);\n\nstruct AVS_ScriptEnvironment {\n        IScriptEnvironment * env;\n        const char * error;\n        AVS_ScriptEnvironment(IScriptEnvironment * e = 0)\n                : env(e), error(0) {}\n};\n#endif\n\ntypedef struct AVS_Clip AVS_Clip;\ntypedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment;\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_VideoInfo\n//\n\n// AVS_VideoInfo is laid out identically to VideoInfo\ntypedef struct AVS_VideoInfo {\n  int width, height;    // width=0 means no video\n  unsigned fps_numerator, fps_denominator;\n  int num_frames;\n\n  int pixel_type;\n\n  int audio_samples_per_second;   // 0 means no audio\n  int sample_type;\n  int64_t num_audio_samples;\n  int nchannels;\n\n  // Image type properties\n  // BFF, TFF, FIELDBASED. Also used for storing Channel Mask\n  // Manipulate it through the channelmask interface calls \n  int image_type;\n} AVS_VideoInfo;\n\n// useful functions of the above\nAVSC_INLINE int avs_has_video(const AVS_VideoInfo * p)\n        { return (p->width!=0); }\n\nAVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p)\n        { return (p->audio_samples_per_second!=0); }\n\nAVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p)\n        { return !!(p->pixel_type&AVS_CS_BGR); }\n\nAVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p)\n        { return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); }\n\nAVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p)\n       { return ((p->pixel_type&AVS_CS_BGR32)==AVS_CS_BGR32) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); }\n\nAVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p)\n        { return !!(p->pixel_type&AVS_CS_YUV ); }\n\nAVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p)\n        { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }\n\nAVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); // avs+: for generic 444 check, use avs_is_yuv444\n\nAVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); // avs+: for generic 422 check, use avs_is_yuv422\n\nAVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ; // avs+: for generic 420 check, use avs_is_yuv420\n\nAVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); // avs+: for generic grayscale, use avs_is_y\n\nAVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane);\n\nAVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane);\n\nAVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels);\n\nAVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane);\n\nAVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi);\n\nAVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space);\n\n// no API for these, inline helper functions\nAVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)\n{\n  return ((p->image_type & property) == property);\n}\n\nAVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p)\n{\n  return !!(p->pixel_type & AVS_CS_PLANAR);\n}\n\nAVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p)\n{\n  return !!(p->image_type & AVS_IT_FIELDBASED);\n}\n\nAVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p)\n{\n  return ((p->image_type & AVS_IT_FIELDBASED) && (p->image_type & (AVS_IT_BFF | AVS_IT_TFF)));\n}\n\nAVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p)\n{\n  return !!(p->image_type & AVS_IT_BFF);\n}\n\nAVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p)\n{\n  return !!(p->image_type & AVS_IT_TFF);\n}\n\nAVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p)\n        { return p->audio_samples_per_second; }\n\nAVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p)\n{\n    switch (p->sample_type) {\n      case AVS_SAMPLE_INT8:  return sizeof(signed char);\n      case AVS_SAMPLE_INT16: return sizeof(signed short);\n      case AVS_SAMPLE_INT24: return 3;\n      case AVS_SAMPLE_INT32: return sizeof(signed int);\n      case AVS_SAMPLE_FLOAT: return sizeof(float);\n      default: return 0;\n    }\n}\n\nAVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p)\n        { return p->nchannels*avs_bytes_per_channel_sample(p);}\n\nAVSC_INLINE int64_t avs_audio_samples_from_frames(const AVS_VideoInfo * p, int64_t frames)\n        { return ((int64_t)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); }\n\nAVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, int64_t samples)\n        { return (int)(samples * (int64_t)p->fps_numerator / (int64_t)p->fps_denominator / (int64_t)p->audio_samples_per_second); }\n\nAVSC_INLINE int64_t avs_audio_samples_from_bytes(const AVS_VideoInfo * p, int64_t bytes)\n        { return bytes / avs_bytes_per_audio_sample(p); }\n\nAVSC_INLINE int64_t avs_bytes_from_audio_samples(const AVS_VideoInfo * p, int64_t samples)\n        { return samples * avs_bytes_per_audio_sample(p); }\n\nAVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p)\n        { return p->nchannels; }\n\nAVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p)\n        { return p->sample_type;}\n\n// useful mutator\n// Note: these are video format properties, neither frame properties, nor system properties\nAVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property)\n        { p->image_type|=property; }\n\nAVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property)\n        { p->image_type&=~property; }\n\nAVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased)\n        { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; }\n\nAVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)\n{\n    unsigned x=numerator, y=denominator;\n    while (y) {   // find gcd\n      unsigned t = x%y; x = y; y = t;\n    }\n    p->fps_numerator = numerator/x;\n    p->fps_denominator = denominator/x;\n}\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE int avs_is_same_colorspace(const AVS_VideoInfo * x, const AVS_VideoInfo * y)\n{\n        return (x->pixel_type == y->pixel_type)\n                || (avs_is_yv12(x) && avs_is_yv12(y));\n}\n#endif\n\n// AviSynth+ extensions\nAVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv444\nAVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv422\nAVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv420\nAVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); // deprecated, use avs_is_y\nAVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv444\nAVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv422\nAVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv420\nAVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); // deprecated, use avs_is_y\n\nAVSC_API(int, avs_is_444)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_422)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_420)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_y)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_num_components)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_component_size)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p);\n\n// V10\nAVSC_API(bool, avs_is_channel_mask_known)(const AVS_VideoInfo* p);\n\nAVSC_API(void, avs_set_channel_mask)(const AVS_VideoInfo* p, bool isChannelMaskKnown, unsigned int dwChannelMask);\n\nAVSC_API(unsigned int, avs_get_channel_mask)(const AVS_VideoInfo* p);\n\n// end of Avisynth+ specific\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_VideoFrame\n//\n\n// VideoFrameBuffer holds information about a memory block which is used\n// for video data.  For efficiency, instances of this class are not deleted\n// when the refcount reaches zero; instead they're stored in a linked list\n// to be reused.  The instances are deleted when the corresponding AVS\n// file is closed.\n\n// AVS_VideoFrameBuffer is laid out identically to VideoFrameBuffer\n// DO NOT USE THIS STRUCTURE DIRECTLY\ntypedef struct AVS_VideoFrameBuffer {\n  BYTE * data;\n  int data_size;\n  // sequence_number is incremented every time the buffer is changed, so\n  // that stale views can tell they're no longer valid.\n  volatile long sequence_number;\n\n  volatile long refcount;\n\n  void* device; // avs+\n} AVS_VideoFrameBuffer;\n\n// VideoFrame holds a \"window\" into a VideoFrameBuffer.\n\n// AVS_VideoFrame is laid out identically to VideoFrame\n// DO NOT USE THIS STRUCTURE DIRECTLY\ntypedef struct AVS_VideoFrame {\n  volatile long refcount;\n  AVS_VideoFrameBuffer * vfb;\n  int offset;\n  // DO NOT USE THEM DIRECTLY\n  // Use avs_get_pitch_p, avs_get_row_size_p, avs_get_height_p\n  int pitch, row_size, height;\n  int offsetU, offsetV;\n  int pitchUV;  // U&V offsets are from top of picture.\n  int row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane.\n                            // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable)\n                            // the decision on existence of UV is checked by zero pitch\n  // AVS+ extension, avisynth.h: class does not break plugins if appended here\n  int offsetA;\n  int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none\n  void* properties; // interface V8: frame properties\n  // DO NOT USE DIRECTLY\n  // Use avs_video_frame_get_pixel_type (and avs_video_frame_amend_pixel_type in special cases)\n  int pixel_type; // Interface V10: an automatically maintained copy from AVS_VideoInfo\n} AVS_VideoFrame;\n\n// Access functions for AVS_VideoFrame\nAVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p);\n\n// V9\nAVSC_API(int, avs_is_property_writable)(const AVS_VideoFrame* p);\n\nAVSC_API(BYTE *, avs_get_write_ptr_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *);\n// makes a shallow copy of a video frame\nAVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *);\n\n// V10\nAVSC_API(int, avs_video_frame_get_pixel_type)(const AVS_VideoFrame* p);\n// V10\nAVSC_API(void, avs_video_frame_amend_pixel_type)(AVS_VideoFrame* p, int new_pixel_type);\n\n// no API for these, inline helper functions\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) {\n  return avs_get_pitch_p(p, 0);\n}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) {\n        return avs_get_row_size_p(p, 0); }\n#endif\n\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) {\n  return avs_get_height_p(p, 0);\n}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) {\n        return avs_get_read_ptr_p(p, 0);}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) {\n        return avs_get_write_ptr_p(p, 0);}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE void avs_release_frame(AVS_VideoFrame * f)\n  {avs_release_video_frame(f);}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f)\n  {return avs_copy_video_frame(f);}\n#endif\n\n// Interface V8: frame properties\n// AVS_Map is just a placeholder for AVSMap\ntypedef struct AVS_Map {\n  void* data;\n} AVS_Map;\n\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_Value\n//\n\n// Treat AVS_Value as a fat pointer.  That is use avs_copy_value\n// and avs_release_value appropriately as you would if AVS_Value was\n// a pointer.\n\n// To maintain source code compatibility with future versions of the\n// avisynth_c API don't use the AVS_Value directly.  Use the helper\n// functions below.\n\n// AVS_Value is laid out identically to AVSValue\ntypedef struct AVS_Value AVS_Value;\nstruct AVS_Value {\n  short type;  // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong, or fu'n'ction\n               // for some function e'rror\n  short array_size;\n  union {\n    void * clip; // do not use directly, use avs_take_clip\n    char boolean;\n    int integer;\n    float floating_pt;\n    const char * string;\n    const AVS_Value * array;\n    void * function; // not supported on C interface\n#ifdef X86_64\n    // if ever, only x64 will support. It breaks struct size on 32 bit\n    int64_t longlong; // 8 bytes\n    double double_pt; // 8 bytes\n#endif\n  } d;\n};\n\n// AVS_Value should be initialized with avs_void.\n// Should also set to avs_void after the value is released\n// with avs_copy_value.  Consider it the equivalent of setting\n// a pointer to NULL\nstatic const AVS_Value avs_void = {'v'};\n\nAVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src);\nAVSC_API(void, avs_release_value)(AVS_Value);\nAVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);\nAVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *);\n\n\n// no API for these, inline helper functions\nAVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; }\nAVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; }\nAVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; }\nAVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; }\nAVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; }\nAVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; }\nAVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; }\nAVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; }\n\nAVSC_INLINE int avs_as_bool(AVS_Value v)\n        { return v.d.boolean; }\nAVSC_INLINE int avs_as_int(AVS_Value v)\n        { return v.d.integer; }\nAVSC_INLINE const char * avs_as_string(AVS_Value v)\n        { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }\nAVSC_INLINE double avs_as_float(AVS_Value v)\n        { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; }\nAVSC_INLINE const char * avs_as_error(AVS_Value v)\n        { return avs_is_error(v) ? v.d.string : 0; }\nAVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)\n        { return v.d.array; }\nAVSC_INLINE int avs_array_size(AVS_Value v)\n        { return avs_is_array(v) ? v.array_size : 1; }\nAVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)\n        { return avs_is_array(v) ? v.d.array[index] : v; }\n\n// only use these functions on an AVS_Value that does not already have\n// an active value.  Remember, treat AVS_Value as a fat pointer.\nAVSC_INLINE AVS_Value avs_new_value_bool(int v0)\n        { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }\nAVSC_INLINE AVS_Value avs_new_value_int(int v0)\n        { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; }\nAVSC_INLINE AVS_Value avs_new_value_string(const char * v0)\n        { AVS_Value v; v.type = 's'; v.d.string = v0; return v; }\nAVSC_INLINE AVS_Value avs_new_value_float(float v0)\n        { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}\nAVSC_INLINE AVS_Value avs_new_value_error(const char * v0)\n        { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; }\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0)\n        { AVS_Value v; avs_set_to_clip(&v, v0); return v; }\n#endif\nAVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size)\n        { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; }\n// end of inline helper functions\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_Clip\n//\n\nAVSC_API(void, avs_release_clip)(AVS_Clip *);\nAVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *);\n\nAVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error\n\nAVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *);\n\nAVSC_API(int, avs_get_version)(AVS_Clip *);\n\nAVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n);\n// The returned video frame must be released with avs_release_video_frame\n\nAVSC_API(int, avs_get_parity)(AVS_Clip *, int n);\n// return field parity if field_based, else parity of first field in frame\n\nAVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf,\n                             int64_t start, int64_t count);\n// start and count are in samples\n\nAVSC_API(int, avs_set_cache_hints)(AVS_Clip *,\n                                   int cachehints, int frame_range);\n\n// This is the callback type used by avs_add_function\ntypedef AVS_Value (AVSC_CC * AVS_ApplyFunc)\n                        (AVS_ScriptEnvironment *, AVS_Value args, void * user_data);\n\ntypedef struct AVS_FilterInfo AVS_FilterInfo;\nstruct AVS_FilterInfo\n{\n  // these members should not be modified outside of the AVS_ApplyFunc callback\n  AVS_Clip * child;\n  AVS_VideoInfo vi;\n  AVS_ScriptEnvironment * env;\n  AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);\n  int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);\n  int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf,\n                                  int64_t start, int64_t count);\n  int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints,\n                                        int frame_range);\n  void (AVSC_CC * free_filter)(AVS_FilterInfo *);\n\n  // Should be set when ever there is an error to report.\n  // It is cleared before any of the above methods are called\n  const char * error;\n  // this is to store whatever and may be modified at will\n  void * user_data;\n};\n\n// Create a new filter\n// fi is set to point to the AVS_FilterInfo so that you can\n//   modify it once it is initialized.\n// store_child should generally be set to true.  If it is not\n//    set than ALL methods (the function pointers) must be defined\n// If it is set than you do not need to worry about freeing the child\n//    clip.\nAVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,\n                                       AVS_FilterInfo * * fi,\n                                       AVS_Value child, int store_child);\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_ScriptEnvironment\n//\n\n// For GetCPUFlags.  These are backwards-compatible with those in VirtualDub.\nenum {\n                                /* slowest CPU to support extension */\n  AVS_CPU_FORCE        = 0x01,   // N/A\n  AVS_CPU_FPU          = 0x02,   // 386/486DX\n  AVS_CPU_MMX          = 0x04,   // P55C, K6, PII\n  AVS_CPU_INTEGER_SSE  = 0x08,   // PIII, Athlon\n  AVS_CPU_SSE          = 0x10,   // PIII, Athlon XP/MP\n  AVS_CPU_SSE2         = 0x20,   // PIV, Hammer\n  AVS_CPU_3DNOW        = 0x40,   // K6-2\n  AVS_CPU_3DNOW_EXT    = 0x80,   // Athlon\n  AVS_CPU_X86_64       = 0xA0,   // Hammer (note: equiv. to 3DNow + SSE2,\n                                 // which only Hammer will have anyway)\n  AVS_CPUF_SSE3       = 0x100,   //  PIV+, K8 Venice\n  AVS_CPUF_SSSE3      = 0x200,   //  Core 2\n  AVS_CPUF_SSE4       = 0x400,   //  Penryn, Wolfdale, Yorkfield\n  AVS_CPUF_SSE4_1     = 0x400,\n  AVS_CPUF_AVX        = 0x800,   //  Sandy Bridge, Bulldozer\n  AVS_CPUF_SSE4_2    = 0x1000,   //  Nehalem\n  // AVS+\n  AVS_CPUF_AVX2      = 0x2000,   //  Haswell\n  AVS_CPUF_FMA3      = 0x4000,\n  AVS_CPUF_F16C      = 0x8000,\n  AVS_CPUF_MOVBE     = 0x10000,   // Big Endian Move\n  AVS_CPUF_POPCNT    = 0x20000,\n  AVS_CPUF_AES       = 0x40000,\n  AVS_CPUF_FMA4      = 0x80000,\n\n  AVS_CPUF_AVX512F    = 0x100000,  // AVX-512 Foundation.\n  AVS_CPUF_AVX512DQ   = 0x200000,  // AVX-512 DQ (Double/Quad granular) Instructions\n  AVS_CPUF_AVX512PF   = 0x400000,  // AVX-512 Prefetch\n  AVS_CPUF_AVX512ER   = 0x800000,  // AVX-512 Exponential and Reciprocal\n  AVS_CPUF_AVX512CD   = 0x1000000, // AVX-512 Conflict Detection\n  AVS_CPUF_AVX512BW   = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions\n  AVS_CPUF_AVX512VL   = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions\n  AVS_CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit\n  AVS_CPUF_AVX512VBMI = 0x10000000 // AVX-512 VBMI\n};\n\n\nAVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error\n\nAVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *);\nAVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);\n\nAVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length);\nAVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...);\n\nAVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, va_list val);\n\nAVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *,\n                                const char * name, const char * params,\n                                AVS_ApplyFunc apply, void * user_data);\n\nAVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name);\n\nAVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name,\n                               AVS_Value args, const char** arg_names);\n// The returned value must be be released with avs_release_value\n\nAVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name);\n// The returned value must be be released with avs_release_value\n\nAVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val);\n\nAVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val);\n\n//void avs_push_context(AVS_ScriptEnvironment *, int level=0);\n//void avs_pop_context(AVS_ScriptEnvironment *);\n\n// partially deprecated, from V8 use avs_new_video_frame_p_a (frame property copy)\nAVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *,\n                                          const AVS_VideoInfo * vi, int align);\n// align should be at least 16 for classic Avisynth\n// Avisynth+: any value, Avs+ ensures a minimum alignment if too small align is provided\n\n// no API for these, inline helper functions\n#ifndef AVSC_NO_DECLSPEC\n// partially deprecated, from V8 use avs_new_video_frame_p (frame property copy)\n// this inline function is calling an API function\nAVSC_INLINE AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env,\n                                     const AVS_VideoInfo * vi)\n  {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}\n\n// an older compatibility alias\n// this inline function is calling an API function\nAVSC_INLINE AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env,\n                               const AVS_VideoInfo * vi)\n  {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}\n#endif\n// end of inline helper functions\n\nAVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);\n\n// V9\nAVSC_API(int, avs_make_property_writable)(AVS_ScriptEnvironment*, AVS_VideoFrame** pvf);\n\nAVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height);\n\ntypedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env);\nAVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);\n\nAVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height);\n// The returned video frame must be be released\nAVSC_API(AVS_VideoFrame*, avs_subframe_planar)(AVS_ScriptEnvironment*, AVS_VideoFrame* src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV);\n// The returned video frame must be be released\n// see also avs_subframe_planar_a in interface V8\n\nAVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);\n\nAVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);\n\n// avisynth.dll exports this; it's a way to use it as a library, without\n// writing an AVS script or without going through AVIFile.\nAVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);\n\n// this symbol is the entry point for the plugin and must\n// be defined\nAVSC_EXPORT\nconst char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env);\n\n\nAVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *);\n\n///////////////////////////////////////////////////////////////////////////////\n//\n// Avisynth+ V8 interface elements\n//\n\nAVSC_API(AVS_VideoFrame*, avs_subframe_planar_a)(AVS_ScriptEnvironment*, AVS_VideoFrame* src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA);\n// The returned video frame must be be released\n\nAVSC_API(void, avs_copy_frame_props)(AVS_ScriptEnvironment* p, const AVS_VideoFrame* src, AVS_VideoFrame* dst);\nAVSC_API(const AVS_Map*, avs_get_frame_props_ro)(AVS_ScriptEnvironment* p, const AVS_VideoFrame* frame);\nAVSC_API(AVS_Map*, avs_get_frame_props_rw)(AVS_ScriptEnvironment* p, AVS_VideoFrame* frame);\nAVSC_API(int, avs_prop_num_keys)(AVS_ScriptEnvironment* p, const AVS_Map* map);\nAVSC_API(const char*, avs_prop_get_key)(AVS_ScriptEnvironment* p, const AVS_Map* map, int index);\nAVSC_API(int, avs_prop_num_elements)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key);\n\n// see AVS_PROPTYPE_... enums\nAVSC_API(char, avs_prop_get_type)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key);\n\n// see AVS_GETPROPERROR_... enums\nAVSC_API(int64_t, avs_prop_get_int)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\nAVSC_API(double, avs_prop_get_float)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\n// Note: avs_prop_get_data was fixed in interface V9.1\nAVSC_API(const char*, avs_prop_get_data)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\nAVSC_API(int, avs_prop_get_data_size)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\nAVSC_API(AVS_Clip*, avs_prop_get_clip)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\nAVSC_API(const AVS_VideoFrame*, avs_prop_get_frame)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\n\nAVSC_API(int, avs_prop_delete_key)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key);\n\n// see AVS_PROPAPPENDMODE_... enums\nAVSC_API(int, avs_prop_set_int)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, int64_t i, int append);\nAVSC_API(int, avs_prop_set_float)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, double d, int append);\nAVSC_API(int, avs_prop_set_data)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const char* d, int length, int append);\nAVSC_API(int, avs_prop_set_clip)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, AVS_Clip* clip, int append);\nAVSC_API(int, avs_prop_set_frame)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const AVS_VideoFrame* frame, int append);\n\nAVSC_API(const int64_t*, avs_prop_get_int_array)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int* error);\nAVSC_API(const double*, avs_prop_get_float_array)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int* error);\nAVSC_API(int, avs_prop_set_int_array)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const int64_t* i, int size);\nAVSC_API(int, avs_prop_set_float_array)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const double* d, int size);\n\nAVSC_API(void, avs_clear_map)(AVS_ScriptEnvironment* p, AVS_Map* map);\n\n// with frame property source\nAVSC_API(AVS_VideoFrame*, avs_new_video_frame_p)(AVS_ScriptEnvironment*,\n  const AVS_VideoInfo* vi, const AVS_VideoFrame* prop_src);\n\n// with frame property source\nAVSC_API(AVS_VideoFrame*, avs_new_video_frame_p_a)(AVS_ScriptEnvironment*,\n  const AVS_VideoInfo* vi, const AVS_VideoFrame* prop_src, int align);\n\n// Generic query to ask for various system properties, see AVS_AEP_xxx enums\nAVSC_API(size_t, avs_get_env_property)(AVS_ScriptEnvironment*, int avs_aep_prop);\n\n// buffer pool, see AVS_ALLOCTYPE enums\nAVSC_API(void *, avs_pool_allocate)(AVS_ScriptEnvironment*, size_t nBytes, size_t alignment, int avs_alloc_type);\nAVSC_API(void, avs_pool_free)(AVS_ScriptEnvironment*, void *ptr);\n\n// Interface V8\n// Returns TRUE (1) and the requested variable. If the method fails, returns 0 (FALSE) and does not touch 'val'.\n// The returned AVS_Value *val value must be be released with avs_release_value only on success\n// AVS_Value *val is not caller allocated\nAVSC_API(int, avs_get_var_try)(AVS_ScriptEnvironment*, const char* name, AVS_Value* val);\n\n// Interface V8\n// Return the value of the requested variable.\n// If the variable was not found or had the wrong type,\n// return the supplied default value.\nAVSC_API(int, avs_get_var_bool)(AVS_ScriptEnvironment*, const char* name, int def);\nAVSC_API(int, avs_get_var_int)(AVS_ScriptEnvironment*, const char* name, int def);\nAVSC_API(double, avs_get_var_double)(AVS_ScriptEnvironment*, const char* name, double def);\nAVSC_API(const char*, avs_get_var_string)(AVS_ScriptEnvironment*, const char* name, const char* def);\nAVSC_API(int64_t, avs_get_var_long)(AVS_ScriptEnvironment*, const char* name, int64_t def);\n\n#if defined(AVS_WINDOWS)\n// The following stuff is only relevant for Windows DLL handling; Linux does it completely differently.\n#ifdef AVSC_NO_DECLSPEC\n// This part uses LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport)\n// When AVSC_NO_DECLSPEC is defined, you can use avs_load_library to populate API functions into a struct\n// AVSC_INLINE functions which call onto an API functions should be treated specially (todo)\n\n/*\n  The following functions needs to have been declared, probably from windows.h\n\n  void* malloc(size_t)\n  void free(void*);\n\n  HMODULE LoadLibraryA(const char*);\n  void* GetProcAddress(HMODULE, const char*);\n  FreeLibrary(HMODULE);\n*/\n\n\ntypedef struct AVS_Library AVS_Library;\n\n#define AVSC_DECLARE_FUNC(name) name##_func name\n\n// AVSC_DECLARE_FUNC helps keeping naming convention: type is xxxxx_func, function name is xxxxx\n// e.g. \"AVSC_DECLARE_FUNC(avs_add_function);\"\n// is a shortcut for \"avs_add_function_func avs_add_function;\"\n\n// Note: AVSC_INLINE functions, which call into API,\n// are guarded by #ifndef AVSC_NO_DECLSPEC.\n// They should call the appropriate library-> API entry.\n\nstruct AVS_Library {\n  HMODULE handle;\n\n  AVSC_DECLARE_FUNC(avs_add_function);\n  AVSC_DECLARE_FUNC(avs_at_exit);\n  AVSC_DECLARE_FUNC(avs_bit_blt);\n  AVSC_DECLARE_FUNC(avs_check_version);\n  AVSC_DECLARE_FUNC(avs_clip_get_error);\n  AVSC_DECLARE_FUNC(avs_copy_clip);\n  AVSC_DECLARE_FUNC(avs_copy_value);\n  AVSC_DECLARE_FUNC(avs_copy_video_frame);\n  AVSC_DECLARE_FUNC(avs_create_script_environment);\n  AVSC_DECLARE_FUNC(avs_delete_script_environment);\n  AVSC_DECLARE_FUNC(avs_function_exists);\n  AVSC_DECLARE_FUNC(avs_get_audio);\n  AVSC_DECLARE_FUNC(avs_get_cpu_flags);\n  AVSC_DECLARE_FUNC(avs_get_frame);\n  AVSC_DECLARE_FUNC(avs_get_parity);\n  AVSC_DECLARE_FUNC(avs_get_var);\n  AVSC_DECLARE_FUNC(avs_get_version);\n  AVSC_DECLARE_FUNC(avs_get_video_info);\n  AVSC_DECLARE_FUNC(avs_invoke);\n  AVSC_DECLARE_FUNC(avs_make_writable);\n  AVSC_DECLARE_FUNC(avs_new_c_filter);\n  AVSC_DECLARE_FUNC(avs_new_video_frame_a);\n  AVSC_DECLARE_FUNC(avs_release_clip);\n  AVSC_DECLARE_FUNC(avs_release_value);\n  AVSC_DECLARE_FUNC(avs_release_video_frame);\n  AVSC_DECLARE_FUNC(avs_save_string);\n  AVSC_DECLARE_FUNC(avs_set_cache_hints);\n  AVSC_DECLARE_FUNC(avs_set_global_var);\n  AVSC_DECLARE_FUNC(avs_set_memory_max);\n  AVSC_DECLARE_FUNC(avs_set_to_clip);\n  AVSC_DECLARE_FUNC(avs_set_var);\n  AVSC_DECLARE_FUNC(avs_set_working_dir);\n  AVSC_DECLARE_FUNC(avs_sprintf);\n  AVSC_DECLARE_FUNC(avs_subframe);\n  AVSC_DECLARE_FUNC(avs_subframe_planar);\n  AVSC_DECLARE_FUNC(avs_take_clip);\n  AVSC_DECLARE_FUNC(avs_vsprintf);\n\n  AVSC_DECLARE_FUNC(avs_get_error);\n  AVSC_DECLARE_FUNC(avs_is_yv24);\n  AVSC_DECLARE_FUNC(avs_is_yv16);\n  AVSC_DECLARE_FUNC(avs_is_yv12);\n  AVSC_DECLARE_FUNC(avs_is_yv411);\n  AVSC_DECLARE_FUNC(avs_is_y8);\n  AVSC_DECLARE_FUNC(avs_is_color_space);\n\n  AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling);\n  AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling);\n  AVSC_DECLARE_FUNC(avs_bits_per_pixel);\n  AVSC_DECLARE_FUNC(avs_bytes_from_pixels);\n  AVSC_DECLARE_FUNC(avs_row_size);\n  AVSC_DECLARE_FUNC(avs_bmp_size);\n  AVSC_DECLARE_FUNC(avs_get_pitch_p);\n  AVSC_DECLARE_FUNC(avs_get_row_size_p);\n  AVSC_DECLARE_FUNC(avs_get_height_p);\n  AVSC_DECLARE_FUNC(avs_get_read_ptr_p);\n  AVSC_DECLARE_FUNC(avs_is_writable);\n  AVSC_DECLARE_FUNC(avs_get_write_ptr_p);\n\n  // Avisynth+ specific\n  // Note: these functions are simulated/use fallback to existing functions\n  AVSC_DECLARE_FUNC(avs_is_rgb48);\n  AVSC_DECLARE_FUNC(avs_is_rgb64);\n  AVSC_DECLARE_FUNC(avs_is_yuv444p16);\n  AVSC_DECLARE_FUNC(avs_is_yuv422p16);\n  AVSC_DECLARE_FUNC(avs_is_yuv420p16);\n  AVSC_DECLARE_FUNC(avs_is_y16);\n  AVSC_DECLARE_FUNC(avs_is_yuv444ps);\n  AVSC_DECLARE_FUNC(avs_is_yuv422ps);\n  AVSC_DECLARE_FUNC(avs_is_yuv420ps);\n  AVSC_DECLARE_FUNC(avs_is_y32);\n  AVSC_DECLARE_FUNC(avs_is_444);\n  AVSC_DECLARE_FUNC(avs_is_422);\n  AVSC_DECLARE_FUNC(avs_is_420);\n  AVSC_DECLARE_FUNC(avs_is_y);\n  AVSC_DECLARE_FUNC(avs_is_yuva);\n  AVSC_DECLARE_FUNC(avs_is_planar_rgb);\n  AVSC_DECLARE_FUNC(avs_is_planar_rgba);\n  AVSC_DECLARE_FUNC(avs_num_components);\n  AVSC_DECLARE_FUNC(avs_component_size);\n  AVSC_DECLARE_FUNC(avs_bits_per_component);\n\n  ///////////////////////////////////////////////////////////////////////////////\n  // Avisynth+ new interface elements from interface version 8\n  // avs_subframe_planar with alpha support\n  AVSC_DECLARE_FUNC(avs_subframe_planar_a);\n\n  // frame properties\n  AVSC_DECLARE_FUNC(avs_copy_frame_props);\n  AVSC_DECLARE_FUNC(avs_get_frame_props_ro);\n  AVSC_DECLARE_FUNC(avs_get_frame_props_rw);\n  AVSC_DECLARE_FUNC(avs_prop_num_keys);\n  AVSC_DECLARE_FUNC(avs_prop_get_key);\n  AVSC_DECLARE_FUNC(avs_prop_num_elements);\n  AVSC_DECLARE_FUNC(avs_prop_get_type);\n  AVSC_DECLARE_FUNC(avs_prop_get_int);\n  AVSC_DECLARE_FUNC(avs_prop_get_float);\n  AVSC_DECLARE_FUNC(avs_prop_get_data);\n  AVSC_DECLARE_FUNC(avs_prop_get_data_size);\n  AVSC_DECLARE_FUNC(avs_prop_get_clip);\n  AVSC_DECLARE_FUNC(avs_prop_get_frame);\n  AVSC_DECLARE_FUNC(avs_prop_delete_key);\n  AVSC_DECLARE_FUNC(avs_prop_set_int);\n  AVSC_DECLARE_FUNC(avs_prop_set_float);\n  AVSC_DECLARE_FUNC(avs_prop_set_data);\n  AVSC_DECLARE_FUNC(avs_prop_set_clip);\n  AVSC_DECLARE_FUNC(avs_prop_set_frame);\n\n  AVSC_DECLARE_FUNC(avs_prop_get_int_array);\n  AVSC_DECLARE_FUNC(avs_prop_get_float_array);\n  AVSC_DECLARE_FUNC(avs_prop_set_int_array);\n  AVSC_DECLARE_FUNC(avs_prop_set_float_array);\n\n  AVSC_DECLARE_FUNC(avs_clear_map);\n\n  // NewVideoFrame with frame properties\n  AVSC_DECLARE_FUNC(avs_new_video_frame_p);\n  AVSC_DECLARE_FUNC(avs_new_video_frame_p_a);\n\n  AVSC_DECLARE_FUNC(avs_get_env_property);\n\n  AVSC_DECLARE_FUNC(avs_get_var_try);\n  AVSC_DECLARE_FUNC(avs_get_var_bool);\n  AVSC_DECLARE_FUNC(avs_get_var_int);\n  AVSC_DECLARE_FUNC(avs_get_var_double);\n  AVSC_DECLARE_FUNC(avs_get_var_string);\n  AVSC_DECLARE_FUNC(avs_get_var_long);\n\n  AVSC_DECLARE_FUNC(avs_pool_allocate);\n  AVSC_DECLARE_FUNC(avs_pool_free);\n\n  // V9\n  AVSC_DECLARE_FUNC(avs_is_property_writable);\n  AVSC_DECLARE_FUNC(avs_make_property_writable);\n\n  // V10\n  AVSC_DECLARE_FUNC(avs_video_frame_get_pixel_type);\n  AVSC_DECLARE_FUNC(avs_video_frame_amend_pixel_type);\n\n  // V10\n  AVSC_DECLARE_FUNC(avs_is_channel_mask_known);\n  AVSC_DECLARE_FUNC(avs_set_channel_mask);\n  AVSC_DECLARE_FUNC(avs_get_channel_mask);\n\n};\n\n#undef AVSC_DECLARE_FUNC\n\n#ifdef AVS26_FALLBACK_SIMULATION\n// Helper functions for fallback simulation\n// Avisynth+ extensions do not exist in classic Avisynth so they are simulated\nAVSC_INLINE int avs_is_xx_fallback_return_false(const AVS_VideoInfo * p)\n{\n  return 0;\n}\n\n// Avisynth+ extensions do not exist in classic Avisynth so they are simulated\nAVSC_INLINE int avs_num_components_fallback(const AVS_VideoInfo * p)\n{\n  switch (p->pixel_type) {\n  case AVS_CS_UNKNOWN:\n    return 0;\n  case AVS_CS_RAW32:\n  case AVS_CS_Y8:\n    return 1;\n  case AVS_CS_BGR32:\n    return 4; // not planar but return the count\n  default:\n    return 3;\n  }\n}\n\n// Avisynth+ extensions do not exist in classic Avisynth so they are simulated\nAVSC_INLINE int avs_component_size_fallback(const AVS_VideoInfo * p)\n{\n  return 1;\n}\n\n// Avisynth+ extensions do not exist in classic Avisynth so they are simulated\nAVSC_INLINE int avs_bits_per_component_fallback(const AVS_VideoInfo * p)\n{\n  return 8;\n}\n// End of helper functions for fallback simulation\n#endif // AVS26_FALLBACK_SIMULATION\n\n// avs_load_library() allocates an array for API procedure entries\n// reads and fills the entries with live procedure addresses.\n// AVSC_INLINE helpers which are calling into API procedures are not treated here (todo)\n\nAVSC_INLINE AVS_Library * avs_load_library() {\n  AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library));\n  if (library == NULL)\n    return NULL;\n  library->handle = LoadLibraryA(\"avisynth\");\n  if (library->handle == NULL)\n    goto fail;\n\n#define __AVSC_STRINGIFY(x) #x\n#define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x)\n#define AVSC_LOAD_FUNC(name) {\\\n  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\\\n  if (library->name == NULL)\\\n    goto fail;\\\n}\n\n#ifdef AVS26_FALLBACK_SIMULATION\n// When an API function is not loadable, let's try a replacement\n// Missing Avisynth+ functions will be substituted with classic Avisynth compatible methods\n/*\nAvisynth+                 When method is missing (classic Avisynth)\navs_is_rgb48              constant false\navs_is_rgb64              constant false\navs_is_444                avs_is_yv24\navs_is_422                avs_is_yv16\navs_is_420                avs_is_yv12\navs_is_y                  avs_is_y8\navs_is_yuva               constant false\navs_is_planar_rgb         constant false\navs_is_planar_rgba        constant false\navs_num_components        special: avs_num_components_fake Y8:1 RGB32:4 else 3\navs_component_size        constant 1 (1 bytes/component)\navs_bits_per_component    constant 8 (8 bits/component)\n*/\n\n  // try to load an alternative function\n#define AVSC_LOAD_FUNC_FALLBACK(name,name2) {\\\n  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\\\n  if (library->name == NULL)\\\n    library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name2));\\\n  if (library->name == NULL)\\\n    goto fail;\\\n}\n\n  // try to assign a replacement function\n#define AVSC_LOAD_FUNC_FALLBACK_SIMULATED(name,name2) {\\\n  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\\\n  if (library->name == NULL)\\\n    library->name = name2;\\\n  if (library->name == NULL)\\\n    goto fail;\\\n}\n#endif // AVS26_FALLBACK_SIMULATION\n\n  AVSC_LOAD_FUNC(avs_add_function);\n  AVSC_LOAD_FUNC(avs_at_exit);\n  AVSC_LOAD_FUNC(avs_bit_blt);\n  AVSC_LOAD_FUNC(avs_check_version);\n  AVSC_LOAD_FUNC(avs_clip_get_error);\n  AVSC_LOAD_FUNC(avs_copy_clip);\n  AVSC_LOAD_FUNC(avs_copy_value);\n  AVSC_LOAD_FUNC(avs_copy_video_frame);\n  AVSC_LOAD_FUNC(avs_create_script_environment);\n  AVSC_LOAD_FUNC(avs_delete_script_environment);\n  AVSC_LOAD_FUNC(avs_function_exists);\n  AVSC_LOAD_FUNC(avs_get_audio);\n  AVSC_LOAD_FUNC(avs_get_cpu_flags);\n  AVSC_LOAD_FUNC(avs_get_frame);\n  AVSC_LOAD_FUNC(avs_get_parity);\n  AVSC_LOAD_FUNC(avs_get_var);\n  AVSC_LOAD_FUNC(avs_get_version);\n  AVSC_LOAD_FUNC(avs_get_video_info);\n  AVSC_LOAD_FUNC(avs_invoke);\n  AVSC_LOAD_FUNC(avs_make_writable);\n  AVSC_LOAD_FUNC(avs_new_c_filter);\n  AVSC_LOAD_FUNC(avs_new_video_frame_a);\n\n\n\n  AVSC_LOAD_FUNC(avs_release_clip);\n  AVSC_LOAD_FUNC(avs_release_value);\n  AVSC_LOAD_FUNC(avs_release_video_frame);\n  AVSC_LOAD_FUNC(avs_save_string);\n  AVSC_LOAD_FUNC(avs_set_cache_hints);\n  AVSC_LOAD_FUNC(avs_set_global_var);\n  AVSC_LOAD_FUNC(avs_set_memory_max);\n  AVSC_LOAD_FUNC(avs_set_to_clip);\n  AVSC_LOAD_FUNC(avs_set_var);\n  AVSC_LOAD_FUNC(avs_set_working_dir);\n  AVSC_LOAD_FUNC(avs_sprintf);\n  AVSC_LOAD_FUNC(avs_subframe);\n  AVSC_LOAD_FUNC(avs_subframe_planar);\n  AVSC_LOAD_FUNC(avs_take_clip);\n  AVSC_LOAD_FUNC(avs_vsprintf);\n\n  AVSC_LOAD_FUNC(avs_get_error);\n  AVSC_LOAD_FUNC(avs_is_yv24);\n  AVSC_LOAD_FUNC(avs_is_yv16);\n  AVSC_LOAD_FUNC(avs_is_yv12);\n  AVSC_LOAD_FUNC(avs_is_yv411);\n  AVSC_LOAD_FUNC(avs_is_y8);\n  AVSC_LOAD_FUNC(avs_is_color_space);\n\n  AVSC_LOAD_FUNC(avs_get_plane_width_subsampling);\n  AVSC_LOAD_FUNC(avs_get_plane_height_subsampling);\n  AVSC_LOAD_FUNC(avs_bits_per_pixel);\n  AVSC_LOAD_FUNC(avs_bytes_from_pixels);\n  AVSC_LOAD_FUNC(avs_row_size);\n  AVSC_LOAD_FUNC(avs_bmp_size);\n  AVSC_LOAD_FUNC(avs_get_pitch_p);\n  AVSC_LOAD_FUNC(avs_get_row_size_p);\n  AVSC_LOAD_FUNC(avs_get_height_p);\n  AVSC_LOAD_FUNC(avs_get_read_ptr_p);\n  AVSC_LOAD_FUNC(avs_is_writable);\n  AVSC_LOAD_FUNC(avs_get_write_ptr_p);\n\n  // Avisynth+ specific\n#ifdef AVS26_FALLBACK_SIMULATION\n  // replace with fallback fn when does not exist\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb48, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb64, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK(avs_is_444, avs_is_yv24);\n  AVSC_LOAD_FUNC_FALLBACK(avs_is_422, avs_is_yv16);\n  AVSC_LOAD_FUNC_FALLBACK(avs_is_420, avs_is_yv12);\n  AVSC_LOAD_FUNC_FALLBACK(avs_is_y, avs_is_y8);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuva, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgb, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgba, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_num_components, avs_num_components_fallback);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_component_size, avs_component_size_fallback);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_bits_per_component, avs_bits_per_component_fallback);\n#else\n  // Avisynth+ specific\n  AVSC_LOAD_FUNC(avs_is_rgb48);\n  AVSC_LOAD_FUNC(avs_is_rgb64);\n  AVSC_LOAD_FUNC(avs_is_444);\n  AVSC_LOAD_FUNC(avs_is_422);\n  AVSC_LOAD_FUNC(avs_is_420);\n  AVSC_LOAD_FUNC(avs_is_y);\n  AVSC_LOAD_FUNC(avs_is_yuva);\n  AVSC_LOAD_FUNC(avs_is_planar_rgb);\n  AVSC_LOAD_FUNC(avs_is_planar_rgba);\n  AVSC_LOAD_FUNC(avs_num_components);\n  AVSC_LOAD_FUNC(avs_component_size);\n  AVSC_LOAD_FUNC(avs_bits_per_component);\n#endif\n  // Avisynth+ interface V8, no backward compatible simulation\n  AVSC_LOAD_FUNC(avs_subframe_planar_a);\n  // frame properties\n  AVSC_LOAD_FUNC(avs_copy_frame_props);\n  AVSC_LOAD_FUNC(avs_get_frame_props_ro);\n  AVSC_LOAD_FUNC(avs_get_frame_props_rw);\n  AVSC_LOAD_FUNC(avs_prop_num_keys);\n  AVSC_LOAD_FUNC(avs_prop_get_key);\n  AVSC_LOAD_FUNC(avs_prop_num_elements);\n  AVSC_LOAD_FUNC(avs_prop_get_type);\n  AVSC_LOAD_FUNC(avs_prop_get_int);\n  AVSC_LOAD_FUNC(avs_prop_get_float);\n  AVSC_LOAD_FUNC(avs_prop_get_data);\n  AVSC_LOAD_FUNC(avs_prop_get_data_size);\n  AVSC_LOAD_FUNC(avs_prop_get_clip);\n  AVSC_LOAD_FUNC(avs_prop_get_frame);\n  AVSC_LOAD_FUNC(avs_prop_delete_key);\n  AVSC_LOAD_FUNC(avs_prop_set_int);\n  AVSC_LOAD_FUNC(avs_prop_set_float);\n  AVSC_LOAD_FUNC(avs_prop_set_data);\n  AVSC_LOAD_FUNC(avs_prop_set_clip);\n  AVSC_LOAD_FUNC(avs_prop_set_frame);\n\n  AVSC_LOAD_FUNC(avs_prop_get_int_array);\n  AVSC_LOAD_FUNC(avs_prop_get_float_array);\n  AVSC_LOAD_FUNC(avs_prop_set_int_array);\n  AVSC_LOAD_FUNC(avs_prop_set_float_array);\n\n  AVSC_LOAD_FUNC(avs_clear_map);\n\n  // NewVideoFrame with frame properties\n  AVSC_LOAD_FUNC(avs_new_video_frame_p);\n  AVSC_LOAD_FUNC(avs_new_video_frame_p_a);\n\n  AVSC_LOAD_FUNC(avs_get_env_property);\n\n  AVSC_LOAD_FUNC(avs_get_var_try);\n  AVSC_LOAD_FUNC(avs_get_var_bool);\n  AVSC_LOAD_FUNC(avs_get_var_int);\n  AVSC_LOAD_FUNC(avs_get_var_double);\n  AVSC_LOAD_FUNC(avs_get_var_string);\n  AVSC_LOAD_FUNC(avs_get_var_long);\n\n  AVSC_LOAD_FUNC(avs_pool_allocate);\n  AVSC_LOAD_FUNC(avs_pool_free);\n\n  // V9\n  AVSC_LOAD_FUNC(avs_make_property_writable);\n  AVSC_LOAD_FUNC(avs_is_property_writable);\n\n  // V10\n  AVSC_LOAD_FUNC(avs_video_frame_get_pixel_type);\n  AVSC_LOAD_FUNC(avs_video_frame_amend_pixel_type);\n\n  // V10\n  AVSC_LOAD_FUNC(avs_is_channel_mask_known);\n  AVSC_LOAD_FUNC(avs_set_channel_mask);\n  AVSC_LOAD_FUNC(avs_get_channel_mask);\n\n#undef __AVSC_STRINGIFY\n#undef AVSC_STRINGIFY\n#undef AVSC_LOAD_FUNC\n#undef AVSC_LOAD_FUNC_FALLBACK\n#undef AVSC_LOAD_FUNC_FALLBACK_SIMULATED\n\n  return library;\n\nfail:\n  free(library);\n  return NULL;\n}\n\nAVSC_INLINE void avs_free_library(AVS_Library *library) {\n  if (library == NULL)\n    return;\n  FreeLibrary(library->handle);\n  free(library);\n}\n#endif\n\n#endif // AVS_WINDOWS\n\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/alignment.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n#ifndef AVS_ALIGNMENT_H\n#define AVS_ALIGNMENT_H\n\n// Functions and macros to help work with alignment requirements.\n\n// Tells if a number is a power of two.\n#define IS_POWER2(n) ((n) && !((n) & ((n) - 1)))\n\n// Tells if the pointer \"ptr\" is aligned to \"align\" bytes.\n#define IS_PTR_ALIGNED(ptr, align) (((uintptr_t)ptr & ((uintptr_t)(align-1))) == 0)\n\n// Rounds up the number \"n\" to the next greater multiple of \"align\"\n#define ALIGN_NUMBER(n, align) (((n) + (align)-1) & (~((align)-1)))\n\n// Rounds up the pointer address \"ptr\" to the next greater multiple of \"align\"\n#define ALIGN_POINTER(ptr, align) (((uintptr_t)(ptr) + (align)-1) & (~(uintptr_t)((align)-1)))\n\n#ifdef __cplusplus\n\n#include <cassert>\n#include <cstdlib>\n#include <cstdint>\n#include \"config.h\"\n\n#if defined(MSVC) && _MSC_VER<1400\n    // needed for VS2013, otherwise C++11 'alignas' works\n    #define avs_alignas(x) __declspec(align(x))\n#else\n    // assumes C++11 support\n    #define avs_alignas(x) alignas(x)\n#endif\n\ntemplate<typename T>\nstatic bool IsPtrAligned(T* ptr, size_t align)\n{\n  assert(IS_POWER2(align));\n  return (bool)IS_PTR_ALIGNED(ptr, align);\n}\n\ntemplate<typename T>\nstatic T AlignNumber(T n, T align)\n{\n  assert(IS_POWER2(align));\n  return ALIGN_NUMBER(n, align);\n}\n\ntemplate<typename T>\nstatic T* AlignPointer(T* ptr, size_t align)\n{\n  assert(IS_POWER2(align));\n  return (T*)ALIGN_POINTER(ptr, align);\n}\n\nextern \"C\"\n{\n#else\n#include <stdlib.h>\n#endif  // __cplusplus\n\n// Returns a new buffer that is at least the size \"nbytes\".\n// The buffer will be aligned to \"align\" bytes.\n// Returns NULL on error. On successful allocation,\n// the returned buffer must be freed using \"avs_free\".\ninline void* avs_malloc(size_t nbytes, size_t align)\n{\n  if (!IS_POWER2(align))\n    return NULL;\n\n  size_t offset = sizeof(void*) + align - 1;\n\n  void *orig = malloc(nbytes + offset);\n  if (orig == NULL)\n   return NULL;\n\n  void **aligned = (void**)(((uintptr_t)orig + (uintptr_t)offset) & (~(uintptr_t)(align-1)));\n  aligned[-1] = orig;\n  return aligned;\n}\n\n// Buffers allocated using \"avs_malloc\" must be freed\n// using \"avs_free\" instead of \"free\".\ninline void avs_free(void *ptr)\n{\n  // Mirroring free()'s semantic requires us to accept NULLs\n  if (ptr == NULL)\n    return;\n\n  free(((void**)ptr)[-1]);\n}\n\n#ifdef __cplusplus\n} // extern \"C\"\n\n// The point of these undef's is to force using the template functions\n// if we are in C++ mode. For C, the user can rely only on the macros.\n#undef IS_PTR_ALIGNED\n#undef ALIGN_NUMBER\n#undef ALIGN_POINTER\n\n#endif  // __cplusplus\n\n#endif  //AVS_ALIGNMENT_H\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/arch.h",
    "content": "#ifndef _AVS_ARCH_H_\n#define _AVS_ARCH_H_\n\n#define       AVS_ARCH          i386\t    \t// e.g. i386\n\n#endif  //  _AVS_ARCH_H_\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/capi.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n#ifndef AVS_CAPI_H\n#define AVS_CAPI_H\n\n#include \"config.h\"\n\n#ifdef AVS_POSIX\n// this is also defined in avs/posix.h\n#ifndef AVS_HAIKU\n#define __declspec(x)\n#endif\n#endif\n\n#ifdef __cplusplus\n#  define EXTERN_C extern \"C\"\n#else\n#  define EXTERN_C\n#endif\n\n#ifdef AVS_WINDOWS\n#ifdef BUILDING_AVSCORE\n#  if defined(GCC) && defined(X86_32)\n#    define AVSC_CC\n#  else // MSVC builds and 64-bit GCC\n#    ifndef AVSC_USE_STDCALL\n#      define AVSC_CC __cdecl\n#    else\n#      define AVSC_CC __stdcall\n#    endif\n#  endif\n#else // needed for programs that talk to AviSynth+\n#  ifndef AVSC_WIN32_GCC32 // see comment below\n#    ifndef AVSC_USE_STDCALL\n#      define AVSC_CC __cdecl\n#    else\n#      define AVSC_CC __stdcall\n#    endif\n#  else\n#    define AVSC_CC\n#  endif\n#endif\n#  else\n#    define AVSC_CC\n#endif\n\n// On 64-bit Windows, there's only one calling convention,\n// so there is no difference between MSVC and GCC. On 32-bit,\n// this isn't true. The convention that GCC needs to use to\n// even build AviSynth+ as 32-bit makes anything that uses\n// it incompatible with 32-bit MSVC builds of AviSynth+.\n// The AVSC_WIN32_GCC32 define is meant to provide a user\n// switchable way to make builds of FFmpeg to test 32-bit\n// GCC builds of AviSynth+ without having to screw around\n// with alternate headers, while still default to the usual\n// situation of using 32-bit MSVC builds of AviSynth+.\n\n// Hopefully, this situation will eventually be resolved\n// and a broadly compatible solution will arise so the\n// same 32-bit FFmpeg build can handle either MSVC or GCC\n// builds of AviSynth+.\n\n#define AVSC_INLINE static __inline\n\n#ifdef BUILDING_AVSCORE\n#ifdef AVS_WINDOWS\n#  ifndef AVS_STATIC_LIB\n#    define AVSC_EXPORT __declspec(dllexport)\n#  else\n#    define AVSC_EXPORT\n#  endif\n#  define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name\n#else\n#  define AVSC_EXPORT EXTERN_C\n#  define AVSC_API(ret, name) EXTERN_C ret AVSC_CC name\n#endif\n#else\n#  define AVSC_EXPORT EXTERN_C __declspec(dllexport)\n#  ifndef AVS_STATIC_LIB\n#    define AVSC_IMPORT __declspec(dllimport)\n#  else\n#    define AVSC_IMPORT\n#  endif\n#  ifndef AVSC_NO_DECLSPEC\n#    define AVSC_API(ret, name) EXTERN_C AVSC_IMPORT ret AVSC_CC name\n#  else\n#    define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func)\n#  endif\n#endif\n\n#endif //AVS_CAPI_H\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/config.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n#ifndef AVS_CONFIG_H\n#define AVS_CONFIG_H\n\n// Undefine this to get cdecl calling convention\n#define AVSC_USE_STDCALL 1\n\n// NOTE TO PLUGIN AUTHORS:\n// Because FRAME_ALIGN can be substantially higher than the alignment\n// a plugin actually needs, plugins should not use FRAME_ALIGN to check for\n// alignment. They should always request the exact alignment value they need.\n// This is to make sure that plugins work over the widest range of AviSynth\n// builds possible.\n#define FRAME_ALIGN 64\n\n#if   defined(_M_AMD64) || defined(__x86_64)\n#   define X86_64\n#elif defined(_M_IX86) || defined(__i386__)\n#   define X86_32\n// VS2017 introduced _M_ARM64\n#elif defined(_M_ARM64) || defined(__aarch64__)\n#   define ARM64\n#elif defined(_M_ARM) || defined(__arm__)\n#   define ARM32\n#elif defined(__PPC64__)\n#   define PPC64\n#elif defined(_M_PPC) || defined(__PPC__) || defined(__POWERPC__)\n#   define PPC32\n#elif defined(__riscv)\n#   define RISCV\n#elif defined(__sparc_v9__)\n#   define SPARC\n#elif defined(__mips__)\n#   define MIPS\n#else\n#   error Unsupported CPU architecture.\n#endif\n\n//            VC++  LLVM-Clang-cl   MinGW-Gnu\n// MSVC        x          x\n// MSVC_PURE   x\n// CLANG                  x\n// GCC                                  x\n\n#if defined(__clang__)\n// Check clang first. clang-cl also defines __MSC_VER\n// We set MSVC because they are mostly compatible\n#   define CLANG\n#if defined(_MSC_VER)\n#   define MSVC\n#   define AVS_FORCEINLINE __attribute__((always_inline))\n#else\n#   define AVS_FORCEINLINE __attribute__((always_inline)) inline\n#endif\n#elif   defined(_MSC_VER)\n#   define MSVC\n#   define MSVC_PURE\n#   define AVS_FORCEINLINE __forceinline\n#elif defined(__GNUC__)\n#   define GCC\n#   define AVS_FORCEINLINE __attribute__((always_inline)) inline\n#elif defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)\n// Intel C++ Compilers with MSVC command line interface will not appear here rather at _MSC_VER\n#   define AVS_FORCEINLINE inline\n#   undef __forceinline\n#   define __forceinline inline\n#else\n#   error Unsupported compiler.\n#   define AVS_FORCEINLINE inline\n#   undef __forceinline\n#   define __forceinline inline\n#endif\n\n#if defined(_WIN32)\n#   define AVS_WINDOWS\n#elif defined(__linux__)\n#   define AVS_LINUX\n#   define AVS_POSIX\n#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)\n#   define AVS_BSD\n#   define AVS_POSIX\n#elif defined(__APPLE__)\n#   define AVS_MACOS\n#   define AVS_POSIX\n#elif defined(__HAIKU__)\n#   define AVS_HAIKU\n#   define AVS_POSIX\n#else\n#   error Operating system unsupported.\n#endif\n\n// useful warnings disabler macros for supported compilers\n\n#if defined(_MSC_VER)\n#define DISABLE_WARNING_PUSH           __pragma(warning( push ))\n#define DISABLE_WARNING_POP            __pragma(warning( pop ))\n#define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))\n\n#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE      DISABLE_WARNING(4101)\n#define DISABLE_WARNING_UNREFERENCED_FUNCTION            DISABLE_WARNING(4505)\n// other warnings you want to deactivate...\n\n#elif defined(__GNUC__) || defined(__clang__)\n#define DO_PRAGMA(X) _Pragma(#X)\n#define DISABLE_WARNING_PUSH           DO_PRAGMA(GCC diagnostic push)\n#define DISABLE_WARNING_POP            DO_PRAGMA(GCC diagnostic pop)\n#define DISABLE_WARNING(warningName)   DO_PRAGMA(GCC diagnostic ignored #warningName)\n\n#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE      DISABLE_WARNING(-Wunused-variable)\n#define DISABLE_WARNING_UNREFERENCED_FUNCTION            DISABLE_WARNING(-Wunused-function)\n// other warnings you want to deactivate...\n\n#else\n#define DISABLE_WARNING_PUSH\n#define DISABLE_WARNING_POP\n#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE\n#define DISABLE_WARNING_UNREFERENCED_FUNCTION\n// other warnings you want to deactivate...\n\n#endif\n\n#if defined(AVS_WINDOWS) && defined(_USING_V110_SDK71_)\n// Windows XP does not have proper initialization for\n// thread local variables.\n// Use workaround instead __declspec(thread)\n#define XP_TLS\n#endif\n\n#ifndef MSVC\n// GCC and Clang can be used on big endian systems, MSVC can't.\n#  if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n#    define AVS_ENDIANNESS \"little\"\n#  elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n#    define AVS_ENDIANNESS \"big\"\n#  else\n#    define AVS_ENDIANNESS \"middle\"\n#  endif\n#else\n#define AVS_ENDIANNESS \"little\"\n#endif\n\n#endif //AVS_CONFIG_H\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/cpuid.h",
    "content": "// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making a\n// combined work based on Avisynth.  Thus, the terms and conditions of the GNU\n// General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate with\n// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license\n// terms of these independent modules, and to copy and distribute the\n// resulting combined work under terms of your choice, provided that\n// every copy of the combined work is accompanied by a complete copy of\n// the source code of Avisynth (the version of Avisynth used to produce the\n// combined work), being distributed under the terms of the GNU General\n// Public License plus this exception.  An independent module is a module\n// which is not derived from or based on Avisynth, such as 3rd-party filters,\n// import and export plugins, or graphical user interfaces.\n\n#ifndef AVSCORE_CPUID_H\n#define AVSCORE_CPUID_H\n\n// For GetCPUFlags.  These are backwards-compatible with those in VirtualDub.\n// ending with SSE4_2\n// For emulation see https://software.intel.com/en-us/articles/intel-software-development-emulator\nenum {\n                    /* oldest CPU to support extension */\n  CPUF_FORCE        =  0x01,   //  N/A\n  CPUF_FPU          =  0x02,   //  386/486DX\n  CPUF_MMX          =  0x04,   //  P55C, K6, PII\n  CPUF_INTEGER_SSE  =  0x08,   //  PIII, Athlon\n  CPUF_SSE          =  0x10,   //  PIII, Athlon XP/MP\n  CPUF_SSE2         =  0x20,   //  PIV, K8\n  CPUF_3DNOW        =  0x40,   //  K6-2\n  CPUF_3DNOW_EXT    =  0x80,   //  Athlon\n  CPUF_X86_64       =  0xA0,   //  Hammer (note: equiv. to 3DNow + SSE2, which\n                               //          only Hammer will have anyway)\n  CPUF_SSE3         = 0x100,   //  PIV+, K8 Venice\n  CPUF_SSSE3        = 0x200,   //  Core 2\n  CPUF_SSE4         = 0x400,\n  CPUF_SSE4_1       = 0x400,   //  Penryn, Wolfdale, Yorkfield\n  CPUF_AVX          = 0x800,   //  Sandy Bridge, Bulldozer\n  CPUF_SSE4_2       = 0x1000,  //  Nehalem\n  // AVS+\n  CPUF_AVX2         = 0x2000,   //  Haswell\n  CPUF_FMA3         = 0x4000,\n  CPUF_F16C         = 0x8000,\n  CPUF_MOVBE        = 0x10000,  // Big Endian move\n  CPUF_POPCNT       = 0x20000,\n  CPUF_AES          = 0x40000,\n  CPUF_FMA4         = 0x80000,\n\n  CPUF_AVX512F      = 0x100000,  // AVX-512 Foundation.\n  CPUF_AVX512DQ     = 0x200000,  // AVX-512 DQ (Double/Quad granular) Instructions\n  CPUF_AVX512PF     = 0x400000,  // AVX-512 Prefetch\n  CPUF_AVX512ER     = 0x800000,  // AVX-512 Exponential and Reciprocal\n  CPUF_AVX512CD     = 0x1000000, // AVX-512 Conflict Detection\n  CPUF_AVX512BW     = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions\n  CPUF_AVX512VL     = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions\n  CPUF_AVX512IFMA   = 0x8000000, // AVX-512 IFMA integer 52 bit\n  CPUF_AVX512VBMI   = 0x10000000,// AVX-512 VBMI\n};\n\n#ifdef BUILDING_AVSCORE\nint GetCPUFlags();\nvoid SetMaxCPU(int new_flags);\n#endif\n\n#endif // AVSCORE_CPUID_H\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/filesystem.h",
    "content": "#pragma once\n\n// Snippet copied from filesystem/README.md\n\n#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)\n#if __has_include(<filesystem>)\n#define GHC_USE_STD_FS\n#include <filesystem>\nnamespace fs = std::filesystem;\n#endif\n#endif\n#ifndef GHC_USE_STD_FS\n#include <ghc/filesystem.hpp>\nnamespace fs = ghc::filesystem;\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/minmax.h",
    "content": "// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making a\n// combined work based on Avisynth.  Thus, the terms and conditions of the GNU\n// General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate with\n// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license\n// terms of these independent modules, and to copy and distribute the\n// resulting combined work under terms of your choice, provided that\n// every copy of the combined work is accompanied by a complete copy of\n// the source code of Avisynth (the version of Avisynth used to produce the\n// combined work), being distributed under the terms of the GNU General\n// Public License plus this exception.  An independent module is a module\n// which is not derived from or based on Avisynth, such as 3rd-party filters,\n// import and export plugins, or graphical user interfaces.\n\n#ifndef AVSCORE_MINMAX_H\n#define AVSCORE_MINMAX_H\n\ntemplate<typename T>\nT min(T v1, T v2)\n{\n  return v1 < v2 ? v1 : v2;\n}\n\ntemplate<typename T>\nT max(T v1, T v2)\n{\n  return v1 > v2 ? v1 : v2;\n}\n\ntemplate<typename T>\nT clamp(T n, T min, T max)\n{\n    n = n > max ? max : n;\n    return n < min ? min : n;\n}\n\n#endif // AVSCORE_MINMAX_H\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/posix.h",
    "content": "// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making a\n// combined work based on Avisynth.  Thus, the terms and conditions of the GNU\n// General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate with\n// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license\n// terms of these independent modules, and to copy and distribute the\n// resulting combined work under terms of your choice, provided that\n// every copy of the combined work is accompanied by a complete copy of\n// the source code of Avisynth (the version of Avisynth used to produce the\n// combined work), being distributed under the terms of the GNU General\n// Public License plus this exception.  An independent module is a module\n// which is not derived from or based on Avisynth, such as 3rd-party filters,\n// import and export plugins, or graphical user interfaces.\n\n#ifdef AVS_POSIX\n#ifndef AVSCORE_POSIX_H\n#define AVSCORE_POSIX_H\n\n#ifdef __cplusplus\n#include <cstring>\n#endif\n#include <strings.h>\n#include <unistd.h>\n\n// Define these MSVC-extension used in Avisynth\n#define __single_inheritance\n\n// These things don't exist in Linux\n#if defined(AVS_HAIKU)\n#undef __declspec\n#endif\n#define __declspec(x)\n#define lstrlen strlen\n#define lstrcmp strcmp\n#define lstrcmpi strcasecmp\n#define _stricmp strcasecmp\n#define _strnicmp strncasecmp\n#define _strdup strdup\n#define SetCurrentDirectory(x) chdir(x)\n#define SetCurrentDirectoryW(x) chdir(x)\n#define GetCurrentDirectoryW(x) getcwd(x)\n#define _putenv putenv\n#define _alloca alloca\n\n// Borrowing some compatibility macros from AvxSynth, slightly modified\n#define UInt32x32To64(a, b) ((uint64_t)(((uint64_t)((uint32_t)(a))) * ((uint32_t)(b))))\n#define Int64ShrlMod32(a, b) ((uint64_t)((uint64_t)(a) >> (b)))\n#define Int32x32To64(a, b)  ((int64_t)(((int64_t)((long)(a))) * ((long)(b))))\n\n#define InterlockedIncrement(x) __sync_add_and_fetch((x), 1)\n#define InterlockedDecrement(x) __sync_sub_and_fetch((x), 1)\n#define InterlockedExchangeAdd(x, v) __sync_add_and_fetch((x), (v))\n\n#define MulDiv(nNumber, nNumerator, nDenominator)   (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator))\n\n#ifndef TRUE\n#define TRUE  true\n#endif\n\n#ifndef FALSE\n#define FALSE false\n#endif\n\n#define S_FALSE       (0x00000001)\n#define E_FAIL        (0x80004005)\n#define FAILED(hr)    ((hr) & 0x80000000)\n#define SUCCEEDED(hr) (!FAILED(hr))\n\n// Statuses copied from comments in exception.cpp\n#define STATUS_GUARD_PAGE_VIOLATION 0x80000001\n#define STATUS_DATATYPE_MISALIGNMENT 0x80000002\n#define STATUS_BREAKPOINT 0x80000003\n#define STATUS_SINGLE_STEP 0x80000004\n#define STATUS_ACCESS_VIOLATION 0xc0000005\n#define STATUS_IN_PAGE_ERROR 0xc0000006\n#define STATUS_INVALID_HANDLE 0xc0000008\n#define STATUS_NO_MEMORY 0xc0000017\n#define STATUS_ILLEGAL_INSTRUCTION 0xc000001d\n#define STATUS_NONCONTINUABLE_EXCEPTION 0xc0000025\n#define STATUS_INVALID_DISPOSITION 0xc0000026\n#define STATUS_ARRAY_BOUNDS_EXCEEDED 0xc000008c\n#define STATUS_FLOAT_DENORMAL_OPERAND 0xc000008d\n#define STATUS_FLOAT_DIVIDE_BY_ZERO 0xc000008e\n#define STATUS_FLOAT_INEXACT_RESULT 0xc000008f\n#define STATUS_FLOAT_INVALID_OPERATION 0xc0000090\n#define STATUS_FLOAT_OVERFLOW 0xc0000091\n#define STATUS_FLOAT_STACK_CHECK 0xc0000092\n#define STATUS_FLOAT_UNDERFLOW 0xc0000093\n#define STATUS_INTEGER_DIVIDE_BY_ZERO 0xc0000094\n#define STATUS_INTEGER_OVERFLOW 0xc0000095\n#define STATUS_PRIVILEGED_INSTRUCTION 0xc0000096\n#define STATUS_STACK_OVERFLOW 0xc00000fd\n\n// Calling convension\n#ifndef AVS_HAIKU\n#define __stdcall\n#define __cdecl\n#endif\n\n// PowerPC OS X is really niche these days, but this painless equivocation\n// of the function/macro names used in posix_get_available_memory()\n// is all it takes to let it work.  The G5 was 64-bit, and if 10.5 Leopard\n// can run in native 64-bit, it probably uses the names in that block as-is.\n#ifdef AVS_MACOS\n#ifdef PPC32\n#define vm_statistics64_data_t vm_statistics_data_t\n#define HOST_VM_INFO64_COUNT HOST_VM_INFO_COUNT\n#define HOST_VM_INFO64 HOST_VM_INFO\n#define host_statistics64 host_statistics\n#endif // PPC32\n#endif // AVS_MACOS\n\n#endif // AVSCORE_POSIX_H\n#endif // AVS_POSIX\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/types.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n#ifndef AVS_TYPES_H\n#define AVS_TYPES_H\n\n// Define all types necessary for interfacing with avisynth.dll\n#include <stdint.h>\n#include <stdbool.h>\n#ifdef __cplusplus\n  #include <cstddef>\n  #include <cstdarg>\n#else\n  #include <stddef.h>\n  #include <stdarg.h>\n#endif\n\n// Raster types used by VirtualDub & Avisynth\ntypedef uint32_t Pixel32;\ntypedef uint8_t  BYTE;\n\n// Audio Sample information\ntypedef float SFLOAT;\n\n#endif //AVS_TYPES_H\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/version.h",
    "content": "#ifndef _AVS_VERSION_H_\n#define _AVS_VERSION_H_\n\n#include \"arch.h\"\n\n#define       AVS_PPSTR_(x)    \t#x\n#define       AVS_PPSTR(x)    \tAVS_PPSTR_(x)\n\n#define       AVS_PROJECT       AviSynth+\n#define       AVS_MAJOR_VER     3\n#define       AVS_MINOR_VER     7\n#define       AVS_BUGFIX_VER    3\n#ifdef RELEASE_TARBALL\n#define       AVS_FULLVERSION\tAVS_PPSTR(AVS_PROJECT) \" \" AVS_PPSTR(AVS_MAJOR_VER) \".\" AVS_PPSTR(AVS_MINOR_VER) \".\" AVS_PPSTR(AVS_BUGFIX_VER) \" (\" AVS_PPSTR(AVS_ARCH) \")\"\n#else\n#define       AVS_DEVNEXT_REV   \n#define       AVS_DEV_REVDATE   \n#define       AVS_DEV_GITHASH   \n#define       AVS_SEQREV        \t\t// e.g. 1576\n#define       AVS_BRANCH        \t\t// e.g. master\n#define       AVS_FULLVERSION\tAVS_PPSTR(AVS_PROJECT) \" \" AVS_PPSTR(AVS_MAJOR_VER) \".\" AVS_PPSTR(AVS_MINOR_VER) \".\" AVS_PPSTR(AVS_BUGFIX_VER) \" (r\" AVS_PPSTR(AVS_SEQREV) \", \" AVS_PPSTR(AVS_BRANCH) \", \" AVS_PPSTR(AVS_ARCH) \")\"\n#endif\n\n#endif  //  _AVS_VERSION_H_\n"
  },
  {
    "path": "thirdparty/32/include/avisynth/avs/win.h",
    "content": "// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making a\n// combined work based on Avisynth.  Thus, the terms and conditions of the GNU\n// General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate with\n// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license\n// terms of these independent modules, and to copy and distribute the\n// resulting combined work under terms of your choice, provided that\n// every copy of the combined work is accompanied by a complete copy of\n// the source code of Avisynth (the version of Avisynth used to produce the\n// combined work), being distributed under the terms of the GNU General\n// Public License plus this exception.  An independent module is a module\n// which is not derived from or based on Avisynth, such as 3rd-party filters,\n// import and export plugins, or graphical user interfaces.\n\n#ifndef AVSCORE_WIN_H\n#define AVSCORE_WIN_H\n\n// Whenever you need windows headers, start by including this file, then the rest.\n\n// WWUUT? We require XP now?\n#if !defined(NTDDI_VERSION) && !defined(_WIN32_WINNT)\n  #define NTDDI_VERSION 0x05020000\n  #define _WIN32_WINNT  0x0502\n#endif\n\n#define WIN32_LEAN_AND_MEAN\n#define STRICT\n#if !defined(NOMINMAX)\n    #define NOMINMAX\n#endif\n\n#include <windows.h>\n\n// Provision for UTF-8 max 4 bytes per code point\n#define AVS_MAX_PATH MAX_PATH*4\n\n#endif // AVSCORE_WIN_H\n"
  },
  {
    "path": "thirdparty/32/include/dav1d/common.h",
    "content": "/*\n * Copyright © 2018, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_COMMON_H\n#define DAV1D_COMMON_H\n\n#include <errno.h>\n#include <stddef.h>\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef DAV1D_API\n    #if defined _WIN32\n      #if defined DAV1D_BUILDING_DLL\n        #define DAV1D_API __declspec(dllexport)\n      #else\n        #define DAV1D_API\n      #endif\n    #else\n      #if __GNUC__ >= 4\n        #define DAV1D_API __attribute__ ((visibility (\"default\")))\n      #else\n        #define DAV1D_API\n      #endif\n    #endif\n#endif\n\n#if EPERM > 0\n#define DAV1D_ERR(e) (-(e)) ///< Negate POSIX error code.\n#else\n#define DAV1D_ERR(e) (e)\n#endif\n\n/**\n * A reference-counted object wrapper for a user-configurable pointer.\n */\ntypedef struct Dav1dUserData {\n    const uint8_t *data; ///< data pointer\n    struct Dav1dRef *ref; ///< allocation origin\n} Dav1dUserData;\n\n/**\n * Input packet metadata which are copied from the input data used to\n * decode each image into the matching structure of the output image\n * returned back to the user. Since these are metadata fields, they\n * can be used for other purposes than the documented ones, they will\n * still be passed from input data to output picture without being\n * used internally.\n */\ntypedef struct Dav1dDataProps {\n    int64_t timestamp; ///< container timestamp of input data, INT64_MIN if unknown (default)\n    int64_t duration; ///< container duration of input data, 0 if unknown (default)\n    int64_t offset; ///< stream offset of input data, -1 if unknown (default)\n    size_t size; ///< packet size, default Dav1dData.sz\n    struct Dav1dUserData user_data; ///< user-configurable data, default NULL members\n} Dav1dDataProps;\n\n/**\n * Release reference to a Dav1dDataProps.\n */\nDAV1D_API void dav1d_data_props_unref(Dav1dDataProps *props);\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_COMMON_H */\n"
  },
  {
    "path": "thirdparty/32/include/dav1d/data.h",
    "content": "/*\n * Copyright © 2018, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_DATA_H\n#define DAV1D_DATA_H\n\n#include <stddef.h>\n#include <stdint.h>\n\n#include \"common.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct Dav1dData {\n    const uint8_t *data; ///< data pointer\n    size_t sz; ///< data size\n    struct Dav1dRef *ref; ///< allocation origin\n    Dav1dDataProps m; ///< user provided metadata passed to the output picture\n} Dav1dData;\n\n/**\n * Allocate data.\n *\n * @param data Input context.\n * @param   sz Size of the data that should be allocated.\n *\n * @return Pointer to the allocated buffer on success. NULL on error.\n */\nDAV1D_API uint8_t * dav1d_data_create(Dav1dData *data, size_t sz);\n\n/**\n * Wrap an existing data array.\n *\n * @param          data Input context.\n * @param           buf The data to be wrapped.\n * @param            sz Size of the data.\n * @param free_callback Function to be called when we release our last\n *                      reference to this data. In this callback, $buf will be\n *                      the $buf argument to this function, and $cookie will\n *                      be the $cookie input argument to this function.\n * @param        cookie Opaque parameter passed to free_callback().\n *\n * @return 0 on success. A negative DAV1D_ERR value on error.\n */\nDAV1D_API int dav1d_data_wrap(Dav1dData *data, const uint8_t *buf, size_t sz,\n                              void (*free_callback)(const uint8_t *buf, void *cookie),\n                              void *cookie);\n\n/**\n * Wrap a user-provided data pointer into a reference counted object.\n *\n * data->m.user_data field will initialized to wrap the provided $user_data\n * pointer.\n *\n * $free_callback will be called on the same thread that released the last\n * reference. If frame threading is used, make sure $free_callback is\n * thread-safe.\n *\n * @param          data Input context.\n * @param     user_data The user data to be wrapped.\n * @param free_callback Function to be called when we release our last\n *                      reference to this data. In this callback, $user_data\n *                      will be the $user_data argument to this function, and\n *                      $cookie will be the $cookie input argument to this\n *                      function.\n * @param        cookie Opaque parameter passed to $free_callback.\n *\n * @return 0 on success. A negative DAV1D_ERR value on error.\n */\nDAV1D_API int dav1d_data_wrap_user_data(Dav1dData *data,\n                                        const uint8_t *user_data,\n                                        void (*free_callback)(const uint8_t *user_data,\n                                                              void *cookie),\n                                        void *cookie);\n\n/**\n * Free the data reference.\n *\n * The reference count for data->m.user_data will be decremented (if it has been\n * initialized with dav1d_data_wrap_user_data). The $data object will be memset\n * to 0.\n *\n * @param data Input context.\n */\nDAV1D_API void dav1d_data_unref(Dav1dData *data);\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_DATA_H */\n"
  },
  {
    "path": "thirdparty/32/include/dav1d/dav1d.h",
    "content": "/*\n * Copyright © 2018-2021, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_H\n#define DAV1D_H\n\n#include <errno.h>\n#include <stdarg.h>\n\n#include \"common.h\"\n#include \"picture.h\"\n#include \"data.h\"\n#include \"version.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct Dav1dContext Dav1dContext;\ntypedef struct Dav1dRef Dav1dRef;\n\n#define DAV1D_MAX_THREADS 256\n#define DAV1D_MAX_FRAME_DELAY 256\n\ntypedef struct Dav1dLogger {\n    void *cookie; ///< Custom data to pass to the callback.\n    /**\n     * Logger callback. May be NULL to disable logging.\n     *\n     * @param cookie Custom pointer passed to all calls.\n     * @param format The vprintf compatible format string.\n     * @param     ap List of arguments referenced by the format string.\n     */\n    void (*callback)(void *cookie, const char *format, va_list ap);\n} Dav1dLogger;\n\nenum Dav1dInloopFilterType {\n    DAV1D_INLOOPFILTER_NONE        = 0,\n    DAV1D_INLOOPFILTER_DEBLOCK     = 1 << 0,\n    DAV1D_INLOOPFILTER_CDEF        = 1 << 1,\n    DAV1D_INLOOPFILTER_RESTORATION = 1 << 2,\n    DAV1D_INLOOPFILTER_ALL = DAV1D_INLOOPFILTER_DEBLOCK |\n                             DAV1D_INLOOPFILTER_CDEF |\n                             DAV1D_INLOOPFILTER_RESTORATION,\n};\n\nenum Dav1dDecodeFrameType {\n    DAV1D_DECODEFRAMETYPE_ALL   = 0, ///< decode and return all frames\n    DAV1D_DECODEFRAMETYPE_REFERENCE = 1,///< decode and return frames referenced by other frames only\n    DAV1D_DECODEFRAMETYPE_INTRA = 2, ///< decode and return intra frames only (includes keyframes)\n    DAV1D_DECODEFRAMETYPE_KEY   = 3, ///< decode and return keyframes only\n};\n\ntypedef struct Dav1dSettings {\n    int n_threads; ///< number of threads (0 = number of logical cores in host system, default 0)\n    int max_frame_delay; ///< Set to 1 for low-latency decoding (0 = ceil(sqrt(n_threads)), default 0)\n    int apply_grain; ///< whether to apply film grain on output frames (default 1)\n    int operating_point; ///< select an operating point for scalable AV1 bitstreams (0 - 31, default 0)\n    int all_layers; ///< output all spatial layers of a scalable AV1 biststream (default 1)\n    unsigned frame_size_limit; ///< maximum frame size, in pixels (0 = unlimited, default 0)\n    Dav1dPicAllocator allocator; ///< Picture allocator callback.\n    Dav1dLogger logger; ///< Logger callback.\n    int strict_std_compliance; ///< whether to abort decoding on standard compliance violations\n                               ///< that don't affect actual bitstream decoding (e.g. inconsistent\n                               ///< or invalid metadata, default 0)\n    int output_invisible_frames; ///< output invisibly coded frames (in coding order) in addition\n                                 ///< to all visible frames. Because of show-existing-frame, this\n                                 ///< means some frames may appear twice (once when coded,\n                                 ///< once when shown, default 0)\n    enum Dav1dInloopFilterType inloop_filters; ///< postfilters to enable during decoding (default\n                                               ///< DAV1D_INLOOPFILTER_ALL)\n    enum Dav1dDecodeFrameType decode_frame_type; ///< frame types to decode (default\n                                                 ///< DAV1D_DECODEFRAMETYPE_ALL)\n    uint8_t reserved[16]; ///< reserved for future use\n} Dav1dSettings;\n\n/**\n * Get library version.\n */\nDAV1D_API const char *dav1d_version(void);\n\n/**\n * Get library API version.\n *\n * @return A value in the format 0x00XXYYZZ, where XX is the major version,\n *         YY the minor version, and ZZ the patch version.\n * @see DAV1D_API_MAJOR, DAV1D_API_MINOR, DAV1D_API_PATCH\n */\nDAV1D_API unsigned dav1d_version_api(void);\n\n/**\n * Initialize settings to default values.\n *\n * @param s Input settings context.\n */\nDAV1D_API void dav1d_default_settings(Dav1dSettings *s);\n\n/**\n * Allocate and open a decoder instance.\n *\n * @param c_out The decoder instance to open. *c_out will be set to the\n *              allocated context.\n * @param     s Input settings context.\n *\n * @note The context must be freed using dav1d_close() when decoding is\n *       finished.\n *\n * @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error.\n */\nDAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);\n\n/**\n * Parse a Sequence Header OBU from bitstream data.\n *\n * @param out Output Sequence Header.\n * @param buf The data to be parser.\n * @param sz  Size of the data.\n *\n * @return\n *                  0: Success, and out is filled with the parsed Sequence Header\n *                     OBU parameters.\n *  DAV1D_ERR(ENOENT): No Sequence Header OBUs were found in the buffer.\n *  Other negative DAV1D_ERR codes: Invalid data in the buffer, invalid passed-in\n *                                  arguments, and other errors during parsing.\n *\n * @note It is safe to feed this function data containing other OBUs than a\n *       Sequence Header, as they will simply be ignored. If there is more than\n *       one Sequence Header OBU present, only the last will be returned.\n */\nDAV1D_API int dav1d_parse_sequence_header(Dav1dSequenceHeader *out,\n                                          const uint8_t *buf, const size_t sz);\n\n/**\n * Feed bitstream data to the decoder, in the form of one or multiple AV1\n * Open Bitstream Units (OBUs).\n *\n * @param   c Input decoder instance.\n * @param  in Input bitstream data. On success, ownership of the reference is\n *            passed to the library.\n *\n * @return\n *         0: Success, and the data was consumed.\n *  DAV1D_ERR(EAGAIN): The data can't be consumed. dav1d_get_picture() should\n *                     be called to get one or more frames before the function\n *                     can consume new data.\n *  Other negative DAV1D_ERR codes: Error during decoding or because of invalid\n *                                  passed-in arguments. The reference remains\n *                                  owned by the caller.\n */\nDAV1D_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in);\n\n/**\n * Return a decoded picture.\n *\n * @param   c Input decoder instance.\n * @param out Output frame. The caller assumes ownership of the returned\n *            reference.\n *\n * @return\n *         0: Success, and a frame is returned.\n *  DAV1D_ERR(EAGAIN): Not enough data to output a frame. dav1d_send_data()\n *                     should be called with new input.\n *  Other negative DAV1D_ERR codes: Error during decoding or because of invalid\n *                                  passed-in arguments.\n *\n * @note To drain buffered frames from the decoder (i.e. on end of stream),\n *       call this function until it returns DAV1D_ERR(EAGAIN).\n *\n * @code{.c}\n *  Dav1dData data = { 0 };\n *  Dav1dPicture p = { 0 };\n *  int res;\n *\n *  read_data(&data);\n *  do {\n *      res = dav1d_send_data(c, &data);\n *      // Keep going even if the function can't consume the current data\n *         packet. It eventually will after one or more frames have been\n *         returned in this loop.\n *      if (res < 0 && res != DAV1D_ERR(EAGAIN))\n *          free_and_abort();\n *      res = dav1d_get_picture(c, &p);\n *      if (res < 0) {\n *          if (res != DAV1D_ERR(EAGAIN))\n *              free_and_abort();\n *      } else\n *          output_and_unref_picture(&p);\n *  // Stay in the loop as long as there's data to consume.\n *  } while (data.sz || read_data(&data) == SUCCESS);\n *\n *  // Handle EOS by draining all buffered frames.\n *  do {\n *      res = dav1d_get_picture(c, &p);\n *      if (res < 0) {\n *          if (res != DAV1D_ERR(EAGAIN))\n *              free_and_abort();\n *      } else\n *          output_and_unref_picture(&p);\n *  } while (res == 0);\n * @endcode\n */\nDAV1D_API int dav1d_get_picture(Dav1dContext *c, Dav1dPicture *out);\n\n/**\n * Apply film grain to a previously decoded picture. If the picture contains no\n * film grain metadata, then this function merely returns a new reference.\n *\n * @param   c Input decoder instance.\n * @param out Output frame. The caller assumes ownership of the returned\n *            reference.\n * @param  in Input frame. No ownership is transferred.\n *\n * @return\n *         0: Success, and a frame is returned.\n *  Other negative DAV1D_ERR codes: Error due to lack of memory or because of\n *                                  invalid passed-in arguments.\n *\n * @note If `Dav1dSettings.apply_grain` is true, film grain was already applied\n *       by `dav1d_get_picture`, and so calling this function leads to double\n *       application of film grain. Users should only call this when needed.\n */\nDAV1D_API int dav1d_apply_grain(Dav1dContext *c, Dav1dPicture *out,\n                                const Dav1dPicture *in);\n\n/**\n * Close a decoder instance and free all associated memory.\n *\n * @param c_out The decoder instance to close. *c_out will be set to NULL.\n */\nDAV1D_API void dav1d_close(Dav1dContext **c_out);\n\n/**\n * Flush all delayed frames in decoder and clear internal decoder state,\n * to be used when seeking.\n *\n * @param c Input decoder instance.\n *\n * @note Decoding will start only after a valid sequence header OBU is\n *       delivered to dav1d_send_data().\n *\n */\nDAV1D_API void dav1d_flush(Dav1dContext *c);\n\nenum Dav1dEventFlags {\n    /**\n     * The last returned picture contains a reference to a new Sequence Header,\n     * either because it's the start of a new coded sequence, or the decoder was\n     * flushed before it was generated.\n     */\n    DAV1D_EVENT_FLAG_NEW_SEQUENCE =       1 << 0,\n    /**\n     * The last returned picture contains a reference to a Sequence Header with\n     * new operating parameters information for the current coded sequence.\n     */\n    DAV1D_EVENT_FLAG_NEW_OP_PARAMS_INFO = 1 << 1,\n};\n\n/**\n * Fetch a combination of DAV1D_EVENT_FLAG_* event flags generated by the decoding\n * process.\n *\n * @param c Input decoder instance.\n * @param flags Where to write the flags.\n *\n * @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error.\n *\n * @note Calling this function will clear all the event flags currently stored in\n *       the decoder.\n *\n */\nDAV1D_API int dav1d_get_event_flags(Dav1dContext *c, enum Dav1dEventFlags *flags);\n\n/**\n * Retrieve the user-provided metadata associated with the input data packet\n * for the last decoding error reported to the user, i.e. a negative return\n * value (not EAGAIN) from dav1d_send_data() or dav1d_get_picture().\n *\n * @param   c Input decoder instance.\n * @param out Output Dav1dDataProps. On success, the caller assumes ownership of\n *            the returned reference.\n *\n * @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error.\n */\nDAV1D_API int dav1d_get_decode_error_data_props(Dav1dContext *c, Dav1dDataProps *out);\n\n/**\n * Get the decoder delay, which is the number of internally buffered frames, not\n * including reference frames.\n * This value is guaranteed to be >= 1 and <= max_frame_delay.\n *\n * @param s Input settings context.\n *\n * @return Decoder frame delay on success, or < 0 (a negative DAV1D_ERR code) on\n *         error.\n *\n * @note The returned delay is valid only for a Dav1dContext initialized with the\n *       provided Dav1dSettings.\n */\nDAV1D_API int dav1d_get_frame_delay(const Dav1dSettings *s);\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_H */\n"
  },
  {
    "path": "thirdparty/32/include/dav1d/headers.h",
    "content": "/*\n * Copyright © 2018-2020, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_HEADERS_H\n#define DAV1D_HEADERS_H\n\n#include <stdint.h>\n#include <stddef.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// Constants from Section 3. \"Symbols and abbreviated terms\"\n#define DAV1D_MAX_CDEF_STRENGTHS 8\n#define DAV1D_MAX_OPERATING_POINTS 32\n#define DAV1D_MAX_TILE_COLS 64\n#define DAV1D_MAX_TILE_ROWS 64\n#define DAV1D_MAX_SEGMENTS 8\n#define DAV1D_NUM_REF_FRAMES 8\n#define DAV1D_PRIMARY_REF_NONE 7\n#define DAV1D_REFS_PER_FRAME 7\n#define DAV1D_TOTAL_REFS_PER_FRAME (DAV1D_REFS_PER_FRAME + 1)\n\nenum Dav1dObuType {\n    DAV1D_OBU_SEQ_HDR   = 1,\n    DAV1D_OBU_TD        = 2,\n    DAV1D_OBU_FRAME_HDR = 3,\n    DAV1D_OBU_TILE_GRP  = 4,\n    DAV1D_OBU_METADATA  = 5,\n    DAV1D_OBU_FRAME     = 6,\n    DAV1D_OBU_REDUNDANT_FRAME_HDR = 7,\n    DAV1D_OBU_PADDING   = 15,\n};\n\nenum Dav1dTxfmMode {\n    DAV1D_TX_4X4_ONLY,\n    DAV1D_TX_LARGEST,\n    DAV1D_TX_SWITCHABLE,\n    DAV1D_N_TX_MODES,\n};\n\nenum Dav1dFilterMode {\n    DAV1D_FILTER_8TAP_REGULAR,\n    DAV1D_FILTER_8TAP_SMOOTH,\n    DAV1D_FILTER_8TAP_SHARP,\n    DAV1D_N_SWITCHABLE_FILTERS,\n    DAV1D_FILTER_BILINEAR = DAV1D_N_SWITCHABLE_FILTERS,\n    DAV1D_N_FILTERS,\n    DAV1D_FILTER_SWITCHABLE = DAV1D_N_FILTERS,\n};\n\nenum Dav1dAdaptiveBoolean {\n    DAV1D_OFF = 0,\n    DAV1D_ON = 1,\n    DAV1D_ADAPTIVE = 2,\n};\n\nenum Dav1dRestorationType {\n    DAV1D_RESTORATION_NONE,\n    DAV1D_RESTORATION_SWITCHABLE,\n    DAV1D_RESTORATION_WIENER,\n    DAV1D_RESTORATION_SGRPROJ,\n};\n\nenum Dav1dWarpedMotionType {\n    DAV1D_WM_TYPE_IDENTITY,\n    DAV1D_WM_TYPE_TRANSLATION,\n    DAV1D_WM_TYPE_ROT_ZOOM,\n    DAV1D_WM_TYPE_AFFINE,\n};\n\ntypedef struct Dav1dWarpedMotionParams {\n    enum Dav1dWarpedMotionType type;\n    int32_t matrix[6];\n    union {\n        struct {\n            int16_t alpha, beta, gamma, delta;\n        } p;\n        int16_t abcd[4];\n    } u;\n} Dav1dWarpedMotionParams;\n\nenum Dav1dPixelLayout {\n    DAV1D_PIXEL_LAYOUT_I400, ///< monochrome\n    DAV1D_PIXEL_LAYOUT_I420, ///< 4:2:0 planar\n    DAV1D_PIXEL_LAYOUT_I422, ///< 4:2:2 planar\n    DAV1D_PIXEL_LAYOUT_I444, ///< 4:4:4 planar\n};\n\nenum Dav1dFrameType {\n    DAV1D_FRAME_TYPE_KEY = 0,    ///< Key Intra frame\n    DAV1D_FRAME_TYPE_INTER = 1,  ///< Inter frame\n    DAV1D_FRAME_TYPE_INTRA = 2,  ///< Non key Intra frame\n    DAV1D_FRAME_TYPE_SWITCH = 3, ///< Switch Inter frame\n};\n\nenum Dav1dColorPrimaries {\n    DAV1D_COLOR_PRI_BT709 = 1,\n    DAV1D_COLOR_PRI_UNKNOWN = 2,\n    DAV1D_COLOR_PRI_BT470M = 4,\n    DAV1D_COLOR_PRI_BT470BG = 5,\n    DAV1D_COLOR_PRI_BT601 = 6,\n    DAV1D_COLOR_PRI_SMPTE240 = 7,\n    DAV1D_COLOR_PRI_FILM = 8,\n    DAV1D_COLOR_PRI_BT2020 = 9,\n    DAV1D_COLOR_PRI_XYZ = 10,\n    DAV1D_COLOR_PRI_SMPTE431 = 11,\n    DAV1D_COLOR_PRI_SMPTE432 = 12,\n    DAV1D_COLOR_PRI_EBU3213 = 22,\n    DAV1D_COLOR_PRI_RESERVED = 255,\n};\n\nenum Dav1dTransferCharacteristics {\n    DAV1D_TRC_BT709 = 1,\n    DAV1D_TRC_UNKNOWN = 2,\n    DAV1D_TRC_BT470M = 4,\n    DAV1D_TRC_BT470BG = 5,\n    DAV1D_TRC_BT601 = 6,\n    DAV1D_TRC_SMPTE240 = 7,\n    DAV1D_TRC_LINEAR = 8,\n    DAV1D_TRC_LOG100 = 9,         ///< logarithmic (100:1 range)\n    DAV1D_TRC_LOG100_SQRT10 = 10, ///< lograithmic (100*sqrt(10):1 range)\n    DAV1D_TRC_IEC61966 = 11,\n    DAV1D_TRC_BT1361 = 12,\n    DAV1D_TRC_SRGB = 13,\n    DAV1D_TRC_BT2020_10BIT = 14,\n    DAV1D_TRC_BT2020_12BIT = 15,\n    DAV1D_TRC_SMPTE2084 = 16,     ///< PQ\n    DAV1D_TRC_SMPTE428 = 17,\n    DAV1D_TRC_HLG = 18,           ///< hybrid log/gamma (BT.2100 / ARIB STD-B67)\n    DAV1D_TRC_RESERVED = 255,\n};\n\nenum Dav1dMatrixCoefficients {\n    DAV1D_MC_IDENTITY = 0,\n    DAV1D_MC_BT709 = 1,\n    DAV1D_MC_UNKNOWN = 2,\n    DAV1D_MC_FCC = 4,\n    DAV1D_MC_BT470BG = 5,\n    DAV1D_MC_BT601 = 6,\n    DAV1D_MC_SMPTE240 = 7,\n    DAV1D_MC_SMPTE_YCGCO = 8,\n    DAV1D_MC_BT2020_NCL = 9,\n    DAV1D_MC_BT2020_CL = 10,\n    DAV1D_MC_SMPTE2085 = 11,\n    DAV1D_MC_CHROMAT_NCL = 12, ///< Chromaticity-derived\n    DAV1D_MC_CHROMAT_CL = 13,\n    DAV1D_MC_ICTCP = 14,\n    DAV1D_MC_RESERVED = 255,\n};\n\nenum Dav1dChromaSamplePosition {\n    DAV1D_CHR_UNKNOWN = 0,\n    DAV1D_CHR_VERTICAL = 1,  ///< Horizontally co-located with luma(0, 0)\n                           ///< sample, between two vertical samples\n    DAV1D_CHR_COLOCATED = 2, ///< Co-located with luma(0, 0) sample\n};\n\ntypedef struct Dav1dContentLightLevel {\n    uint16_t max_content_light_level;\n    uint16_t max_frame_average_light_level;\n} Dav1dContentLightLevel;\n\ntypedef struct Dav1dMasteringDisplay {\n    uint16_t primaries[3][2]; ///< 0.16 fixed point\n    uint16_t white_point[2]; ///< 0.16 fixed point\n    uint32_t max_luminance; ///< 24.8 fixed point\n    uint32_t min_luminance; ///< 18.14 fixed point\n} Dav1dMasteringDisplay;\n\ntypedef struct Dav1dITUTT35 {\n    uint8_t  country_code;\n    uint8_t  country_code_extension_byte;\n    size_t   payload_size;\n    uint8_t *payload;\n} Dav1dITUTT35;\n\ntypedef struct Dav1dSequenceHeader {\n    /**\n     * Stream profile, 0 for 8-10 bits/component 4:2:0 or monochrome;\n     * 1 for 8-10 bits/component 4:4:4; 2 for 4:2:2 at any bits/component,\n     * or 12 bits/component at any chroma subsampling.\n     */\n    uint8_t profile;\n    /**\n     * Maximum dimensions for this stream. In non-scalable streams, these\n     * are often the actual dimensions of the stream, although that is not\n     * a normative requirement.\n     */\n    int max_width, max_height;\n    enum Dav1dPixelLayout layout; ///< format of the picture\n    enum Dav1dColorPrimaries pri; ///< color primaries (av1)\n    enum Dav1dTransferCharacteristics trc; ///< transfer characteristics (av1)\n    enum Dav1dMatrixCoefficients mtrx; ///< matrix coefficients (av1)\n    enum Dav1dChromaSamplePosition chr; ///< chroma sample position (av1)\n    /**\n     * 0, 1 and 2 mean 8, 10 or 12 bits/component, respectively. This is not\n     * exactly the same as 'hbd' from the spec; the spec's hbd distinguishes\n     * between 8 (0) and 10-12 (1) bits/component, and another element\n     * (twelve_bit) to distinguish between 10 and 12 bits/component. To get\n     * the spec's hbd, use !!our_hbd, and to get twelve_bit, use hbd == 2.\n     */\n    uint8_t hbd;\n    /**\n     * Pixel data uses JPEG pixel range ([0,255] for 8bits) instead of\n     * MPEG pixel range ([16,235] for 8bits luma, [16,240] for 8bits chroma).\n     */\n    uint8_t color_range;\n\n    uint8_t num_operating_points;\n    struct Dav1dSequenceHeaderOperatingPoint {\n        uint8_t major_level, minor_level;\n        uint8_t initial_display_delay;\n        uint16_t idc;\n        uint8_t tier;\n        uint8_t decoder_model_param_present;\n        uint8_t display_model_param_present;\n    } operating_points[DAV1D_MAX_OPERATING_POINTS];\n\n    uint8_t still_picture;\n    uint8_t reduced_still_picture_header;\n    uint8_t timing_info_present;\n    uint32_t num_units_in_tick;\n    uint32_t time_scale;\n    uint8_t equal_picture_interval;\n    uint32_t num_ticks_per_picture;\n    uint8_t decoder_model_info_present;\n    uint8_t encoder_decoder_buffer_delay_length;\n    uint32_t num_units_in_decoding_tick;\n    uint8_t buffer_removal_delay_length;\n    uint8_t frame_presentation_delay_length;\n    uint8_t display_model_info_present;\n    uint8_t width_n_bits, height_n_bits;\n    uint8_t frame_id_numbers_present;\n    uint8_t delta_frame_id_n_bits;\n    uint8_t frame_id_n_bits;\n    uint8_t sb128;\n    uint8_t filter_intra;\n    uint8_t intra_edge_filter;\n    uint8_t inter_intra;\n    uint8_t masked_compound;\n    uint8_t warped_motion;\n    uint8_t dual_filter;\n    uint8_t order_hint;\n    uint8_t jnt_comp;\n    uint8_t ref_frame_mvs;\n    enum Dav1dAdaptiveBoolean screen_content_tools;\n    enum Dav1dAdaptiveBoolean force_integer_mv;\n    uint8_t order_hint_n_bits;\n    uint8_t super_res;\n    uint8_t cdef;\n    uint8_t restoration;\n    uint8_t ss_hor, ss_ver, monochrome;\n    uint8_t color_description_present;\n    uint8_t separate_uv_delta_q;\n    uint8_t film_grain_present;\n\n    // Dav1dSequenceHeaders of the same sequence are required to be\n    // bit-identical until this offset. See 7.5 \"Ordering of OBUs\":\n    //   Within a particular coded video sequence, the contents of\n    //   sequence_header_obu must be bit-identical each time the\n    //   sequence header appears except for the contents of\n    //   operating_parameters_info.\n    struct Dav1dSequenceHeaderOperatingParameterInfo {\n        uint32_t decoder_buffer_delay;\n        uint32_t encoder_buffer_delay;\n        uint8_t low_delay_mode;\n    } operating_parameter_info[DAV1D_MAX_OPERATING_POINTS];\n} Dav1dSequenceHeader;\n\ntypedef struct Dav1dSegmentationData {\n    int16_t delta_q;\n    int8_t delta_lf_y_v, delta_lf_y_h, delta_lf_u, delta_lf_v;\n    int8_t ref;\n    uint8_t skip;\n    uint8_t globalmv;\n} Dav1dSegmentationData;\n\ntypedef struct Dav1dSegmentationDataSet {\n    Dav1dSegmentationData d[DAV1D_MAX_SEGMENTS];\n    uint8_t preskip;\n    int8_t last_active_segid;\n} Dav1dSegmentationDataSet;\n\ntypedef struct Dav1dLoopfilterModeRefDeltas {\n    int8_t mode_delta[2 /* is_zeromv */];\n    int8_t ref_delta[DAV1D_TOTAL_REFS_PER_FRAME];\n} Dav1dLoopfilterModeRefDeltas;\n\ntypedef struct Dav1dFilmGrainData {\n    unsigned seed;\n    int num_y_points;\n    uint8_t y_points[14][2 /* value, scaling */];\n    int chroma_scaling_from_luma;\n    int num_uv_points[2];\n    uint8_t uv_points[2][10][2 /* value, scaling */];\n    int scaling_shift;\n    int ar_coeff_lag;\n    int8_t ar_coeffs_y[24];\n    int8_t ar_coeffs_uv[2][25 + 3 /* padding for alignment purposes */];\n    uint64_t ar_coeff_shift;\n    int grain_scale_shift;\n    int uv_mult[2];\n    int uv_luma_mult[2];\n    int uv_offset[2];\n    int overlap_flag;\n    int clip_to_restricted_range;\n} Dav1dFilmGrainData;\n\ntypedef struct Dav1dFrameHeader {\n    struct {\n        Dav1dFilmGrainData data;\n        uint8_t present, update;\n    } film_grain; ///< film grain parameters\n    enum Dav1dFrameType frame_type; ///< type of the picture\n    int width[2 /* { coded_width, superresolution_upscaled_width } */], height;\n    uint8_t frame_offset; ///< frame number\n    uint8_t temporal_id; ///< temporal id of the frame for SVC\n    uint8_t spatial_id; ///< spatial id of the frame for SVC\n\n    uint8_t show_existing_frame;\n    uint8_t existing_frame_idx;\n    uint32_t frame_id;\n    uint32_t frame_presentation_delay;\n    uint8_t show_frame;\n    uint8_t showable_frame;\n    uint8_t error_resilient_mode;\n    uint8_t disable_cdf_update;\n    uint8_t allow_screen_content_tools;\n    uint8_t force_integer_mv;\n    uint8_t frame_size_override;\n    uint8_t primary_ref_frame;\n    uint8_t buffer_removal_time_present;\n    struct Dav1dFrameHeaderOperatingPoint {\n        uint32_t buffer_removal_time;\n    } operating_points[DAV1D_MAX_OPERATING_POINTS];\n    uint8_t refresh_frame_flags;\n    int render_width, render_height;\n    struct {\n        uint8_t width_scale_denominator;\n        uint8_t enabled;\n    } super_res;\n    uint8_t have_render_size;\n    uint8_t allow_intrabc;\n    uint8_t frame_ref_short_signaling;\n    int8_t refidx[DAV1D_REFS_PER_FRAME];\n    uint8_t hp;\n    enum Dav1dFilterMode subpel_filter_mode;\n    uint8_t switchable_motion_mode;\n    uint8_t use_ref_frame_mvs;\n    uint8_t refresh_context;\n    struct {\n        uint8_t uniform;\n        uint8_t n_bytes;\n        uint8_t min_log2_cols, max_log2_cols, log2_cols, cols;\n        uint8_t min_log2_rows, max_log2_rows, log2_rows, rows;\n        uint16_t col_start_sb[DAV1D_MAX_TILE_COLS + 1];\n        uint16_t row_start_sb[DAV1D_MAX_TILE_ROWS + 1];\n        uint16_t update;\n    } tiling;\n    struct {\n        uint8_t yac;\n        int8_t ydc_delta;\n        int8_t udc_delta, uac_delta, vdc_delta, vac_delta;\n        uint8_t qm, qm_y, qm_u, qm_v;\n    } quant;\n    struct {\n        uint8_t enabled, update_map, temporal, update_data;\n        Dav1dSegmentationDataSet seg_data;\n        uint8_t lossless[DAV1D_MAX_SEGMENTS], qidx[DAV1D_MAX_SEGMENTS];\n    } segmentation;\n    struct {\n        struct {\n            uint8_t present;\n            uint8_t res_log2;\n        } q;\n        struct {\n            uint8_t present;\n            uint8_t res_log2;\n            uint8_t multi;\n        } lf;\n    } delta;\n    uint8_t all_lossless;\n    struct {\n        uint8_t level_y[2 /* dir */];\n        uint8_t level_u, level_v;\n        uint8_t mode_ref_delta_enabled;\n        uint8_t mode_ref_delta_update;\n        Dav1dLoopfilterModeRefDeltas mode_ref_deltas;\n        uint8_t sharpness;\n    } loopfilter;\n    struct {\n        uint8_t damping;\n        uint8_t n_bits;\n        uint8_t y_strength[DAV1D_MAX_CDEF_STRENGTHS];\n        uint8_t uv_strength[DAV1D_MAX_CDEF_STRENGTHS];\n    } cdef;\n    struct {\n        enum Dav1dRestorationType type[3 /* plane */];\n        uint8_t unit_size[2 /* y, uv */];\n    } restoration;\n    enum Dav1dTxfmMode txfm_mode;\n    uint8_t switchable_comp_refs;\n    uint8_t skip_mode_allowed, skip_mode_enabled;\n    int8_t skip_mode_refs[2];\n    uint8_t warp_motion;\n    uint8_t reduced_txtp_set;\n    Dav1dWarpedMotionParams gmv[DAV1D_REFS_PER_FRAME];\n} Dav1dFrameHeader;\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_HEADERS_H */\n"
  },
  {
    "path": "thirdparty/32/include/dav1d/picture.h",
    "content": "/*\n * Copyright © 2018-2020, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_PICTURE_H\n#define DAV1D_PICTURE_H\n\n#include <stddef.h>\n#include <stdint.h>\n\n#include \"common.h\"\n#include \"headers.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Number of bytes to align AND pad picture memory buffers by, so that SIMD\n * implementations can over-read by a few bytes, and use aligned read/write\n * instructions. */\n#define DAV1D_PICTURE_ALIGNMENT 64\n\ntypedef struct Dav1dPictureParameters {\n    int w; ///< width (in pixels)\n    int h; ///< height (in pixels)\n    enum Dav1dPixelLayout layout; ///< format of the picture\n    int bpc; ///< bits per pixel component (8 or 10)\n} Dav1dPictureParameters;\n\ntypedef struct Dav1dPicture {\n    Dav1dSequenceHeader *seq_hdr;\n    Dav1dFrameHeader *frame_hdr;\n\n    /**\n     * Pointers to planar image data (Y is [0], U is [1], V is [2]). The data\n     * should be bytes (for 8 bpc) or words (for 10 bpc). In case of words\n     * containing 10 bpc image data, the pixels should be located in the LSB\n     * bits, so that values range between [0, 1023]; the upper bits should be\n     * zero'ed out.\n     */\n    void *data[3];\n\n    /**\n     * Number of bytes between 2 lines in data[] for luma [0] or chroma [1].\n     */\n    ptrdiff_t stride[2];\n\n    Dav1dPictureParameters p;\n    Dav1dDataProps m;\n\n    /**\n     * High Dynamic Range Content Light Level metadata applying to this picture,\n     * as defined in section 5.8.3 and 6.7.3\n     */\n    Dav1dContentLightLevel *content_light;\n    /**\n     * High Dynamic Range Mastering Display Color Volume metadata applying to\n     * this picture, as defined in section 5.8.4 and 6.7.4\n     */\n    Dav1dMasteringDisplay *mastering_display;\n    /**\n     * Array of ITU-T T.35 metadata as defined in section 5.8.2 and 6.7.2\n     */\n    Dav1dITUTT35 *itut_t35;\n\n    /**\n     * Number of ITU-T T35 metadata entries in the array\n     */\n    size_t n_itut_t35;\n\n    uintptr_t reserved[4]; ///< reserved for future use\n\n    struct Dav1dRef *frame_hdr_ref; ///< Dav1dFrameHeader allocation origin\n    struct Dav1dRef *seq_hdr_ref; ///< Dav1dSequenceHeader allocation origin\n    struct Dav1dRef *content_light_ref; ///< Dav1dContentLightLevel allocation origin\n    struct Dav1dRef *mastering_display_ref; ///< Dav1dMasteringDisplay allocation origin\n    struct Dav1dRef *itut_t35_ref; ///< Dav1dITUTT35 allocation origin\n    uintptr_t reserved_ref[4]; ///< reserved for future use\n    struct Dav1dRef *ref; ///< Frame data allocation origin\n\n    void *allocator_data; ///< pointer managed by the allocator\n} Dav1dPicture;\n\ntypedef struct Dav1dPicAllocator {\n    void *cookie; ///< custom data to pass to the allocator callbacks.\n    /**\n     * Allocate the picture buffer based on the Dav1dPictureParameters.\n     *\n     * The data[0], data[1] and data[2] must be DAV1D_PICTURE_ALIGNMENT byte\n     * aligned and with a pixel width/height multiple of 128 pixels. Any\n     * allocated memory area should also be padded by DAV1D_PICTURE_ALIGNMENT\n     * bytes.\n     * data[1] and data[2] must share the same stride[1].\n     *\n     * This function will be called on the main thread (the thread which calls\n     * dav1d_get_picture()).\n     *\n     * @param  pic The picture to allocate the buffer for. The callback needs to\n     *             fill the picture data[0], data[1], data[2], stride[0] and\n     *             stride[1].\n     *             The allocator can fill the pic allocator_data pointer with\n     *             a custom pointer that will be passed to\n     *             release_picture_callback().\n     * @param cookie Custom pointer passed to all calls.\n     *\n     * @note No fields other than data, stride and allocator_data must be filled\n     *       by this callback.\n     * @return 0 on success. A negative DAV1D_ERR value on error.\n     */\n    int (*alloc_picture_callback)(Dav1dPicture *pic, void *cookie);\n    /**\n     * Release the picture buffer.\n     *\n     * If frame threading is used, this function may be called by the main\n     * thread (the thread which calls dav1d_get_picture()) or any of the frame\n     * threads and thus must be thread-safe. If frame threading is not used,\n     * this function will only be called on the main thread.\n     *\n     * @param pic    The picture that was filled by alloc_picture_callback().\n     * @param cookie Custom pointer passed to all calls.\n     */\n    void (*release_picture_callback)(Dav1dPicture *pic, void *cookie);\n} Dav1dPicAllocator;\n\n/**\n * Release reference to a picture.\n */\nDAV1D_API void dav1d_picture_unref(Dav1dPicture *p);\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_PICTURE_H */\n"
  },
  {
    "path": "thirdparty/32/include/dav1d/version.h",
    "content": "/*\n * Copyright © 2019-2024, VideoLAN and dav1d authors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_VERSION_H\n#define DAV1D_VERSION_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define DAV1D_API_VERSION_MAJOR 7\n#define DAV1D_API_VERSION_MINOR 0\n#define DAV1D_API_VERSION_PATCH 0\n\n/**\n * Extract version components from the value returned by\n * dav1d_version_int()\n */\n#define DAV1D_API_MAJOR(v) (((v) >> 16) & 0xFF)\n#define DAV1D_API_MINOR(v) (((v) >>  8) & 0xFF)\n#define DAV1D_API_PATCH(v) (((v) >>  0) & 0xFF)\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_VERSION_H */\n"
  },
  {
    "path": "thirdparty/32/include/gmp.h",
    "content": "/* Definitions for GNU multiple precision functions.   -*- mode: c -*-\n\nCopyright 1991, 1993-1997, 1999-2016, 2020, 2021 Free Software\nFoundation, Inc.\n\nThis file is part of the GNU MP Library.\n\nThe GNU MP Library is free software; you can redistribute it and/or modify\nit under the terms of either:\n\n  * the GNU Lesser General Public License as published by the Free\n    Software Foundation; either version 3 of the License, or (at your\n    option) any later version.\n\nor\n\n  * the GNU General Public License as published by the Free Software\n    Foundation; either version 2 of the License, or (at your option) any\n    later version.\n\nor both in parallel, as here.\n\nThe GNU MP Library is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\nor FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\nfor more details.\n\nYou should have received copies of the GNU General Public License and the\nGNU Lesser General Public License along with the GNU MP Library.  If not,\nsee https://www.gnu.org/licenses/.  */\n\n#ifndef __GMP_H__\n\n#if defined (__cplusplus)\n#include <iosfwd>   /* for std::istream, std::ostream, std::string */\n#include <cstdio>\n#endif\n\n\n/* Instantiated by configure. */\n#if ! defined (__GMP_WITHIN_CONFIGURE)\n#define __GMP_HAVE_HOST_CPU_FAMILY_power   0\n#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0\n#define GMP_LIMB_BITS                      32\n#define GMP_NAIL_BITS                      0\n#endif\n#define GMP_NUMB_BITS     (GMP_LIMB_BITS - GMP_NAIL_BITS)\n#define GMP_NUMB_MASK     ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)\n#define GMP_NUMB_MAX      GMP_NUMB_MASK\n#define GMP_NAIL_MASK     (~ GMP_NUMB_MASK)\n\n\n#ifndef __GNU_MP__\n#define __GNU_MP__ 6\n\n#include <stddef.h>    /* for size_t */\n#include <limits.h>\n\n/* Instantiated by configure. */\n#if ! defined (__GMP_WITHIN_CONFIGURE)\n/* #undef _LONG_LONG_LIMB */\n#define __GMP_LIBGMP_DLL  0\n#endif\n\n\n/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in\n   all other circumstances.\n\n   When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,\n   or when compiling for an application it's an import directive.  The two\n   cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles\n   (and not defined from an application).\n\n   __GMP_DECLSPEC_XX is similarly used for libgmpxx.  __GMP_WITHIN_GMPXX\n   indicates when building libgmpxx, and in that case libgmpxx functions are\n   exports, but libgmp functions which might get called are imports.\n\n   Libtool DLL_EXPORT define is not used.\n\n   There's no attempt to support GMP built both static and DLL.  Doing so\n   would mean applications would have to tell us which of the two is going\n   to be used when linking, and that seems very tedious and error prone if\n   using GMP by hand, and equally tedious from a package since autoconf and\n   automake don't give much help.\n\n   __GMP_DECLSPEC is required on all documented global functions and\n   variables, the various internals in gmp-impl.h etc can be left unadorned.\n   But internals used by the test programs or speed measuring programs\n   should have __GMP_DECLSPEC, and certainly constants or variables must\n   have it or the wrong address will be resolved.\n\n   In gcc __declspec can go at either the start or end of a prototype.\n\n   In Microsoft C __declspec must go at the start, or after the type like\n   void __declspec(...) *foo()\".  There's no __dllexport or anything to\n   guard against someone foolish #defining dllexport.  _export used to be\n   available, but no longer.\n\n   In Borland C _export still exists, but needs to go after the type, like\n   \"void _export foo();\".  Would have to change the __GMP_DECLSPEC syntax to\n   make use of that.  Probably more trouble than it's worth.  */\n\n#if defined (__GNUC__)\n#define __GMP_DECLSPEC_EXPORT  __declspec(__dllexport__)\n#define __GMP_DECLSPEC_IMPORT  __declspec(__dllimport__)\n#endif\n#if defined (_MSC_VER) || defined (__BORLANDC__)\n#define __GMP_DECLSPEC_EXPORT  __declspec(dllexport)\n#define __GMP_DECLSPEC_IMPORT  __declspec(dllimport)\n#endif\n#ifdef __WATCOMC__\n#define __GMP_DECLSPEC_EXPORT  __export\n#define __GMP_DECLSPEC_IMPORT  __import\n#endif\n#ifdef __IBMC__\n#define __GMP_DECLSPEC_EXPORT  _Export\n#define __GMP_DECLSPEC_IMPORT  _Import\n#endif\n\n#if __GMP_LIBGMP_DLL\n#ifdef __GMP_WITHIN_GMP\n/* compiling to go into a DLL libgmp */\n#define __GMP_DECLSPEC  __GMP_DECLSPEC_EXPORT\n#else\n/* compiling to go into an application which will link to a DLL libgmp */\n#define __GMP_DECLSPEC  __GMP_DECLSPEC_IMPORT\n#endif\n#else\n/* all other cases */\n#define __GMP_DECLSPEC\n#endif\n\n\n#ifdef __GMP_SHORT_LIMB\ntypedef unsigned int\t\tmp_limb_t;\ntypedef int\t\t\tmp_limb_signed_t;\n#else\n#ifdef _LONG_LONG_LIMB\ntypedef unsigned long long int\tmp_limb_t;\ntypedef long long int\t\tmp_limb_signed_t;\n#else\ntypedef unsigned long int\tmp_limb_t;\ntypedef long int\t\tmp_limb_signed_t;\n#endif\n#endif\ntypedef unsigned long int\tmp_bitcnt_t;\n\n/* For reference, note that the name __mpz_struct gets into C++ mangled\n   function names, which means although the \"__\" suggests an internal, we\n   must leave this name for binary compatibility.  */\ntypedef struct\n{\n  int _mp_alloc;\t\t/* Number of *limbs* allocated and pointed\n\t\t\t\t   to by the _mp_d field.  */\n  int _mp_size;\t\t\t/* abs(_mp_size) is the number of limbs the\n\t\t\t\t   last field points to.  If _mp_size is\n\t\t\t\t   negative this is a negative number.  */\n  mp_limb_t *_mp_d;\t\t/* Pointer to the limbs.  */\n} __mpz_struct;\n\n#endif /* __GNU_MP__ */\n\n\ntypedef __mpz_struct MP_INT;    /* gmp 1 source compatibility */\ntypedef __mpz_struct mpz_t[1];\n\ntypedef mp_limb_t *\t\tmp_ptr;\ntypedef const mp_limb_t *\tmp_srcptr;\n#if defined (_CRAY) && ! defined (_CRAYMPP)\n/* plain `int' is much faster (48 bits) */\n#define __GMP_MP_SIZE_T_INT     1\ntypedef int\t\t\tmp_size_t;\ntypedef int\t\t\tmp_exp_t;\n#else\n#define __GMP_MP_SIZE_T_INT     0\ntypedef long int\t\tmp_size_t;\ntypedef long int\t\tmp_exp_t;\n#endif\n\ntypedef struct\n{\n  __mpz_struct _mp_num;\n  __mpz_struct _mp_den;\n} __mpq_struct;\n\ntypedef __mpq_struct MP_RAT;    /* gmp 1 source compatibility */\ntypedef __mpq_struct mpq_t[1];\n\ntypedef struct\n{\n  int _mp_prec;\t\t\t/* Max precision, in number of `mp_limb_t's.\n\t\t\t\t   Set by mpf_init and modified by\n\t\t\t\t   mpf_set_prec.  The area pointed to by the\n\t\t\t\t   _mp_d field contains `prec' + 1 limbs.  */\n  int _mp_size;\t\t\t/* abs(_mp_size) is the number of limbs the\n\t\t\t\t   last field points to.  If _mp_size is\n\t\t\t\t   negative this is a negative number.  */\n  mp_exp_t _mp_exp;\t\t/* Exponent, in the base of `mp_limb_t'.  */\n  mp_limb_t *_mp_d;\t\t/* Pointer to the limbs.  */\n} __mpf_struct;\n\n/* typedef __mpf_struct MP_FLOAT; */\ntypedef __mpf_struct mpf_t[1];\n\n/* Available random number generation algorithms.  */\ntypedef enum\n{\n  GMP_RAND_ALG_DEFAULT = 0,\n  GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential.  */\n} gmp_randalg_t;\n\n/* Random state struct.  */\ntypedef struct\n{\n  mpz_t _mp_seed;\t  /* _mp_d member points to state of the generator. */\n  gmp_randalg_t _mp_alg;  /* Currently unused. */\n  union {\n    void *_mp_lc;         /* Pointer to function pointers structure.  */\n  } _mp_algdata;\n} __gmp_randstate_struct;\ntypedef __gmp_randstate_struct gmp_randstate_t[1];\n\n/* Types for function declarations in gmp files.  */\n/* ??? Should not pollute user name space with these ??? */\ntypedef const __mpz_struct *mpz_srcptr;\ntypedef __mpz_struct *mpz_ptr;\ntypedef const __mpf_struct *mpf_srcptr;\ntypedef __mpf_struct *mpf_ptr;\ntypedef const __mpq_struct *mpq_srcptr;\ntypedef __mpq_struct *mpq_ptr;\ntypedef __gmp_randstate_struct *gmp_randstate_ptr;\ntypedef const __gmp_randstate_struct *gmp_randstate_srcptr;\n\n\n#if __GMP_LIBGMP_DLL\n#ifdef __GMP_WITHIN_GMPXX\n/* compiling to go into a DLL libgmpxx */\n#define __GMP_DECLSPEC_XX  __GMP_DECLSPEC_EXPORT\n#else\n/* compiling to go into a application which will link to a DLL libgmpxx */\n#define __GMP_DECLSPEC_XX  __GMP_DECLSPEC_IMPORT\n#endif\n#else\n/* all other cases */\n#define __GMP_DECLSPEC_XX\n#endif\n\n\n#ifndef __MPN\n#define __MPN(x) __gmpn_##x\n#endif\n\n/* For reference, \"defined(EOF)\" cannot be used here.  In g++ 2.95.4,\n   <iostream> defines EOF but not FILE.  */\n#if defined (FILE)                                              \\\n  || defined (H_STDIO)                                          \\\n  || defined (_H_STDIO)               /* AIX */                 \\\n  || defined (_STDIO_H)               /* glibc, Sun, SCO */     \\\n  || defined (_STDIO_H_)              /* BSD, OSF */            \\\n  || defined (__STDIO_H)              /* Borland */             \\\n  || defined (__STDIO_H__)            /* IRIX */                \\\n  || defined (_STDIO_INCLUDED)        /* HPUX */                \\\n  || defined (__dj_include_stdio_h_)  /* DJGPP */               \\\n  || defined (_FILE_DEFINED)          /* Microsoft */           \\\n  || defined (__STDIO__)              /* Apple MPW MrC */       \\\n  || defined (_MSL_STDIO_H)           /* Metrowerks */          \\\n  || defined (_STDIO_H_INCLUDED)      /* QNX4 */\t\t\\\n  || defined (_ISO_STDIO_ISO_H)       /* Sun C++ */\t\t\\\n  || defined (__STDIO_LOADED)         /* VMS */\t\t\t\\\n  || defined (_STDIO)                 /* HPE NonStop */         \\\n  || defined (__DEFINED_FILE)         /* musl */\n#define _GMP_H_HAVE_FILE 1\n#endif\n\n/* In ISO C, if a prototype involving \"struct obstack *\" is given without\n   that structure defined, then the struct is scoped down to just the\n   prototype, causing a conflict if it's subsequently defined for real.  So\n   only give prototypes if we've got obstack.h.  */\n#if defined (_OBSTACK_H)   /* glibc <obstack.h> */\n#define _GMP_H_HAVE_OBSTACK 1\n#endif\n\n/* The prototypes for gmp_vprintf etc are provided only if va_list is defined,\n   via an application having included <stdarg.h>.  Usually va_list is a typedef\n   so can't be tested directly, but C99 specifies that va_start is a macro.\n\n   <stdio.h> will define some sort of va_list for vprintf and vfprintf, but\n   let's not bother trying to use that since it's not standard and since\n   application uses for gmp_vprintf etc will almost certainly require the\n   whole <stdarg.h> anyway.  */\n\n#ifdef va_start\n#define _GMP_H_HAVE_VA_LIST 1\n#endif\n\n/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */\n#if defined (__GNUC__) && defined (__GNUC_MINOR__)\n#define __GMP_GNUC_PREREQ(maj, min) \\\n  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))\n#else\n#define __GMP_GNUC_PREREQ(maj, min)  0\n#endif\n\n/* \"pure\" is in gcc 2.96 and up, see \"(gcc)Function Attributes\".  Basically\n   it means a function does nothing but examine its arguments and memory\n   (global or via arguments) to generate a return value, but changes nothing\n   and has no side-effects.  __GMP_NO_ATTRIBUTE_CONST_PURE lets\n   tune/common.c etc turn this off when trying to write timing loops.  */\n#if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE)\n#define __GMP_ATTRIBUTE_PURE   __attribute__ ((__pure__))\n#else\n#define __GMP_ATTRIBUTE_PURE\n#endif\n\n\n/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean\n   to \"g++ -Wold-style-cast\".\n\n   Casts in \"extern inline\" code within an extern \"C\" block don't induce\n   these warnings, so __GMP_CAST only needs to be used on documented\n   macros.  */\n\n#ifdef __cplusplus\n#define __GMP_CAST(type, expr)  (static_cast<type> (expr))\n#else\n#define __GMP_CAST(type, expr)  ((type) (expr))\n#endif\n\n\n/* An empty \"throw ()\" means the function doesn't throw any C++ exceptions,\n   this can save some stack frame info in applications.\n\n   Currently it's given only on functions which never divide-by-zero etc,\n   don't allocate memory, and are expected to never need to allocate memory.\n   This leaves open the possibility of a C++ throw from a future GMP\n   exceptions scheme.\n\n   mpz_set_ui etc are omitted to leave open the lazy allocation scheme\n   described in doc/tasks.html.  mpz_get_d etc are omitted to leave open\n   exceptions for float overflows.\n\n   Note that __GMP_NOTHROW must be given on any inlines the same as on their\n   prototypes (for g++ at least, where they're used together).  Note also\n   that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like\n   __GMP_ATTRIBUTE_PURE.  */\n\n#if defined (__cplusplus)\n#if __cplusplus >= 201103L\n#define __GMP_NOTHROW  noexcept\n#else\n#define __GMP_NOTHROW  throw ()\n#endif\n#else\n#define __GMP_NOTHROW\n#endif\n\n\n/* PORTME: What other compilers have a useful \"extern inline\"?  \"static\n   inline\" would be an acceptable substitute if the compiler (or linker)\n   discards unused statics.  */\n\n /* gcc has __inline__ in all modes, including strict ansi.  Give a prototype\n    for an inline too, so as to correctly specify \"dllimport\" on windows, in\n    case the function is called rather than inlined.\n    GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99\n    inline semantics, unless -fgnu89-inline is used.  */\n#ifdef __GNUC__\n#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) \\\n  || (defined __GNUC_GNU_INLINE__ && defined __cplusplus)\n#define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__))\n#else\n#define __GMP_EXTERN_INLINE      extern __inline__\n#endif\n#define __GMP_INLINE_PROTOTYPES  1\n#endif\n\n/* DEC C (eg. version 5.9) supports \"static __inline foo()\", even in -std1\n   strict ANSI mode.  Inlining is done even when not optimizing (ie. -O0\n   mode, which is the default), but an unnecessary local copy of foo is\n   emitted unless -O is used.  \"extern __inline\" is accepted, but the\n   \"extern\" appears to be ignored, ie. it becomes a plain global function\n   but which is inlined within its file.  Don't know if all old versions of\n   DEC C supported __inline, but as a start let's do the right thing for\n   current versions.  */\n#ifdef __DECC\n#define __GMP_EXTERN_INLINE  static __inline\n#endif\n\n/* SCO OpenUNIX 8 cc supports \"static inline foo()\" but not in -Xc strict\n   ANSI mode (__STDC__ is 1 in that mode).  Inlining only actually takes\n   place under -O.  Without -O \"foo\" seems to be emitted whether it's used\n   or not, which is wasteful.  \"extern inline foo()\" isn't useful, the\n   \"extern\" is apparently ignored, so foo is inlined if possible but also\n   emitted as a global, which causes multiple definition errors when\n   building a shared libgmp.  */\n#ifdef __SCO_VERSION__\n#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \\\n  && ! defined (__GMP_EXTERN_INLINE)\n#define __GMP_EXTERN_INLINE  static inline\n#endif\n#endif\n\n/* Microsoft's C compiler accepts __inline */\n#ifdef _MSC_VER\n#define __GMP_EXTERN_INLINE  __inline\n#endif\n\n/* Recent enough Sun C compilers want \"inline\" */\n#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \\\n  && ! defined (__GMP_EXTERN_INLINE)\n#define __GMP_EXTERN_INLINE  inline\n#endif\n\n/* Somewhat older Sun C compilers want \"static inline\" */\n#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \\\n  && ! defined (__GMP_EXTERN_INLINE)\n#define __GMP_EXTERN_INLINE  static inline\n#endif\n\n\n/* C++ always has \"inline\" and since it's a normal feature the linker should\n   discard duplicate non-inlined copies, or if it doesn't then that's a\n   problem for everyone, not just GMP.  */\n#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)\n#define __GMP_EXTERN_INLINE  inline\n#endif\n\n/* Don't do any inlining within a configure run, since if the compiler ends\n   up emitting copies of the code into the object file it can end up\n   demanding the various support routines (like mpn_popcount) for linking,\n   making the \"alloca\" test and perhaps others fail.  And on hppa ia64 a\n   pre-release gcc 3.2 was seen not respecting the \"extern\" in \"extern\n   __inline__\", triggering this problem too.  */\n#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE\n#undef __GMP_EXTERN_INLINE\n#endif\n\n/* By default, don't give a prototype when there's going to be an inline\n   version.  Note in particular that Cray C++ objects to the combination of\n   prototype and inline.  */\n#ifdef __GMP_EXTERN_INLINE\n#ifndef __GMP_INLINE_PROTOTYPES\n#define __GMP_INLINE_PROTOTYPES  0\n#endif\n#else\n#define __GMP_INLINE_PROTOTYPES  1\n#endif\n\n\n#define __GMP_ABS(x)   ((x) >= 0 ? (x) : -(x))\n#define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i))\n\n\n/* __builtin_expect is in gcc 3.0, and not in 2.95. */\n#if __GMP_GNUC_PREREQ (3,0)\n#define __GMP_LIKELY(cond)    __builtin_expect ((cond) != 0, 1)\n#define __GMP_UNLIKELY(cond)  __builtin_expect ((cond) != 0, 0)\n#else\n#define __GMP_LIKELY(cond)    (cond)\n#define __GMP_UNLIKELY(cond)  (cond)\n#endif\n\n#ifdef _CRAY\n#define __GMP_CRAY_Pragma(str)  _Pragma (str)\n#else\n#define __GMP_CRAY_Pragma(str)\n#endif\n\n\n/* Allow direct user access to numerator and denominator of an mpq_t object.  */\n#define mpq_numref(Q) (&((Q)->_mp_num))\n#define mpq_denref(Q) (&((Q)->_mp_den))\n\n\n#if defined (__cplusplus)\nextern \"C\" {\nusing std::FILE;\n#endif\n\n#define mp_set_memory_functions __gmp_set_memory_functions\n__GMP_DECLSPEC void mp_set_memory_functions (void *(*) (size_t),\n\t\t\t\t      void *(*) (void *, size_t, size_t),\n\t\t\t\t      void (*) (void *, size_t)) __GMP_NOTHROW;\n\n#define mp_get_memory_functions __gmp_get_memory_functions\n__GMP_DECLSPEC void mp_get_memory_functions (void *(**) (size_t),\n\t\t\t\t      void *(**) (void *, size_t, size_t),\n\t\t\t\t      void (**) (void *, size_t)) __GMP_NOTHROW;\n\n#define mp_bits_per_limb __gmp_bits_per_limb\n__GMP_DECLSPEC extern const int mp_bits_per_limb;\n\n#define gmp_errno __gmp_errno\n__GMP_DECLSPEC extern int gmp_errno;\n\n#define gmp_version __gmp_version\n__GMP_DECLSPEC extern const char * const gmp_version;\n\n\n/**************** Random number routines.  ****************/\n\n/* obsolete */\n#define gmp_randinit __gmp_randinit\n__GMP_DECLSPEC void gmp_randinit (gmp_randstate_ptr, gmp_randalg_t, ...);\n\n#define gmp_randinit_default __gmp_randinit_default\n__GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_ptr);\n\n#define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp\n__GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_ptr, mpz_srcptr, unsigned long int, mp_bitcnt_t);\n\n#define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size\n__GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_ptr, mp_bitcnt_t);\n\n#define gmp_randinit_mt __gmp_randinit_mt\n__GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_ptr);\n\n#define gmp_randinit_set __gmp_randinit_set\n__GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_ptr, gmp_randstate_srcptr);\n\n#define gmp_randseed __gmp_randseed\n__GMP_DECLSPEC void gmp_randseed (gmp_randstate_ptr, mpz_srcptr);\n\n#define gmp_randseed_ui __gmp_randseed_ui\n__GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_ptr, unsigned long int);\n\n#define gmp_randclear __gmp_randclear\n__GMP_DECLSPEC void gmp_randclear (gmp_randstate_ptr);\n\n#define gmp_urandomb_ui __gmp_urandomb_ui\n__GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_ptr, unsigned long);\n\n#define gmp_urandomm_ui __gmp_urandomm_ui\n__GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_ptr, unsigned long);\n\n\n/**************** Formatted output routines.  ****************/\n\n#define gmp_asprintf __gmp_asprintf\n__GMP_DECLSPEC int gmp_asprintf (char **, const char *, ...);\n\n#define gmp_fprintf __gmp_fprintf\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC int gmp_fprintf (FILE *, const char *, ...);\n#endif\n\n#define gmp_obstack_printf __gmp_obstack_printf\n#if defined (_GMP_H_HAVE_OBSTACK)\n__GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...);\n#endif\n\n#define gmp_obstack_vprintf __gmp_obstack_vprintf\n#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list);\n#endif\n\n#define gmp_printf __gmp_printf\n__GMP_DECLSPEC int gmp_printf (const char *, ...);\n\n#define gmp_snprintf __gmp_snprintf\n__GMP_DECLSPEC int gmp_snprintf (char *, size_t, const char *, ...);\n\n#define gmp_sprintf __gmp_sprintf\n__GMP_DECLSPEC int gmp_sprintf (char *, const char *, ...);\n\n#define gmp_vasprintf __gmp_vasprintf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vasprintf (char **, const char *, va_list);\n#endif\n\n#define gmp_vfprintf __gmp_vfprintf\n#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vfprintf (FILE *, const char *, va_list);\n#endif\n\n#define gmp_vprintf __gmp_vprintf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vprintf (const char *, va_list);\n#endif\n\n#define gmp_vsnprintf __gmp_vsnprintf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vsnprintf (char *, size_t, const char *, va_list);\n#endif\n\n#define gmp_vsprintf __gmp_vsprintf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vsprintf (char *, const char *, va_list);\n#endif\n\n\n/**************** Formatted input routines.  ****************/\n\n#define gmp_fscanf __gmp_fscanf\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC int gmp_fscanf (FILE *, const char *, ...);\n#endif\n\n#define gmp_scanf __gmp_scanf\n__GMP_DECLSPEC int gmp_scanf (const char *, ...);\n\n#define gmp_sscanf __gmp_sscanf\n__GMP_DECLSPEC int gmp_sscanf (const char *, const char *, ...);\n\n#define gmp_vfscanf __gmp_vfscanf\n#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vfscanf (FILE *, const char *, va_list);\n#endif\n\n#define gmp_vscanf __gmp_vscanf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vscanf (const char *, va_list);\n#endif\n\n#define gmp_vsscanf __gmp_vsscanf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vsscanf (const char *, const char *, va_list);\n#endif\n\n\n/**************** Integer (i.e. Z) routines.  ****************/\n\n#define _mpz_realloc __gmpz_realloc\n#define mpz_realloc __gmpz_realloc\n__GMP_DECLSPEC void *_mpz_realloc (mpz_ptr, mp_size_t);\n\n#define mpz_abs __gmpz_abs\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs)\n__GMP_DECLSPEC void mpz_abs (mpz_ptr, mpz_srcptr);\n#endif\n\n#define mpz_add __gmpz_add\n__GMP_DECLSPEC void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_add_ui __gmpz_add_ui\n__GMP_DECLSPEC void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_addmul __gmpz_addmul\n__GMP_DECLSPEC void mpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_addmul_ui __gmpz_addmul_ui\n__GMP_DECLSPEC void mpz_addmul_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_and __gmpz_and\n__GMP_DECLSPEC void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_array_init __gmpz_array_init\n__GMP_DECLSPEC void mpz_array_init (mpz_ptr, mp_size_t, mp_size_t);\n\n#define mpz_bin_ui __gmpz_bin_ui\n__GMP_DECLSPEC void mpz_bin_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_bin_uiui __gmpz_bin_uiui\n__GMP_DECLSPEC void mpz_bin_uiui (mpz_ptr, unsigned long int, unsigned long int);\n\n#define mpz_cdiv_q __gmpz_cdiv_q\n__GMP_DECLSPEC void mpz_cdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp\n__GMP_DECLSPEC void mpz_cdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_cdiv_q_ui __gmpz_cdiv_q_ui\n__GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_cdiv_qr __gmpz_cdiv_qr\n__GMP_DECLSPEC void mpz_cdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui\n__GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_cdiv_r __gmpz_cdiv_r\n__GMP_DECLSPEC void mpz_cdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp\n__GMP_DECLSPEC void mpz_cdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_cdiv_r_ui __gmpz_cdiv_r_ui\n__GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_cdiv_ui __gmpz_cdiv_ui\n__GMP_DECLSPEC unsigned long int mpz_cdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_clear __gmpz_clear\n__GMP_DECLSPEC void mpz_clear (mpz_ptr);\n\n#define mpz_clears __gmpz_clears\n__GMP_DECLSPEC void mpz_clears (mpz_ptr, ...);\n\n#define mpz_clrbit __gmpz_clrbit\n__GMP_DECLSPEC void mpz_clrbit (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_cmp __gmpz_cmp\n__GMP_DECLSPEC int mpz_cmp (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_cmp_d __gmpz_cmp_d\n__GMP_DECLSPEC int mpz_cmp_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE;\n\n#define _mpz_cmp_si __gmpz_cmp_si\n__GMP_DECLSPEC int _mpz_cmp_si (mpz_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define _mpz_cmp_ui __gmpz_cmp_ui\n__GMP_DECLSPEC int _mpz_cmp_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_cmpabs __gmpz_cmpabs\n__GMP_DECLSPEC int mpz_cmpabs (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_cmpabs_d __gmpz_cmpabs_d\n__GMP_DECLSPEC int mpz_cmpabs_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_cmpabs_ui __gmpz_cmpabs_ui\n__GMP_DECLSPEC int mpz_cmpabs_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_com __gmpz_com\n__GMP_DECLSPEC void mpz_com (mpz_ptr, mpz_srcptr);\n\n#define mpz_combit __gmpz_combit\n__GMP_DECLSPEC void mpz_combit (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_congruent_p __gmpz_congruent_p\n__GMP_DECLSPEC int mpz_congruent_p (mpz_srcptr, mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_congruent_2exp_p __gmpz_congruent_2exp_p\n__GMP_DECLSPEC int mpz_congruent_2exp_p (mpz_srcptr, mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_congruent_ui_p __gmpz_congruent_ui_p\n__GMP_DECLSPEC int mpz_congruent_ui_p (mpz_srcptr, unsigned long, unsigned long) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_divexact __gmpz_divexact\n__GMP_DECLSPEC void mpz_divexact (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_divexact_ui __gmpz_divexact_ui\n__GMP_DECLSPEC void mpz_divexact_ui (mpz_ptr, mpz_srcptr, unsigned long);\n\n#define mpz_divisible_p __gmpz_divisible_p\n__GMP_DECLSPEC int mpz_divisible_p (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_divisible_ui_p __gmpz_divisible_ui_p\n__GMP_DECLSPEC int mpz_divisible_ui_p (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_divisible_2exp_p __gmpz_divisible_2exp_p\n__GMP_DECLSPEC int mpz_divisible_2exp_p (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_dump __gmpz_dump\n__GMP_DECLSPEC void mpz_dump (mpz_srcptr);\n\n#define mpz_export __gmpz_export\n__GMP_DECLSPEC void *mpz_export (void *, size_t *, int, size_t, int, size_t, mpz_srcptr);\n\n#define mpz_fac_ui __gmpz_fac_ui\n__GMP_DECLSPEC void mpz_fac_ui (mpz_ptr, unsigned long int);\n\n#define mpz_2fac_ui __gmpz_2fac_ui\n__GMP_DECLSPEC void mpz_2fac_ui (mpz_ptr, unsigned long int);\n\n#define mpz_mfac_uiui __gmpz_mfac_uiui\n__GMP_DECLSPEC void mpz_mfac_uiui (mpz_ptr, unsigned long int, unsigned long int);\n\n#define mpz_primorial_ui __gmpz_primorial_ui\n__GMP_DECLSPEC void mpz_primorial_ui (mpz_ptr, unsigned long int);\n\n#define mpz_fdiv_q __gmpz_fdiv_q\n__GMP_DECLSPEC void mpz_fdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp\n__GMP_DECLSPEC void mpz_fdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_fdiv_q_ui __gmpz_fdiv_q_ui\n__GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_fdiv_qr __gmpz_fdiv_qr\n__GMP_DECLSPEC void mpz_fdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui\n__GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_fdiv_r __gmpz_fdiv_r\n__GMP_DECLSPEC void mpz_fdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp\n__GMP_DECLSPEC void mpz_fdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_fdiv_r_ui __gmpz_fdiv_r_ui\n__GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_fdiv_ui __gmpz_fdiv_ui\n__GMP_DECLSPEC unsigned long int mpz_fdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_fib_ui __gmpz_fib_ui\n__GMP_DECLSPEC void mpz_fib_ui (mpz_ptr, unsigned long int);\n\n#define mpz_fib2_ui __gmpz_fib2_ui\n__GMP_DECLSPEC void mpz_fib2_ui (mpz_ptr, mpz_ptr, unsigned long int);\n\n#define mpz_fits_sint_p __gmpz_fits_sint_p\n__GMP_DECLSPEC int mpz_fits_sint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_fits_slong_p __gmpz_fits_slong_p\n__GMP_DECLSPEC int mpz_fits_slong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_fits_sshort_p __gmpz_fits_sshort_p\n__GMP_DECLSPEC int mpz_fits_sshort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_fits_uint_p __gmpz_fits_uint_p\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p)\n__GMP_DECLSPEC int mpz_fits_uint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_fits_ulong_p __gmpz_fits_ulong_p\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p)\n__GMP_DECLSPEC int mpz_fits_ulong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_fits_ushort_p __gmpz_fits_ushort_p\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p)\n__GMP_DECLSPEC int mpz_fits_ushort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_gcd __gmpz_gcd\n__GMP_DECLSPEC void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_gcd_ui __gmpz_gcd_ui\n__GMP_DECLSPEC unsigned long int mpz_gcd_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_gcdext __gmpz_gcdext\n__GMP_DECLSPEC void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_get_d __gmpz_get_d\n__GMP_DECLSPEC double mpz_get_d (mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_get_d_2exp __gmpz_get_d_2exp\n__GMP_DECLSPEC double mpz_get_d_2exp (signed long int *, mpz_srcptr);\n\n#define mpz_get_si __gmpz_get_si\n__GMP_DECLSPEC /* signed */ long int mpz_get_si (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_get_str __gmpz_get_str\n__GMP_DECLSPEC char *mpz_get_str (char *, int, mpz_srcptr);\n\n#define mpz_get_ui __gmpz_get_ui\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui)\n__GMP_DECLSPEC unsigned long int mpz_get_ui (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_getlimbn __gmpz_getlimbn\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn)\n__GMP_DECLSPEC mp_limb_t mpz_getlimbn (mpz_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_hamdist __gmpz_hamdist\n__GMP_DECLSPEC mp_bitcnt_t mpz_hamdist (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_import __gmpz_import\n__GMP_DECLSPEC void mpz_import (mpz_ptr, size_t, int, size_t, int, size_t, const void *);\n\n#define mpz_init __gmpz_init\n__GMP_DECLSPEC void mpz_init (mpz_ptr) __GMP_NOTHROW;\n\n#define mpz_init2 __gmpz_init2\n__GMP_DECLSPEC void mpz_init2 (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_inits __gmpz_inits\n__GMP_DECLSPEC void mpz_inits (mpz_ptr, ...) __GMP_NOTHROW;\n\n#define mpz_init_set __gmpz_init_set\n__GMP_DECLSPEC void mpz_init_set (mpz_ptr, mpz_srcptr);\n\n#define mpz_init_set_d __gmpz_init_set_d\n__GMP_DECLSPEC void mpz_init_set_d (mpz_ptr, double);\n\n#define mpz_init_set_si __gmpz_init_set_si\n__GMP_DECLSPEC void mpz_init_set_si (mpz_ptr, signed long int);\n\n#define mpz_init_set_str __gmpz_init_set_str\n__GMP_DECLSPEC int mpz_init_set_str (mpz_ptr, const char *, int);\n\n#define mpz_init_set_ui __gmpz_init_set_ui\n__GMP_DECLSPEC void mpz_init_set_ui (mpz_ptr, unsigned long int);\n\n#define mpz_inp_raw __gmpz_inp_raw\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpz_inp_raw (mpz_ptr, FILE *);\n#endif\n\n#define mpz_inp_str __gmpz_inp_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpz_inp_str (mpz_ptr, FILE *, int);\n#endif\n\n#define mpz_invert __gmpz_invert\n__GMP_DECLSPEC int mpz_invert (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_ior __gmpz_ior\n__GMP_DECLSPEC void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_jacobi __gmpz_jacobi\n__GMP_DECLSPEC int mpz_jacobi (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_kronecker mpz_jacobi  /* alias */\n\n#define mpz_kronecker_si __gmpz_kronecker_si\n__GMP_DECLSPEC int mpz_kronecker_si (mpz_srcptr, long) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_kronecker_ui __gmpz_kronecker_ui\n__GMP_DECLSPEC int mpz_kronecker_ui (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_si_kronecker __gmpz_si_kronecker\n__GMP_DECLSPEC int mpz_si_kronecker (long, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_ui_kronecker __gmpz_ui_kronecker\n__GMP_DECLSPEC int mpz_ui_kronecker (unsigned long, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_lcm __gmpz_lcm\n__GMP_DECLSPEC void mpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_lcm_ui __gmpz_lcm_ui\n__GMP_DECLSPEC void mpz_lcm_ui (mpz_ptr, mpz_srcptr, unsigned long);\n\n#define mpz_legendre mpz_jacobi  /* alias */\n\n#define mpz_lucnum_ui __gmpz_lucnum_ui\n__GMP_DECLSPEC void mpz_lucnum_ui (mpz_ptr, unsigned long int);\n\n#define mpz_lucnum2_ui __gmpz_lucnum2_ui\n__GMP_DECLSPEC void mpz_lucnum2_ui (mpz_ptr, mpz_ptr, unsigned long int);\n\n#define mpz_millerrabin __gmpz_millerrabin\n__GMP_DECLSPEC int mpz_millerrabin (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_mod __gmpz_mod\n__GMP_DECLSPEC void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */\n\n#define mpz_mul __gmpz_mul\n__GMP_DECLSPEC void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_mul_2exp __gmpz_mul_2exp\n__GMP_DECLSPEC void mpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_mul_si __gmpz_mul_si\n__GMP_DECLSPEC void mpz_mul_si (mpz_ptr, mpz_srcptr, long int);\n\n#define mpz_mul_ui __gmpz_mul_ui\n__GMP_DECLSPEC void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_neg __gmpz_neg\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg)\n__GMP_DECLSPEC void mpz_neg (mpz_ptr, mpz_srcptr);\n#endif\n\n#define mpz_nextprime __gmpz_nextprime\n__GMP_DECLSPEC void mpz_nextprime (mpz_ptr, mpz_srcptr);\n\n#define mpz_prevprime __gmpz_prevprime\n__GMP_DECLSPEC int mpz_prevprime (mpz_ptr, mpz_srcptr);\n\n#define mpz_out_raw __gmpz_out_raw\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpz_out_raw (FILE *, mpz_srcptr);\n#endif\n\n#define mpz_out_str __gmpz_out_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpz_out_str (FILE *, int, mpz_srcptr);\n#endif\n\n#define mpz_perfect_power_p __gmpz_perfect_power_p\n__GMP_DECLSPEC int mpz_perfect_power_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_perfect_square_p __gmpz_perfect_square_p\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p)\n__GMP_DECLSPEC int mpz_perfect_square_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_popcount __gmpz_popcount\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount)\n__GMP_DECLSPEC mp_bitcnt_t mpz_popcount (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_pow_ui __gmpz_pow_ui\n__GMP_DECLSPEC void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_powm __gmpz_powm\n__GMP_DECLSPEC void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_powm_sec __gmpz_powm_sec\n__GMP_DECLSPEC void mpz_powm_sec (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_powm_ui __gmpz_powm_ui\n__GMP_DECLSPEC void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr);\n\n#define mpz_probab_prime_p __gmpz_probab_prime_p\n__GMP_DECLSPEC int mpz_probab_prime_p (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_random __gmpz_random\n__GMP_DECLSPEC void mpz_random (mpz_ptr, mp_size_t);\n\n#define mpz_random2 __gmpz_random2\n__GMP_DECLSPEC void mpz_random2 (mpz_ptr, mp_size_t);\n\n#define mpz_realloc2 __gmpz_realloc2\n__GMP_DECLSPEC void mpz_realloc2 (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_remove __gmpz_remove\n__GMP_DECLSPEC mp_bitcnt_t mpz_remove (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_root __gmpz_root\n__GMP_DECLSPEC int mpz_root (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_rootrem __gmpz_rootrem\n__GMP_DECLSPEC void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_rrandomb __gmpz_rrandomb\n__GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_ptr, mp_bitcnt_t);\n\n#define mpz_scan0 __gmpz_scan0\n__GMP_DECLSPEC mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_scan1 __gmpz_scan1\n__GMP_DECLSPEC mp_bitcnt_t mpz_scan1 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_set __gmpz_set\n__GMP_DECLSPEC void mpz_set (mpz_ptr, mpz_srcptr);\n\n#define mpz_set_d __gmpz_set_d\n__GMP_DECLSPEC void mpz_set_d (mpz_ptr, double);\n\n#define mpz_set_f __gmpz_set_f\n__GMP_DECLSPEC void mpz_set_f (mpz_ptr, mpf_srcptr);\n\n#define mpz_set_q __gmpz_set_q\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q)\n__GMP_DECLSPEC void mpz_set_q (mpz_ptr, mpq_srcptr);\n#endif\n\n#define mpz_set_si __gmpz_set_si\n__GMP_DECLSPEC void mpz_set_si (mpz_ptr, signed long int);\n\n#define mpz_set_str __gmpz_set_str\n__GMP_DECLSPEC int mpz_set_str (mpz_ptr, const char *, int);\n\n#define mpz_set_ui __gmpz_set_ui\n__GMP_DECLSPEC void mpz_set_ui (mpz_ptr, unsigned long int);\n\n#define mpz_setbit __gmpz_setbit\n__GMP_DECLSPEC void mpz_setbit (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_size __gmpz_size\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)\n__GMP_DECLSPEC size_t mpz_size (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_sizeinbase __gmpz_sizeinbase\n__GMP_DECLSPEC size_t mpz_sizeinbase (mpz_srcptr, int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_sqrt __gmpz_sqrt\n__GMP_DECLSPEC void mpz_sqrt (mpz_ptr, mpz_srcptr);\n\n#define mpz_sqrtrem __gmpz_sqrtrem\n__GMP_DECLSPEC void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr);\n\n#define mpz_sub __gmpz_sub\n__GMP_DECLSPEC void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_sub_ui __gmpz_sub_ui\n__GMP_DECLSPEC void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_ui_sub __gmpz_ui_sub\n__GMP_DECLSPEC void mpz_ui_sub (mpz_ptr, unsigned long int, mpz_srcptr);\n\n#define mpz_submul __gmpz_submul\n__GMP_DECLSPEC void mpz_submul (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_submul_ui __gmpz_submul_ui\n__GMP_DECLSPEC void mpz_submul_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_swap __gmpz_swap\n__GMP_DECLSPEC void mpz_swap (mpz_ptr, mpz_ptr) __GMP_NOTHROW;\n\n#define mpz_tdiv_ui __gmpz_tdiv_ui\n__GMP_DECLSPEC unsigned long int mpz_tdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_tdiv_q __gmpz_tdiv_q\n__GMP_DECLSPEC void mpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp\n__GMP_DECLSPEC void mpz_tdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_tdiv_q_ui __gmpz_tdiv_q_ui\n__GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_tdiv_qr __gmpz_tdiv_qr\n__GMP_DECLSPEC void mpz_tdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui\n__GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_tdiv_r __gmpz_tdiv_r\n__GMP_DECLSPEC void mpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp\n__GMP_DECLSPEC void mpz_tdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_tdiv_r_ui __gmpz_tdiv_r_ui\n__GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_tstbit __gmpz_tstbit\n__GMP_DECLSPEC int mpz_tstbit (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_ui_pow_ui __gmpz_ui_pow_ui\n__GMP_DECLSPEC void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int);\n\n#define mpz_urandomb __gmpz_urandomb\n__GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_ptr, mp_bitcnt_t);\n\n#define mpz_urandomm __gmpz_urandomm\n__GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_ptr, mpz_srcptr);\n\n#define mpz_xor __gmpz_xor\n#define mpz_eor __gmpz_xor\n__GMP_DECLSPEC void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_limbs_read __gmpz_limbs_read\n__GMP_DECLSPEC mp_srcptr mpz_limbs_read (mpz_srcptr);\n\n#define mpz_limbs_write __gmpz_limbs_write\n__GMP_DECLSPEC mp_ptr mpz_limbs_write (mpz_ptr, mp_size_t);\n\n#define mpz_limbs_modify __gmpz_limbs_modify\n__GMP_DECLSPEC mp_ptr mpz_limbs_modify (mpz_ptr, mp_size_t);\n\n#define mpz_limbs_finish __gmpz_limbs_finish\n__GMP_DECLSPEC void mpz_limbs_finish (mpz_ptr, mp_size_t);\n\n#define mpz_roinit_n __gmpz_roinit_n\n__GMP_DECLSPEC mpz_srcptr mpz_roinit_n (mpz_ptr, mp_srcptr, mp_size_t);\n\n#define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }}\n\n/**************** Rational (i.e. Q) routines.  ****************/\n\n#define mpq_abs __gmpq_abs\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs)\n__GMP_DECLSPEC void mpq_abs (mpq_ptr, mpq_srcptr);\n#endif\n\n#define mpq_add __gmpq_add\n__GMP_DECLSPEC void mpq_add (mpq_ptr, mpq_srcptr, mpq_srcptr);\n\n#define mpq_canonicalize __gmpq_canonicalize\n__GMP_DECLSPEC void mpq_canonicalize (mpq_ptr);\n\n#define mpq_clear __gmpq_clear\n__GMP_DECLSPEC void mpq_clear (mpq_ptr);\n\n#define mpq_clears __gmpq_clears\n__GMP_DECLSPEC void mpq_clears (mpq_ptr, ...);\n\n#define mpq_cmp __gmpq_cmp\n__GMP_DECLSPEC int mpq_cmp (mpq_srcptr, mpq_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define _mpq_cmp_si __gmpq_cmp_si\n__GMP_DECLSPEC int _mpq_cmp_si (mpq_srcptr, long, unsigned long) __GMP_ATTRIBUTE_PURE;\n\n#define _mpq_cmp_ui __gmpq_cmp_ui\n__GMP_DECLSPEC int _mpq_cmp_ui (mpq_srcptr, unsigned long int, unsigned long int) __GMP_ATTRIBUTE_PURE;\n\n#define mpq_cmp_z __gmpq_cmp_z\n__GMP_DECLSPEC int mpq_cmp_z (mpq_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpq_div __gmpq_div\n__GMP_DECLSPEC void mpq_div (mpq_ptr, mpq_srcptr, mpq_srcptr);\n\n#define mpq_div_2exp __gmpq_div_2exp\n__GMP_DECLSPEC void mpq_div_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t);\n\n#define mpq_equal __gmpq_equal\n__GMP_DECLSPEC int mpq_equal (mpq_srcptr, mpq_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpq_get_num __gmpq_get_num\n__GMP_DECLSPEC void mpq_get_num (mpz_ptr, mpq_srcptr);\n\n#define mpq_get_den __gmpq_get_den\n__GMP_DECLSPEC void mpq_get_den (mpz_ptr, mpq_srcptr);\n\n#define mpq_get_d __gmpq_get_d\n__GMP_DECLSPEC double mpq_get_d (mpq_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpq_get_str __gmpq_get_str\n__GMP_DECLSPEC char *mpq_get_str (char *, int, mpq_srcptr);\n\n#define mpq_init __gmpq_init\n__GMP_DECLSPEC void mpq_init (mpq_ptr);\n\n#define mpq_inits __gmpq_inits\n__GMP_DECLSPEC void mpq_inits (mpq_ptr, ...);\n\n#define mpq_inp_str __gmpq_inp_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpq_inp_str (mpq_ptr, FILE *, int);\n#endif\n\n#define mpq_inv __gmpq_inv\n__GMP_DECLSPEC void mpq_inv (mpq_ptr, mpq_srcptr);\n\n#define mpq_mul __gmpq_mul\n__GMP_DECLSPEC void mpq_mul (mpq_ptr, mpq_srcptr, mpq_srcptr);\n\n#define mpq_mul_2exp __gmpq_mul_2exp\n__GMP_DECLSPEC void mpq_mul_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t);\n\n#define mpq_neg __gmpq_neg\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg)\n__GMP_DECLSPEC void mpq_neg (mpq_ptr, mpq_srcptr);\n#endif\n\n#define mpq_out_str __gmpq_out_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpq_out_str (FILE *, int, mpq_srcptr);\n#endif\n\n#define mpq_set __gmpq_set\n__GMP_DECLSPEC void mpq_set (mpq_ptr, mpq_srcptr);\n\n#define mpq_set_d __gmpq_set_d\n__GMP_DECLSPEC void mpq_set_d (mpq_ptr, double);\n\n#define mpq_set_den __gmpq_set_den\n__GMP_DECLSPEC void mpq_set_den (mpq_ptr, mpz_srcptr);\n\n#define mpq_set_f __gmpq_set_f\n__GMP_DECLSPEC void mpq_set_f (mpq_ptr, mpf_srcptr);\n\n#define mpq_set_num __gmpq_set_num\n__GMP_DECLSPEC void mpq_set_num (mpq_ptr, mpz_srcptr);\n\n#define mpq_set_si __gmpq_set_si\n__GMP_DECLSPEC void mpq_set_si (mpq_ptr, signed long int, unsigned long int);\n\n#define mpq_set_str __gmpq_set_str\n__GMP_DECLSPEC int mpq_set_str (mpq_ptr, const char *, int);\n\n#define mpq_set_ui __gmpq_set_ui\n__GMP_DECLSPEC void mpq_set_ui (mpq_ptr, unsigned long int, unsigned long int);\n\n#define mpq_set_z __gmpq_set_z\n__GMP_DECLSPEC void mpq_set_z (mpq_ptr, mpz_srcptr);\n\n#define mpq_sub __gmpq_sub\n__GMP_DECLSPEC void mpq_sub (mpq_ptr, mpq_srcptr, mpq_srcptr);\n\n#define mpq_swap __gmpq_swap\n__GMP_DECLSPEC void mpq_swap (mpq_ptr, mpq_ptr) __GMP_NOTHROW;\n\n\n/**************** Float (i.e. F) routines.  ****************/\n\n#define mpf_abs __gmpf_abs\n__GMP_DECLSPEC void mpf_abs (mpf_ptr, mpf_srcptr);\n\n#define mpf_add __gmpf_add\n__GMP_DECLSPEC void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_add_ui __gmpf_add_ui\n__GMP_DECLSPEC void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n#define mpf_ceil __gmpf_ceil\n__GMP_DECLSPEC void mpf_ceil (mpf_ptr, mpf_srcptr);\n\n#define mpf_clear __gmpf_clear\n__GMP_DECLSPEC void mpf_clear (mpf_ptr);\n\n#define mpf_clears __gmpf_clears\n__GMP_DECLSPEC void mpf_clears (mpf_ptr, ...);\n\n#define mpf_cmp __gmpf_cmp\n__GMP_DECLSPEC int mpf_cmp (mpf_srcptr, mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_cmp_z __gmpf_cmp_z\n__GMP_DECLSPEC int mpf_cmp_z (mpf_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_cmp_d __gmpf_cmp_d\n__GMP_DECLSPEC int mpf_cmp_d (mpf_srcptr, double) __GMP_ATTRIBUTE_PURE;\n\n#define mpf_cmp_si __gmpf_cmp_si\n__GMP_DECLSPEC int mpf_cmp_si (mpf_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_cmp_ui __gmpf_cmp_ui\n__GMP_DECLSPEC int mpf_cmp_ui (mpf_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_div __gmpf_div\n__GMP_DECLSPEC void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_div_2exp __gmpf_div_2exp\n__GMP_DECLSPEC void mpf_div_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t);\n\n#define mpf_div_ui __gmpf_div_ui\n__GMP_DECLSPEC void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n\n#define mpf_dump __gmpf_dump\n__GMP_DECLSPEC void mpf_dump (mpf_srcptr);\n\n#define mpf_eq __gmpf_eq\n__GMP_DECLSPEC int mpf_eq (mpf_srcptr, mpf_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_sint_p __gmpf_fits_sint_p\n__GMP_DECLSPEC int mpf_fits_sint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_slong_p __gmpf_fits_slong_p\n__GMP_DECLSPEC int mpf_fits_slong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_sshort_p __gmpf_fits_sshort_p\n__GMP_DECLSPEC int mpf_fits_sshort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_uint_p __gmpf_fits_uint_p\n__GMP_DECLSPEC int mpf_fits_uint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_ulong_p __gmpf_fits_ulong_p\n__GMP_DECLSPEC int mpf_fits_ulong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_ushort_p __gmpf_fits_ushort_p\n__GMP_DECLSPEC int mpf_fits_ushort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_floor __gmpf_floor\n__GMP_DECLSPEC void mpf_floor (mpf_ptr, mpf_srcptr);\n\n#define mpf_get_d __gmpf_get_d\n__GMP_DECLSPEC double mpf_get_d (mpf_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpf_get_d_2exp __gmpf_get_d_2exp\n__GMP_DECLSPEC double mpf_get_d_2exp (signed long int *, mpf_srcptr);\n\n#define mpf_get_default_prec __gmpf_get_default_prec\n__GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec (void) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_get_prec __gmpf_get_prec\n__GMP_DECLSPEC mp_bitcnt_t mpf_get_prec (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_get_si __gmpf_get_si\n__GMP_DECLSPEC long mpf_get_si (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_get_str __gmpf_get_str\n__GMP_DECLSPEC char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr);\n\n#define mpf_get_ui __gmpf_get_ui\n__GMP_DECLSPEC unsigned long mpf_get_ui (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_init __gmpf_init\n__GMP_DECLSPEC void mpf_init (mpf_ptr);\n\n#define mpf_init2 __gmpf_init2\n__GMP_DECLSPEC void mpf_init2 (mpf_ptr, mp_bitcnt_t);\n\n#define mpf_inits __gmpf_inits\n__GMP_DECLSPEC void mpf_inits (mpf_ptr, ...);\n\n#define mpf_init_set __gmpf_init_set\n__GMP_DECLSPEC void mpf_init_set (mpf_ptr, mpf_srcptr);\n\n#define mpf_init_set_d __gmpf_init_set_d\n__GMP_DECLSPEC void mpf_init_set_d (mpf_ptr, double);\n\n#define mpf_init_set_si __gmpf_init_set_si\n__GMP_DECLSPEC void mpf_init_set_si (mpf_ptr, signed long int);\n\n#define mpf_init_set_str __gmpf_init_set_str\n__GMP_DECLSPEC int mpf_init_set_str (mpf_ptr, const char *, int);\n\n#define mpf_init_set_ui __gmpf_init_set_ui\n__GMP_DECLSPEC void mpf_init_set_ui (mpf_ptr, unsigned long int);\n\n#define mpf_inp_str __gmpf_inp_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpf_inp_str (mpf_ptr, FILE *, int);\n#endif\n\n#define mpf_integer_p __gmpf_integer_p\n__GMP_DECLSPEC int mpf_integer_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_mul __gmpf_mul\n__GMP_DECLSPEC void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_mul_2exp __gmpf_mul_2exp\n__GMP_DECLSPEC void mpf_mul_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t);\n\n#define mpf_mul_ui __gmpf_mul_ui\n__GMP_DECLSPEC void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n\n#define mpf_neg __gmpf_neg\n__GMP_DECLSPEC void mpf_neg (mpf_ptr, mpf_srcptr);\n\n#define mpf_out_str __gmpf_out_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpf_out_str (FILE *, int, size_t, mpf_srcptr);\n#endif\n\n#define mpf_pow_ui __gmpf_pow_ui\n__GMP_DECLSPEC void mpf_pow_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n\n#define mpf_random2 __gmpf_random2\n__GMP_DECLSPEC void mpf_random2 (mpf_ptr, mp_size_t, mp_exp_t);\n\n#define mpf_reldiff __gmpf_reldiff\n__GMP_DECLSPEC void mpf_reldiff (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_set __gmpf_set\n__GMP_DECLSPEC void mpf_set (mpf_ptr, mpf_srcptr);\n\n#define mpf_set_d __gmpf_set_d\n__GMP_DECLSPEC void mpf_set_d (mpf_ptr, double);\n\n#define mpf_set_default_prec __gmpf_set_default_prec\n__GMP_DECLSPEC void mpf_set_default_prec (mp_bitcnt_t) __GMP_NOTHROW;\n\n#define mpf_set_prec __gmpf_set_prec\n__GMP_DECLSPEC void mpf_set_prec (mpf_ptr, mp_bitcnt_t);\n\n#define mpf_set_prec_raw __gmpf_set_prec_raw\n__GMP_DECLSPEC void mpf_set_prec_raw (mpf_ptr, mp_bitcnt_t) __GMP_NOTHROW;\n\n#define mpf_set_q __gmpf_set_q\n__GMP_DECLSPEC void mpf_set_q (mpf_ptr, mpq_srcptr);\n\n#define mpf_set_si __gmpf_set_si\n__GMP_DECLSPEC void mpf_set_si (mpf_ptr, signed long int);\n\n#define mpf_set_str __gmpf_set_str\n__GMP_DECLSPEC int mpf_set_str (mpf_ptr, const char *, int);\n\n#define mpf_set_ui __gmpf_set_ui\n__GMP_DECLSPEC void mpf_set_ui (mpf_ptr, unsigned long int);\n\n#define mpf_set_z __gmpf_set_z\n__GMP_DECLSPEC void mpf_set_z (mpf_ptr, mpz_srcptr);\n\n#define mpf_size __gmpf_size\n__GMP_DECLSPEC size_t mpf_size (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_sqrt __gmpf_sqrt\n__GMP_DECLSPEC void mpf_sqrt (mpf_ptr, mpf_srcptr);\n\n#define mpf_sqrt_ui __gmpf_sqrt_ui\n__GMP_DECLSPEC void mpf_sqrt_ui (mpf_ptr, unsigned long int);\n\n#define mpf_sub __gmpf_sub\n__GMP_DECLSPEC void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_sub_ui __gmpf_sub_ui\n__GMP_DECLSPEC void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n\n#define mpf_swap __gmpf_swap\n__GMP_DECLSPEC void mpf_swap (mpf_ptr, mpf_ptr) __GMP_NOTHROW;\n\n#define mpf_trunc __gmpf_trunc\n__GMP_DECLSPEC void mpf_trunc (mpf_ptr, mpf_srcptr);\n\n#define mpf_ui_div __gmpf_ui_div\n__GMP_DECLSPEC void mpf_ui_div (mpf_ptr, unsigned long int, mpf_srcptr);\n\n#define mpf_ui_sub __gmpf_ui_sub\n__GMP_DECLSPEC void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr);\n\n#define mpf_urandomb __gmpf_urandomb\n__GMP_DECLSPEC void mpf_urandomb (mpf_ptr, gmp_randstate_ptr, mp_bitcnt_t);\n\n\n/************ Low level positive-integer (i.e. N) routines.  ************/\n\n/* This is ugly, but we need to make user calls reach the prefixed function. */\n\n#define mpn_add __MPN(add)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add)\n__GMP_DECLSPEC mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);\n#endif\n\n#define mpn_add_1 __MPN(add_1)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1)\n__GMP_DECLSPEC mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW;\n#endif\n\n#define mpn_add_n __MPN(add_n)\n__GMP_DECLSPEC mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_addmul_1 __MPN(addmul_1)\n__GMP_DECLSPEC mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_cmp __MPN(cmp)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp)\n__GMP_DECLSPEC int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpn_zero_p __MPN(zero_p)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_zero_p)\n__GMP_DECLSPEC int mpn_zero_p (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpn_divexact_1 __MPN(divexact_1)\n__GMP_DECLSPEC void mpn_divexact_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_divexact_by3(dst,src,size) \\\n  mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0))\n\n#define mpn_divexact_by3c __MPN(divexact_by3c)\n__GMP_DECLSPEC mp_limb_t mpn_divexact_by3c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_divmod_1(qp,np,nsize,dlimb) \\\n  mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb)\n\n#define mpn_divrem __MPN(divrem)\n__GMP_DECLSPEC mp_limb_t mpn_divrem (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t);\n\n#define mpn_divrem_1 __MPN(divrem_1)\n__GMP_DECLSPEC mp_limb_t mpn_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_divrem_2 __MPN(divrem_2)\n__GMP_DECLSPEC mp_limb_t mpn_divrem_2 (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr);\n\n#define mpn_div_qr_1 __MPN(div_qr_1)\n__GMP_DECLSPEC mp_limb_t mpn_div_qr_1 (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_div_qr_2 __MPN(div_qr_2)\n__GMP_DECLSPEC mp_limb_t mpn_div_qr_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);\n\n#define mpn_gcd __MPN(gcd)\n__GMP_DECLSPEC mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t);\n\n#define mpn_gcd_11 __MPN(gcd_11)\n__GMP_DECLSPEC mp_limb_t mpn_gcd_11 (mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_gcd_1 __MPN(gcd_1)\n__GMP_DECLSPEC mp_limb_t mpn_gcd_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_gcdext_1 __MPN(gcdext_1)\n__GMP_DECLSPEC mp_limb_t mpn_gcdext_1 (mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t);\n\n#define mpn_gcdext __MPN(gcdext)\n__GMP_DECLSPEC mp_size_t mpn_gcdext (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t);\n\n#define mpn_get_str __MPN(get_str)\n__GMP_DECLSPEC size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t);\n\n#define mpn_hamdist __MPN(hamdist)\n__GMP_DECLSPEC mp_bitcnt_t mpn_hamdist (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpn_lshift __MPN(lshift)\n__GMP_DECLSPEC mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);\n\n#define mpn_mod_1 __MPN(mod_1)\n__GMP_DECLSPEC mp_limb_t mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_mul __MPN(mul)\n__GMP_DECLSPEC mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);\n\n#define mpn_mul_1 __MPN(mul_1)\n__GMP_DECLSPEC mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_mul_n __MPN(mul_n)\n__GMP_DECLSPEC void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_sqr __MPN(sqr)\n__GMP_DECLSPEC void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t);\n\n#define mpn_neg __MPN(neg)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_neg)\n__GMP_DECLSPEC mp_limb_t mpn_neg (mp_ptr, mp_srcptr, mp_size_t);\n#endif\n\n#define mpn_com __MPN(com)\n__GMP_DECLSPEC void mpn_com (mp_ptr, mp_srcptr, mp_size_t);\n\n#define mpn_perfect_square_p __MPN(perfect_square_p)\n__GMP_DECLSPEC int mpn_perfect_square_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_perfect_power_p __MPN(perfect_power_p)\n__GMP_DECLSPEC int mpn_perfect_power_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_popcount __MPN(popcount)\n__GMP_DECLSPEC mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpn_pow_1 __MPN(pow_1)\n__GMP_DECLSPEC mp_size_t mpn_pow_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);\n\n/* undocumented now, but retained here for upward compatibility */\n#define mpn_preinv_mod_1 __MPN(preinv_mod_1)\n__GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_random __MPN(random)\n__GMP_DECLSPEC void mpn_random (mp_ptr, mp_size_t);\n\n#define mpn_random2 __MPN(random2)\n__GMP_DECLSPEC void mpn_random2 (mp_ptr, mp_size_t);\n\n#define mpn_rshift __MPN(rshift)\n__GMP_DECLSPEC mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);\n\n#define mpn_scan0 __MPN(scan0)\n__GMP_DECLSPEC mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_scan1 __MPN(scan1)\n__GMP_DECLSPEC mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_set_str __MPN(set_str)\n__GMP_DECLSPEC mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int);\n\n#define mpn_sizeinbase __MPN(sizeinbase)\n__GMP_DECLSPEC size_t mpn_sizeinbase (mp_srcptr, mp_size_t, int);\n\n#define mpn_sqrtrem __MPN(sqrtrem)\n__GMP_DECLSPEC mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t);\n\n#define mpn_sub __MPN(sub)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub)\n__GMP_DECLSPEC mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);\n#endif\n\n#define mpn_sub_1 __MPN(sub_1)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1)\n__GMP_DECLSPEC mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW;\n#endif\n\n#define mpn_sub_n __MPN(sub_n)\n__GMP_DECLSPEC mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_submul_1 __MPN(submul_1)\n__GMP_DECLSPEC mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_tdiv_qr __MPN(tdiv_qr)\n__GMP_DECLSPEC void mpn_tdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);\n\n#define mpn_and_n __MPN(and_n)\n__GMP_DECLSPEC void mpn_and_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_andn_n __MPN(andn_n)\n__GMP_DECLSPEC void mpn_andn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_nand_n __MPN(nand_n)\n__GMP_DECLSPEC void mpn_nand_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_ior_n __MPN(ior_n)\n__GMP_DECLSPEC void mpn_ior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_iorn_n __MPN(iorn_n)\n__GMP_DECLSPEC void mpn_iorn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_nior_n __MPN(nior_n)\n__GMP_DECLSPEC void mpn_nior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_xor_n __MPN(xor_n)\n__GMP_DECLSPEC void mpn_xor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_xnor_n __MPN(xnor_n)\n__GMP_DECLSPEC void mpn_xnor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_copyi __MPN(copyi)\n__GMP_DECLSPEC void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t);\n#define mpn_copyd __MPN(copyd)\n__GMP_DECLSPEC void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t);\n#define mpn_zero __MPN(zero)\n__GMP_DECLSPEC void mpn_zero (mp_ptr, mp_size_t);\n\n#define mpn_cnd_add_n __MPN(cnd_add_n)\n__GMP_DECLSPEC mp_limb_t mpn_cnd_add_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_cnd_sub_n __MPN(cnd_sub_n)\n__GMP_DECLSPEC mp_limb_t mpn_cnd_sub_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_sec_add_1 __MPN(sec_add_1)\n__GMP_DECLSPEC mp_limb_t mpn_sec_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);\n#define mpn_sec_add_1_itch __MPN(sec_add_1_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_add_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_sub_1 __MPN(sec_sub_1)\n__GMP_DECLSPEC mp_limb_t mpn_sec_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);\n#define mpn_sec_sub_1_itch __MPN(sec_sub_1_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_sub_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_cnd_swap  __MPN(cnd_swap)\n__GMP_DECLSPEC void mpn_cnd_swap (mp_limb_t, volatile mp_limb_t *, volatile mp_limb_t *, mp_size_t);\n\n#define mpn_sec_mul __MPN(sec_mul)\n__GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_mul_itch __MPN(sec_mul_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_sqr __MPN(sec_sqr)\n__GMP_DECLSPEC void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_sqr_itch __MPN(sec_sqr_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_powm __MPN(sec_powm)\n__GMP_DECLSPEC void mpn_sec_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_bitcnt_t, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_powm_itch __MPN(sec_powm_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_bitcnt_t, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_tabselect __MPN(sec_tabselect)\n__GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t);\n\n#define mpn_sec_div_qr __MPN(sec_div_qr)\n__GMP_DECLSPEC mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_div_qr_itch __MPN(sec_div_qr_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;\n#define mpn_sec_div_r __MPN(sec_div_r)\n__GMP_DECLSPEC void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_div_r_itch __MPN(sec_div_r_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_invert __MPN(sec_invert)\n__GMP_DECLSPEC int mpn_sec_invert (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_bitcnt_t, mp_ptr);\n#define mpn_sec_invert_itch __MPN(sec_invert_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_invert_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n\n/**************** mpz inlines ****************/\n\n/* The following are provided as inlines where possible, but always exist as\n   library functions too, for binary compatibility.\n\n   Within gmp itself this inlining generally isn't relied on, since it\n   doesn't get done for all compilers, whereas if something is worth\n   inlining then it's worth arranging always.\n\n   There are two styles of inlining here.  When the same bit of code is\n   wanted for the inline as for the library version, then __GMP_FORCE_foo\n   arranges for that code to be emitted and the __GMP_EXTERN_INLINE\n   directive suppressed, eg. mpz_fits_uint_p.  When a different bit of code\n   is wanted for the inline than for the library version, then\n   __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs.  */\n\n#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)\n__GMP_EXTERN_INLINE void\nmpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)\n{\n  if (__gmp_w != __gmp_u)\n    mpz_set (__gmp_w, __gmp_u);\n  __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);\n}\n#endif\n\n#if GMP_NAIL_BITS == 0\n#define __GMPZ_FITS_UTYPE_P(z,maxval)\t\t\t\t\t\\\n  mp_size_t  __gmp_n = z->_mp_size;\t\t\t\t\t\\\n  mp_ptr  __gmp_p = z->_mp_d;\t\t\t\t\t\t\\\n  return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval));\n#else\n#define __GMPZ_FITS_UTYPE_P(z,maxval)\t\t\t\t\t\\\n  mp_size_t  __gmp_n = z->_mp_size;\t\t\t\t\t\\\n  mp_ptr  __gmp_p = z->_mp_d;\t\t\t\t\t\t\\\n  return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval)\t\\\n\t  || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS)));\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p)\n#if ! defined (__GMP_FORCE_mpz_fits_uint_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  __GMPZ_FITS_UTYPE_P (__gmp_z, UINT_MAX);\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p)\n#if ! defined (__GMP_FORCE_mpz_fits_ulong_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  __GMPZ_FITS_UTYPE_P (__gmp_z, ULONG_MAX);\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p)\n#if ! defined (__GMP_FORCE_mpz_fits_ushort_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  __GMPZ_FITS_UTYPE_P (__gmp_z, USHRT_MAX);\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)\n#if ! defined (__GMP_FORCE_mpz_get_ui)\n__GMP_EXTERN_INLINE\n#endif\nunsigned long\nmpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  mp_ptr __gmp_p = __gmp_z->_mp_d;\n  mp_size_t __gmp_n = __gmp_z->_mp_size;\n  mp_limb_t __gmp_l = __gmp_p[0];\n  /* This is a \"#if\" rather than a plain \"if\" so as to avoid gcc warnings\n     about \"<< GMP_NUMB_BITS\" exceeding the type size, and to avoid Borland\n     C++ 6.0 warnings about condition always true for something like\n     \"ULONG_MAX < GMP_NUMB_MASK\".  */\n#if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB)\n  /* limb==long and no nails, or limb==longlong, one limb is enough */\n  return (__gmp_n != 0 ? __gmp_l : 0);\n#else\n  /* limb==long and nails, need two limbs when available */\n  __gmp_n = __GMP_ABS (__gmp_n);\n  if (__gmp_n <= 1)\n    return (__gmp_n != 0 ? __gmp_l : 0);\n  else\n    return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);\n#endif\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn)\n#if ! defined (__GMP_FORCE_mpz_getlimbn)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW\n{\n  mp_limb_t  __gmp_result = 0;\n  if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size)))\n    __gmp_result = __gmp_z->_mp_d[__gmp_n];\n  return __gmp_result;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg)\n__GMP_EXTERN_INLINE void\nmpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)\n{\n  if (__gmp_w != __gmp_u)\n    mpz_set (__gmp_w, __gmp_u);\n  __gmp_w->_mp_size = - __gmp_w->_mp_size;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p)\n#if ! defined (__GMP_FORCE_mpz_perfect_square_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpz_perfect_square_p (mpz_srcptr __gmp_a)\n{\n  mp_size_t __gmp_asize;\n  int       __gmp_result;\n\n  __gmp_asize = __gmp_a->_mp_size;\n  __gmp_result = (__gmp_asize >= 0);  /* zero is a square, negatives are not */\n  if (__GMP_LIKELY (__gmp_asize > 0))\n    __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize);\n  return __gmp_result;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount)\n#if ! defined (__GMP_FORCE_mpz_popcount)\n__GMP_EXTERN_INLINE\n#endif\nmp_bitcnt_t\nmpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW\n{\n  mp_size_t      __gmp_usize;\n  mp_bitcnt_t    __gmp_result;\n\n  __gmp_usize = __gmp_u->_mp_size;\n  __gmp_result = (__gmp_usize < 0 ? ~ __GMP_CAST (mp_bitcnt_t, 0) : __GMP_CAST (mp_bitcnt_t, 0));\n  if (__GMP_LIKELY (__gmp_usize > 0))\n    __gmp_result =  mpn_popcount (__gmp_u->_mp_d, __gmp_usize);\n  return __gmp_result;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q)\n#if ! defined (__GMP_FORCE_mpz_set_q)\n__GMP_EXTERN_INLINE\n#endif\nvoid\nmpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u)\n{\n  mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u));\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)\n#if ! defined (__GMP_FORCE_mpz_size)\n__GMP_EXTERN_INLINE\n#endif\nsize_t\nmpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  return __GMP_ABS (__gmp_z->_mp_size);\n}\n#endif\n\n\n/**************** mpq inlines ****************/\n\n#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs)\n__GMP_EXTERN_INLINE void\nmpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)\n{\n  if (__gmp_w != __gmp_u)\n    mpq_set (__gmp_w, __gmp_u);\n  __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size);\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg)\n__GMP_EXTERN_INLINE void\nmpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)\n{\n  if (__gmp_w != __gmp_u)\n    mpq_set (__gmp_w, __gmp_u);\n  __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size;\n}\n#endif\n\n\n/**************** mpn inlines ****************/\n\n/* The comments with __GMPN_ADD_1 below apply here too.\n\n   The test for FUNCTION returning 0 should predict well.  If it's assumed\n   {yp,ysize} will usually have a random number of bits then the high limb\n   won't be full and a carry out will occur a good deal less than 50% of the\n   time.\n\n   ysize==0 isn't a documented feature, but is used internally in a few\n   places.\n\n   Producing cout last stops it using up a register during the main part of\n   the calculation, though gcc (as of 3.0) on an \"if (mpn_add (...))\"\n   doesn't seem able to move the true and false legs of the conditional up\n   to the two places cout is generated.  */\n\n#define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST)     \\\n  do {                                                                  \\\n    mp_size_t  __gmp_i;                                                 \\\n    mp_limb_t  __gmp_x;                                                 \\\n                                                                        \\\n    /* ASSERT ((ysize) >= 0); */                                        \\\n    /* ASSERT ((xsize) >= (ysize)); */                                  \\\n    /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */      \\\n    /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */      \\\n                                                                        \\\n    __gmp_i = (ysize);                                                  \\\n    if (__gmp_i != 0)                                                   \\\n      {                                                                 \\\n        if (FUNCTION (wp, xp, yp, __gmp_i))                             \\\n          {                                                             \\\n            do                                                          \\\n              {                                                         \\\n                if (__gmp_i >= (xsize))                                 \\\n                  {                                                     \\\n                    (cout) = 1;                                         \\\n                    goto __gmp_done;                                    \\\n                  }                                                     \\\n                __gmp_x = (xp)[__gmp_i];                                \\\n              }                                                         \\\n            while (TEST);                                               \\\n          }                                                             \\\n      }                                                                 \\\n    if ((wp) != (xp))                                                   \\\n      __GMPN_COPY_REST (wp, xp, xsize, __gmp_i);                        \\\n    (cout) = 0;                                                         \\\n  __gmp_done:                                                           \\\n    ;                                                                   \\\n  } while (0)\n\n#define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize)              \\\n  __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n,       \\\n               (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0))\n#define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize)              \\\n  __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n,       \\\n               (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0))\n\n\n/* The use of __gmp_i indexing is designed to ensure a compile time src==dst\n   remains nice and clear to the compiler, so that __GMPN_COPY_REST can\n   disappear, and the load/add/store gets a chance to become a\n   read-modify-write on CISC CPUs.\n\n   Alternatives:\n\n   Using a pair of pointers instead of indexing would be possible, but gcc\n   isn't able to recognise compile-time src==dst in that case, even when the\n   pointers are incremented more or less together.  Other compilers would\n   very likely have similar difficulty.\n\n   gcc could use \"if (__builtin_constant_p(src==dst) && src==dst)\" or\n   similar to detect a compile-time src==dst.  This works nicely on gcc\n   2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems\n   to be always false, for a pointer p.  But the current code form seems\n   good enough for src==dst anyway.\n\n   gcc on x86 as usual doesn't give particularly good flags handling for the\n   carry/borrow detection.  It's tempting to want some multi instruction asm\n   blocks to help it, and this was tried, but in truth there's only a few\n   instructions to save and any gain is all too easily lost by register\n   juggling setting up for the asm.  */\n\n#if GMP_NAIL_BITS == 0\n#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB)\t\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    mp_size_t  __gmp_i;\t\t\t\t\t\t\\\n    mp_limb_t  __gmp_x, __gmp_r;                                \\\n\t\t\t\t\t\t\t\t\\\n    /* ASSERT ((n) >= 1); */\t\t\t\t\t\\\n    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */\t\\\n\t\t\t\t\t\t\t\t\\\n    __gmp_x = (src)[0];\t\t\t\t\t\t\\\n    __gmp_r = __gmp_x OP (v);                                   \\\n    (dst)[0] = __gmp_r;\t\t\t\t\t\t\\\n    if (CB (__gmp_r, __gmp_x, (v)))                             \\\n      {\t\t\t\t\t\t\t\t\\\n\t(cout) = 1;\t\t\t\t\t\t\\\n\tfor (__gmp_i = 1; __gmp_i < (n);)                       \\\n\t  {\t\t\t\t\t\t\t\\\n\t    __gmp_x = (src)[__gmp_i];                           \\\n\t    __gmp_r = __gmp_x OP 1;                             \\\n\t    (dst)[__gmp_i] = __gmp_r;                           \\\n\t    ++__gmp_i;\t\t\t\t\t\t\\\n\t    if (!CB (__gmp_r, __gmp_x, 1))                      \\\n\t      {\t\t\t\t\t\t\t\\\n\t\tif ((src) != (dst))\t\t\t\t\\\n\t\t  __GMPN_COPY_REST (dst, src, n, __gmp_i);      \\\n\t\t(cout) = 0;\t\t\t\t\t\\\n\t\tbreak;\t\t\t\t\t\t\\\n\t      }\t\t\t\t\t\t\t\\\n\t  }\t\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\\\n    else\t\t\t\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\\\n\tif ((src) != (dst))\t\t\t\t\t\\\n\t  __GMPN_COPY_REST (dst, src, n, 1);\t\t\t\\\n\t(cout) = 0;\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\\\n  } while (0)\n#endif\n\n#if GMP_NAIL_BITS >= 1\n#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB)\t\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    mp_size_t  __gmp_i;\t\t\t\t\t\t\\\n    mp_limb_t  __gmp_x, __gmp_r;\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n    /* ASSERT ((n) >= 1); */\t\t\t\t\t\\\n    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */\t\\\n\t\t\t\t\t\t\t\t\\\n    __gmp_x = (src)[0];\t\t\t\t\t\t\\\n    __gmp_r = __gmp_x OP (v);\t\t\t\t\t\\\n    (dst)[0] = __gmp_r & GMP_NUMB_MASK;\t\t\t\t\\\n    if (__gmp_r >> GMP_NUMB_BITS != 0)\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\\\n\t(cout) = 1;\t\t\t\t\t\t\\\n\tfor (__gmp_i = 1; __gmp_i < (n);)\t\t\t\\\n\t  {\t\t\t\t\t\t\t\\\n\t    __gmp_x = (src)[__gmp_i];\t\t\t\t\\\n\t    __gmp_r = __gmp_x OP 1;\t\t\t\t\\\n\t    (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK;\t\t\\\n\t    ++__gmp_i;\t\t\t\t\t\t\\\n\t    if (__gmp_r >> GMP_NUMB_BITS == 0)\t\t\t\\\n\t      {\t\t\t\t\t\t\t\\\n\t\tif ((src) != (dst))\t\t\t\t\\\n\t\t  __GMPN_COPY_REST (dst, src, n, __gmp_i);\t\\\n\t\t(cout) = 0;\t\t\t\t\t\\\n\t\tbreak;\t\t\t\t\t\t\\\n\t      }\t\t\t\t\t\t\t\\\n\t  }\t\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\\\n    else\t\t\t\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\\\n\tif ((src) != (dst))\t\t\t\t\t\\\n\t  __GMPN_COPY_REST (dst, src, n, 1);\t\t\t\\\n\t(cout) = 0;\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\\\n  } while (0)\n#endif\n\n#define __GMPN_ADDCB(r,x,y) ((r) < (y))\n#define __GMPN_SUBCB(r,x,y) ((x) < (y))\n\n#define __GMPN_ADD_1(cout, dst, src, n, v)\t     \\\n  __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB)\n#define __GMPN_SUB_1(cout, dst, src, n, v)\t     \\\n  __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB)\n\n\n/* Compare {xp,size} and {yp,size}, setting \"result\" to positive, zero or\n   negative.  size==0 is allowed.  On random data usually only one limb will\n   need to be examined to get a result, so it's worth having it inline.  */\n#define __GMPN_CMP(result, xp, yp, size)                                \\\n  do {                                                                  \\\n    mp_size_t  __gmp_i;                                                 \\\n    mp_limb_t  __gmp_x, __gmp_y;                                        \\\n                                                                        \\\n    /* ASSERT ((size) >= 0); */                                         \\\n                                                                        \\\n    (result) = 0;                                                       \\\n    __gmp_i = (size);                                                   \\\n    while (--__gmp_i >= 0)                                              \\\n      {                                                                 \\\n        __gmp_x = (xp)[__gmp_i];                                        \\\n        __gmp_y = (yp)[__gmp_i];                                        \\\n        if (__gmp_x != __gmp_y)                                         \\\n          {                                                             \\\n            /* Cannot use __gmp_x - __gmp_y, may overflow an \"int\" */   \\\n            (result) = (__gmp_x > __gmp_y ? 1 : -1);                    \\\n            break;                                                      \\\n          }                                                             \\\n      }                                                                 \\\n  } while (0)\n\n\n#if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST)\n#define __GMPN_COPY_REST(dst, src, size, start)                 \\\n  do {                                                          \\\n    /* ASSERT ((start) >= 0); */                                \\\n    /* ASSERT ((start) <= (size)); */                           \\\n    __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \\\n  } while (0)\n#endif\n\n/* Copy {src,size} to {dst,size}, starting at \"start\".  This is designed to\n   keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1,\n   __GMPN_ADD, etc.  */\n#if ! defined (__GMPN_COPY_REST)\n#define __GMPN_COPY_REST(dst, src, size, start)                 \\\n  do {                                                          \\\n    mp_size_t __gmp_j;                                          \\\n    /* ASSERT ((size) >= 0); */                                 \\\n    /* ASSERT ((start) >= 0); */                                \\\n    /* ASSERT ((start) <= (size)); */                           \\\n    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */     \\\n    __GMP_CRAY_Pragma (\"_CRI ivdep\");                           \\\n    for (__gmp_j = (start); __gmp_j < (size); __gmp_j++)        \\\n      (dst)[__gmp_j] = (src)[__gmp_j];                          \\\n  } while (0)\n#endif\n\n/* Enhancement: Use some of the smarter code from gmp-impl.h.  Maybe use\n   mpn_copyi if there's a native version, and if we don't mind demanding\n   binary compatibility for it (on targets which use it).  */\n\n#if ! defined (__GMPN_COPY)\n#define __GMPN_COPY(dst, src, size)   __GMPN_COPY_REST (dst, src, size, 0)\n#endif\n\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add)\n#if ! defined (__GMP_FORCE_mpn_add)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)\n{\n  mp_limb_t  __gmp_c;\n  __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);\n  return __gmp_c;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1)\n#if ! defined (__GMP_FORCE_mpn_add_1)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW\n{\n  mp_limb_t  __gmp_c;\n  __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);\n  return __gmp_c;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp)\n#if ! defined (__GMP_FORCE_mpn_cmp)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW\n{\n  int __gmp_result;\n  __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size);\n  return __gmp_result;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_zero_p)\n#if ! defined (__GMP_FORCE_mpn_zero_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpn_zero_p (mp_srcptr __gmp_p, mp_size_t __gmp_n) __GMP_NOTHROW\n{\n  /* if (__GMP_LIKELY (__gmp_n > 0)) */\n    do {\n      if (__gmp_p[--__gmp_n] != 0)\n\treturn 0;\n    } while (__gmp_n != 0);\n  return 1;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)\n#if ! defined (__GMP_FORCE_mpn_sub)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)\n{\n  mp_limb_t  __gmp_c;\n  __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);\n  return __gmp_c;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1)\n#if ! defined (__GMP_FORCE_mpn_sub_1)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW\n{\n  mp_limb_t  __gmp_c;\n  __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);\n  return __gmp_c;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_neg)\n#if ! defined (__GMP_FORCE_mpn_neg)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n)\n{\n  while (*__gmp_up == 0) /* Low zero limbs are unchanged by negation. */\n    {\n      *__gmp_rp = 0;\n      if (!--__gmp_n) /* All zero */\n\treturn 0;\n      ++__gmp_up; ++__gmp_rp;\n    }\n\n  *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK;\n\n  if (--__gmp_n) /* Higher limbs get complemented. */\n    mpn_com (++__gmp_rp, ++__gmp_up, __gmp_n);\n\n  return 1;\n}\n#endif\n\n#if defined (__cplusplus)\n}\n#endif\n\n\n/* Allow faster testing for negative, zero, and positive.  */\n#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)\n#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)\n#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)\n\n/* When using GCC, optimize certain common comparisons.  */\n#if defined (__GNUC__) && __GNUC__ >= 2\n#define mpz_cmp_ui(Z,UI) \\\n  (__builtin_constant_p (UI) && (UI) == 0\t\t\t\t\\\n   ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))\n#define mpz_cmp_si(Z,SI)\t\t\t\t\t\t\\\n  (__builtin_constant_p ((SI) >= 0) && (SI) >= 0\t\t\t\\\n   ? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI))\t\t\t\\\n   : _mpz_cmp_si (Z,SI))\n#define mpq_cmp_ui(Q,NUI,DUI)\t\t\t\t\t\\\n  (__builtin_constant_p (NUI) && (NUI) == 0 ? mpq_sgn (Q)\t\\\n   : __builtin_constant_p ((NUI) == (DUI)) && (NUI) == (DUI)\t\\\n   ? mpz_cmp (mpq_numref (Q), mpq_denref (Q))\t\t\t\\\n   : _mpq_cmp_ui (Q,NUI,DUI))\n#define mpq_cmp_si(q,n,d)\t\t\t\t\\\n  (__builtin_constant_p ((n) >= 0) && (n) >= 0\t\t\\\n   ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d)\t\\\n   : _mpq_cmp_si (q, n, d))\n#else\n#define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)\n#define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)\n#define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)\n#define mpq_cmp_si(q,n,d)  _mpq_cmp_si(q,n,d)\n#endif\n\n\n/* Using \"&\" rather than \"&&\" means these can come out branch-free.  Every\n   mpz_t has at least one limb allocated, so fetching the low limb is always\n   allowed.  */\n#define mpz_odd_p(z)   (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0]))\n#define mpz_even_p(z)  (! mpz_odd_p (z))\n\n\n/**************** C++ routines ****************/\n\n#ifdef __cplusplus\n__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr);\n__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr);\n__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr);\n__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr);\n__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr);\n__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr);\n#endif\n\n\n/* Source-level compatibility with GMP 2 and earlier. */\n#define mpn_divmod(qp,np,nsize,dp,dsize) \\\n  mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize)\n\n/* Source-level compatibility with GMP 1.  */\n#define mpz_mdiv\tmpz_fdiv_q\n#define mpz_mdivmod\tmpz_fdiv_qr\n#define mpz_mmod\tmpz_fdiv_r\n#define mpz_mdiv_ui\tmpz_fdiv_q_ui\n#define mpz_mdivmod_ui(q,r,n,d) \\\n  (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))\n#define mpz_mmod_ui(r,n,d) \\\n  (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))\n\n/* Useful synonyms, but not quite compatible with GMP 1.  */\n#define mpz_div\t\tmpz_fdiv_q\n#define mpz_divmod\tmpz_fdiv_qr\n#define mpz_div_ui\tmpz_fdiv_q_ui\n#define mpz_divmod_ui\tmpz_fdiv_qr_ui\n#define mpz_div_2exp\tmpz_fdiv_q_2exp\n#define mpz_mod_2exp\tmpz_fdiv_r_2exp\n\nenum\n{\n  GMP_ERROR_NONE = 0,\n  GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,\n  GMP_ERROR_DIVISION_BY_ZERO = 2,\n  GMP_ERROR_SQRT_OF_NEGATIVE = 4,\n  GMP_ERROR_INVALID_ARGUMENT = 8,\n  GMP_ERROR_MPZ_OVERFLOW = 16\n};\n\n/* Define CC and CFLAGS which were used to build this version of GMP */\n#define __GMP_CC \"gcc\"\n#define __GMP_CFLAGS \"-m32 -O2 -pedantic -fomit-frame-pointer -mtune=pentiumpro -march=pentiumpro\"\n\n/* Major version number is the value of __GNU_MP__ too, above. */\n#define __GNU_MP_VERSION            6\n#define __GNU_MP_VERSION_MINOR      3\n#define __GNU_MP_VERSION_PATCHLEVEL 0\n#define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL)\n\n#define __GMP_H__\n#endif /* __GMP_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/abstract.h",
    "content": "/*\n * Copyright (C) 2010-2012 Free Software Foundation, Inc.\n * Copyright (C) 2015-2017 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_ABSTRACT_H\n#define GNUTLS_ABSTRACT_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n#include <gnutls/pkcs11.h>\n#include <gnutls/openpgp.h>\n#include <gnutls/tpm.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/* Public key operations */\n\n#define GNUTLS_PUBKEY_VERIFY_FLAG_TLS_RSA GNUTLS_PUBKEY_VERIFY_FLAG_TLS1_RSA\n/**\n * gnutls_pubkey_flags:\n * @GNUTLS_PUBKEY_DISABLE_CALLBACKS: The following flag disables call to PIN callbacks. Only\n *   relevant to TPM keys.\n * @GNUTLS_PUBKEY_GET_OPENPGP_FINGERPRINT: request an OPENPGP fingerprint instead of the default.\n *\n * Enumeration of different certificate import flags.\n */\ntypedef enum gnutls_pubkey_flags {\n\tGNUTLS_PUBKEY_DISABLE_CALLBACKS = 1 << 2,\n\tGNUTLS_PUBKEY_GET_OPENPGP_FINGERPRINT = 1 << 3\n} gnutls_pubkey_flags_t;\n\n/**\n * gnutls_abstract_export_flags:\n * @GNUTLS_EXPORT_FLAG_NO_LZ: do not prepend a leading zero to exported values\n *\n * Enumeration of different certificate import flags.\n */\ntypedef enum gnutls_abstract_export_flags {\n\tGNUTLS_EXPORT_FLAG_NO_LZ = 1\n} gnutls_abstract_export_flags_t;\n\n#define GNUTLS_PUBKEY_VERIFY_FLAG_TLS1_RSA GNUTLS_VERIFY_USE_TLS1_RSA\n\ntypedef int (*gnutls_privkey_sign_func) (gnutls_privkey_t key,\n\t\t\t\t\t void *userdata,\n\t\t\t\t\t const gnutls_datum_t *raw_data,\n\t\t\t\t\t gnutls_datum_t * signature);\n\n\ntypedef int (*gnutls_privkey_decrypt_func) (gnutls_privkey_t key,\n\t\t\t\t\t    void *userdata,\n\t\t\t\t\t    const gnutls_datum_t *ciphertext,\n\t\t\t\t\t    gnutls_datum_t * plaintext);\n\ntypedef int (*gnutls_privkey_decrypt_func2) (gnutls_privkey_t key,\n\t\t\t\t\t     void *userdata,\n\t\t\t\t\t     const gnutls_datum_t *ciphertext,\n\t\t\t\t\t     unsigned char * plaintext,\n\t\t\t\t\t     size_t plaintext_size);\n\n/* to be called to sign pre-hashed data. The input will be\n * the output of the hash (such as SHA256) corresponding to\n * the signature algorithm. The algorithm GNUTLS_SIGN_RSA_RAW\n * will be provided when RSA PKCS#1 DigestInfo structure is provided\n * as data (when this is called from a TLS 1.0 or 1.1 session).\n */\ntypedef int (*gnutls_privkey_sign_hash_func) (gnutls_privkey_t key,\n\t\t\t\t\t      gnutls_sign_algorithm_t algo,\n\t\t\t\t\t      void *userdata,\n\t\t\t\t\t      unsigned int flags,\n\t\t\t\t\t      const gnutls_datum_t *hash,\n\t\t\t\t\t      gnutls_datum_t * signature);\n\n/* to be called to sign data. The input data will be\n * the data to be signed (and hashed), with the provided\n * signature algorithm. This function is used for algorithms\n * like ed25519 which cannot take pre-hashed data as input.\n */\ntypedef int (*gnutls_privkey_sign_data_func) (gnutls_privkey_t key,\n\t\t\t\t\t      gnutls_sign_algorithm_t algo,\n\t\t\t\t\t      void *userdata,\n\t\t\t\t\t      unsigned int flags,\n\t\t\t\t\t      const gnutls_datum_t *data,\n\t\t\t\t\t      gnutls_datum_t * signature);\n\ntypedef void (*gnutls_privkey_deinit_func) (gnutls_privkey_t key,\n\t\t\t\t\t    void *userdata);\n\n\n#define GNUTLS_SIGN_ALGO_TO_FLAGS(sig) (unsigned int)((sig)<<20)\n#define GNUTLS_FLAGS_TO_SIGN_ALGO(flags) (unsigned int)((flags)>>20)\n\n/* Should return the public key algorithm (gnutls_pk_algorithm_t) */\n#define GNUTLS_PRIVKEY_INFO_PK_ALGO 1\n/* Should return the preferred signature algorithm (gnutls_sign_algorithm_t) or 0. */\n#define GNUTLS_PRIVKEY_INFO_SIGN_ALGO (1<<1)\n/* Should return true (1) or false (0) if the provided sign algorithm\n * (obtained with GNUTLS_FLAGS_TO_SIGN_ALGO) is supported.\n */\n#define GNUTLS_PRIVKEY_INFO_HAVE_SIGN_ALGO (1<<2)\n/* Should return the number of bits of the public key algorithm (required for RSA-PSS)\n * It is the value that should be returned by gnutls_pubkey_get_pk_algorithm() */\n#define GNUTLS_PRIVKEY_INFO_PK_ALGO_BITS (1<<3)\n\n/* returns information on the public key associated with userdata */\ntypedef int (*gnutls_privkey_info_func) (gnutls_privkey_t key, unsigned int flags, void *userdata);\n\nint gnutls_pubkey_init(gnutls_pubkey_t * key);\nvoid gnutls_pubkey_deinit(gnutls_pubkey_t key);\n\nint gnutls_pubkey_verify_params(gnutls_pubkey_t key);\n\nvoid gnutls_pubkey_set_pin_function(gnutls_pubkey_t key,\n\t\t\t\t    gnutls_pin_callback_t fn,\n\t\t\t\t    void *userdata);\n\nint gnutls_pubkey_get_pk_algorithm(gnutls_pubkey_t key,\n\t\t\t\t   unsigned int *bits);\n\nint\ngnutls_pubkey_set_spki(gnutls_pubkey_t key,\n\t\t\tconst gnutls_x509_spki_t spki,\n\t\t\tunsigned int flags);\n\nint\ngnutls_pubkey_get_spki(gnutls_pubkey_t key,\n\t\t\tconst gnutls_x509_spki_t spki,\n\t\t\tunsigned int flags);\n\nint gnutls_pubkey_import_x509(gnutls_pubkey_t key,\n\t\t\t      gnutls_x509_crt_t crt, unsigned int flags);\nint gnutls_pubkey_import_x509_crq(gnutls_pubkey_t key,\n\t\t\t\t  gnutls_x509_crq_t crq,\n\t\t\t\t  unsigned int flags);\nint gnutls_pubkey_import_pkcs11(gnutls_pubkey_t key,\n\t\t\t\tgnutls_pkcs11_obj_t obj,\n\t\t\t\tunsigned int flags);\nint gnutls_pubkey_import_openpgp(gnutls_pubkey_t key,\n\t\t\t\t gnutls_openpgp_crt_t crt,\n\t\t\t\t unsigned int flags);\n\nint gnutls_pubkey_import_openpgp_raw(gnutls_pubkey_t pkey,\n\t\t\t\t     const gnutls_datum_t * data,\n\t\t\t\t     gnutls_openpgp_crt_fmt_t\n\t\t\t\t     format,\n\t\t\t\t     const gnutls_openpgp_keyid_t\n\t\t\t\t     keyid, unsigned int flags);\nint gnutls_pubkey_import_x509_raw(gnutls_pubkey_t pkey,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t\t  unsigned int flags);\n\nint\ngnutls_pubkey_import_privkey(gnutls_pubkey_t key,\n\t\t\t     gnutls_privkey_t pkey,\n\t\t\t     unsigned int usage, unsigned int flags);\n\nint\ngnutls_pubkey_import_tpm_url(gnutls_pubkey_t pkey,\n\t\t\t     const char *url,\n\t\t\t     const char *srk_password, unsigned int flags);\n\nint\ngnutls_pubkey_import_url(gnutls_pubkey_t key, const char *url,\n\t\t\t unsigned int flags);\n\nint\ngnutls_pubkey_import_tpm_raw(gnutls_pubkey_t pkey,\n\t\t\t     const gnutls_datum_t * fdata,\n\t\t\t     gnutls_tpmkey_fmt_t format,\n\t\t\t     const char *srk_password, unsigned int flags);\n\nint gnutls_pubkey_get_preferred_hash_algorithm(gnutls_pubkey_t key,\n\t\t\t\t\t       gnutls_digest_algorithm_t\n\t\t\t\t\t       * hash, unsigned int *mand);\n\n#define gnutls_pubkey_get_pk_rsa_raw gnutls_pubkey_export_rsa_raw\nint gnutls_pubkey_export_rsa_raw(gnutls_pubkey_t key,\n\t\t\t\t gnutls_datum_t * m, gnutls_datum_t * e);\n\nint gnutls_pubkey_export_rsa_raw2(gnutls_pubkey_t key,\n\t\t\t\t  gnutls_datum_t * m, gnutls_datum_t * e,\n\t\t\t\t  unsigned flags);\n\n#define gnutls_pubkey_get_pk_dsa_raw gnutls_pubkey_export_dsa_raw\nint gnutls_pubkey_export_dsa_raw(gnutls_pubkey_t key,\n\t\t\t\t gnutls_datum_t * p,\n\t\t\t\t gnutls_datum_t * q,\n\t\t\t\t gnutls_datum_t * g, gnutls_datum_t * y);\n\nint gnutls_pubkey_export_dsa_raw2(gnutls_pubkey_t key,\n\t\t\t\t gnutls_datum_t * p,\n\t\t\t\t gnutls_datum_t * q,\n\t\t\t\t gnutls_datum_t * g, gnutls_datum_t * y,\n\t\t\t\t unsigned flags);\n\nint gnutls_pubkey_export_ecc_raw2(gnutls_pubkey_t key,\n\t\t\t\t gnutls_ecc_curve_t * curve,\n\t\t\t\t gnutls_datum_t * x, gnutls_datum_t * y,\n\t\t\t\t unsigned flags);\n\nint gnutls_pubkey_export_gost_raw2(gnutls_pubkey_t key,\n\t\t\t\t   gnutls_ecc_curve_t * curve,\n\t\t\t\t   gnutls_digest_algorithm_t * digest,\n\t\t\t\t   gnutls_gost_paramset_t * paramset,\n\t\t\t\t   gnutls_datum_t * x, gnutls_datum_t * y,\n\t\t\t\t   unsigned int flags);\n\n#define gnutls_pubkey_get_pk_ecc_raw gnutls_pubkey_export_ecc_raw\nint gnutls_pubkey_export_ecc_raw(gnutls_pubkey_t key,\n\t\t\t\t gnutls_ecc_curve_t * curve,\n\t\t\t\t gnutls_datum_t * x, gnutls_datum_t * y);\n\n#define gnutls_pubkey_get_pk_ecc_x962 gnutls_pubkey_export_ecc_x962\nint gnutls_pubkey_export_ecc_x962(gnutls_pubkey_t key,\n\t\t\t\t  gnutls_datum_t * parameters,\n\t\t\t\t  gnutls_datum_t * ecpoint);\n\nint gnutls_pubkey_export(gnutls_pubkey_t key,\n\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t void *output_data, size_t * output_data_size);\n\nint gnutls_pubkey_export2(gnutls_pubkey_t key,\n\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t  gnutls_datum_t * out);\n\nint gnutls_pubkey_get_key_id(gnutls_pubkey_t key,\n\t\t\t     unsigned int flags,\n\t\t\t     unsigned char *output_data,\n\t\t\t     size_t * output_data_size);\n\nint\ngnutls_pubkey_get_openpgp_key_id(gnutls_pubkey_t key,\n\t\t\t\t unsigned int flags,\n\t\t\t\t unsigned char *output_data,\n\t\t\t\t size_t * output_data_size,\n\t\t\t\t unsigned int *subkey);\n\nint gnutls_pubkey_get_key_usage(gnutls_pubkey_t key, unsigned int *usage);\nint gnutls_pubkey_set_key_usage(gnutls_pubkey_t key, unsigned int usage);\n\nint gnutls_pubkey_import(gnutls_pubkey_t key,\n\t\t\t const gnutls_datum_t * data,\n\t\t\t gnutls_x509_crt_fmt_t format);\n\n\n#define gnutls_pubkey_import_pkcs11_url(key, url, flags) gnutls_pubkey_import_url(key, url, flags)\n\nint gnutls_pubkey_import_dsa_raw(gnutls_pubkey_t key,\n\t\t\t\t const gnutls_datum_t * p,\n\t\t\t\t const gnutls_datum_t * q,\n\t\t\t\t const gnutls_datum_t * g,\n\t\t\t\t const gnutls_datum_t * y);\nint gnutls_pubkey_import_rsa_raw(gnutls_pubkey_t key,\n\t\t\t\t const gnutls_datum_t * m,\n\t\t\t\t const gnutls_datum_t * e);\n\nint\ngnutls_pubkey_import_ecc_x962(gnutls_pubkey_t key,\n\t\t\t      const gnutls_datum_t * parameters,\n\t\t\t      const gnutls_datum_t * ecpoint);\n\nint\ngnutls_pubkey_import_ecc_raw(gnutls_pubkey_t key,\n\t\t\t     gnutls_ecc_curve_t curve,\n\t\t\t     const gnutls_datum_t * x,\n\t\t\t     const gnutls_datum_t * y);\n\nint\ngnutls_pubkey_import_gost_raw(gnutls_pubkey_t key,\n\t\t\t     gnutls_ecc_curve_t curve,\n\t\t\t     gnutls_digest_algorithm_t digest,\n\t\t\t     gnutls_gost_paramset_t paramset,\n\t\t\t     const gnutls_datum_t * x,\n\t\t\t     const gnutls_datum_t * y);\n\nint\ngnutls_pubkey_encrypt_data(gnutls_pubkey_t key,\n\t\t\t   unsigned int flags,\n\t\t\t   const gnutls_datum_t * plaintext,\n\t\t\t   gnutls_datum_t * ciphertext);\n\nint gnutls_x509_crt_set_pubkey(gnutls_x509_crt_t crt, gnutls_pubkey_t key);\n\nint gnutls_x509_crq_set_pubkey(gnutls_x509_crq_t crq, gnutls_pubkey_t key);\n\nint\ngnutls_pubkey_verify_hash2(gnutls_pubkey_t key,\n\t\t\t   gnutls_sign_algorithm_t algo,\n\t\t\t   unsigned int flags,\n\t\t\t   const gnutls_datum_t * hash,\n\t\t\t   const gnutls_datum_t * signature);\n\nint\ngnutls_pubkey_verify_data2(gnutls_pubkey_t pubkey,\n\t\t\t   gnutls_sign_algorithm_t algo,\n\t\t\t   unsigned int flags,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   const gnutls_datum_t * signature);\n\n/* Private key operations */\n\nint gnutls_privkey_init(gnutls_privkey_t * key);\nvoid gnutls_privkey_deinit(gnutls_privkey_t key);\n\n/* macros to allow specifying a subgroup and group size in gnutls_privkey_generate()\n * and gnutls_x509_privkey_generate() */\n#define GNUTLS_SUBGROUP_TO_BITS(group, subgroup) (unsigned int)((subgroup<<16)|(group))\n#define GNUTLS_BITS_TO_SUBGROUP(bits) ((bits >> 16) & 0xFFFF)\n#define GNUTLS_BITS_TO_GROUP(bits) (bits & 0xFFFF)\n#define GNUTLS_BITS_HAVE_SUBGROUP(bits) ((bits) & 0xFFFF0000)\n\nint\ngnutls_privkey_generate (gnutls_privkey_t key,\n                         gnutls_pk_algorithm_t algo, unsigned int bits,\n                         unsigned int flags);\nint\ngnutls_privkey_generate2(gnutls_privkey_t pkey,\n\t\t\t gnutls_pk_algorithm_t algo, unsigned int bits,\n\t\t\t unsigned int flags, const gnutls_keygen_data_st *data, unsigned data_size);\n\nint\ngnutls_privkey_set_spki(gnutls_privkey_t key,\n\t\t\tconst gnutls_x509_spki_t spki,\n\t\t\tunsigned int flags);\n\nint\ngnutls_privkey_get_spki(gnutls_privkey_t key,\n\t\t\tconst gnutls_x509_spki_t spki,\n\t\t\tunsigned int flags);\n\nint gnutls_privkey_verify_seed(gnutls_privkey_t key, gnutls_digest_algorithm_t, const void *seed, size_t seed_size);\nint gnutls_privkey_get_seed(gnutls_privkey_t key, gnutls_digest_algorithm_t*, void *seed, size_t *seed_size);\n\nint gnutls_privkey_verify_params(gnutls_privkey_t key);\n\nvoid gnutls_privkey_set_flags(gnutls_privkey_t key, unsigned int flags);\n\nvoid gnutls_privkey_set_pin_function (gnutls_privkey_t key,\n                                      gnutls_pin_callback_t fn, void *userdata);\n\nint gnutls_privkey_get_pk_algorithm(gnutls_privkey_t key,\n\t\t\t\t    unsigned int *bits);\ngnutls_privkey_type_t gnutls_privkey_get_type(gnutls_privkey_t key);\nint gnutls_privkey_status(gnutls_privkey_t key);\n\n/**\n * gnutls_privkey_flags:\n * @GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA: Make an RSA signature on the hashed data as in the TLS protocol.\n * @GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS: Make an RSA signature on the hashed data with the PSS padding.\n * @GNUTLS_PRIVKEY_FLAG_REPRODUCIBLE: Make a signature on the hashed data with reproducible parameters.\n *   For RSA-PSS, that means to use empty salt instead of random value. To\n *   verify a signature created using this flag, the corresponding SPKI needs\n *   to be set on the public key. Use gnutls_pubkey_set_spki() for that.\n *   For ECDSA/DSA, it uses the deterministic construction of random parameter\n *   according to RFC 6979. Note that this only supports the NIST curves and DSA\n *   subgroup bits up to 512.\n * @GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE: When importing a private key, automatically\n *   release it when the structure it was imported is released.\n * @GNUTLS_PRIVKEY_IMPORT_COPY: Copy required values during import.\n * @GNUTLS_PRIVKEY_DISABLE_CALLBACKS: The following flag disables call to PIN callbacks etc.\n *   Only relevant to TPM keys.\n * @GNUTLS_PRIVKEY_FLAG_PROVABLE: When generating a key involving prime numbers, use provable primes; a seed may be required.\n * @GNUTLS_PRIVKEY_FLAG_CA: The generated private key is going to be used as a CA (relevant for RSA-PSS keys).\n * @GNUTLS_PRIVKEY_FLAG_EXPORT_COMPAT: Keys generated or imported as provable require an extended format which cannot be read by previous versions\n *   of gnutls or other applications. By setting this flag the key will be exported in a backwards compatible way,\n *   even if the information about the seed used will be lost.\n * @GNUTLS_PRIVKEY_FLAG_RSA_PSS_FIXED_SALT_LENGTH: When making an RSA-PSS\n *   signature, use the salt whose length is equal to the digest length, as\n *   mandated in RFC 8446 4.2.3.\n *\n * Enumeration of different certificate import flags.\n */\ntypedef enum gnutls_privkey_flags {\n\tGNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE = 1,\n\tGNUTLS_PRIVKEY_IMPORT_COPY = 1 << 1,\n\tGNUTLS_PRIVKEY_DISABLE_CALLBACKS = 1 << 2,\n\tGNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA = 1 << 4,\n\tGNUTLS_PRIVKEY_FLAG_PROVABLE = 1 << 5,\n\tGNUTLS_PRIVKEY_FLAG_EXPORT_COMPAT = 1 << 6,\n\tGNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS = 1 << 7,\n\tGNUTLS_PRIVKEY_FLAG_REPRODUCIBLE = 1 << 8,\n\tGNUTLS_PRIVKEY_FLAG_CA = 1 << 9,\n\tGNUTLS_PRIVKEY_FLAG_RSA_PSS_FIXED_SALT_LENGTH = 1 << 10\n} gnutls_privkey_flags_t;\n\nint gnutls_privkey_import_pkcs11(gnutls_privkey_t pkey,\n\t\t\t\t gnutls_pkcs11_privkey_t key,\n\t\t\t\t unsigned int flags);\nint gnutls_privkey_import_x509(gnutls_privkey_t pkey,\n\t\t\t       gnutls_x509_privkey_t key,\n\t\t\t       unsigned int flags);\nint gnutls_privkey_import_openpgp(gnutls_privkey_t pkey,\n\t\t\t\t  gnutls_openpgp_privkey_t key,\n\t\t\t\t  unsigned int flags);\n\nint gnutls_privkey_export_x509(gnutls_privkey_t pkey,\n                               gnutls_x509_privkey_t * key);\nint gnutls_privkey_export_openpgp(gnutls_privkey_t pkey,\n                                  gnutls_openpgp_privkey_t * key);\nint\ngnutls_privkey_export_pkcs11(gnutls_privkey_t pkey,\n                             gnutls_pkcs11_privkey_t *key);\n\nint gnutls_privkey_import_openpgp_raw(gnutls_privkey_t pkey,\n\t\t\t\t      const gnutls_datum_t * data,\n\t\t\t\t      gnutls_openpgp_crt_fmt_t\n\t\t\t\t      format,\n\t\t\t\t      const gnutls_openpgp_keyid_t\n\t\t\t\t      keyid, const char *password);\n\nint gnutls_privkey_import_x509_raw(gnutls_privkey_t pkey,\n\t\t\t\t   const gnutls_datum_t * data,\n\t\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t\t   const char *password,\n\t\t\t\t   unsigned int flags);\n\nint\ngnutls_privkey_import_tpm_raw(gnutls_privkey_t pkey,\n\t\t\t      const gnutls_datum_t * fdata,\n\t\t\t      gnutls_tpmkey_fmt_t format,\n\t\t\t      const char *srk_password,\n\t\t\t      const char *key_password,\n\t\t\t      unsigned int flags);\n\nint\ngnutls_privkey_import_tpm_url(gnutls_privkey_t pkey,\n\t\t\t      const char *url,\n\t\t\t      const char *srk_password,\n\t\t\t      const char *key_password,\n\t\t\t      unsigned int flags);\n\nint gnutls_privkey_import_url(gnutls_privkey_t key,\n\t\t\t      const char *url, unsigned int flags);\n\n#if 0\n/* for documentation purposes */\nint gnutls_privkey_import_pkcs11_url(gnutls_privkey_t key, const char *url);\n#endif\n\n#define gnutls_privkey_import_pkcs11_url(key, url) gnutls_privkey_import_url(key, url, 0)\n\nint\ngnutls_privkey_import_ext(gnutls_privkey_t pkey,\n\t\t\t  gnutls_pk_algorithm_t pk,\n\t\t\t  void *userdata,\n\t\t\t  gnutls_privkey_sign_func sign_func,\n\t\t\t  gnutls_privkey_decrypt_func\n\t\t\t  decrypt_func, unsigned int flags);\n\nint\ngnutls_privkey_import_ext2(gnutls_privkey_t pkey,\n\t\t\t   gnutls_pk_algorithm_t pk,\n\t\t\t   void *userdata,\n\t\t\t   gnutls_privkey_sign_func sign_func,\n\t\t\t   gnutls_privkey_decrypt_func\n\t\t\t   decrypt_func,\n\t\t\t   gnutls_privkey_deinit_func deinit_func,\n\t\t\t   unsigned int flags);\n\nint\ngnutls_privkey_import_ext3(gnutls_privkey_t pkey,\n                           void *userdata,\n                           gnutls_privkey_sign_func sign_func,\n                           gnutls_privkey_decrypt_func decrypt_func,\n                           gnutls_privkey_deinit_func deinit_func,\n                           gnutls_privkey_info_func info_func,\n                           unsigned int flags);\n\nint\ngnutls_privkey_import_ext4(gnutls_privkey_t pkey,\n                           void *userdata,\n                           gnutls_privkey_sign_data_func sign_data_func,\n                           gnutls_privkey_sign_hash_func sign_hash_func,\n                           gnutls_privkey_decrypt_func decrypt_func,\n                           gnutls_privkey_deinit_func deinit_func,\n                           gnutls_privkey_info_func info_func,\n                           unsigned int flags);\n\nint gnutls_privkey_import_dsa_raw(gnutls_privkey_t key,\n\t\t\t\t       const gnutls_datum_t * p,\n\t\t\t\t       const gnutls_datum_t * q,\n\t\t\t\t       const gnutls_datum_t * g,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * x);\n\nint gnutls_privkey_import_rsa_raw(gnutls_privkey_t key,\n\t\t\t\t\tconst gnutls_datum_t * m,\n\t\t\t\t\tconst gnutls_datum_t * e,\n\t\t\t\t\tconst gnutls_datum_t * d,\n\t\t\t\t\tconst gnutls_datum_t * p,\n\t\t\t\t\tconst gnutls_datum_t * q,\n\t\t\t\t\tconst gnutls_datum_t * u,\n\t\t\t\t\tconst gnutls_datum_t * e1,\n\t\t\t\t\tconst gnutls_datum_t * e2);\nint gnutls_privkey_import_ecc_raw(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t curve,\n\t\t\t\t       const gnutls_datum_t * x,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * k);\n\nint gnutls_privkey_import_gost_raw(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t curve,\n\t\t\t\t       gnutls_digest_algorithm_t digest,\n\t\t\t\t       gnutls_gost_paramset_t paramset,\n\t\t\t\t       const gnutls_datum_t * x,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * k);\n\n\nint gnutls_privkey_sign_data(gnutls_privkey_t signer,\n\t\t\t     gnutls_digest_algorithm_t hash,\n\t\t\t     unsigned int flags,\n\t\t\t     const gnutls_datum_t * data,\n\t\t\t     gnutls_datum_t * signature);\n\nint gnutls_privkey_sign_data2(gnutls_privkey_t signer,\n\t\t\t      gnutls_sign_algorithm_t algo,\n\t\t\t      unsigned int flags,\n\t\t\t      const gnutls_datum_t * data,\n\t\t\t      gnutls_datum_t * signature);\n\n#define gnutls_privkey_sign_raw_data(key, flags, data, sig) \\\n\tgnutls_privkey_sign_hash ( key, 0, GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA, data, sig)\n\nint gnutls_privkey_sign_hash(gnutls_privkey_t signer,\n\t\t\t     gnutls_digest_algorithm_t hash_algo,\n\t\t\t     unsigned int flags,\n\t\t\t     const gnutls_datum_t * hash_data,\n\t\t\t     gnutls_datum_t * signature);\n\nint gnutls_privkey_sign_hash2(gnutls_privkey_t signer,\n\t\t\t      gnutls_sign_algorithm_t algo,\n\t\t\t      unsigned int flags,\n\t\t\t      const gnutls_datum_t * hash_data,\n\t\t\t      gnutls_datum_t * signature);\n\nint gnutls_privkey_decrypt_data(gnutls_privkey_t key,\n\t\t\t\tunsigned int flags,\n\t\t\t\tconst gnutls_datum_t * ciphertext,\n\t\t\t\tgnutls_datum_t * plaintext);\n\nint gnutls_privkey_decrypt_data2(gnutls_privkey_t key,\n\t\t\t\t unsigned int flags,\n\t\t\t\t const gnutls_datum_t * ciphertext,\n\t\t\t\t unsigned char * plaintext,\n                                 size_t plaintext_size);\n\nint\ngnutls_privkey_export_rsa_raw(gnutls_privkey_t key,\n\t\t\t\t    gnutls_datum_t * m, gnutls_datum_t * e,\n\t\t\t\t    gnutls_datum_t * d, gnutls_datum_t * p,\n\t\t\t\t    gnutls_datum_t * q, gnutls_datum_t * u,\n\t\t\t\t    gnutls_datum_t * e1,\n\t\t\t\t    gnutls_datum_t * e2);\n\nint\ngnutls_privkey_export_rsa_raw2(gnutls_privkey_t key,\n\t\t\t\t    gnutls_datum_t * m, gnutls_datum_t * e,\n\t\t\t\t    gnutls_datum_t * d, gnutls_datum_t * p,\n\t\t\t\t    gnutls_datum_t * q, gnutls_datum_t * u,\n\t\t\t\t    gnutls_datum_t * e1,\n\t\t\t\t    gnutls_datum_t * e2, unsigned flags);\n\nint\ngnutls_privkey_export_dsa_raw(gnutls_privkey_t key,\n\t\t\t     gnutls_datum_t * p, gnutls_datum_t * q,\n\t\t\t     gnutls_datum_t * g, gnutls_datum_t * y,\n\t\t\t     gnutls_datum_t * x);\n\nint\ngnutls_privkey_export_dsa_raw2(gnutls_privkey_t key,\n\t\t\t     gnutls_datum_t * p, gnutls_datum_t * q,\n\t\t\t     gnutls_datum_t * g, gnutls_datum_t * y,\n\t\t\t     gnutls_datum_t * x, unsigned flags);\n\nint\ngnutls_privkey_export_ecc_raw(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k);\n\nint\ngnutls_privkey_export_ecc_raw2(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k,\n\t\t\t\t       unsigned flags);\n\nint\ngnutls_privkey_export_gost_raw2(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_digest_algorithm_t * digest,\n\t\t\t\t       gnutls_gost_paramset_t * paramset,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k,\n\t\t\t\t       unsigned flags);\n\n\nint gnutls_x509_crt_privkey_sign(gnutls_x509_crt_t crt,\n\t\t\t\t gnutls_x509_crt_t issuer,\n\t\t\t\t gnutls_privkey_t issuer_key,\n\t\t\t\t gnutls_digest_algorithm_t dig,\n\t\t\t\t unsigned int flags);\n\nint gnutls_x509_crl_privkey_sign(gnutls_x509_crl_t crl,\n\t\t\t\t gnutls_x509_crt_t issuer,\n\t\t\t\t gnutls_privkey_t issuer_key,\n\t\t\t\t gnutls_digest_algorithm_t dig,\n\t\t\t\t unsigned int flags);\n\nint gnutls_x509_crq_privkey_sign(gnutls_x509_crq_t crq,\n\t\t\t\t gnutls_privkey_t key,\n\t\t\t\t gnutls_digest_algorithm_t dig,\n\t\t\t\t unsigned int flags);\n\n/**\n * gnutls_pcert_st:\n * @pubkey: public key of parsed certificate.\n * @cert: certificate itself of parsed certificate\n * @type: type of certificate, a #gnutls_certificate_type_t type.\n *\n * A parsed certificate.\n */\ntypedef struct gnutls_pcert_st {\n\tgnutls_pubkey_t pubkey;\n\tgnutls_datum_t cert;\n\tgnutls_certificate_type_t type;\n} gnutls_pcert_st;\n\n/* This flag is unused/ignored */\n#define GNUTLS_PCERT_NO_CERT 1\n\nint gnutls_pcert_import_x509(gnutls_pcert_st * pcert,\n\t\t\t     gnutls_x509_crt_t crt, unsigned int flags);\n\nint gnutls_pcert_import_x509_list(gnutls_pcert_st * pcert,\n\t\t\t\t  gnutls_x509_crt_t *crt, unsigned *ncrt,\n\t\t\t\t  unsigned int flags);\n\nint gnutls_pcert_export_x509(gnutls_pcert_st * pcert,\n                             gnutls_x509_crt_t * crt);\n\nint\ngnutls_pcert_list_import_x509_raw(gnutls_pcert_st * pcerts,\n\t\t\t\t  unsigned int *pcert_max,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t\t  unsigned int flags);\n\nint gnutls_pcert_list_import_x509_file(gnutls_pcert_st *pcert_list,\n\t\t\t\t       unsigned *pcert_list_size,\n\t\t\t\t       const char *file,\n\t\t\t\t       gnutls_x509_crt_fmt_t format,\n\t\t\t\t       gnutls_pin_callback_t pin_fn,\n\t\t\t\t       void *pin_fn_userdata,\n\t\t\t\t       unsigned int flags);\n\nint gnutls_pcert_import_x509_raw(gnutls_pcert_st * pcert,\n\t\t\t\t const gnutls_datum_t * cert,\n\t\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t\t unsigned int flags);\n\nint gnutls_pcert_import_openpgp_raw(gnutls_pcert_st * pcert,\n\t\t\t\t    const gnutls_datum_t * cert,\n\t\t\t\t    gnutls_openpgp_crt_fmt_t\n\t\t\t\t    format,\n\t\t\t\t    gnutls_openpgp_keyid_t keyid,\n\t\t\t\t    unsigned int flags);\n\nint gnutls_pcert_import_openpgp(gnutls_pcert_st * pcert,\n\t\t\t\tgnutls_openpgp_crt_t crt,\n\t\t\t\tunsigned int flags);\n\nint gnutls_pcert_export_openpgp(gnutls_pcert_st * pcert,\n                                gnutls_openpgp_crt_t * crt);\n\nvoid gnutls_pcert_deinit(gnutls_pcert_st * pcert);\n\nint gnutls_pcert_import_rawpk(gnutls_pcert_st* pcert,\n\t\t\t     gnutls_pubkey_t key, unsigned int flags);\n\nint gnutls_pcert_import_rawpk_raw(gnutls_pcert_st* pcert,\n\t\t\t\t    const gnutls_datum_t* rawpubkey,\n\t\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t\t    unsigned int key_usage, unsigned int flags);\n\n/* For certificate credentials */\n\t/* This is the same as gnutls_certificate_retrieve_function()\n\t * but retrieves a gnutls_pcert_st which requires much less processing\n\t * within the library.\n\t */\ntypedef int gnutls_certificate_retrieve_function2(gnutls_session_t,\n\t\t\t\t  const gnutls_datum_t *req_ca_rdn,\n\t\t\t\t  int nreqs,\n\t\t\t\t  const gnutls_pk_algorithm_t *pk_algos,\n\t\t\t\t  int pk_algos_length,\n\t\t\t\t  gnutls_pcert_st**,\n\t\t\t\t  unsigned int *pcert_length,\n\t\t\t\t  gnutls_privkey_t *privkey);\n\n\nvoid gnutls_certificate_set_retrieve_function2\n    (gnutls_certificate_credentials_t cred,\n     gnutls_certificate_retrieve_function2 *func);\n\nstruct gnutls_cert_retr_st {\n\tunsigned version; /* set to 1 */\n\tgnutls_certificate_credentials_t cred;\n\tconst gnutls_datum_t *req_ca_rdn;\n\tunsigned nreqs;\n\tconst gnutls_pk_algorithm_t *pk_algos;\n\tunsigned pk_algos_length;\n\n\t/* other fields may be added if version is > 1 */\n\tunsigned char padding[64];\n};\n\n/* When the callback sets this value, gnutls will deinitialize the given\n * values after use */\n#define GNUTLS_CERT_RETR_DEINIT_ALL 1\n\ntypedef int gnutls_certificate_retrieve_function3(\n\t\t\t\tgnutls_session_t,\n\t\t\t\tconst struct gnutls_cert_retr_st *info,\n\t\t\t\tgnutls_pcert_st **certs,\n\t\t\t\tunsigned int *certs_length,\n\t\t\t\tgnutls_ocsp_data_st **ocsp,\n\t\t\t\tunsigned int *ocsp_length,\n\t\t\t\tgnutls_privkey_t *privkey,\n\t\t\t\tunsigned int *flags);\n\n\nvoid gnutls_certificate_set_retrieve_function3\n    (gnutls_certificate_credentials_t cred,\n     gnutls_certificate_retrieve_function3 *func);\n\nint\ngnutls_certificate_set_key(gnutls_certificate_credentials_t res,\n\t\t\t   const char **names,\n\t\t\t   int names_size,\n\t\t\t   gnutls_pcert_st * pcert_list,\n\t\t\t   int pcert_list_size, gnutls_privkey_t key);\n\nint\ngnutls_pubkey_print(gnutls_pubkey_t pubkey,\n\t\t    gnutls_certificate_print_formats_t format,\n\t\t    gnutls_datum_t * out);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_ABSTRACT_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/compat.h",
    "content": "/*\n * Copyright (C) 2008-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* Typedefs for more compatibility with older GnuTLS. */\n\n#ifndef GNUTLS_COMPAT_H\n#define GNUTLS_COMPAT_H\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#ifdef __GNUC__\n\n#define _GNUTLS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)\n\n#if !defined GNUTLS_INTERNAL_BUILD\n#if _GNUTLS_GCC_VERSION >= 30100\n#define _GNUTLS_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))\n#endif\n#endif\n\n#endif\t\t\t\t/* __GNUC__ */\n\n#ifndef _GNUTLS_GCC_ATTR_DEPRECATED\n#define _GNUTLS_GCC_ATTR_DEPRECATED\n#endif\n\n/* gnutls_connection_end_t was made redundant in 2.99.0 */\ntypedef unsigned int gnutls_connection_end_t _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* Stuff deprecated in 2.x */\ntypedef gnutls_cipher_algorithm_t gnutls_cipher_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_kx_algorithm_t gnutls_kx_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_mac_algorithm_t gnutls_mac_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_digest_algorithm_t gnutls_digest_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_compression_method_t gnutls_compression_method\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_connection_end_t gnutls_connection_end\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_crt_fmt_t gnutls_x509_crt_fmt\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_pk_algorithm_t gnutls_pk_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_sign_algorithm_t gnutls_sign_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_close_request_t gnutls_close_request\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_certificate_request_t gnutls_certificate_request\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_certificate_status_t gnutls_certificate_status\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_session_t gnutls_session _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_alert_level_t gnutls_alert_level\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_alert_description_t gnutls_alert_description\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_subject_alt_name_t gnutls_x509_subject_alt_name\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_openpgp_privkey_t gnutls_openpgp_privkey\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_openpgp_keyring_t gnutls_openpgp_keyring\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_crt_t gnutls_x509_crt _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_privkey_t gnutls_x509_privkey\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_crl_t gnutls_x509_crl _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_crq_t gnutls_x509_crq _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_certificate_credentials_t\n    gnutls_certificate_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_anon_server_credentials_t\n    gnutls_anon_server_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_anon_client_credentials_t\n    gnutls_anon_client_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_srp_client_credentials_t\n    gnutls_srp_client_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_srp_server_credentials_t\n    gnutls_srp_server_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_dh_params_t gnutls_dh_params _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_rsa_params_t gnutls_rsa_params _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_params_type_t gnutls_params_type\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_credentials_type_t gnutls_credentials_type\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_certificate_type_t gnutls_certificate_type\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_datum_t gnutls_datum _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_transport_ptr_t gnutls_transport_ptr\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* Old verification flags */\n#define GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT  (0)\n\n/* Old SRP alerts removed in 2.1.x because the TLS-SRP RFC was\n   modified to use the PSK alert. */\n#define GNUTLS_A_MISSING_SRP_USERNAME GNUTLS_A_UNKNOWN_PSK_IDENTITY\n#define GNUTLS_A_UNKNOWN_SRP_USERNAME GNUTLS_A_UNKNOWN_PSK_IDENTITY\n\n/* OpenPGP stuff renamed in 2.1.x. */\n#define GNUTLS_OPENPGP_KEY GNUTLS_OPENPGP_CERT\n#define GNUTLS_OPENPGP_KEY_FINGERPRINT GNUTLS_OPENPGP_CERT_FINGERPRINT\n#define gnutls_openpgp_send_key gnutls_openpgp_send_cert\ntypedef gnutls_openpgp_crt_status_t gnutls_openpgp_key_status_t\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_openpgp_crt_t gnutls_openpgp_key_t\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n#define gnutls_openpgp_key_init gnutls_openpgp_crt_init\n#define gnutls_openpgp_key_deinit gnutls_openpgp_crt_deinit\n#define gnutls_openpgp_key_import gnutls_openpgp_crt_import\n#define gnutls_openpgp_key_export gnutls_openpgp_crt_export\n#define gnutls_openpgp_key_get_key_usage gnutls_openpgp_crt_get_key_usage\n#define gnutls_openpgp_key_get_fingerprint gnutls_openpgp_crt_get_fingerprint\n#define gnutls_openpgp_key_get_pk_algorithm gnutls_openpgp_crt_get_pk_algorithm\n#define gnutls_openpgp_key_get_name gnutls_openpgp_crt_get_name\n#define gnutls_openpgp_key_get_version gnutls_openpgp_crt_get_version\n#define gnutls_openpgp_key_get_creation_time gnutls_openpgp_crt_get_creation_time\n#define gnutls_openpgp_key_get_expiration_time gnutls_openpgp_crt_get_expiration_time\n#define gnutls_openpgp_key_get_id gnutls_openpgp_crt_get_id\n#define gnutls_openpgp_key_check_hostname gnutls_openpgp_crt_check_hostname\n\n/* OpenPGP stuff renamed in 2.3.x. */\n#define gnutls_openpgp_crt_get_id gnutls_openpgp_crt_get_key_id\n\n/* New better names renamed in 2.3.x, add these for backwards\n   compatibility with old poor names.*/\n#define GNUTLS_X509_CRT_FULL GNUTLS_CRT_PRINT_FULL\n#define GNUTLS_X509_CRT_ONELINE GNUTLS_CRT_PRINT_ONELINE\n#define GNUTLS_X509_CRT_UNSIGNED_FULL GNUTLS_CRT_PRINT_UNSIGNED_FULL\n\n/* Namespace problems. */\n#define LIBGNUTLS_VERSION GNUTLS_VERSION\n#define LIBGNUTLS_VERSION_MAJOR GNUTLS_VERSION_MAJOR\n#define LIBGNUTLS_VERSION_MINOR GNUTLS_VERSION_MINOR\n#define LIBGNUTLS_VERSION_PATCH GNUTLS_VERSION_PATCH\n#define LIBGNUTLS_VERSION_NUMBER GNUTLS_VERSION_NUMBER\n#define LIBGNUTLS_EXTRA_VERSION GNUTLS_VERSION\n\n/* This is a very dangerous and error-prone function.\n * Use gnutls_privkey_sign_hash() instead.\n */\nint gnutls_x509_privkey_sign_hash(gnutls_x509_privkey_t key,\n\t\t\t\t  const gnutls_datum_t * hash,\n\t\t\t\t  gnutls_datum_t * signature)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_sign_hash(gnutls_openpgp_privkey_t key,\n\t\t\t\t     const gnutls_datum_t * hash,\n\t\t\t\t     gnutls_datum_t * signature)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\t/* gnutls_pubkey_get_preferred_hash_algorithm() */\nint gnutls_x509_crt_get_preferred_hash_algorithm(gnutls_x509_crt_t\n\t\t\t\t\t\t crt,\n\t\t\t\t\t\t gnutls_digest_algorithm_t\n\t\t\t\t\t\t * hash, unsigned int\n\t\t\t\t\t\t *mand)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\t/* use gnutls_privkey_sign_hash() with the GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA flag */\n\n#ifdef _ISOC99_SOURCE\n/* we provide older functions for compatibility as inline functions that\n * depend on gnutls_session_get_random. */\n\nstatic inline const void\n*gnutls_session_get_server_random(gnutls_session_t session)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\nstatic inline const void\n*gnutls_session_get_server_random(gnutls_session_t session)\n{\n\tgnutls_datum_t rnd;\n\tgnutls_session_get_random(session, NULL, &rnd);\t/*doc-skip */\n\treturn rnd.data;\n}\n\nstatic inline const void\n*gnutls_session_get_client_random(gnutls_session_t session)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\nstatic inline const void\n*gnutls_session_get_client_random(gnutls_session_t session)\n{\n\tgnutls_datum_t rnd;\n\tgnutls_session_get_random(session, &rnd, NULL);\t/*doc-skip */\n\treturn rnd.data;\n}\n#endif\n\nvoid\ngnutls_global_set_mem_functions(gnutls_alloc_function alloc_func,\n\t\t\t\tgnutls_alloc_function secure_alloc_func,\n\t\t\t\tgnutls_is_secure_function is_secure_func,\n\t\t\t\tgnutls_realloc_function realloc_func,\n\t\t\t\tgnutls_free_function free_func) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* defined in old headers - unused nevertheless */\n#define GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA 0\n\n/* old compression related functions */\ngnutls_compression_method_t\ngnutls_compression_get(gnutls_session_t session) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nconst char *\ngnutls_compression_get_name(gnutls_compression_method_t\n\t\t\t    algorithm) __GNUTLS_CONST__ _GNUTLS_GCC_ATTR_DEPRECATED;\n\ngnutls_compression_method_t\n\tgnutls_compression_get_id(const char *name) __GNUTLS_CONST__ _GNUTLS_GCC_ATTR_DEPRECATED;\n\nconst gnutls_compression_method_t *\n\tgnutls_compression_list(void) __GNUTLS_PURE__ _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_priority_compression_list(gnutls_priority_t pcache,\n\t\t\t\t     const unsigned int **list) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_COMPAT_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/crypto.h",
    "content": "/*\n * Copyright (C) 2008-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_CRYPTO_H\n#define GNUTLS_CRYPTO_H\n\n#include <gnutls/gnutls.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\ntypedef struct api_cipher_hd_st *gnutls_cipher_hd_t;\n\nint gnutls_cipher_init(gnutls_cipher_hd_t * handle,\n\t\t       gnutls_cipher_algorithm_t cipher,\n\t\t       const gnutls_datum_t * key,\n\t\t       const gnutls_datum_t * iv);\nint gnutls_cipher_encrypt(const gnutls_cipher_hd_t handle,\n\t\t\t  void *text, size_t textlen);\nint gnutls_cipher_decrypt(const gnutls_cipher_hd_t handle,\n\t\t\t  void *ciphertext, size_t ciphertextlen);\nint gnutls_cipher_decrypt2(gnutls_cipher_hd_t handle,\n\t\t\t   const void *ciphertext,\n\t\t\t   size_t ciphertextlen, void *text,\n\t\t\t   size_t textlen);\nint gnutls_cipher_encrypt2(gnutls_cipher_hd_t handle,\n\t\t\t   const void *text, size_t textlen,\n\t\t\t   void *ciphertext, size_t ciphertextlen);\n\n/**\n * gnutls_cipher_flags_t:\n * @GNUTLS_CIPHER_PADDING_PKCS7: Flag to indicate PKCS#7 padding\n *\n * Enumeration of flags to control block cipher padding, used by\n * gnutls_cipher_encrypt3() and gnutls_cipher_decrypt3().\n *\n * Since: 3.7.7\n */\ntypedef enum gnutls_cipher_flags_t {\n\tGNUTLS_CIPHER_PADDING_PKCS7 = 1\n} gnutls_cipher_flags_t;\n\nint gnutls_cipher_encrypt3(gnutls_cipher_hd_t handle,\n\t\t\t   const void *ptext, size_t ptext_len,\n\t\t\t   void *ctext, size_t *ctext_len,\n\t\t\t   unsigned flags);\nint gnutls_cipher_decrypt3(gnutls_cipher_hd_t handle,\n\t\t\t   const void *ctext, size_t ctext_len,\n\t\t\t   void *ptext, size_t *ptext_len,\n\t\t\t   unsigned flags);\n\nvoid gnutls_cipher_set_iv(gnutls_cipher_hd_t handle, void *iv,\n\t\t\t  size_t ivlen);\n\nint gnutls_cipher_tag(gnutls_cipher_hd_t handle, void *tag,\n\t\t      size_t tag_size);\nint gnutls_cipher_add_auth(gnutls_cipher_hd_t handle,\n\t\t\t   const void *text, size_t text_size);\n\nvoid gnutls_cipher_deinit(gnutls_cipher_hd_t handle);\nunsigned gnutls_cipher_get_block_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\nunsigned gnutls_cipher_get_iv_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\nunsigned gnutls_cipher_get_tag_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\n\n/* AEAD API\n */\ntypedef struct api_aead_cipher_hd_st *gnutls_aead_cipher_hd_t;\n\nint gnutls_aead_cipher_init(gnutls_aead_cipher_hd_t * handle,\n\t\t\t    gnutls_cipher_algorithm_t cipher,\n\t\t\t    const gnutls_datum_t * key);\n\nint gnutls_aead_cipher_set_key(gnutls_aead_cipher_hd_t handle,\n\t\t\t       const gnutls_datum_t *key);\n\nint\ngnutls_aead_cipher_decrypt(gnutls_aead_cipher_hd_t handle,\n\t\t\t   const void *nonce, size_t nonce_len,\n\t\t\t   const void *auth, size_t auth_len,\n\t\t\t   size_t tag_size,\n\t\t\t   const void *ctext, size_t ctext_len,\n\t\t\t   void *ptext, size_t *ptext_len);\nint\ngnutls_aead_cipher_encrypt(gnutls_aead_cipher_hd_t handle,\n\t\t\t   const void *nonce, size_t nonce_len,\n\t\t\t   const void *auth, size_t auth_len,\n\t\t\t   size_t tag_size,\n\t\t\t   const void *ptext, size_t ptext_len,\n\t\t\t   void *ctext, size_t *ctext_len);\n\nint\ngnutls_aead_cipher_encryptv(gnutls_aead_cipher_hd_t handle,\n\t\t\t    const void *nonce, size_t nonce_len,\n\t\t\t    const giovec_t *auth_iov, int auth_iovcnt,\n\t\t\t    size_t tag_size,\n\t\t\t    const giovec_t *iov, int iovcnt,\n\t\t\t    void *ctext, size_t *ctext_len);\n\nint\ngnutls_aead_cipher_encryptv2(gnutls_aead_cipher_hd_t handle,\n\t\t\t     const void *nonce, size_t nonce_len,\n\t\t\t     const giovec_t *auth_iov, int auth_iovcnt,\n\t\t\t     const giovec_t *iov, int iovcnt,\n\t\t\t     void *tag, size_t *tag_size);\n\nint\ngnutls_aead_cipher_decryptv2(gnutls_aead_cipher_hd_t handle,\n\t\t\t     const void *nonce, size_t nonce_len,\n\t\t\t     const giovec_t *auth_iov, int auth_iovcnt,\n\t\t\t     const giovec_t *iov, int iovcnt,\n\t\t\t     void *tag, size_t tag_size);\n\nvoid gnutls_aead_cipher_deinit(gnutls_aead_cipher_hd_t handle);\n\n/* Hash - MAC API */\n\ntypedef struct hash_hd_st *gnutls_hash_hd_t;\ntypedef struct hmac_hd_st *gnutls_hmac_hd_t;\n\nsize_t gnutls_mac_get_nonce_size(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\nint gnutls_hmac_init(gnutls_hmac_hd_t * dig,\n\t\t     gnutls_mac_algorithm_t algorithm,\n\t\t     const void *key, size_t keylen);\nvoid gnutls_hmac_set_nonce(gnutls_hmac_hd_t handle,\n\t\t\t   const void *nonce, size_t nonce_len);\nint gnutls_hmac(gnutls_hmac_hd_t handle, const void *text, size_t textlen);\nvoid gnutls_hmac_output(gnutls_hmac_hd_t handle, void *digest);\nvoid gnutls_hmac_deinit(gnutls_hmac_hd_t handle, void *digest);\nunsigned gnutls_hmac_get_len(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\nunsigned gnutls_hmac_get_key_size(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\nint gnutls_hmac_fast(gnutls_mac_algorithm_t algorithm,\n\t\t     const void *key, size_t keylen,\n\t\t     const void *text, size_t textlen, void *digest);\ngnutls_hmac_hd_t gnutls_hmac_copy(gnutls_hmac_hd_t handle);\n\nint gnutls_hash_init(gnutls_hash_hd_t * dig,\n\t\t     gnutls_digest_algorithm_t algorithm);\nint gnutls_hash(gnutls_hash_hd_t handle, const void *text, size_t textlen);\nvoid gnutls_hash_output(gnutls_hash_hd_t handle, void *digest);\nvoid gnutls_hash_deinit(gnutls_hash_hd_t handle, void *digest);\nunsigned gnutls_hash_get_len(gnutls_digest_algorithm_t algorithm) __GNUTLS_CONST__;\nint gnutls_hash_fast(gnutls_digest_algorithm_t algorithm,\n\t\t     const void *text, size_t textlen, void *digest);\ngnutls_hash_hd_t gnutls_hash_copy(gnutls_hash_hd_t handle);\n\n/* KDF API */\n\nint gnutls_hkdf_extract(gnutls_mac_algorithm_t mac,\n\t\t\tconst gnutls_datum_t *key,\n\t\t\tconst gnutls_datum_t *salt,\n\t\t\tvoid *output);\n\nint gnutls_hkdf_expand(gnutls_mac_algorithm_t mac,\n\t\t       const gnutls_datum_t *key,\n\t\t       const gnutls_datum_t *info,\n\t\t       void *output, size_t length);\n\nint gnutls_pbkdf2(gnutls_mac_algorithm_t mac,\n\t\t  const gnutls_datum_t *key,\n\t\t  const gnutls_datum_t *salt,\n\t\t  unsigned iter_count,\n\t\t  void *output, size_t length);\n\n/* register ciphers */\n\n\n/**\n * gnutls_rnd_level_t:\n * @GNUTLS_RND_NONCE: Non-predictable random number.  Fatal in parts\n *   of session if broken, i.e., vulnerable to statistical analysis.\n * @GNUTLS_RND_RANDOM: Pseudo-random cryptographic random number.\n *   Fatal in session if broken. Example use: temporal keys.\n * @GNUTLS_RND_KEY: Fatal in many sessions if broken. Example use:\n *   Long-term keys.\n *\n * Enumeration of random quality levels.\n */\ntypedef enum gnutls_rnd_level {\n\tGNUTLS_RND_NONCE = 0,\n\tGNUTLS_RND_RANDOM = 1,\n\tGNUTLS_RND_KEY = 2\n} gnutls_rnd_level_t;\n\nint gnutls_rnd(gnutls_rnd_level_t level, void *data, size_t len);\n\nvoid gnutls_rnd_refresh(void);\n\n\n/* API to override ciphers and MAC algorithms \n */\n\ntypedef int (*gnutls_cipher_init_func) (gnutls_cipher_algorithm_t, void **ctx, int enc);\ntypedef int (*gnutls_cipher_setkey_func) (void *ctx, const void *key, size_t keysize);\n/* old style ciphers */\ntypedef int (*gnutls_cipher_setiv_func) (void *ctx, const void *iv, size_t ivsize);\ntypedef int (*gnutls_cipher_getiv_func) (void *ctx, void *iv, size_t ivsize);\ntypedef int (*gnutls_cipher_encrypt_func) (void *ctx, const void *plain, size_t plainsize,\n\t\t\t\tvoid *encr, size_t encrsize);\ntypedef int (*gnutls_cipher_decrypt_func) (void *ctx, const void *encr, size_t encrsize,\n\t\t\tvoid *plain, size_t plainsize);\n\n/* aead ciphers */\ntypedef int (*gnutls_cipher_auth_func) (void *ctx, const void *data, size_t datasize);\ntypedef void (*gnutls_cipher_tag_func) (void *ctx, void *tag, size_t tagsize);\n\ntypedef int (*gnutls_cipher_aead_encrypt_func) (void *ctx,\n\t\t\tconst void *nonce, size_t noncesize,\n\t\t\tconst void *auth, size_t authsize,\n\t\t\tsize_t tag_size,\n\t\t\tconst void *plain, size_t plainsize,\n\t\t\tvoid *encr, size_t encrsize);\ntypedef int (*gnutls_cipher_aead_decrypt_func) (void *ctx,\n\t\t\tconst void *nonce, size_t noncesize,\n\t\t\tconst void *auth, size_t authsize,\n\t\t\tsize_t tag_size,\n\t\t\tconst void *encr, size_t encrsize,\n\t\t\tvoid *plain, size_t plainsize);\ntypedef void (*gnutls_cipher_deinit_func) (void *ctx);\n\nint\ngnutls_crypto_register_cipher(gnutls_cipher_algorithm_t algorithm,\n\t\t\t      int priority,\n\t\t\t      gnutls_cipher_init_func init,\n\t\t\t      gnutls_cipher_setkey_func setkey,\n\t\t\t      gnutls_cipher_setiv_func setiv,\n\t\t\t      gnutls_cipher_encrypt_func encrypt,\n\t\t\t      gnutls_cipher_decrypt_func decrypt,\n\t\t\t      gnutls_cipher_deinit_func deinit)\n\t\t\t      _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint\ngnutls_crypto_register_aead_cipher(gnutls_cipher_algorithm_t algorithm,\n\t\t\t      int priority,\n\t\t\t      gnutls_cipher_init_func init,\n\t\t\t      gnutls_cipher_setkey_func setkey,\n\t\t\t      gnutls_cipher_aead_encrypt_func aead_encrypt,\n\t\t\t      gnutls_cipher_aead_decrypt_func aead_decrypt,\n\t\t\t      gnutls_cipher_deinit_func deinit)\n\t\t\t      _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntypedef int (*gnutls_mac_init_func) (gnutls_mac_algorithm_t, void **ctx);\ntypedef int (*gnutls_mac_setkey_func) (void *ctx, const void *key, size_t keysize);\ntypedef int (*gnutls_mac_setnonce_func) (void *ctx, const void *nonce, size_t noncesize);\ntypedef int (*gnutls_mac_hash_func) (void *ctx, const void *text, size_t textsize);\ntypedef int (*gnutls_mac_output_func) (void *src_ctx, void *digest, size_t digestsize);\ntypedef void (*gnutls_mac_deinit_func) (void *ctx);\ntypedef int (*gnutls_mac_fast_func) (gnutls_mac_algorithm_t, const void *nonce,\n\t\t     size_t nonce_size, const void *key, size_t keysize,\n\t\t     const void *text, size_t textsize, void *digest);\ntypedef void *(*gnutls_mac_copy_func) (const void *ctx);\n\nint\ngnutls_crypto_register_mac(gnutls_mac_algorithm_t mac,\n\t\t\t   int priority,\n\t\t\t   gnutls_mac_init_func init,\n\t\t\t   gnutls_mac_setkey_func setkey,\n\t\t\t   gnutls_mac_setnonce_func setnonce,\n\t\t\t   gnutls_mac_hash_func hash,\n\t\t\t   gnutls_mac_output_func output,\n\t\t\t   gnutls_mac_deinit_func deinit,\n\t\t\t   gnutls_mac_fast_func hash_fast)\n\t\t\t   _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntypedef int (*gnutls_digest_init_func) (gnutls_digest_algorithm_t, void **ctx);\ntypedef int (*gnutls_digest_hash_func) (void *ctx, const void *text, size_t textsize);\ntypedef int (*gnutls_digest_output_func) (void *src_ctx, void *digest, size_t digestsize);\ntypedef void (*gnutls_digest_deinit_func) (void *ctx);\ntypedef int (*gnutls_digest_fast_func) (gnutls_digest_algorithm_t,\n\t\t     const void *text, size_t textsize, void *digest);\ntypedef void *(*gnutls_digest_copy_func) (const void *ctx);\n\nint\ngnutls_crypto_register_digest(gnutls_digest_algorithm_t digest,\n\t\t\t   int priority,\n\t\t\t   gnutls_digest_init_func init,\n\t\t\t   gnutls_digest_hash_func hash,\n\t\t\t   gnutls_digest_output_func output,\n\t\t\t   gnutls_digest_deinit_func deinit,\n\t\t\t   gnutls_digest_fast_func hash_fast)\n\t\t\t   _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* RSA-PKCS#1 1.5 helper functions */\nint\ngnutls_encode_ber_digest_info(gnutls_digest_algorithm_t hash,\n\t\t\t      const gnutls_datum_t * digest,\n\t\t\t      gnutls_datum_t * output);\n\nint\ngnutls_decode_ber_digest_info(const gnutls_datum_t * info,\n\t\t\t      gnutls_digest_algorithm_t *hash,\n\t\t\t      unsigned char *digest, unsigned int *digest_size);\n\nint gnutls_decode_rs_value(const gnutls_datum_t * sig_value, gnutls_datum_t *r, gnutls_datum_t *s);\nint gnutls_encode_rs_value(gnutls_datum_t * sig_value, const gnutls_datum_t * r, const gnutls_datum_t * s);\n\nint gnutls_encode_gost_rs_value(gnutls_datum_t * sig_value, const gnutls_datum_t * r, const gnutls_datum_t  *s);\nint gnutls_decode_gost_rs_value(const gnutls_datum_t * sig_value, gnutls_datum_t * r, gnutls_datum_t * s);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_CRYPTO_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/dtls.h",
    "content": "/*\n * Copyright (C) 2011-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for the X.509\n * certificate and CRL handling functions.\n */\n\n#ifndef GNUTLS_DTLS_H\n#define GNUTLS_DTLS_H\n\n#include <gnutls/gnutls.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#define GNUTLS_COOKIE_KEY_SIZE 16\n\nvoid gnutls_dtls_set_timeouts(gnutls_session_t session,\n\t\t\t      unsigned int retrans_timeout,\n\t\t\t      unsigned int total_timeout);\n\nunsigned int gnutls_dtls_get_mtu(gnutls_session_t session);\nunsigned int gnutls_dtls_get_data_mtu(gnutls_session_t session);\n\nvoid gnutls_dtls_set_mtu(gnutls_session_t session, unsigned int mtu);\nint gnutls_dtls_set_data_mtu(gnutls_session_t session, unsigned int mtu);\n\nunsigned int gnutls_dtls_get_timeout(gnutls_session_t session);\n\n/**\n * gnutls_dtls_prestate_st:\n * @record_seq: record sequence number\n * @hsk_read_seq: handshake read sequence number\n * @hsk_write_seq: handshake write sequence number\n *\n * DTLS cookie prestate struct.  This is usually never modified by\n * the application, it is used to carry the cookie data between\n * gnutls_dtls_cookie_send(), gnutls_dtls_cookie_verify() and\n * gnutls_dtls_prestate_set().\n */\ntypedef struct {\n\tunsigned int record_seq;\n\tunsigned int hsk_read_seq;\n\tunsigned int hsk_write_seq;\n} gnutls_dtls_prestate_st;\n\nint gnutls_dtls_cookie_send(gnutls_datum_t * key,\n\t\t\t    void *client_data,\n\t\t\t    size_t client_data_size,\n\t\t\t    gnutls_dtls_prestate_st * prestate,\n\t\t\t    gnutls_transport_ptr_t ptr,\n\t\t\t    gnutls_push_func push_func);\n\nint gnutls_dtls_cookie_verify(gnutls_datum_t * key,\n\t\t\t      void *client_data,\n\t\t\t      size_t client_data_size, void *_msg,\n\t\t\t      size_t msg_size,\n\t\t\t      gnutls_dtls_prestate_st * prestate);\n\nvoid gnutls_dtls_prestate_set(gnutls_session_t session,\n\t\t\t      gnutls_dtls_prestate_st * prestate);\n\nunsigned int gnutls_record_get_discarded(gnutls_session_t session);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_DTLS_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/gnutls.h",
    "content": "/* -*- c -*-\n * Copyright (C) 2000-2016 Free Software Foundation, Inc.\n * Copyright (C) 2015-2017 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for all the\n * high level functionality of the gnutls main library.\n *\n * If the optional C++ binding was built, it is available in\n * gnutls/gnutlsxx.h.\n *\n * The openssl compatibility layer (which is under the GNU GPL\n * license) is in gnutls/openssl.h.\n *\n * The low level cipher functionality is in gnutls/crypto.h.\n */\n\n#ifndef GNUTLS_GNUTLS_H\n#define GNUTLS_GNUTLS_H\n\n/* Get ssize_t. */\n#include <sys/types.h>\n\n/* Get size_t. */\n#include <stddef.h>\n\n/* Get time_t. */\n#include <time.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#define GNUTLS_VERSION \"3.7.10\"\n\n#define GNUTLS_VERSION_MAJOR 3\n#define GNUTLS_VERSION_MINOR 7\n#define GNUTLS_VERSION_PATCH 10\n\n#define GNUTLS_VERSION_NUMBER 0x03070a\n\n#define GNUTLS_CIPHER_RIJNDAEL_128_CBC GNUTLS_CIPHER_AES_128_CBC\n#define GNUTLS_CIPHER_RIJNDAEL_256_CBC GNUTLS_CIPHER_AES_256_CBC\n#define GNUTLS_CIPHER_RIJNDAEL_CBC GNUTLS_CIPHER_AES_128_CBC\n#define GNUTLS_CIPHER_ARCFOUR GNUTLS_CIPHER_ARCFOUR_128\n\n#if !defined(GNUTLS_INTERNAL_BUILD) && defined(_WIN32)\n# define _SYM_EXPORT __declspec(dllimport)\n#else\n# define _SYM_EXPORT\n#endif\n\n#ifdef __GNUC__\n# define __GNUTLS_CONST__  __attribute__((const))\n# define __GNUTLS_PURE__  __attribute__((pure))\n#else\n# define __GNUTLS_CONST__\n# define __GNUTLS_PURE__\n#endif\n\n\n/* Use the following definition globally in your program to disable\n * implicit initialization of gnutls. */\n#define GNUTLS_SKIP_GLOBAL_INIT int _gnutls_global_init_skip(void); \\\n    int _gnutls_global_init_skip(void) {return 1;}\n\n/**\n * gnutls_cipher_algorithm_t:\n * @GNUTLS_CIPHER_UNKNOWN: Value to identify an unknown/unsupported algorithm.\n * @GNUTLS_CIPHER_NULL: The NULL (identity) encryption algorithm.\n * @GNUTLS_CIPHER_ARCFOUR_128: ARCFOUR stream cipher with 128-bit keys.\n * @GNUTLS_CIPHER_3DES_CBC: 3DES in CBC mode.\n * @GNUTLS_CIPHER_AES_128_CBC: AES in CBC mode with 128-bit keys.\n * @GNUTLS_CIPHER_AES_192_CBC: AES in CBC mode with 192-bit keys.\n * @GNUTLS_CIPHER_AES_256_CBC: AES in CBC mode with 256-bit keys.\n * @GNUTLS_CIPHER_AES_128_CFB8: AES in CFB8 mode with 128-bit keys.\n * @GNUTLS_CIPHER_AES_192_CFB8: AES in CFB8 mode with 192-bit keys.\n * @GNUTLS_CIPHER_AES_256_CFB8: AES in CFB8 mode with 256-bit keys.\n * @GNUTLS_CIPHER_ARCFOUR_40: ARCFOUR stream cipher with 40-bit keys.\n * @GNUTLS_CIPHER_CAMELLIA_128_CBC: Camellia in CBC mode with 128-bit keys.\n * @GNUTLS_CIPHER_CAMELLIA_192_CBC: Camellia in CBC mode with 192-bit keys.\n * @GNUTLS_CIPHER_CAMELLIA_256_CBC: Camellia in CBC mode with 256-bit keys.\n * @GNUTLS_CIPHER_RC2_40_CBC: RC2 in CBC mode with 40-bit keys.\n * @GNUTLS_CIPHER_DES_CBC: DES in CBC mode (56-bit keys).\n * @GNUTLS_CIPHER_AES_128_GCM: AES in GCM mode with 128-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_256_GCM: AES in GCM mode with 256-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_128_CCM: AES in CCM mode with 128-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_256_CCM: AES in CCM mode with 256-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_128_CCM_8: AES in CCM mode with 64-bit tag and 128-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_256_CCM_8: AES in CCM mode with 64-bit tag and 256-bit keys (AEAD).\n * @GNUTLS_CIPHER_CAMELLIA_128_GCM: CAMELLIA in GCM mode with 128-bit keys (AEAD).\n * @GNUTLS_CIPHER_CAMELLIA_256_GCM: CAMELLIA in GCM mode with 256-bit keys (AEAD).\n * @GNUTLS_CIPHER_SALSA20_256: Salsa20 with 256-bit keys.\n * @GNUTLS_CIPHER_ESTREAM_SALSA20_256: Estream's Salsa20 variant with 256-bit keys.\n * @GNUTLS_CIPHER_CHACHA20_32: Chacha20 cipher with 96-bit nonces and 32-bit block counters.\n * @GNUTLS_CIPHER_CHACHA20_64: Chacha20 cipher with 64-bit nonces and 64-bit block counters.\n * @GNUTLS_CIPHER_CHACHA20_POLY1305: The Chacha20 cipher with the Poly1305 authenticator (AEAD).\n * @GNUTLS_CIPHER_GOST28147_TC26Z_CFB: GOST 28147-89 (Magma) cipher in CFB mode with TC26 Z S-box.\n * @GNUTLS_CIPHER_GOST28147_CPA_CFB: GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro A S-box.\n * @GNUTLS_CIPHER_GOST28147_CPB_CFB: GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro B S-box.\n * @GNUTLS_CIPHER_GOST28147_CPC_CFB: GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro C S-box.\n * @GNUTLS_CIPHER_GOST28147_CPD_CFB: GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro D S-box.\n * @GNUTLS_CIPHER_AES_128_XTS: AES in XTS mode with 128-bit key + 128bit tweak key.\n * @GNUTLS_CIPHER_AES_256_XTS: AES in XTS mode with 256-bit key + 256bit tweak key.\n *                             Note that the XTS ciphers are message oriented.\n *                             The whole message needs to be provided with a single call, because\n *                             cipher-stealing requires to know where the message actually terminates\n *                             in order to be able to compute where the stealing occurs.\n * @GNUTLS_CIPHER_GOST28147_TC26Z_CNT: GOST 28147-89 (Magma) cipher in CNT mode with TC26 Z S-box.\n * @GNUTLS_CIPHER_MAGMA_CTR_ACPKM: GOST R 34.12-2015 (Magma) cipher in CTR-ACPKM mode.\n * @GNUTLS_CIPHER_KUZNYECHIK_CTR_ACPKM: GOST R 34.12-2015 (Kuznyechik) cipher in CTR-ACPKM mode.\n * @GNUTLS_CIPHER_IDEA_PGP_CFB: IDEA in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_3DES_PGP_CFB: 3DES in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_CAST5_PGP_CFB: CAST5 in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_BLOWFISH_PGP_CFB: Blowfish in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_SAFER_SK128_PGP_CFB: Safer-SK in CFB mode with 128-bit keys (placeholder - unsupported).\n * @GNUTLS_CIPHER_AES128_PGP_CFB: AES in CFB mode with 128-bit keys (placeholder - unsupported).\n * @GNUTLS_CIPHER_AES192_PGP_CFB: AES in CFB mode with 192-bit keys (placeholder - unsupported).\n * @GNUTLS_CIPHER_AES256_PGP_CFB: AES in CFB mode with 256-bit keys (placeholder - unsupported).\n * @GNUTLS_CIPHER_TWOFISH_PGP_CFB: Twofish in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_AES_128_SIV: AES in SIV mode with 128-bit key.\n * @GNUTLS_CIPHER_AES_256_SIV: AES in SIV mode with 256-bit key.\n *                             Note that the SIV ciphers can only be used with\n *                             the AEAD interface, and the IV plays a role as\n *                             the authentication tag while it is prepended to\n *                             the cipher text.\n * @GNUTLS_CIPHER_AES_192_GCM: AES in GCM mode with 192-bit keys (AEAD).\n *\n * Enumeration of different symmetric encryption algorithms.\n */\ntypedef enum gnutls_cipher_algorithm {\n\tGNUTLS_CIPHER_UNKNOWN = 0,\n\tGNUTLS_CIPHER_NULL = 1,\n\tGNUTLS_CIPHER_ARCFOUR_128 = 2,\n\tGNUTLS_CIPHER_3DES_CBC = 3,\n\tGNUTLS_CIPHER_AES_128_CBC = 4,\n\tGNUTLS_CIPHER_AES_256_CBC = 5,\n\tGNUTLS_CIPHER_ARCFOUR_40 = 6,\n\tGNUTLS_CIPHER_CAMELLIA_128_CBC = 7,\n\tGNUTLS_CIPHER_CAMELLIA_256_CBC = 8,\n\tGNUTLS_CIPHER_AES_192_CBC = 9,\n\tGNUTLS_CIPHER_AES_128_GCM = 10,\n\tGNUTLS_CIPHER_AES_256_GCM = 11,\n\tGNUTLS_CIPHER_CAMELLIA_192_CBC = 12,\n\tGNUTLS_CIPHER_SALSA20_256 = 13,\n\tGNUTLS_CIPHER_ESTREAM_SALSA20_256 = 14,\n\tGNUTLS_CIPHER_CAMELLIA_128_GCM = 15,\n\tGNUTLS_CIPHER_CAMELLIA_256_GCM = 16,\n\tGNUTLS_CIPHER_RC2_40_CBC = 17,\n\tGNUTLS_CIPHER_DES_CBC = 18,\n\tGNUTLS_CIPHER_AES_128_CCM = 19,\n\tGNUTLS_CIPHER_AES_256_CCM = 20,\n\tGNUTLS_CIPHER_AES_128_CCM_8 = 21,\n\tGNUTLS_CIPHER_AES_256_CCM_8 = 22,\n\tGNUTLS_CIPHER_CHACHA20_POLY1305 = 23,\n\tGNUTLS_CIPHER_GOST28147_TC26Z_CFB = 24,\n\tGNUTLS_CIPHER_GOST28147_CPA_CFB = 25,\n\tGNUTLS_CIPHER_GOST28147_CPB_CFB = 26,\n\tGNUTLS_CIPHER_GOST28147_CPC_CFB = 27,\n\tGNUTLS_CIPHER_GOST28147_CPD_CFB = 28,\n\tGNUTLS_CIPHER_AES_128_CFB8 = 29,\n\tGNUTLS_CIPHER_AES_192_CFB8 = 30,\n\tGNUTLS_CIPHER_AES_256_CFB8 = 31,\n\tGNUTLS_CIPHER_AES_128_XTS = 32,\n\tGNUTLS_CIPHER_AES_256_XTS = 33,\n\tGNUTLS_CIPHER_GOST28147_TC26Z_CNT = 34,\n\tGNUTLS_CIPHER_CHACHA20_64 = 35,\n\tGNUTLS_CIPHER_CHACHA20_32 = 36,\n\tGNUTLS_CIPHER_AES_128_SIV = 37,\n\tGNUTLS_CIPHER_AES_256_SIV = 38,\n\tGNUTLS_CIPHER_AES_192_GCM = 39,\n\tGNUTLS_CIPHER_MAGMA_CTR_ACPKM = 40,\n\tGNUTLS_CIPHER_KUZNYECHIK_CTR_ACPKM = 41,\n\n\t/* used only for PGP internals. Ignored in TLS/SSL\n\t */\n\tGNUTLS_CIPHER_IDEA_PGP_CFB = 200,\n\tGNUTLS_CIPHER_3DES_PGP_CFB = 201,\n\tGNUTLS_CIPHER_CAST5_PGP_CFB = 202,\n\tGNUTLS_CIPHER_BLOWFISH_PGP_CFB = 203,\n\tGNUTLS_CIPHER_SAFER_SK128_PGP_CFB = 204,\n\tGNUTLS_CIPHER_AES128_PGP_CFB = 205,\n\tGNUTLS_CIPHER_AES192_PGP_CFB = 206,\n\tGNUTLS_CIPHER_AES256_PGP_CFB = 207,\n\tGNUTLS_CIPHER_TWOFISH_PGP_CFB = 208\n} gnutls_cipher_algorithm_t;\n\n/**\n * gnutls_kx_algorithm_t:\n * @GNUTLS_KX_UNKNOWN: Unknown key-exchange algorithm.\n * @GNUTLS_KX_RSA: RSA key-exchange algorithm.\n * @GNUTLS_KX_DHE_DSS: DHE-DSS key-exchange algorithm.\n * @GNUTLS_KX_DHE_RSA: DHE-RSA key-exchange algorithm.\n * @GNUTLS_KX_ECDHE_RSA: ECDHE-RSA key-exchange algorithm.\n * @GNUTLS_KX_ECDHE_ECDSA: ECDHE-ECDSA key-exchange algorithm.\n * @GNUTLS_KX_ANON_DH: Anon-DH key-exchange algorithm.\n * @GNUTLS_KX_ANON_ECDH: Anon-ECDH key-exchange algorithm.\n * @GNUTLS_KX_SRP: SRP key-exchange algorithm.\n * @GNUTLS_KX_RSA_EXPORT: RSA-EXPORT key-exchange algorithm (defunc).\n * @GNUTLS_KX_SRP_RSA: SRP-RSA key-exchange algorithm.\n * @GNUTLS_KX_SRP_DSS: SRP-DSS key-exchange algorithm.\n * @GNUTLS_KX_PSK: PSK key-exchange algorithm.\n * @GNUTLS_KX_DHE_PSK: DHE-PSK key-exchange algorithm.\n * @GNUTLS_KX_ECDHE_PSK: ECDHE-PSK key-exchange algorithm.\n * @GNUTLS_KX_RSA_PSK: RSA-PSK key-exchange algorithm.\n * @GNUTLS_KX_VKO_GOST_12: VKO GOST R 34.10-2012 key-exchange algorithm.\n *\n * Enumeration of different key exchange algorithms.\n */\ntypedef enum {\n\tGNUTLS_KX_UNKNOWN = 0,\n\tGNUTLS_KX_RSA = 1,\n\tGNUTLS_KX_DHE_DSS = 2,\n\tGNUTLS_KX_DHE_RSA = 3,\n\tGNUTLS_KX_ANON_DH = 4,\n\tGNUTLS_KX_SRP = 5,\n\tGNUTLS_KX_RSA_EXPORT = 6,\n\tGNUTLS_KX_SRP_RSA = 7,\n\tGNUTLS_KX_SRP_DSS = 8,\n\tGNUTLS_KX_PSK = 9,\n\tGNUTLS_KX_DHE_PSK = 10,\n\tGNUTLS_KX_ANON_ECDH = 11,\n\tGNUTLS_KX_ECDHE_RSA = 12,\n\tGNUTLS_KX_ECDHE_ECDSA = 13,\n\tGNUTLS_KX_ECDHE_PSK = 14,\n\tGNUTLS_KX_RSA_PSK = 15,\n\tGNUTLS_KX_VKO_GOST_12 = 16\n} gnutls_kx_algorithm_t;\n\n/**\n * gnutls_params_type_t:\n * @GNUTLS_PARAMS_RSA_EXPORT: Session RSA-EXPORT parameters (defunc).\n * @GNUTLS_PARAMS_DH: Session Diffie-Hellman parameters.\n * @GNUTLS_PARAMS_ECDH: Session Elliptic-Curve Diffie-Hellman parameters.\n *\n * Enumeration of different TLS session parameter types.\n */\ntypedef enum {\n\tGNUTLS_PARAMS_RSA_EXPORT = 1,\n\tGNUTLS_PARAMS_DH = 2,\n\tGNUTLS_PARAMS_ECDH = 3\n} gnutls_params_type_t;\n\n/**\n * gnutls_credentials_type_t:\n * @GNUTLS_CRD_CERTIFICATE: Certificate credential.\n * @GNUTLS_CRD_ANON: Anonymous credential.\n * @GNUTLS_CRD_SRP: SRP credential.\n * @GNUTLS_CRD_PSK: PSK credential.\n * @GNUTLS_CRD_IA: IA credential.\n *\n * Enumeration of different credential types.\n */\ntypedef enum {\n\tGNUTLS_CRD_CERTIFICATE = 1,\n\tGNUTLS_CRD_ANON,\n\tGNUTLS_CRD_SRP,\n\tGNUTLS_CRD_PSK,\n\tGNUTLS_CRD_IA\n} gnutls_credentials_type_t;\n\n#define GNUTLS_MAC_SHA GNUTLS_MAC_SHA1\n#define GNUTLS_DIG_SHA GNUTLS_DIG_SHA1\n\n/**\n * gnutls_mac_algorithm_t:\n * @GNUTLS_MAC_UNKNOWN: Unknown MAC algorithm.\n * @GNUTLS_MAC_NULL: NULL MAC algorithm (empty output).\n * @GNUTLS_MAC_MD5: HMAC-MD5 algorithm.\n * @GNUTLS_MAC_SHA1: HMAC-SHA-1 algorithm.\n * @GNUTLS_MAC_RMD160: HMAC-RMD160 algorithm.\n * @GNUTLS_MAC_MD2: HMAC-MD2 algorithm.\n * @GNUTLS_MAC_SHA256: HMAC-SHA-256 algorithm.\n * @GNUTLS_MAC_SHA384: HMAC-SHA-384 algorithm.\n * @GNUTLS_MAC_SHA512: HMAC-SHA-512 algorithm.\n * @GNUTLS_MAC_SHA224: HMAC-SHA-224 algorithm.\n * @GNUTLS_MAC_MD5_SHA1: Combined MD5+SHA1 MAC placeholder.\n * @GNUTLS_MAC_GOSTR_94: HMAC GOST R 34.11-94 algorithm.\n * @GNUTLS_MAC_STREEBOG_256: HMAC GOST R 34.11-2001 (Streebog) algorithm, 256 bit.\n * @GNUTLS_MAC_STREEBOG_512: HMAC GOST R 34.11-2001 (Streebog) algorithm, 512 bit.\n * @GNUTLS_MAC_AEAD: MAC implicit through AEAD cipher.\n * @GNUTLS_MAC_UMAC_96: The UMAC-96 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_UMAC_128: The UMAC-128 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_AES_CMAC_128: The AES-CMAC-128 MAC algorithm.\n * @GNUTLS_MAC_AES_CMAC_256: The AES-CMAC-256 MAC algorithm.\n * @GNUTLS_MAC_AES_GMAC_128: The AES-GMAC-128 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_AES_GMAC_192: The AES-GMAC-192 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_AES_GMAC_256: The AES-GMAC-256 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_SHA3_224: Reserved; unimplemented.\n * @GNUTLS_MAC_SHA3_256: Reserved; unimplemented.\n * @GNUTLS_MAC_SHA3_384: Reserved; unimplemented.\n * @GNUTLS_MAC_SHA3_512: Reserved; unimplemented.\n * @GNUTLS_MAC_GOST28147_TC26Z_IMIT: The GOST 28147-89 working in IMIT mode with TC26 Z S-box.\n * @GNUTLS_MAC_SHAKE_128: Reserved; unimplemented.\n * @GNUTLS_MAC_SHAKE_256: Reserved; unimplemented.\n * @GNUTLS_MAC_MAGMA_OMAC: GOST R 34.12-2015 (Magma) in OMAC (CMAC) mode.\n * @GNUTLS_MAC_KUZNYECHIK_OMAC: GOST R 34.12-2015 (Kuznyechik) in OMAC (CMAC) mode.\n *\n * Enumeration of different Message Authentication Code (MAC)\n * algorithms.\n */\ntypedef enum {\n\tGNUTLS_MAC_UNKNOWN = 0,\n\tGNUTLS_MAC_NULL = 1,\n\tGNUTLS_MAC_MD5 = 2,\n\tGNUTLS_MAC_SHA1 = 3,\n\tGNUTLS_MAC_RMD160 = 4,\n\tGNUTLS_MAC_MD2 = 5,\n\tGNUTLS_MAC_SHA256 = 6,\n\tGNUTLS_MAC_SHA384 = 7,\n\tGNUTLS_MAC_SHA512 = 8,\n\tGNUTLS_MAC_SHA224 = 9,\n\tGNUTLS_MAC_SHA3_224 = 10, /* reserved: no implementation */\n\tGNUTLS_MAC_SHA3_256 = 11, /* reserved: no implementation */\n\tGNUTLS_MAC_SHA3_384 = 12, /* reserved: no implementation */\n\tGNUTLS_MAC_SHA3_512 = 13, /* reserved: no implementation */\n\tGNUTLS_MAC_MD5_SHA1 = 14, /* reserved: no implementation */\n\tGNUTLS_MAC_GOSTR_94 = 15,\n\tGNUTLS_MAC_STREEBOG_256 = 16,\n\tGNUTLS_MAC_STREEBOG_512 = 17,\n\t/* If you add anything here, make sure you align with\n\t   gnutls_digest_algorithm_t. */\n\tGNUTLS_MAC_AEAD = 200,\t/* indicates that MAC is on the cipher */\n\tGNUTLS_MAC_UMAC_96 = 201,\n\tGNUTLS_MAC_UMAC_128 = 202,\n\tGNUTLS_MAC_AES_CMAC_128 = 203,\n\tGNUTLS_MAC_AES_CMAC_256 = 204,\n\tGNUTLS_MAC_AES_GMAC_128 = 205,\n\tGNUTLS_MAC_AES_GMAC_192 = 206,\n\tGNUTLS_MAC_AES_GMAC_256 = 207,\n\tGNUTLS_MAC_GOST28147_TC26Z_IMIT = 208,\n\tGNUTLS_MAC_SHAKE_128 = 209,\n\tGNUTLS_MAC_SHAKE_256 = 210,\n\tGNUTLS_MAC_MAGMA_OMAC = 211,\n\tGNUTLS_MAC_KUZNYECHIK_OMAC = 212\n} gnutls_mac_algorithm_t;\n\n/**\n * gnutls_digest_algorithm_t:\n * @GNUTLS_DIG_UNKNOWN: Unknown hash algorithm.\n * @GNUTLS_DIG_NULL: NULL hash algorithm (empty output).\n * @GNUTLS_DIG_MD5: MD5 algorithm.\n * @GNUTLS_DIG_SHA1: SHA-1 algorithm.\n * @GNUTLS_DIG_RMD160: RMD160 algorithm.\n * @GNUTLS_DIG_MD2: MD2 algorithm.\n * @GNUTLS_DIG_SHA256: SHA-256 algorithm.\n * @GNUTLS_DIG_SHA384: SHA-384 algorithm.\n * @GNUTLS_DIG_SHA512: SHA-512 algorithm.\n * @GNUTLS_DIG_SHA224: SHA-224 algorithm.\n * @GNUTLS_DIG_SHA3_224: SHA3-224 algorithm.\n * @GNUTLS_DIG_SHA3_256: SHA3-256 algorithm.\n * @GNUTLS_DIG_SHA3_384: SHA3-384 algorithm.\n * @GNUTLS_DIG_SHA3_512: SHA3-512 algorithm.\n * @GNUTLS_DIG_MD5_SHA1: Combined MD5+SHA1 algorithm.\n * @GNUTLS_DIG_GOSTR_94: GOST R 34.11-94 algorithm.\n * @GNUTLS_DIG_STREEBOG_256: GOST R 34.11-2001 (Streebog) algorithm, 256 bit.\n * @GNUTLS_DIG_STREEBOG_512: GOST R 34.11-2001 (Streebog) algorithm, 512 bit.\n * @GNUTLS_DIG_SHAKE_128: Reserved; unimplemented.\n * @GNUTLS_DIG_SHAKE_256: Reserved; unimplemented.\n *\n * Enumeration of different digest (hash) algorithms.\n */\ntypedef enum {\n\tGNUTLS_DIG_UNKNOWN = GNUTLS_MAC_UNKNOWN,\n\tGNUTLS_DIG_NULL = GNUTLS_MAC_NULL,\n\tGNUTLS_DIG_MD5 = GNUTLS_MAC_MD5,\n\tGNUTLS_DIG_SHA1 = GNUTLS_MAC_SHA1,\n\tGNUTLS_DIG_RMD160 = GNUTLS_MAC_RMD160,\n\tGNUTLS_DIG_MD2 = GNUTLS_MAC_MD2,\n\tGNUTLS_DIG_SHA256 = GNUTLS_MAC_SHA256,\n\tGNUTLS_DIG_SHA384 = GNUTLS_MAC_SHA384,\n\tGNUTLS_DIG_SHA512 = GNUTLS_MAC_SHA512,\n\tGNUTLS_DIG_SHA224 = GNUTLS_MAC_SHA224,\n\tGNUTLS_DIG_SHA3_224 = GNUTLS_MAC_SHA3_224,\n\tGNUTLS_DIG_SHA3_256 = GNUTLS_MAC_SHA3_256,\n\tGNUTLS_DIG_SHA3_384 = GNUTLS_MAC_SHA3_384,\n\tGNUTLS_DIG_SHA3_512 = GNUTLS_MAC_SHA3_512,\n\tGNUTLS_DIG_MD5_SHA1 = GNUTLS_MAC_MD5_SHA1,\n\tGNUTLS_DIG_GOSTR_94 = GNUTLS_MAC_GOSTR_94,\n\tGNUTLS_DIG_STREEBOG_256 = GNUTLS_MAC_STREEBOG_256,\n\tGNUTLS_DIG_STREEBOG_512 = GNUTLS_MAC_STREEBOG_512,\n\tGNUTLS_DIG_SHAKE_128 = GNUTLS_MAC_SHAKE_128,\n\tGNUTLS_DIG_SHAKE_256 = GNUTLS_MAC_SHAKE_256\n\t    /* If you add anything here, make sure you align with\n\t       gnutls_mac_algorithm_t. */\n} gnutls_digest_algorithm_t;\n\n  /* exported for other gnutls headers. This is the maximum number of\n   * algorithms (ciphers, kx or macs).\n   */\n#define GNUTLS_MAX_ALGORITHM_NUM 128\n#define GNUTLS_MAX_SESSION_ID_SIZE 32\n\n\n/**\n * gnutls_compression_method_t:\n * @GNUTLS_COMP_UNKNOWN: Unknown compression method.\n * @GNUTLS_COMP_NULL: The NULL compression method (no compression).\n * @GNUTLS_COMP_DEFLATE: The DEFLATE compression method from zlib.\n * @GNUTLS_COMP_ZLIB: Same as %GNUTLS_COMP_DEFLATE.\n * @GNUTLS_COMP_BROTLI: Brotli compression method.\n * @GNUTLS_COMP_ZSTD: Zstandard compression method.\n *\n * Enumeration of different TLS compression methods.\n */\ntypedef enum {\n\tGNUTLS_COMP_UNKNOWN = 0,\n\tGNUTLS_COMP_NULL = 1,\n\tGNUTLS_COMP_DEFLATE = 2,\n\tGNUTLS_COMP_ZLIB = GNUTLS_COMP_DEFLATE,\n\tGNUTLS_COMP_BROTLI = 3,\n\tGNUTLS_COMP_ZSTD = 4\n} gnutls_compression_method_t;\n\n\n/**\n * gnutls_init_flags_t:\n *\n * @GNUTLS_SERVER: Connection end is a server.\n * @GNUTLS_CLIENT: Connection end is a client.\n * @GNUTLS_DATAGRAM: Connection is datagram oriented (DTLS). Since 3.0.0.\n * @GNUTLS_NONBLOCK: Connection should not block. Since 3.0.0.\n * @GNUTLS_NO_SIGNAL: In systems where SIGPIPE is delivered on send, it will be disabled. That flag has effect in systems which support the MSG_NOSIGNAL sockets flag (since 3.4.2).\n * @GNUTLS_NO_EXTENSIONS: Do not enable any TLS extensions by default (since 3.1.2). As TLS 1.2 and later require extensions this option is considered obsolete and should not be used.\n * @GNUTLS_NO_REPLAY_PROTECTION: Disable any replay protection in DTLS. This must only be used if  replay protection is achieved using other means. Since 3.2.2.\n * @GNUTLS_ALLOW_ID_CHANGE: Allow the peer to replace its certificate, or change its ID during a rehandshake. This change is often used in attacks and thus prohibited by default. Since 3.5.0.\n * @GNUTLS_ENABLE_FALSE_START: Enable the TLS false start on client side if the negotiated ciphersuites allow it. This will enable sending data prior to the handshake being complete, and may introduce a risk of crypto failure when combined with certain key exchanged; for that GnuTLS may not enable that option in ciphersuites that are known to be not safe for false start. Since 3.5.0.\n * @GNUTLS_ENABLE_EARLY_START: Under TLS1.3 allow the server to return earlier than the full handshake\n *   finish; similarly to false start the handshake will be completed once data are received by the\n *   client, while the server is able to transmit sooner. This is not enabled by default as it could\n *   break certain existing server assumptions and use-cases. Since 3.6.4.\n * @GNUTLS_ENABLE_EARLY_DATA: Under TLS1.3 allow the server to receive early data sent as part of the initial ClientHello (0-RTT).\n *   This can also be used to explicitly indicate that the client will send early data.\n *   This is not enabled by default as early data has weaker security properties than other data. Since 3.6.5.\n * @GNUTLS_FORCE_CLIENT_CERT: When in client side and only a single cert is specified, send that certificate irrespective of the issuers expected by the server. Since 3.5.0.\n * @GNUTLS_NO_TICKETS: Flag to indicate that the session should not use resumption with session tickets.\n * @GNUTLS_NO_TICKETS_TLS12: Flag to indicate that the session should not use resumption with session tickets. This flag only has effect if TLS 1.2 is used.\n * @GNUTLS_KEY_SHARE_TOP3: Generate key shares for the top-3 different groups which are enabled.\n *   That is, as each group is associated with a key type (EC, finite field, x25519), generate\n *   three keys using %GNUTLS_PK_DH, %GNUTLS_PK_EC, %GNUTLS_PK_ECDH_X25519 if all of them are enabled.\n * @GNUTLS_KEY_SHARE_TOP2: Generate key shares for the top-2 different groups which are enabled.\n *   For example (ECDH + x25519). This is the default.\n * @GNUTLS_KEY_SHARE_TOP: Generate key share for the first group which is enabled.\n *   For example x25519. This option is the most performant for client (less CPU spent\n *   generating keys), but if the server doesn't support the advertized option it may\n *   result to more roundtrips needed to discover the server's choice.\n * @GNUTLS_NO_AUTO_REKEY: Disable auto-rekeying under TLS1.3. If this option is not specified\n *   gnutls will force a rekey after 2^24 records have been sent.\n * @GNUTLS_POST_HANDSHAKE_AUTH: Enable post handshake authentication for server and client. When set and\n *   a server requests authentication after handshake %GNUTLS_E_REAUTH_REQUEST will be returned\n *   by gnutls_record_recv(). A client should then call gnutls_reauth() to re-authenticate.\n * @GNUTLS_SAFE_PADDING_CHECK: Flag to indicate that the TLS 1.3 padding check will be done in a\n *   safe way which doesn't leak the pad size based on GnuTLS processing time. This is of use to\n *   applications which hide the length of transferred data via the TLS1.3 padding mechanism and\n *   are already taking steps to hide the data processing time. This comes at a performance\n *   penalty.\n * @GNUTLS_AUTO_REAUTH: Enable transparent re-authentication in client side when the server\n *    requests to. That is, reauthentication is handled within gnutls_record_recv(), and\n *    the %GNUTLS_E_REHANDSHAKE or %GNUTLS_E_REAUTH_REQUEST are not returned. This must be\n *    enabled with %GNUTLS_POST_HANDSHAKE_AUTH for TLS1.3. Enabling this flag requires to restore\n *    interrupted calls to gnutls_record_recv() based on the output of gnutls_record_get_direction(),\n *    since gnutls_record_recv() could be interrupted when sending when this flag is enabled.\n *    Note this flag may not be used if you are using the same session for sending and receiving\n *    in different threads.\n * @GNUTLS_ENABLE_RAWPK: Allows raw public-keys to be negotiated during the handshake. Since 3.6.6.\n * @GNUTLS_NO_AUTO_SEND_TICKET: Under TLS1.3 disable auto-sending of\n *    session tickets during the handshake.\n * @GNUTLS_NO_END_OF_EARLY_DATA: Under TLS1.3 suppress sending EndOfEarlyData message. Since 3.7.2.\n *\n * Enumeration of different flags for gnutls_init() function. All the flags\n * can be combined except @GNUTLS_SERVER and @GNUTLS_CLIENT which are mutually\n * exclusive.\n *\n * The key share options relate to the TLS 1.3 key share extension\n * which is a speculative key generation expecting that the server\n * would support the generated key.\n */\ntypedef enum {\n\tGNUTLS_SERVER = 1,\n\tGNUTLS_CLIENT = (1<<1),\n\tGNUTLS_DATAGRAM = (1<<2),\n\tGNUTLS_NONBLOCK = (1<<3),\n\tGNUTLS_NO_EXTENSIONS = (1<<4),\n\tGNUTLS_NO_REPLAY_PROTECTION = (1<<5),\n\tGNUTLS_NO_SIGNAL = (1<<6),\n\tGNUTLS_ALLOW_ID_CHANGE = (1<<7),\n\tGNUTLS_ENABLE_FALSE_START = (1<<8),\n\tGNUTLS_FORCE_CLIENT_CERT = (1<<9),\n\tGNUTLS_NO_TICKETS = (1<<10),\n\tGNUTLS_KEY_SHARE_TOP = (1<<11),\n\tGNUTLS_KEY_SHARE_TOP2 = (1<<12),\n\tGNUTLS_KEY_SHARE_TOP3 = (1<<13),\n\tGNUTLS_POST_HANDSHAKE_AUTH = (1<<14),\n\tGNUTLS_NO_AUTO_REKEY = (1<<15),\n\tGNUTLS_SAFE_PADDING_CHECK = (1<<16),\n\tGNUTLS_ENABLE_EARLY_START = (1<<17),\n\tGNUTLS_ENABLE_RAWPK = (1<<18),\n\tGNUTLS_AUTO_REAUTH = (1<<19),\n\tGNUTLS_ENABLE_EARLY_DATA = (1<<20),\n\tGNUTLS_NO_AUTO_SEND_TICKET = (1<<21),\n\tGNUTLS_NO_END_OF_EARLY_DATA = (1<<22),\n\tGNUTLS_NO_TICKETS_TLS12 = (1<<23)\n} gnutls_init_flags_t;\n\n/* compatibility defines (previous versions of gnutls\n * used defines instead of enumerated values). */\n#define GNUTLS_SERVER (1)\n#define GNUTLS_CLIENT (1<<1)\n#define GNUTLS_DATAGRAM (1<<2)\n#define GNUTLS_NONBLOCK (1<<3)\n#define GNUTLS_NO_EXTENSIONS (1<<4)\n#define GNUTLS_NO_REPLAY_PROTECTION (1<<5)\n#define GNUTLS_NO_SIGNAL (1<<6)\n#define GNUTLS_ALLOW_ID_CHANGE (1<<7)\n#define GNUTLS_ENABLE_FALSE_START (1<<8)\n#define GNUTLS_FORCE_CLIENT_CERT (1<<9)\n#define GNUTLS_NO_TICKETS (1<<10)\n#define GNUTLS_ENABLE_CERT_TYPE_NEG 0\n\t// Here for compatibility reasons\n\n/**\n * gnutls_alert_level_t:\n * @GNUTLS_AL_WARNING: Alert of warning severity.\n * @GNUTLS_AL_FATAL: Alert of fatal severity.\n *\n * Enumeration of different TLS alert severities.\n */\ntypedef enum {\n\tGNUTLS_AL_WARNING = 1,\n\tGNUTLS_AL_FATAL\n} gnutls_alert_level_t;\n\n/**\n * gnutls_alert_description_t:\n * @GNUTLS_A_CLOSE_NOTIFY: Close notify.\n * @GNUTLS_A_UNEXPECTED_MESSAGE: Unexpected message.\n * @GNUTLS_A_BAD_RECORD_MAC: Bad record MAC.\n * @GNUTLS_A_DECRYPTION_FAILED: Decryption failed.\n * @GNUTLS_A_RECORD_OVERFLOW: Record overflow.\n * @GNUTLS_A_DECOMPRESSION_FAILURE: Decompression failed.\n * @GNUTLS_A_HANDSHAKE_FAILURE: Handshake failed.\n * @GNUTLS_A_SSL3_NO_CERTIFICATE: No certificate.\n * @GNUTLS_A_BAD_CERTIFICATE: Certificate is bad.\n * @GNUTLS_A_UNSUPPORTED_CERTIFICATE: Certificate is not supported.\n * @GNUTLS_A_CERTIFICATE_REVOKED: Certificate was revoked.\n * @GNUTLS_A_CERTIFICATE_EXPIRED: Certificate is expired.\n * @GNUTLS_A_CERTIFICATE_UNKNOWN: Unknown certificate.\n * @GNUTLS_A_ILLEGAL_PARAMETER: Illegal parameter.\n * @GNUTLS_A_UNKNOWN_CA: CA is unknown.\n * @GNUTLS_A_ACCESS_DENIED: Access was denied.\n * @GNUTLS_A_DECODE_ERROR: Decode error.\n * @GNUTLS_A_DECRYPT_ERROR: Decrypt error.\n * @GNUTLS_A_EXPORT_RESTRICTION: Export restriction.\n * @GNUTLS_A_PROTOCOL_VERSION: Error in protocol version.\n * @GNUTLS_A_INSUFFICIENT_SECURITY: Insufficient security.\n * @GNUTLS_A_INTERNAL_ERROR: Internal error.\n * @GNUTLS_A_INAPPROPRIATE_FALLBACK: Inappropriate fallback,\n * @GNUTLS_A_USER_CANCELED: User canceled.\n * @GNUTLS_A_NO_RENEGOTIATION: No renegotiation is allowed.\n * @GNUTLS_A_MISSING_EXTENSION: An extension was expected but was not seen\n * @GNUTLS_A_UNSUPPORTED_EXTENSION: An unsupported extension was\n *   sent.\n * @GNUTLS_A_CERTIFICATE_UNOBTAINABLE: Could not retrieve the\n *   specified certificate.\n * @GNUTLS_A_UNRECOGNIZED_NAME: The server name sent was not\n *   recognized.\n * @GNUTLS_A_UNKNOWN_PSK_IDENTITY: The SRP/PSK username is missing\n *   or not known.\n * @GNUTLS_A_CERTIFICATE_REQUIRED: Certificate is required.\n * @GNUTLS_A_NO_APPLICATION_PROTOCOL: The ALPN protocol requested is\n *   not supported by the peer.\n *\n * Enumeration of different TLS alerts.\n */\ntypedef enum {\n\tGNUTLS_A_CLOSE_NOTIFY,\n\tGNUTLS_A_UNEXPECTED_MESSAGE = 10,\n\tGNUTLS_A_BAD_RECORD_MAC = 20,\n\tGNUTLS_A_DECRYPTION_FAILED,\n\tGNUTLS_A_RECORD_OVERFLOW,\n\tGNUTLS_A_DECOMPRESSION_FAILURE = 30,\n\tGNUTLS_A_HANDSHAKE_FAILURE = 40,\n\tGNUTLS_A_SSL3_NO_CERTIFICATE = 41,\n\tGNUTLS_A_BAD_CERTIFICATE = 42,\n\tGNUTLS_A_UNSUPPORTED_CERTIFICATE,\n\tGNUTLS_A_CERTIFICATE_REVOKED,\n\tGNUTLS_A_CERTIFICATE_EXPIRED,\n\tGNUTLS_A_CERTIFICATE_UNKNOWN,\n\tGNUTLS_A_ILLEGAL_PARAMETER,\n\tGNUTLS_A_UNKNOWN_CA,\n\tGNUTLS_A_ACCESS_DENIED,\n\tGNUTLS_A_DECODE_ERROR = 50,\n\tGNUTLS_A_DECRYPT_ERROR,\n\tGNUTLS_A_EXPORT_RESTRICTION = 60,\n\tGNUTLS_A_PROTOCOL_VERSION = 70,\n\tGNUTLS_A_INSUFFICIENT_SECURITY,\n\tGNUTLS_A_INTERNAL_ERROR = 80,\n\tGNUTLS_A_INAPPROPRIATE_FALLBACK = 86,\n\tGNUTLS_A_USER_CANCELED = 90,\n\tGNUTLS_A_NO_RENEGOTIATION = 100,\n\tGNUTLS_A_MISSING_EXTENSION = 109,\n\tGNUTLS_A_UNSUPPORTED_EXTENSION = 110,\n\tGNUTLS_A_CERTIFICATE_UNOBTAINABLE = 111,\n\tGNUTLS_A_UNRECOGNIZED_NAME = 112,\n\tGNUTLS_A_UNKNOWN_PSK_IDENTITY = 115,\n\tGNUTLS_A_CERTIFICATE_REQUIRED = 116,\n\tGNUTLS_A_NO_APPLICATION_PROTOCOL = 120,\n\tGNUTLS_A_MAX = GNUTLS_A_NO_APPLICATION_PROTOCOL\n} gnutls_alert_description_t;\n\n/**\n * gnutls_handshake_description_t:\n * @GNUTLS_HANDSHAKE_HELLO_REQUEST: Hello request.\n * @GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST: DTLS Hello verify request.\n * @GNUTLS_HANDSHAKE_CLIENT_HELLO: Client hello.\n * @GNUTLS_HANDSHAKE_SERVER_HELLO: Server hello.\n * @GNUTLS_HANDSHAKE_END_OF_EARLY_DATA: End of early data.\n * @GNUTLS_HANDSHAKE_HELLO_RETRY_REQUEST: Hello retry request.\n * @GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: New session ticket.\n * @GNUTLS_HANDSHAKE_CERTIFICATE_PKT: Certificate packet.\n * @GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: Server key exchange.\n * @GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: Certificate request.\n * @GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: Server hello done.\n * @GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: Certificate verify.\n * @GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: Client key exchange.\n * @GNUTLS_HANDSHAKE_FINISHED: Finished.\n * @GNUTLS_HANDSHAKE_CERTIFICATE_STATUS: Certificate status (OCSP).\n * @GNUTLS_HANDSHAKE_KEY_UPDATE: TLS1.3 key update message.\n * @GNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT: Compressed certificate packet.\n * @GNUTLS_HANDSHAKE_SUPPLEMENTAL: Supplemental.\n * @GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC: Change Cipher Spec.\n * @GNUTLS_HANDSHAKE_CLIENT_HELLO_V2: SSLv2 Client Hello.\n * @GNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS: Encrypted extensions message.\n *\n * Enumeration of different TLS handshake packets.\n */\ntypedef enum {\n\tGNUTLS_HANDSHAKE_HELLO_REQUEST = 0,\n\tGNUTLS_HANDSHAKE_CLIENT_HELLO = 1,\n\tGNUTLS_HANDSHAKE_SERVER_HELLO = 2,\n\tGNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST = 3,\n\tGNUTLS_HANDSHAKE_NEW_SESSION_TICKET = 4,\n\tGNUTLS_HANDSHAKE_END_OF_EARLY_DATA = 5,\n\tGNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS = 8,\n\tGNUTLS_HANDSHAKE_CERTIFICATE_PKT = 11,\n\tGNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE = 12,\n\tGNUTLS_HANDSHAKE_CERTIFICATE_REQUEST = 13,\n\tGNUTLS_HANDSHAKE_SERVER_HELLO_DONE = 14,\n\tGNUTLS_HANDSHAKE_CERTIFICATE_VERIFY = 15,\n\tGNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE = 16,\n\tGNUTLS_HANDSHAKE_FINISHED = 20,\n\tGNUTLS_HANDSHAKE_CERTIFICATE_STATUS = 22,\n\tGNUTLS_HANDSHAKE_SUPPLEMENTAL = 23,\n\tGNUTLS_HANDSHAKE_KEY_UPDATE = 24,\n\tGNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT = 25,\n\tGNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC = 254,\n\tGNUTLS_HANDSHAKE_CLIENT_HELLO_V2 = 1024,\n\tGNUTLS_HANDSHAKE_HELLO_RETRY_REQUEST = 1025,\n} gnutls_handshake_description_t;\n\n#define GNUTLS_HANDSHAKE_ANY ((unsigned int)-1)\n\nconst char\n    *gnutls_handshake_description_get_name(gnutls_handshake_description_t\n\t\t\t\t\t   type);\n\n/**\n * gnutls_certificate_status_t:\n * @GNUTLS_CERT_INVALID: The certificate is not signed by one of the\n *   known authorities or the signature is invalid (deprecated by the flags \n *   %GNUTLS_CERT_SIGNATURE_FAILURE and %GNUTLS_CERT_SIGNER_NOT_FOUND).\n * @GNUTLS_CERT_SIGNATURE_FAILURE: The signature verification failed.\n * @GNUTLS_CERT_REVOKED: Certificate is revoked by its authority.  In X.509 this will be\n *   set only if CRLs are checked.\n * @GNUTLS_CERT_SIGNER_NOT_FOUND: The certificate's issuer is not known. \n *   This is the case if the issuer is not included in the trusted certificate list.\n * @GNUTLS_CERT_SIGNER_NOT_CA: The certificate's signer was not a CA. This\n *   may happen if this was a version 1 certificate, which is common with\n *   some CAs, or a version 3 certificate without the basic constrains extension.\n * @GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE: The certificate's signer constraints were\n *   violated.\n * @GNUTLS_CERT_INSECURE_ALGORITHM:  The certificate was signed using an insecure\n *   algorithm such as MD2 or MD5. These algorithms have been broken and\n *   should not be trusted.\n * @GNUTLS_CERT_NOT_ACTIVATED: The certificate is not yet activated.\n * @GNUTLS_CERT_EXPIRED: The certificate has expired.\n * @GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED: The revocation data are old and have been superseded.\n * @GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE: The revocation data have a future issue date.\n * @GNUTLS_CERT_UNEXPECTED_OWNER: The owner is not the expected one.\n * @GNUTLS_CERT_MISMATCH: The certificate presented isn't the expected one (TOFU)\n * @GNUTLS_CERT_PURPOSE_MISMATCH: The certificate or an intermediate does not match the intended purpose (extended key usage).\n * @GNUTLS_CERT_MISSING_OCSP_STATUS: The certificate requires the server to send the certificate status, but no status was received.\n * @GNUTLS_CERT_INVALID_OCSP_STATUS: The received OCSP status response is invalid.\n * @GNUTLS_CERT_UNKNOWN_CRIT_EXTENSIONS: The certificate has extensions marked as critical which are not supported.\n *\n * Enumeration of certificate status codes.  Note that the status\n * bits may have different meanings in OpenPGP keys and X.509\n * certificate verification.\n */\ntypedef enum {\n\tGNUTLS_CERT_INVALID = 1 << 1,\n\tGNUTLS_CERT_REVOKED = 1 << 5,\n\tGNUTLS_CERT_SIGNER_NOT_FOUND = 1 << 6,\n\tGNUTLS_CERT_SIGNER_NOT_CA = 1 << 7,\n\tGNUTLS_CERT_INSECURE_ALGORITHM = 1 << 8,\n\tGNUTLS_CERT_NOT_ACTIVATED = 1 << 9,\n\tGNUTLS_CERT_EXPIRED = 1 << 10,\n\tGNUTLS_CERT_SIGNATURE_FAILURE = 1 << 11,\n\tGNUTLS_CERT_REVOCATION_DATA_SUPERSEDED = 1 << 12,\n\tGNUTLS_CERT_UNEXPECTED_OWNER = 1 << 14,\n\tGNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE = 1 << 15,\n\tGNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE = 1 << 16,\n\tGNUTLS_CERT_MISMATCH = 1 << 17,\n\tGNUTLS_CERT_PURPOSE_MISMATCH = 1 << 18,\n\tGNUTLS_CERT_MISSING_OCSP_STATUS = 1 << 19,\n\tGNUTLS_CERT_INVALID_OCSP_STATUS = 1 << 20,\n\tGNUTLS_CERT_UNKNOWN_CRIT_EXTENSIONS = 1 << 21\n} gnutls_certificate_status_t;\n\n/**\n * gnutls_certificate_request_t:\n * @GNUTLS_CERT_IGNORE: Ignore certificate.\n * @GNUTLS_CERT_REQUEST: Request certificate.\n * @GNUTLS_CERT_REQUIRE: Require certificate.\n *\n * Enumeration of certificate request types.\n */\ntypedef enum {\n\tGNUTLS_CERT_IGNORE = 0,\n\tGNUTLS_CERT_REQUEST = 1,\n\tGNUTLS_CERT_REQUIRE = 2\n} gnutls_certificate_request_t;\n\n/**\n * gnutls_openpgp_crt_status_t:\n * @GNUTLS_OPENPGP_CERT: Send entire certificate.\n * @GNUTLS_OPENPGP_CERT_FINGERPRINT: Send only certificate fingerprint.\n *\n * Enumeration of ways to send OpenPGP certificate.\n */\ntypedef enum {\n\tGNUTLS_OPENPGP_CERT = 0,\n\tGNUTLS_OPENPGP_CERT_FINGERPRINT = 1\n} gnutls_openpgp_crt_status_t;\n\n/**\n * gnutls_close_request_t:\n * @GNUTLS_SHUT_RDWR: Disallow further receives/sends.\n * @GNUTLS_SHUT_WR: Disallow further sends.\n *\n * Enumeration of how TLS session should be terminated.  See gnutls_bye().\n */\ntypedef enum {\n\tGNUTLS_SHUT_RDWR = 0,\n\tGNUTLS_SHUT_WR = 1\n} gnutls_close_request_t;\n\n/**\n * gnutls_protocol_t:\n * @GNUTLS_SSL3: SSL version 3.0.\n * @GNUTLS_TLS1_0: TLS version 1.0.\n * @GNUTLS_TLS1: Same as %GNUTLS_TLS1_0.\n * @GNUTLS_TLS1_1: TLS version 1.1.\n * @GNUTLS_TLS1_2: TLS version 1.2.\n * @GNUTLS_TLS1_3: TLS version 1.3.\n * @GNUTLS_DTLS1_0: DTLS version 1.0.\n * @GNUTLS_DTLS1_2: DTLS version 1.2.\n * @GNUTLS_DTLS0_9: DTLS version 0.9 (Cisco AnyConnect / OpenSSL 0.9.8e).\n * @GNUTLS_TLS_VERSION_MAX: Maps to the highest supported TLS version.\n * @GNUTLS_DTLS_VERSION_MAX: Maps to the highest supported DTLS version.\n * @GNUTLS_VERSION_UNKNOWN: Unknown SSL/TLS version.\n *\n * Enumeration of different SSL/TLS protocol versions.\n */\ntypedef enum {\n\tGNUTLS_SSL3 = 1,\n\tGNUTLS_TLS1_0 = 2,\n\tGNUTLS_TLS1 = GNUTLS_TLS1_0,\n\tGNUTLS_TLS1_1 = 3,\n\tGNUTLS_TLS1_2 = 4,\n\tGNUTLS_TLS1_3 = 5,\n\n\tGNUTLS_DTLS0_9 = 200,\n\tGNUTLS_DTLS1_0 = 201,\t/* 201 */\n\tGNUTLS_DTLS1_2 = 202,\n\tGNUTLS_DTLS_VERSION_MIN = GNUTLS_DTLS0_9,\n\tGNUTLS_DTLS_VERSION_MAX = GNUTLS_DTLS1_2,\n\tGNUTLS_TLS_VERSION_MAX = GNUTLS_TLS1_3,\n\tGNUTLS_VERSION_UNKNOWN = 0xff\t/* change it to 0xffff */\n} gnutls_protocol_t;\n\n#define GNUTLS_CRT_RAW GNUTLS_CRT_RAWPK\n\n/**\n * gnutls_certificate_type_t:\n * @GNUTLS_CRT_UNKNOWN: Unknown certificate type.\n * @GNUTLS_CRT_X509: X.509 Certificate.\n * @GNUTLS_CRT_OPENPGP: OpenPGP certificate.\n * @GNUTLS_CRT_RAWPK: Raw public-key (SubjectPublicKeyInfo)\n *\n * Enumeration of different certificate types.\n */\ntypedef enum {\n\tGNUTLS_CRT_UNKNOWN = 0,\n\tGNUTLS_CRT_X509 = 1,\n\tGNUTLS_CRT_OPENPGP = 2,\n\tGNUTLS_CRT_RAWPK = 3,\n\tGNUTLS_CRT_MAX = GNUTLS_CRT_RAWPK\n} gnutls_certificate_type_t;\n\n/**\n * gnutls_x509_crt_fmt_t:\n * @GNUTLS_X509_FMT_DER: X.509 certificate in DER format (binary).\n * @GNUTLS_X509_FMT_PEM: X.509 certificate in PEM format (text).\n *\n * Enumeration of different certificate encoding formats.\n */\ntypedef enum {\n\tGNUTLS_X509_FMT_DER = 0,\n\tGNUTLS_X509_FMT_PEM = 1\n} gnutls_x509_crt_fmt_t;\n\n/**\n * gnutls_certificate_print_formats_t:\n * @GNUTLS_CRT_PRINT_FULL: Full information about certificate.\n * @GNUTLS_CRT_PRINT_FULL_NUMBERS: Full information about certificate and include easy to parse public key parameters.\n * @GNUTLS_CRT_PRINT_COMPACT: Information about certificate name in one line, plus identification of the public key.\n * @GNUTLS_CRT_PRINT_ONELINE: Information about certificate in one line.\n * @GNUTLS_CRT_PRINT_UNSIGNED_FULL: All info for an unsigned certificate.\n *\n * Enumeration of different certificate printing variants.\n */\ntypedef enum gnutls_certificate_print_formats {\n\tGNUTLS_CRT_PRINT_FULL = 0,\n\tGNUTLS_CRT_PRINT_ONELINE = 1,\n\tGNUTLS_CRT_PRINT_UNSIGNED_FULL = 2,\n\tGNUTLS_CRT_PRINT_COMPACT = 3,\n\tGNUTLS_CRT_PRINT_FULL_NUMBERS = 4\n} gnutls_certificate_print_formats_t;\n\n#define GNUTLS_PK_ECC GNUTLS_PK_ECDSA\n#define GNUTLS_PK_EC GNUTLS_PK_ECDSA\n\n#define GNUTLS_PK_ECDHX GNUTLS_PK_ECDH_X25519\n/**\n * gnutls_pk_algorithm_t:\n * @GNUTLS_PK_UNKNOWN: Unknown public-key algorithm.\n * @GNUTLS_PK_RSA: RSA public-key algorithm.\n * @GNUTLS_PK_RSA_PSS: RSA public-key algorithm, with PSS padding.\n * @GNUTLS_PK_DSA: DSA public-key algorithm.\n * @GNUTLS_PK_DH: Diffie-Hellman algorithm. Used to generate parameters.\n * @GNUTLS_PK_ECDSA: Elliptic curve algorithm. These parameters are compatible with the ECDSA and ECDH algorithm.\n * @GNUTLS_PK_ECDH_X25519: Elliptic curve algorithm, restricted to ECDH as per rfc7748.\n * @GNUTLS_PK_EDDSA_ED25519: Edwards curve Digital signature algorithm. Used with SHA512 on signatures.\n * @GNUTLS_PK_GOST_01: GOST R 34.10-2001 algorithm per rfc5832.\n * @GNUTLS_PK_GOST_12_256: GOST R 34.10-2012 algorithm, 256-bit key per rfc7091.\n * @GNUTLS_PK_GOST_12_512: GOST R 34.10-2012 algorithm, 512-bit key per rfc7091.\n * @GNUTLS_PK_ECDH_X448: Elliptic curve algorithm, restricted to ECDH as per rfc7748.\n * @GNUTLS_PK_EDDSA_ED448: Edwards curve Digital signature algorithm. Used with SHAKE256 on signatures.\n *\n * Enumeration of different public-key algorithms.\n */\ntypedef enum {\n\tGNUTLS_PK_UNKNOWN = 0,\n\tGNUTLS_PK_RSA = 1,\n\tGNUTLS_PK_DSA = 2,\n\tGNUTLS_PK_DH = 3,\n\tGNUTLS_PK_ECDSA = 4,\n\tGNUTLS_PK_ECDH_X25519 = 5,\n\tGNUTLS_PK_RSA_PSS = 6,\n\tGNUTLS_PK_EDDSA_ED25519 = 7,\n\tGNUTLS_PK_GOST_01 = 8,\n\tGNUTLS_PK_GOST_12_256 = 9,\n\tGNUTLS_PK_GOST_12_512 = 10,\n\tGNUTLS_PK_ECDH_X448 = 11,\n\tGNUTLS_PK_EDDSA_ED448 = 12,\n\tGNUTLS_PK_MAX = GNUTLS_PK_EDDSA_ED448\n} gnutls_pk_algorithm_t;\n\n\nconst char *gnutls_pk_algorithm_get_name(gnutls_pk_algorithm_t algorithm);\n\n/**\n * gnutls_sign_algorithm_t:\n * @GNUTLS_SIGN_UNKNOWN: Unknown signature algorithm.\n * @GNUTLS_SIGN_RSA_RAW: Digital signature algorithm RSA with DigestInfo formatted data\n * @GNUTLS_SIGN_RSA_SHA1: Digital signature algorithm RSA with SHA-1\n * @GNUTLS_SIGN_RSA_SHA: Same as %GNUTLS_SIGN_RSA_SHA1.\n * @GNUTLS_SIGN_DSA_SHA1: Digital signature algorithm DSA with SHA-1\n * @GNUTLS_SIGN_DSA_SHA224: Digital signature algorithm DSA with SHA-224\n * @GNUTLS_SIGN_DSA_SHA256: Digital signature algorithm DSA with SHA-256\n * @GNUTLS_SIGN_DSA_SHA384: Digital signature algorithm DSA with SHA-384\n * @GNUTLS_SIGN_DSA_SHA512: Digital signature algorithm DSA with SHA-512\n * @GNUTLS_SIGN_DSA_SHA: Same as %GNUTLS_SIGN_DSA_SHA1.\n * @GNUTLS_SIGN_RSA_MD5: Digital signature algorithm RSA with MD5.\n * @GNUTLS_SIGN_RSA_MD2: Digital signature algorithm RSA with MD2.\n * @GNUTLS_SIGN_RSA_RMD160: Digital signature algorithm RSA with RMD-160.\n * @GNUTLS_SIGN_RSA_SHA256: Digital signature algorithm RSA with SHA-256.\n * @GNUTLS_SIGN_RSA_SHA384: Digital signature algorithm RSA with SHA-384.\n * @GNUTLS_SIGN_RSA_SHA512: Digital signature algorithm RSA with SHA-512.\n * @GNUTLS_SIGN_RSA_SHA224: Digital signature algorithm RSA with SHA-224.\n * @GNUTLS_SIGN_ECDSA_SHA1: ECDSA with SHA1.\n * @GNUTLS_SIGN_ECDSA_SHA224: Digital signature algorithm ECDSA with SHA-224.\n * @GNUTLS_SIGN_ECDSA_SHA256: Digital signature algorithm ECDSA with SHA-256.\n * @GNUTLS_SIGN_ECDSA_SHA384: Digital signature algorithm ECDSA with SHA-384.\n * @GNUTLS_SIGN_ECDSA_SHA512: Digital signature algorithm ECDSA with SHA-512.\n * @GNUTLS_SIGN_ECDSA_SECP256R1_SHA256: Digital signature algorithm ECDSA-SECP256R1 with SHA-256 (used in TLS 1.3 but not PKIX).\n * @GNUTLS_SIGN_ECDSA_SECP384R1_SHA384: Digital signature algorithm ECDSA-SECP384R1 with SHA-384 (used in TLS 1.3 but not PKIX).\n * @GNUTLS_SIGN_ECDSA_SECP521R1_SHA512: Digital signature algorithm ECDSA-SECP521R1 with SHA-512 (used in TLS 1.3 but not PKIX).\n * @GNUTLS_SIGN_ECDSA_SHA3_224: Digital signature algorithm ECDSA with SHA3-224.\n * @GNUTLS_SIGN_ECDSA_SHA3_256: Digital signature algorithm ECDSA with SHA3-256.\n * @GNUTLS_SIGN_ECDSA_SHA3_384: Digital signature algorithm ECDSA with SHA3-384.\n * @GNUTLS_SIGN_ECDSA_SHA3_512: Digital signature algorithm ECDSA with SHA3-512.\n * @GNUTLS_SIGN_DSA_SHA3_224: Digital signature algorithm DSA with SHA3-224.\n * @GNUTLS_SIGN_DSA_SHA3_256: Digital signature algorithm DSA with SHA3-256.\n * @GNUTLS_SIGN_DSA_SHA3_384: Digital signature algorithm DSA with SHA3-384.\n * @GNUTLS_SIGN_DSA_SHA3_512: Digital signature algorithm DSA with SHA3-512.\n * @GNUTLS_SIGN_RSA_SHA3_224: Digital signature algorithm RSA with SHA3-224.\n * @GNUTLS_SIGN_RSA_SHA3_256: Digital signature algorithm RSA with SHA3-256.\n * @GNUTLS_SIGN_RSA_SHA3_384: Digital signature algorithm RSA with SHA3-384.\n * @GNUTLS_SIGN_RSA_SHA3_512: Digital signature algorithm RSA with SHA3-512.\n * @GNUTLS_SIGN_RSA_PSS_RSAE_SHA256: Digital signature algorithm RSA with SHA-256,\n *      with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical\n *      to #GNUTLS_SIGN_RSA_PSS_SHA256, but they are distinct as the TLS1.3 protocol\n *      treats them differently.\n * @GNUTLS_SIGN_RSA_PSS_RSAE_SHA384: Digital signature algorithm RSA with SHA-384,\n *      with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical\n *      to #GNUTLS_SIGN_RSA_PSS_SHA384, but they are distinct as the TLS1.3 protocol\n *      treats them differently.\n * @GNUTLS_SIGN_RSA_PSS_RSAE_SHA512: Digital signature algorithm RSA with SHA-512,\n *      with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical\n *      to #GNUTLS_SIGN_RSA_PSS_SHA512, but they are distinct as the TLS1.3 protocol\n *      treats them differently.\n * @GNUTLS_SIGN_RSA_PSS_SHA256: Digital signature algorithm RSA with SHA-256, with PSS padding (RSA-PSS certificate).\n * @GNUTLS_SIGN_RSA_PSS_SHA384: Digital signature algorithm RSA with SHA-384, with PSS padding (RSA-PSS certificate).\n * @GNUTLS_SIGN_RSA_PSS_SHA512: Digital signature algorithm RSA with SHA-512, with PSS padding (RSA-PSS certificate).\n * @GNUTLS_SIGN_EDDSA_ED25519: Digital signature algorithm EdDSA with Ed25519 curve.\n * @GNUTLS_SIGN_GOST_94: Digital signature algorithm GOST R 34.10-2001 with GOST R 34.11-94\n * @GNUTLS_SIGN_GOST_256: Digital signature algorithm GOST R 34.10-2012 with GOST R 34.11-2012 256 bit\n * @GNUTLS_SIGN_GOST_512: Digital signature algorithm GOST R 34.10-2012 with GOST R 34.11-2012 512 bit\n * @GNUTLS_SIGN_EDDSA_ED448: Digital signature algorithm EdDSA with Ed448 curve.\n *\n * Enumeration of different digital signature algorithms.\n */\ntypedef enum {\n\tGNUTLS_SIGN_UNKNOWN = 0,\n\tGNUTLS_SIGN_RSA_SHA1 = 1,\n\tGNUTLS_SIGN_RSA_SHA = GNUTLS_SIGN_RSA_SHA1,\n\tGNUTLS_SIGN_DSA_SHA1 = 2,\n\tGNUTLS_SIGN_DSA_SHA = GNUTLS_SIGN_DSA_SHA1,\n\tGNUTLS_SIGN_RSA_MD5 = 3,\n\tGNUTLS_SIGN_RSA_MD2 = 4,\n\tGNUTLS_SIGN_RSA_RMD160 = 5,\n\tGNUTLS_SIGN_RSA_SHA256 = 6,\n\tGNUTLS_SIGN_RSA_SHA384 = 7,\n\tGNUTLS_SIGN_RSA_SHA512 = 8,\n\tGNUTLS_SIGN_RSA_SHA224 = 9,\n\tGNUTLS_SIGN_DSA_SHA224 = 10,\n\tGNUTLS_SIGN_DSA_SHA256 = 11,\n\tGNUTLS_SIGN_ECDSA_SHA1 = 12,\n\tGNUTLS_SIGN_ECDSA_SHA224 = 13,\n\tGNUTLS_SIGN_ECDSA_SHA256 = 14,\n\tGNUTLS_SIGN_ECDSA_SHA384 = 15,\n\tGNUTLS_SIGN_ECDSA_SHA512 = 16,\n\tGNUTLS_SIGN_DSA_SHA384 = 17,\n\tGNUTLS_SIGN_DSA_SHA512 = 18,\n\tGNUTLS_SIGN_ECDSA_SHA3_224 = 20,\n\tGNUTLS_SIGN_ECDSA_SHA3_256 = 21,\n\tGNUTLS_SIGN_ECDSA_SHA3_384 = 22,\n\tGNUTLS_SIGN_ECDSA_SHA3_512 = 23,\n\n\tGNUTLS_SIGN_DSA_SHA3_224 = 24,\n\tGNUTLS_SIGN_DSA_SHA3_256 = 25,\n\tGNUTLS_SIGN_DSA_SHA3_384 = 26,\n\tGNUTLS_SIGN_DSA_SHA3_512 = 27,\n\tGNUTLS_SIGN_RSA_SHA3_224 = 28,\n\tGNUTLS_SIGN_RSA_SHA3_256 = 29,\n\tGNUTLS_SIGN_RSA_SHA3_384 = 30,\n\tGNUTLS_SIGN_RSA_SHA3_512 = 31,\n\n\tGNUTLS_SIGN_RSA_PSS_SHA256 = 32,\n\tGNUTLS_SIGN_RSA_PSS_SHA384 = 33,\n\tGNUTLS_SIGN_RSA_PSS_SHA512 = 34,\n\tGNUTLS_SIGN_EDDSA_ED25519 = 35,\n\tGNUTLS_SIGN_RSA_RAW = 36,\n\n\tGNUTLS_SIGN_ECDSA_SECP256R1_SHA256 = 37,\n\tGNUTLS_SIGN_ECDSA_SECP384R1_SHA384 = 38,\n\tGNUTLS_SIGN_ECDSA_SECP521R1_SHA512 = 39,\n\n\tGNUTLS_SIGN_RSA_PSS_RSAE_SHA256 = 40,\n\tGNUTLS_SIGN_RSA_PSS_RSAE_SHA384 = 41,\n\tGNUTLS_SIGN_RSA_PSS_RSAE_SHA512 = 42,\n\n\tGNUTLS_SIGN_GOST_94 = 43,\n\tGNUTLS_SIGN_GOST_256 = 44,\n\tGNUTLS_SIGN_GOST_512 = 45,\n\tGNUTLS_SIGN_EDDSA_ED448 = 46,\n\tGNUTLS_SIGN_MAX = GNUTLS_SIGN_EDDSA_ED448\n} gnutls_sign_algorithm_t;\n\n/**\n * gnutls_ecc_curve_t:\n * @GNUTLS_ECC_CURVE_INVALID: Cannot be known\n * @GNUTLS_ECC_CURVE_SECP192R1: the SECP192R1 curve\n * @GNUTLS_ECC_CURVE_SECP224R1: the SECP224R1 curve\n * @GNUTLS_ECC_CURVE_SECP256R1: the SECP256R1 curve\n * @GNUTLS_ECC_CURVE_SECP384R1: the SECP384R1 curve\n * @GNUTLS_ECC_CURVE_SECP521R1: the SECP521R1 curve\n * @GNUTLS_ECC_CURVE_X25519: the X25519 curve (ECDH only)\n * @GNUTLS_ECC_CURVE_ED25519: the Ed25519 curve\n * @GNUTLS_ECC_CURVE_GOST256CPA: GOST R 34.10 CryptoPro 256 A curve\n * @GNUTLS_ECC_CURVE_GOST256CPB: GOST R 34.10 CryptoPro 256 B curve\n * @GNUTLS_ECC_CURVE_GOST256CPC: GOST R 34.10 CryptoPro 256 C curve\n * @GNUTLS_ECC_CURVE_GOST256CPXA: GOST R 34.10 CryptoPro 256 XchA curve\n * @GNUTLS_ECC_CURVE_GOST256CPXB: GOST R 34.10 CryptoPro 256 XchB curve\n * @GNUTLS_ECC_CURVE_GOST512A: GOST R 34.10 TC26 512 A curve\n * @GNUTLS_ECC_CURVE_GOST512B: GOST R 34.10 TC26 512 B curve\n * @GNUTLS_ECC_CURVE_GOST512C: GOST R 34.10 TC26 512 C curve\n * @GNUTLS_ECC_CURVE_GOST256A: GOST R 34.10 TC26 256 A curve\n * @GNUTLS_ECC_CURVE_GOST256B: GOST R 34.10 TC26 256 B curve\n * @GNUTLS_ECC_CURVE_GOST256C: GOST R 34.10 TC26 256 C curve\n * @GNUTLS_ECC_CURVE_GOST256D: GOST R 34.10 TC26 256 D curve\n * @GNUTLS_ECC_CURVE_X448: the X448 curve (ECDH only)\n * @GNUTLS_ECC_CURVE_ED448: the Ed448 curve\n *\n * Enumeration of ECC curves.\n */\ntypedef enum {\n\tGNUTLS_ECC_CURVE_INVALID = 0,\n\tGNUTLS_ECC_CURVE_SECP224R1,\n\tGNUTLS_ECC_CURVE_SECP256R1,\n\tGNUTLS_ECC_CURVE_SECP384R1,\n\tGNUTLS_ECC_CURVE_SECP521R1,\n\tGNUTLS_ECC_CURVE_SECP192R1,\n\tGNUTLS_ECC_CURVE_X25519,\n\tGNUTLS_ECC_CURVE_ED25519,\n\tGNUTLS_ECC_CURVE_GOST256CPA,\n\tGNUTLS_ECC_CURVE_GOST256CPB,\n\tGNUTLS_ECC_CURVE_GOST256CPC,\n\tGNUTLS_ECC_CURVE_GOST256CPXA,\n\tGNUTLS_ECC_CURVE_GOST256CPXB,\n\tGNUTLS_ECC_CURVE_GOST512A,\n\tGNUTLS_ECC_CURVE_GOST512B,\n\tGNUTLS_ECC_CURVE_GOST512C,\n\tGNUTLS_ECC_CURVE_GOST256A,\n\tGNUTLS_ECC_CURVE_GOST256B,\n\tGNUTLS_ECC_CURVE_GOST256C,\n\tGNUTLS_ECC_CURVE_GOST256D,\n\tGNUTLS_ECC_CURVE_X448,\n\tGNUTLS_ECC_CURVE_ED448,\n\tGNUTLS_ECC_CURVE_MAX = GNUTLS_ECC_CURVE_ED448\n} gnutls_ecc_curve_t;\n\n/**\n * gnutls_group_t:\n * @GNUTLS_GROUP_INVALID: Indicates unknown/invalid group\n * @GNUTLS_GROUP_SECP192R1: the SECP192R1 curve group (legacy, only for TLS 1.2 compatibility)\n * @GNUTLS_GROUP_SECP224R1: the SECP224R1 curve group (legacy, only for TLS 1.2 compatibility)\n * @GNUTLS_GROUP_SECP256R1: the SECP256R1 curve group\n * @GNUTLS_GROUP_SECP384R1: the SECP384R1 curve group\n * @GNUTLS_GROUP_SECP521R1: the SECP521R1 curve group\n * @GNUTLS_GROUP_X25519: the X25519 curve group\n * @GNUTLS_GROUP_GC256A: the GOST R 34.10 TC26 256 A curve group\n * @GNUTLS_GROUP_GC256B: the GOST R 34.10 TC26 256 B curve group\n * @GNUTLS_GROUP_GC256C: the GOST R 34.10 TC26 256 C curve group\n * @GNUTLS_GROUP_GC256D: the GOST R 34.10 TC26 256 D curve group\n * @GNUTLS_GROUP_GC512A: the GOST R 34.10 TC26 512 A curve group\n * @GNUTLS_GROUP_GC512B: the GOST R 34.10 TC26 512 B curve group\n * @GNUTLS_GROUP_GC512C: the GOST R 34.10 TC26 512 C curve group\n * @GNUTLS_GROUP_FFDHE2048: the FFDHE2048 group\n * @GNUTLS_GROUP_FFDHE3072: the FFDHE3072 group\n * @GNUTLS_GROUP_FFDHE4096: the FFDHE4096 group\n * @GNUTLS_GROUP_FFDHE6144: the FFDHE6144 group\n * @GNUTLS_GROUP_FFDHE8192: the FFDHE8192 group\n * @GNUTLS_GROUP_X448: the X448 curve group\n *\n * Enumeration of supported groups. It is intended to be backwards\n * compatible with the enumerations in %gnutls_ecc_curve_t for the groups\n * which are valid elliptic curves.\n */\ntypedef enum {\n\tGNUTLS_GROUP_INVALID = 0,\n\tGNUTLS_GROUP_SECP192R1 = GNUTLS_ECC_CURVE_SECP192R1,\n\tGNUTLS_GROUP_SECP224R1 = GNUTLS_ECC_CURVE_SECP224R1,\n\tGNUTLS_GROUP_SECP256R1 = GNUTLS_ECC_CURVE_SECP256R1,\n\tGNUTLS_GROUP_SECP384R1 = GNUTLS_ECC_CURVE_SECP384R1,\n\tGNUTLS_GROUP_SECP521R1 = GNUTLS_ECC_CURVE_SECP521R1,\n\tGNUTLS_GROUP_X25519 = GNUTLS_ECC_CURVE_X25519,\n\tGNUTLS_GROUP_X448 = GNUTLS_ECC_CURVE_X448,\n\n\tGNUTLS_GROUP_GC256A = GNUTLS_ECC_CURVE_GOST256A,\n\tGNUTLS_GROUP_GC256B = GNUTLS_ECC_CURVE_GOST256B,\n\tGNUTLS_GROUP_GC256C = GNUTLS_ECC_CURVE_GOST256C,\n\tGNUTLS_GROUP_GC256D = GNUTLS_ECC_CURVE_GOST256D,\n\tGNUTLS_GROUP_GC512A = GNUTLS_ECC_CURVE_GOST512A,\n\tGNUTLS_GROUP_GC512B = GNUTLS_ECC_CURVE_GOST512B,\n\tGNUTLS_GROUP_GC512C = GNUTLS_ECC_CURVE_GOST512C,\n\n\tGNUTLS_GROUP_FFDHE2048 = 256,\n\tGNUTLS_GROUP_FFDHE3072,\n\tGNUTLS_GROUP_FFDHE4096,\n\tGNUTLS_GROUP_FFDHE8192,\n\tGNUTLS_GROUP_FFDHE6144,\n\tGNUTLS_GROUP_MAX = GNUTLS_GROUP_FFDHE6144,\n} gnutls_group_t;\n\n/* macros to allow specifying a specific curve in gnutls_privkey_generate()\n * and gnutls_x509_privkey_generate() */\n#define GNUTLS_CURVE_TO_BITS(curve) (unsigned int)(((unsigned int)1<<31)|((unsigned int)(curve)))\n#define GNUTLS_BITS_TO_CURVE(bits) (((unsigned int)(bits)) & 0x7FFFFFFF)\n#define GNUTLS_BITS_ARE_CURVE(bits) (((unsigned int)(bits)) & 0x80000000)\n\n/**\n * gnutls_sec_param_t:\n * @GNUTLS_SEC_PARAM_UNKNOWN: Cannot be known\n * @GNUTLS_SEC_PARAM_INSECURE: Less than 42 bits of security\n * @GNUTLS_SEC_PARAM_EXPORT: 42 bits of security\n * @GNUTLS_SEC_PARAM_VERY_WEAK: 64 bits of security\n * @GNUTLS_SEC_PARAM_WEAK: 72 bits of security\n * @GNUTLS_SEC_PARAM_LOW: 80 bits of security\n * @GNUTLS_SEC_PARAM_LEGACY: 96 bits of security\n * @GNUTLS_SEC_PARAM_MEDIUM: 112 bits of security (used to be %GNUTLS_SEC_PARAM_NORMAL)\n * @GNUTLS_SEC_PARAM_HIGH: 128 bits of security\n * @GNUTLS_SEC_PARAM_ULTRA: 192 bits of security\n * @GNUTLS_SEC_PARAM_FUTURE: 256 bits of security\n *\n * Enumeration of security parameters for passive attacks.\n */\ntypedef enum {\n\tGNUTLS_SEC_PARAM_UNKNOWN = 0,\n\tGNUTLS_SEC_PARAM_INSECURE = 5,\n\tGNUTLS_SEC_PARAM_EXPORT = 10,\n\tGNUTLS_SEC_PARAM_VERY_WEAK = 15,\n\tGNUTLS_SEC_PARAM_WEAK = 20,\n\tGNUTLS_SEC_PARAM_LOW = 25,\n\tGNUTLS_SEC_PARAM_LEGACY = 30,\n\tGNUTLS_SEC_PARAM_MEDIUM = 35,\n\tGNUTLS_SEC_PARAM_HIGH = 40,\n\tGNUTLS_SEC_PARAM_ULTRA = 45,\n\tGNUTLS_SEC_PARAM_FUTURE = 50,\n\tGNUTLS_SEC_PARAM_MAX = GNUTLS_SEC_PARAM_FUTURE\n} gnutls_sec_param_t;\n\n/* old name */\n#define GNUTLS_SEC_PARAM_NORMAL GNUTLS_SEC_PARAM_MEDIUM\n\n/**\n * gnutls_channel_binding_t:\n * @GNUTLS_CB_TLS_UNIQUE: \"tls-unique\" (RFC 5929) channel binding\n * @GNUTLS_CB_TLS_SERVER_END_POINT: \"tls-server-end-point\" (RFC 5929) channel binding\n * @GNUTLS_CB_TLS_EXPORTER: \"tls-exporter\" (RFC 9266) channel binding\n *\n * Enumeration of supported channel binding types.\n */\ntypedef enum {\n\tGNUTLS_CB_TLS_UNIQUE,\n\tGNUTLS_CB_TLS_SERVER_END_POINT,\n\tGNUTLS_CB_TLS_EXPORTER\n} gnutls_channel_binding_t;\n\n/**\n * gnutls_gost_paramset_t:\n * @GNUTLS_GOST_PARAMSET_UNKNOWN: Unknown/default parameter set\n * @GNUTLS_GOST_PARAMSET_TC26_Z: Specified by TC26, see rfc7836\n * @GNUTLS_GOST_PARAMSET_CP_A: CryptoPro-A, see rfc4357\n * @GNUTLS_GOST_PARAMSET_CP_B: CryptoPro-B, see rfc4357\n * @GNUTLS_GOST_PARAMSET_CP_C: CryptoPro-C, see rfc4357\n * @GNUTLS_GOST_PARAMSET_CP_D: CryptoPro-D, see rfc4357\n *\n * Enumeration of different GOST 28147 parameter sets.\n */\ntypedef enum {\n\tGNUTLS_GOST_PARAMSET_UNKNOWN = 0,\n\tGNUTLS_GOST_PARAMSET_TC26_Z,\n\tGNUTLS_GOST_PARAMSET_CP_A,\n\tGNUTLS_GOST_PARAMSET_CP_B,\n\tGNUTLS_GOST_PARAMSET_CP_C,\n\tGNUTLS_GOST_PARAMSET_CP_D\n} gnutls_gost_paramset_t;\n\n/**\n * gnutls_ctype_target_t:\n * @GNUTLS_CTYPE_CLIENT: for requesting client certificate type values.\n * @GNUTLS_CTYPE_SERVER: for requesting server certificate type values.\n * @GNUTLS_CTYPE_OURS: for requesting our certificate type values.\n * @GNUTLS_CTYPE_PEERS: for requesting the peers' certificate type values.\n *\n * Enumeration of certificate type targets with respect to asymmetric\n * certificate types as specified in RFC7250 and P2P connection set up\n * as specified in draft-vanrein-tls-symmetry-02.\n */\ntypedef enum {\n\tGNUTLS_CTYPE_CLIENT,\n\tGNUTLS_CTYPE_SERVER,\n\tGNUTLS_CTYPE_OURS,\n\tGNUTLS_CTYPE_PEERS\n} gnutls_ctype_target_t;\n\n/* If you want to change this, then also change the define in\n * gnutls_int.h, and recompile.\n */\ntypedef void *gnutls_transport_ptr_t;\n\nstruct gnutls_session_int;\ntypedef struct gnutls_session_int *gnutls_session_t;\n\nstruct gnutls_dh_params_int;\ntypedef struct gnutls_dh_params_int *gnutls_dh_params_t;\n\n  /* XXX ugly. */\nstruct gnutls_x509_privkey_int;\ntypedef struct gnutls_x509_privkey_int *gnutls_rsa_params_t;\n\nstruct gnutls_priority_st;\ntypedef struct gnutls_priority_st *gnutls_priority_t;\n\ntypedef struct {\n\tunsigned char *data;\n\tunsigned int size;\n} gnutls_datum_t;\n\ntypedef struct gnutls_library_config_st {\n\tconst char *name;\n\tconst char *value;\n} gnutls_library_config_st;\n\n\ntypedef struct gnutls_params_st {\n\tgnutls_params_type_t type;\n\tunion params {\n\t\tgnutls_dh_params_t dh;\n\t\tgnutls_rsa_params_t rsa_export;\n\t} params;\n\tint deinit;\n} gnutls_params_st;\n\ntypedef int gnutls_params_function(gnutls_session_t, gnutls_params_type_t,\n\t\t\t\t   gnutls_params_st *);\n\n/* internal functions */\n\nint gnutls_init(gnutls_session_t * session, unsigned int flags);\nvoid gnutls_deinit(gnutls_session_t session);\n#define _gnutls_deinit(x) gnutls_deinit(x)\n\nint gnutls_bye(gnutls_session_t session, gnutls_close_request_t how);\n\nint gnutls_handshake(gnutls_session_t session);\n\nint gnutls_reauth(gnutls_session_t session, unsigned int flags);\n\n#define GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT ((unsigned int)-1)\n#define GNUTLS_INDEFINITE_TIMEOUT ((unsigned int)-2)\nvoid gnutls_handshake_set_timeout(gnutls_session_t session,\n\t\t\t\t  unsigned int ms);\nint gnutls_rehandshake(gnutls_session_t session);\n\n#define GNUTLS_KU_PEER 1\nint gnutls_session_key_update(gnutls_session_t session, unsigned flags);\n\ngnutls_alert_description_t gnutls_alert_get(gnutls_session_t session);\nint gnutls_alert_send(gnutls_session_t session,\n\t\t      gnutls_alert_level_t level,\n\t\t      gnutls_alert_description_t desc);\nint gnutls_alert_send_appropriate(gnutls_session_t session, int err);\nconst char *gnutls_alert_get_name(gnutls_alert_description_t alert);\nconst char *gnutls_alert_get_strname(gnutls_alert_description_t alert);\n\ngnutls_sec_param_t gnutls_pk_bits_to_sec_param(gnutls_pk_algorithm_t algo,\n\t\t\t\t\t       unsigned int bits);\nconst char *gnutls_sec_param_get_name(gnutls_sec_param_t param);\nunsigned int gnutls_sec_param_to_pk_bits(gnutls_pk_algorithm_t algo,\n\t\t\t\t\t gnutls_sec_param_t param);\nunsigned int\n\tgnutls_sec_param_to_symmetric_bits(gnutls_sec_param_t param) __GNUTLS_CONST__;\n\n/* Elliptic curves */\nconst char *\n\tgnutls_ecc_curve_get_name(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;\nconst char *\n\tgnutls_ecc_curve_get_oid(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_group_get_name(gnutls_group_t group) __GNUTLS_CONST__;\n\nint\n\tgnutls_ecc_curve_get_size(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;\ngnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);\n\ngnutls_group_t gnutls_group_get(gnutls_session_t session);\n\n/* get information on the current session */\ngnutls_cipher_algorithm_t gnutls_cipher_get(gnutls_session_t session);\ngnutls_cipher_algorithm_t gnutls_early_cipher_get(gnutls_session_t session);\ngnutls_kx_algorithm_t gnutls_kx_get(gnutls_session_t session);\ngnutls_mac_algorithm_t gnutls_mac_get(gnutls_session_t session);\ngnutls_digest_algorithm_t gnutls_prf_hash_get(const gnutls_session_t session);\ngnutls_digest_algorithm_t\ngnutls_early_prf_hash_get(const gnutls_session_t session);\ngnutls_certificate_type_t\ngnutls_certificate_type_get(gnutls_session_t session);\ngnutls_certificate_type_t\ngnutls_certificate_type_get2(gnutls_session_t session,\n\t\t\t     gnutls_ctype_target_t target);\n\nint gnutls_sign_algorithm_get(gnutls_session_t session);\nint gnutls_sign_algorithm_get_client(gnutls_session_t session);\n\nint gnutls_sign_algorithm_get_requested(gnutls_session_t session,\n\t\t\t\t\tsize_t indx,\n\t\t\t\t\tgnutls_sign_algorithm_t * algo);\n\n/* the name of the specified algorithms */\nconst char *\n\tgnutls_cipher_get_name(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\nconst char *\n\tgnutls_mac_get_name(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_digest_get_name(gnutls_digest_algorithm_t algorithm) __GNUTLS_CONST__;\nconst char *\n\tgnutls_digest_get_oid(gnutls_digest_algorithm_t algorithm) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_kx_get_name(gnutls_kx_algorithm_t algorithm) __GNUTLS_CONST__;\nconst char *\n\tgnutls_certificate_type_get_name(gnutls_certificate_type_t\n\t\t\t\t\t     type) __GNUTLS_CONST__;\nconst char *\n\tgnutls_pk_get_name(gnutls_pk_algorithm_t algorithm) __GNUTLS_CONST__;\nconst char *\n\tgnutls_pk_get_oid(gnutls_pk_algorithm_t algorithm) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_sign_get_name(gnutls_sign_algorithm_t algorithm) __GNUTLS_CONST__;\n\nconst char *gnutls_sign_get_oid(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_gost_paramset_get_name(gnutls_gost_paramset_t param) __GNUTLS_CONST__;\nconst char *\n\tgnutls_gost_paramset_get_oid(gnutls_gost_paramset_t param) __GNUTLS_CONST__;\n\nsize_t\n\tgnutls_cipher_get_key_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\nsize_t\n\tgnutls_mac_get_key_size(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\n\nunsigned gnutls_sign_is_secure(gnutls_sign_algorithm_t algorithm) __GNUTLS_CONST__;\n\n/* It is possible that a signature algorithm is ok to use for short-lived\n * data (e.g., to sign a TLS session), but not for data that are long-lived\n * like certificates. This flag is about checking the security of the algorithm\n * for long-lived data. */\n#define GNUTLS_SIGN_FLAG_SECURE_FOR_CERTS 1\nunsigned gnutls_sign_is_secure2(gnutls_sign_algorithm_t algorithm, unsigned int flags) __GNUTLS_CONST__;\n\ngnutls_digest_algorithm_t\n\tgnutls_sign_get_hash_algorithm(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;\ngnutls_pk_algorithm_t\n\tgnutls_sign_get_pk_algorithm(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;\ngnutls_sign_algorithm_t\n\tgnutls_pk_to_sign(gnutls_pk_algorithm_t pk,\n\t\t  gnutls_digest_algorithm_t hash) __GNUTLS_CONST__;\n\nunsigned\ngnutls_sign_supports_pk_algorithm(gnutls_sign_algorithm_t sign, gnutls_pk_algorithm_t pk) __GNUTLS_CONST__;\n\n#define gnutls_sign_algorithm_get_name gnutls_sign_get_name\n\ngnutls_mac_algorithm_t gnutls_mac_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_digest_algorithm_t gnutls_digest_get_id(const char *name) __GNUTLS_CONST__;\n\ngnutls_cipher_algorithm_t\n\tgnutls_cipher_get_id(const char *name) __GNUTLS_CONST__;\n\ngnutls_kx_algorithm_t\n\tgnutls_kx_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_protocol_t\n\tgnutls_protocol_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_certificate_type_t\n\tgnutls_certificate_type_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_pk_algorithm_t\n\tgnutls_pk_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_sign_algorithm_t\n\tgnutls_sign_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_ecc_curve_t gnutls_ecc_curve_get_id(const char *name)  __GNUTLS_CONST__;\ngnutls_pk_algorithm_t gnutls_ecc_curve_get_pk(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;\ngnutls_group_t gnutls_group_get_id(const char *name);\n\ngnutls_digest_algorithm_t\n\tgnutls_oid_to_digest(const char *oid)  __GNUTLS_CONST__;\ngnutls_mac_algorithm_t\n\tgnutls_oid_to_mac(const char *oid)  __GNUTLS_CONST__;\ngnutls_pk_algorithm_t\n\tgnutls_oid_to_pk(const char *oid) __GNUTLS_CONST__;\ngnutls_sign_algorithm_t\n\tgnutls_oid_to_sign(const char *oid) __GNUTLS_CONST__;\ngnutls_ecc_curve_t\n\tgnutls_oid_to_ecc_curve(const char *oid) __GNUTLS_CONST__;\ngnutls_gost_paramset_t\n\tgnutls_oid_to_gost_paramset(const char *oid) __GNUTLS_CONST__;\n\n  /* list supported algorithms */\nconst gnutls_ecc_curve_t *\n\tgnutls_ecc_curve_list(void)  __GNUTLS_PURE__;\nconst gnutls_group_t *\n\tgnutls_group_list(void)  __GNUTLS_PURE__;\nconst gnutls_cipher_algorithm_t *\n\tgnutls_cipher_list(void) __GNUTLS_PURE__;\nconst gnutls_mac_algorithm_t *\n\tgnutls_mac_list(void) __GNUTLS_PURE__;\nconst gnutls_digest_algorithm_t *\n\tgnutls_digest_list(void) __GNUTLS_PURE__;\nconst gnutls_protocol_t *\n\tgnutls_protocol_list(void) __GNUTLS_PURE__;\nconst gnutls_certificate_type_t *\n\tgnutls_certificate_type_list(void) __GNUTLS_PURE__;\nconst gnutls_kx_algorithm_t *\n\tgnutls_kx_list(void) __GNUTLS_PURE__;\nconst gnutls_pk_algorithm_t *\n\tgnutls_pk_list(void) __GNUTLS_PURE__;\nconst gnutls_sign_algorithm_t *\n\tgnutls_sign_list(void) __GNUTLS_PURE__;\nconst char *\n\tgnutls_cipher_suite_info(size_t idx,\n\t\t\t         unsigned char *cs_id,\n\t\t\t\t gnutls_kx_algorithm_t * kx,\n\t\t\t\t gnutls_cipher_algorithm_t * cipher,\n\t\t\t\t gnutls_mac_algorithm_t * mac,\n\t\t\t\t gnutls_protocol_t * min_version);\n\n  /* functions for run-time enablement of algorithms */\nint gnutls_ecc_curve_set_enabled(gnutls_ecc_curve_t curve,\n\t\t\t\t unsigned int enabled);\nint gnutls_sign_set_secure(gnutls_sign_algorithm_t sign, unsigned int secure);\nint gnutls_sign_set_secure_for_certs(gnutls_sign_algorithm_t sign,\n\t\t\t\t     unsigned int secure);\nint gnutls_digest_set_secure(gnutls_digest_algorithm_t dig,\n\t\t\t     unsigned int secure);\nint gnutls_protocol_set_enabled(gnutls_protocol_t version,\n\t\t\t\tunsigned int enabled);\n\n  /* error functions */\nint gnutls_error_is_fatal(int error) __GNUTLS_CONST__;\nint gnutls_error_to_alert(int err, int *level);\n\nvoid gnutls_perror(int error);\nconst char * gnutls_strerror(int error) __GNUTLS_CONST__;\nconst char * gnutls_strerror_name(int error) __GNUTLS_CONST__;\n\n/* Semi-internal functions.\n */\nvoid gnutls_handshake_set_private_extensions(gnutls_session_t session,\n\t\t\t\t\t     int allow);\nint gnutls_handshake_set_random(gnutls_session_t session,\n\t\t\t\tconst gnutls_datum_t * random);\n\ngnutls_handshake_description_t\ngnutls_handshake_get_last_out(gnutls_session_t session);\ngnutls_handshake_description_t\ngnutls_handshake_get_last_in(gnutls_session_t session);\n\n/* Record layer functions.\n */\n#define GNUTLS_HEARTBEAT_WAIT 1\nint gnutls_heartbeat_ping(gnutls_session_t session, size_t data_size,\n\t\t\t  unsigned int max_tries, unsigned int flags);\nint gnutls_heartbeat_pong(gnutls_session_t session, unsigned int flags);\n\nvoid gnutls_record_set_timeout(gnutls_session_t session, unsigned int ms);\nvoid gnutls_record_disable_padding(gnutls_session_t session);\n\nvoid gnutls_record_cork(gnutls_session_t session);\n#define GNUTLS_RECORD_WAIT 1\nint gnutls_record_uncork(gnutls_session_t session, unsigned int flags);\nsize_t gnutls_record_discard_queued(gnutls_session_t session);\n\nint\ngnutls_record_get_state(gnutls_session_t session,\n\t\t\tunsigned read,\n\t\t\tgnutls_datum_t *mac_key,\n\t\t\tgnutls_datum_t *IV,\n\t\t\tgnutls_datum_t *cipher_key,\n\t\t\tunsigned char seq_number[8]);\n\nint\ngnutls_record_set_state(gnutls_session_t session,\n\t\t\tunsigned read,\n\t\t\tconst unsigned char seq_number[8]);\n\ntypedef struct {\n\tsize_t low;\n\tsize_t high;\n} gnutls_range_st;\n\nint gnutls_range_split(gnutls_session_t session,\n\t\t       const gnutls_range_st * orig,\n\t\t       gnutls_range_st * small_range,\n\t\t       gnutls_range_st * rem_range);\n\nssize_t gnutls_record_send(gnutls_session_t session, const void *data,\n\t\t\t   size_t data_size);\nssize_t gnutls_record_send2(gnutls_session_t session, const void *data,\n\t\t\t    size_t data_size, size_t pad, unsigned flags);\nssize_t gnutls_record_send_range(gnutls_session_t session,\n\t\t\t\t const void *data, size_t data_size,\n\t\t\t\t const gnutls_range_st * range);\nssize_t gnutls_record_send_file(gnutls_session_t session, int fd,\n\t\toff_t *offset, size_t count);\nssize_t gnutls_record_recv(gnutls_session_t session, void *data,\n\t\t\t   size_t data_size);\n\ntypedef struct mbuffer_st *gnutls_packet_t;\n\nssize_t\ngnutls_record_recv_packet(gnutls_session_t session,\n\t\t\t  gnutls_packet_t *packet);\n\nvoid gnutls_packet_get(gnutls_packet_t packet, gnutls_datum_t *data, unsigned char *sequence);\nvoid gnutls_packet_deinit(gnutls_packet_t packet);\n\n#define gnutls_read gnutls_record_recv\n#define gnutls_write gnutls_record_send\nssize_t gnutls_record_recv_seq(gnutls_session_t session, void *data,\n\t\t\t       size_t data_size, unsigned char *seq);\n\nsize_t gnutls_record_overhead_size(gnutls_session_t session);\n\nsize_t\n\tgnutls_est_record_overhead_size(gnutls_protocol_t version,\n\t\t\t\t        gnutls_cipher_algorithm_t cipher,\n\t\t\t\t        gnutls_mac_algorithm_t mac,\n\t\t\t\t        gnutls_compression_method_t comp,\n\t\t\t\t        unsigned int flags) __GNUTLS_CONST__;\n\nvoid gnutls_session_enable_compatibility_mode(gnutls_session_t session);\n#define gnutls_record_set_max_empty_records(session, x)\n\nunsigned gnutls_record_can_use_length_hiding(gnutls_session_t session);\n\nint gnutls_record_get_direction(gnutls_session_t session);\n\nsize_t gnutls_record_get_max_size(gnutls_session_t session);\nssize_t gnutls_record_set_max_size(gnutls_session_t session, size_t size);\nssize_t gnutls_record_set_max_recv_size(gnutls_session_t session, size_t size);\n\nsize_t gnutls_record_check_pending(gnutls_session_t session);\nsize_t gnutls_record_check_corked(gnutls_session_t session);\n\nsize_t gnutls_record_get_max_early_data_size(gnutls_session_t session);\nint gnutls_record_set_max_early_data_size(gnutls_session_t session, size_t size);\nssize_t gnutls_record_send_early_data(gnutls_session_t session,\n\t\t\t\t      const void *data,\n\t\t\t\t      size_t length);\nssize_t gnutls_record_recv_early_data(gnutls_session_t session,\n\t\t\t\t      void *data,\n\t\t\t\t      size_t data_size);\n\nvoid gnutls_session_force_valid(gnutls_session_t session);\n\nint gnutls_prf(gnutls_session_t session,\n\t       size_t label_size, const char *label,\n\t       int server_random_first,\n\t       size_t extra_size, const char *extra,\n\t       size_t outsize, char *out);\nint gnutls_prf_rfc5705(gnutls_session_t session,\n\t       size_t label_size, const char *label,\n\t       size_t context_size, const char *context,\n\t       size_t outsize, char *out);\nint gnutls_prf_early(gnutls_session_t session,\n\t\t     size_t label_size, const char *label,\n\t\t     size_t context_size, const char *context,\n\t\t     size_t outsize, char *out);\n\nint gnutls_prf_raw(gnutls_session_t session,\n\t\t   size_t label_size, const char *label,\n\t\t   size_t seed_size, const char *seed,\n\t\t   size_t outsize, char *out);\n\n/**\n * gnutls_server_name_type_t:\n * @GNUTLS_NAME_DNS: Domain Name System name type.\n *\n * Enumeration of different server name types.\n */\ntypedef enum {\n\tGNUTLS_NAME_DNS = 1\n} gnutls_server_name_type_t;\n\nint gnutls_server_name_set(gnutls_session_t session,\n\t\t\t   gnutls_server_name_type_t type,\n\t\t\t   const void *name, size_t name_length);\n\nint gnutls_server_name_get(gnutls_session_t session,\n\t\t\t   void *data, size_t * data_length,\n\t\t\t   unsigned int *type, unsigned int indx);\n\nunsigned int gnutls_heartbeat_get_timeout(gnutls_session_t session);\nvoid gnutls_heartbeat_set_timeouts(gnutls_session_t session,\n\t\t\t\t   unsigned int retrans_timeout,\n\t\t\t\t   unsigned int total_timeout);\n\n#define GNUTLS_HB_PEER_ALLOWED_TO_SEND (1)\n#define GNUTLS_HB_PEER_NOT_ALLOWED_TO_SEND (1<<1)\n\n  /* Heartbeat */\nvoid gnutls_heartbeat_enable(gnutls_session_t session, unsigned int type);\n\n#define GNUTLS_HB_LOCAL_ALLOWED_TO_SEND (1<<2)\nunsigned gnutls_heartbeat_allowed(gnutls_session_t session, unsigned int type);\n\n  /* Safe renegotiation */\nunsigned gnutls_safe_renegotiation_status(gnutls_session_t session);\nunsigned gnutls_session_ext_master_secret_status(gnutls_session_t session);\nunsigned gnutls_session_etm_status(gnutls_session_t session);\n\n/**\n * gnutls_session_flags_t:\n * @GNUTLS_SFLAGS_SAFE_RENEGOTIATION: Safe renegotiation (RFC5746) was used\n * @GNUTLS_SFLAGS_EXT_MASTER_SECRET: The extended master secret (RFC7627) extension was used\n * @GNUTLS_SFLAGS_ETM: The encrypt then MAC (RFC7366) extension was used\n * @GNUTLS_SFLAGS_RFC7919: The RFC7919 Diffie-Hellman parameters were negotiated\n * @GNUTLS_SFLAGS_HB_LOCAL_SEND: The heartbeat negotiation allows the local side to send heartbeat messages\n * @GNUTLS_SFLAGS_HB_PEER_SEND: The heartbeat negotiation allows the peer to send heartbeat messages\n * @GNUTLS_SFLAGS_FALSE_START: False start was used in this client session.\n * @GNUTLS_SFLAGS_SESSION_TICKET: A session ticket has been received by the server.\n * @GNUTLS_SFLAGS_POST_HANDSHAKE_AUTH: Indicates client capability for post-handshake auth; set only on server side.\n * @GNUTLS_SFLAGS_EARLY_START: The TLS1.3 server session returned early.\n * @GNUTLS_SFLAGS_EARLY_DATA: The TLS1.3 early data has been received by the server.\n * @GNUTLS_SFLAGS_CLI_REQUESTED_OCSP: Set when the client has requested OCSP staple during handshake.\n * @GNUTLS_SFLAGS_SERV_REQUESTED_OCSP: Set when the server has requested OCSP staple during handshake.\n *\n * Enumeration of different session parameters.\n */\ntypedef enum {\n\tGNUTLS_SFLAGS_SAFE_RENEGOTIATION = 1,\n\tGNUTLS_SFLAGS_EXT_MASTER_SECRET = 1<<1,\n\tGNUTLS_SFLAGS_ETM = 1<<2,\n\tGNUTLS_SFLAGS_HB_LOCAL_SEND = 1<<3,\n\tGNUTLS_SFLAGS_HB_PEER_SEND = 1<<4,\n\tGNUTLS_SFLAGS_FALSE_START = 1<<5,\n\tGNUTLS_SFLAGS_RFC7919 = 1<<6,\n\tGNUTLS_SFLAGS_SESSION_TICKET = 1<<7,\n\tGNUTLS_SFLAGS_POST_HANDSHAKE_AUTH = 1<<8,\n\tGNUTLS_SFLAGS_EARLY_START = 1<<9,\n\tGNUTLS_SFLAGS_EARLY_DATA = 1<<10,\n\tGNUTLS_SFLAGS_CLI_REQUESTED_OCSP = 1<<11,\n\tGNUTLS_SFLAGS_SERV_REQUESTED_OCSP = 1<<12\n} gnutls_session_flags_t;\n\nunsigned gnutls_session_get_flags(gnutls_session_t session);\n\n/**\n * gnutls_supplemental_data_format_type_t:\n * @GNUTLS_SUPPLEMENTAL_UNKNOWN: Unknown data format\n *\n * Enumeration of different supplemental data types (RFC 4680).\n */\ntypedef enum {\n\tGNUTLS_SUPPLEMENTAL_UNKNOWN = 0,\n} gnutls_supplemental_data_format_type_t;\n\nconst char\n*gnutls_supplemental_get_name(gnutls_supplemental_data_format_type_t type);\n\n  /* SessionTicket, RFC 5077. */\nint gnutls_session_ticket_key_generate(gnutls_datum_t * key);\nint gnutls_session_ticket_enable_client(gnutls_session_t session);\nint gnutls_session_ticket_enable_server(gnutls_session_t session,\n\t\t\t\t\tconst gnutls_datum_t * key);\n\nint gnutls_session_ticket_send(gnutls_session_t session, unsigned nr, unsigned flags);\n\n  /* SRTP, RFC 5764 */\n\n/**\n * gnutls_srtp_profile_t:\n * @GNUTLS_SRTP_AES128_CM_HMAC_SHA1_80: 128 bit AES with a 80 bit HMAC-SHA1\n * @GNUTLS_SRTP_AES128_CM_HMAC_SHA1_32: 128 bit AES with a 32 bit HMAC-SHA1\n * @GNUTLS_SRTP_NULL_HMAC_SHA1_80: NULL cipher with a 80 bit HMAC-SHA1\n * @GNUTLS_SRTP_NULL_HMAC_SHA1_32: NULL cipher with a 32 bit HMAC-SHA1\n *\n * Enumeration of different SRTP protection profiles.\n */\ntypedef enum {\n\tGNUTLS_SRTP_AES128_CM_HMAC_SHA1_80 = 0x0001,\n\tGNUTLS_SRTP_AES128_CM_HMAC_SHA1_32 = 0x0002,\n\tGNUTLS_SRTP_NULL_HMAC_SHA1_80 = 0x0005,\n\tGNUTLS_SRTP_NULL_HMAC_SHA1_32 = 0x0006\n} gnutls_srtp_profile_t;\n\nint gnutls_srtp_set_profile(gnutls_session_t session,\n\t\t\t    gnutls_srtp_profile_t profile);\nint gnutls_srtp_set_profile_direct(gnutls_session_t session,\n\t\t\t\t   const char *profiles,\n\t\t\t\t   const char **err_pos);\nint gnutls_srtp_get_selected_profile(gnutls_session_t session,\n\t\t\t\t     gnutls_srtp_profile_t * profile);\n\nconst char *gnutls_srtp_get_profile_name(gnutls_srtp_profile_t profile);\nint gnutls_srtp_get_profile_id(const char *name,\n\t\t\t       gnutls_srtp_profile_t * profile);\nint gnutls_srtp_get_keys(gnutls_session_t session,\n\t\t\t void *key_material,\n\t\t\t unsigned int key_material_size,\n\t\t\t gnutls_datum_t * client_key,\n\t\t\t gnutls_datum_t * client_salt,\n\t\t\t gnutls_datum_t * server_key,\n\t\t\t gnutls_datum_t * server_salt);\n\nint gnutls_srtp_set_mki(gnutls_session_t session,\n\t\t\tconst gnutls_datum_t * mki);\nint gnutls_srtp_get_mki(gnutls_session_t session, gnutls_datum_t * mki);\n\n/* COMPRESS_CERTIFICATE extension, RFC8879 */\ngnutls_compression_method_t\ngnutls_compress_certificate_get_selected_method(gnutls_session_t session);\nint gnutls_compress_certificate_set_methods(gnutls_session_t session,\n\t\t\t\t\t    const gnutls_compression_method_t * methods,\n\t\t\t\t\t    size_t methods_len);\n\n/* ALPN TLS extension */\n\n/**\n * gnutls_alpn_flags_t:\n * @GNUTLS_ALPN_MANDATORY: Require ALPN negotiation. The connection will be\n *   aborted if no matching ALPN protocol is found.\n * @GNUTLS_ALPN_SERVER_PRECEDENCE: The choices set by the server\n *   will take precedence over the client's.\n *\n * Enumeration of different ALPN flags. These are used by gnutls_alpn_set_protocols().\n */\ntypedef enum {\n\tGNUTLS_ALPN_MANDATORY = 1,\n\tGNUTLS_ALPN_SERVER_PRECEDENCE = (1<<1)\n} gnutls_alpn_flags_t;\n\n#define GNUTLS_ALPN_MAND GNUTLS_ALPN_MANDATORY\nint gnutls_alpn_get_selected_protocol(gnutls_session_t session,\n\t\t\t\t      gnutls_datum_t * protocol);\nint gnutls_alpn_set_protocols(gnutls_session_t session,\n\t\t\t      const gnutls_datum_t * protocols,\n\t\t\t      unsigned protocols_size, unsigned flags);\n\nint gnutls_key_generate(gnutls_datum_t * key, unsigned int key_size);\n\n\n#define GNUTLS_PRIORITY_INIT_DEF_APPEND 1\nint gnutls_priority_init(gnutls_priority_t * priority_cache,\n\t\t\t const char *priorities, const char **err_pos);\nint gnutls_priority_init2(gnutls_priority_t * priority_cache,\n\t\t\t  const char *priorities, const char **err_pos,\n\t\t\t  unsigned flags);\nvoid gnutls_priority_deinit(gnutls_priority_t priority_cache);\nint gnutls_priority_get_cipher_suite_index(gnutls_priority_t pcache,\n\t\t\t\t\t   unsigned int idx,\n\t\t\t\t\t   unsigned int *sidx);\n\n#define GNUTLS_PRIORITY_LIST_INIT_KEYWORDS 1\n#define GNUTLS_PRIORITY_LIST_SPECIAL 2\nconst char *\ngnutls_priority_string_list(unsigned iter, unsigned int flags);\n\nint gnutls_priority_set(gnutls_session_t session,\n\t\t\tgnutls_priority_t priority);\n\nint gnutls_priority_set_direct(gnutls_session_t session,\n\t\t\t       const char *priorities,\n\t\t\t       const char **err_pos);\n\nint gnutls_priority_certificate_type_list(gnutls_priority_t pcache,\n\t\t\t\t\t  const unsigned int **list);\nint gnutls_priority_certificate_type_list2(gnutls_priority_t pcache,\n\t\t\t\t\t  const unsigned int **list,\n\t\t\t\t\t  gnutls_ctype_target_t target);\nint gnutls_priority_sign_list(gnutls_priority_t pcache,\n\t\t\t      const unsigned int **list);\nint gnutls_priority_protocol_list(gnutls_priority_t pcache,\n\t\t\t\t  const unsigned int **list);\nint gnutls_priority_ecc_curve_list(gnutls_priority_t pcache,\n\t\t\t\t   const unsigned int **list);\nint\ngnutls_priority_group_list(gnutls_priority_t pcache,\n\t\t\t   const unsigned int **list);\n\nint gnutls_priority_kx_list(gnutls_priority_t pcache,\n\t\t\t    const unsigned int **list);\nint gnutls_priority_cipher_list(gnutls_priority_t pcache,\n\t\t\t\tconst unsigned int **list);\nint gnutls_priority_mac_list(gnutls_priority_t pcache,\n\t\t\t     const unsigned int **list);\n\nconst char *gnutls_get_system_config_file(void);\n\nint gnutls_set_default_priority(gnutls_session_t session);\nint gnutls_set_default_priority_append(gnutls_session_t session,\n\t\t\t\t       const char *add_prio,\n\t\t\t\t       const char **err_pos,\n\t\t\t\t       unsigned flags);\n\n/* Returns the name of a cipher suite */\nconst char *\n\tgnutls_cipher_suite_get_name(gnutls_kx_algorithm_t kx_algorithm,\n\t\t\t\t     gnutls_cipher_algorithm_t cipher_algorithm,\n\t\t\t\t     gnutls_mac_algorithm_t mac_algorithm) __GNUTLS_CONST__;\n\nconst char *\ngnutls_ciphersuite_get(gnutls_session_t session) __GNUTLS_CONST__;\n\n/* get the currently used protocol version */\ngnutls_protocol_t gnutls_protocol_get_version(gnutls_session_t session);\n\nconst char *\n\tgnutls_protocol_get_name(gnutls_protocol_t version) __GNUTLS_CONST__;\n\n\n/* get/set session\n */\nint gnutls_session_set_data(gnutls_session_t session,\n\t\t\t    const void *session_data,\n\t\t\t    size_t session_data_size);\nint gnutls_session_get_data(gnutls_session_t session, void *session_data,\n\t\t\t    size_t * session_data_size);\nint gnutls_session_get_data2(gnutls_session_t session,\n\t\t\t     gnutls_datum_t * data);\nvoid gnutls_session_get_random(gnutls_session_t session,\n\t\t\t       gnutls_datum_t * client,\n\t\t\t       gnutls_datum_t * server);\n\nvoid gnutls_session_get_master_secret(gnutls_session_t session,\n\t\t\t              gnutls_datum_t * secret);\n\nchar *gnutls_session_get_desc(gnutls_session_t session);\n\ntypedef int gnutls_certificate_verify_function(gnutls_session_t);\nvoid gnutls_session_set_verify_function(gnutls_session_t session, gnutls_certificate_verify_function * func);\n\n/**\n * gnutls_vdata_types_t:\n * @GNUTLS_DT_UNKNOWN: Unknown data type.\n * @GNUTLS_DT_DNS_HOSTNAME: The data contain a null-terminated DNS hostname; the hostname will be \n *   matched using the RFC6125 rules. If the data contain a textual IP (v4 or v6) address it will\n *   be marched against the IPAddress Alternative name, unless the verification flag %GNUTLS_VERIFY_DO_NOT_ALLOW_IP_MATCHES\n *   is specified.\n * @GNUTLS_DT_IP_ADDRESS: The data contain a raw IP address (4 or 16 bytes). If will be matched\n *   against the IPAddress Alternative name; option available since 3.6.0.\n * @GNUTLS_DT_RFC822NAME: The data contain a null-terminated email address; the email will be\n *   matched against the RFC822Name Alternative name of the certificate, or the EMAIL DN component if the\n *   former isn't available. Prior to matching the email address will be converted to ACE\n *   (ASCII-compatible-encoding).\n * @GNUTLS_DT_KEY_PURPOSE_OID: The data contain a null-terminated key purpose OID. It will be matched\n *   against the certificate's Extended Key Usage extension.\n *\n * Enumeration of different typed-data options. They are used as input to certificate\n * verification functions to provide information about the name and purpose of the\n * certificate. Only a single option of a type can be provided to the relevant functions\n * (i.e., options %GNUTLS_DT_DNS_HOSTNAME, %GNUTLS_DT_IP_ADDRESS and\n * %GNUTLS_DT_RFC822NAME cannot be combined).\n */\ntypedef enum {\n\tGNUTLS_DT_UNKNOWN = 0,\n\tGNUTLS_DT_DNS_HOSTNAME = 1,\n\tGNUTLS_DT_KEY_PURPOSE_OID = 2,\n\tGNUTLS_DT_RFC822NAME = 3,\n\tGNUTLS_DT_IP_ADDRESS = 4\n} gnutls_vdata_types_t;\n\ntypedef struct {\n\tgnutls_vdata_types_t type;\n\tunsigned char *data;\n\tunsigned int size;\n} gnutls_typed_vdata_st;\n\nvoid gnutls_session_set_verify_cert(gnutls_session_t session,\n\t\t\t       const char *hostname, unsigned flags);\n\nvoid\ngnutls_session_set_verify_cert2(gnutls_session_t session,\n\t\t\t\tgnutls_typed_vdata_st * data,\n\t\t\t\tunsigned elements, unsigned flags);\n\nunsigned int gnutls_session_get_verify_cert_status(gnutls_session_t);\n\nint gnutls_session_set_premaster(gnutls_session_t session,\n\t\t\t\t unsigned int entity,\n\t\t\t\t gnutls_protocol_t version,\n\t\t\t\t gnutls_kx_algorithm_t kx,\n\t\t\t\t gnutls_cipher_algorithm_t cipher,\n\t\t\t\t gnutls_mac_algorithm_t mac,\n\t\t\t\t gnutls_compression_method_t comp,\n\t\t\t\t const gnutls_datum_t * master,\n\t\t\t\t const gnutls_datum_t * session_id);\n\n/* returns the session ID */\n#define GNUTLS_MAX_SESSION_ID 32\nint gnutls_session_get_id(gnutls_session_t session, void *session_id,\n\t\t\t  size_t * session_id_size);\nint gnutls_session_get_id2(gnutls_session_t session,\n\t\t\t   gnutls_datum_t * session_id);\n\nint gnutls_session_set_id(gnutls_session_t session,\n\t\t\t  const gnutls_datum_t * sid);\n\nint gnutls_session_channel_binding(gnutls_session_t session,\n\t\t\t\t   gnutls_channel_binding_t cbtype,\n\t\t\t\t   gnutls_datum_t * cb);\n\n/* checks if this session is a resumed one\n */\nint gnutls_session_is_resumed(gnutls_session_t session);\nint gnutls_session_resumption_requested(gnutls_session_t session);\n\ntypedef int (*gnutls_db_store_func) (void *, gnutls_datum_t key,\n\t\t\t\t     gnutls_datum_t data);\ntypedef int (*gnutls_db_remove_func) (void *, gnutls_datum_t key);\ntypedef gnutls_datum_t(*gnutls_db_retr_func) (void *, gnutls_datum_t key);\n\nvoid gnutls_db_set_cache_expiration(gnutls_session_t session, int seconds);\nunsigned gnutls_db_get_default_cache_expiration(void);\n\nvoid gnutls_db_remove_session(gnutls_session_t session);\nvoid gnutls_db_set_retrieve_function(gnutls_session_t session,\n\t\t\t\t     gnutls_db_retr_func retr_func);\nvoid gnutls_db_set_remove_function(gnutls_session_t session,\n\t\t\t\t   gnutls_db_remove_func rem_func);\nvoid gnutls_db_set_store_function(gnutls_session_t session,\n\t\t\t\t  gnutls_db_store_func store_func);\nvoid gnutls_db_set_ptr(gnutls_session_t session, void *ptr);\nvoid *gnutls_db_get_ptr(gnutls_session_t session);\nint gnutls_db_check_entry(gnutls_session_t session,\n\t\t\t  gnutls_datum_t session_entry);\ntime_t gnutls_db_check_entry_time(gnutls_datum_t * entry);\ntime_t gnutls_db_check_entry_expire_time(gnutls_datum_t * entry);\n\n  /**\n   * gnutls_handshake_hook_func:\n   * @session: the current session\n   * @htype: the type of the handshake message (%gnutls_handshake_description_t)\n   * @when: non zero if this is a post-process/generation call and zero otherwise\n   * @incoming: non zero if this is an incoming message and zero if this is an outgoing message\n   * @msg: the (const) data of the handshake message without the handshake headers.\n   *\n   * Function prototype for handshake hooks. It is set using\n   * gnutls_handshake_set_hook_function().\n   *\n   * Returns: Non zero on error.\n   */\n#define GNUTLS_HOOK_POST (1)\n#define GNUTLS_HOOK_PRE (0)\n#define GNUTLS_HOOK_BOTH (-1)\n\ntypedef int (*gnutls_handshake_hook_func) (gnutls_session_t,\n\t\t\t\t\t   unsigned int htype,\n\t\t\t\t\t   unsigned when,\n\t\t\t\t\t   unsigned int incoming,\n\t\t\t\t\t   const gnutls_datum_t *msg);\nvoid gnutls_handshake_set_hook_function(gnutls_session_t session,\n\t\t\t\t\tunsigned int htype, int when,\n\t\t\t\t\tgnutls_handshake_hook_func func);\n\n#define gnutls_handshake_post_client_hello_func gnutls_handshake_simple_hook_func\ntypedef int (*gnutls_handshake_simple_hook_func) (gnutls_session_t);\nvoid\ngnutls_handshake_set_post_client_hello_function(gnutls_session_t session,\n\t\t\t\t\t\tgnutls_handshake_simple_hook_func func);\n\nvoid gnutls_handshake_set_max_packet_length(gnutls_session_t session,\n\t\t\t\t\t    size_t max);\n\n/* returns libgnutls version (call it with a NULL argument)\n */\nconst char * gnutls_check_version(const char *req_version) __GNUTLS_CONST__;\n\n/* A macro which will allow optimizing out calls to gnutls_check_version()\n * when the version being compiled with is sufficient.\n * Used as:\n *   if (gnutls_check_version_numerc(3,3,16)) {\n */\n#define gnutls_check_version_numeric(a,b,c) \\\n\t((GNUTLS_VERSION_MAJOR >= (a)) &&  \\\n\t ((GNUTLS_VERSION_NUMBER >= ( ((a) << 16) + ((b) << 8) + (c) )) || \\\n\t gnutls_check_version(#a \".\" #b \".\" #c)))\n\n/* Functions for setting/clearing credentials\n */\nvoid gnutls_credentials_clear(gnutls_session_t session);\n\n/* cred is a structure defined by the kx algorithm\n */\nint gnutls_credentials_set(gnutls_session_t session,\n\t\t\t   gnutls_credentials_type_t type, void *cred);\nint gnutls_credentials_get(gnutls_session_t session,\n\t\t\t   gnutls_credentials_type_t type, void **cred);\n#define gnutls_cred_set\tgnutls_credentials_set\n\n/* x.509 types */\n\nstruct gnutls_pubkey_st;\ntypedef struct gnutls_pubkey_st *gnutls_pubkey_t;\n\nstruct gnutls_privkey_st;\ntypedef struct gnutls_privkey_st *gnutls_privkey_t;\n\nstruct gnutls_x509_privkey_int;\ntypedef struct gnutls_x509_privkey_int *gnutls_x509_privkey_t;\n\nstruct gnutls_x509_crl_int;\ntypedef struct gnutls_x509_crl_int *gnutls_x509_crl_t;\n\nstruct gnutls_x509_crt_int;\ntypedef struct gnutls_x509_crt_int *gnutls_x509_crt_t;\n\nstruct gnutls_x509_crq_int;\ntypedef struct gnutls_x509_crq_int *gnutls_x509_crq_t;\n\nstruct gnutls_openpgp_keyring_int;\ntypedef struct gnutls_openpgp_keyring_int *gnutls_openpgp_keyring_t;\n\n\n/* Credential structures - used in gnutls_credentials_set(); */\n\nstruct gnutls_certificate_credentials_st;\ntypedef struct gnutls_certificate_credentials_st\n*gnutls_certificate_credentials_t;\ntypedef gnutls_certificate_credentials_t\n    gnutls_certificate_server_credentials;\ntypedef gnutls_certificate_credentials_t\n    gnutls_certificate_client_credentials;\n\ntypedef struct gnutls_anon_server_credentials_st\n*gnutls_anon_server_credentials_t;\ntypedef struct gnutls_anon_client_credentials_st\n*gnutls_anon_client_credentials_t;\n\nvoid gnutls_anon_free_server_credentials(gnutls_anon_server_credentials_t\n\t\t\t\t\t sc);\nint\ngnutls_anon_allocate_server_credentials(gnutls_anon_server_credentials_t\n\t\t\t\t\t* sc);\n\nvoid gnutls_anon_set_server_dh_params(gnutls_anon_server_credentials_t res,\n\t\t\t\t      gnutls_dh_params_t dh_params);\n\nint\ngnutls_anon_set_server_known_dh_params(gnutls_anon_server_credentials_t res,\n\t\t\t\t\tgnutls_sec_param_t sec_param);\n\nvoid\ngnutls_anon_set_server_params_function(gnutls_anon_server_credentials_t\n\t\t\t\t       res, gnutls_params_function * func);\n\nvoid\ngnutls_anon_free_client_credentials(gnutls_anon_client_credentials_t sc);\nint\ngnutls_anon_allocate_client_credentials(gnutls_anon_client_credentials_t\n\t\t\t\t\t* sc);\n\n/* CERTFILE is an x509 certificate in PEM form.\n * KEYFILE is a pkcs-1 private key in PEM form (for RSA keys).\n */\nvoid\ngnutls_certificate_free_credentials(gnutls_certificate_credentials_t sc);\nint\ngnutls_certificate_allocate_credentials(gnutls_certificate_credentials_t\n\t\t\t\t\t* res);\n\nint\ngnutls_certificate_get_issuer(gnutls_certificate_credentials_t sc,\n\t\t\t      gnutls_x509_crt_t cert,\n\t\t\t      gnutls_x509_crt_t * issuer,\n\t\t\t      unsigned int flags);\n\nint gnutls_certificate_get_crt_raw(gnutls_certificate_credentials_t sc,\n\t\t\t\t   unsigned idx1, unsigned idx2,\n\t\t\t\t   gnutls_datum_t * cert);\n\nvoid gnutls_certificate_free_keys(gnutls_certificate_credentials_t sc);\nvoid gnutls_certificate_free_cas(gnutls_certificate_credentials_t sc);\nvoid gnutls_certificate_free_ca_names(gnutls_certificate_credentials_t sc);\nvoid gnutls_certificate_free_crls(gnutls_certificate_credentials_t sc);\n\nvoid gnutls_certificate_set_dh_params(gnutls_certificate_credentials_t res,\n\t\t\t\t      gnutls_dh_params_t dh_params);\n\nint gnutls_certificate_set_known_dh_params(gnutls_certificate_credentials_t res,\n\t\t\t\t\t   gnutls_sec_param_t sec_param);\nvoid gnutls_certificate_set_verify_flags(gnutls_certificate_credentials_t\n\t\t\t\t\t res, unsigned int flags);\nunsigned int\ngnutls_certificate_get_verify_flags(gnutls_certificate_credentials_t res);\n\n/**\n * gnutls_certificate_flags:\n * @GNUTLS_CERTIFICATE_SKIP_KEY_CERT_MATCH: Skip the key and certificate matching check.\n * @GNUTLS_CERTIFICATE_API_V2: If set the gnutls_certificate_set_*key* functions will return an index of the added key pair instead of zero.\n * @GNUTLS_CERTIFICATE_SKIP_OCSP_RESPONSE_CHECK: If set, the gnutls_certificate_set_ocsp_status_request_file\n *    function, will not check whether the response set matches any of the certificates.\n * @GNUTLS_CERTIFICATE_VERIFY_CRLS: This will enable CRL verification when added in the certificate structure.\n *    When used, it requires CAs to be added before CRLs.\n *\n * Enumeration of different certificate credentials flags.\n */\ntypedef enum gnutls_certificate_flags {\n\tGNUTLS_CERTIFICATE_SKIP_KEY_CERT_MATCH = 1,\n\tGNUTLS_CERTIFICATE_API_V2 = (1<<1),\n\tGNUTLS_CERTIFICATE_SKIP_OCSP_RESPONSE_CHECK = (1<<2),\n\tGNUTLS_CERTIFICATE_VERIFY_CRLS = (1<<3)\n} gnutls_certificate_flags;\n\nvoid gnutls_certificate_set_flags(gnutls_certificate_credentials_t,\n\t\t\t\t  unsigned flags);\n\nvoid gnutls_certificate_set_verify_limits(gnutls_certificate_credentials_t\n\t\t\t\t\t  res, unsigned int max_bits,\n\t\t\t\t\t  unsigned int max_depth);\n\nint\ngnutls_certificate_set_x509_system_trust(gnutls_certificate_credentials_t\n\t\t\t\t\t cred);\n\nint\ngnutls_certificate_set_x509_trust_file(gnutls_certificate_credentials_t\n\t\t\t\t       cred, const char *cafile,\n\t\t\t\t       gnutls_x509_crt_fmt_t type);\nint\ngnutls_certificate_set_x509_trust_dir(gnutls_certificate_credentials_t cred,\n\t\t\t\t      const char *ca_dir,\n\t\t\t\t      gnutls_x509_crt_fmt_t type);\n\nint gnutls_certificate_set_x509_trust_mem(gnutls_certificate_credentials_t\n\t\t\t\t\t  res, const gnutls_datum_t * ca,\n\t\t\t\t\t  gnutls_x509_crt_fmt_t type);\n\nint\ngnutls_certificate_set_x509_crl_file(gnutls_certificate_credentials_t\n\t\t\t\t     res, const char *crlfile,\n\t\t\t\t     gnutls_x509_crt_fmt_t type);\nint gnutls_certificate_set_x509_crl_mem(gnutls_certificate_credentials_t\n\t\t\t\t\tres, const gnutls_datum_t * CRL,\n\t\t\t\t\tgnutls_x509_crt_fmt_t type);\n\nint\ngnutls_certificate_set_x509_key_file(gnutls_certificate_credentials_t\n\t\t\t\t     res, const char *certfile,\n\t\t\t\t     const char *keyfile,\n\t\t\t\t     gnutls_x509_crt_fmt_t type);\n\nint\ngnutls_certificate_set_x509_key_file2(gnutls_certificate_credentials_t\n\t\t\t\t      res, const char *certfile,\n\t\t\t\t      const char *keyfile,\n\t\t\t\t      gnutls_x509_crt_fmt_t type,\n\t\t\t\t      const char *pass,\n\t\t\t\t      unsigned int flags);\n\nint gnutls_certificate_set_x509_key_mem(gnutls_certificate_credentials_t\n\t\t\t\t\tres, const gnutls_datum_t * cert,\n\t\t\t\t\tconst gnutls_datum_t * key,\n\t\t\t\t\tgnutls_x509_crt_fmt_t type);\n\nint gnutls_certificate_set_x509_key_mem2(gnutls_certificate_credentials_t\n\t\t\t\t\t res, const gnutls_datum_t * cert,\n\t\t\t\t\t const gnutls_datum_t * key,\n\t\t\t\t\t gnutls_x509_crt_fmt_t type,\n\t\t\t\t\t const char *pass,\n\t\t\t\t\t unsigned int flags);\n\nvoid gnutls_certificate_send_x509_rdn_sequence(gnutls_session_t session,\n\t\t\t\t\t       int status);\n\nint\ngnutls_certificate_set_x509_simple_pkcs12_file\n(gnutls_certificate_credentials_t res, const char *pkcs12file,\n gnutls_x509_crt_fmt_t type, const char *password);\nint\ngnutls_certificate_set_x509_simple_pkcs12_mem\n(gnutls_certificate_credentials_t res, const gnutls_datum_t * p12blob,\n gnutls_x509_crt_fmt_t type, const char *password);\n\n/* New functions to allow setting already parsed X.509 stuff.\n */\n\nint gnutls_certificate_set_x509_key(gnutls_certificate_credentials_t res,\n\t\t\t\t    gnutls_x509_crt_t * cert_list,\n\t\t\t\t    int cert_list_size,\n\t\t\t\t    gnutls_x509_privkey_t key);\nint gnutls_certificate_set_x509_trust(gnutls_certificate_credentials_t res,\n\t\t\t\t      gnutls_x509_crt_t * ca_list,\n\t\t\t\t      int ca_list_size);\nint gnutls_certificate_set_x509_crl(gnutls_certificate_credentials_t res,\n\t\t\t\t    gnutls_x509_crl_t * crl_list,\n\t\t\t\t    int crl_list_size);\n\nint gnutls_certificate_get_x509_key(gnutls_certificate_credentials_t res,\n                                    unsigned index,\n                                    gnutls_x509_privkey_t *key);\nint gnutls_certificate_get_x509_crt(gnutls_certificate_credentials_t res,\n                                    unsigned index,\n                                    gnutls_x509_crt_t **crt_list,\n                                    unsigned *crt_list_size);\n\n  /* OCSP status request extension, RFC 6066 */\ntypedef int (*gnutls_status_request_ocsp_func)\n (gnutls_session_t session, void *ptr, gnutls_datum_t *ocsp_response);\n\nvoid\ngnutls_certificate_set_ocsp_status_request_function\n(gnutls_certificate_credentials_t res,\ngnutls_status_request_ocsp_func ocsp_func, void *ptr);\n\nint\ngnutls_certificate_set_ocsp_status_request_function2\n(gnutls_certificate_credentials_t res, unsigned idx,\ngnutls_status_request_ocsp_func ocsp_func, void *ptr);\n\nint\ngnutls_certificate_set_ocsp_status_request_file\n(gnutls_certificate_credentials_t res, const char *response_file,\n unsigned idx);\n\nint\ngnutls_certificate_set_ocsp_status_request_file2\n(gnutls_certificate_credentials_t res, const char *response_file,\n unsigned idx, gnutls_x509_crt_fmt_t fmt);\n\nint\ngnutls_certificate_set_ocsp_status_request_mem\n(gnutls_certificate_credentials_t res, const gnutls_datum_t *resp,\n unsigned idx, gnutls_x509_crt_fmt_t fmt);\n\ntypedef struct gnutls_ocsp_data_st {\n\tunsigned int version; /* must be zero */\n\tgnutls_datum_t response;\n\ttime_t exptime;\n\tunsigned char padding[32];\n} gnutls_ocsp_data_st;\n\ntime_t\ngnutls_certificate_get_ocsp_expiration(gnutls_certificate_credentials_t sc,\n\t\t\t\t       unsigned idx,\n\t\t\t\t       int oidx,\n\t\t\t\t       unsigned flags);\n\nint gnutls_ocsp_status_request_enable_client(gnutls_session_t session,\n\t\t\t\t\t     gnutls_datum_t * responder_id,\n\t\t\t\t\t     size_t responder_id_size,\n\t\t\t\t\t     gnutls_datum_t *\n\t\t\t\t\t     request_extensions);\n\nint gnutls_ocsp_status_request_get(gnutls_session_t session,\n\t\t\t\t   gnutls_datum_t * response);\n\n#define GNUTLS_OCSP_SR_IS_AVAIL 1\nunsigned gnutls_ocsp_status_request_is_checked(gnutls_session_t session,\n\t\t\t\t\t       unsigned int flags);\n\nint\ngnutls_ocsp_status_request_get2(gnutls_session_t session,\n\t\t\t        unsigned idx,\n\t\t\t        gnutls_datum_t * response);\n\n/* RAW public key functions (RFC7250) */\nint gnutls_certificate_set_rawpk_key_mem(gnutls_certificate_credentials_t cred,\n\t\t\t\t    const gnutls_datum_t* spki,\n\t\t\t\t    const gnutls_datum_t* pkey,\n\t\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t\t    const char* pass,\n\t\t\t\t    unsigned int key_usage,\n\t\t\t\t    const char **names,\n\t\t\t\t    unsigned int names_length,\n\t\t\t\t    unsigned int flags);\n\nint gnutls_certificate_set_rawpk_key_file(gnutls_certificate_credentials_t cred,\n\t\t\t\t      const char* rawpkfile,\n\t\t\t\t      const char* privkeyfile,\n\t\t\t\t      gnutls_x509_crt_fmt_t format,\n\t\t\t\t      const char *pass,\n\t\t\t\t      unsigned int key_usage,\n\t\t\t\t      const char **names,\n\t\t\t\t      unsigned int names_length,\n\t\t\t\t      unsigned int privkey_flags,\n\t\t\t\t      unsigned int pkcs11_flags);\n\n\n/* global state functions\n */\nint gnutls_global_init(void);\nvoid gnutls_global_deinit(void);\n\nconst gnutls_library_config_st *gnutls_get_library_config(void);\n\n  /**\n   * gnutls_time_func:\n   * @t: where to store time.\n   *\n   * Function prototype for time()-like function.  Set with\n   * gnutls_global_set_time_function().\n   *\n   * Returns: Number of seconds since the epoch, or (time_t)-1 on errors.\n   */\ntypedef time_t(*gnutls_time_func) (time_t * t);\n\ntypedef int (*mutex_init_func) (void **mutex);\ntypedef int (*mutex_lock_func) (void **mutex);\ntypedef int (*mutex_unlock_func) (void **mutex);\ntypedef int (*mutex_deinit_func) (void **mutex);\n\nvoid gnutls_global_set_mutex(mutex_init_func init,\n\t\t\t     mutex_deinit_func deinit,\n\t\t\t     mutex_lock_func lock,\n\t\t\t     mutex_unlock_func unlock);\n\ntypedef void *(*gnutls_alloc_function) (size_t);\ntypedef void *(*gnutls_calloc_function) (size_t, size_t);\ntypedef int (*gnutls_is_secure_function) (const void *);\ntypedef void (*gnutls_free_function) (void *);\ntypedef void *(*gnutls_realloc_function) (void *, size_t);\n\nvoid gnutls_global_set_time_function(gnutls_time_func time_func);\n\n/* For use in callbacks */\nextern _SYM_EXPORT gnutls_alloc_function gnutls_malloc;\nextern _SYM_EXPORT gnutls_realloc_function gnutls_realloc;\nextern _SYM_EXPORT gnutls_calloc_function gnutls_calloc;\nextern _SYM_EXPORT gnutls_free_function gnutls_free;\n\n#ifdef GNUTLS_INTERNAL_BUILD\n#define gnutls_free(a) gnutls_free((void *) (a)), a=NULL\n#endif\n\nextern _SYM_EXPORT char *(*gnutls_strdup) (const char *);\n\n/* a variant of memset that doesn't get optimized out */\nvoid gnutls_memset(void *data, int c, size_t size);\n\n/* constant time memcmp */\nint gnutls_memcmp(const void *s1, const void *s2, size_t n);\n\ntypedef void (*gnutls_log_func) (int, const char *);\ntypedef void (*gnutls_audit_log_func) (gnutls_session_t, const char *);\nvoid gnutls_global_set_log_function(gnutls_log_func log_func);\nvoid gnutls_global_set_audit_log_function(gnutls_audit_log_func log_func);\nvoid gnutls_global_set_log_level(int level);\n\n  /**\n   * gnutls_keylog_func:\n   * @session: the current session\n   * @label: the keylog label\n   * @secret: the (const) data of the derived secret.\n   *\n   * Function prototype for keylog hooks. It is set using\n   * gnutls_session_set_keylog_function().\n   *\n   * Returns: Non zero on error.\n   * Since: 3.6.13\n   */\ntypedef int (*gnutls_keylog_func) (gnutls_session_t session,\n\t\t\t\t   const char *label,\n\t\t\t\t   const gnutls_datum_t *secret);\ngnutls_keylog_func gnutls_session_get_keylog_function(const gnutls_session_t session);\nvoid gnutls_session_set_keylog_function(gnutls_session_t session,\n\t\t\t\t\tgnutls_keylog_func func);\n\n/* Diffie-Hellman parameter handling.\n */\nint gnutls_dh_params_init(gnutls_dh_params_t * dh_params);\nvoid gnutls_dh_params_deinit(gnutls_dh_params_t dh_params);\nint gnutls_dh_params_import_raw(gnutls_dh_params_t dh_params,\n\t\t\t\tconst gnutls_datum_t * prime,\n\t\t\t\tconst gnutls_datum_t * generator);\nint gnutls_dh_params_import_dsa(gnutls_dh_params_t dh_params, gnutls_x509_privkey_t key);\nint gnutls_dh_params_import_raw2(gnutls_dh_params_t dh_params,\n\t\t\t\t const gnutls_datum_t * prime,\n\t\t\t\t const gnutls_datum_t * generator,\n\t\t\t\t unsigned key_bits);\nint gnutls_dh_params_import_raw3(gnutls_dh_params_t dh_params,\n\t\t\t\t const gnutls_datum_t * prime,\n\t\t\t\t const gnutls_datum_t * q,\n\t\t\t\t const gnutls_datum_t * generator);\nint gnutls_dh_params_import_pkcs3(gnutls_dh_params_t params,\n\t\t\t\t  const gnutls_datum_t * pkcs3_params,\n\t\t\t\t  gnutls_x509_crt_fmt_t format);\nint gnutls_dh_params_generate2(gnutls_dh_params_t params,\n\t\t\t       unsigned int bits);\nint gnutls_dh_params_export_pkcs3(gnutls_dh_params_t params,\n\t\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t\t  unsigned char *params_data,\n\t\t\t\t  size_t * params_data_size);\nint gnutls_dh_params_export2_pkcs3(gnutls_dh_params_t params,\n\t\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t\t   gnutls_datum_t * out);\nint gnutls_dh_params_export_raw(gnutls_dh_params_t params,\n\t\t\t\tgnutls_datum_t * prime,\n\t\t\t\tgnutls_datum_t * generator,\n\t\t\t\tunsigned int *bits);\nint gnutls_dh_params_cpy(gnutls_dh_params_t dst, gnutls_dh_params_t src);\n\n\n\n/* Session stuff\n */\ntypedef struct {\n    void *iov_base;\n    size_t iov_len;\n} giovec_t;\n\ntypedef ssize_t(*gnutls_pull_func) (gnutls_transport_ptr_t, void *,\n\t\t\t\t    size_t);\ntypedef ssize_t(*gnutls_push_func) (gnutls_transport_ptr_t, const void *,\n\t\t\t\t    size_t);\n\nint gnutls_system_recv_timeout(gnutls_transport_ptr_t ptr, unsigned int ms);\ntypedef int (*gnutls_pull_timeout_func) (gnutls_transport_ptr_t,\n\t\t\t\t\t unsigned int ms);\n\ntypedef ssize_t(*gnutls_vec_push_func) (gnutls_transport_ptr_t,\n\t\t\t\t\tconst giovec_t * iov, int iovcnt);\n\ntypedef int (*gnutls_errno_func) (gnutls_transport_ptr_t);\n\n#if 0\n /* This will be defined as macro. */\n  void gnutls_transport_set_int (gnutls_session_t session, int r);\n#endif\n\nvoid gnutls_transport_set_int2(gnutls_session_t session, int r, int s);\n#define gnutls_transport_set_int(s, i) gnutls_transport_set_int2(s, i, i)\n\nvoid gnutls_transport_get_int2(gnutls_session_t session, int *r, int *s);\nint gnutls_transport_get_int(gnutls_session_t session);\n\nvoid gnutls_transport_set_ptr(gnutls_session_t session,\n\t\t\t      gnutls_transport_ptr_t ptr);\nvoid gnutls_transport_set_ptr2(gnutls_session_t session,\n\t\t\t       gnutls_transport_ptr_t recv_ptr,\n\t\t\t       gnutls_transport_ptr_t send_ptr);\n\ngnutls_transport_ptr_t gnutls_transport_get_ptr(gnutls_session_t session);\nvoid gnutls_transport_get_ptr2(gnutls_session_t session,\n\t\t\t       gnutls_transport_ptr_t * recv_ptr,\n\t\t\t       gnutls_transport_ptr_t * send_ptr);\n\nvoid gnutls_transport_set_vec_push_function(gnutls_session_t session,\n\t\t\t\t\t    gnutls_vec_push_func vec_func);\nvoid gnutls_transport_set_push_function(gnutls_session_t session,\n\t\t\t\t\tgnutls_push_func push_func);\nvoid gnutls_transport_set_pull_function(gnutls_session_t session,\n\t\t\t\t\tgnutls_pull_func pull_func);\n\nvoid gnutls_transport_set_pull_timeout_function(gnutls_session_t session,\n\t\t\t\t\t\tgnutls_pull_timeout_func\n\t\t\t\t\t\tfunc);\n\nvoid gnutls_transport_set_errno_function(gnutls_session_t session,\n\t\t\t\t\t gnutls_errno_func errno_func);\n\nvoid gnutls_transport_set_errno(gnutls_session_t session, int err);\n\n/* session specific\n */\nvoid gnutls_session_set_ptr(gnutls_session_t session, void *ptr);\nvoid *gnutls_session_get_ptr(gnutls_session_t session);\n\nvoid gnutls_openpgp_send_cert(gnutls_session_t session,\n\t\t\t      gnutls_openpgp_crt_status_t status);\n\n/* This function returns the hash of the given data.\n */\nint gnutls_fingerprint(gnutls_digest_algorithm_t algo,\n\t\t       const gnutls_datum_t * data, void *result,\n\t\t       size_t * result_size);\n\n  /**\n   * gnutls_random_art_t:\n   * @GNUTLS_RANDOM_ART_OPENSSH: OpenSSH-style random art.\n   *\n   * Enumeration of different random art types.\n   */\ntypedef enum gnutls_random_art {\n\tGNUTLS_RANDOM_ART_OPENSSH = 1\n} gnutls_random_art_t;\n\nint gnutls_random_art(gnutls_random_art_t type,\n\t\t      const char *key_type, unsigned int key_size,\n\t\t      void *fpr, size_t fpr_size, gnutls_datum_t * art);\n\n/* IDNA */\n#define GNUTLS_IDNA_FORCE_2008 (1<<1)\nint gnutls_idna_map(const char * input, unsigned ilen, gnutls_datum_t *out, unsigned flags);\nint gnutls_idna_reverse_map(const char *input, unsigned ilen, gnutls_datum_t *out, unsigned flags);\n\n/* SRP\n */\n\ntypedef struct gnutls_srp_server_credentials_st\n*gnutls_srp_server_credentials_t;\ntypedef struct gnutls_srp_client_credentials_st\n*gnutls_srp_client_credentials_t;\n\nvoid\ngnutls_srp_free_client_credentials(gnutls_srp_client_credentials_t sc);\nint\ngnutls_srp_allocate_client_credentials(gnutls_srp_client_credentials_t *\n\t\t\t\t       sc);\nint gnutls_srp_set_client_credentials(gnutls_srp_client_credentials_t res,\n\t\t\t\t      const char *username,\n\t\t\t\t      const char *password);\n\nvoid\ngnutls_srp_free_server_credentials(gnutls_srp_server_credentials_t sc);\nint\ngnutls_srp_allocate_server_credentials(gnutls_srp_server_credentials_t *\n\t\t\t\t       sc);\nint gnutls_srp_set_server_credentials_file(gnutls_srp_server_credentials_t\n\t\t\t\t\t   res, const char *password_file,\n\t\t\t\t\t   const char *password_conf_file);\n\nconst char *gnutls_srp_server_get_username(gnutls_session_t session);\n\nvoid gnutls_srp_set_prime_bits(gnutls_session_t session,\n                               unsigned int bits);\n\nint gnutls_srp_verifier(const char *username,\n\t\t\tconst char *password,\n\t\t\tconst gnutls_datum_t * salt,\n\t\t\tconst gnutls_datum_t * generator,\n\t\t\tconst gnutls_datum_t * prime,\n\t\t\tgnutls_datum_t * res);\n\n/* The static parameters defined in draft-ietf-tls-srp-05\n * Those should be used as input to gnutls_srp_verifier().\n */\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_8192_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_8192_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_4096_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_4096_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_3072_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_3072_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_2048_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_2048_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1536_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1536_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1024_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1024_group_generator;\n\n/* The static parameters defined in rfc7919\n */\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_8192_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_8192_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_8192_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_8192_key_bits;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_6144_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_6144_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_6144_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_6144_key_bits;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_4096_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_4096_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_4096_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_4096_key_bits;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_3072_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_3072_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_3072_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_3072_key_bits;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_2048_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_2048_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_2048_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_2048_key_bits;\n\ntypedef int gnutls_srp_server_credentials_function(gnutls_session_t,\n\t\t\t\t\t\t   const char *username,\n\t\t\t\t\t\t   gnutls_datum_t * salt,\n\t\t\t\t\t\t   gnutls_datum_t *\n\t\t\t\t\t\t   verifier,\n\t\t\t\t\t\t   gnutls_datum_t *\n\t\t\t\t\t\t   generator,\n\t\t\t\t\t\t   gnutls_datum_t * prime);\nvoid\ngnutls_srp_set_server_credentials_function(gnutls_srp_server_credentials_t\n\t\t\t\t\t   cred,\n\t\t\t\t\t   gnutls_srp_server_credentials_function\n\t\t\t\t\t   * func);\n\ntypedef int gnutls_srp_client_credentials_function(gnutls_session_t,\n\t\t\t\t\t\t   char **, char **);\nvoid\ngnutls_srp_set_client_credentials_function(gnutls_srp_client_credentials_t\n\t\t\t\t\t   cred,\n\t\t\t\t\t   gnutls_srp_client_credentials_function\n\t\t\t\t\t   * func);\n\nint gnutls_srp_base64_encode(const gnutls_datum_t * data, char *result,\n\t\t\t     size_t * result_size);\nint gnutls_srp_base64_encode2(const gnutls_datum_t * data,\n\t\t\t\t   gnutls_datum_t * result);\n\nint gnutls_srp_base64_decode(const gnutls_datum_t * b64_data, char *result,\n\t\t\t     size_t * result_size);\nint gnutls_srp_base64_decode2(const gnutls_datum_t * b64_data,\n\t\t\t\t   gnutls_datum_t * result);\n\n#define gnutls_srp_base64_encode_alloc gnutls_srp_base64_encode2\n#define gnutls_srp_base64_decode_alloc gnutls_srp_base64_decode2\n\nvoid\ngnutls_srp_set_server_fake_salt_seed(gnutls_srp_server_credentials_t\n\t\t\t\t     sc,\n\t\t\t\t     const gnutls_datum_t * seed,\n\t\t\t\t     unsigned int salt_length);\n\n/* PSK stuff */\ntypedef struct gnutls_psk_server_credentials_st\n*gnutls_psk_server_credentials_t;\ntypedef struct gnutls_psk_client_credentials_st\n*gnutls_psk_client_credentials_t;\n\n/**\n * gnutls_psk_key_flags:\n * @GNUTLS_PSK_KEY_RAW: PSK-key in raw format.\n * @GNUTLS_PSK_KEY_HEX: PSK-key in hex format.\n *\n * Enumeration of different PSK key flags.\n */\ntypedef enum gnutls_psk_key_flags {\n\tGNUTLS_PSK_KEY_RAW = 0,\n\tGNUTLS_PSK_KEY_HEX\n} gnutls_psk_key_flags;\n\nvoid\ngnutls_psk_free_client_credentials(gnutls_psk_client_credentials_t sc);\nint\ngnutls_psk_allocate_client_credentials(gnutls_psk_client_credentials_t *\n\t\t\t\t       sc);\nint gnutls_psk_set_client_credentials(gnutls_psk_client_credentials_t res,\n\t\t\t\t      const char *username,\n\t\t\t\t      const gnutls_datum_t * key,\n\t\t\t\t      gnutls_psk_key_flags flags);\nint gnutls_psk_set_client_credentials2(gnutls_psk_client_credentials_t res,\n\t\t\t\t       const gnutls_datum_t *username,\n\t\t\t\t       const gnutls_datum_t *key,\n\t\t\t\t       gnutls_psk_key_flags flags);\n\nvoid\ngnutls_psk_free_server_credentials(gnutls_psk_server_credentials_t sc);\nint\ngnutls_psk_allocate_server_credentials(gnutls_psk_server_credentials_t *\n\t\t\t\t       sc);\nint gnutls_psk_set_server_credentials_file(gnutls_psk_server_credentials_t\n\t\t\t\t\t   res, const char *password_file);\n\nint\ngnutls_psk_set_server_credentials_hint(gnutls_psk_server_credentials_t\n\t\t\t\t       res, const char *hint);\n\nconst char *gnutls_psk_server_get_username(gnutls_session_t session);\nint gnutls_psk_server_get_username2(gnutls_session_t session,\n\t\t\t\t    gnutls_datum_t *out);\nconst char *gnutls_psk_client_get_hint(gnutls_session_t session);\n\ntypedef int gnutls_psk_server_credentials_function(gnutls_session_t,\n\t\t\t\t\t\t   const char *username,\n\t\t\t\t\t\t   gnutls_datum_t * key);\ntypedef int gnutls_psk_server_credentials_function2(gnutls_session_t,\n\t\t\t\t\t\t    const gnutls_datum_t *username,\n\t\t\t\t\t\t    gnutls_datum_t *key);\nvoid\ngnutls_psk_set_server_credentials_function(gnutls_psk_server_credentials_t\n\t\t\t\t\t   cred,\n\t\t\t\t\t   gnutls_psk_server_credentials_function\n\t\t\t\t\t   * func);\nvoid\ngnutls_psk_set_server_credentials_function2(gnutls_psk_server_credentials_t cred,\n\t\t\t\t\t    gnutls_psk_server_credentials_function2 *func);\n\ntypedef int gnutls_psk_client_credentials_function(gnutls_session_t,\n\t\t\t\t\t\t   char **username,\n\t\t\t\t\t\t   gnutls_datum_t * key);\ntypedef int gnutls_psk_client_credentials_function2(gnutls_session_t,\n\t\t\t\t\t\t    gnutls_datum_t *username,\n\t\t\t\t\t\t    gnutls_datum_t *key);\nvoid\ngnutls_psk_set_client_credentials_function(gnutls_psk_client_credentials_t\n\t\t\t\t\t   cred,\n\t\t\t\t\t   gnutls_psk_client_credentials_function\n\t\t\t\t\t   * func);\nvoid\ngnutls_psk_set_client_credentials_function2(gnutls_psk_client_credentials_t cred,\n\t\t\t\t\t    gnutls_psk_client_credentials_function2 *func);\n\nint gnutls_hex_encode(const gnutls_datum_t * data, char *result,\n\t\t      size_t * result_size);\nint gnutls_hex_decode(const gnutls_datum_t * hex_data, void *result,\n\t\t      size_t * result_size);\n\nint gnutls_hex_encode2(const gnutls_datum_t * data, gnutls_datum_t *result);\nint gnutls_hex_decode2(const gnutls_datum_t * data, gnutls_datum_t *result);\n\nvoid\ngnutls_psk_set_server_dh_params(gnutls_psk_server_credentials_t res,\n\t\t\t\tgnutls_dh_params_t dh_params);\n\nint\ngnutls_psk_set_server_known_dh_params(gnutls_psk_server_credentials_t res,\n\t\t\t\t      gnutls_sec_param_t sec_param);\n\nvoid\ngnutls_psk_set_server_params_function(gnutls_psk_server_credentials_t\n\t\t\t\t      res, gnutls_params_function * func);\n\n/**\n * gnutls_x509_subject_alt_name_t:\n * @GNUTLS_SAN_DNSNAME: DNS-name SAN.\n * @GNUTLS_SAN_RFC822NAME: E-mail address SAN.\n * @GNUTLS_SAN_URI: URI SAN.\n * @GNUTLS_SAN_IPADDRESS: IP address SAN.\n * @GNUTLS_SAN_OTHERNAME: OtherName SAN.\n * @GNUTLS_SAN_DN: DN SAN.\n * @GNUTLS_SAN_REGISTERED_ID: RegisteredID.\n * @GNUTLS_SAN_OTHERNAME_XMPP: Virtual SAN, used by certain functions for convenience.\n * @GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL: Virtual SAN, used by certain functions for convenience.\n * @GNUTLS_SAN_OTHERNAME_MSUSERPRINCIPAL: Virtual SAN, used by certain functions for convenience.\n *\n * Enumeration of different subject alternative names types.\n */\ntypedef enum gnutls_x509_subject_alt_name_t {\n\tGNUTLS_SAN_DNSNAME = 1,\n\tGNUTLS_SAN_RFC822NAME = 2,\n\tGNUTLS_SAN_URI = 3,\n\tGNUTLS_SAN_IPADDRESS = 4,\n\tGNUTLS_SAN_OTHERNAME = 5,\n\tGNUTLS_SAN_DN = 6,\n\tGNUTLS_SAN_REGISTERED_ID = 7,\n\tGNUTLS_SAN_MAX = GNUTLS_SAN_REGISTERED_ID,\n\t/* The following are \"virtual\" subject alternative name types, in\n\t   that they are represented by an otherName value and an OID.\n\t   Used by gnutls_x509_crt_get_subject_alt_othername_oid.  */\n\tGNUTLS_SAN_OTHERNAME_XMPP = 1000,\n\tGNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL,\n\tGNUTLS_SAN_OTHERNAME_MSUSERPRINCIPAL\n} gnutls_x509_subject_alt_name_t;\n\nstruct gnutls_openpgp_crt_int;\ntypedef struct gnutls_openpgp_crt_int *gnutls_openpgp_crt_t;\n\nstruct gnutls_openpgp_privkey_int;\ntypedef struct gnutls_openpgp_privkey_int *gnutls_openpgp_privkey_t;\n\nstruct gnutls_pkcs11_privkey_st;\ntypedef struct gnutls_pkcs11_privkey_st *gnutls_pkcs11_privkey_t;\n\n/**\n * gnutls_privkey_type_t:\n * @GNUTLS_PRIVKEY_X509: X.509 private key, #gnutls_x509_privkey_t.\n * @GNUTLS_PRIVKEY_OPENPGP: OpenPGP private key, #gnutls_openpgp_privkey_t.\n * @GNUTLS_PRIVKEY_PKCS11: PKCS11 private key, #gnutls_pkcs11_privkey_t.\n * @GNUTLS_PRIVKEY_EXT: External private key, operating using callbacks.\n *\n * Enumeration of different private key types.\n */\ntypedef enum {\n\tGNUTLS_PRIVKEY_X509,\n\tGNUTLS_PRIVKEY_OPENPGP,\n\tGNUTLS_PRIVKEY_PKCS11,\n\tGNUTLS_PRIVKEY_EXT\n} gnutls_privkey_type_t;\n\ntypedef struct gnutls_retr2_st {\n\tgnutls_certificate_type_t cert_type;\n\tgnutls_privkey_type_t key_type;\n\n\tunion {\n\t\tgnutls_x509_crt_t *x509;\n\t\tgnutls_openpgp_crt_t pgp;\n\t} cert;\n\tunsigned int ncerts;\t/* one for pgp keys */\n\n\tunion {\n\t\tgnutls_x509_privkey_t x509;\n\t\tgnutls_openpgp_privkey_t pgp;\n\t\tgnutls_pkcs11_privkey_t pkcs11;\n\t} key;\n\n\tunsigned int deinit_all;\t/* if non zero all keys will be deinited */\n} gnutls_retr2_st;\n\n\n  /* Functions that allow auth_info_t structures handling\n   */\n\ngnutls_credentials_type_t gnutls_auth_get_type(gnutls_session_t session);\ngnutls_credentials_type_t\ngnutls_auth_server_get_type(gnutls_session_t session);\ngnutls_credentials_type_t\ngnutls_auth_client_get_type(gnutls_session_t session);\n\n  /* DH */\n\nvoid gnutls_dh_set_prime_bits(gnutls_session_t session, unsigned int bits);\nint gnutls_dh_get_secret_bits(gnutls_session_t session);\nint gnutls_dh_get_peers_public_bits(gnutls_session_t session);\nint gnutls_dh_get_prime_bits(gnutls_session_t session);\n\nint gnutls_dh_get_group(gnutls_session_t session, gnutls_datum_t * raw_gen,\n\t\t\tgnutls_datum_t * raw_prime);\nint gnutls_dh_get_pubkey(gnutls_session_t session,\n\t\t\t gnutls_datum_t * raw_key);\n\n  /* X509PKI */\n\n\n  /* These are set on the credentials structure.\n   */\n\n  /* use gnutls_certificate_set_retrieve_function2() in abstract.h\n   * instead. It's much more efficient.\n   */\n\ntypedef int gnutls_certificate_retrieve_function(gnutls_session_t,\n\t\t\t\t\t\t const\n\t\t\t\t\t\t gnutls_datum_t *\n\t\t\t\t\t\t req_ca_rdn,\n\t\t\t\t\t\t int nreqs,\n\t\t\t\t\t\t const\n\t\t\t\t\t\t gnutls_pk_algorithm_t\n\t\t\t\t\t\t * pk_algos,\n\t\t\t\t\t\t int\n\t\t\t\t\t\t pk_algos_length,\n\t\t\t\t\t\t gnutls_retr2_st *);\n\n\nvoid\ngnutls_certificate_set_retrieve_function(gnutls_certificate_credentials_t\n\t\t\t\t\t cred,\n\t\t\t\t\t gnutls_certificate_retrieve_function\n\t\t\t\t\t * func);\n\nvoid\ngnutls_certificate_set_verify_function(gnutls_certificate_credentials_t\n\t\t\t\t       cred,\n\t\t\t\t       gnutls_certificate_verify_function\n\t\t\t\t       * func);\n\nvoid\ngnutls_certificate_server_set_request(gnutls_session_t session,\n\t\t\t\t      gnutls_certificate_request_t req);\n\n  /* get data from the session\n   */\nconst gnutls_datum_t *gnutls_certificate_get_peers(gnutls_session_t\n\t\t\t\t\t\t   session, unsigned int\n\t\t\t\t\t\t   *list_size);\nconst gnutls_datum_t *gnutls_certificate_get_ours(gnutls_session_t\n\t\t\t\t\t\t  session);\n\nint gnutls_certificate_get_peers_subkey_id(gnutls_session_t session,\n\t\t\t\t\t   gnutls_datum_t * id);\n\ntime_t gnutls_certificate_activation_time_peers(gnutls_session_t session);\ntime_t gnutls_certificate_expiration_time_peers(gnutls_session_t session);\n\nunsigned gnutls_certificate_client_get_request_status(gnutls_session_t session);\nint gnutls_certificate_verify_peers2(gnutls_session_t session,\n\t\t\t\t     unsigned int *status);\nint gnutls_certificate_verify_peers3(gnutls_session_t session,\n\t\t\t\t     const char *hostname,\n\t\t\t\t     unsigned int *status);\n\nint\ngnutls_certificate_verify_peers(gnutls_session_t session,\n\t\t\t\tgnutls_typed_vdata_st * data,\n\t\t\t\tunsigned int elements,\n\t\t\t\tunsigned int *status);\n\nint gnutls_certificate_verification_status_print(unsigned int status,\n\t\t\t\t\t\t gnutls_certificate_type_t\n\t\t\t\t\t\t type,\n\t\t\t\t\t\t gnutls_datum_t * out,\n\t\t\t\t\t\t unsigned int flags);\n\nint gnutls_pem_base64_encode(const char *msg, const gnutls_datum_t * data,\n\t\t\t     char *result, size_t * result_size);\nint gnutls_pem_base64_decode(const char *header,\n\t\t\t     const gnutls_datum_t * b64_data,\n\t\t\t     unsigned char *result, size_t * result_size);\n\nint gnutls_pem_base64_encode2(const char *msg,\n\t\t\t\t   const gnutls_datum_t * data,\n\t\t\t\t   gnutls_datum_t * result);\nint gnutls_pem_base64_decode2(const char *header,\n\t\t\t\t   const gnutls_datum_t * b64_data,\n\t\t\t\t   gnutls_datum_t * result);\n\nint gnutls_base64_encode2(const gnutls_datum_t * data,\n\t\t\t  gnutls_datum_t * result);\nint gnutls_base64_decode2(const gnutls_datum_t * b64_data,\n\t\t\t  gnutls_datum_t * result);\n\n#define gnutls_pem_base64_encode_alloc gnutls_pem_base64_encode2\n#define gnutls_pem_base64_decode_alloc gnutls_pem_base64_decode2\n\n  /* key_usage will be an OR of the following values:\n   */\n\n  /* when the key is to be used for signing: */\n#define GNUTLS_KEY_DIGITAL_SIGNATURE\t128\n#define GNUTLS_KEY_NON_REPUDIATION\t64\n  /* when the key is to be used for encryption: */\n#define GNUTLS_KEY_KEY_ENCIPHERMENT\t32\n#define GNUTLS_KEY_DATA_ENCIPHERMENT\t16\n#define GNUTLS_KEY_KEY_AGREEMENT\t8\n#define GNUTLS_KEY_KEY_CERT_SIGN\t4\n#define GNUTLS_KEY_CRL_SIGN\t\t2\n#define GNUTLS_KEY_ENCIPHER_ONLY\t1\n#define GNUTLS_KEY_DECIPHER_ONLY\t32768\n\nvoid\ngnutls_certificate_set_params_function(gnutls_certificate_credentials_t\n\t\t\t\t       res, gnutls_params_function * func);\nvoid gnutls_anon_set_params_function(gnutls_anon_server_credentials_t res,\n\t\t\t\t     gnutls_params_function * func);\nvoid gnutls_psk_set_params_function(gnutls_psk_server_credentials_t res,\n\t\t\t\t    gnutls_params_function * func);\n\nint gnutls_hex2bin(const char *hex_data, size_t hex_size,\n\t\t   void *bin_data, size_t * bin_size);\n\n  /* Trust on first use (or ssh like) functions */\n\n  /* stores the provided information to a database\n   */\ntypedef int (*gnutls_tdb_store_func) (const char *db_name,\n\t\t\t\t      const char *host,\n\t\t\t\t      const char *service,\n\t\t\t\t      time_t expiration,\n\t\t\t\t      const gnutls_datum_t * pubkey);\n\ntypedef int (*gnutls_tdb_store_commitment_func) (const char *db_name,\n\t\t\t\t\t\t const char *host,\n\t\t\t\t\t\t const char *service,\n\t\t\t\t\t\t time_t expiration,\n\t\t\t\t\t\t gnutls_digest_algorithm_t\n\t\t\t\t\t\t hash_algo,\n\t\t\t\t\t\t const gnutls_datum_t *\n\t\t\t\t\t\t hash);\n\n  /* searches for the provided host/service pair that match the\n   * provided public key in the database. */\ntypedef int (*gnutls_tdb_verify_func) (const char *db_name,\n\t\t\t\t       const char *host,\n\t\t\t\t       const char *service,\n\t\t\t\t       const gnutls_datum_t * pubkey);\n\n\nstruct gnutls_tdb_int;\ntypedef struct gnutls_tdb_int *gnutls_tdb_t;\n\nint gnutls_tdb_init(gnutls_tdb_t * tdb);\nvoid gnutls_tdb_set_store_func(gnutls_tdb_t tdb,\n\t\t\t       gnutls_tdb_store_func store);\nvoid gnutls_tdb_set_store_commitment_func(gnutls_tdb_t tdb,\n\t\t\t\t\t  gnutls_tdb_store_commitment_func\n\t\t\t\t\t  cstore);\nvoid gnutls_tdb_set_verify_func(gnutls_tdb_t tdb,\n\t\t\t\tgnutls_tdb_verify_func verify);\nvoid gnutls_tdb_deinit(gnutls_tdb_t tdb);\n\nint gnutls_verify_stored_pubkey(const char *db_name,\n\t\t\t\tgnutls_tdb_t tdb,\n\t\t\t\tconst char *host,\n\t\t\t\tconst char *service,\n\t\t\t\tgnutls_certificate_type_t cert_type,\n\t\t\t\tconst gnutls_datum_t * cert,\n\t\t\t\tunsigned int flags);\n\n#define GNUTLS_SCOMMIT_FLAG_ALLOW_BROKEN 1\nint gnutls_store_commitment(const char *db_name,\n\t\t\t    gnutls_tdb_t tdb,\n\t\t\t    const char *host,\n\t\t\t    const char *service,\n\t\t\t    gnutls_digest_algorithm_t hash_algo,\n\t\t\t    const gnutls_datum_t * hash,\n\t\t\t    time_t expiration, unsigned int flags);\n\nint gnutls_store_pubkey(const char *db_name,\n\t\t\tgnutls_tdb_t tdb,\n\t\t\tconst char *host,\n\t\t\tconst char *service,\n\t\t\tgnutls_certificate_type_t cert_type,\n\t\t\tconst gnutls_datum_t * cert,\n\t\t\ttime_t expiration, unsigned int flags);\n\n  /* Other helper functions */\nint gnutls_load_file(const char *filename, gnutls_datum_t * data);\n\nunsigned gnutls_url_is_supported(const char *url);\n\n  /* PIN callback */\n\n/**\n * gnutls_pin_flag_t:\n * @GNUTLS_PIN_USER: The PIN for the user.\n * @GNUTLS_PIN_SO: The PIN for the security officer (admin).\n * @GNUTLS_PIN_CONTEXT_SPECIFIC: The PIN is for a specific action and key like signing.\n * @GNUTLS_PIN_FINAL_TRY: This is the final try before blocking.\n * @GNUTLS_PIN_COUNT_LOW: Few tries remain before token blocks.\n * @GNUTLS_PIN_WRONG: Last given PIN was not correct.\n *\n * Enumeration of different flags that are input to the PIN function.\n */\ntypedef enum {\n\tGNUTLS_PIN_USER = (1 << 0),\n\tGNUTLS_PIN_SO = (1 << 1),\n\tGNUTLS_PIN_FINAL_TRY = (1 << 2),\n\tGNUTLS_PIN_COUNT_LOW = (1 << 3),\n\tGNUTLS_PIN_CONTEXT_SPECIFIC = (1 << 4),\n\tGNUTLS_PIN_WRONG = (1 << 5)\n} gnutls_pin_flag_t;\n\n#define GNUTLS_PKCS11_PIN_USER GNUTLS_PIN_USER\n#define GNUTLS_PKCS11_PIN_SO GNUTLS_PIN_SO\n#define GNUTLS_PKCS11_PIN_FINAL_TRY GNUTLS_PIN_FINAL_TRY\n#define GNUTLS_PKCS11_PIN_COUNT_LOW  GNUTLS_PIN_COUNT_LOW\n#define GNUTLS_PKCS11_PIN_CONTEXT_SPECIFIC GNUTLS_PIN_CONTEXT_SPECIFIC\n#define GNUTLS_PKCS11_PIN_WRONG GNUTLS_PIN_WRONG\n\n/**\n * gnutls_pin_callback_t:\n * @userdata: user-controlled data from gnutls_pkcs11_set_pin_function().\n * @attempt: pin-attempt counter, initially 0.\n * @token_url: URL of token.\n * @token_label: label of token.\n * @flags: a #gnutls_pin_flag_t flag.\n * @pin: buffer to hold PIN, of size @pin_max.\n * @pin_max: size of @pin buffer.\n *\n * Callback function type for PKCS#11 or TPM PIN entry.  It is set by\n * functions like gnutls_pkcs11_set_pin_function().\n *\n * The callback should provides the PIN code to unlock the token with\n * label @token_label, specified by the URL @token_url.\n *\n * The PIN code, as a NUL-terminated ASCII string, should be copied\n * into the @pin buffer (of maximum size @pin_max), and return 0 to\n * indicate success.  Alternatively, the callback may return a\n * negative gnutls error code to indicate failure and cancel PIN entry\n * (in which case, the contents of the @pin parameter are ignored).\n *\n * When a PIN is required, the callback will be invoked repeatedly\n * (and indefinitely) until either the returned PIN code is correct,\n * the callback returns failure, or the token refuses login (e.g. when\n * the token is locked due to too many incorrect PINs!).  For the\n * first such invocation, the @attempt counter will have value zero;\n * it will increase by one for each subsequent attempt.\n *\n * Returns: %GNUTLS_E_SUCCESS (0) on success or a negative error code on error.\n *\n * Since: 2.12.0\n **/\ntypedef int (*gnutls_pin_callback_t) (void *userdata, int attempt,\n\t\t\t\t      const char *token_url,\n\t\t\t\t      const char *token_label,\n\t\t\t\t      unsigned int flags,\n\t\t\t\t      char *pin, size_t pin_max);\n\nvoid gnutls_certificate_set_pin_function(gnutls_certificate_credentials_t,\n\t\t\t\t\t gnutls_pin_callback_t fn,\n\t\t\t\t\t void *userdata);\n\n/* Public string related functions */\ntypedef struct gnutls_buffer_st *gnutls_buffer_t;\n\nint gnutls_buffer_append_data(gnutls_buffer_t, const void *data, size_t data_size);\n\n#define GNUTLS_UTF8_IGNORE_ERRS 1\nint gnutls_utf8_password_normalize(const unsigned char *password, unsigned password_len,\n\t\t\t\t   gnutls_datum_t *out, unsigned flags);\n\n/* Public extensions related functions */\n\ntypedef void *gnutls_ext_priv_data_t;\n\nvoid gnutls_ext_set_data(gnutls_session_t session, unsigned type,\n\t\t\t gnutls_ext_priv_data_t);\nint gnutls_ext_get_data(gnutls_session_t session, unsigned type,\n\t\t\tgnutls_ext_priv_data_t *);\n\nunsigned gnutls_ext_get_current_msg(gnutls_session_t session);\n\ntypedef int (*gnutls_ext_recv_func) (gnutls_session_t session,\n\t\t\t\t     const unsigned char *data,\n\t\t\t\t     size_t len);\n\ntypedef int (*gnutls_ext_send_func) (gnutls_session_t session,\n\t\t\t\t     gnutls_buffer_t extdata);\n\ntypedef void (*gnutls_ext_deinit_data_func) (gnutls_ext_priv_data_t data);\n\ntypedef int (*gnutls_ext_pack_func) (gnutls_ext_priv_data_t data,\n\t\t\t\t     gnutls_buffer_t packed_data);\n\ntypedef int (*gnutls_ext_unpack_func) (gnutls_buffer_t packed_data,\n\t\t\t\t       gnutls_ext_priv_data_t *data);\n\n#define GNUTLS_EXT_RAW_FLAG_TLS_CLIENT_HELLO 1\n#define GNUTLS_EXT_RAW_FLAG_DTLS_CLIENT_HELLO (1<<1)\ntypedef int (*gnutls_ext_raw_process_func)(void *ctx, unsigned tls_id, const unsigned char *data, unsigned data_size);\nint gnutls_ext_raw_parse(void *ctx, gnutls_ext_raw_process_func cb,\n\t\t\t const gnutls_datum_t *data, unsigned int flags);\n\n/**\n * gnutls_ext_parse_type_t:\n * @GNUTLS_EXT_NONE: Never to be parsed\n * @GNUTLS_EXT_ANY: Any extension type (should not be used as it is used only internally).\n * @GNUTLS_EXT_VERSION_NEG: Extensions to be parsed first for TLS version negotiation.\n * @GNUTLS_EXT_MANDATORY: Parsed after @GNUTLS_EXT_VERSION_NEG and even when resuming.\n * @GNUTLS_EXT_APPLICATION: Parsed after @GNUTLS_EXT_MANDATORY\n * @GNUTLS_EXT_TLS: TLS-internal extensions, parsed after @GNUTLS_EXT_APPLICATION.\n *\n * Enumeration of different TLS extension parsing phases.  The @gnutls_ext_parse_type_t\n * indicates the time/phase an extension is parsed during Client or Server hello parsing.\n *\n */\ntypedef enum {\n  GNUTLS_EXT_ANY = 0,\n  GNUTLS_EXT_APPLICATION = 1,\n  GNUTLS_EXT_TLS = 2,\n  GNUTLS_EXT_MANDATORY = 3,\n  GNUTLS_EXT_NONE = 4,\n  GNUTLS_EXT_VERSION_NEG = 5\n} gnutls_ext_parse_type_t;\n\n/**\n * gnutls_ext_flags_t:\n * @GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL: If specified the extension registered will override the internal; this does not work with extensions existing prior to 3.6.0.\n * @GNUTLS_EXT_FLAG_CLIENT_HELLO: This extension can be present in a client hello\n * @GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO: This extension can be present in a TLS1.2 or earlier server hello\n * @GNUTLS_EXT_FLAG_TLS13_SERVER_HELLO: This extension can be present in a TLS1.3 server hello\n * @GNUTLS_EXT_FLAG_EE: This extension can be present in encrypted extensions message\n * @GNUTLS_EXT_FLAG_HRR: This extension can be present in hello retry request message\n * @GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST: When flag is present, this extension will be send even if the client didn't advertise it. An extension of this type is the Cookie TLS1.3 extension.\n * @GNUTLS_EXT_FLAG_DTLS: This extension can be present under DTLS; otherwise ignored.\n * @GNUTLS_EXT_FLAG_TLS: This extension can be present under TLS; otherwise ignored.\n *\n * Enumeration of different TLS extension registration flags.\n */\ntypedef enum {\n  GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL = 1,\n  GNUTLS_EXT_FLAG_CLIENT_HELLO = (1<<1),\n  GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO = (1<<2),\n  GNUTLS_EXT_FLAG_TLS13_SERVER_HELLO = (1<<3),\n  GNUTLS_EXT_FLAG_EE = (1<<4), /* ENCRYPTED */\n  GNUTLS_EXT_FLAG_HRR = (1<<5),\n  GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST = (1<<6),\n  GNUTLS_EXT_FLAG_TLS = (1<<7),\n  GNUTLS_EXT_FLAG_DTLS = (1<<8)\n} gnutls_ext_flags_t;\n\n/* Register a custom tls extension\n */\nint gnutls_ext_register(const char *name, int type, gnutls_ext_parse_type_t parse_point,\n\t\t\t\tgnutls_ext_recv_func recv_func, gnutls_ext_send_func send_func, \n\t\t\t\tgnutls_ext_deinit_data_func deinit_func, gnutls_ext_pack_func pack_func,\n\t\t\t\tgnutls_ext_unpack_func unpack_func);\n\nint gnutls_session_ext_register(gnutls_session_t, const char *name, int type, gnutls_ext_parse_type_t parse_point,\n\t\t\t\tgnutls_ext_recv_func recv_func, gnutls_ext_send_func send_func, \n\t\t\t\tgnutls_ext_deinit_data_func deinit_func, gnutls_ext_pack_func pack_func,\n\t\t\t\tgnutls_ext_unpack_func unpack_func, unsigned flags);\n\nconst char *gnutls_ext_get_name(unsigned int ext);\nconst char *gnutls_ext_get_name2(gnutls_session_t session, unsigned int tls_id,\n\t\t\t\t gnutls_ext_parse_type_t parse_point);\n\n/* Public supplemental data related functions */\n\ntypedef int (*gnutls_supp_recv_func) (gnutls_session_t session,\n\t\t\t       const unsigned char * data, size_t data_size);\ntypedef int (*gnutls_supp_send_func) (gnutls_session_t session,\n\t\t\t       gnutls_buffer_t buf);\n\nint gnutls_supplemental_register(const char *name,\n\t\t\t\tgnutls_supplemental_data_format_type_t type,\n\t\t\t\tgnutls_supp_recv_func supp_recv_func,\n\t\t\t\tgnutls_supp_send_func supp_send_func);\n\nint gnutls_session_supplemental_register(gnutls_session_t session, const char *name,\n\t\t\t\tgnutls_supplemental_data_format_type_t type,\n\t\t\t\tgnutls_supp_recv_func supp_recv_func,\n\t\t\t\tgnutls_supp_send_func supp_send_func,\n\t\t\t\tunsigned int flags);\n\nvoid gnutls_supplemental_recv(gnutls_session_t session, unsigned do_recv_supplemental);\n\nvoid gnutls_supplemental_send(gnutls_session_t session, unsigned do_send_supplemental);\n\n/* Anti-replay related functions */\n\ntypedef struct gnutls_anti_replay_st *gnutls_anti_replay_t;\n\nint gnutls_anti_replay_init(gnutls_anti_replay_t *anti_replay);\nvoid gnutls_anti_replay_deinit(gnutls_anti_replay_t anti_replay);\nvoid gnutls_anti_replay_set_window(gnutls_anti_replay_t anti_replay,\n\t\t\t\t   unsigned int window);\nvoid gnutls_anti_replay_enable(gnutls_session_t session,\n\t\t\t       gnutls_anti_replay_t anti_replay);\n\ntypedef int (*gnutls_db_add_func) (void *, time_t exp_time, const gnutls_datum_t *key,\n\t\t\t\t   const gnutls_datum_t *data);\n\nvoid gnutls_anti_replay_set_add_function(gnutls_anti_replay_t,\n\t\t\t\t\t gnutls_db_add_func add_func);\n\nvoid gnutls_anti_replay_set_ptr(gnutls_anti_replay_t, void *ptr);\n\n\n/**\n * gnutls_record_encryption_level_t:\n * @GNUTLS_ENCRYPTION_LEVEL_INITIAL: initial level that doesn't involve any\n *    encryption\n * @GNUTLS_ENCRYPTION_LEVEL_EARLY: early traffic secret is installed\n * @GNUTLS_ENCRYPTION_LEVEL_HANDSHAKE: handshake traffic secret is installed\n * @GNUTLS_ENCRYPTION_LEVEL_APPLICATION: application traffic secret is installed\n *\n * Enumeration of different levels of record encryption currently in place.\n * This is used by gnutls_handshake_set_read_function() and\n * gnutls_handshake_write().\n *\n * Since: 3.7.0\n */\ntypedef enum {\n\tGNUTLS_ENCRYPTION_LEVEL_INITIAL,\n\tGNUTLS_ENCRYPTION_LEVEL_EARLY,\n\tGNUTLS_ENCRYPTION_LEVEL_HANDSHAKE,\n\tGNUTLS_ENCRYPTION_LEVEL_APPLICATION\n} gnutls_record_encryption_level_t;\n\n  /**\n   * gnutls_handshake_read_func:\n   * @session: the current session\n   * @htype: the type of the handshake message (#gnutls_handshake_description_t)\n   * @level: #gnutls_record_encryption_level_t\n   * @data: the (const) data that was being sent\n   * @data_size: the size of data\n   *\n   * Function prototype for handshake intercepting hooks. It is set using\n   * gnutls_handshake_set_read_function().\n   *\n   * Returns: Non zero on error.\n   * Since: 3.7.0\n   */\ntypedef int (*gnutls_handshake_read_func) (gnutls_session_t session,\n\t\t\t\t\t   gnutls_record_encryption_level_t level,\n\t\t\t\t\t   gnutls_handshake_description_t htype,\n\t\t\t\t\t   const void *data, size_t data_size);\n\nvoid\ngnutls_handshake_set_read_function(gnutls_session_t session,\n\t\t\t\t   gnutls_handshake_read_func func);\n\nint\ngnutls_handshake_write(gnutls_session_t session,\n\t\t       gnutls_record_encryption_level_t level,\n\t\t       const void *data, size_t data_size);\n\n  /**\n   * gnutls_handshake_secret_func:\n   * @session: the current session\n   * @level: the encryption level\n   * @secret_read: the secret used for reading, can be %NULL if not set\n   * @secret_write: the secret used for writing, can be %NULL if not set\n   * @secret_size: the size of the secrets\n   *\n   * Function prototype for secret hooks. It is set using\n   * gnutls_handshake_set_secret_function().\n   *\n   * Returns: Non zero on error.\n   * Since: 3.7.0\n   */\ntypedef int (*gnutls_handshake_secret_func) (gnutls_session_t session,\n\t\t\t\t\t     gnutls_record_encryption_level_t level,\n\t\t\t\t\t     const void *secret_read,\n\t\t\t\t\t     const void *secret_write,\n\t\t\t\t\t     size_t secret_size);\n\nvoid\ngnutls_handshake_set_secret_function(gnutls_session_t session,\n\t\t\t\t     gnutls_handshake_secret_func func);\n\n  /**\n   * gnutls_alert_read_func:\n   * @session: the current session\n   * @level: #gnutls_record_encryption_level_t\n   * @alert_level: the level of the alert\n   * @alert_desc: the alert description\n   *\n   * Function prototype for alert intercepting hooks. It is set using\n   * gnutls_alert_set_read_function().\n   *\n   * Returns: Non zero on error.\n   * Since: 3.7.0\n   */\ntypedef int (*gnutls_alert_read_func) (gnutls_session_t session,\n\t\t\t\t       gnutls_record_encryption_level_t level,\n\t\t\t\t       gnutls_alert_level_t alert_level,\n\t\t\t\t       gnutls_alert_description_t alert_desc);\n\nvoid\ngnutls_alert_set_read_function(gnutls_session_t session,\n\t\t\t       gnutls_alert_read_func func);\n\n/* FIPS140-2 related functions */\nunsigned gnutls_fips140_mode_enabled(void);\n\n/**\n * gnutls_fips_mode_t:\n * @GNUTLS_FIPS140_DISABLED: The FIPS140-2 mode is disabled.\n * @GNUTLS_FIPS140_STRICT: The default mode; all forbidden operations will cause an\n *                         operation failure via error code.\n * @GNUTLS_FIPS140_LAX: The library still uses the FIPS140-2 relevant algorithms but all\n *                      forbidden by FIPS140-2 operations are allowed; this is useful when the\n *                      application is aware of the followed security policy, and needs\n *                      to utilize disallowed operations for other reasons (e.g., compatibility).\n * @GNUTLS_FIPS140_LOG: Similarly to %GNUTLS_FIPS140_LAX, it allows forbidden operations; any use of them results\n *                      to a message to the audit callback functions.\n * @GNUTLS_FIPS140_SELFTESTS: A transient state during library initialization. That state\n *\t\t\tcannot be set or seen by applications.\n *\n * Enumeration of different operational modes under FIPS140-2.\n */\ntypedef enum gnutls_fips_mode_t {\n  GNUTLS_FIPS140_DISABLED = 0,\n  GNUTLS_FIPS140_STRICT = 1,\n  GNUTLS_FIPS140_SELFTESTS = 2,\n  GNUTLS_FIPS140_LAX = 3,\n  GNUTLS_FIPS140_LOG = 4\n} gnutls_fips_mode_t;\n\n#define GNUTLS_FIPS140_SET_MODE_THREAD 1\n\nvoid gnutls_fips140_set_mode(gnutls_fips_mode_t mode, unsigned flags);\n\n#define GNUTLS_FIPS140_SET_LAX_MODE() do { \\\n\tif (gnutls_fips140_mode_enabled()) \\\n\t\tgnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, GNUTLS_FIPS140_SET_MODE_THREAD); \\\n\t} while(0)\n\n#define GNUTLS_FIPS140_SET_STRICT_MODE() do { \\\n\tif (gnutls_fips140_mode_enabled()) \\\n\t\tgnutls_fips140_set_mode(GNUTLS_FIPS140_STRICT, GNUTLS_FIPS140_SET_MODE_THREAD); \\\n\t} while(0)\n\ntypedef struct gnutls_fips140_context_st *gnutls_fips140_context_t;\n\nint gnutls_fips140_context_init(gnutls_fips140_context_t *context);\nvoid gnutls_fips140_context_deinit(gnutls_fips140_context_t context);\n\n/**\n * gnutls_fips140_operation_state_t:\n * @GNUTLS_FIPS140_OP_INITIAL: no previous operation has done\n * @GNUTLS_FIPS140_OP_APPROVED: the previous operation was FIPS approved\n * @GNUTLS_FIPS140_OP_NOT_APPROVED: the previous operation was not FIPS approved\n * @GNUTLS_FIPS140_OP_ERROR: the previous operation caused an error regardless of FIPS\n *\n * The FIPS operation state set by the preceding operation.\n *\n * There are state transition rules among the enum values:\n * - When the context is attached to a thread, it will be set to reset\n *   to the %GNUTLS_FIPS140_OP_INITIAL state\n * - From the %GNUTLS_FIPS140_OP_INITIAL state, the context can\n *   transition to either %GNUTLS_FIPS140_OP_APPROVED,\n *   %GNUTLS_FIPS140_OP_NOT_APPROVED, or %GNUTLS_FIPS140_OP_ERROR\n * - From the %GNUTLS_FIPS140_OP_APPROVED state, the context can\n *   transition to %GNUTLS_FIPS140_OP_NOT_APPROVED\n * - All other transitions are prohibited.\n *\n * Since: 3.7.3\n */\ntypedef enum {\n        GNUTLS_FIPS140_OP_INITIAL,\n        GNUTLS_FIPS140_OP_APPROVED,\n        GNUTLS_FIPS140_OP_NOT_APPROVED,\n        GNUTLS_FIPS140_OP_ERROR\n} gnutls_fips140_operation_state_t;\n\ngnutls_fips140_operation_state_t\ngnutls_fips140_get_operation_state(gnutls_fips140_context_t context);\n\nint gnutls_fips140_push_context(gnutls_fips140_context_t context);\nint gnutls_fips140_pop_context(void);\n\nint gnutls_fips140_run_self_tests(void);\n\n  /* Gnutls error codes. The mapping to a TLS alert is also shown in\n   * comments.\n   */\n\n#define GNUTLS_E_SUCCESS 0\n#define\tGNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3\n#define\tGNUTLS_E_UNKNOWN_CIPHER_TYPE -6\n#define\tGNUTLS_E_LARGE_PACKET -7\n#define GNUTLS_E_UNSUPPORTED_VERSION_PACKET -8\t/* GNUTLS_A_PROTOCOL_VERSION */\n#define GNUTLS_E_TLS_PACKET_DECODING_ERROR GNUTLS_E_UNEXPECTED_PACKET_LENGTH\n#define GNUTLS_E_UNEXPECTED_PACKET_LENGTH -9\t/* GNUTLS_A_DECODE_ERROR */\n#define GNUTLS_E_INVALID_SESSION -10\n#define GNUTLS_E_FATAL_ALERT_RECEIVED -12\n#define GNUTLS_E_UNEXPECTED_PACKET -15\t/* GNUTLS_A_UNEXPECTED_MESSAGE */\n#define GNUTLS_E_WARNING_ALERT_RECEIVED -16\n#define GNUTLS_E_ERROR_IN_FINISHED_PACKET -18\n#define GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET -19\n#define\tGNUTLS_E_UNKNOWN_CIPHER_SUITE -21\t/* GNUTLS_A_HANDSHAKE_FAILURE */\n#define\tGNUTLS_E_UNWANTED_ALGORITHM -22\n#define\tGNUTLS_E_MPI_SCAN_FAILED -23\n#define GNUTLS_E_DECRYPTION_FAILED -24\t/* GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_BAD_RECORD_MAC */\n#define GNUTLS_E_MEMORY_ERROR -25\n#define GNUTLS_E_DECOMPRESSION_FAILED -26\t/* GNUTLS_A_DECOMPRESSION_FAILURE */\n#define GNUTLS_E_COMPRESSION_FAILED -27\n#define GNUTLS_E_AGAIN -28\n#define GNUTLS_E_EXPIRED -29\n#define GNUTLS_E_DB_ERROR -30\n#define GNUTLS_E_SRP_PWD_ERROR GNUTLS_E_KEYFILE_ERROR\n#define GNUTLS_E_KEYFILE_ERROR -31\n#define GNUTLS_E_INSUFFICIENT_CREDENTIALS -32\n#define GNUTLS_E_INSUFICIENT_CREDENTIALS GNUTLS_E_INSUFFICIENT_CREDENTIALS\t/* for backwards compatibility only */\n#define GNUTLS_E_INSUFFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS\n#define GNUTLS_E_INSUFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS\t/* for backwards compatibility only */\n\n#define GNUTLS_E_HASH_FAILED -33\n#define GNUTLS_E_BASE64_DECODING_ERROR -34\n\n#define\tGNUTLS_E_MPI_PRINT_FAILED -35\n#define GNUTLS_E_REHANDSHAKE -37\t/* GNUTLS_A_NO_RENEGOTIATION */\n#define GNUTLS_E_GOT_APPLICATION_DATA -38\n#define GNUTLS_E_RECORD_LIMIT_REACHED -39\n#define GNUTLS_E_ENCRYPTION_FAILED -40\n\n#define GNUTLS_E_PK_ENCRYPTION_FAILED -44\n#define GNUTLS_E_PK_DECRYPTION_FAILED -45\n#define GNUTLS_E_PK_SIGN_FAILED -46\n#define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47\n#define GNUTLS_E_KEY_USAGE_VIOLATION -48\n#define GNUTLS_E_NO_CERTIFICATE_FOUND -49\t/* GNUTLS_A_BAD_CERTIFICATE */\n#define GNUTLS_E_INVALID_REQUEST -50\n#define GNUTLS_E_SHORT_MEMORY_BUFFER -51\n#define GNUTLS_E_INTERRUPTED -52\n#define GNUTLS_E_PUSH_ERROR -53\n#define GNUTLS_E_PULL_ERROR -54\n#define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55\t/* GNUTLS_A_ILLEGAL_PARAMETER */\n#define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56\n#define GNUTLS_E_PKCS1_WRONG_PAD -57\n#define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58\n#define GNUTLS_E_INTERNAL_ERROR -59\n#define GNUTLS_E_DH_PRIME_UNACCEPTABLE -63\n#define GNUTLS_E_FILE_ERROR -64\n#define GNUTLS_E_TOO_MANY_EMPTY_PACKETS -78\n#define GNUTLS_E_UNKNOWN_PK_ALGORITHM -80\n#define GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS -81\n#define GNUTLS_E_RECEIVED_DISALLOWED_NAME -82 /* GNUTLS_A_ILLEGAL_PARAMETER */\n#define GNUTLS_E_CERTIFICATE_REQUIRED -112 /* GNUTLS_A_CERTIFICATE_REQUIRED */\n\n  /* returned if you need to generate temporary RSA\n   * parameters. These are needed for export cipher suites.\n   */\n#define GNUTLS_E_NO_TEMPORARY_RSA_PARAMS -84\n\n#define GNUTLS_E_NO_COMPRESSION_ALGORITHMS -86\n#define GNUTLS_E_NO_CIPHER_SUITES -87\n\n#define GNUTLS_E_OPENPGP_GETKEY_FAILED -88\n#define GNUTLS_E_PK_SIG_VERIFY_FAILED -89\n\n#define GNUTLS_E_ILLEGAL_SRP_USERNAME -90\n#define GNUTLS_E_SRP_PWD_PARSING_ERROR GNUTLS_E_KEYFILE_PARSING_ERROR\n#define GNUTLS_E_KEYFILE_PARSING_ERROR -91\n#define GNUTLS_E_NO_TEMPORARY_DH_PARAMS -93\n\n  /* For certificate and key stuff\n   */\n#define GNUTLS_E_ASN1_ELEMENT_NOT_FOUND -67\n#define GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND -68\n#define GNUTLS_E_ASN1_DER_ERROR -69\n#define GNUTLS_E_ASN1_VALUE_NOT_FOUND -70\n#define GNUTLS_E_ASN1_GENERIC_ERROR -71\n#define GNUTLS_E_ASN1_VALUE_NOT_VALID -72\n#define GNUTLS_E_ASN1_TAG_ERROR -73\n#define GNUTLS_E_ASN1_TAG_IMPLICIT -74\n#define GNUTLS_E_ASN1_TYPE_ANY_ERROR -75\n#define GNUTLS_E_ASN1_SYNTAX_ERROR -76\n#define GNUTLS_E_ASN1_DER_OVERFLOW -77\n#define GNUTLS_E_OPENPGP_UID_REVOKED -79\n#define GNUTLS_E_CERTIFICATE_ERROR -43\n#define GNUTLS_E_X509_CERTIFICATE_ERROR GNUTLS_E_CERTIFICATE_ERROR\n#define GNUTLS_E_CERTIFICATE_KEY_MISMATCH -60\n#define GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE -61\t/* GNUTLS_A_UNSUPPORTED_CERTIFICATE */\n#define GNUTLS_E_X509_UNKNOWN_SAN -62\n#define GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED -94\n#define GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE -95\n#define GNUTLS_E_UNKNOWN_HASH_ALGORITHM -96\n#define GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE -97\n#define GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE -98\n#define GNUTLS_E_INVALID_PASSWORD -99\n#define GNUTLS_E_MAC_VERIFY_FAILED -100\t/* for PKCS #12 MAC */\n#define GNUTLS_E_CONSTRAINT_ERROR -101\n\n#define GNUTLS_E_WARNING_IA_IPHF_RECEIVED -102\n#define GNUTLS_E_WARNING_IA_FPHF_RECEIVED -103\n\n#define GNUTLS_E_IA_VERIFY_FAILED -104\n#define GNUTLS_E_UNKNOWN_ALGORITHM -105\n#define GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM -106\n#define GNUTLS_E_SAFE_RENEGOTIATION_FAILED -107\n#define GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED -108\n#define GNUTLS_E_UNKNOWN_SRP_USERNAME -109\n#define GNUTLS_E_PREMATURE_TERMINATION -110\n\n#define GNUTLS_E_MALFORMED_CIDR -111\n\n#define GNUTLS_E_BASE64_ENCODING_ERROR -201\n#define GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY -202\t/* obsolete */\n#define GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY -202\n#define GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY -203\n\n#define GNUTLS_E_OPENPGP_KEYRING_ERROR -204\n#define GNUTLS_E_X509_UNSUPPORTED_OID -205\n\n#define GNUTLS_E_RANDOM_FAILED -206\n#define GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR -207\n\n#define GNUTLS_E_OPENPGP_SUBKEY_ERROR -208\n\n#define GNUTLS_E_CRYPTO_ALREADY_REGISTERED GNUTLS_E_ALREADY_REGISTERED\n#define GNUTLS_E_ALREADY_REGISTERED -209\n\n#define GNUTLS_E_HANDSHAKE_TOO_LARGE -210\n\n#define GNUTLS_E_CRYPTODEV_IOCTL_ERROR -211\n#define GNUTLS_E_CRYPTODEV_DEVICE_ERROR -212\n\n#define GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE -213\n#define GNUTLS_E_BAD_COOKIE -214\n#define GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR -215\n#define GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL -216\n#define GNUTLS_E_INSUFFICIENT_SECURITY -217\n\n#define GNUTLS_E_HEARTBEAT_PONG_RECEIVED -292\n#define GNUTLS_E_HEARTBEAT_PING_RECEIVED -293\n\n#define GNUTLS_E_UNRECOGNIZED_NAME -294\n\n/* PKCS11 related */\n#define GNUTLS_E_PKCS11_ERROR -300\n#define GNUTLS_E_PKCS11_LOAD_ERROR -301\n#define GNUTLS_E_PARSING_ERROR -302\n#define GNUTLS_E_PKCS11_PIN_ERROR -303\n\n#define GNUTLS_E_PKCS11_SLOT_ERROR -305\n#define GNUTLS_E_LOCKING_ERROR -306\n#define GNUTLS_E_PKCS11_ATTRIBUTE_ERROR -307\n#define GNUTLS_E_PKCS11_DEVICE_ERROR -308\n#define GNUTLS_E_PKCS11_DATA_ERROR -309\n#define GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR -310\n#define GNUTLS_E_PKCS11_KEY_ERROR -311\n#define GNUTLS_E_PKCS11_PIN_EXPIRED -312\n#define GNUTLS_E_PKCS11_PIN_LOCKED -313\n#define GNUTLS_E_PKCS11_SESSION_ERROR -314\n#define GNUTLS_E_PKCS11_SIGNATURE_ERROR -315\n#define GNUTLS_E_PKCS11_TOKEN_ERROR -316\n#define GNUTLS_E_PKCS11_USER_ERROR -317\n\n#define GNUTLS_E_CRYPTO_INIT_FAILED -318\n#define GNUTLS_E_TIMEDOUT -319\n#define GNUTLS_E_USER_ERROR -320\n#define GNUTLS_E_ECC_NO_SUPPORTED_CURVES -321\n#define GNUTLS_E_ECC_UNSUPPORTED_CURVE -322\n#define GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE -323\n#define GNUTLS_E_CERTIFICATE_LIST_UNSORTED -324\n#define GNUTLS_E_ILLEGAL_PARAMETER -325 /* GNUTLS_A_ILLEGAL_PARAMETER */\n#define GNUTLS_E_NO_PRIORITIES_WERE_SET -326\n#define GNUTLS_E_X509_UNSUPPORTED_EXTENSION -327\n#define GNUTLS_E_SESSION_EOF -328\n\n#define GNUTLS_E_TPM_ERROR -329\n#define GNUTLS_E_TPM_KEY_PASSWORD_ERROR -330\n#define GNUTLS_E_TPM_SRK_PASSWORD_ERROR -331\n#define GNUTLS_E_TPM_SESSION_ERROR -332\n#define GNUTLS_E_TPM_KEY_NOT_FOUND -333\n#define GNUTLS_E_TPM_UNINITIALIZED -334\n#define GNUTLS_E_TPM_NO_LIB -335\n\n#define GNUTLS_E_NO_CERTIFICATE_STATUS -340\n#define GNUTLS_E_OCSP_RESPONSE_ERROR -341\n#define GNUTLS_E_RANDOM_DEVICE_ERROR -342\n#define GNUTLS_E_AUTH_ERROR -343\n#define GNUTLS_E_NO_APPLICATION_PROTOCOL -344\n#define GNUTLS_E_SOCKETS_INIT_ERROR -345\n#define GNUTLS_E_KEY_IMPORT_FAILED -346\n#define GNUTLS_E_INAPPROPRIATE_FALLBACK -347 /*GNUTLS_A_INAPPROPRIATE_FALLBACK*/\n#define GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR -348\n#define GNUTLS_E_PRIVKEY_VERIFICATION_ERROR -349\n#define GNUTLS_E_UNEXPECTED_EXTENSIONS_LENGTH -350 /*GNUTLS_A_DECODE_ERROR*/\n#define GNUTLS_E_ASN1_EMBEDDED_NULL_IN_STRING -351\n\n#define GNUTLS_E_SELF_TEST_ERROR -400\n#define GNUTLS_E_NO_SELF_TEST -401\n#define GNUTLS_E_LIB_IN_ERROR_STATE -402\n#define GNUTLS_E_PK_GENERATION_ERROR -403\n#define GNUTLS_E_IDNA_ERROR -404\n\n#define GNUTLS_E_NEED_FALLBACK -405\n#define GNUTLS_E_SESSION_USER_ID_CHANGED -406\n#define GNUTLS_E_HANDSHAKE_DURING_FALSE_START -407\n#define GNUTLS_E_UNAVAILABLE_DURING_HANDSHAKE -408\n#define GNUTLS_E_PK_INVALID_PUBKEY -409\n#define GNUTLS_E_PK_INVALID_PRIVKEY -410\n#define GNUTLS_E_NOT_YET_ACTIVATED -411\n#define GNUTLS_E_INVALID_UTF8_STRING -412\n#define GNUTLS_E_NO_EMBEDDED_DATA -413\n#define GNUTLS_E_INVALID_UTF8_EMAIL -414\n#define GNUTLS_E_INVALID_PASSWORD_STRING -415\n#define GNUTLS_E_CERTIFICATE_TIME_ERROR -416\n#define GNUTLS_E_RECORD_OVERFLOW -417\t/* GNUTLS_A_RECORD_OVERFLOW */\n#define GNUTLS_E_ASN1_TIME_ERROR -418\n#define GNUTLS_E_INCOMPATIBLE_SIG_WITH_KEY -419\n#define GNUTLS_E_PK_INVALID_PUBKEY_PARAMS -420\n#define GNUTLS_E_PK_NO_VALIDATION_PARAMS -421\n#define GNUTLS_E_OCSP_MISMATCH_WITH_CERTS -422\n\n#define GNUTLS_E_NO_COMMON_KEY_SHARE -423\n#define GNUTLS_E_REAUTH_REQUEST -424\n#define GNUTLS_E_TOO_MANY_MATCHES -425\n#define GNUTLS_E_CRL_VERIFICATION_ERROR -426\n#define GNUTLS_E_MISSING_EXTENSION -427\n#define GNUTLS_E_DB_ENTRY_EXISTS -428\n#define GNUTLS_E_EARLY_DATA_REJECTED -429\n#define GNUTLS_E_X509_DUPLICATE_EXTENSION -430\n\n#define GNUTLS_E_UNIMPLEMENTED_FEATURE -1250\n\n/* Internal errors of the library; will never be returned\n * to a calling application */\n#define GNUTLS_E_INT_RET_0 -1251\n#define GNUTLS_E_INT_CHECK_AGAIN -1252\n\n#define GNUTLS_E_APPLICATION_ERROR_MAX -65000\n#define GNUTLS_E_APPLICATION_ERROR_MIN -65500\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#include <gnutls/compat.h>\n\n#endif /* GNUTLS_GNUTLS_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/ocsp.h",
    "content": "/*\n * Copyright (C) 2011-2012 Free Software Foundation, Inc.\n *\n * Author: Simon Josefsson\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* Online Certificate Status Protocol - RFC 2560\n */\n\n#ifndef GNUTLS_OCSP_H\n#define GNUTLS_OCSP_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#define GNUTLS_OCSP_NONCE \"1.3.6.1.5.5.7.48.1.2\"\n\n/**\n * gnutls_ocsp_print_formats_t:\n * @GNUTLS_OCSP_PRINT_FULL: Full information about OCSP request/response.\n * @GNUTLS_OCSP_PRINT_COMPACT: More compact information about OCSP request/response.\n *\n * Enumeration of different OCSP printing variants.\n */\ntypedef enum gnutls_ocsp_print_formats_t {\n\tGNUTLS_OCSP_PRINT_FULL = 0,\n\tGNUTLS_OCSP_PRINT_COMPACT = 1\n} gnutls_ocsp_print_formats_t;\n\n/**\n * gnutls_ocsp_resp_status_t:\n * @GNUTLS_OCSP_RESP_SUCCESSFUL: Response has valid confirmations.\n * @GNUTLS_OCSP_RESP_MALFORMEDREQUEST: Illegal confirmation request\n * @GNUTLS_OCSP_RESP_INTERNALERROR: Internal error in issuer\n * @GNUTLS_OCSP_RESP_TRYLATER: Try again later\n * @GNUTLS_OCSP_RESP_SIGREQUIRED: Must sign the request\n * @GNUTLS_OCSP_RESP_UNAUTHORIZED: Request unauthorized\n *\n * Enumeration of different OCSP response status codes.\n */\ntypedef enum gnutls_ocsp_resp_status_t {\n\tGNUTLS_OCSP_RESP_SUCCESSFUL = 0,\n\tGNUTLS_OCSP_RESP_MALFORMEDREQUEST = 1,\n\tGNUTLS_OCSP_RESP_INTERNALERROR = 2,\n\tGNUTLS_OCSP_RESP_TRYLATER = 3,\n\tGNUTLS_OCSP_RESP_SIGREQUIRED = 5,\n\tGNUTLS_OCSP_RESP_UNAUTHORIZED = 6\n} gnutls_ocsp_resp_status_t;\n\n/**\n * gnutls_ocsp_cert_status_t:\n * @GNUTLS_OCSP_CERT_GOOD: Positive response to status inquiry.\n * @GNUTLS_OCSP_CERT_REVOKED: Certificate has been revoked.\n * @GNUTLS_OCSP_CERT_UNKNOWN: The responder doesn't know about the\n *   certificate.\n *\n * Enumeration of different OCSP response certificate status codes.\n */\ntypedef enum gnutls_ocsp_cert_status_t {\n\tGNUTLS_OCSP_CERT_GOOD = 0,\n\tGNUTLS_OCSP_CERT_REVOKED = 1,\n\tGNUTLS_OCSP_CERT_UNKNOWN = 2\n} gnutls_ocsp_cert_status_t;\n\n/**\n * gnutls_x509_crl_reason_t:\n * @GNUTLS_X509_CRLREASON_UNSPECIFIED: Unspecified reason.\n * @GNUTLS_X509_CRLREASON_KEYCOMPROMISE: Private key compromised.\n * @GNUTLS_X509_CRLREASON_CACOMPROMISE: CA compromised.\n * @GNUTLS_X509_CRLREASON_AFFILIATIONCHANGED: Affiliation has changed.\n * @GNUTLS_X509_CRLREASON_SUPERSEDED: Certificate superseded.\n * @GNUTLS_X509_CRLREASON_CESSATIONOFOPERATION: Operation has ceased.\n * @GNUTLS_X509_CRLREASON_CERTIFICATEHOLD: Certificate is on hold.\n * @GNUTLS_X509_CRLREASON_REMOVEFROMCRL: Will be removed from delta CRL.\n * @GNUTLS_X509_CRLREASON_PRIVILEGEWITHDRAWN: Privilege withdrawn.\n * @GNUTLS_X509_CRLREASON_AACOMPROMISE: AA compromised.\n *\n * Enumeration of different reason codes.  Note that this\n * corresponds to the CRLReason ASN.1 enumeration type, and not the\n * ReasonFlags ASN.1 bit string.\n */\ntypedef enum gnutls_x509_crl_reason_t {\n\tGNUTLS_X509_CRLREASON_UNSPECIFIED = 0,\n\tGNUTLS_X509_CRLREASON_KEYCOMPROMISE = 1,\n\tGNUTLS_X509_CRLREASON_CACOMPROMISE = 2,\n\tGNUTLS_X509_CRLREASON_AFFILIATIONCHANGED = 3,\n\tGNUTLS_X509_CRLREASON_SUPERSEDED = 4,\n\tGNUTLS_X509_CRLREASON_CESSATIONOFOPERATION = 5,\n\tGNUTLS_X509_CRLREASON_CERTIFICATEHOLD = 6,\n\tGNUTLS_X509_CRLREASON_REMOVEFROMCRL = 8,\n\tGNUTLS_X509_CRLREASON_PRIVILEGEWITHDRAWN = 9,\n\tGNUTLS_X509_CRLREASON_AACOMPROMISE = 10\n} gnutls_x509_crl_reason_t;\n\n/* When adding a verify failure reason update:\n * _gnutls_ocsp_verify_status_to_str()\n */\n/**\n * gnutls_ocsp_verify_reason_t:\n * @GNUTLS_OCSP_VERIFY_SIGNER_NOT_FOUND: Signer cert not found.\n * @GNUTLS_OCSP_VERIFY_SIGNER_KEYUSAGE_ERROR: Signer keyusage bits incorrect.\n * @GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER: Signer is not trusted.\n * @GNUTLS_OCSP_VERIFY_INSECURE_ALGORITHM: Signature using insecure algorithm.\n * @GNUTLS_OCSP_VERIFY_SIGNATURE_FAILURE: Signature mismatch.\n * @GNUTLS_OCSP_VERIFY_CERT_NOT_ACTIVATED: Signer cert is not yet activated.\n * @GNUTLS_OCSP_VERIFY_CERT_EXPIRED: Signer cert has expired.\n *\n * Enumeration of OCSP verify status codes, used by\n * gnutls_ocsp_resp_verify() and gnutls_ocsp_resp_verify_direct().\n */\ntypedef enum gnutls_ocsp_verify_reason_t {\n\tGNUTLS_OCSP_VERIFY_SIGNER_NOT_FOUND = 1,\n\tGNUTLS_OCSP_VERIFY_SIGNER_KEYUSAGE_ERROR = 2,\n\tGNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER = 4,\n\tGNUTLS_OCSP_VERIFY_INSECURE_ALGORITHM = 8,\n\tGNUTLS_OCSP_VERIFY_SIGNATURE_FAILURE = 16,\n\tGNUTLS_OCSP_VERIFY_CERT_NOT_ACTIVATED = 32,\n\tGNUTLS_OCSP_VERIFY_CERT_EXPIRED = 64\n} gnutls_ocsp_verify_reason_t;\n\nstruct gnutls_ocsp_req_int;\ntypedef struct gnutls_ocsp_req_int *gnutls_ocsp_req_t;\ntypedef const struct gnutls_ocsp_req_int *gnutls_ocsp_req_const_t;\n\nint gnutls_ocsp_req_init(gnutls_ocsp_req_t * req);\nvoid gnutls_ocsp_req_deinit(gnutls_ocsp_req_t req);\n\nint gnutls_ocsp_req_import(gnutls_ocsp_req_t req,\n\t\t\t   const gnutls_datum_t * data);\nint gnutls_ocsp_req_export(gnutls_ocsp_req_const_t req, gnutls_datum_t * data);\nint gnutls_ocsp_req_print(gnutls_ocsp_req_const_t req,\n\t\t\t  gnutls_ocsp_print_formats_t format,\n\t\t\t  gnutls_datum_t * out);\n\nint gnutls_ocsp_req_get_version(gnutls_ocsp_req_const_t req);\n\nint gnutls_ocsp_req_get_cert_id(gnutls_ocsp_req_const_t req,\n\t\t\t\tunsigned indx,\n\t\t\t\tgnutls_digest_algorithm_t * digest,\n\t\t\t\tgnutls_datum_t * issuer_name_hash,\n\t\t\t\tgnutls_datum_t * issuer_key_hash,\n\t\t\t\tgnutls_datum_t * serial_number);\nint gnutls_ocsp_req_add_cert_id(gnutls_ocsp_req_t req,\n\t\t\t\tgnutls_digest_algorithm_t digest,\n\t\t\t\tconst gnutls_datum_t *\n\t\t\t\tissuer_name_hash,\n\t\t\t\tconst gnutls_datum_t *\n\t\t\t\tissuer_key_hash,\n\t\t\t\tconst gnutls_datum_t * serial_number);\nint gnutls_ocsp_req_add_cert(gnutls_ocsp_req_t req,\n\t\t\t     gnutls_digest_algorithm_t digest,\n\t\t\t     gnutls_x509_crt_t issuer,\n\t\t\t     gnutls_x509_crt_t cert);\n\nint gnutls_ocsp_req_get_extension(gnutls_ocsp_req_const_t req,\n\t\t\t\t  unsigned indx,\n\t\t\t\t  gnutls_datum_t * oid,\n\t\t\t\t  unsigned int *critical,\n\t\t\t\t  gnutls_datum_t * data);\nint gnutls_ocsp_req_set_extension(gnutls_ocsp_req_t req,\n\t\t\t\t  const char *oid,\n\t\t\t\t  unsigned int critical,\n\t\t\t\t  const gnutls_datum_t * data);\n\nint gnutls_ocsp_req_get_nonce(gnutls_ocsp_req_const_t req,\n\t\t\t      unsigned int *critical,\n\t\t\t      gnutls_datum_t * nonce);\nint gnutls_ocsp_req_set_nonce(gnutls_ocsp_req_t req,\n\t\t\t      unsigned int critical,\n\t\t\t      const gnutls_datum_t * nonce);\nint gnutls_ocsp_req_randomize_nonce(gnutls_ocsp_req_t req);\n\nstruct gnutls_ocsp_resp_int;\ntypedef struct gnutls_ocsp_resp_int *gnutls_ocsp_resp_t;\ntypedef const struct gnutls_ocsp_resp_int *gnutls_ocsp_resp_const_t;\n\nint gnutls_ocsp_resp_init(gnutls_ocsp_resp_t * resp);\nvoid gnutls_ocsp_resp_deinit(gnutls_ocsp_resp_t resp);\n\nint gnutls_ocsp_resp_import(gnutls_ocsp_resp_t resp,\n\t\t\t    const gnutls_datum_t * data);\nint gnutls_ocsp_resp_import2(gnutls_ocsp_resp_t resp,\n\t\t\t     const gnutls_datum_t * data,\n\t\t\t     gnutls_x509_crt_fmt_t fmt);\nint gnutls_ocsp_resp_export(gnutls_ocsp_resp_const_t resp,\n\t\t\t    gnutls_datum_t * data);\nint gnutls_ocsp_resp_export2(gnutls_ocsp_resp_const_t resp,\n\t\t\t     gnutls_datum_t * data,\n\t\t\t     gnutls_x509_crt_fmt_t fmt);\nint gnutls_ocsp_resp_print(gnutls_ocsp_resp_const_t resp,\n\t\t\t   gnutls_ocsp_print_formats_t format,\n\t\t\t   gnutls_datum_t * out);\n\nint gnutls_ocsp_resp_get_status(gnutls_ocsp_resp_const_t resp);\nint gnutls_ocsp_resp_get_response(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t  gnutls_datum_t *\n\t\t\t\t  response_type_oid,\n\t\t\t\t  gnutls_datum_t * response);\n\nint gnutls_ocsp_resp_get_version(gnutls_ocsp_resp_const_t resp);\nint gnutls_ocsp_resp_get_responder(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t   gnutls_datum_t * dn);\nint gnutls_ocsp_resp_get_responder2(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t    gnutls_datum_t * dn,\n\t\t\t\t    unsigned flags);\n\n/* the raw key ID of the responder */\n#define GNUTLS_OCSP_RESP_ID_KEY 1\n/* the raw DN of the responder */\n#define GNUTLS_OCSP_RESP_ID_DN 2\nint\ngnutls_ocsp_resp_get_responder_raw_id(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t      unsigned type,\n\t\t\t\t      gnutls_datum_t * raw);\n\ntime_t gnutls_ocsp_resp_get_produced(gnutls_ocsp_resp_const_t resp);\nint gnutls_ocsp_resp_get_single(gnutls_ocsp_resp_const_t resp,\n\t\t\t\tunsigned indx,\n\t\t\t\tgnutls_digest_algorithm_t * digest,\n\t\t\t\tgnutls_datum_t * issuer_name_hash,\n\t\t\t\tgnutls_datum_t * issuer_key_hash,\n\t\t\t\tgnutls_datum_t * serial_number,\n\t\t\t\tunsigned int *cert_status,\n\t\t\t\ttime_t * this_update,\n\t\t\t\ttime_t * next_update,\n\t\t\t\ttime_t * revocation_time,\n\t\t\t\tunsigned int *revocation_reason);\nint gnutls_ocsp_resp_get_extension(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t   unsigned indx,\n\t\t\t\t   gnutls_datum_t * oid,\n\t\t\t\t   unsigned int *critical,\n\t\t\t\t   gnutls_datum_t * data);\nint gnutls_ocsp_resp_get_nonce(gnutls_ocsp_resp_const_t resp,\n\t\t\t       unsigned int *critical,\n\t\t\t       gnutls_datum_t * nonce);\nint gnutls_ocsp_resp_get_signature_algorithm(gnutls_ocsp_resp_const_t resp);\nint gnutls_ocsp_resp_get_signature(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t   gnutls_datum_t * sig);\nint gnutls_ocsp_resp_get_certs(gnutls_ocsp_resp_const_t resp,\n\t\t\t       gnutls_x509_crt_t ** certs,\n\t\t\t       size_t * ncerts);\n\nint gnutls_ocsp_resp_verify_direct(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t   gnutls_x509_crt_t issuer,\n\t\t\t\t   unsigned int *verify,\n\t\t\t\t   unsigned int flags);\nint gnutls_ocsp_resp_verify(gnutls_ocsp_resp_const_t resp,\n\t\t\t    gnutls_x509_trust_list_t trustlist,\n\t\t\t    unsigned int *verify, unsigned int flags);\n\nint gnutls_ocsp_resp_check_crt(gnutls_ocsp_resp_const_t resp,\n\t\t\t       unsigned int indx, gnutls_x509_crt_t crt);\n\nint\ngnutls_ocsp_resp_list_import2(gnutls_ocsp_resp_t **ocsps,\n\t\t\t     unsigned int *size,\n\t\t\t     const gnutls_datum_t *resp_data,\n\t\t\t     gnutls_x509_crt_fmt_t format,\n\t\t\t     unsigned int flags);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_OCSP_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/openpgp.h",
    "content": "/*\n * Copyright (C) 2003-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for the OpenPGP\n * key and private key parsing functions.\n */\n\n#ifndef GNUTLS_OPENPGP_H\n#define GNUTLS_OPENPGP_H\n\n#include <gnutls/gnutls.h>\n#include <limits.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/* Openpgp certificate stuff\n */\n\n/**\n * gnutls_openpgp_crt_fmt_t:\n * @GNUTLS_OPENPGP_FMT_RAW: OpenPGP certificate in raw format.\n * @GNUTLS_OPENPGP_FMT_BASE64: OpenPGP certificate in base64 format.\n *\n * Enumeration of different OpenPGP key formats.\n */\ntypedef enum gnutls_openpgp_crt_fmt {\n\tGNUTLS_OPENPGP_FMT_RAW,\n\tGNUTLS_OPENPGP_FMT_BASE64\n} gnutls_openpgp_crt_fmt_t;\n\n#define GNUTLS_OPENPGP_KEYID_SIZE 8\n#define GNUTLS_OPENPGP_V4_FINGERPRINT_SIZE 20\ntypedef unsigned char\n gnutls_openpgp_keyid_t[GNUTLS_OPENPGP_KEYID_SIZE];\n\n/* gnutls_openpgp_cert_t should be defined in gnutls.h\n */\n\n\t/* initializes the memory for gnutls_openpgp_crt_t struct */\nint gnutls_openpgp_crt_init(gnutls_openpgp_crt_t * key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\t/* frees all memory */\nvoid gnutls_openpgp_crt_deinit(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_import(gnutls_openpgp_crt_t key,\n\t\t\t      const gnutls_datum_t * data,\n\t\t\t      gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_export(gnutls_openpgp_crt_t key,\n\t\t\t      gnutls_openpgp_crt_fmt_t format,\n\t\t\t      void *output_data,\n\t\t\t      size_t * output_data_size) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_export2(gnutls_openpgp_crt_t key,\n\t\t\t       gnutls_openpgp_crt_fmt_t format,\n\t\t\t       gnutls_datum_t * out) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_print(gnutls_openpgp_crt_t cert,\n\t\t\t     gnutls_certificate_print_formats_t\n\t\t\t     format, gnutls_datum_t * out) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* The key_usage flags are defined in gnutls.h. They are\n * the GNUTLS_KEY_* definitions.\n */\n#define GNUTLS_OPENPGP_MASTER_KEYID_IDX INT_MAX\n\nint gnutls_openpgp_crt_get_key_usage(gnutls_openpgp_crt_t key,\n\t\t\t\t     unsigned int *key_usage) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_fingerprint(gnutls_openpgp_crt_t key,\n\t\t\t\t       void *fpr, size_t * fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_fingerprint(gnutls_openpgp_crt_t\n\t\t\t\t\t      key,\n\t\t\t\t\t      unsigned int idx,\n\t\t\t\t\t      void *fpr, size_t * fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_name(gnutls_openpgp_crt_t key,\n\t\t\t\tint idx, char *buf, size_t * sizeof_buf) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ngnutls_pk_algorithm_t\ngnutls_openpgp_crt_get_pk_algorithm(gnutls_openpgp_crt_t key,\n\t\t\t\t    unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_version(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntime_t gnutls_openpgp_crt_get_creation_time(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\ntime_t gnutls_openpgp_crt_get_expiration_time(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_key_id(gnutls_openpgp_crt_t key,\n\t\t\t\t  gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_check_hostname(gnutls_openpgp_crt_t key,\n\t\t\t\t      const char *hostname) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_check_hostname2(gnutls_openpgp_crt_t key,\n\t\t\t\t      const char *hostname, unsigned int flags) _GNUTLS_GCC_ATTR_DEPRECATED;\nint\ngnutls_openpgp_crt_check_email(gnutls_openpgp_crt_t key, const char *email, unsigned flags) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_revoked_status(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_subkey_count(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_idx(gnutls_openpgp_crt_t key,\n\t\t\t\t      const gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_revoked_status\n    (gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\ngnutls_pk_algorithm_t\ngnutls_openpgp_crt_get_subkey_pk_algorithm(gnutls_openpgp_crt_t\n\t\t\t\t\t   key,\n\t\t\t\t\t   unsigned int idx,\n\t\t\t\t\t   unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;\ntime_t\n    gnutls_openpgp_crt_get_subkey_creation_time\n    (gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\ntime_t\n    gnutls_openpgp_crt_get_subkey_expiration_time\n    (gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_id(gnutls_openpgp_crt_t key,\n\t\t\t\t     unsigned int idx,\n\t\t\t\t     gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_usage(gnutls_openpgp_crt_t key,\n\t\t\t\t\tunsigned int idx,\n\t\t\t\t\tunsigned int *key_usage) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_subkey_pk_dsa_raw(gnutls_openpgp_crt_t\n\t\t\t\t\t     crt, unsigned int idx,\n\t\t\t\t\t     gnutls_datum_t * p,\n\t\t\t\t\t     gnutls_datum_t * q,\n\t\t\t\t\t     gnutls_datum_t * g,\n\t\t\t\t\t     gnutls_datum_t * y) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_pk_rsa_raw(gnutls_openpgp_crt_t\n\t\t\t\t\t     crt, unsigned int idx,\n\t\t\t\t\t     gnutls_datum_t * m,\n\t\t\t\t\t     gnutls_datum_t * e) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_pk_dsa_raw(gnutls_openpgp_crt_t crt,\n\t\t\t\t      gnutls_datum_t * p,\n\t\t\t\t      gnutls_datum_t * q,\n\t\t\t\t      gnutls_datum_t * g,\n\t\t\t\t      gnutls_datum_t * y) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_pk_rsa_raw(gnutls_openpgp_crt_t crt,\n\t\t\t\t      gnutls_datum_t * m,\n\t\t\t\t      gnutls_datum_t * e) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_preferred_key_id(gnutls_openpgp_crt_t\n\t\t\t\t\t    key,\n\t\t\t\t\t    gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint\ngnutls_openpgp_crt_set_preferred_key_id(gnutls_openpgp_crt_t key,\n\t\t\t\t\tconst\n\t\t\t\t\tgnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* privkey stuff.\n */\nint gnutls_openpgp_privkey_init(gnutls_openpgp_privkey_t * key) _GNUTLS_GCC_ATTR_DEPRECATED;\nvoid gnutls_openpgp_privkey_deinit(gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\ngnutls_pk_algorithm_t\n    gnutls_openpgp_privkey_get_pk_algorithm\n    (gnutls_openpgp_privkey_t key, unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ngnutls_sec_param_t\ngnutls_openpgp_privkey_sec_param(gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_import(gnutls_openpgp_privkey_t key,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  gnutls_openpgp_crt_fmt_t format,\n\t\t\t\t  const char *password,\n\t\t\t\t  unsigned int flags) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_get_fingerprint(gnutls_openpgp_privkey_t\n\t\t\t\t\t   key, void *fpr,\n\t\t\t\t\t   size_t * fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_subkey_fingerprint\n    (gnutls_openpgp_privkey_t key, unsigned int idx, void *fpr,\n     size_t * fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_key_id(gnutls_openpgp_privkey_t key,\n\t\t\t\t      gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_subkey_count(gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_subkey_idx(gnutls_openpgp_privkey_t\n\t\t\t\t\t  key,\n\t\t\t\t\t  const\n\t\t\t\t\t  gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_get_subkey_revoked_status\n    (gnutls_openpgp_privkey_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_get_revoked_status\n    (gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ngnutls_pk_algorithm_t\n    gnutls_openpgp_privkey_get_subkey_pk_algorithm\n    (gnutls_openpgp_privkey_t key, unsigned int idx, unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntime_t\n    gnutls_openpgp_privkey_get_subkey_expiration_time\n    (gnutls_openpgp_privkey_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_get_subkey_id(gnutls_openpgp_privkey_t\n\t\t\t\t\t key, unsigned int idx,\n\t\t\t\t\t gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntime_t\n    gnutls_openpgp_privkey_get_subkey_creation_time\n    (gnutls_openpgp_privkey_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_export_subkey_dsa_raw\n    (gnutls_openpgp_privkey_t pkey, unsigned int idx,\n     gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * g,\n     gnutls_datum_t * y, gnutls_datum_t * x) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_export_subkey_rsa_raw\n    (gnutls_openpgp_privkey_t pkey, unsigned int idx,\n     gnutls_datum_t * m, gnutls_datum_t * e, gnutls_datum_t * d,\n     gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * u) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_export_dsa_raw(gnutls_openpgp_privkey_t\n\t\t\t\t\t  pkey, gnutls_datum_t * p,\n\t\t\t\t\t  gnutls_datum_t * q,\n\t\t\t\t\t  gnutls_datum_t * g,\n\t\t\t\t\t  gnutls_datum_t * y,\n\t\t\t\t\t  gnutls_datum_t * x) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_export_rsa_raw(gnutls_openpgp_privkey_t\n\t\t\t\t\t  pkey, gnutls_datum_t * m,\n\t\t\t\t\t  gnutls_datum_t * e,\n\t\t\t\t\t  gnutls_datum_t * d,\n\t\t\t\t\t  gnutls_datum_t * p,\n\t\t\t\t\t  gnutls_datum_t * q,\n\t\t\t\t\t  gnutls_datum_t * u) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_export(gnutls_openpgp_privkey_t key,\n\t\t\t\t  gnutls_openpgp_crt_fmt_t format,\n\t\t\t\t  const char *password,\n\t\t\t\t  unsigned int flags,\n\t\t\t\t  void *output_data,\n\t\t\t\t  size_t * output_data_size) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_export2(gnutls_openpgp_privkey_t key,\n\t\t\t\t   gnutls_openpgp_crt_fmt_t format,\n\t\t\t\t   const char *password,\n\t\t\t\t   unsigned int flags,\n\t\t\t\t   gnutls_datum_t * out) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_set_preferred_key_id\n    (gnutls_openpgp_privkey_t key, const gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_preferred_key_id\n    (gnutls_openpgp_privkey_t key, gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_auth_subkey(gnutls_openpgp_crt_t crt,\n\t\t\t\t       gnutls_openpgp_keyid_t\n\t\t\t\t       keyid, unsigned int flag) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* Keyring stuff.\n */\n\nint gnutls_openpgp_keyring_init(gnutls_openpgp_keyring_t * keyring) _GNUTLS_GCC_ATTR_DEPRECATED;\nvoid gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring_t keyring) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_keyring_import(gnutls_openpgp_keyring_t keyring,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_keyring_check_id(gnutls_openpgp_keyring_t ring,\n\t\t\t\t    const gnutls_openpgp_keyid_t\n\t\t\t\t    keyid, unsigned int flags) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\nint gnutls_openpgp_crt_verify_ring(gnutls_openpgp_crt_t key,\n\t\t\t\t   gnutls_openpgp_keyring_t\n\t\t\t\t   keyring, unsigned int flags,\n\t\t\t\t   unsigned int *verify\n\t\t\t\t   /* the output of the verification */\n    ) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_verify_self(gnutls_openpgp_crt_t key,\n\t\t\t\t   unsigned int flags,\n\t\t\t\t   unsigned int *verify) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_keyring_get_crt(gnutls_openpgp_keyring_t ring,\n\t\t\t\t   unsigned int idx,\n\t\t\t\t   gnutls_openpgp_crt_t * cert) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_keyring_get_crt_count(gnutls_openpgp_keyring_t ring) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\n\n/**\n * gnutls_openpgp_recv_key_func:\n * @session: a TLS session\n * @keyfpr: key fingerprint\n * @keyfpr_length: length of key fingerprint\n * @key: output key.\n *\n * A callback of this type is used to retrieve OpenPGP keys.  Only\n * useful on the server, and will only be used if the peer send a key\n * fingerprint instead of a full key.  See also\n * gnutls_openpgp_set_recv_key_function().\n *\n * The variable @key must be allocated using gnutls_malloc().\n *\n * Returns: On success, %GNUTLS_E_SUCCESS (zero) is returned,\n *   otherwise an error code is returned.\n */\ntypedef int (*gnutls_openpgp_recv_key_func) (gnutls_session_t\n\t\t\t\t\t     session,\n\t\t\t\t\t     const unsigned char\n\t\t\t\t\t     *keyfpr,\n\t\t\t\t\t     unsigned int\n\t\t\t\t\t     keyfpr_length,\n\t\t\t\t\t     gnutls_datum_t * key);\n\nvoid\ngnutls_openpgp_set_recv_key_function(gnutls_session_t session,\n\t\t\t\t     gnutls_openpgp_recv_key_func func) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\n\n/* certificate authentication stuff.\n */\nint gnutls_certificate_set_openpgp_key\n    (gnutls_certificate_credentials_t res,\n     gnutls_openpgp_crt_t crt, gnutls_openpgp_privkey_t pkey) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint\ngnutls_certificate_get_openpgp_key(gnutls_certificate_credentials_t res,\n                                   unsigned index,\n                                   gnutls_openpgp_privkey_t *key) _GNUTLS_GCC_ATTR_DEPRECATED;\nint\ngnutls_certificate_get_openpgp_crt(gnutls_certificate_credentials_t res,\n                                   unsigned index,\n                                   gnutls_openpgp_crt_t **crt_list,\n                                   unsigned *crt_list_size) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint\n gnutls_certificate_set_openpgp_key_file\n    (gnutls_certificate_credentials_t res, const char *certfile,\n     const char *keyfile, gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_certificate_set_openpgp_key_mem\n    (gnutls_certificate_credentials_t res,\n     const gnutls_datum_t * cert, const gnutls_datum_t * key,\n     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint\n gnutls_certificate_set_openpgp_key_file2\n    (gnutls_certificate_credentials_t res, const char *certfile,\n     const char *keyfile, const char *subkey_id,\n     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\nint\n gnutls_certificate_set_openpgp_key_mem2\n    (gnutls_certificate_credentials_t res,\n     const gnutls_datum_t * cert, const gnutls_datum_t * key,\n     const char *subkey_id, gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_certificate_set_openpgp_keyring_mem\n    (gnutls_certificate_credentials_t c, const unsigned char *data,\n     size_t dlen, gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_certificate_set_openpgp_keyring_file\n    (gnutls_certificate_credentials_t c, const char *file,\n     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_OPENPGP_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/pkcs11.h",
    "content": "/*\n * Copyright (C) 2010-2012 Free Software Foundation, Inc.\n * Copyright (C) 2016-2018 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_PKCS11_H\n#define GNUTLS_PKCS11_H\n\n#include <stdarg.h>\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#define GNUTLS_PKCS11_MAX_PIN_LEN 256\n\n/**\n * gnutls_pkcs11_token_callback_t:\n * @userdata: user-controlled data from gnutls_pkcs11_set_token_function().\n * @label: token label.\n * @retry: retry counter, initially 0.\n *\n * Token callback function. The callback will be used to ask the user\n * to re-insert the token with given (null terminated) label.  The\n * callback should return zero if token has been inserted by user and\n * a negative error code otherwise.  It might be called multiple times\n * if the token is not detected and the retry counter will be\n * increased.\n *\n * Returns: %GNUTLS_E_SUCCESS (0) on success or a negative error code\n * on error.\n *\n * Since: 2.12.0\n **/\ntypedef int (*gnutls_pkcs11_token_callback_t) (void *const\n\t\t\t\t\t       userdata,\n\t\t\t\t\t       const char *const\n\t\t\t\t\t       label, unsigned retry);\n\n\nstruct gnutls_pkcs11_obj_st;\ntypedef struct gnutls_pkcs11_obj_st *gnutls_pkcs11_obj_t;\n\n\n#define GNUTLS_PKCS11_FLAG_MANUAL 0\t/* Manual loading of libraries */\n#define GNUTLS_PKCS11_FLAG_AUTO 1\t/* Automatically load libraries by reading /etc/gnutls/pkcs11.conf */\n#define GNUTLS_PKCS11_FLAG_AUTO_TRUSTED (1<<1)\t/* Automatically load trusted libraries by reading /etc/gnutls/pkcs11.conf */\n\n/* pkcs11.conf format:\n * load = /lib/xxx-pkcs11.so\n * load = /lib/yyy-pkcs11.so\n */\n\nint gnutls_pkcs11_init(unsigned int flags,\n\t\t       const char *deprecated_config_file);\nint gnutls_pkcs11_reinit(void);\nvoid gnutls_pkcs11_deinit(void);\nvoid gnutls_pkcs11_set_token_function\n    (gnutls_pkcs11_token_callback_t fn, void *userdata);\n\nvoid gnutls_pkcs11_set_pin_function(gnutls_pin_callback_t fn,\n\t\t\t\t    void *userdata);\n\ngnutls_pin_callback_t gnutls_pkcs11_get_pin_function(void\n\t\t\t\t\t\t     **userdata);\n\nint gnutls_pkcs11_add_provider(const char *name, const char *params);\nint gnutls_pkcs11_obj_init(gnutls_pkcs11_obj_t * obj);\nvoid gnutls_pkcs11_obj_set_pin_function(gnutls_pkcs11_obj_t obj,\n\t\t\t\t\tgnutls_pin_callback_t fn,\n\t\t\t\t\tvoid *userdata);\n\n/**\n * gnutls_pkcs11_obj_flags:\n * @GNUTLS_PKCS11_OBJ_FLAG_LOGIN: Force login in the token for the operation (seek+store). \n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED: object marked as trusted (seek+store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE: object is explicitly marked as sensitive -unexportable (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_LOGIN_SO: force login as a security officer in the token for the operation (seek+store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE: marked as private -requires PIN to access (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_PRIVATE: marked as not private (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_ANY: When retrieving an object, do not set any requirements (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_TRUSTED: When retrieving an object, only retrieve the marked as trusted (alias to %GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED).\n *   In gnutls_pkcs11_crt_is_known() it implies %GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_COMPARE if %GNUTLS_PKCS11_OBJ_FLAG_COMPARE_KEY is not given.\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_DISTRUSTED: When writing an object, mark it as distrusted (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_DISTRUSTED: When retrieving an object, only retrieve the marked as distrusted (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_COMPARE: When checking an object's presence, fully compare it before returning any result (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_COMPARE_KEY: When checking an object's presence, compare the key before returning any result (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_PRESENT_IN_TRUSTED_MODULE: The object must be present in a marked as trusted module (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_CA: Mark the object as a CA (seek+store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_KEY_WRAP: Mark the generated key pair as wrapping and unwrapping keys (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_OVERWRITE_TRUSTMOD_EXT: When an issuer is requested, override its extensions with the ones present in the trust module (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_ALWAYS_AUTH: Mark the key pair as requiring authentication (pin entry) before every operation (seek+store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_EXTRACTABLE: Mark the key pair as being extractable (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_NEVER_EXTRACTABLE: If set, the object was never marked as extractable (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_CRT: When searching, restrict to certificates only (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_PUBKEY: When searching, restrict to public key objects only (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_PRIVKEY: When searching, restrict to private key objects only (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_NO_STORE_PUBKEY: When generating a keypair don't store the public key (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_SENSITIVE: object marked as not sensitive -exportable (store).\n *\n * Enumeration of different PKCS #11 object flags. Some flags are used\n * to mark objects when storing, while others are also used while seeking\n * or retrieving objects.\n */\ntypedef enum gnutls_pkcs11_obj_flags {\n\tGNUTLS_PKCS11_OBJ_FLAG_LOGIN = (1<<0),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED = (1<<1),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE = (1<<2),\n\tGNUTLS_PKCS11_OBJ_FLAG_LOGIN_SO = (1<<3),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE = (1<<4),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_PRIVATE = (1<<5),\n\tGNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_ANY = (1<<6),\n\tGNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_TRUSTED = GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED,\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_DISTRUSTED = (1<<8),\n\tGNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_DISTRUSTED = GNUTLS_PKCS11_OBJ_FLAG_MARK_DISTRUSTED,\n\tGNUTLS_PKCS11_OBJ_FLAG_COMPARE = (1<<9),\n\tGNUTLS_PKCS11_OBJ_FLAG_PRESENT_IN_TRUSTED_MODULE = (1<<10),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_CA = (1<<11),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_KEY_WRAP = (1<<12),\n\tGNUTLS_PKCS11_OBJ_FLAG_COMPARE_KEY = (1<<13),\n\tGNUTLS_PKCS11_OBJ_FLAG_OVERWRITE_TRUSTMOD_EXT = (1<<14),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_ALWAYS_AUTH = (1<<15),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_EXTRACTABLE = (1<<16),\n\tGNUTLS_PKCS11_OBJ_FLAG_NEVER_EXTRACTABLE = (1<<17),\n\tGNUTLS_PKCS11_OBJ_FLAG_CRT = (1<<18),\n\tGNUTLS_PKCS11_OBJ_FLAG_WITH_PRIVKEY = (1<<19),\n\tGNUTLS_PKCS11_OBJ_FLAG_PUBKEY = (1<<20),\n\tGNUTLS_PKCS11_OBJ_FLAG_NO_STORE_PUBKEY = GNUTLS_PKCS11_OBJ_FLAG_PUBKEY,\n\tGNUTLS_PKCS11_OBJ_FLAG_PRIVKEY = (1<<21),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_SENSITIVE = (1<<22),\n\t/* flags 1<<29 and later are reserved - see pkcs11_int.h */\n} gnutls_pkcs11_obj_flags;\n\n#define gnutls_pkcs11_obj_attr_t gnutls_pkcs11_obj_flags\n\n/**\n * gnutls_pkcs11_url_type_t:\n * @GNUTLS_PKCS11_URL_GENERIC: A generic-purpose URL.\n * @GNUTLS_PKCS11_URL_LIB: A URL that specifies the library used as well.\n * @GNUTLS_PKCS11_URL_LIB_VERSION: A URL that specifies the library and its version.\n *\n * Enumeration of different URL extraction flags.\n */\ntypedef enum {\n\tGNUTLS_PKCS11_URL_GENERIC,\t/* URL specifies the object on token level */\n\tGNUTLS_PKCS11_URL_LIB,\t/* URL specifies the object on module level */\n\tGNUTLS_PKCS11_URL_LIB_VERSION\t/* URL specifies the object on module and version level */\n} gnutls_pkcs11_url_type_t;\n\nint gnutls_pkcs11_obj_import_url(gnutls_pkcs11_obj_t obj,\n\t\t\t\t const char *url, unsigned int flags\n\t\t\t\t /* GNUTLS_PKCS11_OBJ_FLAG_* */ );\nint gnutls_pkcs11_obj_export_url(gnutls_pkcs11_obj_t obj,\n\t\t\t\t gnutls_pkcs11_url_type_t detailed,\n\t\t\t\t char **url);\nvoid gnutls_pkcs11_obj_deinit(gnutls_pkcs11_obj_t obj);\n\nint gnutls_pkcs11_obj_export(gnutls_pkcs11_obj_t obj,\n\t\t\t     void *output_data, size_t * output_data_size);\nint gnutls_pkcs11_obj_export2(gnutls_pkcs11_obj_t obj,\n\t\t\t      gnutls_datum_t * out);\n\nint gnutls_pkcs11_obj_export3(gnutls_pkcs11_obj_t obj, gnutls_x509_crt_fmt_t fmt,\n\t\t\t      gnutls_datum_t * out);\n\nint gnutls_pkcs11_get_raw_issuer(const char *url, gnutls_x509_crt_t cert,\n\t\t\t     gnutls_datum_t * issuer,\n\t\t\t     gnutls_x509_crt_fmt_t fmt,\n\t\t\t     unsigned int flags);\n\nint gnutls_pkcs11_get_raw_issuer_by_dn (const char *url, const gnutls_datum_t *dn,\n\t\t\t\t\tgnutls_datum_t *issuer,\n\t\t\t\t\tgnutls_x509_crt_fmt_t fmt,\n\t\t\t\t\tunsigned int flags);\n\nint gnutls_pkcs11_get_raw_issuer_by_subject_key_id (const char *url, \n\t\t\t\t\tconst gnutls_datum_t *dn,\n\t\t\t\t\tconst gnutls_datum_t *spki,\n\t\t\t\t\tgnutls_datum_t *issuer,\n\t\t\t\t\tgnutls_x509_crt_fmt_t fmt,\n\t\t\t\t\tunsigned int flags);\n\nunsigned gnutls_pkcs11_crt_is_known(const char *url, gnutls_x509_crt_t cert,\n\t\t\t     unsigned int flags);\n\n#if 0\n/* for documentation */\nint gnutls_pkcs11_copy_x509_crt(const char *token_url,\n\t\t\t\tgnutls_x509_crt_t crt,\n\t\t\t\tconst char *label, unsigned int flags\n\t\t\t\t/* GNUTLS_PKCS11_OBJ_FLAG_* */ );\n\nint gnutls_pkcs11_copy_x509_privkey(const char *token_url,\n\t\t\t\t    gnutls_x509_privkey_t key,\n\t\t\t\t    const char *label,\n\t\t\t\t    unsigned int key_usage,\n\t\t\t\t    unsigned int flags);\nint\ngnutls_pkcs11_privkey_generate2(const char *url, gnutls_pk_algorithm_t pk,\n\t\t\t\tunsigned int bits, const char *label,\n\t\t\t\tgnutls_x509_crt_fmt_t fmt,\n\t\t\t\tgnutls_datum_t * pubkey,\n\t\t\t\tunsigned int flags);\nint\ngnutls_pkcs11_privkey_generate(const char *url, gnutls_pk_algorithm_t pk,\n\t\t\t       unsigned int bits, const char *label,\n\t\t\t       unsigned int flags);\n#endif\n\nint\ngnutls_pkcs11_copy_pubkey(const char *token_url,\n\t\t\t  gnutls_pubkey_t crt, const char *label,\n\t\t\t  const gnutls_datum_t *cid,\n\t\t\t  unsigned int key_usage, unsigned int flags);\n\n#define gnutls_pkcs11_copy_x509_crt(url, crt, label, flags) \\\n\tgnutls_pkcs11_copy_x509_crt2(url, crt, label, NULL, flags)\n\nint gnutls_pkcs11_copy_x509_crt2(const char *token_url,\n\t\t\t\tgnutls_x509_crt_t crt,\n\t\t\t\tconst char *label,\n\t\t\t\tconst gnutls_datum_t *id,\n\t\t\t\tunsigned int flags /* GNUTLS_PKCS11_OBJ_FLAG_* */);\n\n#define gnutls_pkcs11_copy_x509_privkey(url, key, label, usage, flags) \\\n\tgnutls_pkcs11_copy_x509_privkey2(url, key, label, NULL, usage, flags)\nint gnutls_pkcs11_copy_x509_privkey2(const char *token_url,\n\t\t\t\t    gnutls_x509_privkey_t key,\n\t\t\t\t    const char *label,\n\t\t\t\t    const gnutls_datum_t *cid,\n\t\t\t\t    unsigned int key_usage\n\t\t\t\t    /*GNUTLS_KEY_* */ ,\n\t\t\t\t    unsigned int flags\n\t\t\t\t    /* GNUTLS_PKCS11_OBJ_FLAG_* */\n);\n\nint gnutls_pkcs11_delete_url(const char *object_url, unsigned int flags\n\t\t\t     /* GNUTLS_PKCS11_OBJ_FLAG_* */ );\n\nint gnutls_pkcs11_copy_secret_key(const char *token_url,\n\t\t\t\t  gnutls_datum_t * key,\n\t\t\t\t  const char *label, unsigned int key_usage\n\t\t\t\t  /* GNUTLS_KEY_* */ ,\n\t\t\t\t  unsigned int flags\n\t\t\t\t  /* GNUTLS_PKCS11_OBJ_FLAG_* */ );\n\n/**\n * gnutls_pkcs11_obj_info_t:\n * @GNUTLS_PKCS11_OBJ_ID_HEX: The object ID in hex. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_LABEL: The object label. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_TOKEN_LABEL: The token's label. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_TOKEN_SERIAL: The token's serial number. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_TOKEN_MANUFACTURER: The token's manufacturer. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_TOKEN_MODEL: The token's model. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_ID: The object ID. Raw bytes.\n * @GNUTLS_PKCS11_OBJ_LIBRARY_VERSION: The library's version. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_LIBRARY_DESCRIPTION: The library's description. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_LIBRARY_MANUFACTURER: The library's manufacturer name. Null-terminated text.\n *\n * Enumeration of several object information types.\n */\ntypedef enum {\n\tGNUTLS_PKCS11_OBJ_ID_HEX = 1,\n\tGNUTLS_PKCS11_OBJ_LABEL,\n\tGNUTLS_PKCS11_OBJ_TOKEN_LABEL,\n\tGNUTLS_PKCS11_OBJ_TOKEN_SERIAL,\n\tGNUTLS_PKCS11_OBJ_TOKEN_MANUFACTURER,\n\tGNUTLS_PKCS11_OBJ_TOKEN_MODEL,\n\tGNUTLS_PKCS11_OBJ_ID,\n\t/* the pkcs11 provider library info  */\n\tGNUTLS_PKCS11_OBJ_LIBRARY_VERSION,\n\tGNUTLS_PKCS11_OBJ_LIBRARY_DESCRIPTION,\n\tGNUTLS_PKCS11_OBJ_LIBRARY_MANUFACTURER\n} gnutls_pkcs11_obj_info_t;\n\nint\ngnutls_pkcs11_obj_get_ptr(gnutls_pkcs11_obj_t obj, void **ptr,\n\t\t\t  void **session, void **ohandle,\n\t\t\t  unsigned long *slot_id,\n\t\t\t  unsigned int flags);\n\nint gnutls_pkcs11_obj_get_info(gnutls_pkcs11_obj_t obj,\n\t\t\t       gnutls_pkcs11_obj_info_t itype,\n\t\t\t       void *output, size_t * output_size);\nint gnutls_pkcs11_obj_set_info(gnutls_pkcs11_obj_t obj,\n\t\t\t       gnutls_pkcs11_obj_info_t itype,\n\t\t\t       const void *data, size_t data_size,\n\t\t\t       unsigned flags);\n\n#define GNUTLS_PKCS11_OBJ_ATTR_CRT_ALL GNUTLS_PKCS11_OBJ_FLAG_CRT\n#define GNUTLS_PKCS11_OBJ_ATTR_MATCH 0 /* always match the given URL */\n#define GNUTLS_PKCS11_OBJ_ATTR_ALL 0 /* match everything! */\n#define GNUTLS_PKCS11_OBJ_ATTR_CRT_TRUSTED (GNUTLS_PKCS11_OBJ_FLAG_CRT|GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED)\n#define GNUTLS_PKCS11_OBJ_ATTR_CRT_WITH_PRIVKEY (GNUTLS_PKCS11_OBJ_FLAG_CRT|GNUTLS_PKCS11_OBJ_FLAG_WITH_PRIVKEY)\n#define GNUTLS_PKCS11_OBJ_ATTR_CRT_TRUSTED_CA (GNUTLS_PKCS11_OBJ_FLAG_CRT|GNUTLS_PKCS11_OBJ_FLAG_MARK_CA|GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED)\n#define GNUTLS_PKCS11_OBJ_ATTR_PUBKEY GNUTLS_PKCS11_OBJ_FLAG_PUBKEY\n#define GNUTLS_PKCS11_OBJ_ATTR_PRIVKEY GNUTLS_PKCS11_OBJ_FLAG_PRIVKEY\n\n/**\n * gnutls_pkcs11_token_info_t:\n * @GNUTLS_PKCS11_TOKEN_LABEL: The token's label (string)\n * @GNUTLS_PKCS11_TOKEN_SERIAL: The token's serial number (string)\n * @GNUTLS_PKCS11_TOKEN_MANUFACTURER: The token's manufacturer (string)\n * @GNUTLS_PKCS11_TOKEN_MODEL: The token's model (string)\n * @GNUTLS_PKCS11_TOKEN_MODNAME: The token's module name (string - since 3.4.3). This value is\n *   unavailable for providers which were manually loaded.\n *\n * Enumeration of types for retrieving token information.\n */\ntypedef enum {\n\tGNUTLS_PKCS11_TOKEN_LABEL,\n\tGNUTLS_PKCS11_TOKEN_SERIAL,\n\tGNUTLS_PKCS11_TOKEN_MANUFACTURER,\n\tGNUTLS_PKCS11_TOKEN_MODEL,\n\tGNUTLS_PKCS11_TOKEN_MODNAME\n} gnutls_pkcs11_token_info_t;\n\n/**\n * gnutls_pkcs11_obj_type_t:\n * @GNUTLS_PKCS11_OBJ_UNKNOWN: Unknown PKCS11 object.\n * @GNUTLS_PKCS11_OBJ_X509_CRT: X.509 certificate.\n * @GNUTLS_PKCS11_OBJ_PUBKEY: Public key.\n * @GNUTLS_PKCS11_OBJ_PRIVKEY: Private key.\n * @GNUTLS_PKCS11_OBJ_SECRET_KEY: Secret key.\n * @GNUTLS_PKCS11_OBJ_DATA: Data object.\n * @GNUTLS_PKCS11_OBJ_X509_CRT_EXTENSION: X.509 certificate extension (supported by p11-kit trust module only).\n *\n * Enumeration of object types.\n */\ntypedef enum {\n\tGNUTLS_PKCS11_OBJ_UNKNOWN,\n\tGNUTLS_PKCS11_OBJ_X509_CRT,\n\tGNUTLS_PKCS11_OBJ_PUBKEY,\n\tGNUTLS_PKCS11_OBJ_PRIVKEY,\n\tGNUTLS_PKCS11_OBJ_SECRET_KEY,\n\tGNUTLS_PKCS11_OBJ_DATA,\n\tGNUTLS_PKCS11_OBJ_X509_CRT_EXTENSION\n} gnutls_pkcs11_obj_type_t;\n\nint\ngnutls_pkcs11_token_init(const char *token_url,\n\t\t\t const char *so_pin, const char *label);\n\nint\ngnutls_pkcs11_token_get_ptr(const char *url, void **ptr, unsigned long *slot_id,\n\t\t\t    unsigned int flags);\n\nint\ngnutls_pkcs11_token_get_mechanism(const char *url,\n\t\t\t\t  unsigned int idx,\n\t\t\t\t  unsigned long *mechanism);\n\nunsigned\ngnutls_pkcs11_token_check_mechanism(const char *url,\n\t\t\t\t    unsigned long mechanism,\n\t\t\t\t    void *ptr, unsigned psize, unsigned flags);\n\nint gnutls_pkcs11_token_set_pin(const char *token_url, const char *oldpin, const char *newpin, unsigned int flags\t/*gnutls_pin_flag_t */);\n\nint gnutls_pkcs11_token_get_url(unsigned int seq,\n\t\t\t\tgnutls_pkcs11_url_type_t detailed,\n\t\t\t\tchar **url);\nint gnutls_pkcs11_token_get_info(const char *url,\n\t\t\t\t gnutls_pkcs11_token_info_t ttype,\n\t\t\t\t void *output, size_t * output_size);\n\n#define GNUTLS_PKCS11_TOKEN_HW 1\n#define GNUTLS_PKCS11_TOKEN_TRUSTED (1<<1) /* p11-kit trusted */\n#define GNUTLS_PKCS11_TOKEN_RNG (1<<2) /* CKF_RNG */\n#define GNUTLS_PKCS11_TOKEN_LOGIN_REQUIRED (1<<3) /* CKF_LOGIN_REQUIRED */\n#define GNUTLS_PKCS11_TOKEN_PROTECTED_AUTHENTICATION_PATH (1<<4) /* CKF_PROTECTED_AUTHENTICATION_PATH */\n#define GNUTLS_PKCS11_TOKEN_INITIALIZED (1<<5) /* CKF_TOKEN_INITIALIZED */\n#define GNUTLS_PKCS11_TOKEN_USER_PIN_COUNT_LOW (1<<6) /* CKF_USER_PIN_COUNT_LOW */\n#define GNUTLS_PKCS11_TOKEN_USER_PIN_FINAL_TRY (1<<7) /* CKF_USER_PIN_FINAL_TRY */\n#define GNUTLS_PKCS11_TOKEN_USER_PIN_LOCKED (1<<8) /* CKF_USER_PIN_LOCKED */\n#define GNUTLS_PKCS11_TOKEN_SO_PIN_COUNT_LOW (1<<9) /* CKF_SO_PIN_COUNT_LOW */\n#define GNUTLS_PKCS11_TOKEN_SO_PIN_FINAL_TRY (1<<10) /* CKF_SO_PIN_FINAL_TRY */\n#define GNUTLS_PKCS11_TOKEN_SO_PIN_LOCKED (1<<11) /* CKF_SO_PIN_LOCKED */\n#define GNUTLS_PKCS11_TOKEN_USER_PIN_INITIALIZED (1<<12) /* CKF_USER_PIN_INITIALIZED */\n#define GNUTLS_PKCS11_TOKEN_ERROR_STATE (1<<13) /* CKF_ERROR_STATE */\n\nint gnutls_pkcs11_token_get_flags(const char *url, unsigned int *flags);\n\n#define gnutls_pkcs11_obj_list_import_url(p_list, n_list, url, attrs, flags) gnutls_pkcs11_obj_list_import_url3(p_list, n_list, url, attrs|flags)\n#define gnutls_pkcs11_obj_list_import_url2(p_list, n_list, url, attrs, flags) gnutls_pkcs11_obj_list_import_url4(p_list, n_list, url, attrs|flags)\n\nint gnutls_pkcs11_obj_list_import_url3(gnutls_pkcs11_obj_t * p_list,\n\t\t\t\t      unsigned int *const n_list,\n\t\t\t\t      const char *url,\n\t\t\t\t      unsigned int flags\n\t\t\t\t      /* GNUTLS_PKCS11_OBJ_FLAG_* */\n    );\n\nint\ngnutls_pkcs11_obj_list_import_url4(gnutls_pkcs11_obj_t ** p_list,\n\t\t\t\t   unsigned int *n_list,\n\t\t\t\t   const char *url,\n\t\t\t\t   unsigned int flags\n\t\t\t\t   /* GNUTLS_PKCS11_OBJ_FLAG_* */\n    );\n\nint gnutls_x509_crt_import_pkcs11(gnutls_x509_crt_t crt,\n\t\t\t\t  gnutls_pkcs11_obj_t pkcs11_crt);\n\ngnutls_pkcs11_obj_type_t\ngnutls_pkcs11_obj_get_type(gnutls_pkcs11_obj_t obj);\nconst char *gnutls_pkcs11_type_get_name(gnutls_pkcs11_obj_type_t type);\n\nint\ngnutls_pkcs11_obj_get_exts(gnutls_pkcs11_obj_t obj,\n\t\t\t   struct gnutls_x509_ext_st **exts, unsigned int *exts_size,\n\t\t\t   unsigned int flags);\n\nint\ngnutls_pkcs11_obj_get_flags(gnutls_pkcs11_obj_t obj, unsigned int *oflags);\nchar *gnutls_pkcs11_obj_flags_get_str(unsigned int flags);\n\nint gnutls_x509_crt_list_import_pkcs11(gnutls_x509_crt_t * certs,\n\t\t\t\t       unsigned int cert_max,\n\t\t\t\t       gnutls_pkcs11_obj_t *\n\t\t\t\t       const objs, unsigned int flags\n\t\t\t\t       /* must be zero */ );\n\n/* private key functions...*/\nint gnutls_pkcs11_privkey_init(gnutls_pkcs11_privkey_t * key);\n\nint\ngnutls_pkcs11_privkey_cpy(gnutls_pkcs11_privkey_t dst,\n\t\t\t  gnutls_pkcs11_privkey_t src);\n\nvoid gnutls_pkcs11_privkey_set_pin_function(gnutls_pkcs11_privkey_t\n\t\t\t\t\t    key,\n\t\t\t\t\t    gnutls_pin_callback_t\n\t\t\t\t\t    fn, void *userdata);\nvoid gnutls_pkcs11_privkey_deinit(gnutls_pkcs11_privkey_t key);\nint gnutls_pkcs11_privkey_get_pk_algorithm(gnutls_pkcs11_privkey_t\n\t\t\t\t\t   key, unsigned int *bits);\nint gnutls_pkcs11_privkey_get_info(gnutls_pkcs11_privkey_t pkey,\n\t\t\t\t   gnutls_pkcs11_obj_info_t itype,\n\t\t\t\t   void *output, size_t * output_size);\n\nint gnutls_pkcs11_privkey_import_url(gnutls_pkcs11_privkey_t pkey,\n\t\t\t\t     const char *url, unsigned int flags);\n\nint gnutls_pkcs11_privkey_export_url(gnutls_pkcs11_privkey_t key,\n\t\t\t\t     gnutls_pkcs11_url_type_t\n\t\t\t\t     detailed, char **url);\nunsigned gnutls_pkcs11_privkey_status(gnutls_pkcs11_privkey_t key);\n\n#define gnutls_pkcs11_privkey_generate(url, pk, bits, label, flags) \\\n\tgnutls_pkcs11_privkey_generate3(url, pk, bits, label, NULL, 0, NULL, 0, flags)\n\n#define gnutls_pkcs11_privkey_generate2(url, pk, bits, label, fmt, pubkey, flags) \\\n\tgnutls_pkcs11_privkey_generate3(url, pk, bits, label, NULL, fmt, pubkey, 0, flags)\n\nint\ngnutls_pkcs11_privkey_generate3(const char *url,\n\t\t\t\tgnutls_pk_algorithm_t pk,\n\t\t\t\tunsigned int bits,\n\t\t\t\tconst char *label,\n\t\t\t\tconst gnutls_datum_t *cid,\n\t\t\t\tgnutls_x509_crt_fmt_t fmt,\n\t\t\t\tgnutls_datum_t * pubkey,\n\t\t\t\tunsigned int key_usage,\n\t\t\t\tunsigned int flags);\n\nint\ngnutls_pkcs11_privkey_export_pubkey(gnutls_pkcs11_privkey_t pkey,\n\t\t\t      gnutls_x509_crt_fmt_t fmt,\n\t\t\t      gnutls_datum_t * pubkey,\n\t\t\t      unsigned int flags);\n\nint\ngnutls_pkcs11_token_get_random(const char *token_url,\n\t\t\t       void *data, size_t len);\n\nint\ngnutls_pkcs11_copy_attached_extension(const char *token_url,\n\t\t\t\t      gnutls_x509_crt_t crt,\n\t\t\t\t      gnutls_datum_t *data,\n\t\t\t\t      const char *label,\n\t\t\t\t      unsigned int flags);\n\n#define gnutls_x509_crt_import_pkcs11_url gnutls_x509_crt_import_url\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_PKCS11_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/pkcs12.h",
    "content": "/*\n * Copyright (C) 2003-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_PKCS12_H\n#define GNUTLS_PKCS12_H\n\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n\t/* PKCS12 structures handling\n\t */\nstruct gnutls_pkcs12_int;\ntypedef struct gnutls_pkcs12_int *gnutls_pkcs12_t;\n\nstruct gnutls_pkcs12_bag_int;\ntypedef struct gnutls_pkcs12_bag_int *gnutls_pkcs12_bag_t;\n\nint gnutls_pkcs12_init(gnutls_pkcs12_t * pkcs12);\nvoid gnutls_pkcs12_deinit(gnutls_pkcs12_t pkcs12);\nint gnutls_pkcs12_import(gnutls_pkcs12_t pkcs12,\n\t\t\t const gnutls_datum_t * data,\n\t\t\t gnutls_x509_crt_fmt_t format, unsigned int flags);\nint gnutls_pkcs12_export(gnutls_pkcs12_t pkcs12,\n\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t void *output_data, size_t * output_data_size);\nint gnutls_pkcs12_export2(gnutls_pkcs12_t pkcs12,\n\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t  gnutls_datum_t * out);\n\nint gnutls_pkcs12_get_bag(gnutls_pkcs12_t pkcs12,\n\t\t\t  int indx, gnutls_pkcs12_bag_t bag);\nint gnutls_pkcs12_set_bag(gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag);\n\nint gnutls_pkcs12_generate_mac(gnutls_pkcs12_t pkcs12, const char *pass);\nint gnutls_pkcs12_generate_mac2(gnutls_pkcs12_t pkcs12, gnutls_mac_algorithm_t mac, const char *pass);\nint gnutls_pkcs12_verify_mac(gnutls_pkcs12_t pkcs12, const char *pass);\n\nint gnutls_pkcs12_bag_decrypt(gnutls_pkcs12_bag_t bag, const char *pass);\nint gnutls_pkcs12_bag_encrypt(gnutls_pkcs12_bag_t bag,\n\t\t\t      const char *pass, unsigned int flags);\n\nint\ngnutls_pkcs12_bag_enc_info(gnutls_pkcs12_bag_t bag, unsigned int *schema, unsigned int *cipher,\n\tvoid *salt, unsigned int *salt_size, unsigned int *iter_count, char **oid);\nint\ngnutls_pkcs12_mac_info(gnutls_pkcs12_t pkcs12, unsigned int *mac,\n\tvoid *salt, unsigned int *salt_size, unsigned int *iter_count, char **oid);\n\n#define GNUTLS_PKCS12_SP_INCLUDE_SELF_SIGNED 1\nint gnutls_pkcs12_simple_parse(gnutls_pkcs12_t p12,\n\t\t\t       const char *password,\n\t\t\t       gnutls_x509_privkey_t * key,\n\t\t\t       gnutls_x509_crt_t ** chain,\n\t\t\t       unsigned int *chain_len,\n\t\t\t       gnutls_x509_crt_t ** extra_certs,\n\t\t\t       unsigned int *extra_certs_len,\n\t\t\t       gnutls_x509_crl_t * crl,\n\t\t\t       unsigned int flags);\n\n/**\n * gnutls_pkcs12_bag_type_t:\n * @GNUTLS_BAG_EMPTY: Empty PKCS-12 bag.\n * @GNUTLS_BAG_PKCS8_ENCRYPTED_KEY: PKCS-12 bag with PKCS-8 encrypted key.\n * @GNUTLS_BAG_PKCS8_KEY: PKCS-12 bag with PKCS-8 key.\n * @GNUTLS_BAG_CERTIFICATE: PKCS-12 bag with certificate.\n * @GNUTLS_BAG_CRL: PKCS-12 bag with CRL.\n * @GNUTLS_BAG_SECRET: PKCS-12 bag with secret PKCS-9 keys.\n * @GNUTLS_BAG_ENCRYPTED: Encrypted PKCS-12 bag.\n * @GNUTLS_BAG_UNKNOWN: Unknown PKCS-12 bag.\n *\n * Enumeration of different PKCS 12 bag types.\n */\ntypedef enum gnutls_pkcs12_bag_type_t {\n\tGNUTLS_BAG_EMPTY = 0,\n\tGNUTLS_BAG_PKCS8_ENCRYPTED_KEY = 1,\n\tGNUTLS_BAG_PKCS8_KEY = 2,\n\tGNUTLS_BAG_CERTIFICATE = 3,\n\tGNUTLS_BAG_CRL = 4,\n\tGNUTLS_BAG_SECRET = 5,\t/* Secret data. Underspecified in pkcs-12,\n\t\t\t\t * gnutls extension. We use the PKCS-9\n\t\t\t\t * random nonce ID 1.2.840.113549.1.9.25.3\n\t\t\t\t * to store randomly generated keys.\n\t\t\t\t */\n\tGNUTLS_BAG_ENCRYPTED = 10,\n\tGNUTLS_BAG_UNKNOWN = 20\n} gnutls_pkcs12_bag_type_t;\n\nint\ngnutls_pkcs12_bag_get_type(gnutls_pkcs12_bag_t bag, unsigned indx);\nint gnutls_pkcs12_bag_get_data(gnutls_pkcs12_bag_t bag, unsigned indx,\n\t\t\t       gnutls_datum_t * data);\nint gnutls_pkcs12_bag_set_data(gnutls_pkcs12_bag_t bag,\n\t\t\t       gnutls_pkcs12_bag_type_t type,\n\t\t\t       const gnutls_datum_t * data);\nint gnutls_pkcs12_bag_set_crl(gnutls_pkcs12_bag_t bag,\n\t\t\t      gnutls_x509_crl_t crl);\nint gnutls_pkcs12_bag_set_crt(gnutls_pkcs12_bag_t bag,\n\t\t\t      gnutls_x509_crt_t crt);\n\nint\ngnutls_pkcs12_bag_set_privkey(gnutls_pkcs12_bag_t bag,\n\t\t\t      gnutls_x509_privkey_t privkey,\n\t\t\t      const char *password, unsigned flags);\n\nint gnutls_pkcs12_bag_init(gnutls_pkcs12_bag_t * bag);\nvoid gnutls_pkcs12_bag_deinit(gnutls_pkcs12_bag_t bag);\nint gnutls_pkcs12_bag_get_count(gnutls_pkcs12_bag_t bag);\n\nint gnutls_pkcs12_bag_get_key_id(gnutls_pkcs12_bag_t bag, unsigned indx,\n\t\t\t\t gnutls_datum_t * id);\nint gnutls_pkcs12_bag_set_key_id(gnutls_pkcs12_bag_t bag, unsigned indx,\n\t\t\t\t const gnutls_datum_t * id);\n\nint gnutls_pkcs12_bag_get_friendly_name(gnutls_pkcs12_bag_t bag,\n\t\t\t\t\tunsigned indx, char **name);\nint gnutls_pkcs12_bag_set_friendly_name(gnutls_pkcs12_bag_t bag,\n\t\t\t\t\tunsigned indx, const char *name);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_PKCS12_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/pkcs7.h",
    "content": "/*\n * Copyright (C) 2003-2012 Free Software Foundation, Inc.\n * Copyright (C) 2015 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for the X.509\n * certificate and CRL handling functions.\n */\n\n#ifndef GNUTLS_PKCS7_H\n#define GNUTLS_PKCS7_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/* PKCS7 structures handling\n */\nstruct gnutls_pkcs7_int;\ntypedef struct gnutls_pkcs7_int *gnutls_pkcs7_t;\n\nint gnutls_pkcs7_init(gnutls_pkcs7_t * pkcs7);\nvoid gnutls_pkcs7_deinit(gnutls_pkcs7_t pkcs7);\nint gnutls_pkcs7_import(gnutls_pkcs7_t pkcs7,\n\t\t\tconst gnutls_datum_t * data,\n\t\t\tgnutls_x509_crt_fmt_t format);\nint gnutls_pkcs7_export(gnutls_pkcs7_t pkcs7,\n\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\tvoid *output_data, size_t * output_data_size);\nint gnutls_pkcs7_export2(gnutls_pkcs7_t pkcs7,\n\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t gnutls_datum_t * out);\n\nint gnutls_pkcs7_get_signature_count(gnutls_pkcs7_t pkcs7);\n\n#define GNUTLS_PKCS7_EDATA_GET_RAW (1<<24)\nint gnutls_pkcs7_get_embedded_data(gnutls_pkcs7_t pkcs7, unsigned flags, gnutls_datum_t *data);\n\nconst char *\ngnutls_pkcs7_get_embedded_data_oid(gnutls_pkcs7_t pkcs7);\n\nint gnutls_pkcs7_get_crt_count(gnutls_pkcs7_t pkcs7);\nint gnutls_pkcs7_get_crt_raw(gnutls_pkcs7_t pkcs7, unsigned indx,\n\t\t\t     void *certificate, size_t * certificate_size);\n\nint gnutls_pkcs7_set_crt_raw(gnutls_pkcs7_t pkcs7,\n\t\t\t     const gnutls_datum_t * crt);\nint gnutls_pkcs7_set_crt(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt);\nint gnutls_pkcs7_delete_crt(gnutls_pkcs7_t pkcs7, int indx);\n\nint gnutls_pkcs7_get_crl_raw(gnutls_pkcs7_t pkcs7,\n\t\t\t     unsigned indx, void *crl, size_t * crl_size);\nint gnutls_pkcs7_get_crl_count(gnutls_pkcs7_t pkcs7);\n\nint gnutls_pkcs7_set_crl_raw(gnutls_pkcs7_t pkcs7,\n\t\t\t     const gnutls_datum_t * crl);\nint gnutls_pkcs7_set_crl(gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl);\nint gnutls_pkcs7_delete_crl(gnutls_pkcs7_t pkcs7, int indx);\n\ntypedef struct gnutls_pkcs7_attrs_st *gnutls_pkcs7_attrs_t;\n\ntypedef struct gnutls_pkcs7_signature_info_st {\n\tgnutls_sign_algorithm_t algo;\n\tgnutls_datum_t sig;\n\tgnutls_datum_t issuer_dn;\n\tgnutls_datum_t signer_serial;\n\tgnutls_datum_t issuer_keyid;\n\ttime_t signing_time;\n\tgnutls_pkcs7_attrs_t signed_attrs;\n\tgnutls_pkcs7_attrs_t unsigned_attrs;\n\tchar pad[64];\n} gnutls_pkcs7_signature_info_st;\n\nvoid gnutls_pkcs7_signature_info_deinit(gnutls_pkcs7_signature_info_st *info);\nint gnutls_pkcs7_get_signature_info(gnutls_pkcs7_t pkcs7, unsigned idx, gnutls_pkcs7_signature_info_st *info);\n\nint gnutls_pkcs7_verify_direct(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t signer,\n\t\t\t       unsigned idx, const gnutls_datum_t *data, unsigned flags);\nint gnutls_pkcs7_verify(gnutls_pkcs7_t pkcs7, gnutls_x509_trust_list_t tl,\n\t\t\tgnutls_typed_vdata_st * vdata, unsigned int vdata_size,\n\t\t\tunsigned idx, const gnutls_datum_t *data, unsigned flags);\n\n#define GNUTLS_PKCS7_ATTR_ENCODE_OCTET_STRING 1\nint gnutls_pkcs7_add_attr(gnutls_pkcs7_attrs_t *list, const char *oid, gnutls_datum_t *data, unsigned flags);\nvoid gnutls_pkcs7_attrs_deinit(gnutls_pkcs7_attrs_t list);\nint gnutls_pkcs7_get_attr(gnutls_pkcs7_attrs_t list, unsigned idx, char **oid, gnutls_datum_t *data, unsigned flags);\n\n/**\n * gnutls_pkcs7_sign_flags:\n * @GNUTLS_PKCS7_EMBED_DATA: The signed data will be embedded in the structure.\n * @GNUTLS_PKCS7_INCLUDE_TIME: The signing time will be included in the structure.\n * @GNUTLS_PKCS7_INCLUDE_CERT: The signer's certificate will be included in the cert list.\n * @GNUTLS_PKCS7_WRITE_SPKI: Use the signer's key identifier instead of name.\n *\n * Enumeration of the different PKCS #7 signature flags.\n */\ntypedef enum gnutls_pkcs7_sign_flags {\n\tGNUTLS_PKCS7_EMBED_DATA = 1,\n\tGNUTLS_PKCS7_INCLUDE_TIME = (1<<1),\n\tGNUTLS_PKCS7_INCLUDE_CERT = (1<<2),\n\tGNUTLS_PKCS7_WRITE_SPKI = (1<<3)\n} gnutls_pkcs7_sign_flags;\n\nint gnutls_pkcs7_sign(gnutls_pkcs7_t pkcs7,\n\t\t      gnutls_x509_crt_t signer,\n\t\t      gnutls_privkey_t signer_key,\n\t\t      const gnutls_datum_t *data,\n\t\t      gnutls_pkcs7_attrs_t signed_attrs,\n\t\t      gnutls_pkcs7_attrs_t unsigned_attrs,\n\t\t      gnutls_digest_algorithm_t dig,\n\t\t      unsigned flags);\n\nint\ngnutls_pkcs7_get_crt_raw2(gnutls_pkcs7_t pkcs7,\n\t\t\t  unsigned indx, gnutls_datum_t *cert);\nint\ngnutls_pkcs7_get_crl_raw2(gnutls_pkcs7_t pkcs7,\n\t\t\t  unsigned indx, gnutls_datum_t *crl);\n\nint gnutls_pkcs7_print(gnutls_pkcs7_t pkcs7,\n\t\t       gnutls_certificate_print_formats_t format,\n\t\t       gnutls_datum_t * out);\n\nint gnutls_pkcs7_print_signature_info(gnutls_pkcs7_signature_info_st * info,\n\t\t\t\t      gnutls_certificate_print_formats_t format,\n\t\t\t\t      gnutls_datum_t * out);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_PKCS7_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/self-test.h",
    "content": "/*\n * Copyright (C) 2014 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_SELF_TEST_H\n#define GNUTLS_SELF_TEST_H\n\n#include <gnutls/gnutls.h>\n\n /* Self checking functions */\n \n#define GNUTLS_SELF_TEST_FLAG_ALL 1\n#define GNUTLS_SELF_TEST_FLAG_NO_COMPAT (1<<1)\n\nint gnutls_cipher_self_test(unsigned flags, gnutls_cipher_algorithm_t cipher);\nint gnutls_mac_self_test(unsigned flags, gnutls_mac_algorithm_t mac);\nint gnutls_digest_self_test(unsigned flags, gnutls_digest_algorithm_t digest);\nint gnutls_pk_self_test(unsigned flags, gnutls_pk_algorithm_t pk);\nint gnutls_hkdf_self_test(unsigned flags, gnutls_mac_algorithm_t mac);\nint gnutls_pbkdf2_self_test(unsigned flags, gnutls_mac_algorithm_t mac);\nint gnutls_tlsprf_self_test(unsigned flags, gnutls_mac_algorithm_t mac);\n\n#endif /* GNUTLS_SELF_TEST_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/socket.h",
    "content": "/*\n * Copyright (C) 2016 Free Software Foundation, Inc.\n *\n * Author: Tim Ruehsen\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains socket related types, prototypes and includes.\n */\n\n#ifndef GNUTLS_SOCKET_H\n#define GNUTLS_SOCKET_H\n\n#include <gnutls/gnutls.h>\n\n/* Get socklen_t */\n#include <sys/socket.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/**\n * gnutls_transport_ktls_enable_flags_t:\n * @GNUTLS_KTLS_RECV: ktls enabled for recv function.\n * @GNUTLS_KTLS_SEND: ktls enabled for send function.\n * @GNUTLS_KTLS_DUPLEX: ktls enabled for both recv and send functions.\n *\n * Flag enumeration of ktls enable status for recv and send functions.\n * This is used by gnutls_transport_is_ktls_enabled().\n *\n * Since: 3.7.3\n */\ntypedef enum {\n\tGNUTLS_KTLS_RECV = 1 << 0,\n\tGNUTLS_KTLS_SEND = 1 << 1,\n\tGNUTLS_KTLS_DUPLEX = GNUTLS_KTLS_RECV | GNUTLS_KTLS_SEND,\n} gnutls_transport_ktls_enable_flags_t;\n\n\ngnutls_transport_ktls_enable_flags_t\ngnutls_transport_is_ktls_enabled(gnutls_session_t session);\n\nvoid gnutls_transport_set_fastopen(gnutls_session_t session,\n                                   int fd,\n                                   struct sockaddr *connect_addr,\n                                   socklen_t connect_addrlen,\n                                   unsigned int flags);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_SOCKET_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/system-keys.h",
    "content": "/*\n * Copyright (C) 2014 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_SYSTEM_KEYS_H\n#define GNUTLS_SYSTEM_KEYS_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* This API allows to access user key and certificate pairs that are\n * available in the current system. If any passwords are required,\n * they will be requested through the pin callbacks.\n */\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\nstruct system_key_iter_st;\ntypedef struct system_key_iter_st *gnutls_system_key_iter_t;\n\nvoid gnutls_system_key_iter_deinit(gnutls_system_key_iter_t iter);\nint\ngnutls_system_key_iter_get_info(gnutls_system_key_iter_t *iter,\n\t\t\t       unsigned cert_type /* gnutls_certificate_type_t */,\n\t\t\t       char **cert_url,\n\t\t\t       char **key_url,\n\t\t\t       char **label,\n\t\t\t       gnutls_datum_t *der,\n\t\t\t       unsigned int flags);\n\nint gnutls_system_key_delete(const char *cert_url, const char *key_url);\n\nint gnutls_system_key_add_x509(gnutls_x509_crt_t crt, gnutls_x509_privkey_t privkey,\n\t\t\t\tconst char *label, char **cert_url, char **key_url);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_SYSTEM_KEYS_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/tpm.h",
    "content": "/*\n * Copyright (C) 2010-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_TPM_H\n#define GNUTLS_TPM_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\nstruct tpm_key_list_st;\ntypedef struct tpm_key_list_st *gnutls_tpm_key_list_t;\n\n#define GNUTLS_TPM_KEY_SIGNING (1<<1)\n#define GNUTLS_TPM_REGISTER_KEY (1<<2)\n#define GNUTLS_TPM_KEY_USER (1<<3)\n\n/**\n * gnutls_tpmkey_fmt_t:\n * @GNUTLS_TPMKEY_FMT_RAW: The portable data format.\n * @GNUTLS_TPMKEY_FMT_DER: An alias for the raw format.\n * @GNUTLS_TPMKEY_FMT_CTK_PEM: A custom data format used by some TPM tools.\n *\n * Enumeration of different certificate encoding formats.\n */\ntypedef enum {\n\tGNUTLS_TPMKEY_FMT_RAW = 0,\n\tGNUTLS_TPMKEY_FMT_DER = GNUTLS_TPMKEY_FMT_RAW,\n\tGNUTLS_TPMKEY_FMT_CTK_PEM = 1\n} gnutls_tpmkey_fmt_t;\n\nint\ngnutls_tpm_privkey_generate(gnutls_pk_algorithm_t pk,\n\t\t\t    unsigned int bits,\n\t\t\t    const char *srk_password,\n\t\t\t    const char *key_password,\n\t\t\t    gnutls_tpmkey_fmt_t format,\n\t\t\t    gnutls_x509_crt_fmt_t pub_format,\n\t\t\t    gnutls_datum_t * privkey,\n\t\t\t    gnutls_datum_t * pubkey, unsigned int flags);\n\nvoid gnutls_tpm_key_list_deinit(gnutls_tpm_key_list_t list);\nint gnutls_tpm_key_list_get_url(gnutls_tpm_key_list_t list,\n\t\t\t\tunsigned int idx, char **url,\n\t\t\t\tunsigned int flags);\nint gnutls_tpm_get_registered(gnutls_tpm_key_list_t * list);\nint gnutls_tpm_privkey_delete(const char *url, const char *srk_password);\n\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_TPM_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/urls.h",
    "content": "/*\n * Copyright (C) 2014 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_URLS_H\n#define GNUTLS_URLS_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n#include <gnutls/abstract.h>\n\n/* This API allows to register application specific URLs for\n * keys and certificates.\n */\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\ntypedef int (*gnutls_privkey_import_url_func)(gnutls_privkey_t pkey,\n\t\t\t\t\t       const char *url, unsigned flags);\n\ntypedef int (*gnutls_x509_crt_import_url_func)(gnutls_x509_crt_t pkey,\n\t\t\t\t\t        const char *url, unsigned flags);\n\n/* The following callbacks are optional */\n\n/* This is to enable gnutls_pubkey_import_url() */\ntypedef int (*gnutls_pubkey_import_url_func)(gnutls_pubkey_t pkey,\n\t\t\t\t\t     const char *url, unsigned flags);\n\n/* This is to allow constructing a certificate chain. It will be provided\n * the initial certificate URL and the certificate to find its issuer, and must\n * return zero and the DER encoding of the issuer's certificate. If not available,\n * it should return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE. */\ntypedef int (*gnutls_get_raw_issuer_func)(const char *url, gnutls_x509_crt_t crt,\n\t\t\t\t\t  gnutls_datum_t *issuer_der, unsigned flags);\n\ntypedef struct gnutls_custom_url_st {\n\tconst char *name;\n\tunsigned name_size;\n\tgnutls_privkey_import_url_func import_key;\n\tgnutls_x509_crt_import_url_func import_crt;\n\tgnutls_pubkey_import_url_func import_pubkey;\n\tgnutls_get_raw_issuer_func get_issuer;\n\tvoid *future1; /* replace in a future extension */\n\tvoid *future2; /* replace in a future extension */\n} gnutls_custom_url_st;\n\nint gnutls_register_custom_url(const gnutls_custom_url_st *st);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_URLS_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/x509-ext.h",
    "content": "/*\n * Copyright (C) 2014 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* Prototypes for direct handling of extension data */\n\n#ifndef GNUTLS_X509_EXT_H\n#define GNUTLS_X509_EXT_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\ntypedef struct gnutls_subject_alt_names_st *gnutls_subject_alt_names_t;\n\nint gnutls_subject_alt_names_init(gnutls_subject_alt_names_t *);\nvoid gnutls_subject_alt_names_deinit(gnutls_subject_alt_names_t sans);\nint gnutls_subject_alt_names_get(gnutls_subject_alt_names_t sans, unsigned int seq,\n\t\t\t\t unsigned int *san_type, gnutls_datum_t * san,\n\t\t\t\t gnutls_datum_t * othername_oid);\nint gnutls_subject_alt_names_set(gnutls_subject_alt_names_t sans,\n\t\t\t\t unsigned int san_type,\n\t\t\t\t const gnutls_datum_t * san,\n\t\t\t\t const char* othername_oid);\n\n\nint gnutls_x509_ext_import_subject_alt_names(const gnutls_datum_t * ext,\n\t\t\t\t\t gnutls_subject_alt_names_t,\n\t\t\t\t\t unsigned int flags);\nint gnutls_x509_ext_export_subject_alt_names(gnutls_subject_alt_names_t,\n\t\t\t\t\t  gnutls_datum_t * ext);\n\n/* They are exactly the same */\n#define gnutls_x509_ext_import_issuer_alt_name gnutls_x509_ext_import_subject_alt_name\n#define gnutls_x509_ext_export_issuer_alt_name gnutls_x509_ext_export_subject_alt_name\n\ntypedef struct gnutls_x509_crl_dist_points_st *gnutls_x509_crl_dist_points_t;\n\nint gnutls_x509_crl_dist_points_init(gnutls_x509_crl_dist_points_t *);\nvoid gnutls_x509_crl_dist_points_deinit(gnutls_x509_crl_dist_points_t);\nint gnutls_x509_crl_dist_points_get(gnutls_x509_crl_dist_points_t, unsigned int seq,\n\t\t\t\t  unsigned int *type,\n\t\t\t\t  gnutls_datum_t *dist, unsigned int *reason_flags);\nint gnutls_x509_crl_dist_points_set(gnutls_x509_crl_dist_points_t,\n\t\t\t\t gnutls_x509_subject_alt_name_t type,\n\t\t\t\t const gnutls_datum_t *dist, unsigned int reason_flags);\n\nint gnutls_x509_ext_import_crl_dist_points(const gnutls_datum_t * ext,\n\t\t\t\t\tgnutls_x509_crl_dist_points_t dp,\n\t\t\t\t\tunsigned int flags);\nint gnutls_x509_ext_export_crl_dist_points(gnutls_x509_crl_dist_points_t dp,\n\t\t\t\t\tgnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_name_constraints(const gnutls_datum_t * ext,\n\t\t\t\t\t gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t unsigned int flags);\nint gnutls_x509_ext_export_name_constraints(gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t gnutls_datum_t * ext);\n\ntypedef struct gnutls_x509_aia_st *gnutls_x509_aia_t;\n\nint gnutls_x509_aia_init(gnutls_x509_aia_t *);\nvoid gnutls_x509_aia_deinit(gnutls_x509_aia_t);\nint gnutls_x509_aia_get(gnutls_x509_aia_t aia, unsigned int seq,\n\t\t\tgnutls_datum_t *oid,\n\t\t\tunsigned *san_type,\n\t\t\tgnutls_datum_t *san);\nint gnutls_x509_aia_set(gnutls_x509_aia_t aia,\n\t\t\tconst char *oid,\n\t\t\tunsigned san_type,\n\t\t\tconst gnutls_datum_t * san);\n\nint gnutls_x509_ext_import_aia(const gnutls_datum_t * ext,\n\t\t\t\tgnutls_x509_aia_t,\n\t\t\t\tunsigned int flags);\nint gnutls_x509_ext_export_aia(gnutls_x509_aia_t aia,\n\t\t\t\t\t      gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_subject_key_id(const gnutls_datum_t * ext,\n\t\t\t\t       gnutls_datum_t * id);\nint gnutls_x509_ext_export_subject_key_id(const gnutls_datum_t * id,\n\t\t\t\t       gnutls_datum_t * ext);\n\ntypedef struct gnutls_x509_aki_st *gnutls_x509_aki_t;\n\nint gnutls_x509_ext_export_authority_key_id(gnutls_x509_aki_t,\n\t\t\t\t\t gnutls_datum_t * ext);\nint gnutls_x509_ext_import_authority_key_id(const gnutls_datum_t * ext,\n\t\t\t\t\t gnutls_x509_aki_t,\n\t\t\t\t\t unsigned int flags);\n\nint gnutls_x509_othername_to_virtual(const char *oid, \n\t\t\t\t     const gnutls_datum_t *othername,\n\t\t\t\t     unsigned int *virt_type,\n\t\t\t\t     gnutls_datum_t *virt);\n\nint gnutls_x509_aki_init(gnutls_x509_aki_t *);\nint gnutls_x509_aki_get_id(gnutls_x509_aki_t, gnutls_datum_t *id);\nint gnutls_x509_aki_get_cert_issuer(gnutls_x509_aki_t aki, unsigned int seq,\n\t\t\t\t unsigned int *san_type, gnutls_datum_t * san,\n\t\t\t\t gnutls_datum_t *othername_oid,\n\t\t\t\t gnutls_datum_t *serial);\nint gnutls_x509_aki_set_id(gnutls_x509_aki_t aki, const gnutls_datum_t *id);\nint gnutls_x509_aki_set_cert_issuer(gnutls_x509_aki_t aki, \n\t\t\t\t unsigned int san_type, \n\t\t\t\t const gnutls_datum_t * san,\n\t\t\t\t const char *othername_oid,\n\t\t\t\t const gnutls_datum_t * serial);\nvoid gnutls_x509_aki_deinit(gnutls_x509_aki_t);\n\nint gnutls_x509_ext_import_private_key_usage_period(const gnutls_datum_t * ext,\n\t\t\t\t\t\t time_t * activation,\n\t\t\t\t\t\t time_t * expiration);\nint gnutls_x509_ext_export_private_key_usage_period(time_t activation,\n\t\t\t\t\t\t time_t expiration,\n\t\t\t\t\t\t gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_basic_constraints(const gnutls_datum_t * ext,\n\t\t\t\t\t  unsigned int *ca, int *pathlen);\nint gnutls_x509_ext_export_basic_constraints(unsigned int ca, int pathlen,\n\t\t\t\t\t  gnutls_datum_t * ext);\n\ntypedef struct gnutls_x509_key_purposes_st *gnutls_x509_key_purposes_t;\n\nint gnutls_x509_key_purpose_init(gnutls_x509_key_purposes_t *p);\nvoid gnutls_x509_key_purpose_deinit(gnutls_x509_key_purposes_t p);\nint gnutls_x509_key_purpose_set(gnutls_x509_key_purposes_t p, const char *oid);\nint gnutls_x509_key_purpose_get(gnutls_x509_key_purposes_t p, unsigned idx, gnutls_datum_t *oid);\n\nint gnutls_x509_ext_import_key_purposes(const gnutls_datum_t * ext,\n\t\t\t\t     gnutls_x509_key_purposes_t,\n\t\t\t\t     unsigned int flags);\nint gnutls_x509_ext_export_key_purposes(gnutls_x509_key_purposes_t,\n\t\t\t\t     gnutls_datum_t * ext);\n\n\nint gnutls_x509_ext_import_key_usage(const gnutls_datum_t * ext,\n\t\t\t\t  unsigned int *key_usage);\nint gnutls_x509_ext_export_key_usage(unsigned int key_usage,\n\t\t\t\t  gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_inhibit_anypolicy(const gnutls_datum_t * ext,\n\t\t\t\t  unsigned int *skipcerts);\nint gnutls_x509_ext_export_inhibit_anypolicy(unsigned int skipcerts,\n\t\t\t\t  gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_proxy(const gnutls_datum_t * ext, int *pathlen,\n\t\t\t      char **policyLanguage, char **policy,\n\t\t\t      size_t * sizeof_policy);\nint gnutls_x509_ext_export_proxy(int pathLenConstraint, const char *policyLanguage,\n\t\t\t      const char *policy, size_t sizeof_policy,\n\t\t\t      gnutls_datum_t * ext);\n\ntypedef struct gnutls_x509_policies_st *gnutls_x509_policies_t;\n\nint gnutls_x509_policies_init(gnutls_x509_policies_t *);\nvoid gnutls_x509_policies_deinit(gnutls_x509_policies_t);\n\nint gnutls_x509_policies_get(gnutls_x509_policies_t policies, unsigned int seq,\n\t\t\t\t struct gnutls_x509_policy_st *policy);\nint gnutls_x509_policies_set(gnutls_x509_policies_t policies,\n\t\t\t\t const struct gnutls_x509_policy_st *policy);\n\nint gnutls_x509_ext_import_policies(const gnutls_datum_t * ext, gnutls_x509_policies_t\n\t\t\t\t policies,\n\t\t\t\t unsigned int flags);\nint gnutls_x509_ext_export_policies(gnutls_x509_policies_t policies,\n\t\t\t\t gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_tlsfeatures(const gnutls_datum_t * ext,\n\t\t\t\t\t\t\t\t\t   gnutls_x509_tlsfeatures_t,\n\t\t\t\t\t\t\t\t\t   unsigned int flags);\n\nint gnutls_x509_ext_export_tlsfeatures(gnutls_x509_tlsfeatures_t f,\n\t\t\t\t\t  gnutls_datum_t * ext);\n\nint gnutls_x509_tlsfeatures_add(gnutls_x509_tlsfeatures_t f, unsigned int feature);\n\ntypedef struct gnutls_x509_ct_scts_st *gnutls_x509_ct_scts_t;\n\nint gnutls_x509_ext_ct_scts_init(gnutls_x509_ct_scts_t * scts);\nvoid gnutls_x509_ext_ct_scts_deinit(gnutls_x509_ct_scts_t scts);\nint gnutls_x509_ext_ct_import_scts(const gnutls_datum_t * ext,\n\t\t\t\t   gnutls_x509_ct_scts_t scts, unsigned int flags);\nint gnutls_x509_ext_ct_export_scts(const gnutls_x509_ct_scts_t scts, gnutls_datum_t * ext);\nint gnutls_x509_ct_sct_get_version(const gnutls_x509_ct_scts_t scts, unsigned idx,\n\t\t\t\t   unsigned int *version_out);\nint gnutls_x509_ct_sct_get(const gnutls_x509_ct_scts_t scts,\n\t\t\t   unsigned idx,\n\t\t\t   time_t *timestamp,\n\t\t\t   gnutls_datum_t *logid,\n\t\t\t   gnutls_sign_algorithm_t *sigalg,\n\t\t\t   gnutls_datum_t *signature);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_X509_EXT_H */\n"
  },
  {
    "path": "thirdparty/32/include/gnutls/x509.h",
    "content": "/*\n * Copyright (C) 2003-2016 Free Software Foundation, Inc.\n * Copyright (C) 2015-2016 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for the X.509\n * certificate and CRL handling functions.\n */\n\n#ifndef GNUTLS_X509_H\n#define GNUTLS_X509_H\n\n#include <gnutls/gnutls.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/* Some OIDs usually found in Distinguished names, or\n * in Subject Directory Attribute extensions.\n */\n#define GNUTLS_OID_X520_COUNTRY_NAME\t\t\"2.5.4.6\"\n#define GNUTLS_OID_X520_ORGANIZATION_NAME\t\"2.5.4.10\"\n#define GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME \"2.5.4.11\"\n#define GNUTLS_OID_X520_COMMON_NAME\t\t\"2.5.4.3\"\n#define GNUTLS_OID_X520_LOCALITY_NAME\t\t\"2.5.4.7\"\n#define GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME\t\"2.5.4.8\"\n\n#define GNUTLS_OID_X520_INITIALS\t\t\"2.5.4.43\"\n#define GNUTLS_OID_X520_GENERATION_QUALIFIER\t\"2.5.4.44\"\n#define GNUTLS_OID_X520_SURNAME\t\t\t\"2.5.4.4\"\n#define GNUTLS_OID_X520_GIVEN_NAME\t\t\"2.5.4.42\"\n#define GNUTLS_OID_X520_TITLE\t\t\t\"2.5.4.12\"\n#define GNUTLS_OID_X520_DN_QUALIFIER\t\t\"2.5.4.46\"\n#define GNUTLS_OID_X520_PSEUDONYM\t\t\"2.5.4.65\"\n#define GNUTLS_OID_X520_POSTALCODE              \"2.5.4.17\"\n#define GNUTLS_OID_X520_NAME                    \"2.5.4.41\"\n\n#define GNUTLS_OID_LDAP_DC\t\t\t\"0.9.2342.19200300.100.1.25\"\n#define GNUTLS_OID_LDAP_UID\t\t\t\"0.9.2342.19200300.100.1.1\"\n\n/* The following should not be included in DN.\n */\n#define GNUTLS_OID_PKCS9_EMAIL\t\t\t\"1.2.840.113549.1.9.1\"\n\n#define GNUTLS_OID_PKIX_DATE_OF_BIRTH\t\t\"1.3.6.1.5.5.7.9.1\"\n#define GNUTLS_OID_PKIX_PLACE_OF_BIRTH\t\t\"1.3.6.1.5.5.7.9.2\"\n#define GNUTLS_OID_PKIX_GENDER\t\t\t\"1.3.6.1.5.5.7.9.3\"\n#define GNUTLS_OID_PKIX_COUNTRY_OF_CITIZENSHIP\t\"1.3.6.1.5.5.7.9.4\"\n#define GNUTLS_OID_PKIX_COUNTRY_OF_RESIDENCE\t\"1.3.6.1.5.5.7.9.5\"\n\n/* Key purpose Object Identifiers.\n */\n#define GNUTLS_KP_TLS_WWW_SERVER\t\t\"1.3.6.1.5.5.7.3.1\"\n#define GNUTLS_KP_TLS_WWW_CLIENT                \"1.3.6.1.5.5.7.3.2\"\n#define GNUTLS_KP_CODE_SIGNING\t\t\t\"1.3.6.1.5.5.7.3.3\"\n#define GNUTLS_KP_MS_SMART_CARD_LOGON\t\t\"1.3.6.1.4.1.311.20.2.2\"\n#define GNUTLS_KP_EMAIL_PROTECTION\t\t\"1.3.6.1.5.5.7.3.4\"\n#define GNUTLS_KP_TIME_STAMPING\t\t\t\"1.3.6.1.5.5.7.3.8\"\n#define GNUTLS_KP_OCSP_SIGNING\t\t\t\"1.3.6.1.5.5.7.3.9\"\n#define GNUTLS_KP_IPSEC_IKE\t\t\t\"1.3.6.1.5.5.7.3.17\"\n#define GNUTLS_KP_ANY\t\t\t\t\"2.5.29.37.0\"\n\n#define GNUTLS_KP_FLAG_DISALLOW_ANY\t\t1\n\n#define GNUTLS_OID_AIA\t\t\t\t\"1.3.6.1.5.5.7.1.1\"\n#define GNUTLS_OID_AD_OCSP\t\t\t\"1.3.6.1.5.5.7.48.1\"\n#define GNUTLS_OID_AD_CAISSUERS\t\t\t\"1.3.6.1.5.5.7.48.2\"\n\n#define GNUTLS_FSAN_SET 0\n#define GNUTLS_FSAN_APPEND 1\n#define GNUTLS_FSAN_ENCODE_OCTET_STRING (1<<1)\n#define GNUTLS_FSAN_ENCODE_UTF8_STRING (1<<2)\n\n#define GNUTLS_X509EXT_OID_SUBJECT_KEY_ID \"2.5.29.14\"\n#define GNUTLS_X509EXT_OID_KEY_USAGE \"2.5.29.15\"\n#define GNUTLS_X509EXT_OID_PRIVATE_KEY_USAGE_PERIOD \"2.5.29.16\"\n#define GNUTLS_X509EXT_OID_SAN \"2.5.29.17\"\n#define GNUTLS_X509EXT_OID_IAN \"2.5.29.18\"\n#define GNUTLS_X509EXT_OID_BASIC_CONSTRAINTS \"2.5.29.19\"\n#define GNUTLS_X509EXT_OID_NAME_CONSTRAINTS \"2.5.29.30\"\n#define GNUTLS_X509EXT_OID_CRL_DIST_POINTS \"2.5.29.31\"\n#define GNUTLS_X509EXT_OID_CRT_POLICY \"2.5.29.32\"\n#define GNUTLS_X509EXT_OID_AUTHORITY_KEY_ID \"2.5.29.35\"\n#define GNUTLS_X509EXT_OID_EXTENDED_KEY_USAGE \"2.5.29.37\"\n#define GNUTLS_X509EXT_OID_INHIBIT_ANYPOLICY \"2.5.29.52\"\n#define GNUTLS_X509EXT_OID_AUTHORITY_INFO_ACCESS \"1.3.6.1.5.5.7.1.1\"\n#define GNUTLS_X509EXT_OID_PROXY_CRT_INFO \"1.3.6.1.5.5.7.1.14\"\n#define GNUTLS_X509EXT_OID_TLSFEATURES \"1.3.6.1.5.5.7.1.24\"\n#define GNUTLS_X509EXT_OID_CT_SCT_V1 \"1.3.6.1.4.1.11129.2.4.2\"\n\n#define GNUTLS_X509_OID_POLICY_ANY \"2.5.29.54\"\n\n/* Certificate handling functions.\n */\n\n/**\n * gnutls_certificate_import_flags:\n * @GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED: Fail if the\n *   certificates in the buffer are more than the space allocated for\n *   certificates. The error code will be %GNUTLS_E_SHORT_MEMORY_BUFFER.\n * @GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED: Fail if the certificates\n *   in the buffer are not ordered starting from subject to issuer.\n *   The error code will be %GNUTLS_E_CERTIFICATE_LIST_UNSORTED.\n * @GNUTLS_X509_CRT_LIST_SORT: Sort the certificate chain if unsorted.\n *\n * Enumeration of different certificate import flags.\n */\ntypedef enum gnutls_certificate_import_flags {\n\tGNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED = 1,\n\tGNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED = 1<<1,\n\tGNUTLS_X509_CRT_LIST_SORT = 1<<2\n} gnutls_certificate_import_flags;\n\nint gnutls_x509_crt_init(gnutls_x509_crt_t * cert);\nvoid gnutls_x509_crt_deinit(gnutls_x509_crt_t cert);\n\n/**\n * gnutls_certificate_import_flags:\n * @GNUTLS_X509_CRT_FLAG_IGNORE_SANITY: Ignore any sanity checks at the\n *   import of the certificate; i.e., ignore checks such as version/field\n *   matching and strict time field checks. Intended to be used for debugging.\n *\n * Enumeration of different certificate flags.\n */\ntypedef enum gnutls_x509_crt_flags {\n\tGNUTLS_X509_CRT_FLAG_IGNORE_SANITY = 1\n} gnutls_x509_crt_flags;\nvoid gnutls_x509_crt_set_flags(gnutls_x509_crt_t cert, unsigned flags);\n\nunsigned gnutls_x509_crt_equals(gnutls_x509_crt_t cert1, gnutls_x509_crt_t cert2);\nunsigned gnutls_x509_crt_equals2(gnutls_x509_crt_t cert1, const gnutls_datum_t * der);\n\nint gnutls_x509_crt_import(gnutls_x509_crt_t cert,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   gnutls_x509_crt_fmt_t format);\nint gnutls_x509_crt_list_import2(gnutls_x509_crt_t ** certs,\n\t\t\t\t unsigned int *size,\n\t\t\t\t const gnutls_datum_t * data,\n\t\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t\t unsigned int flags);\nint gnutls_x509_crt_list_import(gnutls_x509_crt_t * certs,\n\t\t\t\tunsigned int *cert_max,\n\t\t\t\tconst gnutls_datum_t * data,\n\t\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\t\tunsigned int flags);\n\nint gnutls_x509_crt_import_url(gnutls_x509_crt_t crt,\n\t\t\t\t      const char *url, unsigned int flags\n\t\t\t\t      /* GNUTLS_PKCS11_OBJ_FLAG_* */\n    );\n\nint\ngnutls_x509_crt_list_import_url(gnutls_x509_crt_t **certs,\n\t\t\t\tunsigned int *size,\n\t\t\t\tconst char *url,\n\t\t\t\tgnutls_pin_callback_t pin_fn,\n\t\t\t\tvoid *pin_fn_userdata,\n\t\t\t\tunsigned int flags);\n\nint gnutls_x509_crt_export(gnutls_x509_crt_t cert,\n\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t   void *output_data, size_t * output_data_size);\nint gnutls_x509_crt_export2(gnutls_x509_crt_t cert,\n\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t    gnutls_datum_t * out);\nint gnutls_x509_crt_get_private_key_usage_period(gnutls_x509_crt_t\n\t\t\t\t\t\t cert,\n\t\t\t\t\t\t time_t *\n\t\t\t\t\t\t activation,\n\t\t\t\t\t\t time_t *\n\t\t\t\t\t\t expiration, unsigned int\n\t\t\t\t\t\t *critical);\n\nint gnutls_x509_crt_get_issuer_dn(gnutls_x509_crt_t cert,\n\t\t\t\t  char *buf, size_t * buf_size);\nint gnutls_x509_crt_get_issuer_dn2(gnutls_x509_crt_t cert,\n\t\t\t\t   gnutls_datum_t * dn);\nint gnutls_x509_crt_get_issuer_dn3(gnutls_x509_crt_t cert,\n\t\t\t\t   gnutls_datum_t * dn, unsigned flags);\nint gnutls_x509_crt_get_issuer_dn_oid(gnutls_x509_crt_t cert,\n\t\t\t\t      unsigned indx, void *oid,\n\t\t\t\t      size_t * oid_size);\nint gnutls_x509_crt_get_issuer_dn_by_oid(gnutls_x509_crt_t cert,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t unsigned int raw_flag,\n\t\t\t\t\t void *buf, size_t * buf_size);\n\nint gnutls_x509_crt_get_dn(gnutls_x509_crt_t cert, char *buf,\n\t\t\t   size_t * buf_size);\nint gnutls_x509_crt_get_dn2(gnutls_x509_crt_t cert, gnutls_datum_t * dn);\nint gnutls_x509_crt_get_dn3(gnutls_x509_crt_t cert, gnutls_datum_t * dn, unsigned flags);\n\nint gnutls_x509_crt_get_dn_oid(gnutls_x509_crt_t cert, unsigned indx,\n\t\t\t       void *oid, size_t * oid_size);\nint gnutls_x509_crt_get_dn_by_oid(gnutls_x509_crt_t cert,\n\t\t\t\t  const char *oid, unsigned indx,\n\t\t\t\t  unsigned int raw_flag, void *buf,\n\t\t\t\t  size_t * buf_size);\nunsigned gnutls_x509_crt_check_hostname(gnutls_x509_crt_t cert,\n\t\t\t\t   const char *hostname);\nunsigned gnutls_x509_crt_check_hostname2(gnutls_x509_crt_t cert,\n\t\t\t\t\t const char *hostname, unsigned int flags);\nunsigned\ngnutls_x509_crt_check_email(gnutls_x509_crt_t cert,\n\t\t\t    const char *email, unsigned int flags);\n\nunsigned\ngnutls_x509_crt_check_ip(gnutls_x509_crt_t cert,\n\t\t\t const unsigned char *ip, unsigned int ip_size,\n\t\t\t unsigned int flags);\n\nint gnutls_x509_crt_get_signature_algorithm(gnutls_x509_crt_t cert);\nint gnutls_x509_crt_get_signature(gnutls_x509_crt_t cert,\n\t\t\t\t  char *sig, size_t * sizeof_sig);\nint gnutls_x509_crt_get_version(gnutls_x509_crt_t cert);\n\nint gnutls_x509_crt_get_pk_oid(gnutls_x509_crt_t cert, char *oid, size_t *oid_size);\nint gnutls_x509_crt_get_signature_oid(gnutls_x509_crt_t cert, char *oid, size_t *oid_size);\n\n/**\n * gnutls_keyid_flags_t:\n * @GNUTLS_KEYID_USE_SHA1: Use SHA1 as the key ID algorithm (default).\n * @GNUTLS_KEYID_USE_SHA256: Use SHA256 as the key ID algorithm.\n * @GNUTLS_KEYID_USE_SHA512: Use SHA512 as the key ID algorithm.\n * @GNUTLS_KEYID_USE_BEST_KNOWN: Use the best known algorithm to calculate key ID. Using that option will make your program behavior depend on the version of gnutls linked with. That option has a cap of 64-bytes key IDs.\n *\n * Enumeration of different flags for the key ID functions.\n \n */\ntypedef enum {\n\tGNUTLS_KEYID_USE_SHA1 = 0,\n\tGNUTLS_KEYID_USE_SHA256 = (1<<0),\n\tGNUTLS_KEYID_USE_SHA512 = (1<<1),\n\tGNUTLS_KEYID_USE_BEST_KNOWN = (1<<30)\n} gnutls_keyid_flags_t;\nint gnutls_x509_crt_get_key_id(gnutls_x509_crt_t crt,\n\t\t\t       unsigned int flags,\n\t\t\t       unsigned char *output_data,\n\t\t\t       size_t * output_data_size);\n\nint gnutls_x509_crt_set_private_key_usage_period(gnutls_x509_crt_t\n\t\t\t\t\t\t crt,\n\t\t\t\t\t\t time_t activation,\n\t\t\t\t\t\t time_t expiration);\nint gnutls_x509_crt_set_authority_key_id(gnutls_x509_crt_t cert,\n\t\t\t\t\t const void *id, size_t id_size);\nint gnutls_x509_crt_get_authority_key_id(gnutls_x509_crt_t cert,\n\t\t\t\t\t void *id,\n\t\t\t\t\t size_t * id_size,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_crt_get_authority_key_gn_serial(gnutls_x509_crt_t\n\t\t\t\t\t\tcert,\n\t\t\t\t\t\tunsigned int seq,\n\t\t\t\t\t\tvoid *alt,\n\t\t\t\t\t\tsize_t * alt_size,\n\t\t\t\t\t\tunsigned int\n\t\t\t\t\t\t*alt_type,\n\t\t\t\t\t\tvoid *serial,\n\t\t\t\t\t\tsize_t *\n\t\t\t\t\t\tserial_size, unsigned int\n\t\t\t\t\t\t*critical);\n\nint gnutls_x509_crt_get_subject_key_id(gnutls_x509_crt_t cert,\n\t\t\t\t       void *ret,\n\t\t\t\t       size_t * ret_size,\n\t\t\t\t       unsigned int *critical);\n\nint gnutls_x509_crt_get_subject_unique_id(gnutls_x509_crt_t crt,\n\t\t\t\t\t  char *buf, size_t * buf_size);\n\nint gnutls_x509_crt_get_issuer_unique_id(gnutls_x509_crt_t crt,\n\t\t\t\t\t char *buf, size_t * buf_size);\n\nvoid gnutls_x509_crt_set_pin_function(gnutls_x509_crt_t crt,\n\t\t\t\t      gnutls_pin_callback_t fn,\n\t\t\t\t      void *userdata);\n\n  /**\n   * gnutls_info_access_what_t:\n   * @GNUTLS_IA_ACCESSMETHOD_OID: Get accessMethod OID.\n   * @GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE: Get accessLocation name type.\n   * @GNUTLS_IA_URI: Get accessLocation URI value.\n   * @GNUTLS_IA_OCSP_URI: get accessLocation URI value for OCSP.\n   * @GNUTLS_IA_CAISSUERS_URI: get accessLocation URI value for caIssuers.\n   *\n   * Enumeration of types for the @what parameter of\n   * gnutls_x509_crt_get_authority_info_access().\n   */\ntypedef enum gnutls_info_access_what_t {\n\tGNUTLS_IA_ACCESSMETHOD_OID = 1,\n\tGNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE = 2,\n\t/* use 100-108 for the generalName types, populate as needed */\n\tGNUTLS_IA_URI = 106,\n\t/* quick-access variants that match both OID and name type. */\n\tGNUTLS_IA_UNKNOWN = 10000,\n\tGNUTLS_IA_OCSP_URI = 10006,\n\tGNUTLS_IA_CAISSUERS_URI = 10106\n} gnutls_info_access_what_t;\n\nint gnutls_x509_crt_get_authority_info_access(gnutls_x509_crt_t\n\t\t\t\t\t      crt,\n\t\t\t\t\t      unsigned int seq,\n\t\t\t\t\t      int what,\n\t\t\t\t\t      gnutls_datum_t *\n\t\t\t\t\t      data, unsigned int\n\t\t\t\t\t      *critical);\n\ntypedef struct gnutls_name_constraints_st *gnutls_x509_name_constraints_t;\n\nunsigned gnutls_x509_name_constraints_check(gnutls_x509_name_constraints_t nc,\n\t\t\t\t       gnutls_x509_subject_alt_name_t type,\n\t\t\t\t       const gnutls_datum_t * name);\nunsigned gnutls_x509_name_constraints_check_crt(gnutls_x509_name_constraints_t nc,\n\t\t\t\t       gnutls_x509_subject_alt_name_t type,\n\t\t\t\t       gnutls_x509_crt_t crt);\n\nint gnutls_x509_name_constraints_init(gnutls_x509_name_constraints_t *nc);\nvoid gnutls_x509_name_constraints_deinit(gnutls_x509_name_constraints_t nc);\n\n#define GNUTLS_EXT_FLAG_APPEND 1\n\n#define GNUTLS_NAME_CONSTRAINTS_FLAG_APPEND GNUTLS_EXT_FLAG_APPEND\nint gnutls_x509_crt_get_name_constraints(gnutls_x509_crt_t crt,\n\t\t\t\t\t gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t unsigned int flags,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_name_constraints_add_permitted(gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t       gnutls_x509_subject_alt_name_t type,\n\t\t\t\t\t       const gnutls_datum_t * name);\nint gnutls_x509_name_constraints_add_excluded(gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t      gnutls_x509_subject_alt_name_t type,\n\t\t\t\t\t      const gnutls_datum_t * name);\nint gnutls_x509_crt_set_name_constraints(gnutls_x509_crt_t crt, \n\t\t\t\t\t gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t unsigned int critical);\nint gnutls_x509_name_constraints_get_permitted(gnutls_x509_name_constraints_t nc,\n\t\t\t\t     unsigned idx,\n\t\t\t\t     unsigned *type, gnutls_datum_t * name);\nint gnutls_x509_name_constraints_get_excluded(gnutls_x509_name_constraints_t nc,\n\t\t\t\t     unsigned idx,\n\t\t\t\t     unsigned *type, gnutls_datum_t * name);\nint gnutls_x509_cidr_to_rfc5280(const char *cidr, gnutls_datum_t *cidr_rfc5280);\n\n\n#define GNUTLS_CRL_REASON_SUPERSEEDED GNUTLS_CRL_REASON_SUPERSEDED,\n  /**\n   * gnutls_x509_crl_reason_flags_t:\n   * @GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN: The privileges were withdrawn from the owner.\n   * @GNUTLS_CRL_REASON_CERTIFICATE_HOLD: The certificate is on hold.\n   * @GNUTLS_CRL_REASON_CESSATION_OF_OPERATION: The end-entity is no longer operating.\n   * @GNUTLS_CRL_REASON_SUPERSEDED: There is a newer certificate of the owner.\n   * @GNUTLS_CRL_REASON_AFFILIATION_CHANGED: The end-entity affiliation has changed.\n   * @GNUTLS_CRL_REASON_CA_COMPROMISE: The CA was compromised.\n   * @GNUTLS_CRL_REASON_KEY_COMPROMISE: The certificate's key was compromised.\n   * @GNUTLS_CRL_REASON_UNUSED: The key was never used.\n   * @GNUTLS_CRL_REASON_AA_COMPROMISE: AA compromised.\n   *\n   * Enumeration of types for the CRL revocation reasons. \n   */\ntypedef enum gnutls_x509_crl_reason_flags_t {\n\tGNUTLS_CRL_REASON_UNSPECIFIED = 0,\n\tGNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN = 1,\n\tGNUTLS_CRL_REASON_CERTIFICATE_HOLD = 2,\n\tGNUTLS_CRL_REASON_CESSATION_OF_OPERATION = 4,\n\tGNUTLS_CRL_REASON_SUPERSEDED = 8,\n\tGNUTLS_CRL_REASON_AFFILIATION_CHANGED = 16,\n\tGNUTLS_CRL_REASON_CA_COMPROMISE = 32,\n\tGNUTLS_CRL_REASON_KEY_COMPROMISE = 64,\n\tGNUTLS_CRL_REASON_UNUSED = 128,\n\tGNUTLS_CRL_REASON_AA_COMPROMISE = 32768\n} gnutls_x509_crl_reason_flags_t;\n\nint gnutls_x509_crt_get_crl_dist_points(gnutls_x509_crt_t cert,\n\t\t\t\t\tunsigned int seq,\n\t\t\t\t\tvoid *ret,\n\t\t\t\t\tsize_t * ret_size,\n\t\t\t\t\tunsigned int *reason_flags,\n\t\t\t\t\tunsigned int *critical);\nint gnutls_x509_crt_set_crl_dist_points2(gnutls_x509_crt_t crt,\n\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t type, const void *data,\n\t\t\t\t\t unsigned int data_size,\n\t\t\t\t\t unsigned int reason_flags);\nint gnutls_x509_crt_set_crl_dist_points(gnutls_x509_crt_t crt,\n\t\t\t\t\tgnutls_x509_subject_alt_name_t\n\t\t\t\t\ttype,\n\t\t\t\t\tconst void *data_string,\n\t\t\t\t\tunsigned int reason_flags);\nint gnutls_x509_crt_cpy_crl_dist_points(gnutls_x509_crt_t dst,\n\t\t\t\t\tgnutls_x509_crt_t src);\n\nint gnutls_x509_crl_sign(gnutls_x509_crl_t crl,\n\t\t\t gnutls_x509_crt_t issuer,\n\t\t\t gnutls_x509_privkey_t issuer_key);\n\nint gnutls_x509_crl_sign2(gnutls_x509_crl_t crl,\n\t\t\t  gnutls_x509_crt_t issuer,\n\t\t\t  gnutls_x509_privkey_t issuer_key,\n\t\t\t  gnutls_digest_algorithm_t dig,\n\t\t\t  unsigned int flags);\n\ntime_t gnutls_x509_crt_get_activation_time(gnutls_x509_crt_t cert);\n\n/* This macro is deprecated and defunc; do not use */\n#define GNUTLS_X509_NO_WELL_DEFINED_EXPIRATION ((time_t)4294197631)\n\ntime_t gnutls_x509_crt_get_expiration_time(gnutls_x509_crt_t cert);\nint gnutls_x509_crt_get_serial(gnutls_x509_crt_t cert,\n\t\t\t       void *result, size_t * result_size);\n\ntypedef struct gnutls_x509_spki_st *gnutls_x509_spki_t;\n\nint gnutls_x509_spki_init(gnutls_x509_spki_t *spki);\nvoid gnutls_x509_spki_deinit(gnutls_x509_spki_t spki);\n\nint gnutls_x509_spki_get_rsa_pss_params(gnutls_x509_spki_t spki,\n\t\t\tgnutls_digest_algorithm_t *dig, unsigned int *salt_size);\n\nvoid gnutls_x509_spki_set_rsa_pss_params(gnutls_x509_spki_t spki,\n\t\t\tgnutls_digest_algorithm_t dig, unsigned int salt_size);\n\nint gnutls_x509_crt_get_pk_algorithm(gnutls_x509_crt_t cert,\n\t\t\t\t     unsigned int *bits);\nint gnutls_x509_crt_set_spki(gnutls_x509_crt_t crt, const gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\nint gnutls_x509_crt_get_spki(gnutls_x509_crt_t cert, gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\n\nint gnutls_x509_crt_get_pk_rsa_raw(gnutls_x509_crt_t crt,\n\t\t\t\t   gnutls_datum_t * m, gnutls_datum_t * e);\nint gnutls_x509_crt_get_pk_dsa_raw(gnutls_x509_crt_t crt,\n\t\t\t\t   gnutls_datum_t * p,\n\t\t\t\t   gnutls_datum_t * q,\n\t\t\t\t   gnutls_datum_t * g, gnutls_datum_t * y);\nint gnutls_x509_crt_get_pk_ecc_raw(gnutls_x509_crt_t crt,\n\t\t\t\t   gnutls_ecc_curve_t * curve,\n\t\t\t\t   gnutls_datum_t * x,\n\t\t\t\t   gnutls_datum_t * y);\nint gnutls_x509_crt_get_pk_gost_raw(gnutls_x509_crt_t crt,\n\t\t\t\t    gnutls_ecc_curve_t * curve,\n\t\t\t\t    gnutls_digest_algorithm_t * digest,\n\t\t\t\t    gnutls_gost_paramset_t *paramset,\n\t\t\t\t    gnutls_datum_t * x, gnutls_datum_t * y);\n\nint gnutls_x509_crt_get_subject_alt_name(gnutls_x509_crt_t cert,\n\t\t\t\t\t unsigned int seq,\n\t\t\t\t\t void *san,\n\t\t\t\t\t size_t * san_size,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_crt_get_subject_alt_name2(gnutls_x509_crt_t cert,\n\t\t\t\t\t  unsigned int seq,\n\t\t\t\t\t  void *san,\n\t\t\t\t\t  size_t * san_size,\n\t\t\t\t\t  unsigned int *san_type,\n\t\t\t\t\t  unsigned int *critical);\n\nint gnutls_x509_crt_get_subject_alt_othername_oid(gnutls_x509_crt_t\n\t\t\t\t\t\t  cert,\n\t\t\t\t\t\t  unsigned int seq,\n\t\t\t\t\t\t  void *oid,\n\t\t\t\t\t\t  size_t * oid_size);\n\nint gnutls_x509_crt_get_issuer_alt_name(gnutls_x509_crt_t cert,\n\t\t\t\t\tunsigned int seq,\n\t\t\t\t\tvoid *ian,\n\t\t\t\t\tsize_t * ian_size,\n\t\t\t\t\tunsigned int *critical);\nint gnutls_x509_crt_get_issuer_alt_name2(gnutls_x509_crt_t cert,\n\t\t\t\t\t unsigned int seq,\n\t\t\t\t\t void *ian,\n\t\t\t\t\t size_t * ian_size,\n\t\t\t\t\t unsigned int *ian_type,\n\t\t\t\t\t unsigned int *critical);\n\nint gnutls_x509_crt_get_issuer_alt_othername_oid(gnutls_x509_crt_t\n\t\t\t\t\t\t cert,\n\t\t\t\t\t\t unsigned int seq,\n\t\t\t\t\t\t void *ret,\n\t\t\t\t\t\t size_t * ret_size);\n\nint gnutls_x509_crt_get_ca_status(gnutls_x509_crt_t cert,\n\t\t\t\t  unsigned int *critical);\nint gnutls_x509_crt_get_basic_constraints(gnutls_x509_crt_t cert,\n\t\t\t\t\t  unsigned int *critical,\n\t\t\t\t\t  unsigned int *ca, int *pathlen);\n\n/* The key_usage flags are defined in gnutls.h. They are the\n * GNUTLS_KEY_* definitions.\n */\nint gnutls_x509_crt_get_key_usage(gnutls_x509_crt_t cert,\n\t\t\t\t  unsigned int *key_usage,\n\t\t\t\t  unsigned int *critical);\nint gnutls_x509_crt_set_key_usage(gnutls_x509_crt_t crt,\n\t\t\t\t  unsigned int usage);\nint gnutls_x509_crt_set_authority_info_access(gnutls_x509_crt_t\n\t\t\t\t\t      crt, int what,\n\t\t\t\t\t      gnutls_datum_t * data);\n\nint gnutls_x509_crt_get_inhibit_anypolicy(gnutls_x509_crt_t cert,\n\t\t\t\t  unsigned int *skipcerts,\n\t\t\t\t  unsigned int *critical);\nint\ngnutls_x509_crt_set_inhibit_anypolicy(gnutls_x509_crt_t crt, unsigned int skipcerts);\n\nint gnutls_x509_crt_get_proxy(gnutls_x509_crt_t cert,\n\t\t\t      unsigned int *critical,\n\t\t\t      int *pathlen,\n\t\t\t      char **policyLanguage,\n\t\t\t      char **policy, size_t * sizeof_policy);\n\n\ntypedef struct gnutls_x509_tlsfeatures_st *gnutls_x509_tlsfeatures_t;\n\nint gnutls_x509_tlsfeatures_init(gnutls_x509_tlsfeatures_t *features);\nvoid gnutls_x509_tlsfeatures_deinit(gnutls_x509_tlsfeatures_t);\nint gnutls_x509_tlsfeatures_get(gnutls_x509_tlsfeatures_t f, unsigned idx, unsigned int *feature);\n\nint gnutls_x509_crt_set_tlsfeatures(gnutls_x509_crt_t crt,\n\t\t\t\t    gnutls_x509_tlsfeatures_t features);\n\nint gnutls_x509_crt_get_tlsfeatures(gnutls_x509_crt_t cert,\n\t\t\t\t    gnutls_x509_tlsfeatures_t features,\n\t\t\t\t    unsigned int flags,\n\t\t\t\t    unsigned int *critical);\n\nunsigned gnutls_x509_tlsfeatures_check_crt(gnutls_x509_tlsfeatures_t feat,\n\t\t\t\t           gnutls_x509_crt_t crt);\n\n\n#define GNUTLS_MAX_QUALIFIERS 8\n\n  /**\n   * gnutls_x509_qualifier_t:\n   * @GNUTLS_X509_QUALIFIER_UNKNOWN: Unknown qualifier.\n   * @GNUTLS_X509_QUALIFIER_URI: A URL\n   * @GNUTLS_X509_QUALIFIER_NOICE: A text notice.\n   *\n   * Enumeration of types for the X.509 qualifiers, of the certificate policy extension. \n   */\ntypedef enum gnutls_x509_qualifier_t {\n\tGNUTLS_X509_QUALIFIER_UNKNOWN = 0, GNUTLS_X509_QUALIFIER_URI,\n\tGNUTLS_X509_QUALIFIER_NOTICE\n} gnutls_x509_qualifier_t;\n\ntypedef struct gnutls_x509_policy_st {\n\tchar *oid;\n\tunsigned int qualifiers;\n\tstruct {\n\t\tgnutls_x509_qualifier_t type;\n\t\tchar *data;\n\t\tunsigned int size;\n\t} qualifier[GNUTLS_MAX_QUALIFIERS];\n} gnutls_x509_policy_st;\n\nvoid gnutls_x509_policy_release(struct gnutls_x509_policy_st\n\t\t\t\t*policy);\nint gnutls_x509_crt_get_policy(gnutls_x509_crt_t crt, unsigned indx, struct gnutls_x509_policy_st\n\t\t\t       *policy, unsigned int *critical);\nint gnutls_x509_crt_set_policy(gnutls_x509_crt_t crt, const struct gnutls_x509_policy_st\n\t\t\t       *policy, unsigned int critical);\n\nint gnutls_x509_dn_oid_known(const char *oid);\n\n#define GNUTLS_X509_DN_OID_RETURN_OID 1\nconst char *gnutls_x509_dn_oid_name(const char *oid, unsigned int flags);\n\n\t/* Read extensions by OID. */\nint gnutls_x509_crt_get_extension_oid(gnutls_x509_crt_t cert,\n\t\t\t\t      unsigned indx, void *oid,\n\t\t\t\t      size_t * oid_size);\nint gnutls_x509_crt_get_extension_by_oid(gnutls_x509_crt_t cert,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t void *buf,\n\t\t\t\t\t size_t * buf_size,\n\t\t\t\t\t unsigned int *critical);\n\nint gnutls_x509_crq_get_signature_algorithm(gnutls_x509_crq_t crq);\nint\ngnutls_x509_crq_get_extension_by_oid2(gnutls_x509_crq_t crq,\n\t\t\t\t     const char *oid, unsigned indx,\n\t\t\t\t     gnutls_datum_t *output,\n\t\t\t\t     unsigned int *critical);\n\n\t/* Read extensions by sequence number. */\nint gnutls_x509_crt_get_extension_info(gnutls_x509_crt_t cert,\n\t\t\t\t       unsigned indx, void *oid,\n\t\t\t\t       size_t * oid_size,\n\t\t\t\t       unsigned int *critical);\nint gnutls_x509_crt_get_extension_data(gnutls_x509_crt_t cert,\n\t\t\t\t       unsigned indx, void *data,\n\t\t\t\t       size_t * sizeof_data);\nint\ngnutls_x509_crt_get_extension_data2(gnutls_x509_crt_t cert,\n\t\t\t       unsigned indx, gnutls_datum_t * data);\n\n\nint gnutls_x509_crt_set_extension_by_oid(gnutls_x509_crt_t crt,\n\t\t\t\t\t const char *oid,\n\t\t\t\t\t const void *buf,\n\t\t\t\t\t size_t sizeof_buf,\n\t\t\t\t\t unsigned int critical);\n\n/* X.509 Certificate writing.\n */\nint gnutls_x509_crt_set_dn(gnutls_x509_crt_t crt, const char *dn,\n\t\t\t   const char **err);\n\nint gnutls_x509_crt_set_dn_by_oid(gnutls_x509_crt_t crt,\n\t\t\t\t  const char *oid,\n\t\t\t\t  unsigned int raw_flag,\n\t\t\t\t  const void *name,\n\t\t\t\t  unsigned int sizeof_name);\nint gnutls_x509_crt_set_issuer_dn_by_oid(gnutls_x509_crt_t crt,\n\t\t\t\t\t const char *oid,\n\t\t\t\t\t unsigned int raw_flag,\n\t\t\t\t\t const void *name,\n\t\t\t\t\t unsigned int sizeof_name);\nint gnutls_x509_crt_set_issuer_dn(gnutls_x509_crt_t crt,\n\t\t\t\t  const char *dn, const char **err);\n\nint gnutls_x509_crt_set_version(gnutls_x509_crt_t crt,\n\t\t\t\tunsigned int version);\nint gnutls_x509_crt_set_key(gnutls_x509_crt_t crt,\n\t\t\t    gnutls_x509_privkey_t key);\nint gnutls_x509_crt_set_ca_status(gnutls_x509_crt_t crt, unsigned int ca);\nint gnutls_x509_crt_set_basic_constraints(gnutls_x509_crt_t crt,\n\t\t\t\t\t  unsigned int ca,\n\t\t\t\t\t  int pathLenConstraint);\n\nint\ngnutls_x509_crt_set_subject_unique_id(gnutls_x509_crt_t cert, const void *id,\n\t\t\t   size_t id_size);\nint\ngnutls_x509_crt_set_issuer_unique_id(gnutls_x509_crt_t cert, const void *id,\n\t\t\t   size_t id_size);\n\nint gnutls_x509_crt_set_subject_alternative_name(gnutls_x509_crt_t\n\t\t\t\t\t\t crt,\n\t\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t\t type, const char\n\t\t\t\t\t\t *data_string);\nint gnutls_x509_crt_set_subject_alt_name(gnutls_x509_crt_t crt,\n\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t type, const void *data,\n\t\t\t\t\t unsigned int data_size,\n\t\t\t\t\t unsigned int flags);\n\nint\ngnutls_x509_crt_set_subject_alt_othername(gnutls_x509_crt_t crt,\n\t\t\t\t     const char *oid,\n\t\t\t\t     const void *data,\n\t\t\t\t     unsigned int data_size,\n\t\t\t\t     unsigned int flags);\n\nint gnutls_x509_crt_set_issuer_alt_name(gnutls_x509_crt_t crt,\n\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t type, const void *data,\n\t\t\t\t\t unsigned int data_size,\n\t\t\t\t\t unsigned int flags);\n\nint\ngnutls_x509_crt_set_issuer_alt_othername(gnutls_x509_crt_t crt,\n\t\t\t\t     const char *oid,\n\t\t\t\t     const void *data,\n\t\t\t\t     unsigned int data_size,\n\t\t\t\t     unsigned int flags);\n\nint gnutls_x509_crt_sign(gnutls_x509_crt_t crt,\n\t\t\t gnutls_x509_crt_t issuer,\n\t\t\t gnutls_x509_privkey_t issuer_key);\nint gnutls_x509_crt_sign2(gnutls_x509_crt_t crt,\n\t\t\t  gnutls_x509_crt_t issuer,\n\t\t\t  gnutls_x509_privkey_t issuer_key,\n\t\t\t  gnutls_digest_algorithm_t dig,\n\t\t\t  unsigned int flags);\nint gnutls_x509_crt_set_activation_time(gnutls_x509_crt_t cert,\n\t\t\t\t\ttime_t act_time);\nint gnutls_x509_crt_set_expiration_time(gnutls_x509_crt_t cert,\n\t\t\t\t\ttime_t exp_time);\nint gnutls_x509_crt_set_serial(gnutls_x509_crt_t cert,\n\t\t\t       const void *serial, size_t serial_size);\n\nint gnutls_x509_crt_set_subject_key_id(gnutls_x509_crt_t cert,\n\t\t\t\t       const void *id, size_t id_size);\n\nint gnutls_x509_crt_set_proxy_dn(gnutls_x509_crt_t crt,\n\t\t\t\t gnutls_x509_crt_t eecrt,\n\t\t\t\t unsigned int raw_flag,\n\t\t\t\t const void *name,\n\t\t\t\t unsigned int sizeof_name);\nint gnutls_x509_crt_set_proxy(gnutls_x509_crt_t crt,\n\t\t\t      int pathLenConstraint,\n\t\t\t      const char *policyLanguage,\n\t\t\t      const char *policy, size_t sizeof_policy);\n\nint gnutls_x509_crt_print(gnutls_x509_crt_t cert,\n\t\t\t  gnutls_certificate_print_formats_t\n\t\t\t  format, gnutls_datum_t * out);\nint gnutls_x509_crl_print(gnutls_x509_crl_t crl,\n\t\t\t  gnutls_certificate_print_formats_t\n\t\t\t  format, gnutls_datum_t * out);\n\n\t/* Access to internal Certificate fields.\n\t */\nint gnutls_x509_crt_get_raw_issuer_dn(gnutls_x509_crt_t cert,\n\t\t\t\t      gnutls_datum_t * start);\nint gnutls_x509_crt_get_raw_dn(gnutls_x509_crt_t cert,\n\t\t\t       gnutls_datum_t * start);\n\n/* RDN handling.\n */\nint gnutls_x509_rdn_get(const gnutls_datum_t * idn,\n\t\t\tchar *buf, size_t * sizeof_buf);\nint\ngnutls_x509_rdn_get2(const gnutls_datum_t * idn,\n                     gnutls_datum_t *str, unsigned flags);\n\nint gnutls_x509_rdn_get_oid(const gnutls_datum_t * idn,\n\t\t\t    unsigned indx, void *buf, size_t * sizeof_buf);\n\nint gnutls_x509_rdn_get_by_oid(const gnutls_datum_t * idn,\n\t\t\t       const char *oid, unsigned indx,\n\t\t\t       unsigned int raw_flag, void *buf,\n\t\t\t       size_t * sizeof_buf);\n\ntypedef struct gnutls_x509_dn_st *gnutls_x509_dn_t;\n\ntypedef struct gnutls_x509_ava_st {\n\tgnutls_datum_t oid;\n\tgnutls_datum_t value;\n\tunsigned long value_tag;\n} gnutls_x509_ava_st;\n\nint gnutls_x509_crt_get_subject(gnutls_x509_crt_t cert,\n\t\t\t\tgnutls_x509_dn_t * dn);\nint gnutls_x509_crt_get_issuer(gnutls_x509_crt_t cert,\n\t\t\t       gnutls_x509_dn_t * dn);\nint gnutls_x509_dn_get_rdn_ava(gnutls_x509_dn_t dn, int irdn,\n\t\t\t       int iava, gnutls_x509_ava_st * ava);\n\nint gnutls_x509_dn_get_str(gnutls_x509_dn_t dn, gnutls_datum_t *str);\n\n#define GNUTLS_X509_DN_FLAG_COMPAT 1\nint gnutls_x509_dn_get_str2(gnutls_x509_dn_t dn, gnutls_datum_t *str, unsigned flags);\n\nint\ngnutls_x509_dn_set_str(gnutls_x509_dn_t dn, const char *str, const char **err);\n\nint gnutls_x509_dn_init(gnutls_x509_dn_t * dn);\n\nint gnutls_x509_dn_import(gnutls_x509_dn_t dn,\n\t\t\t  const gnutls_datum_t * data);\n\nint gnutls_x509_dn_export(gnutls_x509_dn_t dn,\n\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t  void *output_data, size_t * output_data_size);\nint gnutls_x509_dn_export2(gnutls_x509_dn_t dn,\n\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t   gnutls_datum_t * out);\n\nvoid gnutls_x509_dn_deinit(gnutls_x509_dn_t dn);\n\n\n/* CRL handling functions.\n */\nint gnutls_x509_crl_init(gnutls_x509_crl_t * crl);\nvoid gnutls_x509_crl_deinit(gnutls_x509_crl_t crl);\n\nint gnutls_x509_crl_import(gnutls_x509_crl_t crl,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   gnutls_x509_crt_fmt_t format);\nint gnutls_x509_crl_export(gnutls_x509_crl_t crl,\n\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t   void *output_data, size_t * output_data_size);\nint gnutls_x509_crl_export2(gnutls_x509_crl_t crl,\n\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t    gnutls_datum_t * out);\n\nint\ngnutls_x509_crl_get_raw_issuer_dn(gnutls_x509_crl_t crl,\n\t\t\t\t  gnutls_datum_t * dn);\n\nint gnutls_x509_crl_get_issuer_dn(gnutls_x509_crl_t crl,\n\t\t\t\t  char *buf, size_t * sizeof_buf);\nint gnutls_x509_crl_get_issuer_dn2(gnutls_x509_crl_t crl,\n\t\t\t\t   gnutls_datum_t * dn);\nint gnutls_x509_crl_get_issuer_dn3(gnutls_x509_crl_t crl,\n\t\t\t\t   gnutls_datum_t * dn, unsigned flags);\n\nint gnutls_x509_crl_get_issuer_dn_by_oid(gnutls_x509_crl_t crl,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t unsigned int raw_flag,\n\t\t\t\t\t void *buf, size_t * sizeof_buf);\nint gnutls_x509_crl_get_dn_oid(gnutls_x509_crl_t crl, unsigned indx,\n\t\t\t       void *oid, size_t * sizeof_oid);\n\nint gnutls_x509_crl_get_signature_algorithm(gnutls_x509_crl_t crl);\nint gnutls_x509_crl_get_signature(gnutls_x509_crl_t crl,\n\t\t\t\t  char *sig, size_t * sizeof_sig);\nint gnutls_x509_crl_get_version(gnutls_x509_crl_t crl);\n\nint gnutls_x509_crl_get_signature_oid(gnutls_x509_crl_t crl, char *oid, size_t *oid_size);\n\ntime_t gnutls_x509_crl_get_this_update(gnutls_x509_crl_t crl);\ntime_t gnutls_x509_crl_get_next_update(gnutls_x509_crl_t crl);\n\nint gnutls_x509_crl_get_crt_count(gnutls_x509_crl_t crl);\nint gnutls_x509_crl_get_crt_serial(gnutls_x509_crl_t crl, unsigned indx,\n\t\t\t\t   unsigned char *serial,\n\t\t\t\t   size_t * serial_size, time_t * t);\n\ntypedef struct gnutls_x509_crl_iter * gnutls_x509_crl_iter_t;\n\nint gnutls_x509_crl_iter_crt_serial(gnutls_x509_crl_t crl,\n\t\t\t\t    gnutls_x509_crl_iter_t *,\n\t\t\t\t    unsigned char *serial,\n\t\t\t\t    size_t * serial_size, time_t * t);\n\nvoid gnutls_x509_crl_iter_deinit(gnutls_x509_crl_iter_t);\n\n#define gnutls_x509_crl_get_certificate_count gnutls_x509_crl_get_crt_count\n#define gnutls_x509_crl_get_certificate gnutls_x509_crl_get_crt_serial\n\nunsigned gnutls_x509_crl_check_issuer(gnutls_x509_crl_t crl,\n\t\t\t\t gnutls_x509_crt_t issuer);\n\nint gnutls_x509_crl_list_import2(gnutls_x509_crl_t ** crls,\n\t\t\t\t unsigned int *size,\n\t\t\t\t const gnutls_datum_t * data,\n\t\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t\t unsigned int flags);\n\nint gnutls_x509_crl_list_import(gnutls_x509_crl_t * crls,\n\t\t\t\tunsigned int *crl_max,\n\t\t\t\tconst gnutls_datum_t * data,\n\t\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\t\tunsigned int flags);\n/* CRL writing.\n */\nint gnutls_x509_crl_set_version(gnutls_x509_crl_t crl,\n\t\t\t\tunsigned int version);\nint gnutls_x509_crl_set_this_update(gnutls_x509_crl_t crl,\n\t\t\t\t    time_t act_time);\nint gnutls_x509_crl_set_next_update(gnutls_x509_crl_t crl,\n\t\t\t\t    time_t exp_time);\nint gnutls_x509_crl_set_crt_serial(gnutls_x509_crl_t crl,\n\t\t\t\t   const void *serial,\n\t\t\t\t   size_t serial_size,\n\t\t\t\t   time_t revocation_time);\nint gnutls_x509_crl_set_crt(gnutls_x509_crl_t crl,\n\t\t\t    gnutls_x509_crt_t crt, time_t revocation_time);\n\nint gnutls_x509_crl_get_authority_key_id(gnutls_x509_crl_t crl,\n\t\t\t\t\t void *id,\n\t\t\t\t\t size_t * id_size,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_crl_get_authority_key_gn_serial(gnutls_x509_crl_t\n\t\t\t\t\t\tcrl,\n\t\t\t\t\t\tunsigned int seq,\n\t\t\t\t\t\tvoid *alt,\n\t\t\t\t\t\tsize_t * alt_size,\n\t\t\t\t\t\tunsigned int\n\t\t\t\t\t\t*alt_type,\n\t\t\t\t\t\tvoid *serial,\n\t\t\t\t\t\tsize_t *\n\t\t\t\t\t\tserial_size, unsigned int\n\t\t\t\t\t\t*critical);\n\nint gnutls_x509_crl_get_number(gnutls_x509_crl_t crl, void *ret,\n\t\t\t       size_t * ret_size, unsigned int *critical);\n\nint gnutls_x509_crl_get_extension_oid(gnutls_x509_crl_t crl,\n\t\t\t\t      unsigned indx, void *oid,\n\t\t\t\t      size_t * sizeof_oid);\n\nint gnutls_x509_crl_get_extension_info(gnutls_x509_crl_t crl,\n\t\t\t\t       unsigned indx, void *oid,\n\t\t\t\t       size_t * sizeof_oid,\n\t\t\t\t       unsigned int *critical);\n\nint gnutls_x509_crl_get_extension_data(gnutls_x509_crl_t crl,\n\t\t\t\t       unsigned indx, void *data,\n\t\t\t\t       size_t * sizeof_data);\nint\ngnutls_x509_crl_get_extension_data2(gnutls_x509_crl_t crl,\n\t\t\t       unsigned indx, gnutls_datum_t * data);\n\nint gnutls_x509_crl_set_authority_key_id(gnutls_x509_crl_t crl,\n\t\t\t\t\t const void *id, size_t id_size);\n\nint gnutls_x509_crl_set_number(gnutls_x509_crl_t crl,\n\t\t\t       const void *nr, size_t nr_size);\n\n\n/* X.509 Certificate verification functions.\n */\n\n/**\n * gnutls_certificate_verify_flags:\n * @GNUTLS_VERIFY_DISABLE_CA_SIGN: If set a signer does not have to be\n *   a certificate authority. This flag should normally be disabled,\n *   unless you know what this means.\n * @GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS: If set a signer in the trusted\n *   list is never checked for expiration or activation.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT: Do not allow trusted CA\n *   certificates that have version 1.  This option is to be used\n *   to deprecate all certificates of version 1.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_SAME: If a certificate is not signed by\n *   anyone trusted but exists in the trusted CA list do not treat it\n *   as trusted.\n * @GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN: A certificate chain is tolerated\n *   if unsorted (the case with many TLS servers out there). This is the\n *   default since GnuTLS 3.1.4.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN: Do not tolerate an unsorted\n *   certificate chain.\n * @GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT: Allow CA certificates that\n *   have version 1 (both root and intermediate). This might be\n *   dangerous since those haven't the basicConstraints\n *   extension. \n * @GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2: Allow certificates to be signed\n *   using the broken MD2 algorithm.\n * @GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5: Allow certificates to be signed\n *   using the broken MD5 algorithm.\n * @GNUTLS_VERIFY_ALLOW_SIGN_WITH_SHA1: Allow certificates to be signed\n *   using the broken SHA1 hash algorithm.\n * @GNUTLS_VERIFY_ALLOW_BROKEN: Allow certificates to be signed\n *   using any broken algorithm.\n * @GNUTLS_VERIFY_DISABLE_TIME_CHECKS: Disable checking of activation\n *   and expiration validity periods of certificate chains. Don't set\n *   this unless you understand the security implications.\n * @GNUTLS_VERIFY_DISABLE_CRL_CHECKS: Disable checking for validity\n *   using certificate revocation lists or the available OCSP data.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_WILDCARDS: When including a hostname\n *   check in the verification, do not consider any wildcards.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_IP_MATCHES: When verifying a hostname\n *   prevent textual IP addresses from matching IP addresses in the\n *   certificate. Treat the input only as a DNS name.\n * @GNUTLS_VERIFY_USE_TLS1_RSA: This indicates that a (raw) RSA signature is provided\n *   as in the TLS 1.0 protocol. Not all functions accept this flag.\n * @GNUTLS_VERIFY_IGNORE_UNKNOWN_CRIT_EXTENSIONS: This signals the verification\n *   process, not to fail on unknown critical extensions.\n * @GNUTLS_VERIFY_RSA_PSS_FIXED_SALT_LENGTH: Disallow RSA-PSS signatures made\n *   with mismatching salt length with digest length, as mandated in RFC 8446\n *   4.2.3.\n *\n * Enumeration of different certificate verify flags. Additional\n * verification profiles can be set using GNUTLS_PROFILE_TO_VFLAGS()\n * and %gnutls_certificate_verification_profiles_t.\n */\ntypedef enum gnutls_certificate_verify_flags {\n\tGNUTLS_VERIFY_DISABLE_CA_SIGN = 1 << 0,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_IP_MATCHES = 1<<1,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_SAME = 1 << 2,\n\tGNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT = 1 << 3,\n\tGNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2 = 1 << 4,\n\tGNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5 = 1 << 5,\n\tGNUTLS_VERIFY_DISABLE_TIME_CHECKS = 1 << 6,\n\tGNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS = 1 << 7,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT = 1 << 8,\n\tGNUTLS_VERIFY_DISABLE_CRL_CHECKS = 1 << 9,\n\tGNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN = 1 << 10,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN = 1 << 11,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_WILDCARDS = 1 << 12,\n\tGNUTLS_VERIFY_USE_TLS1_RSA = 1 << 13,\n\tGNUTLS_VERIFY_IGNORE_UNKNOWN_CRIT_EXTENSIONS = 1 << 14,\n\tGNUTLS_VERIFY_ALLOW_SIGN_WITH_SHA1 = 1 << 15,\n\tGNUTLS_VERIFY_RSA_PSS_FIXED_SALT_LENGTH = 1 << 16\n\t/* cannot exceed 2^24 due to GNUTLS_PROFILE_TO_VFLAGS() */\n} gnutls_certificate_verify_flags;\n\n#define GNUTLS_VERIFY_ALLOW_BROKEN (GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2|GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5)\n\n/**\n * gnutls_certificate_verification_profiles_t:\n * @GNUTLS_PROFILE_UNKNOWN: An invalid/unknown profile.\n * @GNUTLS_PROFILE_VERY_WEAK: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_VERY_WEAK (64 bits)\n * @GNUTLS_PROFILE_LOW: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_LOW (80 bits)\n * @GNUTLS_PROFILE_LEGACY: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_LEGACY (96 bits)\n * @GNUTLS_PROFILE_MEDIUM: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_MEDIUM (112 bits)\n * @GNUTLS_PROFILE_HIGH: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_HIGH (128 bits)\n * @GNUTLS_PROFILE_ULTRA: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_ULTRA (192 bits)\n * @GNUTLS_PROFILE_FUTURE: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_FUTURE (256 bits)\n * @GNUTLS_PROFILE_SUITEB128: A verification profile that\n *  applies the SUITEB128 rules\n * @GNUTLS_PROFILE_SUITEB192: A verification profile that\n *  applies the SUITEB192 rules\n *\n * Enumeration of different certificate verification profiles.\n */\ntypedef enum gnutls_certificate_verification_profiles_t {\n\tGNUTLS_PROFILE_UNKNOWN = 0,\n\tGNUTLS_PROFILE_VERY_WEAK = 1,\n\tGNUTLS_PROFILE_LOW = 2,\n\tGNUTLS_PROFILE_LEGACY = 4,\n\tGNUTLS_PROFILE_MEDIUM = 5,\n\tGNUTLS_PROFILE_HIGH = 6,\n\tGNUTLS_PROFILE_ULTRA = 7,\n\tGNUTLS_PROFILE_FUTURE = 8,\n\t\n\tGNUTLS_PROFILE_SUITEB128=32,\n\tGNUTLS_PROFILE_SUITEB192=33\n\t/*GNUTLS_PROFILE_MAX=255*/\n} gnutls_certificate_verification_profiles_t;\n\n#define GNUTLS_PROFILE_TO_VFLAGS(x) \\\n\t(((unsigned)x)<<24)\n\n#define GNUTLS_VFLAGS_PROFILE_MASK (0xff000000)\n\n#define GNUTLS_VFLAGS_TO_PROFILE(x) \\\n\t((((unsigned)x)>>24)&0xff)\n\nconst char *\n\tgnutls_certificate_verification_profile_get_name(gnutls_certificate_verification_profiles_t id) __GNUTLS_CONST__;\ngnutls_certificate_verification_profiles_t gnutls_certificate_verification_profile_get_id(const char *name) __GNUTLS_CONST__;\n\nunsigned gnutls_x509_crt_check_issuer(gnutls_x509_crt_t cert,\n\t\t\t\t gnutls_x509_crt_t issuer);\n\nint gnutls_x509_crt_list_verify(const gnutls_x509_crt_t *\n\t\t\t\tcert_list, unsigned cert_list_length,\n\t\t\t\tconst gnutls_x509_crt_t * CA_list,\n\t\t\t\tunsigned CA_list_length,\n\t\t\t\tconst gnutls_x509_crl_t * CRL_list,\n\t\t\t\tunsigned CRL_list_length,\n\t\t\t\tunsigned int flags, unsigned int *verify);\n\nint gnutls_x509_crt_verify(gnutls_x509_crt_t cert,\n\t\t\t   const gnutls_x509_crt_t * CA_list,\n\t\t\t   unsigned CA_list_length, unsigned int flags,\n\t\t\t   unsigned int *verify);\nint gnutls_x509_crl_verify(gnutls_x509_crl_t crl,\n\t\t\t   const gnutls_x509_crt_t * CA_list,\n\t\t\t   unsigned CA_list_length, unsigned int flags,\n\t\t\t   unsigned int *verify);\n\nint\ngnutls_x509_crt_verify_data2(gnutls_x509_crt_t crt,\n\t\t\t   gnutls_sign_algorithm_t algo,\n\t\t\t   unsigned int flags,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   const gnutls_datum_t * signature);\n\nint gnutls_x509_crt_check_revocation(gnutls_x509_crt_t cert,\n\t\t\t\t     const gnutls_x509_crl_t *\n\t\t\t\t     crl_list, unsigned crl_list_length);\n\nint gnutls_x509_crt_get_fingerprint(gnutls_x509_crt_t cert,\n\t\t\t\t    gnutls_digest_algorithm_t algo,\n\t\t\t\t    void *buf, size_t * buf_size);\n\nint gnutls_x509_crt_get_key_purpose_oid(gnutls_x509_crt_t cert,\n\t\t\t\t\tunsigned indx, void *oid,\n\t\t\t\t\tsize_t * oid_size,\n\t\t\t\t\tunsigned int *critical);\nint gnutls_x509_crt_set_key_purpose_oid(gnutls_x509_crt_t cert,\n\t\t\t\t\tconst void *oid,\n\t\t\t\t\tunsigned int critical);\n\nunsigned gnutls_x509_crt_check_key_purpose(gnutls_x509_crt_t cert,\n\t\tconst char *purpose, unsigned flags);\n\n/* Private key handling.\n */\n\n/* Flags for the gnutls_x509_privkey_export_pkcs8() function.\n */\n\n#define GNUTLS_PKCS8_PLAIN GNUTLS_PKCS_PLAIN\n#define GNUTLS_PKCS8_USE_PKCS12_3DES GNUTLS_PKCS_PKCS12_3DES\n#define GNUTLS_PKCS8_USE_PKCS12_ARCFOUR GNUTLS_PKCS_PKCS12_ARCFOUR\n#define GNUTLS_PKCS8_USE_PKCS12_RC2_40 GNUTLS_PKCS_PKCS12_RC2_40\n\n/**\n * gnutls_pkcs_encrypt_flags_t:\n * @GNUTLS_PKCS_PLAIN: Unencrypted private key.\n * @GNUTLS_PKCS_NULL_PASSWORD: Some schemas distinguish between an empty and a NULL password.\n * @GNUTLS_PKCS_PKCS12_3DES: PKCS-12 3DES.\n * @GNUTLS_PKCS_PKCS12_ARCFOUR: PKCS-12 ARCFOUR.\n * @GNUTLS_PKCS_PKCS12_RC2_40: PKCS-12 RC2-40.\n * @GNUTLS_PKCS_PBES2_3DES: PBES2 3DES.\n * @GNUTLS_PKCS_PBES2_AES_128: PBES2 AES-128.\n * @GNUTLS_PKCS_PBES2_AES_192: PBES2 AES-192.\n * @GNUTLS_PKCS_PBES2_AES_256: PBES2 AES-256.\n * @GNUTLS_PKCS_PBES2_DES: PBES2 single DES.\n * @GNUTLS_PKCS_PBES1_DES_MD5: PBES1 with single DES; for compatibility with openssl only.\n * @GNUTLS_PKCS_PBES2_GOST_TC26Z: PBES2 GOST 28147-89 CFB with TC26-Z S-box.\n * @GNUTLS_PKCS_PBES2_GOST_CPA: PBES2 GOST 28147-89 CFB with CryptoPro-A S-box.\n * @GNUTLS_PKCS_PBES2_GOST_CPB: PBES2 GOST 28147-89 CFB with CryptoPro-B S-box.\n * @GNUTLS_PKCS_PBES2_GOST_CPC: PBES2 GOST 28147-89 CFB with CryptoPro-C S-box.\n * @GNUTLS_PKCS_PBES2_GOST_CPD: PBES2 GOST 28147-89 CFB with CryptoPro-D S-box.\n *\n * Enumeration of different PKCS encryption flags.\n */\ntypedef enum gnutls_pkcs_encrypt_flags_t {\n\tGNUTLS_PKCS_PLAIN = 1,\n\tGNUTLS_PKCS_PKCS12_3DES = 1<<1,\n\tGNUTLS_PKCS_PKCS12_ARCFOUR = 1<<2,\n\tGNUTLS_PKCS_PKCS12_RC2_40 = 1<<3,\n\tGNUTLS_PKCS_PBES2_3DES = 1<<4,\n\tGNUTLS_PKCS_PBES2_AES_128 = 1<<5,\n\tGNUTLS_PKCS_PBES2_AES_192 = 1<<6,\n\tGNUTLS_PKCS_PBES2_AES_256 = 1<<7,\n\tGNUTLS_PKCS_NULL_PASSWORD = 1<<8,\n\tGNUTLS_PKCS_PBES2_DES = 1<<9,\n\tGNUTLS_PKCS_PBES1_DES_MD5 = 1<<10,\n\tGNUTLS_PKCS_PBES2_GOST_TC26Z = 1<<11,\n\tGNUTLS_PKCS_PBES2_GOST_CPA = 1<<12,\n\tGNUTLS_PKCS_PBES2_GOST_CPB = 1<<13,\n\tGNUTLS_PKCS_PBES2_GOST_CPC = 1<<14,\n\tGNUTLS_PKCS_PBES2_GOST_CPD = 1<<15\n} gnutls_pkcs_encrypt_flags_t;\n\n#define GNUTLS_PKCS_CIPHER_MASK(x) ((x)&(~(GNUTLS_PKCS_NULL_PASSWORD)))\n\n#define GNUTLS_PKCS_USE_PKCS12_3DES GNUTLS_PKCS_PKCS12_3DES\n#define GNUTLS_PKCS_USE_PKCS12_ARCFOUR GNUTLS_PKCS_PKCS12_ARCFOUR\n#define GNUTLS_PKCS_USE_PKCS12_RC2_40 GNUTLS_PKCS_PKCS12_RC2_40\n#define GNUTLS_PKCS_USE_PBES2_3DES GNUTLS_PKCS_PBES2_3DES\n#define GNUTLS_PKCS_USE_PBES2_AES_128 GNUTLS_PKCS_PBES2_AES_128\n#define GNUTLS_PKCS_USE_PBES2_AES_192 GNUTLS_PKCS_PBES2_AES_192\n#define GNUTLS_PKCS_USE_PBES2_AES_256 GNUTLS_PKCS_PBES2_AES_256\n#define GNUTLS_PKCS_USE_PBES2_GOST_TC26Z GNUTLS_PKCS_PBES2_GOST_TC26Z\n#define GNUTLS_PKCS_USE_PBES2_GOST_CPA GNUTLS_PKCS_PBES2_GOST_CPA\n#define GNUTLS_PKCS_USE_PBES2_GOST_CPB GNUTLS_PKCS_PBES2_GOST_CPB\n#define GNUTLS_PKCS_USE_PBES2_GOST_CPC GNUTLS_PKCS_PBES2_GOST_CPC\n#define GNUTLS_PKCS_USE_PBES2_GOST_CPD GNUTLS_PKCS_PBES2_GOST_CPD\n\nconst char *gnutls_pkcs_schema_get_name(unsigned int schema);\nconst char *gnutls_pkcs_schema_get_oid(unsigned int schema);\n\nint gnutls_x509_privkey_init(gnutls_x509_privkey_t * key);\nvoid gnutls_x509_privkey_deinit(gnutls_x509_privkey_t key);\ngnutls_sec_param_t\ngnutls_x509_privkey_sec_param(gnutls_x509_privkey_t key);\n\nvoid gnutls_x509_privkey_set_pin_function(gnutls_x509_privkey_t key,\n\t\t\t\t      gnutls_pin_callback_t fn,\n\t\t\t\t      void *userdata);\n\nint gnutls_x509_privkey_cpy(gnutls_x509_privkey_t dst,\n\t\t\t    gnutls_x509_privkey_t src);\nint gnutls_x509_privkey_import(gnutls_x509_privkey_t key,\n\t\t\t       const gnutls_datum_t * data,\n\t\t\t       gnutls_x509_crt_fmt_t format);\nint gnutls_x509_privkey_import_pkcs8(gnutls_x509_privkey_t key,\n\t\t\t\t     const gnutls_datum_t * data,\n\t\t\t\t     gnutls_x509_crt_fmt_t format,\n\t\t\t\t     const char *password,\n\t\t\t\t     unsigned int flags);\nint gnutls_x509_privkey_import_openssl(gnutls_x509_privkey_t key,\n\t\t\t\t       const gnutls_datum_t * data,\n\t\t\t\t       const char *password);\n\nint\ngnutls_pkcs8_info(const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format,\n\t\t  unsigned int *schema, unsigned int *cipher,\n\t\t  void *salt, unsigned int *salt_size,\n\t\t  unsigned int *iter_count, char **oid);\n\nint gnutls_x509_privkey_import2(gnutls_x509_privkey_t key,\n\t\t\t\tconst gnutls_datum_t * data,\n\t\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\t\tconst char *password, unsigned int flags);\n\nint gnutls_x509_privkey_import_rsa_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       const gnutls_datum_t * m,\n\t\t\t\t       const gnutls_datum_t * e,\n\t\t\t\t       const gnutls_datum_t * d,\n\t\t\t\t       const gnutls_datum_t * p,\n\t\t\t\t       const gnutls_datum_t * q,\n\t\t\t\t       const gnutls_datum_t * u);\nint gnutls_x509_privkey_import_rsa_raw2(gnutls_x509_privkey_t key,\n\t\t\t\t\tconst gnutls_datum_t * m,\n\t\t\t\t\tconst gnutls_datum_t * e,\n\t\t\t\t\tconst gnutls_datum_t * d,\n\t\t\t\t\tconst gnutls_datum_t * p,\n\t\t\t\t\tconst gnutls_datum_t * q,\n\t\t\t\t\tconst gnutls_datum_t * u,\n\t\t\t\t\tconst gnutls_datum_t * e1,\n\t\t\t\t\tconst gnutls_datum_t * e2);\nint gnutls_x509_privkey_import_ecc_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t curve,\n\t\t\t\t       const gnutls_datum_t * x,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * k);\nint gnutls_x509_privkey_import_gost_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t curve,\n\t\t\t\t       gnutls_digest_algorithm_t digest,\n\t\t\t\t       gnutls_gost_paramset_t paramset,\n\t\t\t\t       const gnutls_datum_t * x,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * k);\n\nint gnutls_x509_privkey_fix(gnutls_x509_privkey_t key);\n\nint gnutls_x509_privkey_export_dsa_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_datum_t * p,\n\t\t\t\t       gnutls_datum_t * q,\n\t\t\t\t       gnutls_datum_t * g,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * x);\nint gnutls_x509_privkey_import_dsa_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       const gnutls_datum_t * p,\n\t\t\t\t       const gnutls_datum_t * q,\n\t\t\t\t       const gnutls_datum_t * g,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * x);\n\nint gnutls_x509_privkey_get_pk_algorithm(gnutls_x509_privkey_t key);\nint gnutls_x509_privkey_get_pk_algorithm2(gnutls_x509_privkey_t\n\t\t\t\t\t  key, unsigned int *bits);\nint gnutls_x509_privkey_get_spki(gnutls_x509_privkey_t key,\n\t\t\t\t gnutls_x509_spki_t spki,\n\t\t\t\t unsigned int flags);\nint\ngnutls_x509_privkey_set_spki(gnutls_x509_privkey_t key,\n\t\t\t     const gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\n\nint gnutls_x509_privkey_get_key_id(gnutls_x509_privkey_t key,\n\t\t\t\t   unsigned int flags,\n\t\t\t\t   unsigned char *output_data,\n\t\t\t\t   size_t * output_data_size);\n\nint gnutls_x509_privkey_generate(gnutls_x509_privkey_t key,\n\t\t\t\t gnutls_pk_algorithm_t algo,\n\t\t\t\t unsigned int bits, unsigned int flags);\n\nvoid gnutls_x509_privkey_set_flags(gnutls_x509_privkey_t key, unsigned int flags);\n\n/**\n * gnutls_keygen_types_t:\n * @GNUTLS_KEYGEN_SEED: Specifies the seed to be used in key generation.\n * @GNUTLS_KEYGEN_DIGEST: The size field specifies the hash algorithm to be used in key generation.\n * @GNUTLS_KEYGEN_SPKI: data points to a %gnutls_x509_spki_t structure; it is not used after the key generation call.\n *\n * Enumeration of different key generation data options.\n */\ntypedef enum {\n\tGNUTLS_KEYGEN_SEED = 1,\n\tGNUTLS_KEYGEN_DIGEST = 2,\n\tGNUTLS_KEYGEN_SPKI = 3\n} gnutls_keygen_types_t;\n\ntypedef struct {\n\tgnutls_keygen_types_t type;\n\tunsigned char *data;\n\tunsigned int size;\n} gnutls_keygen_data_st;\n\nint\ngnutls_x509_privkey_generate2(gnutls_x509_privkey_t key,\n\t\t\t      gnutls_pk_algorithm_t algo, unsigned int bits,\n\t\t\t      unsigned int flags, const gnutls_keygen_data_st *data, unsigned data_size);\n\nint gnutls_x509_privkey_verify_seed(gnutls_x509_privkey_t key, gnutls_digest_algorithm_t, const void *seed, size_t seed_size);\nint gnutls_x509_privkey_get_seed(gnutls_x509_privkey_t key, gnutls_digest_algorithm_t*, void *seed, size_t *seed_size);\n\nint gnutls_x509_privkey_verify_params(gnutls_x509_privkey_t key);\n\nint gnutls_x509_privkey_export(gnutls_x509_privkey_t key,\n\t\t\t       gnutls_x509_crt_fmt_t format,\n\t\t\t       void *output_data,\n\t\t\t       size_t * output_data_size);\nint gnutls_x509_privkey_export2(gnutls_x509_privkey_t key,\n\t\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\t\tgnutls_datum_t * out);\nint gnutls_x509_privkey_export_pkcs8(gnutls_x509_privkey_t key,\n\t\t\t\t     gnutls_x509_crt_fmt_t format,\n\t\t\t\t     const char *password,\n\t\t\t\t     unsigned int flags,\n\t\t\t\t     void *output_data,\n\t\t\t\t     size_t * output_data_size);\nint gnutls_x509_privkey_export2_pkcs8(gnutls_x509_privkey_t key,\n\t\t\t\t      gnutls_x509_crt_fmt_t format,\n\t\t\t\t      const char *password,\n\t\t\t\t      unsigned int flags,\n\t\t\t\t      gnutls_datum_t * out);\nint gnutls_x509_privkey_export_rsa_raw2(gnutls_x509_privkey_t key,\n\t\t\t\t\tgnutls_datum_t * m,\n\t\t\t\t\tgnutls_datum_t * e,\n\t\t\t\t\tgnutls_datum_t * d,\n\t\t\t\t\tgnutls_datum_t * p,\n\t\t\t\t\tgnutls_datum_t * q,\n\t\t\t\t\tgnutls_datum_t * u,\n\t\t\t\t\tgnutls_datum_t * e1,\n\t\t\t\t\tgnutls_datum_t * e2);\nint gnutls_x509_privkey_export_rsa_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_datum_t * m,\n\t\t\t\t       gnutls_datum_t * e,\n\t\t\t\t       gnutls_datum_t * d,\n\t\t\t\t       gnutls_datum_t * p,\n\t\t\t\t       gnutls_datum_t * q,\n\t\t\t\t       gnutls_datum_t * u);\nint gnutls_x509_privkey_export_ecc_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k);\nint gnutls_x509_privkey_export_gost_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_digest_algorithm_t * digest,\n\t\t\t\t       gnutls_gost_paramset_t * paramset,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k);\n\nint gnutls_x509_privkey_sign_data(gnutls_x509_privkey_t key,\n\t\t\t\t  gnutls_digest_algorithm_t digest,\n\t\t\t\t  unsigned int flags,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  void *signature,\n\t\t\t\t  size_t * signature_size);\n\n/* Certificate request stuff.\n */\nint gnutls_x509_crq_sign(gnutls_x509_crq_t crq,\n\t\t\t gnutls_x509_privkey_t key);\n\nint gnutls_x509_crq_sign2(gnutls_x509_crq_t crq,\n\t\t\t  gnutls_x509_privkey_t key,\n\t\t\t  gnutls_digest_algorithm_t dig,\n\t\t\t  unsigned int flags);\n\nint gnutls_x509_crq_print(gnutls_x509_crq_t crq,\n\t\t\t  gnutls_certificate_print_formats_t\n\t\t\t  format, gnutls_datum_t * out);\n\nint gnutls_x509_crq_verify(gnutls_x509_crq_t crq, unsigned int flags);\n\nint gnutls_x509_crq_init(gnutls_x509_crq_t * crq);\nvoid gnutls_x509_crq_deinit(gnutls_x509_crq_t crq);\nint gnutls_x509_crq_import(gnutls_x509_crq_t crq,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   gnutls_x509_crt_fmt_t format);\n\nint gnutls_x509_crq_get_private_key_usage_period(gnutls_x509_crq_t\n\t\t\t\t\t\t cert,\n\t\t\t\t\t\t time_t *\n\t\t\t\t\t\t activation,\n\t\t\t\t\t\t time_t *\n\t\t\t\t\t\t expiration, unsigned int\n\t\t\t\t\t\t *critical);\n\nint gnutls_x509_crq_get_dn(gnutls_x509_crq_t crq, char *buf,\n\t\t\t   size_t * sizeof_buf);\nint gnutls_x509_crq_get_dn2(gnutls_x509_crq_t crq, gnutls_datum_t * dn);\nint gnutls_x509_crq_get_dn3(gnutls_x509_crq_t crq, gnutls_datum_t * dn, unsigned flags);\nint gnutls_x509_crq_get_dn_oid(gnutls_x509_crq_t crq, unsigned indx,\n\t\t\t       void *oid, size_t * sizeof_oid);\nint gnutls_x509_crq_get_dn_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t  const char *oid, unsigned indx,\n\t\t\t\t  unsigned int raw_flag, void *buf,\n\t\t\t\t  size_t * sizeof_buf);\nint gnutls_x509_crq_set_dn(gnutls_x509_crq_t crq, const char *dn,\n\t\t\t   const char **err);\nint gnutls_x509_crq_set_dn_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t  const char *oid,\n\t\t\t\t  unsigned int raw_flag,\n\t\t\t\t  const void *data,\n\t\t\t\t  unsigned int sizeof_data);\nint gnutls_x509_crq_set_version(gnutls_x509_crq_t crq,\n\t\t\t\tunsigned int version);\nint gnutls_x509_crq_get_version(gnutls_x509_crq_t crq);\nint gnutls_x509_crq_set_key(gnutls_x509_crq_t crq,\n\t\t\t    gnutls_x509_privkey_t key);\n\nint\ngnutls_x509_crq_set_extension_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t     const char *oid, const void *buf,\n\t\t\t\t     size_t sizeof_buf,\n\t\t\t\t     unsigned int critical);\n\nint gnutls_x509_crq_set_challenge_password(gnutls_x509_crq_t crq,\n\t\t\t\t\t   const char *pass);\nint gnutls_x509_crq_get_challenge_password(gnutls_x509_crq_t crq,\n\t\t\t\t\t   char *pass,\n\t\t\t\t\t   size_t * sizeof_pass);\n\nint gnutls_x509_crq_set_attribute_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\t const char *oid,\n\t\t\t\t\t void *buf, size_t sizeof_buf);\nint gnutls_x509_crq_get_attribute_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t void *buf, size_t * sizeof_buf);\n\nint gnutls_x509_crq_export(gnutls_x509_crq_t crq,\n\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t   void *output_data, size_t * output_data_size);\nint gnutls_x509_crq_export2(gnutls_x509_crq_t crq,\n\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t    gnutls_datum_t * out);\n\nint gnutls_x509_crt_set_crq(gnutls_x509_crt_t crt, gnutls_x509_crq_t crq);\nint gnutls_x509_crt_set_crq_extensions(gnutls_x509_crt_t crt,\n\t\t\t\t       gnutls_x509_crq_t crq);\n\nint\ngnutls_x509_crt_set_crq_extension_by_oid(gnutls_x509_crt_t crt,\n\t\t\t\t         gnutls_x509_crq_t crq, const char *oid,\n\t\t\t\t         unsigned flags);\n\nint gnutls_x509_crq_set_private_key_usage_period(gnutls_x509_crq_t\n\t\t\t\t\t\t crq,\n\t\t\t\t\t\t time_t activation,\n\t\t\t\t\t\t time_t expiration);\nint gnutls_x509_crq_set_key_rsa_raw(gnutls_x509_crq_t crq,\n\t\t\t\t    const gnutls_datum_t * m,\n\t\t\t\t    const gnutls_datum_t * e);\nint gnutls_x509_crq_set_subject_alt_name(gnutls_x509_crq_t crq,\n\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t nt, const void *data,\n\t\t\t\t\t unsigned int data_size,\n\t\t\t\t\t unsigned int flags);\n\nint\ngnutls_x509_crq_set_subject_alt_othername(gnutls_x509_crq_t crq,\n\t\t\t\t     const char *oid,\n\t\t\t\t     const void *data,\n\t\t\t\t     unsigned int data_size,\n\t\t\t\t     unsigned int flags);\n\nint gnutls_x509_crq_set_key_usage(gnutls_x509_crq_t crq,\n\t\t\t\t  unsigned int usage);\nint gnutls_x509_crq_set_basic_constraints(gnutls_x509_crq_t crq,\n\t\t\t\t\t  unsigned int ca,\n\t\t\t\t\t  int pathLenConstraint);\nint gnutls_x509_crq_set_key_purpose_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\tconst void *oid,\n\t\t\t\t\tunsigned int critical);\nint gnutls_x509_crq_get_key_purpose_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\tunsigned indx, void *oid,\n\t\t\t\t\tsize_t * sizeof_oid,\n\t\t\t\t\tunsigned int *critical);\n\nint gnutls_x509_crq_get_extension_data(gnutls_x509_crq_t crq,\n\t\t\t\t       unsigned indx, void *data,\n\t\t\t\t       size_t * sizeof_data);\nint\ngnutls_x509_crq_get_extension_data2(gnutls_x509_crq_t crq,\n\t\t\t       unsigned indx,\n\t\t\t       gnutls_datum_t * data);\nint gnutls_x509_crq_get_extension_info(gnutls_x509_crq_t crq,\n\t\t\t\t       unsigned indx, void *oid,\n\t\t\t\t       size_t * sizeof_oid,\n\t\t\t\t       unsigned int *critical);\nint gnutls_x509_crq_get_attribute_data(gnutls_x509_crq_t crq,\n\t\t\t\t       unsigned indx, void *data,\n\t\t\t\t       size_t * sizeof_data);\nint gnutls_x509_crq_get_attribute_info(gnutls_x509_crq_t crq,\n\t\t\t\t       unsigned indx, void *oid,\n\t\t\t\t       size_t * sizeof_oid);\nint gnutls_x509_crq_get_pk_algorithm(gnutls_x509_crq_t crq,\n\t\t\t\t     unsigned int *bits);\nint gnutls_x509_crq_get_spki(gnutls_x509_crq_t crq, gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\n\nint gnutls_x509_crq_set_spki(gnutls_x509_crq_t crq, const gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\n\nint gnutls_x509_crq_get_signature_oid(gnutls_x509_crq_t crq, char *oid, size_t *oid_size);\nint gnutls_x509_crq_get_pk_oid(gnutls_x509_crq_t crq, char *oid, size_t *oid_size);\n\nint gnutls_x509_crq_get_key_id(gnutls_x509_crq_t crq,\n\t\t\t       unsigned int flags,\n\t\t\t       unsigned char *output_data,\n\t\t\t       size_t * output_data_size);\nint gnutls_x509_crq_get_key_rsa_raw(gnutls_x509_crq_t crq,\n\t\t\t\t    gnutls_datum_t * m,\n\t\t\t\t    gnutls_datum_t * e);\n\nint gnutls_x509_crq_get_key_usage(gnutls_x509_crq_t crq,\n\t\t\t\t  unsigned int *key_usage,\n\t\t\t\t  unsigned int *critical);\nint gnutls_x509_crq_get_basic_constraints(gnutls_x509_crq_t crq,\n\t\t\t\t\t  unsigned int *critical,\n\t\t\t\t\t  unsigned int *ca, int *pathlen);\nint gnutls_x509_crq_get_subject_alt_name(gnutls_x509_crq_t crq,\n\t\t\t\t\t unsigned int seq,\n\t\t\t\t\t void *ret,\n\t\t\t\t\t size_t * ret_size,\n\t\t\t\t\t unsigned int *ret_type,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_crq_get_subject_alt_othername_oid(gnutls_x509_crq_t\n\t\t\t\t\t\t  crq,\n\t\t\t\t\t\t  unsigned int seq,\n\t\t\t\t\t\t  void *ret,\n\t\t\t\t\t\t  size_t * ret_size);\n\nint gnutls_x509_crq_get_extension_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t void *buf,\n\t\t\t\t\t size_t * sizeof_buf,\n\t\t\t\t\t unsigned int *critical);\n\nint gnutls_x509_crq_get_tlsfeatures(gnutls_x509_crq_t crq,\n\t\t\t\t    gnutls_x509_tlsfeatures_t features,\n\t\t\t\t    unsigned flags,\n\t\t\t\t    unsigned int *critical);\nint gnutls_x509_crq_set_tlsfeatures(gnutls_x509_crq_t crq,\n\t\t\t\t    gnutls_x509_tlsfeatures_t features);\n\nint\ngnutls_x509_crt_get_extension_by_oid2(gnutls_x509_crt_t cert,\n\t\t\t\t     const char *oid, unsigned indx,\n\t\t\t\t     gnutls_datum_t *output,\n\t\t\t\t     unsigned int *critical);\n\ntypedef struct gnutls_x509_trust_list_st *gnutls_x509_trust_list_t;\ntypedef struct gnutls_x509_trust_list_iter *gnutls_x509_trust_list_iter_t;\n\nint\ngnutls_x509_trust_list_init(gnutls_x509_trust_list_t * list,\n\t\t\t    unsigned int size);\n\nvoid\ngnutls_x509_trust_list_deinit(gnutls_x509_trust_list_t list,\n\t\t\t      unsigned int all);\n\nint gnutls_x509_trust_list_get_issuer(gnutls_x509_trust_list_t\n\t\t\t\t      list, gnutls_x509_crt_t cert,\n\t\t\t\t      gnutls_x509_crt_t * issuer,\n\t\t\t\t      unsigned int flags);\n\nint gnutls_x509_trust_list_get_issuer_by_dn(gnutls_x509_trust_list_t list,\n\t\t\t\t      const gnutls_datum_t *dn,\n\t\t\t\t      gnutls_x509_crt_t *issuer,\n\t\t\t\t      unsigned int flags);\n\nint gnutls_x509_trust_list_get_issuer_by_subject_key_id(gnutls_x509_trust_list_t list,\n\t\t\t\t      const gnutls_datum_t *dn,\n\t\t\t\t      const gnutls_datum_t *spki,\n\t\t\t\t      gnutls_x509_crt_t *issuer,\n\t\t\t\t      unsigned int flags);\n/**\n * gnutls_trust_list_flags_t:\n * @GNUTLS_TL_VERIFY_CRL: If any CRLs are provided they will be verified for validity\n *   prior to be added. The CA certificates that will be used for verification are the\n *   ones already added in the trusted list.\n * @GNUTLS_TL_USE_IN_TLS: Internal flag used by GnuTLS. If provided the trust list\n *   structure will cache a copy of CA DNs to be used in the certificate request\n *   TLS message.\n * @GNUTLS_TL_NO_DUPLICATES: If this flag is specified, a function adding certificates\n *   will check and eliminate any duplicates.\n * @GNUTLS_TL_NO_DUPLICATE_KEY: If this flag is specified, a certificate sharing the\n *   same key as a previously added on will not be added.\n * @GNUTLS_TL_GET_COPY: The semantics of this flag are documented to the functions which\n *   are applicable. In general, on returned value, the function will provide a copy\n *   if this flag is provided, rather than a pointer to internal data.\n * @GNUTLS_TL_FAIL_ON_INVALID_CRL: If an CRL is added which cannot be validated return\n *   an error instead of ignoring (must be used with %GNUTLS_TL_VERIFY_CRL).\n *\n * Enumeration of different certificate trust list flags.\n */\ntypedef enum gnutls_trust_list_flags_t {\n\tGNUTLS_TL_VERIFY_CRL = 1,\n#define GNUTLS_TL_VERIFY_CRL 1\n\tGNUTLS_TL_USE_IN_TLS = (1<<1),\n#define GNUTLS_TL_USE_IN_TLS (1<<1)\n\tGNUTLS_TL_NO_DUPLICATES = (1<<2),\n#define GNUTLS_TL_NO_DUPLICATES (1<<2)\n\tGNUTLS_TL_NO_DUPLICATE_KEY = (1<<3),\n#define GNUTLS_TL_NO_DUPLICATE_KEY (1<<3)\n\tGNUTLS_TL_GET_COPY = (1<<4),\n#define GNUTLS_TL_GET_COPY (1<<4)\n\tGNUTLS_TL_FAIL_ON_INVALID_CRL = (1<<5)\n#define GNUTLS_TL_FAIL_ON_INVALID_CRL (1<<5)\n} gnutls_trust_list_flags_t;\n\nint\ngnutls_x509_trust_list_add_cas(gnutls_x509_trust_list_t list,\n\t\t\t       const gnutls_x509_crt_t * clist,\n\t\t\t       unsigned clist_size, unsigned int flags);\nint gnutls_x509_trust_list_remove_cas(gnutls_x509_trust_list_t\n\t\t\t\t      list,\n\t\t\t\t      const gnutls_x509_crt_t *\n\t\t\t\t      clist, unsigned clist_size);\n\nint gnutls_x509_trust_list_add_named_crt(gnutls_x509_trust_list_t\n\t\t\t\t\t list,\n\t\t\t\t\t gnutls_x509_crt_t cert,\n\t\t\t\t\t const void *name,\n\t\t\t\t\t size_t name_size,\n\t\t\t\t\t unsigned int flags);\n\nint\ngnutls_x509_trust_list_add_crls(gnutls_x509_trust_list_t list,\n\t\t\t\tconst gnutls_x509_crl_t *\n\t\t\t\tcrl_list, unsigned crl_size,\n\t\t\t\tunsigned int flags,\n\t\t\t\tunsigned int verification_flags);\n\n\nint\ngnutls_x509_trust_list_iter_get_ca(gnutls_x509_trust_list_t list,\n                                   gnutls_x509_trust_list_iter_t *iter,\n                                   gnutls_x509_crt_t *crt);\n\nvoid gnutls_x509_trust_list_iter_deinit(gnutls_x509_trust_list_iter_t iter);\n\ntypedef int gnutls_verify_output_function(gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer,\n\t\t\t\t\t\t\t\t\t\t\t\t /* The issuer if verification failed\n\t\t\t\t\t\t\t\t\t\t\t\t * because of him. might be null.\n\t\t\t\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t  gnutls_x509_crl_t crl,\t/* The CRL that caused verification failure \n\t\t\t\t\t\t\t\t\t * if any. Might be null.\n\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t  unsigned int\n\t\t\t\t\t  verification_output);\n\nvoid gnutls_session_set_verify_output_function(gnutls_session_t session,\n\t\tgnutls_verify_output_function * func);\n\nint gnutls_x509_trust_list_verify_named_crt\n    (gnutls_x509_trust_list_t list, gnutls_x509_crt_t cert,\n     const void *name, size_t name_size, unsigned int flags,\n     unsigned int *verify, gnutls_verify_output_function func);\n\nint\ngnutls_x509_trust_list_verify_crt2(gnutls_x509_trust_list_t list,\n\t\t\t\t  gnutls_x509_crt_t * cert_list,\n\t\t\t\t  unsigned int cert_list_size,\n\t\t\t\t  gnutls_typed_vdata_st * data,\n\t\t\t\t  unsigned int elements,\n\t\t\t\t  unsigned int flags,\n\t\t\t\t  unsigned int *voutput,\n\t\t\t\t  gnutls_verify_output_function func);\n\nint\ngnutls_x509_trust_list_verify_crt(gnutls_x509_trust_list_t list,\n\t\t\t\t  gnutls_x509_crt_t * cert_list,\n\t\t\t\t  unsigned int cert_list_size,\n\t\t\t\t  unsigned int flags,\n\t\t\t\t  unsigned int *verify,\n\t\t\t\t  gnutls_verify_output_function func);\n\n\t/* trust list convenience functions */\nint\ngnutls_x509_trust_list_add_trust_mem(gnutls_x509_trust_list_t\n\t\t\t\t     list,\n\t\t\t\t     const gnutls_datum_t * cas,\n\t\t\t\t     const gnutls_datum_t * crls,\n\t\t\t\t     gnutls_x509_crt_fmt_t type,\n\t\t\t\t     unsigned int tl_flags,\n\t\t\t\t     unsigned int tl_vflags);\n\nint\ngnutls_x509_trust_list_add_trust_file(gnutls_x509_trust_list_t\n\t\t\t\t      list, const char *ca_file,\n\t\t\t\t      const char *crl_file,\n\t\t\t\t      gnutls_x509_crt_fmt_t type,\n\t\t\t\t      unsigned int tl_flags,\n\t\t\t\t      unsigned int tl_vflags);\n\nint\ngnutls_x509_trust_list_add_trust_dir(gnutls_x509_trust_list_t list,\n\t\t\t\t      const char *ca_dir,\n\t\t\t\t      const char *crl_dir,\n\t\t\t\t      gnutls_x509_crt_fmt_t type,\n\t\t\t\t      unsigned int tl_flags,\n\t\t\t\t      unsigned int tl_vflags);\n\nint\ngnutls_x509_trust_list_remove_trust_file(gnutls_x509_trust_list_t\n\t\t\t\t\t list,\n\t\t\t\t\t const char *ca_file,\n\t\t\t\t\t gnutls_x509_crt_fmt_t type);\n\nint\ngnutls_x509_trust_list_remove_trust_mem(gnutls_x509_trust_list_t\n\t\t\t\t\tlist,\n\t\t\t\t\tconst gnutls_datum_t *\n\t\t\t\t\tcas, gnutls_x509_crt_fmt_t type);\n\nint\ngnutls_x509_trust_list_add_system_trust(gnutls_x509_trust_list_t\n\t\t\t\t\tlist,\n\t\t\t\t\tunsigned int tl_flags,\n\t\t\t\t\tunsigned int tl_vflags);\n\ntypedef int gnutls_x509_trust_list_getissuer_function(gnutls_x509_trust_list_t list,\n\t\t\t\t\t\t      const gnutls_x509_crt_t cert,\n\t\t\t\t\t\t      gnutls_x509_crt_t **issuers,\n\t\t\t\t\t\t      unsigned int *issuers_size);\n\nvoid gnutls_x509_trust_list_set_getissuer_function(gnutls_x509_trust_list_t tlist,\n\t\t\t\tgnutls_x509_trust_list_getissuer_function *func);\n\nvoid gnutls_x509_trust_list_set_ptr(gnutls_x509_trust_list_t tlist, void *ptr);\n\nvoid *gnutls_x509_trust_list_get_ptr(gnutls_x509_trust_list_t tlist);\n\nvoid gnutls_certificate_set_trust_list\n    (gnutls_certificate_credentials_t res,\n     gnutls_x509_trust_list_t tlist, unsigned flags);\nvoid gnutls_certificate_get_trust_list\n    (gnutls_certificate_credentials_t res,\n     gnutls_x509_trust_list_t *tlist);\n\ntypedef struct gnutls_x509_ext_st {\n\tchar *oid;\n\tunsigned int critical;\n\tgnutls_datum_t data;\n} gnutls_x509_ext_st;\n\nvoid gnutls_x509_ext_deinit(gnutls_x509_ext_st *ext);\n\nint\ngnutls_x509_ext_print(gnutls_x509_ext_st *exts, unsigned int exts_size,\n\t\t      gnutls_certificate_print_formats_t format,\n\t\t      gnutls_datum_t * out);\n\n#include <gnutls/pkcs7.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_X509_H */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/HTMLparser.h",
    "content": "/*\n * Summary: interface for an HTML 4.0 non-verifying parser\n * Description: this module implements an HTML 4.0 non-verifying parser\n *              with API compatible with the XML parser ones. It should\n *              be able to parse \"real world\" HTML, even if severely\n *              broken from a specification point of view.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __HTML_PARSER_H__\n#define __HTML_PARSER_H__\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n\n#ifdef LIBXML_HTML_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Most of the back-end structures from XML and HTML are shared.\n */\ntypedef xmlParserCtxt htmlParserCtxt;\ntypedef xmlParserCtxtPtr htmlParserCtxtPtr;\ntypedef xmlParserNodeInfo htmlParserNodeInfo;\ntypedef xmlSAXHandler htmlSAXHandler;\ntypedef xmlSAXHandlerPtr htmlSAXHandlerPtr;\ntypedef xmlParserInput htmlParserInput;\ntypedef xmlParserInputPtr htmlParserInputPtr;\ntypedef xmlDocPtr htmlDocPtr;\ntypedef xmlNodePtr htmlNodePtr;\n\n/*\n * Internal description of an HTML element, representing HTML 4.01\n * and XHTML 1.0 (which share the same structure).\n */\ntypedef struct _htmlElemDesc htmlElemDesc;\ntypedef htmlElemDesc *htmlElemDescPtr;\nstruct _htmlElemDesc {\n    const char *name;\t/* The tag name */\n    char startTag;      /* Whether the start tag can be implied */\n    char endTag;        /* Whether the end tag can be implied */\n    char saveEndTag;    /* Whether the end tag should be saved */\n    char empty;         /* Is this an empty element ? */\n    char depr;          /* Is this a deprecated element ? */\n    char dtd;           /* 1: only in Loose DTD, 2: only Frameset one */\n    char isinline;      /* is this a block 0 or inline 1 element */\n    const char *desc;   /* the description */\n\n/* NRK Jan.2003\n * New fields encapsulating HTML structure\n *\n * Bugs:\n *\tThis is a very limited representation.  It fails to tell us when\n *\tan element *requires* subelements (we only have whether they're\n *\tallowed or not), and it doesn't tell us where CDATA and PCDATA\n *\tare allowed.  Some element relationships are not fully represented:\n *\tthese are flagged with the word MODIFIER\n */\n    const char** subelts;\t\t/* allowed sub-elements of this element */\n    const char* defaultsubelt;\t/* subelement for suggested auto-repair\n\t\t\t\t\t   if necessary or NULL */\n    const char** attrs_opt;\t\t/* Optional Attributes */\n    const char** attrs_depr;\t\t/* Additional deprecated attributes */\n    const char** attrs_req;\t\t/* Required attributes */\n};\n\n/*\n * Internal description of an HTML entity.\n */\ntypedef struct _htmlEntityDesc htmlEntityDesc;\ntypedef htmlEntityDesc *htmlEntityDescPtr;\nstruct _htmlEntityDesc {\n    unsigned int value;\t/* the UNICODE value for the character */\n    const char *name;\t/* The entity name */\n    const char *desc;   /* the description */\n};\n\n/*\n * There is only few public functions.\n */\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\thtmlInitAutoClose\t(void);\nXMLPUBFUN const htmlElemDesc *\n\t\t\thtmlTagLookup\t(const xmlChar *tag);\nXMLPUBFUN const htmlEntityDesc *\n\t\t\thtmlEntityLookup(const xmlChar *name);\nXMLPUBFUN const htmlEntityDesc *\n\t\t\thtmlEntityValueLookup(unsigned int value);\n\nXMLPUBFUN int\n\t\t\thtmlIsAutoClosed(htmlDocPtr doc,\n\t\t\t\t\t htmlNodePtr elem);\nXMLPUBFUN int\n\t\t\thtmlAutoCloseTag(htmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t htmlNodePtr elem);\nXML_DEPRECATED\nXMLPUBFUN const htmlEntityDesc *\n\t\t\thtmlParseEntityRef(htmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar **str);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\thtmlParseCharRef(htmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\thtmlParseElement(htmlParserCtxtPtr ctxt);\n\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlNewParserCtxt(void);\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlNewSAXParserCtxt(const htmlSAXHandler *sax,\n\t\t\t\t\t     void *userData);\n\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlCreateMemoryParserCtxt(const char *buffer,\n\t\t\t\t\t\t   int size);\n\nXMLPUBFUN int\n\t\t\thtmlParseDocument(htmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN htmlDocPtr\n\t\t\thtmlSAXParseDoc\t(const xmlChar *cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t htmlSAXHandlerPtr sax,\n\t\t\t\t\t void *userData);\nXMLPUBFUN htmlDocPtr\n\t\t\thtmlParseDoc\t(const xmlChar *cur,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlCreateFileParserCtxt(const char *filename,\n\t                                         const char *encoding);\nXML_DEPRECATED\nXMLPUBFUN htmlDocPtr\n\t\t\thtmlSAXParseFile(const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t htmlSAXHandlerPtr sax,\n\t\t\t\t\t void *userData);\nXMLPUBFUN htmlDocPtr\n\t\t\thtmlParseFile\t(const char *filename,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN int\n\t\t\tUTF8ToHtml\t(unsigned char *out,\n\t\t\t\t\t int *outlen,\n\t\t\t\t\t const unsigned char *in,\n\t\t\t\t\t int *inlen);\nXMLPUBFUN int\n\t\t\thtmlEncodeEntities(unsigned char *out,\n\t\t\t\t\t int *outlen,\n\t\t\t\t\t const unsigned char *in,\n\t\t\t\t\t int *inlen, int quoteChar);\nXMLPUBFUN int\n\t\t\thtmlIsScriptAttribute(const xmlChar *name);\nXMLPUBFUN int\n\t\t\thtmlHandleOmittedElem(int val);\n\n#ifdef LIBXML_PUSH_ENABLED\n/**\n * Interfaces for the Push mode.\n */\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,\n\t\t\t\t\t\t void *user_data,\n\t\t\t\t\t\t const char *chunk,\n\t\t\t\t\t\t int size,\n\t\t\t\t\t\t const char *filename,\n\t\t\t\t\t\t xmlCharEncoding enc);\nXMLPUBFUN int\n\t\t\thtmlParseChunk\t\t(htmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const char *chunk,\n\t\t\t\t\t\t int size,\n\t\t\t\t\t\t int terminate);\n#endif /* LIBXML_PUSH_ENABLED */\n\nXMLPUBFUN void\n\t\t\thtmlFreeParserCtxt\t(htmlParserCtxtPtr ctxt);\n\n/*\n * New set of simpler/more flexible APIs\n */\n/**\n * xmlParserOption:\n *\n * This is the set of XML parser options that can be passed down\n * to the xmlReadDoc() and similar calls.\n */\ntypedef enum {\n    HTML_PARSE_RECOVER  = 1<<0, /* Relaxed parsing */\n    HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */\n    HTML_PARSE_NOERROR\t= 1<<5,\t/* suppress error reports */\n    HTML_PARSE_NOWARNING= 1<<6,\t/* suppress warning reports */\n    HTML_PARSE_PEDANTIC\t= 1<<7,\t/* pedantic error reporting */\n    HTML_PARSE_NOBLANKS\t= 1<<8,\t/* remove blank nodes */\n    HTML_PARSE_NONET\t= 1<<11,/* Forbid network access */\n    HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */\n    HTML_PARSE_COMPACT  = 1<<16,/* compact small text nodes */\n    HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */\n} htmlParserOption;\n\nXMLPUBFUN void\n\t\thtmlCtxtReset\t\t(htmlParserCtxtPtr ctxt);\nXMLPUBFUN int\n\t\thtmlCtxtUseOptions\t(htmlParserCtxtPtr ctxt,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadDoc\t\t(const xmlChar *cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadFile\t\t(const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadMemory\t\t(const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadFd\t\t(int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadIO\t\t(xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadDoc\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadFile\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadMemory\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadFd\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadIO\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\n/* NRK/Jan2003: further knowledge of HTML structure\n */\ntypedef enum {\n  HTML_NA = 0 ,\t\t/* something we don't check at all */\n  HTML_INVALID = 0x1 ,\n  HTML_DEPRECATED = 0x2 ,\n  HTML_VALID = 0x4 ,\n  HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */\n} htmlStatus ;\n\n/* Using htmlElemDesc rather than name here, to emphasise the fact\n   that otherwise there's a lookup overhead\n*/\nXMLPUBFUN htmlStatus htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ;\nXMLPUBFUN int htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ;\nXMLPUBFUN htmlStatus htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ;\nXMLPUBFUN htmlStatus htmlNodeStatus(const htmlNodePtr, int) ;\n/**\n * htmlDefaultSubelement:\n * @elt: HTML element\n *\n * Returns the default subelement for this element\n */\n#define htmlDefaultSubelement(elt) elt->defaultsubelt\n/**\n * htmlElementAllowedHereDesc:\n * @parent: HTML parent element\n * @elt: HTML element\n *\n * Checks whether an HTML element description may be a\n * direct child of the specified element.\n *\n * Returns 1 if allowed; 0 otherwise.\n */\n#define htmlElementAllowedHereDesc(parent,elt) \\\n\thtmlElementAllowedHere((parent), (elt)->name)\n/**\n * htmlRequiredAttrs:\n * @elt: HTML element\n *\n * Returns the attributes required for the specified element.\n */\n#define htmlRequiredAttrs(elt) (elt)->attrs_req\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_HTML_ENABLED */\n#endif /* __HTML_PARSER_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/HTMLtree.h",
    "content": "/*\n * Summary: specific APIs to process HTML tree, especially serialization\n * Description: this module implements a few function needed to process\n *              tree in an HTML specific way.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __HTML_TREE_H__\n#define __HTML_TREE_H__\n\n#include <stdio.h>\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/HTMLparser.h>\n\n#ifdef LIBXML_HTML_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/**\n * HTML_TEXT_NODE:\n *\n * Macro. A text node in a HTML document is really implemented\n * the same way as a text node in an XML document.\n */\n#define HTML_TEXT_NODE\t\tXML_TEXT_NODE\n/**\n * HTML_ENTITY_REF_NODE:\n *\n * Macro. An entity reference in a HTML document is really implemented\n * the same way as an entity reference in an XML document.\n */\n#define HTML_ENTITY_REF_NODE\tXML_ENTITY_REF_NODE\n/**\n * HTML_COMMENT_NODE:\n *\n * Macro. A comment in a HTML document is really implemented\n * the same way as a comment in an XML document.\n */\n#define HTML_COMMENT_NODE\tXML_COMMENT_NODE\n/**\n * HTML_PRESERVE_NODE:\n *\n * Macro. A preserved node in a HTML document is really implemented\n * the same way as a CDATA section in an XML document.\n */\n#define HTML_PRESERVE_NODE\tXML_CDATA_SECTION_NODE\n/**\n * HTML_PI_NODE:\n *\n * Macro. A processing instruction in a HTML document is really implemented\n * the same way as a processing instruction in an XML document.\n */\n#define HTML_PI_NODE\t\tXML_PI_NODE\n\nXMLPUBFUN htmlDocPtr\n\t\thtmlNewDoc\t\t(const xmlChar *URI,\n\t\t\t\t\t const xmlChar *ExternalID);\nXMLPUBFUN htmlDocPtr\n\t\thtmlNewDocNoDtD\t\t(const xmlChar *URI,\n\t\t\t\t\t const xmlChar *ExternalID);\nXMLPUBFUN const xmlChar *\n\t\thtmlGetMetaEncoding\t(htmlDocPtr doc);\nXMLPUBFUN int\n\t\thtmlSetMetaEncoding\t(htmlDocPtr doc,\n\t\t\t\t\t const xmlChar *encoding);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\thtmlDocDumpMemory\t(xmlDocPtr cur,\n\t\t\t\t\t xmlChar **mem,\n\t\t\t\t\t int *size);\nXMLPUBFUN void\n\t\thtmlDocDumpMemoryFormat\t(xmlDocPtr cur,\n\t\t\t\t\t xmlChar **mem,\n\t\t\t\t\t int *size,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\thtmlDocDump\t\t(FILE *f,\n\t\t\t\t\t xmlDocPtr cur);\nXMLPUBFUN int\n\t\thtmlSaveFile\t\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur);\nXMLPUBFUN int\n\t\thtmlNodeDump\t\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur);\nXMLPUBFUN void\n\t\thtmlNodeDumpFile\t(FILE *out,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur);\nXMLPUBFUN int\n\t\thtmlNodeDumpFileFormat\t(FILE *out,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\thtmlSaveFileEnc\t\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN int\n\t\thtmlSaveFileFormat\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\n\nXMLPUBFUN void\n\t\thtmlNodeDumpFormatOutput(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\nXMLPUBFUN void\n\t\thtmlDocContentDumpOutput(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN void\n\t\thtmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\nXMLPUBFUN void\n\t\thtmlNodeDumpOutput\t(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t const char *encoding);\n\n#endif /* LIBXML_OUTPUT_ENABLED */\n\nXMLPUBFUN int\n\t\thtmlIsBooleanAttr\t(const xmlChar *name);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_HTML_ENABLED */\n\n#endif /* __HTML_TREE_H__ */\n\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/SAX.h",
    "content": "/*\n * Summary: Old SAX version 1 handler, deprecated\n * Description: DEPRECATED set of SAX version 1 interfaces used to\n *              build the DOM tree.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SAX_H__\n#define __XML_SAX_H__\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n\n#ifdef LIBXML_LEGACY_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\tgetPublicId\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\tgetSystemId\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tsetDocumentLocator\t\t(void *ctx,\n\t\t\t\t\t\t xmlSAXLocatorPtr loc);\n\nXML_DEPRECATED\nXMLPUBFUN int\n\t\tgetLineNumber\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\tgetColumnNumber\t\t\t(void *ctx);\n\nXML_DEPRECATED\nXMLPUBFUN int\n\t\tisStandalone\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\thasInternalSubset\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\thasExternalSubset\t\t(void *ctx);\n\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tinternalSubset\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\texternalSubset\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\nXML_DEPRECATED\nXMLPUBFUN xmlEntityPtr\n\t\tgetEntity\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN xmlEntityPtr\n\t\tgetParameterEntity\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN xmlParserInputPtr\n\t\tresolveEntity\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId);\n\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tentityDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId,\n\t\t\t\t\t\t xmlChar *content);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tattributeDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t int def,\n\t\t\t\t\t\t const xmlChar *defaultValue,\n\t\t\t\t\t\t xmlEnumerationPtr tree);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\telementDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t xmlElementContentPtr content);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tnotationDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tunparsedEntityDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId,\n\t\t\t\t\t\t const xmlChar *notationName);\n\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tstartDocument\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tendDocument\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tattribute\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t const xmlChar *value);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tstartElement\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t const xmlChar **atts);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tendElement\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\treference\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tcharacters\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *ch,\n\t\t\t\t\t\t int len);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tignorableWhitespace\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *ch,\n\t\t\t\t\t\t int len);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tprocessingInstruction\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *target,\n\t\t\t\t\t\t const xmlChar *data);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tglobalNamespace\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *href,\n\t\t\t\t\t\t const xmlChar *prefix);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tsetNamespace\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN xmlNsPtr\n\t\tgetNamespace\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\tcheckNamespace\t\t\t(void *ctx,\n\t\t\t\t\t\t xmlChar *nameSpace);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tnamespaceDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *href,\n\t\t\t\t\t\t const xmlChar *prefix);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tcomment\t\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *value);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tcdataBlock\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t int len);\n\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tinitxmlDefaultSAXHandler\t(xmlSAXHandlerV1 *hdlr,\n\t\t\t\t\t\t int warning);\n#ifdef LIBXML_HTML_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tinithtmlDefaultSAXHandler\t(xmlSAXHandlerV1 *hdlr);\n#endif\n#endif /* LIBXML_SAX1_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_LEGACY_ENABLED */\n\n#endif /* __XML_SAX_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/SAX2.h",
    "content": "/*\n * Summary: SAX2 parser interface used to build the DOM tree\n * Description: those are the default SAX2 interfaces used by\n *              the library when building DOM tree.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SAX2_H__\n#define __XML_SAX2_H__\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nXMLPUBFUN const xmlChar *\n\t\txmlSAX2GetPublicId\t\t(void *ctx);\nXMLPUBFUN const xmlChar *\n\t\txmlSAX2GetSystemId\t\t(void *ctx);\nXMLPUBFUN void\n\t\txmlSAX2SetDocumentLocator\t(void *ctx,\n\t\t\t\t\t\t xmlSAXLocatorPtr loc);\n\nXMLPUBFUN int\n\t\txmlSAX2GetLineNumber\t\t(void *ctx);\nXMLPUBFUN int\n\t\txmlSAX2GetColumnNumber\t\t(void *ctx);\n\nXMLPUBFUN int\n\t\txmlSAX2IsStandalone\t\t(void *ctx);\nXMLPUBFUN int\n\t\txmlSAX2HasInternalSubset\t(void *ctx);\nXMLPUBFUN int\n\t\txmlSAX2HasExternalSubset\t(void *ctx);\n\nXMLPUBFUN void\n\t\txmlSAX2InternalSubset\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN void\n\t\txmlSAX2ExternalSubset\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlEntityPtr\n\t\txmlSAX2GetEntity\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlEntityPtr\n\t\txmlSAX2GetParameterEntity\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlParserInputPtr\n\t\txmlSAX2ResolveEntity\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId);\n\nXMLPUBFUN void\n\t\txmlSAX2EntityDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId,\n\t\t\t\t\t\t xmlChar *content);\nXMLPUBFUN void\n\t\txmlSAX2AttributeDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t int def,\n\t\t\t\t\t\t const xmlChar *defaultValue,\n\t\t\t\t\t\t xmlEnumerationPtr tree);\nXMLPUBFUN void\n\t\txmlSAX2ElementDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t xmlElementContentPtr content);\nXMLPUBFUN void\n\t\txmlSAX2NotationDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId);\nXMLPUBFUN void\n\t\txmlSAX2UnparsedEntityDecl\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId,\n\t\t\t\t\t\t const xmlChar *notationName);\n\nXMLPUBFUN void\n\t\txmlSAX2StartDocument\t\t(void *ctx);\nXMLPUBFUN void\n\t\txmlSAX2EndDocument\t\t(void *ctx);\n#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \\\n    defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)\nXMLPUBFUN void\n\t\txmlSAX2StartElement\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t const xmlChar **atts);\nXMLPUBFUN void\n\t\txmlSAX2EndElement\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\n#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */\nXMLPUBFUN void\n\t\txmlSAX2StartElementNs\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *localname,\n\t\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t\t const xmlChar *URI,\n\t\t\t\t\t\t int nb_namespaces,\n\t\t\t\t\t\t const xmlChar **namespaces,\n\t\t\t\t\t\t int nb_attributes,\n\t\t\t\t\t\t int nb_defaulted,\n\t\t\t\t\t\t const xmlChar **attributes);\nXMLPUBFUN void\n\t\txmlSAX2EndElementNs\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *localname,\n\t\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t\t const xmlChar *URI);\nXMLPUBFUN void\n\t\txmlSAX2Reference\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN void\n\t\txmlSAX2Characters\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *ch,\n\t\t\t\t\t\t int len);\nXMLPUBFUN void\n\t\txmlSAX2IgnorableWhitespace\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *ch,\n\t\t\t\t\t\t int len);\nXMLPUBFUN void\n\t\txmlSAX2ProcessingInstruction\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *target,\n\t\t\t\t\t\t const xmlChar *data);\nXMLPUBFUN void\n\t\txmlSAX2Comment\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN void\n\t\txmlSAX2CDataBlock\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t int len);\n\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlSAXDefaultVersion\t\t(int version);\n#endif /* LIBXML_SAX1_ENABLED */\n\nXMLPUBFUN int\n\t\txmlSAXVersion\t\t\t(xmlSAXHandler *hdlr,\n\t\t\t\t\t\t int version);\nXMLPUBFUN void\n\t\txmlSAX2InitDefaultSAXHandler    (xmlSAXHandler *hdlr,\n\t\t\t\t\t\t int warning);\n#ifdef LIBXML_HTML_ENABLED\nXMLPUBFUN void\n\t\txmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\thtmlDefaultSAXHandlerInit\t(void);\n#endif\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlDefaultSAXHandlerInit\t(void);\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_SAX2_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/c14n.h",
    "content": "/*\n * Summary: Provide Canonical XML and Exclusive XML Canonicalization\n * Description: the c14n modules provides a\n *\n * \"Canonical XML\" implementation\n * http://www.w3.org/TR/xml-c14n\n *\n * and an\n *\n * \"Exclusive XML Canonicalization\" implementation\n * http://www.w3.org/TR/xml-exc-c14n\n\n * Copy: See Copyright for the status of this software.\n *\n * Author: Aleksey Sanin <aleksey@aleksey.com>\n */\n#ifndef __XML_C14N_H__\n#define __XML_C14N_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_C14N_ENABLED\n#ifdef LIBXML_OUTPUT_ENABLED\n\n#include <libxml/tree.h>\n#include <libxml/xpath.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/*\n * XML Canonicalization\n * http://www.w3.org/TR/xml-c14n\n *\n * Exclusive XML Canonicalization\n * http://www.w3.org/TR/xml-exc-c14n\n *\n * Canonical form of an XML document could be created if and only if\n *  a) default attributes (if any) are added to all nodes\n *  b) all character and parsed entity references are resolved\n * In order to achieve this in libxml2 the document MUST be loaded with\n * following global settings:\n *\n *    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;\n *    xmlSubstituteEntitiesDefault(1);\n *\n * or corresponding parser context setting:\n *    xmlParserCtxtPtr ctxt;\n *\n *    ...\n *    ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;\n *    ctxt->replaceEntities = 1;\n *    ...\n */\n\n/*\n * xmlC14NMode:\n *\n * Predefined values for C14N modes\n *\n */\ntypedef enum {\n    XML_C14N_1_0            = 0,    /* Original C14N 1.0 spec */\n    XML_C14N_EXCLUSIVE_1_0  = 1,    /* Exclusive C14N 1.0 spec */\n    XML_C14N_1_1            = 2     /* C14N 1.1 spec */\n} xmlC14NMode;\n\nXMLPUBFUN int\n\t\txmlC14NDocSaveTo\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodeSetPtr nodes,\n\t\t\t\t\t int mode, /* a xmlC14NMode */\n\t\t\t\t\t xmlChar **inclusive_ns_prefixes,\n\t\t\t\t\t int with_comments,\n\t\t\t\t\t xmlOutputBufferPtr buf);\n\nXMLPUBFUN int\n\t\txmlC14NDocDumpMemory\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodeSetPtr nodes,\n\t\t\t\t\t int mode, /* a xmlC14NMode */\n\t\t\t\t\t xmlChar **inclusive_ns_prefixes,\n\t\t\t\t\t int with_comments,\n\t\t\t\t\t xmlChar **doc_txt_ptr);\n\nXMLPUBFUN int\n\t\txmlC14NDocSave\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodeSetPtr nodes,\n\t\t\t\t\t int mode, /* a xmlC14NMode */\n\t\t\t\t\t xmlChar **inclusive_ns_prefixes,\n\t\t\t\t\t int with_comments,\n\t\t\t\t\t const char* filename,\n\t\t\t\t\t int compression);\n\n\n/**\n * This is the core C14N function\n */\n/**\n * xmlC14NIsVisibleCallback:\n * @user_data: user data\n * @node: the current node\n * @parent: the parent node\n *\n * Signature for a C14N callback on visible nodes\n *\n * Returns 1 if the node should be included\n */\ntypedef int (*xmlC14NIsVisibleCallback)\t(void* user_data,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t xmlNodePtr parent);\n\nXMLPUBFUN int\n\t\txmlC14NExecute\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlC14NIsVisibleCallback is_visible_callback,\n\t\t\t\t\t void* user_data,\n\t\t\t\t\t int mode, /* a xmlC14NMode */\n\t\t\t\t\t xmlChar **inclusive_ns_prefixes,\n\t\t\t\t\t int with_comments,\n\t\t\t\t\t xmlOutputBufferPtr buf);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* LIBXML_OUTPUT_ENABLED */\n#endif /* LIBXML_C14N_ENABLED */\n#endif /* __XML_C14N_H__ */\n\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/catalog.h",
    "content": "/**\n * Summary: interfaces to the Catalog handling system\n * Description: the catalog module implements the support for\n * XML Catalogs and SGML catalogs\n *\n * SGML Open Technical Resolution TR9401:1997.\n * http://www.jclark.com/sp/catalog.htm\n *\n * XML Catalogs Working Draft 06 August 2001\n * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_CATALOG_H__\n#define __XML_CATALOG_H__\n\n#include <stdio.h>\n\n#include <libxml/xmlversion.h>\n#include <libxml/xmlstring.h>\n#include <libxml/tree.h>\n\n#ifdef LIBXML_CATALOG_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * XML_CATALOGS_NAMESPACE:\n *\n * The namespace for the XML Catalogs elements.\n */\n#define XML_CATALOGS_NAMESPACE\t\t\t\t\t\\\n    (const xmlChar *) \"urn:oasis:names:tc:entity:xmlns:xml:catalog\"\n/**\n * XML_CATALOG_PI:\n *\n * The specific XML Catalog Processing Instruction name.\n */\n#define XML_CATALOG_PI\t\t\t\t\t\t\\\n    (const xmlChar *) \"oasis-xml-catalog\"\n\n/*\n * The API is voluntarily limited to general cataloging.\n */\ntypedef enum {\n    XML_CATA_PREFER_NONE = 0,\n    XML_CATA_PREFER_PUBLIC = 1,\n    XML_CATA_PREFER_SYSTEM\n} xmlCatalogPrefer;\n\ntypedef enum {\n    XML_CATA_ALLOW_NONE = 0,\n    XML_CATA_ALLOW_GLOBAL = 1,\n    XML_CATA_ALLOW_DOCUMENT = 2,\n    XML_CATA_ALLOW_ALL = 3\n} xmlCatalogAllow;\n\ntypedef struct _xmlCatalog xmlCatalog;\ntypedef xmlCatalog *xmlCatalogPtr;\n\n/*\n * Operations on a given catalog.\n */\nXMLPUBFUN xmlCatalogPtr\n\t\txmlNewCatalog\t\t(int sgml);\nXMLPUBFUN xmlCatalogPtr\n\t\txmlLoadACatalog\t\t(const char *filename);\nXMLPUBFUN xmlCatalogPtr\n\t\txmlLoadSGMLSuperCatalog\t(const char *filename);\nXMLPUBFUN int\n\t\txmlConvertSGMLCatalog\t(xmlCatalogPtr catal);\nXMLPUBFUN int\n\t\txmlACatalogAdd\t\t(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *type,\n\t\t\t\t\t const xmlChar *orig,\n\t\t\t\t\t const xmlChar *replace);\nXMLPUBFUN int\n\t\txmlACatalogRemove\t(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlChar *\n\t\txmlACatalogResolve\t(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *pubID,\n\t                                 const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlACatalogResolveSystem(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlACatalogResolvePublic(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *pubID);\nXMLPUBFUN xmlChar *\n\t\txmlACatalogResolveURI\t(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *URI);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlACatalogDump\t\t(xmlCatalogPtr catal,\n\t\t\t\t\t FILE *out);\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN void\n\t\txmlFreeCatalog\t\t(xmlCatalogPtr catal);\nXMLPUBFUN int\n\t\txmlCatalogIsEmpty\t(xmlCatalogPtr catal);\n\n/*\n * Global operations.\n */\nXMLPUBFUN void\n\t\txmlInitializeCatalog\t(void);\nXMLPUBFUN int\n\t\txmlLoadCatalog\t\t(const char *filename);\nXMLPUBFUN void\n\t\txmlLoadCatalogs\t\t(const char *paths);\nXMLPUBFUN void\n\t\txmlCatalogCleanup\t(void);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlCatalogDump\t\t(FILE *out);\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN xmlChar *\n\t\txmlCatalogResolve\t(const xmlChar *pubID,\n\t                                 const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogResolveSystem\t(const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogResolvePublic\t(const xmlChar *pubID);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogResolveURI\t(const xmlChar *URI);\nXMLPUBFUN int\n\t\txmlCatalogAdd\t\t(const xmlChar *type,\n\t\t\t\t\t const xmlChar *orig,\n\t\t\t\t\t const xmlChar *replace);\nXMLPUBFUN int\n\t\txmlCatalogRemove\t(const xmlChar *value);\nXMLPUBFUN xmlDocPtr\n\t\txmlParseCatalogFile\t(const char *filename);\nXMLPUBFUN int\n\t\txmlCatalogConvert\t(void);\n\n/*\n * Strictly minimal interfaces for per-document catalogs used\n * by the parser.\n */\nXMLPUBFUN void\n\t\txmlCatalogFreeLocal\t(void *catalogs);\nXMLPUBFUN void *\n\t\txmlCatalogAddLocal\t(void *catalogs,\n\t\t\t\t\t const xmlChar *URL);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogLocalResolve\t(void *catalogs,\n\t\t\t\t\t const xmlChar *pubID,\n\t                                 const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogLocalResolveURI(void *catalogs,\n\t\t\t\t\t const xmlChar *URI);\n/*\n * Preference settings.\n */\nXMLPUBFUN int\n\t\txmlCatalogSetDebug\t(int level);\nXMLPUBFUN xmlCatalogPrefer\n\t\txmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer);\nXMLPUBFUN void\n\t\txmlCatalogSetDefaults\t(xmlCatalogAllow allow);\nXMLPUBFUN xmlCatalogAllow\n\t\txmlCatalogGetDefaults\t(void);\n\n\n/* DEPRECATED interfaces */\nXMLPUBFUN const xmlChar *\n\t\txmlCatalogGetSystem\t(const xmlChar *sysID);\nXMLPUBFUN const xmlChar *\n\t\txmlCatalogGetPublic\t(const xmlChar *pubID);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* LIBXML_CATALOG_ENABLED */\n#endif /* __XML_CATALOG_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/chvalid.h",
    "content": "/*\n * Summary: Unicode character range checking\n * Description: this module exports interfaces for the character\n *               range validation APIs\n *\n * This file is automatically generated from the cvs source\n * definition files using the genChRanges.py Python script\n *\n * Generation date: Mon Mar 27 11:09:48 2006\n * Sources: chvalid.def\n * Author: William Brack <wbrack@mmm.com.hk>\n */\n\n#ifndef __XML_CHVALID_H__\n#define __XML_CHVALID_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Define our typedefs and structures\n *\n */\ntypedef struct _xmlChSRange xmlChSRange;\ntypedef xmlChSRange *xmlChSRangePtr;\nstruct _xmlChSRange {\n    unsigned short\tlow;\n    unsigned short\thigh;\n};\n\ntypedef struct _xmlChLRange xmlChLRange;\ntypedef xmlChLRange *xmlChLRangePtr;\nstruct _xmlChLRange {\n    unsigned int\tlow;\n    unsigned int\thigh;\n};\n\ntypedef struct _xmlChRangeGroup xmlChRangeGroup;\ntypedef xmlChRangeGroup *xmlChRangeGroupPtr;\nstruct _xmlChRangeGroup {\n    int\t\t\tnbShortRange;\n    int\t\t\tnbLongRange;\n    const xmlChSRange\t*shortRange;\t/* points to an array of ranges */\n    const xmlChLRange\t*longRange;\n};\n\n/**\n * Range checking routine\n */\nXMLPUBFUN int\n\t\txmlCharInRange(unsigned int val, const xmlChRangeGroup *group);\n\n\n/**\n * xmlIsBaseChar_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsBaseChar_ch(c)\t(((0x41 <= (c)) && ((c) <= 0x5a)) || \\\n\t\t\t\t ((0x61 <= (c)) && ((c) <= 0x7a)) || \\\n\t\t\t\t ((0xc0 <= (c)) && ((c) <= 0xd6)) || \\\n\t\t\t\t ((0xd8 <= (c)) && ((c) <= 0xf6)) || \\\n\t\t\t\t  (0xf8 <= (c)))\n\n/**\n * xmlIsBaseCharQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsBaseCharQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsBaseChar_ch((c)) : \\\n\t\t\t\t xmlCharInRange((c), &xmlIsBaseCharGroup))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup;\n\n/**\n * xmlIsBlank_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsBlank_ch(c)\t(((c) == 0x20) || \\\n\t\t\t\t ((0x9 <= (c)) && ((c) <= 0xa)) || \\\n\t\t\t\t ((c) == 0xd))\n\n/**\n * xmlIsBlankQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsBlankQ(c)\t\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsBlank_ch((c)) : 0)\n\n\n/**\n * xmlIsChar_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsChar_ch(c)\t\t(((0x9 <= (c)) && ((c) <= 0xa)) || \\\n\t\t\t\t ((c) == 0xd) || \\\n\t\t\t\t  (0x20 <= (c)))\n\n/**\n * xmlIsCharQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsCharQ(c)\t\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsChar_ch((c)) :\\\n\t\t\t\t(((0x100 <= (c)) && ((c) <= 0xd7ff)) || \\\n\t\t\t\t ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \\\n\t\t\t\t ((0x10000 <= (c)) && ((c) <= 0x10ffff))))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsCharGroup;\n\n/**\n * xmlIsCombiningQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsCombiningQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t 0 : \\\n\t\t\t\t xmlCharInRange((c), &xmlIsCombiningGroup))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup;\n\n/**\n * xmlIsDigit_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsDigit_ch(c)\t(((0x30 <= (c)) && ((c) <= 0x39)))\n\n/**\n * xmlIsDigitQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsDigitQ(c)\t\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsDigit_ch((c)) : \\\n\t\t\t\t xmlCharInRange((c), &xmlIsDigitGroup))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup;\n\n/**\n * xmlIsExtender_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsExtender_ch(c)\t(((c) == 0xb7))\n\n/**\n * xmlIsExtenderQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsExtenderQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsExtender_ch((c)) : \\\n\t\t\t\t xmlCharInRange((c), &xmlIsExtenderGroup))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup;\n\n/**\n * xmlIsIdeographicQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsIdeographicQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t 0 :\\\n\t\t\t\t(((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \\\n\t\t\t\t ((c) == 0x3007) || \\\n\t\t\t\t ((0x3021 <= (c)) && ((c) <= 0x3029))))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup;\nXMLPUBVAR const unsigned char xmlIsPubidChar_tab[256];\n\n/**\n * xmlIsPubidChar_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsPubidChar_ch(c)\t(xmlIsPubidChar_tab[(c)])\n\n/**\n * xmlIsPubidCharQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsPubidCharQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsPubidChar_ch((c)) : 0)\n\nXMLPUBFUN int\n\t\txmlIsBaseChar(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsBlank(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsChar(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsCombining(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsDigit(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsExtender(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsIdeographic(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsPubidChar(unsigned int ch);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_CHVALID_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/debugXML.h",
    "content": "/*\n * Summary: Tree debugging APIs\n * Description: Interfaces to a set of routines used for debugging the tree\n *              produced by the XML parser.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __DEBUG_XML__\n#define __DEBUG_XML__\n#include <stdio.h>\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef LIBXML_DEBUG_ENABLED\n\n#include <libxml/xpath.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The standard Dump routines.\n */\nXMLPUBFUN void\n\txmlDebugDumpString\t(FILE *output,\n\t\t\t\t const xmlChar *str);\nXMLPUBFUN void\n\txmlDebugDumpAttr\t(FILE *output,\n\t\t\t\t xmlAttrPtr attr,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpAttrList\t(FILE *output,\n\t\t\t\t xmlAttrPtr attr,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpOneNode\t(FILE *output,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpNode\t(FILE *output,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpNodeList\t(FILE *output,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpDocumentHead(FILE *output,\n\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN void\n\txmlDebugDumpDocument\t(FILE *output,\n\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN void\n\txmlDebugDumpDTD\t\t(FILE *output,\n\t\t\t\t xmlDtdPtr dtd);\nXMLPUBFUN void\n\txmlDebugDumpEntities\t(FILE *output,\n\t\t\t\t xmlDocPtr doc);\n\n/****************************************************************\n *\t\t\t\t\t\t\t\t*\n *\t\t\tChecking routines\t\t\t*\n *\t\t\t\t\t\t\t\t*\n ****************************************************************/\n\nXMLPUBFUN int\n\txmlDebugCheckDocument\t(FILE * output,\n\t\t\t\t xmlDocPtr doc);\n\n/****************************************************************\n *\t\t\t\t\t\t\t\t*\n *\t\t\tXML shell helpers\t\t\t*\n *\t\t\t\t\t\t\t\t*\n ****************************************************************/\n\nXMLPUBFUN void\n\txmlLsOneNode\t\t(FILE *output, xmlNodePtr node);\nXMLPUBFUN int\n\txmlLsCountNode\t\t(xmlNodePtr node);\n\nXMLPUBFUN const char *\n\txmlBoolToText\t\t(int boolval);\n\n/****************************************************************\n *\t\t\t\t\t\t\t\t*\n *\t The XML shell related structures and functions\t\t*\n *\t\t\t\t\t\t\t\t*\n ****************************************************************/\n\n#ifdef LIBXML_XPATH_ENABLED\n/**\n * xmlShellReadlineFunc:\n * @prompt:  a string prompt\n *\n * This is a generic signature for the XML shell input function.\n *\n * Returns a string which will be freed by the Shell.\n */\ntypedef char * (* xmlShellReadlineFunc)(char *prompt);\n\n/**\n * xmlShellCtxt:\n *\n * A debugging shell context.\n * TODO: add the defined function tables.\n */\ntypedef struct _xmlShellCtxt xmlShellCtxt;\ntypedef xmlShellCtxt *xmlShellCtxtPtr;\nstruct _xmlShellCtxt {\n    char *filename;\n    xmlDocPtr doc;\n    xmlNodePtr node;\n    xmlXPathContextPtr pctxt;\n    int loaded;\n    FILE *output;\n    xmlShellReadlineFunc input;\n};\n\n/**\n * xmlShellCmd:\n * @ctxt:  a shell context\n * @arg:  a string argument\n * @node:  a first node\n * @node2:  a second node\n *\n * This is a generic signature for the XML shell functions.\n *\n * Returns an int, negative returns indicating errors.\n */\ntypedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,\n                             char *arg,\n\t\t\t     xmlNodePtr node,\n\t\t\t     xmlNodePtr node2);\n\nXMLPUBFUN void\n\txmlShellPrintXPathError\t(int errorType,\n\t\t\t\t const char *arg);\nXMLPUBFUN void\n\txmlShellPrintXPathResult(xmlXPathObjectPtr list);\nXMLPUBFUN int\n\txmlShellList\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellBase\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellDir\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellLoad\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *filename,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\txmlShellPrintNode\t(xmlNodePtr node);\nXMLPUBFUN int\n\txmlShellCat\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellWrite\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *filename,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellSave\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *filename,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\n#endif /* LIBXML_OUTPUT_ENABLED */\n#ifdef LIBXML_VALID_ENABLED\nXMLPUBFUN int\n\txmlShellValidate\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *dtd,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\n#endif /* LIBXML_VALID_ENABLED */\nXMLPUBFUN int\n\txmlShellDu\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr tree,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellPwd\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *buffer,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\n\n/*\n * The Shell interface.\n */\nXMLPUBFUN void\n\txmlShell\t\t(xmlDocPtr doc,\n\t\t\t\t char *filename,\n\t\t\t\t xmlShellReadlineFunc input,\n\t\t\t\t FILE *output);\n\n#endif /* LIBXML_XPATH_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_DEBUG_ENABLED */\n#endif /* __DEBUG_XML__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/dict.h",
    "content": "/*\n * Summary: string dictionary\n * Description: dictionary of reusable strings, just used to avoid allocation\n *         and freeing operations.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_DICT_H__\n#define __XML_DICT_H__\n\n#include <stddef.h>\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The dictionary.\n */\ntypedef struct _xmlDict xmlDict;\ntypedef xmlDict *xmlDictPtr;\n\n/*\n * Initializer\n */\nXML_DEPRECATED\nXMLPUBFUN int  xmlInitializeDict(void);\n\n/*\n * Constructor and destructor.\n */\nXMLPUBFUN xmlDictPtr\n\t\t\txmlDictCreate\t(void);\nXMLPUBFUN size_t\n\t\t\txmlDictSetLimit\t(xmlDictPtr dict,\n                                         size_t limit);\nXMLPUBFUN size_t\n\t\t\txmlDictGetUsage (xmlDictPtr dict);\nXMLPUBFUN xmlDictPtr\n\t\t\txmlDictCreateSub(xmlDictPtr sub);\nXMLPUBFUN int\n\t\t\txmlDictReference(xmlDictPtr dict);\nXMLPUBFUN void\n\t\t\txmlDictFree\t(xmlDictPtr dict);\n\n/*\n * Lookup of entry in the dictionary.\n */\nXMLPUBFUN const xmlChar *\n\t\t\txmlDictLookup\t(xmlDictPtr dict,\n\t\t                         const xmlChar *name,\n\t\t                         int len);\nXMLPUBFUN const xmlChar *\n\t\t\txmlDictExists\t(xmlDictPtr dict,\n\t\t                         const xmlChar *name,\n\t\t                         int len);\nXMLPUBFUN const xmlChar *\n\t\t\txmlDictQLookup\t(xmlDictPtr dict,\n\t\t                         const xmlChar *prefix,\n\t\t                         const xmlChar *name);\nXMLPUBFUN int\n\t\t\txmlDictOwns\t(xmlDictPtr dict,\n\t\t\t\t\t const xmlChar *str);\nXMLPUBFUN int\n\t\t\txmlDictSize\t(xmlDictPtr dict);\n\n/*\n * Cleanup function\n */\nXML_DEPRECATED\nXMLPUBFUN void\n                        xmlDictCleanup  (void);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* ! __XML_DICT_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/encoding.h",
    "content": "/*\n * Summary: interface for the encoding conversion functions\n * Description: interface for the encoding conversion functions needed for\n *              XML basic encoding and iconv() support.\n *\n * Related specs are\n * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies\n * [ISO-10646]    UTF-8 and UTF-16 in Annexes\n * [ISO-8859-1]   ISO Latin-1 characters codes.\n * [UNICODE]      The Unicode Consortium, \"The Unicode Standard --\n *                Worldwide Character Encoding -- Version 1.0\", Addison-\n *                Wesley, Volume 1, 1991, Volume 2, 1992.  UTF-8 is\n *                described in Unicode Technical Report #4.\n * [US-ASCII]     Coded Character Set--7-bit American Standard Code for\n *                Information Interchange, ANSI X3.4-1986.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_CHAR_ENCODING_H__\n#define __XML_CHAR_ENCODING_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_ICONV_ENABLED\n#include <iconv.h>\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * xmlCharEncoding:\n *\n * Predefined values for some standard encodings.\n * Libxml does not do beforehand translation on UTF8 and ISOLatinX.\n * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default.\n *\n * Anything else would have to be translated to UTF8 before being\n * given to the parser itself. The BOM for UTF16 and the encoding\n * declaration are looked at and a converter is looked for at that\n * point. If not found the parser stops here as asked by the XML REC. A\n * converter can be registered by the user using xmlRegisterCharEncodingHandler\n * but the current form doesn't allow stateful transcoding (a serious\n * problem agreed !). If iconv has been found it will be used\n * automatically and allow stateful transcoding, the simplest is then\n * to be sure to enable iconv and to provide iconv libs for the encoding\n * support needed.\n *\n * Note that the generic \"UTF-16\" is not a predefined value.  Instead, only\n * the specific UTF-16LE and UTF-16BE are present.\n */\ntypedef enum {\n    XML_CHAR_ENCODING_ERROR=   -1, /* No char encoding detected */\n    XML_CHAR_ENCODING_NONE=\t0, /* No char encoding detected */\n    XML_CHAR_ENCODING_UTF8=\t1, /* UTF-8 */\n    XML_CHAR_ENCODING_UTF16LE=\t2, /* UTF-16 little endian */\n    XML_CHAR_ENCODING_UTF16BE=\t3, /* UTF-16 big endian */\n    XML_CHAR_ENCODING_UCS4LE=\t4, /* UCS-4 little endian */\n    XML_CHAR_ENCODING_UCS4BE=\t5, /* UCS-4 big endian */\n    XML_CHAR_ENCODING_EBCDIC=\t6, /* EBCDIC uh! */\n    XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */\n    XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */\n    XML_CHAR_ENCODING_UCS2=\t9, /* UCS-2 */\n    XML_CHAR_ENCODING_8859_1=\t10,/* ISO-8859-1 ISO Latin 1 */\n    XML_CHAR_ENCODING_8859_2=\t11,/* ISO-8859-2 ISO Latin 2 */\n    XML_CHAR_ENCODING_8859_3=\t12,/* ISO-8859-3 */\n    XML_CHAR_ENCODING_8859_4=\t13,/* ISO-8859-4 */\n    XML_CHAR_ENCODING_8859_5=\t14,/* ISO-8859-5 */\n    XML_CHAR_ENCODING_8859_6=\t15,/* ISO-8859-6 */\n    XML_CHAR_ENCODING_8859_7=\t16,/* ISO-8859-7 */\n    XML_CHAR_ENCODING_8859_8=\t17,/* ISO-8859-8 */\n    XML_CHAR_ENCODING_8859_9=\t18,/* ISO-8859-9 */\n    XML_CHAR_ENCODING_2022_JP=  19,/* ISO-2022-JP */\n    XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */\n    XML_CHAR_ENCODING_EUC_JP=   21,/* EUC-JP */\n    XML_CHAR_ENCODING_ASCII=    22 /* pure ASCII */\n} xmlCharEncoding;\n\n/**\n * xmlCharEncodingInputFunc:\n * @out:  a pointer to an array of bytes to store the UTF-8 result\n * @outlen:  the length of @out\n * @in:  a pointer to an array of chars in the original encoding\n * @inlen:  the length of @in\n *\n * Take a block of chars in the original encoding and try to convert\n * it to an UTF-8 block of chars out.\n *\n * Returns the number of bytes written, -1 if lack of space, or -2\n *     if the transcoding failed.\n * The value of @inlen after return is the number of octets consumed\n *     if the return value is positive, else unpredictiable.\n * The value of @outlen after return is the number of octets consumed.\n */\ntypedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,\n                                         const unsigned char *in, int *inlen);\n\n\n/**\n * xmlCharEncodingOutputFunc:\n * @out:  a pointer to an array of bytes to store the result\n * @outlen:  the length of @out\n * @in:  a pointer to an array of UTF-8 chars\n * @inlen:  the length of @in\n *\n * Take a block of UTF-8 chars in and try to convert it to another\n * encoding.\n * Note: a first call designed to produce heading info is called with\n * in = NULL. If stateful this should also initialize the encoder state.\n *\n * Returns the number of bytes written, -1 if lack of space, or -2\n *     if the transcoding failed.\n * The value of @inlen after return is the number of octets consumed\n *     if the return value is positive, else unpredictiable.\n * The value of @outlen after return is the number of octets produced.\n */\ntypedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,\n                                          const unsigned char *in, int *inlen);\n\n\n/*\n * Block defining the handlers for non UTF-8 encodings.\n * If iconv is supported, there are two extra fields.\n */\ntypedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;\ntypedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;\nstruct _xmlCharEncodingHandler {\n    char                       *name;\n    xmlCharEncodingInputFunc   input;\n    xmlCharEncodingOutputFunc  output;\n#ifdef LIBXML_ICONV_ENABLED\n    iconv_t                    iconv_in;\n    iconv_t                    iconv_out;\n#endif /* LIBXML_ICONV_ENABLED */\n#ifdef LIBXML_ICU_ENABLED\n    struct _uconv_t            *uconv_in;\n    struct _uconv_t            *uconv_out;\n#endif /* LIBXML_ICU_ENABLED */\n};\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/tree.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Interfaces for encoding handlers.\n */\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlInitCharEncodingHandlers\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlCleanupCharEncodingHandlers\t(void);\nXMLPUBFUN void\n\txmlRegisterCharEncodingHandler\t(xmlCharEncodingHandlerPtr handler);\nXMLPUBFUN xmlCharEncodingHandlerPtr\n\txmlGetCharEncodingHandler\t(xmlCharEncoding enc);\nXMLPUBFUN xmlCharEncodingHandlerPtr\n\txmlFindCharEncodingHandler\t(const char *name);\nXMLPUBFUN xmlCharEncodingHandlerPtr\n\txmlNewCharEncodingHandler\t(const char *name,\n\t\t\t\t\t xmlCharEncodingInputFunc input,\n\t\t\t\t\t xmlCharEncodingOutputFunc output);\n\n/*\n * Interfaces for encoding names and aliases.\n */\nXMLPUBFUN int\n\txmlAddEncodingAlias\t\t(const char *name,\n\t\t\t\t\t const char *alias);\nXMLPUBFUN int\n\txmlDelEncodingAlias\t\t(const char *alias);\nXMLPUBFUN const char *\n\txmlGetEncodingAlias\t\t(const char *alias);\nXMLPUBFUN void\n\txmlCleanupEncodingAliases\t(void);\nXMLPUBFUN xmlCharEncoding\n\txmlParseCharEncoding\t\t(const char *name);\nXMLPUBFUN const char *\n\txmlGetCharEncodingName\t\t(xmlCharEncoding enc);\n\n/*\n * Interfaces directly used by the parsers.\n */\nXMLPUBFUN xmlCharEncoding\n\txmlDetectCharEncoding\t\t(const unsigned char *in,\n\t\t\t\t\t int len);\n\nXMLPUBFUN int\n\txmlCharEncOutFunc\t\t(xmlCharEncodingHandler *handler,\n\t\t\t\t\t xmlBufferPtr out,\n\t\t\t\t\t xmlBufferPtr in);\n\nXMLPUBFUN int\n\txmlCharEncInFunc\t\t(xmlCharEncodingHandler *handler,\n\t\t\t\t\t xmlBufferPtr out,\n\t\t\t\t\t xmlBufferPtr in);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlCharEncFirstLine\t\t(xmlCharEncodingHandler *handler,\n\t\t\t\t\t xmlBufferPtr out,\n\t\t\t\t\t xmlBufferPtr in);\nXMLPUBFUN int\n\txmlCharEncCloseFunc\t\t(xmlCharEncodingHandler *handler);\n\n/*\n * Export a few useful functions\n */\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN int\n\tUTF8Toisolat1\t\t\t(unsigned char *out,\n\t\t\t\t\t int *outlen,\n\t\t\t\t\t const unsigned char *in,\n\t\t\t\t\t int *inlen);\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN int\n\tisolat1ToUTF8\t\t\t(unsigned char *out,\n\t\t\t\t\t int *outlen,\n\t\t\t\t\t const unsigned char *in,\n\t\t\t\t\t int *inlen);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_CHAR_ENCODING_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/entities.h",
    "content": "/*\n * Summary: interface for the XML entities handling\n * Description: this module provides some of the entity API needed\n *              for the parser and applications.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_ENTITIES_H__\n#define __XML_ENTITIES_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The different valid entity types.\n */\ntypedef enum {\n    XML_INTERNAL_GENERAL_ENTITY = 1,\n    XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,\n    XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,\n    XML_INTERNAL_PARAMETER_ENTITY = 4,\n    XML_EXTERNAL_PARAMETER_ENTITY = 5,\n    XML_INTERNAL_PREDEFINED_ENTITY = 6\n} xmlEntityType;\n\n/*\n * An unit of storage for an entity, contains the string, the value\n * and the linkind data needed for the linking in the hash table.\n */\n\nstruct _xmlEntity {\n    void           *_private;\t        /* application data */\n    xmlElementType          type;       /* XML_ENTITY_DECL, must be second ! */\n    const xmlChar          *name;\t/* Entity name */\n    struct _xmlNode    *children;\t/* First child link */\n    struct _xmlNode        *last;\t/* Last child link */\n    struct _xmlDtd       *parent;\t/* -> DTD */\n    struct _xmlNode        *next;\t/* next sibling link  */\n    struct _xmlNode        *prev;\t/* previous sibling link  */\n    struct _xmlDoc          *doc;       /* the containing document */\n\n    xmlChar                *orig;\t/* content without ref substitution */\n    xmlChar             *content;\t/* content or ndata if unparsed */\n    int                   length;\t/* the content length */\n    xmlEntityType          etype;\t/* The entity type */\n    const xmlChar    *ExternalID;\t/* External identifier for PUBLIC */\n    const xmlChar      *SystemID;\t/* URI for a SYSTEM or PUBLIC Entity */\n\n    struct _xmlEntity     *nexte;\t/* unused */\n    const xmlChar           *URI;\t/* the full URI as computed */\n    int                    owner;\t/* does the entity own the childrens */\n    int                    flags;       /* various flags */\n    unsigned long   expandedSize;       /* expanded size */\n};\n\n/*\n * All entities are stored in an hash table.\n * There is 2 separate hash tables for global and parameter entities.\n */\n\ntypedef struct _xmlHashTable xmlEntitiesTable;\ntypedef xmlEntitiesTable *xmlEntitiesTablePtr;\n\n/*\n * External functions:\n */\n\n#ifdef LIBXML_LEGACY_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlInitializePredefinedEntities\t(void);\n#endif /* LIBXML_LEGACY_ENABLED */\n\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlNewEntity\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID,\n\t\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlAddDocEntity\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID,\n\t\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlAddDtdEntity\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID,\n\t\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlGetPredefinedEntity\t(const xmlChar *name);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlGetDocEntity\t\t(const xmlDoc *doc,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlGetDtdEntity\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlGetParameterEntity\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name);\n#ifdef LIBXML_LEGACY_ENABLED\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlEncodeEntities\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *input);\n#endif /* LIBXML_LEGACY_ENABLED */\nXMLPUBFUN xmlChar *\n\t\t\txmlEncodeEntitiesReentrant(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *input);\nXMLPUBFUN xmlChar *\n\t\t\txmlEncodeSpecialChars\t(const xmlDoc *doc,\n\t\t\t\t\t\t const xmlChar *input);\nXMLPUBFUN xmlEntitiesTablePtr\n\t\t\txmlCreateEntitiesTable\t(void);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlEntitiesTablePtr\n\t\t\txmlCopyEntitiesTable\t(xmlEntitiesTablePtr table);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\t\txmlFreeEntitiesTable\t(xmlEntitiesTablePtr table);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\t\txmlDumpEntitiesTable\t(xmlBufferPtr buf,\n\t\t\t\t\t\t xmlEntitiesTablePtr table);\nXMLPUBFUN void\n\t\t\txmlDumpEntityDecl\t(xmlBufferPtr buf,\n\t\t\t\t\t\t xmlEntityPtr ent);\n#endif /* LIBXML_OUTPUT_ENABLED */\n#ifdef LIBXML_LEGACY_ENABLED\nXMLPUBFUN void\n\t\t\txmlCleanupPredefinedEntities(void);\n#endif /* LIBXML_LEGACY_ENABLED */\n\n\n#ifdef __cplusplus\n}\n#endif\n\n# endif /* __XML_ENTITIES_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/globals.h",
    "content": "/*\n * Summary: interface for all global variables of the library\n * Description: all the global variables and thread handling for\n *              those variables is handled by this module.\n *\n * The bottom of this file is automatically generated by build_glob.py\n * based on the description file global.data\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Gary Pennington <Gary.Pennington@uk.sun.com>, Daniel Veillard\n */\n\n#ifndef __XML_GLOBALS_H\n#define __XML_GLOBALS_H\n\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n#include <libxml/xmlerror.h>\n#include <libxml/SAX2.h>\n#include <libxml/xmlmemory.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN void xmlInitGlobals(void);\nXML_DEPRECATED\nXMLPUBFUN void xmlCleanupGlobals(void);\n\n/**\n * xmlParserInputBufferCreateFilenameFunc:\n * @URI: the URI to read from\n * @enc: the requested source encoding\n *\n * Signature for the function doing the lookup for a suitable input method\n * corresponding to an URI.\n *\n * Returns the new xmlParserInputBufferPtr in case of success or NULL if no\n *         method was found.\n */\ntypedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI,\n\t\t\t\t\t\t\t\t\t   xmlCharEncoding enc);\n\n\n/**\n * xmlOutputBufferCreateFilenameFunc:\n * @URI: the URI to write to\n * @enc: the requested target encoding\n *\n * Signature for the function doing the lookup for a suitable output method\n * corresponding to an URI.\n *\n * Returns the new xmlOutputBufferPtr in case of success or NULL if no\n *         method was found.\n */\ntypedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI,\n\t\t\t\t\t\t\t\t xmlCharEncodingHandlerPtr encoder,\n\t\t\t\t\t\t\t\t int compression);\n\nXMLPUBFUN xmlParserInputBufferCreateFilenameFunc\nxmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);\nXMLPUBFUN xmlOutputBufferCreateFilenameFunc\nxmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func);\n\n/*\n * Externally global symbols which need to be protected for backwards\n * compatibility support.\n */\n\n#undef\thtmlDefaultSAXHandler\n#undef\toldXMLWDcompatibility\n#undef\txmlBufferAllocScheme\n#undef\txmlDefaultBufferSize\n#undef\txmlDefaultSAXHandler\n#undef\txmlDefaultSAXLocator\n#undef\txmlDoValidityCheckingDefaultValue\n#undef\txmlFree\n#undef\txmlGenericError\n#undef\txmlStructuredError\n#undef\txmlGenericErrorContext\n#undef\txmlStructuredErrorContext\n#undef\txmlGetWarningsDefaultValue\n#undef\txmlIndentTreeOutput\n#undef  xmlTreeIndentString\n#undef\txmlKeepBlanksDefaultValue\n#undef\txmlLineNumbersDefaultValue\n#undef\txmlLoadExtDtdDefaultValue\n#undef\txmlMalloc\n#undef\txmlMallocAtomic\n#undef\txmlMemStrdup\n#undef\txmlParserDebugEntities\n#undef\txmlParserVersion\n#undef\txmlPedanticParserDefaultValue\n#undef\txmlRealloc\n#undef\txmlSaveNoEmptyTags\n#undef\txmlSubstituteEntitiesDefaultValue\n#undef  xmlRegisterNodeDefaultValue\n#undef  xmlDeregisterNodeDefaultValue\n#undef  xmlLastError\n#undef  xmlParserInputBufferCreateFilenameValue\n#undef  xmlOutputBufferCreateFilenameValue\n\n/**\n * xmlRegisterNodeFunc:\n * @node: the current node\n *\n * Signature for the registration callback of a created node\n */\ntypedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);\n/**\n * xmlDeregisterNodeFunc:\n * @node: the current node\n *\n * Signature for the deregistration callback of a discarded node\n */\ntypedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);\n\ntypedef struct _xmlGlobalState xmlGlobalState;\ntypedef xmlGlobalState *xmlGlobalStatePtr;\nstruct _xmlGlobalState\n{\n\tconst char *xmlParserVersion;\n\n\txmlSAXLocator xmlDefaultSAXLocator;\n\txmlSAXHandlerV1 xmlDefaultSAXHandler;\n\txmlSAXHandlerV1 docbDefaultSAXHandler; /* unused */\n\txmlSAXHandlerV1 htmlDefaultSAXHandler;\n\n\txmlFreeFunc xmlFree;\n\txmlMallocFunc xmlMalloc;\n\txmlStrdupFunc xmlMemStrdup;\n\txmlReallocFunc xmlRealloc;\n\n\txmlGenericErrorFunc xmlGenericError;\n\txmlStructuredErrorFunc xmlStructuredError;\n\tvoid *xmlGenericErrorContext;\n\n\tint oldXMLWDcompatibility;\n\n\txmlBufferAllocationScheme xmlBufferAllocScheme;\n\tint xmlDefaultBufferSize;\n\n\tint xmlSubstituteEntitiesDefaultValue;\n\tint xmlDoValidityCheckingDefaultValue;\n\tint xmlGetWarningsDefaultValue;\n\tint xmlKeepBlanksDefaultValue;\n\tint xmlLineNumbersDefaultValue;\n\tint xmlLoadExtDtdDefaultValue;\n\tint xmlParserDebugEntities;\n\tint xmlPedanticParserDefaultValue;\n\n\tint xmlSaveNoEmptyTags;\n\tint xmlIndentTreeOutput;\n\tconst char *xmlTreeIndentString;\n\n\txmlRegisterNodeFunc xmlRegisterNodeDefaultValue;\n\txmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;\n\n\txmlMallocFunc xmlMallocAtomic;\n\txmlError xmlLastError;\n\n\txmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;\n\txmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;\n\n\tvoid *xmlStructuredErrorContext;\n};\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/threads.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nXMLPUBFUN void\txmlInitializeGlobalState(xmlGlobalStatePtr gs);\n\nXMLPUBFUN void xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);\n\nXMLPUBFUN void xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler);\n\nXMLPUBFUN xmlRegisterNodeFunc xmlRegisterNodeDefault(xmlRegisterNodeFunc func);\nXMLPUBFUN xmlRegisterNodeFunc xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);\nXMLPUBFUN xmlDeregisterNodeFunc xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);\nXMLPUBFUN xmlDeregisterNodeFunc xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);\n\nXMLPUBFUN xmlOutputBufferCreateFilenameFunc\n\txmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);\nXMLPUBFUN xmlParserInputBufferCreateFilenameFunc\n\txmlThrDefParserInputBufferCreateFilenameDefault(\n\t\t\t\txmlParserInputBufferCreateFilenameFunc func);\n\n/*\n * In general the memory allocation entry points are not kept\n * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED\n *    - xmlMalloc\n *    - xmlMallocAtomic\n *    - xmlRealloc\n *    - xmlMemStrdup\n *    - xmlFree\n */\n\n#ifdef LIBXML_THREAD_ALLOC_ENABLED\n/** DOC_DISABLE */\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlMallocFunc * __xmlMalloc(void);\n#define xmlMalloc \\\n(*(__xmlMalloc()))\n#else\nXMLPUBVAR xmlMallocFunc xmlMalloc;\n#endif\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlMallocFunc * __xmlMallocAtomic(void);\n#define xmlMallocAtomic \\\n(*(__xmlMallocAtomic()))\n#else\nXMLPUBVAR xmlMallocFunc xmlMallocAtomic;\n#endif\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlReallocFunc * __xmlRealloc(void);\n#define xmlRealloc \\\n(*(__xmlRealloc()))\n#else\nXMLPUBVAR xmlReallocFunc xmlRealloc;\n#endif\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlFreeFunc * __xmlFree(void);\n#define xmlFree \\\n(*(__xmlFree()))\n#else\nXMLPUBVAR xmlFreeFunc xmlFree;\n#endif\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlStrdupFunc * __xmlMemStrdup(void);\n#define xmlMemStrdup \\\n(*(__xmlMemStrdup()))\n#else\nXMLPUBVAR xmlStrdupFunc xmlMemStrdup;\n#endif\n\n/** DOC_ENABLE */\n#else /* !LIBXML_THREAD_ALLOC_ENABLED */\nXMLPUBVAR xmlMallocFunc xmlMalloc;\nXMLPUBVAR xmlMallocFunc xmlMallocAtomic;\nXMLPUBVAR xmlReallocFunc xmlRealloc;\nXMLPUBVAR xmlFreeFunc xmlFree;\nXMLPUBVAR xmlStrdupFunc xmlMemStrdup;\n#endif /* LIBXML_THREAD_ALLOC_ENABLED */\n\n#ifdef LIBXML_HTML_ENABLED\nXML_DEPRECATED\nXMLPUBFUN xmlSAXHandlerV1 * __htmlDefaultSAXHandler(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define htmlDefaultSAXHandler \\\n(*(__htmlDefaultSAXHandler()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler;\n#endif\n#endif\n\nXMLPUBFUN xmlError * __xmlLastError(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlLastError \\\n(*(__xmlLastError()))\n#else\nXMLPUBVAR xmlError xmlLastError;\n#endif\n\n/*\n * Everything starting from the line below is\n * Automatically generated by build_glob.py.\n * Do not modify the previous line.\n */\n\n\nXML_DEPRECATED\nXMLPUBFUN int * __oldXMLWDcompatibility(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define oldXMLWDcompatibility \\\n(*(__oldXMLWDcompatibility()))\n#else\nXML_DEPRECATED\nXMLPUBVAR int oldXMLWDcompatibility;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlBufferAllocationScheme * __xmlBufferAllocScheme(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlBufferAllocScheme \\\n(*(__xmlBufferAllocScheme()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;\n#endif\nXML_DEPRECATED\nXMLPUBFUN xmlBufferAllocationScheme\n\txmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);\n\nXML_DEPRECATED\nXMLPUBFUN int * __xmlDefaultBufferSize(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDefaultBufferSize \\\n(*(__xmlDefaultBufferSize()))\n#else\nXML_DEPRECATED\nXMLPUBVAR int xmlDefaultBufferSize;\n#endif\nXML_DEPRECATED\nXMLPUBFUN int xmlThrDefDefaultBufferSize(int v);\n\nXML_DEPRECATED\nXMLPUBFUN xmlSAXHandlerV1 * __xmlDefaultSAXHandler(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDefaultSAXHandler \\\n(*(__xmlDefaultSAXHandler()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlSAXLocator * __xmlDefaultSAXLocator(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDefaultSAXLocator \\\n(*(__xmlDefaultSAXLocator()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator;\n#endif\n\nXMLPUBFUN int * __xmlDoValidityCheckingDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDoValidityCheckingDefaultValue \\\n(*(__xmlDoValidityCheckingDefaultValue()))\n#else\nXMLPUBVAR int xmlDoValidityCheckingDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefDoValidityCheckingDefaultValue(int v);\n\nXMLPUBFUN xmlGenericErrorFunc * __xmlGenericError(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlGenericError \\\n(*(__xmlGenericError()))\n#else\nXMLPUBVAR xmlGenericErrorFunc xmlGenericError;\n#endif\n\nXMLPUBFUN xmlStructuredErrorFunc * __xmlStructuredError(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlStructuredError \\\n(*(__xmlStructuredError()))\n#else\nXMLPUBVAR xmlStructuredErrorFunc xmlStructuredError;\n#endif\n\nXMLPUBFUN void * * __xmlGenericErrorContext(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlGenericErrorContext \\\n(*(__xmlGenericErrorContext()))\n#else\nXMLPUBVAR void * xmlGenericErrorContext;\n#endif\n\nXMLPUBFUN void * * __xmlStructuredErrorContext(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlStructuredErrorContext \\\n(*(__xmlStructuredErrorContext()))\n#else\nXMLPUBVAR void * xmlStructuredErrorContext;\n#endif\n\nXMLPUBFUN int * __xmlGetWarningsDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlGetWarningsDefaultValue \\\n(*(__xmlGetWarningsDefaultValue()))\n#else\nXMLPUBVAR int xmlGetWarningsDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefGetWarningsDefaultValue(int v);\n\nXMLPUBFUN int * __xmlIndentTreeOutput(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlIndentTreeOutput \\\n(*(__xmlIndentTreeOutput()))\n#else\nXMLPUBVAR int xmlIndentTreeOutput;\n#endif\nXMLPUBFUN int xmlThrDefIndentTreeOutput(int v);\n\nXMLPUBFUN const char * * __xmlTreeIndentString(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlTreeIndentString \\\n(*(__xmlTreeIndentString()))\n#else\nXMLPUBVAR const char * xmlTreeIndentString;\n#endif\nXMLPUBFUN const char * xmlThrDefTreeIndentString(const char * v);\n\nXMLPUBFUN int * __xmlKeepBlanksDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlKeepBlanksDefaultValue \\\n(*(__xmlKeepBlanksDefaultValue()))\n#else\nXMLPUBVAR int xmlKeepBlanksDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefKeepBlanksDefaultValue(int v);\n\nXML_DEPRECATED\nXMLPUBFUN int * __xmlLineNumbersDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlLineNumbersDefaultValue \\\n(*(__xmlLineNumbersDefaultValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR int xmlLineNumbersDefaultValue;\n#endif\nXML_DEPRECATED\nXMLPUBFUN int xmlThrDefLineNumbersDefaultValue(int v);\n\nXMLPUBFUN int * __xmlLoadExtDtdDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlLoadExtDtdDefaultValue \\\n(*(__xmlLoadExtDtdDefaultValue()))\n#else\nXMLPUBVAR int xmlLoadExtDtdDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefLoadExtDtdDefaultValue(int v);\n\nXMLPUBFUN int * __xmlParserDebugEntities(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlParserDebugEntities \\\n(*(__xmlParserDebugEntities()))\n#else\nXMLPUBVAR int xmlParserDebugEntities;\n#endif\nXMLPUBFUN int xmlThrDefParserDebugEntities(int v);\n\nXMLPUBFUN const char * * __xmlParserVersion(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlParserVersion \\\n(*(__xmlParserVersion()))\n#else\nXMLPUBVAR const char * xmlParserVersion;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN int * __xmlPedanticParserDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlPedanticParserDefaultValue \\\n(*(__xmlPedanticParserDefaultValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR int xmlPedanticParserDefaultValue;\n#endif\nXML_DEPRECATED\nXMLPUBFUN int xmlThrDefPedanticParserDefaultValue(int v);\n\nXMLPUBFUN int * __xmlSaveNoEmptyTags(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlSaveNoEmptyTags \\\n(*(__xmlSaveNoEmptyTags()))\n#else\nXMLPUBVAR int xmlSaveNoEmptyTags;\n#endif\nXMLPUBFUN int xmlThrDefSaveNoEmptyTags(int v);\n\nXMLPUBFUN int * __xmlSubstituteEntitiesDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlSubstituteEntitiesDefaultValue \\\n(*(__xmlSubstituteEntitiesDefaultValue()))\n#else\nXMLPUBVAR int xmlSubstituteEntitiesDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefSubstituteEntitiesDefaultValue(int v);\n\nXML_DEPRECATED\nXMLPUBFUN xmlRegisterNodeFunc * __xmlRegisterNodeDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlRegisterNodeDefaultValue \\\n(*(__xmlRegisterNodeDefaultValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlDeregisterNodeFunc * __xmlDeregisterNodeDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDeregisterNodeDefaultValue \\\n(*(__xmlDeregisterNodeDefaultValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlParserInputBufferCreateFilenameFunc * \\\n\t\t\t\t__xmlParserInputBufferCreateFilenameValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlParserInputBufferCreateFilenameValue \\\n(*(__xmlParserInputBufferCreateFilenameValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlOutputBufferCreateFilenameFunc * __xmlOutputBufferCreateFilenameValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlOutputBufferCreateFilenameValue \\\n(*(__xmlOutputBufferCreateFilenameValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_GLOBALS_H */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/hash.h",
    "content": "/*\n * Summary: Chained hash tables\n * Description: This module implements the hash table support used in\n *\t\tvarious places in the library.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Bjorn Reese <bjorn.reese@systematic.dk>\n */\n\n#ifndef __XML_HASH_H__\n#define __XML_HASH_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The hash table.\n */\ntypedef struct _xmlHashTable xmlHashTable;\ntypedef xmlHashTable *xmlHashTablePtr;\n\n#ifdef __cplusplus\n}\n#endif\n\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n#include <libxml/dict.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Recent version of gcc produce a warning when a function pointer is assigned\n * to an object pointer, or vice versa.  The following macro is a dirty hack\n * to allow suppression of the warning.  If your architecture has function\n * pointers which are a different size than a void pointer, there may be some\n * serious trouble within the library.\n */\n/**\n * XML_CAST_FPTR:\n * @fptr:  pointer to a function\n *\n * Macro to do a casting from an object pointer to a\n * function pointer without encountering a warning from\n * gcc\n *\n * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))\n * This macro violated ISO C aliasing rules (gcc4 on s390 broke)\n * so it is disabled now\n */\n\n#define XML_CAST_FPTR(fptr) fptr\n\n\n/*\n * function types:\n */\n/**\n * xmlHashDeallocator:\n * @payload:  the data in the hash\n * @name:  the name associated\n *\n * Callback to free data from a hash.\n */\ntypedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);\n/**\n * xmlHashCopier:\n * @payload:  the data in the hash\n * @name:  the name associated\n *\n * Callback to copy data from a hash.\n *\n * Returns a copy of the data or NULL in case of error.\n */\ntypedef void *(*xmlHashCopier)(void *payload, const xmlChar *name);\n/**\n * xmlHashScanner:\n * @payload:  the data in the hash\n * @data:  extra scanner data\n * @name:  the name associated\n *\n * Callback when scanning data in a hash with the simple scanner.\n */\ntypedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name);\n/**\n * xmlHashScannerFull:\n * @payload:  the data in the hash\n * @data:  extra scanner data\n * @name:  the name associated\n * @name2:  the second name associated\n * @name3:  the third name associated\n *\n * Callback when scanning data in a hash with the full scanner.\n */\ntypedef void (*xmlHashScannerFull)(void *payload, void *data,\n\t\t\t\t   const xmlChar *name, const xmlChar *name2,\n\t\t\t\t   const xmlChar *name3);\n\n/*\n * Constructor and destructor.\n */\nXMLPUBFUN xmlHashTablePtr\n\t\t\txmlHashCreate\t(int size);\nXMLPUBFUN xmlHashTablePtr\n\t\t\txmlHashCreateDict(int size,\n\t\t\t\t\t xmlDictPtr dict);\nXMLPUBFUN void\n\t\t\txmlHashFree\t(xmlHashTablePtr table,\n\t\t\t\t\t xmlHashDeallocator f);\nXMLPUBFUN void\n\t\t\txmlHashDefaultDeallocator(void *entry,\n\t\t\t\t\t const xmlChar *name);\n\n/*\n * Add a new entry to the hash table.\n */\nXMLPUBFUN int\n\t\t\txmlHashAddEntry\t(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         void *userdata);\nXMLPUBFUN int\n\t\t\txmlHashUpdateEntry(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         void *userdata,\n\t\t\t\t\t xmlHashDeallocator f);\nXMLPUBFUN int\n\t\t\txmlHashAddEntry2(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         const xmlChar *name2,\n\t\t                         void *userdata);\nXMLPUBFUN int\n\t\t\txmlHashUpdateEntry2(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         const xmlChar *name2,\n\t\t                         void *userdata,\n\t\t\t\t\t xmlHashDeallocator f);\nXMLPUBFUN int\n\t\t\txmlHashAddEntry3(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         const xmlChar *name2,\n\t\t                         const xmlChar *name3,\n\t\t                         void *userdata);\nXMLPUBFUN int\n\t\t\txmlHashUpdateEntry3(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         const xmlChar *name2,\n\t\t                         const xmlChar *name3,\n\t\t                         void *userdata,\n\t\t\t\t\t xmlHashDeallocator f);\n\n/*\n * Remove an entry from the hash table.\n */\nXMLPUBFUN int\n\t\t\txmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,\n                           xmlHashDeallocator f);\nXMLPUBFUN int\n\t\t\txmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,\n                            const xmlChar *name2, xmlHashDeallocator f);\nXMLPUBFUN int \n\t\t\txmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,\n                            const xmlChar *name2, const xmlChar *name3,\n                            xmlHashDeallocator f);\n\n/*\n * Retrieve the userdata.\n */\nXMLPUBFUN void *\n\t\t\txmlHashLookup\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN void *\n\t\t\txmlHashLookup2\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *name2);\nXMLPUBFUN void *\n\t\t\txmlHashLookup3\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *name3);\nXMLPUBFUN void *\n\t\t\txmlHashQLookup\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN void *\n\t\t\txmlHashQLookup2\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *prefix2);\nXMLPUBFUN void *\n\t\t\txmlHashQLookup3\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *prefix2,\n\t\t\t\t\t const xmlChar *name3,\n\t\t\t\t\t const xmlChar *prefix3);\n\n/*\n * Helpers.\n */\nXMLPUBFUN xmlHashTablePtr\n\t\t\txmlHashCopy\t(xmlHashTablePtr table,\n\t\t\t\t\t xmlHashCopier f);\nXMLPUBFUN int\n\t\t\txmlHashSize\t(xmlHashTablePtr table);\nXMLPUBFUN void\n\t\t\txmlHashScan\t(xmlHashTablePtr table,\n\t\t\t\t\t xmlHashScanner f,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\t\txmlHashScan3\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *name3,\n\t\t\t\t\t xmlHashScanner f,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\t\txmlHashScanFull\t(xmlHashTablePtr table,\n\t\t\t\t\t xmlHashScannerFull f,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\t\txmlHashScanFull3(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *name3,\n\t\t\t\t\t xmlHashScannerFull f,\n\t\t\t\t\t void *data);\n#ifdef __cplusplus\n}\n#endif\n#endif /* ! __XML_HASH_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/list.h",
    "content": "/*\n * Summary: lists interfaces\n * Description: this module implement the list support used in\n * various place in the library.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Gary Pennington <Gary.Pennington@uk.sun.com>\n */\n\n#ifndef __XML_LINK_INCLUDE__\n#define __XML_LINK_INCLUDE__\n\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct _xmlLink xmlLink;\ntypedef xmlLink *xmlLinkPtr;\n\ntypedef struct _xmlList xmlList;\ntypedef xmlList *xmlListPtr;\n\n/**\n * xmlListDeallocator:\n * @lk:  the data to deallocate\n *\n * Callback function used to free data from a list.\n */\ntypedef void (*xmlListDeallocator) (xmlLinkPtr lk);\n/**\n * xmlListDataCompare:\n * @data0: the first data\n * @data1: the second data\n *\n * Callback function used to compare 2 data.\n *\n * Returns 0 is equality, -1 or 1 otherwise depending on the ordering.\n */\ntypedef int  (*xmlListDataCompare) (const void *data0, const void *data1);\n/**\n * xmlListWalker:\n * @data: the data found in the list\n * @user: extra user provided data to the walker\n *\n * Callback function used when walking a list with xmlListWalk().\n *\n * Returns 0 to stop walking the list, 1 otherwise.\n */\ntypedef int (*xmlListWalker) (const void *data, void *user);\n\n/* Creation/Deletion */\nXMLPUBFUN xmlListPtr\n\t\txmlListCreate\t\t(xmlListDeallocator deallocator,\n\t                                 xmlListDataCompare compare);\nXMLPUBFUN void\n\t\txmlListDelete\t\t(xmlListPtr l);\n\n/* Basic Operators */\nXMLPUBFUN void *\n\t\txmlListSearch\t\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN void *\n\t\txmlListReverseSearch\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\txmlListInsert\t\t(xmlListPtr l,\n\t\t\t\t\t void *data) ;\nXMLPUBFUN int\n\t\txmlListAppend\t\t(xmlListPtr l,\n\t\t\t\t\t void *data) ;\nXMLPUBFUN int\n\t\txmlListRemoveFirst\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\txmlListRemoveLast\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\txmlListRemoveAll\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\txmlListClear\t\t(xmlListPtr l);\nXMLPUBFUN int\n\t\txmlListEmpty\t\t(xmlListPtr l);\nXMLPUBFUN xmlLinkPtr\n\t\txmlListFront\t\t(xmlListPtr l);\nXMLPUBFUN xmlLinkPtr\n\t\txmlListEnd\t\t(xmlListPtr l);\nXMLPUBFUN int\n\t\txmlListSize\t\t(xmlListPtr l);\n\nXMLPUBFUN void\n\t\txmlListPopFront\t\t(xmlListPtr l);\nXMLPUBFUN void\n\t\txmlListPopBack\t\t(xmlListPtr l);\nXMLPUBFUN int\n\t\txmlListPushFront\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\txmlListPushBack\t\t(xmlListPtr l,\n\t\t\t\t\t void *data);\n\n/* Advanced Operators */\nXMLPUBFUN void\n\t\txmlListReverse\t\t(xmlListPtr l);\nXMLPUBFUN void\n\t\txmlListSort\t\t(xmlListPtr l);\nXMLPUBFUN void\n\t\txmlListWalk\t\t(xmlListPtr l,\n\t\t\t\t\t xmlListWalker walker,\n\t\t\t\t\t void *user);\nXMLPUBFUN void\n\t\txmlListReverseWalk\t(xmlListPtr l,\n\t\t\t\t\t xmlListWalker walker,\n\t\t\t\t\t void *user);\nXMLPUBFUN void\n\t\txmlListMerge\t\t(xmlListPtr l1,\n\t\t\t\t\t xmlListPtr l2);\nXMLPUBFUN xmlListPtr\n\t\txmlListDup\t\t(const xmlListPtr old);\nXMLPUBFUN int\n\t\txmlListCopy\t\t(xmlListPtr cur,\n\t\t\t\t\t const xmlListPtr old);\n/* Link operators */\nXMLPUBFUN void *\n\t\txmlLinkGetData          (xmlLinkPtr lk);\n\n/* xmlListUnique() */\n/* xmlListSwap */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_LINK_INCLUDE__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/nanoftp.h",
    "content": "/*\n * Summary: minimal FTP implementation\n * Description: minimal FTP implementation allowing to fetch resources\n *              like external subset. This module is DEPRECATED, do not\n *              use any of its functions.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __NANO_FTP_H__\n#define __NANO_FTP_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_FTP_ENABLED\n\n/* Needed for portability to Windows 64 bits */\n#if defined(_WIN32)\n#include <winsock2.h>\n#else\n/**\n * SOCKET:\n *\n * macro used to provide portability of code to windows sockets\n */\n#define SOCKET int\n/**\n * INVALID_SOCKET:\n *\n * macro used to provide portability of code to windows sockets\n * the value to be used when the socket is not valid\n */\n#undef  INVALID_SOCKET\n#define INVALID_SOCKET (-1)\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * ftpListCallback:\n * @userData:  user provided data for the callback\n * @filename:  the file name (including \"->\" when links are shown)\n * @attrib:  the attribute string\n * @owner:  the owner string\n * @group:  the group string\n * @size:  the file size\n * @links:  the link count\n * @year:  the year\n * @month:  the month\n * @day:  the day\n * @hour:  the hour\n * @minute:  the minute\n *\n * A callback for the xmlNanoFTPList command.\n * Note that only one of year and day:minute are specified.\n */\ntypedef void (*ftpListCallback) (void *userData,\n\t                         const char *filename, const char *attrib,\n\t                         const char *owner, const char *group,\n\t\t\t\t unsigned long size, int links, int year,\n\t\t\t\t const char *month, int day, int hour,\n\t\t\t\t int minute);\n/**\n * ftpDataCallback:\n * @userData: the user provided context\n * @data: the data received\n * @len: its size in bytes\n *\n * A callback for the xmlNanoFTPGet command.\n */\ntypedef void (*ftpDataCallback) (void *userData,\n\t\t\t\t const char *data,\n\t\t\t\t int len);\n\n/*\n * Init\n */\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPInit\t\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPCleanup\t(void);\n\n/*\n * Creating/freeing contexts.\n */\nXML_DEPRECATED\nXMLPUBFUN void *\n\txmlNanoFTPNewCtxt\t(const char *URL);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPFreeCtxt\t(void * ctx);\nXML_DEPRECATED\nXMLPUBFUN void *\n\txmlNanoFTPConnectTo\t(const char *server,\n\t\t\t\t int port);\n/*\n * Opening/closing session connections.\n */\nXML_DEPRECATED\nXMLPUBFUN void *\n\txmlNanoFTPOpen\t\t(const char *URL);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPConnect\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPClose\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPQuit\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPScanProxy\t(const char *URL);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPProxy\t\t(const char *host,\n\t\t\t\t int port,\n\t\t\t\t const char *user,\n\t\t\t\t const char *passwd,\n\t\t\t\t int type);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPUpdateURL\t(void *ctx,\n\t\t\t\t const char *URL);\n\n/*\n * Rather internal commands.\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPGetResponse\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPCheckResponse\t(void *ctx);\n\n/*\n * CD/DIR/GET handlers.\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPCwd\t\t(void *ctx,\n\t\t\t\t const char *directory);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPDele\t\t(void *ctx,\n\t\t\t\t const char *file);\n\nXML_DEPRECATED\nXMLPUBFUN SOCKET\n\txmlNanoFTPGetConnection\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPCloseConnection(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPList\t\t(void *ctx,\n\t\t\t\t ftpListCallback callback,\n\t\t\t\t void *userData,\n\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN SOCKET\n\txmlNanoFTPGetSocket\t(void *ctx,\n\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPGet\t\t(void *ctx,\n\t\t\t\t ftpDataCallback callback,\n\t\t\t\t void *userData,\n\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPRead\t\t(void *ctx,\n\t\t\t\t void *dest,\n\t\t\t\t int len);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* LIBXML_FTP_ENABLED */\n#endif /* __NANO_FTP_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/nanohttp.h",
    "content": "/*\n * Summary: minimal HTTP implementation\n * Description: minimal HTTP implementation allowing to fetch resources\n *              like external subset.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __NANO_HTTP_H__\n#define __NANO_HTTP_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_HTTP_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nXMLPUBFUN void\n\txmlNanoHTTPInit\t\t(void);\nXMLPUBFUN void\n\txmlNanoHTTPCleanup\t(void);\nXMLPUBFUN void\n\txmlNanoHTTPScanProxy\t(const char *URL);\nXMLPUBFUN int\n\txmlNanoHTTPFetch\t(const char *URL,\n\t\t\t\t const char *filename,\n\t\t\t\t char **contentType);\nXMLPUBFUN void *\n\txmlNanoHTTPMethod\t(const char *URL,\n\t\t\t\t const char *method,\n\t\t\t\t const char *input,\n\t\t\t\t char **contentType,\n\t\t\t\t const char *headers,\n\t\t\t\t int   ilen);\nXMLPUBFUN void *\n\txmlNanoHTTPMethodRedir\t(const char *URL,\n\t\t\t\t const char *method,\n\t\t\t\t const char *input,\n\t\t\t\t char **contentType,\n\t\t\t\t char **redir,\n\t\t\t\t const char *headers,\n\t\t\t\t int   ilen);\nXMLPUBFUN void *\n\txmlNanoHTTPOpen\t\t(const char *URL,\n\t\t\t\t char **contentType);\nXMLPUBFUN void *\n\txmlNanoHTTPOpenRedir\t(const char *URL,\n\t\t\t\t char **contentType,\n\t\t\t\t char **redir);\nXMLPUBFUN int\n\txmlNanoHTTPReturnCode\t(void *ctx);\nXMLPUBFUN const char *\n\txmlNanoHTTPAuthHeader\t(void *ctx);\nXMLPUBFUN const char *\n\txmlNanoHTTPRedir\t(void *ctx);\nXMLPUBFUN int\n\txmlNanoHTTPContentLength( void * ctx );\nXMLPUBFUN const char *\n\txmlNanoHTTPEncoding\t(void *ctx);\nXMLPUBFUN const char *\n\txmlNanoHTTPMimeType\t(void *ctx);\nXMLPUBFUN int\n\txmlNanoHTTPRead\t\t(void *ctx,\n\t\t\t\t void *dest,\n\t\t\t\t int len);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN int\n\txmlNanoHTTPSave\t\t(void *ctxt,\n\t\t\t\t const char *filename);\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN void\n\txmlNanoHTTPClose\t(void *ctx);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_HTTP_ENABLED */\n#endif /* __NANO_HTTP_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/parser.h",
    "content": "/*\n * Summary: the core parser module\n * Description: Interfaces, constants and types related to the XML parser\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_PARSER_H__\n#define __XML_PARSER_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/dict.h>\n#include <libxml/hash.h>\n#include <libxml/valid.h>\n#include <libxml/entities.h>\n#include <libxml/xmlerror.h>\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * XML_DEFAULT_VERSION:\n *\n * The default version of XML used: 1.0\n */\n#define XML_DEFAULT_VERSION\t\"1.0\"\n\n/**\n * xmlParserInput:\n *\n * An xmlParserInput is an input flow for the XML processor.\n * Each entity parsed is associated an xmlParserInput (except the\n * few predefined ones). This is the case both for internal entities\n * - in which case the flow is already completely in memory - or\n * external entities - in which case we use the buf structure for\n * progressive reading and I18N conversions to the internal UTF-8 format.\n */\n\n/**\n * xmlParserInputDeallocate:\n * @str:  the string to deallocate\n *\n * Callback for freeing some parser input allocations.\n */\ntypedef void (* xmlParserInputDeallocate)(xmlChar *str);\n\nstruct _xmlParserInput {\n    /* Input buffer */\n    xmlParserInputBufferPtr buf;      /* UTF-8 encoded buffer */\n\n    const char *filename;             /* The file analyzed, if any */\n    const char *directory;            /* the directory/base of the file */\n    const xmlChar *base;              /* Base of the array to parse */\n    const xmlChar *cur;               /* Current char being parsed */\n    const xmlChar *end;               /* end of the array to parse */\n    int length;                       /* length if known */\n    int line;                         /* Current line */\n    int col;                          /* Current column */\n    unsigned long consumed;           /* How many xmlChars already consumed */\n    xmlParserInputDeallocate free;    /* function to deallocate the base */\n    const xmlChar *encoding;          /* the encoding string for entity */\n    const xmlChar *version;           /* the version string for entity */\n    int standalone;                   /* Was that entity marked standalone */\n    int id;                           /* an unique identifier for the entity */\n    unsigned long parentConsumed;     /* consumed bytes from parents */\n    xmlEntityPtr entity;              /* entity, if any */\n};\n\n/**\n * xmlParserNodeInfo:\n *\n * The parser can be asked to collect Node information, i.e. at what\n * place in the file they were detected.\n * NOTE: This is off by default and not very well tested.\n */\ntypedef struct _xmlParserNodeInfo xmlParserNodeInfo;\ntypedef xmlParserNodeInfo *xmlParserNodeInfoPtr;\n\nstruct _xmlParserNodeInfo {\n  const struct _xmlNode* node;\n  /* Position & line # that text that created the node begins & ends on */\n  unsigned long begin_pos;\n  unsigned long begin_line;\n  unsigned long end_pos;\n  unsigned long end_line;\n};\n\ntypedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;\ntypedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;\nstruct _xmlParserNodeInfoSeq {\n  unsigned long maximum;\n  unsigned long length;\n  xmlParserNodeInfo* buffer;\n};\n\n/**\n * xmlParserInputState:\n *\n * The parser is now working also as a state based parser.\n * The recursive one use the state info for entities processing.\n */\ntypedef enum {\n    XML_PARSER_EOF = -1,\t/* nothing is to be parsed */\n    XML_PARSER_START = 0,\t/* nothing has been parsed */\n    XML_PARSER_MISC,\t\t/* Misc* before int subset */\n    XML_PARSER_PI,\t\t/* Within a processing instruction */\n    XML_PARSER_DTD,\t\t/* within some DTD content */\n    XML_PARSER_PROLOG,\t\t/* Misc* after internal subset */\n    XML_PARSER_COMMENT,\t\t/* within a comment */\n    XML_PARSER_START_TAG,\t/* within a start tag */\n    XML_PARSER_CONTENT,\t\t/* within the content */\n    XML_PARSER_CDATA_SECTION,\t/* within a CDATA section */\n    XML_PARSER_END_TAG,\t\t/* within a closing tag */\n    XML_PARSER_ENTITY_DECL,\t/* within an entity declaration */\n    XML_PARSER_ENTITY_VALUE,\t/* within an entity value in a decl */\n    XML_PARSER_ATTRIBUTE_VALUE,\t/* within an attribute value */\n    XML_PARSER_SYSTEM_LITERAL,\t/* within a SYSTEM value */\n    XML_PARSER_EPILOG,\t\t/* the Misc* after the last end tag */\n    XML_PARSER_IGNORE,\t\t/* within an IGNORED section */\n    XML_PARSER_PUBLIC_LITERAL\t/* within a PUBLIC value */\n} xmlParserInputState;\n\n/**\n * XML_DETECT_IDS:\n *\n * Bit in the loadsubset context field to tell to do ID/REFs lookups.\n * Use it to initialize xmlLoadExtDtdDefaultValue.\n */\n#define XML_DETECT_IDS\t\t2\n\n/**\n * XML_COMPLETE_ATTRS:\n *\n * Bit in the loadsubset context field to tell to do complete the\n * elements attributes lists with the ones defaulted from the DTDs.\n * Use it to initialize xmlLoadExtDtdDefaultValue.\n */\n#define XML_COMPLETE_ATTRS\t4\n\n/**\n * XML_SKIP_IDS:\n *\n * Bit in the loadsubset context field to tell to not do ID/REFs registration.\n * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.\n */\n#define XML_SKIP_IDS\t\t8\n\n/**\n * xmlParserMode:\n *\n * A parser can operate in various modes\n */\ntypedef enum {\n    XML_PARSE_UNKNOWN = 0,\n    XML_PARSE_DOM = 1,\n    XML_PARSE_SAX = 2,\n    XML_PARSE_PUSH_DOM = 3,\n    XML_PARSE_PUSH_SAX = 4,\n    XML_PARSE_READER = 5\n} xmlParserMode;\n\ntypedef struct _xmlStartTag xmlStartTag;\n\n/**\n * xmlParserCtxt:\n *\n * The parser context.\n * NOTE This doesn't completely define the parser state, the (current ?)\n *      design of the parser uses recursive function calls since this allow\n *      and easy mapping from the production rules of the specification\n *      to the actual code. The drawback is that the actual function call\n *      also reflect the parser state. However most of the parsing routines\n *      takes as the only argument the parser context pointer, so migrating\n *      to a state based parser for progressive parsing shouldn't be too hard.\n */\nstruct _xmlParserCtxt {\n    struct _xmlSAXHandler *sax;       /* The SAX handler */\n    void            *userData;        /* For SAX interface only, used by DOM build */\n    xmlDocPtr           myDoc;        /* the document being built */\n    int            wellFormed;        /* is the document well formed */\n    int       replaceEntities;        /* shall we replace entities ? */\n    const xmlChar    *version;        /* the XML version string */\n    const xmlChar   *encoding;        /* the declared encoding, if any */\n    int            standalone;        /* standalone document */\n    int                  html;        /* an HTML(1) document\n                                       * 3 is HTML after <head>\n                                       * 10 is HTML after <body>\n                                       */\n\n    /* Input stream stack */\n    xmlParserInputPtr  input;         /* Current input stream */\n    int                inputNr;       /* Number of current input streams */\n    int                inputMax;      /* Max number of input streams */\n    xmlParserInputPtr *inputTab;      /* stack of inputs */\n\n    /* Node analysis stack only used for DOM building */\n    xmlNodePtr         node;          /* Current parsed Node */\n    int                nodeNr;        /* Depth of the parsing stack */\n    int                nodeMax;       /* Max depth of the parsing stack */\n    xmlNodePtr        *nodeTab;       /* array of nodes */\n\n    int record_info;                  /* Whether node info should be kept */\n    xmlParserNodeInfoSeq node_seq;    /* info about each node parsed */\n\n    int errNo;                        /* error code */\n\n    int     hasExternalSubset;        /* reference and external subset */\n    int             hasPErefs;        /* the internal subset has PE refs */\n    int              external;        /* are we parsing an external entity */\n\n    int                 valid;        /* is the document valid */\n    int              validate;        /* shall we try to validate ? */\n    xmlValidCtxt        vctxt;        /* The validity context */\n\n    xmlParserInputState instate;      /* current type of input */\n    int                 token;        /* next char look-ahead */\n\n    char           *directory;        /* the data directory */\n\n    /* Node name stack */\n    const xmlChar     *name;          /* Current parsed Node */\n    int                nameNr;        /* Depth of the parsing stack */\n    int                nameMax;       /* Max depth of the parsing stack */\n    const xmlChar *   *nameTab;       /* array of nodes */\n\n    long               nbChars;       /* unused */\n    long            checkIndex;       /* used by progressive parsing lookup */\n    int             keepBlanks;       /* ugly but ... */\n    int             disableSAX;       /* SAX callbacks are disabled */\n    int               inSubset;       /* Parsing is in int 1/ext 2 subset */\n    const xmlChar *    intSubName;    /* name of subset */\n    xmlChar *          extSubURI;     /* URI of external subset */\n    xmlChar *          extSubSystem;  /* SYSTEM ID of external subset */\n\n    /* xml:space values */\n    int *              space;         /* Should the parser preserve spaces */\n    int                spaceNr;       /* Depth of the parsing stack */\n    int                spaceMax;      /* Max depth of the parsing stack */\n    int *              spaceTab;      /* array of space infos */\n\n    int                depth;         /* to prevent entity substitution loops */\n    xmlParserInputPtr  entity;        /* used to check entities boundaries */\n    int                charset;       /* encoding of the in-memory content\n\t\t\t\t         actually an xmlCharEncoding */\n    int                nodelen;       /* Those two fields are there to */\n    int                nodemem;       /* Speed up large node parsing */\n    int                pedantic;      /* signal pedantic warnings */\n    void              *_private;      /* For user data, libxml won't touch it */\n\n    int                loadsubset;    /* should the external subset be loaded */\n    int                linenumbers;   /* set line number in element content */\n    void              *catalogs;      /* document's own catalog */\n    int                recovery;      /* run in recovery mode */\n    int                progressive;   /* is this a progressive parsing */\n    xmlDictPtr         dict;          /* dictionary for the parser */\n    const xmlChar *   *atts;          /* array for the attributes callbacks */\n    int                maxatts;       /* the size of the array */\n    int                docdict;       /* use strings from dict to build tree */\n\n    /*\n     * pre-interned strings\n     */\n    const xmlChar *str_xml;\n    const xmlChar *str_xmlns;\n    const xmlChar *str_xml_ns;\n\n    /*\n     * Everything below is used only by the new SAX mode\n     */\n    int                sax2;          /* operating in the new SAX mode */\n    int                nsNr;          /* the number of inherited namespaces */\n    int                nsMax;         /* the size of the arrays */\n    const xmlChar *   *nsTab;         /* the array of prefix/namespace name */\n    int               *attallocs;     /* which attribute were allocated */\n    xmlStartTag       *pushTab;       /* array of data for push */\n    xmlHashTablePtr    attsDefault;   /* defaulted attributes if any */\n    xmlHashTablePtr    attsSpecial;   /* non-CDATA attributes if any */\n    int                nsWellFormed;  /* is the document XML Namespace okay */\n    int                options;       /* Extra options */\n\n    /*\n     * Those fields are needed only for streaming parsing so far\n     */\n    int               dictNames;    /* Use dictionary names for the tree */\n    int               freeElemsNr;  /* number of freed element nodes */\n    xmlNodePtr        freeElems;    /* List of freed element nodes */\n    int               freeAttrsNr;  /* number of freed attributes nodes */\n    xmlAttrPtr        freeAttrs;    /* List of freed attributes nodes */\n\n    /*\n     * the complete error information for the last error.\n     */\n    xmlError          lastError;\n    xmlParserMode     parseMode;    /* the parser mode */\n    unsigned long    nbentities;    /* unused */\n    unsigned long  sizeentities;    /* size of parsed entities */\n\n    /* for use by HTML non-recursive parser */\n    xmlParserNodeInfo *nodeInfo;      /* Current NodeInfo */\n    int                nodeInfoNr;    /* Depth of the parsing stack */\n    int                nodeInfoMax;   /* Max depth of the parsing stack */\n    xmlParserNodeInfo *nodeInfoTab;   /* array of nodeInfos */\n\n    int                input_id;      /* we need to label inputs */\n    unsigned long      sizeentcopy;   /* volume of entity copy */\n\n    int           endCheckState;    /* quote state for push parser */\n    unsigned short     nbErrors;    /* number of errors */\n    unsigned short   nbWarnings;    /* number of warnings */\n};\n\n/**\n * xmlSAXLocator:\n *\n * A SAX Locator.\n */\nstruct _xmlSAXLocator {\n    const xmlChar *(*getPublicId)(void *ctx);\n    const xmlChar *(*getSystemId)(void *ctx);\n    int (*getLineNumber)(void *ctx);\n    int (*getColumnNumber)(void *ctx);\n};\n\n/**\n * xmlSAXHandler:\n *\n * A SAX handler is bunch of callbacks called by the parser when processing\n * of the input generate data or structure information.\n */\n\n/**\n * resolveEntitySAXFunc:\n * @ctx:  the user data (XML parser context)\n * @publicId: The public ID of the entity\n * @systemId: The system ID of the entity\n *\n * Callback:\n * The entity loader, to control the loading of external entities,\n * the application can either:\n *    - override this resolveEntity() callback in the SAX block\n *    - or better use the xmlSetExternalEntityLoader() function to\n *      set up it's own entity resolution routine\n *\n * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.\n */\ntypedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *publicId,\n\t\t\t\tconst xmlChar *systemId);\n/**\n * internalSubsetSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  the root element name\n * @ExternalID:  the external ID\n * @SystemID:  the SYSTEM ID (e.g. filename or URL)\n *\n * Callback on internal subset declaration.\n */\ntypedef void (*internalSubsetSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *ExternalID,\n\t\t\t\tconst xmlChar *SystemID);\n/**\n * externalSubsetSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  the root element name\n * @ExternalID:  the external ID\n * @SystemID:  the SYSTEM ID (e.g. filename or URL)\n *\n * Callback on external subset declaration.\n */\ntypedef void (*externalSubsetSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *ExternalID,\n\t\t\t\tconst xmlChar *SystemID);\n/**\n * getEntitySAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name: The entity name\n *\n * Get an entity by name.\n *\n * Returns the xmlEntityPtr if found.\n */\ntypedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name);\n/**\n * getParameterEntitySAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name: The entity name\n *\n * Get a parameter entity by name.\n *\n * Returns the xmlEntityPtr if found.\n */\ntypedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name);\n/**\n * entityDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  the entity name\n * @type:  the entity type\n * @publicId: The public ID of the entity\n * @systemId: The system ID of the entity\n * @content: the entity value (without processing).\n *\n * An entity definition has been parsed.\n */\ntypedef void (*entityDeclSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tint type,\n\t\t\t\tconst xmlChar *publicId,\n\t\t\t\tconst xmlChar *systemId,\n\t\t\t\txmlChar *content);\n/**\n * notationDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name: The name of the notation\n * @publicId: The public ID of the entity\n * @systemId: The system ID of the entity\n *\n * What to do when a notation declaration has been parsed.\n */\ntypedef void (*notationDeclSAXFunc)(void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *publicId,\n\t\t\t\tconst xmlChar *systemId);\n/**\n * attributeDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @elem:  the name of the element\n * @fullname:  the attribute name\n * @type:  the attribute type\n * @def:  the type of default value\n * @defaultValue: the attribute default value\n * @tree:  the tree of enumerated value set\n *\n * An attribute definition has been parsed.\n */\ntypedef void (*attributeDeclSAXFunc)(void *ctx,\n\t\t\t\tconst xmlChar *elem,\n\t\t\t\tconst xmlChar *fullname,\n\t\t\t\tint type,\n\t\t\t\tint def,\n\t\t\t\tconst xmlChar *defaultValue,\n\t\t\t\txmlEnumerationPtr tree);\n/**\n * elementDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  the element name\n * @type:  the element type\n * @content: the element value tree\n *\n * An element definition has been parsed.\n */\ntypedef void (*elementDeclSAXFunc)(void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tint type,\n\t\t\t\txmlElementContentPtr content);\n/**\n * unparsedEntityDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name: The name of the entity\n * @publicId: The public ID of the entity\n * @systemId: The system ID of the entity\n * @notationName: the name of the notation\n *\n * What to do when an unparsed entity declaration is parsed.\n */\ntypedef void (*unparsedEntityDeclSAXFunc)(void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *publicId,\n\t\t\t\tconst xmlChar *systemId,\n\t\t\t\tconst xmlChar *notationName);\n/**\n * setDocumentLocatorSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @loc: A SAX Locator\n *\n * Receive the document locator at startup, actually xmlDefaultSAXLocator.\n * Everything is available on the context, so this is useless in our case.\n */\ntypedef void (*setDocumentLocatorSAXFunc) (void *ctx,\n\t\t\t\txmlSAXLocatorPtr loc);\n/**\n * startDocumentSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Called when the document start being processed.\n */\ntypedef void (*startDocumentSAXFunc) (void *ctx);\n/**\n * endDocumentSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Called when the document end has been detected.\n */\ntypedef void (*endDocumentSAXFunc) (void *ctx);\n/**\n * startElementSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  The element name, including namespace prefix\n * @atts:  An array of name/value attributes pairs, NULL terminated\n *\n * Called when an opening tag has been processed.\n */\ntypedef void (*startElementSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar **atts);\n/**\n * endElementSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  The element name\n *\n * Called when the end of an element has been detected.\n */\ntypedef void (*endElementSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name);\n/**\n * attributeSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  The attribute name, including namespace prefix\n * @value:  The attribute value\n *\n * Handle an attribute that has been read by the parser.\n * The default handling is to convert the attribute into an\n * DOM subtree and past it in a new xmlAttr element added to\n * the element.\n */\ntypedef void (*attributeSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *value);\n/**\n * referenceSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  The entity name\n *\n * Called when an entity reference is detected.\n */\ntypedef void (*referenceSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name);\n/**\n * charactersSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @ch:  a xmlChar string\n * @len: the number of xmlChar\n *\n * Receiving some chars from the parser.\n */\ntypedef void (*charactersSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *ch,\n\t\t\t\tint len);\n/**\n * ignorableWhitespaceSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @ch:  a xmlChar string\n * @len: the number of xmlChar\n *\n * Receiving some ignorable whitespaces from the parser.\n * UNUSED: by default the DOM building will use characters.\n */\ntypedef void (*ignorableWhitespaceSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *ch,\n\t\t\t\tint len);\n/**\n * processingInstructionSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @target:  the target name\n * @data: the PI data's\n *\n * A processing instruction has been parsed.\n */\ntypedef void (*processingInstructionSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *target,\n\t\t\t\tconst xmlChar *data);\n/**\n * commentSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @value:  the comment content\n *\n * A comment has been parsed.\n */\ntypedef void (*commentSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *value);\n/**\n * cdataBlockSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @value:  The pcdata content\n * @len:  the block length\n *\n * Called when a pcdata block has been parsed.\n */\ntypedef void (*cdataBlockSAXFunc) (\n\t                        void *ctx,\n\t\t\t\tconst xmlChar *value,\n\t\t\t\tint len);\n/**\n * warningSAXFunc:\n * @ctx:  an XML parser context\n * @msg:  the message to display/transmit\n * @...:  extra parameters for the message display\n *\n * Display and format a warning messages, callback.\n */\ntypedef void (*warningSAXFunc) (void *ctx,\n\t\t\t\tconst char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n/**\n * errorSAXFunc:\n * @ctx:  an XML parser context\n * @msg:  the message to display/transmit\n * @...:  extra parameters for the message display\n *\n * Display and format an error messages, callback.\n */\ntypedef void (*errorSAXFunc) (void *ctx,\n\t\t\t\tconst char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n/**\n * fatalErrorSAXFunc:\n * @ctx:  an XML parser context\n * @msg:  the message to display/transmit\n * @...:  extra parameters for the message display\n *\n * Display and format fatal error messages, callback.\n * Note: so far fatalError() SAX callbacks are not used, error()\n *       get all the callbacks for errors.\n */\ntypedef void (*fatalErrorSAXFunc) (void *ctx,\n\t\t\t\tconst char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n/**\n * isStandaloneSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Is this document tagged standalone?\n *\n * Returns 1 if true\n */\ntypedef int (*isStandaloneSAXFunc) (void *ctx);\n/**\n * hasInternalSubsetSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Does this document has an internal subset.\n *\n * Returns 1 if true\n */\ntypedef int (*hasInternalSubsetSAXFunc) (void *ctx);\n\n/**\n * hasExternalSubsetSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Does this document has an external subset?\n *\n * Returns 1 if true\n */\ntypedef int (*hasExternalSubsetSAXFunc) (void *ctx);\n\n/************************************************************************\n *\t\t\t\t\t\t\t\t\t*\n *\t\t\tThe SAX version 2 API extensions\t\t*\n *\t\t\t\t\t\t\t\t\t*\n ************************************************************************/\n/**\n * XML_SAX2_MAGIC:\n *\n * Special constant found in SAX2 blocks initialized fields\n */\n#define XML_SAX2_MAGIC 0xDEEDBEAF\n\n/**\n * startElementNsSAX2Func:\n * @ctx:  the user data (XML parser context)\n * @localname:  the local name of the element\n * @prefix:  the element namespace prefix if available\n * @URI:  the element namespace name if available\n * @nb_namespaces:  number of namespace definitions on that node\n * @namespaces:  pointer to the array of prefix/URI pairs namespace definitions\n * @nb_attributes:  the number of attributes on that node\n * @nb_defaulted:  the number of defaulted attributes. The defaulted\n *                  ones are at the end of the array\n * @attributes:  pointer to the array of (localname/prefix/URI/value/end)\n *               attribute values.\n *\n * SAX2 callback when an element start has been detected by the parser.\n * It provides the namespace information for the element, as well as\n * the new namespace declarations on the element.\n */\n\ntypedef void (*startElementNsSAX2Func) (void *ctx,\n\t\t\t\t\tconst xmlChar *localname,\n\t\t\t\t\tconst xmlChar *prefix,\n\t\t\t\t\tconst xmlChar *URI,\n\t\t\t\t\tint nb_namespaces,\n\t\t\t\t\tconst xmlChar **namespaces,\n\t\t\t\t\tint nb_attributes,\n\t\t\t\t\tint nb_defaulted,\n\t\t\t\t\tconst xmlChar **attributes);\n\n/**\n * endElementNsSAX2Func:\n * @ctx:  the user data (XML parser context)\n * @localname:  the local name of the element\n * @prefix:  the element namespace prefix if available\n * @URI:  the element namespace name if available\n *\n * SAX2 callback when an element end has been detected by the parser.\n * It provides the namespace information for the element.\n */\n\ntypedef void (*endElementNsSAX2Func)   (void *ctx,\n\t\t\t\t\tconst xmlChar *localname,\n\t\t\t\t\tconst xmlChar *prefix,\n\t\t\t\t\tconst xmlChar *URI);\n\n\nstruct _xmlSAXHandler {\n    internalSubsetSAXFunc internalSubset;\n    isStandaloneSAXFunc isStandalone;\n    hasInternalSubsetSAXFunc hasInternalSubset;\n    hasExternalSubsetSAXFunc hasExternalSubset;\n    resolveEntitySAXFunc resolveEntity;\n    getEntitySAXFunc getEntity;\n    entityDeclSAXFunc entityDecl;\n    notationDeclSAXFunc notationDecl;\n    attributeDeclSAXFunc attributeDecl;\n    elementDeclSAXFunc elementDecl;\n    unparsedEntityDeclSAXFunc unparsedEntityDecl;\n    setDocumentLocatorSAXFunc setDocumentLocator;\n    startDocumentSAXFunc startDocument;\n    endDocumentSAXFunc endDocument;\n    startElementSAXFunc startElement;\n    endElementSAXFunc endElement;\n    referenceSAXFunc reference;\n    charactersSAXFunc characters;\n    ignorableWhitespaceSAXFunc ignorableWhitespace;\n    processingInstructionSAXFunc processingInstruction;\n    commentSAXFunc comment;\n    warningSAXFunc warning;\n    errorSAXFunc error;\n    fatalErrorSAXFunc fatalError; /* unused error() get all the errors */\n    getParameterEntitySAXFunc getParameterEntity;\n    cdataBlockSAXFunc cdataBlock;\n    externalSubsetSAXFunc externalSubset;\n    unsigned int initialized;\n    /* The following fields are extensions available only on version 2 */\n    void *_private;\n    startElementNsSAX2Func startElementNs;\n    endElementNsSAX2Func endElementNs;\n    xmlStructuredErrorFunc serror;\n};\n\n/*\n * SAX Version 1\n */\ntypedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;\ntypedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;\nstruct _xmlSAXHandlerV1 {\n    internalSubsetSAXFunc internalSubset;\n    isStandaloneSAXFunc isStandalone;\n    hasInternalSubsetSAXFunc hasInternalSubset;\n    hasExternalSubsetSAXFunc hasExternalSubset;\n    resolveEntitySAXFunc resolveEntity;\n    getEntitySAXFunc getEntity;\n    entityDeclSAXFunc entityDecl;\n    notationDeclSAXFunc notationDecl;\n    attributeDeclSAXFunc attributeDecl;\n    elementDeclSAXFunc elementDecl;\n    unparsedEntityDeclSAXFunc unparsedEntityDecl;\n    setDocumentLocatorSAXFunc setDocumentLocator;\n    startDocumentSAXFunc startDocument;\n    endDocumentSAXFunc endDocument;\n    startElementSAXFunc startElement;\n    endElementSAXFunc endElement;\n    referenceSAXFunc reference;\n    charactersSAXFunc characters;\n    ignorableWhitespaceSAXFunc ignorableWhitespace;\n    processingInstructionSAXFunc processingInstruction;\n    commentSAXFunc comment;\n    warningSAXFunc warning;\n    errorSAXFunc error;\n    fatalErrorSAXFunc fatalError; /* unused error() get all the errors */\n    getParameterEntitySAXFunc getParameterEntity;\n    cdataBlockSAXFunc cdataBlock;\n    externalSubsetSAXFunc externalSubset;\n    unsigned int initialized;\n};\n\n\n/**\n * xmlExternalEntityLoader:\n * @URL: The System ID of the resource requested\n * @ID: The Public ID of the resource requested\n * @context: the XML parser context\n *\n * External entity loaders types.\n *\n * Returns the entity input parser.\n */\ntypedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,\n\t\t\t\t\t const char *ID,\n\t\t\t\t\t xmlParserCtxtPtr context);\n\n#ifdef __cplusplus\n}\n#endif\n\n#include <libxml/encoding.h>\n#include <libxml/xmlIO.h>\n#include <libxml/globals.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*\n * Init/Cleanup\n */\nXMLPUBFUN void\n\t\txmlInitParser\t\t(void);\nXMLPUBFUN void\n\t\txmlCleanupParser\t(void);\n\n/*\n * Input functions\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlParserInputRead\t(xmlParserInputPtr in,\n\t\t\t\t\t int len);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlParserInputGrow\t(xmlParserInputPtr in,\n\t\t\t\t\t int len);\n\n/*\n * Basic parsing Interfaces\n */\n#ifdef LIBXML_SAX1_ENABLED\nXMLPUBFUN xmlDocPtr\n\t\txmlParseDoc\t\t(const xmlChar *cur);\nXMLPUBFUN xmlDocPtr\n\t\txmlParseFile\t\t(const char *filename);\nXMLPUBFUN xmlDocPtr\n\t\txmlParseMemory\t\t(const char *buffer,\n\t\t\t\t\t int size);\n#endif /* LIBXML_SAX1_ENABLED */\nXMLPUBFUN int\n\t\txmlSubstituteEntitiesDefault(int val);\nXMLPUBFUN int\n\t\txmlKeepBlanksDefault\t(int val);\nXMLPUBFUN void\n\t\txmlStopParser\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlPedanticParserDefault(int val);\nXMLPUBFUN int\n\t\txmlLineNumbersDefault\t(int val);\n\n#ifdef LIBXML_SAX1_ENABLED\n/*\n * Recovery mode\n */\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlRecoverDoc\t\t(const xmlChar *cur);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlRecoverMemory\t(const char *buffer,\n\t\t\t\t\t int size);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlRecoverFile\t\t(const char *filename);\n#endif /* LIBXML_SAX1_ENABLED */\n\n/*\n * Less common routines and SAX interfaces\n */\nXMLPUBFUN int\n\t\txmlParseDocument\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlParseExtParsedEnt\t(xmlParserCtxtPtr ctxt);\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlSAXUserParseFile\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlSAXUserParseMemory\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseDoc\t\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const xmlChar *cur,\n\t\t\t\t\t int recovery);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseMemory\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t int recovery);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t int recovery,\n\t\t\t\t\t void *data);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseFile\t\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t int recovery);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseFileWithData\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t int recovery,\n\t\t\t\t\t void *data);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseEntity\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlParseEntity\t\t(const char *filename);\n#endif /* LIBXML_SAX1_ENABLED */\n\n#ifdef LIBXML_VALID_ENABLED\nXML_DEPRECATED\nXMLPUBFUN xmlDtdPtr\n\t\txmlSAXParseDTD\t\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlDtdPtr\n\t\txmlParseDTD\t\t(const xmlChar *ExternalID,\n\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlDtdPtr\n\t\txmlIOParseDTD\t\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t xmlParserInputBufferPtr input,\n\t\t\t\t\t xmlCharEncoding enc);\n#endif /* LIBXML_VALID_ENABLE */\n#ifdef LIBXML_SAX1_ENABLED\nXMLPUBFUN int\n\t\txmlParseBalancedChunkMemory(xmlDocPtr doc,\n\t\t\t\t\t xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t int depth,\n\t\t\t\t\t const xmlChar *string,\n\t\t\t\t\t xmlNodePtr *lst);\n#endif /* LIBXML_SAX1_ENABLED */\nXMLPUBFUN xmlParserErrors\n\t\txmlParseInNodeContext\t(xmlNodePtr node,\n\t\t\t\t\t const char *data,\n\t\t\t\t\t int datalen,\n\t\t\t\t\t int options,\n\t\t\t\t\t xmlNodePtr *lst);\n#ifdef LIBXML_SAX1_ENABLED\nXMLPUBFUN int\n\t\txmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,\n                     xmlSAXHandlerPtr sax,\n                     void *user_data,\n                     int depth,\n                     const xmlChar *string,\n                     xmlNodePtr *lst,\n                     int recover);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlParseExternalEntity\t(xmlDocPtr doc,\n\t\t\t\t\t xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t int depth,\n\t\t\t\t\t const xmlChar *URL,\n\t\t\t\t\t const xmlChar *ID,\n\t\t\t\t\t xmlNodePtr *lst);\n#endif /* LIBXML_SAX1_ENABLED */\nXMLPUBFUN int\n\t\txmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,\n\t\t\t\t\t const xmlChar *URL,\n\t\t\t\t\t const xmlChar *ID,\n\t\t\t\t\t xmlNodePtr *lst);\n\n/*\n * Parser contexts handling.\n */\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlNewParserCtxt\t(void);\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlNewSAXParserCtxt\t(const xmlSAXHandler *sax,\n\t\t\t\t\t void *userData);\nXMLPUBFUN int\n\t\txmlInitParserCtxt\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\txmlClearParserCtxt\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\txmlFreeParserCtxt\t(xmlParserCtxtPtr ctxt);\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlSetupParserForBuffer\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar* buffer,\n\t\t\t\t\t const char *filename);\n#endif /* LIBXML_SAX1_ENABLED */\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlCreateDocParserCtxt\t(const xmlChar *cur);\n\n#ifdef LIBXML_LEGACY_ENABLED\n/*\n * Reading/setting optional parsing features.\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlGetFeaturesList\t(int *len,\n\t\t\t\t\t const char **result);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlGetFeature\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *name,\n\t\t\t\t\t void *result);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlSetFeature\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *name,\n\t\t\t\t\t void *value);\n#endif /* LIBXML_LEGACY_ENABLED */\n\n#ifdef LIBXML_PUSH_ENABLED\n/*\n * Interfaces for the Push mode.\n */\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t const char *chunk,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *filename);\nXMLPUBFUN int\n\t\txmlParseChunk\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *chunk,\n\t\t\t\t\t int size,\n\t\t\t\t\t int terminate);\n#endif /* LIBXML_PUSH_ENABLED */\n\n/*\n * Special I/O mode.\n */\n\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlCreateIOParserCtxt\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t xmlInputReadCallback   ioread,\n\t\t\t\t\t xmlInputCloseCallback  ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t xmlCharEncoding enc);\n\nXMLPUBFUN xmlParserInputPtr\n\t\txmlNewIOInputStream\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlParserInputBufferPtr input,\n\t\t\t\t\t xmlCharEncoding enc);\n\n/*\n * Node infos.\n */\nXMLPUBFUN const xmlParserNodeInfo*\n\t\txmlParserFindNodeInfo\t(const xmlParserCtxtPtr ctxt,\n\t\t\t\t         const xmlNodePtr node);\nXMLPUBFUN void\n\t\txmlInitNodeInfoSeq\t(xmlParserNodeInfoSeqPtr seq);\nXMLPUBFUN void\n\t\txmlClearNodeInfoSeq\t(xmlParserNodeInfoSeqPtr seq);\nXMLPUBFUN unsigned long\n\t\txmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,\n                                         const xmlNodePtr node);\nXMLPUBFUN void\n\t\txmlParserAddNodeInfo\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlParserNodeInfoPtr info);\n\n/*\n * External entities handling actually implemented in xmlIO.\n */\n\nXMLPUBFUN void\n\t\txmlSetExternalEntityLoader(xmlExternalEntityLoader f);\nXMLPUBFUN xmlExternalEntityLoader\n\t\txmlGetExternalEntityLoader(void);\nXMLPUBFUN xmlParserInputPtr\n\t\txmlLoadExternalEntity\t(const char *URL,\n\t\t\t\t\t const char *ID,\n\t\t\t\t\t xmlParserCtxtPtr ctxt);\n\n/*\n * Index lookup, actually implemented in the encoding module\n */\nXMLPUBFUN long\n\t\txmlByteConsumed\t\t(xmlParserCtxtPtr ctxt);\n\n/*\n * New set of simpler/more flexible APIs\n */\n/**\n * xmlParserOption:\n *\n * This is the set of XML parser options that can be passed down\n * to the xmlReadDoc() and similar calls.\n */\ntypedef enum {\n    XML_PARSE_RECOVER\t= 1<<0,\t/* recover on errors */\n    XML_PARSE_NOENT\t= 1<<1,\t/* substitute entities */\n    XML_PARSE_DTDLOAD\t= 1<<2,\t/* load the external subset */\n    XML_PARSE_DTDATTR\t= 1<<3,\t/* default DTD attributes */\n    XML_PARSE_DTDVALID\t= 1<<4,\t/* validate with the DTD */\n    XML_PARSE_NOERROR\t= 1<<5,\t/* suppress error reports */\n    XML_PARSE_NOWARNING\t= 1<<6,\t/* suppress warning reports */\n    XML_PARSE_PEDANTIC\t= 1<<7,\t/* pedantic error reporting */\n    XML_PARSE_NOBLANKS\t= 1<<8,\t/* remove blank nodes */\n    XML_PARSE_SAX1\t= 1<<9,\t/* use the SAX1 interface internally */\n    XML_PARSE_XINCLUDE\t= 1<<10,/* Implement XInclude substitution  */\n    XML_PARSE_NONET\t= 1<<11,/* Forbid network access */\n    XML_PARSE_NODICT\t= 1<<12,/* Do not reuse the context dictionary */\n    XML_PARSE_NSCLEAN\t= 1<<13,/* remove redundant namespaces declarations */\n    XML_PARSE_NOCDATA\t= 1<<14,/* merge CDATA as text nodes */\n    XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */\n    XML_PARSE_COMPACT   = 1<<16,/* compact small text nodes; no modification of\n                                   the tree allowed afterwards (will possibly\n\t\t\t\t   crash if you try to modify the tree) */\n    XML_PARSE_OLD10\t= 1<<17,/* parse using XML-1.0 before update 5 */\n    XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */\n    XML_PARSE_HUGE      = 1<<19,/* relax any hardcoded limit from the parser */\n    XML_PARSE_OLDSAX    = 1<<20,/* parse using SAX2 interface before 2.7.0 */\n    XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */\n    XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */\n} xmlParserOption;\n\nXMLPUBFUN void\n\t\txmlCtxtReset\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlCtxtResetPush\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *chunk,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN int\n\t\txmlCtxtUseOptions\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadDoc\t\t(const xmlChar *cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadFile\t\t(const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadMemory\t\t(const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadFd\t\t(int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadIO\t\t(xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadDoc\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadFile\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadMemory\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadFd\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadIO\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\n/*\n * Library wide options\n */\n/**\n * xmlFeature:\n *\n * Used to examine the existence of features that can be enabled\n * or disabled at compile-time.\n * They used to be called XML_FEATURE_xxx but this clashed with Expat\n */\ntypedef enum {\n    XML_WITH_THREAD = 1,\n    XML_WITH_TREE = 2,\n    XML_WITH_OUTPUT = 3,\n    XML_WITH_PUSH = 4,\n    XML_WITH_READER = 5,\n    XML_WITH_PATTERN = 6,\n    XML_WITH_WRITER = 7,\n    XML_WITH_SAX1 = 8,\n    XML_WITH_FTP = 9,\n    XML_WITH_HTTP = 10,\n    XML_WITH_VALID = 11,\n    XML_WITH_HTML = 12,\n    XML_WITH_LEGACY = 13,\n    XML_WITH_C14N = 14,\n    XML_WITH_CATALOG = 15,\n    XML_WITH_XPATH = 16,\n    XML_WITH_XPTR = 17,\n    XML_WITH_XINCLUDE = 18,\n    XML_WITH_ICONV = 19,\n    XML_WITH_ISO8859X = 20,\n    XML_WITH_UNICODE = 21,\n    XML_WITH_REGEXP = 22,\n    XML_WITH_AUTOMATA = 23,\n    XML_WITH_EXPR = 24,\n    XML_WITH_SCHEMAS = 25,\n    XML_WITH_SCHEMATRON = 26,\n    XML_WITH_MODULES = 27,\n    XML_WITH_DEBUG = 28,\n    XML_WITH_DEBUG_MEM = 29,\n    XML_WITH_DEBUG_RUN = 30,\n    XML_WITH_ZLIB = 31,\n    XML_WITH_ICU = 32,\n    XML_WITH_LZMA = 33,\n    XML_WITH_NONE = 99999 /* just to be sure of allocation size */\n} xmlFeature;\n\nXMLPUBFUN int\n\t\txmlHasFeature\t\t(xmlFeature feature);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_PARSER_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/parserInternals.h",
    "content": "/*\n * Summary: internals routines and limits exported by the parser.\n * Description: this module exports a number of internal parsing routines\n *              they are not really all intended for applications but\n *              can prove useful doing low level processing.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_PARSER_INTERNALS_H__\n#define __XML_PARSER_INTERNALS_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n#include <libxml/HTMLparser.h>\n#include <libxml/chvalid.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlParserMaxDepth:\n *\n * arbitrary depth limit for the XML documents that we allow to\n * process. This is not a limitation of the parser but a safety\n * boundary feature, use XML_PARSE_HUGE option to override it.\n */\nXMLPUBVAR unsigned int xmlParserMaxDepth;\n\n/**\n * XML_MAX_TEXT_LENGTH:\n *\n * Maximum size allowed for a single text node when building a tree.\n * This is not a limitation of the parser but a safety boundary feature,\n * use XML_PARSE_HUGE option to override it.\n * Introduced in 2.9.0\n */\n#define XML_MAX_TEXT_LENGTH 10000000\n\n/**\n * XML_MAX_HUGE_LENGTH:\n *\n * Maximum size allowed when XML_PARSE_HUGE is set.\n */\n#define XML_MAX_HUGE_LENGTH 1000000000\n\n/**\n * XML_MAX_NAME_LENGTH:\n *\n * Maximum size allowed for a markup identifier.\n * This is not a limitation of the parser but a safety boundary feature,\n * use XML_PARSE_HUGE option to override it.\n * Note that with the use of parsing dictionaries overriding the limit\n * may result in more runtime memory usage in face of \"unfriendly' content\n * Introduced in 2.9.0\n */\n#define XML_MAX_NAME_LENGTH 50000\n\n/**\n * XML_MAX_DICTIONARY_LIMIT:\n *\n * Maximum size allowed by the parser for a dictionary by default\n * This is not a limitation of the parser but a safety boundary feature,\n * use XML_PARSE_HUGE option to override it.\n * Introduced in 2.9.0\n */\n#define XML_MAX_DICTIONARY_LIMIT 10000000\n\n/**\n * XML_MAX_LOOKUP_LIMIT:\n *\n * Maximum size allowed by the parser for ahead lookup\n * This is an upper boundary enforced by the parser to avoid bad\n * behaviour on \"unfriendly' content\n * Introduced in 2.9.0\n */\n#define XML_MAX_LOOKUP_LIMIT 10000000\n\n/**\n * XML_MAX_NAMELEN:\n *\n * Identifiers can be longer, but this will be more costly\n * at runtime.\n */\n#define XML_MAX_NAMELEN 100\n\n/**\n * INPUT_CHUNK:\n *\n * The parser tries to always have that amount of input ready.\n * One of the point is providing context when reporting errors.\n */\n#define INPUT_CHUNK\t250\n\n/************************************************************************\n *\t\t\t\t\t\t\t\t\t*\n * UNICODE version of the macros.\t\t\t\t\t*\n *\t\t\t\t\t\t\t\t\t*\n ************************************************************************/\n/**\n * IS_BYTE_CHAR:\n * @c:  an byte value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [2] Char ::= #x9 | #xA | #xD | [#x20...]\n * any byte character in the accepted range\n */\n#define IS_BYTE_CHAR(c)\t xmlIsChar_ch(c)\n\n/**\n * IS_CHAR:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]\n *                  | [#x10000-#x10FFFF]\n * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.\n */\n#define IS_CHAR(c)   xmlIsCharQ(c)\n\n/**\n * IS_CHAR_CH:\n * @c: an xmlChar (usually an unsigned char)\n *\n * Behaves like IS_CHAR on single-byte value\n */\n#define IS_CHAR_CH(c)  xmlIsChar_ch(c)\n\n/**\n * IS_BLANK:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [3] S ::= (#x20 | #x9 | #xD | #xA)+\n */\n#define IS_BLANK(c)  xmlIsBlankQ(c)\n\n/**\n * IS_BLANK_CH:\n * @c:  an xmlChar value (normally unsigned char)\n *\n * Behaviour same as IS_BLANK\n */\n#define IS_BLANK_CH(c)  xmlIsBlank_ch(c)\n\n/**\n * IS_BASECHAR:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [85] BaseChar ::= ... long list see REC ...\n */\n#define IS_BASECHAR(c) xmlIsBaseCharQ(c)\n\n/**\n * IS_DIGIT:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [88] Digit ::= ... long list see REC ...\n */\n#define IS_DIGIT(c) xmlIsDigitQ(c)\n\n/**\n * IS_DIGIT_CH:\n * @c:  an xmlChar value (usually an unsigned char)\n *\n * Behaves like IS_DIGIT but with a single byte argument\n */\n#define IS_DIGIT_CH(c)  xmlIsDigit_ch(c)\n\n/**\n * IS_COMBINING:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [87] CombiningChar ::= ... long list see REC ...\n */\n#define IS_COMBINING(c) xmlIsCombiningQ(c)\n\n/**\n * IS_COMBINING_CH:\n * @c:  an xmlChar (usually an unsigned char)\n *\n * Always false (all combining chars > 0xff)\n */\n#define IS_COMBINING_CH(c) 0\n\n/**\n * IS_EXTENDER:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n *\n * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |\n *                   #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] |\n *                   [#x309D-#x309E] | [#x30FC-#x30FE]\n */\n#define IS_EXTENDER(c) xmlIsExtenderQ(c)\n\n/**\n * IS_EXTENDER_CH:\n * @c:  an xmlChar value (usually an unsigned char)\n *\n * Behaves like IS_EXTENDER but with a single-byte argument\n */\n#define IS_EXTENDER_CH(c)  xmlIsExtender_ch(c)\n\n/**\n * IS_IDEOGRAPHIC:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n *\n * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]\n */\n#define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c)\n\n/**\n * IS_LETTER:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n *\n * [84] Letter ::= BaseChar | Ideographic\n */\n#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))\n\n/**\n * IS_LETTER_CH:\n * @c:  an xmlChar value (normally unsigned char)\n *\n * Macro behaves like IS_LETTER, but only check base chars\n *\n */\n#define IS_LETTER_CH(c) xmlIsBaseChar_ch(c)\n\n/**\n * IS_ASCII_LETTER:\n * @c: an xmlChar value\n *\n * Macro to check [a-zA-Z]\n *\n */\n#define IS_ASCII_LETTER(c)\t(((0x41 <= (c)) && ((c) <= 0x5a)) || \\\n\t\t\t\t ((0x61 <= (c)) && ((c) <= 0x7a)))\n\n/**\n * IS_ASCII_DIGIT:\n * @c: an xmlChar value\n *\n * Macro to check [0-9]\n *\n */\n#define IS_ASCII_DIGIT(c)\t((0x30 <= (c)) && ((c) <= 0x39))\n\n/**\n * IS_PUBIDCHAR:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n *\n * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]\n */\n#define IS_PUBIDCHAR(c)\txmlIsPubidCharQ(c)\n\n/**\n * IS_PUBIDCHAR_CH:\n * @c:  an xmlChar value (normally unsigned char)\n *\n * Same as IS_PUBIDCHAR but for single-byte value\n */\n#define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c)\n\n/**\n * Global variables used for predefined strings.\n */\nXMLPUBVAR const xmlChar xmlStringText[];\nXMLPUBVAR const xmlChar xmlStringTextNoenc[];\nXMLPUBVAR const xmlChar xmlStringComment[];\n\n/*\n * Function to finish the work of the macros where needed.\n */\nXMLPUBFUN int                   xmlIsLetter     (int c);\n\n/**\n * Parser context.\n */\nXMLPUBFUN xmlParserCtxtPtr\n\t\t\txmlCreateFileParserCtxt\t(const char *filename);\nXMLPUBFUN xmlParserCtxtPtr\n\t\t\txmlCreateURLParserCtxt\t(const char *filename,\n\t\t\t\t\t\t int options);\nXMLPUBFUN xmlParserCtxtPtr\n\t\t\txmlCreateMemoryParserCtxt(const char *buffer,\n\t\t\t\t\t\t int size);\nXMLPUBFUN xmlParserCtxtPtr\n\t\t\txmlCreateEntityParserCtxt(const xmlChar *URL,\n\t\t\t\t\t\t const xmlChar *ID,\n\t\t\t\t\t\t const xmlChar *base);\nXMLPUBFUN int\n\t\t\txmlSwitchEncoding\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlCharEncoding enc);\nXMLPUBFUN int\n\t\t\txmlSwitchToEncoding\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlCharEncodingHandlerPtr handler);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlSwitchInputEncoding\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlParserInputPtr input,\n\t\t\t\t\t xmlCharEncodingHandlerPtr handler);\n\n/**\n * Input Streams.\n */\nXMLPUBFUN xmlParserInputPtr\n\t\t\txmlNewStringInputStream\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *buffer);\nXML_DEPRECATED\nXMLPUBFUN xmlParserInputPtr\n\t\t\txmlNewEntityInputStream\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlEntityPtr entity);\nXMLPUBFUN int\n\t\t\txmlPushInput\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlParserInputPtr input);\nXMLPUBFUN xmlChar\n\t\t\txmlPopInput\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t\txmlFreeInputStream\t(xmlParserInputPtr input);\nXMLPUBFUN xmlParserInputPtr\n\t\t\txmlNewInputFromFile\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const char *filename);\nXMLPUBFUN xmlParserInputPtr\n\t\t\txmlNewInputStream\t(xmlParserCtxtPtr ctxt);\n\n/**\n * Namespaces.\n */\nXMLPUBFUN xmlChar *\n\t\t\txmlSplitQName\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t xmlChar **prefix);\n\n/**\n * Generic production rules.\n */\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParseName\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseNmtoken\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseEntityValue\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **orig);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseAttValue\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseSystemLiteral\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParsePubidLiteral\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseCharData\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int cdata);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseExternalID\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **publicID,\n\t\t\t\t\t\t int strict);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseComment\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParsePITarget\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParsePI\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseNotationDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseEntityDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseDefaultDecl\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **value);\nXML_DEPRECATED\nXMLPUBFUN xmlEnumerationPtr\n\t\t\txmlParseNotationType\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlEnumerationPtr\n\t\t\txmlParseEnumerationType\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseEnumeratedType\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlEnumerationPtr *tree);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseAttributeType\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlEnumerationPtr *tree);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlElementContentPtr\n\t\t\txmlParseElementMixedContentDecl\n\t\t\t\t\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int inputchk);\nXML_DEPRECATED\nXMLPUBFUN xmlElementContentPtr\n\t\t\txmlParseElementChildrenContentDecl\n\t\t\t\t\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int inputchk);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseElementContentDecl(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t xmlElementContentPtr *result);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseElementDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseMarkupDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseCharRef\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlParseEntityRef\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseReference\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParsePEReference\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseDocTypeDecl\t(xmlParserCtxtPtr ctxt);\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParseAttribute\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **value);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParseStartTag\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseEndTag\t\t(xmlParserCtxtPtr ctxt);\n#endif /* LIBXML_SAX1_ENABLED */\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseCDSect\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t\txmlParseContent\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseElement\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseVersionNum\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseVersionInfo\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseEncName\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParseEncodingDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseSDDecl\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseXMLDecl\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseTextDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseMisc\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t\txmlParseExternalSubset\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\n/**\n * XML_SUBSTITUTE_NONE:\n *\n * If no entities need to be substituted.\n */\n#define XML_SUBSTITUTE_NONE\t0\n/**\n * XML_SUBSTITUTE_REF:\n *\n * Whether general entities need to be substituted.\n */\n#define XML_SUBSTITUTE_REF\t1\n/**\n * XML_SUBSTITUTE_PEREF:\n *\n * Whether parameter entities need to be substituted.\n */\n#define XML_SUBSTITUTE_PEREF\t2\n/**\n * XML_SUBSTITUTE_BOTH:\n *\n * Both general and parameter entities need to be substituted.\n */\n#define XML_SUBSTITUTE_BOTH\t3\n\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\txmlStringDecodeEntities\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t\t int what,\n\t\t\t\t\t\t xmlChar end,\n\t\t\t\t\t\t xmlChar  end2,\n\t\t\t\t\t\t xmlChar end3);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\txmlStringLenDecodeEntities\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t\t int len,\n\t\t\t\t\t\t int what,\n\t\t\t\t\t\t xmlChar end,\n\t\t\t\t\t\t xmlChar  end2,\n\t\t\t\t\t\t xmlChar end3);\n\n/*\n * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.\n */\nXML_DEPRECATED\nXMLPUBFUN int\t\t\tnodePush\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlNodePtr value);\nXML_DEPRECATED\nXMLPUBFUN xmlNodePtr\t\tnodePop\t\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN int\t\t\tinputPush\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlParserInputPtr value);\nXMLPUBFUN xmlParserInputPtr\tinputPop\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\tnamePop\t\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\t\t\tnamePush\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *value);\n\n/*\n * other commodities shared between parser.c and parserInternals.\n */\nXML_DEPRECATED\nXMLPUBFUN int\t\t\txmlSkipBlankChars\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\t\t\txmlStringCurrentChar\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *cur,\n\t\t\t\t\t\t int *len);\nXML_DEPRECATED\nXMLPUBFUN void\t\t\txmlParserHandlePEReference(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\t\t\txmlCheckLanguageID\t(const xmlChar *lang);\n\n/*\n * Really core function shared with HTML parser.\n */\nXML_DEPRECATED\nXMLPUBFUN int\t\t\txmlCurrentChar\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int *len);\nXMLPUBFUN int\t\txmlCopyCharMultiByte\t(xmlChar *out,\n\t\t\t\t\t\t int val);\nXMLPUBFUN int\t\t\txmlCopyChar\t\t(int len,\n\t\t\t\t\t\t xmlChar *out,\n\t\t\t\t\t\t int val);\nXML_DEPRECATED\nXMLPUBFUN void\t\t\txmlNextChar\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\t\t\txmlParserInputShrink\t(xmlParserInputPtr in);\n\n/*\n * Specific function to keep track of entities references\n * and used by the XSLT debugger.\n */\n#ifdef LIBXML_LEGACY_ENABLED\n/**\n * xmlEntityReferenceFunc:\n * @ent: the entity\n * @firstNode:  the fist node in the chunk\n * @lastNode:  the last nod in the chunk\n *\n * Callback function used when one needs to be able to track back the\n * provenance of a chunk of nodes inherited from an entity replacement.\n */\ntypedef\tvoid\t(*xmlEntityReferenceFunc)\t(xmlEntityPtr ent,\n\t\t\t\t\t\t xmlNodePtr firstNode,\n\t\t\t\t\t\t xmlNodePtr lastNode);\n\nXML_DEPRECATED\nXMLPUBFUN void\t\txmlSetEntityReferenceFunc\t(xmlEntityReferenceFunc func);\n\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseQuotedString\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n                        xmlParseNamespace       (xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlNamespaceParseNSDef\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlScanName\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlNamespaceParseNCName\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\txmlParserHandleReference(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlNamespaceParseQName\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **prefix);\n/**\n * Entities\n */\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\txmlDecodeEntities\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int len,\n\t\t\t\t\t\t int what,\n\t\t\t\t\t\t xmlChar end,\n\t\t\t\t\t\t xmlChar  end2,\n\t\t\t\t\t\t xmlChar end3);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlHandleEntity\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlEntityPtr entity);\n\n#endif /* LIBXML_LEGACY_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_PARSER_INTERNALS_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/pattern.h",
    "content": "/*\n * Summary: pattern expression handling\n * Description: allows to compile and test pattern expressions for nodes\n *              either in a tree or based on a parser state.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_PATTERN_H__\n#define __XML_PATTERN_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/dict.h>\n\n#ifdef LIBXML_PATTERN_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlPattern:\n *\n * A compiled (XPath based) pattern to select nodes\n */\ntypedef struct _xmlPattern xmlPattern;\ntypedef xmlPattern *xmlPatternPtr;\n\n/**\n * xmlPatternFlags:\n *\n * This is the set of options affecting the behaviour of pattern\n * matching with this module\n *\n */\ntypedef enum {\n    XML_PATTERN_DEFAULT\t\t= 0,\t/* simple pattern match */\n    XML_PATTERN_XPATH\t\t= 1<<0,\t/* standard XPath pattern */\n    XML_PATTERN_XSSEL\t\t= 1<<1,\t/* XPath subset for schema selector */\n    XML_PATTERN_XSFIELD\t\t= 1<<2\t/* XPath subset for schema field */\n} xmlPatternFlags;\n\nXMLPUBFUN void\n\t\t\txmlFreePattern\t\t(xmlPatternPtr comp);\n\nXMLPUBFUN void\n\t\t\txmlFreePatternList\t(xmlPatternPtr comp);\n\nXMLPUBFUN xmlPatternPtr\n\t\t\txmlPatterncompile\t(const xmlChar *pattern,\n\t\t\t\t\t\t xmlDict *dict,\n\t\t\t\t\t\t int flags,\n\t\t\t\t\t\t const xmlChar **namespaces);\nXMLPUBFUN int\n\t\t\txmlPatternMatch\t\t(xmlPatternPtr comp,\n\t\t\t\t\t\t xmlNodePtr node);\n\n/* streaming interfaces */\ntypedef struct _xmlStreamCtxt xmlStreamCtxt;\ntypedef xmlStreamCtxt *xmlStreamCtxtPtr;\n\nXMLPUBFUN int\n\t\t\txmlPatternStreamable\t(xmlPatternPtr comp);\nXMLPUBFUN int\n\t\t\txmlPatternMaxDepth\t(xmlPatternPtr comp);\nXMLPUBFUN int\n\t\t\txmlPatternMinDepth\t(xmlPatternPtr comp);\nXMLPUBFUN int\n\t\t\txmlPatternFromRoot\t(xmlPatternPtr comp);\nXMLPUBFUN xmlStreamCtxtPtr\n\t\t\txmlPatternGetStreamCtxt\t(xmlPatternPtr comp);\nXMLPUBFUN void\n\t\t\txmlFreeStreamCtxt\t(xmlStreamCtxtPtr stream);\nXMLPUBFUN int\n\t\t\txmlStreamPushNode\t(xmlStreamCtxtPtr stream,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns,\n\t\t\t\t\t\t int nodeType);\nXMLPUBFUN int\n\t\t\txmlStreamPush\t\t(xmlStreamCtxtPtr stream,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns);\nXMLPUBFUN int\n\t\t\txmlStreamPushAttr\t(xmlStreamCtxtPtr stream,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns);\nXMLPUBFUN int\n\t\t\txmlStreamPop\t\t(xmlStreamCtxtPtr stream);\nXMLPUBFUN int\n\t\t\txmlStreamWantsAnyNode\t(xmlStreamCtxtPtr stream);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_PATTERN_ENABLED */\n\n#endif /* __XML_PATTERN_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/relaxng.h",
    "content": "/*\n * Summary: implementation of the Relax-NG validation\n * Description: implementation of the Relax-NG validation\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_RELAX_NG__\n#define __XML_RELAX_NG__\n\n#include <libxml/xmlversion.h>\n#include <libxml/hash.h>\n#include <libxml/xmlstring.h>\n\n#ifdef LIBXML_SCHEMAS_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct _xmlRelaxNG xmlRelaxNG;\ntypedef xmlRelaxNG *xmlRelaxNGPtr;\n\n\n/**\n * xmlRelaxNGValidityErrorFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of an error callback from a Relax-NG validation\n */\ntypedef void (*xmlRelaxNGValidityErrorFunc) (void *ctx,\n\t\t\t\t\t\t      const char *msg,\n\t\t\t\t\t\t      ...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * xmlRelaxNGValidityWarningFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of a warning callback from a Relax-NG validation\n */\ntypedef void (*xmlRelaxNGValidityWarningFunc) (void *ctx,\n\t\t\t\t\t\t\tconst char *msg,\n\t\t\t\t\t\t\t...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * A schemas validation context\n */\ntypedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt;\ntypedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr;\n\ntypedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt;\ntypedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr;\n\n/*\n * xmlRelaxNGValidErr:\n *\n * List of possible Relax NG validation errors\n */\ntypedef enum {\n    XML_RELAXNG_OK = 0,\n    XML_RELAXNG_ERR_MEMORY,\n    XML_RELAXNG_ERR_TYPE,\n    XML_RELAXNG_ERR_TYPEVAL,\n    XML_RELAXNG_ERR_DUPID,\n    XML_RELAXNG_ERR_TYPECMP,\n    XML_RELAXNG_ERR_NOSTATE,\n    XML_RELAXNG_ERR_NODEFINE,\n    XML_RELAXNG_ERR_LISTEXTRA,\n    XML_RELAXNG_ERR_LISTEMPTY,\n    XML_RELAXNG_ERR_INTERNODATA,\n    XML_RELAXNG_ERR_INTERSEQ,\n    XML_RELAXNG_ERR_INTEREXTRA,\n    XML_RELAXNG_ERR_ELEMNAME,\n    XML_RELAXNG_ERR_ATTRNAME,\n    XML_RELAXNG_ERR_ELEMNONS,\n    XML_RELAXNG_ERR_ATTRNONS,\n    XML_RELAXNG_ERR_ELEMWRONGNS,\n    XML_RELAXNG_ERR_ATTRWRONGNS,\n    XML_RELAXNG_ERR_ELEMEXTRANS,\n    XML_RELAXNG_ERR_ATTREXTRANS,\n    XML_RELAXNG_ERR_ELEMNOTEMPTY,\n    XML_RELAXNG_ERR_NOELEM,\n    XML_RELAXNG_ERR_NOTELEM,\n    XML_RELAXNG_ERR_ATTRVALID,\n    XML_RELAXNG_ERR_CONTENTVALID,\n    XML_RELAXNG_ERR_EXTRACONTENT,\n    XML_RELAXNG_ERR_INVALIDATTR,\n    XML_RELAXNG_ERR_DATAELEM,\n    XML_RELAXNG_ERR_VALELEM,\n    XML_RELAXNG_ERR_LISTELEM,\n    XML_RELAXNG_ERR_DATATYPE,\n    XML_RELAXNG_ERR_VALUE,\n    XML_RELAXNG_ERR_LIST,\n    XML_RELAXNG_ERR_NOGRAMMAR,\n    XML_RELAXNG_ERR_EXTRADATA,\n    XML_RELAXNG_ERR_LACKDATA,\n    XML_RELAXNG_ERR_INTERNAL,\n    XML_RELAXNG_ERR_ELEMWRONG,\n    XML_RELAXNG_ERR_TEXTWRONG\n} xmlRelaxNGValidErr;\n\n/*\n * xmlRelaxNGParserFlags:\n *\n * List of possible Relax NG Parser flags\n */\ntypedef enum {\n    XML_RELAXNGP_NONE = 0,\n    XML_RELAXNGP_FREE_DOC = 1,\n    XML_RELAXNGP_CRNG = 2\n} xmlRelaxNGParserFlag;\n\nXMLPUBFUN int\n\t\t    xmlRelaxNGInitTypes\t\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlRelaxNGCleanupTypes\t(void);\n\n/*\n * Interfaces for parsing.\n */\nXMLPUBFUN xmlRelaxNGParserCtxtPtr\n\t\t    xmlRelaxNGNewParserCtxt\t(const char *URL);\nXMLPUBFUN xmlRelaxNGParserCtxtPtr\n\t\t    xmlRelaxNGNewMemParserCtxt\t(const char *buffer,\n\t\t\t\t\t\t int size);\nXMLPUBFUN xmlRelaxNGParserCtxtPtr\n\t\t    xmlRelaxNGNewDocParserCtxt\t(xmlDocPtr doc);\n\nXMLPUBFUN int\n\t\t    xmlRelaxParserSetFlag\t(xmlRelaxNGParserCtxtPtr ctxt,\n\t\t\t\t\t\t int flag);\n\nXMLPUBFUN void\n\t\t    xmlRelaxNGFreeParserCtxt\t(xmlRelaxNGParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t    xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,\n\t\t\t\t\t xmlRelaxNGValidityErrorFunc err,\n\t\t\t\t\t xmlRelaxNGValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t\t    xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,\n\t\t\t\t\t xmlRelaxNGValidityErrorFunc *err,\n\t\t\t\t\t xmlRelaxNGValidityWarningFunc *warn,\n\t\t\t\t\t void **ctx);\nXMLPUBFUN void\n\t\t    xmlRelaxNGSetParserStructuredErrors(\n\t\t\t\t\t xmlRelaxNGParserCtxtPtr ctxt,\n\t\t\t\t\t xmlStructuredErrorFunc serror,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN xmlRelaxNGPtr\n\t\t    xmlRelaxNGParse\t\t(xmlRelaxNGParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t    xmlRelaxNGFree\t\t(xmlRelaxNGPtr schema);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\t    xmlRelaxNGDump\t\t(FILE *output,\n\t\t\t\t\t xmlRelaxNGPtr schema);\nXMLPUBFUN void\n\t\t    xmlRelaxNGDumpTree\t(FILE * output,\n\t\t\t\t\t xmlRelaxNGPtr schema);\n#endif /* LIBXML_OUTPUT_ENABLED */\n/*\n * Interfaces for validating\n */\nXMLPUBFUN void\n\t\t    xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlRelaxNGValidityErrorFunc err,\n\t\t\t\t\t xmlRelaxNGValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t\t    xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlRelaxNGValidityErrorFunc *err,\n\t\t\t\t\t xmlRelaxNGValidityWarningFunc *warn,\n\t\t\t\t\t void **ctx);\nXMLPUBFUN void\n\t\t\txmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t  xmlStructuredErrorFunc serror, void *ctx);\nXMLPUBFUN xmlRelaxNGValidCtxtPtr\n\t\t    xmlRelaxNGNewValidCtxt\t(xmlRelaxNGPtr schema);\nXMLPUBFUN void\n\t\t    xmlRelaxNGFreeValidCtxt\t(xmlRelaxNGValidCtxtPtr ctxt);\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidateDoc\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t\t xmlDocPtr doc);\n/*\n * Interfaces for progressive validation when possible\n */\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidatePushElement\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidatePushCData\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *data,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidatePopElement\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidateFullElement\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMAS_ENABLED */\n\n#endif /* __XML_RELAX_NG__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/schemasInternals.h",
    "content": "/*\n * Summary: internal interfaces for XML Schemas\n * Description: internal interfaces for the XML Schemas handling\n *              and schema validity checking\n *\t\tThe Schemas development is a Work In Progress.\n *              Some of those interfaces are not guaranteed to be API or ABI stable !\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SCHEMA_INTERNALS_H__\n#define __XML_SCHEMA_INTERNALS_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_SCHEMAS_ENABLED\n\n#include <libxml/xmlregexp.h>\n#include <libxml/hash.h>\n#include <libxml/dict.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef enum {\n    XML_SCHEMAS_UNKNOWN = 0,\n    XML_SCHEMAS_STRING = 1,\n    XML_SCHEMAS_NORMSTRING = 2,\n    XML_SCHEMAS_DECIMAL = 3,\n    XML_SCHEMAS_TIME = 4,\n    XML_SCHEMAS_GDAY = 5,\n    XML_SCHEMAS_GMONTH = 6,\n    XML_SCHEMAS_GMONTHDAY = 7,\n    XML_SCHEMAS_GYEAR = 8,\n    XML_SCHEMAS_GYEARMONTH = 9,\n    XML_SCHEMAS_DATE = 10,\n    XML_SCHEMAS_DATETIME = 11,\n    XML_SCHEMAS_DURATION = 12,\n    XML_SCHEMAS_FLOAT = 13,\n    XML_SCHEMAS_DOUBLE = 14,\n    XML_SCHEMAS_BOOLEAN = 15,\n    XML_SCHEMAS_TOKEN = 16,\n    XML_SCHEMAS_LANGUAGE = 17,\n    XML_SCHEMAS_NMTOKEN = 18,\n    XML_SCHEMAS_NMTOKENS = 19,\n    XML_SCHEMAS_NAME = 20,\n    XML_SCHEMAS_QNAME = 21,\n    XML_SCHEMAS_NCNAME = 22,\n    XML_SCHEMAS_ID = 23,\n    XML_SCHEMAS_IDREF = 24,\n    XML_SCHEMAS_IDREFS = 25,\n    XML_SCHEMAS_ENTITY = 26,\n    XML_SCHEMAS_ENTITIES = 27,\n    XML_SCHEMAS_NOTATION = 28,\n    XML_SCHEMAS_ANYURI = 29,\n    XML_SCHEMAS_INTEGER = 30,\n    XML_SCHEMAS_NPINTEGER = 31,\n    XML_SCHEMAS_NINTEGER = 32,\n    XML_SCHEMAS_NNINTEGER = 33,\n    XML_SCHEMAS_PINTEGER = 34,\n    XML_SCHEMAS_INT = 35,\n    XML_SCHEMAS_UINT = 36,\n    XML_SCHEMAS_LONG = 37,\n    XML_SCHEMAS_ULONG = 38,\n    XML_SCHEMAS_SHORT = 39,\n    XML_SCHEMAS_USHORT = 40,\n    XML_SCHEMAS_BYTE = 41,\n    XML_SCHEMAS_UBYTE = 42,\n    XML_SCHEMAS_HEXBINARY = 43,\n    XML_SCHEMAS_BASE64BINARY = 44,\n    XML_SCHEMAS_ANYTYPE = 45,\n    XML_SCHEMAS_ANYSIMPLETYPE = 46\n} xmlSchemaValType;\n\n/*\n * XML Schemas defines multiple type of types.\n */\ntypedef enum {\n    XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */\n    XML_SCHEMA_TYPE_ANY,\n    XML_SCHEMA_TYPE_FACET,\n    XML_SCHEMA_TYPE_SIMPLE,\n    XML_SCHEMA_TYPE_COMPLEX,\n    XML_SCHEMA_TYPE_SEQUENCE = 6,\n    XML_SCHEMA_TYPE_CHOICE,\n    XML_SCHEMA_TYPE_ALL,\n    XML_SCHEMA_TYPE_SIMPLE_CONTENT,\n    XML_SCHEMA_TYPE_COMPLEX_CONTENT,\n    XML_SCHEMA_TYPE_UR,\n    XML_SCHEMA_TYPE_RESTRICTION,\n    XML_SCHEMA_TYPE_EXTENSION,\n    XML_SCHEMA_TYPE_ELEMENT,\n    XML_SCHEMA_TYPE_ATTRIBUTE,\n    XML_SCHEMA_TYPE_ATTRIBUTEGROUP,\n    XML_SCHEMA_TYPE_GROUP,\n    XML_SCHEMA_TYPE_NOTATION,\n    XML_SCHEMA_TYPE_LIST,\n    XML_SCHEMA_TYPE_UNION,\n    XML_SCHEMA_TYPE_ANY_ATTRIBUTE,\n    XML_SCHEMA_TYPE_IDC_UNIQUE,\n    XML_SCHEMA_TYPE_IDC_KEY,\n    XML_SCHEMA_TYPE_IDC_KEYREF,\n    XML_SCHEMA_TYPE_PARTICLE = 25,\n    XML_SCHEMA_TYPE_ATTRIBUTE_USE,\n    XML_SCHEMA_FACET_MININCLUSIVE = 1000,\n    XML_SCHEMA_FACET_MINEXCLUSIVE,\n    XML_SCHEMA_FACET_MAXINCLUSIVE,\n    XML_SCHEMA_FACET_MAXEXCLUSIVE,\n    XML_SCHEMA_FACET_TOTALDIGITS,\n    XML_SCHEMA_FACET_FRACTIONDIGITS,\n    XML_SCHEMA_FACET_PATTERN,\n    XML_SCHEMA_FACET_ENUMERATION,\n    XML_SCHEMA_FACET_WHITESPACE,\n    XML_SCHEMA_FACET_LENGTH,\n    XML_SCHEMA_FACET_MAXLENGTH,\n    XML_SCHEMA_FACET_MINLENGTH,\n    XML_SCHEMA_EXTRA_QNAMEREF = 2000,\n    XML_SCHEMA_EXTRA_ATTR_USE_PROHIB\n} xmlSchemaTypeType;\n\ntypedef enum {\n    XML_SCHEMA_CONTENT_UNKNOWN = 0,\n    XML_SCHEMA_CONTENT_EMPTY = 1,\n    XML_SCHEMA_CONTENT_ELEMENTS,\n    XML_SCHEMA_CONTENT_MIXED,\n    XML_SCHEMA_CONTENT_SIMPLE,\n    XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */\n    XML_SCHEMA_CONTENT_BASIC,\n    XML_SCHEMA_CONTENT_ANY\n} xmlSchemaContentType;\n\ntypedef struct _xmlSchemaVal xmlSchemaVal;\ntypedef xmlSchemaVal *xmlSchemaValPtr;\n\ntypedef struct _xmlSchemaType xmlSchemaType;\ntypedef xmlSchemaType *xmlSchemaTypePtr;\n\ntypedef struct _xmlSchemaFacet xmlSchemaFacet;\ntypedef xmlSchemaFacet *xmlSchemaFacetPtr;\n\n/**\n * Annotation\n */\ntypedef struct _xmlSchemaAnnot xmlSchemaAnnot;\ntypedef xmlSchemaAnnot *xmlSchemaAnnotPtr;\nstruct _xmlSchemaAnnot {\n    struct _xmlSchemaAnnot *next;\n    xmlNodePtr content;         /* the annotation */\n};\n\n/**\n * XML_SCHEMAS_ANYATTR_SKIP:\n *\n * Skip unknown attribute from validation\n * Obsolete, not used anymore.\n */\n#define XML_SCHEMAS_ANYATTR_SKIP        1\n/**\n * XML_SCHEMAS_ANYATTR_LAX:\n *\n * Ignore validation non definition on attributes\n * Obsolete, not used anymore.\n */\n#define XML_SCHEMAS_ANYATTR_LAX                2\n/**\n * XML_SCHEMAS_ANYATTR_STRICT:\n *\n * Apply strict validation rules on attributes\n * Obsolete, not used anymore.\n */\n#define XML_SCHEMAS_ANYATTR_STRICT        3\n/**\n * XML_SCHEMAS_ANY_SKIP:\n *\n * Skip unknown attribute from validation\n */\n#define XML_SCHEMAS_ANY_SKIP        1\n/**\n * XML_SCHEMAS_ANY_LAX:\n *\n * Used by wildcards.\n * Validate if type found, don't worry if not found\n */\n#define XML_SCHEMAS_ANY_LAX                2\n/**\n * XML_SCHEMAS_ANY_STRICT:\n *\n * Used by wildcards.\n * Apply strict validation rules\n */\n#define XML_SCHEMAS_ANY_STRICT        3\n/**\n * XML_SCHEMAS_ATTR_USE_PROHIBITED:\n *\n * Used by wildcards.\n * The attribute is prohibited.\n */\n#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0\n/**\n * XML_SCHEMAS_ATTR_USE_REQUIRED:\n *\n * The attribute is required.\n */\n#define XML_SCHEMAS_ATTR_USE_REQUIRED 1\n/**\n * XML_SCHEMAS_ATTR_USE_OPTIONAL:\n *\n * The attribute is optional.\n */\n#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2\n/**\n * XML_SCHEMAS_ATTR_GLOBAL:\n *\n * allow elements in no namespace\n */\n#define XML_SCHEMAS_ATTR_GLOBAL        1 << 0\n/**\n * XML_SCHEMAS_ATTR_NSDEFAULT:\n *\n * allow elements in no namespace\n */\n#define XML_SCHEMAS_ATTR_NSDEFAULT        1 << 7\n/**\n * XML_SCHEMAS_ATTR_INTERNAL_RESOLVED:\n *\n * this is set when the \"type\" and \"ref\" references\n * have been resolved.\n */\n#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED        1 << 8\n/**\n * XML_SCHEMAS_ATTR_FIXED:\n *\n * the attribute has a fixed value\n */\n#define XML_SCHEMAS_ATTR_FIXED        1 << 9\n\n/**\n * xmlSchemaAttribute:\n * An attribute definition.\n */\n\ntypedef struct _xmlSchemaAttribute xmlSchemaAttribute;\ntypedef xmlSchemaAttribute *xmlSchemaAttributePtr;\nstruct _xmlSchemaAttribute {\n    xmlSchemaTypeType type;\n    struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */\n    const xmlChar *name; /* the name of the declaration */\n    const xmlChar *id; /* Deprecated; not used */\n    const xmlChar *ref; /* Deprecated; not used */\n    const xmlChar *refNs; /* Deprecated; not used */\n    const xmlChar *typeName; /* the local name of the type definition */\n    const xmlChar *typeNs; /* the ns URI of the type definition */\n    xmlSchemaAnnotPtr annot;\n\n    xmlSchemaTypePtr base; /* Deprecated; not used */\n    int occurs; /* Deprecated; not used */\n    const xmlChar *defValue; /* The initial value of the value constraint */\n    xmlSchemaTypePtr subtypes; /* the type definition */\n    xmlNodePtr node;\n    const xmlChar *targetNamespace;\n    int flags;\n    const xmlChar *refPrefix; /* Deprecated; not used */\n    xmlSchemaValPtr defVal; /* The compiled value constraint */\n    xmlSchemaAttributePtr refDecl; /* Deprecated; not used */\n};\n\n/**\n * xmlSchemaAttributeLink:\n * Used to build a list of attribute uses on complexType definitions.\n * WARNING: Deprecated; not used.\n */\ntypedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink;\ntypedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr;\nstruct _xmlSchemaAttributeLink {\n    struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */\n    struct _xmlSchemaAttribute *attr;/* the linked attribute */\n};\n\n/**\n * XML_SCHEMAS_WILDCARD_COMPLETE:\n *\n * If the wildcard is complete.\n */\n#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0\n\n/**\n * xmlSchemaCharValueLink:\n * Used to build a list of namespaces on wildcards.\n */\ntypedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs;\ntypedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr;\nstruct _xmlSchemaWildcardNs {\n    struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */\n    const xmlChar *value;/* the value */\n};\n\n/**\n * xmlSchemaWildcard.\n * A wildcard.\n */\ntypedef struct _xmlSchemaWildcard xmlSchemaWildcard;\ntypedef xmlSchemaWildcard *xmlSchemaWildcardPtr;\nstruct _xmlSchemaWildcard {\n    xmlSchemaTypeType type;        /* The kind of type */\n    const xmlChar *id; /* Deprecated; not used */\n    xmlSchemaAnnotPtr annot;\n    xmlNodePtr node;\n    int minOccurs; /* Deprecated; not used */\n    int maxOccurs; /* Deprecated; not used */\n    int processContents;\n    int any; /* Indicates if the ns constraint is of ##any */\n    xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */\n    xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */\n    int flags;\n};\n\n/**\n * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED:\n *\n * The attribute wildcard has been built.\n */\n#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0\n/**\n * XML_SCHEMAS_ATTRGROUP_GLOBAL:\n *\n * The attribute group has been defined.\n */\n#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1\n/**\n * XML_SCHEMAS_ATTRGROUP_MARKED:\n *\n * Marks the attr group as marked; used for circular checks.\n */\n#define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2\n\n/**\n * XML_SCHEMAS_ATTRGROUP_REDEFINED:\n *\n * The attr group was redefined.\n */\n#define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3\n/**\n * XML_SCHEMAS_ATTRGROUP_HAS_REFS:\n *\n * Whether this attr. group contains attr. group references.\n */\n#define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4\n\n/**\n * An attribute group definition.\n *\n * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures\n * must be kept similar\n */\ntypedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;\ntypedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;\nstruct _xmlSchemaAttributeGroup {\n    xmlSchemaTypeType type;        /* The kind of type */\n    struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */\n    const xmlChar *name;\n    const xmlChar *id;\n    const xmlChar *ref; /* Deprecated; not used */\n    const xmlChar *refNs; /* Deprecated; not used */\n    xmlSchemaAnnotPtr annot;\n\n    xmlSchemaAttributePtr attributes; /* Deprecated; not used */\n    xmlNodePtr node;\n    int flags;\n    xmlSchemaWildcardPtr attributeWildcard;\n    const xmlChar *refPrefix; /* Deprecated; not used */\n    xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */\n    const xmlChar *targetNamespace;\n    void *attrUses;\n};\n\n/**\n * xmlSchemaTypeLink:\n * Used to build a list of types (e.g. member types of\n * simpleType with variety \"union\").\n */\ntypedef struct _xmlSchemaTypeLink xmlSchemaTypeLink;\ntypedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr;\nstruct _xmlSchemaTypeLink {\n    struct _xmlSchemaTypeLink *next;/* the next type link ... */\n    xmlSchemaTypePtr type;/* the linked type */\n};\n\n/**\n * xmlSchemaFacetLink:\n * Used to build a list of facets.\n */\ntypedef struct _xmlSchemaFacetLink xmlSchemaFacetLink;\ntypedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr;\nstruct _xmlSchemaFacetLink {\n    struct _xmlSchemaFacetLink *next;/* the next facet link ... */\n    xmlSchemaFacetPtr facet;/* the linked facet */\n};\n\n/**\n * XML_SCHEMAS_TYPE_MIXED:\n *\n * the element content type is mixed\n */\n#define XML_SCHEMAS_TYPE_MIXED                1 << 0\n/**\n * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION:\n *\n * the simple or complex type has a derivation method of \"extension\".\n */\n#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION                1 << 1\n/**\n * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION:\n *\n * the simple or complex type has a derivation method of \"restriction\".\n */\n#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION                1 << 2\n/**\n * XML_SCHEMAS_TYPE_GLOBAL:\n *\n * the type is global\n */\n#define XML_SCHEMAS_TYPE_GLOBAL                1 << 3\n/**\n * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD:\n *\n * the complexType owns an attribute wildcard, i.e.\n * it can be freed by the complexType\n */\n#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD    1 << 4 /* Obsolete. */\n/**\n * XML_SCHEMAS_TYPE_VARIETY_ABSENT:\n *\n * the simpleType has a variety of \"absent\".\n * TODO: Actually not necessary :-/, since if\n * none of the variety flags occur then it's\n * automatically absent.\n */\n#define XML_SCHEMAS_TYPE_VARIETY_ABSENT    1 << 5\n/**\n * XML_SCHEMAS_TYPE_VARIETY_LIST:\n *\n * the simpleType has a variety of \"list\".\n */\n#define XML_SCHEMAS_TYPE_VARIETY_LIST    1 << 6\n/**\n * XML_SCHEMAS_TYPE_VARIETY_UNION:\n *\n * the simpleType has a variety of \"union\".\n */\n#define XML_SCHEMAS_TYPE_VARIETY_UNION    1 << 7\n/**\n * XML_SCHEMAS_TYPE_VARIETY_ATOMIC:\n *\n * the simpleType has a variety of \"union\".\n */\n#define XML_SCHEMAS_TYPE_VARIETY_ATOMIC    1 << 8\n/**\n * XML_SCHEMAS_TYPE_FINAL_EXTENSION:\n *\n * the complexType has a final of \"extension\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_EXTENSION    1 << 9\n/**\n * XML_SCHEMAS_TYPE_FINAL_RESTRICTION:\n *\n * the simpleType/complexType has a final of \"restriction\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_RESTRICTION    1 << 10\n/**\n * XML_SCHEMAS_TYPE_FINAL_LIST:\n *\n * the simpleType has a final of \"list\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_LIST    1 << 11\n/**\n * XML_SCHEMAS_TYPE_FINAL_UNION:\n *\n * the simpleType has a final of \"union\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_UNION    1 << 12\n/**\n * XML_SCHEMAS_TYPE_FINAL_DEFAULT:\n *\n * the simpleType has a final of \"default\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_DEFAULT    1 << 13\n/**\n * XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE:\n *\n * Marks the item as a builtin primitive.\n */\n#define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE    1 << 14\n/**\n * XML_SCHEMAS_TYPE_MARKED:\n *\n * Marks the item as marked; used for circular checks.\n */\n#define XML_SCHEMAS_TYPE_MARKED        1 << 16\n/**\n * XML_SCHEMAS_TYPE_BLOCK_DEFAULT:\n *\n * the complexType did not specify 'block' so use the default of the\n * <schema> item.\n */\n#define XML_SCHEMAS_TYPE_BLOCK_DEFAULT    1 << 17\n/**\n * XML_SCHEMAS_TYPE_BLOCK_EXTENSION:\n *\n * the complexType has a 'block' of \"extension\".\n */\n#define XML_SCHEMAS_TYPE_BLOCK_EXTENSION    1 << 18\n/**\n * XML_SCHEMAS_TYPE_BLOCK_RESTRICTION:\n *\n * the complexType has a 'block' of \"restriction\".\n */\n#define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION    1 << 19\n/**\n * XML_SCHEMAS_TYPE_ABSTRACT:\n *\n * the simple/complexType is abstract.\n */\n#define XML_SCHEMAS_TYPE_ABSTRACT    1 << 20\n/**\n * XML_SCHEMAS_TYPE_FACETSNEEDVALUE:\n *\n * indicates if the facets need a computed value\n */\n#define XML_SCHEMAS_TYPE_FACETSNEEDVALUE    1 << 21\n/**\n * XML_SCHEMAS_TYPE_INTERNAL_RESOLVED:\n *\n * indicates that the type was typefixed\n */\n#define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED    1 << 22\n/**\n * XML_SCHEMAS_TYPE_INTERNAL_INVALID:\n *\n * indicates that the type is invalid\n */\n#define XML_SCHEMAS_TYPE_INTERNAL_INVALID    1 << 23\n/**\n * XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE:\n *\n * a whitespace-facet value of \"preserve\"\n */\n#define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE    1 << 24\n/**\n * XML_SCHEMAS_TYPE_WHITESPACE_REPLACE:\n *\n * a whitespace-facet value of \"replace\"\n */\n#define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE    1 << 25\n/**\n * XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE:\n *\n * a whitespace-facet value of \"collapse\"\n */\n#define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE    1 << 26\n/**\n * XML_SCHEMAS_TYPE_HAS_FACETS:\n *\n * has facets\n */\n#define XML_SCHEMAS_TYPE_HAS_FACETS    1 << 27\n/**\n * XML_SCHEMAS_TYPE_NORMVALUENEEDED:\n *\n * indicates if the facets (pattern) need a normalized value\n */\n#define XML_SCHEMAS_TYPE_NORMVALUENEEDED    1 << 28\n\n/**\n * XML_SCHEMAS_TYPE_FIXUP_1:\n *\n * First stage of fixup was done.\n */\n#define XML_SCHEMAS_TYPE_FIXUP_1    1 << 29\n\n/**\n * XML_SCHEMAS_TYPE_REDEFINED:\n *\n * The type was redefined.\n */\n#define XML_SCHEMAS_TYPE_REDEFINED    1 << 30\n/**\n * XML_SCHEMAS_TYPE_REDEFINING:\n *\n * The type redefines an other type.\n */\n/* #define XML_SCHEMAS_TYPE_REDEFINING    1 << 31 */\n\n/**\n * _xmlSchemaType:\n *\n * Schemas type definition.\n */\nstruct _xmlSchemaType {\n    xmlSchemaTypeType type; /* The kind of type */\n    struct _xmlSchemaType *next; /* the next type if in a sequence ... */\n    const xmlChar *name;\n    const xmlChar *id ; /* Deprecated; not used */\n    const xmlChar *ref; /* Deprecated; not used */\n    const xmlChar *refNs; /* Deprecated; not used */\n    xmlSchemaAnnotPtr annot;\n    xmlSchemaTypePtr subtypes;\n    xmlSchemaAttributePtr attributes; /* Deprecated; not used */\n    xmlNodePtr node;\n    int minOccurs; /* Deprecated; not used */\n    int maxOccurs; /* Deprecated; not used */\n\n    int flags;\n    xmlSchemaContentType contentType;\n    const xmlChar *base; /* Base type's local name */\n    const xmlChar *baseNs; /* Base type's target namespace */\n    xmlSchemaTypePtr baseType; /* The base type component */\n    xmlSchemaFacetPtr facets; /* Local facets */\n    struct _xmlSchemaType *redef; /* Deprecated; not used */\n    int recurse; /* Obsolete */\n    xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */\n    xmlSchemaWildcardPtr attributeWildcard;\n    int builtInType; /* Type of built-in types. */\n    xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */\n    xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */\n    const xmlChar *refPrefix; /* Deprecated; not used */\n    xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types.\n                                        Could we use @subtypes for this? */\n    xmlRegexpPtr contModel; /* Holds the automaton of the content model */\n    const xmlChar *targetNamespace;\n    void *attrUses;\n};\n\n/*\n * xmlSchemaElement:\n * An element definition.\n *\n * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of\n * structures must be kept similar\n */\n/**\n * XML_SCHEMAS_ELEM_NILLABLE:\n *\n * the element is nillable\n */\n#define XML_SCHEMAS_ELEM_NILLABLE        1 << 0\n/**\n * XML_SCHEMAS_ELEM_GLOBAL:\n *\n * the element is global\n */\n#define XML_SCHEMAS_ELEM_GLOBAL                1 << 1\n/**\n * XML_SCHEMAS_ELEM_DEFAULT:\n *\n * the element has a default value\n */\n#define XML_SCHEMAS_ELEM_DEFAULT        1 << 2\n/**\n * XML_SCHEMAS_ELEM_FIXED:\n *\n * the element has a fixed value\n */\n#define XML_SCHEMAS_ELEM_FIXED                1 << 3\n/**\n * XML_SCHEMAS_ELEM_ABSTRACT:\n *\n * the element is abstract\n */\n#define XML_SCHEMAS_ELEM_ABSTRACT        1 << 4\n/**\n * XML_SCHEMAS_ELEM_TOPLEVEL:\n *\n * the element is top level\n * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead\n */\n#define XML_SCHEMAS_ELEM_TOPLEVEL        1 << 5\n/**\n * XML_SCHEMAS_ELEM_REF:\n *\n * the element is a reference to a type\n */\n#define XML_SCHEMAS_ELEM_REF                1 << 6\n/**\n * XML_SCHEMAS_ELEM_NSDEFAULT:\n *\n * allow elements in no namespace\n * Obsolete, not used anymore.\n */\n#define XML_SCHEMAS_ELEM_NSDEFAULT        1 << 7\n/**\n * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED:\n *\n * this is set when \"type\", \"ref\", \"substitutionGroup\"\n * references have been resolved.\n */\n#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED        1 << 8\n /**\n * XML_SCHEMAS_ELEM_CIRCULAR:\n *\n * a helper flag for the search of circular references.\n */\n#define XML_SCHEMAS_ELEM_CIRCULAR        1 << 9\n/**\n * XML_SCHEMAS_ELEM_BLOCK_ABSENT:\n *\n * the \"block\" attribute is absent\n */\n#define XML_SCHEMAS_ELEM_BLOCK_ABSENT        1 << 10\n/**\n * XML_SCHEMAS_ELEM_BLOCK_EXTENSION:\n *\n * disallowed substitutions are absent\n */\n#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION        1 << 11\n/**\n * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION:\n *\n * disallowed substitutions: \"restriction\"\n */\n#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION        1 << 12\n/**\n * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION:\n *\n * disallowed substitutions: \"substitution\"\n */\n#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION        1 << 13\n/**\n * XML_SCHEMAS_ELEM_FINAL_ABSENT:\n *\n * substitution group exclusions are absent\n */\n#define XML_SCHEMAS_ELEM_FINAL_ABSENT        1 << 14\n/**\n * XML_SCHEMAS_ELEM_FINAL_EXTENSION:\n *\n * substitution group exclusions: \"extension\"\n */\n#define XML_SCHEMAS_ELEM_FINAL_EXTENSION        1 << 15\n/**\n * XML_SCHEMAS_ELEM_FINAL_RESTRICTION:\n *\n * substitution group exclusions: \"restriction\"\n */\n#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION        1 << 16\n/**\n * XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD:\n *\n * the declaration is a substitution group head\n */\n#define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD        1 << 17\n/**\n * XML_SCHEMAS_ELEM_INTERNAL_CHECKED:\n *\n * this is set when the elem decl has been checked against\n * all constraints\n */\n#define XML_SCHEMAS_ELEM_INTERNAL_CHECKED        1 << 18\n\ntypedef struct _xmlSchemaElement xmlSchemaElement;\ntypedef xmlSchemaElement *xmlSchemaElementPtr;\nstruct _xmlSchemaElement {\n    xmlSchemaTypeType type; /* The kind of type */\n    struct _xmlSchemaType *next; /* Not used? */\n    const xmlChar *name;\n    const xmlChar *id; /* Deprecated; not used */\n    const xmlChar *ref; /* Deprecated; not used */\n    const xmlChar *refNs; /* Deprecated; not used */\n    xmlSchemaAnnotPtr annot;\n    xmlSchemaTypePtr subtypes; /* the type definition */\n    xmlSchemaAttributePtr attributes;\n    xmlNodePtr node;\n    int minOccurs; /* Deprecated; not used */\n    int maxOccurs; /* Deprecated; not used */\n\n    int flags;\n    const xmlChar *targetNamespace;\n    const xmlChar *namedType;\n    const xmlChar *namedTypeNs;\n    const xmlChar *substGroup;\n    const xmlChar *substGroupNs;\n    const xmlChar *scope;\n    const xmlChar *value; /* The original value of the value constraint. */\n    struct _xmlSchemaElement *refDecl; /* This will now be used for the\n                                          substitution group affiliation */\n    xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */\n    xmlSchemaContentType contentType;\n    const xmlChar *refPrefix; /* Deprecated; not used */\n    xmlSchemaValPtr defVal; /* The compiled value constraint. */\n    void *idcs; /* The identity-constraint defs */\n};\n\n/*\n * XML_SCHEMAS_FACET_UNKNOWN:\n *\n * unknown facet handling\n */\n#define XML_SCHEMAS_FACET_UNKNOWN        0\n/*\n * XML_SCHEMAS_FACET_PRESERVE:\n *\n * preserve the type of the facet\n */\n#define XML_SCHEMAS_FACET_PRESERVE        1\n/*\n * XML_SCHEMAS_FACET_REPLACE:\n *\n * replace the type of the facet\n */\n#define XML_SCHEMAS_FACET_REPLACE        2\n/*\n * XML_SCHEMAS_FACET_COLLAPSE:\n *\n * collapse the types of the facet\n */\n#define XML_SCHEMAS_FACET_COLLAPSE        3\n/**\n * A facet definition.\n */\nstruct _xmlSchemaFacet {\n    xmlSchemaTypeType type;        /* The kind of type */\n    struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */\n    const xmlChar *value; /* The original value */\n    const xmlChar *id; /* Obsolete */\n    xmlSchemaAnnotPtr annot;\n    xmlNodePtr node;\n    int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */\n    int whitespace;\n    xmlSchemaValPtr val; /* The compiled value */\n    xmlRegexpPtr    regexp; /* The regex for patterns */\n};\n\n/**\n * A notation definition.\n */\ntypedef struct _xmlSchemaNotation xmlSchemaNotation;\ntypedef xmlSchemaNotation *xmlSchemaNotationPtr;\nstruct _xmlSchemaNotation {\n    xmlSchemaTypeType type; /* The kind of type */\n    const xmlChar *name;\n    xmlSchemaAnnotPtr annot;\n    const xmlChar *identifier;\n    const xmlChar *targetNamespace;\n};\n\n/*\n* TODO: Actually all those flags used for the schema should sit\n* on the schema parser context, since they are used only\n* during parsing an XML schema document, and not available\n* on the component level as per spec.\n*/\n/**\n * XML_SCHEMAS_QUALIF_ELEM:\n *\n * Reflects elementFormDefault == qualified in\n * an XML schema document.\n */\n#define XML_SCHEMAS_QUALIF_ELEM                1 << 0\n/**\n * XML_SCHEMAS_QUALIF_ATTR:\n *\n * Reflects attributeFormDefault == qualified in\n * an XML schema document.\n */\n#define XML_SCHEMAS_QUALIF_ATTR            1 << 1\n/**\n * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION:\n *\n * the schema has \"extension\" in the set of finalDefault.\n */\n#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION        1 << 2\n/**\n * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION:\n *\n * the schema has \"restriction\" in the set of finalDefault.\n */\n#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION            1 << 3\n/**\n * XML_SCHEMAS_FINAL_DEFAULT_LIST:\n *\n * the schema has \"list\" in the set of finalDefault.\n */\n#define XML_SCHEMAS_FINAL_DEFAULT_LIST            1 << 4\n/**\n * XML_SCHEMAS_FINAL_DEFAULT_UNION:\n *\n * the schema has \"union\" in the set of finalDefault.\n */\n#define XML_SCHEMAS_FINAL_DEFAULT_UNION            1 << 5\n/**\n * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION:\n *\n * the schema has \"extension\" in the set of blockDefault.\n */\n#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION            1 << 6\n/**\n * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION:\n *\n * the schema has \"restriction\" in the set of blockDefault.\n */\n#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION            1 << 7\n/**\n * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION:\n *\n * the schema has \"substitution\" in the set of blockDefault.\n */\n#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION            1 << 8\n/**\n * XML_SCHEMAS_INCLUDING_CONVERT_NS:\n *\n * the schema is currently including an other schema with\n * no target namespace.\n */\n#define XML_SCHEMAS_INCLUDING_CONVERT_NS            1 << 9\n/**\n * _xmlSchema:\n *\n * A Schemas definition\n */\nstruct _xmlSchema {\n    const xmlChar *name; /* schema name */\n    const xmlChar *targetNamespace; /* the target namespace */\n    const xmlChar *version;\n    const xmlChar *id; /* Obsolete */\n    xmlDocPtr doc;\n    xmlSchemaAnnotPtr annot;\n    int flags;\n\n    xmlHashTablePtr typeDecl;\n    xmlHashTablePtr attrDecl;\n    xmlHashTablePtr attrgrpDecl;\n    xmlHashTablePtr elemDecl;\n    xmlHashTablePtr notaDecl;\n\n    xmlHashTablePtr schemasImports;\n\n    void *_private;        /* unused by the library for users or bindings */\n    xmlHashTablePtr groupDecl;\n    xmlDictPtr      dict;\n    void *includes;     /* the includes, this is opaque for now */\n    int preserve;        /* whether to free the document */\n    int counter; /* used to give anonymous components unique names */\n    xmlHashTablePtr idcDef; /* All identity-constraint defs. */\n    void *volatiles; /* Obsolete */\n};\n\nXMLPUBFUN void         xmlSchemaFreeType        (xmlSchemaTypePtr type);\nXMLPUBFUN void         xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMAS_ENABLED */\n#endif /* __XML_SCHEMA_INTERNALS_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/schematron.h",
    "content": "/*\n * Summary: XML Schematron implementation\n * Description: interface to the XML Schematron validity checking.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SCHEMATRON_H__\n#define __XML_SCHEMATRON_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_SCHEMATRON_ENABLED\n\n#include <libxml/tree.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef enum {\n    XML_SCHEMATRON_OUT_QUIET = 1 << 0,\t/* quiet no report */\n    XML_SCHEMATRON_OUT_TEXT = 1 << 1,\t/* build a textual report */\n    XML_SCHEMATRON_OUT_XML = 1 << 2,\t/* output SVRL */\n    XML_SCHEMATRON_OUT_ERROR = 1 << 3,  /* output via xmlStructuredErrorFunc */\n    XML_SCHEMATRON_OUT_FILE = 1 << 8,\t/* output to a file descriptor */\n    XML_SCHEMATRON_OUT_BUFFER = 1 << 9,\t/* output to a buffer */\n    XML_SCHEMATRON_OUT_IO = 1 << 10\t/* output to I/O mechanism */\n} xmlSchematronValidOptions;\n\n/**\n * The schemas related types are kept internal\n */\ntypedef struct _xmlSchematron xmlSchematron;\ntypedef xmlSchematron *xmlSchematronPtr;\n\n/**\n * xmlSchematronValidityErrorFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of an error callback from a Schematron validation\n */\ntypedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...);\n\n/**\n * xmlSchematronValidityWarningFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of a warning callback from a Schematron validation\n */\ntypedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...);\n\n/**\n * A schemas validation context\n */\ntypedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt;\ntypedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr;\n\ntypedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt;\ntypedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr;\n\n/*\n * Interfaces for parsing.\n */\nXMLPUBFUN xmlSchematronParserCtxtPtr\n\t    xmlSchematronNewParserCtxt\t(const char *URL);\nXMLPUBFUN xmlSchematronParserCtxtPtr\n\t    xmlSchematronNewMemParserCtxt(const char *buffer,\n\t\t\t\t\t int size);\nXMLPUBFUN xmlSchematronParserCtxtPtr\n\t    xmlSchematronNewDocParserCtxt(xmlDocPtr doc);\nXMLPUBFUN void\n\t    xmlSchematronFreeParserCtxt\t(xmlSchematronParserCtxtPtr ctxt);\n/*****\nXMLPUBFUN void\n\t    xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt,\n\t\t\t\t\t xmlSchematronValidityErrorFunc err,\n\t\t\t\t\t xmlSchematronValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t\txmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt,\n\t\t\t\t\txmlSchematronValidityErrorFunc * err,\n\t\t\t\t\txmlSchematronValidityWarningFunc * warn,\n\t\t\t\t\tvoid **ctx);\nXMLPUBFUN int\n\t\txmlSchematronIsValid\t(xmlSchematronValidCtxtPtr ctxt);\n *****/\nXMLPUBFUN xmlSchematronPtr\n\t    xmlSchematronParse\t\t(xmlSchematronParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t    xmlSchematronFree\t\t(xmlSchematronPtr schema);\n/*\n * Interfaces for validating\n */\nXMLPUBFUN void\n\t    xmlSchematronSetValidStructuredErrors(\n\t                                  xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t  xmlStructuredErrorFunc serror,\n\t\t\t\t\t  void *ctx);\n/******\nXMLPUBFUN void\n\t    xmlSchematronSetValidErrors\t(xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSchematronValidityErrorFunc err,\n\t\t\t\t\t xmlSchematronValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t    xmlSchematronGetValidErrors\t(xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSchematronValidityErrorFunc *err,\n\t\t\t\t\t xmlSchematronValidityWarningFunc *warn,\n\t\t\t\t\t void **ctx);\nXMLPUBFUN int\n\t    xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t    xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt);\nXMLPUBFUN int\n            xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt,\n\t\t\t                 xmlNodePtr elem);\n *******/\n\nXMLPUBFUN xmlSchematronValidCtxtPtr\n\t    xmlSchematronNewValidCtxt\t(xmlSchematronPtr schema,\n\t\t\t\t\t int options);\nXMLPUBFUN void\n\t    xmlSchematronFreeValidCtxt\t(xmlSchematronValidCtxtPtr ctxt);\nXMLPUBFUN int\n\t    xmlSchematronValidateDoc\t(xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr instance);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMATRON_ENABLED */\n#endif /* __XML_SCHEMATRON_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/threads.h",
    "content": "/**\n * Summary: interfaces for thread handling\n * Description: set of generic threading related routines\n *              should work with pthreads, Windows native or TLS threads\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_THREADS_H__\n#define __XML_THREADS_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * xmlMutex are a simple mutual exception locks.\n */\ntypedef struct _xmlMutex xmlMutex;\ntypedef xmlMutex *xmlMutexPtr;\n\n/*\n * xmlRMutex are reentrant mutual exception locks.\n */\ntypedef struct _xmlRMutex xmlRMutex;\ntypedef xmlRMutex *xmlRMutexPtr;\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/globals.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nXMLPUBFUN xmlMutexPtr\n\t\t\txmlNewMutex\t(void);\nXMLPUBFUN void\n\t\t\txmlMutexLock\t(xmlMutexPtr tok);\nXMLPUBFUN void\n\t\t\txmlMutexUnlock\t(xmlMutexPtr tok);\nXMLPUBFUN void\n\t\t\txmlFreeMutex\t(xmlMutexPtr tok);\n\nXMLPUBFUN xmlRMutexPtr\n\t\t\txmlNewRMutex\t(void);\nXMLPUBFUN void\n\t\t\txmlRMutexLock\t(xmlRMutexPtr tok);\nXMLPUBFUN void\n\t\t\txmlRMutexUnlock\t(xmlRMutexPtr tok);\nXMLPUBFUN void\n\t\t\txmlFreeRMutex\t(xmlRMutexPtr tok);\n\n/*\n * Library wide APIs.\n */\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlInitThreads\t(void);\nXMLPUBFUN void\n\t\t\txmlLockLibrary\t(void);\nXMLPUBFUN void\n\t\t\txmlUnlockLibrary(void);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlGetThreadId\t(void);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlIsMainThread\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlCleanupThreads(void);\nXML_DEPRECATED\nXMLPUBFUN xmlGlobalStatePtr\n\t\t\txmlGetGlobalState(void);\n\n/** DOC_DISABLE */\n#if defined(LIBXML_THREAD_ENABLED) && defined(_WIN32) && \\\n    !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)\nint\nxmlDllMain(void *hinstDLL, unsigned long fdwReason,\n           void *lpvReserved);\n#endif\n/** DOC_ENABLE */\n\n#ifdef __cplusplus\n}\n#endif\n\n\n#endif /* __XML_THREADS_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/tree.h",
    "content": "/*\n * Summary: interfaces for tree manipulation\n * Description: this module describes the structures found in an tree resulting\n *              from an XML or HTML parsing, as well as the API provided for\n *              various processing on that tree\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_TREE_H__\n#define __XML_TREE_H__\n\n#include <stdio.h>\n#include <limits.h>\n#include <libxml/xmlversion.h>\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Some of the basic types pointer to structures:\n */\n/* xmlIO.h */\ntypedef struct _xmlParserInputBuffer xmlParserInputBuffer;\ntypedef xmlParserInputBuffer *xmlParserInputBufferPtr;\n\ntypedef struct _xmlOutputBuffer xmlOutputBuffer;\ntypedef xmlOutputBuffer *xmlOutputBufferPtr;\n\n/* parser.h */\ntypedef struct _xmlParserInput xmlParserInput;\ntypedef xmlParserInput *xmlParserInputPtr;\n\ntypedef struct _xmlParserCtxt xmlParserCtxt;\ntypedef xmlParserCtxt *xmlParserCtxtPtr;\n\ntypedef struct _xmlSAXLocator xmlSAXLocator;\ntypedef xmlSAXLocator *xmlSAXLocatorPtr;\n\ntypedef struct _xmlSAXHandler xmlSAXHandler;\ntypedef xmlSAXHandler *xmlSAXHandlerPtr;\n\n/* entities.h */\ntypedef struct _xmlEntity xmlEntity;\ntypedef xmlEntity *xmlEntityPtr;\n\n/**\n * BASE_BUFFER_SIZE:\n *\n * default buffer size 4000.\n */\n#define BASE_BUFFER_SIZE 4096\n\n/**\n * LIBXML_NAMESPACE_DICT:\n *\n * Defines experimental behaviour:\n * 1) xmlNs gets an additional field @context (a xmlDoc)\n * 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc.\n */\n/* #define LIBXML_NAMESPACE_DICT */\n\n/**\n * xmlBufferAllocationScheme:\n *\n * A buffer allocation scheme can be defined to either match exactly the\n * need or double it's allocated size each time it is found too small.\n */\n\ntypedef enum {\n    XML_BUFFER_ALLOC_DOUBLEIT,\t/* double each time one need to grow */\n    XML_BUFFER_ALLOC_EXACT,\t/* grow only to the minimal size */\n    XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer, deprecated */\n    XML_BUFFER_ALLOC_IO,\t/* special allocation scheme used for I/O */\n    XML_BUFFER_ALLOC_HYBRID,\t/* exact up to a threshold, and doubleit thereafter */\n    XML_BUFFER_ALLOC_BOUNDED\t/* limit the upper size of the buffer */\n} xmlBufferAllocationScheme;\n\n/**\n * xmlBuffer:\n *\n * A buffer structure, this old construct is limited to 2GB and\n * is being deprecated, use API with xmlBuf instead\n */\ntypedef struct _xmlBuffer xmlBuffer;\ntypedef xmlBuffer *xmlBufferPtr;\nstruct _xmlBuffer {\n    xmlChar *content;\t\t/* The buffer content UTF8 */\n    unsigned int use;\t\t/* The buffer size used */\n    unsigned int size;\t\t/* The buffer size */\n    xmlBufferAllocationScheme alloc; /* The realloc method */\n    xmlChar *contentIO;\t\t/* in IO mode we may have a different base */\n};\n\n/**\n * xmlBuf:\n *\n * A buffer structure, new one, the actual structure internals are not public\n */\n\ntypedef struct _xmlBuf xmlBuf;\n\n/**\n * xmlBufPtr:\n *\n * A pointer to a buffer structure, the actual structure internals are not\n * public\n */\n\ntypedef xmlBuf *xmlBufPtr;\n\n/*\n * A few public routines for xmlBuf. As those are expected to be used\n * mostly internally the bulk of the routines are internal in buf.h\n */\nXMLPUBFUN xmlChar*       xmlBufContent\t(const xmlBuf* buf);\nXMLPUBFUN xmlChar*       xmlBufEnd      (xmlBufPtr buf);\nXMLPUBFUN size_t         xmlBufUse      (const xmlBufPtr buf);\nXMLPUBFUN size_t         xmlBufShrink\t(xmlBufPtr buf, size_t len);\n\n/*\n * LIBXML2_NEW_BUFFER:\n *\n * Macro used to express that the API use the new buffers for\n * xmlParserInputBuffer and xmlOutputBuffer. The change was\n * introduced in 2.9.0.\n */\n#define LIBXML2_NEW_BUFFER\n\n/**\n * XML_XML_NAMESPACE:\n *\n * This is the namespace for the special xml: prefix predefined in the\n * XML Namespace specification.\n */\n#define XML_XML_NAMESPACE \\\n    (const xmlChar *) \"http://www.w3.org/XML/1998/namespace\"\n\n/**\n * XML_XML_ID:\n *\n * This is the name for the special xml:id attribute\n */\n#define XML_XML_ID (const xmlChar *) \"xml:id\"\n\n/*\n * The different element types carried by an XML tree.\n *\n * NOTE: This is synchronized with DOM Level1 values\n *       See http://www.w3.org/TR/REC-DOM-Level-1/\n *\n * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should\n * be deprecated to use an XML_DTD_NODE.\n */\ntypedef enum {\n    XML_ELEMENT_NODE=\t\t1,\n    XML_ATTRIBUTE_NODE=\t\t2,\n    XML_TEXT_NODE=\t\t3,\n    XML_CDATA_SECTION_NODE=\t4,\n    XML_ENTITY_REF_NODE=\t5,\n    XML_ENTITY_NODE=\t\t6,\n    XML_PI_NODE=\t\t7,\n    XML_COMMENT_NODE=\t\t8,\n    XML_DOCUMENT_NODE=\t\t9,\n    XML_DOCUMENT_TYPE_NODE=\t10,\n    XML_DOCUMENT_FRAG_NODE=\t11,\n    XML_NOTATION_NODE=\t\t12,\n    XML_HTML_DOCUMENT_NODE=\t13,\n    XML_DTD_NODE=\t\t14,\n    XML_ELEMENT_DECL=\t\t15,\n    XML_ATTRIBUTE_DECL=\t\t16,\n    XML_ENTITY_DECL=\t\t17,\n    XML_NAMESPACE_DECL=\t\t18,\n    XML_XINCLUDE_START=\t\t19,\n    XML_XINCLUDE_END=\t\t20\n    /* XML_DOCB_DOCUMENT_NODE=\t21 */ /* removed */\n} xmlElementType;\n\n/** DOC_DISABLE */\n/* For backward compatibility */\n#define XML_DOCB_DOCUMENT_NODE 21\n/** DOC_ENABLE */\n\n/**\n * xmlNotation:\n *\n * A DTD Notation definition.\n */\n\ntypedef struct _xmlNotation xmlNotation;\ntypedef xmlNotation *xmlNotationPtr;\nstruct _xmlNotation {\n    const xmlChar               *name;\t        /* Notation name */\n    const xmlChar               *PublicID;\t/* Public identifier, if any */\n    const xmlChar               *SystemID;\t/* System identifier, if any */\n};\n\n/**\n * xmlAttributeType:\n *\n * A DTD Attribute type definition.\n */\n\ntypedef enum {\n    XML_ATTRIBUTE_CDATA = 1,\n    XML_ATTRIBUTE_ID,\n    XML_ATTRIBUTE_IDREF\t,\n    XML_ATTRIBUTE_IDREFS,\n    XML_ATTRIBUTE_ENTITY,\n    XML_ATTRIBUTE_ENTITIES,\n    XML_ATTRIBUTE_NMTOKEN,\n    XML_ATTRIBUTE_NMTOKENS,\n    XML_ATTRIBUTE_ENUMERATION,\n    XML_ATTRIBUTE_NOTATION\n} xmlAttributeType;\n\n/**\n * xmlAttributeDefault:\n *\n * A DTD Attribute default definition.\n */\n\ntypedef enum {\n    XML_ATTRIBUTE_NONE = 1,\n    XML_ATTRIBUTE_REQUIRED,\n    XML_ATTRIBUTE_IMPLIED,\n    XML_ATTRIBUTE_FIXED\n} xmlAttributeDefault;\n\n/**\n * xmlEnumeration:\n *\n * List structure used when there is an enumeration in DTDs.\n */\n\ntypedef struct _xmlEnumeration xmlEnumeration;\ntypedef xmlEnumeration *xmlEnumerationPtr;\nstruct _xmlEnumeration {\n    struct _xmlEnumeration    *next;\t/* next one */\n    const xmlChar            *name;\t/* Enumeration name */\n};\n\n/**\n * xmlAttribute:\n *\n * An Attribute declaration in a DTD.\n */\n\ntypedef struct _xmlAttribute xmlAttribute;\ntypedef xmlAttribute *xmlAttributePtr;\nstruct _xmlAttribute {\n    void           *_private;\t        /* application data */\n    xmlElementType          type;       /* XML_ATTRIBUTE_DECL, must be second ! */\n    const xmlChar          *name;\t/* Attribute name */\n    struct _xmlNode    *children;\t/* NULL */\n    struct _xmlNode        *last;\t/* NULL */\n    struct _xmlDtd       *parent;\t/* -> DTD */\n    struct _xmlNode        *next;\t/* next sibling link  */\n    struct _xmlNode        *prev;\t/* previous sibling link  */\n    struct _xmlDoc          *doc;       /* the containing document */\n\n    struct _xmlAttribute  *nexth;\t/* next in hash table */\n    xmlAttributeType       atype;\t/* The attribute type */\n    xmlAttributeDefault      def;\t/* the default */\n    const xmlChar  *defaultValue;\t/* or the default value */\n    xmlEnumerationPtr       tree;       /* or the enumeration tree if any */\n    const xmlChar        *prefix;\t/* the namespace prefix if any */\n    const xmlChar          *elem;\t/* Element holding the attribute */\n};\n\n/**\n * xmlElementContentType:\n *\n * Possible definitions of element content types.\n */\ntypedef enum {\n    XML_ELEMENT_CONTENT_PCDATA = 1,\n    XML_ELEMENT_CONTENT_ELEMENT,\n    XML_ELEMENT_CONTENT_SEQ,\n    XML_ELEMENT_CONTENT_OR\n} xmlElementContentType;\n\n/**\n * xmlElementContentOccur:\n *\n * Possible definitions of element content occurrences.\n */\ntypedef enum {\n    XML_ELEMENT_CONTENT_ONCE = 1,\n    XML_ELEMENT_CONTENT_OPT,\n    XML_ELEMENT_CONTENT_MULT,\n    XML_ELEMENT_CONTENT_PLUS\n} xmlElementContentOccur;\n\n/**\n * xmlElementContent:\n *\n * An XML Element content as stored after parsing an element definition\n * in a DTD.\n */\n\ntypedef struct _xmlElementContent xmlElementContent;\ntypedef xmlElementContent *xmlElementContentPtr;\nstruct _xmlElementContent {\n    xmlElementContentType     type;\t/* PCDATA, ELEMENT, SEQ or OR */\n    xmlElementContentOccur    ocur;\t/* ONCE, OPT, MULT or PLUS */\n    const xmlChar             *name;\t/* Element name */\n    struct _xmlElementContent *c1;\t/* first child */\n    struct _xmlElementContent *c2;\t/* second child */\n    struct _xmlElementContent *parent;\t/* parent */\n    const xmlChar             *prefix;\t/* Namespace prefix */\n};\n\n/**\n * xmlElementTypeVal:\n *\n * The different possibilities for an element content type.\n */\n\ntypedef enum {\n    XML_ELEMENT_TYPE_UNDEFINED = 0,\n    XML_ELEMENT_TYPE_EMPTY = 1,\n    XML_ELEMENT_TYPE_ANY,\n    XML_ELEMENT_TYPE_MIXED,\n    XML_ELEMENT_TYPE_ELEMENT\n} xmlElementTypeVal;\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/xmlregexp.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlElement:\n *\n * An XML Element declaration from a DTD.\n */\n\ntypedef struct _xmlElement xmlElement;\ntypedef xmlElement *xmlElementPtr;\nstruct _xmlElement {\n    void           *_private;\t        /* application data */\n    xmlElementType          type;       /* XML_ELEMENT_DECL, must be second ! */\n    const xmlChar          *name;\t/* Element name */\n    struct _xmlNode    *children;\t/* NULL */\n    struct _xmlNode        *last;\t/* NULL */\n    struct _xmlDtd       *parent;\t/* -> DTD */\n    struct _xmlNode        *next;\t/* next sibling link  */\n    struct _xmlNode        *prev;\t/* previous sibling link  */\n    struct _xmlDoc          *doc;       /* the containing document */\n\n    xmlElementTypeVal      etype;\t/* The type */\n    xmlElementContentPtr content;\t/* the allowed element content */\n    xmlAttributePtr   attributes;\t/* List of the declared attributes */\n    const xmlChar        *prefix;\t/* the namespace prefix if any */\n#ifdef LIBXML_REGEXP_ENABLED\n    xmlRegexpPtr       contModel;\t/* the validating regexp */\n#else\n    void\t      *contModel;\n#endif\n};\n\n\n/**\n * XML_LOCAL_NAMESPACE:\n *\n * A namespace declaration node.\n */\n#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL\ntypedef xmlElementType xmlNsType;\n\n/**\n * xmlNs:\n *\n * An XML namespace.\n * Note that prefix == NULL is valid, it defines the default namespace\n * within the subtree (until overridden).\n *\n * xmlNsType is unified with xmlElementType.\n */\n\ntypedef struct _xmlNs xmlNs;\ntypedef xmlNs *xmlNsPtr;\nstruct _xmlNs {\n    struct _xmlNs  *next;\t/* next Ns link for this node  */\n    xmlNsType      type;\t/* global or local */\n    const xmlChar *href;\t/* URL for the namespace */\n    const xmlChar *prefix;\t/* prefix for the namespace */\n    void           *_private;   /* application data */\n    struct _xmlDoc *context;\t\t/* normally an xmlDoc */\n};\n\n/**\n * xmlDtd:\n *\n * An XML DTD, as defined by <!DOCTYPE ... There is actually one for\n * the internal subset and for the external subset.\n */\ntypedef struct _xmlDtd xmlDtd;\ntypedef xmlDtd *xmlDtdPtr;\nstruct _xmlDtd {\n    void           *_private;\t/* application data */\n    xmlElementType  type;       /* XML_DTD_NODE, must be second ! */\n    const xmlChar *name;\t/* Name of the DTD */\n    struct _xmlNode *children;\t/* the value of the property link */\n    struct _xmlNode *last;\t/* last child link */\n    struct _xmlDoc  *parent;\t/* child->parent link */\n    struct _xmlNode *next;\t/* next sibling link  */\n    struct _xmlNode *prev;\t/* previous sibling link  */\n    struct _xmlDoc  *doc;\t/* the containing document */\n\n    /* End of common part */\n    void          *notations;   /* Hash table for notations if any */\n    void          *elements;    /* Hash table for elements if any */\n    void          *attributes;  /* Hash table for attributes if any */\n    void          *entities;    /* Hash table for entities if any */\n    const xmlChar *ExternalID;\t/* External identifier for PUBLIC DTD */\n    const xmlChar *SystemID;\t/* URI for a SYSTEM or PUBLIC DTD */\n    void          *pentities;   /* Hash table for param entities if any */\n};\n\n/**\n * xmlAttr:\n *\n * An attribute on an XML node.\n */\ntypedef struct _xmlAttr xmlAttr;\ntypedef xmlAttr *xmlAttrPtr;\nstruct _xmlAttr {\n    void           *_private;\t/* application data */\n    xmlElementType   type;      /* XML_ATTRIBUTE_NODE, must be second ! */\n    const xmlChar   *name;      /* the name of the property */\n    struct _xmlNode *children;\t/* the value of the property */\n    struct _xmlNode *last;\t/* NULL */\n    struct _xmlNode *parent;\t/* child->parent link */\n    struct _xmlAttr *next;\t/* next sibling link  */\n    struct _xmlAttr *prev;\t/* previous sibling link  */\n    struct _xmlDoc  *doc;\t/* the containing document */\n    xmlNs           *ns;        /* pointer to the associated namespace */\n    xmlAttributeType atype;     /* the attribute type if validating */\n    void            *psvi;\t/* for type/PSVI information */\n};\n\n/**\n * xmlID:\n *\n * An XML ID instance.\n */\n\ntypedef struct _xmlID xmlID;\ntypedef xmlID *xmlIDPtr;\nstruct _xmlID {\n    struct _xmlID    *next;\t/* next ID */\n    const xmlChar    *value;\t/* The ID name */\n    xmlAttrPtr        attr;\t/* The attribute holding it */\n    const xmlChar    *name;\t/* The attribute if attr is not available */\n    int               lineno;\t/* The line number if attr is not available */\n    struct _xmlDoc   *doc;\t/* The document holding the ID */\n};\n\n/**\n * xmlRef:\n *\n * An XML IDREF instance.\n */\n\ntypedef struct _xmlRef xmlRef;\ntypedef xmlRef *xmlRefPtr;\nstruct _xmlRef {\n    struct _xmlRef    *next;\t/* next Ref */\n    const xmlChar     *value;\t/* The Ref name */\n    xmlAttrPtr        attr;\t/* The attribute holding it */\n    const xmlChar    *name;\t/* The attribute if attr is not available */\n    int               lineno;\t/* The line number if attr is not available */\n};\n\n/**\n * xmlNode:\n *\n * A node in an XML tree.\n */\ntypedef struct _xmlNode xmlNode;\ntypedef xmlNode *xmlNodePtr;\nstruct _xmlNode {\n    void           *_private;\t/* application data */\n    xmlElementType   type;\t/* type number, must be second ! */\n    const xmlChar   *name;      /* the name of the node, or the entity */\n    struct _xmlNode *children;\t/* parent->childs link */\n    struct _xmlNode *last;\t/* last child link */\n    struct _xmlNode *parent;\t/* child->parent link */\n    struct _xmlNode *next;\t/* next sibling link  */\n    struct _xmlNode *prev;\t/* previous sibling link  */\n    struct _xmlDoc  *doc;\t/* the containing document */\n\n    /* End of common part */\n    xmlNs           *ns;        /* pointer to the associated namespace */\n    xmlChar         *content;   /* the content */\n    struct _xmlAttr *properties;/* properties list */\n    xmlNs           *nsDef;     /* namespace definitions on this node */\n    void            *psvi;\t/* for type/PSVI information */\n    unsigned short   line;\t/* line number */\n    unsigned short   extra;\t/* extra data for XPath/XSLT */\n};\n\n/**\n * XML_GET_CONTENT:\n *\n * Macro to extract the content pointer of a node.\n */\n#define XML_GET_CONTENT(n)\t\t\t\t\t\\\n    ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content)\n\n/**\n * XML_GET_LINE:\n *\n * Macro to extract the line number of an element node.\n */\n#define XML_GET_LINE(n)\t\t\t\t\t\t\\\n    (xmlGetLineNo(n))\n\n/**\n * xmlDocProperty\n *\n * Set of properties of the document as found by the parser\n * Some of them are linked to similarly named xmlParserOption\n */\ntypedef enum {\n    XML_DOC_WELLFORMED\t\t= 1<<0, /* document is XML well formed */\n    XML_DOC_NSVALID\t\t= 1<<1, /* document is Namespace valid */\n    XML_DOC_OLD10\t\t= 1<<2, /* parsed with old XML-1.0 parser */\n    XML_DOC_DTDVALID\t\t= 1<<3, /* DTD validation was successful */\n    XML_DOC_XINCLUDE\t\t= 1<<4, /* XInclude substitution was done */\n    XML_DOC_USERBUILT\t\t= 1<<5, /* Document was built using the API\n                                           and not by parsing an instance */\n    XML_DOC_INTERNAL\t\t= 1<<6, /* built for internal processing */\n    XML_DOC_HTML\t\t= 1<<7  /* parsed or built HTML document */\n} xmlDocProperties;\n\n/**\n * xmlDoc:\n *\n * An XML document.\n */\ntypedef struct _xmlDoc xmlDoc;\ntypedef xmlDoc *xmlDocPtr;\nstruct _xmlDoc {\n    void           *_private;\t/* application data */\n    xmlElementType  type;       /* XML_DOCUMENT_NODE, must be second ! */\n    char           *name;\t/* name/filename/URI of the document */\n    struct _xmlNode *children;\t/* the document tree */\n    struct _xmlNode *last;\t/* last child link */\n    struct _xmlNode *parent;\t/* child->parent link */\n    struct _xmlNode *next;\t/* next sibling link  */\n    struct _xmlNode *prev;\t/* previous sibling link  */\n    struct _xmlDoc  *doc;\t/* autoreference to itself */\n\n    /* End of common part */\n    int             compression;/* level of zlib compression */\n    int             standalone; /* standalone document (no external refs)\n\t\t\t\t     1 if standalone=\"yes\"\n\t\t\t\t     0 if standalone=\"no\"\n\t\t\t\t    -1 if there is no XML declaration\n\t\t\t\t    -2 if there is an XML declaration, but no\n\t\t\t\t\tstandalone attribute was specified */\n    struct _xmlDtd  *intSubset;\t/* the document internal subset */\n    struct _xmlDtd  *extSubset;\t/* the document external subset */\n    struct _xmlNs   *oldNs;\t/* Global namespace, the old way */\n    const xmlChar  *version;\t/* the XML version string */\n    const xmlChar  *encoding;   /* external initial encoding, if any */\n    void           *ids;        /* Hash table for ID attributes if any */\n    void           *refs;       /* Hash table for IDREFs attributes if any */\n    const xmlChar  *URL;\t/* The URI for that document */\n    int             charset;    /* Internal flag for charset handling,\n\t\t\t\t   actually an xmlCharEncoding */\n    struct _xmlDict *dict;      /* dict used to allocate names or NULL */\n    void           *psvi;\t/* for type/PSVI information */\n    int             parseFlags;\t/* set of xmlParserOption used to parse the\n\t\t\t\t   document */\n    int             properties;\t/* set of xmlDocProperties for this document\n\t\t\t\t   set at the end of parsing */\n};\n\n\ntypedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt;\ntypedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr;\n\n/**\n * xmlDOMWrapAcquireNsFunction:\n * @ctxt:  a DOM wrapper context\n * @node:  the context node (element or attribute)\n * @nsName:  the requested namespace name\n * @nsPrefix:  the requested namespace prefix\n *\n * A function called to acquire namespaces (xmlNs) from the wrapper.\n *\n * Returns an xmlNsPtr or NULL in case of an error.\n */\ntypedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t\t const xmlChar *nsName,\n\t\t\t\t\t\t const xmlChar *nsPrefix);\n\n/**\n * xmlDOMWrapCtxt:\n *\n * Context for DOM wrapper-operations.\n */\nstruct _xmlDOMWrapCtxt {\n    void * _private;\n    /*\n    * The type of this context, just in case we need specialized\n    * contexts in the future.\n    */\n    int type;\n    /*\n    * Internal namespace map used for various operations.\n    */\n    void * namespaceMap;\n    /*\n    * Use this one to acquire an xmlNsPtr intended for node->ns.\n    * (Note that this is not intended for elem->nsDef).\n    */\n    xmlDOMWrapAcquireNsFunction getNsForNodeFunc;\n};\n\n/**\n * xmlChildrenNode:\n *\n * Macro for compatibility naming layer with libxml1. Maps\n * to \"children.\"\n */\n#ifndef xmlChildrenNode\n#define xmlChildrenNode children\n#endif\n\n/**\n * xmlRootNode:\n *\n * Macro for compatibility naming layer with libxml1. Maps\n * to \"children\".\n */\n#ifndef xmlRootNode\n#define xmlRootNode children\n#endif\n\n/*\n * Variables.\n */\n\n/*\n * Some helper functions\n */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \\\n    defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \\\n    defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \\\n    defined(LIBXML_LEGACY_ENABLED)\nXMLPUBFUN int\n\t\txmlValidateNCName\t(const xmlChar *value,\n\t\t\t\t\t int space);\n#endif\n\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN int\n\t\txmlValidateQName\t(const xmlChar *value,\n\t\t\t\t\t int space);\nXMLPUBFUN int\n\t\txmlValidateName\t\t(const xmlChar *value,\n\t\t\t\t\t int space);\nXMLPUBFUN int\n\t\txmlValidateNMToken\t(const xmlChar *value,\n\t\t\t\t\t int space);\n#endif\n\nXMLPUBFUN xmlChar *\n\t\txmlBuildQName\t\t(const xmlChar *ncname,\n\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t xmlChar *memory,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlChar *\n\t\txmlSplitQName2\t\t(const xmlChar *name,\n\t\t\t\t\t xmlChar **prefix);\nXMLPUBFUN const xmlChar *\n\t\txmlSplitQName3\t\t(const xmlChar *name,\n\t\t\t\t\t int *len);\n\n/*\n * Handling Buffers, the old ones see @xmlBuf for the new ones.\n */\n\nXMLPUBFUN void\n\t\txmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);\nXMLPUBFUN xmlBufferAllocationScheme\n\t\txmlGetBufferAllocationScheme(void);\n\nXMLPUBFUN xmlBufferPtr\n\t\txmlBufferCreate\t\t(void);\nXMLPUBFUN xmlBufferPtr\n\t\txmlBufferCreateSize\t(size_t size);\nXMLPUBFUN xmlBufferPtr\n\t\txmlBufferCreateStatic\t(void *mem,\n\t\t\t\t\t size_t size);\nXMLPUBFUN int\n\t\txmlBufferResize\t\t(xmlBufferPtr buf,\n\t\t\t\t\t unsigned int size);\nXMLPUBFUN void\n\t\txmlBufferFree\t\t(xmlBufferPtr buf);\nXMLPUBFUN int\n\t\txmlBufferDump\t\t(FILE *file,\n\t\t\t\t\t xmlBufferPtr buf);\nXMLPUBFUN int\n\t\txmlBufferAdd\t\t(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\txmlBufferAddHead\t(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\txmlBufferCat\t\t(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *str);\nXMLPUBFUN int\n\t\txmlBufferCCat\t\t(xmlBufferPtr buf,\n\t\t\t\t\t const char *str);\nXMLPUBFUN int\n\t\txmlBufferShrink\t\t(xmlBufferPtr buf,\n\t\t\t\t\t unsigned int len);\nXMLPUBFUN int\n\t\txmlBufferGrow\t\t(xmlBufferPtr buf,\n\t\t\t\t\t unsigned int len);\nXMLPUBFUN void\n\t\txmlBufferEmpty\t\t(xmlBufferPtr buf);\nXMLPUBFUN const xmlChar*\n\t\txmlBufferContent\t(const xmlBuffer *buf);\nXMLPUBFUN xmlChar*\n\t\txmlBufferDetach         (xmlBufferPtr buf);\nXMLPUBFUN void\n\t\txmlBufferSetAllocationScheme(xmlBufferPtr buf,\n\t\t\t\t\t xmlBufferAllocationScheme scheme);\nXMLPUBFUN int\n\t\txmlBufferLength\t\t(const xmlBuffer *buf);\n\n/*\n * Creating/freeing new structures.\n */\nXMLPUBFUN xmlDtdPtr\n\t\txmlCreateIntSubset\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlDtdPtr\n\t\txmlNewDtd\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlDtdPtr\n\t\txmlGetIntSubset\t\t(const xmlDoc *doc);\nXMLPUBFUN void\n\t\txmlFreeDtd\t\t(xmlDtdPtr cur);\n#ifdef LIBXML_LEGACY_ENABLED\nXML_DEPRECATED\nXMLPUBFUN xmlNsPtr\n\t\txmlNewGlobalNs\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *href,\n\t\t\t\t\t const xmlChar *prefix);\n#endif /* LIBXML_LEGACY_ENABLED */\nXMLPUBFUN xmlNsPtr\n\t\txmlNewNs\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *href,\n\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN void\n\t\txmlFreeNs\t\t(xmlNsPtr cur);\nXMLPUBFUN void\n\t\txmlFreeNsList\t\t(xmlNsPtr cur);\nXMLPUBFUN xmlDocPtr\n\t\txmlNewDoc\t\t(const xmlChar *version);\nXMLPUBFUN void\n\t\txmlFreeDoc\t\t(xmlDocPtr cur);\nXMLPUBFUN xmlAttrPtr\n\t\txmlNewDocProp\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN xmlAttrPtr\n\t\txmlNewProp\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\n#endif\nXMLPUBFUN xmlAttrPtr\n\t\txmlNewNsProp\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlAttrPtr\n\t\txmlNewNsPropEatName\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN void\n\t\txmlFreePropList\t\t(xmlAttrPtr cur);\nXMLPUBFUN void\n\t\txmlFreeProp\t\t(xmlAttrPtr cur);\nXMLPUBFUN xmlAttrPtr\n\t\txmlCopyProp\t\t(xmlNodePtr target,\n\t\t\t\t\t xmlAttrPtr cur);\nXMLPUBFUN xmlAttrPtr\n\t\txmlCopyPropList\t\t(xmlNodePtr target,\n\t\t\t\t\t xmlAttrPtr cur);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlDtdPtr\n\t\txmlCopyDtd\t\t(xmlDtdPtr dtd);\n#endif /* LIBXML_TREE_ENABLED */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN xmlDocPtr\n\t\txmlCopyDoc\t\t(xmlDocPtr doc,\n\t\t\t\t\t int recursive);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */\n/*\n * Creating new nodes.\n */\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocNode\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocNodeEatName\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewNode\t\t(xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewNodeEatName\t(xmlNsPtr ns,\n\t\t\t\t\t xmlChar *name);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN xmlNodePtr\n\t\txmlNewChild\t\t(xmlNodePtr parent,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\n#endif\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocText\t\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewText\t\t(const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocPI\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewPI\t\t(const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocTextLen\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewTextLen\t\t(const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocComment\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewComment\t\t(const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewCDataBlock\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewCharRef\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewReference\t\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlNodePtr\n\t\txmlCopyNode\t\t(xmlNodePtr node,\n\t\t\t\t\t int recursive);\nXMLPUBFUN xmlNodePtr\n\t\txmlDocCopyNode\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t int recursive);\nXMLPUBFUN xmlNodePtr\n\t\txmlDocCopyNodeList\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodePtr\n\t\txmlCopyNodeList\t\t(xmlNodePtr node);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlNodePtr\n\t\txmlNewTextChild\t\t(xmlNodePtr parent,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocRawNode\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocFragment\t(xmlDocPtr doc);\n#endif /* LIBXML_TREE_ENABLED */\n\n/*\n * Navigating.\n */\nXMLPUBFUN long\n\t\txmlGetLineNo\t\t(const xmlNode *node);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)\nXMLPUBFUN xmlChar *\n\t\txmlGetNodePath\t\t(const xmlNode *node);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */\nXMLPUBFUN xmlNodePtr\n\t\txmlDocGetRootElement\t(const xmlDoc *doc);\nXMLPUBFUN xmlNodePtr\n\t\txmlGetLastChild\t\t(const xmlNode *parent);\nXMLPUBFUN int\n\t\txmlNodeIsText\t\t(const xmlNode *node);\nXMLPUBFUN int\n\t\txmlIsBlankNode\t\t(const xmlNode *node);\n\n/*\n * Changing the structure.\n */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)\nXMLPUBFUN xmlNodePtr\n\t\txmlDocSetRootElement\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr root);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN void\n\t\txmlNodeSetName\t\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *name);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN xmlNodePtr\n\t\txmlAddChild\t\t(xmlNodePtr parent,\n\t\t\t\t\t xmlNodePtr cur);\nXMLPUBFUN xmlNodePtr\n\t\txmlAddChildList\t\t(xmlNodePtr parent,\n\t\t\t\t\t xmlNodePtr cur);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)\nXMLPUBFUN xmlNodePtr\n\t\txmlReplaceNode\t\t(xmlNodePtr old,\n\t\t\t\t\t xmlNodePtr cur);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)\nXMLPUBFUN xmlNodePtr\n\t\txmlAddPrevSibling\t(xmlNodePtr cur,\n\t\t\t\t\t xmlNodePtr elem);\n#endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */\nXMLPUBFUN xmlNodePtr\n\t\txmlAddSibling\t\t(xmlNodePtr cur,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN xmlNodePtr\n\t\txmlAddNextSibling\t(xmlNodePtr cur,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN void\n\t\txmlUnlinkNode\t\t(xmlNodePtr cur);\nXMLPUBFUN xmlNodePtr\n\t\txmlTextMerge\t\t(xmlNodePtr first,\n\t\t\t\t\t xmlNodePtr second);\nXMLPUBFUN int\n\t\txmlTextConcat\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN void\n\t\txmlFreeNodeList\t\t(xmlNodePtr cur);\nXMLPUBFUN void\n\t\txmlFreeNode\t\t(xmlNodePtr cur);\nXMLPUBFUN void\n\t\txmlSetTreeDoc\t\t(xmlNodePtr tree,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN void\n\t\txmlSetListDoc\t\t(xmlNodePtr list,\n\t\t\t\t\t xmlDocPtr doc);\n/*\n * Namespaces.\n */\nXMLPUBFUN xmlNsPtr\n\t\txmlSearchNs\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t const xmlChar *nameSpace);\nXMLPUBFUN xmlNsPtr\n\t\txmlSearchNsByHref\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t const xmlChar *href);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN xmlNsPtr *\n\t\txmlGetNsList\t\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlNode *node);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */\n\nXMLPUBFUN void\n\t\txmlSetNs\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns);\nXMLPUBFUN xmlNsPtr\n\t\txmlCopyNamespace\t(xmlNsPtr cur);\nXMLPUBFUN xmlNsPtr\n\t\txmlCopyNamespaceList\t(xmlNsPtr cur);\n\n/*\n * Changing the content.\n */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)\nXMLPUBFUN xmlAttrPtr\n\t\txmlSetProp\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlAttrPtr\n\t\txmlSetNsProp\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \\\n\t  defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */\nXMLPUBFUN xmlChar *\n\t\txmlGetNoNsProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlChar *\n\t\txmlGetProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlAttrPtr\n\t\txmlHasProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlAttrPtr\n\t\txmlHasNsProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *nameSpace);\nXMLPUBFUN xmlChar *\n\t\txmlGetNsProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *nameSpace);\nXMLPUBFUN xmlNodePtr\n\t\txmlStringGetNodeList\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlNodePtr\n\t\txmlStringLenGetNodeList\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlChar *\n\t\txmlNodeListGetString\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlNode *list,\n\t\t\t\t\t int inLine);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlChar *\n\t\txmlNodeListGetRawString\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlNode *list,\n\t\t\t\t\t int inLine);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlNodeSetContent\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *content);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN void\n\t\txmlNodeSetContentLen\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlNodeAddContent\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN void\n\t\txmlNodeAddContentLen\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlChar *\n\t\txmlNodeGetContent\t(const xmlNode *cur);\n\nXMLPUBFUN int\n\t\txmlNodeBufGetContent\t(xmlBufferPtr buffer,\n\t\t\t\t\t const xmlNode *cur);\nXMLPUBFUN int\n\t\txmlBufGetNodeContent\t(xmlBufPtr buf,\n\t\t\t\t\t const xmlNode *cur);\n\nXMLPUBFUN xmlChar *\n\t\txmlNodeGetLang\t\t(const xmlNode *cur);\nXMLPUBFUN int\n\t\txmlNodeGetSpacePreserve\t(const xmlNode *cur);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN void\n\t\txmlNodeSetLang\t\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *lang);\nXMLPUBFUN void\n\t\txmlNodeSetSpacePreserve (xmlNodePtr cur,\n\t\t\t\t\t int val);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN xmlChar *\n\t\txmlNodeGetBase\t\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlNode *cur);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)\nXMLPUBFUN void\n\t\txmlNodeSetBase\t\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *uri);\n#endif\n\n/*\n * Removing content.\n */\nXMLPUBFUN int\n\t\txmlRemoveProp\t\t(xmlAttrPtr cur);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN int\n\t\txmlUnsetNsProp\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN int\n\t\txmlUnsetProp\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *name);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */\n\n/*\n * Internal, don't use.\n */\nXMLPUBFUN void\n\t\txmlBufferWriteCHAR\t(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *string);\nXMLPUBFUN void\n\t\txmlBufferWriteChar\t(xmlBufferPtr buf,\n\t\t\t\t\t const char *string);\nXMLPUBFUN void\n\t\txmlBufferWriteQuotedString(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *string);\n\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlAttrPtr attr,\n\t\t\t\t\t const xmlChar *string);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n#ifdef LIBXML_TREE_ENABLED\n/*\n * Namespace handling.\n */\nXMLPUBFUN int\n\t\txmlReconciliateNs\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr tree);\n#endif\n\n#ifdef LIBXML_OUTPUT_ENABLED\n/*\n * Saving.\n */\nXMLPUBFUN void\n\t\txmlDocDumpFormatMemory\t(xmlDocPtr cur,\n\t\t\t\t\t xmlChar **mem,\n\t\t\t\t\t int *size,\n\t\t\t\t\t int format);\nXMLPUBFUN void\n\t\txmlDocDumpMemory\t(xmlDocPtr cur,\n\t\t\t\t\t xmlChar **mem,\n\t\t\t\t\t int *size);\nXMLPUBFUN void\n\t\txmlDocDumpMemoryEnc\t(xmlDocPtr out_doc,\n\t\t\t\t\t xmlChar **doc_txt_ptr,\n\t\t\t\t\t int * doc_txt_len,\n\t\t\t\t\t const char *txt_encoding);\nXMLPUBFUN void\n\t\txmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,\n\t\t\t\t\t xmlChar **doc_txt_ptr,\n\t\t\t\t\t int * doc_txt_len,\n\t\t\t\t\t const char *txt_encoding,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\txmlDocFormatDump\t(FILE *f,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\txmlDocDump\t\t(FILE *f,\n\t\t\t\t\t xmlDocPtr cur);\nXMLPUBFUN void\n\t\txmlElemDump\t\t(FILE *f,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur);\nXMLPUBFUN int\n\t\txmlSaveFile\t\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur);\nXMLPUBFUN int\n\t\txmlSaveFormatFile\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t int format);\nXMLPUBFUN size_t\n\t\txmlBufNodeDump\t\t(xmlBufPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t int level,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\txmlNodeDump\t\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t int level,\n\t\t\t\t\t int format);\n\nXMLPUBFUN int\n\t\txmlSaveFileTo\t\t(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN int\n\t\txmlSaveFormatFileTo     (xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t         const char *encoding,\n\t\t\t\t         int format);\nXMLPUBFUN void\n\t\txmlNodeDumpOutput\t(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t int level,\n\t\t\t\t\t int format,\n\t\t\t\t\t const char *encoding);\n\nXMLPUBFUN int\n\t\txmlSaveFormatFileEnc    (const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\n\nXMLPUBFUN int\n\t\txmlSaveFileEnc\t\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding);\n\n#endif /* LIBXML_OUTPUT_ENABLED */\n/*\n * XHTML\n */\nXMLPUBFUN int\n\t\txmlIsXHTML\t\t(const xmlChar *systemID,\n\t\t\t\t\t const xmlChar *publicID);\n\n/*\n * Compression.\n */\nXMLPUBFUN int\n\t\txmlGetDocCompressMode\t(const xmlDoc *doc);\nXMLPUBFUN void\n\t\txmlSetDocCompressMode\t(xmlDocPtr doc,\n\t\t\t\t\t int mode);\nXMLPUBFUN int\n\t\txmlGetCompressMode\t(void);\nXMLPUBFUN void\n\t\txmlSetCompressMode\t(int mode);\n\n/*\n* DOM-wrapper helper functions.\n*/\nXMLPUBFUN xmlDOMWrapCtxtPtr\n\t\txmlDOMWrapNewCtxt\t(void);\nXMLPUBFUN void\n\t\txmlDOMWrapFreeCtxt\t(xmlDOMWrapCtxtPtr ctxt);\nXMLPUBFUN int\n\t    xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t    xmlDOMWrapAdoptNode\t\t(xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr sourceDoc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t xmlDocPtr destDoc,\n\t\t\t\t\t xmlNodePtr destParent,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t    xmlDOMWrapRemoveNode\t(xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t    xmlDOMWrapCloneNode\t\t(xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr sourceDoc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t xmlNodePtr *clonedNode,\n\t\t\t\t\t xmlDocPtr destDoc,\n\t\t\t\t\t xmlNodePtr destParent,\n\t\t\t\t\t int deep,\n\t\t\t\t\t int options);\n\n#ifdef LIBXML_TREE_ENABLED\n/*\n * 5 interfaces from DOM ElementTraversal, but different in entities\n * traversal.\n */\nXMLPUBFUN unsigned long\n            xmlChildElementCount        (xmlNodePtr parent);\nXMLPUBFUN xmlNodePtr\n            xmlNextElementSibling       (xmlNodePtr node);\nXMLPUBFUN xmlNodePtr\n            xmlFirstElementChild        (xmlNodePtr parent);\nXMLPUBFUN xmlNodePtr\n            xmlLastElementChild         (xmlNodePtr parent);\nXMLPUBFUN xmlNodePtr\n            xmlPreviousElementSibling   (xmlNodePtr node);\n#endif\n#ifdef __cplusplus\n}\n#endif\n#ifndef __XML_PARSER_H__\n#include <libxml/xmlmemory.h>\n#endif\n\n#endif /* __XML_TREE_H__ */\n\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/uri.h",
    "content": "/**\n * Summary: library of generic URI related routines\n * Description: library of generic URI related routines\n *              Implements RFC 2396\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_URI_H__\n#define __XML_URI_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlURI:\n *\n * A parsed URI reference. This is a struct containing the various fields\n * as described in RFC 2396 but separated for further processing.\n *\n * Note: query is a deprecated field which is incorrectly unescaped.\n * query_raw takes precedence over query if the former is set.\n * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127\n */\ntypedef struct _xmlURI xmlURI;\ntypedef xmlURI *xmlURIPtr;\nstruct _xmlURI {\n    char *scheme;\t/* the URI scheme */\n    char *opaque;\t/* opaque part */\n    char *authority;\t/* the authority part */\n    char *server;\t/* the server part */\n    char *user;\t\t/* the user part */\n    int port;\t\t/* the port number */\n    char *path;\t\t/* the path string */\n    char *query;\t/* the query string (deprecated - use with caution) */\n    char *fragment;\t/* the fragment identifier */\n    int  cleanup;\t/* parsing potentially unclean URI */\n    char *query_raw;\t/* the query string (as it appears in the URI) */\n};\n\n/*\n * This function is in tree.h:\n * xmlChar *\txmlNodeGetBase\t(xmlDocPtr doc,\n *                               xmlNodePtr cur);\n */\nXMLPUBFUN xmlURIPtr\n\t\txmlCreateURI\t\t(void);\nXMLPUBFUN xmlChar *\n\t\txmlBuildURI\t\t(const xmlChar *URI,\n\t\t\t\t\t const xmlChar *base);\nXMLPUBFUN xmlChar *\n\t\txmlBuildRelativeURI\t(const xmlChar *URI,\n\t\t\t\t\t const xmlChar *base);\nXMLPUBFUN xmlURIPtr\n\t\txmlParseURI\t\t(const char *str);\nXMLPUBFUN xmlURIPtr\n\t\txmlParseURIRaw\t\t(const char *str,\n\t\t\t\t\t int raw);\nXMLPUBFUN int\n\t\txmlParseURIReference\t(xmlURIPtr uri,\n\t\t\t\t\t const char *str);\nXMLPUBFUN xmlChar *\n\t\txmlSaveUri\t\t(xmlURIPtr uri);\nXMLPUBFUN void\n\t\txmlPrintURI\t\t(FILE *stream,\n\t\t\t\t\t xmlURIPtr uri);\nXMLPUBFUN xmlChar *\n\t\txmlURIEscapeStr         (const xmlChar *str,\n\t\t\t\t\t const xmlChar *list);\nXMLPUBFUN char *\n\t\txmlURIUnescapeString\t(const char *str,\n\t\t\t\t\t int len,\n\t\t\t\t\t char *target);\nXMLPUBFUN int\n\t\txmlNormalizeURIPath\t(char *path);\nXMLPUBFUN xmlChar *\n\t\txmlURIEscape\t\t(const xmlChar *str);\nXMLPUBFUN void\n\t\txmlFreeURI\t\t(xmlURIPtr uri);\nXMLPUBFUN xmlChar*\n\t\txmlCanonicPath\t\t(const xmlChar *path);\nXMLPUBFUN xmlChar*\n\t\txmlPathToURI\t\t(const xmlChar *path);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_URI_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/valid.h",
    "content": "/*\n * Summary: The DTD validation\n * Description: API for the DTD handling and the validity checking\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_VALID_H__\n#define __XML_VALID_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/xmlerror.h>\n#include <libxml/tree.h>\n#include <libxml/list.h>\n#include <libxml/xmlautomata.h>\n#include <libxml/xmlregexp.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Validation state added for non-determinist content model.\n */\ntypedef struct _xmlValidState xmlValidState;\ntypedef xmlValidState *xmlValidStatePtr;\n\n/**\n * xmlValidityErrorFunc:\n * @ctx:  usually an xmlValidCtxtPtr to a validity error context,\n *        but comes from ctxt->userData (which normally contains such\n *        a pointer); ctxt->userData can be changed by the user.\n * @msg:  the string to format *printf like vararg\n * @...:  remaining arguments to the format\n *\n * Callback called when a validity error is found. This is a message\n * oriented function similar to an *printf function.\n */\ntypedef void (*xmlValidityErrorFunc) (void *ctx,\n\t\t\t     const char *msg,\n\t\t\t     ...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * xmlValidityWarningFunc:\n * @ctx:  usually an xmlValidCtxtPtr to a validity error context,\n *        but comes from ctxt->userData (which normally contains such\n *        a pointer); ctxt->userData can be changed by the user.\n * @msg:  the string to format *printf like vararg\n * @...:  remaining arguments to the format\n *\n * Callback called when a validity warning is found. This is a message\n * oriented function similar to an *printf function.\n */\ntypedef void (*xmlValidityWarningFunc) (void *ctx,\n\t\t\t       const char *msg,\n\t\t\t       ...) LIBXML_ATTR_FORMAT(2,3);\n\n/*\n * xmlValidCtxt:\n * An xmlValidCtxt is used for error reporting when validating.\n */\ntypedef struct _xmlValidCtxt xmlValidCtxt;\ntypedef xmlValidCtxt *xmlValidCtxtPtr;\nstruct _xmlValidCtxt {\n    void *userData;\t\t\t/* user specific data block */\n    xmlValidityErrorFunc error;\t\t/* the callback in case of errors */\n    xmlValidityWarningFunc warning;\t/* the callback in case of warning */\n\n    /* Node analysis stack used when validating within entities */\n    xmlNodePtr         node;          /* Current parsed Node */\n    int                nodeNr;        /* Depth of the parsing stack */\n    int                nodeMax;       /* Max depth of the parsing stack */\n    xmlNodePtr        *nodeTab;       /* array of nodes */\n\n    unsigned int         flags;       /* internal flags */\n    xmlDocPtr              doc;       /* the document */\n    int                  valid;       /* temporary validity check result */\n\n    /* state state used for non-determinist content validation */\n    xmlValidState     *vstate;        /* current state */\n    int                vstateNr;      /* Depth of the validation stack */\n    int                vstateMax;     /* Max depth of the validation stack */\n    xmlValidState     *vstateTab;     /* array of validation states */\n\n#ifdef LIBXML_REGEXP_ENABLED\n    xmlAutomataPtr            am;     /* the automata */\n    xmlAutomataStatePtr    state;     /* used to build the automata */\n#else\n    void                     *am;\n    void                  *state;\n#endif\n};\n\n/*\n * ALL notation declarations are stored in a table.\n * There is one table per DTD.\n */\n\ntypedef struct _xmlHashTable xmlNotationTable;\ntypedef xmlNotationTable *xmlNotationTablePtr;\n\n/*\n * ALL element declarations are stored in a table.\n * There is one table per DTD.\n */\n\ntypedef struct _xmlHashTable xmlElementTable;\ntypedef xmlElementTable *xmlElementTablePtr;\n\n/*\n * ALL attribute declarations are stored in a table.\n * There is one table per DTD.\n */\n\ntypedef struct _xmlHashTable xmlAttributeTable;\ntypedef xmlAttributeTable *xmlAttributeTablePtr;\n\n/*\n * ALL IDs attributes are stored in a table.\n * There is one table per document.\n */\n\ntypedef struct _xmlHashTable xmlIDTable;\ntypedef xmlIDTable *xmlIDTablePtr;\n\n/*\n * ALL Refs attributes are stored in a table.\n * There is one table per document.\n */\n\ntypedef struct _xmlHashTable xmlRefTable;\ntypedef xmlRefTable *xmlRefTablePtr;\n\n/* Notation */\nXMLPUBFUN xmlNotationPtr\n\t\txmlAddNotationDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *PublicID,\n\t\t\t\t\t const xmlChar *SystemID);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlNotationTablePtr\n\t\txmlCopyNotationTable\t(xmlNotationTablePtr table);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlFreeNotationTable\t(xmlNotationTablePtr table);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlDumpNotationDecl\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlNotationPtr nota);\nXMLPUBFUN void\n\t\txmlDumpNotationTable\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlNotationTablePtr table);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n/* Element Content */\n/* the non Doc version are being deprecated */\nXMLPUBFUN xmlElementContentPtr\n\t\txmlNewElementContent\t(const xmlChar *name,\n\t\t\t\t\t xmlElementContentType type);\nXMLPUBFUN xmlElementContentPtr\n\t\txmlCopyElementContent\t(xmlElementContentPtr content);\nXMLPUBFUN void\n\t\txmlFreeElementContent\t(xmlElementContentPtr cur);\n/* the new versions with doc argument */\nXMLPUBFUN xmlElementContentPtr\n\t\txmlNewDocElementContent\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t xmlElementContentType type);\nXMLPUBFUN xmlElementContentPtr\n\t\txmlCopyDocElementContent(xmlDocPtr doc,\n\t\t\t\t\t xmlElementContentPtr content);\nXMLPUBFUN void\n\t\txmlFreeDocElementContent(xmlDocPtr doc,\n\t\t\t\t\t xmlElementContentPtr cur);\nXMLPUBFUN void\n\t\txmlSnprintfElementContent(char *buf,\n\t\t\t\t\t int size,\n\t                                 xmlElementContentPtr content,\n\t\t\t\t\t int englob);\n#ifdef LIBXML_OUTPUT_ENABLED\n/* DEPRECATED */\nXMLPUBFUN void\n\t\txmlSprintfElementContent(char *buf,\n\t                                 xmlElementContentPtr content,\n\t\t\t\t\t int englob);\n#endif /* LIBXML_OUTPUT_ENABLED */\n/* DEPRECATED */\n\n/* Element */\nXMLPUBFUN xmlElementPtr\n\t\txmlAddElementDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t xmlElementTypeVal type,\n\t\t\t\t\t xmlElementContentPtr content);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlElementTablePtr\n\t\txmlCopyElementTable\t(xmlElementTablePtr table);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlFreeElementTable\t(xmlElementTablePtr table);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlDumpElementTable\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlElementTablePtr table);\nXMLPUBFUN void\n\t\txmlDumpElementDecl\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlElementPtr elem);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n/* Enumeration */\nXMLPUBFUN xmlEnumerationPtr\n\t\txmlCreateEnumeration\t(const xmlChar *name);\nXMLPUBFUN void\n\t\txmlFreeEnumeration\t(xmlEnumerationPtr cur);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlEnumerationPtr\n\t\txmlCopyEnumeration\t(xmlEnumerationPtr cur);\n#endif /* LIBXML_TREE_ENABLED */\n\n/* Attribute */\nXMLPUBFUN xmlAttributePtr\n\t\txmlAddAttributeDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *ns,\n\t\t\t\t\t xmlAttributeType type,\n\t\t\t\t\t xmlAttributeDefault def,\n\t\t\t\t\t const xmlChar *defaultValue,\n\t\t\t\t\t xmlEnumerationPtr tree);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlAttributeTablePtr\n\t\txmlCopyAttributeTable  (xmlAttributeTablePtr table);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlFreeAttributeTable  (xmlAttributeTablePtr table);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlDumpAttributeTable  (xmlBufferPtr buf,\n\t\t\t\t\txmlAttributeTablePtr table);\nXMLPUBFUN void\n\t\txmlDumpAttributeDecl   (xmlBufferPtr buf,\n\t\t\t\t\txmlAttributePtr attr);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n/* IDs */\nXMLPUBFUN xmlIDPtr\n\t\txmlAddID\t       (xmlValidCtxtPtr ctxt,\n\t\t\t\t\txmlDocPtr doc,\n\t\t\t\t\tconst xmlChar *value,\n\t\t\t\t\txmlAttrPtr attr);\nXMLPUBFUN void\n\t\txmlFreeIDTable\t       (xmlIDTablePtr table);\nXMLPUBFUN xmlAttrPtr\n\t\txmlGetID\t       (xmlDocPtr doc,\n\t\t\t\t\tconst xmlChar *ID);\nXMLPUBFUN int\n\t\txmlIsID\t\t       (xmlDocPtr doc,\n\t\t\t\t\txmlNodePtr elem,\n\t\t\t\t\txmlAttrPtr attr);\nXMLPUBFUN int\n\t\txmlRemoveID\t       (xmlDocPtr doc,\n\t\t\t\t\txmlAttrPtr attr);\n\n/* IDREFs */\nXML_DEPRECATED\nXMLPUBFUN xmlRefPtr\n\t\txmlAddRef\t       (xmlValidCtxtPtr ctxt,\n\t\t\t\t\txmlDocPtr doc,\n\t\t\t\t\tconst xmlChar *value,\n\t\t\t\t\txmlAttrPtr attr);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlFreeRefTable\t       (xmlRefTablePtr table);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlIsRef\t       (xmlDocPtr doc,\n\t\t\t\t\txmlNodePtr elem,\n\t\t\t\t\txmlAttrPtr attr);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlRemoveRef\t       (xmlDocPtr doc,\n\t\t\t\t\txmlAttrPtr attr);\nXML_DEPRECATED\nXMLPUBFUN xmlListPtr\n\t\txmlGetRefs\t       (xmlDocPtr doc,\n\t\t\t\t\tconst xmlChar *ID);\n\n/**\n * The public function calls related to validity checking.\n */\n#ifdef LIBXML_VALID_ENABLED\n/* Allocate/Release Validation Contexts */\nXMLPUBFUN xmlValidCtxtPtr\n\t\txmlNewValidCtxt(void);\nXMLPUBFUN void\n\t\txmlFreeValidCtxt(xmlValidCtxtPtr);\n\nXMLPUBFUN int\n\t\txmlValidateRoot\t\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlValidateElementDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t                         xmlElementPtr elem);\nXMLPUBFUN xmlChar *\n\t\txmlValidNormalizeAttributeValue(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlChar *\n\t\txmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t                         xmlAttributePtr attr);\nXMLPUBFUN int\n\t\txmlValidateAttributeValue(xmlAttributeType type,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateNotationDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t                         xmlNotationPtr nota);\nXMLPUBFUN int\n\t\txmlValidateDtd\t\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlDtdPtr dtd);\nXMLPUBFUN int\n\t\txmlValidateDtdFinal\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlValidateDocument\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlValidateElement\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN int\n\t\txmlValidateOneElement\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t                         xmlNodePtr elem);\nXMLPUBFUN int\n\t\txmlValidateOneAttribute\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr\telem,\n\t\t\t\t\t xmlAttrPtr attr,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateOneNamespace\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\n#endif /* LIBXML_VALID_ENABLED */\n\n#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN int\n\t\txmlValidateNotationUse\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *notationName);\n#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */\n\nXMLPUBFUN int\n\t\txmlIsMixedElement\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlAttributePtr\n\t\txmlGetDtdAttrDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlAttributePtr\n\t\txmlGetDtdQAttrDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN xmlNotationPtr\n\t\txmlGetDtdNotationDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlElementPtr\n\t\txmlGetDtdQElementDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN xmlElementPtr\n\t\txmlGetDtdElementDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name);\n\n#ifdef LIBXML_VALID_ENABLED\n\nXMLPUBFUN int\n\t\txmlValidGetPotentialChildren(xmlElementContent *ctree,\n\t\t\t\t\t const xmlChar **names,\n\t\t\t\t\t int *len,\n\t\t\t\t\t int max);\n\nXMLPUBFUN int\n\t\txmlValidGetValidElements(xmlNode *prev,\n\t\t\t\t\t xmlNode *next,\n\t\t\t\t\t const xmlChar **names,\n\t\t\t\t\t int max);\nXMLPUBFUN int\n\t\txmlValidateNameValue\t(const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateNamesValue\t(const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateNmtokenValue\t(const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateNmtokensValue(const xmlChar *value);\n\n#ifdef LIBXML_REGEXP_ENABLED\n/*\n * Validation based on the regexp support\n */\nXMLPUBFUN int\n\t\txmlValidBuildContentModel(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlElementPtr elem);\n\nXMLPUBFUN int\n\t\txmlValidatePushElement\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *qname);\nXMLPUBFUN int\n\t\txmlValidatePushCData\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *data,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\txmlValidatePopElement\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *qname);\n#endif /* LIBXML_REGEXP_ENABLED */\n#endif /* LIBXML_VALID_ENABLED */\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_VALID_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xinclude.h",
    "content": "/*\n * Summary: implementation of XInclude\n * Description: API to handle XInclude processing,\n * implements the\n * World Wide Web Consortium Last Call Working Draft 10 November 2003\n * http://www.w3.org/TR/2003/WD-xinclude-20031110\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XINCLUDE_H__\n#define __XML_XINCLUDE_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef LIBXML_XINCLUDE_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * XINCLUDE_NS:\n *\n * Macro defining the Xinclude namespace: http://www.w3.org/2003/XInclude\n */\n#define XINCLUDE_NS (const xmlChar *) \"http://www.w3.org/2003/XInclude\"\n/**\n * XINCLUDE_OLD_NS:\n *\n * Macro defining the draft Xinclude namespace: http://www.w3.org/2001/XInclude\n */\n#define XINCLUDE_OLD_NS (const xmlChar *) \"http://www.w3.org/2001/XInclude\"\n/**\n * XINCLUDE_NODE:\n *\n * Macro defining \"include\"\n */\n#define XINCLUDE_NODE (const xmlChar *) \"include\"\n/**\n * XINCLUDE_FALLBACK:\n *\n * Macro defining \"fallback\"\n */\n#define XINCLUDE_FALLBACK (const xmlChar *) \"fallback\"\n/**\n * XINCLUDE_HREF:\n *\n * Macro defining \"href\"\n */\n#define XINCLUDE_HREF (const xmlChar *) \"href\"\n/**\n * XINCLUDE_PARSE:\n *\n * Macro defining \"parse\"\n */\n#define XINCLUDE_PARSE (const xmlChar *) \"parse\"\n/**\n * XINCLUDE_PARSE_XML:\n *\n * Macro defining \"xml\"\n */\n#define XINCLUDE_PARSE_XML (const xmlChar *) \"xml\"\n/**\n * XINCLUDE_PARSE_TEXT:\n *\n * Macro defining \"text\"\n */\n#define XINCLUDE_PARSE_TEXT (const xmlChar *) \"text\"\n/**\n * XINCLUDE_PARSE_ENCODING:\n *\n * Macro defining \"encoding\"\n */\n#define XINCLUDE_PARSE_ENCODING (const xmlChar *) \"encoding\"\n/**\n * XINCLUDE_PARSE_XPOINTER:\n *\n * Macro defining \"xpointer\"\n */\n#define XINCLUDE_PARSE_XPOINTER (const xmlChar *) \"xpointer\"\n\ntypedef struct _xmlXIncludeCtxt xmlXIncludeCtxt;\ntypedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;\n\n/*\n * standalone processing\n */\nXMLPUBFUN int\n\t\txmlXIncludeProcess\t(xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlXIncludeProcessFlags\t(xmlDocPtr doc,\n\t\t\t\t\t int flags);\nXMLPUBFUN int\n\t\txmlXIncludeProcessFlagsData(xmlDocPtr doc,\n\t\t\t\t\t int flags,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n                xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree,\n                                         int flags,\n                                         void *data);\nXMLPUBFUN int\n\t\txmlXIncludeProcessTree\t(xmlNodePtr tree);\nXMLPUBFUN int\n\t\txmlXIncludeProcessTreeFlags(xmlNodePtr tree,\n\t\t\t\t\t int flags);\n/*\n * contextual processing\n */\nXMLPUBFUN xmlXIncludeCtxtPtr\n\t\txmlXIncludeNewContext\t(xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlXIncludeSetFlags\t(xmlXIncludeCtxtPtr ctxt,\n\t\t\t\t\t int flags);\nXMLPUBFUN void\n\t\txmlXIncludeFreeContext\t(xmlXIncludeCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlXIncludeProcessNode\t(xmlXIncludeCtxtPtr ctxt,\n\t\t\t\t\t xmlNodePtr tree);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XINCLUDE_ENABLED */\n\n#endif /* __XML_XINCLUDE_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xlink.h",
    "content": "/*\n * Summary: unfinished XLink detection module\n * Description: unfinished XLink detection module\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XLINK_H__\n#define __XML_XLINK_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef LIBXML_XPTR_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * Various defines for the various Link properties.\n *\n * NOTE: the link detection layer will try to resolve QName expansion\n *       of namespaces. If \"foo\" is the prefix for \"http://foo.com/\"\n *       then the link detection layer will expand role=\"foo:myrole\"\n *       to \"http://foo.com/:myrole\".\n * NOTE: the link detection layer will expand URI-References found on\n *       href attributes by using the base mechanism if found.\n */\ntypedef xmlChar *xlinkHRef;\ntypedef xmlChar *xlinkRole;\ntypedef xmlChar *xlinkTitle;\n\ntypedef enum {\n    XLINK_TYPE_NONE = 0,\n    XLINK_TYPE_SIMPLE,\n    XLINK_TYPE_EXTENDED,\n    XLINK_TYPE_EXTENDED_SET\n} xlinkType;\n\ntypedef enum {\n    XLINK_SHOW_NONE = 0,\n    XLINK_SHOW_NEW,\n    XLINK_SHOW_EMBED,\n    XLINK_SHOW_REPLACE\n} xlinkShow;\n\ntypedef enum {\n    XLINK_ACTUATE_NONE = 0,\n    XLINK_ACTUATE_AUTO,\n    XLINK_ACTUATE_ONREQUEST\n} xlinkActuate;\n\n/**\n * xlinkNodeDetectFunc:\n * @ctx:  user data pointer\n * @node:  the node to check\n *\n * This is the prototype for the link detection routine.\n * It calls the default link detection callbacks upon link detection.\n */\ntypedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node);\n\n/*\n * The link detection module interact with the upper layers using\n * a set of callback registered at parsing time.\n */\n\n/**\n * xlinkSimpleLinkFunk:\n * @ctx:  user data pointer\n * @node:  the node carrying the link\n * @href:  the target of the link\n * @role:  the role string\n * @title:  the link title\n *\n * This is the prototype for a simple link detection callback.\n */\ntypedef void\n(*xlinkSimpleLinkFunk)\t(void *ctx,\n\t\t\t xmlNodePtr node,\n\t\t\t const xlinkHRef href,\n\t\t\t const xlinkRole role,\n\t\t\t const xlinkTitle title);\n\n/**\n * xlinkExtendedLinkFunk:\n * @ctx:  user data pointer\n * @node:  the node carrying the link\n * @nbLocators: the number of locators detected on the link\n * @hrefs:  pointer to the array of locator hrefs\n * @roles:  pointer to the array of locator roles\n * @nbArcs: the number of arcs detected on the link\n * @from:  pointer to the array of source roles found on the arcs\n * @to:  pointer to the array of target roles found on the arcs\n * @show:  array of values for the show attributes found on the arcs\n * @actuate:  array of values for the actuate attributes found on the arcs\n * @nbTitles: the number of titles detected on the link\n * @title:  array of titles detected on the link\n * @langs:  array of xml:lang values for the titles\n *\n * This is the prototype for a extended link detection callback.\n */\ntypedef void\n(*xlinkExtendedLinkFunk)(void *ctx,\n\t\t\t xmlNodePtr node,\n\t\t\t int nbLocators,\n\t\t\t const xlinkHRef *hrefs,\n\t\t\t const xlinkRole *roles,\n\t\t\t int nbArcs,\n\t\t\t const xlinkRole *from,\n\t\t\t const xlinkRole *to,\n\t\t\t xlinkShow *show,\n\t\t\t xlinkActuate *actuate,\n\t\t\t int nbTitles,\n\t\t\t const xlinkTitle *titles,\n\t\t\t const xmlChar **langs);\n\n/**\n * xlinkExtendedLinkSetFunk:\n * @ctx:  user data pointer\n * @node:  the node carrying the link\n * @nbLocators: the number of locators detected on the link\n * @hrefs:  pointer to the array of locator hrefs\n * @roles:  pointer to the array of locator roles\n * @nbTitles: the number of titles detected on the link\n * @title:  array of titles detected on the link\n * @langs:  array of xml:lang values for the titles\n *\n * This is the prototype for a extended link set detection callback.\n */\ntypedef void\n(*xlinkExtendedLinkSetFunk)\t(void *ctx,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t int nbLocators,\n\t\t\t\t const xlinkHRef *hrefs,\n\t\t\t\t const xlinkRole *roles,\n\t\t\t\t int nbTitles,\n\t\t\t\t const xlinkTitle *titles,\n\t\t\t\t const xmlChar **langs);\n\n/**\n * This is the structure containing a set of Links detection callbacks.\n *\n * There is no default xlink callbacks, if one want to get link\n * recognition activated, those call backs must be provided before parsing.\n */\ntypedef struct _xlinkHandler xlinkHandler;\ntypedef xlinkHandler *xlinkHandlerPtr;\nstruct _xlinkHandler {\n    xlinkSimpleLinkFunk simple;\n    xlinkExtendedLinkFunk extended;\n    xlinkExtendedLinkSetFunk set;\n};\n\n/*\n * The default detection routine, can be overridden, they call the default\n * detection callbacks.\n */\n\nXMLPUBFUN xlinkNodeDetectFunc\n\t\txlinkGetDefaultDetect\t(void);\nXMLPUBFUN void\n\t\txlinkSetDefaultDetect\t(xlinkNodeDetectFunc func);\n\n/*\n * Routines to set/get the default handlers.\n */\nXMLPUBFUN xlinkHandlerPtr\n\t\txlinkGetDefaultHandler\t(void);\nXMLPUBFUN void\n\t\txlinkSetDefaultHandler\t(xlinkHandlerPtr handler);\n\n/*\n * Link detection module itself.\n */\nXMLPUBFUN xlinkType\n\t\txlinkIsLink\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XPTR_ENABLED */\n\n#endif /* __XML_XLINK_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlIO.h",
    "content": "/*\n * Summary: interface for the I/O interfaces used by the parser\n * Description: interface for the I/O interfaces used by the parser\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_IO_H__\n#define __XML_IO_H__\n\n#include <stdio.h>\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Those are the functions and datatypes for the parser input\n * I/O structures.\n */\n\n/**\n * xmlInputMatchCallback:\n * @filename: the filename or URI\n *\n * Callback used in the I/O Input API to detect if the current handler\n * can provide input functionality for this resource.\n *\n * Returns 1 if yes and 0 if another Input module should be used\n */\ntypedef int (*xmlInputMatchCallback) (char const *filename);\n/**\n * xmlInputOpenCallback:\n * @filename: the filename or URI\n *\n * Callback used in the I/O Input API to open the resource\n *\n * Returns an Input context or NULL in case or error\n */\ntypedef void * (*xmlInputOpenCallback) (char const *filename);\n/**\n * xmlInputReadCallback:\n * @context:  an Input context\n * @buffer:  the buffer to store data read\n * @len:  the length of the buffer in bytes\n *\n * Callback used in the I/O Input API to read the resource\n *\n * Returns the number of bytes read or -1 in case of error\n */\ntypedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);\n/**\n * xmlInputCloseCallback:\n * @context:  an Input context\n *\n * Callback used in the I/O Input API to close the resource\n *\n * Returns 0 or -1 in case of error\n */\ntypedef int (*xmlInputCloseCallback) (void * context);\n\n#ifdef LIBXML_OUTPUT_ENABLED\n/*\n * Those are the functions and datatypes for the library output\n * I/O structures.\n */\n\n/**\n * xmlOutputMatchCallback:\n * @filename: the filename or URI\n *\n * Callback used in the I/O Output API to detect if the current handler\n * can provide output functionality for this resource.\n *\n * Returns 1 if yes and 0 if another Output module should be used\n */\ntypedef int (*xmlOutputMatchCallback) (char const *filename);\n/**\n * xmlOutputOpenCallback:\n * @filename: the filename or URI\n *\n * Callback used in the I/O Output API to open the resource\n *\n * Returns an Output context or NULL in case or error\n */\ntypedef void * (*xmlOutputOpenCallback) (char const *filename);\n/**\n * xmlOutputWriteCallback:\n * @context:  an Output context\n * @buffer:  the buffer of data to write\n * @len:  the length of the buffer in bytes\n *\n * Callback used in the I/O Output API to write to the resource\n *\n * Returns the number of bytes written or -1 in case of error\n */\ntypedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,\n                                       int len);\n/**\n * xmlOutputCloseCallback:\n * @context:  an Output context\n *\n * Callback used in the I/O Output API to close the resource\n *\n * Returns 0 or -1 in case of error\n */\ntypedef int (*xmlOutputCloseCallback) (void * context);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#include <libxml/globals.h>\n#include <libxml/tree.h>\n#include <libxml/parser.h>\n#include <libxml/encoding.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nstruct _xmlParserInputBuffer {\n    void*                  context;\n    xmlInputReadCallback   readcallback;\n    xmlInputCloseCallback  closecallback;\n\n    xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */\n\n    xmlBufPtr buffer;    /* Local buffer encoded in UTF-8 */\n    xmlBufPtr raw;       /* if encoder != NULL buffer for raw input */\n    int\tcompressed;\t    /* -1=unknown, 0=not compressed, 1=compressed */\n    int error;\n    unsigned long rawconsumed;/* amount consumed from raw */\n};\n\n\n#ifdef LIBXML_OUTPUT_ENABLED\nstruct _xmlOutputBuffer {\n    void*                   context;\n    xmlOutputWriteCallback  writecallback;\n    xmlOutputCloseCallback  closecallback;\n\n    xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */\n\n    xmlBufPtr buffer;    /* Local buffer encoded in UTF-8 or ISOLatin */\n    xmlBufPtr conv;      /* if encoder != NULL buffer for output */\n    int written;            /* total number of byte written */\n    int error;\n};\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n/*\n * Interfaces for input\n */\nXMLPUBFUN void\n\txmlCleanupInputCallbacks\t\t(void);\n\nXMLPUBFUN int\n\txmlPopInputCallbacks\t\t\t(void);\n\nXMLPUBFUN void\n\txmlRegisterDefaultInputCallbacks\t(void);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlAllocParserInputBuffer\t\t(xmlCharEncoding enc);\n\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateFilename\t(const char *URI,\n                                                 xmlCharEncoding enc);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateFile\t\t(FILE *file,\n                                                 xmlCharEncoding enc);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateFd\t\t(int fd,\n\t                                         xmlCharEncoding enc);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateMem\t\t(const char *mem, int size,\n\t                                         xmlCharEncoding enc);\nXML_DEPRECATED\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateStatic\t(const char *mem, int size,\n\t                                         xmlCharEncoding enc);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateIO\t\t(xmlInputReadCallback   ioread,\n\t\t\t\t\t\t xmlInputCloseCallback  ioclose,\n\t\t\t\t\t\t void *ioctx,\n\t                                         xmlCharEncoding enc);\nXMLPUBFUN int\n\txmlParserInputBufferRead\t\t(xmlParserInputBufferPtr in,\n\t\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlParserInputBufferGrow\t\t(xmlParserInputBufferPtr in,\n\t\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlParserInputBufferPush\t\t(xmlParserInputBufferPtr in,\n\t\t\t\t\t\t int len,\n\t\t\t\t\t\t const char *buf);\nXMLPUBFUN void\n\txmlFreeParserInputBuffer\t\t(xmlParserInputBufferPtr in);\nXMLPUBFUN char *\n\txmlParserGetDirectory\t\t\t(const char *filename);\n\nXMLPUBFUN int\n\txmlRegisterInputCallbacks\t\t(xmlInputMatchCallback matchFunc,\n\t\t\t\t\t\t xmlInputOpenCallback openFunc,\n\t\t\t\t\t\t xmlInputReadCallback readFunc,\n\t\t\t\t\t\t xmlInputCloseCallback closeFunc);\n\nxmlParserInputBufferPtr\n\t__xmlParserInputBufferCreateFilename(const char *URI,\n\t\t\t\t\t\txmlCharEncoding enc);\n\n#ifdef LIBXML_OUTPUT_ENABLED\n/*\n * Interfaces for output\n */\nXMLPUBFUN void\n\txmlCleanupOutputCallbacks\t\t(void);\nXMLPUBFUN int\n\txmlPopOutputCallbacks\t\t\t(void);\nXMLPUBFUN void\n\txmlRegisterDefaultOutputCallbacks(void);\nXMLPUBFUN xmlOutputBufferPtr\n\txmlAllocOutputBuffer\t\t(xmlCharEncodingHandlerPtr encoder);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateFilename\t(const char *URI,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder,\n\t\t\t\t\t int compression);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateFile\t(FILE *file,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateBuffer\t(xmlBufferPtr buffer,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateFd\t\t(int fd,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateIO\t\t(xmlOutputWriteCallback   iowrite,\n\t\t\t\t\t xmlOutputCloseCallback  ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder);\n\n/* Couple of APIs to get the output without digging into the buffers */\nXMLPUBFUN const xmlChar *\n        xmlOutputBufferGetContent       (xmlOutputBufferPtr out);\nXMLPUBFUN size_t\n        xmlOutputBufferGetSize          (xmlOutputBufferPtr out);\n\nXMLPUBFUN int\n\txmlOutputBufferWrite\t\t(xmlOutputBufferPtr out,\n\t\t\t\t\t int len,\n\t\t\t\t\t const char *buf);\nXMLPUBFUN int\n\txmlOutputBufferWriteString\t(xmlOutputBufferPtr out,\n\t\t\t\t\t const char *str);\nXMLPUBFUN int\n\txmlOutputBufferWriteEscape\t(xmlOutputBufferPtr out,\n\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t xmlCharEncodingOutputFunc escaping);\n\nXMLPUBFUN int\n\txmlOutputBufferFlush\t\t(xmlOutputBufferPtr out);\nXMLPUBFUN int\n\txmlOutputBufferClose\t\t(xmlOutputBufferPtr out);\n\nXMLPUBFUN int\n\txmlRegisterOutputCallbacks\t(xmlOutputMatchCallback matchFunc,\n\t\t\t\t\t xmlOutputOpenCallback openFunc,\n\t\t\t\t\t xmlOutputWriteCallback writeFunc,\n\t\t\t\t\t xmlOutputCloseCallback closeFunc);\n\nxmlOutputBufferPtr\n\t__xmlOutputBufferCreateFilename(const char *URI,\n                              xmlCharEncodingHandlerPtr encoder,\n                              int compression);\n\n#ifdef LIBXML_HTTP_ENABLED\n/*  This function only exists if HTTP support built into the library  */\nXMLPUBFUN void\n\txmlRegisterHTTPPostCallbacks\t(void );\n#endif /* LIBXML_HTTP_ENABLED */\n\n#endif /* LIBXML_OUTPUT_ENABLED */\n\nXMLPUBFUN xmlParserInputPtr\n\txmlCheckHTTPInput\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlParserInputPtr ret);\n\n/*\n * A predefined entity loader disabling network accesses\n */\nXMLPUBFUN xmlParserInputPtr\n\txmlNoNetExternalEntityLoader\t(const char *URL,\n\t\t\t\t\t const char *ID,\n\t\t\t\t\t xmlParserCtxtPtr ctxt);\n\n/*\n * xmlNormalizeWindowsPath is obsolete, don't use it.\n * Check xmlCanonicPath in uri.h for a better alternative.\n */\nXMLPUBFUN xmlChar *\n\txmlNormalizeWindowsPath\t\t(const xmlChar *path);\n\nXMLPUBFUN int\n\txmlCheckFilename\t\t(const char *path);\n/**\n * Default 'file://' protocol callbacks\n */\nXMLPUBFUN int\n\txmlFileMatch\t\t\t(const char *filename);\nXMLPUBFUN void *\n\txmlFileOpen\t\t\t(const char *filename);\nXMLPUBFUN int\n\txmlFileRead\t\t\t(void * context,\n\t\t\t\t\t char * buffer,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlFileClose\t\t\t(void * context);\n\n/**\n * Default 'http://' protocol callbacks\n */\n#ifdef LIBXML_HTTP_ENABLED\nXMLPUBFUN int\n\txmlIOHTTPMatch\t\t\t(const char *filename);\nXMLPUBFUN void *\n\txmlIOHTTPOpen\t\t\t(const char *filename);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void *\n\txmlIOHTTPOpenW\t\t\t(const char * post_uri,\n\t\t\t\t\t int   compression );\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN int\n\txmlIOHTTPRead\t\t\t(void * context,\n\t\t\t\t\t char * buffer,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlIOHTTPClose\t\t\t(void * context);\n#endif /* LIBXML_HTTP_ENABLED */\n\n/**\n * Default 'ftp://' protocol callbacks\n */\n#ifdef LIBXML_FTP_ENABLED\nXMLPUBFUN int\n\txmlIOFTPMatch\t\t\t(const char *filename);\nXMLPUBFUN void *\n\txmlIOFTPOpen\t\t\t(const char *filename);\nXMLPUBFUN int\n\txmlIOFTPRead\t\t\t(void * context,\n\t\t\t\t\t char * buffer,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlIOFTPClose\t\t\t(void * context);\n#endif /* LIBXML_FTP_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_IO_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlautomata.h",
    "content": "/*\n * Summary: API to build regexp automata\n * Description: the API to build regexp automata\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_AUTOMATA_H__\n#define __XML_AUTOMATA_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_REGEXP_ENABLED\n#ifdef LIBXML_AUTOMATA_ENABLED\n\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlAutomataPtr:\n *\n * A libxml automata description, It can be compiled into a regexp\n */\ntypedef struct _xmlAutomata xmlAutomata;\ntypedef xmlAutomata *xmlAutomataPtr;\n\n/**\n * xmlAutomataStatePtr:\n *\n * A state int the automata description,\n */\ntypedef struct _xmlAutomataState xmlAutomataState;\ntypedef xmlAutomataState *xmlAutomataStatePtr;\n\n/*\n * Building API\n */\nXMLPUBFUN xmlAutomataPtr\n\t\t    xmlNewAutomata\t\t(void);\nXMLPUBFUN void\n\t\t    xmlFreeAutomata\t\t(xmlAutomataPtr am);\n\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataGetInitState\t(xmlAutomataPtr am);\nXMLPUBFUN int\n\t\t    xmlAutomataSetFinalState\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr state);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewState\t\t(xmlAutomataPtr am);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewTransition\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewTransition2\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t const xmlChar *token2,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n                    xmlAutomataNewNegTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t const xmlChar *token2,\n\t\t\t\t\t\t void *data);\n\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewCountTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewCountTrans2\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t const xmlChar *token2,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewOnceTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewOnceTrans2\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t const xmlChar *token2,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewAllTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t int lax);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewEpsilon\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewCountedTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t int counter);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewCounterTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t int counter);\nXMLPUBFUN int\n\t\t    xmlAutomataNewCounter\t(xmlAutomataPtr am,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max);\n\nXMLPUBFUN struct _xmlRegexp *\n\t\t    xmlAutomataCompile\t\t(xmlAutomataPtr am);\nXMLPUBFUN int\n\t\t    xmlAutomataIsDeterminist\t(xmlAutomataPtr am);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_AUTOMATA_ENABLED */\n#endif /* LIBXML_REGEXP_ENABLED */\n\n#endif /* __XML_AUTOMATA_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlerror.h",
    "content": "/*\n * Summary: error handling\n * Description: the API used to report errors\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#include <libxml/parser.h>\n\n#ifndef __XML_ERROR_H__\n#define __XML_ERROR_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlErrorLevel:\n *\n * Indicates the level of an error\n */\ntypedef enum {\n    XML_ERR_NONE = 0,\n    XML_ERR_WARNING = 1,\t/* A simple warning */\n    XML_ERR_ERROR = 2,\t\t/* A recoverable error */\n    XML_ERR_FATAL = 3\t\t/* A fatal error */\n} xmlErrorLevel;\n\n/**\n * xmlErrorDomain:\n *\n * Indicates where an error may have come from\n */\ntypedef enum {\n    XML_FROM_NONE = 0,\n    XML_FROM_PARSER,\t/* The XML parser */\n    XML_FROM_TREE,\t/* The tree module */\n    XML_FROM_NAMESPACE,\t/* The XML Namespace module */\n    XML_FROM_DTD,\t/* The XML DTD validation with parser context*/\n    XML_FROM_HTML,\t/* The HTML parser */\n    XML_FROM_MEMORY,\t/* The memory allocator */\n    XML_FROM_OUTPUT,\t/* The serialization code */\n    XML_FROM_IO,\t/* The Input/Output stack */\n    XML_FROM_FTP,\t/* The FTP module */\n    XML_FROM_HTTP,\t/* The HTTP module */\n    XML_FROM_XINCLUDE,\t/* The XInclude processing */\n    XML_FROM_XPATH,\t/* The XPath module */\n    XML_FROM_XPOINTER,\t/* The XPointer module */\n    XML_FROM_REGEXP,\t/* The regular expressions module */\n    XML_FROM_DATATYPE,\t/* The W3C XML Schemas Datatype module */\n    XML_FROM_SCHEMASP,\t/* The W3C XML Schemas parser module */\n    XML_FROM_SCHEMASV,\t/* The W3C XML Schemas validation module */\n    XML_FROM_RELAXNGP,\t/* The Relax-NG parser module */\n    XML_FROM_RELAXNGV,\t/* The Relax-NG validator module */\n    XML_FROM_CATALOG,\t/* The Catalog module */\n    XML_FROM_C14N,\t/* The Canonicalization module */\n    XML_FROM_XSLT,\t/* The XSLT engine from libxslt */\n    XML_FROM_VALID,\t/* The XML DTD validation with valid context */\n    XML_FROM_CHECK,\t/* The error checking module */\n    XML_FROM_WRITER,\t/* The xmlwriter module */\n    XML_FROM_MODULE,\t/* The dynamically loaded module module*/\n    XML_FROM_I18N,\t/* The module handling character conversion */\n    XML_FROM_SCHEMATRONV,/* The Schematron validator module */\n    XML_FROM_BUFFER,    /* The buffers module */\n    XML_FROM_URI        /* The URI module */\n} xmlErrorDomain;\n\n/**\n * xmlError:\n *\n * An XML Error instance.\n */\n\ntypedef struct _xmlError xmlError;\ntypedef xmlError *xmlErrorPtr;\nstruct _xmlError {\n    int\t\tdomain;\t/* What part of the library raised this error */\n    int\t\tcode;\t/* The error code, e.g. an xmlParserError */\n    char       *message;/* human-readable informative error message */\n    xmlErrorLevel level;/* how consequent is the error */\n    char       *file;\t/* the filename */\n    int\t\tline;\t/* the line number if available */\n    char       *str1;\t/* extra string information */\n    char       *str2;\t/* extra string information */\n    char       *str3;\t/* extra string information */\n    int\t\tint1;\t/* extra number information */\n    int\t\tint2;\t/* error column # or 0 if N/A (todo: rename field when we would brk ABI) */\n    void       *ctxt;   /* the parser context if available */\n    void       *node;   /* the node in the tree */\n};\n\n/**\n * xmlParserError:\n *\n * This is an error that the XML (or HTML) parser can generate\n */\ntypedef enum {\n    XML_ERR_OK = 0,\n    XML_ERR_INTERNAL_ERROR, /* 1 */\n    XML_ERR_NO_MEMORY, /* 2 */\n    XML_ERR_DOCUMENT_START, /* 3 */\n    XML_ERR_DOCUMENT_EMPTY, /* 4 */\n    XML_ERR_DOCUMENT_END, /* 5 */\n    XML_ERR_INVALID_HEX_CHARREF, /* 6 */\n    XML_ERR_INVALID_DEC_CHARREF, /* 7 */\n    XML_ERR_INVALID_CHARREF, /* 8 */\n    XML_ERR_INVALID_CHAR, /* 9 */\n    XML_ERR_CHARREF_AT_EOF, /* 10 */\n    XML_ERR_CHARREF_IN_PROLOG, /* 11 */\n    XML_ERR_CHARREF_IN_EPILOG, /* 12 */\n    XML_ERR_CHARREF_IN_DTD, /* 13 */\n    XML_ERR_ENTITYREF_AT_EOF, /* 14 */\n    XML_ERR_ENTITYREF_IN_PROLOG, /* 15 */\n    XML_ERR_ENTITYREF_IN_EPILOG, /* 16 */\n    XML_ERR_ENTITYREF_IN_DTD, /* 17 */\n    XML_ERR_PEREF_AT_EOF, /* 18 */\n    XML_ERR_PEREF_IN_PROLOG, /* 19 */\n    XML_ERR_PEREF_IN_EPILOG, /* 20 */\n    XML_ERR_PEREF_IN_INT_SUBSET, /* 21 */\n    XML_ERR_ENTITYREF_NO_NAME, /* 22 */\n    XML_ERR_ENTITYREF_SEMICOL_MISSING, /* 23 */\n    XML_ERR_PEREF_NO_NAME, /* 24 */\n    XML_ERR_PEREF_SEMICOL_MISSING, /* 25 */\n    XML_ERR_UNDECLARED_ENTITY, /* 26 */\n    XML_WAR_UNDECLARED_ENTITY, /* 27 */\n    XML_ERR_UNPARSED_ENTITY, /* 28 */\n    XML_ERR_ENTITY_IS_EXTERNAL, /* 29 */\n    XML_ERR_ENTITY_IS_PARAMETER, /* 30 */\n    XML_ERR_UNKNOWN_ENCODING, /* 31 */\n    XML_ERR_UNSUPPORTED_ENCODING, /* 32 */\n    XML_ERR_STRING_NOT_STARTED, /* 33 */\n    XML_ERR_STRING_NOT_CLOSED, /* 34 */\n    XML_ERR_NS_DECL_ERROR, /* 35 */\n    XML_ERR_ENTITY_NOT_STARTED, /* 36 */\n    XML_ERR_ENTITY_NOT_FINISHED, /* 37 */\n    XML_ERR_LT_IN_ATTRIBUTE, /* 38 */\n    XML_ERR_ATTRIBUTE_NOT_STARTED, /* 39 */\n    XML_ERR_ATTRIBUTE_NOT_FINISHED, /* 40 */\n    XML_ERR_ATTRIBUTE_WITHOUT_VALUE, /* 41 */\n    XML_ERR_ATTRIBUTE_REDEFINED, /* 42 */\n    XML_ERR_LITERAL_NOT_STARTED, /* 43 */\n    XML_ERR_LITERAL_NOT_FINISHED, /* 44 */\n    XML_ERR_COMMENT_NOT_FINISHED, /* 45 */\n    XML_ERR_PI_NOT_STARTED, /* 46 */\n    XML_ERR_PI_NOT_FINISHED, /* 47 */\n    XML_ERR_NOTATION_NOT_STARTED, /* 48 */\n    XML_ERR_NOTATION_NOT_FINISHED, /* 49 */\n    XML_ERR_ATTLIST_NOT_STARTED, /* 50 */\n    XML_ERR_ATTLIST_NOT_FINISHED, /* 51 */\n    XML_ERR_MIXED_NOT_STARTED, /* 52 */\n    XML_ERR_MIXED_NOT_FINISHED, /* 53 */\n    XML_ERR_ELEMCONTENT_NOT_STARTED, /* 54 */\n    XML_ERR_ELEMCONTENT_NOT_FINISHED, /* 55 */\n    XML_ERR_XMLDECL_NOT_STARTED, /* 56 */\n    XML_ERR_XMLDECL_NOT_FINISHED, /* 57 */\n    XML_ERR_CONDSEC_NOT_STARTED, /* 58 */\n    XML_ERR_CONDSEC_NOT_FINISHED, /* 59 */\n    XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 60 */\n    XML_ERR_DOCTYPE_NOT_FINISHED, /* 61 */\n    XML_ERR_MISPLACED_CDATA_END, /* 62 */\n    XML_ERR_CDATA_NOT_FINISHED, /* 63 */\n    XML_ERR_RESERVED_XML_NAME, /* 64 */\n    XML_ERR_SPACE_REQUIRED, /* 65 */\n    XML_ERR_SEPARATOR_REQUIRED, /* 66 */\n    XML_ERR_NMTOKEN_REQUIRED, /* 67 */\n    XML_ERR_NAME_REQUIRED, /* 68 */\n    XML_ERR_PCDATA_REQUIRED, /* 69 */\n    XML_ERR_URI_REQUIRED, /* 70 */\n    XML_ERR_PUBID_REQUIRED, /* 71 */\n    XML_ERR_LT_REQUIRED, /* 72 */\n    XML_ERR_GT_REQUIRED, /* 73 */\n    XML_ERR_LTSLASH_REQUIRED, /* 74 */\n    XML_ERR_EQUAL_REQUIRED, /* 75 */\n    XML_ERR_TAG_NAME_MISMATCH, /* 76 */\n    XML_ERR_TAG_NOT_FINISHED, /* 77 */\n    XML_ERR_STANDALONE_VALUE, /* 78 */\n    XML_ERR_ENCODING_NAME, /* 79 */\n    XML_ERR_HYPHEN_IN_COMMENT, /* 80 */\n    XML_ERR_INVALID_ENCODING, /* 81 */\n    XML_ERR_EXT_ENTITY_STANDALONE, /* 82 */\n    XML_ERR_CONDSEC_INVALID, /* 83 */\n    XML_ERR_VALUE_REQUIRED, /* 84 */\n    XML_ERR_NOT_WELL_BALANCED, /* 85 */\n    XML_ERR_EXTRA_CONTENT, /* 86 */\n    XML_ERR_ENTITY_CHAR_ERROR, /* 87 */\n    XML_ERR_ENTITY_PE_INTERNAL, /* 88 */\n    XML_ERR_ENTITY_LOOP, /* 89 */\n    XML_ERR_ENTITY_BOUNDARY, /* 90 */\n    XML_ERR_INVALID_URI, /* 91 */\n    XML_ERR_URI_FRAGMENT, /* 92 */\n    XML_WAR_CATALOG_PI, /* 93 */\n    XML_ERR_NO_DTD, /* 94 */\n    XML_ERR_CONDSEC_INVALID_KEYWORD, /* 95 */\n    XML_ERR_VERSION_MISSING, /* 96 */\n    XML_WAR_UNKNOWN_VERSION, /* 97 */\n    XML_WAR_LANG_VALUE, /* 98 */\n    XML_WAR_NS_URI, /* 99 */\n    XML_WAR_NS_URI_RELATIVE, /* 100 */\n    XML_ERR_MISSING_ENCODING, /* 101 */\n    XML_WAR_SPACE_VALUE, /* 102 */\n    XML_ERR_NOT_STANDALONE, /* 103 */\n    XML_ERR_ENTITY_PROCESSING, /* 104 */\n    XML_ERR_NOTATION_PROCESSING, /* 105 */\n    XML_WAR_NS_COLUMN, /* 106 */\n    XML_WAR_ENTITY_REDEFINED, /* 107 */\n    XML_ERR_UNKNOWN_VERSION, /* 108 */\n    XML_ERR_VERSION_MISMATCH, /* 109 */\n    XML_ERR_NAME_TOO_LONG, /* 110 */\n    XML_ERR_USER_STOP, /* 111 */\n    XML_ERR_COMMENT_ABRUPTLY_ENDED, /* 112 */\n    XML_NS_ERR_XML_NAMESPACE = 200,\n    XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */\n    XML_NS_ERR_QNAME, /* 202 */\n    XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */\n    XML_NS_ERR_EMPTY, /* 204 */\n    XML_NS_ERR_COLON, /* 205 */\n    XML_DTD_ATTRIBUTE_DEFAULT = 500,\n    XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */\n    XML_DTD_ATTRIBUTE_VALUE, /* 502 */\n    XML_DTD_CONTENT_ERROR, /* 503 */\n    XML_DTD_CONTENT_MODEL, /* 504 */\n    XML_DTD_CONTENT_NOT_DETERMINIST, /* 505 */\n    XML_DTD_DIFFERENT_PREFIX, /* 506 */\n    XML_DTD_ELEM_DEFAULT_NAMESPACE, /* 507 */\n    XML_DTD_ELEM_NAMESPACE, /* 508 */\n    XML_DTD_ELEM_REDEFINED, /* 509 */\n    XML_DTD_EMPTY_NOTATION, /* 510 */\n    XML_DTD_ENTITY_TYPE, /* 511 */\n    XML_DTD_ID_FIXED, /* 512 */\n    XML_DTD_ID_REDEFINED, /* 513 */\n    XML_DTD_ID_SUBSET, /* 514 */\n    XML_DTD_INVALID_CHILD, /* 515 */\n    XML_DTD_INVALID_DEFAULT, /* 516 */\n    XML_DTD_LOAD_ERROR, /* 517 */\n    XML_DTD_MISSING_ATTRIBUTE, /* 518 */\n    XML_DTD_MIXED_CORRUPT, /* 519 */\n    XML_DTD_MULTIPLE_ID, /* 520 */\n    XML_DTD_NO_DOC, /* 521 */\n    XML_DTD_NO_DTD, /* 522 */\n    XML_DTD_NO_ELEM_NAME, /* 523 */\n    XML_DTD_NO_PREFIX, /* 524 */\n    XML_DTD_NO_ROOT, /* 525 */\n    XML_DTD_NOTATION_REDEFINED, /* 526 */\n    XML_DTD_NOTATION_VALUE, /* 527 */\n    XML_DTD_NOT_EMPTY, /* 528 */\n    XML_DTD_NOT_PCDATA, /* 529 */\n    XML_DTD_NOT_STANDALONE, /* 530 */\n    XML_DTD_ROOT_NAME, /* 531 */\n    XML_DTD_STANDALONE_WHITE_SPACE, /* 532 */\n    XML_DTD_UNKNOWN_ATTRIBUTE, /* 533 */\n    XML_DTD_UNKNOWN_ELEM, /* 534 */\n    XML_DTD_UNKNOWN_ENTITY, /* 535 */\n    XML_DTD_UNKNOWN_ID, /* 536 */\n    XML_DTD_UNKNOWN_NOTATION, /* 537 */\n    XML_DTD_STANDALONE_DEFAULTED, /* 538 */\n    XML_DTD_XMLID_VALUE, /* 539 */\n    XML_DTD_XMLID_TYPE, /* 540 */\n    XML_DTD_DUP_TOKEN, /* 541 */\n    XML_HTML_STRUCURE_ERROR = 800,\n    XML_HTML_UNKNOWN_TAG, /* 801 */\n    XML_HTML_INCORRECTLY_OPENED_COMMENT, /* 802 */\n    XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000,\n    XML_RNGP_ATTR_CONFLICT, /* 1001 */\n    XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */\n    XML_RNGP_ATTRIBUTE_CONTENT, /* 1003 */\n    XML_RNGP_ATTRIBUTE_EMPTY, /* 1004 */\n    XML_RNGP_ATTRIBUTE_NOOP, /* 1005 */\n    XML_RNGP_CHOICE_CONTENT, /* 1006 */\n    XML_RNGP_CHOICE_EMPTY, /* 1007 */\n    XML_RNGP_CREATE_FAILURE, /* 1008 */\n    XML_RNGP_DATA_CONTENT, /* 1009 */\n    XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, /* 1010 */\n    XML_RNGP_DEFINE_CREATE_FAILED, /* 1011 */\n    XML_RNGP_DEFINE_EMPTY, /* 1012 */\n    XML_RNGP_DEFINE_MISSING, /* 1013 */\n    XML_RNGP_DEFINE_NAME_MISSING, /* 1014 */\n    XML_RNGP_ELEM_CONTENT_EMPTY, /* 1015 */\n    XML_RNGP_ELEM_CONTENT_ERROR, /* 1016 */\n    XML_RNGP_ELEMENT_EMPTY, /* 1017 */\n    XML_RNGP_ELEMENT_CONTENT, /* 1018 */\n    XML_RNGP_ELEMENT_NAME, /* 1019 */\n    XML_RNGP_ELEMENT_NO_CONTENT, /* 1020 */\n    XML_RNGP_ELEM_TEXT_CONFLICT, /* 1021 */\n    XML_RNGP_EMPTY, /* 1022 */\n    XML_RNGP_EMPTY_CONSTRUCT, /* 1023 */\n    XML_RNGP_EMPTY_CONTENT, /* 1024 */\n    XML_RNGP_EMPTY_NOT_EMPTY, /* 1025 */\n    XML_RNGP_ERROR_TYPE_LIB, /* 1026 */\n    XML_RNGP_EXCEPT_EMPTY, /* 1027 */\n    XML_RNGP_EXCEPT_MISSING, /* 1028 */\n    XML_RNGP_EXCEPT_MULTIPLE, /* 1029 */\n    XML_RNGP_EXCEPT_NO_CONTENT, /* 1030 */\n    XML_RNGP_EXTERNALREF_EMTPY, /* 1031 */\n    XML_RNGP_EXTERNAL_REF_FAILURE, /* 1032 */\n    XML_RNGP_EXTERNALREF_RECURSE, /* 1033 */\n    XML_RNGP_FORBIDDEN_ATTRIBUTE, /* 1034 */\n    XML_RNGP_FOREIGN_ELEMENT, /* 1035 */\n    XML_RNGP_GRAMMAR_CONTENT, /* 1036 */\n    XML_RNGP_GRAMMAR_EMPTY, /* 1037 */\n    XML_RNGP_GRAMMAR_MISSING, /* 1038 */\n    XML_RNGP_GRAMMAR_NO_START, /* 1039 */\n    XML_RNGP_GROUP_ATTR_CONFLICT, /* 1040 */\n    XML_RNGP_HREF_ERROR, /* 1041 */\n    XML_RNGP_INCLUDE_EMPTY, /* 1042 */\n    XML_RNGP_INCLUDE_FAILURE, /* 1043 */\n    XML_RNGP_INCLUDE_RECURSE, /* 1044 */\n    XML_RNGP_INTERLEAVE_ADD, /* 1045 */\n    XML_RNGP_INTERLEAVE_CREATE_FAILED, /* 1046 */\n    XML_RNGP_INTERLEAVE_EMPTY, /* 1047 */\n    XML_RNGP_INTERLEAVE_NO_CONTENT, /* 1048 */\n    XML_RNGP_INVALID_DEFINE_NAME, /* 1049 */\n    XML_RNGP_INVALID_URI, /* 1050 */\n    XML_RNGP_INVALID_VALUE, /* 1051 */\n    XML_RNGP_MISSING_HREF, /* 1052 */\n    XML_RNGP_NAME_MISSING, /* 1053 */\n    XML_RNGP_NEED_COMBINE, /* 1054 */\n    XML_RNGP_NOTALLOWED_NOT_EMPTY, /* 1055 */\n    XML_RNGP_NSNAME_ATTR_ANCESTOR, /* 1056 */\n    XML_RNGP_NSNAME_NO_NS, /* 1057 */\n    XML_RNGP_PARAM_FORBIDDEN, /* 1058 */\n    XML_RNGP_PARAM_NAME_MISSING, /* 1059 */\n    XML_RNGP_PARENTREF_CREATE_FAILED, /* 1060 */\n    XML_RNGP_PARENTREF_NAME_INVALID, /* 1061 */\n    XML_RNGP_PARENTREF_NO_NAME, /* 1062 */\n    XML_RNGP_PARENTREF_NO_PARENT, /* 1063 */\n    XML_RNGP_PARENTREF_NOT_EMPTY, /* 1064 */\n    XML_RNGP_PARSE_ERROR, /* 1065 */\n    XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, /* 1066 */\n    XML_RNGP_PAT_ATTR_ATTR, /* 1067 */\n    XML_RNGP_PAT_ATTR_ELEM, /* 1068 */\n    XML_RNGP_PAT_DATA_EXCEPT_ATTR, /* 1069 */\n    XML_RNGP_PAT_DATA_EXCEPT_ELEM, /* 1070 */\n    XML_RNGP_PAT_DATA_EXCEPT_EMPTY, /* 1071 */\n    XML_RNGP_PAT_DATA_EXCEPT_GROUP, /* 1072 */\n    XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, /* 1073 */\n    XML_RNGP_PAT_DATA_EXCEPT_LIST, /* 1074 */\n    XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, /* 1075 */\n    XML_RNGP_PAT_DATA_EXCEPT_REF, /* 1076 */\n    XML_RNGP_PAT_DATA_EXCEPT_TEXT, /* 1077 */\n    XML_RNGP_PAT_LIST_ATTR, /* 1078 */\n    XML_RNGP_PAT_LIST_ELEM, /* 1079 */\n    XML_RNGP_PAT_LIST_INTERLEAVE, /* 1080 */\n    XML_RNGP_PAT_LIST_LIST, /* 1081 */\n    XML_RNGP_PAT_LIST_REF, /* 1082 */\n    XML_RNGP_PAT_LIST_TEXT, /* 1083 */\n    XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, /* 1084 */\n    XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, /* 1085 */\n    XML_RNGP_PAT_ONEMORE_GROUP_ATTR, /* 1086 */\n    XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, /* 1087 */\n    XML_RNGP_PAT_START_ATTR, /* 1088 */\n    XML_RNGP_PAT_START_DATA, /* 1089 */\n    XML_RNGP_PAT_START_EMPTY, /* 1090 */\n    XML_RNGP_PAT_START_GROUP, /* 1091 */\n    XML_RNGP_PAT_START_INTERLEAVE, /* 1092 */\n    XML_RNGP_PAT_START_LIST, /* 1093 */\n    XML_RNGP_PAT_START_ONEMORE, /* 1094 */\n    XML_RNGP_PAT_START_TEXT, /* 1095 */\n    XML_RNGP_PAT_START_VALUE, /* 1096 */\n    XML_RNGP_PREFIX_UNDEFINED, /* 1097 */\n    XML_RNGP_REF_CREATE_FAILED, /* 1098 */\n    XML_RNGP_REF_CYCLE, /* 1099 */\n    XML_RNGP_REF_NAME_INVALID, /* 1100 */\n    XML_RNGP_REF_NO_DEF, /* 1101 */\n    XML_RNGP_REF_NO_NAME, /* 1102 */\n    XML_RNGP_REF_NOT_EMPTY, /* 1103 */\n    XML_RNGP_START_CHOICE_AND_INTERLEAVE, /* 1104 */\n    XML_RNGP_START_CONTENT, /* 1105 */\n    XML_RNGP_START_EMPTY, /* 1106 */\n    XML_RNGP_START_MISSING, /* 1107 */\n    XML_RNGP_TEXT_EXPECTED, /* 1108 */\n    XML_RNGP_TEXT_HAS_CHILD, /* 1109 */\n    XML_RNGP_TYPE_MISSING, /* 1110 */\n    XML_RNGP_TYPE_NOT_FOUND, /* 1111 */\n    XML_RNGP_TYPE_VALUE, /* 1112 */\n    XML_RNGP_UNKNOWN_ATTRIBUTE, /* 1113 */\n    XML_RNGP_UNKNOWN_COMBINE, /* 1114 */\n    XML_RNGP_UNKNOWN_CONSTRUCT, /* 1115 */\n    XML_RNGP_UNKNOWN_TYPE_LIB, /* 1116 */\n    XML_RNGP_URI_FRAGMENT, /* 1117 */\n    XML_RNGP_URI_NOT_ABSOLUTE, /* 1118 */\n    XML_RNGP_VALUE_EMPTY, /* 1119 */\n    XML_RNGP_VALUE_NO_CONTENT, /* 1120 */\n    XML_RNGP_XMLNS_NAME, /* 1121 */\n    XML_RNGP_XML_NS, /* 1122 */\n    XML_XPATH_EXPRESSION_OK = 1200,\n    XML_XPATH_NUMBER_ERROR, /* 1201 */\n    XML_XPATH_UNFINISHED_LITERAL_ERROR, /* 1202 */\n    XML_XPATH_START_LITERAL_ERROR, /* 1203 */\n    XML_XPATH_VARIABLE_REF_ERROR, /* 1204 */\n    XML_XPATH_UNDEF_VARIABLE_ERROR, /* 1205 */\n    XML_XPATH_INVALID_PREDICATE_ERROR, /* 1206 */\n    XML_XPATH_EXPR_ERROR, /* 1207 */\n    XML_XPATH_UNCLOSED_ERROR, /* 1208 */\n    XML_XPATH_UNKNOWN_FUNC_ERROR, /* 1209 */\n    XML_XPATH_INVALID_OPERAND, /* 1210 */\n    XML_XPATH_INVALID_TYPE, /* 1211 */\n    XML_XPATH_INVALID_ARITY, /* 1212 */\n    XML_XPATH_INVALID_CTXT_SIZE, /* 1213 */\n    XML_XPATH_INVALID_CTXT_POSITION, /* 1214 */\n    XML_XPATH_MEMORY_ERROR, /* 1215 */\n    XML_XPTR_SYNTAX_ERROR, /* 1216 */\n    XML_XPTR_RESOURCE_ERROR, /* 1217 */\n    XML_XPTR_SUB_RESOURCE_ERROR, /* 1218 */\n    XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */\n    XML_XPATH_ENCODING_ERROR, /* 1220 */\n    XML_XPATH_INVALID_CHAR_ERROR, /* 1221 */\n    XML_TREE_INVALID_HEX = 1300,\n    XML_TREE_INVALID_DEC, /* 1301 */\n    XML_TREE_UNTERMINATED_ENTITY, /* 1302 */\n    XML_TREE_NOT_UTF8, /* 1303 */\n    XML_SAVE_NOT_UTF8 = 1400,\n    XML_SAVE_CHAR_INVALID, /* 1401 */\n    XML_SAVE_NO_DOCTYPE, /* 1402 */\n    XML_SAVE_UNKNOWN_ENCODING, /* 1403 */\n    XML_REGEXP_COMPILE_ERROR = 1450,\n    XML_IO_UNKNOWN = 1500,\n    XML_IO_EACCES, /* 1501 */\n    XML_IO_EAGAIN, /* 1502 */\n    XML_IO_EBADF, /* 1503 */\n    XML_IO_EBADMSG, /* 1504 */\n    XML_IO_EBUSY, /* 1505 */\n    XML_IO_ECANCELED, /* 1506 */\n    XML_IO_ECHILD, /* 1507 */\n    XML_IO_EDEADLK, /* 1508 */\n    XML_IO_EDOM, /* 1509 */\n    XML_IO_EEXIST, /* 1510 */\n    XML_IO_EFAULT, /* 1511 */\n    XML_IO_EFBIG, /* 1512 */\n    XML_IO_EINPROGRESS, /* 1513 */\n    XML_IO_EINTR, /* 1514 */\n    XML_IO_EINVAL, /* 1515 */\n    XML_IO_EIO, /* 1516 */\n    XML_IO_EISDIR, /* 1517 */\n    XML_IO_EMFILE, /* 1518 */\n    XML_IO_EMLINK, /* 1519 */\n    XML_IO_EMSGSIZE, /* 1520 */\n    XML_IO_ENAMETOOLONG, /* 1521 */\n    XML_IO_ENFILE, /* 1522 */\n    XML_IO_ENODEV, /* 1523 */\n    XML_IO_ENOENT, /* 1524 */\n    XML_IO_ENOEXEC, /* 1525 */\n    XML_IO_ENOLCK, /* 1526 */\n    XML_IO_ENOMEM, /* 1527 */\n    XML_IO_ENOSPC, /* 1528 */\n    XML_IO_ENOSYS, /* 1529 */\n    XML_IO_ENOTDIR, /* 1530 */\n    XML_IO_ENOTEMPTY, /* 1531 */\n    XML_IO_ENOTSUP, /* 1532 */\n    XML_IO_ENOTTY, /* 1533 */\n    XML_IO_ENXIO, /* 1534 */\n    XML_IO_EPERM, /* 1535 */\n    XML_IO_EPIPE, /* 1536 */\n    XML_IO_ERANGE, /* 1537 */\n    XML_IO_EROFS, /* 1538 */\n    XML_IO_ESPIPE, /* 1539 */\n    XML_IO_ESRCH, /* 1540 */\n    XML_IO_ETIMEDOUT, /* 1541 */\n    XML_IO_EXDEV, /* 1542 */\n    XML_IO_NETWORK_ATTEMPT, /* 1543 */\n    XML_IO_ENCODER, /* 1544 */\n    XML_IO_FLUSH, /* 1545 */\n    XML_IO_WRITE, /* 1546 */\n    XML_IO_NO_INPUT, /* 1547 */\n    XML_IO_BUFFER_FULL, /* 1548 */\n    XML_IO_LOAD_ERROR, /* 1549 */\n    XML_IO_ENOTSOCK, /* 1550 */\n    XML_IO_EISCONN, /* 1551 */\n    XML_IO_ECONNREFUSED, /* 1552 */\n    XML_IO_ENETUNREACH, /* 1553 */\n    XML_IO_EADDRINUSE, /* 1554 */\n    XML_IO_EALREADY, /* 1555 */\n    XML_IO_EAFNOSUPPORT, /* 1556 */\n    XML_XINCLUDE_RECURSION=1600,\n    XML_XINCLUDE_PARSE_VALUE, /* 1601 */\n    XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */\n    XML_XINCLUDE_NO_HREF, /* 1603 */\n    XML_XINCLUDE_NO_FALLBACK, /* 1604 */\n    XML_XINCLUDE_HREF_URI, /* 1605 */\n    XML_XINCLUDE_TEXT_FRAGMENT, /* 1606 */\n    XML_XINCLUDE_TEXT_DOCUMENT, /* 1607 */\n    XML_XINCLUDE_INVALID_CHAR, /* 1608 */\n    XML_XINCLUDE_BUILD_FAILED, /* 1609 */\n    XML_XINCLUDE_UNKNOWN_ENCODING, /* 1610 */\n    XML_XINCLUDE_MULTIPLE_ROOT, /* 1611 */\n    XML_XINCLUDE_XPTR_FAILED, /* 1612 */\n    XML_XINCLUDE_XPTR_RESULT, /* 1613 */\n    XML_XINCLUDE_INCLUDE_IN_INCLUDE, /* 1614 */\n    XML_XINCLUDE_FALLBACKS_IN_INCLUDE, /* 1615 */\n    XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, /* 1616 */\n    XML_XINCLUDE_DEPRECATED_NS, /* 1617 */\n    XML_XINCLUDE_FRAGMENT_ID, /* 1618 */\n    XML_CATALOG_MISSING_ATTR = 1650,\n    XML_CATALOG_ENTRY_BROKEN, /* 1651 */\n    XML_CATALOG_PREFER_VALUE, /* 1652 */\n    XML_CATALOG_NOT_CATALOG, /* 1653 */\n    XML_CATALOG_RECURSION, /* 1654 */\n    XML_SCHEMAP_PREFIX_UNDEFINED = 1700,\n    XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, /* 1701 */\n    XML_SCHEMAP_ATTRGRP_NONAME_NOREF, /* 1702 */\n    XML_SCHEMAP_ATTR_NONAME_NOREF, /* 1703 */\n    XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, /* 1704 */\n    XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, /* 1705 */\n    XML_SCHEMAP_ELEM_NONAME_NOREF, /* 1706 */\n    XML_SCHEMAP_EXTENSION_NO_BASE, /* 1707 */\n    XML_SCHEMAP_FACET_NO_VALUE, /* 1708 */\n    XML_SCHEMAP_FAILED_BUILD_IMPORT, /* 1709 */\n    XML_SCHEMAP_GROUP_NONAME_NOREF, /* 1710 */\n    XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, /* 1711 */\n    XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, /* 1712 */\n    XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, /* 1713 */\n    XML_SCHEMAP_INVALID_BOOLEAN, /* 1714 */\n    XML_SCHEMAP_INVALID_ENUM, /* 1715 */\n    XML_SCHEMAP_INVALID_FACET, /* 1716 */\n    XML_SCHEMAP_INVALID_FACET_VALUE, /* 1717 */\n    XML_SCHEMAP_INVALID_MAXOCCURS, /* 1718 */\n    XML_SCHEMAP_INVALID_MINOCCURS, /* 1719 */\n    XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, /* 1720 */\n    XML_SCHEMAP_INVALID_WHITE_SPACE, /* 1721 */\n    XML_SCHEMAP_NOATTR_NOREF, /* 1722 */\n    XML_SCHEMAP_NOTATION_NO_NAME, /* 1723 */\n    XML_SCHEMAP_NOTYPE_NOREF, /* 1724 */\n    XML_SCHEMAP_REF_AND_SUBTYPE, /* 1725 */\n    XML_SCHEMAP_RESTRICTION_NONAME_NOREF, /* 1726 */\n    XML_SCHEMAP_SIMPLETYPE_NONAME, /* 1727 */\n    XML_SCHEMAP_TYPE_AND_SUBTYPE, /* 1728 */\n    XML_SCHEMAP_UNKNOWN_ALL_CHILD, /* 1729 */\n    XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, /* 1730 */\n    XML_SCHEMAP_UNKNOWN_ATTR_CHILD, /* 1731 */\n    XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, /* 1732 */\n    XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, /* 1733 */\n    XML_SCHEMAP_UNKNOWN_BASE_TYPE, /* 1734 */\n    XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, /* 1735 */\n    XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, /* 1736 */\n    XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, /* 1737 */\n    XML_SCHEMAP_UNKNOWN_ELEM_CHILD, /* 1738 */\n    XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, /* 1739 */\n    XML_SCHEMAP_UNKNOWN_FACET_CHILD, /* 1740 */\n    XML_SCHEMAP_UNKNOWN_FACET_TYPE, /* 1741 */\n    XML_SCHEMAP_UNKNOWN_GROUP_CHILD, /* 1742 */\n    XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, /* 1743 */\n    XML_SCHEMAP_UNKNOWN_LIST_CHILD, /* 1744 */\n    XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, /* 1745 */\n    XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, /* 1746 */\n    XML_SCHEMAP_UNKNOWN_REF, /* 1747 */\n    XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, /* 1748 */\n    XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, /* 1749 */\n    XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, /* 1750 */\n    XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, /* 1751 */\n    XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, /* 1752 */\n    XML_SCHEMAP_UNKNOWN_TYPE, /* 1753 */\n    XML_SCHEMAP_UNKNOWN_UNION_CHILD, /* 1754 */\n    XML_SCHEMAP_ELEM_DEFAULT_FIXED, /* 1755 */\n    XML_SCHEMAP_REGEXP_INVALID, /* 1756 */\n    XML_SCHEMAP_FAILED_LOAD, /* 1757 */\n    XML_SCHEMAP_NOTHING_TO_PARSE, /* 1758 */\n    XML_SCHEMAP_NOROOT, /* 1759 */\n    XML_SCHEMAP_REDEFINED_GROUP, /* 1760 */\n    XML_SCHEMAP_REDEFINED_TYPE, /* 1761 */\n    XML_SCHEMAP_REDEFINED_ELEMENT, /* 1762 */\n    XML_SCHEMAP_REDEFINED_ATTRGROUP, /* 1763 */\n    XML_SCHEMAP_REDEFINED_ATTR, /* 1764 */\n    XML_SCHEMAP_REDEFINED_NOTATION, /* 1765 */\n    XML_SCHEMAP_FAILED_PARSE, /* 1766 */\n    XML_SCHEMAP_UNKNOWN_PREFIX, /* 1767 */\n    XML_SCHEMAP_DEF_AND_PREFIX, /* 1768 */\n    XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, /* 1769 */\n    XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, /* 1770 */\n    XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, /* 1771 */\n    XML_SCHEMAP_NOT_SCHEMA, /* 1772 */\n    XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, /* 1773 */\n    XML_SCHEMAP_INVALID_ATTR_USE, /* 1774 */\n    XML_SCHEMAP_RECURSIVE, /* 1775 */\n    XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, /* 1776 */\n    XML_SCHEMAP_INVALID_ATTR_COMBINATION, /* 1777 */\n    XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, /* 1778 */\n    XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1779 */\n    XML_SCHEMAP_INVALID_ATTR_NAME, /* 1780 */\n    XML_SCHEMAP_REF_AND_CONTENT, /* 1781 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1782 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1783 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1784 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1785 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1786 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1787 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1788 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1789 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1790 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1791 */\n    XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1792 */\n    XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1793 */\n    XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1794 */\n    XML_SCHEMAP_SRC_IMPORT_3_1, /* 1795 */\n    XML_SCHEMAP_SRC_IMPORT_3_2, /* 1796 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, /* 1797 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, /* 1798 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, /* 1799 */\n    XML_SCHEMAP_COS_CT_EXTENDS_1_3, /* 1800 */\n    XML_SCHEMAV_NOROOT = 1801,\n    XML_SCHEMAV_UNDECLAREDELEM, /* 1802 */\n    XML_SCHEMAV_NOTTOPLEVEL, /* 1803 */\n    XML_SCHEMAV_MISSING, /* 1804 */\n    XML_SCHEMAV_WRONGELEM, /* 1805 */\n    XML_SCHEMAV_NOTYPE, /* 1806 */\n    XML_SCHEMAV_NOROLLBACK, /* 1807 */\n    XML_SCHEMAV_ISABSTRACT, /* 1808 */\n    XML_SCHEMAV_NOTEMPTY, /* 1809 */\n    XML_SCHEMAV_ELEMCONT, /* 1810 */\n    XML_SCHEMAV_HAVEDEFAULT, /* 1811 */\n    XML_SCHEMAV_NOTNILLABLE, /* 1812 */\n    XML_SCHEMAV_EXTRACONTENT, /* 1813 */\n    XML_SCHEMAV_INVALIDATTR, /* 1814 */\n    XML_SCHEMAV_INVALIDELEM, /* 1815 */\n    XML_SCHEMAV_NOTDETERMINIST, /* 1816 */\n    XML_SCHEMAV_CONSTRUCT, /* 1817 */\n    XML_SCHEMAV_INTERNAL, /* 1818 */\n    XML_SCHEMAV_NOTSIMPLE, /* 1819 */\n    XML_SCHEMAV_ATTRUNKNOWN, /* 1820 */\n    XML_SCHEMAV_ATTRINVALID, /* 1821 */\n    XML_SCHEMAV_VALUE, /* 1822 */\n    XML_SCHEMAV_FACET, /* 1823 */\n    XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, /* 1824 */\n    XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, /* 1825 */\n    XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, /* 1826 */\n    XML_SCHEMAV_CVC_TYPE_3_1_1, /* 1827 */\n    XML_SCHEMAV_CVC_TYPE_3_1_2, /* 1828 */\n    XML_SCHEMAV_CVC_FACET_VALID, /* 1829 */\n    XML_SCHEMAV_CVC_LENGTH_VALID, /* 1830 */\n    XML_SCHEMAV_CVC_MINLENGTH_VALID, /* 1831 */\n    XML_SCHEMAV_CVC_MAXLENGTH_VALID, /* 1832 */\n    XML_SCHEMAV_CVC_MININCLUSIVE_VALID, /* 1833 */\n    XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, /* 1834 */\n    XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, /* 1835 */\n    XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, /* 1836 */\n    XML_SCHEMAV_CVC_TOTALDIGITS_VALID, /* 1837 */\n    XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, /* 1838 */\n    XML_SCHEMAV_CVC_PATTERN_VALID, /* 1839 */\n    XML_SCHEMAV_CVC_ENUMERATION_VALID, /* 1840 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, /* 1841 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, /* 1842 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, /* 1843 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, /* 1844 */\n    XML_SCHEMAV_CVC_ELT_1, /* 1845 */\n    XML_SCHEMAV_CVC_ELT_2, /* 1846 */\n    XML_SCHEMAV_CVC_ELT_3_1, /* 1847 */\n    XML_SCHEMAV_CVC_ELT_3_2_1, /* 1848 */\n    XML_SCHEMAV_CVC_ELT_3_2_2, /* 1849 */\n    XML_SCHEMAV_CVC_ELT_4_1, /* 1850 */\n    XML_SCHEMAV_CVC_ELT_4_2, /* 1851 */\n    XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */\n    XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */\n    XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */\n    XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */\n    XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */\n    XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */\n    XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */\n    XML_SCHEMAV_CVC_ELT_6, /* 1859 */\n    XML_SCHEMAV_CVC_ELT_7, /* 1860 */\n    XML_SCHEMAV_CVC_ATTRIBUTE_1, /* 1861 */\n    XML_SCHEMAV_CVC_ATTRIBUTE_2, /* 1862 */\n    XML_SCHEMAV_CVC_ATTRIBUTE_3, /* 1863 */\n    XML_SCHEMAV_CVC_ATTRIBUTE_4, /* 1864 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, /* 1865 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, /* 1866 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, /* 1867 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_4, /* 1868 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, /* 1869 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, /* 1870 */\n    XML_SCHEMAV_ELEMENT_CONTENT, /* 1871 */\n    XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* 1872 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_1, /* 1873 */\n    XML_SCHEMAV_CVC_AU, /* 1874 */\n    XML_SCHEMAV_CVC_TYPE_1, /* 1875 */\n    XML_SCHEMAV_CVC_TYPE_2, /* 1876 */\n    XML_SCHEMAV_CVC_IDC, /* 1877 */\n    XML_SCHEMAV_CVC_WILDCARD, /* 1878 */\n    XML_SCHEMAV_MISC, /* 1879 */\n    XML_XPTR_UNKNOWN_SCHEME = 1900,\n    XML_XPTR_CHILDSEQ_START, /* 1901 */\n    XML_XPTR_EVAL_FAILED, /* 1902 */\n    XML_XPTR_EXTRA_OBJECTS, /* 1903 */\n    XML_C14N_CREATE_CTXT = 1950,\n    XML_C14N_REQUIRES_UTF8, /* 1951 */\n    XML_C14N_CREATE_STACK, /* 1952 */\n    XML_C14N_INVALID_NODE, /* 1953 */\n    XML_C14N_UNKNOW_NODE, /* 1954 */\n    XML_C14N_RELATIVE_NAMESPACE, /* 1955 */\n    XML_FTP_PASV_ANSWER = 2000,\n    XML_FTP_EPSV_ANSWER, /* 2001 */\n    XML_FTP_ACCNT, /* 2002 */\n    XML_FTP_URL_SYNTAX, /* 2003 */\n    XML_HTTP_URL_SYNTAX = 2020,\n    XML_HTTP_USE_IP, /* 2021 */\n    XML_HTTP_UNKNOWN_HOST, /* 2022 */\n    XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000,\n    XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */\n    XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */\n    XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */\n    XML_SCHEMAP_SRC_RESOLVE, /* 3004 */\n    XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */\n    XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */\n    XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */\n    XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */\n    XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */\n    XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, /* 3016 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, /* 3017 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, /* 3018 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, /* 3019 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, /* 3020 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, /* 3021 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, /* 3022 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_1, /* 3023 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, /* 3024 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, /* 3025 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, /* 3026 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, /* 3027 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */\n    XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */\n    XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */\n    XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */\n    XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */\n    XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, /* 3035 */\n    XML_SCHEMAP_S4S_ATTR_MISSING, /* 3036 */\n    XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, /* 3037 */\n    XML_SCHEMAP_SRC_ELEMENT_1, /* 3038 */\n    XML_SCHEMAP_SRC_ELEMENT_2_1, /* 3039 */\n    XML_SCHEMAP_SRC_ELEMENT_2_2, /* 3040 */\n    XML_SCHEMAP_SRC_ELEMENT_3, /* 3041 */\n    XML_SCHEMAP_P_PROPS_CORRECT_1, /* 3042 */\n    XML_SCHEMAP_P_PROPS_CORRECT_2_1, /* 3043 */\n    XML_SCHEMAP_P_PROPS_CORRECT_2_2, /* 3044 */\n    XML_SCHEMAP_E_PROPS_CORRECT_2, /* 3045 */\n    XML_SCHEMAP_E_PROPS_CORRECT_3, /* 3046 */\n    XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */\n    XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */\n    XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */\n    XML_SCHEMAP_SRC_INCLUDE, /* 3050 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */\n    XML_SCHEMAP_NO_XMLNS, /* 3056 */\n    XML_SCHEMAP_NO_XSI, /* 3057 */\n    XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */\n    XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */\n    XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */\n    XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, /* 3061 */\n    XML_SCHEMAP_CVC_SIMPLE_TYPE, /* 3062 */\n    XML_SCHEMAP_COS_CT_EXTENDS_1_1, /* 3063 */\n    XML_SCHEMAP_SRC_IMPORT_1_1, /* 3064 */\n    XML_SCHEMAP_SRC_IMPORT_1_2, /* 3065 */\n    XML_SCHEMAP_SRC_IMPORT_2, /* 3066 */\n    XML_SCHEMAP_SRC_IMPORT_2_1, /* 3067 */\n    XML_SCHEMAP_SRC_IMPORT_2_2, /* 3068 */\n    XML_SCHEMAP_INTERNAL, /* 3069 non-W3C */\n    XML_SCHEMAP_NOT_DETERMINISTIC, /* 3070 non-W3C */\n    XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1, /* 3071 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, /* 3072 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, /* 3073 */\n    XML_SCHEMAP_MG_PROPS_CORRECT_1, /* 3074 */\n    XML_SCHEMAP_MG_PROPS_CORRECT_2, /* 3075 */\n    XML_SCHEMAP_SRC_CT_1, /* 3076 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */\n    XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */\n    XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */\n    XML_SCHEMAP_C_PROPS_CORRECT, /* 3080 */\n    XML_SCHEMAP_SRC_REDEFINE, /* 3081 */\n    XML_SCHEMAP_SRC_IMPORT, /* 3082 */\n    XML_SCHEMAP_WARN_SKIP_SCHEMA, /* 3083 */\n    XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, /* 3084 */\n    XML_SCHEMAP_WARN_ATTR_REDECL_PROH, /* 3085 */\n    XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, /* 3085 */\n    XML_SCHEMAP_AG_PROPS_CORRECT, /* 3086 */\n    XML_SCHEMAP_COS_CT_EXTENDS_1_2, /* 3087 */\n    XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */\n    XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */\n    XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */\n    XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */\n    XML_SCHEMATRONV_REPORT,\n    XML_MODULE_OPEN = 4900, /* 4900 */\n    XML_MODULE_CLOSE, /* 4901 */\n    XML_CHECK_FOUND_ELEMENT = 5000,\n    XML_CHECK_FOUND_ATTRIBUTE, /* 5001 */\n    XML_CHECK_FOUND_TEXT, /* 5002 */\n    XML_CHECK_FOUND_CDATA, /* 5003 */\n    XML_CHECK_FOUND_ENTITYREF, /* 5004 */\n    XML_CHECK_FOUND_ENTITY, /* 5005 */\n    XML_CHECK_FOUND_PI, /* 5006 */\n    XML_CHECK_FOUND_COMMENT, /* 5007 */\n    XML_CHECK_FOUND_DOCTYPE, /* 5008 */\n    XML_CHECK_FOUND_FRAGMENT, /* 5009 */\n    XML_CHECK_FOUND_NOTATION, /* 5010 */\n    XML_CHECK_UNKNOWN_NODE, /* 5011 */\n    XML_CHECK_ENTITY_TYPE, /* 5012 */\n    XML_CHECK_NO_PARENT, /* 5013 */\n    XML_CHECK_NO_DOC, /* 5014 */\n    XML_CHECK_NO_NAME, /* 5015 */\n    XML_CHECK_NO_ELEM, /* 5016 */\n    XML_CHECK_WRONG_DOC, /* 5017 */\n    XML_CHECK_NO_PREV, /* 5018 */\n    XML_CHECK_WRONG_PREV, /* 5019 */\n    XML_CHECK_NO_NEXT, /* 5020 */\n    XML_CHECK_WRONG_NEXT, /* 5021 */\n    XML_CHECK_NOT_DTD, /* 5022 */\n    XML_CHECK_NOT_ATTR, /* 5023 */\n    XML_CHECK_NOT_ATTR_DECL, /* 5024 */\n    XML_CHECK_NOT_ELEM_DECL, /* 5025 */\n    XML_CHECK_NOT_ENTITY_DECL, /* 5026 */\n    XML_CHECK_NOT_NS_DECL, /* 5027 */\n    XML_CHECK_NO_HREF, /* 5028 */\n    XML_CHECK_WRONG_PARENT,/* 5029 */\n    XML_CHECK_NS_SCOPE, /* 5030 */\n    XML_CHECK_NS_ANCESTOR, /* 5031 */\n    XML_CHECK_NOT_UTF8, /* 5032 */\n    XML_CHECK_NO_DICT, /* 5033 */\n    XML_CHECK_NOT_NCNAME, /* 5034 */\n    XML_CHECK_OUTSIDE_DICT, /* 5035 */\n    XML_CHECK_WRONG_NAME, /* 5036 */\n    XML_CHECK_NAME_NOT_NULL, /* 5037 */\n    XML_I18N_NO_NAME = 6000,\n    XML_I18N_NO_HANDLER, /* 6001 */\n    XML_I18N_EXCESS_HANDLER, /* 6002 */\n    XML_I18N_CONV_FAILED, /* 6003 */\n    XML_I18N_NO_OUTPUT, /* 6004 */\n    XML_BUF_OVERFLOW = 7000\n} xmlParserErrors;\n\n/**\n * xmlGenericErrorFunc:\n * @ctx:  a parsing context\n * @msg:  the message\n * @...:  the extra arguments of the varargs to format the message\n *\n * Signature of the function to use when there is an error and\n * no parsing or validity context available .\n */\ntypedef void (*xmlGenericErrorFunc) (void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\n/**\n * xmlStructuredErrorFunc:\n * @userData:  user provided data for the error callback\n * @error:  the error being raised.\n *\n * Signature of the function to use when there is an error and\n * the module handles the new error reporting mechanism.\n */\ntypedef void (*xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error);\n\n/*\n * Use the following function to reset the two global variables\n * xmlGenericError and xmlGenericErrorContext.\n */\nXMLPUBFUN void\n    xmlSetGenericErrorFunc\t(void *ctx,\n\t\t\t\t xmlGenericErrorFunc handler);\nXML_DEPRECATED\nXMLPUBFUN void\n    initGenericErrorDefaultFunc\t(xmlGenericErrorFunc *handler);\n\nXMLPUBFUN void\n    xmlSetStructuredErrorFunc\t(void *ctx,\n\t\t\t\t xmlStructuredErrorFunc handler);\n/*\n * Default message routines used by SAX and Valid context for error\n * and warning reporting.\n */\nXMLPUBFUN void\n    xmlParserError\t\t(void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\nXMLPUBFUN void\n    xmlParserWarning\t\t(void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\nXMLPUBFUN void\n    xmlParserValidityError\t(void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\nXMLPUBFUN void\n    xmlParserValidityWarning\t(void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\nXMLPUBFUN void\n    xmlParserPrintFileInfo\t(xmlParserInputPtr input);\nXMLPUBFUN void\n    xmlParserPrintFileContext\t(xmlParserInputPtr input);\n\n/*\n * Extended error information routines\n */\nXMLPUBFUN xmlErrorPtr\n    xmlGetLastError\t\t(void);\nXMLPUBFUN void\n    xmlResetLastError\t\t(void);\nXMLPUBFUN xmlErrorPtr\n    xmlCtxtGetLastError\t\t(void *ctx);\nXMLPUBFUN void\n    xmlCtxtResetLastError\t(void *ctx);\nXMLPUBFUN void\n    xmlResetError\t\t(xmlErrorPtr err);\nXMLPUBFUN int\n    xmlCopyError\t\t(xmlErrorPtr from,\n\t\t\t\t xmlErrorPtr to);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_ERROR_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlexports.h",
    "content": "/*\n * Summary: macros for marking symbols as exportable/importable.\n * Description: macros for marking symbols as exportable/importable.\n *\n * Copy: See Copyright for the status of this software.\n */\n\n#ifndef __XML_EXPORTS_H__\n#define __XML_EXPORTS_H__\n\n/** DOC_DISABLE */\n#if defined(_WIN32) || defined(__CYGWIN__)\n  #ifdef LIBXML_STATIC\n    #define XMLPUBLIC\n  #elif defined(IN_LIBXML)\n    #define XMLPUBLIC __declspec(dllexport)\n  #else\n    #define XMLPUBLIC __declspec(dllimport)\n  #endif\n#else /* not Windows */\n  #define XMLPUBLIC\n#endif /* platform switch */\n/** DOC_ENABLE */\n\n/*\n * XMLPUBFUN:\n *\n * Macro which declares an exportable function\n */\n#define XMLPUBFUN XMLPUBLIC\n\n/**\n * XMLPUBVAR:\n *\n * Macro which declares an exportable variable\n */\n#define XMLPUBVAR XMLPUBLIC extern\n\n/** DOC_DISABLE */\n/* Compatibility */\n#define XMLCALL\n#define XMLCDECL\n#if !defined(LIBXML_DLL_IMPORT)\n#define LIBXML_DLL_IMPORT XMLPUBVAR\n#endif\n/** DOC_ENABLE */\n\n#endif /* __XML_EXPORTS_H__ */\n\n\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlmemory.h",
    "content": "/*\n * Summary: interface for the memory allocator\n * Description: provides interfaces for the memory allocator,\n *              including debugging capabilities.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __DEBUG_MEMORY_ALLOC__\n#define __DEBUG_MEMORY_ALLOC__\n\n#include <stdio.h>\n#include <libxml/xmlversion.h>\n\n/**\n * DEBUG_MEMORY:\n *\n * DEBUG_MEMORY replaces the allocator with a collect and debug\n * shell to the libc allocator.\n * DEBUG_MEMORY should only be activated when debugging\n * libxml i.e. if libxml has been configured with --with-debug-mem too.\n */\n/* #define DEBUG_MEMORY_FREED */\n/* #define DEBUG_MEMORY_LOCATION */\n\n#ifdef DEBUG\n#ifndef DEBUG_MEMORY\n#define DEBUG_MEMORY\n#endif\n#endif\n\n/**\n * DEBUG_MEMORY_LOCATION:\n *\n * DEBUG_MEMORY_LOCATION should be activated only when debugging\n * libxml i.e. if libxml has been configured with --with-debug-mem too.\n */\n#ifdef DEBUG_MEMORY_LOCATION\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The XML memory wrapper support 4 basic overloadable functions.\n */\n/**\n * xmlFreeFunc:\n * @mem: an already allocated block of memory\n *\n * Signature for a free() implementation.\n */\ntypedef void (*xmlFreeFunc)(void *mem);\n/**\n * xmlMallocFunc:\n * @size:  the size requested in bytes\n *\n * Signature for a malloc() implementation.\n *\n * Returns a pointer to the newly allocated block or NULL in case of error.\n */\ntypedef void *(LIBXML_ATTR_ALLOC_SIZE(1) *xmlMallocFunc)(size_t size);\n\n/**\n * xmlReallocFunc:\n * @mem: an already allocated block of memory\n * @size:  the new size requested in bytes\n *\n * Signature for a realloc() implementation.\n *\n * Returns a pointer to the newly reallocated block or NULL in case of error.\n */\ntypedef void *(*xmlReallocFunc)(void *mem, size_t size);\n\n/**\n * xmlStrdupFunc:\n * @str: a zero terminated string\n *\n * Signature for an strdup() implementation.\n *\n * Returns the copy of the string or NULL in case of error.\n */\ntypedef char *(*xmlStrdupFunc)(const char *str);\n\n/*\n * The 4 interfaces used for all memory handling within libxml.\nLIBXML_DLL_IMPORT xmlFreeFunc xmlFree;\nLIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc;\nLIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic;\nLIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc;\nLIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup;\n */\n\n/*\n * The way to overload the existing functions.\n * The xmlGc function have an extra entry for atomic block\n * allocations useful for garbage collected memory allocators\n */\nXMLPUBFUN int\n\txmlMemSetup\t(xmlFreeFunc freeFunc,\n\t\t\t xmlMallocFunc mallocFunc,\n\t\t\t xmlReallocFunc reallocFunc,\n\t\t\t xmlStrdupFunc strdupFunc);\nXMLPUBFUN int\n\txmlMemGet\t(xmlFreeFunc *freeFunc,\n\t\t\t xmlMallocFunc *mallocFunc,\n\t\t\t xmlReallocFunc *reallocFunc,\n\t\t\t xmlStrdupFunc *strdupFunc);\nXMLPUBFUN int\n\txmlGcMemSetup\t(xmlFreeFunc freeFunc,\n\t\t\t xmlMallocFunc mallocFunc,\n\t\t\t xmlMallocFunc mallocAtomicFunc,\n\t\t\t xmlReallocFunc reallocFunc,\n\t\t\t xmlStrdupFunc strdupFunc);\nXMLPUBFUN int\n\txmlGcMemGet\t(xmlFreeFunc *freeFunc,\n\t\t\t xmlMallocFunc *mallocFunc,\n\t\t\t xmlMallocFunc *mallocAtomicFunc,\n\t\t\t xmlReallocFunc *reallocFunc,\n\t\t\t xmlStrdupFunc *strdupFunc);\n\n/*\n * Initialization of the memory layer.\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlInitMemory\t(void);\n\n/*\n * Cleanup of the memory layer.\n */\nXML_DEPRECATED\nXMLPUBFUN void\n                xmlCleanupMemory        (void);\n/*\n * These are specific to the XML debug memory wrapper.\n */\nXMLPUBFUN size_t\n\txmlMemSize\t(void *ptr);\nXMLPUBFUN int\n\txmlMemUsed\t(void);\nXMLPUBFUN int\n\txmlMemBlocks\t(void);\nXMLPUBFUN void\n\txmlMemDisplay\t(FILE *fp);\nXMLPUBFUN void\n\txmlMemDisplayLast(FILE *fp, long nbBytes);\nXMLPUBFUN void\n\txmlMemShow\t(FILE *fp, int nr);\nXMLPUBFUN void\n\txmlMemoryDump\t(void);\nXMLPUBFUN void *\n\txmlMemMalloc\t(size_t size) LIBXML_ATTR_ALLOC_SIZE(1);\nXMLPUBFUN void *\n\txmlMemRealloc\t(void *ptr,size_t size);\nXMLPUBFUN void\n\txmlMemFree\t(void *ptr);\nXMLPUBFUN char *\n\txmlMemoryStrdup\t(const char *str);\nXMLPUBFUN void *\n\txmlMallocLoc\t(size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);\nXMLPUBFUN void *\n\txmlReallocLoc\t(void *ptr, size_t size, const char *file, int line);\nXMLPUBFUN void *\n\txmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);\nXMLPUBFUN char *\n\txmlMemStrdupLoc\t(const char *str, const char *file, int line);\n\n\n#ifdef DEBUG_MEMORY_LOCATION\n/**\n * xmlMalloc:\n * @size:  number of bytes to allocate\n *\n * Wrapper for the malloc() function used in the XML library.\n *\n * Returns the pointer to the allocated area or NULL in case of error.\n */\n#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__)\n/**\n * xmlMallocAtomic:\n * @size:  number of bytes to allocate\n *\n * Wrapper for the malloc() function used in the XML library for allocation\n * of block not containing pointers to other areas.\n *\n * Returns the pointer to the allocated area or NULL in case of error.\n */\n#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__)\n/**\n * xmlRealloc:\n * @ptr:  pointer to the existing allocated area\n * @size:  number of bytes to allocate\n *\n * Wrapper for the realloc() function used in the XML library.\n *\n * Returns the pointer to the allocated area or NULL in case of error.\n */\n#define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__)\n/**\n * xmlMemStrdup:\n * @str:  pointer to the existing string\n *\n * Wrapper for the strdup() function, xmlStrdup() is usually preferred.\n *\n * Returns the pointer to the allocated area or NULL in case of error.\n */\n#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__)\n\n#endif /* DEBUG_MEMORY_LOCATION */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#ifndef __XML_GLOBALS_H\n#ifndef __XML_THREADS_H__\n#include <libxml/threads.h>\n#include <libxml/globals.h>\n#endif\n#endif\n\n#endif  /* __DEBUG_MEMORY_ALLOC__ */\n\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlmodule.h",
    "content": "/*\n * Summary: dynamic module loading\n * Description: basic API for dynamic module loading, used by\n *              libexslt added in 2.6.17\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Joel W. Reed\n */\n\n#ifndef __XML_MODULE_H__\n#define __XML_MODULE_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_MODULES_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlModulePtr:\n *\n * A handle to a dynamically loaded module\n */\ntypedef struct _xmlModule xmlModule;\ntypedef xmlModule *xmlModulePtr;\n\n/**\n * xmlModuleOption:\n *\n * enumeration of options that can be passed down to xmlModuleOpen()\n */\ntypedef enum {\n    XML_MODULE_LAZY = 1,\t/* lazy binding */\n    XML_MODULE_LOCAL= 2\t\t/* local binding */\n} xmlModuleOption;\n\nXMLPUBFUN xmlModulePtr xmlModuleOpen\t(const char *filename,\n\t\t\t\t\t\t int options);\n\nXMLPUBFUN int xmlModuleSymbol\t\t(xmlModulePtr module,\n\t\t\t\t\t\t const char* name,\n\t\t\t\t\t\t void **result);\n\nXMLPUBFUN int xmlModuleClose\t\t(xmlModulePtr module);\n\nXMLPUBFUN int xmlModuleFree\t\t(xmlModulePtr module);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_MODULES_ENABLED */\n\n#endif /*__XML_MODULE_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlreader.h",
    "content": "/*\n * Summary: the XMLReader implementation\n * Description: API of the XML streaming API based on C# interfaces.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XMLREADER_H__\n#define __XML_XMLREADER_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/xmlIO.h>\n#ifdef LIBXML_SCHEMAS_ENABLED\n#include <libxml/relaxng.h>\n#include <libxml/xmlschemas.h>\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlParserSeverities:\n *\n * How severe an error callback is when the per-reader error callback API\n * is used.\n */\ntypedef enum {\n    XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,\n    XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,\n    XML_PARSER_SEVERITY_WARNING = 3,\n    XML_PARSER_SEVERITY_ERROR = 4\n} xmlParserSeverities;\n\n#ifdef LIBXML_READER_ENABLED\n\n/**\n * xmlTextReaderMode:\n *\n * Internal state values for the reader.\n */\ntypedef enum {\n    XML_TEXTREADER_MODE_INITIAL = 0,\n    XML_TEXTREADER_MODE_INTERACTIVE = 1,\n    XML_TEXTREADER_MODE_ERROR = 2,\n    XML_TEXTREADER_MODE_EOF =3,\n    XML_TEXTREADER_MODE_CLOSED = 4,\n    XML_TEXTREADER_MODE_READING = 5\n} xmlTextReaderMode;\n\n/**\n * xmlParserProperties:\n *\n * Some common options to use with xmlTextReaderSetParserProp, but it\n * is better to use xmlParserOption and the xmlReaderNewxxx and\n * xmlReaderForxxx APIs now.\n */\ntypedef enum {\n    XML_PARSER_LOADDTD = 1,\n    XML_PARSER_DEFAULTATTRS = 2,\n    XML_PARSER_VALIDATE = 3,\n    XML_PARSER_SUBST_ENTITIES = 4\n} xmlParserProperties;\n\n/**\n * xmlReaderTypes:\n *\n * Predefined constants for the different types of nodes.\n */\ntypedef enum {\n    XML_READER_TYPE_NONE = 0,\n    XML_READER_TYPE_ELEMENT = 1,\n    XML_READER_TYPE_ATTRIBUTE = 2,\n    XML_READER_TYPE_TEXT = 3,\n    XML_READER_TYPE_CDATA = 4,\n    XML_READER_TYPE_ENTITY_REFERENCE = 5,\n    XML_READER_TYPE_ENTITY = 6,\n    XML_READER_TYPE_PROCESSING_INSTRUCTION = 7,\n    XML_READER_TYPE_COMMENT = 8,\n    XML_READER_TYPE_DOCUMENT = 9,\n    XML_READER_TYPE_DOCUMENT_TYPE = 10,\n    XML_READER_TYPE_DOCUMENT_FRAGMENT = 11,\n    XML_READER_TYPE_NOTATION = 12,\n    XML_READER_TYPE_WHITESPACE = 13,\n    XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14,\n    XML_READER_TYPE_END_ELEMENT = 15,\n    XML_READER_TYPE_END_ENTITY = 16,\n    XML_READER_TYPE_XML_DECLARATION = 17\n} xmlReaderTypes;\n\n/**\n * xmlTextReader:\n *\n * Structure for an xmlReader context.\n */\ntypedef struct _xmlTextReader xmlTextReader;\n\n/**\n * xmlTextReaderPtr:\n *\n * Pointer to an xmlReader context.\n */\ntypedef xmlTextReader *xmlTextReaderPtr;\n\n/*\n * Constructors & Destructor\n */\nXMLPUBFUN xmlTextReaderPtr\n\t\t\txmlNewTextReader\t(xmlParserInputBufferPtr input,\n\t                                         const char *URI);\nXMLPUBFUN xmlTextReaderPtr\n\t\t\txmlNewTextReaderFilename(const char *URI);\n\nXMLPUBFUN void\n\t\t\txmlFreeTextReader\t(xmlTextReaderPtr reader);\n\nXMLPUBFUN int\n            xmlTextReaderSetup(xmlTextReaderPtr reader,\n                   xmlParserInputBufferPtr input, const char *URL,\n                   const char *encoding, int options);\n\n/*\n * Iterators\n */\nXMLPUBFUN int\n\t\t\txmlTextReaderRead\t(xmlTextReaderPtr reader);\n\n#ifdef LIBXML_WRITER_ENABLED\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderReadInnerXml(xmlTextReaderPtr reader);\n\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderReadOuterXml(xmlTextReaderPtr reader);\n#endif\n\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderReadString\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);\n\n/*\n * Attributes of the node\n */\nXMLPUBFUN int\n\t\t\txmlTextReaderAttributeCount(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderDepth\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderHasAttributes(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderHasValue(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderIsDefault\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderNodeType\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderQuoteChar\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderReadState\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n                        xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);\n\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstBaseUri\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstLocalName\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstName\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstPrefix\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstXmlLang\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstString\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *str);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstValue\t(xmlTextReaderPtr reader);\n\n/*\n * use the Const version of the routine for\n * better performance and simpler code\n */\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderBaseUri\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderLocalName\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderName\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderNamespaceUri(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderPrefix\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderXmlLang\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderValue\t(xmlTextReaderPtr reader);\n\n/*\n * Methods of the XmlTextReader\n */\nXMLPUBFUN int\n\t\t    xmlTextReaderClose\t\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t    xmlTextReaderGetAttributeNo\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t int no);\nXMLPUBFUN xmlChar *\n\t\t    xmlTextReaderGetAttribute\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlChar *\n\t\t    xmlTextReaderGetAttributeNs\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *localName,\n\t\t\t\t\t\t const xmlChar *namespaceURI);\nXMLPUBFUN xmlParserInputBufferPtr\n\t\t    xmlTextReaderGetRemainder\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t    xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,\n\t\t\t\t\t\t int no);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *localName,\n\t\t\t\t\t\t const xmlChar *namespaceURI);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToElement\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderNormalization\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstEncoding  (xmlTextReaderPtr reader);\n\n/*\n * Extensions\n */\nXMLPUBFUN int\n\t\t    xmlTextReaderSetParserProp\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t int prop,\n\t\t\t\t\t\t int value);\nXMLPUBFUN int\n\t\t    xmlTextReaderGetParserProp\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t int prop);\nXMLPUBFUN xmlNodePtr\n\t\t    xmlTextReaderCurrentNode\t(xmlTextReaderPtr reader);\n\nXMLPUBFUN int\n            xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);\n\nXMLPUBFUN int\n            xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);\n\nXMLPUBFUN xmlNodePtr\n\t\t    xmlTextReaderPreserve\t(xmlTextReaderPtr reader);\n#ifdef LIBXML_PATTERN_ENABLED\nXMLPUBFUN int\n\t\t    xmlTextReaderPreservePattern(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *pattern,\n\t\t\t\t\t\t const xmlChar **namespaces);\n#endif /* LIBXML_PATTERN_ENABLED */\nXMLPUBFUN xmlDocPtr\n\t\t    xmlTextReaderCurrentDoc\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlNodePtr\n\t\t    xmlTextReaderExpand\t\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderNext\t\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderNextSibling\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderIsValid\t(xmlTextReaderPtr reader);\n#ifdef LIBXML_SCHEMAS_ENABLED\nXMLPUBFUN int\n\t\t    xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const char *rng);\nXMLPUBFUN int\n\t\t    xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,\n\t\t\t\t\t\t xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t\t int options);\n\nXMLPUBFUN int\n\t\t    xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,\n\t\t\t\t\t\t xmlRelaxNGPtr schema);\nXMLPUBFUN int\n\t\t    xmlTextReaderSchemaValidate\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const char *xsd);\nXMLPUBFUN int\n\t\t    xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,\n\t\t\t\t\t\t xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\t    xmlTextReaderSetSchema\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t xmlSchemaPtr schema);\n#endif\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderStandalone     (xmlTextReaderPtr reader);\n\n\n/*\n * Index lookup\n */\nXMLPUBFUN long\n\t\txmlTextReaderByteConsumed\t(xmlTextReaderPtr reader);\n\n/*\n * New more complete APIs for simpler creation and reuse of readers\n */\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderWalker\t\t(xmlDocPtr doc);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForDoc\t\t(const xmlChar * cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForFile\t(const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForMemory\t(const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForFd\t\t(int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForIO\t\t(xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\nXMLPUBFUN int\n\t\txmlReaderNewWalker\t(xmlTextReaderPtr reader,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlReaderNewDoc\t\t(xmlTextReaderPtr reader,\n\t\t\t\t\t const xmlChar * cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\txmlReaderNewFile\t(xmlTextReaderPtr reader,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\txmlReaderNewMemory\t(xmlTextReaderPtr reader,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\txmlReaderNewFd\t\t(xmlTextReaderPtr reader,\n\t\t\t\t\t int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\txmlReaderNewIO\t\t(xmlTextReaderPtr reader,\n\t\t\t\t\t xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n/*\n * Error handling extensions\n */\ntypedef void *  xmlTextReaderLocatorPtr;\n\n/**\n * xmlTextReaderErrorFunc:\n * @arg: the user argument\n * @msg: the message\n * @severity: the severity of the error\n * @locator: a locator indicating where the error occurred\n *\n * Signature of an error callback from a reader parser\n */\ntypedef void (*xmlTextReaderErrorFunc)(void *arg,\n\t\t\t\t\t       const char *msg,\n\t\t\t\t\t       xmlParserSeverities severity,\n\t\t\t\t\t       xmlTextReaderLocatorPtr locator);\nXMLPUBFUN int\n\t    xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);\nXMLPUBFUN xmlChar *\n\t    xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);\nXMLPUBFUN void\n\t    xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,\n\t\t\t\t\t xmlTextReaderErrorFunc f,\n\t\t\t\t\t void *arg);\nXMLPUBFUN void\n\t    xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,\n\t\t\t\t\t\t   xmlStructuredErrorFunc f,\n\t\t\t\t\t\t   void *arg);\nXMLPUBFUN void\n\t    xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,\n\t\t\t\t\t xmlTextReaderErrorFunc *f,\n\t\t\t\t\t void **arg);\n\n#endif /* LIBXML_READER_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_XMLREADER_H__ */\n\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlregexp.h",
    "content": "/*\n * Summary: regular expressions handling\n * Description: basic API for libxml regular expressions handling used\n *              for XML Schemas and validation.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_REGEXP_H__\n#define __XML_REGEXP_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_REGEXP_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlRegexpPtr:\n *\n * A libxml regular expression, they can actually be far more complex\n * thank the POSIX regex expressions.\n */\ntypedef struct _xmlRegexp xmlRegexp;\ntypedef xmlRegexp *xmlRegexpPtr;\n\n/**\n * xmlRegExecCtxtPtr:\n *\n * A libxml progressive regular expression evaluation context\n */\ntypedef struct _xmlRegExecCtxt xmlRegExecCtxt;\ntypedef xmlRegExecCtxt *xmlRegExecCtxtPtr;\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/tree.h>\n#include <libxml/dict.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The POSIX like API\n */\nXMLPUBFUN xmlRegexpPtr\n\t\t    xmlRegexpCompile\t(const xmlChar *regexp);\nXMLPUBFUN void\t\t\t xmlRegFreeRegexp(xmlRegexpPtr regexp);\nXMLPUBFUN int\n\t\t    xmlRegexpExec\t(xmlRegexpPtr comp,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN void\n\t\t    xmlRegexpPrint\t(FILE *output,\n\t\t\t\t\t xmlRegexpPtr regexp);\nXMLPUBFUN int\n\t\t    xmlRegexpIsDeterminist(xmlRegexpPtr comp);\n\n/**\n * xmlRegExecCallbacks:\n * @exec: the regular expression context\n * @token: the current token string\n * @transdata: transition data\n * @inputdata: input data\n *\n * Callback function when doing a transition in the automata\n */\ntypedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,\n\t                             const xmlChar *token,\n\t\t\t\t     void *transdata,\n\t\t\t\t     void *inputdata);\n\n/*\n * The progressive API\n */\nXMLPUBFUN xmlRegExecCtxtPtr\n\t\t    xmlRegNewExecCtxt\t(xmlRegexpPtr comp,\n\t\t\t\t\t xmlRegExecCallbacks callback,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\t    xmlRegFreeExecCtxt\t(xmlRegExecCtxtPtr exec);\nXMLPUBFUN int\n\t\t    xmlRegExecPushString(xmlRegExecCtxtPtr exec,\n\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\t    xmlRegExecPushString2(xmlRegExecCtxtPtr exec,\n\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t const xmlChar *value2,\n\t\t\t\t\t void *data);\n\nXMLPUBFUN int\n\t\t    xmlRegExecNextValues(xmlRegExecCtxtPtr exec,\n\t\t\t\t\t int *nbval,\n\t\t\t\t\t int *nbneg,\n\t\t\t\t\t xmlChar **values,\n\t\t\t\t\t int *terminal);\nXMLPUBFUN int\n\t\t    xmlRegExecErrInfo\t(xmlRegExecCtxtPtr exec,\n\t\t\t\t\t const xmlChar **string,\n\t\t\t\t\t int *nbval,\n\t\t\t\t\t int *nbneg,\n\t\t\t\t\t xmlChar **values,\n\t\t\t\t\t int *terminal);\n#ifdef LIBXML_EXPR_ENABLED\n/*\n * Formal regular expression handling\n * Its goal is to do some formal work on content models\n */\n\n/* expressions are used within a context */\ntypedef struct _xmlExpCtxt xmlExpCtxt;\ntypedef xmlExpCtxt *xmlExpCtxtPtr;\n\nXMLPUBFUN void\n\t\t\txmlExpFreeCtxt\t(xmlExpCtxtPtr ctxt);\nXMLPUBFUN xmlExpCtxtPtr\n\t\t\txmlExpNewCtxt\t(int maxNodes,\n\t\t\t\t\t xmlDictPtr dict);\n\nXMLPUBFUN int\n\t\t\txmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);\nXMLPUBFUN int\n\t\t\txmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);\n\n/* Expressions are trees but the tree is opaque */\ntypedef struct _xmlExpNode xmlExpNode;\ntypedef xmlExpNode *xmlExpNodePtr;\n\ntypedef enum {\n    XML_EXP_EMPTY = 0,\n    XML_EXP_FORBID = 1,\n    XML_EXP_ATOM = 2,\n    XML_EXP_SEQ = 3,\n    XML_EXP_OR = 4,\n    XML_EXP_COUNT = 5\n} xmlExpNodeType;\n\n/*\n * 2 core expressions shared by all for the empty language set\n * and for the set with just the empty token\n */\nXMLPUBVAR xmlExpNodePtr forbiddenExp;\nXMLPUBVAR xmlExpNodePtr emptyExp;\n\n/*\n * Expressions are reference counted internally\n */\nXMLPUBFUN void\n\t\t\txmlExpFree\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr);\nXMLPUBFUN void\n\t\t\txmlExpRef\t(xmlExpNodePtr expr);\n\n/*\n * constructors can be either manual or from a string\n */\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpParse\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t const char *expr);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpNewAtom\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpNewOr\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr left,\n\t\t\t\t\t xmlExpNodePtr right);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpNewSeq\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr left,\n\t\t\t\t\t xmlExpNodePtr right);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpNewRange\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr subset,\n\t\t\t\t\t int min,\n\t\t\t\t\t int max);\n/*\n * The really interesting APIs\n */\nXMLPUBFUN int\n\t\t\txmlExpIsNillable(xmlExpNodePtr expr);\nXMLPUBFUN int\n\t\t\txmlExpMaxToken\t(xmlExpNodePtr expr);\nXMLPUBFUN int\n\t\t\txmlExpGetLanguage(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t const xmlChar**langList,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\t\txmlExpGetStart\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t const xmlChar**tokList,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpStringDerive(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpExpDerive\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t xmlExpNodePtr sub);\nXMLPUBFUN int\n\t\t\txmlExpSubsume\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t xmlExpNodePtr sub);\nXMLPUBFUN void\n\t\t\txmlExpDump\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlExpNodePtr expr);\n#endif /* LIBXML_EXPR_ENABLED */\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_REGEXP_ENABLED */\n\n#endif /*__XML_REGEXP_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlsave.h",
    "content": "/*\n * Summary: the XML document serializer\n * Description: API to save document or subtree of document\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XMLSAVE_H__\n#define __XML_XMLSAVE_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/encoding.h>\n#include <libxml/xmlIO.h>\n\n#ifdef LIBXML_OUTPUT_ENABLED\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlSaveOption:\n *\n * This is the set of XML save options that can be passed down\n * to the xmlSaveToFd() and similar calls.\n */\ntypedef enum {\n    XML_SAVE_FORMAT     = 1<<0,\t/* format save output */\n    XML_SAVE_NO_DECL    = 1<<1,\t/* drop the xml declaration */\n    XML_SAVE_NO_EMPTY\t= 1<<2, /* no empty tags */\n    XML_SAVE_NO_XHTML\t= 1<<3, /* disable XHTML1 specific rules */\n    XML_SAVE_XHTML\t= 1<<4, /* force XHTML1 specific rules */\n    XML_SAVE_AS_XML     = 1<<5, /* force XML serialization on HTML doc */\n    XML_SAVE_AS_HTML    = 1<<6, /* force HTML serialization on XML doc */\n    XML_SAVE_WSNONSIG   = 1<<7  /* format with non-significant whitespace */\n} xmlSaveOption;\n\n\ntypedef struct _xmlSaveCtxt xmlSaveCtxt;\ntypedef xmlSaveCtxt *xmlSaveCtxtPtr;\n\nXMLPUBFUN xmlSaveCtxtPtr\n\t\txmlSaveToFd\t\t(int fd,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlSaveCtxtPtr\n\t\txmlSaveToFilename\t(const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\nXMLPUBFUN xmlSaveCtxtPtr\n\t\txmlSaveToBuffer\t\t(xmlBufferPtr buffer,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\nXMLPUBFUN xmlSaveCtxtPtr\n\t\txmlSaveToIO\t\t(xmlOutputWriteCallback iowrite,\n\t\t\t\t\t xmlOutputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\nXMLPUBFUN long\n\t\txmlSaveDoc\t\t(xmlSaveCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN long\n\t\txmlSaveTree\t\t(xmlSaveCtxtPtr ctxt,\n\t\t\t\t\t xmlNodePtr node);\n\nXMLPUBFUN int\n\t\txmlSaveFlush\t\t(xmlSaveCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlSaveClose\t\t(xmlSaveCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlSaveSetEscape\t(xmlSaveCtxtPtr ctxt,\n\t\t\t\t\t xmlCharEncodingOutputFunc escape);\nXMLPUBFUN int\n\t\txmlSaveSetAttrEscape\t(xmlSaveCtxtPtr ctxt,\n\t\t\t\t\t xmlCharEncodingOutputFunc escape);\n#ifdef __cplusplus\n}\n#endif\n#endif /* LIBXML_OUTPUT_ENABLED */\n#endif /* __XML_XMLSAVE_H__ */\n\n\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlschemas.h",
    "content": "/*\n * Summary: incomplete XML Schemas structure implementation\n * Description: interface to the XML Schemas handling and schema validity\n *              checking, it is incomplete right now.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SCHEMA_H__\n#define __XML_SCHEMA_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_SCHEMAS_ENABLED\n\n#include <libxml/tree.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * This error codes are obsolete; not used any more.\n */\ntypedef enum {\n    XML_SCHEMAS_ERR_OK\t\t= 0,\n    XML_SCHEMAS_ERR_NOROOT\t= 1,\n    XML_SCHEMAS_ERR_UNDECLAREDELEM,\n    XML_SCHEMAS_ERR_NOTTOPLEVEL,\n    XML_SCHEMAS_ERR_MISSING,\n    XML_SCHEMAS_ERR_WRONGELEM,\n    XML_SCHEMAS_ERR_NOTYPE,\n    XML_SCHEMAS_ERR_NOROLLBACK,\n    XML_SCHEMAS_ERR_ISABSTRACT,\n    XML_SCHEMAS_ERR_NOTEMPTY,\n    XML_SCHEMAS_ERR_ELEMCONT,\n    XML_SCHEMAS_ERR_HAVEDEFAULT,\n    XML_SCHEMAS_ERR_NOTNILLABLE,\n    XML_SCHEMAS_ERR_EXTRACONTENT,\n    XML_SCHEMAS_ERR_INVALIDATTR,\n    XML_SCHEMAS_ERR_INVALIDELEM,\n    XML_SCHEMAS_ERR_NOTDETERMINIST,\n    XML_SCHEMAS_ERR_CONSTRUCT,\n    XML_SCHEMAS_ERR_INTERNAL,\n    XML_SCHEMAS_ERR_NOTSIMPLE,\n    XML_SCHEMAS_ERR_ATTRUNKNOWN,\n    XML_SCHEMAS_ERR_ATTRINVALID,\n    XML_SCHEMAS_ERR_VALUE,\n    XML_SCHEMAS_ERR_FACET,\n    XML_SCHEMAS_ERR_,\n    XML_SCHEMAS_ERR_XXX\n} xmlSchemaValidError;\n\n/*\n* ATTENTION: Change xmlSchemaSetValidOptions's check\n* for invalid values, if adding to the validation\n* options below.\n*/\n/**\n * xmlSchemaValidOption:\n *\n * This is the set of XML Schema validation options.\n */\ntypedef enum {\n    XML_SCHEMA_VAL_VC_I_CREATE\t\t\t= 1<<0\n\t/* Default/fixed: create an attribute node\n\t* or an element's text node on the instance.\n\t*/\n} xmlSchemaValidOption;\n\n/*\n    XML_SCHEMA_VAL_XSI_ASSEMBLE\t\t\t= 1<<1,\n\t* assemble schemata using\n\t* xsi:schemaLocation and\n\t* xsi:noNamespaceSchemaLocation\n*/\n\n/**\n * The schemas related types are kept internal\n */\ntypedef struct _xmlSchema xmlSchema;\ntypedef xmlSchema *xmlSchemaPtr;\n\n/**\n * xmlSchemaValidityErrorFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of an error callback from an XSD validation\n */\ntypedef void (*xmlSchemaValidityErrorFunc)\n                 (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * xmlSchemaValidityWarningFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of a warning callback from an XSD validation\n */\ntypedef void (*xmlSchemaValidityWarningFunc)\n                 (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * A schemas validation context\n */\ntypedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;\ntypedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;\n\ntypedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;\ntypedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;\n\n/**\n * xmlSchemaValidityLocatorFunc:\n * @ctx: user provided context\n * @file: returned file information\n * @line: returned line information\n *\n * A schemas validation locator, a callback called by the validator.\n * This is used when file or node information are not available\n * to find out what file and line number are affected\n *\n * Returns: 0 in case of success and -1 in case of error\n */\n\ntypedef int (*xmlSchemaValidityLocatorFunc) (void *ctx,\n                           const char **file, unsigned long *line);\n\n/*\n * Interfaces for parsing.\n */\nXMLPUBFUN xmlSchemaParserCtxtPtr\n\t    xmlSchemaNewParserCtxt\t(const char *URL);\nXMLPUBFUN xmlSchemaParserCtxtPtr\n\t    xmlSchemaNewMemParserCtxt\t(const char *buffer,\n\t\t\t\t\t int size);\nXMLPUBFUN xmlSchemaParserCtxtPtr\n\t    xmlSchemaNewDocParserCtxt\t(xmlDocPtr doc);\nXMLPUBFUN void\n\t    xmlSchemaFreeParserCtxt\t(xmlSchemaParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t    xmlSchemaSetParserErrors\t(xmlSchemaParserCtxtPtr ctxt,\n\t\t\t\t\t xmlSchemaValidityErrorFunc err,\n\t\t\t\t\t xmlSchemaValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN void\n\t    xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,\n\t\t\t\t\t xmlStructuredErrorFunc serror,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t\txmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,\n\t\t\t\t\txmlSchemaValidityErrorFunc * err,\n\t\t\t\t\txmlSchemaValidityWarningFunc * warn,\n\t\t\t\t\tvoid **ctx);\nXMLPUBFUN int\n\t\txmlSchemaIsValid\t(xmlSchemaValidCtxtPtr ctxt);\n\nXMLPUBFUN xmlSchemaPtr\n\t    xmlSchemaParse\t\t(xmlSchemaParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t    xmlSchemaFree\t\t(xmlSchemaPtr schema);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t    xmlSchemaDump\t\t(FILE *output,\n\t\t\t\t\t xmlSchemaPtr schema);\n#endif /* LIBXML_OUTPUT_ENABLED */\n/*\n * Interfaces for validating\n */\nXMLPUBFUN void\n\t    xmlSchemaSetValidErrors\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSchemaValidityErrorFunc err,\n\t\t\t\t\t xmlSchemaValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN void\n\t    xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlStructuredErrorFunc serror,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t    xmlSchemaGetValidErrors\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSchemaValidityErrorFunc *err,\n\t\t\t\t\t xmlSchemaValidityWarningFunc *warn,\n\t\t\t\t\t void **ctx);\nXMLPUBFUN int\n\t    xmlSchemaSetValidOptions\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t int options);\nXMLPUBFUN void\n            xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,\n\t                                 const char *filename);\nXMLPUBFUN int\n\t    xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);\n\nXMLPUBFUN xmlSchemaValidCtxtPtr\n\t    xmlSchemaNewValidCtxt\t(xmlSchemaPtr schema);\nXMLPUBFUN void\n\t    xmlSchemaFreeValidCtxt\t(xmlSchemaValidCtxtPtr ctxt);\nXMLPUBFUN int\n\t    xmlSchemaValidateDoc\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr instance);\nXMLPUBFUN int\n            xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,\n\t\t\t                 xmlNodePtr elem);\nXMLPUBFUN int\n\t    xmlSchemaValidateStream\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlParserInputBufferPtr input,\n\t\t\t\t\t xmlCharEncoding enc,\n\t\t\t\t\t xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data);\nXMLPUBFUN int\n\t    xmlSchemaValidateFile\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t const char * filename,\n\t\t\t\t\t int options);\n\nXMLPUBFUN xmlParserCtxtPtr\n\t    xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);\n\n/*\n * Interface to insert Schemas SAX validation in a SAX stream\n */\ntypedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;\ntypedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;\n\nXMLPUBFUN xmlSchemaSAXPlugPtr\n            xmlSchemaSAXPlug\t\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSAXHandlerPtr *sax,\n\t\t\t\t\t void **user_data);\nXMLPUBFUN int\n            xmlSchemaSAXUnplug\t\t(xmlSchemaSAXPlugPtr plug);\n\n\nXMLPUBFUN void\n            xmlSchemaValidateSetLocator\t(xmlSchemaValidCtxtPtr vctxt,\n\t\t\t\t\t xmlSchemaValidityLocatorFunc f,\n\t\t\t\t\t void *ctxt);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMAS_ENABLED */\n#endif /* __XML_SCHEMA_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlschemastypes.h",
    "content": "/*\n * Summary: implementation of XML Schema Datatypes\n * Description: module providing the XML Schema Datatypes implementation\n *              both definition and validity checking\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SCHEMA_TYPES_H__\n#define __XML_SCHEMA_TYPES_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_SCHEMAS_ENABLED\n\n#include <libxml/schemasInternals.h>\n#include <libxml/xmlschemas.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef enum {\n    XML_SCHEMA_WHITESPACE_UNKNOWN = 0,\n    XML_SCHEMA_WHITESPACE_PRESERVE = 1,\n    XML_SCHEMA_WHITESPACE_REPLACE = 2,\n    XML_SCHEMA_WHITESPACE_COLLAPSE = 3\n} xmlSchemaWhitespaceValueType;\n\nXMLPUBFUN int\n\t\txmlSchemaInitTypes\t\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlSchemaCleanupTypes\t\t(void);\nXMLPUBFUN xmlSchemaTypePtr\n\t\txmlSchemaGetPredefinedType\t(const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns);\nXMLPUBFUN int\n\t\txmlSchemaValidatePredefinedType\t(xmlSchemaTypePtr type,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr *val);\nXMLPUBFUN int\n\t\txmlSchemaValPredefTypeNode\t(xmlSchemaTypePtr type,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr *val,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN int\n\t\txmlSchemaValidateFacet\t\t(xmlSchemaTypePtr base,\n\t\t\t\t\t\t xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr val);\nXMLPUBFUN int\n\t\txmlSchemaValidateFacetWhtsp\t(xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType fws,\n\t\t\t\t\t\t xmlSchemaValType valType,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr val,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType ws);\nXMLPUBFUN void\n\t\txmlSchemaFreeValue\t\t(xmlSchemaValPtr val);\nXMLPUBFUN xmlSchemaFacetPtr\n\t\txmlSchemaNewFacet\t\t(void);\nXMLPUBFUN int\n\t\txmlSchemaCheckFacet\t\t(xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t xmlSchemaTypePtr typeDecl,\n\t\t\t\t\t\t xmlSchemaParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN void\n\t\txmlSchemaFreeFacet\t\t(xmlSchemaFacetPtr facet);\nXMLPUBFUN int\n\t\txmlSchemaCompareValues\t\t(xmlSchemaValPtr x,\n\t\t\t\t\t\t xmlSchemaValPtr y);\nXMLPUBFUN xmlSchemaTypePtr\n    xmlSchemaGetBuiltInListSimpleTypeItemType\t(xmlSchemaTypePtr type);\nXMLPUBFUN int\n    xmlSchemaValidateListSimpleTypeFacet\t(xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t unsigned long actualLen,\n\t\t\t\t\t\t unsigned long *expectedLen);\nXMLPUBFUN xmlSchemaTypePtr\n\t\txmlSchemaGetBuiltInType\t\t(xmlSchemaValType type);\nXMLPUBFUN int\n\t\txmlSchemaIsBuiltInTypeFacet\t(xmlSchemaTypePtr type,\n\t\t\t\t\t\t int facetType);\nXMLPUBFUN xmlChar *\n\t\txmlSchemaCollapseString\t\t(const xmlChar *value);\nXMLPUBFUN xmlChar *\n\t\txmlSchemaWhiteSpaceReplace\t(const xmlChar *value);\nXMLPUBFUN unsigned long \n\t\txmlSchemaGetFacetValueAsULong\t(xmlSchemaFacetPtr facet);\nXMLPUBFUN int\n\t\txmlSchemaValidateLengthFacet\t(xmlSchemaTypePtr type,\n\t\t\t\t\t\t xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr val,\n\t\t\t\t\t\t unsigned long *length);\nXMLPUBFUN int\n\t\txmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t  xmlSchemaValType valType,\n\t\t\t\t\t\t  const xmlChar *value,\n\t\t\t\t\t\t  xmlSchemaValPtr val,\n\t\t\t\t\t\t  unsigned long *length,\n\t\t\t\t\t\t  xmlSchemaWhitespaceValueType ws);\nXMLPUBFUN int\n\t\txmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr *val,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN int\n\t\txmlSchemaGetCanonValue\t\t(xmlSchemaValPtr val,\n\t\t\t\t\t\t const xmlChar **retValue);\nXMLPUBFUN int\n\t\txmlSchemaGetCanonValueWhtsp\t(xmlSchemaValPtr val,\n\t\t\t\t\t\t const xmlChar **retValue,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType ws);\nXMLPUBFUN int\n\t\txmlSchemaValueAppend\t\t(xmlSchemaValPtr prev,\n\t\t\t\t\t\t xmlSchemaValPtr cur);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaValueGetNext\t\t(xmlSchemaValPtr cur);\nXMLPUBFUN const xmlChar *\n\t\txmlSchemaValueGetAsString\t(xmlSchemaValPtr val);\nXMLPUBFUN int\n\t\txmlSchemaValueGetAsBoolean\t(xmlSchemaValPtr val);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaNewStringValue\t\t(xmlSchemaValType type,\n\t\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaNewNOTATIONValue\t(const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaNewQNameValue\t\t(const xmlChar *namespaceName,\n\t\t\t\t\t\t const xmlChar *localName);\nXMLPUBFUN int\n\t\txmlSchemaCompareValuesWhtsp\t(xmlSchemaValPtr x,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType xws,\n\t\t\t\t\t\t xmlSchemaValPtr y,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType yws);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaCopyValue\t\t(xmlSchemaValPtr val);\nXMLPUBFUN xmlSchemaValType\n\t\txmlSchemaGetValType\t\t(xmlSchemaValPtr val);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMAS_ENABLED */\n#endif /* __XML_SCHEMA_TYPES_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlstring.h",
    "content": "/*\n * Summary: set of routines to process strings\n * Description: type and interfaces needed for the internal string handling\n *              of the library, especially UTF8 processing.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_STRING_H__\n#define __XML_STRING_H__\n\n#include <stdarg.h>\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlChar:\n *\n * This is a basic byte in an UTF-8 encoded string.\n * It's unsigned allowing to pinpoint case where char * are assigned\n * to xmlChar * (possibly making serialization back impossible).\n */\ntypedef unsigned char xmlChar;\n\n/**\n * BAD_CAST:\n *\n * Macro to cast a string to an xmlChar * when one know its safe.\n */\n#define BAD_CAST (xmlChar *)\n\n/*\n * xmlChar handling\n */\nXMLPUBFUN xmlChar *\n                xmlStrdup                (const xmlChar *cur);\nXMLPUBFUN xmlChar *\n                xmlStrndup               (const xmlChar *cur,\n                                         int len);\nXMLPUBFUN xmlChar *\n                xmlCharStrndup           (const char *cur,\n                                         int len);\nXMLPUBFUN xmlChar *\n                xmlCharStrdup            (const char *cur);\nXMLPUBFUN xmlChar *\n                xmlStrsub                (const xmlChar *str,\n                                         int start,\n                                         int len);\nXMLPUBFUN const xmlChar *\n                xmlStrchr                (const xmlChar *str,\n                                         xmlChar val);\nXMLPUBFUN const xmlChar *\n                xmlStrstr                (const xmlChar *str,\n                                         const xmlChar *val);\nXMLPUBFUN const xmlChar *\n                xmlStrcasestr            (const xmlChar *str,\n                                         const xmlChar *val);\nXMLPUBFUN int\n                xmlStrcmp                (const xmlChar *str1,\n                                         const xmlChar *str2);\nXMLPUBFUN int\n                xmlStrncmp               (const xmlChar *str1,\n                                         const xmlChar *str2,\n                                         int len);\nXMLPUBFUN int\n                xmlStrcasecmp            (const xmlChar *str1,\n                                         const xmlChar *str2);\nXMLPUBFUN int\n                xmlStrncasecmp           (const xmlChar *str1,\n                                         const xmlChar *str2,\n                                         int len);\nXMLPUBFUN int\n                xmlStrEqual              (const xmlChar *str1,\n                                         const xmlChar *str2);\nXMLPUBFUN int\n                xmlStrQEqual             (const xmlChar *pref,\n                                         const xmlChar *name,\n                                         const xmlChar *str);\nXMLPUBFUN int\n                xmlStrlen                (const xmlChar *str);\nXMLPUBFUN xmlChar *\n                xmlStrcat                (xmlChar *cur,\n                                         const xmlChar *add);\nXMLPUBFUN xmlChar *\n                xmlStrncat               (xmlChar *cur,\n                                         const xmlChar *add,\n                                         int len);\nXMLPUBFUN xmlChar *\n                xmlStrncatNew            (const xmlChar *str1,\n                                         const xmlChar *str2,\n                                         int len);\nXMLPUBFUN int\n                xmlStrPrintf             (xmlChar *buf,\n                                         int len,\n                                         const char *msg,\n                                         ...) LIBXML_ATTR_FORMAT(3,4);\nXMLPUBFUN int\n                xmlStrVPrintf                (xmlChar *buf,\n                                         int len,\n                                         const char *msg,\n                                         va_list ap) LIBXML_ATTR_FORMAT(3,0);\n\nXMLPUBFUN int\n        xmlGetUTF8Char                   (const unsigned char *utf,\n                                         int *len);\nXMLPUBFUN int\n        xmlCheckUTF8                     (const unsigned char *utf);\nXMLPUBFUN int\n        xmlUTF8Strsize                   (const xmlChar *utf,\n                                         int len);\nXMLPUBFUN xmlChar *\n        xmlUTF8Strndup                   (const xmlChar *utf,\n                                         int len);\nXMLPUBFUN const xmlChar *\n        xmlUTF8Strpos                    (const xmlChar *utf,\n                                         int pos);\nXMLPUBFUN int\n        xmlUTF8Strloc                    (const xmlChar *utf,\n                                         const xmlChar *utfchar);\nXMLPUBFUN xmlChar *\n        xmlUTF8Strsub                    (const xmlChar *utf,\n                                         int start,\n                                         int len);\nXMLPUBFUN int\n        xmlUTF8Strlen                    (const xmlChar *utf);\nXMLPUBFUN int\n        xmlUTF8Size                      (const xmlChar *utf);\nXMLPUBFUN int\n        xmlUTF8Charcmp                   (const xmlChar *utf1,\n                                         const xmlChar *utf2);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_STRING_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlunicode.h",
    "content": "/*\n * Summary: Unicode character APIs\n * Description: API for the Unicode character APIs\n *\n * This file is automatically generated from the\n * UCS description files of the Unicode Character Database\n * http://www.unicode.org/Public/4.0-Update1/UCD-4.0.1.html\n * using the genUnicode.py Python script.\n *\n * Generation date: Mon Mar 27 11:09:52 2006\n * Sources: Blocks-4.0.1.txt UnicodeData-4.0.1.txt\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_UNICODE_H__\n#define __XML_UNICODE_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_UNICODE_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nXMLPUBFUN int xmlUCSIsAegeanNumbers\t(int code);\nXMLPUBFUN int xmlUCSIsAlphabeticPresentationForms\t(int code);\nXMLPUBFUN int xmlUCSIsArabic\t(int code);\nXMLPUBFUN int xmlUCSIsArabicPresentationFormsA\t(int code);\nXMLPUBFUN int xmlUCSIsArabicPresentationFormsB\t(int code);\nXMLPUBFUN int xmlUCSIsArmenian\t(int code);\nXMLPUBFUN int xmlUCSIsArrows\t(int code);\nXMLPUBFUN int xmlUCSIsBasicLatin\t(int code);\nXMLPUBFUN int xmlUCSIsBengali\t(int code);\nXMLPUBFUN int xmlUCSIsBlockElements\t(int code);\nXMLPUBFUN int xmlUCSIsBopomofo\t(int code);\nXMLPUBFUN int xmlUCSIsBopomofoExtended\t(int code);\nXMLPUBFUN int xmlUCSIsBoxDrawing\t(int code);\nXMLPUBFUN int xmlUCSIsBraillePatterns\t(int code);\nXMLPUBFUN int xmlUCSIsBuhid\t(int code);\nXMLPUBFUN int xmlUCSIsByzantineMusicalSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsCJKCompatibility\t(int code);\nXMLPUBFUN int xmlUCSIsCJKCompatibilityForms\t(int code);\nXMLPUBFUN int xmlUCSIsCJKCompatibilityIdeographs\t(int code);\nXMLPUBFUN int xmlUCSIsCJKCompatibilityIdeographsSupplement\t(int code);\nXMLPUBFUN int xmlUCSIsCJKRadicalsSupplement\t(int code);\nXMLPUBFUN int xmlUCSIsCJKSymbolsandPunctuation\t(int code);\nXMLPUBFUN int xmlUCSIsCJKUnifiedIdeographs\t(int code);\nXMLPUBFUN int xmlUCSIsCJKUnifiedIdeographsExtensionA\t(int code);\nXMLPUBFUN int xmlUCSIsCJKUnifiedIdeographsExtensionB\t(int code);\nXMLPUBFUN int xmlUCSIsCherokee\t(int code);\nXMLPUBFUN int xmlUCSIsCombiningDiacriticalMarks\t(int code);\nXMLPUBFUN int xmlUCSIsCombiningDiacriticalMarksforSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsCombiningHalfMarks\t(int code);\nXMLPUBFUN int xmlUCSIsCombiningMarksforSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsControlPictures\t(int code);\nXMLPUBFUN int xmlUCSIsCurrencySymbols\t(int code);\nXMLPUBFUN int xmlUCSIsCypriotSyllabary\t(int code);\nXMLPUBFUN int xmlUCSIsCyrillic\t(int code);\nXMLPUBFUN int xmlUCSIsCyrillicSupplement\t(int code);\nXMLPUBFUN int xmlUCSIsDeseret\t(int code);\nXMLPUBFUN int xmlUCSIsDevanagari\t(int code);\nXMLPUBFUN int xmlUCSIsDingbats\t(int code);\nXMLPUBFUN int xmlUCSIsEnclosedAlphanumerics\t(int code);\nXMLPUBFUN int xmlUCSIsEnclosedCJKLettersandMonths\t(int code);\nXMLPUBFUN int xmlUCSIsEthiopic\t(int code);\nXMLPUBFUN int xmlUCSIsGeneralPunctuation\t(int code);\nXMLPUBFUN int xmlUCSIsGeometricShapes\t(int code);\nXMLPUBFUN int xmlUCSIsGeorgian\t(int code);\nXMLPUBFUN int xmlUCSIsGothic\t(int code);\nXMLPUBFUN int xmlUCSIsGreek\t(int code);\nXMLPUBFUN int xmlUCSIsGreekExtended\t(int code);\nXMLPUBFUN int xmlUCSIsGreekandCoptic\t(int code);\nXMLPUBFUN int xmlUCSIsGujarati\t(int code);\nXMLPUBFUN int xmlUCSIsGurmukhi\t(int code);\nXMLPUBFUN int xmlUCSIsHalfwidthandFullwidthForms\t(int code);\nXMLPUBFUN int xmlUCSIsHangulCompatibilityJamo\t(int code);\nXMLPUBFUN int xmlUCSIsHangulJamo\t(int code);\nXMLPUBFUN int xmlUCSIsHangulSyllables\t(int code);\nXMLPUBFUN int xmlUCSIsHanunoo\t(int code);\nXMLPUBFUN int xmlUCSIsHebrew\t(int code);\nXMLPUBFUN int xmlUCSIsHighPrivateUseSurrogates\t(int code);\nXMLPUBFUN int xmlUCSIsHighSurrogates\t(int code);\nXMLPUBFUN int xmlUCSIsHiragana\t(int code);\nXMLPUBFUN int xmlUCSIsIPAExtensions\t(int code);\nXMLPUBFUN int xmlUCSIsIdeographicDescriptionCharacters\t(int code);\nXMLPUBFUN int xmlUCSIsKanbun\t(int code);\nXMLPUBFUN int xmlUCSIsKangxiRadicals\t(int code);\nXMLPUBFUN int xmlUCSIsKannada\t(int code);\nXMLPUBFUN int xmlUCSIsKatakana\t(int code);\nXMLPUBFUN int xmlUCSIsKatakanaPhoneticExtensions\t(int code);\nXMLPUBFUN int xmlUCSIsKhmer\t(int code);\nXMLPUBFUN int xmlUCSIsKhmerSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsLao\t(int code);\nXMLPUBFUN int xmlUCSIsLatin1Supplement\t(int code);\nXMLPUBFUN int xmlUCSIsLatinExtendedA\t(int code);\nXMLPUBFUN int xmlUCSIsLatinExtendedB\t(int code);\nXMLPUBFUN int xmlUCSIsLatinExtendedAdditional\t(int code);\nXMLPUBFUN int xmlUCSIsLetterlikeSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsLimbu\t(int code);\nXMLPUBFUN int xmlUCSIsLinearBIdeograms\t(int code);\nXMLPUBFUN int xmlUCSIsLinearBSyllabary\t(int code);\nXMLPUBFUN int xmlUCSIsLowSurrogates\t(int code);\nXMLPUBFUN int xmlUCSIsMalayalam\t(int code);\nXMLPUBFUN int xmlUCSIsMathematicalAlphanumericSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsMathematicalOperators\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousMathematicalSymbolsA\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousMathematicalSymbolsB\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousSymbolsandArrows\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousTechnical\t(int code);\nXMLPUBFUN int xmlUCSIsMongolian\t(int code);\nXMLPUBFUN int xmlUCSIsMusicalSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsMyanmar\t(int code);\nXMLPUBFUN int xmlUCSIsNumberForms\t(int code);\nXMLPUBFUN int xmlUCSIsOgham\t(int code);\nXMLPUBFUN int xmlUCSIsOldItalic\t(int code);\nXMLPUBFUN int xmlUCSIsOpticalCharacterRecognition\t(int code);\nXMLPUBFUN int xmlUCSIsOriya\t(int code);\nXMLPUBFUN int xmlUCSIsOsmanya\t(int code);\nXMLPUBFUN int xmlUCSIsPhoneticExtensions\t(int code);\nXMLPUBFUN int xmlUCSIsPrivateUse\t(int code);\nXMLPUBFUN int xmlUCSIsPrivateUseArea\t(int code);\nXMLPUBFUN int xmlUCSIsRunic\t(int code);\nXMLPUBFUN int xmlUCSIsShavian\t(int code);\nXMLPUBFUN int xmlUCSIsSinhala\t(int code);\nXMLPUBFUN int xmlUCSIsSmallFormVariants\t(int code);\nXMLPUBFUN int xmlUCSIsSpacingModifierLetters\t(int code);\nXMLPUBFUN int xmlUCSIsSpecials\t(int code);\nXMLPUBFUN int xmlUCSIsSuperscriptsandSubscripts\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementalArrowsA\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementalArrowsB\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementalMathematicalOperators\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementaryPrivateUseAreaA\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementaryPrivateUseAreaB\t(int code);\nXMLPUBFUN int xmlUCSIsSyriac\t(int code);\nXMLPUBFUN int xmlUCSIsTagalog\t(int code);\nXMLPUBFUN int xmlUCSIsTagbanwa\t(int code);\nXMLPUBFUN int xmlUCSIsTags\t(int code);\nXMLPUBFUN int xmlUCSIsTaiLe\t(int code);\nXMLPUBFUN int xmlUCSIsTaiXuanJingSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsTamil\t(int code);\nXMLPUBFUN int xmlUCSIsTelugu\t(int code);\nXMLPUBFUN int xmlUCSIsThaana\t(int code);\nXMLPUBFUN int xmlUCSIsThai\t(int code);\nXMLPUBFUN int xmlUCSIsTibetan\t(int code);\nXMLPUBFUN int xmlUCSIsUgaritic\t(int code);\nXMLPUBFUN int xmlUCSIsUnifiedCanadianAboriginalSyllabics\t(int code);\nXMLPUBFUN int xmlUCSIsVariationSelectors\t(int code);\nXMLPUBFUN int xmlUCSIsVariationSelectorsSupplement\t(int code);\nXMLPUBFUN int xmlUCSIsYiRadicals\t(int code);\nXMLPUBFUN int xmlUCSIsYiSyllables\t(int code);\nXMLPUBFUN int xmlUCSIsYijingHexagramSymbols\t(int code);\n\nXMLPUBFUN int xmlUCSIsBlock\t(int code, const char *block);\n\nXMLPUBFUN int xmlUCSIsCatC\t(int code);\nXMLPUBFUN int xmlUCSIsCatCc\t(int code);\nXMLPUBFUN int xmlUCSIsCatCf\t(int code);\nXMLPUBFUN int xmlUCSIsCatCo\t(int code);\nXMLPUBFUN int xmlUCSIsCatCs\t(int code);\nXMLPUBFUN int xmlUCSIsCatL\t(int code);\nXMLPUBFUN int xmlUCSIsCatLl\t(int code);\nXMLPUBFUN int xmlUCSIsCatLm\t(int code);\nXMLPUBFUN int xmlUCSIsCatLo\t(int code);\nXMLPUBFUN int xmlUCSIsCatLt\t(int code);\nXMLPUBFUN int xmlUCSIsCatLu\t(int code);\nXMLPUBFUN int xmlUCSIsCatM\t(int code);\nXMLPUBFUN int xmlUCSIsCatMc\t(int code);\nXMLPUBFUN int xmlUCSIsCatMe\t(int code);\nXMLPUBFUN int xmlUCSIsCatMn\t(int code);\nXMLPUBFUN int xmlUCSIsCatN\t(int code);\nXMLPUBFUN int xmlUCSIsCatNd\t(int code);\nXMLPUBFUN int xmlUCSIsCatNl\t(int code);\nXMLPUBFUN int xmlUCSIsCatNo\t(int code);\nXMLPUBFUN int xmlUCSIsCatP\t(int code);\nXMLPUBFUN int xmlUCSIsCatPc\t(int code);\nXMLPUBFUN int xmlUCSIsCatPd\t(int code);\nXMLPUBFUN int xmlUCSIsCatPe\t(int code);\nXMLPUBFUN int xmlUCSIsCatPf\t(int code);\nXMLPUBFUN int xmlUCSIsCatPi\t(int code);\nXMLPUBFUN int xmlUCSIsCatPo\t(int code);\nXMLPUBFUN int xmlUCSIsCatPs\t(int code);\nXMLPUBFUN int xmlUCSIsCatS\t(int code);\nXMLPUBFUN int xmlUCSIsCatSc\t(int code);\nXMLPUBFUN int xmlUCSIsCatSk\t(int code);\nXMLPUBFUN int xmlUCSIsCatSm\t(int code);\nXMLPUBFUN int xmlUCSIsCatSo\t(int code);\nXMLPUBFUN int xmlUCSIsCatZ\t(int code);\nXMLPUBFUN int xmlUCSIsCatZl\t(int code);\nXMLPUBFUN int xmlUCSIsCatZp\t(int code);\nXMLPUBFUN int xmlUCSIsCatZs\t(int code);\n\nXMLPUBFUN int xmlUCSIsCat\t(int code, const char *cat);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_UNICODE_ENABLED */\n\n#endif /* __XML_UNICODE_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlversion.h",
    "content": "/*\n * Summary: compile-time version information\n * Description: compile-time version information for the XML library\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_VERSION_H__\n#define __XML_VERSION_H__\n\n#include <libxml/xmlexports.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * use those to be sure nothing nasty will happen if\n * your library and includes mismatch\n */\n#ifndef LIBXML2_COMPILING_MSCCDEF\nXMLPUBFUN void xmlCheckVersion(int version);\n#endif /* LIBXML2_COMPILING_MSCCDEF */\n\n/**\n * LIBXML_DOTTED_VERSION:\n *\n * the version string like \"1.2.3\"\n */\n#define LIBXML_DOTTED_VERSION \"2.11.5\"\n\n/**\n * LIBXML_VERSION:\n *\n * the version number: 1.2.3 value is 10203\n */\n#define LIBXML_VERSION 21105\n\n/**\n * LIBXML_VERSION_STRING:\n *\n * the version number string, 1.2.3 value is \"10203\"\n */\n#define LIBXML_VERSION_STRING \"21105\"\n\n/**\n * LIBXML_VERSION_EXTRA:\n *\n * extra version information, used to show a git commit description\n */\n#define LIBXML_VERSION_EXTRA \"\"\n\n/**\n * LIBXML_TEST_VERSION:\n *\n * Macro to check that the libxml version in use is compatible with\n * the version the software has been compiled against\n */\n#define LIBXML_TEST_VERSION xmlCheckVersion(21105);\n\n#ifndef VMS\n#if 0\n/**\n * WITH_TRIO:\n *\n * defined if the trio support need to be configured in\n */\n#define WITH_TRIO\n#else\n/**\n * WITHOUT_TRIO:\n *\n * defined if the trio support should not be configured in\n */\n#define WITHOUT_TRIO\n#endif\n#else /* VMS */\n/**\n * WITH_TRIO:\n *\n * defined if the trio support need to be configured in\n */\n#define WITH_TRIO 1\n#endif /* VMS */\n\n/**\n * LIBXML_THREAD_ENABLED:\n *\n * Whether the thread support is configured in\n */\n#if 0\n#define LIBXML_THREAD_ENABLED\n#endif\n\n/**\n * LIBXML_THREAD_ALLOC_ENABLED:\n *\n * Whether the allocation hooks are per-thread\n */\n#if 0\n#define LIBXML_THREAD_ALLOC_ENABLED\n#endif\n\n/**\n * LIBXML_TREE_ENABLED:\n *\n * Whether the DOM like tree manipulation API support is configured in\n */\n#if 1\n#define LIBXML_TREE_ENABLED\n#endif\n\n/**\n * LIBXML_OUTPUT_ENABLED:\n *\n * Whether the serialization/saving support is configured in\n */\n#if 1\n#define LIBXML_OUTPUT_ENABLED\n#endif\n\n/**\n * LIBXML_PUSH_ENABLED:\n *\n * Whether the push parsing interfaces are configured in\n */\n#if 1\n#define LIBXML_PUSH_ENABLED\n#endif\n\n/**\n * LIBXML_READER_ENABLED:\n *\n * Whether the xmlReader parsing interface is configured in\n */\n#if 1\n#define LIBXML_READER_ENABLED\n#endif\n\n/**\n * LIBXML_PATTERN_ENABLED:\n *\n * Whether the xmlPattern node selection interface is configured in\n */\n#if 1\n#define LIBXML_PATTERN_ENABLED\n#endif\n\n/**\n * LIBXML_WRITER_ENABLED:\n *\n * Whether the xmlWriter saving interface is configured in\n */\n#if 1\n#define LIBXML_WRITER_ENABLED\n#endif\n\n/**\n * LIBXML_SAX1_ENABLED:\n *\n * Whether the older SAX1 interface is configured in\n */\n#if 1\n#define LIBXML_SAX1_ENABLED\n#endif\n\n/**\n * LIBXML_FTP_ENABLED:\n *\n * Whether the FTP support is configured in\n */\n#if 0\n#define LIBXML_FTP_ENABLED\n#endif\n\n/**\n * LIBXML_HTTP_ENABLED:\n *\n * Whether the HTTP support is configured in\n */\n#if 0\n#define LIBXML_HTTP_ENABLED\n#endif\n\n/**\n * LIBXML_VALID_ENABLED:\n *\n * Whether the DTD validation support is configured in\n */\n#if 1\n#define LIBXML_VALID_ENABLED\n#endif\n\n/**\n * LIBXML_HTML_ENABLED:\n *\n * Whether the HTML support is configured in\n */\n#if 1\n#define LIBXML_HTML_ENABLED\n#endif\n\n/**\n * LIBXML_LEGACY_ENABLED:\n *\n * Whether the deprecated APIs are compiled in for compatibility\n */\n#if 0\n#define LIBXML_LEGACY_ENABLED\n#endif\n\n/**\n * LIBXML_C14N_ENABLED:\n *\n * Whether the Canonicalization support is configured in\n */\n#if 1\n#define LIBXML_C14N_ENABLED\n#endif\n\n/**\n * LIBXML_CATALOG_ENABLED:\n *\n * Whether the Catalog support is configured in\n */\n#if 1\n#define LIBXML_CATALOG_ENABLED\n#endif\n\n/**\n * LIBXML_XPATH_ENABLED:\n *\n * Whether XPath is configured in\n */\n#if 1\n#define LIBXML_XPATH_ENABLED\n#endif\n\n/**\n * LIBXML_XPTR_ENABLED:\n *\n * Whether XPointer is configured in\n */\n#if 1\n#define LIBXML_XPTR_ENABLED\n#endif\n\n/**\n * LIBXML_XPTR_LOCS_ENABLED:\n *\n * Whether support for XPointer locations is configured in\n */\n#if 0\n#define LIBXML_XPTR_LOCS_ENABLED\n#endif\n\n/**\n * LIBXML_XINCLUDE_ENABLED:\n *\n * Whether XInclude is configured in\n */\n#if 1\n#define LIBXML_XINCLUDE_ENABLED\n#endif\n\n/**\n * LIBXML_ICONV_ENABLED:\n *\n * Whether iconv support is available\n */\n#if 0\n#define LIBXML_ICONV_ENABLED\n#endif\n\n/**\n * LIBXML_ICU_ENABLED:\n *\n * Whether icu support is available\n */\n#if 0\n#define LIBXML_ICU_ENABLED\n#endif\n\n/**\n * LIBXML_ISO8859X_ENABLED:\n *\n * Whether ISO-8859-* support is made available in case iconv is not\n */\n#if 1\n#define LIBXML_ISO8859X_ENABLED\n#endif\n\n/**\n * LIBXML_DEBUG_ENABLED:\n *\n * Whether Debugging module is configured in\n */\n#if 1\n#define LIBXML_DEBUG_ENABLED\n#endif\n\n/**\n * DEBUG_MEMORY_LOCATION:\n *\n * Whether the memory debugging is configured in\n */\n#if 0\n#define DEBUG_MEMORY_LOCATION\n#endif\n\n/**\n * LIBXML_DEBUG_RUNTIME:\n *\n * Removed\n */\n#if 0\n#define LIBXML_DEBUG_RUNTIME\n#endif\n\n/**\n * LIBXML_UNICODE_ENABLED:\n *\n * Whether the Unicode related interfaces are compiled in\n */\n#if 1\n#define LIBXML_UNICODE_ENABLED\n#endif\n\n/**\n * LIBXML_REGEXP_ENABLED:\n *\n * Whether the regular expressions interfaces are compiled in\n */\n#if 1\n#define LIBXML_REGEXP_ENABLED\n#endif\n\n/**\n * LIBXML_AUTOMATA_ENABLED:\n *\n * Whether the automata interfaces are compiled in\n */\n#if 1\n#define LIBXML_AUTOMATA_ENABLED\n#endif\n\n/**\n * LIBXML_EXPR_ENABLED:\n *\n * Whether the formal expressions interfaces are compiled in\n *\n * This code is unused and disabled unconditionally for now.\n */\n#if 0\n#define LIBXML_EXPR_ENABLED\n#endif\n\n/**\n * LIBXML_SCHEMAS_ENABLED:\n *\n * Whether the Schemas validation interfaces are compiled in\n */\n#if 1\n#define LIBXML_SCHEMAS_ENABLED\n#endif\n\n/**\n * LIBXML_SCHEMATRON_ENABLED:\n *\n * Whether the Schematron validation interfaces are compiled in\n */\n#if 1\n#define LIBXML_SCHEMATRON_ENABLED\n#endif\n\n/**\n * LIBXML_MODULES_ENABLED:\n *\n * Whether the module interfaces are compiled in\n */\n#if 1\n#define LIBXML_MODULES_ENABLED\n/**\n * LIBXML_MODULE_EXTENSION:\n *\n * the string suffix used by dynamic modules (usually shared libraries)\n */\n#define LIBXML_MODULE_EXTENSION \".dll\" \n#endif\n\n/**\n * LIBXML_ZLIB_ENABLED:\n *\n * Whether the Zlib support is compiled in\n */\n#if 1\n#define LIBXML_ZLIB_ENABLED\n#endif\n\n/**\n * LIBXML_LZMA_ENABLED:\n *\n * Whether the Lzma support is compiled in\n */\n#if 0\n#define LIBXML_LZMA_ENABLED\n#endif\n\n#ifdef __GNUC__\n/** DOC_DISABLE */\n\n#ifndef ATTRIBUTE_UNUSED\n# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))\n#  define ATTRIBUTE_UNUSED __attribute__((unused))\n# else\n#  define ATTRIBUTE_UNUSED\n# endif\n#endif\n\n#ifndef LIBXML_ATTR_ALLOC_SIZE\n# if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))))\n#  define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))\n# else\n#  define LIBXML_ATTR_ALLOC_SIZE(x)\n# endif\n#else\n# define LIBXML_ATTR_ALLOC_SIZE(x)\n#endif\n\n#ifndef LIBXML_ATTR_FORMAT\n# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))\n#  define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))\n# else\n#  define LIBXML_ATTR_FORMAT(fmt,args)\n# endif\n#else\n# define LIBXML_ATTR_FORMAT(fmt,args)\n#endif\n\n#ifndef XML_DEPRECATED\n#  if defined (IN_LIBXML) || (__GNUC__ * 100 + __GNUC_MINOR__ < 301)\n#    define XML_DEPRECATED\n/* Available since at least GCC 3.1 */\n#  else\n#    define XML_DEPRECATED __attribute__((deprecated))\n#  endif\n#endif\n\n#if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)\n#define XML_IGNORE_FPTR_CAST_WARNINGS \\\n    _Pragma(\"GCC diagnostic push\") \\\n    _Pragma(\"GCC diagnostic ignored \\\"-Wpedantic\\\"\") \\\n    _Pragma(\"GCC diagnostic ignored \\\"-Wcast-function-type\\\"\")\n#define XML_POP_WARNINGS \\\n    _Pragma(\"GCC diagnostic pop\")\n#else\n#define XML_IGNORE_FPTR_CAST_WARNINGS\n#define XML_POP_WARNINGS\n#endif\n\n/** DOC_ENABLE */\n#else /* ! __GNUC__ */\n/**\n * ATTRIBUTE_UNUSED:\n *\n * Macro used to signal to GCC unused function parameters\n */\n#define ATTRIBUTE_UNUSED\n/**\n * LIBXML_ATTR_ALLOC_SIZE:\n *\n * Macro used to indicate to GCC this is an allocator function\n */\n#define LIBXML_ATTR_ALLOC_SIZE(x)\n/**\n * LIBXML_ATTR_FORMAT:\n *\n * Macro used to indicate to GCC the parameter are printf like\n */\n#define LIBXML_ATTR_FORMAT(fmt,args)\n/**\n * XML_DEPRECATED:\n *\n * Macro used to indicate that a function, variable, type or struct member\n * is deprecated.\n */\n#ifndef XML_DEPRECATED\n#  if defined (IN_LIBXML) || !defined (_MSC_VER)\n#    define XML_DEPRECATED\n/* Available since Visual Studio 2005 */\n#  elif defined (_MSC_VER) && (_MSC_VER >= 1400)\n#    define XML_DEPRECATED __declspec(deprecated)\n#  endif\n#endif\n/**\n * LIBXML_IGNORE_FPTR_CAST_WARNINGS:\n *\n * Macro used to ignore pointer cast warnings that can't be worked around.\n */\n#if defined (_MSC_VER) && (_MSC_VER >= 1400)\n#  define XML_IGNORE_FPTR_CAST_WARNINGS __pragma(warning(push))\n#else\n#  define XML_IGNORE_FPTR_CAST_WARNINGS\n#endif\n/**\n * XML_POP_WARNINGS:\n *\n * Macro used to restore warnings state.\n */\n#ifndef XML_POP_WARNINGS\n#  if defined (_MSC_VER) && (_MSC_VER >= 1400)\n#    define XML_POP_WARNINGS __pragma(warning(pop))\n#  else\n#    define XML_POP_WARNINGS\n#  endif\n#endif\n#endif /* __GNUC__ */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n#endif\n\n\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xmlwriter.h",
    "content": "/*\n * Summary: text writing API for XML\n * Description: text writing API for XML\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Alfred Mickautsch <alfred@mickautsch.de>\n */\n\n#ifndef __XML_XMLWRITER_H__\n#define __XML_XMLWRITER_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_WRITER_ENABLED\n\n#include <stdarg.h>\n#include <libxml/xmlIO.h>\n#include <libxml/list.h>\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n    typedef struct _xmlTextWriter xmlTextWriter;\n    typedef xmlTextWriter *xmlTextWriterPtr;\n\n/*\n * Constructors & Destructor\n */\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriter(xmlOutputBufferPtr out);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterFilename(const char *uri, int compression);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterMemory(xmlBufferPtr buf, int compression);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterDoc(xmlDocPtr * doc, int compression);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node,\n                             int compression);\n    XMLPUBFUN void xmlFreeTextWriter(xmlTextWriterPtr writer);\n\n/*\n * Functions\n */\n\n\n/*\n * Document\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDocument(xmlTextWriterPtr writer,\n                                   const char *version,\n                                   const char *encoding,\n                                   const char *standalone);\n    XMLPUBFUN int xmlTextWriterEndDocument(xmlTextWriterPtr\n                                                   writer);\n\n/*\n * Comments\n */\n    XMLPUBFUN int xmlTextWriterStartComment(xmlTextWriterPtr\n                                                    writer);\n    XMLPUBFUN int xmlTextWriterEndComment(xmlTextWriterPtr writer);\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,\n                                        const char *format, ...)\n\t\t\t\t\tLIBXML_ATTR_FORMAT(2,3);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,\n                                         const char *format,\n                                         va_list argptr)\n\t\t\t\t\t LIBXML_ATTR_FORMAT(2,0);\n    XMLPUBFUN int xmlTextWriterWriteComment(xmlTextWriterPtr\n                                                    writer,\n                                                    const xmlChar *\n                                                    content);\n\n/*\n * Elements\n */\n    XMLPUBFUN int\n        xmlTextWriterStartElement(xmlTextWriterPtr writer,\n                                  const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterStartElementNS(xmlTextWriterPtr\n                                                      writer,\n                                                      const xmlChar *\n                                                      prefix,\n                                                      const xmlChar * name,\n                                                      const xmlChar *\n                                                      namespaceURI);\n    XMLPUBFUN int xmlTextWriterEndElement(xmlTextWriterPtr writer);\n    XMLPUBFUN int xmlTextWriterFullEndElement(xmlTextWriterPtr\n                                                      writer);\n\n/*\n * Elements conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,\n                                        const xmlChar * name,\n                                        const char *format, ...)\n\t\t\t\t\tLIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,\n                                         const xmlChar * name,\n                                         const char *format,\n                                         va_list argptr)\n\t\t\t\t\t LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int xmlTextWriterWriteElement(xmlTextWriterPtr\n                                                    writer,\n                                                    const xmlChar * name,\n                                                    const xmlChar *\n                                                    content);\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,\n                                          const xmlChar * prefix,\n                                          const xmlChar * name,\n                                          const xmlChar * namespaceURI,\n                                          const char *format, ...)\n\t\t\t\t\t  LIBXML_ATTR_FORMAT(5,6);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,\n                                           const xmlChar * prefix,\n                                           const xmlChar * name,\n                                           const xmlChar * namespaceURI,\n                                           const char *format,\n                                           va_list argptr)\n\t\t\t\t\t   LIBXML_ATTR_FORMAT(5,0);\n    XMLPUBFUN int xmlTextWriterWriteElementNS(xmlTextWriterPtr\n                                                      writer,\n                                                      const xmlChar *\n                                                      prefix,\n                                                      const xmlChar * name,\n                                                      const xmlChar *\n                                                      namespaceURI,\n                                                      const xmlChar *\n                                                      content);\n\n/*\n * Text\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,\n                                    const char *format, ...)\n\t\t\t\t    LIBXML_ATTR_FORMAT(2,3);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,\n                                     const char *format, va_list argptr)\n\t\t\t\t     LIBXML_ATTR_FORMAT(2,0);\n    XMLPUBFUN int\n        xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,\n                                 const xmlChar * content, int len);\n    XMLPUBFUN int\n        xmlTextWriterWriteRaw(xmlTextWriterPtr writer,\n                              const xmlChar * content);\n    XMLPUBFUN int xmlTextWriterWriteFormatString(xmlTextWriterPtr\n                                                         writer,\n                                                         const char\n                                                         *format, ...)\n\t\t\t\t\t\t\t LIBXML_ATTR_FORMAT(2,3);\n    XMLPUBFUN int xmlTextWriterWriteVFormatString(xmlTextWriterPtr\n                                                          writer,\n                                                          const char\n                                                          *format,\n                                                          va_list argptr)\n\t\t\t\t\t\t\t  LIBXML_ATTR_FORMAT(2,0);\n    XMLPUBFUN int xmlTextWriterWriteString(xmlTextWriterPtr writer,\n                                                   const xmlChar *\n                                                   content);\n    XMLPUBFUN int xmlTextWriterWriteBase64(xmlTextWriterPtr writer,\n                                                   const char *data,\n                                                   int start, int len);\n    XMLPUBFUN int xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,\n                                                   const char *data,\n                                                   int start, int len);\n\n/*\n * Attributes\n */\n    XMLPUBFUN int\n        xmlTextWriterStartAttribute(xmlTextWriterPtr writer,\n                                    const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterStartAttributeNS(xmlTextWriterPtr\n                                                        writer,\n                                                        const xmlChar *\n                                                        prefix,\n                                                        const xmlChar *\n                                                        name,\n                                                        const xmlChar *\n                                                        namespaceURI);\n    XMLPUBFUN int xmlTextWriterEndAttribute(xmlTextWriterPtr\n                                                    writer);\n\n/*\n * Attributes conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,\n                                          const xmlChar * name,\n                                          const char *format, ...)\n\t\t\t\t\t  LIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,\n                                           const xmlChar * name,\n                                           const char *format,\n                                           va_list argptr)\n\t\t\t\t\t   LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int xmlTextWriterWriteAttribute(xmlTextWriterPtr\n                                                      writer,\n                                                      const xmlChar * name,\n                                                      const xmlChar *\n                                                      content);\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,\n                                            const xmlChar * prefix,\n                                            const xmlChar * name,\n                                            const xmlChar * namespaceURI,\n                                            const char *format, ...)\n\t\t\t\t\t    LIBXML_ATTR_FORMAT(5,6);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,\n                                             const xmlChar * prefix,\n                                             const xmlChar * name,\n                                             const xmlChar * namespaceURI,\n                                             const char *format,\n                                             va_list argptr)\n\t\t\t\t\t     LIBXML_ATTR_FORMAT(5,0);\n    XMLPUBFUN int xmlTextWriterWriteAttributeNS(xmlTextWriterPtr\n                                                        writer,\n                                                        const xmlChar *\n                                                        prefix,\n                                                        const xmlChar *\n                                                        name,\n                                                        const xmlChar *\n                                                        namespaceURI,\n                                                        const xmlChar *\n                                                        content);\n\n/*\n * PI's\n */\n    XMLPUBFUN int\n        xmlTextWriterStartPI(xmlTextWriterPtr writer,\n                             const xmlChar * target);\n    XMLPUBFUN int xmlTextWriterEndPI(xmlTextWriterPtr writer);\n\n/*\n * PI conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,\n                                   const xmlChar * target,\n                                   const char *format, ...)\n\t\t\t\t   LIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,\n                                    const xmlChar * target,\n                                    const char *format, va_list argptr)\n\t\t\t\t    LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int\n        xmlTextWriterWritePI(xmlTextWriterPtr writer,\n                             const xmlChar * target,\n                             const xmlChar * content);\n\n/**\n * xmlTextWriterWriteProcessingInstruction:\n *\n * This macro maps to xmlTextWriterWritePI\n */\n#define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI\n\n/*\n * CDATA\n */\n    XMLPUBFUN int xmlTextWriterStartCDATA(xmlTextWriterPtr writer);\n    XMLPUBFUN int xmlTextWriterEndCDATA(xmlTextWriterPtr writer);\n\n/*\n * CDATA conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,\n                                      const char *format, ...)\n\t\t\t\t      LIBXML_ATTR_FORMAT(2,3);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,\n                                       const char *format, va_list argptr)\n\t\t\t\t       LIBXML_ATTR_FORMAT(2,0);\n    XMLPUBFUN int\n        xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,\n                                const xmlChar * content);\n\n/*\n * DTD\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDTD(xmlTextWriterPtr writer,\n                              const xmlChar * name,\n                              const xmlChar * pubid,\n                              const xmlChar * sysid);\n    XMLPUBFUN int xmlTextWriterEndDTD(xmlTextWriterPtr writer);\n\n/*\n * DTD conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,\n                                    const xmlChar * name,\n                                    const xmlChar * pubid,\n                                    const xmlChar * sysid,\n                                    const char *format, ...)\n\t\t\t\t    LIBXML_ATTR_FORMAT(5,6);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,\n                                     const xmlChar * name,\n                                     const xmlChar * pubid,\n                                     const xmlChar * sysid,\n                                     const char *format, va_list argptr)\n\t\t\t\t     LIBXML_ATTR_FORMAT(5,0);\n    XMLPUBFUN int\n        xmlTextWriterWriteDTD(xmlTextWriterPtr writer,\n                              const xmlChar * name,\n                              const xmlChar * pubid,\n                              const xmlChar * sysid,\n                              const xmlChar * subset);\n\n/**\n * xmlTextWriterWriteDocType:\n *\n * this macro maps to xmlTextWriterWriteDTD\n */\n#define xmlTextWriterWriteDocType xmlTextWriterWriteDTD\n\n/*\n * DTD element definition\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDTDElement(xmlTextWriterPtr writer,\n                                     const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterEndDTDElement(xmlTextWriterPtr\n                                                     writer);\n\n/*\n * DTD element definition conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,\n                                           const xmlChar * name,\n                                           const char *format, ...)\n\t\t\t\t\t   LIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,\n                                            const xmlChar * name,\n                                            const char *format,\n                                            va_list argptr)\n\t\t\t\t\t    LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int xmlTextWriterWriteDTDElement(xmlTextWriterPtr\n                                                       writer,\n                                                       const xmlChar *\n                                                       name,\n                                                       const xmlChar *\n                                                       content);\n\n/*\n * DTD attribute list definition\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer,\n                                     const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterEndDTDAttlist(xmlTextWriterPtr\n                                                     writer);\n\n/*\n * DTD attribute list definition conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,\n                                           const xmlChar * name,\n                                           const char *format, ...)\n\t\t\t\t\t   LIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,\n                                            const xmlChar * name,\n                                            const char *format,\n                                            va_list argptr)\n\t\t\t\t\t    LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr\n                                                       writer,\n                                                       const xmlChar *\n                                                       name,\n                                                       const xmlChar *\n                                                       content);\n\n/*\n * DTD entity definition\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,\n                                    int pe, const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterEndDTDEntity(xmlTextWriterPtr\n                                                    writer);\n\n/*\n * DTD entity definition conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,\n                                                  int pe,\n                                                  const xmlChar * name,\n                                                  const char *format, ...)\n\t\t\t\t\t\t  LIBXML_ATTR_FORMAT(4,5);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,\n                                                   int pe,\n                                                   const xmlChar * name,\n                                                   const char *format,\n                                                   va_list argptr)\n\t\t\t\t\t\t   LIBXML_ATTR_FORMAT(4,0);\n    XMLPUBFUN int\n        xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,\n                                            int pe,\n                                            const xmlChar * name,\n                                            const xmlChar * content);\n    XMLPUBFUN int\n        xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,\n                                            int pe,\n                                            const xmlChar * name,\n                                            const xmlChar * pubid,\n                                            const xmlChar * sysid,\n                                            const xmlChar * ndataid);\n    XMLPUBFUN int\n        xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr\n                                                    writer,\n                                                    const xmlChar * pubid,\n                                                    const xmlChar * sysid,\n                                                    const xmlChar *\n                                                    ndataid);\n    XMLPUBFUN int xmlTextWriterWriteDTDEntity(xmlTextWriterPtr\n                                                      writer, int pe,\n                                                      const xmlChar * name,\n                                                      const xmlChar *\n                                                      pubid,\n                                                      const xmlChar *\n                                                      sysid,\n                                                      const xmlChar *\n                                                      ndataid,\n                                                      const xmlChar *\n                                                      content);\n\n/*\n * DTD notation definition\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer,\n                                      const xmlChar * name,\n                                      const xmlChar * pubid,\n                                      const xmlChar * sysid);\n\n/*\n * Indentation\n */\n    XMLPUBFUN int\n        xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);\n    XMLPUBFUN int\n        xmlTextWriterSetIndentString(xmlTextWriterPtr writer,\n                                     const xmlChar * str);\n\n    XMLPUBFUN int\n        xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar);\n\n\n/*\n * misc\n */\n    XMLPUBFUN int xmlTextWriterFlush(xmlTextWriterPtr writer);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_WRITER_ENABLED */\n\n#endif                          /* __XML_XMLWRITER_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xpath.h",
    "content": "/*\n * Summary: XML Path Language implementation\n * Description: API for the XML Path Language implementation\n *\n * XML Path Language implementation\n * XPath is a language for addressing parts of an XML document,\n * designed to be used by both XSLT and XPointer\n *     http://www.w3.org/TR/xpath\n *\n * Implements\n * W3C Recommendation 16 November 1999\n *     http://www.w3.org/TR/1999/REC-xpath-19991116\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XPATH_H__\n#define __XML_XPATH_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_XPATH_ENABLED\n\n#include <libxml/xmlerror.h>\n#include <libxml/tree.h>\n#include <libxml/hash.h>\n#endif /* LIBXML_XPATH_ENABLED */\n\n#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED */\n\n#ifdef LIBXML_XPATH_ENABLED\n\ntypedef struct _xmlXPathContext xmlXPathContext;\ntypedef xmlXPathContext *xmlXPathContextPtr;\ntypedef struct _xmlXPathParserContext xmlXPathParserContext;\ntypedef xmlXPathParserContext *xmlXPathParserContextPtr;\n\n/**\n * The set of XPath error codes.\n */\n\ntypedef enum {\n    XPATH_EXPRESSION_OK = 0,\n    XPATH_NUMBER_ERROR,\n    XPATH_UNFINISHED_LITERAL_ERROR,\n    XPATH_START_LITERAL_ERROR,\n    XPATH_VARIABLE_REF_ERROR,\n    XPATH_UNDEF_VARIABLE_ERROR,\n    XPATH_INVALID_PREDICATE_ERROR,\n    XPATH_EXPR_ERROR,\n    XPATH_UNCLOSED_ERROR,\n    XPATH_UNKNOWN_FUNC_ERROR,\n    XPATH_INVALID_OPERAND,\n    XPATH_INVALID_TYPE,\n    XPATH_INVALID_ARITY,\n    XPATH_INVALID_CTXT_SIZE,\n    XPATH_INVALID_CTXT_POSITION,\n    XPATH_MEMORY_ERROR,\n    XPTR_SYNTAX_ERROR,\n    XPTR_RESOURCE_ERROR,\n    XPTR_SUB_RESOURCE_ERROR,\n    XPATH_UNDEF_PREFIX_ERROR,\n    XPATH_ENCODING_ERROR,\n    XPATH_INVALID_CHAR_ERROR,\n    XPATH_INVALID_CTXT,\n    XPATH_STACK_ERROR,\n    XPATH_FORBID_VARIABLE_ERROR,\n    XPATH_OP_LIMIT_EXCEEDED,\n    XPATH_RECURSION_LIMIT_EXCEEDED\n} xmlXPathError;\n\n/*\n * A node-set (an unordered collection of nodes without duplicates).\n */\ntypedef struct _xmlNodeSet xmlNodeSet;\ntypedef xmlNodeSet *xmlNodeSetPtr;\nstruct _xmlNodeSet {\n    int nodeNr;\t\t\t/* number of nodes in the set */\n    int nodeMax;\t\t/* size of the array as allocated */\n    xmlNodePtr *nodeTab;\t/* array of nodes in no particular order */\n    /* @@ with_ns to check whether namespace nodes should be looked at @@ */\n};\n\n/*\n * An expression is evaluated to yield an object, which\n * has one of the following four basic types:\n *   - node-set\n *   - boolean\n *   - number\n *   - string\n *\n * @@ XPointer will add more types !\n */\n\ntypedef enum {\n    XPATH_UNDEFINED = 0,\n    XPATH_NODESET = 1,\n    XPATH_BOOLEAN = 2,\n    XPATH_NUMBER = 3,\n    XPATH_STRING = 4,\n#ifdef LIBXML_XPTR_LOCS_ENABLED\n    XPATH_POINT = 5,\n    XPATH_RANGE = 6,\n    XPATH_LOCATIONSET = 7,\n#endif\n    XPATH_USERS = 8,\n    XPATH_XSLT_TREE = 9  /* An XSLT value tree, non modifiable */\n} xmlXPathObjectType;\n\n#ifndef LIBXML_XPTR_LOCS_ENABLED\n/** DOC_DISABLE */\n#define XPATH_POINT 5\n#define XPATH_RANGE 6\n#define XPATH_LOCATIONSET 7\n/** DOC_ENABLE */\n#endif\n\ntypedef struct _xmlXPathObject xmlXPathObject;\ntypedef xmlXPathObject *xmlXPathObjectPtr;\nstruct _xmlXPathObject {\n    xmlXPathObjectType type;\n    xmlNodeSetPtr nodesetval;\n    int boolval;\n    double floatval;\n    xmlChar *stringval;\n    void *user;\n    int index;\n    void *user2;\n    int index2;\n};\n\n/**\n * xmlXPathConvertFunc:\n * @obj:  an XPath object\n * @type:  the number of the target type\n *\n * A conversion function is associated to a type and used to cast\n * the new type to primitive values.\n *\n * Returns -1 in case of error, 0 otherwise\n */\ntypedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type);\n\n/*\n * Extra type: a name and a conversion function.\n */\n\ntypedef struct _xmlXPathType xmlXPathType;\ntypedef xmlXPathType *xmlXPathTypePtr;\nstruct _xmlXPathType {\n    const xmlChar         *name;\t\t/* the type name */\n    xmlXPathConvertFunc func;\t\t/* the conversion function */\n};\n\n/*\n * Extra variable: a name and a value.\n */\n\ntypedef struct _xmlXPathVariable xmlXPathVariable;\ntypedef xmlXPathVariable *xmlXPathVariablePtr;\nstruct _xmlXPathVariable {\n    const xmlChar       *name;\t\t/* the variable name */\n    xmlXPathObjectPtr value;\t\t/* the value */\n};\n\n/**\n * xmlXPathEvalFunc:\n * @ctxt: an XPath parser context\n * @nargs: the number of arguments passed to the function\n *\n * An XPath evaluation function, the parameters are on the XPath context stack.\n */\n\ntypedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt,\n\t                         int nargs);\n\n/*\n * Extra function: a name and a evaluation function.\n */\n\ntypedef struct _xmlXPathFunct xmlXPathFunct;\ntypedef xmlXPathFunct *xmlXPathFuncPtr;\nstruct _xmlXPathFunct {\n    const xmlChar      *name;\t\t/* the function name */\n    xmlXPathEvalFunc func;\t\t/* the evaluation function */\n};\n\n/**\n * xmlXPathAxisFunc:\n * @ctxt:  the XPath interpreter context\n * @cur:  the previous node being explored on that axis\n *\n * An axis traversal function. To traverse an axis, the engine calls\n * the first time with cur == NULL and repeat until the function returns\n * NULL indicating the end of the axis traversal.\n *\n * Returns the next node in that axis or NULL if at the end of the axis.\n */\n\ntypedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt,\n\t\t\t\t xmlXPathObjectPtr cur);\n\n/*\n * Extra axis: a name and an axis function.\n */\n\ntypedef struct _xmlXPathAxis xmlXPathAxis;\ntypedef xmlXPathAxis *xmlXPathAxisPtr;\nstruct _xmlXPathAxis {\n    const xmlChar      *name;\t\t/* the axis name */\n    xmlXPathAxisFunc func;\t\t/* the search function */\n};\n\n/**\n * xmlXPathFunction:\n * @ctxt:  the XPath interprestation context\n * @nargs:  the number of arguments\n *\n * An XPath function.\n * The arguments (if any) are popped out from the context stack\n * and the result is pushed on the stack.\n */\n\ntypedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs);\n\n/*\n * Function and Variable Lookup.\n */\n\n/**\n * xmlXPathVariableLookupFunc:\n * @ctxt:  an XPath context\n * @name:  name of the variable\n * @ns_uri:  the namespace name hosting this variable\n *\n * Prototype for callbacks used to plug variable lookup in the XPath\n * engine.\n *\n * Returns the XPath object value or NULL if not found.\n */\ntypedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt,\n                                         const xmlChar *name,\n                                         const xmlChar *ns_uri);\n\n/**\n * xmlXPathFuncLookupFunc:\n * @ctxt:  an XPath context\n * @name:  name of the function\n * @ns_uri:  the namespace name hosting this function\n *\n * Prototype for callbacks used to plug function lookup in the XPath\n * engine.\n *\n * Returns the XPath function or NULL if not found.\n */\ntypedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *ns_uri);\n\n/**\n * xmlXPathFlags:\n * Flags for XPath engine compilation and runtime\n */\n/**\n * XML_XPATH_CHECKNS:\n *\n * check namespaces at compilation\n */\n#define XML_XPATH_CHECKNS (1<<0)\n/**\n * XML_XPATH_NOVAR:\n *\n * forbid variables in expression\n */\n#define XML_XPATH_NOVAR\t  (1<<1)\n\n/**\n * xmlXPathContext:\n *\n * Expression evaluation occurs with respect to a context.\n * he context consists of:\n *    - a node (the context node)\n *    - a node list (the context node list)\n *    - a set of variable bindings\n *    - a function library\n *    - the set of namespace declarations in scope for the expression\n * Following the switch to hash tables, this need to be trimmed up at\n * the next binary incompatible release.\n * The node may be modified when the context is passed to libxml2\n * for an XPath evaluation so you may need to initialize it again\n * before the next call.\n */\n\nstruct _xmlXPathContext {\n    xmlDocPtr doc;\t\t\t/* The current document */\n    xmlNodePtr node;\t\t\t/* The current node */\n\n    int nb_variables_unused;\t\t/* unused (hash table) */\n    int max_variables_unused;\t\t/* unused (hash table) */\n    xmlHashTablePtr varHash;\t\t/* Hash table of defined variables */\n\n    int nb_types;\t\t\t/* number of defined types */\n    int max_types;\t\t\t/* max number of types */\n    xmlXPathTypePtr types;\t\t/* Array of defined types */\n\n    int nb_funcs_unused;\t\t/* unused (hash table) */\n    int max_funcs_unused;\t\t/* unused (hash table) */\n    xmlHashTablePtr funcHash;\t\t/* Hash table of defined funcs */\n\n    int nb_axis;\t\t\t/* number of defined axis */\n    int max_axis;\t\t\t/* max number of axis */\n    xmlXPathAxisPtr axis;\t\t/* Array of defined axis */\n\n    /* the namespace nodes of the context node */\n    xmlNsPtr *namespaces;\t\t/* Array of namespaces */\n    int nsNr;\t\t\t\t/* number of namespace in scope */\n    void *user;\t\t\t\t/* function to free */\n\n    /* extra variables */\n    int contextSize;\t\t\t/* the context size */\n    int proximityPosition;\t\t/* the proximity position */\n\n    /* extra stuff for XPointer */\n    int xptr;\t\t\t\t/* is this an XPointer context? */\n    xmlNodePtr here;\t\t\t/* for here() */\n    xmlNodePtr origin;\t\t\t/* for origin() */\n\n    /* the set of namespace declarations in scope for the expression */\n    xmlHashTablePtr nsHash;\t\t/* The namespaces hash table */\n    xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */\n    void *varLookupData;\t\t/* variable lookup data */\n\n    /* Possibility to link in an extra item */\n    void *extra;                        /* needed for XSLT */\n\n    /* The function name and URI when calling a function */\n    const xmlChar *function;\n    const xmlChar *functionURI;\n\n    /* function lookup function and data */\n    xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */\n    void *funcLookupData;\t\t/* function lookup data */\n\n    /* temporary namespace lists kept for walking the namespace axis */\n    xmlNsPtr *tmpNsList;\t\t/* Array of namespaces */\n    int tmpNsNr;\t\t\t/* number of namespaces in scope */\n\n    /* error reporting mechanism */\n    void *userData;                     /* user specific data block */\n    xmlStructuredErrorFunc error;       /* the callback in case of errors */\n    xmlError lastError;\t\t\t/* the last error */\n    xmlNodePtr debugNode;\t\t/* the source node XSLT */\n\n    /* dictionary */\n    xmlDictPtr dict;\t\t\t/* dictionary if any */\n\n    int flags;\t\t\t\t/* flags to control compilation */\n\n    /* Cache for reusal of XPath objects */\n    void *cache;\n\n    /* Resource limits */\n    unsigned long opLimit;\n    unsigned long opCount;\n    int depth;\n};\n\n/*\n * The structure of a compiled expression form is not public.\n */\n\ntypedef struct _xmlXPathCompExpr xmlXPathCompExpr;\ntypedef xmlXPathCompExpr *xmlXPathCompExprPtr;\n\n/**\n * xmlXPathParserContext:\n *\n * An XPath parser context. It contains pure parsing information,\n * an xmlXPathContext, and the stack of objects.\n */\nstruct _xmlXPathParserContext {\n    const xmlChar *cur;\t\t\t/* the current char being parsed */\n    const xmlChar *base;\t\t\t/* the full expression */\n\n    int error;\t\t\t\t/* error code */\n\n    xmlXPathContextPtr  context;\t/* the evaluation context */\n    xmlXPathObjectPtr     value;\t/* the current value */\n    int                 valueNr;\t/* number of values stacked */\n    int                valueMax;\t/* max number of values stacked */\n    xmlXPathObjectPtr *valueTab;\t/* stack of values */\n\n    xmlXPathCompExprPtr comp;\t\t/* the precompiled expression */\n    int xptr;\t\t\t\t/* it this an XPointer expression */\n    xmlNodePtr         ancestor;\t/* used for walking preceding axis */\n\n    int              valueFrame;        /* unused */\n};\n\n/************************************************************************\n *\t\t\t\t\t\t\t\t\t*\n *\t\t\tPublic API\t\t\t\t\t*\n *\t\t\t\t\t\t\t\t\t*\n ************************************************************************/\n\n/**\n * Objects and Nodesets handling\n */\n\nXMLPUBVAR double xmlXPathNAN;\nXMLPUBVAR double xmlXPathPINF;\nXMLPUBVAR double xmlXPathNINF;\n\n/* These macros may later turn into functions */\n/**\n * xmlXPathNodeSetGetLength:\n * @ns:  a node-set\n *\n * Implement a functionality similar to the DOM NodeList.length.\n *\n * Returns the number of nodes in the node-set.\n */\n#define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0)\n/**\n * xmlXPathNodeSetItem:\n * @ns:  a node-set\n * @index:  index of a node in the set\n *\n * Implements a functionality similar to the DOM NodeList.item().\n *\n * Returns the xmlNodePtr at the given @index in @ns or NULL if\n *         @index is out of range (0 to length-1)\n */\n#define xmlXPathNodeSetItem(ns, index)\t\t\t\t\\\n\t\t((((ns) != NULL) &&\t\t\t\t\\\n\t\t  ((index) >= 0) && ((index) < (ns)->nodeNr)) ?\t\\\n\t\t (ns)->nodeTab[(index)]\t\t\t\t\\\n\t\t : NULL)\n/**\n * xmlXPathNodeSetIsEmpty:\n * @ns: a node-set\n *\n * Checks whether @ns is empty or not.\n *\n * Returns %TRUE if @ns is an empty node-set.\n */\n#define xmlXPathNodeSetIsEmpty(ns)                                      \\\n    (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL))\n\n\nXMLPUBFUN void\n\t\t    xmlXPathFreeObject\t\t(xmlXPathObjectPtr obj);\nXMLPUBFUN xmlNodeSetPtr\n\t\t    xmlXPathNodeSetCreate\t(xmlNodePtr val);\nXMLPUBFUN void\n\t\t    xmlXPathFreeNodeSetList\t(xmlXPathObjectPtr obj);\nXMLPUBFUN void\n\t\t    xmlXPathFreeNodeSet\t\t(xmlNodeSetPtr obj);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathObjectCopy\t\t(xmlXPathObjectPtr val);\nXMLPUBFUN int\n\t\t    xmlXPathCmpNodes\t\t(xmlNodePtr node1,\n\t\t\t\t\t\t xmlNodePtr node2);\n/**\n * Conversion functions to basic types.\n */\nXMLPUBFUN int\n\t\t    xmlXPathCastNumberToBoolean\t(double val);\nXMLPUBFUN int\n\t\t    xmlXPathCastStringToBoolean\t(const xmlChar * val);\nXMLPUBFUN int\n\t\t    xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns);\nXMLPUBFUN int\n\t\t    xmlXPathCastToBoolean\t(xmlXPathObjectPtr val);\n\nXMLPUBFUN double\n\t\t    xmlXPathCastBooleanToNumber\t(int val);\nXMLPUBFUN double\n\t\t    xmlXPathCastStringToNumber\t(const xmlChar * val);\nXMLPUBFUN double\n\t\t    xmlXPathCastNodeToNumber\t(xmlNodePtr node);\nXMLPUBFUN double\n\t\t    xmlXPathCastNodeSetToNumber\t(xmlNodeSetPtr ns);\nXMLPUBFUN double\n\t\t    xmlXPathCastToNumber\t(xmlXPathObjectPtr val);\n\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastBooleanToString\t(int val);\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastNumberToString\t(double val);\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastNodeToString\t(xmlNodePtr node);\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastNodeSetToString\t(xmlNodeSetPtr ns);\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastToString\t(xmlXPathObjectPtr val);\n\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathConvertBoolean\t(xmlXPathObjectPtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathConvertNumber\t(xmlXPathObjectPtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathConvertString\t(xmlXPathObjectPtr val);\n\n/**\n * Context handling.\n */\nXMLPUBFUN xmlXPathContextPtr\n\t\t    xmlXPathNewContext\t\t(xmlDocPtr doc);\nXMLPUBFUN void\n\t\t    xmlXPathFreeContext\t\t(xmlXPathContextPtr ctxt);\nXMLPUBFUN int\n\t\t    xmlXPathContextSetCache(xmlXPathContextPtr ctxt,\n\t\t\t\t            int active,\n\t\t\t\t\t    int value,\n\t\t\t\t\t    int options);\n/**\n * Evaluation functions.\n */\nXMLPUBFUN long\n\t\t    xmlXPathOrderDocElems\t(xmlDocPtr doc);\nXMLPUBFUN int\n\t\t    xmlXPathSetContextNode\t(xmlNodePtr node,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathNodeEval\t\t(xmlNodePtr node,\n\t\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathEval\t\t(const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathEvalExpression\t(const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctxt);\nXMLPUBFUN int\n\t\t    xmlXPathEvalPredicate\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t xmlXPathObjectPtr res);\n/**\n * Separate compilation/evaluation entry points.\n */\nXMLPUBFUN xmlXPathCompExprPtr\n\t\t    xmlXPathCompile\t\t(const xmlChar *str);\nXMLPUBFUN xmlXPathCompExprPtr\n\t\t    xmlXPathCtxtCompile\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *str);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathCompiledEval\t(xmlXPathCompExprPtr comp,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\nXMLPUBFUN int\n\t\t    xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp,\n\t\t\t\t\t\t xmlXPathContextPtr ctxt);\nXMLPUBFUN void\n\t\t    xmlXPathFreeCompExpr\t(xmlXPathCompExprPtr comp);\n#endif /* LIBXML_XPATH_ENABLED */\n#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPathInit\t\t(void);\nXMLPUBFUN int\n\t\txmlXPathIsNaN\t(double val);\nXMLPUBFUN int\n\t\txmlXPathIsInf\t(double val);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED*/\n#endif /* ! __XML_XPATH_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xpathInternals.h",
    "content": "/*\n * Summary: internal interfaces for XML Path Language implementation\n * Description: internal interfaces for XML Path Language implementation\n *              used to build new modules on top of XPath like XPointer and\n *              XSLT\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XPATH_INTERNALS_H__\n#define __XML_XPATH_INTERNALS_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/xpath.h>\n\n#ifdef LIBXML_XPATH_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/************************************************************************\n *\t\t\t\t\t\t\t\t\t*\n *\t\t\tHelpers\t\t\t\t\t\t*\n *\t\t\t\t\t\t\t\t\t*\n ************************************************************************/\n\n/*\n * Many of these macros may later turn into functions. They\n * shouldn't be used in #ifdef's preprocessor instructions.\n */\n/**\n * xmlXPathSetError:\n * @ctxt:  an XPath parser context\n * @err:  an xmlXPathError code\n *\n * Raises an error.\n */\n#define xmlXPathSetError(ctxt, err)\t\t\t\t\t\\\n    { xmlXPatherror((ctxt), __FILE__, __LINE__, (err));\t\t\t\\\n      if ((ctxt) != NULL) (ctxt)->error = (err); }\n\n/**\n * xmlXPathSetArityError:\n * @ctxt:  an XPath parser context\n *\n * Raises an XPATH_INVALID_ARITY error.\n */\n#define xmlXPathSetArityError(ctxt)\t\t\t\t\t\\\n    xmlXPathSetError((ctxt), XPATH_INVALID_ARITY)\n\n/**\n * xmlXPathSetTypeError:\n * @ctxt:  an XPath parser context\n *\n * Raises an XPATH_INVALID_TYPE error.\n */\n#define xmlXPathSetTypeError(ctxt)\t\t\t\t\t\\\n    xmlXPathSetError((ctxt), XPATH_INVALID_TYPE)\n\n/**\n * xmlXPathGetError:\n * @ctxt:  an XPath parser context\n *\n * Get the error code of an XPath context.\n *\n * Returns the context error.\n */\n#define xmlXPathGetError(ctxt)\t  ((ctxt)->error)\n\n/**\n * xmlXPathCheckError:\n * @ctxt:  an XPath parser context\n *\n * Check if an XPath error was raised.\n *\n * Returns true if an error has been raised, false otherwise.\n */\n#define xmlXPathCheckError(ctxt)  ((ctxt)->error != XPATH_EXPRESSION_OK)\n\n/**\n * xmlXPathGetDocument:\n * @ctxt:  an XPath parser context\n *\n * Get the document of an XPath context.\n *\n * Returns the context document.\n */\n#define xmlXPathGetDocument(ctxt)\t((ctxt)->context->doc)\n\n/**\n * xmlXPathGetContextNode:\n * @ctxt: an XPath parser context\n *\n * Get the context node of an XPath context.\n *\n * Returns the context node.\n */\n#define xmlXPathGetContextNode(ctxt)\t((ctxt)->context->node)\n\nXMLPUBFUN int\n\t\txmlXPathPopBoolean\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN double\n\t\txmlXPathPopNumber\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN xmlChar *\n\t\txmlXPathPopString\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathPopNodeSet\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void *\n\t\txmlXPathPopExternal\t(xmlXPathParserContextPtr ctxt);\n\n/**\n * xmlXPathReturnBoolean:\n * @ctxt:  an XPath parser context\n * @val:  a boolean\n *\n * Pushes the boolean @val on the context stack.\n */\n#define xmlXPathReturnBoolean(ctxt, val)\t\t\t\t\\\n    valuePush((ctxt), xmlXPathNewBoolean(val))\n\n/**\n * xmlXPathReturnTrue:\n * @ctxt:  an XPath parser context\n *\n * Pushes true on the context stack.\n */\n#define xmlXPathReturnTrue(ctxt)   xmlXPathReturnBoolean((ctxt), 1)\n\n/**\n * xmlXPathReturnFalse:\n * @ctxt:  an XPath parser context\n *\n * Pushes false on the context stack.\n */\n#define xmlXPathReturnFalse(ctxt)  xmlXPathReturnBoolean((ctxt), 0)\n\n/**\n * xmlXPathReturnNumber:\n * @ctxt:  an XPath parser context\n * @val:  a double\n *\n * Pushes the double @val on the context stack.\n */\n#define xmlXPathReturnNumber(ctxt, val)\t\t\t\t\t\\\n    valuePush((ctxt), xmlXPathNewFloat(val))\n\n/**\n * xmlXPathReturnString:\n * @ctxt:  an XPath parser context\n * @str:  a string\n *\n * Pushes the string @str on the context stack.\n */\n#define xmlXPathReturnString(ctxt, str)\t\t\t\t\t\\\n    valuePush((ctxt), xmlXPathWrapString(str))\n\n/**\n * xmlXPathReturnEmptyString:\n * @ctxt:  an XPath parser context\n *\n * Pushes an empty string on the stack.\n */\n#define xmlXPathReturnEmptyString(ctxt)\t\t\t\t\t\\\n    valuePush((ctxt), xmlXPathNewCString(\"\"))\n\n/**\n * xmlXPathReturnNodeSet:\n * @ctxt:  an XPath parser context\n * @ns:  a node-set\n *\n * Pushes the node-set @ns on the context stack.\n */\n#define xmlXPathReturnNodeSet(ctxt, ns)\t\t\t\t\t\\\n    valuePush((ctxt), xmlXPathWrapNodeSet(ns))\n\n/**\n * xmlXPathReturnEmptyNodeSet:\n * @ctxt:  an XPath parser context\n *\n * Pushes an empty node-set on the context stack.\n */\n#define xmlXPathReturnEmptyNodeSet(ctxt)\t\t\t\t\\\n    valuePush((ctxt), xmlXPathNewNodeSet(NULL))\n\n/**\n * xmlXPathReturnExternal:\n * @ctxt:  an XPath parser context\n * @val:  user data\n *\n * Pushes user data on the context stack.\n */\n#define xmlXPathReturnExternal(ctxt, val)\t\t\t\t\\\n    valuePush((ctxt), xmlXPathWrapExternal(val))\n\n/**\n * xmlXPathStackIsNodeSet:\n * @ctxt: an XPath parser context\n *\n * Check if the current value on the XPath stack is a node set or\n * an XSLT value tree.\n *\n * Returns true if the current object on the stack is a node-set.\n */\n#define xmlXPathStackIsNodeSet(ctxt)\t\t\t\t\t\\\n    (((ctxt)->value != NULL)\t\t\t\t\t\t\\\n     && (((ctxt)->value->type == XPATH_NODESET)\t\t\t\t\\\n         || ((ctxt)->value->type == XPATH_XSLT_TREE)))\n\n/**\n * xmlXPathStackIsExternal:\n * @ctxt: an XPath parser context\n *\n * Checks if the current value on the XPath stack is an external\n * object.\n *\n * Returns true if the current object on the stack is an external\n * object.\n */\n#define xmlXPathStackIsExternal(ctxt)\t\t\t\t\t\\\n\t((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS))\n\n/**\n * xmlXPathEmptyNodeSet:\n * @ns:  a node-set\n *\n * Empties a node-set.\n */\n#define xmlXPathEmptyNodeSet(ns)\t\t\t\t\t\\\n    { while ((ns)->nodeNr > 0) (ns)->nodeTab[--(ns)->nodeNr] = NULL; }\n\n/**\n * CHECK_ERROR:\n *\n * Macro to return from the function if an XPath error was detected.\n */\n#define CHECK_ERROR\t\t\t\t\t\t\t\\\n    if (ctxt->error != XPATH_EXPRESSION_OK) return\n\n/**\n * CHECK_ERROR0:\n *\n * Macro to return 0 from the function if an XPath error was detected.\n */\n#define CHECK_ERROR0\t\t\t\t\t\t\t\\\n    if (ctxt->error != XPATH_EXPRESSION_OK) return(0)\n\n/**\n * XP_ERROR:\n * @X:  the error code\n *\n * Macro to raise an XPath error and return.\n */\n#define XP_ERROR(X)\t\t\t\t\t\t\t\\\n    { xmlXPathErr(ctxt, X); return; }\n\n/**\n * XP_ERROR0:\n * @X:  the error code\n *\n * Macro to raise an XPath error and return 0.\n */\n#define XP_ERROR0(X)\t\t\t\t\t\t\t\\\n    { xmlXPathErr(ctxt, X); return(0); }\n\n/**\n * CHECK_TYPE:\n * @typeval:  the XPath type\n *\n * Macro to check that the value on top of the XPath stack is of a given\n * type.\n */\n#define CHECK_TYPE(typeval)\t\t\t\t\t\t\\\n    if ((ctxt->value == NULL) || (ctxt->value->type != typeval))\t\\\n        XP_ERROR(XPATH_INVALID_TYPE)\n\n/**\n * CHECK_TYPE0:\n * @typeval:  the XPath type\n *\n * Macro to check that the value on top of the XPath stack is of a given\n * type. Return(0) in case of failure\n */\n#define CHECK_TYPE0(typeval)\t\t\t\t\t\t\\\n    if ((ctxt->value == NULL) || (ctxt->value->type != typeval))\t\\\n        XP_ERROR0(XPATH_INVALID_TYPE)\n\n/**\n * CHECK_ARITY:\n * @x:  the number of expected args\n *\n * Macro to check that the number of args passed to an XPath function matches.\n */\n#define CHECK_ARITY(x)\t\t\t\t\t\t\t\\\n    if (ctxt == NULL) return;\t\t\t\t\t\t\\\n    if (nargs != (x))\t\t\t\t\t\t\t\\\n        XP_ERROR(XPATH_INVALID_ARITY);\t\t\t\t\t\\\n    if (ctxt->valueNr < ctxt->valueFrame + (x))\t\t\t\t\\\n        XP_ERROR(XPATH_STACK_ERROR);\n\n/**\n * CAST_TO_STRING:\n *\n * Macro to try to cast the value on the top of the XPath stack to a string.\n */\n#define CAST_TO_STRING\t\t\t\t\t\t\t\\\n    if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING))\t\\\n        xmlXPathStringFunction(ctxt, 1);\n\n/**\n * CAST_TO_NUMBER:\n *\n * Macro to try to cast the value on the top of the XPath stack to a number.\n */\n#define CAST_TO_NUMBER\t\t\t\t\t\t\t\\\n    if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER))\t\\\n        xmlXPathNumberFunction(ctxt, 1);\n\n/**\n * CAST_TO_BOOLEAN:\n *\n * Macro to try to cast the value on the top of the XPath stack to a boolean.\n */\n#define CAST_TO_BOOLEAN\t\t\t\t\t\t\t\\\n    if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN))\t\\\n        xmlXPathBooleanFunction(ctxt, 1);\n\n/*\n * Variable Lookup forwarding.\n */\n\nXMLPUBFUN void\n\txmlXPathRegisterVariableLookup\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t xmlXPathVariableLookupFunc f,\n\t\t\t\t\t void *data);\n\n/*\n * Function Lookup forwarding.\n */\n\nXMLPUBFUN void\n\t    xmlXPathRegisterFuncLookup\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t xmlXPathFuncLookupFunc f,\n\t\t\t\t\t void *funcCtxt);\n\n/*\n * Error reporting.\n */\nXMLPUBFUN void\n\t\txmlXPatherror\t(xmlXPathParserContextPtr ctxt,\n\t\t\t\t const char *file,\n\t\t\t\t int line,\n\t\t\t\t int no);\n\nXMLPUBFUN void\n\t\txmlXPathErr\t(xmlXPathParserContextPtr ctxt,\n\t\t\t\t int error);\n\n#ifdef LIBXML_DEBUG_ENABLED\nXMLPUBFUN void\n\t\txmlXPathDebugDumpObject\t(FILE *output,\n\t\t\t\t\t xmlXPathObjectPtr cur,\n\t\t\t\t\t int depth);\nXMLPUBFUN void\n\t    xmlXPathDebugDumpCompExpr(FILE *output,\n\t\t\t\t\t xmlXPathCompExprPtr comp,\n\t\t\t\t\t int depth);\n#endif\n/**\n * NodeSet handling.\n */\nXMLPUBFUN int\n\t\txmlXPathNodeSetContains\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr val);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathDifference\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathIntersection\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\n\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathDistinctSorted\t\t(xmlNodeSetPtr nodes);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathDistinct\t\t(xmlNodeSetPtr nodes);\n\nXMLPUBFUN int\n\t\txmlXPathHasSameNodes\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\n\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeLeadingSorted\t(xmlNodeSetPtr nodes,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathLeadingSorted\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeLeading\t\t(xmlNodeSetPtr nodes,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathLeading\t\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\n\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeTrailingSorted\t(xmlNodeSetPtr nodes,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathTrailingSorted\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeTrailing\t\t(xmlNodeSetPtr nodes,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathTrailing\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\n\n\n/**\n * Extending a context.\n */\n\nXMLPUBFUN int\n\t\txmlXPathRegisterNs\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t\t const xmlChar *ns_uri);\nXMLPUBFUN const xmlChar *\n\t\txmlXPathNsLookup\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN void\n\t\txmlXPathRegisteredNsCleanup\t(xmlXPathContextPtr ctxt);\n\nXMLPUBFUN int\n\t\txmlXPathRegisterFunc\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t xmlXPathFunction f);\nXMLPUBFUN int\n\t\txmlXPathRegisterFuncNS\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns_uri,\n\t\t\t\t\t\t xmlXPathFunction f);\nXMLPUBFUN int\n\t\txmlXPathRegisterVariable\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t xmlXPathObjectPtr value);\nXMLPUBFUN int\n\t\txmlXPathRegisterVariableNS\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns_uri,\n\t\t\t\t\t\t xmlXPathObjectPtr value);\nXMLPUBFUN xmlXPathFunction\n\t\txmlXPathFunctionLookup\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlXPathFunction\n\t\txmlXPathFunctionLookupNS\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns_uri);\nXMLPUBFUN void\n\t\txmlXPathRegisteredFuncsCleanup\t(xmlXPathContextPtr ctxt);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathVariableLookup\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathVariableLookupNS\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns_uri);\nXMLPUBFUN void\n\t\txmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);\n\n/**\n * Utilities to extend XPath.\n */\nXMLPUBFUN xmlXPathParserContextPtr\n\t\t  xmlXPathNewParserContext\t(const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctxt);\nXMLPUBFUN void\n\t\txmlXPathFreeParserContext\t(xmlXPathParserContextPtr ctxt);\n\n/* TODO: remap to xmlXPathValuePop and Push. */\nXMLPUBFUN xmlXPathObjectPtr\n\t\tvaluePop\t\t\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN int\n\t\tvaluePush\t\t\t(xmlXPathParserContextPtr ctxt,\n\t\t\t\t\t\t xmlXPathObjectPtr value);\n\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewString\t\t(const xmlChar *val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewCString\t\t(const char *val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathWrapString\t\t(xmlChar *val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathWrapCString\t\t(char * val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewFloat\t\t(double val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewBoolean\t\t(int val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewNodeSet\t\t(xmlNodePtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewValueTree\t\t(xmlNodePtr val);\nXMLPUBFUN int\n\t\txmlXPathNodeSetAdd\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr val);\nXMLPUBFUN int\n\t\txmlXPathNodeSetAddUnique\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr val);\nXMLPUBFUN int\n\t\txmlXPathNodeSetAddNs\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t\t xmlNsPtr ns);\nXMLPUBFUN void\n\t\txmlXPathNodeSetSort\t\t(xmlNodeSetPtr set);\n\nXMLPUBFUN void\n\t\txmlXPathRoot\t\t\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void\n\t\txmlXPathEvalExpr\t\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN xmlChar *\n\t\txmlXPathParseName\t\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN xmlChar *\n\t\txmlXPathParseNCName\t\t(xmlXPathParserContextPtr ctxt);\n\n/*\n * Existing functions.\n */\nXMLPUBFUN double\n\t\txmlXPathStringEvalNumber\t(const xmlChar *str);\nXMLPUBFUN int\n\t\txmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,\n\t\t\t\t\t\t xmlXPathObjectPtr res);\nXMLPUBFUN void\n\t\txmlXPathRegisterAllFunctions\t(xmlXPathContextPtr ctxt);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeSetMerge\t\t(xmlNodeSetPtr val1,\n\t\t\t\t\t\t xmlNodeSetPtr val2);\nXMLPUBFUN void\n\t\txmlXPathNodeSetDel\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr val);\nXMLPUBFUN void\n\t\txmlXPathNodeSetRemove\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t int val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewNodeSetList\t\t(xmlNodeSetPtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathWrapNodeSet\t\t(xmlNodeSetPtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathWrapExternal\t\t(void *val);\n\nXMLPUBFUN int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN int xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);\nXMLPUBFUN void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathAddValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathSubValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathModValues(xmlXPathParserContextPtr ctxt);\n\nXMLPUBFUN int xmlXPathIsNodeType(const xmlChar *name);\n\n/*\n * Some of the axis navigation routines.\n */\nXMLPUBFUN xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\n/*\n * The official core of XPath functions.\n */\nXMLPUBFUN void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);\n\n/**\n * Really internal functions\n */\nXMLPUBFUN void xmlXPathNodeSetFreeNs(xmlNsPtr ns);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XPATH_ENABLED */\n#endif /* ! __XML_XPATH_INTERNALS_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/libxml2/libxml/xpointer.h",
    "content": "/*\n * Summary: API to handle XML Pointers\n * Description: API to handle XML Pointers\n * Base implementation was made accordingly to\n * W3C Candidate Recommendation 7 June 2000\n * http://www.w3.org/TR/2000/CR-xptr-20000607\n *\n * Added support for the element() scheme described in:\n * W3C Proposed Recommendation 13 November 2002\n * http://www.w3.org/TR/2002/PR-xptr-element-20021113/\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XPTR_H__\n#define __XML_XPTR_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_XPTR_ENABLED\n\n#include <libxml/tree.h>\n#include <libxml/xpath.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef LIBXML_XPTR_LOCS_ENABLED\n/*\n * A Location Set\n */\ntypedef struct _xmlLocationSet xmlLocationSet;\ntypedef xmlLocationSet *xmlLocationSetPtr;\nstruct _xmlLocationSet {\n    int locNr;\t\t      /* number of locations in the set */\n    int locMax;\t\t      /* size of the array as allocated */\n    xmlXPathObjectPtr *locTab;/* array of locations */\n};\n\n/*\n * Handling of location sets.\n */\n\nXML_DEPRECATED\nXMLPUBFUN xmlLocationSetPtr\n\t\t    xmlXPtrLocationSetCreate\t(xmlXPathObjectPtr val);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrFreeLocationSet\t(xmlLocationSetPtr obj);\nXML_DEPRECATED\nXMLPUBFUN xmlLocationSetPtr\n\t\t    xmlXPtrLocationSetMerge\t(xmlLocationSetPtr val1,\n\t\t\t\t\t\t xmlLocationSetPtr val2);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRange\t\t(xmlNodePtr start,\n\t\t\t\t\t\t int startindex,\n\t\t\t\t\t\t xmlNodePtr end,\n\t\t\t\t\t\t int endindex);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangePoints\t(xmlXPathObjectPtr start,\n\t\t\t\t\t\t xmlXPathObjectPtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangeNodePoint\t(xmlNodePtr start,\n\t\t\t\t\t\t xmlXPathObjectPtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangePointNode\t(xmlXPathObjectPtr start,\n\t\t\t\t\t\t xmlNodePtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangeNodes\t(xmlNodePtr start,\n\t\t\t\t\t\t xmlNodePtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewLocationSetNodes\t(xmlNodePtr start,\n\t\t\t\t\t\t xmlNodePtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangeNodeObject\t(xmlNodePtr start,\n\t\t\t\t\t\t xmlXPathObjectPtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewCollapsedRange\t(xmlNodePtr start);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrLocationSetAdd\t(xmlLocationSetPtr cur,\n\t\t\t\t\t\t xmlXPathObjectPtr val);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrWrapLocationSet\t(xmlLocationSetPtr val);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrLocationSetDel\t(xmlLocationSetPtr cur,\n\t\t\t\t\t\t xmlXPathObjectPtr val);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrLocationSetRemove\t(xmlLocationSetPtr cur,\n\t\t\t\t\t\t int val);\n#endif /* LIBXML_XPTR_LOCS_ENABLED */\n\n/*\n * Functions.\n */\nXMLPUBFUN xmlXPathContextPtr\n\t\t    xmlXPtrNewContext\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t xmlNodePtr here,\n\t\t\t\t\t\t xmlNodePtr origin);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrEval\t\t\t(const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\n#ifdef LIBXML_XPTR_LOCS_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrRangeToFunction\t(xmlXPathParserContextPtr ctxt,\n\t\t\t\t\t\t int nargs);\nXML_DEPRECATED\nXMLPUBFUN xmlNodePtr\n\t\t    xmlXPtrBuildNodeList\t(xmlXPathObjectPtr obj);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrEvalRangePredicate\t(xmlXPathParserContextPtr ctxt);\n#endif /* LIBXML_XPTR_LOCS_ENABLED */\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XPTR_ENABLED */\n#endif /* __XML_XPTR_H__ */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/aes.h",
    "content": "/* aes.h\n\n   The aes/rijndael block cipher.\n\n   Copyright (C) 2001, 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_AES_H_INCLUDED\n#define NETTLE_AES_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define aes_set_encrypt_key nettle_aes_set_encrypt_key\n#define aes_set_decrypt_key nettle_aes_set_decrypt_key\n#define aes_invert_key nettle_aes_invert_key\n#define aes_encrypt nettle_aes_encrypt\n#define aes_decrypt nettle_aes_decrypt\n#define aes128_set_encrypt_key nettle_aes128_set_encrypt_key\n#define aes128_set_decrypt_key nettle_aes128_set_decrypt_key\n#define aes128_invert_key nettle_aes128_invert_key\n#define aes128_encrypt nettle_aes128_encrypt\n#define aes128_decrypt nettle_aes128_decrypt\n#define aes192_set_encrypt_key nettle_aes192_set_encrypt_key\n#define aes192_set_decrypt_key nettle_aes192_set_decrypt_key\n#define aes192_invert_key nettle_aes192_invert_key\n#define aes192_encrypt nettle_aes192_encrypt\n#define aes192_decrypt nettle_aes192_decrypt\n#define aes256_set_encrypt_key nettle_aes256_set_encrypt_key\n#define aes256_set_decrypt_key nettle_aes256_set_decrypt_key\n#define aes256_invert_key nettle_aes256_invert_key\n#define aes256_encrypt nettle_aes256_encrypt\n#define aes256_decrypt nettle_aes256_decrypt\n\n#define AES_BLOCK_SIZE 16\n\n#define AES128_KEY_SIZE 16\n#define AES192_KEY_SIZE 24\n#define AES256_KEY_SIZE 32\n#define _AES128_ROUNDS 10\n#define _AES192_ROUNDS 12\n#define _AES256_ROUNDS 14\n\nstruct aes128_ctx\n{\n  uint32_t keys[4 * (_AES128_ROUNDS + 1)];\n};\n\nvoid\naes128_set_encrypt_key(struct aes128_ctx *ctx, const uint8_t *key);\nvoid\naes128_set_decrypt_key(struct aes128_ctx *ctx, const uint8_t *key);\nvoid\naes128_invert_key(struct aes128_ctx *dst,\n\t\t  const struct aes128_ctx *src);\nvoid\naes128_encrypt(const struct aes128_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\nvoid\naes128_decrypt(const struct aes128_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\n\nstruct aes192_ctx\n{\n  uint32_t keys[4 * (_AES192_ROUNDS + 1)];\n};\n\nvoid\naes192_set_encrypt_key(struct aes192_ctx *ctx, const uint8_t *key);\nvoid\naes192_set_decrypt_key(struct aes192_ctx *ctx, const uint8_t *key);\nvoid\naes192_invert_key(struct aes192_ctx *dst,\n\t\t  const struct aes192_ctx *src);\nvoid\naes192_encrypt(const struct aes192_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\nvoid\naes192_decrypt(const struct aes192_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\n\nstruct aes256_ctx\n{\n  uint32_t keys[4 * (_AES256_ROUNDS + 1)];\n};\n\nvoid\naes256_set_encrypt_key(struct aes256_ctx *ctx, const uint8_t *key);\nvoid\naes256_set_decrypt_key(struct aes256_ctx *ctx, const uint8_t *key);\nvoid\naes256_invert_key(struct aes256_ctx *dst,\n\t\t  const struct aes256_ctx *src);\nvoid\naes256_encrypt(const struct aes256_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\nvoid\naes256_decrypt(const struct aes256_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\n\n/* The older nettle-2.7 AES interface is deprecated, please migrate to\n   the newer interface where each algorithm has a fixed key size. */\n\n/* Variable key size between 128 and 256 bits. But the only valid\n * values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */\n#define AES_MIN_KEY_SIZE AES128_KEY_SIZE\n#define AES_MAX_KEY_SIZE AES256_KEY_SIZE\n\n#define AES_KEY_SIZE 32\n\nstruct aes_ctx\n{\n  unsigned key_size;  /* In octets */\n  union {\n    struct aes128_ctx ctx128;\n    struct aes192_ctx ctx192;\n    struct aes256_ctx ctx256;\n  } u;\n};\n\nvoid\naes_set_encrypt_key(struct aes_ctx *ctx,\n\t\t    size_t length, const uint8_t *key)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\naes_set_decrypt_key(struct aes_ctx *ctx,\n\t\t   size_t length, const uint8_t *key)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\naes_invert_key(struct aes_ctx *dst,\n\t       const struct aes_ctx *src)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\naes_encrypt(const struct aes_ctx *ctx,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src) _NETTLE_ATTRIBUTE_DEPRECATED;\nvoid\naes_decrypt(const struct aes_ctx *ctx,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src) _NETTLE_ATTRIBUTE_DEPRECATED;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_AES_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/arcfour.h",
    "content": "/* arcfour.h\n\n   The arcfour/rc4 stream cipher.\n\n   Copyright (C) 2001, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_ARCFOUR_H_INCLUDED\n#define NETTLE_ARCFOUR_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define arcfour128_set_key nettle_arcfour128_set_key\n#define arcfour_set_key nettle_arcfour_set_key\n#define arcfour_crypt nettle_arcfour_crypt\n\n/* Minimum and maximum keysizes, and a reasonable default. In\n * octets.*/\n#define ARCFOUR_MIN_KEY_SIZE 1\n#define ARCFOUR_MAX_KEY_SIZE 256\n#define ARCFOUR_KEY_SIZE 16\n#define ARCFOUR128_KEY_SIZE 16\n\nstruct arcfour_ctx\n{\n  uint8_t S[256];\n  uint8_t i;\n  uint8_t j;\n};\n\nvoid\narcfour_set_key(struct arcfour_ctx *ctx,\n\t\tsize_t length, const uint8_t *key);\n\nvoid\narcfour128_set_key(struct arcfour_ctx *ctx, const uint8_t *key);\n\nvoid\narcfour_crypt(struct arcfour_ctx *ctx,\n\t      size_t length, uint8_t *dst,\n\t      const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ARCFOUR_H_INCLUDED */\n\n"
  },
  {
    "path": "thirdparty/32/include/nettle/arctwo.h",
    "content": "/* arctwo.h\n\n   The arctwo/rfc2268 block cipher.\n\n   Copyright (C) 2004 Simon Josefsson\n   Copyright (C) 2002, 2004, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_ARCTWO_H_INCLUDED\n#define NETTLE_ARCTWO_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define arctwo_set_key nettle_arctwo_set_key\n#define arctwo_set_key_ekb nettle_arctwo_set_key_ekb\n#define arctwo_set_key_gutmann nettle_arctwo_set_key_gutmann\n#define arctwo40_set_key nettle_arctwo40_set_key\n#define arctwo64_set_key nettle_arctwo64_set_key\n#define arctwo128_set_key nettle_arctwo128_set_key\n#define arctwo128_set_key_gutmann nettle_arctwo128_set_key_gutmann\n#define arctwo_encrypt nettle_arctwo_encrypt\n#define arctwo_decrypt nettle_arctwo_decrypt\n\n#define ARCTWO_BLOCK_SIZE 8\n\n/* Variable key size from 1 byte to 128 bytes. */\n#define ARCTWO_MIN_KEY_SIZE 1\n#define ARCTWO_MAX_KEY_SIZE 128\n\n#define ARCTWO_KEY_SIZE 8\n\nstruct arctwo_ctx\n{\n  uint16_t S[64];\n};\n\n/* Key expansion function that takes the \"effective key bits\", 1-1024,\n   as an explicit argument. 0 means maximum key bits. */\nvoid\narctwo_set_key_ekb (struct arctwo_ctx *ctx,\n\t\t    size_t length, const uint8_t * key, unsigned ekb);\n\n/* Equvivalent to arctwo_set_key_ekb, with ekb = 8 * length */\nvoid\narctwo_set_key (struct arctwo_ctx *ctx, size_t length, const uint8_t *key);\nvoid\narctwo40_set_key (struct arctwo_ctx *ctx, const uint8_t *key);\nvoid\narctwo64_set_key (struct arctwo_ctx *ctx, const uint8_t *key);\nvoid\narctwo128_set_key (struct arctwo_ctx *ctx, const uint8_t *key);\n\n/* Equvivalent to arctwo_set_key_ekb, with ekb = 1024 */\nvoid\narctwo_set_key_gutmann (struct arctwo_ctx *ctx,\n\t\t\tsize_t length, const uint8_t *key);\nvoid\narctwo128_set_key_gutmann (struct arctwo_ctx *ctx,\n\t\t\t   const uint8_t *key);\n\nvoid\narctwo_encrypt (struct arctwo_ctx *ctx,\n\t\tsize_t length, uint8_t *dst, const uint8_t *src);\nvoid\narctwo_decrypt (struct arctwo_ctx *ctx,\n\t\tsize_t length, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ARCTWO_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/asn1.h",
    "content": "/* asn1.h\n\n   Limited support for ASN.1 DER decoding.\n\n   Copyright (C) 2005 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_ASN1_H_INCLUDED\n#define NETTLE_ASN1_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define asn1_der_iterator_first nettle_asn1_der_iterator_first\n#define asn1_der_iterator_next nettle_asn1_der_iterator_next\n#define asn1_der_decode_constructed nettle_asn1_der_decode_constructed\n#define asn1_der_decode_constructed_last nettle_asn1_der_decode_constructed_last\n#define asn1_der_decode_bitstring nettle_asn1_der_decode_bitstring\n#define asn1_der_decode_bitstring_last nettle_asn1_der_decode_bitstring_last\n#define asn1_der_get_uint32 nettle_asn1_der_get_uint32\n#define asn1_der_get_bignum nettle_asn1_der_get_bignum\n\n\n/* enum asn1_type keeps the class number and the constructive in bits\n   13-14, and the constructive flag in bit 12. The remaining 14 bits\n   are the tag (although currently, only tags in the range 0-30 are\n   supported). */\n\nenum\n  {\n    ASN1_TYPE_CONSTRUCTED = 1 << 12,\n\n    ASN1_CLASS_UNIVERSAL = 0,\n    ASN1_CLASS_APPLICATION = 1 << 13,\n    ASN1_CLASS_CONTEXT_SPECIFIC = 2 << 13,\n    ASN1_CLASS_PRIVATE = 3 << 13,\n\n    ASN1_CLASS_MASK = 3 << 13,\n    ASN1_CLASS_SHIFT = 13,\n  };\n\nenum asn1_type\n  {\n    ASN1_BOOLEAN = 1,\n    ASN1_INTEGER = 2,\n    ASN1_BITSTRING = 3,\n    ASN1_OCTETSTRING = 4,\n    ASN1_NULL = 5,\n    ASN1_IDENTIFIER = 6,\n    ASN1_REAL = 9,\n    ASN1_ENUMERATED = 10,\n    ASN1_UTF8STRING = 12,\n    ASN1_SEQUENCE = 16 | ASN1_TYPE_CONSTRUCTED,\n    ASN1_SET = 17 | ASN1_TYPE_CONSTRUCTED,\n    ASN1_PRINTABLESTRING = 19,\n    ASN1_TELETEXSTRING = 20,\n    ASN1_IA5STRING = 22,\n    ASN1_UTC = 23,\n    ASN1_UNIVERSALSTRING = 28,\n    ASN1_BMPSTRING = 30,\n  };\n\nenum asn1_iterator_result\n  {\n    ASN1_ITERATOR_ERROR,\n    ASN1_ITERATOR_PRIMITIVE,\n    ASN1_ITERATOR_CONSTRUCTED,\n    ASN1_ITERATOR_END,\n  };\n\n/* Parsing DER objects. */\nstruct asn1_der_iterator\n{\n  size_t buffer_length;\n  const uint8_t *buffer;\n\n  /* Next object to parse. */\n  size_t pos;\n\n  enum asn1_type type;\n\n  /* Pointer to the current object */\n  size_t length;\n  const uint8_t *data;\n};\n\n/* Initializes the iterator. */\nenum asn1_iterator_result\nasn1_der_iterator_first(struct asn1_der_iterator *iterator,\n\t\t\tsize_t length, const uint8_t *input);\n\nenum asn1_iterator_result\nasn1_der_iterator_next(struct asn1_der_iterator *iterator);\n\n/* Starts parsing of a constructed object. */\nenum asn1_iterator_result\nasn1_der_decode_constructed(struct asn1_der_iterator *i,\n\t\t\t    struct asn1_der_iterator *contents);\n\n/* For the common case that we have a sequence at the end of the\n   object. Checks that the current object is the final one, and then\n   reinitializes the iterator to parse its ontents. */\nenum asn1_iterator_result\nasn1_der_decode_constructed_last(struct asn1_der_iterator *i);\n\nenum asn1_iterator_result\nasn1_der_decode_bitstring(struct asn1_der_iterator *i,\n\t\t\t  struct asn1_der_iterator *contents);\n\nenum asn1_iterator_result\nasn1_der_decode_bitstring_last(struct asn1_der_iterator *i);\n\n/* All these functions return 1 on success, 0 on failure */\nint\nasn1_der_get_uint32(struct asn1_der_iterator *i,\n\t\t    uint32_t *x);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ASN1_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/balloon.h",
    "content": "/* balloon.h\n\n   Balloon password-hashing algorithm.\n\n   Copyright (C) 2022 Zoltan Fridrich\n   Copyright (C) 2022 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* For a description of the algorithm, see:\n * Boneh, D., Corrigan-Gibbs, H., Schechter, S. (2017, May 12). Balloon Hashing:\n * A Memory-Hard Function Providing Provable Protection Against Sequential Attacks.\n * Retrieved Sep 1, 2022, from https://eprint.iacr.org/2016/027.pdf\n */\n\n#ifndef NETTLE_BALLOON_H_INCLUDED\n#define NETTLE_BALLOON_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define balloon nettle_balloon\n#define balloon_itch nettle_balloon_itch\n#define balloon_sha1 nettle_balloon_sha1\n#define balloon_sha256 nettle_balloon_sha256\n#define balloon_sha384 nettle_balloon_sha384\n#define balloon_sha512 nettle_balloon_sha512\n\nvoid\nballoon(void *hash_ctx,\n        nettle_hash_update_func *update,\n        nettle_hash_digest_func *digest,\n        size_t digest_size, size_t s_cost, size_t t_cost,\n        size_t passwd_length, const uint8_t *passwd,\n        size_t salt_length, const uint8_t *salt,\n        uint8_t *scratch, uint8_t *dst);\n\nsize_t\nballoon_itch(size_t digest_size, size_t s_cost);\n\nvoid\nballoon_sha1(size_t s_cost, size_t t_cost,\n             size_t passwd_length, const uint8_t *passwd,\n             size_t salt_length, const uint8_t *salt,\n             uint8_t *scratch, uint8_t *dst);\n\nvoid\nballoon_sha256(size_t s_cost, size_t t_cost,\n               size_t passwd_length, const uint8_t *passwd,\n               size_t salt_length, const uint8_t *salt,\n               uint8_t *scratch, uint8_t *dst);\n\nvoid\nballoon_sha384(size_t s_cost, size_t t_cost,\n               size_t passwd_length, const uint8_t *passwd,\n               size_t salt_length, const uint8_t *salt,\n               uint8_t *scratch, uint8_t *dst);\n\nvoid\nballoon_sha512(size_t s_cost, size_t t_cost,\n               size_t passwd_length, const uint8_t *passwd,\n               size_t salt_length, const uint8_t *salt,\n               uint8_t *scratch, uint8_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BALLOON_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/base16.h",
    "content": "/* base16.h\n   \n   Hex encoding and decoding, following spki conventions (i.e.\n   allowing whitespace between digits).\n\n   Copyright (C) 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BASE16_H_INCLUDED\n#define NETTLE_BASE16_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define base16_encode_single nettle_base16_encode_single\n#define base16_encode_update nettle_base16_encode_update\n#define base16_decode_init nettle_base16_decode_init\n#define base16_decode_single nettle_base16_decode_single\n#define base16_decode_update nettle_base16_decode_update\n#define base16_decode_final nettle_base16_decode_final\n\n/* Base16 encoding */\n\n/* Maximum length of output for base16_encode_update. */\n#define BASE16_ENCODE_LENGTH(length) ((length) * 2)\n\n/* Encodes a single byte. Always stores two digits in dst[0] and dst[1]. */\nvoid\nbase16_encode_single(char *dst,\n\t\t     uint8_t src);\n\n/* Always stores BASE16_ENCODE_LENGTH(length) digits in dst. */\nvoid\nbase16_encode_update(char *dst,\n\t\t     size_t length,\n\t\t     const uint8_t *src);\n\n\n/* Base16 decoding */\n\n/* Maximum length of output for base16_decode_update. */\n/* We have at most 4 buffered bits, and a total of (length + 1) * 4 bits. */\n#define BASE16_DECODE_LENGTH(length) (((length) + 1) / 2)\n\nstruct base16_decode_ctx\n{\n  unsigned char word; /* Leftover bits */\n  unsigned char bits; /* Number buffered bits */\n};\n\nvoid\nbase16_decode_init(struct base16_decode_ctx *ctx);\n\n/* Decodes a single byte. Returns amount of output (0 or 1), or -1 on\n * errors. */\nint\nbase16_decode_single(struct base16_decode_ctx *ctx,\n\t\t     uint8_t *dst,\n\t\t     char src);\n\n/* Returns 1 on success, 0 on error. DST should point to an area of\n * size at least BASE16_DECODE_LENGTH(length). The amount of data\n * generated is returned in *DST_LENGTH. */\n\nint\nbase16_decode_update(struct base16_decode_ctx *ctx,\n\t\t     size_t *dst_length,\n\t\t     uint8_t *dst,\n\t\t     size_t src_length,\n\t\t     const char *src);\n\n/* Returns 1 on success. */\nint\nbase16_decode_final(struct base16_decode_ctx *ctx);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BASE16_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/base64.h",
    "content": "/* base64.h\n   \n   Base-64 encoding and decoding.\n\n   Copyright (C) 2002 Niels Möller, Dan Egnor\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BASE64_H_INCLUDED\n#define NETTLE_BASE64_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define base64_encode_init nettle_base64_encode_init\n#define base64url_encode_init nettle_base64url_encode_init\n#define base64_encode_single nettle_base64_encode_single\n#define base64_encode_update nettle_base64_encode_update\n#define base64_encode_final nettle_base64_encode_final\n#define base64_encode_raw nettle_base64_encode_raw\n#define base64_encode_group nettle_base64_encode_group\n#define base64_decode_init nettle_base64_decode_init\n#define base64url_decode_init nettle_base64url_decode_init\n#define base64_decode_single nettle_base64_decode_single\n#define base64_decode_update nettle_base64_decode_update\n#define base64_decode_final nettle_base64_decode_final\n\n#define BASE64_BINARY_BLOCK_SIZE 3\n#define BASE64_TEXT_BLOCK_SIZE 4\n\n/* Base64 encoding */\n\n/* Maximum length of output for base64_encode_update. NOTE: Doesn't\n * include any padding that base64_encode_final may add. */\n/* We have at most 4 buffered bits, and a total of (4 + length * 8) bits. */\n#define BASE64_ENCODE_LENGTH(length) (((length) * 8 + 4)/6)\n\n/* Maximum length of output generated by base64_encode_final. */\n#define BASE64_ENCODE_FINAL_LENGTH 3\n\n/* Exact length of output generated by base64_encode_raw, including\n * padding. */\n#define BASE64_ENCODE_RAW_LENGTH(length) ((((length) + 2)/3)*4)\n\nstruct base64_encode_ctx\n{\n  const char *alphabet;    /* Alphabet to use for encoding */\n  unsigned short word;     /* Leftover bits */\n  unsigned char bits;      /* Number of bits, always 0, 2, or 4. */\n};\n\n/* Initialize encoding context for base-64 */\nvoid\nbase64_encode_init(struct base64_encode_ctx *ctx);\n\n/* Initialize encoding context for URL safe alphabet, RFC 4648. */\nvoid\nbase64url_encode_init(struct base64_encode_ctx *ctx);\n\n/* Encodes a single byte. Returns amount of output (always 1 or 2). */\nsize_t\nbase64_encode_single(struct base64_encode_ctx *ctx,\n\t\t     char *dst,\n\t\t     uint8_t src);\n\n/* Returns the number of output characters. DST should point to an\n * area of size at least BASE64_ENCODE_LENGTH(length). */\nsize_t\nbase64_encode_update(struct base64_encode_ctx *ctx,\n\t\t     char *dst,\n\t\t     size_t length,\n\t\t     const uint8_t *src);\n\n/* DST should point to an area of size at least\n * BASE64_ENCODE_FINAL_LENGTH */\nsize_t\nbase64_encode_final(struct base64_encode_ctx *ctx,\n\t\t    char *dst);\n\n/* Lower level functions */\n\n/* Encodes a string in one go, including any padding at the end.\n * Generates exactly BASE64_ENCODE_RAW_LENGTH(length) bytes of output.\n * Supports overlapped operation, if src <= dst. FIXME: Use of overlap\n * is deprecated, if needed there should be a separate public fucntion\n * to do that.*/\nvoid\nbase64_encode_raw(char *dst, size_t length, const uint8_t *src);\n\nvoid\nbase64_encode_group(char *dst, uint32_t group);\n\n\n/* Base64 decoding */\n\n/* Maximum length of output for base64_decode_update. */\n/* We have at most 6 buffered bits, and a total of (length + 1) * 6 bits. */\n#define BASE64_DECODE_LENGTH(length) ((((length) + 1) * 6) / 8)\n\nstruct base64_decode_ctx\n{\n  const signed char *table; /* Decoding table */\n  unsigned short word;      /* Leftover bits */\n  unsigned char bits;       /* Number buffered bits */\n\n  /* Number of padding characters encountered */\n  unsigned char padding;\n};\n\n/* Initialize decoding context for base-64 */\nvoid\nbase64_decode_init(struct base64_decode_ctx *ctx);\n\n/* Initialize encoding context for URL safe alphabet, RFC 4648. */\nvoid\nbase64url_decode_init(struct base64_decode_ctx *ctx);\n\n/* Decodes a single byte. Returns amount of output (0 or 1), or -1 on\n * errors. */\nint\nbase64_decode_single(struct base64_decode_ctx *ctx,\n\t\t     uint8_t *dst,\n\t\t     char src);\n\n/* Returns 1 on success, 0 on error. DST should point to an area of\n * size at least BASE64_DECODE_LENGTH(length). The amount of data\n * generated is returned in *DST_LENGTH. */\nint\nbase64_decode_update(struct base64_decode_ctx *ctx,\n\t\t     size_t *dst_length,\n\t\t     uint8_t *dst,\n\t\t     size_t src_length,\n\t\t     const char *src);\n\n/* Returns 1 on success. */\nint\nbase64_decode_final(struct base64_decode_ctx *ctx);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BASE64_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/bignum.h",
    "content": "/* bignum.h\n\n   Bignum operations that are missing from gmp.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BIGNUM_H_INCLUDED\n#define NETTLE_BIGNUM_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n/* For NETTLE_USE_MINI_GMP */\n#include \"version.h\"\n\n#if NETTLE_USE_MINI_GMP\n# include \"mini-gmp.h\"\n\n# define GMP_NUMB_MASK (~(mp_limb_t) 0)\n\n/* Side-channel silent powm not available in mini-gmp. */\n# define mpz_powm_sec mpz_powm\n#else\n# include <gmp.h>\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Size needed for signed encoding, including extra sign byte if\n * necessary. */\nsize_t\nnettle_mpz_sizeinbase_256_s(const mpz_t x);\n\n/* Size needed for unsigned encoding */\nsize_t\nnettle_mpz_sizeinbase_256_u(const mpz_t x);\n\n/* Writes an integer as length octets, using big endian byte order,\n * and two's complement for negative numbers. */\nvoid\nnettle_mpz_get_str_256(size_t length, uint8_t *s, const mpz_t x);\n\n/* Reads a big endian, two's complement, integer. */\nvoid\nnettle_mpz_set_str_256_s(mpz_t x,\n\t\t\t size_t length, const uint8_t *s);\n\nvoid\nnettle_mpz_init_set_str_256_s(mpz_t x,\n\t\t\t      size_t length, const uint8_t *s);\n\n/* Similar, but for unsigned format. These function don't interpret\n * the most significant bit as the sign. */\nvoid\nnettle_mpz_set_str_256_u(mpz_t x,\n\t\t\t size_t length, const uint8_t *s);\n\nvoid\nnettle_mpz_init_set_str_256_u(mpz_t x,\n\t\t\t      size_t length, const uint8_t *s);\n\n/* Returns a uniformly distributed random number 0 <= x < 2^n */\nvoid\nnettle_mpz_random_size(mpz_t x,\n\t\t       void *ctx, nettle_random_func *random,\n\t\t       unsigned bits);\n\n/* Returns a number x, almost uniformly random in the range\n * 0 <= x < n. */\nvoid\nnettle_mpz_random(mpz_t x, \n\t\t  void *ctx, nettle_random_func *random,\n\t\t  const mpz_t n);\n\nvoid\nnettle_random_prime(mpz_t p, unsigned bits, int top_bits_set,\n\t\t    void *ctx, nettle_random_func *random,\n\t\t    void *progress_ctx, nettle_progress_func *progress);\n\n  \n/* sexp parsing */\nstruct sexp_iterator;\n\n/* If LIMIT is non-zero, the number must be at most LIMIT bits.\n * Implies sexp_iterator_next. */\nint\nnettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i);\n\n\n/* der parsing */\nstruct asn1_der_iterator;\n\nint\nnettle_asn1_der_get_bignum(struct asn1_der_iterator *iterator,\n\t\t\t   mpz_t x, unsigned max_bits);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BIGNUM_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/blowfish.h",
    "content": "/* blowfish.h\n\n   Blowfish block cipher.\n\n   Copyright (C) 2014 Niels Möller\n   Copyright (C) 1998, 2001 FSF, Ray Dassen, Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BLOWFISH_H_INCLUDED\n#define NETTLE_BLOWFISH_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define blowfish_set_key nettle_blowfish_set_key\n#define blowfish128_set_key nettle_blowfish128_set_key\n#define blowfish_encrypt nettle_blowfish_encrypt\n#define blowfish_decrypt nettle_blowfish_decrypt\n#define blowfish_bcrypt_hash nettle_blowfish_bcrypt_hash\n#define blowfish_bcrypt_verify nettle_blowfish_bcrypt_verify\n\n#define BLOWFISH_BLOCK_SIZE 8\n\n/* Variable key size between 64 and 448 bits. */\n#define BLOWFISH_MIN_KEY_SIZE 8\n#define BLOWFISH_MAX_KEY_SIZE 56\n\n/* Default to 128 bits */\n#define BLOWFISH_KEY_SIZE 16\n\n#define BLOWFISH128_KEY_SIZE 16\n\n#define _BLOWFISH_ROUNDS 16\n\n#define BLOWFISH_BCRYPT_HASH_SIZE (60 + 1) /* Including null-terminator */\n#define BLOWFISH_BCRYPT_BINSALT_SIZE 16    /* Binary string size */\n\nstruct blowfish_ctx\n{\n  uint32_t s[4][256];\n  uint32_t p[_BLOWFISH_ROUNDS+2];\n};\n\n/* Returns 0 for weak keys, otherwise 1. */\nint\nblowfish_set_key(struct blowfish_ctx *ctx,\n                 size_t length, const uint8_t *key);\nint\nblowfish128_set_key(struct blowfish_ctx *ctx, const uint8_t *key);\n\nvoid\nblowfish_encrypt(const struct blowfish_ctx *ctx,\n                 size_t length, uint8_t *dst,\n                 const uint8_t *src);\nvoid\nblowfish_decrypt(const struct blowfish_ctx *ctx,\n                 size_t length, uint8_t *dst,\n                 const uint8_t *src);\n\n/* dst parameter must point to a buffer of minimally\n * BLOWFISH_BCRYPT_HASH_SIZE bytes */\nint\nblowfish_bcrypt_hash(uint8_t *dst,\n                     size_t lenkey, const uint8_t *key,\n                     size_t lenscheme, const uint8_t *scheme,\n\t\t     int log2rounds,\n\t\t     const uint8_t *salt);\nint\nblowfish_bcrypt_verify(size_t lenkey, const uint8_t *key,\n                       size_t lenhashed, const uint8_t *hashed);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BLOWFISH_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/buffer.h",
    "content": "/* buffer.h\n\n   A bare-bones string stream.\n\n   Copyright (C) 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BUFFER_H_INCLUDED\n#define NETTLE_BUFFER_H_INCLUDED\n\n#include \"realloc.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct nettle_buffer\n{\n  uint8_t *contents;\n  /* Allocated size */\n  size_t alloc;\n\n  void *realloc_ctx;\n  nettle_realloc_func *realloc;\n\n  /* Current size */\n  size_t size;\n};\n\n/* Initializes a buffer that uses plain realloc */\nvoid\nnettle_buffer_init(struct nettle_buffer *buffer);\n\nvoid\nnettle_buffer_init_realloc(struct nettle_buffer *buffer,\n\t\t\t   void *realloc_ctx,\n\t\t\t   nettle_realloc_func *realloc);\n\n/* Initializes a buffer of fix size */\nvoid\nnettle_buffer_init_size(struct nettle_buffer *buffer,\n\t\t\tsize_t length, uint8_t *space);\n\nvoid\nnettle_buffer_clear(struct nettle_buffer *buffer);\n\n/* Resets the buffer, without freeing the buffer space. */\nvoid\nnettle_buffer_reset(struct nettle_buffer *buffer);\n\nint\nnettle_buffer_grow(struct nettle_buffer *buffer,\n\t\t   size_t length);\n\n#define NETTLE_BUFFER_PUTC(buffer, c) \\\n( (((buffer)->size < (buffer)->alloc) || nettle_buffer_grow((buffer), 1)) \\\n  && ((buffer)->contents[(buffer)->size++] = (c), 1) )\n\nint\nnettle_buffer_write(struct nettle_buffer *buffer,\n\t\t    size_t length, const uint8_t *data);\n\n/* Like nettle_buffer_write, but instead of copying data to the\n * buffer, it returns a pointer to the area where the caller can copy\n * the data. The pointer is valid only until the next call that can\n * reallocate the buffer. */\nuint8_t *\nnettle_buffer_space(struct nettle_buffer *buffer,\n\t\t    size_t length);\n\n/* Copy the contents of SRC to the end of DST. */\nint\nnettle_buffer_copy(struct nettle_buffer *dst,\n\t\t   const struct nettle_buffer *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BUFFER_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/camellia.h",
    "content": "/* camellia.h\n\n   Copyright (C) 2006,2007 NTT\n   (Nippon Telegraph and Telephone Corporation).\n\n   Copyright (C) 2010, 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CAMELLIA_H_INCLUDED\n#define NETTLE_CAMELLIA_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define camellia128_set_encrypt_key nettle_camellia128_set_encrypt_key\n#define camellia128_set_decrypt_key nettle_camellia_set_decrypt_key\n#define camellia128_invert_key nettle_camellia128_invert_key\n#define camellia128_crypt nettle_camellia128_crypt\n\n#define camellia192_set_encrypt_key nettle_camellia192_set_encrypt_key\n#define camellia192_set_decrypt_key nettle_camellia192_set_decrypt_key\n\n#define camellia256_set_encrypt_key nettle_camellia256_set_encrypt_key\n#define camellia256_set_decrypt_key nettle_camellia256_set_decrypt_key\n#define camellia256_invert_key nettle_camellia256_invert_key\n#define camellia256_crypt nettle_camellia256_crypt\n\n\n#define CAMELLIA_BLOCK_SIZE 16\n/* Valid key sizes are 128, 192 or 256 bits (16, 24 or 32 bytes) */\n#define CAMELLIA128_KEY_SIZE 16\n#define CAMELLIA192_KEY_SIZE 24\n#define CAMELLIA256_KEY_SIZE 32\n\n/* For 128-bit keys, there are 18 regular rounds, pre- and\n   post-whitening, and two FL and FLINV rounds, using a total of 26\n   subkeys, each of 64 bit. For 192- and 256-bit keys, there are 6\n   additional regular rounds and one additional FL and FLINV, using a\n   total of 34 subkeys. */\n/* The clever combination of subkeys imply one of the pre- and\n   post-whitening keys is folded with the round keys, so that subkey\n   #1 and the last one (#25 or #33) is not used. The result is that we\n   have only 24 or 32 subkeys at the end of key setup. */\n\n#define _CAMELLIA128_NKEYS 24\n#define _CAMELLIA256_NKEYS 32\n\nstruct camellia128_ctx\n{\n  uint64_t keys[_CAMELLIA128_NKEYS];\n};\n\nvoid\ncamellia128_set_encrypt_key(struct camellia128_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia128_set_decrypt_key(struct camellia128_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia128_invert_key(struct camellia128_ctx *dst,\n\t\t       const struct camellia128_ctx *src);\n\nvoid\ncamellia128_crypt(const struct camellia128_ctx *ctx,\n\t\t  size_t length, uint8_t *dst,\n\t\t  const uint8_t *src);\n\nstruct camellia256_ctx\n{\n  uint64_t keys[_CAMELLIA256_NKEYS];\n};\n\nvoid\ncamellia256_set_encrypt_key(struct camellia256_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia256_set_decrypt_key(struct camellia256_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia256_invert_key(struct camellia256_ctx *dst,\n\t\t       const struct camellia256_ctx *src);\n\nvoid\ncamellia256_crypt(const struct camellia256_ctx *ctx,\n\t\t  size_t length, uint8_t *dst,\n\t\t  const uint8_t *src);\n\n/* camellia192 is the same as camellia256, except for the key\n   schedule. */\n/* Slightly ugly with a #define on a struct tag, since it might cause\n   surprises if also used as a name of a variable. */\n#define camellia192_ctx camellia256_ctx\n\nvoid\ncamellia192_set_encrypt_key(struct camellia256_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia192_set_decrypt_key(struct camellia256_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\n#define camellia192_invert_key camellia256_invert_key\n#define camellia192_crypt camellia256_crypt\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CAMELLIA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/cast128.h",
    "content": "/* cast128.h\n\n   The CAST-128 block cipher.\n\n   Copyright (C) 2001, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_CAST128_H_INCLUDED\n#define NETTLE_CAST128_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define cast5_set_key nettle_cast5_set_key\n#define cast128_set_key nettle_cast128_set_key\n#define cast128_encrypt nettle_cast128_encrypt\n#define cast128_decrypt nettle_cast128_decrypt\n\n#define CAST128_BLOCK_SIZE 8\n\n/* Variable key size between 40 and 128. */\n#define CAST5_MIN_KEY_SIZE 5\n#define CAST5_MAX_KEY_SIZE 16\n\n#define CAST128_KEY_SIZE 16\n\nstruct cast128_ctx\n{\n  unsigned rounds;  /* Number of rounds to use, 12 or 16 */\n  /* Expanded key, rotations (5 bits only) and 32-bit masks. */\n  unsigned char Kr[16];\n  uint32_t Km[16];\n};\n\n/* Using variable key size. */\nvoid\ncast5_set_key(struct cast128_ctx *ctx,\n\t      size_t length, const uint8_t *key);\n\nvoid\ncast128_set_key(struct cast128_ctx *ctx, const uint8_t *key);\n\nvoid\ncast128_encrypt(const struct cast128_ctx *ctx,\n\t\tsize_t length, uint8_t *dst,\n\t\tconst uint8_t *src);\nvoid\ncast128_decrypt(const struct cast128_ctx *ctx,\n\t\tsize_t length, uint8_t *dst,\n\t\tconst uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CAST128_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/cbc.h",
    "content": "/* cbc.h\n\n   Cipher block chaining mode.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CBC_H_INCLUDED\n#define NETTLE_CBC_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define cbc_encrypt nettle_cbc_encrypt\n#define cbc_decrypt nettle_cbc_decrypt\n#define cbc_aes128_encrypt nettle_cbc_aes128_encrypt\n#define cbc_aes192_encrypt nettle_cbc_aes192_encrypt\n#define cbc_aes256_encrypt nettle_cbc_aes256_encrypt\n\nvoid\ncbc_encrypt(const void *ctx, nettle_cipher_func *f,\n\t    size_t block_size, uint8_t *iv,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\nvoid\ncbc_decrypt(const void *ctx, nettle_cipher_func *f,\n\t    size_t block_size, uint8_t *iv,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\n#define CBC_CTX(type, size) \\\n{ type ctx; uint8_t iv[size]; }\n\n#define CBC_SET_IV(ctx, data) \\\nmemcpy((ctx)->iv, (data), sizeof((ctx)->iv))\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define CBC_ENCRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cbc_encrypt((void *) &(self)->ctx,\t\t\t\\\n\t\t (nettle_cipher_func *) (f),\t\t\\\n\t\t sizeof((self)->iv), (self)->iv,\t\\\n\t\t (length), (dst), (src)))\n\n#define CBC_DECRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cbc_decrypt((void *) &(self)->ctx,\t\t\t\\\n\t\t (nettle_cipher_func *) (f),\t\t\\\n\t\t sizeof((self)->iv), (self)->iv,\t\\\n\t\t (length), (dst), (src)))\n\nvoid\ncbc_aes128_encrypt(const struct aes128_ctx *ctx, uint8_t *iv,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ncbc_aes192_encrypt(const struct aes192_ctx *ctx, uint8_t *iv,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ncbc_aes256_encrypt(const struct aes256_ctx *ctx, uint8_t *iv,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CBC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/ccm.h",
    "content": "/* ccm.h\n\n   Counter with CBC-MAC mode, specified by NIST,\n   http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf\n\n   Copyright (C) 2014 Exegin Technologies Limited\n   Copyright (C) 2014 Owen Kirby\n\n   Contributed to GNU Nettle by Owen Kirby\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* NIST SP800-38C doesn't specify the particular formatting and\n * counter generation algorithm for CCM, but it does include an\n * example algorithm. This example has become the de-factor standard,\n * and has been adopted by both the IETF and IEEE across a wide\n * variety of protocols.\n */\n\n#ifndef NETTLE_CCM_H_INCLUDED\n#define NETTLE_CCM_H_INCLUDED\n\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ccm_set_nonce nettle_ccm_set_nonce\n#define ccm_update nettle_ccm_update\n#define ccm_encrypt nettle_ccm_encrypt\n#define ccm_decrypt nettle_ccm_decrypt\n#define ccm_digest nettle_ccm_digest\n#define ccm_encrypt_message nettle_ccm_encrypt_message\n#define ccm_decrypt_message nettle_ccm_decrypt_message\n\n#define ccm_aes128_set_key nettle_ccm_aes128_set_key\n#define ccm_aes128_set_nonce nettle_ccm_aes128_set_nonce\n#define ccm_aes128_update nettle_ccm_aes128_update\n#define ccm_aes128_encrypt nettle_ccm_aes128_encrypt\n#define ccm_aes128_decrypt nettle_ccm_aes128_decrypt\n#define ccm_aes128_digest nettle_ccm_aes128_digest\n#define ccm_aes128_encrypt_message nettle_ccm_aes128_encrypt_message\n#define ccm_aes128_decrypt_message nettle_ccm_aes128_decrypt_message\n\n#define ccm_aes192_set_key nettle_ccm_aes192_set_key\n#define ccm_aes192_set_nonce nettle_ccm_aes192_set_nonce\n#define ccm_aes192_update nettle_ccm_aes192_update\n#define ccm_aes192_encrypt nettle_ccm_aes192_encrypt\n#define ccm_aes192_decrypt nettle_ccm_aes192_decrypt\n#define ccm_aes192_digest nettle_ccm_aes192_digest\n#define ccm_aes192_encrypt_message nettle_ccm_aes192_encrypt_message\n#define ccm_aes192_decrypt_message nettle_ccm_aes192_decrypt_message\n\n#define ccm_aes256_set_key nettle_ccm_aes256_set_key\n#define ccm_aes256_set_nonce nettle_ccm_aes256_set_nonce\n#define ccm_aes256_update nettle_ccm_aes256_update\n#define ccm_aes256_encrypt nettle_ccm_aes256_encrypt\n#define ccm_aes256_decrypt nettle_ccm_aes256_decrypt\n#define ccm_aes256_digest nettle_ccm_aes256_digest\n#define ccm_aes256_encrypt_message nettle_ccm_aes256_encrypt_message\n#define ccm_aes256_decrypt_message nettle_ccm_aes256_decrypt_message\n\n/* For CCM, the block size of the block cipher shall be 128 bits. */\n#define CCM_BLOCK_SIZE  16\n#define CCM_DIGEST_SIZE 16\n#define CCM_MIN_NONCE_SIZE 7\n#define CCM_MAX_NONCE_SIZE 14\n\n/* Maximum cleartext message size, as a function of the nonce size N.\n   The length field is L octets, with L = 15 - N, and then the maximum\n   size M = 2^{8L} - 1. */\n#define CCM_MAX_MSG_SIZE(N)\t\t\t\\\n  ((sizeof(size_t) + (N) <= 15)\t\t\t\\\n   ? ~(size_t) 0\t\t\t\t\\\n   : ((size_t) 1 << (8*(15 - N))) - 1)\n\n/* Per-message state */\nstruct ccm_ctx {\n  union nettle_block16 ctr;     /* Counter for CTR encryption. */\n  union nettle_block16 tag;     /* CBC-MAC message tag. */\n  /* Length of data processed by the CBC-MAC modulus the block size */\n  unsigned int blength;\n};\n\n/*\n * CCM mode requires the adata and message lengths when building the IV, which\n * prevents streaming processing and it incompatible with the AEAD API.\n */\nvoid\nccm_set_nonce(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t      size_t noncelen, const uint8_t *nonce,\n\t      size_t authlen, size_t msglen, size_t taglen);\n\nvoid\nccm_update(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t    size_t length, const uint8_t *data);\n\nvoid\nccm_encrypt(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_decrypt(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_digest(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t   size_t length, uint8_t *digest);\n\n/*\n * All-in-one encryption and decryption API:\n *  tlength = sizeof(digest)\n *  mlength = sizeof(cleartext)\n *  clength = sizeof(ciphertext) = mlength + tlength\n *\n * The ciphertext will contain the encrypted payload with the message digest\n * appended to the end.\n */\nvoid\nccm_encrypt_message(const void *cipher, nettle_cipher_func *f,\n\t\t    size_t nlength, const uint8_t *nonce,\n\t\t    size_t alength, const uint8_t *adata,\n\t\t    size_t tlength,\n\t\t    size_t clength, uint8_t *dst, const uint8_t *src);\n\n/*\n * The decryption function will write the plaintext to dst and parse the digest\n * from the final tlength bytes of the ciphertext. If the digest matched the\n * value computed during decryption then this will return 1, or it will return\n * 0 if the digest was invalid.\n */\nint\nccm_decrypt_message(const void *cipher, nettle_cipher_func *f,\n\t\t    size_t nlength, const uint8_t *nonce,\n\t\t    size_t alength, const uint8_t *adata,\n\t\t    size_t tlength,\n\t\t    size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* CCM Mode with AES-128 */\nstruct ccm_aes128_ctx {\n    struct ccm_ctx      ccm;\n    struct aes128_ctx   cipher;\n};\n\nvoid\nccm_aes128_set_key(struct ccm_aes128_ctx *ctx, const uint8_t *key);\n\nvoid\nccm_aes128_set_nonce(struct ccm_aes128_ctx *ctx,\n\t\t     size_t length, const uint8_t *nonce,\n\t\t     size_t authlen, size_t msglen, size_t taglen);\n\nvoid\nccm_aes128_update (struct ccm_aes128_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nccm_aes128_encrypt(struct ccm_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes128_decrypt(struct ccm_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes128_digest(struct ccm_aes128_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\n/* FIXME: For next API/ABI break: first argument should be const\n   struct aes128_ctx *, and similarly for other ccm_*_message\n   functions below. */\nvoid\nccm_aes128_encrypt_message(struct ccm_aes128_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nccm_aes128_decrypt_message(struct ccm_aes128_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t mlength, uint8_t *dst, const uint8_t *src);\n\nstruct ccm_aes192_ctx {\n    struct ccm_ctx      ccm;\n    struct aes192_ctx   cipher;\n};\n\n/* CCM Mode with AES-192 */\nvoid\nccm_aes192_set_key(struct ccm_aes192_ctx *ctx, const uint8_t *key);\n\nvoid\nccm_aes192_set_nonce(struct ccm_aes192_ctx *ctx,\n\t\t     size_t length, const uint8_t *nonce,\n\t\t     size_t authlen, size_t msglen, size_t taglen);\n\nvoid\nccm_aes192_update(struct ccm_aes192_ctx *ctx,\n\t\t  size_t length, const uint8_t *data);\n\nvoid\nccm_aes192_encrypt(struct ccm_aes192_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes192_decrypt(struct ccm_aes192_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes192_digest(struct ccm_aes192_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\nvoid\nccm_aes192_encrypt_message(struct ccm_aes192_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nccm_aes192_decrypt_message(struct ccm_aes192_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* CCM Mode with AES-256 */\nstruct ccm_aes256_ctx {\n    struct ccm_ctx      ccm;\n    struct aes256_ctx   cipher;\n};\n\nvoid\nccm_aes256_set_key(struct ccm_aes256_ctx *ctx, const uint8_t *key);\n\nvoid\nccm_aes256_set_nonce(struct ccm_aes256_ctx *ctx,\n\t\t     size_t length, const uint8_t *nonce,\n\t\t     size_t authlen, size_t msglen, size_t taglen);\n\nvoid\nccm_aes256_update(struct ccm_aes256_ctx *ctx,\n\t\t  size_t length, const uint8_t *data);\n\nvoid\nccm_aes256_encrypt(struct ccm_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes256_decrypt(struct ccm_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes256_digest(struct ccm_aes256_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\nvoid\nccm_aes256_encrypt_message(struct ccm_aes256_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nccm_aes256_decrypt_message(struct ccm_aes256_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t mlength, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CCM_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/cfb.h",
    "content": "/* cfb.h\n\n   Cipher feedback mode.\n\n   Copyright (C) 2015, 2017 Dmitry Eremin-Solenikov\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CFB_H_INCLUDED\n#define NETTLE_CFB_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define cfb_encrypt nettle_cfb_encrypt\n#define cfb_decrypt nettle_cfb_decrypt\n\n#define cfb8_encrypt nettle_cfb8_encrypt\n#define cfb8_decrypt nettle_cfb8_decrypt\n\nvoid\ncfb_encrypt(const void *ctx, nettle_cipher_func *f,\n\t    size_t block_size, uint8_t *iv,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\nvoid\ncfb_decrypt(const void *ctx, nettle_cipher_func *f,\n\t    size_t block_size, uint8_t *iv,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\nvoid\ncfb8_encrypt(const void *ctx, nettle_cipher_func *f,\n\t     size_t block_size, uint8_t *iv,\n\t     size_t length, uint8_t *dst,\n\t     const uint8_t *src);\n\nvoid\ncfb8_decrypt(const void *ctx, nettle_cipher_func *f,\n\t     size_t block_size, uint8_t *iv,\n\t     size_t length, uint8_t *dst,\n\t     const uint8_t *src);\n\n\n#define CFB_CTX(type, size) \\\n{ type ctx; uint8_t iv[size]; }\n\n#define CFB_SET_IV(ctx, data) \\\nmemcpy((ctx)->iv, (data), sizeof((ctx)->iv))\n\n#define CFB8_CTX CFB_CTX\n#define CFB8_SET_IV CFB_SET_IV\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define CFB_ENCRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cfb_encrypt((void *) &(self)->ctx,\t\t\t\\\n\t\t (nettle_cipher_func *) (f),\t\t\\\n\t\t sizeof((self)->iv), (self)->iv,\t\\\n\t\t (length), (dst), (src)))\n\n#define CFB_DECRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cfb_decrypt((void *) &(self)->ctx,\t\t\t\\\n\t\t (nettle_cipher_func *) (f),\t\t\\\n\t\t sizeof((self)->iv), (self)->iv,\t\\\n\t\t (length), (dst), (src)))\n\n#define CFB8_ENCRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cfb8_encrypt((void *) &(self)->ctx,\t\t\\\n\t\t  (nettle_cipher_func *) (f),\t\t\\\n\t\t  sizeof((self)->iv), (self)->iv,\t\\\n\t\t  (length), (dst), (src)))\n\n#define CFB8_DECRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cfb8_decrypt((void *) &(self)->ctx,\t\t\\\n\t\t  (nettle_cipher_func *) (f),\t\t\\\n\t\t  sizeof((self)->iv), (self)->iv,\t\\\n\t\t  (length), (dst), (src)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CFB_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/chacha-poly1305.h",
    "content": "/* chacha-poly1305.h\n\n   AEAD mechanism based on chacha and poly1305.\n   See draft-agl-tls-chacha20poly1305-04.\n\n   Copyright (C) 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CHACHA_POLY1305_H_INCLUDED\n#define NETTLE_CHACHA_POLY1305_H_INCLUDED\n\n#include \"chacha.h\"\n#include \"poly1305.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define chacha_poly1305_set_key nettle_chacha_poly1305_set_key\n#define chacha_poly1305_set_nonce nettle_chacha_poly1305_set_nonce\n#define chacha_poly1305_update nettle_chacha_poly1305_update\n#define chacha_poly1305_decrypt nettle_chacha_poly1305_decrypt\n#define chacha_poly1305_encrypt nettle_chacha_poly1305_encrypt\n#define chacha_poly1305_digest nettle_chacha_poly1305_digest\n\n#define CHACHA_POLY1305_BLOCK_SIZE 64\n/* FIXME: Any need for 128-bit variant? */\n#define CHACHA_POLY1305_KEY_SIZE 32\n#define CHACHA_POLY1305_NONCE_SIZE CHACHA_NONCE96_SIZE\n#define CHACHA_POLY1305_DIGEST_SIZE 16\n\nstruct chacha_poly1305_ctx\n{\n  struct chacha_ctx chacha;\n  struct poly1305_ctx poly1305;\n  union nettle_block16 s;\n  uint64_t auth_size;\n  uint64_t data_size;\n  /* poly1305 block */\n  uint8_t block[POLY1305_BLOCK_SIZE];\n  unsigned index;\n};\n\nvoid\nchacha_poly1305_set_key (struct chacha_poly1305_ctx *ctx,\n\t\t\t const uint8_t *key);\nvoid\nchacha_poly1305_set_nonce (struct chacha_poly1305_ctx *ctx,\n\t\t\t   const uint8_t *nonce);\n\nvoid\nchacha_poly1305_update (struct chacha_poly1305_ctx *ctx,\n\t\t\tsize_t length, const uint8_t *data);\n\nvoid\nchacha_poly1305_encrypt (struct chacha_poly1305_ctx *ctx,\n\t\t\t size_t length, uint8_t *dst, const uint8_t *src);\n\t\t\t \nvoid\nchacha_poly1305_decrypt (struct chacha_poly1305_ctx *ctx,\n\t\t\t size_t length, uint8_t *dst, const uint8_t *src);\n\t\t\t \nvoid\nchacha_poly1305_digest (struct chacha_poly1305_ctx *ctx,\n\t\t\tsize_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CHACHA_POLY1305_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/chacha.h",
    "content": "/* chacha.h\n\n   The ChaCha stream cipher.\n\n   Copyright (C) 2013 Joachim Strömbergson\n   Copyright (C) 2012 Simon Josefsson\n   Copyright (C) 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CHACHA_H_INCLUDED\n#define NETTLE_CHACHA_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define chacha_set_key nettle_chacha_set_key\n#define chacha_set_nonce nettle_chacha_set_nonce\n#define chacha_set_nonce96 nettle_chacha_set_nonce96\n#define chacha_set_counter nettle_chacha_set_counter\n#define chacha_set_counter32 nettle_chacha_set_counter32\n#define chacha_crypt nettle_chacha_crypt\n#define chacha_crypt32 nettle_chacha_crypt32\n\n/* Currently, only 256-bit keys are supported. */\n#define CHACHA_KEY_SIZE 32\n#define CHACHA_BLOCK_SIZE 64\n#define CHACHA_NONCE_SIZE 8\n#define CHACHA_NONCE96_SIZE 12\n#define CHACHA_COUNTER_SIZE 8\n#define CHACHA_COUNTER32_SIZE 4\n\n#define _CHACHA_STATE_LENGTH 16\n\nstruct chacha_ctx\n{\n  /* Indices 0-3 holds a constant (SIGMA or TAU).\n     Indices 4-11 holds the key.\n     Indices 12-13 holds the block counter.\n     Indices 14-15 holds the IV:\n\n     This creates the state matrix:\n     C C C C\n     K K K K\n     K K K K\n     B B I I\n  */\n  uint32_t state[_CHACHA_STATE_LENGTH];\n};\n\nvoid\nchacha_set_key(struct chacha_ctx *ctx, const uint8_t *key);\n\nvoid\nchacha_set_nonce(struct chacha_ctx *ctx, const uint8_t *nonce);\n\nvoid\nchacha_set_nonce96(struct chacha_ctx *ctx, const uint8_t *nonce);\n\nvoid\nchacha_set_counter(struct chacha_ctx *ctx, const uint8_t *counter);\n\nvoid\nchacha_set_counter32(struct chacha_ctx *ctx, const uint8_t *counter);\n\nvoid\nchacha_crypt(struct chacha_ctx *ctx, size_t length, \n             uint8_t *dst, const uint8_t *src);\n\nvoid\nchacha_crypt32(struct chacha_ctx *ctx, size_t length,\n\t       uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CHACHA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/cmac.h",
    "content": "/* cmac.h\n\n   CMAC mode, as specified in RFC4493\n\n   Copyright (C) 2017 Red Hat, Inc.\n\n   Contributed by Nikos Mavrogiannopoulos\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CMAC_H_INCLUDED\n#define NETTLE_CMAC_H_INCLUDED\n\n#include \"aes.h\"\n#include \"des.h\"\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define CMAC128_DIGEST_SIZE 16\n#define CMAC64_DIGEST_SIZE 8\n\n#define cmac128_set_key nettle_cmac128_set_key\n#define cmac128_init nettle_cmac128_init\n#define cmac128_update nettle_cmac128_update\n#define cmac128_digest nettle_cmac128_digest\n#define cmac_aes128_set_key nettle_cmac_aes128_set_key\n#define cmac_aes128_update nettle_cmac_aes128_update\n#define cmac_aes128_digest nettle_cmac_aes128_digest\n#define cmac_aes256_set_key nettle_cmac_aes256_set_key\n#define cmac_aes256_update nettle_cmac_aes256_update\n#define cmac_aes256_digest nettle_cmac_aes256_digest\n\n#define cmac64_set_key nettle_cmac64_set_key\n#define cmac64_init nettle_cmac64_init\n#define cmac64_update nettle_cmac64_update\n#define cmac64_digest nettle_cmac64_digest\n#define cmac_des3_set_key nettle_cmac_des3_set_key\n#define cmac_des3_update nettle_cmac_des3_update\n#define cmac_des3_digest nettle_cmac_des3_digest\n\nstruct cmac128_key\n{\n  union nettle_block16 K1;\n  union nettle_block16 K2;\n};\n\nstruct cmac128_ctx\n{\n  /* MAC state */\n  union nettle_block16 X;\n\n  /* Block buffer */\n  union nettle_block16 block;\n  size_t index;\n};\n\nstruct cmac64_key\n{\n  union nettle_block8 K1;\n  union nettle_block8 K2;\n};\n\nstruct cmac64_ctx\n{\n  /* MAC state */\n  union nettle_block8 X;\n\n  /* Block buffer */\n  union nettle_block8 block;\n  size_t index;\n};\n\nvoid\ncmac128_set_key(struct cmac128_key *key, const void *cipher,\n\t\tnettle_cipher_func *encrypt);\n\nvoid\ncmac128_init(struct cmac128_ctx *ctx);\n\nvoid\ncmac128_update(struct cmac128_ctx *ctx, const void *cipher,\n\t       nettle_cipher_func *encrypt,\n\t       size_t msg_len, const uint8_t *msg);\nvoid\ncmac128_digest(struct cmac128_ctx *ctx, const struct cmac128_key *key,\n\t       const void *cipher, nettle_cipher_func *encrypt,\n\t       unsigned length, uint8_t *digest);\n\n\n#define CMAC128_CTX(type) \\\n  { struct cmac128_key key; struct cmac128_ctx ctx; type cipher; }\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define CMAC128_SET_KEY(self, set_key, encrypt, cmac_key)\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    (set_key)(&(self)->cipher, (cmac_key));\t\t\t\\\n    if (0) (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\\\n\t\t     (uint8_t *) 0, (const uint8_t *) 0);\t\\\n    cmac128_set_key(&(self)->key, &(self)->cipher,\t\t\\\n\t\t    (nettle_cipher_func *) (encrypt));\t\t\\\n    cmac128_init(&(self)->ctx);\t\t\t\t\t\\\n  } while (0)\n\n#define CMAC128_UPDATE(self, encrypt, length, src)\t\t\\\n  (0 ? (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\\\n     : cmac128_update(&(self)->ctx, &(self)->cipher,\t\t\\\n\t\t      (nettle_cipher_func *)encrypt,\t\t\\\n\t\t      (length), (src)))\n\n#define CMAC128_DIGEST(self, encrypt, length, digest)\t\t\\\n  (0 ? (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\\\n     : cmac128_digest(&(self)->ctx, &(self)->key,\t\t\\\n\t\t      &(self)->cipher,\t\t\t\t\\\n\t\t      (nettle_cipher_func *) (encrypt),\t\t\\\n\t\t      (length), (digest)))\n\nvoid\ncmac64_set_key(struct cmac64_key *key, const void *cipher,\n\t\tnettle_cipher_func *encrypt);\n\nvoid\ncmac64_init(struct cmac64_ctx *ctx);\n\nvoid\ncmac64_update(struct cmac64_ctx *ctx, const void *cipher,\n\t       nettle_cipher_func *encrypt,\n\t       size_t msg_len, const uint8_t *msg);\n\nvoid\ncmac64_digest(struct cmac64_ctx *ctx, const struct cmac64_key *key,\n\t       const void *cipher, nettle_cipher_func *encrypt,\n\t       unsigned length, uint8_t *digest);\n\n\n#define CMAC64_CTX(type) \\\n  { struct cmac64_key key; struct cmac64_ctx ctx; type cipher; }\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define CMAC64_SET_KEY(self, set_key, encrypt, cmac_key)\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    (set_key)(&(self)->cipher, (cmac_key));\t\t\t\\\n    if (0) (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\\\n\t\t     (uint8_t *) 0, (const uint8_t *) 0);\t\\\n    cmac64_set_key(&(self)->key, &(self)->cipher,\t\t\\\n\t\t    (nettle_cipher_func *) (encrypt));\t\t\\\n    cmac64_init(&(self)->ctx);\t\t\t\t\t\\\n  } while (0)\n\n#define CMAC64_UPDATE(self, encrypt, length, src)\t\t\\\n  (0 ? (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\\\n     : cmac64_update(&(self)->ctx, &(self)->cipher,\t\t\\\n\t\t      (nettle_cipher_func *)encrypt,\t\t\\\n\t\t      (length), (src)))\n\n#define CMAC64_DIGEST(self, encrypt, length, digest)\t\t\\\n  (0 ? (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\\\n     : cmac64_digest(&(self)->ctx, &(self)->key,\t\t\\\n\t\t      &(self)->cipher,\t\t\t\t\\\n\t\t      (nettle_cipher_func *) (encrypt),\t\t\\\n\t\t      (length), (digest)))\n\nstruct cmac_aes128_ctx CMAC128_CTX(struct aes128_ctx);\n\nvoid\ncmac_aes128_set_key(struct cmac_aes128_ctx *ctx, const uint8_t *key);\n\nvoid\ncmac_aes128_update(struct cmac_aes128_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\ncmac_aes128_digest(struct cmac_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\nstruct cmac_aes256_ctx CMAC128_CTX(struct aes256_ctx);\n\nvoid\ncmac_aes256_set_key(struct cmac_aes256_ctx *ctx, const uint8_t *key);\n\nvoid\ncmac_aes256_update(struct cmac_aes256_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\ncmac_aes256_digest(struct cmac_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\nstruct cmac_des3_ctx CMAC64_CTX(struct des3_ctx);\n\nvoid\ncmac_des3_set_key(struct cmac_des3_ctx *ctx, const uint8_t *key);\n\nvoid\ncmac_des3_update(struct cmac_des3_ctx *ctx,\n\t\t size_t length, const uint8_t *data);\n\nvoid\ncmac_des3_digest(struct cmac_des3_ctx *ctx,\n\t\t size_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* CMAC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/ctr.h",
    "content": "/* ctr.h\n\n   Counter mode, using an network byte order incremented counter,\n   matching the testcases of NIST 800-38A.\n\n   Copyright (C) 2005 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CTR_H_INCLUDED\n#define NETTLE_CTR_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ctr_crypt nettle_ctr_crypt\n\nvoid\nctr_crypt(const void *ctx, nettle_cipher_func *f,\n\t  size_t block_size, uint8_t *ctr,\n\t  size_t length, uint8_t *dst,\n\t  const uint8_t *src);\n\n#define CTR_CTX(type, size) \\\n{ type ctx; uint8_t ctr[size]; }\n\n#define CTR_SET_COUNTER(ctx, data) \\\nmemcpy((ctx)->ctr, (data), sizeof((ctx)->ctr))\n\n#define CTR_CRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t  (uint8_t *) 0, (const uint8_t *) 0))\t\t\\\n   : ctr_crypt((void *) &(self)->ctx,\t\t\t\\\n\t       (nettle_cipher_func *) (f),\t\t\\\n\t       sizeof((self)->ctr), (self)->ctr,\t\\\n\t       (length), (dst), (src)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CTR_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/curve25519.h",
    "content": "/* curve25519.h\n\n   Copyright (C) 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CURVE25519_H\n#define NETTLE_CURVE25519_H\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define curve25519_mul_g nettle_curve25519_mul_g\n#define curve25519_mul nettle_curve25519_mul\n\n#define CURVE25519_SIZE 32\n\n/* Indicates that curve25519_mul conforms to RFC 7748. */\n#define NETTLE_CURVE25519_RFC7748 1\n\nvoid\ncurve25519_mul_g (uint8_t *q, const uint8_t *n);\n\nvoid\ncurve25519_mul (uint8_t *q, const uint8_t *n, const uint8_t *p);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CURVE25519_H */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/curve448.h",
    "content": "/* curve448.h\n\n   Copyright (C) 2017 Daiki Ueno\n   Copyright (C) 2017 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CURVE448_H\n#define NETTLE_CURVE448_H\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define curve448_mul_g nettle_curve448_mul_g\n#define curve448_mul nettle_curve448_mul\n\n#define CURVE448_SIZE 56\n\nvoid\ncurve448_mul_g (uint8_t *q, const uint8_t *n);\n\nvoid\ncurve448_mul (uint8_t *q, const uint8_t *n, const uint8_t *p);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CURVE448_H */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/des.h",
    "content": "/* des.h\n\n   The des block cipher. And triple des.\n\n   Copyright (C) 1992 Dana L. How\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/*\n *\tdes - fast & portable DES encryption & decryption.\n *\tCopyright (C) 1992  Dana L. How\n *\tPlease see the file `../lib/descore.README' for the complete copyright\n *\tnotice.\n *\n * Slightly edited by Niels Möller, 1997\n */\n\n#ifndef NETTLE_DES_H_INCLUDED\n#define NETTLE_DES_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define des_set_key nettle_des_set_key\n#define des_encrypt nettle_des_encrypt\n#define des_decrypt nettle_des_decrypt\n#define des_check_parity nettle_des_check_parity\n#define des_fix_parity nettle_des_fix_parity\n#define des3_set_key nettle_des3_set_key\n#define des3_encrypt nettle_des3_encrypt\n#define des3_decrypt nettle_des3_decrypt\n\n#define DES_KEY_SIZE 8\n#define DES_BLOCK_SIZE 8\n\n/* Expanded key length */\n#define _DES_KEY_LENGTH 32\n\nstruct des_ctx\n{\n  uint32_t key[_DES_KEY_LENGTH];\n};\n\n/* Returns 1 for good keys and 0 for weak keys. */\nint\ndes_set_key(struct des_ctx *ctx, const uint8_t *key);\n\nvoid\ndes_encrypt(const struct des_ctx *ctx,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\nvoid\ndes_decrypt(const struct des_ctx *ctx,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\nint\ndes_check_parity(size_t length, const uint8_t *key);\n\nvoid\ndes_fix_parity(size_t length, uint8_t *dst,\n\t       const uint8_t *src);\n\n#define DES3_KEY_SIZE 24\n#define DES3_BLOCK_SIZE DES_BLOCK_SIZE\n\nstruct des3_ctx\n{\n  struct des_ctx des[3];\n};\n\n\n/* Returns 1 for good keys and 0 for weak keys. */\nint\ndes3_set_key(struct des3_ctx *ctx, const uint8_t *key);\n\nvoid\ndes3_encrypt(const struct des3_ctx *ctx,\n\t     size_t length, uint8_t *dst,\n\t     const uint8_t *src);\nvoid\ndes3_decrypt(const struct des3_ctx *ctx,\n\t     size_t length, uint8_t *dst,\n\t     const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_DES_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/dsa-compat.h",
    "content": "/* dsa-compat.h\n\n   Old DSA publickey interface.\n\n   Copyright (C) 2002, 2013, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_DSA_COMPAT_H_INCLUDED\n#define NETTLE_DSA_COMPAT_H_INCLUDED\n\n#include \"dsa.h\"\n\n#include \"sha1.h\"\n#include \"sha2.h\"\n\n/* Name mangling */\n#define dsa_public_key_init nettle_dsa_public_key_init\n#define dsa_public_key_clear nettle_dsa_public_key_clear\n#define dsa_private_key_init nettle_dsa_private_key_init\n#define dsa_private_key_clear nettle_dsa_private_key_clear\n#define dsa_sha1_sign nettle_dsa_sha1_sign\n#define dsa_sha1_verify nettle_dsa_sha1_verify\n#define dsa_sha256_sign nettle_dsa_sha256_sign\n#define dsa_sha256_verify nettle_dsa_sha256_verify\n#define dsa_sha1_sign_digest nettle_dsa_sha1_sign_digest\n#define dsa_sha1_verify_digest nettle_dsa_sha1_verify_digest\n#define dsa_sha256_sign_digest nettle_dsa_sha256_sign_digest\n#define dsa_sha256_verify_digest nettle_dsa_sha256_verify_digest\n#define dsa_compat_generate_keypair nettle_dsa_compat_generate_keypair\n\n/* Switch meaning of dsa_generate_keypair */\n#undef dsa_generate_keypair\n#define dsa_generate_keypair nettle_dsa_compat_generate_keypair\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct dsa_public_key\n{\n  /* Same as struct dsa_params, but can't use that struct here without\n     breaking backwards compatibility. Layout must be identical, since\n     this is cast to a struct dsa_param pointer for calling _dsa_sign\n     and _dsa_verify */\n  mpz_t p;\n  mpz_t q;\n  mpz_t g;\n\n  /* Public value */\n  mpz_t y;\n};\n\nstruct dsa_private_key\n{\n  /* Unlike an rsa public key, private key operations will need both\n   * the private and the public information. */\n  mpz_t x;\n};\n\n/* Signing a message works as follows:\n *\n * Store the private key in a dsa_private_key struct.\n *\n * Initialize a hashing context, by callling\n *   sha1_init\n *\n * Hash the message by calling\n *   sha1_update\n *\n * Create the signature by calling\n *   dsa_sha1_sign\n *\n * The signature is represented as a struct dsa_signature. This call also\n * resets the hashing context.\n *\n * When done with the key and signature, don't forget to call\n * dsa_signature_clear.\n */\n\n/* Calls mpz_init to initialize bignum storage. */\nvoid\ndsa_public_key_init(struct dsa_public_key *key);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\ndsa_public_key_clear(struct dsa_public_key *key);\n\n\n/* Calls mpz_init to initialize bignum storage. */\nvoid\ndsa_private_key_init(struct dsa_private_key *key);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\ndsa_private_key_clear(struct dsa_private_key *key);\n\nint\ndsa_sha1_sign(const struct dsa_public_key *pub,\n\t      const struct dsa_private_key *key,\n\t      void *random_ctx, nettle_random_func *random,\n\t      struct sha1_ctx *hash,\n\t      struct dsa_signature *signature);\n\nint\ndsa_sha256_sign(const struct dsa_public_key *pub,\n\t\tconst struct dsa_private_key *key,\n\t\tvoid *random_ctx, nettle_random_func *random,\n\t\tstruct sha256_ctx *hash,\n\t\tstruct dsa_signature *signature);\n\nint\ndsa_sha1_verify(const struct dsa_public_key *key,\n\t\tstruct sha1_ctx *hash,\n\t\tconst struct dsa_signature *signature);\n\nint\ndsa_sha256_verify(const struct dsa_public_key *key,\n\t\t  struct sha256_ctx *hash,\n\t\t  const struct dsa_signature *signature);\n\nint\ndsa_sha1_sign_digest(const struct dsa_public_key *pub,\n\t\t     const struct dsa_private_key *key,\n\t\t     void *random_ctx, nettle_random_func *random,\n\t\t     const uint8_t *digest,\n\t\t     struct dsa_signature *signature);\nint\ndsa_sha256_sign_digest(const struct dsa_public_key *pub,\n\t\t       const struct dsa_private_key *key,\n\t\t       void *random_ctx, nettle_random_func *random,\n\t\t       const uint8_t *digest,\n\t\t       struct dsa_signature *signature);\n\nint\ndsa_sha1_verify_digest(const struct dsa_public_key *key,\n\t\t       const uint8_t *digest,\n\t\t       const struct dsa_signature *signature);\n\nint\ndsa_sha256_verify_digest(const struct dsa_public_key *key,\n\t\t\t const uint8_t *digest,\n\t\t\t const struct dsa_signature *signature);\n\n/* Key generation */\nint\ndsa_generate_keypair(struct dsa_public_key *pub,\n\t\t     struct dsa_private_key *key,\n\n\t\t     void *random_ctx, nettle_random_func *random,\n\t\t     void *progress_ctx, nettle_progress_func *progress,\n\t\t     unsigned p_bits, unsigned q_bits);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_DSA_COMPAT_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/dsa.h",
    "content": "/* dsa.h\n\n   The DSA publickey algorithm.\n\n   Copyright (C) 2002, 2013, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_DSA_H_INCLUDED\n#define NETTLE_DSA_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define dsa_params_init nettle_dsa_params_init\n#define dsa_params_clear nettle_dsa_params_clear\n#define dsa_signature_init nettle_dsa_signature_init\n#define dsa_signature_clear nettle_dsa_signature_clear\n#define dsa_sign nettle_dsa_sign\n#define dsa_verify nettle_dsa_verify\n#define dsa_generate_params nettle_dsa_generate_params\n#define dsa_generate_keypair nettle_dsa_generate_keypair\n#define dsa_signature_from_sexp nettle_dsa_signature_from_sexp\n#define dsa_keypair_to_sexp nettle_dsa_keypair_to_sexp\n#define dsa_keypair_from_sexp_alist nettle_dsa_keypair_from_sexp_alist\n#define dsa_sha1_keypair_from_sexp nettle_dsa_sha1_keypair_from_sexp\n#define dsa_sha256_keypair_from_sexp nettle_dsa_sha256_keypair_from_sexp\n#define dsa_params_from_der_iterator nettle_dsa_params_from_der_iterator\n#define dsa_public_key_from_der_iterator nettle_dsa_public_key_from_der_iterator\n#define dsa_openssl_private_key_from_der_iterator nettle_dsa_openssl_private_key_from_der_iterator \n#define dsa_openssl_private_key_from_der nettle_openssl_provate_key_from_der\n\n/* For FIPS approved parameters */\n#define DSA_SHA1_MIN_P_BITS 512\n#define DSA_SHA1_Q_OCTETS 20\n#define DSA_SHA1_Q_BITS 160\n\n#define DSA_SHA256_MIN_P_BITS 1024\n#define DSA_SHA256_Q_OCTETS 32\n#define DSA_SHA256_Q_BITS 256\n\nstruct dsa_params\n{  \n  /* Modulo */\n  mpz_t p;\n\n  /* Group order */\n  mpz_t q;\n\n  /* Generator */\n  mpz_t g;\n};\n\nvoid\ndsa_params_init (struct dsa_params *params);\n\nvoid\ndsa_params_clear (struct dsa_params *params);\n\nstruct dsa_signature\n{\n  mpz_t r;\n  mpz_t s;\n};\n\n/* Calls mpz_init to initialize bignum storage. */\nvoid\ndsa_signature_init(struct dsa_signature *signature);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\ndsa_signature_clear(struct dsa_signature *signature);\n\nint\ndsa_sign(const struct dsa_params *params,\n\t const mpz_t x,\n\t void *random_ctx, nettle_random_func *random,\n\t size_t digest_size,\n\t const uint8_t *digest,\n\t struct dsa_signature *signature);\n\nint\ndsa_verify(const struct dsa_params *params,\n\t   const mpz_t y,\n\t   size_t digest_size,\n\t   const uint8_t *digest,\n\t   const struct dsa_signature *signature);\n\n\n/* Key generation */\n\nint\ndsa_generate_params(struct dsa_params *params,\n\t\t    void *random_ctx, nettle_random_func *random,\n\t\t    void *progress_ctx, nettle_progress_func *progress,\n\t\t    unsigned p_bits, unsigned q_bits);\n\nvoid\ndsa_generate_keypair (const struct dsa_params *params,\n\t\t      mpz_t pub, mpz_t key,\n\t\t      void *random_ctx, nettle_random_func *random);\n\n/* Keys in sexp form. */\n\nstruct nettle_buffer;\n\n/* Generates a public-key expression if PRIV is NULL .*/\nint\ndsa_keypair_to_sexp(struct nettle_buffer *buffer,\n\t\t    const char *algorithm_name, /* NULL means \"dsa\" */\n\t\t    const struct dsa_params *params,\n\t\t    const mpz_t pub,\n\t\t    const mpz_t priv);\n\nstruct sexp_iterator;\n\nint\ndsa_signature_from_sexp(struct dsa_signature *rs,\n\t\t\tstruct sexp_iterator *i,\n\t\t\tunsigned q_bits);\n\nint\ndsa_keypair_from_sexp_alist(struct dsa_params *params,\n\t\t\t    mpz_t pub,\n\t\t\t    mpz_t priv,\n\t\t\t    unsigned p_max_bits,\n\t\t\t    unsigned q_bits,\n\t\t\t    struct sexp_iterator *i);\n\n/* If PRIV is NULL, expect a public-key expression. If PUB is NULL,\n * expect a private key expression and ignore the parts not needed for\n * the public key. */\n/* Keys must be initialized before calling this function, as usual. */\nint\ndsa_sha1_keypair_from_sexp(struct dsa_params *params,\n\t\t\t   mpz_t pub,\n\t\t\t   mpz_t priv,\n\t\t\t   unsigned p_max_bits,\n\t\t\t   size_t length, const uint8_t *expr);\n\nint\ndsa_sha256_keypair_from_sexp(struct dsa_params *params,\n\t\t\t     mpz_t pub,\n\t\t\t     mpz_t priv,\n\t\t\t     unsigned p_max_bits,\n\t\t\t     size_t length, const uint8_t *expr);\n\n/* Keys in X.509 andd OpenSSL format. */\nstruct asn1_der_iterator;\n\nint\ndsa_params_from_der_iterator(struct dsa_params *params,\n\t\t\t     unsigned max_bits, unsigned q_bits,\n\t\t\t     struct asn1_der_iterator *i);\n\nint\ndsa_public_key_from_der_iterator(const struct dsa_params *params,\n\t\t\t\t mpz_t pub,\n\t\t\t\t struct asn1_der_iterator *i);\n\nint\ndsa_openssl_private_key_from_der_iterator(struct dsa_params *params,\n\t\t\t\t\t  mpz_t pub,\n\t\t\t\t\t  mpz_t priv,\n\t\t\t\t\t  unsigned p_max_bits,\n\t\t\t\t\t  struct asn1_der_iterator *i);\n\nint\ndsa_openssl_private_key_from_der(struct dsa_params *params,\n\t\t\t\t mpz_t pub,\n\t\t\t\t mpz_t priv,\n\t\t\t\t unsigned p_max_bits,\n\t\t\t\t size_t length, const uint8_t *data);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_DSA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/eax.h",
    "content": "/* eax.h\n\n   EAX mode, see http://www.cs.ucdavis.edu/~rogaway/papers/eax.pdf\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_EAX_H_INCLUDED\n#define NETTLE_EAX_H_INCLUDED\n\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define eax_set_key nettle_eax_set_key\n#define eax_set_nonce nettle_eax_set_nonce\n#define eax_update nettle_eax_update\n#define eax_encrypt nettle_eax_encrypt\n#define eax_decrypt nettle_eax_decrypt\n#define eax_digest nettle_eax_digest\n\n#define eax_aes128_set_key nettle_eax_aes128_set_key\n#define eax_aes128_set_nonce nettle_eax_aes128_set_nonce\n#define eax_aes128_update nettle_eax_aes128_update\n#define eax_aes128_encrypt nettle_eax_aes128_encrypt\n#define eax_aes128_decrypt nettle_eax_aes128_decrypt\n#define eax_aes128_digest nettle_eax_aes128_digest\n\n/* Restricted to block ciphers with 128 bit block size. FIXME: Reflect\n   this in naming? */\n\n#define EAX_BLOCK_SIZE 16\n#define EAX_DIGEST_SIZE 16\n/* FIXME: Reasonable default? */\n#define EAX_IV_SIZE 16\n\n/* Values independent of message and nonce */\nstruct eax_key\n{\n  union nettle_block16 pad_block;\n  union nettle_block16 pad_partial;\n};\n\nstruct eax_ctx\n{\n  union nettle_block16 omac_nonce;\n  union nettle_block16 omac_data;\n  union nettle_block16 omac_message;\n  union nettle_block16 ctr;\n};\n\nvoid\neax_set_key (struct eax_key *key, const void *cipher, nettle_cipher_func *f);\n\nvoid\neax_set_nonce (struct eax_ctx *eax, const struct eax_key *key,\n\t       const void *cipher, nettle_cipher_func *f,\n\t       size_t nonce_length, const uint8_t *nonce);\n\nvoid\neax_update (struct eax_ctx *eax, const struct eax_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t data_length, const uint8_t *data);\n\nvoid\neax_encrypt (struct eax_ctx *eax, const struct eax_key *key,\n\t     const void *cipher, nettle_cipher_func *f,\n\t     size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\neax_decrypt (struct eax_ctx *eax, const struct eax_key *key,\n\t     const void *cipher, nettle_cipher_func *f,\n\t     size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\neax_digest (struct eax_ctx *eax, const struct eax_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *digest);\n\n/* Put the cipher last, to get cipher-independent offsets for the EAX\n * state. */\n#define EAX_CTX(type) \\\n  { struct eax_key key; struct eax_ctx eax; type cipher; }\n\n#define EAX_SET_KEY(ctx, set_key, encrypt, data)\t\t\t\\\n  do {\t\t\t\t\t\t\t\t\t\\\n    (set_key)(&(ctx)->cipher, (data));\t\t\t\t\t\\\n    if (0) (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t      (uint8_t *) 0, (const uint8_t *) 0);\t\t\\\n    eax_set_key (&(ctx)->key, &(ctx)->cipher, (nettle_cipher_func *) encrypt); \\\n  } while (0)\n\n#define EAX_SET_NONCE(ctx, encrypt, length, nonce)\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_set_nonce (&(ctx)->eax, &(ctx)->key,\t\t\t\\\n\t\t    &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t    (length), (nonce)))\n\n#define EAX_UPDATE(ctx, encrypt, length, data)\t\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_update (&(ctx)->eax, &(ctx)->key,\t\t\t\t\\\n\t\t &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t (length), (data)))\n\n#define EAX_ENCRYPT(ctx, encrypt, length, dst, src)\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_encrypt (&(ctx)->eax, &(ctx)->key,\t\t\t\t\\\n\t\t &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t  (length), (dst), (src)))\n\n#define EAX_DECRYPT(ctx, encrypt, length, dst, src)\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_decrypt (&(ctx)->eax, &(ctx)->key,\t\t\t\t\\\n\t\t &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t  (length), (dst), (src)))\n\n#define EAX_DIGEST(ctx, encrypt, length, digest)\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_digest (&(ctx)->eax, &(ctx)->key,\t\t\t\t\\\n\t\t &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t (length), (digest)))\n\nstruct eax_aes128_ctx EAX_CTX(struct aes128_ctx);\n\nvoid\neax_aes128_set_key(struct eax_aes128_ctx *ctx, const uint8_t *key);\n\nvoid\neax_aes128_set_nonce(struct eax_aes128_ctx *ctx,\n\t\t     size_t length, const uint8_t *iv);\n\nvoid\neax_aes128_update(struct eax_aes128_ctx *ctx,\n\t\t  size_t length, const uint8_t *data);\n\nvoid\neax_aes128_encrypt(struct eax_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\neax_aes128_decrypt(struct eax_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\neax_aes128_digest(struct eax_aes128_ctx *ctx, size_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_EAX_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/ecc-curve.h",
    "content": "/* ecc-curve.h\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */\n\n#ifndef NETTLE_ECC_CURVE_H_INCLUDED\n#define NETTLE_ECC_CURVE_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* The contents of this struct is internal. */\nstruct ecc_curve;\n\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_gost_gc256b(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_gost_gc512a(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_192r1(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_224r1(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_256r1(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_384r1(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_521r1(void);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ECC_CURVE_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/ecc.h",
    "content": "/* ecc.h\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */\n\n#ifndef NETTLE_ECC_H_INCLUDED\n#define NETTLE_ECC_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ecc_point_init nettle_ecc_point_init\n#define ecc_point_clear nettle_ecc_point_clear\n#define ecc_point_set nettle_ecc_point_set\n#define ecc_point_get nettle_ecc_point_get\n#define ecc_point_mul nettle_ecc_point_mul\n#define ecc_point_mul_g nettle_ecc_point_mul_g\n#define ecc_scalar_init nettle_ecc_scalar_init\n#define ecc_scalar_clear nettle_ecc_scalar_clear\n#define ecc_scalar_set nettle_ecc_scalar_set\n#define ecc_scalar_get nettle_ecc_scalar_get\n#define ecc_scalar_random nettle_ecc_scalar_random\n#define ecc_point_mul nettle_ecc_point_mul\n#define ecc_bit_size nettle_ecc_bit_size\n#define ecc_size nettle_ecc_size\n#define ecc_size_a nettle_ecc_size_a\n#define ecc_size_j nettle_ecc_size_j\n\nstruct ecc_curve;\n\n/* High level interface, for ECDSA, DH, etc */\n\n/* Represents a point on the ECC curve */\nstruct ecc_point\n{\n  const struct ecc_curve *ecc;\n  /* Allocated using the same allocation function as GMP. */\n  mp_limb_t *p;\n};\n\n/* Represents a non-zero scalar, an element of Z_q^*, where q is the\n   group order of the curve. */\nstruct ecc_scalar\n{\n  const struct ecc_curve *ecc;\n  /* Allocated using the same allocation function as GMP. */\n  mp_limb_t *p;\n};\n\nvoid\necc_point_init (struct ecc_point *p, const struct ecc_curve *ecc);\nvoid\necc_point_clear (struct ecc_point *p);\n\n/* Fails and returns zero if the point is not on the curve. */\nint\necc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y);\nvoid\necc_point_get (const struct ecc_point *p, mpz_t x, mpz_t y);\n\nvoid\necc_scalar_init (struct ecc_scalar *s, const struct ecc_curve *ecc);\nvoid\necc_scalar_clear (struct ecc_scalar *s);\n\n/* Fails and returns zero if the scalar is not in the proper range. */\nint\necc_scalar_set (struct ecc_scalar *s, const mpz_t z);\nvoid\necc_scalar_get (const struct ecc_scalar *s, mpz_t z);\n/* Generates a random scalar, suitable as an ECDSA private key or a\n   ECDH exponent. */\nvoid\necc_scalar_random (struct ecc_scalar *s,\n\t\t   void *random_ctx, nettle_random_func *random);\n\n/* Computes r = n p */\nvoid\necc_point_mul (struct ecc_point *r, const struct ecc_scalar *n,\n\t       const struct ecc_point *p);\n\n/* Computes r = n g */\nvoid\necc_point_mul_g (struct ecc_point *r, const struct ecc_scalar *n);\n\n\f\n/* Low-level interface */\n  \n/* Points on a curve are represented as arrays of mp_limb_t, with\n   curve-specific representation. For the secp curves, we use Jacobian\n   coordinates (possibly in Montgomery form for mod multiplication).\n   For curve25519 we use homogeneous coordinates on an equivalent\n   Edwards curve. The suffix \"_h\" denotes this internal\n   representation.\n   \n   Since we use additive notation for the groups, the infinity point\n   on the curve is denoted 0. The infinity point can be represented\n   with x = y = 0 in affine coordinates, and Z = 0 in Jacobian\n   coordinates. However, note that most of the ECC functions do *not*\n   support infinity as an input or output.\n*/\n\n/* Returns the bit size of a single coordinate (and of the prime p). */\nunsigned\necc_bit_size (const struct ecc_curve *ecc);\n\n/* Returns the size of a single coordinate. */\nmp_size_t\necc_size (const struct ecc_curve *ecc);\n\n/* Size of a point, using affine coordinates x, y. */\nmp_size_t\necc_size_a (const struct ecc_curve *ecc);\n\n/* Size of a point, using jacobian coordinates X, Y and Z. */\nmp_size_t\necc_size_j (const struct ecc_curve *ecc);\n\n/* FIXME: Define a generic ecc_dup, ecc_add, for any type of curve. Do\n   they need to handle infinity points? */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ECC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/ecdsa.h",
    "content": "/* ecdsa.h\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */\n\n#ifndef NETTLE_ECDSA_H_INCLUDED\n#define NETTLE_ECDSA_H_INCLUDED\n\n#include \"ecc.h\"\n#include \"dsa.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ecdsa_sign nettle_ecdsa_sign\n#define ecdsa_verify nettle_ecdsa_verify\n#define ecdsa_generate_keypair nettle_ecdsa_generate_keypair\n#define ecc_ecdsa_sign nettle_ecc_ecdsa_sign\n#define ecc_ecdsa_sign_itch nettle_ecc_ecdsa_sign_itch\n#define ecc_ecdsa_verify nettle_ecc_ecdsa_verify\n#define ecc_ecdsa_verify_itch nettle_ecc_ecdsa_verify_itch\n\n/* High level ECDSA functions.\n *\n * A public key is represented as a struct ecc_point, and a private\n * key as a struct ecc_scalar. */\nvoid\necdsa_sign (const struct ecc_scalar *key,\n\t    void *random_ctx, nettle_random_func *random,\n\t    size_t digest_length,\n\t    const uint8_t *digest,\n\t    struct dsa_signature *signature);\n\nint\necdsa_verify (const struct ecc_point *pub,\n\t      size_t length, const uint8_t *digest,\n\t      const struct dsa_signature *signature);\n\nvoid\necdsa_generate_keypair (struct ecc_point *pub,\n\t\t\tstruct ecc_scalar *key,\n\t\t\tvoid *random_ctx, nettle_random_func *random);\n\n/* Low-level ECDSA functions. */\nmp_size_t\necc_ecdsa_sign_itch (const struct ecc_curve *ecc);\n\nvoid\necc_ecdsa_sign (const struct ecc_curve *ecc,\n\t\tconst mp_limb_t *zp,\n\t\t/* Random nonce, must be invertible mod ecc group\n\t\t   order. */\n\t\tconst mp_limb_t *kp,\n\t\tsize_t length, const uint8_t *digest,\n\t\tmp_limb_t *rp, mp_limb_t *sp,\n\t\tmp_limb_t *scratch);\n\nmp_size_t\necc_ecdsa_verify_itch (const struct ecc_curve *ecc);\n\nint\necc_ecdsa_verify (const struct ecc_curve *ecc,\n\t\t  const mp_limb_t *pp, /* Public key */\n\t\t  size_t length, const uint8_t *digest,\n\t\t  const mp_limb_t *rp, const mp_limb_t *sp,\n\t\t  mp_limb_t *scratch);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ECDSA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/eddsa.h",
    "content": "/* eddsa.h\n\n   Copyright (C) 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_EDDSA_H\n#define NETTLE_EDDSA_H\n\n#include \"nettle-types.h\"\n\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ed25519_sha512_set_private_key nettle_ed25519_sha512_set_private_key\n#define ed25519_sha512_public_key nettle_ed25519_sha512_public_key\n#define ed25519_sha512_sign nettle_ed25519_sha512_sign\n#define ed25519_sha512_verify nettle_ed25519_sha512_verify\n#define ed448_shake256_public_key nettle_ed448_shake256_public_key\n#define ed448_shake256_sign nettle_ed448_shake256_sign\n#define ed448_shake256_verify nettle_ed448_shake256_verify\n\n#define ED25519_KEY_SIZE 32\n#define ED25519_SIGNATURE_SIZE 64\n\nvoid\ned25519_sha512_public_key (uint8_t *pub, const uint8_t *priv);\n\nvoid\ned25519_sha512_sign (const uint8_t *pub,\n\t\t     const uint8_t *priv,\t\t     \n\t\t     size_t length, const uint8_t *msg,\n\t\t     uint8_t *signature);\n\nint\ned25519_sha512_verify (const uint8_t *pub,\n\t\t       size_t length, const uint8_t *msg,\n\t\t       const uint8_t *signature);\n\n#define ED448_KEY_SIZE 57\n#define ED448_SIGNATURE_SIZE 114\n\nvoid\ned448_shake256_public_key (uint8_t *pub, const uint8_t *priv);\n\nvoid\ned448_shake256_sign (const uint8_t *pub,\n\t\t     const uint8_t *priv,\n\t\t     size_t length, const uint8_t *msg,\n\t\t     uint8_t *signature);\n\nint\ned448_shake256_verify (const uint8_t *pub,\n\t\t       size_t length, const uint8_t *msg,\n\t\t       const uint8_t *signature);\n\t\t\t   \n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_EDDSA_H */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/gcm.h",
    "content": "/* gcm.h\n\n   Galois counter mode, specified by NIST,\n   http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf\n\n   Copyright (C) 2011 Katholieke Universiteit Leuven\n   Copyright (C) 2011, 2014 Niels Möller\n\n   Contributed by Nikos Mavrogiannopoulos\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_GCM_H_INCLUDED\n#define NETTLE_GCM_H_INCLUDED\n\n#include \"aes.h\"\n#include \"camellia.h\"\n#include \"sm4.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define gcm_set_key nettle_gcm_set_key\n#define gcm_set_iv nettle_gcm_set_iv\n#define gcm_update nettle_gcm_update\n#define gcm_encrypt nettle_gcm_encrypt\n#define gcm_decrypt nettle_gcm_decrypt\n#define gcm_digest nettle_gcm_digest\n\n#define gcm_aes128_set_key nettle_gcm_aes128_set_key\n#define gcm_aes128_set_iv nettle_gcm_aes128_set_iv\n#define gcm_aes128_update nettle_gcm_aes128_update\n#define gcm_aes128_encrypt nettle_gcm_aes128_encrypt\n#define gcm_aes128_decrypt nettle_gcm_aes128_decrypt\n#define gcm_aes128_digest nettle_gcm_aes128_digest\n\n#define gcm_aes192_set_key nettle_gcm_aes192_set_key\n#define gcm_aes192_set_iv nettle_gcm_aes192_set_iv\n#define gcm_aes192_update nettle_gcm_aes192_update\n#define gcm_aes192_encrypt nettle_gcm_aes192_encrypt\n#define gcm_aes192_decrypt nettle_gcm_aes192_decrypt\n#define gcm_aes192_digest nettle_gcm_aes192_digest\n\n#define gcm_aes256_set_key nettle_gcm_aes256_set_key\n#define gcm_aes256_set_iv nettle_gcm_aes256_set_iv\n#define gcm_aes256_update nettle_gcm_aes256_update\n#define gcm_aes256_encrypt nettle_gcm_aes256_encrypt\n#define gcm_aes256_decrypt nettle_gcm_aes256_decrypt\n#define gcm_aes256_digest nettle_gcm_aes256_digest\n\n#define gcm_aes_set_key nettle_gcm_aes_set_key\n#define gcm_aes_set_iv nettle_gcm_aes_set_iv\n#define gcm_aes_update nettle_gcm_aes_update\n#define gcm_aes_encrypt nettle_gcm_aes_encrypt\n#define gcm_aes_decrypt nettle_gcm_aes_decrypt\n#define gcm_aes_digest nettle_gcm_aes_digest\n\n#define gcm_camellia128_set_key nettle_gcm_camellia128_set_key\n#define gcm_camellia128_set_iv nettle_gcm_camellia128_set_iv\n#define gcm_camellia128_update nettle_gcm_camellia128_update\n#define gcm_camellia128_encrypt nettle_gcm_camellia128_encrypt\n#define gcm_camellia128_decrypt nettle_gcm_camellia128_decrypt\n#define gcm_camellia128_digest nettle_gcm_camellia128_digest\n\n#define gcm_camellia256_set_key nettle_gcm_camellia256_set_key\n#define gcm_camellia256_set_iv nettle_gcm_camellia256_set_iv\n#define gcm_camellia256_update nettle_gcm_camellia256_update\n#define gcm_camellia256_encrypt nettle_gcm_camellia256_encrypt\n#define gcm_camellia256_decrypt nettle_gcm_camellia256_decrypt\n#define gcm_camellia256_digest nettle_gcm_camellia256_digest\n\n#define gcm_sm4_set_key nettle_gcm_sm4_set_key\n#define gcm_sm4_set_iv nettle_gcm_sm4_set_iv\n#define gcm_sm4_update nettle_gcm_sm4_update\n#define gcm_sm4_encrypt nettle_gcm_sm4_encrypt\n#define gcm_sm4_decrypt nettle_gcm_sm4_decrypt\n#define gcm_sm4_digest nettle_gcm_sm4_digest\n\n#define GCM_BLOCK_SIZE 16\n#define GCM_IV_SIZE (GCM_BLOCK_SIZE - 4)\n#define GCM_DIGEST_SIZE 16\n#define GCM_TABLE_BITS 8\n\n/* Hashing subkey */\nstruct gcm_key\n{\n  union nettle_block16 h[1 << GCM_TABLE_BITS];\n};\n\n/* Per-message state, depending on the iv */\nstruct gcm_ctx {\n  /* Original counter block */\n  union nettle_block16 iv;\n  /* Updated for each block. */\n  union nettle_block16 ctr;\n  /* Hashing state */\n  union nettle_block16 x;\n  uint64_t auth_size;\n  uint64_t data_size;\n};\n\nvoid\ngcm_set_key(struct gcm_key *key,\n\t    const void *cipher, nettle_cipher_func *f);\n\nvoid\ngcm_set_iv(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t   size_t length, const uint8_t *iv);\n\nvoid\ngcm_update(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t   size_t length, const uint8_t *data);\n\nvoid\ngcm_encrypt(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_decrypt(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_digest(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t   const void *cipher, nettle_cipher_func *f,\n\t   size_t length, uint8_t *digest);\n\n/* Convenience macrology (not sure how useful it is) */\n/* All-in-one context, with hash subkey, message state, and cipher. */\n#define GCM_CTX(type) \\\n  { struct gcm_key key; struct gcm_ctx gcm; type cipher; }\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define GCM_SET_KEY(ctx, set_key, encrypt, gcm_key)\t\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    (set_key)(&(ctx)->cipher, (gcm_key));\t\t\t\\\n    if (0) (encrypt)(&(ctx)->cipher, ~(size_t) 0,\t\t\\\n\t\t     (uint8_t *) 0, (const uint8_t *) 0);\t\\\n    gcm_set_key(&(ctx)->key, &(ctx)->cipher,\t\t\t\\\n\t\t(nettle_cipher_func *) (encrypt));\t\t\\\n  } while (0)\n\n#define GCM_SET_IV(ctx, length, data)\t\t\t\t\\\n  gcm_set_iv(&(ctx)->gcm, &(ctx)->key, (length), (data))\n\n#define GCM_UPDATE(ctx, length, data)\t\t\t\\\n  gcm_update(&(ctx)->gcm, &(ctx)->key, (length), (data))\n\n#define GCM_ENCRYPT(ctx, encrypt, length, dst, src)\t\t\t\\\n  (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n     : gcm_encrypt(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher,\t\t\\\n\t\t   (nettle_cipher_func *) (encrypt),\t\t\t\\\n\t\t   (length), (dst), (src)))\n\n#define GCM_DECRYPT(ctx, encrypt, length, dst, src)\t\t\t\\\n  (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n     : gcm_decrypt(&(ctx)->gcm,  &(ctx)->key, &(ctx)->cipher,\t\t\\\n\t\t   (nettle_cipher_func *) (encrypt),\t\t\t\\\n\t\t   (length), (dst), (src)))\n\n#define GCM_DIGEST(ctx, encrypt, length, digest)\t\t\t\\\n  (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n     : gcm_digest(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher,\t\t\\\n\t\t  (nettle_cipher_func *) (encrypt),\t\t\t\\\n\t\t  (length), (digest)))\n\nstruct gcm_aes128_ctx GCM_CTX(struct aes128_ctx);\n\nvoid\ngcm_aes128_set_key(struct gcm_aes128_ctx *ctx, const uint8_t *key);\n\n/* FIXME: Define _update and _set_iv as some kind of aliaes,\n   there's nothing aes-specific. */\nvoid\ngcm_aes128_update (struct gcm_aes128_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\nvoid\ngcm_aes128_set_iv (struct gcm_aes128_ctx *ctx,\n\t\t   size_t length, const uint8_t *iv);\n\nvoid\ngcm_aes128_encrypt(struct gcm_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes128_decrypt(struct gcm_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes128_digest(struct gcm_aes128_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\nstruct gcm_aes192_ctx GCM_CTX(struct aes192_ctx);\n\nvoid\ngcm_aes192_set_key(struct gcm_aes192_ctx *ctx, const uint8_t *key);\n\nvoid\ngcm_aes192_update (struct gcm_aes192_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\nvoid\ngcm_aes192_set_iv (struct gcm_aes192_ctx *ctx,\n\t\t   size_t length, const uint8_t *iv);\n\nvoid\ngcm_aes192_encrypt(struct gcm_aes192_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes192_decrypt(struct gcm_aes192_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes192_digest(struct gcm_aes192_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\nstruct gcm_aes256_ctx GCM_CTX(struct aes256_ctx);\n\nvoid\ngcm_aes256_set_key(struct gcm_aes256_ctx *ctx, const uint8_t *key);\n\nvoid\ngcm_aes256_update (struct gcm_aes256_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\nvoid\ngcm_aes256_set_iv (struct gcm_aes256_ctx *ctx,\n\t\t   size_t length, const uint8_t *iv);\n\nvoid\ngcm_aes256_encrypt(struct gcm_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes256_decrypt(struct gcm_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes256_digest(struct gcm_aes256_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\n/* Old deprecated aes interface, for backwards compatibility */\nstruct gcm_aes_ctx GCM_CTX(struct aes_ctx);\n\nvoid\ngcm_aes_set_key(struct gcm_aes_ctx *ctx,\n\t\tsize_t length, const uint8_t *key) _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_set_iv(struct gcm_aes_ctx *ctx,\n\t       size_t length, const uint8_t *iv) _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_update(struct gcm_aes_ctx *ctx,\n\t       size_t length, const uint8_t *data) _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_encrypt(struct gcm_aes_ctx *ctx,\n\t\tsize_t length, uint8_t *dst, const uint8_t *src)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_decrypt(struct gcm_aes_ctx *ctx,\n\t\tsize_t length, uint8_t *dst, const uint8_t *src)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_digest(struct gcm_aes_ctx *ctx, size_t length, uint8_t *digest)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\n\nstruct gcm_camellia128_ctx GCM_CTX(struct camellia128_ctx);\n\nvoid gcm_camellia128_set_key(struct gcm_camellia128_ctx *ctx,\n\t\t\t     const uint8_t *key);\nvoid gcm_camellia128_set_iv(struct gcm_camellia128_ctx *ctx,\n\t\t\t    size_t length, const uint8_t *iv);\nvoid gcm_camellia128_update(struct gcm_camellia128_ctx *ctx,\n\t\t\t    size_t length, const uint8_t *data);\nvoid gcm_camellia128_encrypt(struct gcm_camellia128_ctx *ctx,\n\t\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_camellia128_decrypt(struct gcm_camellia128_ctx *ctx,\n\t\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_camellia128_digest(struct gcm_camellia128_ctx *ctx,\n\t\t\t    size_t length, uint8_t *digest);\n\n\nstruct gcm_camellia256_ctx GCM_CTX(struct camellia256_ctx);\n\nvoid gcm_camellia256_set_key(struct gcm_camellia256_ctx *ctx,\n\t\t\t     const uint8_t *key);\nvoid gcm_camellia256_set_iv(struct gcm_camellia256_ctx *ctx,\n\t\t\t    size_t length, const uint8_t *iv);\nvoid gcm_camellia256_update(struct gcm_camellia256_ctx *ctx,\n\t\t\t    size_t length, const uint8_t *data);\nvoid gcm_camellia256_encrypt(struct gcm_camellia256_ctx *ctx,\n\t\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_camellia256_decrypt(struct gcm_camellia256_ctx *ctx,\n\t\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_camellia256_digest(struct gcm_camellia256_ctx *ctx,\n\t\t\t    size_t length, uint8_t *digest);\n\n\nstruct gcm_sm4_ctx GCM_CTX(struct sm4_ctx);\n\nvoid gcm_sm4_set_key(struct gcm_sm4_ctx *ctx, const uint8_t *key);\nvoid gcm_sm4_set_iv(struct gcm_sm4_ctx *ctx,\n\t\t    size_t length, const uint8_t *iv);\nvoid gcm_sm4_update(struct gcm_sm4_ctx *ctx,\n\t\t    size_t length, const uint8_t *data);\nvoid gcm_sm4_encrypt(struct gcm_sm4_ctx *ctx,\n\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_sm4_decrypt(struct gcm_sm4_ctx *ctx,\n\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_sm4_digest(struct gcm_sm4_ctx *ctx,\n\t\t    size_t length, uint8_t *digest);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_GCM_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/gostdsa.h",
    "content": "/* gostdsa.h\n\n   Copyright (C) 2015 Dmity Eremin-Solenikov\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_GOSTDSA_H_INCLUDED\n#define NETTLE_GOSTDSA_H_INCLUDED\n\n#include \"ecc.h\"\n#include \"dsa.h\"\n#include \"ecdsa.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define gostdsa_sign nettle_gostdsa_sign\n#define gostdsa_verify nettle_gostdsa_verify\n#define gostdsa_vko nettle_gostdsa_vko\n#define ecc_gostdsa_sign nettle_ecc_gostdsa_sign\n#define ecc_gostdsa_sign_itch nettle_ecc_gostdsa_sign_itch\n#define ecc_gostdsa_verify nettle_ecc_gostdsa_verify\n#define ecc_gostdsa_verify_itch nettle_ecc_gostdsa_verify_itch\n\n/* Just use ECDSA function for key generation */\n#define gostdsa_generate_keypair ecdsa_generate_keypair\n\n/* High level GOST DSA functions.\n *\n * A public key is represented as a struct ecc_point, and a private\n * key as a struct ecc_scalar. */\nvoid\ngostdsa_sign (const struct ecc_scalar *key,\n\t      void *random_ctx, nettle_random_func *random,\n\t      size_t digest_length,\n\t      const uint8_t *digest,\n\t      struct dsa_signature *signature);\n\nint\ngostdsa_verify (const struct ecc_point *pub,\n\t        size_t length, const uint8_t *digest,\n\t        const struct dsa_signature *signature);\n\nvoid\ngostdsa_vko (const struct ecc_scalar *key,\n\t     const struct ecc_point *pub,\n\t     size_t ukm_length, const uint8_t *ukm,\n\t     uint8_t *out);\n\n/* Low-level GOSTDSA functions. */\nmp_size_t\necc_gostdsa_sign_itch (const struct ecc_curve *ecc);\n\nvoid\necc_gostdsa_sign (const struct ecc_curve *ecc,\n\t\tconst mp_limb_t *zp,\n\t\t/* Random nonce, must be invertible mod ecc group\n\t\t   order. */\n\t\tconst mp_limb_t *kp,\n\t\tsize_t length, const uint8_t *digest,\n\t\tmp_limb_t *rp, mp_limb_t *sp,\n\t\tmp_limb_t *scratch);\n\nmp_size_t\necc_gostdsa_verify_itch (const struct ecc_curve *ecc);\n\nint\necc_gostdsa_verify (const struct ecc_curve *ecc,\n\t\t  const mp_limb_t *pp, /* Public key */\n\t\t  size_t length, const uint8_t *digest,\n\t\t  const mp_limb_t *rp, const mp_limb_t *sp,\n\t\t  mp_limb_t *scratch);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_GOSTDSA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/gosthash94.h",
    "content": "/* gosthash94.h\n\n   The GOST R 34.11-94 hash function, described in RFC 5831.\n\n   Copyright (C) 2012 Nikos Mavrogiannopoulos, Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Based on rhash gost.h. */\n\n/* Copyright: 2009-2012 Aleksey Kravchenko <rhash.admin@gmail.com>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/*\n * Ported to nettle by Nikos Mavrogiannopoulos.\n */\n\n#ifndef NETTLE_GOSTHASH94_H_INCLUDED\n#define NETTLE_GOSTHASH94_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define gosthash94_init nettle_gosthash94_init\n#define gosthash94_update nettle_gosthash94_update\n#define gosthash94_digest nettle_gosthash94_digest\n\n#define gosthash94cp_update nettle_gosthash94cp_update\n#define gosthash94cp_digest nettle_gosthash94cp_digest\n\n#define GOSTHASH94_BLOCK_SIZE 32\n#define GOSTHASH94_DIGEST_SIZE 32\n/* For backwards compatibility */\n#define GOSTHASH94_DATA_SIZE GOSTHASH94_BLOCK_SIZE\n\n#define GOSTHASH94CP_BLOCK_SIZE GOSTHASH94_BLOCK_SIZE\n#define GOSTHASH94CP_DIGEST_SIZE GOSTHASH94_DIGEST_SIZE\n\nstruct gosthash94_ctx\n{\n  uint32_t hash[8]; /* algorithm 256-bit state */\n  uint32_t sum[8];  /* sum of processed message blocks */\n  uint64_t count;               /* Block count */\n  unsigned index;               /* Into buffer */\n  uint8_t block[GOSTHASH94_BLOCK_SIZE]; /* 256-bit buffer for leftovers */\n};\n#define gosthash94cp_ctx gosthash94_ctx\n\nvoid gosthash94_init(struct gosthash94_ctx *ctx);\nvoid gosthash94_update(struct gosthash94_ctx *ctx,\n\t\t       size_t length, const uint8_t *msg);\nvoid gosthash94_digest(struct gosthash94_ctx *ctx,\n\t\t       size_t length, uint8_t *result);\n\n#define gosthash94cp_init gosthash94_init\nvoid gosthash94cp_update(struct gosthash94_ctx *ctx,\n\t\t\t size_t length, const uint8_t *msg);\nvoid gosthash94cp_digest(struct gosthash94_ctx *ctx,\n\t\t\t size_t length, uint8_t *result);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_GOSTHASH94_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/hkdf.h",
    "content": "/* hkdf.h\n\n   TLS PRF code (RFC-5246, RFC-2246).\n\n   Copyright (C) 2017 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_HKDF_H_INCLUDED\n#define NETTLE_HKDF_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define hkdf_extract nettle_hkdf_extract\n#define hkdf_expand nettle_hkdf_expand\n\nvoid\nhkdf_extract(void *mac_ctx,\n\t     nettle_hash_update_func *update,\n\t     nettle_hash_digest_func *digest,\n\t     size_t digest_size,\n\t     size_t secret_size, const uint8_t *secret,\n\t     uint8_t *dst);\n\nvoid\nhkdf_expand(void *mac_ctx,\n\t    nettle_hash_update_func *update,\n\t    nettle_hash_digest_func *digest,\n\t    size_t digest_size,\n\t    size_t info_size, const uint8_t *info,\n\t    size_t length, uint8_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_HKDF_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/hmac.h",
    "content": "/* hmac.h\n\n   HMAC message authentication code (RFC-2104).\n\n   Copyright (C) 2001, 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_HMAC_H_INCLUDED\n#define NETTLE_HMAC_H_INCLUDED\n\n#include \"nettle-meta.h\"\n\n#include \"gosthash94.h\"\n#include \"md5.h\"\n#include \"ripemd160.h\"\n#include \"sha1.h\"\n#include \"sha2.h\"\n#include \"streebog.h\"\n#include \"sm3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define hmac_set_key nettle_hmac_set_key\n#define hmac_update nettle_hmac_update\n#define hmac_digest nettle_hmac_digest\n#define hmac_md5_set_key nettle_hmac_md5_set_key\n#define hmac_md5_update nettle_hmac_md5_update\n#define hmac_md5_digest nettle_hmac_md5_digest\n#define hmac_ripemd160_set_key nettle_hmac_ripemd160_set_key\n#define hmac_ripemd160_update nettle_hmac_ripemd160_update\n#define hmac_ripemd160_digest nettle_hmac_ripemd160_digest\n#define hmac_sha1_set_key nettle_hmac_sha1_set_key\n#define hmac_sha1_update nettle_hmac_sha1_update\n#define hmac_sha1_digest nettle_hmac_sha1_digest\n#define hmac_sha224_set_key nettle_hmac_sha224_set_key\n#define hmac_sha224_digest nettle_hmac_sha224_digest\n#define hmac_sha256_set_key nettle_hmac_sha256_set_key\n#define hmac_sha256_update nettle_hmac_sha256_update\n#define hmac_sha256_digest nettle_hmac_sha256_digest\n#define hmac_sha384_set_key nettle_hmac_sha384_set_key\n#define hmac_sha384_digest nettle_hmac_sha384_digest\n#define hmac_sha512_set_key nettle_hmac_sha512_set_key\n#define hmac_sha512_update nettle_hmac_sha512_update\n#define hmac_sha512_digest nettle_hmac_sha512_digest\n#define hmac_gosthash94_set_key nettle_hmac_gosthash94_set_key\n#define hmac_gosthash94_update nettle_hmac_gosthash94_update\n#define hmac_gosthash94_digest nettle_hmac_gosthash94_digest\n#define hmac_gosthash94cp_set_key nettle_hmac_gosthash94cp_set_key\n#define hmac_gosthash94cp_update nettle_hmac_gosthash94cp_update\n#define hmac_gosthash94cp_digest nettle_hmac_gosthash94cp_digest\n#define hmac_streebog256_set_key nettle_hmac_streebog256_set_key\n#define hmac_streebog256_digest nettle_hmac_streebog256_digest\n#define hmac_streebog512_set_key nettle_hmac_streebog512_set_key\n#define hmac_streebog512_update nettle_hmac_streebog512_update\n#define hmac_streebog512_digest nettle_hmac_streebog512_digest\n#define hmac_sm3_set_key nettle_hmac_sm3_set_key\n#define hmac_sm3_update nettle_hmac_sm3_update\n#define hmac_sm3_digest nettle_hmac_sm3_digest\n\nvoid\nhmac_set_key(void *outer, void *inner, void *state,\n\t     const struct nettle_hash *hash,\n\t     size_t length, const uint8_t *key);\n\n/* This function is not strictly needed, it's s just the same as the\n * hash update function. */\nvoid\nhmac_update(void *state,\n\t    const struct nettle_hash *hash,\n\t    size_t length, const uint8_t *data);\n\nvoid\nhmac_digest(const void *outer, const void *inner, void *state,\n\t    const struct nettle_hash *hash,\n\t    size_t length, uint8_t *digest);\n\n\n#define HMAC_CTX(type) \\\n{ type outer; type inner; type state; }\n\n#define HMAC_SET_KEY(ctx, hash, length, key)\t\t\t\\\n  hmac_set_key( &(ctx)->outer, &(ctx)->inner, &(ctx)->state,\t\\\n                (hash), (length), (key) )\n\n#define HMAC_DIGEST(ctx, hash, length, digest)\t\t\t\\\n  hmac_digest( &(ctx)->outer, &(ctx)->inner, &(ctx)->state,\t\\\n               (hash), (length), (digest) )\n\n/* HMAC using specific hash functions */\n\n/* hmac-md5 */\nstruct hmac_md5_ctx HMAC_CTX(struct md5_ctx);\n\nvoid\nhmac_md5_set_key(struct hmac_md5_ctx *ctx,\n\t\t size_t key_length, const uint8_t *key);\n\nvoid\nhmac_md5_update(struct hmac_md5_ctx *ctx,\n\t\tsize_t length, const uint8_t *data);\n\nvoid\nhmac_md5_digest(struct hmac_md5_ctx *ctx,\n\t\tsize_t length, uint8_t *digest);\n\n\n/* hmac-ripemd160 */\nstruct hmac_ripemd160_ctx HMAC_CTX(struct ripemd160_ctx);\n\nvoid\nhmac_ripemd160_set_key(struct hmac_ripemd160_ctx *ctx,\n\t\t       size_t key_length, const uint8_t *key);\n\nvoid\nhmac_ripemd160_update(struct hmac_ripemd160_ctx *ctx,\n\t\t      size_t length, const uint8_t *data);\n\nvoid\nhmac_ripemd160_digest(struct hmac_ripemd160_ctx *ctx,\n\t\t      size_t length, uint8_t *digest);\n\n\n/* hmac-sha1 */\nstruct hmac_sha1_ctx HMAC_CTX(struct sha1_ctx);\n\nvoid\nhmac_sha1_set_key(struct hmac_sha1_ctx *ctx,\n\t\t  size_t key_length, const uint8_t *key);\n\nvoid\nhmac_sha1_update(struct hmac_sha1_ctx *ctx,\n\t\t size_t length, const uint8_t *data);\n\nvoid\nhmac_sha1_digest(struct hmac_sha1_ctx *ctx,\n\t\t size_t length, uint8_t *digest);\n\n/* hmac-sha256 */\nstruct hmac_sha256_ctx HMAC_CTX(struct sha256_ctx);\n\nvoid\nhmac_sha256_set_key(struct hmac_sha256_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\nvoid\nhmac_sha256_update(struct hmac_sha256_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nhmac_sha256_digest(struct hmac_sha256_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-sha224 */\n#define hmac_sha224_ctx hmac_sha256_ctx\n\nvoid\nhmac_sha224_set_key(struct hmac_sha224_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\n#define hmac_sha224_update nettle_hmac_sha256_update\n\nvoid\nhmac_sha224_digest(struct hmac_sha224_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-sha512 */\nstruct hmac_sha512_ctx HMAC_CTX(struct sha512_ctx);\n\nvoid\nhmac_sha512_set_key(struct hmac_sha512_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\nvoid\nhmac_sha512_update(struct hmac_sha512_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nhmac_sha512_digest(struct hmac_sha512_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-sha384 */\n#define hmac_sha384_ctx hmac_sha512_ctx\n\nvoid\nhmac_sha384_set_key(struct hmac_sha512_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\n#define hmac_sha384_update nettle_hmac_sha512_update\n\nvoid\nhmac_sha384_digest(struct hmac_sha512_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-gosthash94 */\nstruct hmac_gosthash94_ctx HMAC_CTX(struct gosthash94_ctx);\n\nvoid\nhmac_gosthash94_set_key(struct hmac_gosthash94_ctx *ctx,\n\t\t\tsize_t key_length, const uint8_t *key);\n\nvoid\nhmac_gosthash94_update(struct hmac_gosthash94_ctx *ctx,\n\t\t       size_t length, const uint8_t *data);\n\n  void\nhmac_gosthash94_digest(struct hmac_gosthash94_ctx *ctx,\n\t\t       size_t length, uint8_t *digest);\n\nstruct hmac_gosthash94cp_ctx HMAC_CTX(struct gosthash94cp_ctx);\n\nvoid\nhmac_gosthash94cp_set_key(struct hmac_gosthash94cp_ctx *ctx,\n\t\t\t  size_t key_length, const uint8_t *key);\n\nvoid\nhmac_gosthash94cp_update(struct hmac_gosthash94cp_ctx *ctx,\n\t\t\t size_t length, const uint8_t *data);\n\nvoid\nhmac_gosthash94cp_digest(struct hmac_gosthash94cp_ctx *ctx,\n\t\t\t size_t length, uint8_t *digest);\n\n\n/* hmac-streebog */\nstruct hmac_streebog512_ctx HMAC_CTX(struct streebog512_ctx);\n\nvoid\nhmac_streebog512_set_key(struct hmac_streebog512_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\nvoid\nhmac_streebog512_update(struct hmac_streebog512_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nhmac_streebog512_digest(struct hmac_streebog512_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n#define hmac_streebog256_ctx hmac_streebog512_ctx\n\nvoid\nhmac_streebog256_set_key(struct hmac_streebog256_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\n#define hmac_streebog256_update hmac_streebog512_update\n\nvoid\nhmac_streebog256_digest(struct hmac_streebog256_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-sm3 */\nstruct hmac_sm3_ctx HMAC_CTX(struct sm3_ctx);\n\nvoid\nhmac_sm3_set_key(struct hmac_sm3_ctx *ctx,\n\t\t size_t key_length, const uint8_t *key);\n\nvoid\nhmac_sm3_update(struct hmac_sm3_ctx *ctx,\n\t\tsize_t length, const uint8_t *data);\n\nvoid\nhmac_sm3_digest(struct hmac_sm3_ctx *ctx,\n\t\tsize_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_HMAC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/knuth-lfib.h",
    "content": "/* knuth-lfib.h\n\n   The \"lagged fibonacci\" pseudorandomness generator, described in\n   Knuth, TAoCP, 3.6\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* NOTE: This generator is totally inappropriate for cryptographic\n * applications. It is useful for generating deterministic but\n * random-looking test data, and is used by the Nettle testsuite. */\n#ifndef NETTLE_KNUTH_LFIB_H_INCLUDED\n#define NETTLE_KNUTH_LFIB_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define knuth_lfib_init nettle_knuth_lfib_init\n#define knuth_lfib_get nettle_knuth_lfib_get\n#define knuth_lfib_get_array nettle_knuth_lfib_get_array\n#define knuth_lfib_random nettle_knuth_lfib_random\n\n#define _KNUTH_LFIB_KK 100\n\nstruct knuth_lfib_ctx\n{\n  uint32_t x[_KNUTH_LFIB_KK];\n  unsigned index;\n};\n\nvoid\nknuth_lfib_init(struct knuth_lfib_ctx *ctx, uint32_t seed);\n\n/* Get's a single number in the range 0 ... 2^30-1 */\nuint32_t\nknuth_lfib_get(struct knuth_lfib_ctx *ctx);\n\n/* Get an array of numbers */\nvoid\nknuth_lfib_get_array(struct knuth_lfib_ctx *ctx,\n\t\t     size_t n, uint32_t *a);\n\n/* Get an array of octets. */\nvoid\nknuth_lfib_random(struct knuth_lfib_ctx *ctx,\n\t\t  size_t n, uint8_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_KNUTH_LFIB_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/macros.h",
    "content": "/* macros.h\n\n   Copyright (C) 2001, 2010 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_MACROS_H_INCLUDED\n#define NETTLE_MACROS_H_INCLUDED\n\n/* Reads a 64-bit integer, in network, big-endian, byte order */\n#define READ_UINT64(p)\t\t\t\t\\\n(  (((uint64_t) (p)[0]) << 56)\t\t\t\\\n | (((uint64_t) (p)[1]) << 48)\t\t\t\\\n | (((uint64_t) (p)[2]) << 40)\t\t\t\\\n | (((uint64_t) (p)[3]) << 32)\t\t\t\\\n | (((uint64_t) (p)[4]) << 24)\t\t\t\\\n | (((uint64_t) (p)[5]) << 16)\t\t\t\\\n | (((uint64_t) (p)[6]) << 8)\t\t\t\\\n |  ((uint64_t) (p)[7]))\n\n#define WRITE_UINT64(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[0] = ((i) >> 56) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 48) & 0xff;\t\t\t\\\n  (p)[2] = ((i) >> 40) & 0xff;\t\t\t\\\n  (p)[3] = ((i) >> 32) & 0xff;\t\t\t\\\n  (p)[4] = ((i) >> 24) & 0xff;\t\t\t\\\n  (p)[5] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[6] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[7] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n/* Reads a 32-bit integer, in network, big-endian, byte order */\n#define READ_UINT32(p)\t\t\t\t\\\n(  (((uint32_t) (p)[0]) << 24)\t\t\t\\\n | (((uint32_t) (p)[1]) << 16)\t\t\t\\\n | (((uint32_t) (p)[2]) << 8)\t\t\t\\\n |  ((uint32_t) (p)[3]))\n\n#define WRITE_UINT32(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[0] = ((i) >> 24) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[2] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[3] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n/* Analogous macros, for 24 and 16 bit numbers */\n#define READ_UINT24(p)\t\t\t\t\\\n(  (((uint32_t) (p)[0]) << 16)\t\t\t\\\n | (((uint32_t) (p)[1]) << 8)\t\t\t\\\n |  ((uint32_t) (p)[2]))\n\n#define WRITE_UINT24(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[0] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[2] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n#define READ_UINT16(p)\t\t\t\t\\\n(  (((uint32_t) (p)[0]) << 8)\t\t\t\\\n |  ((uint32_t) (p)[1]))\n\n#define WRITE_UINT16(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[0] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[1] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n/* And the other, little-endian, byteorder */\n#define LE_READ_UINT64(p)\t\t\t\\\n(  (((uint64_t) (p)[7]) << 56)\t\t\t\\\n | (((uint64_t) (p)[6]) << 48)\t\t\t\\\n | (((uint64_t) (p)[5]) << 40)\t\t\t\\\n | (((uint64_t) (p)[4]) << 32)\t\t\t\\\n | (((uint64_t) (p)[3]) << 24)\t\t\t\\\n | (((uint64_t) (p)[2]) << 16)\t\t\t\\\n | (((uint64_t) (p)[1]) << 8)\t\t\t\\\n |  ((uint64_t) (p)[0]))\n\n#define LE_WRITE_UINT64(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[7] = ((i) >> 56) & 0xff;\t\t\t\\\n  (p)[6] = ((i) >> 48) & 0xff;\t\t\t\\\n  (p)[5] = ((i) >> 40) & 0xff;\t\t\t\\\n  (p)[4] = ((i) >> 32) & 0xff;\t\t\t\\\n  (p)[3] = ((i) >> 24) & 0xff;\t\t\t\\\n  (p)[2] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[0] = (i) & 0xff;\t\t\t\t\\\n} while (0)\n\n#define LE_READ_UINT32(p)\t\t\t\\\n(  (((uint32_t) (p)[3]) << 24)\t\t\t\\\n | (((uint32_t) (p)[2]) << 16)\t\t\t\\\n | (((uint32_t) (p)[1]) << 8)\t\t\t\\\n |  ((uint32_t) (p)[0]))\n\n#define LE_WRITE_UINT32(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[3] = ((i) >> 24) & 0xff;\t\t\t\\\n  (p)[2] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[0] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n/* Analogous macros, for 16 bit numbers */\n#define LE_READ_UINT16(p)\t\t\t\\\n  (  (((uint32_t) (p)[1]) << 8)\t\t\t\\\n     |  ((uint32_t) (p)[0]))\n\n#define LE_WRITE_UINT16(p, i)\t\t\t\\\n  do {\t\t\t\t\t\t\\\n    (p)[1] = ((i) >> 8) & 0xff;\t\t\t\\\n    (p)[0] = (i) & 0xff;\t\t\t\\\n  } while(0)\n\n/* Macro to make it easier to loop over several blocks. */\n#define FOR_BLOCKS(length, dst, src, blocksize)\t\\\n  assert( !((length) % (blocksize)));           \\\n  for (; (length); ((length) -= (blocksize),\t\\\n\t\t  (dst) += (blocksize),\t\t\\\n\t\t  (src) += (blocksize)) )\n\n/* The masking of the right shift is needed to allow n == 0 (using\n   just 32 - n and 64 - n results in undefined behaviour). Most uses\n   of these macros use a constant and non-zero rotation count. */\n#define ROTL32(n,x) (((x)<<(n)) | ((x)>>((-(n)&31))))\n\n#define ROTL64(n,x) (((x)<<(n)) | ((x)>>((-(n))&63)))\n\n/* Requires that size > 0 */\n#define INCREMENT(size, ctr)\t\t\t\\\n  do {\t\t\t\t\t\t\\\n    unsigned increment_i = (size) - 1;\t\t\\\n    if (++(ctr)[increment_i] == 0)\t\t\\\n      while (increment_i > 0\t\t\t\\\n\t     && ++(ctr)[--increment_i] == 0 )\t\\\n\t;\t\t\t\t\t\\\n  } while (0)\n\n\n/* Helper macro for Merkle-Damgård hash functions. Assumes the context\n   structs includes the following fields:\n\n     uint8_t block[...];\t\t// Buffer holding one block\n     unsigned int index;\t\t// Index into block\n*/\n\n/* Currently used by sha512 (and sha384) only. */\n#define MD_INCR(ctx) ((ctx)->count_high += !++(ctx)->count_low)\n\n/* Takes the compression function f as argument. NOTE: also clobbers\n   length and data. */\n#define MD_UPDATE(ctx, length, data, f, incr)\t\t\t\t\\\n  do {\t\t\t\t\t\t\t\t\t\\\n    if ((ctx)->index)\t\t\t\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\t\\\n\t/* Try to fill partial block */\t\t\t\t\t\\\n\tunsigned __md_left = sizeof((ctx)->block) - (ctx)->index;\t\\\n\tif ((length) < __md_left)\t\t\t\t\t\\\n\t  {\t\t\t\t\t\t\t\t\\\n\t    memcpy((ctx)->block + (ctx)->index, (data), (length));\t\\\n\t    (ctx)->index += (length);\t\t\t\t\t\\\n\t    goto __md_done; /* Finished */\t\t\t\t\\\n\t  }\t\t\t\t\t\t\t\t\\\n\telse\t\t\t\t\t\t\t\t\\\n\t  {\t\t\t\t\t\t\t\t\\\n\t    memcpy((ctx)->block + (ctx)->index, (data), __md_left);\t\\\n\t\t\t\t\t\t\t\t\t\\\n\t    f((ctx), (ctx)->block);\t\t\t\t\t\\\n\t    (incr);\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n\t    (data) += __md_left;\t\t\t\t\t\\\n\t    (length) -= __md_left;\t\t\t\t\t\\\n\t  }\t\t\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\t\\\n    while ((length) >= sizeof((ctx)->block))\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\t\\\n\tf((ctx), (data));\t\t\t\t\t\t\\\n\t(incr);\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n\t(data) += sizeof((ctx)->block);\t\t\t\t\t\\\n\t(length) -= sizeof((ctx)->block);\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\t\\\n    memcpy ((ctx)->block, (data), (length));\t\t\t\t\\\n    (ctx)->index = (length);\t\t\t\t\t\t\\\n  __md_done:\t\t\t\t\t\t\t\t\\\n    ;\t\t\t\t\t\t\t\t\t\\\n  } while (0)\n\n/* Pads the block to a block boundary with the bit pattern 1 0*,\n   leaving size octets for the length field at the end. If needed,\n   compresses the block and starts a new one. */\n#define MD_PAD(ctx, size, f)\t\t\t\t\t\t\\\n  do {\t\t\t\t\t\t\t\t\t\\\n    unsigned __md_i;\t\t\t\t\t\t\t\\\n    __md_i = (ctx)->index;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n    /* Set the first char of padding to 0x80. This is safe since there\t\\\n       is always at least one byte free */\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n    assert(__md_i < sizeof((ctx)->block));\t\t\t\t\\\n    (ctx)->block[__md_i++] = 0x80;\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n    if (__md_i > (sizeof((ctx)->block) - (size)))\t\t\t\\\n      { /* No room for length in this block. Process it and\t\t\\\n\t   pad with another one */\t\t\t\t\t\\\n\tmemset((ctx)->block + __md_i, 0, sizeof((ctx)->block) - __md_i); \\\n\t\t\t\t\t\t\t\t\t\\\n\tf((ctx), (ctx)->block);\t\t\t\t\t\t\\\n\t__md_i = 0;\t\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\t\\\n    memset((ctx)->block + __md_i, 0,\t\t\t\t\t\\\n\t   sizeof((ctx)->block) - (size) - __md_i);\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n  } while (0)\n\n#endif /* NETTLE_MACROS_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/md2.h",
    "content": "/* md2.h\n\n   The MD2 hash function, described in RFC 1319.\n\n   Copyright (C) 2003 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_MD2_H_INCLUDED\n#define NETTLE_MD2_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define md2_init nettle_md2_init\n#define md2_update nettle_md2_update\n#define md2_digest nettle_md2_digest\n\n#define MD2_DIGEST_SIZE 16\n#define MD2_BLOCK_SIZE 16\n/* For backwards compatibility */\n#define MD2_DATA_SIZE MD2_BLOCK_SIZE\n\nstruct md2_ctx\n{\n  uint8_t C[MD2_BLOCK_SIZE];\n  uint8_t X[3 * MD2_BLOCK_SIZE];\n  unsigned index;               /* Into buffer */\n  uint8_t block[MD2_BLOCK_SIZE]; /* Block buffer */\n};\n\nvoid\nmd2_init(struct md2_ctx *ctx);\n\nvoid\nmd2_update(struct md2_ctx *ctx,\n\t   size_t length,\n\t   const uint8_t *data);\n\nvoid\nmd2_digest(struct md2_ctx *ctx,\n\t   size_t length,\n\t   uint8_t *digest);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MD2_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/md4.h",
    "content": "/* md4.h\n\n   The MD4 hash function, described in RFC 1320.\n\n   Copyright (C) 2003 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_MD4_H_INCLUDED\n#define NETTLE_MD4_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define md4_init nettle_md4_init\n#define md4_update nettle_md4_update\n#define md4_digest nettle_md4_digest\n\n#define MD4_DIGEST_SIZE 16\n#define MD4_BLOCK_SIZE 64\n/* For backwards compatibility */\n#define MD4_DATA_SIZE MD4_BLOCK_SIZE\n\n/* Digest is kept internally as 4 32-bit words. */\n#define _MD4_DIGEST_LENGTH 4\n\n/* FIXME: Identical to md5_ctx */\nstruct md4_ctx\n{\n  uint32_t state[_MD4_DIGEST_LENGTH];\n  uint64_t count;\t\t\t/* Block count */\n  unsigned index;\t\t\t/* Into buffer */\n  uint8_t block[MD4_BLOCK_SIZE];\t/* Block buffer */\n};\n\nvoid\nmd4_init(struct md4_ctx *ctx);\n\nvoid\nmd4_update(struct md4_ctx *ctx,\n\t   size_t length,\n\t   const uint8_t *data);\n\nvoid\nmd4_digest(struct md4_ctx *ctx,\n\t   size_t length,\n\t   uint8_t *digest);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MD4_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/md5-compat.h",
    "content": "/* md5-compat.h\n\n   The md5 hash function, RFC 1321-style interface.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_MD5_COMPAT_H_INCLUDED\n#define NETTLE_MD5_COMPAT_H_INCLUDED\n\n#include \"md5.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define MD5Init nettle_MD5Init\n#define MD5Update nettle_MD5Update\n#define MD5Final nettle_MD5Final\n\ntypedef struct md5_ctx MD5_CTX;\n\nvoid MD5Init(MD5_CTX *ctx);\nvoid MD5Update(MD5_CTX *ctx, const unsigned char *data, unsigned int length);\nvoid MD5Final(unsigned char *out, MD5_CTX *ctx);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MD5_COMPAT_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/md5.h",
    "content": "/* md5.h\n\n   The MD5 hash function, described in RFC 1321.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_MD5_H_INCLUDED\n#define NETTLE_MD5_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define md5_init nettle_md5_init\n#define md5_update nettle_md5_update\n#define md5_digest nettle_md5_digest\n#define md5_compress nettle_md5_compress\n\n#define MD5_DIGEST_SIZE 16\n#define MD5_BLOCK_SIZE 64\n/* For backwards compatibility */\n#define MD5_DATA_SIZE MD5_BLOCK_SIZE\n\n/* Digest is kept internally as 4 32-bit words. */\n#define _MD5_DIGEST_LENGTH 4\n\nstruct md5_ctx\n{\n  uint32_t state[_MD5_DIGEST_LENGTH];\n  uint64_t count;               /* Block count */\n  unsigned index;               /* Into buffer */\n  uint8_t block[MD5_BLOCK_SIZE]; /* Block buffer */\n};\n\nvoid\nmd5_init(struct md5_ctx *ctx);\n\nvoid\nmd5_update(struct md5_ctx *ctx,\n\t   size_t length,\n\t   const uint8_t *data);\n\nvoid\nmd5_digest(struct md5_ctx *ctx,\n\t   size_t length,\n\t   uint8_t *digest);\n\n/* MD5 compression function. STATE points to 4 uint32_t words,\n   and DATA points to 64 bytes of input data, possibly unaligned. */\nvoid\nmd5_compress(uint32_t *state, const uint8_t *data);\n\n/* Old name, for backwards compatibility. */\n#define _nettle_md5_compress nettle_md5_compress\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MD5_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/memops.h",
    "content": "/* memops.h\n\n   Copyright (C) 2016 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_MEMOPS_H_INCLUDED\n#define NETTLE_MEMOPS_H_INCLUDED\n\n#include \"memxor.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define cnd_memcpy nettle_cnd_memcpy\n#define memeql_sec nettle_memeql_sec\n\nint\nmemeql_sec (const void *a, const void *b, size_t n);\n\n/* Side-channel silent conditional memcpy. cnd must be 0 (nop) or 1\n   (copy). */\nvoid\ncnd_memcpy(int cnd, volatile void *dst, const volatile void *src, size_t n);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MEMOPS_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/memxor.h",
    "content": "/* memxor.h\n *\n */\n\n#ifndef NETTLE_MEMXOR_H_INCLUDED\n#define NETTLE_MEMXOR_H_INCLUDED\n\n#include <stdlib.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define memxor nettle_memxor\n#define memxor3 nettle_memxor3\n\nvoid *memxor(void *dst, const void *src, size_t n);\nvoid *memxor3(void *dst, const void *a, const void *b, size_t n);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MEMXOR_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/nettle-meta.h",
    "content": "/* nettle-meta.h\n\n   Information about algorithms.\n\n   Copyright (C) 2002, 2014, 2020 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_META_H_INCLUDED\n#define NETTLE_META_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\nstruct nettle_cipher\n{\n  const char *name;\n  \n  unsigned context_size;\n  \n  /* Zero for stream ciphers */\n  unsigned block_size;\n\n  /* Suggested key size; other sizes are sometimes possible. */\n  unsigned key_size;\n\n  nettle_set_key_func *set_encrypt_key;\n  nettle_set_key_func *set_decrypt_key;\n\n  nettle_cipher_func *encrypt;\n  nettle_cipher_func *decrypt;\n};\n\n/* null-terminated list of ciphers implemented by this version of nettle */\nconst struct nettle_cipher * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_ciphers (void);\n\n#define nettle_ciphers (nettle_get_ciphers())\n\nextern const struct nettle_cipher nettle_aes128;\nextern const struct nettle_cipher nettle_aes192;\nextern const struct nettle_cipher nettle_aes256;\n\nextern const struct nettle_cipher nettle_camellia128;\nextern const struct nettle_cipher nettle_camellia192;\nextern const struct nettle_cipher nettle_camellia256;\n\nextern const struct nettle_cipher nettle_cast128;\n\nextern const struct nettle_cipher nettle_serpent128;\nextern const struct nettle_cipher nettle_serpent192;\nextern const struct nettle_cipher nettle_serpent256;\n\nextern const struct nettle_cipher nettle_twofish128;\nextern const struct nettle_cipher nettle_twofish192;\nextern const struct nettle_cipher nettle_twofish256;\n\nextern const struct nettle_cipher nettle_arctwo40;\nextern const struct nettle_cipher nettle_arctwo64;\nextern const struct nettle_cipher nettle_arctwo128;\nextern const struct nettle_cipher nettle_arctwo_gutmann128;\n\nextern const struct nettle_cipher nettle_sm4;\n\nstruct nettle_hash\n{\n  const char *name;\n\n  /* Size of the context struct */\n  unsigned context_size;\n\n  /* Size of digests */\n  unsigned digest_size;\n  \n  /* Internal block size */\n  unsigned block_size;\n\n  nettle_hash_init_func *init;\n  nettle_hash_update_func *update;\n  nettle_hash_digest_func *digest;\n};\n\n#define _NETTLE_HASH(name, NAME) {\t\t\\\n #name,\t\t\t\t\t\t\\\n sizeof(struct name##_ctx),\t\t\t\\\n NAME##_DIGEST_SIZE,\t\t\t\t\\\n NAME##_BLOCK_SIZE,\t\t\t\t\\\n (nettle_hash_init_func *) name##_init,\t\t\\\n (nettle_hash_update_func *) name##_update,\t\\\n (nettle_hash_digest_func *) name##_digest\t\\\n} \n\n/* null-terminated list of digests implemented by this version of nettle */\nconst struct nettle_hash * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_hashes (void);\n\n#define nettle_hashes (nettle_get_hashes())\n\nconst struct nettle_hash *\nnettle_lookup_hash (const char *name);\n\nextern const struct nettle_hash nettle_md2;\nextern const struct nettle_hash nettle_md4;\nextern const struct nettle_hash nettle_md5;\nextern const struct nettle_hash nettle_gosthash94;\nextern const struct nettle_hash nettle_gosthash94cp;\nextern const struct nettle_hash nettle_ripemd160;\nextern const struct nettle_hash nettle_sha1;\nextern const struct nettle_hash nettle_sha224;\nextern const struct nettle_hash nettle_sha256;\nextern const struct nettle_hash nettle_sha384;\nextern const struct nettle_hash nettle_sha512;\nextern const struct nettle_hash nettle_sha512_224;\nextern const struct nettle_hash nettle_sha512_256;\nextern const struct nettle_hash nettle_sha3_224;\nextern const struct nettle_hash nettle_sha3_256;\nextern const struct nettle_hash nettle_sha3_384;\nextern const struct nettle_hash nettle_sha3_512;\nextern const struct nettle_hash nettle_streebog256;\nextern const struct nettle_hash nettle_streebog512;\nextern const struct nettle_hash nettle_sm3;\n\nstruct nettle_mac\n{\n  const char *name;\n\n  /* Size of the context struct */\n  unsigned context_size;\n\n  /* Size of digests */\n  unsigned digest_size;\n\n  /* Key size */\n  unsigned key_size;\n\n  nettle_set_key_func *set_key;\n  nettle_hash_update_func *update;\n  nettle_hash_digest_func *digest;\n};\n\nstruct nettle_aead\n{\n  const char *name;\n  \n  unsigned context_size;\n  /* Block size for encrypt and decrypt. */\n  unsigned block_size;\n  unsigned key_size;\n  unsigned nonce_size;\n  unsigned digest_size;\n\n  nettle_set_key_func *set_encrypt_key;\n  nettle_set_key_func *set_decrypt_key;\n  nettle_set_key_func *set_nonce;\n  nettle_hash_update_func *update;\n  nettle_crypt_func *encrypt;\n  nettle_crypt_func *decrypt;\n  /* FIXME: Drop length argument? */\n  nettle_hash_digest_func *digest;\n};\n\n/* null-terminated list of aead constructions implemented by this\n   version of nettle */\nconst struct nettle_aead * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_aeads (void);\n\n#define nettle_aeads (nettle_get_aeads())\n\nextern const struct nettle_aead nettle_gcm_aes128;\nextern const struct nettle_aead nettle_gcm_aes192;\nextern const struct nettle_aead nettle_gcm_aes256;\nextern const struct nettle_aead nettle_gcm_camellia128;\nextern const struct nettle_aead nettle_gcm_camellia256;\nextern const struct nettle_aead nettle_gcm_sm4;\nextern const struct nettle_aead nettle_eax_aes128;\nextern const struct nettle_aead nettle_chacha_poly1305;\n\nstruct nettle_armor\n{\n  const char *name;\n  unsigned encode_context_size;\n  unsigned decode_context_size;\n\n  unsigned encode_final_length;\n\n  nettle_armor_init_func *encode_init;\n  nettle_armor_length_func *encode_length;\n  nettle_armor_encode_update_func *encode_update;\n  nettle_armor_encode_final_func *encode_final;\n  \n  nettle_armor_init_func *decode_init;\n  nettle_armor_length_func *decode_length;\n  nettle_armor_decode_update_func *decode_update;\n  nettle_armor_decode_final_func *decode_final;\n};\n\n#define _NETTLE_ARMOR(name, NAME) {\t\t\t\t\\\n  #name,\t\t\t\t\t\t\t\\\n  sizeof(struct name##_encode_ctx),\t\t\t\t\\\n  sizeof(struct name##_decode_ctx),\t\t\t\t\\\n  NAME##_ENCODE_FINAL_LENGTH,\t\t\t\t\t\\\n  (nettle_armor_init_func *) name##_encode_init,\t\t\\\n  (nettle_armor_length_func *) name##_encode_length,\t\t\\\n  (nettle_armor_encode_update_func *) name##_encode_update,\t\\\n  (nettle_armor_encode_final_func *) name##_encode_final,\t\\\n  (nettle_armor_init_func *) name##_decode_init,\t\t\\\n  (nettle_armor_length_func *) name##_decode_length,\t\t\\\n  (nettle_armor_decode_update_func *) name##_decode_update,\t\\\n  (nettle_armor_decode_final_func *) name##_decode_final,\t\\\n}\n\n#define _NETTLE_ARMOR_0(name, NAME) {\t\t\t\t\\\n  #name,\t\t\t\t\t\t\t\\\n  0,\t\t\t\t\t\t\t\t\\\n  sizeof(struct name##_decode_ctx),\t\t\t\t\\\n  NAME##_ENCODE_FINAL_LENGTH,\t\t\t\t\t\\\n  (nettle_armor_init_func *) name##_encode_init,\t\t\\\n  (nettle_armor_length_func *) name##_encode_length,\t\t\\\n  (nettle_armor_encode_update_func *) name##_encode_update,\t\\\n  (nettle_armor_encode_final_func *) name##_encode_final,\t\\\n  (nettle_armor_init_func *) name##_decode_init,\t\t\\\n  (nettle_armor_length_func *) name##_decode_length,\t\t\\\n  (nettle_armor_decode_update_func *) name##_decode_update,\t\\\n  (nettle_armor_decode_final_func *) name##_decode_final,\t\\\n}\n\n/* null-terminated list of armor schemes implemented by this version of nettle */\nconst struct nettle_armor * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_armors (void);\n\n#define nettle_armors (nettle_get_armors())\n\nextern const struct nettle_armor nettle_base64;\nextern const struct nettle_armor nettle_base64url;\nextern const struct nettle_armor nettle_base16;\n\n#define _NETTLE_HMAC(name, HASH) {\t\t\\\n  #name,\t\t\t\t\t\\\n  sizeof(struct name##_ctx),\t\t\t\\\n  HASH##_DIGEST_SIZE,\t\t\t\t\\\n  HASH##_DIGEST_SIZE,\t\t\t\t\\\n  name##_set_key_wrapper,\t\t\t\\\n  (nettle_hash_update_func *) name##_update,\t\\\n  (nettle_hash_digest_func *) name##_digest,\t\\\n}\n\n/* null-terminated list of macs implemented by this\n   version of nettle */\nconst struct nettle_mac * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_macs (void);\n\n#define nettle_macs (nettle_get_macs())\n\nextern const struct nettle_mac nettle_cmac_aes128;\nextern const struct nettle_mac nettle_cmac_aes256;\nextern const struct nettle_mac nettle_cmac_des3;\n\n/* HMAC variants with key size = digest size */\nextern const struct nettle_mac nettle_hmac_md5;\nextern const struct nettle_mac nettle_hmac_ripemd160;\nextern const struct nettle_mac nettle_hmac_sha1;\nextern const struct nettle_mac nettle_hmac_sha224;\nextern const struct nettle_mac nettle_hmac_sha256;\nextern const struct nettle_mac nettle_hmac_sha384;\nextern const struct nettle_mac nettle_hmac_sha512;\nextern const struct nettle_mac nettle_hmac_streebog256;\nextern const struct nettle_mac nettle_hmac_streebog512;\nextern const struct nettle_mac nettle_hmac_sm3;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_META_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/nettle-types.h",
    "content": "/* nettle-types.h\n\n   Copyright (C) 2005, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_TYPES_H\n#define NETTLE_TYPES_H\n\n/* For size_t */\n#include <stddef.h>\n#include <stdint.h>\n\n/* Attributes we want to use in installed header files, and hence\n   can't rely on config.h. */\n#ifdef __GNUC__\n\n#define _NETTLE_ATTRIBUTE_PURE __attribute__((pure))\n#ifndef _NETTLE_ATTRIBUTE_DEPRECATED\n/* Variant without message is supported since gcc-3.1 or so. */\n#define _NETTLE_ATTRIBUTE_DEPRECATED __attribute__((deprecated))\n#endif\n\n#else /* !__GNUC__ */\n\n#define _NETTLE_ATTRIBUTE_PURE\n#define _NETTLE_ATTRIBUTE_DEPRECATED\n\n#endif /* !__GNUC__ */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* An aligned 16-byte block. */\nunion nettle_block16\n{\n  uint8_t b[16];\n  unsigned long w[16 / sizeof(unsigned long)] _NETTLE_ATTRIBUTE_DEPRECATED;\n  uint64_t u64[2];\n};\n\nunion nettle_block8\n{\n  uint8_t b[8];\n  uint64_t u64;\n};\n\n/* Randomness. Used by key generation and dsa signature creation. */\ntypedef void nettle_random_func(void *ctx,\n\t\t\t\tsize_t length, uint8_t *dst);\n\n/* Progress report function, mainly for key generation. */\ntypedef void nettle_progress_func(void *ctx, int c);\n\n/* Realloc function, used by struct nettle_buffer. */\ntypedef void *nettle_realloc_func(void *ctx, void *p, size_t length);\n\n/* Ciphers */\ntypedef void nettle_set_key_func(void *ctx, const uint8_t *key);\n\n/* For block ciphers, const context. */\ntypedef void nettle_cipher_func(const void *ctx,\n\t\t\t\tsize_t length, uint8_t *dst,\n\t\t\t\tconst uint8_t *src);\n\n\n/* Uses a void * for cipher contexts. Used for crypt operations where\n   the internal state changes during the encryption. */\ntypedef void nettle_crypt_func(void *ctx,\n\t\t\t       size_t length, uint8_t *dst,\n\t\t\t       const uint8_t *src);\n\n/* Hash algorithms */\ntypedef void nettle_hash_init_func(void *ctx);\ntypedef void nettle_hash_update_func(void *ctx,\n\t\t\t\t     size_t length,\n\t\t\t\t     const uint8_t *src);\ntypedef void nettle_hash_digest_func(void *ctx,\n\t\t\t\t     size_t length, uint8_t *dst);\n\n/* ASCII armor codecs. NOTE: Experimental and subject to change. */\n\ntypedef size_t nettle_armor_length_func(size_t length);\ntypedef void nettle_armor_init_func(void *ctx);\n\ntypedef size_t nettle_armor_encode_update_func(void *ctx,\n\t\t\t\t\t       char *dst,\n\t\t\t\t\t       size_t src_length,\n\t\t\t\t\t       const uint8_t *src);\n\ntypedef size_t nettle_armor_encode_final_func(void *ctx, char *dst);\n\ntypedef int nettle_armor_decode_update_func(void *ctx,\n\t\t\t\t\t    size_t *dst_length,\n\t\t\t\t\t    uint8_t *dst,\n\t\t\t\t\t    size_t src_length,\n\t\t\t\t\t    const char *src);\n\ntypedef int nettle_armor_decode_final_func(void *ctx);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_TYPES_H */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/nist-keywrap.h",
    "content": "/* nist-keywrap.h\n\n   AES Key Wrap function.\n   implements RFC 3394\n   https://tools.ietf.org/html/rfc3394\n\n   Copyright (C) 2021 Nicolas Mora\n                 2021 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_NIST_KEYWRAP_H_INCLUDED\n#define NETTLE_NIST_KEYWRAP_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define nist_keywrap16 nettle_nist_keywrap16\n#define nist_keyunwrap16 nettle_nist_keyunwrap16\n#define aes128_keywrap nettle_aes128_keywrap\n#define aes192_keywrap nettle_aes192_keywrap\n#define aes256_keywrap nettle_aes256_keywrap\n#define aes128_keyunwrap nettle_aes128_keyunwrap\n#define aes192_keyunwrap nettle_aes192_keyunwrap\n#define aes256_keyunwrap nettle_aes256_keyunwrap\n\nvoid\nnist_keywrap16 (const void *ctx, nettle_cipher_func *encrypt,\n\t\tconst uint8_t *iv, size_t ciphertext_length,\n\t\tuint8_t *ciphertext, const uint8_t *cleartext);\n\nint\nnist_keyunwrap16 (const void *ctx, nettle_cipher_func *decrypt,\n        const uint8_t *iv, size_t cleartext_length,\n        uint8_t *cleartext, const uint8_t *ciphertext);\n\nvoid\naes128_keywrap (struct aes128_ctx *ctx,\n\t\tconst uint8_t *iv, size_t ciphertext_length,\n\t\tuint8_t *ciphertext, const uint8_t *cleartext);\n\nvoid\naes192_keywrap (struct aes192_ctx *ctx,\n\t\tconst uint8_t *iv, size_t ciphertext_length,\n\t\tuint8_t *ciphertext, const uint8_t *cleartext);\n\nvoid\naes256_keywrap (struct aes256_ctx *ctx,\n\t\tconst uint8_t *iv, size_t ciphertext_length,\n\t\tuint8_t *ciphertext, const uint8_t *cleartext);\n\nint\naes128_keyunwrap (struct aes128_ctx *ctx,\n\t\t  const uint8_t *iv, size_t cleartext_length,\n\t\t  uint8_t *cleartext, const uint8_t *ciphertext);\n\nint\naes192_keyunwrap (struct aes192_ctx *ctx,\n\t\t  const uint8_t *iv, size_t cleartext_length,\n\t\t  uint8_t *cleartext, const uint8_t *ciphertext);\n\nint\naes256_keyunwrap (struct aes256_ctx *ctx,\n\t\t  const uint8_t *iv, size_t cleartext_length,\n\t\t  uint8_t *cleartext, const uint8_t *ciphertext);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\t\t\t\t/* NETTLE_NIST_KEYWRAP_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/ocb.h",
    "content": "/* ocb.h\n\n   OCB AEAD mode, RFC 7253\n\n   Copyright (C) 2021 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_OCB_H_INCLUDED\n#define NETTLE_OCB_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ocb_set_key nettle_ocb_set_key\n#define ocb_set_nonce nettle_ocb_set_nonce\n#define ocb_update nettle_ocb_update\n#define ocb_encrypt nettle_ocb_encrypt\n#define ocb_decrypt nettle_ocb_decrypt\n#define ocb_digest nettle_ocb_digest\n#define ocb_encrypt_message nettle_ocb_encrypt_message\n#define ocb_decrypt_message nettle_ocb_decrypt_message\n#define ocb_aes128_set_encrypt_key nettle_ocb_aes128_set_encrypt_key\n#define ocb_aes128_set_decrypt_key nettle_ocb_aes128_set_decrypt_key\n#define ocb_aes128_set_nonce nettle_ocb_aes128_set_nonce\n#define ocb_aes128_update nettle_ocb_aes128_update\n#define ocb_aes128_encrypt nettle_ocb_aes128_encrypt\n#define ocb_aes128_decrypt nettle_ocb_aes128_decrypt\n#define ocb_aes128_digest nettle_ocb_aes128_digest\n#define ocb_aes128_encrypt_message nettle_ocb_aes128_encrypt_message\n#define ocb_aes128_decrypt_message nettle_ocb_aes128_decrypt_message\n\n#define OCB_BLOCK_SIZE 16\n#define OCB_DIGEST_SIZE 16\n#define OCB_MAX_NONCE_SIZE 15\n\nstruct ocb_key {\n  /* L_*, L_$ and L_0, and one reserved entry */\n  union nettle_block16 L[4];\n};\n\nstruct ocb_ctx {\n  /* Initial offset, Offset_0 in the spec. */\n  union nettle_block16 initial;\n  /* Offset, updated per block. */\n  union nettle_block16 offset;\n  /* Authentication for the associated data */\n  union nettle_block16 sum;\n  /* Authentication for the message */\n  union nettle_block16 checksum;\n  /* Count of processed blocks. */\n  size_t data_count;\n  size_t message_count;\n};\n\nvoid\nocb_set_key (struct ocb_key *key, const void *cipher, nettle_cipher_func *f);\n\nvoid\nocb_set_nonce (struct ocb_ctx *ctx,\n\t       const void *cipher, nettle_cipher_func *f,\n\t       size_t tag_length, size_t nonce_length, const uint8_t *nonce);\n\nvoid\nocb_update (struct ocb_ctx *ctx, const struct ocb_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, const uint8_t *data);\n\nvoid\nocb_encrypt (struct ocb_ctx *ctx, const struct ocb_key *key,\n\t     const void *cipher, nettle_cipher_func *f,\n\t     size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nocb_decrypt (struct ocb_ctx *ctx, const struct ocb_key *key,\n\t     const void *encrypt_ctx, nettle_cipher_func *encrypt,\n\t     const void *decrypt_ctx, nettle_cipher_func *decrypt,\n\t     size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nocb_digest (const struct ocb_ctx *ctx, const struct ocb_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *digest);\n\n\nvoid\nocb_encrypt_message (const struct ocb_key *ocb_key,\n\t\t     const void *cipher, nettle_cipher_func *f,\n\t\t     size_t nlength, const uint8_t *nonce,\n\t\t     size_t alength, const uint8_t *adata,\n\t\t     size_t tlength,\n\t\t     size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nocb_decrypt_message (const struct ocb_key *ocb_key,\n\t\t     const void *encrypt_ctx, nettle_cipher_func *encrypt,\n\t\t     const void *decrypt_ctx, nettle_cipher_func *decrypt,\n\t\t     size_t nlength, const uint8_t *nonce,\n\t\t     size_t alength, const uint8_t *adata,\n\t\t     size_t tlength,\n\t\t     size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* OCB-AES */\n/* This struct represents an expanded key for ocb-aes encryption. For\n   decryption, a separate decryption context is needed as well. */\nstruct ocb_aes128_encrypt_key\n{\n  struct ocb_key ocb;\n  struct aes128_ctx encrypt;\n};\n\nvoid\nocb_aes128_set_encrypt_key (struct ocb_aes128_encrypt_key *ocb, const uint8_t *key);\n\nvoid\nocb_aes128_set_decrypt_key (struct ocb_aes128_encrypt_key *ocb, struct aes128_ctx *decrypt,\n\t\t\t    const uint8_t *key);\n\nvoid\nocb_aes128_set_nonce (struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t      size_t tag_length, size_t nonce_length, const uint8_t *nonce);\n\nvoid\nocb_aes128_update (struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nocb_aes128_encrypt(struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nocb_aes128_decrypt(struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t   const struct aes128_ctx *decrypt,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nocb_aes128_digest(struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t  size_t length, uint8_t *digest);\n\nvoid\nocb_aes128_encrypt_message (const struct ocb_aes128_encrypt_key *key,\n\t\t\t    size_t nlength, const uint8_t *nonce,\n\t\t\t    size_t alength, const uint8_t *adata,\n\t\t\t    size_t tlength,\n\t\t\t    size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nocb_aes128_decrypt_message (const struct ocb_aes128_encrypt_key *key,\n\t\t\t    const struct aes128_ctx *decrypt,\n\t\t\t    size_t nlength, const uint8_t *nonce,\n\t\t\t    size_t alength, const uint8_t *adata,\n\t\t\t    size_t tlength,\n\t\t\t    size_t mlength, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_OCB_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/pbkdf2.h",
    "content": "/* pbkdf2.h\n\n   PKCS #5 password-based key derivation function PBKDF2, see RFC 2898.\n\n   Copyright (C) 2012 Simon Josefsson\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PBKDF2_H_INCLUDED\n#define NETTLE_PBKDF2_H_INCLUDED\n\n#include \"nettle-meta.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/* Namespace mangling */\n#define pbkdf2 nettle_pbkdf2\n#define pbkdf2_hmac_sha1 nettle_pbkdf2_hmac_sha1\n#define pbkdf2_hmac_sha256 nettle_pbkdf2_hmac_sha256\n#define pbkdf2_hmac_sha384 nettle_pbkdf2_hmac_sha384\n#define pbkdf2_hmac_sha512 nettle_pbkdf2_hmac_sha512\n#define pbkdf2_hmac_gosthash94cp nettle_pbkdf2_hmac_gosthash94cp\n\nvoid\npbkdf2 (void *mac_ctx,\n\tnettle_hash_update_func *update,\n\tnettle_hash_digest_func *digest,\n\tsize_t digest_size, unsigned iterations,\n\tsize_t salt_length, const uint8_t *salt,\n\tsize_t length, uint8_t *dst);\n\n#define PBKDF2(ctx, update, digest, digest_size,\t\t\t\\\n\t       iterations, salt_length, salt, length, dst)\t\t\\\n  (0 ? ((update)((ctx), 0, (uint8_t *) 0),\t\t\t\t\\\n\t(digest)((ctx), 0, (uint8_t *) 0))\t\t\t\t\\\n   : pbkdf2 ((ctx),\t\t\t\t\t\t\t\\\n\t     (nettle_hash_update_func *)(update),\t\t\t\\\n\t     (nettle_hash_digest_func *)(digest),\t\t\t\\\n\t     (digest_size), (iterations),\t\t\t\t\\\n\t     (salt_length), (salt), (length), (dst)))\n\n/* PBKDF2 with specific PRFs. */\n\nvoid\npbkdf2_hmac_sha1 (size_t key_length, const uint8_t *key,\n\t\t  unsigned iterations,\n\t\t  size_t salt_length, const uint8_t *salt,\n\t\t  size_t length, uint8_t *dst);\n\nvoid\npbkdf2_hmac_sha256 (size_t key_length, const uint8_t *key,\n\t\t    unsigned iterations,\n\t\t    size_t salt_length, const uint8_t *salt,\n\t\t    size_t length, uint8_t *dst);\n\nvoid\npbkdf2_hmac_sha384 (size_t key_length, const uint8_t *key,\n\t\t    unsigned iterations,\n\t\t    size_t salt_length, const uint8_t *salt,\n\t\t    size_t length, uint8_t *dst);\n\nvoid\npbkdf2_hmac_sha512 (size_t key_length, const uint8_t *key,\n\t\t    unsigned iterations,\n\t\t    size_t salt_length, const uint8_t *salt,\n\t\t    size_t length, uint8_t *dst);\n\nvoid\npbkdf2_hmac_gosthash94cp (size_t key_length, const uint8_t *key,\n\t\t\t  unsigned iterations,\n\t\t\t  size_t salt_length, const uint8_t *salt,\n\t\t\t  size_t length, uint8_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PBKDF2_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/pgp.h",
    "content": "/* pgp.h\n\n   PGP related functions.\n\n   Copyright (C) 2001, 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PGP_H_INCLUDED\n#define NETTLE_PGP_H_INCLUDED\n\n#include <time.h>\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define pgp_put_uint32 nettle_pgp_put_uint32\n#define pgp_put_uint16 nettle_pgp_put_uint16\n#define pgp_put_mpi nettle_pgp_put_mpi\n#define pgp_put_string nettle_pgp_put_string\n#define pgp_put_length nettle_pgp_put_length\n#define pgp_put_header nettle_pgp_put_header\n#define pgp_put_header_length nettle_pgp_put_header_length\n#define pgp_sub_packet_start nettle_pgp_sub_packet_start\n#define pgp_put_sub_packet nettle_pgp_put_sub_packet\n#define pgp_sub_packet_end nettle_pgp_sub_packet_end\n#define pgp_put_public_rsa_key nettle_pgp_put_public_rsa_key\n#define pgp_put_rsa_sha1_signature nettle_pgp_put_rsa_sha1_signature\n#define pgp_put_userid nettle_pgp_put_userid\n#define pgp_crc24 nettle_pgp_crc24\n#define pgp_armor nettle_pgp_armor\n\nstruct nettle_buffer;\nstruct rsa_public_key;\nstruct rsa_private_key;\nstruct sha1_ctx;\n\nint\npgp_put_uint32(struct nettle_buffer *buffer, uint32_t i);\n\nint\npgp_put_uint16(struct nettle_buffer *buffer, unsigned i);\n\nint\npgp_put_mpi(struct nettle_buffer *buffer, const mpz_t x);\n\nint\npgp_put_string(struct nettle_buffer *buffer,\n\t       unsigned length,\n\t       const uint8_t *s);\n\nint\npgp_put_length(struct nettle_buffer *buffer,\n\t       unsigned length);\n\nint\npgp_put_header(struct nettle_buffer *buffer,\n\t       unsigned tag, unsigned length);\n\nvoid\npgp_put_header_length(struct nettle_buffer *buffer,\n\t\t      /* start of the header */\n\t\t      unsigned start,\n\t\t      unsigned field_size);\n\nunsigned\npgp_sub_packet_start(struct nettle_buffer *buffer);\n\nint\npgp_put_sub_packet(struct nettle_buffer *buffer,\n\t\t   unsigned type,\n\t\t   unsigned length,\n\t\t   const uint8_t *data);\n\nvoid\npgp_sub_packet_end(struct nettle_buffer *buffer, unsigned start);\n\nint\npgp_put_public_rsa_key(struct nettle_buffer *,\n\t\t       const struct rsa_public_key *key,\n\t\t       time_t timestamp);\n\nint\npgp_put_rsa_sha1_signature(struct nettle_buffer *buffer,\n\t\t\t   const struct rsa_private_key *key,\n\t\t\t   const uint8_t *keyid,\n\t\t\t   unsigned type,\n\t\t\t   struct sha1_ctx *hash);\n\nint\npgp_put_userid(struct nettle_buffer *buffer,\n\t       unsigned length,\n\t       const uint8_t *name);\n\nuint32_t\npgp_crc24(unsigned length, const uint8_t *data);\n\nint\npgp_armor(struct nettle_buffer *buffer,\n\t  const char *tag,\n\t  unsigned length,\n\t  const uint8_t *data);\n\n/* Values that can be passed to pgp_put_header when the size of the\n * length field, but not the length itself, is known. Also the minimum length\n * for the given field size. */\nenum pgp_lengths\n  {\n    PGP_LENGTH_ONE_OCTET = 0,\n    PGP_LENGTH_TWO_OCTETS = 192,\n    PGP_LENGTH_FOUR_OCTETS = 8384,\n  };\n\nenum pgp_public_key_algorithm\n  {\n    PGP_RSA = 1,\n    PGP_RSA_ENCRYPT = 2,\n    PGP_RSA_SIGN = 3,\n    PGP_EL_GAMAL_ENCRYPT = 16,\n    PGP_DSA = 17,\n    PGP_EL_GAMAL = 20,\n  };\n\nenum pgp_symmetric_algorithm\n  {\n    PGP_PLAINTEXT = 0,\n    PGP_IDEA = 1,\n    PGP_3DES = 2,\n    PGP_CAST5 = 3,\n    PGP_BLOWFISH = 4,\n    PGP_SAFER_SK = 5,\n    PGP_AES128 = 7,\n    PGP_AES192 = 8,\n    PGP_AES256 = 9,\n  };\n\nenum pgp_compression_algorithm\n  {\n    PGP_UNCOMPRESSED = 0,\n    PGP_ZIP = 1,\n    PGP_ZLIB = 2,\n  };\n\nenum pgp_hash_algorithm\n  {\n    PGP_MD5 = 1,\n    PGP_SHA1 = 2,\n    PGP_RIPEMD = 3,\n    PGP_MD2 = 5,\n    PGP_TIGER192 = 6,\n    PGP_HAVAL = 7,\n  };\n\nenum pgp_tag\n  {\n    PGP_TAG_PUBLIC_SESSION_KEY = 1,\n    PGP_TAG_SIGNATURE = 2,\n    PGP_TAG_SYMMETRIC_SESSION_KEY = 3,\n    PGP_TAG_ONE_PASS_SIGNATURE = 4,\n    PGP_TAG_SECRET_KEY = 5,\n    PGP_TAG_PUBLIC_KEY = 6,\n    PGP_TAG_SECRET_SUBKEY = 7,\n    PGP_TAG_COMPRESSED = 8,\n    PGP_TAG_ENCRYPTED = 9,\n    PGP_TAG_MARKER = 10,\n    PGP_TAG_LITERAL = 11,\n    PGP_TAG_TRUST = 12,\n    PGP_TAG_USERID = 13,\n    PGP_TAG_PUBLIC_SUBKEY = 14,\n  };\n\nenum pgp_signature_type\n  {\n    PGP_SIGN_BINARY = 0,\n    PGP_SIGN_TEXT = 1,\n    PGP_SIGN_STANDALONE = 2,\n    PGP_SIGN_CERTIFICATION = 0x10,\n    PGP_SIGN_CERTIFICATION_PERSONA = 0x11,\n    PGP_SIGN_CERTIFICATION_CASUAL = 0x12,\n    PGP_SIGN_CERTIFICATION_POSITIVE = 0x13,\n    PGP_SIGN_SUBKEY = 0x18,\n    PGP_SIGN_KEY = 0x1f,\n    PGP_SIGN_REVOCATION = 0x20,\n    PGP_SIGN_REVOCATION_SUBKEY = 0x28,\n    PGP_SIGN_REVOCATION_CERTIFICATE = 0x30,\n    PGP_SIGN_TIMESTAMP = 0x40,\n  };\n\nenum pgp_subpacket_tag\n  {\n    PGP_SUBPACKET_CREATION_TIME = 2,\n    PGP_SUBPACKET_SIGNATURE_EXPIRATION_TIME = 3,\n    PGP_SUBPACKET_EXPORTABLE_CERTIFICATION = 4,\n    PGP_SUBPACKET_TRUST_SIGNATURE = 5,\n    PGP_SUBPACKET_REGULAR_EXPRESSION = 6,\n    PGP_SUBPACKET_REVOCABLE = 7,\n    PGP_SUBPACKET_KEY_EXPIRATION_TIME = 9,\n    PGP_SUBPACKET_PLACEHOLDER = 10 ,\n    PGP_SUBPACKET_PREFERRED_SYMMETRIC_ALGORITHMS = 11,\n    PGP_SUBPACKET_REVOCATION_KEY = 12,\n    PGP_SUBPACKET_ISSUER_KEY_ID = 16,\n    PGP_SUBPACKET_NOTATION_DATA = 20,\n    PGP_SUBPACKET_PREFERRED_HASH_ALGORITHMS = 21,\n    PGP_SUBPACKET_PREFERRED_COMPRESSION_ALGORITHMS = 22,\n    PGP_SUBPACKET_KEY_SERVER_PREFERENCES = 23,\n    PGP_SUBPACKET_PREFERRED_KEY_SERVER = 24,\n    PGP_SUBPACKET_PRIMARY_USER_ID = 25,\n    PGP_SUBPACKET_POLICY_URL = 26,\n    PGP_SUBPACKET_KEY_FLAGS = 27,\n    PGP_SUBPACKET_SIGNERS_USER_ID = 28,\n    PGP_SUBPACKET_REASON_FOR_REVOCATION = 29,\n  };\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PGP_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/pkcs1.h",
    "content": "/* pkcs1.h\n\n   PKCS1 embedding.\n\n   Copyright (C) 2003 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PKCS1_H_INCLUDED\n#define NETTLE_PKCS1_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define pkcs1_rsa_digest_encode nettle_pkcs1_rsa_digest_encode\n#define pkcs1_rsa_md5_encode nettle_pkcs1_rsa_md5_encode\n#define pkcs1_rsa_md5_encode_digest nettle_pkcs1_rsa_md5_encode_digest\n#define pkcs1_rsa_sha1_encode nettle_pkcs1_rsa_sha1_encode\n#define pkcs1_rsa_sha1_encode_digest nettle_pkcs1_rsa_sha1_encode_digest\n#define pkcs1_rsa_sha256_encode nettle_pkcs1_rsa_sha256_encode\n#define pkcs1_rsa_sha256_encode_digest nettle_pkcs1_rsa_sha256_encode_digest\n#define pkcs1_rsa_sha512_encode nettle_pkcs1_rsa_sha512_encode\n#define pkcs1_rsa_sha512_encode_digest nettle_pkcs1_rsa_sha512_encode_digest\n#define pkcs1_encrypt nettle_pkcs1_encrypt\n#define pkcs1_decrypt nettle_pkcs1_decrypt\n\nstruct md5_ctx;\nstruct sha1_ctx;\nstruct sha256_ctx;\nstruct sha512_ctx;\n\nint\npkcs1_encrypt (size_t key_size,\n\t       /* For padding */\n\t       void *random_ctx, nettle_random_func *random,\n\t       size_t length, const uint8_t *message,\n\t       mpz_t m);\n\nint\npkcs1_decrypt (size_t key_size,\n\t       const mpz_t m,\n\t       size_t *length, uint8_t *message);\n\nint\npkcs1_rsa_digest_encode(mpz_t m, size_t key_size,\n\t\t\tsize_t di_length, const uint8_t *digest_info);\n\nint\npkcs1_rsa_md5_encode(mpz_t m, size_t length, struct md5_ctx *hash);\n\nint\npkcs1_rsa_md5_encode_digest(mpz_t m, size_t length, const uint8_t *digest);\n\nint\npkcs1_rsa_sha1_encode(mpz_t m, size_t length, struct sha1_ctx *hash);\n\nint\npkcs1_rsa_sha1_encode_digest(mpz_t m, size_t length, const uint8_t *digest);\n\nint\npkcs1_rsa_sha256_encode(mpz_t m, size_t length, struct sha256_ctx *hash);\n\nint\npkcs1_rsa_sha256_encode_digest(mpz_t m, size_t length, const uint8_t *digest);\n\nint\npkcs1_rsa_sha512_encode(mpz_t m, size_t length, struct sha512_ctx *hash);\n\nint\npkcs1_rsa_sha512_encode_digest(mpz_t m, size_t length, const uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PKCS1_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/poly1305.h",
    "content": "/* poly1305.h\n\n   Poly1305 message authentication code.\n\n   Copyright (C) 2013 Nikos Mavrogiannopoulos\n   Copyright (C) 2013, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_POLY1305_H_INCLUDED\n#define NETTLE_POLY1305_H_INCLUDED\n\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define poly1305_aes_set_key nettle_poly1305_aes_set_key\n#define poly1305_aes_set_nonce nettle_poly1305_aes_set_nonce\n#define poly1305_aes_update nettle_poly1305_aes_update\n#define poly1305_aes_digest nettle_poly1305_aes_digest\n\n/* Low level functions/macros for the poly1305 construction. */\n\n#define POLY1305_BLOCK_SIZE 16\n\nstruct poly1305_ctx {\n  /* Key, 128-bit value and some cached multiples. */\n  union\n  {\n    uint32_t r32[6];\n    uint64_t r64[3];\n  } r;\n  uint32_t s32[3];\n  /* State, represented as words of 26, 32 or 64 bits, depending on\n     implementation. */\n  /* High bits first, to maintain alignment. */\n  uint32_t hh;\n  union\n  {\n    uint32_t h32[4];\n    uint64_t h64[2];\n  } h;\n};\n\n/* poly1305-aes */\n\n#define POLY1305_AES_KEY_SIZE 32\n#define POLY1305_AES_DIGEST_SIZE 16\n#define POLY1305_AES_NONCE_SIZE 16\n\nstruct poly1305_aes_ctx\n{\n  /* Keep aes context last, to make it possible to use a general\n     poly1305_update if other variants are added. */\n  struct poly1305_ctx pctx;\n  uint8_t block[POLY1305_BLOCK_SIZE];\n  unsigned index;\n  uint8_t nonce[POLY1305_BLOCK_SIZE];\n  struct aes128_ctx aes;\n};\n\n/* Also initialize the nonce to zero. */\nvoid\npoly1305_aes_set_key (struct poly1305_aes_ctx *ctx, const uint8_t *key);\n\n/* Optional, if not used, messages get incrementing nonces starting\n   from zero. */\nvoid\npoly1305_aes_set_nonce (struct poly1305_aes_ctx *ctx,\n\t\t        const uint8_t *nonce);\n\n/* Update is not aes-specific, but since this is the only implemented\n   variant, we need no more general poly1305_update. */\nvoid\npoly1305_aes_update (struct poly1305_aes_ctx *ctx, size_t length, const uint8_t *data);\n\n/* Also increments the nonce */\nvoid\npoly1305_aes_digest (struct poly1305_aes_ctx *ctx,\n\t       \t     size_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_POLY1305_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/pss-mgf1.h",
    "content": "/* pss-mgf1.h\n\n   PKCS#1 mask generation function 1, used in RSA-PSS (RFC-3447).\n\n   Copyright (C) 2017 Daiki Ueno\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PSS_MGF1_H_INCLUDED\n#define NETTLE_PSS_MGF1_H_INCLUDED\n\n#include \"nettle-meta.h\"\n\n#include \"sha1.h\"\n#include \"sha2.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/* Namespace mangling */\n#define pss_mgf1 nettle_pss_mgf1\n\nvoid\npss_mgf1(const void *seed, const struct nettle_hash *hash,\n\t size_t length, uint8_t *mask);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PSS_MGF1_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/pss.h",
    "content": "/* pss.h\n\n   PKCS#1 RSA-PSS (RFC-3447).\n\n   Copyright (C) 2017 Daiki Ueno\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PSS_H_INCLUDED\n#define NETTLE_PSS_H_INCLUDED\n\n#include \"nettle-meta.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/* Namespace mangling */\n#define pss_encode_mgf1 nettle_pss_encode_mgf1\n#define pss_verify_mgf1 nettle_pss_verify_mgf1\n\nint\npss_encode_mgf1(mpz_t m, size_t bits,\n\t\tconst struct nettle_hash *hash,\n\t\tsize_t salt_length, const uint8_t *salt,\n\t\tconst uint8_t *digest);\n\nint\npss_verify_mgf1(const mpz_t m, size_t bits,\n\t\tconst struct nettle_hash *hash,\n\t\tsize_t salt_length,\n\t\tconst uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PSS_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/realloc.h",
    "content": "/* realloc.h\n\n   Copyright (C) 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_REALLOC_H_INCLUDED\n#define NETTLE_REALLOC_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nnettle_realloc_func nettle_realloc;\nnettle_realloc_func nettle_xrealloc;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_REALLOC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/ripemd160.h",
    "content": "/* ripemd160.h\n\n   RIPEMD-160 hash function.\n\n   Copyright (C) 2011 Andres Mejia\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_RIPEMD160_H_INCLUDED\n#define NETTLE_RIPEMD160_H_INCLUDED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"nettle-types.h\"\n\n/* Name mangling */\n#define ripemd160_init nettle_ripemd160_init\n#define ripemd160_update nettle_ripemd160_update\n#define ripemd160_digest nettle_ripemd160_digest\n\n/* RIPEMD160 */\n\n#define RIPEMD160_DIGEST_SIZE 20\n#define RIPEMD160_BLOCK_SIZE 64\n/* For backwards compatibility */\n#define RIPEMD160_DATA_SIZE RIPEMD160_BLOCK_SIZE\n\n/* Digest is kept internally as 5 32-bit words. */\n#define _RIPEMD160_DIGEST_LENGTH 5\n\nstruct ripemd160_ctx\n{\n  uint32_t state[_RIPEMD160_DIGEST_LENGTH];\n  uint64_t count;         /* 64-bit block count */\n  unsigned int index;\n  uint8_t block[RIPEMD160_BLOCK_SIZE];\n};\n\nvoid\nripemd160_init(struct ripemd160_ctx *ctx);\n\nvoid\nripemd160_update(struct ripemd160_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nripemd160_digest(struct ripemd160_ctx *ctx,\n\t\t size_t length,\n\t\t uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_RIPEMD160_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/rsa.h",
    "content": "/* rsa.h\n\n   The RSA publickey algorithm.\n\n   Copyright (C) 2001, 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_RSA_H_INCLUDED\n#define NETTLE_RSA_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#include \"md5.h\"\n#include \"sha1.h\"\n#include \"sha2.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define rsa_public_key_init nettle_rsa_public_key_init\n#define rsa_public_key_clear nettle_rsa_public_key_clear\n#define rsa_public_key_prepare nettle_rsa_public_key_prepare\n#define rsa_private_key_init nettle_rsa_private_key_init\n#define rsa_private_key_clear nettle_rsa_private_key_clear\n#define rsa_private_key_prepare nettle_rsa_private_key_prepare\n#define rsa_pkcs1_verify nettle_rsa_pkcs1_verify\n#define rsa_pkcs1_sign nettle_rsa_pkcs1_sign\n#define rsa_pkcs1_sign_tr nettle_rsa_pkcs1_sign_tr\n#define rsa_md5_sign nettle_rsa_md5_sign\n#define rsa_md5_sign_tr nettle_rsa_md5_sign_tr\n#define rsa_md5_verify nettle_rsa_md5_verify\n#define rsa_sha1_sign nettle_rsa_sha1_sign\n#define rsa_sha1_sign_tr nettle_rsa_sha1_sign_tr\n#define rsa_sha1_verify nettle_rsa_sha1_verify\n#define rsa_sha256_sign nettle_rsa_sha256_sign\n#define rsa_sha256_sign_tr nettle_rsa_sha256_sign_tr\n#define rsa_sha256_verify nettle_rsa_sha256_verify\n#define rsa_sha512_sign nettle_rsa_sha512_sign\n#define rsa_sha512_sign_tr nettle_rsa_sha512_sign_tr\n#define rsa_sha512_verify nettle_rsa_sha512_verify\n#define rsa_md5_sign_digest nettle_rsa_md5_sign_digest\n#define rsa_md5_sign_digest_tr nettle_rsa_md5_sign_digest_tr\n#define rsa_md5_verify_digest nettle_rsa_md5_verify_digest\n#define rsa_sha1_sign_digest nettle_rsa_sha1_sign_digest\n#define rsa_sha1_sign_digest_tr nettle_rsa_sha1_sign_digest_tr\n#define rsa_sha1_verify_digest nettle_rsa_sha1_verify_digest\n#define rsa_sha256_sign_digest nettle_rsa_sha256_sign_digest\n#define rsa_sha256_sign_digest_tr nettle_rsa_sha256_sign_digest_tr\n#define rsa_sha256_verify_digest nettle_rsa_sha256_verify_digest\n#define rsa_sha512_sign_digest nettle_rsa_sha512_sign_digest\n#define rsa_sha512_sign_digest_tr nettle_rsa_sha512_sign_digest_tr\n#define rsa_sha512_verify_digest nettle_rsa_sha512_verify_digest\n#define rsa_pss_sha256_sign_digest_tr nettle_rsa_pss_sha256_sign_digest_tr\n#define rsa_pss_sha256_verify_digest nettle_rsa_pss_sha256_verify_digest\n#define rsa_pss_sha384_sign_digest_tr nettle_rsa_pss_sha384_sign_digest_tr\n#define rsa_pss_sha384_verify_digest nettle_rsa_pss_sha384_verify_digest\n#define rsa_pss_sha512_sign_digest_tr nettle_rsa_pss_sha512_sign_digest_tr\n#define rsa_pss_sha512_verify_digest nettle_rsa_pss_sha512_verify_digest\n#define rsa_encrypt nettle_rsa_encrypt\n#define rsa_decrypt nettle_rsa_decrypt\n#define rsa_decrypt_tr nettle_rsa_decrypt_tr\n#define rsa_sec_decrypt nettle_rsa_sec_decrypt\n#define rsa_compute_root nettle_rsa_compute_root\n#define rsa_compute_root_tr nettle_rsa_compute_root_tr\n#define rsa_generate_keypair nettle_rsa_generate_keypair\n#define rsa_keypair_to_sexp nettle_rsa_keypair_to_sexp\n#define rsa_keypair_from_sexp_alist nettle_rsa_keypair_from_sexp_alist\n#define rsa_keypair_from_sexp nettle_rsa_keypair_from_sexp\n#define rsa_public_key_from_der_iterator nettle_rsa_public_key_from_der_iterator\n#define rsa_private_key_from_der_iterator nettle_rsa_private_key_from_der_iterator\n#define rsa_keypair_from_der nettle_rsa_keypair_from_der\n#define rsa_keypair_to_openpgp nettle_rsa_keypair_to_openpgp\n\n/* This limit is somewhat arbitrary. Technically, the smallest modulo\n   which makes sense at all is 15 = 3*5, phi(15) = 8, size 4 bits. But\n   for ridiculously small keys, not all odd e are possible (e.g., for\n   5 bits, the only possible modulo is 3*7 = 21, phi(21) = 12, and e =\n   3 don't work). The smallest size that makes sense with pkcs#1, and\n   which allows RSA encryption of one byte messages, is 12 octets, 89\n   bits. */\n\n#define RSA_MINIMUM_N_OCTETS 12\n#define RSA_MINIMUM_N_BITS (8*RSA_MINIMUM_N_OCTETS - 7)\n\nstruct rsa_public_key\n{\n  /* Size of the modulo, in octets. This is also the size of all\n   * signatures that are created or verified with this key. */\n  size_t size;\n  \n  /* Modulo */\n  mpz_t n;\n\n  /* Public exponent */\n  mpz_t e;\n};\n\nstruct rsa_private_key\n{\n  size_t size;\n\n  /* d is filled in by the key generation function; otherwise it's\n   * completely unused. */\n  mpz_t d;\n  \n  /* The two factors */\n  mpz_t p; mpz_t q;\n\n  /* d % (p-1), i.e. a e = 1 (mod (p-1)) */\n  mpz_t a;\n\n  /* d % (q-1), i.e. b e = 1 (mod (q-1)) */\n  mpz_t b;\n\n  /* modular inverse of q , i.e. c q = 1 (mod p) */\n  mpz_t c;\n};\n\n/* Signing a message works as follows:\n *\n * Store the private key in a rsa_private_key struct.\n *\n * Call rsa_private_key_prepare. This initializes the size attribute\n * to the length of a signature.\n *\n * Initialize a hashing context, by callling\n *   md5_init\n *\n * Hash the message by calling\n *   md5_update\n *\n * Create the signature by calling\n *   rsa_md5_sign\n *\n * The signature is represented as a mpz_t bignum. This call also\n * resets the hashing context.\n *\n * When done with the key and signature, don't forget to call\n * mpz_clear.\n */\n \n/* Calls mpz_init to initialize bignum storage. */\nvoid\nrsa_public_key_init(struct rsa_public_key *key);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\nrsa_public_key_clear(struct rsa_public_key *key);\n\nint\nrsa_public_key_prepare(struct rsa_public_key *key);\n\n/* Calls mpz_init to initialize bignum storage. */\nvoid\nrsa_private_key_init(struct rsa_private_key *key);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\nrsa_private_key_clear(struct rsa_private_key *key);\n\nint\nrsa_private_key_prepare(struct rsa_private_key *key);\n\n\n/* PKCS#1 style signatures */\nint\nrsa_pkcs1_sign(const struct rsa_private_key *key,\n\t       size_t length, const uint8_t *digest_info,\n\t       mpz_t s);\n\nint\nrsa_pkcs1_sign_tr(const struct rsa_public_key *pub,\n  \t          const struct rsa_private_key *key,\n\t          void *random_ctx, nettle_random_func *random,\n\t          size_t length, const uint8_t *digest_info,\n   \t          mpz_t s);\nint\nrsa_pkcs1_verify(const struct rsa_public_key *key,\n\t\t size_t length, const uint8_t *digest_info,\n\t\t const mpz_t signature);\n\nint\nrsa_md5_sign(const struct rsa_private_key *key,\n             struct md5_ctx *hash,\n             mpz_t signature);\n\nint\nrsa_md5_sign_tr(const struct rsa_public_key *pub,\n\t\tconst struct rsa_private_key *key,\n\t\tvoid *random_ctx, nettle_random_func *random,\n\t\tstruct md5_ctx *hash, mpz_t s);\n\n\nint\nrsa_md5_verify(const struct rsa_public_key *key,\n               struct md5_ctx *hash,\n\t       const mpz_t signature);\n\nint\nrsa_sha1_sign(const struct rsa_private_key *key,\n              struct sha1_ctx *hash,\n              mpz_t signature);\n\nint\nrsa_sha1_sign_tr(const struct rsa_public_key *pub,\n\t\t const struct rsa_private_key *key,\n\t\t void *random_ctx, nettle_random_func *random,\n\t\t struct sha1_ctx *hash,\n\t\t mpz_t s);\n\nint\nrsa_sha1_verify(const struct rsa_public_key *key,\n                struct sha1_ctx *hash,\n\t\tconst mpz_t signature);\n\nint\nrsa_sha256_sign(const struct rsa_private_key *key,\n\t\tstruct sha256_ctx *hash,\n\t\tmpz_t signature);\n\nint\nrsa_sha256_sign_tr(const struct rsa_public_key *pub,\n\t\t   const struct rsa_private_key *key,\n\t\t   void *random_ctx, nettle_random_func *random,\n\t\t   struct sha256_ctx *hash,\n\t\t   mpz_t s);\n\nint\nrsa_sha256_verify(const struct rsa_public_key *key,\n\t\t  struct sha256_ctx *hash,\n\t\t  const mpz_t signature);\n\nint\nrsa_sha512_sign(const struct rsa_private_key *key,\n\t\tstruct sha512_ctx *hash,\n\t\tmpz_t signature);\n\nint\nrsa_sha512_sign_tr(const struct rsa_public_key *pub,\n\t\t   const struct rsa_private_key *key,\n\t\t   void *random_ctx, nettle_random_func *random,\n\t\t   struct sha512_ctx *hash,\n\t\t   mpz_t s);\n\nint\nrsa_sha512_verify(const struct rsa_public_key *key,\n\t\t  struct sha512_ctx *hash,\n\t\t  const mpz_t signature);\n\n/* Variants taking the digest as argument. */\nint\nrsa_md5_sign_digest(const struct rsa_private_key *key,\n\t\t    const uint8_t *digest,\n\t\t    mpz_t s);\n\nint\nrsa_md5_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t       const struct rsa_private_key *key,\n\t\t       void *random_ctx, nettle_random_func *random,\n\t\t       const uint8_t *digest, mpz_t s);\n\nint\nrsa_md5_verify_digest(const struct rsa_public_key *key,\n\t\t      const uint8_t *digest,\n\t\t      const mpz_t signature);\n\nint\nrsa_sha1_sign_digest(const struct rsa_private_key *key,\n\t\t     const uint8_t *digest,\n\t\t     mpz_t s);\n\nint\nrsa_sha1_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\tconst struct rsa_private_key *key,\n\t\t\tvoid *random_ctx, nettle_random_func *random,\n\t\t\tconst uint8_t *digest,\n\t\t\tmpz_t s);\n\nint\nrsa_sha1_verify_digest(const struct rsa_public_key *key,\n\t\t       const uint8_t *digest,\n\t\t       const mpz_t signature);\n\nint\nrsa_sha256_sign_digest(const struct rsa_private_key *key,\n\t\t       const uint8_t *digest,\n\t\t       mpz_t s);\n\nint\nrsa_sha256_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t  const struct rsa_private_key *key,\n\t\t\t  void *random_ctx, nettle_random_func *random,\n\t\t\t  const uint8_t *digest,\n\t\t\t  mpz_t s);\n\nint\nrsa_sha256_verify_digest(const struct rsa_public_key *key,\n\t\t\t const uint8_t *digest,\n\t\t\t const mpz_t signature);\n\nint\nrsa_sha512_sign_digest(const struct rsa_private_key *key,\n\t\t       const uint8_t *digest,\n\t\t       mpz_t s);\n\nint\nrsa_sha512_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t  const struct rsa_private_key *key,\n\t\t\t  void *random_ctx, nettle_random_func *random,\n\t\t\t  const uint8_t *digest,\n\t\t\t  mpz_t s);\n\nint\nrsa_sha512_verify_digest(const struct rsa_public_key *key,\n\t\t\t const uint8_t *digest,\n\t\t\t const mpz_t signature);\n\n/* PSS style signatures */\nint\nrsa_pss_sha256_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t      const struct rsa_private_key *key,\n\t\t\t      void *random_ctx, nettle_random_func *random,\n\t\t\t      size_t salt_length, const uint8_t *salt,\n\t\t\t      const uint8_t *digest,\n\t\t\t      mpz_t s);\n\nint\nrsa_pss_sha256_verify_digest(const struct rsa_public_key *key,\n\t\t\t     size_t salt_length,\n\t\t\t     const uint8_t *digest,\n\t\t\t     const mpz_t signature);\n\nint\nrsa_pss_sha384_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t      const struct rsa_private_key *key,\n\t\t\t      void *random_ctx, nettle_random_func *random,\n\t\t\t      size_t salt_length, const uint8_t *salt,\n\t\t\t      const uint8_t *digest,\n\t\t\t      mpz_t s);\n\nint\nrsa_pss_sha384_verify_digest(const struct rsa_public_key *key,\n\t\t\t     size_t salt_length,\n\t\t\t     const uint8_t *digest,\n\t\t\t     const mpz_t signature);\n\nint\nrsa_pss_sha512_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t      const struct rsa_private_key *key,\n\t\t\t      void *random_ctx, nettle_random_func *random,\n\t\t\t      size_t salt_length, const uint8_t *salt,\n\t\t\t      const uint8_t *digest,\n\t\t\t      mpz_t s);\n\nint\nrsa_pss_sha512_verify_digest(const struct rsa_public_key *key,\n\t\t\t     size_t salt_length,\n\t\t\t     const uint8_t *digest,\n\t\t\t     const mpz_t signature);\n\n\n/* RSA encryption, using PKCS#1 */\n/* These functions uses the v1.5 padding. What should the v2 (OAEP)\n * functions be called? */\n\n/* Returns 1 on success, 0 on failure, which happens if the\n * message is too long for the key. */\nint\nrsa_encrypt(const struct rsa_public_key *key,\n\t    /* For padding */\n\t    void *random_ctx, nettle_random_func *random,\n\t    size_t length, const uint8_t *cleartext,\n\t    mpz_t cipher);\n\n/* Message must point to a buffer of size *LENGTH. KEY->size is enough\n * for all valid messages. On success, *LENGTH is updated to reflect\n * the actual length of the message. Returns 1 on success, 0 on\n * failure, which happens if decryption failed or if the message\n * didn't fit. */\nint\nrsa_decrypt(const struct rsa_private_key *key,\n\t    size_t *length, uint8_t *cleartext,\n\t    const mpz_t ciphertext);\n\n/* Timing-resistant version, using randomized RSA blinding. */\nint\nrsa_decrypt_tr(const struct rsa_public_key *pub,\n\t       const struct rsa_private_key *key,\n\t       void *random_ctx, nettle_random_func *random,\t       \n\t       size_t *length, uint8_t *message,\n\t       const mpz_t gibberish);\n\n/* like rsa_decrypt_tr but with additional side-channel resistance.\n * NOTE: the length of the final message must be known in advance. */\nint\nrsa_sec_decrypt(const struct rsa_public_key *pub,\n\t        const struct rsa_private_key *key,\n\t        void *random_ctx, nettle_random_func *random,\n\t        size_t length, uint8_t *message,\n\t        const mpz_t gibberish);\n\n/* Compute x, the e:th root of m. Calling it with x == m is allowed.\n   It is required that 0 <= m < n. */\nvoid\nrsa_compute_root(const struct rsa_private_key *key,\n\t\t mpz_t x, const mpz_t m);\n\n/* Safer variant, using RSA blinding, and checking the result after\n   CRT. It is required that 0 <= m < n. */\nint\nrsa_compute_root_tr(const struct rsa_public_key *pub,\n\t\t    const struct rsa_private_key *key,\n\t\t    void *random_ctx, nettle_random_func *random,\n\t\t    mpz_t x, const mpz_t m);\n\n/* Key generation */\n\n/* Note that the key structs must be initialized first. */\nint\nrsa_generate_keypair(struct rsa_public_key *pub,\n\t\t     struct rsa_private_key *key,\n\n\t\t     void *random_ctx, nettle_random_func *random,\n\t\t     void *progress_ctx, nettle_progress_func *progress,\n\n\t\t     /* Desired size of modulo, in bits */\n\t\t     unsigned n_size,\n\t\t     \n\t\t     /* Desired size of public exponent, in bits. If\n\t\t      * zero, the passed in value pub->e is used. */\n\t\t     unsigned e_size);\n\n\n#define RSA_SIGN(key, algorithm, ctx, length, data, signature) ( \\\n  algorithm##_update(ctx, length, data), \\\n  rsa_##algorithm##_sign(key, ctx, signature) \\\n)\n\n#define RSA_VERIFY(key, algorithm, ctx, length, data, signature) ( \\\n  algorithm##_update(ctx, length, data), \\\n  rsa_##algorithm##_verify(key, ctx, signature) \\\n)\n\n\f\n/* Keys in sexp form. */\n\nstruct nettle_buffer;\n\n/* Generates a public-key expression if PRIV is NULL .*/\nint\nrsa_keypair_to_sexp(struct nettle_buffer *buffer,\n\t\t    const char *algorithm_name, /* NULL means \"rsa\" */\n\t\t    const struct rsa_public_key *pub,\n\t\t    const struct rsa_private_key *priv);\n\nstruct sexp_iterator;\n\nint\nrsa_keypair_from_sexp_alist(struct rsa_public_key *pub,\n\t\t\t    struct rsa_private_key *priv,\n\t\t\t    unsigned limit,\n\t\t\t    struct sexp_iterator *i);\n\n/* If PRIV is NULL, expect a public-key expression. If PUB is NULL,\n * expect a private key expression and ignore the parts not needed for\n * the public key. */\n/* Keys must be initialized before calling this function, as usual. */\nint\nrsa_keypair_from_sexp(struct rsa_public_key *pub,\n\t\t      struct rsa_private_key *priv,\n\t\t      unsigned limit,\n\t\t      size_t length, const uint8_t *expr);\n\n\n/* Keys in PKCS#1 format. */\nstruct asn1_der_iterator;\n\nint\nrsa_public_key_from_der_iterator(struct rsa_public_key *pub,\n\t\t\t\t unsigned limit,\n\t\t\t\t struct asn1_der_iterator *i);\n\nint\nrsa_private_key_from_der_iterator(struct rsa_public_key *pub,\n\t\t\t\t  struct rsa_private_key *priv,\n\t\t\t\t  unsigned limit,\n\t\t\t\t  struct asn1_der_iterator *i);\n\n/* For public keys, use PRIV == NULL */ \nint\nrsa_keypair_from_der(struct rsa_public_key *pub,\n\t\t     struct rsa_private_key *priv,\n\t\t     unsigned limit, \n\t\t     size_t length, const uint8_t *data);\n\n/* OpenPGP format. Experimental interface, subject to change. */\nint\nrsa_keypair_to_openpgp(struct nettle_buffer *buffer,\n\t\t       const struct rsa_public_key *pub,\n\t\t       const struct rsa_private_key *priv,\n\t\t       /* A single user id. NUL-terminated utf8. */\n\t\t       const char *userid);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_RSA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/salsa20.h",
    "content": "/* salsa20.h\n\n   The Salsa20 stream cipher.\n\n   Copyright (C) 2012 Simon Josefsson\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SALSA20_H_INCLUDED\n#define NETTLE_SALSA20_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define salsa20_set_key nettle_salsa20_set_key\n#define salsa20_128_set_key nettle_salsa20_128_set_key\n#define salsa20_256_set_key nettle_salsa20_256_set_key\n#define salsa20_set_nonce nettle_salsa20_set_nonce\n#define salsa20_crypt nettle_salsa20_crypt\n\n#define salsa20r12_crypt nettle_salsa20r12_crypt\n\n/* Alias for backwards compatibility */\n#define salsa20_set_iv nettle_salsa20_set_nonce\n\n/* In octets.*/\n#define SALSA20_128_KEY_SIZE 16\n#define SALSA20_256_KEY_SIZE 32\n#define SALSA20_BLOCK_SIZE 64\n#define SALSA20_NONCE_SIZE 8\n#define SALSA20_IV_SIZE SALSA20_NONCE_SIZE\n\n/* Aliases */\n#define SALSA20_MIN_KEY_SIZE 16\n#define SALSA20_MAX_KEY_SIZE 32\n#define SALSA20_KEY_SIZE 32\n\n#define _SALSA20_INPUT_LENGTH 16\n\nstruct salsa20_ctx\n{\n  /* Indices 1-4 and 11-14 holds the key (two identical copies for the\n     shorter key size), indices 0, 5, 10, 15 are constant, indices 6, 7\n     are the IV, and indices 8, 9 are the block counter:\n\n     C K K K\n     K C I I\n     B B C K\n     K K K C\n  */\n  uint32_t input[_SALSA20_INPUT_LENGTH];\n};\n\nvoid\nsalsa20_128_set_key(struct salsa20_ctx *ctx, const uint8_t *key);\nvoid\nsalsa20_256_set_key(struct salsa20_ctx *ctx, const uint8_t *key);\n\nvoid\nsalsa20_set_key(struct salsa20_ctx *ctx,\n\t\tsize_t length, const uint8_t *key);\n\nvoid\nsalsa20_set_nonce(struct salsa20_ctx *ctx, const uint8_t *nonce);\n  \nvoid\nsalsa20_crypt(struct salsa20_ctx *ctx,\n\t      size_t length, uint8_t *dst,\n\t      const uint8_t *src);\n\nvoid\nsalsa20r12_crypt(struct salsa20_ctx *ctx,\n\t\t size_t length, uint8_t *dst,\n\t\t const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SALSA20_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/serpent.h",
    "content": "/* serpent.h\n\n   The serpent block cipher.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Serpent is a 128-bit block cipher that accepts a key size of 256\n * bits, designed by Ross Anderson, Eli Biham, and Lars Knudsen. See\n * http://www.cl.cam.ac.uk/~rja14/serpent.html for details.\n */\n\n#ifndef NETTLE_SERPENT_H_INCLUDED\n#define NETTLE_SERPENT_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define serpent_set_key nettle_serpent_set_key\n#define serpent128_set_key nettle_serpent128_set_key\n#define serpent192_set_key nettle_serpent192_set_key\n#define serpent256_set_key nettle_serpent256_set_key\n#define serpent_encrypt nettle_serpent_encrypt\n#define serpent_decrypt nettle_serpent_decrypt\n\n#define SERPENT_BLOCK_SIZE 16\n\n/* Other key lengths are possible, but the design of Serpent makes\n * smaller key lengths quite pointless; they cheated with the AES\n * requirements, using a 256-bit key length exclusively and just\n * padding it out if the desired key length was less, so there really\n * is no advantage to using key lengths less than 256 bits. */\n#define SERPENT_KEY_SIZE 32\n\n/* Allow keys of size 128 <= bits <= 256 */\n\n#define SERPENT_MIN_KEY_SIZE 16\n#define SERPENT_MAX_KEY_SIZE 32\n\n#define SERPENT128_KEY_SIZE 16\n#define SERPENT192_KEY_SIZE 24\n#define SERPENT256_KEY_SIZE 32\n\nstruct serpent_ctx\n{\n  uint32_t keys[33][4];  /* key schedule */\n};\n\nvoid\nserpent_set_key(struct serpent_ctx *ctx,\n                size_t length, const uint8_t *key);\nvoid\nserpent128_set_key(struct serpent_ctx *ctx, const uint8_t *key);\nvoid\nserpent192_set_key(struct serpent_ctx *ctx, const uint8_t *key);\nvoid\nserpent256_set_key(struct serpent_ctx *ctx, const uint8_t *key);\n\nvoid\nserpent_encrypt(const struct serpent_ctx *ctx,\n                size_t length, uint8_t *dst,\n                const uint8_t *src);\nvoid\nserpent_decrypt(const struct serpent_ctx *ctx,\n                size_t length, uint8_t *dst,\n                const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SERPENT_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/sexp.h",
    "content": "/* sexp.h\n\n   Parsing s-expressions.\n   Copyright (C) 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_SEXP_H_INCLUDED\n#define NETTLE_SEXP_H_INCLUDED\n\n#include <stdarg.h>\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sexp_iterator_first nettle_sexp_iterator_first\n#define sexp_transport_iterator_first nettle_sexp_transport_iterator_first\n#define sexp_iterator_next nettle_sexp_iterator_next\n#define sexp_iterator_enter_list nettle_sexp_iterator_enter_list\n#define sexp_iterator_exit_list nettle_sexp_iterator_exit_list\n#define sexp_iterator_subexpr nettle_sexp_iterator_subexpr\n#define sexp_iterator_get_uint32 nettle_sexp_iterator_get_uint32\n#define sexp_iterator_check_type nettle_sexp_iterator_check_type\n#define sexp_iterator_check_types nettle_sexp_iterator_check_types\n#define sexp_iterator_assoc nettle_sexp_iterator_assoc\n#define sexp_format nettle_sexp_format\n#define sexp_vformat nettle_sexp_vformat\n#define sexp_transport_format nettle_sexp_transport_format\n#define sexp_transport_vformat nettle_sexp_transport_vformat\n#define sexp_token_chars nettle_sexp_token_chars\n\nenum sexp_type\n  { SEXP_ATOM, SEXP_LIST, SEXP_END };\n\nstruct sexp_iterator\n{\n  size_t length;\n  const uint8_t *buffer;\n\n  /* Points at the start of the current sub expression. */\n  size_t start;\n  /* If type is SEXP_LIST, pos points at the start of the current\n   * element. Otherwise, it points at the end. */\n  size_t pos;\n  unsigned level;\n\n  enum sexp_type type;\n  \n  size_t display_length;\n  const uint8_t *display;\n\n  size_t atom_length;\n  const uint8_t *atom;\n};\n\n\n/* All these functions return 1 on success, 0 on failure */\n\n/* Initializes the iterator. */\nint\nsexp_iterator_first(struct sexp_iterator *iterator,\n\t\t    size_t length, const uint8_t *input);\n\n/* NOTE: Decodes the input string in place */\nint\nsexp_transport_iterator_first(struct sexp_iterator *iterator,\n\t\t\t      size_t length, uint8_t *input);\n\nint\nsexp_iterator_next(struct sexp_iterator *iterator);\n\n/* Current element must be a list. */\nint\nsexp_iterator_enter_list(struct sexp_iterator *iterator);\n\n/* Skips the rest of the current list */\nint\nsexp_iterator_exit_list(struct sexp_iterator *iterator);\n\n#if 0\n/* Skips out of as many lists as necessary to get back to the given\n * level. */\nint\nsexp_iterator_exit_lists(struct sexp_iterator *iterator,\n\t\t\t unsigned level);\n#endif\n\n/* Gets start and length of the current subexpression. Implies\n * sexp_iterator_next. */\nconst uint8_t *\nsexp_iterator_subexpr(struct sexp_iterator *iterator,\n\t\t      size_t *length);\n\nint\nsexp_iterator_get_uint32(struct sexp_iterator *iterator,\n\t\t\t uint32_t *x);\n\n\f\n/* Checks the type of the current expression, which should be a list\n *\n *  (<type> ...)\n */\nint\nsexp_iterator_check_type(struct sexp_iterator *iterator,\n\t\t\t const char *type);\n\nconst char *\nsexp_iterator_check_types(struct sexp_iterator *iterator,\n\t\t\t  unsigned ntypes,\n\t\t\t  const char * const *types);\n\n/* Current element must be a list. Looks up element of type\n *\n *   (key rest...)\n *\n * For a matching key, the corresponding iterator is initialized\n * pointing at the start of REST.\n *\n * On success, exits the current list.\n */\nint\nsexp_iterator_assoc(struct sexp_iterator *iterator,\n\t\t    unsigned nkeys,\n\t\t    const char * const *keys,\n\t\t    struct sexp_iterator *values);\n\n\f\n/* Output functions. What is a reasonable API for this? It seems\n * ugly to have to reimplement string streams. */\n\n/* Declared for real in buffer.h */\nstruct nettle_buffer;\n\n/* Returns the number of output characters, or 0 on out of memory. If\n * buffer == NULL, just compute length.\n *\n * Format strings can contained matched parentheses, tokens (\"foo\" in\n * the format string is formatted as \"3:foo\"), whitespace (which\n * separates tokens but is otherwise ignored) and the following\n * formatting specifiers:\n *\n *   %s   String represented as size_t length, const uint8_t *data.\n *\n *   %t   Optional display type, represented as\n *        size_t display_length, const uint8_t *display,\n *        display == NULL means no display type.\n *\n *   %i   Non-negative small integer, uint32_t.\n *\n *   %b   Non-negative bignum, mpz_t.\n *\n *   %l   Literal string (no length added), typically a balanced\n *        subexpression. Represented as size_t length, const uint8_t\n *        *data.\n *\n *   %(, %)  Allows insertion of unbalanced parenthesis.\n *\n * Modifiers:\n *\n *   %0   For %s, %t and %l, says that there's no length argument,\n *        instead the string is NUL-terminated, and there's only one\n *        const uint8_t * argument.\n */\n \nsize_t\nsexp_format(struct nettle_buffer *buffer,\n\t    const char *format, ...);\n\nsize_t\nsexp_vformat(struct nettle_buffer *buffer,\n\t     const char *format, va_list args);\n\nsize_t\nsexp_transport_format(struct nettle_buffer *buffer,\n\t\t      const char *format, ...);\n\nsize_t\nsexp_transport_vformat(struct nettle_buffer *buffer,\n\t\t       const char *format, va_list args);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SEXP_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/sha.h",
    "content": "/* sha.h\n\n   This file is deprecated, and provided only for backwards\n   compatibility with earlier versions of Nettle. Please use sha1.h\n   and/or sha2.h instead.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SHA_H_INCLUDED\n#define NETTLE_SHA_H_INCLUDED\n\n#include \"sha1.h\"\n#include \"sha2.h\"\n\n#endif /* NETTLE_SHA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/sha1.h",
    "content": "/* sha1.h\n\n   The sha1 hash function.\n\n   Copyright (C) 2001, 2012 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_SHA1_H_INCLUDED\n#define NETTLE_SHA1_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sha1_init nettle_sha1_init\n#define sha1_update nettle_sha1_update\n#define sha1_digest nettle_sha1_digest\n#define sha1_compress nettle_sha1_compress\n\n/* SHA1 */\n\n#define SHA1_DIGEST_SIZE 20\n#define SHA1_BLOCK_SIZE 64\n/* For backwards compatibility */\n#define SHA1_DATA_SIZE SHA1_BLOCK_SIZE\n\n/* Digest is kept internally as 5 32-bit words. */\n#define _SHA1_DIGEST_LENGTH 5\n\nstruct sha1_ctx\n{\n  uint32_t state[_SHA1_DIGEST_LENGTH];    /* State variables */\n  uint64_t count;                         /* 64-bit block count */\n  unsigned int index;                     /* index into buffer */\n  uint8_t block[SHA1_BLOCK_SIZE];         /* SHA1 data buffer */\n};\n\nvoid\nsha1_init(struct sha1_ctx *ctx);\n\nvoid\nsha1_update(struct sha1_ctx *ctx,\n\t    size_t length,\n\t    const uint8_t *data);\n\nvoid\nsha1_digest(struct sha1_ctx *ctx,\n\t    size_t length,\n\t    uint8_t *digest);\n\n/* SHA1 compression function. STATE points to 5 uint32_t words,\n   and DATA points to 64 bytes of input data, possibly unaligned. */\nvoid\nsha1_compress(uint32_t *state, const uint8_t *data);\n\n/* Old name, for backwards compatibility. */\n#define _nettle_sha1_compress nettle_sha1_compress\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SHA1_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/sha2.h",
    "content": "/* sha2.h\n\n   The sha2 family of hash functions.\n\n   Copyright (C) 2001, 2012 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_SHA2_H_INCLUDED\n#define NETTLE_SHA2_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sha224_init nettle_sha224_init\n#define sha224_digest nettle_sha224_digest\n#define sha256_init nettle_sha256_init\n#define sha256_update nettle_sha256_update\n#define sha256_digest nettle_sha256_digest\n#define sha256_compress nettle_sha256_compress\n#define sha384_init nettle_sha384_init\n#define sha384_digest nettle_sha384_digest\n#define sha512_init nettle_sha512_init\n#define sha512_update nettle_sha512_update\n#define sha512_digest nettle_sha512_digest\n#define sha512_compress nettle_sha512_compress\n#define sha512_224_init   nettle_sha512_224_init\n#define sha512_224_digest nettle_sha512_224_digest\n#define sha512_256_init   nettle_sha512_256_init\n#define sha512_256_digest nettle_sha512_256_digest\n\n/* For backwards compatibility */\n#define SHA224_DATA_SIZE SHA256_BLOCK_SIZE\n#define SHA256_DATA_SIZE SHA256_BLOCK_SIZE\n#define SHA512_DATA_SIZE SHA512_BLOCK_SIZE\n#define SHA384_DATA_SIZE SHA512_BLOCK_SIZE\n\n/* SHA256 */\n\n#define SHA256_DIGEST_SIZE 32\n#define SHA256_BLOCK_SIZE 64\n\n/* Digest is kept internally as 8 32-bit words. */\n#define _SHA256_DIGEST_LENGTH 8\n\nstruct sha256_ctx\n{\n  uint32_t state[_SHA256_DIGEST_LENGTH];    /* State variables */\n  uint64_t count;                           /* 64-bit block count */\n  unsigned int index;                       /* index into buffer */\n  uint8_t block[SHA256_BLOCK_SIZE];          /* SHA256 data buffer */\n};\n\nvoid\nsha256_init(struct sha256_ctx *ctx);\n\nvoid\nsha256_update(struct sha256_ctx *ctx,\n\t      size_t length,\n\t      const uint8_t *data);\n\nvoid\nsha256_digest(struct sha256_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\nvoid\nsha256_compress(uint32_t *state, const uint8_t *input);\n\n/* SHA224, a truncated SHA256 with different initial state. */\n\n#define SHA224_DIGEST_SIZE 28\n#define SHA224_BLOCK_SIZE SHA256_BLOCK_SIZE\n#define sha224_ctx sha256_ctx\n\nvoid\nsha224_init(struct sha256_ctx *ctx);\n\n#define sha224_update nettle_sha256_update\n\nvoid\nsha224_digest(struct sha256_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\n\n/* SHA512 */\n\n#define SHA512_DIGEST_SIZE 64\n#define SHA512_BLOCK_SIZE 128\n\n/* Digest is kept internally as 8 64-bit words. */\n#define _SHA512_DIGEST_LENGTH 8\n\nstruct sha512_ctx\n{\n  uint64_t state[_SHA512_DIGEST_LENGTH];    /* State variables */\n  uint64_t count_low, count_high;           /* 128-bit block count */\n  unsigned int index;                       /* index into buffer */\n  uint8_t block[SHA512_BLOCK_SIZE];          /* SHA512 data buffer */\n};\n\nvoid\nsha512_init(struct sha512_ctx *ctx);\n\nvoid\nsha512_update(struct sha512_ctx *ctx,\n\t      size_t length,\n\t      const uint8_t *data);\n\nvoid\nsha512_digest(struct sha512_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\nvoid\nsha512_compress(uint64_t *state, const uint8_t *input);\n\n/* SHA384, a truncated SHA512 with different initial state. */\n\n#define SHA384_DIGEST_SIZE 48\n#define SHA384_BLOCK_SIZE SHA512_BLOCK_SIZE\n#define sha384_ctx sha512_ctx\n\nvoid\nsha384_init(struct sha512_ctx *ctx);\n\n#define sha384_update nettle_sha512_update\n\nvoid\nsha384_digest(struct sha512_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\n\n/* SHA512_224 and SHA512_256, two truncated versions of SHA512 \n   with different initial states. */\n\n#define SHA512_224_DIGEST_SIZE 28\n#define SHA512_224_BLOCK_SIZE SHA512_BLOCK_SIZE\n#define sha512_224_ctx sha512_ctx\n\nvoid\nsha512_224_init(struct sha512_224_ctx *ctx);\n\n#define sha512_224_update nettle_sha512_update\n\nvoid\nsha512_224_digest(struct sha512_224_ctx *ctx,\n                  size_t length,\n                  uint8_t *digest);\n\n#define SHA512_256_DIGEST_SIZE 32\n#define SHA512_256_BLOCK_SIZE SHA512_BLOCK_SIZE\n#define sha512_256_ctx sha512_ctx\n\nvoid\nsha512_256_init(struct sha512_256_ctx *ctx);\n\n#define sha512_256_update nettle_sha512_update\n\nvoid\nsha512_256_digest(struct sha512_256_ctx *ctx,\n                  size_t length,\n                  uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SHA2_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/sha3.h",
    "content": "/* sha3.h\n\n   The sha3 hash function (aka Keccak).\n\n   Copyright (C) 2012 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_SHA3_H_INCLUDED\n#define NETTLE_SHA3_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sha3_permute nettle_sha3_permute\n#define sha3_224_init nettle_sha3_224_init\n#define sha3_224_update nettle_sha3_224_update\n#define sha3_224_digest nettle_sha3_224_digest\n#define sha3_256_init nettle_sha3_256_init\n#define sha3_256_update nettle_sha3_256_update\n#define sha3_256_digest nettle_sha3_256_digest\n#define sha3_256_shake nettle_sha3_256_shake\n#define sha3_384_init nettle_sha3_384_init\n#define sha3_384_update nettle_sha3_384_update\n#define sha3_384_digest nettle_sha3_384_digest\n#define sha3_512_init nettle_sha3_512_init\n#define sha3_512_update nettle_sha3_512_update\n#define sha3_512_digest nettle_sha3_512_digest\n\n/* Indicates that SHA3 is the NIST FIPS 202 version. */\n#define NETTLE_SHA3_FIPS202 1\n\n/* The sha3 state is a 5x5 matrix of 64-bit words. In the notation of\n   Keccak description, S[x,y] is element x + 5*y, so if x is\n   interpreted as the row index and y the column index, it is stored\n   in column-major order. */\n#define SHA3_STATE_LENGTH 25\n\n/* The \"width\" is 1600 bits or 200 octets */\nstruct sha3_state\n{\n  uint64_t a[SHA3_STATE_LENGTH];\n};\n\nvoid\nsha3_permute (struct sha3_state *state);\n\n/* The \"capacity\" is set to 2*(digest size), 512 bits or 64 octets.\n   The \"rate\" is the width - capacity, or width - 2 * (digest\n   size). */\n\n#define SHA3_224_DIGEST_SIZE 28\n#define SHA3_224_BLOCK_SIZE 144\n\n#define SHA3_256_DIGEST_SIZE 32\n#define SHA3_256_BLOCK_SIZE 136\n\n#define SHA3_384_DIGEST_SIZE 48\n#define SHA3_384_BLOCK_SIZE 104\n\n#define SHA3_512_DIGEST_SIZE 64\n#define SHA3_512_BLOCK_SIZE 72\n\n/* For backwards compatibility */\n#define SHA3_224_DATA_SIZE SHA3_224_BLOCK_SIZE\n#define SHA3_256_DATA_SIZE SHA3_256_BLOCK_SIZE\n#define SHA3_384_DATA_SIZE SHA3_384_BLOCK_SIZE\n#define SHA3_512_DATA_SIZE SHA3_512_BLOCK_SIZE\n\nstruct sha3_224_ctx\n{\n  struct sha3_state state;\n  unsigned index;\n  uint8_t block[SHA3_224_BLOCK_SIZE];\n};\n\nvoid\nsha3_224_init (struct sha3_224_ctx *ctx);\n\nvoid\nsha3_224_update (struct sha3_224_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nsha3_224_digest(struct sha3_224_ctx *ctx,\n\t\tsize_t length,\n\t\tuint8_t *digest);\n\nstruct sha3_256_ctx\n{\n  struct sha3_state state;\n  unsigned index;\n  uint8_t block[SHA3_256_BLOCK_SIZE];\n};\n\nvoid\nsha3_256_init (struct sha3_256_ctx *ctx);\n\nvoid\nsha3_256_update (struct sha3_256_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nsha3_256_digest(struct sha3_256_ctx *ctx,\n\t\tsize_t length,\n\t\tuint8_t *digest);\n\n/* Alternative digest function implementing shake256, with arbitrary\n   digest size */\nvoid\nsha3_256_shake(struct sha3_256_ctx *ctx,\n\t       size_t length,\n\t       uint8_t *digest);\n\nstruct sha3_384_ctx\n{\n  struct sha3_state state;\n  unsigned index;\n  uint8_t block[SHA3_384_BLOCK_SIZE];\n};\n\nvoid\nsha3_384_init (struct sha3_384_ctx *ctx);\n\nvoid\nsha3_384_update (struct sha3_384_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nsha3_384_digest(struct sha3_384_ctx *ctx,\n\t\tsize_t length,\n\t\tuint8_t *digest);\n\nstruct sha3_512_ctx\n{\n  struct sha3_state state;\n  unsigned index;\n  uint8_t block[SHA3_512_BLOCK_SIZE];\n};\n\nvoid\nsha3_512_init (struct sha3_512_ctx *ctx);\n\nvoid\nsha3_512_update (struct sha3_512_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nsha3_512_digest(struct sha3_512_ctx *ctx,\n\t\tsize_t length,\n\t\tuint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SHA3_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/siv-cmac.h",
    "content": "/* siv-cmac.h\n\n   AES-SIV, RFC5297\n\n   Copyright (C) 2017 Nikos Mavrogiannopoulos\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SIV_H_INCLUDED\n#define NETTLE_SIV_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"nettle-meta.h\"\n#include \"cmac.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define siv_cmac_set_key nettle_siv_cmac_set_key\n#define siv_cmac_encrypt_message nettle_siv_cmac_encrypt_message\n#define siv_cmac_decrypt_message nettle_siv_cmac_decrypt_message\n#define siv_cmac_aes128_set_key nettle_siv_cmac_aes128_set_key\n#define siv_cmac_aes128_encrypt_message nettle_siv_cmac_aes128_encrypt_message\n#define siv_cmac_aes128_decrypt_message nettle_siv_cmac_aes128_decrypt_message\n#define siv_cmac_aes256_set_key nettle_siv_cmac_aes256_set_key\n#define siv_cmac_aes256_encrypt_message nettle_siv_cmac_aes256_encrypt_message\n#define siv_cmac_aes256_decrypt_message nettle_siv_cmac_aes256_decrypt_message\n\n/* For SIV, the block size of the underlying cipher shall be 128 bits. */\n#define SIV_BLOCK_SIZE  16\n#define SIV_DIGEST_SIZE 16\n#define SIV_MIN_NONCE_SIZE 1\n\nvoid\nsiv_cmac_set_key(struct cmac128_key *cmac_key, void *cmac_cipher, void *ctr_cipher,\n\t\t const struct nettle_cipher *nc,\n\t\t const uint8_t *key);\n\nvoid\nsiv_cmac_encrypt_message(const struct cmac128_key *cmac_key, const void *cmac_cipher_ctx,\n\t\t\t const struct nettle_cipher *nc,\n\t\t\t const void *ctr_ctx,\n\t\t\t size_t nlength, const uint8_t *nonce,\n\t\t\t size_t alength, const uint8_t *adata,\n\t\t\t size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_cmac_decrypt_message(const struct cmac128_key *cmac_key, const void *cmac_cipher,\n\t\t\t const struct nettle_cipher *nc,\n\t\t\t const void *ctr_cipher,\n\t\t\t size_t nlength, const uint8_t *nonce,\n\t\t\t size_t alength, const uint8_t *adata,\n\t\t\t size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/*\n * SIV mode requires the aad and plaintext when building the IV, which\n * prevents streaming processing and it incompatible with the AEAD API.\n */\n\n#define SIV_CMAC_CTX(type) { struct cmac128_key cmac_key; type cmac_cipher; type ctr_cipher; }\n\n/* SIV_CMAC_AES128 */\n#define SIV_CMAC_AES128_KEY_SIZE 32\n\nstruct siv_cmac_aes128_ctx SIV_CMAC_CTX(struct aes128_ctx);\n\nvoid\nsiv_cmac_aes128_set_key(struct siv_cmac_aes128_ctx *ctx, const uint8_t *key);\n\nvoid\nsiv_cmac_aes128_encrypt_message(const struct siv_cmac_aes128_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_cmac_aes128_decrypt_message(const struct siv_cmac_aes128_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* SIV_CMAC_AES256 */\n#define SIV_CMAC_AES256_KEY_SIZE 64\n\nstruct siv_cmac_aes256_ctx SIV_CMAC_CTX(struct aes256_ctx);\n\nvoid\nsiv_cmac_aes256_set_key(struct siv_cmac_aes256_ctx *ctx, const uint8_t *key);\n\nvoid\nsiv_cmac_aes256_encrypt_message(const struct siv_cmac_aes256_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_cmac_aes256_decrypt_message(const struct siv_cmac_aes256_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t mlength, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SIV_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/siv-gcm.h",
    "content": "/* siv-gcm.h\n\n   AES-GCM-SIV, RFC8452\n\n   Copyright (C) 2022 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SIV_GCM_H_INCLUDED\n#define NETTLE_SIV_GCM_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"nettle-meta.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define siv_gcm_encrypt_message nettle_siv_gcm_encrypt_message\n#define siv_gcm_decrypt_message nettle_siv_gcm_decrypt_message\n#define siv_gcm_aes128_encrypt_message nettle_siv_gcm_aes128_encrypt_message\n#define siv_gcm_aes128_decrypt_message nettle_siv_gcm_aes128_decrypt_message\n#define siv_gcm_aes256_encrypt_message nettle_siv_gcm_aes256_encrypt_message\n#define siv_gcm_aes256_decrypt_message nettle_siv_gcm_aes256_decrypt_message\n\n/* For AES-GCM-SIV, the block size of the underlying cipher shall be 128 bits. */\n#define SIV_GCM_BLOCK_SIZE 16\n#define SIV_GCM_DIGEST_SIZE 16\n#define SIV_GCM_NONCE_SIZE 12\n\n/* Generic interface.  NC must be a block cipher with 128-bit block\n   size, and keysize that is a multiple of 64 bits, such as AES-128 or\n   AES-256.  */\nvoid\nsiv_gcm_encrypt_message (const struct nettle_cipher *nc,\n\t\t\t const void *ctx,\n\t\t\t void *ctr_ctx,\n\t\t\t size_t nlength, const uint8_t *nonce,\n\t\t\t size_t alength, const uint8_t *adata,\n\t\t\t size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_gcm_decrypt_message (const struct nettle_cipher *nc,\n\t\t\t const void *ctx,\n\t\t\t void *ctr_ctx,\n\t\t\t size_t nlength, const uint8_t *nonce,\n\t\t\t size_t alength, const uint8_t *adata,\n\t\t\t size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* AEAD_AES_128_GCM_SIV */\nvoid\nsiv_gcm_aes128_encrypt_message (const struct aes128_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_gcm_aes128_decrypt_message (const struct aes128_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* AEAD_AES_256_GCM_SIV */\nvoid\nsiv_gcm_aes256_encrypt_message (const struct aes256_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_gcm_aes256_decrypt_message (const struct aes256_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t mlength, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SIV_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/sm3.h",
    "content": "/* sm3.h\n\n   The SM3 hash function.\n\n   Copyright (C) 2017 Jia Zhang\n   Copyright (C) 2021 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SM3_H_INCLUDED\n#define NETTLE_SM3_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sm3_init nettle_sm3_init\n#define sm3_update nettle_sm3_update\n#define sm3_digest nettle_sm3_digest\n\n#define SM3_DIGEST_SIZE 32\n#define SM3_BLOCK_SIZE 64\n\n/* Digest is kept internally as 8 32-bit words. */\n#define _SM3_DIGEST_LENGTH 8\n\nstruct sm3_ctx\n{\n  uint32_t state[_SM3_DIGEST_LENGTH];\n  uint64_t count;               /* Block count */\n  unsigned index;               /* Into buffer */\n  uint8_t block[SM3_BLOCK_SIZE]; /* Block buffer */\n};\n\nvoid\nsm3_init(struct sm3_ctx *ctx);\n\nvoid\nsm3_update(struct sm3_ctx *ctx,\n\t   size_t length,\n\t   const uint8_t *data);\n\nvoid\nsm3_digest(struct sm3_ctx *ctx,\n\t   size_t length,\n\t   uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SM3_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/sm4.h",
    "content": "/* sm4.h\n\n   Copyright (C) 2022 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SM4_H_INCLUDED\n#define NETTLE_SM4_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sm4_set_encrypt_key nettle_sm4_set_encrypt_key\n#define sm4_set_decrypt_key nettle_sm4_set_decrypt_key\n#define sm4_crypt nettle_sm4_crypt\n\n#define SM4_BLOCK_SIZE 16\n#define SM4_KEY_SIZE 16\n\nstruct sm4_ctx\n{\n  uint32_t rkey[32];\n};\n\nvoid\nsm4_set_encrypt_key(struct sm4_ctx *ctx, const uint8_t *key);\n\nvoid\nsm4_set_decrypt_key(struct sm4_ctx *ctx, const uint8_t *key);\n\nvoid\nsm4_crypt(const struct sm4_ctx *context,\n\t  size_t length, uint8_t *dst,\n\t  const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SM4_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/streebog.h",
    "content": "/* streebog.h\n\n   The Streebog family of hash functions.\n\n   Copyright (C) 2020 Dmitry Baryshkov\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_STREEBOG_H_INCLUDED\n#define NETTLE_STREEBOG_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define streebog256_init nettle_streebog256_init\n#define streebog256_digest nettle_streebog256_digest\n#define streebog512_init nettle_streebog512_init\n#define streebog512_update nettle_streebog512_update\n#define streebog512_digest nettle_streebog512_digest\n\n/* STREEBOG512 */\n\n#define STREEBOG512_DIGEST_SIZE 64\n#define STREEBOG512_BLOCK_SIZE 64\n\n/* Digest is kept internally as 8 64-bit words. */\n#define _STREEBOG512_DIGEST_LENGTH 8\n\nstruct streebog512_ctx\n{\n  uint64_t state[_STREEBOG512_DIGEST_LENGTH];    /* State variables */\n  uint64_t count[_STREEBOG512_DIGEST_LENGTH];\n  uint64_t sigma[_STREEBOG512_DIGEST_LENGTH];\n  unsigned int index;                       /* index into buffer */\n  uint8_t block[STREEBOG512_BLOCK_SIZE];          /* STREEBOG512 data buffer */\n};\n\nvoid\nstreebog512_init(struct streebog512_ctx *ctx);\n\nvoid\nstreebog512_update(struct streebog512_ctx *ctx,\n\t      size_t length,\n\t      const uint8_t *data);\n\nvoid\nstreebog512_digest(struct streebog512_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\n\n#define STREEBOG256_DIGEST_SIZE 32\n#define STREEBOG256_BLOCK_SIZE STREEBOG512_BLOCK_SIZE\n#define streebog256_ctx streebog512_ctx\n\nvoid\nstreebog256_init(struct streebog256_ctx *ctx);\n\n#define streebog256_update nettle_streebog512_update\n\nvoid\nstreebog256_digest(struct streebog256_ctx *ctx,\n\t\t  size_t length,\n\t\t  uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_STREEBOG_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/twofish.h",
    "content": "/* twofish.h\n\n   The twofish block cipher.\n\n   Copyright (C) 2001, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/*\n * Twofish is a 128-bit block cipher that accepts a variable-length\n * key up to 256 bits, designed by Bruce Schneier and others.  See\n * http://www.counterpane.com/twofish.html for details.\n */\n\n#ifndef NETTLE_TWOFISH_H_INCLUDED\n#define NETTLE_TWOFISH_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define twofish_set_key nettle_twofish_set_key\n#define twofish128_set_key nettle_twofish128_set_key\n#define twofish192_set_key nettle_twofish192_set_key\n#define twofish256_set_key nettle_twofish256_set_key\n#define twofish_encrypt nettle_twofish_encrypt\n#define twofish_decrypt nettle_twofish_decrypt\n\n#define TWOFISH_BLOCK_SIZE 16\n\n/* Variable key size between 128 and 256 bits. But the only valid\n * values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */\n#define TWOFISH_MIN_KEY_SIZE 16\n#define TWOFISH_MAX_KEY_SIZE 32\n\n#define TWOFISH_KEY_SIZE 32\n#define TWOFISH128_KEY_SIZE 16\n#define TWOFISH192_KEY_SIZE 24\n#define TWOFISH256_KEY_SIZE 32\n\nstruct twofish_ctx\n{\n  uint32_t keys[40];\n  uint32_t s_box[4][256];\n};\n\nvoid\ntwofish_set_key(struct twofish_ctx *ctx,\n\t\tsize_t length, const uint8_t *key);\nvoid\ntwofish128_set_key(struct twofish_ctx *context, const uint8_t *key);\nvoid\ntwofish192_set_key(struct twofish_ctx *context, const uint8_t *key);\nvoid\ntwofish256_set_key(struct twofish_ctx *context, const uint8_t *key);\n\nvoid\ntwofish_encrypt(const struct twofish_ctx *ctx,\n\t\tsize_t length, uint8_t *dst,\n\t\tconst uint8_t *src);\nvoid\ntwofish_decrypt(const struct twofish_ctx *ctx,\n\t\tsize_t length, uint8_t *dst,\n\t\tconst uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_TWOFISH_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/umac.h",
    "content": "/* umac.h\n\n   UMAC message authentication code (RFC-4418).\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_UMAC_H_INCLUDED\n#define NETTLE_UMAC_H_INCLUDED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define umac32_set_key  nettle_umac32_set_key\n#define umac64_set_key  nettle_umac64_set_key\n#define umac96_set_key  nettle_umac96_set_key\n#define umac128_set_key nettle_umac128_set_key\n#define umac32_set_nonce  nettle_umac32_set_nonce\n#define umac64_set_nonce  nettle_umac64_set_nonce\n#define umac96_set_nonce  nettle_umac96_set_nonce\n#define umac128_set_nonce nettle_umac128_set_nonce\n#define umac32_update  nettle_umac32_update\n#define umac64_update  nettle_umac64_update\n#define umac96_update  nettle_umac96_update\n#define umac128_update nettle_umac128_update\n#define umac32_digest  nettle_umac32_digest\n#define umac64_digest  nettle_umac64_digest\n#define umac96_digest  nettle_umac96_digest\n#define umac128_digest nettle_umac128_digest\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#define UMAC_KEY_SIZE AES128_KEY_SIZE\n#define UMAC32_DIGEST_SIZE 4\n#define UMAC64_DIGEST_SIZE 8\n#define UMAC96_DIGEST_SIZE 12\n#define UMAC128_DIGEST_SIZE 16\n#define UMAC_BLOCK_SIZE 1024\n#define UMAC_MIN_NONCE_SIZE 1\n#define UMAC_MAX_NONCE_SIZE AES_BLOCK_SIZE\n/* For backwards compatibility */\n#define UMAC_DATA_SIZE UMAC_BLOCK_SIZE\n\n/* Subkeys and state for UMAC with tag size 32*n bits. */\n#define _UMAC_STATE(n)\t\t\t\t\t\\\n  uint32_t l1_key[UMAC_BLOCK_SIZE/4 + 4*((n)-1)];\t\\\n  /* Keys in 32-bit pieces, high first */\t\t\\\n  uint32_t l2_key[6*(n)];\t\t\t\t\\\n  uint64_t l3_key1[8*(n)];\t\t\t\t\\\n  uint32_t l3_key2[(n)];\t\t\t\t\\\n  /* AES cipher for encrypting the nonce */\t\t\\\n  struct aes128_ctx pdf_key;\t\t\t\t\\\n  /* The l2_state consists of 2*n uint64_t, for poly64\t\\\n     and poly128 hashing, followed by n additional\t\\\n     uint64_t used as an input buffer. */\t\t\\\n  uint64_t l2_state[3*(n)];\t\t\t\t\\\n  /* Input to the pdf_key, zero-padded and low bits\t\\\n     cleared if appropriate. */\t\t\t\t\\\n  uint8_t nonce[AES_BLOCK_SIZE];\t\t\t\\\n  unsigned short nonce_length /* For incrementing */\n\n  /* Buffering */ \n#define _UMAC_BUFFER\t\t\t\t\t\\\n  unsigned index;\t\t\t\t\t\\\n  /* Complete blocks processed */\t\t\t\\\n  uint64_t count;\t\t\t\t\t\\\n  uint8_t block[UMAC_BLOCK_SIZE]\n  \n#define _UMAC_NONCE_CACHED 0x80\n\nstruct umac32_ctx\n{\n  _UMAC_STATE(1);\n  /* Low bits and cache flag. */\n  unsigned short nonce_low;\n  /* Previous padding block */\n  uint32_t pad_cache[AES_BLOCK_SIZE / 4];\n  _UMAC_BUFFER;\n};\n\nstruct umac64_ctx\n{\n  _UMAC_STATE(2);\n  /* Low bit and cache flag. */\n  unsigned short nonce_low;\n  /* Previous padding block */\n  uint32_t pad_cache[AES_BLOCK_SIZE/4];\n  _UMAC_BUFFER;\n};\n\nstruct umac96_ctx\n{\n  _UMAC_STATE(3);\n  _UMAC_BUFFER;\n};\n\nstruct umac128_ctx\n{\n  _UMAC_STATE(4);\n  _UMAC_BUFFER;\n};\n\n/* The _set_key function initialize the nonce to zero. */\nvoid\numac32_set_key (struct umac32_ctx *ctx, const uint8_t *key);\nvoid\numac64_set_key (struct umac64_ctx *ctx, const uint8_t *key);\nvoid\numac96_set_key (struct umac96_ctx *ctx, const uint8_t *key);\nvoid\numac128_set_key (struct umac128_ctx *ctx, const uint8_t *key);\n\n/* Optional, if not used, messages get incrementing nonces starting from zero. */\nvoid\numac32_set_nonce (struct umac32_ctx *ctx,\n\t\t  size_t nonce_length, const uint8_t *nonce);\nvoid\numac64_set_nonce (struct umac64_ctx *ctx,\n\t\t  size_t nonce_length, const uint8_t *nonce);\nvoid\numac96_set_nonce (struct umac96_ctx *ctx,\n\t\t  size_t nonce_length, const uint8_t *nonce);\nvoid\numac128_set_nonce (struct umac128_ctx *ctx,\n\t\t   size_t nonce_length, const uint8_t *nonce);\n\nvoid\numac32_update (struct umac32_ctx *ctx,\n\t       size_t length, const uint8_t *data);\nvoid\numac64_update (struct umac64_ctx *ctx,\n\t       size_t length, const uint8_t *data);\nvoid\numac96_update (struct umac96_ctx *ctx,\n\t       size_t length, const uint8_t *data);\nvoid\numac128_update (struct umac128_ctx *ctx,\n\t\tsize_t length, const uint8_t *data);\n\n/* The _digest functions increment the nonce */\nvoid\numac32_digest (struct umac32_ctx *ctx,\n\t       size_t length, uint8_t *digest);\nvoid\numac64_digest (struct umac64_ctx *ctx,\n\t       size_t length, uint8_t *digest);\nvoid\numac96_digest (struct umac96_ctx *ctx,\n\t       size_t length, uint8_t *digest);\nvoid\numac128_digest (struct umac128_ctx *ctx,\n\t\tsize_t length, uint8_t *digest);\n\n\n/* Internal functions */\n#define UMAC_POLY64_BLOCKS 16384\n\n#define UMAC_P64_OFFSET 59\n#define UMAC_P64 (- (uint64_t) UMAC_P64_OFFSET)\n\n#define UMAC_P128_OFFSET 159\n#define UMAC_P128_HI (~(uint64_t) 0)\n#define UMAC_P128_LO (-(uint64_t) UMAC_P128_OFFSET)\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_UMAC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/version.h",
    "content": "/* version.h\n\n   Information about library version.\n\n   Copyright (C) 2015 Red Hat, Inc.\n   Copyright (C) 2015 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_VERSION_H_INCLUDED\n#define NETTLE_VERSION_H_INCLUDED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Individual version numbers in decimal */\n#define NETTLE_VERSION_MAJOR 3\n#define NETTLE_VERSION_MINOR 9\n\n#define NETTLE_USE_MINI_GMP 0\n\n/* We need a preprocessor constant for GMP_NUMB_BITS, simply using\n   sizeof(mp_limb_t) * CHAR_BIT is not good enough. */\n#if NETTLE_USE_MINI_GMP\n# define GMP_NUMB_BITS n/a\n#endif\n\nint\nnettle_version_major (void);\n\nint\nnettle_version_minor (void);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_VERSION_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/xts.h",
    "content": "/* xts.h\n\n   XEX-based tweaked-codebook mode with ciphertext stealing (XTS)\n\n   Copyright (C) 2005 Niels Möller\n   Copyright (C) 2018 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n\n#ifndef NETTLE_XTS_H_INCLUDED\n#define NETTLE_XTS_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define xts_encrypt_message nettle_xts_encrypt_message\n#define xts_decrypt_message nettle_xts_decrypt_message\n#define xts_aes128_set_encrypt_key nettle_xts_aes128_set_encrypt_key\n#define xts_aes128_set_decrypt_key nettle_xts_aes128_set_decrypt_key\n#define xts_aes128_encrypt_message nettle_xts_aes128_encrypt_message\n#define xts_aes128_decrypt_message nettle_xts_aes128_decrypt_message\n#define xts_aes256_set_encrypt_key nettle_xts_aes256_set_encrypt_key\n#define xts_aes256_set_decrypt_key nettle_xts_aes256_set_decrypt_key\n#define xts_aes256_encrypt_message nettle_xts_aes256_encrypt_message\n#define xts_aes256_decrypt_message nettle_xts_aes256_decrypt_message\n\n#define XTS_BLOCK_SIZE 16\n\nvoid\nxts_encrypt_message(const void *enc_ctx, const void *twk_ctx,\n                nettle_cipher_func *encf,\n                const uint8_t *tweak, size_t length,\n                uint8_t *dst, const uint8_t *src);\nvoid\nxts_decrypt_message(const void *dec_ctx, const void *twk_ctx,\n                    nettle_cipher_func *decf, nettle_cipher_func *encf,\n                    const uint8_t *tweak, size_t length,\n                    uint8_t *dst, const uint8_t *src);\n\n/* XTS Mode with AES-128 */\nstruct xts_aes128_key {\n    struct aes128_ctx cipher;\n    struct aes128_ctx tweak_cipher;\n};\n\nvoid\nxts_aes128_set_encrypt_key(struct xts_aes128_key *xts_key,\n                           const uint8_t *key);\n\nvoid\nxts_aes128_set_decrypt_key(struct xts_aes128_key *xts_key,\n                           const uint8_t *key);\n\nvoid\nxts_aes128_encrypt_message(const struct xts_aes128_key *xtskey,\n                           const uint8_t *tweak, size_t length,\n                           uint8_t *dst, const uint8_t *src);\n\nvoid\nxts_aes128_decrypt_message(const struct xts_aes128_key *xts_key,\n                           const uint8_t *tweak, size_t length,\n                           uint8_t *dst, const uint8_t *src);\n\n/* XTS Mode with AES-256 */\nstruct xts_aes256_key {\n    struct aes256_ctx cipher;\n    struct aes256_ctx tweak_cipher;\n};\n\nvoid\nxts_aes256_set_encrypt_key(struct xts_aes256_key *xts_key,\n                           const uint8_t *key);\n\nvoid\nxts_aes256_set_decrypt_key(struct xts_aes256_key *xts_key,\n                           const uint8_t *key);\n\nvoid\nxts_aes256_encrypt_message(const struct xts_aes256_key *xts_key,\n                           const uint8_t *tweak, size_t length,\n                           uint8_t *dst, const uint8_t *src);\n\nvoid\nxts_aes256_decrypt_message(const struct xts_aes256_key *xts_key,\n                           const uint8_t *tweak, size_t length,\n                           uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_XTS_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/nettle/yarrow.h",
    "content": "/* yarrow.h\n\n   The yarrow pseudo-randomness generator.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_YARROW_H_INCLUDED\n#define NETTLE_YARROW_H_INCLUDED\n\n#include \"aes.h\"\n#include \"sha2.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define yarrow256_init nettle_yarrow256_init\n#define yarrow256_seed nettle_yarrow256_seed\n#define yarrow256_update nettle_yarrow256_update\n#define yarrow256_random nettle_yarrow256_random\n#define yarrow256_is_seeded nettle_yarrow256_is_seeded\n#define yarrow256_needed_sources nettle_yarrow256_needed_sources\n#define yarrow256_fast_reseed nettle_yarrow256_fast_reseed\n#define yarrow256_slow_reseed nettle_yarrow256_slow_reseed\n#define yarrow_key_event_init nettle_yarrow_key_event_init\n#define yarrow_key_event_estimate nettle_yarrow_key_event_estimate\n\n/* Obsolete alias for backwards compatibility. Will be deleted in some\n   later version. */\n#define yarrow256_force_reseed yarrow256_slow_reseed\n  \nenum yarrow_pool_id { YARROW_FAST = 0, YARROW_SLOW = 1 };\n\nstruct yarrow_source\n{\n  /* Indexed by yarrow_pool_id */\n  uint32_t estimate[2];\n  \n  /* The pool next sample should go to. */\n  enum yarrow_pool_id next;\n};\n\n\n#define YARROW256_SEED_FILE_SIZE (2 * AES_BLOCK_SIZE)\n\n/* Yarrow-256, based on SHA-256 and AES-256 */\nstruct yarrow256_ctx\n{\n  /* Indexed by yarrow_pool_id */\n  struct sha256_ctx pools[2];\n\n  int seeded;\n\n  /* The current key and counter block */\n  struct aes256_ctx key;\n  uint8_t counter[AES_BLOCK_SIZE];\n\n  /* The entropy sources */\n  unsigned nsources;\n  struct yarrow_source *sources;\n};\n\nvoid\nyarrow256_init(struct yarrow256_ctx *ctx,\n\t       unsigned nsources,\n\t       struct yarrow_source *sources);\n\nvoid\nyarrow256_seed(struct yarrow256_ctx *ctx,\n\t       size_t length,\n\t       const uint8_t *seed_file);\n\n/* Returns 1 on reseed */\nint\nyarrow256_update(struct yarrow256_ctx *ctx,\n\t\t unsigned source, unsigned entropy,\n\t\t size_t length, const uint8_t *data);\n\nvoid\nyarrow256_random(struct yarrow256_ctx *ctx, size_t length, uint8_t *dst);\n\nint\nyarrow256_is_seeded(struct yarrow256_ctx *ctx);\n\nunsigned\nyarrow256_needed_sources(struct yarrow256_ctx *ctx);\n\nvoid\nyarrow256_fast_reseed(struct yarrow256_ctx *ctx);\n\nvoid\nyarrow256_slow_reseed(struct yarrow256_ctx *ctx);\n\n\n/* Key event estimator */\n#define YARROW_KEY_EVENT_BUFFER 16\n\nstruct yarrow_key_event_ctx\n{\n  /* Counter for initial priming of the state */\n  unsigned index;\n  unsigned chars[YARROW_KEY_EVENT_BUFFER];\n  unsigned previous;\n};\n\nvoid\nyarrow_key_event_init(struct yarrow_key_event_ctx *ctx);\n\nunsigned\nyarrow_key_event_estimate(struct yarrow_key_event_ctx *ctx,\n\t\t\t  unsigned key, unsigned time);\n  \n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_YARROW_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/32/include/opencore-amrnb/interf_dec.h",
    "content": "/* ------------------------------------------------------------------\n * Copyright (C) 2009 Martin Storsjo\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n * -------------------------------------------------------------------\n */\n\n#ifndef OPENCORE_AMRNB_INTERF_DEC_H\n#define OPENCORE_AMRNB_INTERF_DEC_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nvoid* Decoder_Interface_init(void);\nvoid Decoder_Interface_exit(void* state);\nvoid Decoder_Interface_Decode(void* state, const unsigned char* in, short* out, int bfi);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/opencore-amrnb/interf_enc.h",
    "content": "/* ------------------------------------------------------------------\n * Copyright (C) 2009 Martin Storsjo\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n * -------------------------------------------------------------------\n */\n\n#ifndef OPENCORE_AMRNB_INTERF_ENC_H\n#define OPENCORE_AMRNB_INTERF_ENC_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef AMRNB_WRAPPER_INTERNAL\n/* Copied from enc/src/gsmamr_enc.h */\nenum Mode {\n\tMR475 = 0,/* 4.75 kbps */\n\tMR515,    /* 5.15 kbps */\n\tMR59,     /* 5.90 kbps */\n\tMR67,     /* 6.70 kbps */\n\tMR74,     /* 7.40 kbps */\n\tMR795,    /* 7.95 kbps */\n\tMR102,    /* 10.2 kbps */\n\tMR122,    /* 12.2 kbps */\n\tMRDTX,    /* DTX       */\n\tN_MODES   /* Not Used  */\n};\n#endif\n\nvoid* Encoder_Interface_init(int dtx);\nvoid Encoder_Interface_exit(void* state);\nint Encoder_Interface_Encode(void* state, enum Mode mode, const short* speech, unsigned char* out, int forceSpeech);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/opencore-amrwb/dec_if.h",
    "content": "/* ------------------------------------------------------------------\n * Copyright (C) 2009 Martin Storsjo\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n * -------------------------------------------------------------------\n */\n\n#ifndef OPENCORE_AMRWB_DEC_IF_H\n#define OPENCORE_AMRWB_DEC_IF_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define _good_frame 0\n\nvoid* D_IF_init(void);\nvoid D_IF_decode(void* state, const unsigned char* bits, short* synth, int bfi);\nvoid D_IF_exit(void* state);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/opencore-amrwb/if_rom.h",
    "content": "/* ------------------------------------------------------------------\n * Copyright (C) 2009 Martin Storsjo\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n * -------------------------------------------------------------------\n */\n\n#ifndef OPENCORE_AMRWB_IF_ROM_H\n#define OPENCORE_AMRWB_IF_ROM_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdint.h>\ntypedef int16_t Word16;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/speex/speex.h",
    "content": "/* Copyright (C) 2002-2006 Jean-Marc Valin*/\n/**\n  @file speex.h\n  @brief Describes the different modes of the codec\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n#ifndef SPEEX_H\n#define SPEEX_H\n/** @defgroup Codec Speex encoder and decoder\n *  This is the Speex codec itself.\n *  @{\n */\n\n#include \"speex_types.h\"\n#include \"speex_bits.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Values allowed for *ctl() requests */\n\n/** Set enhancement on/off (decoder only) */\n#define SPEEX_SET_ENH 0\n/** Get enhancement state (decoder only) */\n#define SPEEX_GET_ENH 1\n\n/*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/\n/** Obtain frame size used by encoder/decoder */\n#define SPEEX_GET_FRAME_SIZE 3\n\n/** Set quality value */\n#define SPEEX_SET_QUALITY 4\n/** Get current quality setting */\n/* #define SPEEX_GET_QUALITY 5 -- Doesn't make much sense, does it? */\n\n/** Set sub-mode to use */\n#define SPEEX_SET_MODE 6\n/** Get current sub-mode in use */\n#define SPEEX_GET_MODE 7\n\n/** Set low-band sub-mode to use (wideband only)*/\n#define SPEEX_SET_LOW_MODE 8\n/** Get current low-band mode in use (wideband only)*/\n#define SPEEX_GET_LOW_MODE 9\n\n/** Set high-band sub-mode to use (wideband only)*/\n#define SPEEX_SET_HIGH_MODE 10\n/** Get current high-band mode in use (wideband only)*/\n#define SPEEX_GET_HIGH_MODE 11\n\n/** Set VBR on (1) or off (0) */\n#define SPEEX_SET_VBR 12\n/** Get VBR status (1 for on, 0 for off) */\n#define SPEEX_GET_VBR 13\n\n/** Set quality value for VBR encoding (0-10) */\n#define SPEEX_SET_VBR_QUALITY 14\n/** Get current quality value for VBR encoding (0-10) */\n#define SPEEX_GET_VBR_QUALITY 15\n\n/** Set complexity of the encoder (0-10) */\n#define SPEEX_SET_COMPLEXITY 16\n/** Get current complexity of the encoder (0-10) */\n#define SPEEX_GET_COMPLEXITY 17\n\n/** Set bit-rate used by the encoder (or lower) */\n#define SPEEX_SET_BITRATE 18\n/** Get current bit-rate used by the encoder or decoder */\n#define SPEEX_GET_BITRATE 19\n\n/** Define a handler function for in-band Speex request*/\n#define SPEEX_SET_HANDLER 20\n\n/** Define a handler function for in-band user-defined request*/\n#define SPEEX_SET_USER_HANDLER 22\n\n/** Set sampling rate used in bit-rate computation */\n#define SPEEX_SET_SAMPLING_RATE 24\n/** Get sampling rate used in bit-rate computation */\n#define SPEEX_GET_SAMPLING_RATE 25\n\n/** Reset the encoder/decoder memories to zero*/\n#define SPEEX_RESET_STATE 26\n\n/** Get VBR info (mostly used internally) */\n#define SPEEX_GET_RELATIVE_QUALITY 29\n\n/** Set VAD status (1 for on, 0 for off) */\n#define SPEEX_SET_VAD 30\n\n/** Get VAD status (1 for on, 0 for off) */\n#define SPEEX_GET_VAD 31\n\n/** Set Average Bit-Rate (ABR) to n bits per seconds */\n#define SPEEX_SET_ABR 32\n/** Get Average Bit-Rate (ABR) setting (in bps) */\n#define SPEEX_GET_ABR 33\n\n/** Set DTX status (1 for on, 0 for off) */\n#define SPEEX_SET_DTX 34\n/** Get DTX status (1 for on, 0 for off) */\n#define SPEEX_GET_DTX 35\n\n/** Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard) */\n#define SPEEX_SET_SUBMODE_ENCODING 36\n/** Get submode encoding in each frame */\n#define SPEEX_GET_SUBMODE_ENCODING 37\n\n/*#define SPEEX_SET_LOOKAHEAD 38*/\n/** Returns the lookahead used by Speex separately for an encoder and a decoder.\n *  Sum encoder and decoder lookahead values to get the total codec lookahead. */\n#define SPEEX_GET_LOOKAHEAD 39\n\n/** Sets tuning for packet-loss concealment (expected loss rate) */\n#define SPEEX_SET_PLC_TUNING 40\n/** Gets tuning for PLC */\n#define SPEEX_GET_PLC_TUNING 41\n\n/** Sets the max bit-rate allowed in VBR mode */\n#define SPEEX_SET_VBR_MAX_BITRATE 42\n/** Gets the max bit-rate allowed in VBR mode */\n#define SPEEX_GET_VBR_MAX_BITRATE 43\n\n/** Turn on/off input/output high-pass filtering */\n#define SPEEX_SET_HIGHPASS 44\n/** Get status of input/output high-pass filtering */\n#define SPEEX_GET_HIGHPASS 45\n\n/** Get \"activity level\" of the last decoded frame, i.e.\n    how much damage we cause if we remove the frame */\n#define SPEEX_GET_ACTIVITY 47\n\n\n/* Preserving compatibility:*/\n/** Equivalent to SPEEX_SET_ENH */\n#define SPEEX_SET_PF 0\n/** Equivalent to SPEEX_GET_ENH */\n#define SPEEX_GET_PF 1\n\n\n\n\n/* Values allowed for mode queries */\n/** Query the frame size of a mode */\n#define SPEEX_MODE_FRAME_SIZE 0\n\n/** Query the size of an encoded frame for a particular sub-mode */\n#define SPEEX_SUBMODE_BITS_PER_FRAME 1\n\n\n\n/** Get major Speex version */\n#define SPEEX_LIB_GET_MAJOR_VERSION 1\n/** Get minor Speex version */\n#define SPEEX_LIB_GET_MINOR_VERSION 3\n/** Get micro Speex version */\n#define SPEEX_LIB_GET_MICRO_VERSION 5\n/** Get extra Speex version */\n#define SPEEX_LIB_GET_EXTRA_VERSION 7\n/** Get Speex version string */\n#define SPEEX_LIB_GET_VERSION_STRING 9\n\n/*#define SPEEX_LIB_SET_ALLOC_FUNC 10\n#define SPEEX_LIB_GET_ALLOC_FUNC 11\n#define SPEEX_LIB_SET_FREE_FUNC 12\n#define SPEEX_LIB_GET_FREE_FUNC 13\n\n#define SPEEX_LIB_SET_WARNING_FUNC 14\n#define SPEEX_LIB_GET_WARNING_FUNC 15\n#define SPEEX_LIB_SET_ERROR_FUNC 16\n#define SPEEX_LIB_GET_ERROR_FUNC 17\n*/\n\n/** Number of defined modes in Speex */\n#define SPEEX_NB_MODES 3\n\n/** modeID for the defined narrowband mode */\n#define SPEEX_MODEID_NB 0\n\n/** modeID for the defined wideband mode */\n#define SPEEX_MODEID_WB 1\n\n/** modeID for the defined ultra-wideband mode */\n#define SPEEX_MODEID_UWB 2\n\nstruct SpeexMode;\n\n\n/* Prototypes for mode function pointers */\n\n/** Encoder state initialization function */\ntypedef void *(*encoder_init_func)(const struct SpeexMode *mode);\n\n/** Encoder state destruction function */\ntypedef void (*encoder_destroy_func)(void *st);\n\n/** Main encoding function */\ntypedef int (*encode_func)(void *state, void *in, SpeexBits *bits);\n\n/** Function for controlling the encoder options */\ntypedef int (*encoder_ctl_func)(void *state, int request, void *ptr);\n\n/** Decoder state initialization function */\ntypedef void *(*decoder_init_func)(const struct SpeexMode *mode);\n\n/** Decoder state destruction function */\ntypedef void (*decoder_destroy_func)(void *st);\n\n/** Main decoding function */\ntypedef int  (*decode_func)(void *state, SpeexBits *bits, void *out);\n\n/** Function for controlling the decoder options */\ntypedef int (*decoder_ctl_func)(void *state, int request, void *ptr);\n\n\n/** Query function for a mode */\ntypedef int (*mode_query_func)(const void *mode, int request, void *ptr);\n\n/** Struct defining a Speex mode */\ntypedef struct SpeexMode {\n   /** Pointer to the low-level mode data */\n   const void *mode;\n\n   /** Pointer to the mode query function */\n   mode_query_func query;\n\n   /** The name of the mode (you should not rely on this to identify the mode)*/\n   const char *modeName;\n\n   /**ID of the mode*/\n   int modeID;\n\n   /**Version number of the bitstream (incremented every time we break\n    bitstream compatibility*/\n   int bitstream_version;\n\n   /** Pointer to encoder initialization function */\n   encoder_init_func enc_init;\n\n   /** Pointer to encoder destruction function */\n   encoder_destroy_func enc_destroy;\n\n   /** Pointer to frame encoding function */\n   encode_func enc;\n\n   /** Pointer to decoder initialization function */\n   decoder_init_func dec_init;\n\n   /** Pointer to decoder destruction function */\n   decoder_destroy_func dec_destroy;\n\n   /** Pointer to frame decoding function */\n   decode_func dec;\n\n   /** ioctl-like requests for encoder */\n   encoder_ctl_func enc_ctl;\n\n   /** ioctl-like requests for decoder */\n   decoder_ctl_func dec_ctl;\n\n} SpeexMode;\n\n/**\n * Returns a handle to a newly created Speex encoder state structure. For now,\n * the \"mode\" argument can be &nb_mode or &wb_mode . In the future, more modes\n * may be added. Note that for now if you have more than one channels to\n * encode, you need one state per channel.\n *\n * @param mode The mode to use (either speex_nb_mode or speex_wb.mode)\n * @return A newly created encoder state or NULL if state allocation fails\n */\nvoid *speex_encoder_init(const SpeexMode *mode);\n\n/** Frees all resources associated to an existing Speex encoder state.\n * @param state Encoder state to be destroyed */\nvoid speex_encoder_destroy(void *state);\n\n/** Uses an existing encoder state to encode one frame of speech pointed to by\n    \"in\". The encoded bit-stream is saved in \"bits\".\n @param state Encoder state\n @param in Frame that will be encoded with a +-2^15 range. This data MAY be\n        overwritten by the encoder and should be considered uninitialised\n        after the call.\n @param bits Bit-stream where the data will be written\n @return 0 if frame needs not be transmitted (DTX only), 1 otherwise\n */\nint speex_encode(void *state, float *in, SpeexBits *bits);\n\n/** Uses an existing encoder state to encode one frame of speech pointed to by\n    \"in\". The encoded bit-stream is saved in \"bits\".\n @param state Encoder state\n @param in Frame that will be encoded with a +-2^15 range\n @param bits Bit-stream where the data will be written\n @return 0 if frame needs not be transmitted (DTX only), 1 otherwise\n */\nint speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits);\n\n/** Used like the ioctl function to control the encoder parameters\n *\n * @param state Encoder state\n * @param request ioctl-type request (one of the SPEEX_* macros)\n * @param ptr Data exchanged to-from function\n * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter\n */\nint speex_encoder_ctl(void *state, int request, void *ptr);\n\n\n/** Returns a handle to a newly created decoder state structure. For now,\n * the mode argument can be &nb_mode or &wb_mode . In the future, more modes\n * may be added.  Note that for now if you have more than one channels to\n * decode, you need one state per channel.\n *\n * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode)\n * @return A newly created decoder state or NULL if state allocation fails\n */\nvoid *speex_decoder_init(const SpeexMode *mode);\n\n/** Frees all resources associated to an existing decoder state.\n *\n * @param state State to be destroyed\n */\nvoid speex_decoder_destroy(void *state);\n\n/** Uses an existing decoder state to decode one frame of speech from\n * bit-stream bits. The output speech is saved written to out.\n *\n * @param state Decoder state\n * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost)\n * @param out Where to write the decoded frame\n * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream)\n */\nint speex_decode(void *state, SpeexBits *bits, float *out);\n\n/** Uses an existing decoder state to decode one frame of speech from\n * bit-stream bits. The output speech is saved written to out.\n *\n * @param state Decoder state\n * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost)\n * @param out Where to write the decoded frame\n * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream)\n */\nint speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out);\n\n/** Used like the ioctl function to control the encoder parameters\n *\n * @param state Decoder state\n * @param request ioctl-type request (one of the SPEEX_* macros)\n * @param ptr Data exchanged to-from function\n * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter\n */\nint speex_decoder_ctl(void *state, int request, void *ptr);\n\n\n/** Query function for mode information\n *\n * @param mode Speex mode\n * @param request ioctl-type request (one of the SPEEX_* macros)\n * @param ptr Data exchanged to-from function\n * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter\n */\nint speex_mode_query(const SpeexMode *mode, int request, void *ptr);\n\n/** Functions for controlling the behavior of libspeex\n * @param request ioctl-type request (one of the SPEEX_LIB_* macros)\n * @param ptr Data exchanged to-from function\n * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter\n */\nint speex_lib_ctl(int request, void *ptr);\n\n/** Default narrowband mode */\nextern const SpeexMode speex_nb_mode;\n\n/** Default wideband mode */\nextern const SpeexMode speex_wb_mode;\n\n/** Default \"ultra-wideband\" mode */\nextern const SpeexMode speex_uwb_mode;\n\n/** List of all modes available */\nextern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES];\n\n/** Obtain one of the modes available */\nconst SpeexMode * speex_lib_get_mode (int mode);\n\n#ifndef _WIN32\n/* We actually override the function in the narrowband case so that we can avoid linking in the wideband stuff */\n#define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode : speex_lib_get_mode (mode))\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n/** @}*/\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/speex/speex_bits.h",
    "content": "/* Copyright (C) 2002 Jean-Marc Valin */\n/**\n   @file speex_bits.h\n   @brief Handles bit packing/unpacking\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n#ifndef BITS_H\n#define BITS_H\n/** @defgroup SpeexBits SpeexBits: Bit-stream manipulations\n *  This is the structure that holds the bit-stream when encoding or decoding\n * with Speex. It allows some manipulations as well.\n *  @{\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/** Bit-packing data structure representing (part of) a bit-stream. */\ntypedef struct SpeexBits {\n   char *chars;   /**< \"raw\" data */\n   int   nbBits;  /**< Total number of bits stored in the stream*/\n   int   charPtr; /**< Position of the byte \"cursor\" */\n   int   bitPtr;  /**< Position of the bit \"cursor\" within the current char */\n   int   owner;   /**< Does the struct \"own\" the \"raw\" buffer (member \"chars\") */\n   int   overflow;/**< Set to one if we try to read past the valid data */\n   int   buf_size;/**< Allocated size for buffer */\n   int   reserved1; /**< Reserved for future use */\n   void *reserved2; /**< Reserved for future use */\n} SpeexBits;\n\n/** Initializes and allocates resources for a SpeexBits struct */\nvoid speex_bits_init(SpeexBits *bits);\n\n/** Initializes SpeexBits struct using a pre-allocated buffer*/\nvoid speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size);\n\n/** Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data) */\nvoid speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size);\n\n/** Frees all resources associated to a SpeexBits struct. Right now this does nothing since no resources are allocated, but this could change in the future.*/\nvoid speex_bits_destroy(SpeexBits *bits);\n\n/** Resets bits to initial value (just after initialization, erasing content)*/\nvoid speex_bits_reset(SpeexBits *bits);\n\n/** Rewind the bit-stream to the beginning (ready for read) without erasing the content */\nvoid speex_bits_rewind(SpeexBits *bits);\n\n/** Initializes the bit-stream from the data in an area of memory */\nvoid speex_bits_read_from(SpeexBits *bits, const char *bytes, int len);\n\n/** Append bytes to the bit-stream\n *\n * @param bits Bit-stream to operate on\n * @param bytes pointer to the bytes what will be appended\n * @param len Number of bytes of append\n */\nvoid speex_bits_read_whole_bytes(SpeexBits *bits, const char *bytes, int len);\n\n/** Write the content of a bit-stream to an area of memory\n *\n * @param bits Bit-stream to operate on\n * @param bytes Memory location where to write the bits\n * @param max_len Maximum number of bytes to write (i.e. size of the \"bytes\" buffer)\n * @return Number of bytes written to the \"bytes\" buffer\n*/\nint speex_bits_write(SpeexBits *bits, char *bytes, int max_len);\n\n/** Like speex_bits_write, but writes only the complete bytes in the stream. Also removes the written bytes from the stream */\nint speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len);\n\n/** Append bits to the bit-stream\n * @param bits Bit-stream to operate on\n * @param data Value to append as integer\n * @param nbBits number of bits to consider in \"data\"\n */\nvoid speex_bits_pack(SpeexBits *bits, int data, int nbBits);\n\n/** Interpret the next bits in the bit-stream as a signed integer\n *\n * @param bits Bit-stream to operate on\n * @param nbBits Number of bits to interpret\n * @return A signed integer represented by the bits read\n */\nint speex_bits_unpack_signed(SpeexBits *bits, int nbBits);\n\n/** Interpret the next bits in the bit-stream as an unsigned integer\n *\n * @param bits Bit-stream to operate on\n * @param nbBits Number of bits to interpret\n * @return An unsigned integer represented by the bits read\n */\nunsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits);\n\n/** Returns the number of bytes in the bit-stream, including the last one even if it is not \"full\"\n *\n * @param bits Bit-stream to operate on\n * @return Number of bytes in the stream\n */\nint speex_bits_nbytes(SpeexBits *bits);\n\n/** Same as speex_bits_unpack_unsigned, but without modifying the cursor position\n *\n * @param bits Bit-stream to operate on\n * @param nbBits Number of bits to look for\n * @return Value of the bits peeked, interpreted as unsigned\n */\nunsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits);\n\n/** Get the value of the next bit in the stream, without modifying the\n * \"cursor\" position\n *\n * @param bits Bit-stream to operate on\n * @return Value of the bit peeked (one bit only)\n */\nint speex_bits_peek(SpeexBits *bits);\n\n/** Advances the position of the \"bit cursor\" in the stream\n *\n * @param bits Bit-stream to operate on\n * @param n Number of bits to advance\n */\nvoid speex_bits_advance(SpeexBits *bits, int n);\n\n/** Returns the number of bits remaining to be read in a stream\n *\n * @param bits Bit-stream to operate on\n * @return Number of bits that can still be read from the stream\n */\nint speex_bits_remaining(SpeexBits *bits);\n\n/** Insert a terminator so that the data can be sent as a packet while auto-detecting\n * the number of frames in each packet\n *\n * @param bits Bit-stream to operate on\n */\nvoid speex_bits_insert_terminator(SpeexBits *bits);\n\n#ifdef __cplusplus\n}\n#endif\n\n/* @} */\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/speex/speex_callbacks.h",
    "content": "/* Copyright (C) 2002 Jean-Marc Valin*/\n/**\n  @file speex_callbacks.h\n  @brief Describes callback handling and in-band signalling\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n#ifndef SPEEX_CALLBACKS_H\n#define SPEEX_CALLBACKS_H\n/** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder.\n *  @{\n */\n\n#include \"speex.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/** Total number of callbacks */\n#define SPEEX_MAX_CALLBACKS 16\n\n/* Describes all the in-band requests */\n\n/*These are 1-bit requests*/\n/** Request for perceptual enhancement (1 for on, 0 for off) */\n#define SPEEX_INBAND_ENH_REQUEST         0\n/** Reserved */\n#define SPEEX_INBAND_RESERVED1           1\n\n/*These are 4-bit requests*/\n/** Request for a mode change */\n#define SPEEX_INBAND_MODE_REQUEST        2\n/** Request for a low mode change */\n#define SPEEX_INBAND_LOW_MODE_REQUEST    3\n/** Request for a high mode change */\n#define SPEEX_INBAND_HIGH_MODE_REQUEST   4\n/** Request for VBR (1 on, 0 off) */\n#define SPEEX_INBAND_VBR_QUALITY_REQUEST 5\n/** Request to be sent acknowledge */\n#define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6\n/** Request for VBR (1 for on, 0 for off) */\n#define SPEEX_INBAND_VBR_REQUEST         7\n\n/*These are 8-bit requests*/\n/** Send a character in-band */\n#define SPEEX_INBAND_CHAR                8\n/** Intensity stereo information */\n#define SPEEX_INBAND_STEREO              9\n\n/*These are 16-bit requests*/\n/** Transmit max bit-rate allowed */\n#define SPEEX_INBAND_MAX_BITRATE         10\n\n/*These are 32-bit requests*/\n/** Acknowledge packet reception */\n#define SPEEX_INBAND_ACKNOWLEDGE         12\n\n/** Callback function type */\ntypedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data);\n\n/** Callback information */\ntypedef struct SpeexCallback {\n   int callback_id;             /**< ID associated to the callback */\n   speex_callback_func func;    /**< Callback handler function */\n   void *data;                  /**< Data that will be sent to the handler */\n   void *reserved1;             /**< Reserved for future use */\n   int   reserved2;             /**< Reserved for future use */\n} SpeexCallback;\n\n/** Handle in-band request */\nint speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state);\n\n/** Standard handler for mode request (change mode, no questions asked) */\nint speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for high mode request (change high mode, no questions asked) */\nint speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for in-band characters (write to stderr) */\nint speex_std_char_handler(SpeexBits *bits, void *state, void *data);\n\n/** Default handler for user-defined requests: in this case, just ignore */\nint speex_default_user_handler(SpeexBits *bits, void *state, void *data);\n\n\n\n/** Standard handler for low mode request (change low mode, no questions asked) */\nint speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for VBR request (Set VBR, no questions asked) */\nint speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for enhancer request (Turn enhancer on/off, no questions asked) */\nint speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for VBR quality request (Set VBR quality, no questions asked) */\nint speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n/** @} */\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/speex/speex_config_types.h",
    "content": "#ifndef __SPEEX_TYPES_H__\n#define __SPEEX_TYPES_H__\n\n#include <stdint.h>\n\ntypedef int16_t spx_int16_t;\ntypedef uint16_t spx_uint16_t;\ntypedef int32_t spx_int32_t;\ntypedef uint32_t spx_uint32_t;\n\n#endif\n\n"
  },
  {
    "path": "thirdparty/32/include/speex/speex_header.h",
    "content": "/* Copyright (C) 2002 Jean-Marc Valin */\n/**\n   @file speex_header.h\n   @brief Describes the Speex header\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n\n#ifndef SPEEX_HEADER_H\n#define SPEEX_HEADER_H\n/** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header\n *  This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP.\n *  @{\n */\n\n#include \"speex_types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct SpeexMode;\n\n/** Length of the Speex header identifier */\n#define SPEEX_HEADER_STRING_LENGTH 8\n\n/** Maximum number of characters for encoding the Speex version number in the header */\n#define SPEEX_HEADER_VERSION_LENGTH 20\n\n/** Speex header info for file-based formats */\ntypedef struct SpeexHeader {\n   char speex_string[SPEEX_HEADER_STRING_LENGTH];   /**< Identifies a Speex bit-stream, always set to \"Speex   \" */\n   char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */\n   spx_int32_t speex_version_id;       /**< Version for Speex (for checking compatibility) */\n   spx_int32_t header_size;            /**< Total size of the header ( sizeof(SpeexHeader) ) */\n   spx_int32_t rate;                   /**< Sampling rate used */\n   spx_int32_t mode;                   /**< Mode used (0 for narrowband, 1 for wideband) */\n   spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */\n   spx_int32_t nb_channels;            /**< Number of channels encoded */\n   spx_int32_t bitrate;                /**< Bit-rate used */\n   spx_int32_t frame_size;             /**< Size of frames */\n   spx_int32_t vbr;                    /**< 1 for a VBR encoding, 0 otherwise */\n   spx_int32_t frames_per_packet;      /**< Number of frames stored per Ogg packet */\n   spx_int32_t extra_headers;          /**< Number of additional headers after the comments */\n   spx_int32_t reserved1;              /**< Reserved for future use, must be zero */\n   spx_int32_t reserved2;              /**< Reserved for future use, must be zero */\n} SpeexHeader;\n\n/** Initializes a SpeexHeader using basic information */\nvoid speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m);\n\n/** Creates the header packet from the header itself (mostly involves endianness conversion) */\nchar *speex_header_to_packet(SpeexHeader *header, int *size);\n\n/** Creates a SpeexHeader from a packet */\nSpeexHeader *speex_packet_to_header(char *packet, int size);\n\n/** Frees the memory allocated by either speex_header_to_packet() or speex_packet_to_header() */\nvoid speex_header_free(void *ptr);\n\n#ifdef __cplusplus\n}\n#endif\n\n/** @} */\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/speex/speex_stereo.h",
    "content": "/* Copyright (C) 2002 Jean-Marc Valin*/\n/**\n   @file speex_stereo.h\n   @brief Describes the handling for intensity stereo\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef STEREO_H\n#define STEREO_H\n/** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo files\n *  This describes the Speex intensity stereo encoding/decoding\n *  @{\n */\n\n#include \"speex_types.h\"\n#include \"speex_bits.h\"\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/** If you access any of these fields directly, I'll personally come and bite you */\ntypedef struct SpeexStereoState {\n   float balance;      /**< Left/right balance info */\n   float e_ratio;      /**< Ratio of energies: E(left+right)/[E(left)+E(right)]  */\n   float smooth_left;  /**< Smoothed left channel gain */\n   float smooth_right; /**< Smoothed right channel gain */\n   float reserved1;    /**< Reserved for future use */\n   float reserved2;    /**< Reserved for future use */\n} SpeexStereoState;\n\n/** Deprecated. Use speex_stereo_state_init() instead. */\n#define SPEEX_STEREO_STATE_INIT {1,.5,1,1,0,0}\n\n/** Initialise/create a stereo stereo state */\nSpeexStereoState *speex_stereo_state_init(void);\n\n/** Reset/re-initialise an already allocated stereo state */\nvoid speex_stereo_state_reset(SpeexStereoState *stereo);\n\n/** Destroy a stereo stereo state */\nvoid speex_stereo_state_destroy(SpeexStereoState *stereo);\n\n/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */\nvoid speex_encode_stereo(float *data, int frame_size, SpeexBits *bits);\n\n/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */\nvoid speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits);\n\n/** Transforms a mono frame into a stereo frame using intensity stereo info */\nvoid speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo);\n\n/** Transforms a mono frame into a stereo frame using intensity stereo info */\nvoid speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo);\n\n/** Callback handler for intensity stereo info */\nint speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data);\n\n#ifdef __cplusplus\n}\n#endif\n\n/** @} */\n#endif\n"
  },
  {
    "path": "thirdparty/32/include/speex/speex_types.h",
    "content": "/* speex_types.h taken from libogg */\n/********************************************************************\n *                                                                  *\n * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *\n * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *\n * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *\n * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *\n *                                                                  *\n * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *\n * by the Xiph.Org Foundation http://www.xiph.org/                  *\n *                                                                  *\n ********************************************************************\n\n function: #ifdef jail to whip a few platforms into the UNIX ideal.\n last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $\n\n ********************************************************************/\n/**\n   @file speex_types.h\n   @brief Speex types\n*/\n#ifndef _SPEEX_TYPES_H\n#define _SPEEX_TYPES_H\n\n#if defined(_WIN32)\n\n#  if defined(__CYGWIN__)\n#    include <_G_config.h>\n     typedef _G_int32_t spx_int32_t;\n     typedef _G_uint32_t spx_uint32_t;\n     typedef _G_int16_t spx_int16_t;\n     typedef _G_uint16_t spx_uint16_t;\n#  elif defined(__MINGW32__)\n     typedef short spx_int16_t;\n     typedef unsigned short spx_uint16_t;\n     typedef int spx_int32_t;\n     typedef unsigned int spx_uint32_t;\n#  elif defined(__MWERKS__)\n     typedef int spx_int32_t;\n     typedef unsigned int spx_uint32_t;\n     typedef short spx_int16_t;\n     typedef unsigned short spx_uint16_t;\n#  else\n     /* MSVC/Borland */\n     typedef __int32 spx_int32_t;\n     typedef unsigned __int32 spx_uint32_t;\n     typedef __int16 spx_int16_t;\n     typedef unsigned __int16 spx_uint16_t;\n#  endif\n\n#elif defined(__MACOS__)\n\n#  include <sys/types.h>\n   typedef SInt16 spx_int16_t;\n   typedef UInt16 spx_uint16_t;\n   typedef SInt32 spx_int32_t;\n   typedef UInt32 spx_uint32_t;\n\n#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */\n\n#  include <sys/types.h>\n   typedef int16_t spx_int16_t;\n   typedef u_int16_t spx_uint16_t;\n   typedef int32_t spx_int32_t;\n   typedef u_int32_t spx_uint32_t;\n\n#elif defined(__BEOS__)\n\n   /* Be */\n#  include <inttypes.h>\n   typedef int16_t spx_int16_t;\n   typedef u_int16_t spx_uint16_t;\n   typedef int32_t spx_int32_t;\n   typedef u_int32_t spx_uint32_t;\n\n#elif defined (__EMX__)\n\n   /* OS/2 GCC */\n   typedef short spx_int16_t;\n   typedef unsigned short spx_uint16_t;\n   typedef int spx_int32_t;\n   typedef unsigned int spx_uint32_t;\n\n#elif defined (DJGPP)\n\n   /* DJGPP */\n   typedef short spx_int16_t;\n   typedef int spx_int32_t;\n   typedef unsigned int spx_uint32_t;\n\n#elif defined(R5900)\n\n   /* PS2 EE */\n   typedef int spx_int32_t;\n   typedef unsigned spx_uint32_t;\n   typedef short spx_int16_t;\n\n#elif defined(__SYMBIAN32__)\n\n   /* Symbian GCC */\n   typedef signed short spx_int16_t;\n   typedef unsigned short spx_uint16_t;\n   typedef signed int spx_int32_t;\n   typedef unsigned int spx_uint32_t;\n\n#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)\n\n   typedef short spx_int16_t;\n   typedef unsigned short spx_uint16_t;\n   typedef long spx_int32_t;\n   typedef unsigned long spx_uint32_t;\n\n#elif defined(CONFIG_TI_C6X)\n\n   typedef short spx_int16_t;\n   typedef unsigned short spx_uint16_t;\n   typedef int spx_int32_t;\n   typedef unsigned int spx_uint32_t;\n\n#else\n\n#include \"speex_config_types.h\"\n\n#endif\n\n#endif  /* _SPEEX_TYPES_H */\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/dav1d.pc",
    "content": "prefix=.\nincludedir=${prefix}/include\nlibdir=${prefix}/lib\n\nName: libdav1d\nDescription: AV1 decoding library\nVersion: 1.5.1\nLibs: -L${libdir} -ldav1d\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/gmp.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nincludedir=${prefix}/include\nlibdir=${exec_prefix}/lib\n\nName: GNU MP\nDescription: GNU Multiple Precision Arithmetic Library\nURL: https://gmplib.org\nVersion: 6.3.0\nCflags: -I${includedir}\nLibs: -L${libdir} -lgmp\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/gnutls.pc",
    "content": "# Process this file with autoconf to produce a pkg-config metadata file.\n\n# Copyright (C) 2004-2012 Free Software Foundation, Inc.\n\n# Copying and distribution of this file, with or without modification,\n# are permitted in any medium without royalty provided the copyright\n# notice and this notice are preserved.  This file is offered as-is,\n# without any warranty.\n\n# Author: Simon Josefsson\n\nprefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: GnuTLS\nDescription: Transport Security Layer implementation for the GNU system\nURL: https://www.gnutls.org/\nVersion: 3.7.10\nLibs: -L${libdir} -lgnutls\nLibs.private: -lz -lws2_32  -L${libdir}  -latomic  -ladvapi32 -lcrypt32 -lncrypt -lbcrypt\nRequires.private: nettle, hogweed\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/hogweed.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\n# Uses Requires.private and Libs.private, under the assumption that\n# when using shared libraries, the ELF dependencies from libhogweed.so\n# to nettle and gmp work.\n\nName: Hogweed\nDescription: Nettle low-level cryptographic library (public-key algorithms)\nURL: http://www.lysator.liu.se/~nisse/nettle\nVersion: 3.9.1\nRequires:  nettle\nRequires.private: # nettle\nLibs: -L${libdir} -lhogweed  -lgmp -lnettle\nLibs.private: # -lgmp\nCflags: -I${includedir}\n\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/libxml-2.0.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\nmodules=1\n\nName: libXML\nVersion: 2.11.5\nDescription: libXML library version2.\nRequires:\nLibs: -L${libdir} -lxml2\nLibs.private: -lz     -lm\nCflags: -I${includedir}/libxml2  -DLIBXML_STATIC\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/nettle.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: Nettle\nDescription: Nettle low-level cryptographic library (symmetric algorithms)\nURL: http://www.lysator.liu.se/~nisse/nettle\nVersion: 3.9.1\nLibs: -L${libdir} -lnettle\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/opencore-amrnb.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: OpenCORE AMR-NB\nDescription: Adaptive Multi-Rate speech codec library\nVersion: 0.1.6\nLibs: -L${libdir} -lopencore-amrnb\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/opencore-amrwb.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: OpenCORE AMR-WB\nDescription: Adaptive Multi-Rate Wideband speech codec library\nVersion: 0.1.6\nLibs: -L${libdir} -lopencore-amrwb\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/32/lib/pkgconfig/speex.pc",
    "content": "# libspeex pkg-config source file\n\nprefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: speex\nDescription: Speex is an audio codec tuned for speech\nVersion: 1.2.1\nRequires:\nConflicts:\nLibs: -L${libdir} -lspeex\nLibs.private: -lm\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avisynth.h",
    "content": "// Avisynth v2.5.  Copyright 2002 Ben Rudiak-Gould et al.\n// Avisynth v2.6.  Copyright 2006 Klaus Post.\n// Avisynth v2.6.  Copyright 2009 Ian Brabham.\n// Avisynth+ project\n// 20160613: new 16 bit planar pixel_type constants go live!\n// 20160725: pixel_type constants 10-12-14 bit + planar RGB + BRG48/64\n// 20161005: Fallback of VideoInfo functions to defaults if no function exists\n// 20170117: global variables for VfW output OPT_xxxx\n// 20170310: new MT mode: MT_SPECIAL_MT\n// 20171103: (test with SIZETMOD define: Videoframe offsets to size_t, may affect x64)\n// 20171207: C++ Standard Conformance (no change for plugin writers)\n// 20180525: AVS_UNUSED define to supress parameter not used warnings\n// 2020xxxx: AVS_WINDOWS and AVS_POSIX option see avs/config.h\n// 20200305: ScriptEnvironment::VSprintf parameter (void *) changed back to va_list\n// 20200330: removed __stdcall from variadic argument functions (Sprintf)\n//           (remove test SIZETMOD define for clarity)\n//           Integrate Avisynth Neo structures and interface, PFunction, PDevice\n// 20200501: frame property support (NewVideoFrameP and other helpers) to legacy IScriptEnvironment.\n//           move some former IScriptEnvironment2 functions to IScriptEnvironment:\n//           GetEnvProperty (system prop), Allocate, Free (buffer pool)\n//           GetVarTry, GetVarBool/Int/String/Double/Long\n//           Invoke2, Invoke3, InvokeTry, Invoke2Try, Invoke3Try\n//           Interface Version to 8 (classic 2.6 = 6)\n// 20200527  Add IScriptEnvironment_Avs25, used internally\n// 20200607  AVS frame property enums to match existing Avisynth enum style\n// 202112xx  V9-MakePropertyWritable, IsPropertyWritable\n// 2023      V10\n//           prop_src parameter made as const in NewVideoFrameP (non-breaking cosmetics)\n//           Add all enums of public C++ API a name\n//           Add DEFAULT_PLANE as 0 to AvsPlane enum\n//           Made `VideoFrameBuffer` destructor public\n//           Introduce pixel_type to VideoFrame struct\n//           VideoFrame::GetPixelType,VideoFrame::AmendPixelType\n//           AVSValue::GetType\n//           Add enum AvsChannelMask::MASK_SPEAKER_xxx, AvsImageTypeFlags::IT_SPEAKER_xxx\n//           Audio channel mask support for VideoInfo: \n//           Use 20 bits in VideoInfo::image_type for channel mask mapping\n//           IsChannelMaskKnown, SetChannelMask, GetChannelMask in VideoInfo\n\n// http://www.avisynth.org\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making\n// a combined work based on Avisynth.  Thus, the terms and conditions of\n// the GNU General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate\n// with Avisynth solely through the interfaces defined in avisynth.h,\n// regardless of the license terms of these independent modules, and to\n// copy and distribute the resulting combined work under terms of your\n// choice, provided that every copy of the combined work is accompanied\n// by a complete copy of the source code of Avisynth (the version of\n// Avisynth used to produce the combined work), being distributed under\n// the terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based on\n// Avisynth, such as 3rd-party filters, import and export plugins, or\n// graphical user interfaces.\n\n\n#ifndef __AVISYNTH_10_H__\n#define __AVISYNTH_10_H__\n\n#include \"avs/config.h\"\n#include \"avs/capi.h\"\n#include \"avs/types.h\"\n\n#ifdef AVS_POSIX\n# include \"avs/posix.h\"\n#endif\n\n#if defined(AVS_POSIX)\n#if defined(AVS_HAIKU)\n#undef __stdcall\n#undef __cdecl\n#endif\n#define __stdcall\n#define __cdecl\n#endif\n\n// Important note on AVISYNTH_INTERFACE_VERSION V6->V8 change:\n// Note 1: Those few plugins which were using earlier IScriptEnvironment2 despite the big Warning will crash have to be rebuilt.\n// Note 2: How to support earlier avisynth interface with an up-to-date avisynth.h:\n//         Use the new frame property features adaptively after querying that at least v8 is supported\n//         AviSynth property support can be queried (cpp iface example):\n//           has_at_least_v8 = true;\n//           try { env->CheckVersion(8); } catch (const AvisynthError&) { has_at_least_v8 = false; }\n//         and use it:\n//           if (has_at_least_v8) dst = env->NewVideoFrameP(vi, &src); else dst = env->NewVideoFrame(vi);\n\nenum AvsVersion {\n  AVISYNTH_CLASSIC_INTERFACE_VERSION_25 = 3,\n  AVISYNTH_CLASSIC_INTERFACE_VERSION_26BETA = 5,\n  AVISYNTH_CLASSIC_INTERFACE_VERSION = 6,\n  AVISYNTH_INTERFACE_VERSION = 10,\n  AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION = 0 // reset to zero whenever the normal interface version bumps\n};\n\n/* Compiler-specific crap */\n\n// Tell MSVC to stop precompiling here\n#if defined(_MSC_VER) && !defined(__clang__)\n  #pragma hdrstop\n#endif\n\n// Set up debugging macros for MS compilers; for others, step down to the\n// standard <assert.h> interface\n#ifdef _MSC_VER\n  #include <crtdbg.h>\n#else\n  #undef _RPT0\n  #undef _RPT1\n  #undef _RPT2\n  #undef _RPT3\n  #undef _RPT4\n  #undef _RPT5\n  #define _RPT0(a,b) ((void)0)\n  #define _RPT1(a,b,c) ((void)0)\n  #define _RPT2(a,b,c,d) ((void)0)\n  #define _RPT3(a,b,c,d,e) ((void)0)\n  #define _RPT4(a,b,c,d,e,f) ((void)0)\n  #define _RPT5(a,b,c,d,e,f,g) ((void)0)\n\n  #include <cassert>\n  #undef _ASSERTE\n  #undef _ASSERT\n  #define _ASSERTE(x) assert(x)\n  #define _ASSERT(x) assert(x)\n#endif\n\n\n\n// I had problems with Premiere wanting 1-byte alignment for its structures,\n// so I now set the Avisynth struct alignment explicitly here.\n#pragma pack(push,8)\n\n// The VideoInfo struct holds global information about a clip (i.e.\n// information that does not depend on the frame number).  The GetVideoInfo\n// method in IClip returns this struct.\n\nenum AvsSampleType {\n  SAMPLE_INT8  = 1 << 0,\n  SAMPLE_INT16 = 1 << 1,\n  SAMPLE_INT24 = 1 << 2,  // Int24 is a very stupid thing to code, but it's supported by some hardware.\n  SAMPLE_INT32 = 1 << 3,\n  SAMPLE_FLOAT = 1 << 4\n};\n\nenum AvsPlane {\n  DEFAULT_PLANE = 0,\n  PLANAR_Y = 1 << 0,\n  PLANAR_U = 1 << 1,\n  PLANAR_V = 1 << 2,\n  PLANAR_ALIGNED = 1 << 3,\n  PLANAR_Y_ALIGNED = PLANAR_Y | PLANAR_ALIGNED,\n  PLANAR_U_ALIGNED = PLANAR_U | PLANAR_ALIGNED,\n  PLANAR_V_ALIGNED = PLANAR_V | PLANAR_ALIGNED,\n  PLANAR_A = 1 << 4,\n  PLANAR_R = 1 << 5,\n  PLANAR_G = 1 << 6,\n  PLANAR_B = 1 << 7,\n  PLANAR_A_ALIGNED = PLANAR_A | PLANAR_ALIGNED,\n  PLANAR_R_ALIGNED = PLANAR_R | PLANAR_ALIGNED,\n  PLANAR_G_ALIGNED = PLANAR_G | PLANAR_ALIGNED,\n  PLANAR_B_ALIGNED = PLANAR_B | PLANAR_ALIGNED,\n};\n\nclass AvisynthError /* exception */ {\npublic:\n  const char* const msg;\n  AvisynthError(const char* _msg) : msg(_msg) {}\n\n// Ensure AvisynthError cannot be publicly assigned!\nprivate:\n  AvisynthError& operator=(const AvisynthError&);\n}; // end class AvisynthError\n\nenum AvsDeviceType {\n  DEV_TYPE_NONE = 0,\n  DEV_TYPE_CPU = 1,\n  DEV_TYPE_CUDA = 2,\n  DEV_TYPE_ANY = 0xFFFF\n};\n\nenum AvsValueType {\n  VALUE_TYPE_UNDEFINED = 'v',\n  VALUE_TYPE_BOOL = 'b',\n  VALUE_TYPE_INT = 'i',\n  VALUE_TYPE_LONG = 'l',\n  VALUE_TYPE_FLOAT = 'f',\n  VALUE_TYPE_DOUBLE = 'd',\n  VALUE_TYPE_STRING = 's',\n  VALUE_TYPE_CLIP = 'c',\n  VALUE_TYPE_FUNCTION = 'n',\n  VALUE_TYPE_ARRAY = 'a'\n};\n\n/* Forward references */\n#if defined(MSVC)\n    #define SINGLE_INHERITANCE __single_inheritance\n#else\n    #define SINGLE_INHERITANCE\n#endif\nstruct SINGLE_INHERITANCE VideoInfo;\nclass SINGLE_INHERITANCE VideoFrameBuffer;\nclass SINGLE_INHERITANCE VideoFrame;\nclass IClip;\nclass SINGLE_INHERITANCE PClip;\nclass SINGLE_INHERITANCE PVideoFrame;\nclass IScriptEnvironment;\nclass SINGLE_INHERITANCE AVSValue;\nclass INeoEnv;\nclass IFunction;\nclass SINGLE_INHERITANCE PFunction;\nclass Device;\nclass SINGLE_INHERITANCE PDevice;\nclass AVSMap;\n\n\n\n/*\n * Avisynth C++ plugin API code function pointers.\n *\n * In order to maintain binary compatibility with\n * future version do not change the order of the\n * existing function pointers. It will be baked\n * into all existing plugins.\n *\n * Add new function pointers to the end of the\n * structure. The linkage macros generate some\n * protection code to ensure newer plugin do not\n * call non-existing functions in an older host.\n */\n\nstruct AVS_Linkage {\n\n  int Size;\n\n/**********************************************************************/\n\n// struct VideoInfo\n  bool    (VideoInfo::*HasVideo)() const;\n  bool    (VideoInfo::*HasAudio)() const;\n  bool    (VideoInfo::*IsRGB)() const;\n  bool    (VideoInfo::*IsRGB24)() const;\n  bool    (VideoInfo::*IsRGB32)() const;\n  bool    (VideoInfo::*IsYUV)() const;\n  bool    (VideoInfo::*IsYUY2)() const;\n  bool    (VideoInfo::*IsYV24)() const;\n  bool    (VideoInfo::*IsYV16)() const;\n  bool    (VideoInfo::*IsYV12)() const;\n  bool    (VideoInfo::*IsYV411)() const;\n  bool    (VideoInfo::*IsY8)() const;\n  bool    (VideoInfo::*IsColorSpace)(int c_space) const;\n  bool    (VideoInfo::*Is)(int property) const;\n  bool    (VideoInfo::*IsPlanar)() const;\n  bool    (VideoInfo::*IsFieldBased)() const;\n  bool    (VideoInfo::*IsParityKnown)() const;\n  bool    (VideoInfo::*IsBFF)() const;\n  bool    (VideoInfo::*IsTFF)() const;\n  bool    (VideoInfo::*IsVPlaneFirst)() const;\n  int     (VideoInfo::*BytesFromPixels)(int pixels) const;\n  int     (VideoInfo::*RowSize)(int plane) const;\n  int     (VideoInfo::*BMPSize)() const;\n  int64_t (VideoInfo::*AudioSamplesFromFrames)(int frames) const;\n  int     (VideoInfo::*FramesFromAudioSamples)(int64_t samples) const;\n  int64_t (VideoInfo::*AudioSamplesFromBytes)(int64_t bytes) const;\n  int64_t (VideoInfo::*BytesFromAudioSamples)(int64_t samples) const;\n  int     (VideoInfo::*AudioChannels)() const;\n  int     (VideoInfo::*SampleType)() const;\n  bool    (VideoInfo::*IsSampleType)(int testtype) const;\n  int     (VideoInfo::*SamplesPerSecond)() const;\n  int     (VideoInfo::*BytesPerAudioSample)() const;\n  void    (VideoInfo::*SetFieldBased)(bool isfieldbased);\n  void    (VideoInfo::*Set)(int property);\n  void    (VideoInfo::*Clear)(int property);\n  int     (VideoInfo::*GetPlaneWidthSubsampling)(int plane) const;\n  int     (VideoInfo::*GetPlaneHeightSubsampling)(int plane) const;\n  int     (VideoInfo::*BitsPerPixel)() const;\n  int     (VideoInfo::*BytesPerChannelSample)() const;\n  void    (VideoInfo::*SetFPS)(unsigned numerator, unsigned denominator);\n  void    (VideoInfo::*MulDivFPS)(unsigned multiplier, unsigned divisor);\n  bool    (VideoInfo::*IsSameColorspace)(const VideoInfo& vi) const;\n// end struct VideoInfo\n\n/**********************************************************************/\n\n// class VideoFrameBuffer\n  const BYTE* (VideoFrameBuffer::*VFBGetReadPtr)() const;\n  BYTE*       (VideoFrameBuffer::*VFBGetWritePtr)();\n  int         (VideoFrameBuffer::*GetDataSize)() const;\n  int         (VideoFrameBuffer::*GetSequenceNumber)() const;\n  int         (VideoFrameBuffer::*GetRefcount)() const;\n// end class VideoFrameBuffer\n\n/**********************************************************************/\n\n// class VideoFrame\n  int               (VideoFrame::*GetPitch)(int plane) const;\n  int               (VideoFrame::*GetRowSize)(int plane) const;\n  int               (VideoFrame::*GetHeight)(int plane) const;\n  VideoFrameBuffer* (VideoFrame::*GetFrameBuffer)() const;\n  int               (VideoFrame::*GetOffset)(int plane) const;\n  const BYTE*       (VideoFrame::*VFGetReadPtr)(int plane) const;\n  bool              (VideoFrame::*IsWritable)() const;\n  BYTE*             (VideoFrame::*VFGetWritePtr)(int plane) const;\n  void              (VideoFrame::*VideoFrame_DESTRUCTOR)();\n// end class VideoFrame\n\n/**********************************************************************/\n\n// class IClip\n  /* nothing */\n// end class IClip\n\n/**********************************************************************/\n\n// class PClip\n  void (PClip::*PClip_CONSTRUCTOR0)();\n  void (PClip::*PClip_CONSTRUCTOR1)(const PClip& x);\n  void (PClip::*PClip_CONSTRUCTOR2)(IClip* x);\n  void (PClip::*PClip_OPERATOR_ASSIGN0)(IClip* x);\n  void (PClip::*PClip_OPERATOR_ASSIGN1)(const PClip& x);\n  void (PClip::*PClip_DESTRUCTOR)();\n// end class PClip\n\n/**********************************************************************/\n\n// class PVideoFrame\n  void (PVideoFrame::*PVideoFrame_CONSTRUCTOR0)();\n  void (PVideoFrame::*PVideoFrame_CONSTRUCTOR1)(const PVideoFrame& x);\n  void (PVideoFrame::*PVideoFrame_CONSTRUCTOR2)(VideoFrame* x);\n  void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN0)(VideoFrame* x);\n  void (PVideoFrame::*PVideoFrame_OPERATOR_ASSIGN1)(const PVideoFrame& x);\n  void (PVideoFrame::*PVideoFrame_DESTRUCTOR)();\n// end class PVideoFrame\n\n/**********************************************************************/\n\n// class AVSValue\n  void            (AVSValue::*AVSValue_CONSTRUCTOR0)();\n  void            (AVSValue::*AVSValue_CONSTRUCTOR1)(IClip* c);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR2)(const PClip& c);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR3)(bool b);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR4)(int i);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR5)(float f);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR6)(double f);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR7)(const char* s);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR8)(const AVSValue* a, int size);\n  void            (AVSValue::*AVSValue_CONSTRUCTOR9)(const AVSValue& v);\n  void            (AVSValue::*AVSValue_DESTRUCTOR)();\n  AVSValue&       (AVSValue::*AVSValue_OPERATOR_ASSIGN)(const AVSValue& v);\n  const AVSValue& (AVSValue::*AVSValue_OPERATOR_INDEX)(int index) const;\n  bool            (AVSValue::*Defined)() const;\n  bool            (AVSValue::*IsClip)() const;\n  bool            (AVSValue::*IsBool)() const;\n  bool            (AVSValue::*IsInt)() const;\n  bool            (AVSValue::*IsFloat)() const;\n  bool            (AVSValue::*IsString)() const;\n  bool            (AVSValue::*IsArray)() const;\n  PClip           (AVSValue::*AsClip)() const;\n  bool            (AVSValue::*AsBool1)() const;\n  int             (AVSValue::*AsInt1)() const;\n  const char*     (AVSValue::*AsString1)() const;\n  double          (AVSValue::*AsFloat1)() const;\n  bool            (AVSValue::*AsBool2)(bool def) const;\n  int             (AVSValue::*AsInt2)(int def) const;\n  double          (AVSValue::*AsDblDef)(double def) const;\n  double          (AVSValue::*AsFloat2)(float def) const;\n  const char*     (AVSValue::*AsString2)(const char* def) const;\n  int             (AVSValue::*ArraySize)() const;\n// end class AVSValue\n\n/**********************************************************************/\n  // Reserve pointer space so that we can keep compatibility with Avs \"classic\" even if it adds functions on its own\n  void    (VideoInfo::*reserved[32])();\n/**********************************************************************/\n  // AviSynth+ additions\n  int     (VideoInfo::*NumComponents)() const;\n  int     (VideoInfo::*ComponentSize)() const;\n  int     (VideoInfo::*BitsPerComponent)() const;\n  bool    (VideoInfo::*Is444)() const;\n  bool    (VideoInfo::*Is422)() const;\n  bool    (VideoInfo::*Is420)() const;\n  bool    (VideoInfo::*IsY)() const;\n  bool    (VideoInfo::*IsRGB48)() const;\n  bool    (VideoInfo::*IsRGB64)() const;\n  bool    (VideoInfo::*IsYUVA)() const;\n  bool    (VideoInfo::*IsPlanarRGB)() const;\n  bool    (VideoInfo::*IsPlanarRGBA)() const;\n  /**********************************************************************/\n\n  // frame property access\n  AVSMap& (VideoFrame::* getProperties)();\n  const AVSMap& (VideoFrame::* getConstProperties)();\n  void (VideoFrame::* setProperties)(const AVSMap& properties);\n\n  // PFunction\n  void          (AVSValue::* AVSValue_CONSTRUCTOR11)(const PFunction& o);\n  bool          (AVSValue::* IsFunction)() const;\n  void          (PFunction::* PFunction_CONSTRUCTOR0)();\n  void          (PFunction::* PFunction_CONSTRUCTOR1)(IFunction* p);\n  void          (PFunction::* PFunction_CONSTRUCTOR2)(const PFunction& p);\n  PFunction&    (PFunction::* PFunction_OPERATOR_ASSIGN0)(IFunction* other);\n  PFunction&    (PFunction::* PFunction_OPERATOR_ASSIGN1)(const PFunction& other);\n  void          (PFunction::* PFunction_DESTRUCTOR)();\n  // end PFunction\n\n  // extra VideoFrame functions\n  int           (VideoFrame::* VideoFrame_CheckMemory)() const;\n  PDevice       (VideoFrame::* VideoFrame_GetDevice)() const;\n\n  // class PDevice, even if only CPU device\n  void          (PDevice::* PDevice_CONSTRUCTOR0)();\n  void          (PDevice::* PDevice_CONSTRUCTOR1)(Device* p);\n  void          (PDevice::* PDevice_CONSTRUCTOR2)(const PDevice& p);\n  PDevice&      (PDevice::* PDevice_OPERATOR_ASSIGN0)(Device* other);\n  PDevice&      (PDevice::* PDevice_OPERATOR_ASSIGN1)(const PDevice& other);\n  void          (PDevice::* PDevice_DESTRUCTOR)();\n  AvsDeviceType (PDevice::* PDevice_GetType)() const;\n  int           (PDevice::* PDevice_GetId)() const;\n  int           (PDevice::* PDevice_GetIndex)() const;\n  const char*   (PDevice::* PDevice_GetName)() const;\n  // end class PDevice\n\n  // V9: VideoFrame helper\n  bool          (VideoFrame::*IsPropertyWritable)() const;\n\n  // V10\n  int           (VideoFrame::*VideoFrame_GetPixelType)() const;\n  void          (VideoFrame::*VideoFrame_AmendPixelType)(int new_pixel_type);\n  void          (VideoFrameBuffer::*VideoFrameBuffer_DESTRUCTOR)();\n  AvsValueType  (AVSValue::*AVSValue_GetType)() const;\n\n  // V10.1\n  bool          (VideoInfo::* IsChannelMaskKnown)() const;\n  void          (VideoInfo::* SetChannelMask)(bool isChannelMaskKnown, unsigned int dwChannelMask);\n  unsigned int  (VideoInfo::* GetChannelMask)() const;\n\n  /**********************************************************************/\n  // Reserve pointer space for Avisynth+\n  void          (VideoInfo::* reserved2[64 - 31])();\n  /**********************************************************************/\n\n  // AviSynth Neo additions\n  INeoEnv*      (__stdcall *GetNeoEnv)(IScriptEnvironment* env);\n  // As of V8 most PDevice, PFunction linkage entries are moved to standard avs+ place.\n  /**********************************************************************/\n\n  // This part should be identical with AVS_Linkage entries in interface.cpp\n};\n\n#if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB)\n/* Macro resolution for code inside Avisynth.dll */\n# define AVS_BakedCode(arg) ;\n# define AVS_LinkCall(arg)\n# define AVS_LinkCallV(arg)\n# define AVS_LinkCallOpt(arg, argOpt) AVSLinkCall(arg)\n# define AVS_LinkCallOptDefault(arg, argDefaultValue) AVSLinkCall(arg())\n# define CALL_MEMBER_FN(object,ptrToMember)\n\n#else\n/* Macro resolution for code inside user plugin */\n# ifdef AVS_LINKAGE_DLLIMPORT\nextern __declspec(dllimport) const AVS_Linkage* const AVS_linkage;\n# else\nextern const AVS_Linkage* AVS_linkage;\n# endif\n\n# ifndef offsetof\n#  include <stddef.h>\n# endif\n\n# define AVS_BakedCode(arg) { arg ; }\n# define AVS_LinkCall(arg)  !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ?     0 : (this->*(AVS_linkage->arg))\n# define AVS_LinkCall_Void(arg)  !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ?     (void)0 : (this->*(AVS_linkage->arg))\n# define AVS_LinkCallV(arg) !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? *this : (this->*(AVS_linkage->arg))\n// Helper macros for fallback option when a function does not exists\n#define CALL_MEMBER_FN(object,ptrToMember)  ((object)->*(ptrToMember))\n#define AVS_LinkCallOpt(arg, argOpt)  !AVS_linkage ? 0 : \\\n                                      ( offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? \\\n                                        (offsetof(AVS_Linkage, argOpt) >= (size_t)AVS_linkage->Size ? 0 : CALL_MEMBER_FN(this, AVS_linkage->argOpt)() ) : \\\n                                        CALL_MEMBER_FN(this, AVS_linkage->arg)() )\n// AVS_LinkCallOptDefault puts automatically () only after arg\n# define AVS_LinkCallOptDefault(arg, argDefaultValue)  !AVS_linkage || offsetof(AVS_Linkage, arg) >= (size_t)AVS_linkage->Size ? (argDefaultValue) : ((this->*(AVS_linkage->arg))())\n\n#endif\n\nclass PDevice\n{\npublic:\n  PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR0)())\n    PDevice(Device* p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR1)(p))\n    PDevice(const PDevice& p) AVS_BakedCode(AVS_LinkCall_Void(PDevice_CONSTRUCTOR2)(p))\n    PDevice& operator=(Device* p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN0)(p))\n    PDevice& operator=(const PDevice& p) AVS_BakedCode(return AVS_LinkCallV(PDevice_OPERATOR_ASSIGN1)(p))\n    ~PDevice() AVS_BakedCode(AVS_LinkCall_Void(PDevice_DESTRUCTOR)())\n\n    int operator!() const { return !e; }\n  operator void*() const { return e; }\n  Device* operator->() const { return e; }\n\n  AvsDeviceType GetType() const AVS_BakedCode(return AVS_LinkCallOptDefault(PDevice_GetType, DEV_TYPE_NONE))\n    int GetId() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetId)())\n    int GetIndex() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetIndex)())\n    const char* GetName() const AVS_BakedCode(return AVS_LinkCall(PDevice_GetName)())\n\nprivate:\n  Device * e;\n\n#ifdef BUILDING_AVSCORE\npublic:\n  void CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void CONSTRUCTOR1(Device* p);\n  void CONSTRUCTOR2(const PDevice& p);\n  PDevice& OPERATOR_ASSIGN0(Device* p);\n  PDevice& OPERATOR_ASSIGN1(const PDevice& p);\n  void DESTRUCTOR();\n#endif\n};\n\n// Unshifted channel mask constants like in WAVEFORMATEXTENSIBLE\n// in AvsImageTypeFlags they are shifted by 4 bits\nenum AvsChannelMask {\n  MASK_SPEAKER_FRONT_LEFT = 0x1,\n  MASK_SPEAKER_FRONT_RIGHT = 0x2,\n  MASK_SPEAKER_FRONT_CENTER = 0x4,\n  MASK_SPEAKER_LOW_FREQUENCY = 0x8,\n  MASK_SPEAKER_BACK_LEFT = 0x10,\n  MASK_SPEAKER_BACK_RIGHT = 0x20,\n  MASK_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40,\n  MASK_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80,\n  MASK_SPEAKER_BACK_CENTER = 0x100,\n  MASK_SPEAKER_SIDE_LEFT = 0x200,\n  MASK_SPEAKER_SIDE_RIGHT = 0x400,\n  MASK_SPEAKER_TOP_CENTER = 0x800,\n  MASK_SPEAKER_TOP_FRONT_LEFT = 0x1000,\n  MASK_SPEAKER_TOP_FRONT_CENTER = 0x2000,\n  MASK_SPEAKER_TOP_FRONT_RIGHT = 0x4000,\n  MASK_SPEAKER_TOP_BACK_LEFT = 0x8000,\n  MASK_SPEAKER_TOP_BACK_CENTER = 0x10000,\n  MASK_SPEAKER_TOP_BACK_RIGHT = 0x20000,\n  // Bit mask locations used up for the above positions\n  MASK_SPEAKER_DEFINED = 0x0003FFFF,\n  // Bit mask locations reserved for future use\n  MASK_SPEAKER_RESERVED = 0x7FFC0000,\n  // Used to specify that any possible permutation of speaker configurations\n  // Due to lack of available bits this one is put differently into image_type\n  MASK_SPEAKER_ALL = 0x80000000\n};\n\nstruct VideoInfo {\n  int width, height;    // width 0 means no video\n  unsigned fps_numerator, fps_denominator;\n  int num_frames;\n  // This is more extensible than previous versions. More properties can be added seamlessly.\n\n  // Colorspace properties.\n  /*\n    Planar match mask  1111.1000.0000.0111.0000.0111.0000.0111\n    Planar signature   10xx.1000.0000.00xx.0000.00xx.00xx.00xx ?\n    Planar signature   10xx.1000.0000.0xxx.0000.00xx.000x.x0xx ? *new\n    Planar filter mask 1111.1111.1111.1111.1111.1111.1110.0111 (typo from old header fixed)\n    \n    pixel_type mapping\n    ==================\n    pixel_type bit-map PIYB.Z000.0???.0SSS.0000.0???.????.????\n            planar YUV            CCC            HHH.000u.vWWW\n         planar RGB(A)            CCC                       AR\n             nonplanar            CCC            000.00wx xyAR\n    Legend\n    ======\n    Planar YUV:\n      Code Bits Remark\n      W    0-2  Planar Width Subsampling bits\n                Use (X+1) & 3 for GetPlaneWidthSubsampling\n                  000 => 1        YV12, YV16, YUV420, YUV422\n                  001 => 2        YV411, YUV9\n                  010 => reserved\n                  011 => 0        YV24, YUV444, RGBP\n                  1xx => reserved\n      v    3    VPlaneFirst YV12, YV16, YV24, YV411, YUV9\n      u    4    UPlaneFirst I420\n      H    7-9  Planar Height Subsampling bits\n                Use ((X>>8)+1) & 3 for GetPlaneHeightSubsampling\n                  000 => 1        YV12, YUV420\n                  001 => 2        YUV9\n                  010 => reserved\n                  011 => 0        YV16, YV24, YV411, YUV422, YUV444, RGBP\n                  1xx => reserved\n    \n    Planar RGB\n     Code Bits Remark\n       R   0   BGR,  (with SSS bits for 8/16 bit/sample or float)\n       A   1   BGRA, (with SSS bits for 8/16 bit/sample or float)\n    \n    \n    Not Planar, Interleaved (I flag)\n    Code Bits Remark\n      R   0   BGR24, and BGRx in future (with SSS bits for 8/16 bit/sample or float)\n      A   1   BGR32, and BGRAx in future (with SSS bits for 8/16 bit/sample or float)\n      y   2   YUY2\n      x   3-4 reserved\n      w   5   Raw32\n    \n    General\n    Code Bits Remark\n      S 16-18 Sample resolution bits\n              000 => 8\n              001 => 16\n              010 => 32 (float)\n              011,100 => reserved\n              101 => 10 bits\n              110 => 12 bits\n              111 => 14 bits\n    for packed RGB(A): only 8 and 16 bits are valid\n    \n    Other YV12 specific (will never be used)\n      C  20-23 Chroma Placement values 0-4; see CS_xxx_CHROMA_PLACEMENT\n    \n    Color family and layout\n                           Packed      Planar               Planar  Planar\n    Code Bits Remark       RGB/RGBA     YUV  YUY2  Y_Grey  RGB/RGBA  YUVA\n      R   0                  1/0         -    0      -       1/0       -\n      A   1                  0/1         -    0      -       0/1       -\n      y   2                   -          -    1      -        0        -\n      Z  27   YUVA            0          0    0      0        1        1\n      B  28   BGR             1          0    0      0        1*       0\n      Y  29   YUV             0          1    1      1        0        0\n      I  30   Interleaved     1          0    1      1        0        0\n      P  31   Planar          0          1    0      1        1        1\n    * Planar RGB plane order: G,B,R(,A)\n  */\n  enum AvsColorFormat {\n    CS_YUVA        = 1 << 27,\n    CS_BGR         = 1 << 28,\n    CS_YUV         = 1 << 29,\n    CS_INTERLEAVED = 1 << 30,\n    CS_PLANAR      = 1 << 31,\n\n    CS_Shift_Sub_Width   =  0,\n    CS_Shift_Sub_Height  =  8,\n    CS_Shift_Sample_Bits = 16,\n\n    CS_Sub_Width_Mask    = 7 << CS_Shift_Sub_Width,\n    CS_Sub_Width_1       = 3 << CS_Shift_Sub_Width, // YV24\n    CS_Sub_Width_2       = 0 << CS_Shift_Sub_Width, // YV12, I420, YV16\n    CS_Sub_Width_4       = 1 << CS_Shift_Sub_Width, // YUV9, YV411\n\n    CS_VPlaneFirst       = 1 << 3, // YV12, YV16, YV24, YV411, YUV9\n    CS_UPlaneFirst       = 1 << 4, // I420\n\n    CS_Sub_Height_Mask   = 7 << CS_Shift_Sub_Height,\n    CS_Sub_Height_1      = 3 << CS_Shift_Sub_Height, // YV16, YV24, YV411\n    CS_Sub_Height_2      = 0 << CS_Shift_Sub_Height, // YV12, I420\n    CS_Sub_Height_4      = 1 << CS_Shift_Sub_Height, // YUV9\n\n    CS_Sample_Bits_Mask  = 7 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_8     = 0 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_10    = 5 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_12    = 6 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_14    = 7 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_16    = 1 << CS_Shift_Sample_Bits,\n    CS_Sample_Bits_32    = 2 << CS_Shift_Sample_Bits,\n\n    CS_PLANAR_MASK       = CS_PLANAR | CS_INTERLEAVED | CS_YUV | CS_BGR | CS_YUVA\n                           | CS_Sample_Bits_Mask | CS_Sub_Width_Mask | CS_Sub_Height_Mask,\n    CS_PLANAR_FILTER     = ~(CS_VPlaneFirst | CS_UPlaneFirst),\n\n    CS_RGB_TYPE  = 1 << 0,\n    CS_RGBA_TYPE = 1 << 1,\n\n    // Specific colorformats\n    CS_UNKNOWN = 0,\n\n    CS_BGR24 = CS_RGB_TYPE  | CS_BGR | CS_INTERLEAVED,\n    CS_BGR32 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED,\n    CS_YUY2  = 1 << 2 | CS_YUV | CS_INTERLEAVED,\n    //  CS_YV12  = 1 << 3  Reserved\n    //  CS_I420  = 1 << 4  Reserved\n    CS_RAW32 = 1 << 5 | CS_INTERLEAVED,\n\n    //  YV12 must be 0xA0000008. v2.5 Baked API will see all new planar as YV12.\n    //  I420 must be 0xA0000010.\n\n    CS_GENERIC_YUV444  = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_1 | CS_Sub_Height_1,  // 4:4:4 planar\n    CS_GENERIC_YUV422  = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_1,  // 4:2:2 planar\n    CS_GENERIC_YUV420  = CS_PLANAR | CS_YUV | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2,  // 4:2:0 planar\n    CS_GENERIC_Y       = CS_PLANAR | CS_INTERLEAVED | CS_YUV,                                     // Y only (4:0:0)\n    CS_GENERIC_RGBP    = CS_PLANAR | CS_BGR | CS_RGB_TYPE,                                        // planar RGB. Though name is RGB but plane order G,B,R\n    CS_GENERIC_RGBAP   = CS_PLANAR | CS_BGR | CS_RGBA_TYPE,                                       // planar RGBA\n    CS_GENERIC_YUVA444 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_1 | CS_Sub_Height_1, // 4:4:4:A planar\n    CS_GENERIC_YUVA422 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_1, // 4:2:2:A planar\n    CS_GENERIC_YUVA420 = CS_PLANAR | CS_YUVA | CS_VPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2, // 4:2:0:A planar\n\n    CS_YV24  = CS_GENERIC_YUV444 | CS_Sample_Bits_8,  // YVU 4:4:4 planar\n    CS_YV16  = CS_GENERIC_YUV422 | CS_Sample_Bits_8,  // YVU 4:2:2 planar\n    CS_YV12  = CS_GENERIC_YUV420 | CS_Sample_Bits_8,  // YVU 4:2:0 planar\n    CS_I420  = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_UPlaneFirst | CS_Sub_Width_2 | CS_Sub_Height_2,  // YUV 4:2:0 planar\n    CS_IYUV  = CS_I420,\n    CS_YUV9  = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Width_4 | CS_Sub_Height_4,  // YUV 4:1:0 planar\n    CS_YV411 = CS_PLANAR | CS_YUV | CS_Sample_Bits_8 | CS_VPlaneFirst | CS_Sub_Width_4 | CS_Sub_Height_1,  // YUV 4:1:1 planar\n\n    CS_Y8    = CS_GENERIC_Y | CS_Sample_Bits_8,                                                            // Y   4:0:0 planar\n\n    //-------------------------\n    // AVS16: new planar constants go live! Experimental PF 160613\n    // 10-12-14 bit + planar RGB + BRG48/64 160725\n\n    CS_YUV444P10 = CS_GENERIC_YUV444 | CS_Sample_Bits_10, // YUV 4:4:4 10bit samples\n    CS_YUV422P10 = CS_GENERIC_YUV422 | CS_Sample_Bits_10, // YUV 4:2:2 10bit samples\n    CS_YUV420P10 = CS_GENERIC_YUV420 | CS_Sample_Bits_10, // YUV 4:2:0 10bit samples\n    CS_Y10 = CS_GENERIC_Y | CS_Sample_Bits_10,            // Y   4:0:0 10bit samples\n\n    CS_YUV444P12 = CS_GENERIC_YUV444 | CS_Sample_Bits_12, // YUV 4:4:4 12bit samples\n    CS_YUV422P12 = CS_GENERIC_YUV422 | CS_Sample_Bits_12, // YUV 4:2:2 12bit samples\n    CS_YUV420P12 = CS_GENERIC_YUV420 | CS_Sample_Bits_12, // YUV 4:2:0 12bit samples\n    CS_Y12 = CS_GENERIC_Y | CS_Sample_Bits_12,            // Y   4:0:0 12bit samples\n\n    CS_YUV444P14 = CS_GENERIC_YUV444 | CS_Sample_Bits_14, // YUV 4:4:4 14bit samples\n    CS_YUV422P14 = CS_GENERIC_YUV422 | CS_Sample_Bits_14, // YUV 4:2:2 14bit samples\n    CS_YUV420P14 = CS_GENERIC_YUV420 | CS_Sample_Bits_14, // YUV 4:2:0 14bit samples\n    CS_Y14 = CS_GENERIC_Y | CS_Sample_Bits_14,            // Y   4:0:0 14bit samples\n\n    CS_YUV444P16 = CS_GENERIC_YUV444 | CS_Sample_Bits_16, // YUV 4:4:4 16bit samples\n    CS_YUV422P16 = CS_GENERIC_YUV422 | CS_Sample_Bits_16, // YUV 4:2:2 16bit samples\n    CS_YUV420P16 = CS_GENERIC_YUV420 | CS_Sample_Bits_16, // YUV 4:2:0 16bit samples\n    CS_Y16 = CS_GENERIC_Y | CS_Sample_Bits_16,            // Y   4:0:0 16bit samples\n\n    // 32 bit samples (float)\n    CS_YUV444PS = CS_GENERIC_YUV444 | CS_Sample_Bits_32,  // YUV 4:4:4 32bit samples\n    CS_YUV422PS = CS_GENERIC_YUV422 | CS_Sample_Bits_32,  // YUV 4:2:2 32bit samples\n    CS_YUV420PS = CS_GENERIC_YUV420 | CS_Sample_Bits_32,  // YUV 4:2:0 32bit samples\n    CS_Y32 = CS_GENERIC_Y | CS_Sample_Bits_32,            // Y   4:0:0 32bit samples\n\n    // RGB packed\n    CS_BGR48 = CS_RGB_TYPE  | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 3x16 bit\n    CS_BGR64 = CS_RGBA_TYPE | CS_BGR | CS_INTERLEAVED | CS_Sample_Bits_16, // BGR 4x16 bit\n    // no packed 32 bit (float) support for these legacy types\n\n    // RGB planar\n    CS_RGBP   = CS_GENERIC_RGBP | CS_Sample_Bits_8,  // Planar RGB 8 bit samples\n    CS_RGBP8  = CS_GENERIC_RGBP | CS_Sample_Bits_8,  // Planar RGB 8 bit samples\n    CS_RGBP10 = CS_GENERIC_RGBP | CS_Sample_Bits_10, // Planar RGB 10bit samples\n    CS_RGBP12 = CS_GENERIC_RGBP | CS_Sample_Bits_12, // Planar RGB 12bit samples\n    CS_RGBP14 = CS_GENERIC_RGBP | CS_Sample_Bits_14, // Planar RGB 14bit samples\n    CS_RGBP16 = CS_GENERIC_RGBP | CS_Sample_Bits_16, // Planar RGB 16bit samples\n    CS_RGBPS  = CS_GENERIC_RGBP | CS_Sample_Bits_32, // Planar RGB 32bit samples\n\n    // RGBA planar\n    CS_RGBAP   = CS_GENERIC_RGBAP | CS_Sample_Bits_8,  // Planar RGBA 8 bit samples\n    CS_RGBAP8  = CS_GENERIC_RGBAP | CS_Sample_Bits_8,  // Planar RGBA 8 bit samples\n    CS_RGBAP10 = CS_GENERIC_RGBAP | CS_Sample_Bits_10, // Planar RGBA 10bit samples\n    CS_RGBAP12 = CS_GENERIC_RGBAP | CS_Sample_Bits_12, // Planar RGBA 12bit samples\n    CS_RGBAP14 = CS_GENERIC_RGBAP | CS_Sample_Bits_14, // Planar RGBA 14bit samples\n    CS_RGBAP16 = CS_GENERIC_RGBAP | CS_Sample_Bits_16, // Planar RGBA 16bit samples\n    CS_RGBAPS  = CS_GENERIC_RGBAP | CS_Sample_Bits_32, // Planar RGBA 32bit samples\n\n    // Planar YUVA\n    CS_YUVA444    = CS_GENERIC_YUVA444 | CS_Sample_Bits_8,  // YUVA 4:4:4 8bit samples\n    CS_YUVA422    = CS_GENERIC_YUVA422 | CS_Sample_Bits_8,  // YUVA 4:2:2 8bit samples\n    CS_YUVA420    = CS_GENERIC_YUVA420 | CS_Sample_Bits_8,  // YUVA 4:2:0 8bit samples\n\n    CS_YUVA444P10 = CS_GENERIC_YUVA444 | CS_Sample_Bits_10, // YUVA 4:4:4 10bit samples\n    CS_YUVA422P10 = CS_GENERIC_YUVA422 | CS_Sample_Bits_10, // YUVA 4:2:2 10bit samples\n    CS_YUVA420P10 = CS_GENERIC_YUVA420 | CS_Sample_Bits_10, // YUVA 4:2:0 10bit samples\n\n    CS_YUVA444P12 = CS_GENERIC_YUVA444 | CS_Sample_Bits_12, // YUVA 4:4:4 12bit samples\n    CS_YUVA422P12 = CS_GENERIC_YUVA422 | CS_Sample_Bits_12, // YUVA 4:2:2 12bit samples\n    CS_YUVA420P12 = CS_GENERIC_YUVA420 | CS_Sample_Bits_12, // YUVA 4:2:0 12bit samples\n\n    CS_YUVA444P14 = CS_GENERIC_YUVA444 | CS_Sample_Bits_14, // YUVA 4:4:4 14bit samples\n    CS_YUVA422P14 = CS_GENERIC_YUVA422 | CS_Sample_Bits_14, // YUVA 4:2:2 14bit samples\n    CS_YUVA420P14 = CS_GENERIC_YUVA420 | CS_Sample_Bits_14, // YUVA 4:2:0 14bit samples\n\n    CS_YUVA444P16 = CS_GENERIC_YUVA444 | CS_Sample_Bits_16, // YUVA 4:4:4 16bit samples\n    CS_YUVA422P16 = CS_GENERIC_YUVA422 | CS_Sample_Bits_16, // YUVA 4:2:2 16bit samples\n    CS_YUVA420P16 = CS_GENERIC_YUVA420 | CS_Sample_Bits_16, // YUVA 4:2:0 16bit samples\n\n    CS_YUVA444PS  = CS_GENERIC_YUVA444 | CS_Sample_Bits_32,  // YUVA 4:4:4 32bit samples\n    CS_YUVA422PS  = CS_GENERIC_YUVA422 | CS_Sample_Bits_32,  // YUVA 4:2:2 32bit samples\n    CS_YUVA420PS  = CS_GENERIC_YUVA420 | CS_Sample_Bits_32,  // YUVA 4:2:0 32bit samples\n  };\n\n  int pixel_type;                // changed to int as of 2.5\n\n  int audio_samples_per_second;   // 0 means no audio\n  int sample_type;                // as of 2.5\n  int64_t num_audio_samples;      // changed as of 2.5\n  int nchannels;                  // as of 2.5\n\n  // BFF, TFF, FIELDBASED. Also used for storing Channel Mask\n  int image_type;\n\n  enum AvsImageTypeFlags {\n    IT_BFF = 1 << 0,\n    IT_TFF = 1 << 1,\n    IT_FIELDBASED = 1 << 2,\n\n    // Audio channel mask support\n    IT_HAS_CHANNELMASK = 1 << 3,\n    // shifted by 4 bits compared to WAVEFORMATEXTENSIBLE dwChannelMask\n    // otherwise same as AvsChannelMask\n    IT_SPEAKER_FRONT_LEFT = 0x1 << 4,\n    IT_SPEAKER_FRONT_RIGHT = 0x2 << 4,\n    IT_SPEAKER_FRONT_CENTER = 0x4 << 4,\n    IT_SPEAKER_LOW_FREQUENCY = 0x8 << 4,\n    IT_SPEAKER_BACK_LEFT = 0x10 << 4,\n    IT_SPEAKER_BACK_RIGHT = 0x20 << 4,\n    IT_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40 << 4,\n    IT_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80 << 4,\n    IT_SPEAKER_BACK_CENTER = 0x100 << 4,\n    IT_SPEAKER_SIDE_LEFT = 0x200 << 4,\n    IT_SPEAKER_SIDE_RIGHT = 0x400 << 4,\n    IT_SPEAKER_TOP_CENTER = 0x800 << 4,\n    IT_SPEAKER_TOP_FRONT_LEFT = 0x1000 << 4,\n    IT_SPEAKER_TOP_FRONT_CENTER = 0x2000 << 4,\n    IT_SPEAKER_TOP_FRONT_RIGHT = 0x4000 << 4,\n    IT_SPEAKER_TOP_BACK_LEFT = 0x8000 << 4,\n    IT_SPEAKER_TOP_BACK_CENTER = 0x10000 << 4,\n    IT_SPEAKER_TOP_BACK_RIGHT = 0x20000 << 4,\n    // End of officially defined speaker bits\n    // The next one is special, since cannot shift SPEAKER_ALL 0x80000000 further.\n    // Set mask and get mask handles it.\n    IT_SPEAKER_ALL = 0x40000 << 4,\n    // Mask for the defined 18 bits + SPEAKER_ALL\n    IT_SPEAKER_BITS_MASK = (AvsChannelMask::MASK_SPEAKER_DEFINED << 4) | IT_SPEAKER_ALL,\n    IT_NEXT_AVAILABLE = 1 << 23\n  };\n\n  // Chroma placement bits 20 -> 23  ::FIXME:: Really want a Class to support this\n  enum AvsChromaPlacement {\n    CS_UNKNOWN_CHROMA_PLACEMENT = 0 << 20,\n    CS_MPEG1_CHROMA_PLACEMENT   = 1 << 20,\n    CS_MPEG2_CHROMA_PLACEMENT   = 2 << 20,\n    CS_YUY2_CHROMA_PLACEMENT    = 3 << 20,\n    CS_TOPLEFT_CHROMA_PLACEMENT = 4 << 20\n  };\n\n  // useful functions of the above\n  bool HasVideo() const AVS_BakedCode(return AVS_LinkCall(HasVideo)())\n  bool HasAudio() const AVS_BakedCode(return AVS_LinkCall(HasAudio)())\n  bool IsRGB() const AVS_BakedCode(return AVS_LinkCall(IsRGB)())\n  bool IsRGB24() const AVS_BakedCode(return AVS_LinkCall(IsRGB24)())\n  bool IsRGB32() const AVS_BakedCode(return AVS_LinkCall(IsRGB32)())\n  bool IsYUV() const AVS_BakedCode(return AVS_LinkCall(IsYUV)())\n  bool IsYUY2() const AVS_BakedCode(return AVS_LinkCall(IsYUY2)())\n\n  bool IsYV24()  const AVS_BakedCode(return AVS_LinkCall(IsYV24)())\n  bool IsYV16()  const AVS_BakedCode(return AVS_LinkCall(IsYV16)())\n  bool IsYV12()  const AVS_BakedCode(return AVS_LinkCall(IsYV12)())\n  bool IsYV411() const AVS_BakedCode(return AVS_LinkCall(IsYV411)())\n  //bool IsYUV9()  const;\n  bool IsY8()    const AVS_BakedCode(return AVS_LinkCall(IsY8)())\n\n  bool IsColorSpace(int c_space) const AVS_BakedCode(return AVS_LinkCall(IsColorSpace)(c_space))\n\n  bool Is(int property) const AVS_BakedCode(return AVS_LinkCall(Is)(property))\n  bool IsPlanar() const AVS_BakedCode(return AVS_LinkCall(IsPlanar)())\n  bool IsFieldBased() const AVS_BakedCode(return AVS_LinkCall(IsFieldBased)())\n  bool IsParityKnown() const AVS_BakedCode(return AVS_LinkCall(IsParityKnown)())\n  bool IsBFF() const AVS_BakedCode(return AVS_LinkCall(IsBFF)())\n  bool IsTFF() const AVS_BakedCode(return AVS_LinkCall(IsTFF)())\n\n  bool IsVPlaneFirst() const AVS_BakedCode(return AVS_LinkCall(IsVPlaneFirst)())  // Don't use this\n  // Will not work on planar images, but will return only luma planes\n  int BytesFromPixels(int pixels) const AVS_BakedCode(return AVS_LinkCall(BytesFromPixels)(pixels))\n  int RowSize(int plane = DEFAULT_PLANE) const AVS_BakedCode(return AVS_LinkCall(RowSize)(plane))\n  int BMPSize() const AVS_BakedCode(return AVS_LinkCall(BMPSize)())\n\n  int64_t AudioSamplesFromFrames(int frames) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromFrames)(frames))\n  int FramesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(FramesFromAudioSamples)(samples))\n  int64_t AudioSamplesFromBytes(int64_t bytes) const AVS_BakedCode(return AVS_LinkCall(AudioSamplesFromBytes)(bytes))\n  int64_t BytesFromAudioSamples(int64_t samples) const AVS_BakedCode(return AVS_LinkCall(BytesFromAudioSamples)(samples))\n  int AudioChannels() const AVS_BakedCode(return AVS_LinkCall(AudioChannels)())\n  int SampleType() const AVS_BakedCode(return AVS_LinkCall(SampleType)())\n  bool IsSampleType(int testtype) const AVS_BakedCode(return AVS_LinkCall(IsSampleType)(testtype))\n  int SamplesPerSecond() const AVS_BakedCode(return AVS_LinkCall(SamplesPerSecond)())\n  int BytesPerAudioSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerAudioSample)())\n  void SetFieldBased(bool isfieldbased) AVS_BakedCode(AVS_LinkCall_Void(SetFieldBased)(isfieldbased))\n  void Set(int property) AVS_BakedCode(AVS_LinkCall_Void(Set)(property))\n  void Clear(int property) AVS_BakedCode(AVS_LinkCall_Void(Clear)(property))\n  // Subsampling in bitshifts!\n  int GetPlaneWidthSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneWidthSubsampling)(plane))\n  int GetPlaneHeightSubsampling(int plane) const AVS_BakedCode(return AVS_LinkCall(GetPlaneHeightSubsampling)(plane))\n  int BitsPerPixel() const AVS_BakedCode(return AVS_LinkCall(BitsPerPixel)())\n\n  int BytesPerChannelSample() const AVS_BakedCode(return AVS_LinkCall(BytesPerChannelSample)())\n\n  // useful mutator\n  void SetFPS(unsigned numerator, unsigned denominator) AVS_BakedCode(AVS_LinkCall_Void(SetFPS)(numerator, denominator))\n\n  // Range protected multiply-divide of FPS\n  void MulDivFPS(unsigned multiplier, unsigned divisor) AVS_BakedCode(AVS_LinkCall_Void(MulDivFPS)(multiplier, divisor))\n\n  // Test for same colorspace\n  bool IsSameColorspace(const VideoInfo& vi) const AVS_BakedCode(return AVS_LinkCall(IsSameColorspace)(vi))\n\n  // AVS+ extensions\n  // 20161005:\n  //   Mapping of AVS+ extensions to classic 2.6 functions.\n  //   In order to use these extended AVS+ functions for plugins that should work\n  //   either with AVS+ or with Classic (8 bit) Avs 2.6 ans earlier AVS+ versions, there is an\n  //   automatic fallback mechanism.\n  //   From AVS+'s point of view these are not \"baked\" codes, the primary functions should exist.\n  //   Examples:\n  //   Is444() is mapped to IsYV24() for classic AVS2.6\n  //   ComponentSize() returns constant 1 (1 bytes per pixel component)\n  //   BitsPerComponent() returns constant 8 (Classic AVS2.6 is 8 bit only)\n\n  // Returns the number of color channels or planes in a frame\n  int NumComponents() const AVS_BakedCode(return AVS_LinkCallOptDefault(NumComponents, (((AVS_LinkCall(IsYUV)()) && !(AVS_LinkCall(IsY8)())) ? 3 : AVS_LinkCall(BytesFromPixels)(1)) ) )\n\n  // Returns the size in bytes of a single component of a pixel\n  int ComponentSize() const AVS_BakedCode(return AVS_LinkCallOptDefault(ComponentSize, 1))\n\n  // Returns the bit depth of a single component of a pixel\n  int BitsPerComponent() const AVS_BakedCode(return AVS_LinkCallOptDefault(BitsPerComponent, 8))\n\n  // like IsYV24, but bit-depth independent also for YUVA\n  bool Is444() const AVS_BakedCode(return AVS_LinkCallOpt(Is444, IsYV24) )\n\n  // like IsYV16, but bit-depth independent also for YUVA\n  bool Is422() const AVS_BakedCode(return AVS_LinkCallOpt(Is422, IsYV16) )\n\n  // like IsYV12, but bit-depth independent also for YUVA\n  bool Is420() const AVS_BakedCode( return AVS_LinkCallOpt(Is420, IsYV12) )\n\n  // like IsY8, but bit-depth independent\n  bool IsY()   const AVS_BakedCode( return AVS_LinkCallOpt(IsY, IsY8) )\n\n  // like IsRGB24 for 16 bit samples\n  bool IsRGB48() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB48, false) )\n\n  // like IsRGB32 for 16 bit samples\n  bool IsRGB64() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsRGB64, false) )\n\n  // YUVA?\n  bool IsYUVA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsYUVA, false) )\n\n  // Planar RGB?\n  bool IsPlanarRGB() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGB, false) )\n\n  // Planar RGBA?\n  bool IsPlanarRGBA() const AVS_BakedCode( return AVS_LinkCallOptDefault(IsPlanarRGBA, false) )\n\n  // v10.1 interface: audio channel masks\n  bool IsChannelMaskKnown() const AVS_BakedCode(return AVS_LinkCallOptDefault(IsChannelMaskKnown, false) )\n  void SetChannelMask(bool isChannelMaskKnown, unsigned int dwChannelMask) AVS_BakedCode(AVS_LinkCall_Void(SetChannelMask)(isChannelMaskKnown, dwChannelMask))\n  unsigned int GetChannelMask() const AVS_BakedCode(return AVS_LinkCallOptDefault(GetChannelMask, 0) )\n\n}; // end struct VideoInfo\n\n\n\n\n// VideoFrameBuffer holds information about a memory block which is used\n// for video data.  For efficiency, instances of this class are not deleted\n// when the refcount reaches zero; instead they're stored in a linked list\n// to be reused.  The instances are deleted when the corresponding AVS\n// file is closed.\n\nclass VideoFrameBuffer {\n  BYTE* data;\n  int data_size;\n  // sequence_number is incremented every time the buffer is changed, so\n  // that stale views can tell they're no longer valid.\n  volatile long sequence_number;\n\n  friend class VideoFrame;\n  friend class Cache;\n  friend class ScriptEnvironment;\n  volatile long refcount;\n\n  // AVS+CUDA extension, does not break plugins if appended here\n  Device* device;\n\nprotected:\n  VideoFrameBuffer(int size, int margin, Device* device);\n  VideoFrameBuffer();\n\npublic:\n  ~VideoFrameBuffer() AVS_BakedCode(AVS_LinkCall_Void(VideoFrameBuffer_DESTRUCTOR)())\n\n  const BYTE* GetReadPtr() const AVS_BakedCode( return AVS_LinkCall(VFBGetReadPtr)() )\n  BYTE* GetWritePtr() AVS_BakedCode( return AVS_LinkCall(VFBGetWritePtr)() )\n  int GetDataSize() const AVS_BakedCode( return AVS_LinkCall(GetDataSize)() )\n  int GetSequenceNumber() const AVS_BakedCode( return AVS_LinkCall(GetSequenceNumber)() )\n  int GetRefcount() const AVS_BakedCode( return AVS_LinkCall(GetRefcount)() )\n\n// Ensure VideoFrameBuffer cannot be publicly assigned\nprivate:\n  VideoFrameBuffer& operator=(const VideoFrameBuffer&);\n\n#ifdef BUILDING_AVSCORE\npublic:\n    void DESTRUCTOR();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n#endif\n}; // end class VideoFrameBuffer\n\n\n// smart pointer to VideoFrame\nclass PVideoFrame {\n\n  VideoFrame* p;\n\n  void Init(VideoFrame* x);\n  void Set(VideoFrame* x);\n\npublic:\n  PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR0)())\n    PVideoFrame(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR1)(x))\n    PVideoFrame(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_CONSTRUCTOR2)(x))\n    void operator=(VideoFrame* x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN0)(x))\n    void operator=(const PVideoFrame& x) AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_OPERATOR_ASSIGN1)(x))\n\n    VideoFrame* operator->() const { return p; }\n\n  // for conditional expressions\n  operator void*() const { return p; }\n  bool operator!() const { return !p; }\n\n  ~PVideoFrame() AVS_BakedCode(AVS_LinkCall_Void(PVideoFrame_DESTRUCTOR)())\n#ifdef BUILDING_AVSCORE\npublic:\n  void CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void CONSTRUCTOR1(const PVideoFrame& x);\n  void CONSTRUCTOR2(VideoFrame* x);\n  void OPERATOR_ASSIGN0(VideoFrame* x);\n  void OPERATOR_ASSIGN1(const PVideoFrame& x);\n  void DESTRUCTOR();\n#endif\n}; // end class PVideoFrame\n\n\n// VideoFrame holds a \"window\" into a VideoFrameBuffer.  Operator new\n// is overloaded to recycle class instances.\n\nclass VideoFrame {\n  volatile long refcount;\n  VideoFrameBuffer* vfb;\n\n  // Due to technical reasons these members are not const, but should be treated as such.\n  // That means do not modify them once the class has been constructed.\n  int offset;\n  int pitch, row_size, height;\n  int offsetU, offsetV;  // U&V offsets are from top of picture.\n  int pitchUV, row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane.\n                            // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable)\n                            // the decision on existance of UV is checked by zero pitch\n  // AVS+ extension, does not break plugins if appended here\n  int offsetA;\n  int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none\n\n  AVSMap *properties;\n\n  // this one is changable by AmendPixelType in rare cases\n  int pixel_type; // V10 - Copy from VideoInfo\n\n  friend class PVideoFrame;\n  void AddRef();\n  void Release();\n\n  friend class ScriptEnvironment;\n  friend class Cache;\n\n  VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _pixel_type);\n  VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _pixel_type);\n  // for Alpha\n  VideoFrame(VideoFrameBuffer* _vfb, AVSMap* avsmap, int _offset, int _pitch, int _row_size, int _height, int _offsetU, int _offsetV, int _pitchUV, int _row_sizeUV, int _heightUV, int _offsetA, int _pixel_type);\n  void* operator new(size_t size);\n// TESTME: OFFSET U/V may be switched to what could be expected from AVI standard!\npublic:\n  int GetPitch(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetPitch)(plane) )\n  int GetRowSize(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetRowSize)(plane) )\n  int GetHeight(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetHeight)(plane) )\n\n  // generally you shouldn't use these three\n  VideoFrameBuffer* GetFrameBuffer() const AVS_BakedCode( return AVS_LinkCall(GetFrameBuffer)() )\n  int GetOffset(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(GetOffset)(plane) )\n\n  // in plugins use env->SubFrame() -- because implementation code is only available inside avisynth.dll. Doh!\n  VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height) const;\n  VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV) const;\n  // for Alpha\n  VideoFrame* Subframe(int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int pitchUV, int rel_offsetA) const;\n\n  const BYTE* GetReadPtr(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(VFGetReadPtr)(plane) )\n  bool IsWritable() const AVS_BakedCode( return AVS_LinkCall(IsWritable)() )\n  BYTE* GetWritePtr(int plane = DEFAULT_PLANE) const AVS_BakedCode( return AVS_LinkCall(VFGetWritePtr)(plane) )\n\n  AVSMap& getProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getProperties, (AVSMap&)*(AVSMap*)0))\n  const AVSMap& getConstProperties() AVS_BakedCode(return AVS_LinkCallOptDefault(getConstProperties, (const AVSMap&)*(const AVSMap*)0))\n  void setProperties(const AVSMap & _properties) AVS_BakedCode(AVS_LinkCall_Void(setProperties)(_properties))\n\n  PDevice GetDevice() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetDevice)())\n\n  // 0: OK, 1: NG, -1: disabled or non CPU frame\n  int CheckMemory() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_CheckMemory)())\n\n  bool IsPropertyWritable() const AVS_BakedCode(return AVS_LinkCall(IsPropertyWritable)())\n\n  ~VideoFrame() AVS_BakedCode( AVS_LinkCall_Void(VideoFrame_DESTRUCTOR)() )\n\n  int GetPixelType() const AVS_BakedCode(return AVS_LinkCall(VideoFrame_GetPixelType)())\n  // Changes the color format metadata on this frame. Using it on a frame that isn't writable leads\n  // to an inconsistent state, because other filters depend on it. So, use MakeWritable() before.\n  // Only for rare cases where a plugin makes frame bytes pose as another color format.\n  void AmendPixelType(int new_pixel_type) AVS_BakedCode(return AVS_LinkCall_Void(VideoFrame_AmendPixelType)(new_pixel_type))\n\n#ifdef BUILDING_AVSCORE\npublic:\n  void DESTRUCTOR();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n#endif\n\n// Ensure VideoFrame cannot be publicly assigned\nprivate:\n    VideoFrame& operator=(const VideoFrame&);\n\n}; // end class VideoFrame\n\nenum CachePolicyHint {\n  // Values 0 to 5 are reserved for old 2.5 plugins\n  // do not use them in new plugins\n\n  // New 2.6 explicitly defined cache hints.\n  CACHE_NOTHING = 10, // Do not cache video.\n  CACHE_WINDOW = 11, // Hard protect upto X frames within a range of X from the current frame N.\n  CACHE_GENERIC = 12, // LRU cache upto X frames.\n  CACHE_FORCE_GENERIC = 13, // LRU cache upto X frames, override any previous CACHE_WINDOW.\n\n  CACHE_GET_POLICY = 30, // Get the current policy.\n  CACHE_GET_WINDOW = 31, // Get the current window h_span.\n  CACHE_GET_RANGE = 32, // Get the current generic frame range.\n\n  // Set Audio cache mode and answers to CACHE_GETCHILD_AUDIO_MODE\n  CACHE_AUDIO = 50, // Explicitly cache audio, X byte cache.\n  CACHE_AUDIO_NOTHING = 51, // Explicitly do not cache audio.\n  CACHE_AUDIO_NONE = 52, // Audio cache off (auto mode), X byte initial cache.\n  CACHE_AUDIO_AUTO_START_OFF = 52, // synonym\n  CACHE_AUDIO_AUTO = 53, // Audio cache on (auto mode), X byte initial cache.\n  CACHE_AUDIO_AUTO_START_ON = 53, // synonym\n\n  // These just returns actual value if clip is cached\n  CACHE_GET_AUDIO_POLICY = 70, // Get the current audio policy.\n  CACHE_GET_AUDIO_SIZE = 71, // Get the current audio cache size.\n\n  CACHE_PREFETCH_FRAME = 100, // n/a Queue request to prefetch frame N.\n  CACHE_PREFETCH_GO = 101, // n/a Action video prefetches.\n\n  CACHE_PREFETCH_AUDIO_BEGIN = 120, // n/a Begin queue request transaction to prefetch audio (take critical section).\n  CACHE_PREFETCH_AUDIO_STARTLO = 121, // n/a Set low 32 bits of start.\n  CACHE_PREFETCH_AUDIO_STARTHI = 122, // n/a Set high 32 bits of start.\n  CACHE_PREFETCH_AUDIO_COUNT = 123, // n/a Set low 32 bits of length.\n  CACHE_PREFETCH_AUDIO_COMMIT = 124, // n/a Enqueue request transaction to prefetch audio (release critical section).\n  CACHE_PREFETCH_AUDIO_GO = 125, // n/a Action audio prefetches.\n\n  CACHE_GETCHILD_CACHE_MODE = 200, // n/a Cache ask Child for desired video cache mode.\n  CACHE_GETCHILD_CACHE_SIZE = 201, // n/a Cache ask Child for desired video cache size.\n\n  // Filters are queried about their desired audio cache mode.\n  // Child can answer them with CACHE_AUDIO_xxx\n  CACHE_GETCHILD_AUDIO_MODE = 202, // Cache ask Child for desired audio cache mode.\n  CACHE_GETCHILD_AUDIO_SIZE = 203, // Cache ask Child for desired audio cache size.\n\n  CACHE_GETCHILD_COST = 220, // n/a Cache ask Child for estimated processing cost.\n    CACHE_COST_ZERO = 221, // n/a Child response of zero cost (ptr arithmetic only).\n    CACHE_COST_UNIT = 222, // n/a Child response of unit cost (less than or equal 1 full frame blit).\n    CACHE_COST_LOW = 223, // n/a Child response of light cost. (Fast)\n    CACHE_COST_MED = 224, // n/a Child response of medium cost. (Real time)\n    CACHE_COST_HI = 225, // n/a Child response of heavy cost. (Slow)\n\n  CACHE_GETCHILD_THREAD_MODE = 240, // n/a Cache ask Child for thread safetyness.\n    CACHE_THREAD_UNSAFE = 241, // n/a Only 1 thread allowed for all instances. 2.5 filters default!\n    CACHE_THREAD_CLASS = 242, // n/a Only 1 thread allowed for each instance. 2.6 filters default!\n    CACHE_THREAD_SAFE = 243, // n/a Allow all threads in any instance.\n    CACHE_THREAD_OWN = 244, // n/a Safe but limit to 1 thread, internally threaded.\n\n  CACHE_GETCHILD_ACCESS_COST = 260, // n/a Cache ask Child for preferred access pattern.\n    CACHE_ACCESS_RAND = 261, // n/a Filter is access order agnostic.\n    CACHE_ACCESS_SEQ0 = 262, // n/a Filter prefers sequential access (low cost)\n    CACHE_ACCESS_SEQ1 = 263, // n/a Filter needs sequential access (high cost)\n\n  CACHE_AVSPLUS_CONSTANTS = 500,    // Smaller values are reserved for classic Avisynth\n\n  CACHE_DONT_CACHE_ME,              // Filters that don't need caching (eg. trim, cache etc.) should return 1 to this request\n  CACHE_SET_MIN_CAPACITY,\n  CACHE_SET_MAX_CAPACITY,\n  CACHE_GET_MIN_CAPACITY,\n  CACHE_GET_MAX_CAPACITY,\n  CACHE_GET_SIZE,\n  CACHE_GET_REQUESTED_CAP,\n  CACHE_GET_CAPACITY,\n  CACHE_GET_MTMODE,                 // Filters specify their desired MT mode, see enum MtMode\n\n  // By returning IS_CACHE_ANS to IS_CACHE_REQ, we tell the caller we are a cache\n  CACHE_IS_CACHE_REQ,\n  CACHE_IS_CACHE_ANS,\n  // By returning IS_MTGUARD_ANS to IS_MTGUARD_REQ, we tell the caller we are an mt guard\n  CACHE_IS_MTGUARD_REQ,\n  CACHE_IS_MTGUARD_ANS,\n\n  CACHE_AVSPLUS_CUDA_CONSTANTS = 600,\n\n  CACHE_GET_DEV_TYPE,          // Device types a filter can return\n  CACHE_GET_CHILD_DEV_TYPE,    // Device types a filter can receive\n\n  CACHE_USER_CONSTANTS = 1000       // Smaller values are reserved for the core\n};\n\n// Base class for all filters.\nclass IClip {\n  friend class PClip;\n  friend class AVSValue;\n  volatile long refcnt;\n  void AddRef();\n#if BUILDING_AVSCORE\npublic:\n#endif\n  void Release();\npublic:\n  IClip() : refcnt(0) {}\n  virtual int __stdcall GetVersion() { return AVISYNTH_INTERFACE_VERSION; }\n  virtual PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) = 0;\n  virtual bool __stdcall GetParity(int n) = 0;  // return field parity if field_based, else parity of first field in frame\n  virtual void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) = 0;  // start and count are in samples\n  /* Need to check GetVersion first, pre v5 will return random crap from EAX reg. */\n  virtual int __stdcall SetCacheHints(int cachehints,int frame_range) = 0 ;  // We do not pass cache requests upwards, only to the next filter.\n  virtual const VideoInfo& __stdcall GetVideoInfo() = 0;\n  virtual ~IClip() {}\n}; // end class IClip\n\n\n// smart pointer to IClip\nclass PClip {\n\n  IClip* p;\n\n  IClip* GetPointerWithAddRef() const;\n  friend class AVSValue;\n  friend class VideoFrame;\n\n  void Init(IClip* x);\n  void Set(IClip* x);\n\npublic:\n  PClip() AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR0)() )\n  PClip(const PClip& x) AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR1)(x) )\n  PClip(IClip* x) AVS_BakedCode( AVS_LinkCall_Void(PClip_CONSTRUCTOR2)(x) )\n  void operator=(IClip* x) AVS_BakedCode( AVS_LinkCall_Void(PClip_OPERATOR_ASSIGN0)(x) )\n  void operator=(const PClip& x) AVS_BakedCode( AVS_LinkCall_Void(PClip_OPERATOR_ASSIGN1)(x) )\n\n  IClip* operator->() const { return p; }\n\n  // useful in conditional expressions\n  operator void*() const { return p; }\n  bool operator!() const { return !p; }\n\n  ~PClip() AVS_BakedCode( AVS_LinkCall_Void(PClip_DESTRUCTOR)() )\n#ifdef BUILDING_AVSCORE\npublic:\n  void CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void CONSTRUCTOR1(const PClip& x);\n  void CONSTRUCTOR2(IClip* x);\n  void OPERATOR_ASSIGN0(IClip* x);\n  void OPERATOR_ASSIGN1(const PClip& x);\n  void DESTRUCTOR();\n#endif\n}; // end class PClip\n\n// enums for frame property functions\nenum AVSPropTypes {\n  PROPTYPE_UNSET = 'u', // ptUnset\n  PROPTYPE_INT = 'i', // peType\n  PROPTYPE_FLOAT = 'f', // ptFloat\n  PROPTYPE_DATA = 's', // ptData\n  PROPTYPE_CLIP = 'c', // ptClip\n  PROPTYPE_FRAME = 'v' // ptFrame\n  //  ptFunction = 'm'\n};\n\nenum AVSGetPropErrors {\n  GETPROPERROR_UNSET = 1, // peUnset\n  GETPROPERROR_TYPE = 2, // peType\n  GETPROPERROR_INDEX = 4 // peIndex\n};\n\nenum AVSPropAppendMode {\n  PROPAPPENDMODE_REPLACE = 0, // paReplace\n  PROPAPPENDMODE_APPEND = 1, // paAppend\n  PROPAPPENDMODE_TOUCH = 2 // paTouch\n};\n\n\nclass AVSValue {\npublic:\n\n  AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR0)() )\n  AVSValue(IClip* c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR1)(c) )\n  AVSValue(const PClip& c) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR2)(c) )\n  AVSValue(bool b) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR3)(b) )\n  AVSValue(int i) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR4)(i) )\n//  AVSValue(int64_t l);\n  AVSValue(float f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR5)(f) )\n  AVSValue(double f) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR6)(f) )\n  AVSValue(const char* s) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR7)(s) )\n  AVSValue(const AVSValue* a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(a, size) )\n  AVSValue(const AVSValue& a, int size) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR8)(&a, size) )\n  AVSValue(const AVSValue& v) AVS_BakedCode( AVS_LinkCall_Void(AVSValue_CONSTRUCTOR9)(v) )\n  AVSValue(const PFunction& n) AVS_BakedCode(AVS_LinkCall_Void(AVSValue_CONSTRUCTOR11)(n))\n\n  ~AVSValue() AVS_BakedCode( AVS_LinkCall_Void(AVSValue_DESTRUCTOR)() )\n  AVSValue& operator=(const AVSValue& v) AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_ASSIGN)(v) )\n\n  // Note that we transparently allow 'int' to be treated as 'float'.\n  // There are no int<->bool conversions, though.\n\n  bool Defined() const AVS_BakedCode( return AVS_LinkCall(Defined)() )\n  bool IsClip() const AVS_BakedCode( return AVS_LinkCall(IsClip)() )\n  bool IsBool() const AVS_BakedCode( return AVS_LinkCall(IsBool)() )\n  bool IsInt() const AVS_BakedCode( return AVS_LinkCall(IsInt)() )\n//  bool IsLong() const;\n  bool IsFloat() const AVS_BakedCode( return AVS_LinkCall(IsFloat)() )\n  bool IsString() const AVS_BakedCode( return AVS_LinkCall(IsString)() )\n  bool IsArray() const AVS_BakedCode( return AVS_LinkCall(IsArray)() )\n  bool IsFunction() const AVS_BakedCode( return AVS_LinkCall(IsFunction)() )\n\n  PClip AsClip() const AVS_BakedCode( return AVS_LinkCall(AsClip)() )\n  bool AsBool() const AVS_BakedCode( return AVS_LinkCall(AsBool1)() )\n  int AsInt() const AVS_BakedCode( return AVS_LinkCall(AsInt1)() )\n//  int AsLong() const;\n  const char* AsString() const AVS_BakedCode( return AVS_LinkCall(AsString1)() )\n  double AsFloat() const AVS_BakedCode( return AVS_LinkCall(AsFloat1)() )\n  float AsFloatf() const AVS_BakedCode( return float( AVS_LinkCall(AsFloat1)() ) )\n\n  bool AsBool(bool def) const AVS_BakedCode( return AVS_LinkCall(AsBool2)(def) )\n  int AsInt(int def) const AVS_BakedCode( return AVS_LinkCall(AsInt2)(def) )\n  double AsDblDef(double def) const AVS_BakedCode( return AVS_LinkCall(AsDblDef)(def) ) // Value is still a float\n  double AsFloat(float def) const AVS_BakedCode( return AVS_LinkCall(AsFloat2)(def) )\n  float AsFloatf(float def) const AVS_BakedCode( return float( AVS_LinkCall(AsFloat2)(def) ) )\n  const char* AsString(const char* def) const AVS_BakedCode( return AVS_LinkCall(AsString2)(def) )\n  PFunction AsFunction() const; // internal use only\n\n  int ArraySize() const AVS_BakedCode( return AVS_LinkCall(ArraySize)() )\n\n  const AVSValue& operator[](int index) const AVS_BakedCode( return AVS_LinkCallV(AVSValue_OPERATOR_INDEX)(index) )\n\nprivate:\n\n  short type;  // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, fu'n'ction, or RFU: 'l'ong ('d'ouble)\n  short array_size;\n  union {\n    IClip* clip;\n    bool boolean;\n    int integer;\n    float floating_pt;\n    const char* string;\n    const AVSValue* array;\n    IFunction* function;\n    #ifdef X86_64\n    // if ever, only x64 will support. It breaks struct size on 32 bit\n    int64_t longlong; // 8 bytes\n    double double_pt; // 8 bytes\n    #endif\n  };\n\n  void Assign(const AVSValue* src, bool init);\n\npublic:\n  AvsValueType GetType() const AVS_BakedCode( return AVS_LinkCallOptDefault(AVSValue_GetType, VALUE_TYPE_UNDEFINED) )\n\n#ifdef BUILDING_AVSCORE\npublic:\n  void            CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void            CONSTRUCTOR1(IClip* c);\n  void            CONSTRUCTOR2(const PClip& c);\n  void            CONSTRUCTOR3(bool b);\n  void            CONSTRUCTOR4(int i);\n  void            CONSTRUCTOR5(float f);\n  void            CONSTRUCTOR6(double f);\n  void            CONSTRUCTOR7(const char* s);\n  void            CONSTRUCTOR8(const AVSValue* a, int size);\n  void            CONSTRUCTOR9(const AVSValue& v);\n  void            CONSTRUCTOR11(const PFunction& n);\n  void            DESTRUCTOR();\n  AVSValue&       OPERATOR_ASSIGN(const AVSValue& v);\n  const AVSValue& OPERATOR_INDEX(int index) const;\n\n  bool            AsBool1() const;\n  int             AsInt1() const;\n  const char*     AsString1() const;\n  double          AsFloat1() const;\n\n  bool            AsBool2(bool def) const;\n  int             AsInt2(int def) const;\n  double          AsFloat2(float def) const;\n  const char*     AsString2(const char* def) const;\n\n  void            MarkArrayAsC(); // for C interface, no deep-copy and deep-free\n  void            CONSTRUCTOR10(const AVSValue& v, bool c_arrays);\n  AVSValue(const AVSValue& v, bool c_arrays);\n  void            Assign2(const AVSValue* src, bool init, bool c_arrays);\n\n#endif\n}; // end class AVSValue\n\n#define AVS_UNUSED(x) (void)(x)\n\n// instantiable null filter\nclass GenericVideoFilter : public IClip {\nprotected:\n  PClip child;\n  VideoInfo vi;\npublic:\n  GenericVideoFilter(PClip _child) : child(_child) { vi = child->GetVideoInfo(); }\n  PVideoFrame __stdcall GetFrame(int n, IScriptEnvironment* env) { return child->GetFrame(n, env); }\n  void __stdcall GetAudio(void* buf, int64_t start, int64_t count, IScriptEnvironment* env) { child->GetAudio(buf, start, count, env); }\n  const VideoInfo& __stdcall GetVideoInfo() { return vi; }\n  bool __stdcall GetParity(int n) { return child->GetParity(n); }\n  int __stdcall SetCacheHints(int cachehints, int frame_range) { AVS_UNUSED(cachehints); AVS_UNUSED(frame_range); return 0; }  // We do not pass cache requests upwards, only to the next filter.\n};\n\n\nclass PFunction\n{\npublic:\n  PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR0)())\n  PFunction(IFunction* p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR1)(p))\n  PFunction(const PFunction& p) AVS_BakedCode(AVS_LinkCall_Void(PFunction_CONSTRUCTOR2)(p))\n  PFunction& operator=(IFunction* p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN0)(p))\n  PFunction& operator=(const PFunction& p) AVS_BakedCode(return AVS_LinkCallV(PFunction_OPERATOR_ASSIGN1)(p))\n  ~PFunction() AVS_BakedCode(AVS_LinkCall_Void(PFunction_DESTRUCTOR)())\n\n  int operator!() const { return !e; }\n  operator void*() const { return e; }\n  IFunction* operator->() const { return e; }\n\nprivate:\n  IFunction * e;\n\n  friend class AVSValue;\n  IFunction * GetPointerWithAddRef() const;\n  void Init(IFunction* p);\n  void Set(IFunction* p);\n\n#ifdef BUILDING_AVSCORE\npublic:\n  void CONSTRUCTOR0();  /* Damn compiler won't allow taking the address of reserved constructs, make a dummy interlude */\n  void CONSTRUCTOR1(IFunction* p);\n  void CONSTRUCTOR2(const PFunction& p);\n  PFunction& OPERATOR_ASSIGN0(IFunction* p);\n  PFunction& OPERATOR_ASSIGN1(const PFunction& p);\n  void DESTRUCTOR();\n#endif\n};\n\n\n#undef CALL_MEMBER_FN\n#undef AVS_LinkCallOptDefault\n#undef AVS_LinkCallOpt\n#undef AVS_LinkCallV\n#undef AVS_LinkCall\n#undef AVS_BakedCode\n\n\n#include \"avs/cpuid.h\"\n\n// IScriptEnvironment GetEnvProperty\nenum AvsEnvProperty {\n  AEP_PHYSICAL_CPUS = 1,\n  AEP_LOGICAL_CPUS = 2,\n  AEP_THREADPOOL_THREADS = 3,\n  AEP_FILTERCHAIN_THREADS = 4,\n  AEP_THREAD_ID = 5,\n  AEP_VERSION = 6,\n  AEP_HOST_SYSTEM_ENDIANNESS = 7,\n  AEP_INTERFACE_VERSION = 8,\n  AEP_INTERFACE_BUGFIX = 9,\n\n  // Neo additionals\n  AEP_NUM_DEVICES = 901,\n  AEP_FRAME_ALIGN = 902,\n  AEP_PLANE_ALIGN = 903,\n\n  AEP_SUPPRESS_THREAD = 921,\n  AEP_GETFRAME_RECURSIVE = 922,\n};\n\n// IScriptEnvironment::Allocate()\nenum AvsAllocType {\n  AVS_NORMAL_ALLOC = 1,\n  AVS_POOLED_ALLOC = 2\n};\n\n\n// Important note (Windows, MSVC): \n// When extending IScriptEnvironment, do not declare existing names again\n// with different parameters. Methods with the same name will be grouped \n// together in the vtable. This results in shifting all vtable method pointers\n// after such grouping and breaks all plugins who expect the old order.\n// E.g. ApplyMessage will be called instead of GetAVSLinkage.\n// As long as the declaration is compatible with COM interop, the order of \n// declaration is sequential. But if not, overloads in the same class are grouped\n// together in the vtable in the reverse order of declaration.\nclass IScriptEnvironment {\npublic:\n  virtual ~IScriptEnvironment() {}\n\n  virtual /*static*/ int __stdcall GetCPUFlags() = 0;\n\n  virtual char* __stdcall SaveString(const char* s, int length = -1) = 0;\n  virtual char* Sprintf(const char* fmt, ...) = 0;\n  // note: val is really a va_list; I hope everyone typedefs va_list to a pointer\n  // 20200305: (void *) changed back to va_list\n  virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0;\n\n#ifdef AVS_WINDOWS\n  __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0;\n#else\n  virtual void ThrowError(const char* fmt, ...) = 0;\n#endif\n\n  class NotFound /*exception*/ {};  // thrown by Invoke and GetVar\n\n  typedef AVSValue (__cdecl *ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env);\n\n  virtual void __stdcall AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0;\n  virtual bool __stdcall FunctionExists(const char* name) = 0;\n  virtual AVSValue __stdcall Invoke(const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  virtual AVSValue __stdcall GetVar(const char* name) = 0;\n  virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0;\n  virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0;\n\n  virtual void __stdcall PushContext(int level = 0) = 0;\n  virtual void __stdcall PopContext() = 0;\n\n  // note v8: use NewVideoFrameP is possible\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align = FRAME_ALIGN) = 0;\n\n  virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0;\n\n  virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0;\n\n  typedef void (__cdecl *ShutdownFunc)(void* user_data, IScriptEnvironment* env);\n  virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0;\n\n  virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0;\n\n  virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0;\n\n  virtual int __stdcall SetMemoryMax(int mem) = 0;\n\n  virtual int __stdcall SetWorkingDir(const char * newdir) = 0;\n\n  virtual void* __stdcall ManageCache(int key, void* data) = 0;\n\n  enum PlanarChromaAlignmentMode {\n    PlanarChromaAlignmentOff,\n    PlanarChromaAlignmentOn,\n    PlanarChromaAlignmentTest\n  };\n\n  virtual bool __stdcall PlanarChromaAlignment(PlanarChromaAlignmentMode key) = 0;\n\n  virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n                                               int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0;\n\n  // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta\n  virtual void __stdcall DeleteScriptEnvironment() = 0;\n\n  virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,\n                                     int textcolor, int halocolor, int bgcolor) = 0;\n\n  virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0;\n\n  // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6\n  // noThrow version of GetVar\n  virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0;\n\n  // **** AVISYNTH_INTERFACE_VERSION 8 **** AviSynth+ 3.6.0-\n  virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n    int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0;\n\n  virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0;\n  virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0;\n  virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0;\n\n  virtual int __stdcall propNumKeys(const AVSMap* map) = 0;\n\n  virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0;\n  virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0;\n  virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0;\n\n  virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0;\n\n  virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0;\n\n  virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0;\n  virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0;\n  virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0;\n  virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0;\n  virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0;\n\n  virtual const int64_t* __stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0;\n  virtual const double* __stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0;\n  virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0;\n  virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0;\n\n  virtual AVSMap* __stdcall createMap() = 0;\n  virtual void __stdcall freeMap(AVSMap* map) = 0;\n  virtual void __stdcall clearMap(AVSMap* map) = 0;\n\n  // NewVideoFrame with frame property source.\n  virtual PVideoFrame __stdcall NewVideoFrameP(const VideoInfo& vi, const PVideoFrame* prop_src, int align = FRAME_ALIGN) = 0;\n\n  // Generic query to ask for various system properties\n  virtual size_t  __stdcall GetEnvProperty(AvsEnvProperty prop) = 0;\n\n  // Support functions\n  virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0;\n  virtual void __stdcall Free(void* ptr) = 0;\n\n  // these GetVar versions (renamed differently) were moved from IScriptEnvironment2\n\n  // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'.\n  virtual bool  __stdcall GetVarTry(const char* name, AVSValue* val) const = 0; // ex virtual bool  __stdcall GetVar(const char* name, AVSValue* val) const = 0;\n  // Return the value of the requested variable.\n  // If the variable was not found or had the wrong type,\n  // return the supplied default value.\n  virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0;\n  virtual int  __stdcall GetVarInt(const char* name, int def) const = 0;\n  virtual double  __stdcall GetVarDouble(const char* name, double def) const = 0;\n  virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0;\n  // brand new in v8 - though no real int64 support yet\n  virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0;\n\n  // 'Invoke' functions moved here from internal ScriptEnvironments are renamed in order to keep vtable order\n  // Invoke functions with 'Try' will return false instead of throwing NotFound().\n  // ex-IScriptEnvironment2\n  virtual bool __stdcall InvokeTry(AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0;\n  // Since V8\n  virtual AVSValue __stdcall Invoke2(const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  // Ex-INeo\n  virtual bool __stdcall Invoke2Try(AVSValue* result, const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual AVSValue __stdcall Invoke3(const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual bool __stdcall Invoke3Try(AVSValue* result, const AVSValue& implicit_last, const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  // V9\n  virtual bool __stdcall MakePropertyWritable(PVideoFrame* pvf) = 0;\n\n}; // end class IScriptEnvironment. Order is important. Avoid overloads with the same name.\n\n// used internally\nclass IScriptEnvironment_Avs25 {\npublic:\n  virtual ~IScriptEnvironment_Avs25() {}\n\n  virtual /*static*/ int __stdcall GetCPUFlags() = 0;\n\n  virtual char* __stdcall SaveString(const char* s, int length = -1) = 0;\n  virtual char* Sprintf(const char* fmt, ...) = 0;\n  virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0;\n\n#ifdef AVS_WINDOWS\n  __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0;\n#else\n  virtual void ThrowError(const char* fmt, ...) = 0;\n#endif\n\n  class NotFound /*exception*/ {};  // thrown by Invoke and GetVar\n\n  typedef AVSValue(__cdecl* ApplyFunc)(AVSValue args, void* user_data, IScriptEnvironment* env);\n\n  virtual void __stdcall AddFunction25(const char* name, const char* params, ApplyFunc apply, void* user_data) = 0;\n  virtual bool __stdcall FunctionExists(const char* name) = 0;\n  virtual AVSValue __stdcall Invoke25(const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  virtual AVSValue __stdcall GetVar(const char* name) = 0;\n  virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0;\n  virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0;\n\n  virtual void __stdcall PushContext(int level = 0) = 0;\n  virtual void __stdcall PopContext() = 0;\n\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, int align = FRAME_ALIGN) = 0;\n\n  virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0;\n\n  virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0;\n\n  typedef void(__cdecl* ShutdownFunc)(void* user_data, IScriptEnvironment* env);\n  virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0;\n\n  virtual void __stdcall CheckVersion(int version = AVISYNTH_CLASSIC_INTERFACE_VERSION_25) = 0;\n\n  virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0;\n\n  virtual int __stdcall SetMemoryMax(int mem) = 0;\n\n  virtual int __stdcall SetWorkingDir(const char* newdir) = 0;\n\n  // specially returns 1 for key MC_QueryAvs25 to check if called from AVS2.5 interface\n  virtual void* __stdcall ManageCache25(int key, void* data) = 0;\n\n  enum PlanarChromaAlignmentMode {\n    PlanarChromaAlignmentOff,\n    PlanarChromaAlignmentOn,\n    PlanarChromaAlignmentTest\n  };\n\n  virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0;\n\n  virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n    int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0;\n\n  // Despite the name, we provide entries up to V6 in case someone requests\n  // a V3 interface and still wants to use V5-V6 functions\n\n  // **** AVISYNTH_INTERFACE_VERSION 5 **** defined since classic Avisynth 2.6 beta\n  virtual void __stdcall DeleteScriptEnvironment() = 0;\n\n  virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,\n    int textcolor, int halocolor, int bgcolor) = 0;\n\n  virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0;\n\n  // **** AVISYNTH_INTERFACE_VERSION 6 **** defined since classic Avisynth 2.6\n  // noThrow version of GetVar\n  virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0;\n\n}; // end class IScriptEnvironment_Avs25. Order is important.\n\n\nenum MtMode {\n  MT_INVALID = 0,\n  MT_NICE_FILTER = 1,\n  MT_MULTI_INSTANCE = 2,\n  MT_SERIALIZED = 3,\n  MT_SPECIAL_MT = 4,\n  MT_MODE_COUNT = 5\n};\n\nclass IJobCompletion\n{\npublic:\n\n  virtual ~IJobCompletion() {}\n  virtual void __stdcall Wait() = 0;\n  virtual AVSValue __stdcall Get(size_t i) = 0;\n  virtual size_t __stdcall Size() const = 0;\n  virtual size_t __stdcall Capacity() const = 0;\n  virtual void __stdcall Reset() = 0;\n  virtual void __stdcall Destroy() = 0;\n};\n\nclass IScriptEnvironment2;\nclass Prefetcher;\ntypedef AVSValue (*ThreadWorkerFuncPtr)(IScriptEnvironment2* env, void* data);\n\n\n/* -----------------------------------------------------------------------------\n   Note to plugin authors: The interface in IScriptEnvironment2 is\n      preliminary / under construction / only for testing / non-final etc.!\n      As long as you see this note here, IScriptEnvironment2 might still change,\n      in which case your plugin WILL break. This also means that you are welcome\n      to test it and give your feedback about any ideas, improvements, or issues\n      you might have.\n   ----------------------------------------------------------------------------- */\nclass IScriptEnvironment2 : public IScriptEnvironment{\npublic:\n  virtual ~IScriptEnvironment2() {}\n\n  // V8: SubframePlanarA, GetEnvProperty, GetVar versions, Allocate, Free, no-throw Invoke moved to IScriptEnvironment\n\n  // Plugin functions\n  virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0;\n  virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0;\n  virtual void __stdcall ClearAutoloadDirs() = 0;\n  virtual void __stdcall AutoloadPlugins() = 0;\n  virtual void __stdcall AddFunction(const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0;\n  virtual bool __stdcall InternalFunctionExists(const char* name) = 0;\n\n  // Threading\n  virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0; // If filter is \"DEFAULT_MT_MODE\", sets the default MT mode\n  virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0;\n  virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0;\n\n  // These lines are needed so that we can overload the older functions from IScriptEnvironment.\n  using IScriptEnvironment::Invoke;\n  using IScriptEnvironment::AddFunction;\n\n}; // end class IScriptEnvironment2\n\n\n// To allow Avisynth+ add functions to IScriptEnvironment2,\n// Neo defines another new interface, INeoEnv.\n// INeoEnv and the legacy interfaces (IScriptEnvironment/IScriptEnvironment2)\n// share the same ScriptEnvironment instance. The function with the same signature\n// is exactly identical and there is no limitation to switch interfaces.\n// You can use any interface you like.\n// Note to plugin authors : The interface is not stable, see comments in IScriptEnvironment2\nclass INeoEnv {\npublic:\n  virtual ~INeoEnv() {}\n\n  typedef IScriptEnvironment::NotFound NotFound;\n  typedef IScriptEnvironment::ApplyFunc ApplyFunc;\n  typedef IScriptEnvironment::ShutdownFunc ShutdownFunc;\n\n  virtual void __stdcall DeleteScriptEnvironment() = 0;\n\n  virtual const AVS_Linkage* __stdcall GetAVSLinkage() = 0;\n\n  // Get legacy interface (Avisynth+)\n  virtual IScriptEnvironment2* __stdcall GetEnv2() = 0;\n  // Get compatibility interface for AVS CPP 2.5 plugins\n  virtual IScriptEnvironment_Avs25* __stdcall GetEnv25() = 0;\n\n  // Generic system to ask for various properties\n  virtual size_t  __stdcall GetEnvProperty(AvsEnvProperty prop) = 0;\n  virtual int __stdcall GetCPUFlags() = 0;\n\n  // Plugin functions\n  virtual bool __stdcall LoadPlugin(const char* filePath, bool throwOnError, AVSValue *result) = 0;\n  virtual void __stdcall AddAutoloadDir(const char* dirPath, bool toFront) = 0;\n  virtual void __stdcall ClearAutoloadDirs() = 0;\n  virtual void __stdcall AutoloadPlugins() = 0;\n\n  virtual void __stdcall AddFunction(\n    const char* name, const char* params, ApplyFunc apply, void* user_data) = 0;\n  virtual void __stdcall AddFunction(\n    const char* name, const char* params, ApplyFunc apply, void* user_data, const char *exportVar) = 0;\n  virtual bool __stdcall FunctionExists(const char* name) = 0;\n  virtual bool __stdcall InternalFunctionExists(const char* name) = 0;\n\n  // Invoke function. Throws NotFound exception when the specified function does not exist.\n  virtual AVSValue __stdcall Invoke(\n    const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual AVSValue __stdcall Invoke2(\n    const AVSValue& implicit_last, const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual AVSValue __stdcall Invoke3(\n    const AVSValue& implicit_last,\n    const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  // These versions of Invoke will return false instead of throwing NotFound().\n  virtual bool __stdcall InvokeTry(\n    AVSValue* result, const char* name, const AVSValue& args, const char* const* arg_names = 0) = 0;\n  virtual bool __stdcall Invoke2Try(\n    AVSValue* result, const AVSValue& implicit_last,\n    const char* name, const AVSValue args, const char* const* arg_names = 0) = 0;\n  virtual bool __stdcall Invoke3Try(\n    AVSValue* result, const AVSValue& implicit_last,\n    const PFunction& func, const AVSValue args, const char* const* arg_names = 0) = 0;\n\n  // V9\n  virtual bool __stdcall MakePropertyWritable(PVideoFrame* pvf) = 0;\n\n  // Throws exception when the requested variable is not found.\n  virtual AVSValue __stdcall GetVar(const char* name) = 0;\n\n  // noThrow version of GetVar\n  virtual AVSValue __stdcall GetVarDef(const char* name, const AVSValue& def = AVSValue()) = 0;\n\n  // Returns TRUE and the requested variable. If the method fails, returns FALSE and does not touch 'val'.\n  virtual bool  __stdcall GetVarTry(const char* name, AVSValue* val) const = 0;\n\n  // Return the value of the requested variable.\n  // If the variable was not found or had the wrong type,\n  // return the supplied default value.\n  virtual bool __stdcall GetVarBool(const char* name, bool def) const = 0;\n  virtual int  __stdcall GetVarInt(const char* name, int def) const = 0;\n  virtual double  __stdcall GetVarDouble(const char* name, double def) const = 0;\n  virtual const char* __stdcall GetVarString(const char* name, const char* def) const = 0;\n  virtual int64_t __stdcall GetVarLong(const char* name, int64_t def) const = 0;\n\n  virtual bool __stdcall SetVar(const char* name, const AVSValue& val) = 0;\n  virtual bool __stdcall SetGlobalVar(const char* name, const AVSValue& val) = 0;\n\n  // Switch local variables\n  virtual void __stdcall PushContext(int level = 0) = 0;\n  virtual void __stdcall PopContext() = 0;\n\n  // Global variable frame support\n  virtual void __stdcall PushContextGlobal() = 0;\n  virtual void __stdcall PopContextGlobal() = 0;\n\n  // Allocate new video frame\n  // in PNeoEnv: align parameter is no longer supported\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi) = 0; // current device is used\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device) = 0;\n  // as above but with property sources\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PVideoFrame *prop_src) = 0; // current device is used + frame property source\n  virtual PVideoFrame __stdcall NewVideoFrame(const VideoInfo& vi, const PDevice& device, const PVideoFrame* prop_src) = 0; // current device is used + frame property source\n\n  // Frame related operations\n  virtual bool __stdcall MakeWritable(PVideoFrame* pvf) = 0;\n  virtual void __stdcall BitBlt(BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height) = 0;\n\n  virtual PVideoFrame __stdcall Subframe(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size, int new_height) = 0;\n  virtual PVideoFrame __stdcall SubframePlanar(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n    int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV) = 0;\n  virtual PVideoFrame __stdcall SubframePlanarA(PVideoFrame src, int rel_offset, int new_pitch, int new_row_size,\n    int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA) = 0;\n\n  // frame properties support\n  virtual void __stdcall copyFrameProps(const PVideoFrame& src, PVideoFrame& dst) = 0;\n  virtual const AVSMap* __stdcall getFramePropsRO(const PVideoFrame& frame) = 0;\n  virtual AVSMap* __stdcall getFramePropsRW(PVideoFrame& frame) = 0;\n\n  virtual int __stdcall propNumKeys(const AVSMap* map) = 0;\n  virtual const char* __stdcall propGetKey(const AVSMap* map, int index) = 0;\n  virtual int __stdcall propNumElements(const AVSMap* map, const char* key) = 0;\n  virtual char __stdcall propGetType(const AVSMap* map, const char* key) = 0;\n\n  virtual int64_t __stdcall propGetInt(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual double __stdcall propGetFloat(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual const char* __stdcall propGetData(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual int __stdcall propGetDataSize(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual PClip __stdcall propGetClip(const AVSMap* map, const char* key, int index, int* error) = 0;\n  virtual const PVideoFrame __stdcall propGetFrame(const AVSMap* map, const char* key, int index, int* error) = 0;\n\n  virtual int __stdcall propDeleteKey(AVSMap* map, const char* key) = 0;\n\n  virtual int __stdcall propSetInt(AVSMap* map, const char* key, int64_t i, int append) = 0;\n  virtual int __stdcall propSetFloat(AVSMap* map, const char* key, double d, int append) = 0;\n  virtual int __stdcall propSetData(AVSMap* map, const char* key, const char* d, int length, int append) = 0;\n  virtual int __stdcall propSetClip(AVSMap* map, const char* key, PClip& clip, int append) = 0;\n  virtual int __stdcall propSetFrame(AVSMap* map, const char* key, const PVideoFrame& frame, int append) = 0;\n\n  virtual const int64_t *__stdcall propGetIntArray(const AVSMap* map, const char* key, int* error) = 0;\n  virtual const double *__stdcall propGetFloatArray(const AVSMap* map, const char* key, int* error) = 0;\n  virtual int __stdcall propSetIntArray(AVSMap* map, const char* key, const int64_t* i, int size) = 0;\n  virtual int __stdcall propSetFloatArray(AVSMap* map, const char* key, const double* d, int size) = 0;\n\n  virtual AVSMap* __stdcall createMap() = 0;\n  virtual void __stdcall freeMap(AVSMap* map) = 0;\n  virtual void __stdcall clearMap(AVSMap* map) = 0;\n\n  // Support functions\n  virtual void* __stdcall Allocate(size_t nBytes, size_t alignment, AvsAllocType type) = 0;\n  virtual void __stdcall Free(void* ptr) = 0;\n\n  virtual char* __stdcall SaveString(const char* s, int length = -1) = 0;\n  virtual char* __stdcall SaveString(const char* s, int length, bool escape) = 0;\n  virtual char* Sprintf(const char* fmt, ...) = 0;\n  virtual char* __stdcall VSprintf(const char* fmt, va_list val) = 0;\n\n  __declspec(noreturn) virtual void ThrowError(const char* fmt, ...) = 0;\n\n  virtual void __stdcall ApplyMessage(PVideoFrame* frame, const VideoInfo& vi, const char* message, int size,\n    int textcolor, int halocolor, int bgcolor) = 0;\n\n  // Setting\n  virtual int __stdcall SetMemoryMax(int mem) = 0;\n  virtual int __stdcall SetMemoryMax(AvsDeviceType type, int index, int mem) = 0;\n\n  virtual bool __stdcall PlanarChromaAlignment(IScriptEnvironment::PlanarChromaAlignmentMode key) = 0;\n  virtual int __stdcall SetWorkingDir(const char * newdir) = 0;\n  virtual void* __stdcall ManageCache(int key, void* data) = 0;\n\n  virtual void __stdcall AtExit(ShutdownFunc function, void* user_data) = 0;\n  virtual void __stdcall CheckVersion(int version = AVISYNTH_INTERFACE_VERSION) = 0;\n\n  // Threading\n  virtual void __stdcall SetFilterMTMode(const char* filter, MtMode mode, bool force) = 0;\n  virtual IJobCompletion* __stdcall NewCompletion(size_t capacity) = 0;\n  virtual void __stdcall ParallelJob(ThreadWorkerFuncPtr jobFunc, void* jobData, IJobCompletion* completion) = 0;\n\n  // CUDA Support\n  virtual PDevice __stdcall GetDevice(AvsDeviceType dev_type, int dev_index) const = 0;\n  virtual PDevice __stdcall GetDevice() const = 0; // get current device\n  virtual AvsDeviceType __stdcall GetDeviceType() const = 0;\n  virtual int __stdcall GetDeviceId() const  = 0;\n  virtual int __stdcall GetDeviceIndex() const  = 0;\n  virtual void* __stdcall GetDeviceStream() const = 0;\n  virtual void __stdcall DeviceAddCallback(void(*cb)(void*), void* user_data) = 0;\n\n  virtual PVideoFrame __stdcall GetFrame(PClip c, int n, const PDevice& device) = 0;\n\n};\n\n// support interface conversion\nstruct PNeoEnv {\n  INeoEnv* p;\n  PNeoEnv() : p() { }\n  PNeoEnv(IScriptEnvironment* env)\n#if defined(BUILDING_AVSCORE) || defined(AVS_STATIC_LIB)\n    ;\n#else\n  : p(!AVS_linkage || offsetof(AVS_Linkage, GetNeoEnv) >= (size_t)AVS_linkage->Size ? 0 : AVS_linkage->GetNeoEnv(env)) { }\n#endif\n\n  int operator!() const { return !p; }\n  operator void*() const { return p; }\n  INeoEnv* operator->() const { return p; }\n#ifdef BUILDING_AVSCORE\n  inline operator IScriptEnvironment2*();\n  inline operator IScriptEnvironment_Avs25* ();\n#else\n  operator IScriptEnvironment2*() { return p->GetEnv2(); }\n  operator IScriptEnvironment_Avs25* () { return p->GetEnv25(); }\n#endif\n};\n\n\n// avisynth.dll exports this; it's a way to use it as a library, without\n// writing an AVS script or without going through AVIFile.\nAVSC_API(IScriptEnvironment*, CreateScriptEnvironment)(int version = AVISYNTH_INTERFACE_VERSION);\n\n\n// These are some global variables you can set in your script to change AviSynth's behavior.\n#define VARNAME_AllowFloatAudio   \"OPT_AllowFloatAudio\"   // Allow WAVE_FORMAT_IEEE_FLOAT audio output\n#define VARNAME_VDubPlanarHack    \"OPT_VDubPlanarHack\"    // Hack YV16 and YV24 chroma plane order for old VDub's\n#define VARNAME_AVIPadScanlines   \"OPT_AVIPadScanlines\"   // Have scanlines mod4 padded in all pixel formats\n#define VARNAME_UseWaveExtensible \"OPT_UseWaveExtensible\" // Use WAVEFORMATEXTENSIBLE when describing audio to Windows\n#define VARNAME_dwChannelMask     \"OPT_dwChannelMask\"     // Integer audio channel mask. See description of WAVEFORMATEXTENSIBLE for more info.\n#define VARNAME_Enable_V210       \"OPT_Enable_V210\"       // AVS+ use V210 instead of P210 (VfW)\n#define VARNAME_Enable_Y3_10_10   \"OPT_Enable_Y3_10_10\"   // AVS+ use Y3[10][10] instead of P210 (VfW)\n#define VARNAME_Enable_Y3_10_16   \"OPT_Enable_Y3_10_16\"   // AVS+ use Y3[10][16] instead of P216 (VfW)\n#define VARNAME_Enable_b64a       \"OPT_Enable_b64a\"       // AVS+ use b64a instead of BRA[64] (VfW)\n#define VARNAME_Enable_PlanarToPackedRGB \"OPT_Enable_PlanarToPackedRGB\" // AVS+ convert Planar RGB to packed RGB (VfW)\n\n// C exports\n#include \"avs/capi.h\"\nAVSC_API(IScriptEnvironment2*, CreateScriptEnvironment2)(int version = AVISYNTH_INTERFACE_VERSION);\n\n#ifndef BUILDING_AVSCORE\n#undef AVS_UNUSED\n#endif\n\n#pragma pack(pop)\n\n#endif //__AVISYNTH_10_H__\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avisynth_c.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// Copyright 2020 AviSynth+ project\n// Actual C Interface version follows the global Avisynth+ IF version numbers.\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,\n// MA 02110-1301 USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n// NOTE: this is a partial update of the Avisynth C interface to recognize\n// new color spaces and interface elements added in Avisynth 2.60 and AviSynth+.\n// This interface is not 100% Avisynth+ CPP interface equivalent.\n\n// 170103: added new CPU constants (FMA4, AVX512xx)\n// 171102: define SIZETMOD. do not use yet, experimental. Offsets are size_t instead of int. Affects x64.\n// 171106: avs_get_row_size calls into avs_get_row_size_p, instead of direct field access\n// 171106: avs_get_height calls into avs_get_row_size_p, instead of direct field access\n// 180524: AVSC_EXPORT to dllexport in capi.h for avisynth_c_plugin_init\n// 180524: avs_is_same_colorspace VideoInfo parameters to const\n// 181230: Readability: functions regrouped to mix less AVSC_API and AVSC_INLINE, put together Avisynth+ specific stuff\n// 181230: use #ifndef AVSC_NO_DECLSPEC for AVSC_INLINE functions which are calling API functions\n// 181230: comments on avs_load_library (helper for loading API entries dynamically into a struct using AVSC_NO_DECLSPEC define)\n// 181230: define alias AVS_FRAME_ALIGN as FRAME_ALIGN\n// 181230: remove unused form of avs_get_rowsize and avs_get_height (kept earlier for reference)\n// 190104: avs_load_library: smart fallback mechanism for Avisynth+ specific functions:\n//         if they are not loadable, they will work in a classic Avisynth compatible mode\n//         Example#1: e.g. avs_is_444 will call the existing avs_is_yv24 instead\n//         Example#2: avs_bits_per_component will return 8 for all colorspaces (Classic Avisynth supports only 8 bits/pixel)\n//         Thus the Avisynth+ specific API functions are safely callable even when connected to classic Avisynth DLL\n// 2002xx  non-Windows friendly additions\n// 200305  avs_vsprintf parameter type change: (void *) to va_list\n// 200330: (remove test SIZETMOD define for clarity)\n// 200513: user must use explicite #define AVS26_FALLBACK_SIMULATION for having fallback helpers in dynamic loaded library section\n// 200513: Follow AviSynth+ V8 interface additions\n//         AVS_VideoFrame struct extended with placeholder for frame property pointer\n//         avs_subframe_planar_a\n//         avs_copy_frame_props\n//         avs_get_frame_props_ro, avs_get_frame_props_rw\n//         avs_prop_num_keys, avs_prop_get_key, avs_prop_num_elements, avs_prop_get_type, avs_prop_get_data_size\n//         avs_prop_get_int, avs_prop_get_float, avs_prop_get_data, avs_prop_get_clip, avs_prop_get_frame, avs_prop_get_int_array, avs_prop_get_float_array\n//         avs_prop_set_int, avs_prop_set_float, avs_prop_set_data, avs_prop_set_clip, avs_prop_set_frame, avs_prop_set_int_array, avs_prop_set_float_array\n//         avs_prop_delete_key, avs_clear_map\n//         avs_new_video_frame_p, avs_new_video_frame_p_a\n//         avs_get_env_property (internal system properties), AVS_AEP_xxx (AvsEnvProperty) enums\n//         avs_get_var_try, avs_get_var_bool, avs_get_var_int, avs_get_var_double, avs_get_var_string, avs_get_var_long\n//         avs_pool_allocate, avs_pool_free\n// 2021:   Follow AviSynth+ V9 interface additions\n//         avs_is_property_writable, avs_make_property_writable\n//         Add enum AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION (AVISYNTH_INTERFACE_VERSION still exists)\n//         Add enum AVS_AEP_HOST_SYSTEM_ENDIANNESS to system property request types (avs_get_env_property)\n//         Add enums AVS_AEP_INTERFACE_VERSION and AVS_AEP_INTERFACE_BUGFIX for direct interface version system property request types (avs_get_env_property)\n//         Bugfix 9.1: fix avs_prop_get_data\n// 2023:   Follow AviSynth+ V10 interface additions\n//         Add enum AVS_DEFAULT_PLANE (as 0) to plane constants \n//         prop_src argument now const in avs_new_video_frame_p and avs_new_video_frame_p_a (no change in use)\n//         Add pixel_type to struct AVS_VideoFrame\n//         Add avs_video_frame_get_pixel_type and avs_video_frame_amend_pixel_type for getting and setting AVS_VideoFrame pixel_type\n//         Additional AviSynth+ V10 interface additions:\n//         Add enum AVS_SPEAKER_xxx, AVS_IT_SPEAKER_xxx\n//         audio channel mask support avs_is_channel_mask_known, avs_set_channel_mask, avs_get_channel_mask\n\n#ifndef __AVISYNTH_C__\n#define __AVISYNTH_C__\n\n#include \"avs/config.h\"\n#include \"avs/capi.h\"\n#include \"avs/types.h\"\n\n#define AVS_FRAME_ALIGN FRAME_ALIGN\n/////////////////////////////////////////////////////////////////////\n//\n// Constants\n//\n\n#ifndef __AVISYNTH_10_H__\nenum {\n  AVISYNTH_INTERFACE_CLASSIC_VERSION = 6,\n  AVISYNTH_INTERFACE_VERSION = 10,\n  AVISYNTHPLUS_INTERFACE_BUGFIX_VERSION = 0 // reset to zero whenever the normal interface version bumps\n};\n#endif\n\nenum {\n  AVS_SAMPLE_INT8  = 1 << 0,\n  AVS_SAMPLE_INT16 = 1 << 1,\n  AVS_SAMPLE_INT24 = 1 << 2,\n  AVS_SAMPLE_INT32 = 1 << 3,\n  AVS_SAMPLE_FLOAT = 1 << 4\n};\n\nenum {\n  AVS_DEFAULT_PLANE = 0,\n  AVS_PLANAR_Y = 1 << 0,\n  AVS_PLANAR_U = 1 << 1,\n  AVS_PLANAR_V = 1 << 2,\n  AVS_PLANAR_ALIGNED = 1 << 3,\n  AVS_PLANAR_Y_ALIGNED = AVS_PLANAR_Y | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_U_ALIGNED = AVS_PLANAR_U | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_V_ALIGNED = AVS_PLANAR_V | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_A = 1 << 4,\n  AVS_PLANAR_R = 1 << 5,\n  AVS_PLANAR_G = 1 << 6,\n  AVS_PLANAR_B = 1 << 7,\n  AVS_PLANAR_A_ALIGNED = AVS_PLANAR_A | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_R_ALIGNED = AVS_PLANAR_R | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_G_ALIGNED = AVS_PLANAR_G | AVS_PLANAR_ALIGNED,\n  AVS_PLANAR_B_ALIGNED = AVS_PLANAR_B | AVS_PLANAR_ALIGNED\n};\n\n// Colorspace properties.\nenum {\n  AVS_CS_YUVA = 1 << 27,\n  AVS_CS_BGR = 1 << 28,\n  AVS_CS_YUV = 1 << 29,\n  AVS_CS_INTERLEAVED = 1 << 30,\n  AVS_CS_PLANAR = 1 << 31,\n\n  AVS_CS_SHIFT_SUB_WIDTH = 0,\n  AVS_CS_SHIFT_SUB_HEIGHT = 8,\n  AVS_CS_SHIFT_SAMPLE_BITS = 16,\n\n  AVS_CS_SUB_WIDTH_MASK = 7 << AVS_CS_SHIFT_SUB_WIDTH,\n  AVS_CS_SUB_WIDTH_1 = 3 << AVS_CS_SHIFT_SUB_WIDTH, // YV24\n  AVS_CS_SUB_WIDTH_2 = 0 << AVS_CS_SHIFT_SUB_WIDTH, // YV12, I420, YV16\n  AVS_CS_SUB_WIDTH_4 = 1 << AVS_CS_SHIFT_SUB_WIDTH, // YUV9, YV411\n\n  AVS_CS_VPLANEFIRST = 1 << 3, // YV12, YV16, YV24, YV411, YUV9\n  AVS_CS_UPLANEFIRST = 1 << 4, // I420\n\n  AVS_CS_SUB_HEIGHT_MASK = 7 << AVS_CS_SHIFT_SUB_HEIGHT,\n  AVS_CS_SUB_HEIGHT_1 = 3 << AVS_CS_SHIFT_SUB_HEIGHT, // YV16, YV24, YV411\n  AVS_CS_SUB_HEIGHT_2 = 0 << AVS_CS_SHIFT_SUB_HEIGHT, // YV12, I420\n  AVS_CS_SUB_HEIGHT_4 = 1 << AVS_CS_SHIFT_SUB_HEIGHT, // YUV9\n\n  AVS_CS_SAMPLE_BITS_MASK = 7 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_8 = 0 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_10 = 5 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_12 = 6 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_14 = 7 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_16 = 1 << AVS_CS_SHIFT_SAMPLE_BITS,\n  AVS_CS_SAMPLE_BITS_32 = 2 << AVS_CS_SHIFT_SAMPLE_BITS,\n\n  AVS_CS_PLANAR_MASK = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV | AVS_CS_BGR | AVS_CS_YUVA\n                       | AVS_CS_SAMPLE_BITS_MASK | AVS_CS_SUB_WIDTH_MASK | AVS_CS_SUB_HEIGHT_MASK,\n  AVS_CS_PLANAR_FILTER = ~(AVS_CS_VPLANEFIRST | AVS_CS_UPLANEFIRST),\n\n  AVS_CS_RGB_TYPE  = 1 << 0,\n  AVS_CS_RGBA_TYPE = 1 << 1,\n\n  AVS_CS_GENERIC_YUV444  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_1 | AVS_CS_SUB_HEIGHT_1,  // 4:4:4 planar\n  AVS_CS_GENERIC_YUV422  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_1,  // 4:2:2 planar\n  AVS_CS_GENERIC_YUV420  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2,  // 4:2:0 planar\n  AVS_CS_GENERIC_Y       = AVS_CS_PLANAR | AVS_CS_INTERLEAVED | AVS_CS_YUV,                                             // Y only (4:0:0)\n  AVS_CS_GENERIC_RGBP    = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGB_TYPE,                                                // planar RGB\n  AVS_CS_GENERIC_RGBAP   = AVS_CS_PLANAR | AVS_CS_BGR | AVS_CS_RGBA_TYPE,                                               // planar RGBA\n  AVS_CS_GENERIC_YUVA444 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_1 | AVS_CS_SUB_HEIGHT_1, // 4:4:4:A planar\n  AVS_CS_GENERIC_YUVA422 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_1, // 4:2:2:A planar\n  AVS_CS_GENERIC_YUVA420 = AVS_CS_PLANAR | AVS_CS_YUVA | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2  // 4:2:0:A planar\n};\n\n// Specific color formats\nenum {\n  AVS_CS_UNKNOWN = 0,\n  AVS_CS_BGR24 = AVS_CS_RGB_TYPE  | AVS_CS_BGR | AVS_CS_INTERLEAVED,\n  AVS_CS_BGR32 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED,\n  AVS_CS_YUY2 = 1 << 2 | AVS_CS_YUV | AVS_CS_INTERLEAVED,\n  // AVS_CS_YV12 = 1 << 3   Reserved\n  // AVS_CS_I420 = 1 << 4   Reserved\n  AVS_CS_RAW32 = 1 << 5 | AVS_CS_INTERLEAVED,\n\n  AVS_CS_YV24  = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_8,  // YUV 4:4:4 planar\n  AVS_CS_YV16  = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_8,  // YUV 4:2:2 planar\n  AVS_CS_YV12  = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_8,  // YUV 4:2:0 planar\n  AVS_CS_I420  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_UPLANEFIRST | AVS_CS_SUB_WIDTH_2 | AVS_CS_SUB_HEIGHT_2,  // YUV 4:2:0 planar\n  AVS_CS_IYUV  = AVS_CS_I420,\n  AVS_CS_YV411 = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_4 | AVS_CS_SUB_HEIGHT_1,  // YUV 4:1:1 planar\n  AVS_CS_YUV9  = AVS_CS_PLANAR | AVS_CS_YUV | AVS_CS_SAMPLE_BITS_8 | AVS_CS_VPLANEFIRST | AVS_CS_SUB_WIDTH_4 | AVS_CS_SUB_HEIGHT_4,  // YUV 4:1:0 planar\n  AVS_CS_Y8    = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_8,       // Y   4:0:0 planar\n\n  //-------------------------\n  // AVS16: new planar constants go live! Experimental PF 160613\n  // 10-12-14-16 bit + planar RGB + BGR48/64 160725\n  AVS_CS_YUV444P10 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_10, // YUV 4:4:4 10bit samples\n  AVS_CS_YUV422P10 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:2 10bit samples\n  AVS_CS_YUV420P10 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_10, // YUV 4:2:0 10bit samples\n  AVS_CS_Y10       = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_10,      // Y   4:0:0 10bit samples\n\n  AVS_CS_YUV444P12 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_12, // YUV 4:4:4 12bit samples\n  AVS_CS_YUV422P12 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:2 12bit samples\n  AVS_CS_YUV420P12 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_12, // YUV 4:2:0 12bit samples\n  AVS_CS_Y12       = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_12,      // Y   4:0:0 12bit samples\n\n  AVS_CS_YUV444P14 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_14, // YUV 4:4:4 14bit samples\n  AVS_CS_YUV422P14 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:2 14bit samples\n  AVS_CS_YUV420P14 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_14, // YUV 4:2:0 14bit samples\n  AVS_CS_Y14       = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_14,      // Y   4:0:0 14bit samples\n\n  AVS_CS_YUV444P16 = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_16, // YUV 4:4:4 16bit samples\n  AVS_CS_YUV422P16 = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:2 16bit samples\n  AVS_CS_YUV420P16 = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_16, // YUV 4:2:0 16bit samples\n  AVS_CS_Y16       = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_16,      // Y   4:0:0 16bit samples\n\n  // 32 bit samples (float)\n  AVS_CS_YUV444PS = AVS_CS_GENERIC_YUV444 | AVS_CS_SAMPLE_BITS_32,  // YUV 4:4:4 32bit samples\n  AVS_CS_YUV422PS = AVS_CS_GENERIC_YUV422 | AVS_CS_SAMPLE_BITS_32,  // YUV 4:2:2 32bit samples\n  AVS_CS_YUV420PS = AVS_CS_GENERIC_YUV420 | AVS_CS_SAMPLE_BITS_32,  // YUV 4:2:0 32bit samples\n  AVS_CS_Y32      = AVS_CS_GENERIC_Y | AVS_CS_SAMPLE_BITS_32,       // Y   4:0:0 32bit samples\n\n  // RGB packed\n  AVS_CS_BGR48 = AVS_CS_RGB_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16,    // BGR 3x16 bit\n  AVS_CS_BGR64 = AVS_CS_RGBA_TYPE | AVS_CS_BGR | AVS_CS_INTERLEAVED | AVS_CS_SAMPLE_BITS_16,    // BGR 4x16 bit\n  // no packed 32 bit (float) support for these legacy types\n\n  // RGB planar\n  AVS_CS_RGBP   = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_8,  // Planar RGB 8 bit samples\n  AVS_CS_RGBP10 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_10, // Planar RGB 10bit samples\n  AVS_CS_RGBP12 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_12, // Planar RGB 12bit samples\n  AVS_CS_RGBP14 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_14, // Planar RGB 14bit samples\n  AVS_CS_RGBP16 = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_16, // Planar RGB 16bit samples\n  AVS_CS_RGBPS  = AVS_CS_GENERIC_RGBP | AVS_CS_SAMPLE_BITS_32, // Planar RGB 32bit samples\n\n  // RGBA planar\n  AVS_CS_RGBAP   = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_8,  // Planar RGBA 8 bit samples\n  AVS_CS_RGBAP10 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_10, // Planar RGBA 10bit samples\n  AVS_CS_RGBAP12 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_12, // Planar RGBA 12bit samples\n  AVS_CS_RGBAP14 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_14, // Planar RGBA 14bit samples\n  AVS_CS_RGBAP16 = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_16, // Planar RGBA 16bit samples\n  AVS_CS_RGBAPS  = AVS_CS_GENERIC_RGBAP | AVS_CS_SAMPLE_BITS_32, // Planar RGBA 32bit samples\n\n  // Planar YUVA\n  AVS_CS_YUVA444    = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_8,  // YUVA 4:4:4 8bit samples\n  AVS_CS_YUVA422    = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_8,  // YUVA 4:2:2 8bit samples\n  AVS_CS_YUVA420    = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_8,  // YUVA 4:2:0 8bit samples\n\n  AVS_CS_YUVA444P10 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:4:4 10bit samples\n  AVS_CS_YUVA422P10 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:2 10bit samples\n  AVS_CS_YUVA420P10 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_10, // YUVA 4:2:0 10bit samples\n\n  AVS_CS_YUVA444P12 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:4:4 12bit samples\n  AVS_CS_YUVA422P12 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:2 12bit samples\n  AVS_CS_YUVA420P12 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_12, // YUVA 4:2:0 12bit samples\n\n  AVS_CS_YUVA444P14 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:4:4 14bit samples\n  AVS_CS_YUVA422P14 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:2 14bit samples\n  AVS_CS_YUVA420P14 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_14, // YUVA 4:2:0 14bit samples\n\n  AVS_CS_YUVA444P16 = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:4:4 16bit samples\n  AVS_CS_YUVA422P16 = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:2 16bit samples\n  AVS_CS_YUVA420P16 = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_16, // YUVA 4:2:0 16bit samples\n\n  AVS_CS_YUVA444PS  = AVS_CS_GENERIC_YUVA444 | AVS_CS_SAMPLE_BITS_32,  // YUVA 4:4:4 32bit samples\n  AVS_CS_YUVA422PS  = AVS_CS_GENERIC_YUVA422 | AVS_CS_SAMPLE_BITS_32,  // YUVA 4:2:2 32bit samples\n  AVS_CS_YUVA420PS  = AVS_CS_GENERIC_YUVA420 | AVS_CS_SAMPLE_BITS_32,  // YUVA 4:2:0 32bit samples\n};\n\n// AvsChannelMask enum: Unshifted channel mask constants like in WAVEFORMATEXTENSIBLE\n// in AvsImageTypeFlags they are shifted by 4 bits\nenum {\n  AVS_MASK_SPEAKER_FRONT_LEFT = 0x1,\n  AVS_MASK_SPEAKER_FRONT_RIGHT = 0x2,\n  AVS_MASK_SPEAKER_FRONT_CENTER = 0x4,\n  AVS_MASK_SPEAKER_LOW_FREQUENCY = 0x8,\n  AVS_MASK_SPEAKER_BACK_LEFT = 0x10,\n  AVS_MASK_SPEAKER_BACK_RIGHT = 0x20,\n  AVS_MASK_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40,\n  AVS_MASK_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80,\n  AVS_MASK_SPEAKER_BACK_CENTER = 0x100,\n  AVS_MASK_SPEAKER_SIDE_LEFT = 0x200,\n  AVS_MASK_SPEAKER_SIDE_RIGHT = 0x400,\n  AVS_MASK_SPEAKER_TOP_CENTER = 0x800,\n  AVS_MASK_SPEAKER_TOP_FRONT_LEFT = 0x1000,\n  AVS_MASK_SPEAKER_TOP_FRONT_CENTER = 0x2000,\n  AVS_MASK_SPEAKER_TOP_FRONT_RIGHT = 0x4000,\n  AVS_MASK_SPEAKER_TOP_BACK_LEFT = 0x8000,\n  AVS_MASK_SPEAKER_TOP_BACK_CENTER = 0x10000,\n  AVS_MASK_SPEAKER_TOP_BACK_RIGHT = 0x20000,\n  // Bit mask locations used up for the above positions\n  AVS_MASK_SPEAKER_DEFINED = 0x0003FFFF,\n  // Bit mask locations reserved for future use\n  AVS_MASK_SPEAKER_RESERVED = 0x7FFC0000,\n  // Used to specify that any possible permutation of speaker configurations\n  // Due to lack of available bits this one is put differently into image_type\n  AVS_MASK_SPEAKER_ALL = 0x80000000\n};\n\n// AvsImageTypeFlags\nenum {\n  AVS_IT_BFF = 1 << 0,\n  AVS_IT_TFF = 1 << 1,\n  AVS_IT_FIELDBASED = 1 << 2,\n\n  // Audio channel mask support\n  AVS_IT_HAS_CHANNELMASK = 1 << 3,\n  // shifted by 4 bits compared to WAVEFORMATEXTENSIBLE dwChannelMask\n  // otherwise same as AvsChannelMask\n  AVS_IT_SPEAKER_FRONT_LEFT = 0x1 << 4,\n  AVS_IT_SPEAKER_FRONT_RIGHT = 0x2 << 4,\n  AVS_IT_SPEAKER_FRONT_CENTER = 0x4 << 4,\n  AVS_IT_SPEAKER_LOW_FREQUENCY = 0x8 << 4,\n  AVS_IT_SPEAKER_BACK_LEFT = 0x10 << 4,\n  AVS_IT_SPEAKER_BACK_RIGHT = 0x20 << 4,\n  AVS_IT_SPEAKER_FRONT_LEFT_OF_CENTER = 0x40 << 4,\n  AVS_IT_SPEAKER_FRONT_RIGHT_OF_CENTER = 0x80 << 4,\n  AVS_IT_SPEAKER_BACK_CENTER = 0x100 << 4,\n  AVS_IT_SPEAKER_SIDE_LEFT = 0x200 << 4,\n  AVS_IT_SPEAKER_SIDE_RIGHT = 0x400 << 4,\n  AVS_IT_SPEAKER_TOP_CENTER = 0x800 << 4,\n  AVS_IT_SPEAKER_TOP_FRONT_LEFT = 0x1000 << 4,\n  AVS_IT_SPEAKER_TOP_FRONT_CENTER = 0x2000 << 4,\n  AVS_IT_SPEAKER_TOP_FRONT_RIGHT = 0x4000 << 4,\n  AVS_IT_SPEAKER_TOP_BACK_LEFT = 0x8000 << 4,\n  AVS_IT_SPEAKER_TOP_BACK_CENTER = 0x10000 << 4,\n  AVS_IT_SPEAKER_TOP_BACK_RIGHT = 0x20000 << 4,\n  // End of officially defined speaker bits\n  // The next one is special, since cannot shift SPEAKER_ALL 0x80000000 further.\n  // Set mask and get mask handles it.\n  AVS_IT_SPEAKER_ALL = 0x40000 << 4,\n  // Mask for the defined 18 bits + SPEAKER_ALL\n  AVS_IT_SPEAKER_BITS_MASK = (AVS_MASK_SPEAKER_DEFINED << 4) | AVS_IT_SPEAKER_ALL,\n  AVS_IT_NEXT_AVAILABLE = 1 << 23\n};\n\nenum {\n  AVS_FILTER_TYPE = 1,\n  AVS_FILTER_INPUT_COLORSPACE = 2,\n  AVS_FILTER_OUTPUT_TYPE = 9,\n  AVS_FILTER_NAME = 4,\n  AVS_FILTER_AUTHOR = 5,\n  AVS_FILTER_VERSION = 6,\n  AVS_FILTER_ARGS = 7,\n  AVS_FILTER_ARGS_INFO = 8,\n  AVS_FILTER_ARGS_DESCRIPTION = 10,\n  AVS_FILTER_DESCRIPTION = 11\n};\n\nenum {  // SUBTYPES\n  AVS_FILTER_TYPE_AUDIO = 1,\n  AVS_FILTER_TYPE_VIDEO = 2,\n  AVS_FILTER_OUTPUT_TYPE_SAME = 3,\n  AVS_FILTER_OUTPUT_TYPE_DIFFERENT = 4\n};\n\nenum {\n  // New 2.6 explicitly defined cache hints.\n  AVS_CACHE_NOTHING = 10, // Do not cache video.\n  AVS_CACHE_WINDOW = 11, // Hard protect up to X frames within a range of X from the current frame N.\n  AVS_CACHE_GENERIC = 12, // LRU cache up to X frames.\n  AVS_CACHE_FORCE_GENERIC = 13, // LRU cache up to X frames, override any previous CACHE_WINDOW.\n\n  AVS_CACHE_GET_POLICY = 30, // Get the current policy.\n  AVS_CACHE_GET_WINDOW = 31, // Get the current window h_span.\n  AVS_CACHE_GET_RANGE = 32, // Get the current generic frame range.\n\n  // Set Audio cache mode and answers to CACHE_GETCHILD_AUDIO_MODE\n  AVS_CACHE_AUDIO = 50, // Explicitly do cache audio, X byte cache.\n  AVS_CACHE_AUDIO_NOTHING = 51, // Explicitly do not cache audio.\n  AVS_CACHE_AUDIO_NONE = 52, // Audio cache off (auto mode), X byte initial cache.\n  AVS_CACHE_AUDIO_AUTO_START_OFF = 52, // synonym\n  AVS_CACHE_AUDIO_AUTO = 53, // Audio cache on (auto mode), X byte initial cache.\n  AVS_CACHE_AUDIO_AUTO_START_ON = 53, // synonym\n\n  // These just returns actual value if clip is cached\n  AVS_CACHE_GET_AUDIO_POLICY = 70, // Get the current audio policy.\n  AVS_CACHE_GET_AUDIO_SIZE = 71, // Get the current audio cache size.\n\n  AVS_CACHE_PREFETCH_FRAME = 100, // n/a Queue request to prefetch frame N.\n  AVS_CACHE_PREFETCH_GO = 101, // n/a Action video prefetches.\n\n  AVS_CACHE_PREFETCH_AUDIO_BEGIN = 120, // n/a Begin queue request transaction to prefetch audio (take critical section).\n  AVS_CACHE_PREFETCH_AUDIO_STARTLO = 121, // n/a Set low 32 bits of start.\n  AVS_CACHE_PREFETCH_AUDIO_STARTHI = 122, // n/a Set high 32 bits of start.\n  AVS_CACHE_PREFETCH_AUDIO_COUNT = 123, // n/a Set low 32 bits of length.\n  AVS_CACHE_PREFETCH_AUDIO_COMMIT = 124, // n/a Enqueue request transaction to prefetch audio (release critical section).\n  AVS_CACHE_PREFETCH_AUDIO_GO = 125, // n/a Action audio prefetches.\n\n  AVS_CACHE_GETCHILD_CACHE_MODE = 200, // n/a Cache ask Child for desired video cache mode.\n  AVS_CACHE_GETCHILD_CACHE_SIZE = 201, // n/a Cache ask Child for desired video cache size.\n\n  // Filters are queried about their desired audio cache mode.\n  // Child can answer them with CACHE_AUDIO_xxx\n  AVS_CACHE_GETCHILD_AUDIO_MODE = 202, // Cache ask Child for desired audio cache mode.\n  AVS_CACHE_GETCHILD_AUDIO_SIZE = 203, // Cache ask Child for desired audio cache size.\n\n  AVS_CACHE_GETCHILD_COST = 220, // n/a Cache ask Child for estimated processing cost.\n  AVS_CACHE_COST_ZERO = 221, // n/a Child response of zero cost (ptr arithmetic only).\n  AVS_CACHE_COST_UNIT = 222, // n/a Child response of unit cost (less than or equal 1 full frame blit).\n  AVS_CACHE_COST_LOW = 223, // n/a Child response of light cost. (Fast)\n  AVS_CACHE_COST_MED = 224, // n/a Child response of medium cost. (Real time)\n  AVS_CACHE_COST_HI = 225, // n/a Child response of heavy cost. (Slow)\n\n  AVS_CACHE_GETCHILD_THREAD_MODE = 240, // n/a Cache ask Child for thread safety.\n  AVS_CACHE_THREAD_UNSAFE = 241, // n/a Only 1 thread allowed for all instances. 2.5 filters default!\n  AVS_CACHE_THREAD_CLASS = 242, // n/a Only 1 thread allowed for each instance. 2.6 filters default!\n  AVS_CACHE_THREAD_SAFE = 243, // n/a Allow all threads in any instance.\n  AVS_CACHE_THREAD_OWN = 244, // n/a Safe but limit to 1 thread, internally threaded.\n\n  AVS_CACHE_GETCHILD_ACCESS_COST = 260, // Cache ask Child for preferred access pattern.\n  AVS_CACHE_ACCESS_RAND = 261, // Filter is access order agnostic.\n  AVS_CACHE_ACCESS_SEQ0 = 262, // Filter prefers sequential access (low cost)\n  AVS_CACHE_ACCESS_SEQ1 = 263, // Filter needs sequential access (high cost)\n\n  AVS_CACHE_AVSPLUS_CONSTANTS = 500,    // Smaller values are reserved for classic Avisynth\n\n  AVS_CACHE_DONT_CACHE_ME = 501,              // Filters that don't need caching (eg. trim, cache etc.) should return 1 to this request\n  AVS_CACHE_SET_MIN_CAPACITY = 502,\n  AVS_CACHE_SET_MAX_CAPACITY = 503,\n  AVS_CACHE_GET_MIN_CAPACITY = 504,\n  AVS_CACHE_GET_MAX_CAPACITY = 505,\n  AVS_CACHE_GET_SIZE = 506,\n  AVS_CACHE_GET_REQUESTED_CAP = 507,\n  AVS_CACHE_GET_CAPACITY = 508,\n  AVS_CACHE_GET_MTMODE = 509,                 // Filters specify their desired MT mode, see enum MtMode\n\n  // By returning IS_CACHE_ANS to IS_CACHE_REQ, we tell the caller we are a cache\n  AVS_CACHE_IS_CACHE_REQ = 510,\n  AVS_CACHE_IS_CACHE_ANS = 511,\n  // By returning IS_MTGUARD_ANS to IS_MTGUARD_REQ, we tell the caller we are an mt guard\n  AVS_CACHE_IS_MTGUARD_REQ = 512,\n  AVS_CACHE_IS_MTGUARD_ANS = 513,\n\n  AVS_CACHE_AVSPLUS_CUDA_CONSTANTS = 600,\n\n  AVS_CACHE_GET_DEV_TYPE = 601,          // Device types a filter can return\n  AVS_CACHE_GET_CHILD_DEV_TYPE = 602,    // Device types a fitler can receive\n\n  AVS_CACHE_USER_CONSTANTS = 1000       // Smaller values are reserved for the core\n};\n\n\n\n// enums for frame property functions\n// AVSPropTypes\nenum {\n  AVS_PROPTYPE_UNSET = 'u',\n  AVS_PROPTYPE_INT = 'i',\n  AVS_PROPTYPE_FLOAT = 'f',\n  AVS_PROPTYPE_DATA = 's',\n  AVS_PROPTYPE_CLIP = 'c',\n  AVS_PROPTYPE_FRAME = 'v'\n};\n\n// AVSGetPropErrors for avs_prop_get_...\nenum {\n  AVS_GETPROPERROR_UNSET = 1,\n  AVS_GETPROPERROR_TYPE = 2,\n  AVS_GETPROPERROR_INDEX = 4\n};\n\n// AVSPropAppendMode for avs_prop_set_...\nenum {\n  AVS_PROPAPPENDMODE_REPLACE = 0,\n  AVS_PROPAPPENDMODE_APPEND = 1,\n  AVS_PROPAPPENDMODE_TOUCH = 2\n};\n\n// AvsEnvProperty for avs_get_env_property\nenum {\n  AVS_AEP_PHYSICAL_CPUS = 1,\n  AVS_AEP_LOGICAL_CPUS = 2,\n  AVS_AEP_THREADPOOL_THREADS = 3,\n  AVS_AEP_FILTERCHAIN_THREADS = 4,\n  AVS_AEP_THREAD_ID = 5,\n  AVS_AEP_VERSION = 6,\n  AVS_AEP_HOST_SYSTEM_ENDIANNESS = 7,\n  AVS_AEP_INTERFACE_VERSION = 8,\n  AVS_AEP_INTERFACE_BUGFIX = 9,\n\n  // Neo additionals\n  AVS_AEP_NUM_DEVICES = 901,\n  AVS_AEP_FRAME_ALIGN = 902,\n  AVS_AEP_PLANE_ALIGN = 903,\n\n  AVS_AEP_SUPPRESS_THREAD = 921,\n  AVS_AEP_GETFRAME_RECURSIVE = 922\n};\n\n// enum AvsAllocType for avs_allocate\nenum {\n  AVS_ALLOCTYPE_NORMAL_ALLOC = 1,\n  AVS_ALLOCTYPE_POOLED_ALLOC = 2\n};\n\n#ifdef BUILDING_AVSCORE\nAVSValue create_c_video_filter(AVSValue args, void * user_data, IScriptEnvironment * e0);\n\nstruct AVS_ScriptEnvironment {\n        IScriptEnvironment * env;\n        const char * error;\n        AVS_ScriptEnvironment(IScriptEnvironment * e = 0)\n                : env(e), error(0) {}\n};\n#endif\n\ntypedef struct AVS_Clip AVS_Clip;\ntypedef struct AVS_ScriptEnvironment AVS_ScriptEnvironment;\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_VideoInfo\n//\n\n// AVS_VideoInfo is laid out identically to VideoInfo\ntypedef struct AVS_VideoInfo {\n  int width, height;    // width=0 means no video\n  unsigned fps_numerator, fps_denominator;\n  int num_frames;\n\n  int pixel_type;\n\n  int audio_samples_per_second;   // 0 means no audio\n  int sample_type;\n  int64_t num_audio_samples;\n  int nchannels;\n\n  // Image type properties\n  // BFF, TFF, FIELDBASED. Also used for storing Channel Mask\n  // Manipulate it through the channelmask interface calls \n  int image_type;\n} AVS_VideoInfo;\n\n// useful functions of the above\nAVSC_INLINE int avs_has_video(const AVS_VideoInfo * p)\n        { return (p->width!=0); }\n\nAVSC_INLINE int avs_has_audio(const AVS_VideoInfo * p)\n        { return (p->audio_samples_per_second!=0); }\n\nAVSC_INLINE int avs_is_rgb(const AVS_VideoInfo * p)\n        { return !!(p->pixel_type&AVS_CS_BGR); }\n\nAVSC_INLINE int avs_is_rgb24(const AVS_VideoInfo * p)\n        { return ((p->pixel_type&AVS_CS_BGR24)==AVS_CS_BGR24) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); }\n\nAVSC_INLINE int avs_is_rgb32(const AVS_VideoInfo * p)\n       { return ((p->pixel_type&AVS_CS_BGR32)==AVS_CS_BGR32) && ((p->pixel_type & AVS_CS_SAMPLE_BITS_MASK) == AVS_CS_SAMPLE_BITS_8); }\n\nAVSC_INLINE int avs_is_yuv(const AVS_VideoInfo * p)\n        { return !!(p->pixel_type&AVS_CS_YUV ); }\n\nAVSC_INLINE int avs_is_yuy2(const AVS_VideoInfo * p)\n        { return (p->pixel_type & AVS_CS_YUY2) == AVS_CS_YUY2; }\n\nAVSC_API(int, avs_is_yv24)(const AVS_VideoInfo * p); // avs+: for generic 444 check, use avs_is_yuv444\n\nAVSC_API(int, avs_is_yv16)(const AVS_VideoInfo * p); // avs+: for generic 422 check, use avs_is_yuv422\n\nAVSC_API(int, avs_is_yv12)(const AVS_VideoInfo * p) ; // avs+: for generic 420 check, use avs_is_yuv420\n\nAVSC_API(int, avs_is_yv411)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_y8)(const AVS_VideoInfo * p); // avs+: for generic grayscale, use avs_is_y\n\nAVSC_API(int, avs_get_plane_width_subsampling)(const AVS_VideoInfo * p, int plane);\n\nAVSC_API(int, avs_get_plane_height_subsampling)(const AVS_VideoInfo * p, int plane);\n\nAVSC_API(int, avs_bits_per_pixel)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_bytes_from_pixels)(const AVS_VideoInfo * p, int pixels);\n\nAVSC_API(int, avs_row_size)(const AVS_VideoInfo * p, int plane);\n\nAVSC_API(int, avs_bmp_size)(const AVS_VideoInfo * vi);\n\nAVSC_API(int, avs_is_color_space)(const AVS_VideoInfo * p, int c_space);\n\n// no API for these, inline helper functions\nAVSC_INLINE int avs_is_property(const AVS_VideoInfo * p, int property)\n{\n  return ((p->image_type & property) == property);\n}\n\nAVSC_INLINE int avs_is_planar(const AVS_VideoInfo * p)\n{\n  return !!(p->pixel_type & AVS_CS_PLANAR);\n}\n\nAVSC_INLINE int avs_is_field_based(const AVS_VideoInfo * p)\n{\n  return !!(p->image_type & AVS_IT_FIELDBASED);\n}\n\nAVSC_INLINE int avs_is_parity_known(const AVS_VideoInfo * p)\n{\n  return ((p->image_type & AVS_IT_FIELDBASED) && (p->image_type & (AVS_IT_BFF | AVS_IT_TFF)));\n}\n\nAVSC_INLINE int avs_is_bff(const AVS_VideoInfo * p)\n{\n  return !!(p->image_type & AVS_IT_BFF);\n}\n\nAVSC_INLINE int avs_is_tff(const AVS_VideoInfo * p)\n{\n  return !!(p->image_type & AVS_IT_TFF);\n}\n\nAVSC_INLINE int avs_samples_per_second(const AVS_VideoInfo * p)\n        { return p->audio_samples_per_second; }\n\nAVSC_INLINE int avs_bytes_per_channel_sample(const AVS_VideoInfo * p)\n{\n    switch (p->sample_type) {\n      case AVS_SAMPLE_INT8:  return sizeof(signed char);\n      case AVS_SAMPLE_INT16: return sizeof(signed short);\n      case AVS_SAMPLE_INT24: return 3;\n      case AVS_SAMPLE_INT32: return sizeof(signed int);\n      case AVS_SAMPLE_FLOAT: return sizeof(float);\n      default: return 0;\n    }\n}\n\nAVSC_INLINE int avs_bytes_per_audio_sample(const AVS_VideoInfo * p)\n        { return p->nchannels*avs_bytes_per_channel_sample(p);}\n\nAVSC_INLINE int64_t avs_audio_samples_from_frames(const AVS_VideoInfo * p, int64_t frames)\n        { return ((int64_t)(frames) * p->audio_samples_per_second * p->fps_denominator / p->fps_numerator); }\n\nAVSC_INLINE int avs_frames_from_audio_samples(const AVS_VideoInfo * p, int64_t samples)\n        { return (int)(samples * (int64_t)p->fps_numerator / (int64_t)p->fps_denominator / (int64_t)p->audio_samples_per_second); }\n\nAVSC_INLINE int64_t avs_audio_samples_from_bytes(const AVS_VideoInfo * p, int64_t bytes)\n        { return bytes / avs_bytes_per_audio_sample(p); }\n\nAVSC_INLINE int64_t avs_bytes_from_audio_samples(const AVS_VideoInfo * p, int64_t samples)\n        { return samples * avs_bytes_per_audio_sample(p); }\n\nAVSC_INLINE int avs_audio_channels(const AVS_VideoInfo * p)\n        { return p->nchannels; }\n\nAVSC_INLINE int avs_sample_type(const AVS_VideoInfo * p)\n        { return p->sample_type;}\n\n// useful mutator\n// Note: these are video format properties, neither frame properties, nor system properties\nAVSC_INLINE void avs_set_property(AVS_VideoInfo * p, int property)\n        { p->image_type|=property; }\n\nAVSC_INLINE void avs_clear_property(AVS_VideoInfo * p, int property)\n        { p->image_type&=~property; }\n\nAVSC_INLINE void avs_set_field_based(AVS_VideoInfo * p, int isfieldbased)\n        { if (isfieldbased) p->image_type|=AVS_IT_FIELDBASED; else p->image_type&=~AVS_IT_FIELDBASED; }\n\nAVSC_INLINE void avs_set_fps(AVS_VideoInfo * p, unsigned numerator, unsigned denominator)\n{\n    unsigned x=numerator, y=denominator;\n    while (y) {   // find gcd\n      unsigned t = x%y; x = y; y = t;\n    }\n    p->fps_numerator = numerator/x;\n    p->fps_denominator = denominator/x;\n}\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE int avs_is_same_colorspace(const AVS_VideoInfo * x, const AVS_VideoInfo * y)\n{\n        return (x->pixel_type == y->pixel_type)\n                || (avs_is_yv12(x) && avs_is_yv12(y));\n}\n#endif\n\n// AviSynth+ extensions\nAVSC_API(int, avs_is_rgb48)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_rgb64)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_yuv444p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv444\nAVSC_API(int, avs_is_yuv422p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv422\nAVSC_API(int, avs_is_yuv420p16)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv420\nAVSC_API(int, avs_is_y16)(const AVS_VideoInfo * p); // deprecated, use avs_is_y\nAVSC_API(int, avs_is_yuv444ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv444\nAVSC_API(int, avs_is_yuv422ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv422\nAVSC_API(int, avs_is_yuv420ps)(const AVS_VideoInfo * p); // deprecated, use avs_is_yuv420\nAVSC_API(int, avs_is_y32)(const AVS_VideoInfo * p); // deprecated, use avs_is_y\n\nAVSC_API(int, avs_is_444)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_422)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_420)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_y)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_yuva)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_planar_rgb)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_is_planar_rgba)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_num_components)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_component_size)(const AVS_VideoInfo * p);\n\nAVSC_API(int, avs_bits_per_component)(const AVS_VideoInfo * p);\n\n// V10\nAVSC_API(bool, avs_is_channel_mask_known)(const AVS_VideoInfo* p);\n\nAVSC_API(void, avs_set_channel_mask)(const AVS_VideoInfo* p, bool isChannelMaskKnown, unsigned int dwChannelMask);\n\nAVSC_API(unsigned int, avs_get_channel_mask)(const AVS_VideoInfo* p);\n\n// end of Avisynth+ specific\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_VideoFrame\n//\n\n// VideoFrameBuffer holds information about a memory block which is used\n// for video data.  For efficiency, instances of this class are not deleted\n// when the refcount reaches zero; instead they're stored in a linked list\n// to be reused.  The instances are deleted when the corresponding AVS\n// file is closed.\n\n// AVS_VideoFrameBuffer is laid out identically to VideoFrameBuffer\n// DO NOT USE THIS STRUCTURE DIRECTLY\ntypedef struct AVS_VideoFrameBuffer {\n  BYTE * data;\n  int data_size;\n  // sequence_number is incremented every time the buffer is changed, so\n  // that stale views can tell they're no longer valid.\n  volatile long sequence_number;\n\n  volatile long refcount;\n\n  void* device; // avs+\n} AVS_VideoFrameBuffer;\n\n// VideoFrame holds a \"window\" into a VideoFrameBuffer.\n\n// AVS_VideoFrame is laid out identically to VideoFrame\n// DO NOT USE THIS STRUCTURE DIRECTLY\ntypedef struct AVS_VideoFrame {\n  volatile long refcount;\n  AVS_VideoFrameBuffer * vfb;\n  int offset;\n  // DO NOT USE THEM DIRECTLY\n  // Use avs_get_pitch_p, avs_get_row_size_p, avs_get_height_p\n  int pitch, row_size, height;\n  int offsetU, offsetV;\n  int pitchUV;  // U&V offsets are from top of picture.\n  int row_sizeUV, heightUV; // for Planar RGB offsetU, offsetV is for the 2nd and 3rd Plane.\n                            // for Planar RGB pitchUV and row_sizeUV = 0, because when no VideoInfo (MakeWriteable)\n                            // the decision on existence of UV is checked by zero pitch\n  // AVS+ extension, avisynth.h: class does not break plugins if appended here\n  int offsetA;\n  int pitchA, row_sizeA; // 4th alpha plane support, pitch and row_size is 0 is none\n  void* properties; // interface V8: frame properties\n  // DO NOT USE DIRECTLY\n  // Use avs_video_frame_get_pixel_type (and avs_video_frame_amend_pixel_type in special cases)\n  int pixel_type; // Interface V10: an automatically maintained copy from AVS_VideoInfo\n} AVS_VideoFrame;\n\n// Access functions for AVS_VideoFrame\nAVSC_API(int, avs_get_pitch_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(int, avs_get_row_size_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(int, avs_get_height_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(const BYTE *, avs_get_read_ptr_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(int, avs_is_writable)(const AVS_VideoFrame * p);\n\n// V9\nAVSC_API(int, avs_is_property_writable)(const AVS_VideoFrame* p);\n\nAVSC_API(BYTE *, avs_get_write_ptr_p)(const AVS_VideoFrame * p, int plane);\n\nAVSC_API(void, avs_release_video_frame)(AVS_VideoFrame *);\n// makes a shallow copy of a video frame\nAVSC_API(AVS_VideoFrame *, avs_copy_video_frame)(AVS_VideoFrame *);\n\n// V10\nAVSC_API(int, avs_video_frame_get_pixel_type)(const AVS_VideoFrame* p);\n// V10\nAVSC_API(void, avs_video_frame_amend_pixel_type)(AVS_VideoFrame* p, int new_pixel_type);\n\n// no API for these, inline helper functions\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE int avs_get_pitch(const AVS_VideoFrame * p) {\n  return avs_get_pitch_p(p, 0);\n}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE int avs_get_row_size(const AVS_VideoFrame * p) {\n        return avs_get_row_size_p(p, 0); }\n#endif\n\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE int avs_get_height(const AVS_VideoFrame * p) {\n  return avs_get_height_p(p, 0);\n}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE const BYTE* avs_get_read_ptr(const AVS_VideoFrame * p) {\n        return avs_get_read_ptr_p(p, 0);}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE BYTE* avs_get_write_ptr(const AVS_VideoFrame * p) {\n        return avs_get_write_ptr_p(p, 0);}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE void avs_release_frame(AVS_VideoFrame * f)\n  {avs_release_video_frame(f);}\n#endif\n\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE AVS_VideoFrame * avs_copy_frame(AVS_VideoFrame * f)\n  {return avs_copy_video_frame(f);}\n#endif\n\n// Interface V8: frame properties\n// AVS_Map is just a placeholder for AVSMap\ntypedef struct AVS_Map {\n  void* data;\n} AVS_Map;\n\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_Value\n//\n\n// Treat AVS_Value as a fat pointer.  That is use avs_copy_value\n// and avs_release_value appropriately as you would if AVS_Value was\n// a pointer.\n\n// To maintain source code compatibility with future versions of the\n// avisynth_c API don't use the AVS_Value directly.  Use the helper\n// functions below.\n\n// AVS_Value is laid out identically to AVSValue\ntypedef struct AVS_Value AVS_Value;\nstruct AVS_Value {\n  short type;  // 'a'rray, 'c'lip, 'b'ool, 'i'nt, 'f'loat, 's'tring, 'v'oid, or 'l'ong, or fu'n'ction\n               // for some function e'rror\n  short array_size;\n  union {\n    void * clip; // do not use directly, use avs_take_clip\n    char boolean;\n    int integer;\n    float floating_pt;\n    const char * string;\n    const AVS_Value * array;\n    void * function; // not supported on C interface\n#ifdef X86_64\n    // if ever, only x64 will support. It breaks struct size on 32 bit\n    int64_t longlong; // 8 bytes\n    double double_pt; // 8 bytes\n#endif\n  } d;\n};\n\n// AVS_Value should be initialized with avs_void.\n// Should also set to avs_void after the value is released\n// with avs_copy_value.  Consider it the equivalent of setting\n// a pointer to NULL\nstatic const AVS_Value avs_void = {'v'};\n\nAVSC_API(void, avs_copy_value)(AVS_Value * dest, AVS_Value src);\nAVSC_API(void, avs_release_value)(AVS_Value);\nAVSC_API(AVS_Clip *, avs_take_clip)(AVS_Value, AVS_ScriptEnvironment *);\nAVSC_API(void, avs_set_to_clip)(AVS_Value *, AVS_Clip *);\n\n\n// no API for these, inline helper functions\nAVSC_INLINE int avs_defined(AVS_Value v) { return v.type != 'v'; }\nAVSC_INLINE int avs_is_clip(AVS_Value v) { return v.type == 'c'; }\nAVSC_INLINE int avs_is_bool(AVS_Value v) { return v.type == 'b'; }\nAVSC_INLINE int avs_is_int(AVS_Value v) { return v.type == 'i'; }\nAVSC_INLINE int avs_is_float(AVS_Value v) { return v.type == 'f' || v.type == 'i'; }\nAVSC_INLINE int avs_is_string(AVS_Value v) { return v.type == 's'; }\nAVSC_INLINE int avs_is_array(AVS_Value v) { return v.type == 'a'; }\nAVSC_INLINE int avs_is_error(AVS_Value v) { return v.type == 'e'; }\n\nAVSC_INLINE int avs_as_bool(AVS_Value v)\n        { return v.d.boolean; }\nAVSC_INLINE int avs_as_int(AVS_Value v)\n        { return v.d.integer; }\nAVSC_INLINE const char * avs_as_string(AVS_Value v)\n        { return avs_is_error(v) || avs_is_string(v) ? v.d.string : 0; }\nAVSC_INLINE double avs_as_float(AVS_Value v)\n        { return avs_is_int(v) ? v.d.integer : v.d.floating_pt; }\nAVSC_INLINE const char * avs_as_error(AVS_Value v)\n        { return avs_is_error(v) ? v.d.string : 0; }\nAVSC_INLINE const AVS_Value * avs_as_array(AVS_Value v)\n        { return v.d.array; }\nAVSC_INLINE int avs_array_size(AVS_Value v)\n        { return avs_is_array(v) ? v.array_size : 1; }\nAVSC_INLINE AVS_Value avs_array_elt(AVS_Value v, int index)\n        { return avs_is_array(v) ? v.d.array[index] : v; }\n\n// only use these functions on an AVS_Value that does not already have\n// an active value.  Remember, treat AVS_Value as a fat pointer.\nAVSC_INLINE AVS_Value avs_new_value_bool(int v0)\n        { AVS_Value v; v.type = 'b'; v.d.boolean = v0 == 0 ? 0 : 1; return v; }\nAVSC_INLINE AVS_Value avs_new_value_int(int v0)\n        { AVS_Value v; v.type = 'i'; v.d.integer = v0; return v; }\nAVSC_INLINE AVS_Value avs_new_value_string(const char * v0)\n        { AVS_Value v; v.type = 's'; v.d.string = v0; return v; }\nAVSC_INLINE AVS_Value avs_new_value_float(float v0)\n        { AVS_Value v; v.type = 'f'; v.d.floating_pt = v0; return v;}\nAVSC_INLINE AVS_Value avs_new_value_error(const char * v0)\n        { AVS_Value v; v.type = 'e'; v.d.string = v0; return v; }\n#ifndef AVSC_NO_DECLSPEC\n// this inline function is calling an API function\nAVSC_INLINE AVS_Value avs_new_value_clip(AVS_Clip * v0)\n        { AVS_Value v; avs_set_to_clip(&v, v0); return v; }\n#endif\nAVSC_INLINE AVS_Value avs_new_value_array(AVS_Value * v0, int size)\n        { AVS_Value v; v.type = 'a'; v.d.array = v0; v.array_size = (short)size; return v; }\n// end of inline helper functions\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_Clip\n//\n\nAVSC_API(void, avs_release_clip)(AVS_Clip *);\nAVSC_API(AVS_Clip *, avs_copy_clip)(AVS_Clip *);\n\nAVSC_API(const char *, avs_clip_get_error)(AVS_Clip *); // return 0 if no error\n\nAVSC_API(const AVS_VideoInfo *, avs_get_video_info)(AVS_Clip *);\n\nAVSC_API(int, avs_get_version)(AVS_Clip *);\n\nAVSC_API(AVS_VideoFrame *, avs_get_frame)(AVS_Clip *, int n);\n// The returned video frame must be released with avs_release_video_frame\n\nAVSC_API(int, avs_get_parity)(AVS_Clip *, int n);\n// return field parity if field_based, else parity of first field in frame\n\nAVSC_API(int, avs_get_audio)(AVS_Clip *, void * buf,\n                             int64_t start, int64_t count);\n// start and count are in samples\n\nAVSC_API(int, avs_set_cache_hints)(AVS_Clip *,\n                                   int cachehints, int frame_range);\n\n// This is the callback type used by avs_add_function\ntypedef AVS_Value (AVSC_CC * AVS_ApplyFunc)\n                        (AVS_ScriptEnvironment *, AVS_Value args, void * user_data);\n\ntypedef struct AVS_FilterInfo AVS_FilterInfo;\nstruct AVS_FilterInfo\n{\n  // these members should not be modified outside of the AVS_ApplyFunc callback\n  AVS_Clip * child;\n  AVS_VideoInfo vi;\n  AVS_ScriptEnvironment * env;\n  AVS_VideoFrame * (AVSC_CC * get_frame)(AVS_FilterInfo *, int n);\n  int (AVSC_CC * get_parity)(AVS_FilterInfo *, int n);\n  int (AVSC_CC * get_audio)(AVS_FilterInfo *, void * buf,\n                                  int64_t start, int64_t count);\n  int (AVSC_CC * set_cache_hints)(AVS_FilterInfo *, int cachehints,\n                                        int frame_range);\n  void (AVSC_CC * free_filter)(AVS_FilterInfo *);\n\n  // Should be set when ever there is an error to report.\n  // It is cleared before any of the above methods are called\n  const char * error;\n  // this is to store whatever and may be modified at will\n  void * user_data;\n};\n\n// Create a new filter\n// fi is set to point to the AVS_FilterInfo so that you can\n//   modify it once it is initialized.\n// store_child should generally be set to true.  If it is not\n//    set than ALL methods (the function pointers) must be defined\n// If it is set than you do not need to worry about freeing the child\n//    clip.\nAVSC_API(AVS_Clip *, avs_new_c_filter)(AVS_ScriptEnvironment * e,\n                                       AVS_FilterInfo * * fi,\n                                       AVS_Value child, int store_child);\n\n/////////////////////////////////////////////////////////////////////\n//\n// AVS_ScriptEnvironment\n//\n\n// For GetCPUFlags.  These are backwards-compatible with those in VirtualDub.\nenum {\n                                /* slowest CPU to support extension */\n  AVS_CPU_FORCE        = 0x01,   // N/A\n  AVS_CPU_FPU          = 0x02,   // 386/486DX\n  AVS_CPU_MMX          = 0x04,   // P55C, K6, PII\n  AVS_CPU_INTEGER_SSE  = 0x08,   // PIII, Athlon\n  AVS_CPU_SSE          = 0x10,   // PIII, Athlon XP/MP\n  AVS_CPU_SSE2         = 0x20,   // PIV, Hammer\n  AVS_CPU_3DNOW        = 0x40,   // K6-2\n  AVS_CPU_3DNOW_EXT    = 0x80,   // Athlon\n  AVS_CPU_X86_64       = 0xA0,   // Hammer (note: equiv. to 3DNow + SSE2,\n                                 // which only Hammer will have anyway)\n  AVS_CPUF_SSE3       = 0x100,   //  PIV+, K8 Venice\n  AVS_CPUF_SSSE3      = 0x200,   //  Core 2\n  AVS_CPUF_SSE4       = 0x400,   //  Penryn, Wolfdale, Yorkfield\n  AVS_CPUF_SSE4_1     = 0x400,\n  AVS_CPUF_AVX        = 0x800,   //  Sandy Bridge, Bulldozer\n  AVS_CPUF_SSE4_2    = 0x1000,   //  Nehalem\n  // AVS+\n  AVS_CPUF_AVX2      = 0x2000,   //  Haswell\n  AVS_CPUF_FMA3      = 0x4000,\n  AVS_CPUF_F16C      = 0x8000,\n  AVS_CPUF_MOVBE     = 0x10000,   // Big Endian Move\n  AVS_CPUF_POPCNT    = 0x20000,\n  AVS_CPUF_AES       = 0x40000,\n  AVS_CPUF_FMA4      = 0x80000,\n\n  AVS_CPUF_AVX512F    = 0x100000,  // AVX-512 Foundation.\n  AVS_CPUF_AVX512DQ   = 0x200000,  // AVX-512 DQ (Double/Quad granular) Instructions\n  AVS_CPUF_AVX512PF   = 0x400000,  // AVX-512 Prefetch\n  AVS_CPUF_AVX512ER   = 0x800000,  // AVX-512 Exponential and Reciprocal\n  AVS_CPUF_AVX512CD   = 0x1000000, // AVX-512 Conflict Detection\n  AVS_CPUF_AVX512BW   = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions\n  AVS_CPUF_AVX512VL   = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions\n  AVS_CPUF_AVX512IFMA = 0x8000000, // AVX-512 IFMA integer 52 bit\n  AVS_CPUF_AVX512VBMI = 0x10000000 // AVX-512 VBMI\n};\n\n\nAVSC_API(const char *, avs_get_error)(AVS_ScriptEnvironment *); // return 0 if no error\n\nAVSC_API(int, avs_get_cpu_flags)(AVS_ScriptEnvironment *);\nAVSC_API(int, avs_check_version)(AVS_ScriptEnvironment *, int version);\n\nAVSC_API(char *, avs_save_string)(AVS_ScriptEnvironment *, const char* s, int length);\nAVSC_API(char *, avs_sprintf)(AVS_ScriptEnvironment *, const char * fmt, ...);\n\nAVSC_API(char *, avs_vsprintf)(AVS_ScriptEnvironment *, const char * fmt, va_list val);\n\nAVSC_API(int, avs_add_function)(AVS_ScriptEnvironment *,\n                                const char * name, const char * params,\n                                AVS_ApplyFunc apply, void * user_data);\n\nAVSC_API(int, avs_function_exists)(AVS_ScriptEnvironment *, const char * name);\n\nAVSC_API(AVS_Value, avs_invoke)(AVS_ScriptEnvironment *, const char * name,\n                               AVS_Value args, const char** arg_names);\n// The returned value must be be released with avs_release_value\n\nAVSC_API(AVS_Value, avs_get_var)(AVS_ScriptEnvironment *, const char* name);\n// The returned value must be be released with avs_release_value\n\nAVSC_API(int, avs_set_var)(AVS_ScriptEnvironment *, const char* name, AVS_Value val);\n\nAVSC_API(int, avs_set_global_var)(AVS_ScriptEnvironment *, const char* name, const AVS_Value val);\n\n//void avs_push_context(AVS_ScriptEnvironment *, int level=0);\n//void avs_pop_context(AVS_ScriptEnvironment *);\n\n// partially deprecated, from V8 use avs_new_video_frame_p_a (frame property copy)\nAVSC_API(AVS_VideoFrame *, avs_new_video_frame_a)(AVS_ScriptEnvironment *,\n                                          const AVS_VideoInfo * vi, int align);\n// align should be at least 16 for classic Avisynth\n// Avisynth+: any value, Avs+ ensures a minimum alignment if too small align is provided\n\n// no API for these, inline helper functions\n#ifndef AVSC_NO_DECLSPEC\n// partially deprecated, from V8 use avs_new_video_frame_p (frame property copy)\n// this inline function is calling an API function\nAVSC_INLINE AVS_VideoFrame * avs_new_video_frame(AVS_ScriptEnvironment * env,\n                                     const AVS_VideoInfo * vi)\n  {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}\n\n// an older compatibility alias\n// this inline function is calling an API function\nAVSC_INLINE AVS_VideoFrame * avs_new_frame(AVS_ScriptEnvironment * env,\n                               const AVS_VideoInfo * vi)\n  {return avs_new_video_frame_a(env,vi,AVS_FRAME_ALIGN);}\n#endif\n// end of inline helper functions\n\nAVSC_API(int, avs_make_writable)(AVS_ScriptEnvironment *, AVS_VideoFrame * * pvf);\n\n// V9\nAVSC_API(int, avs_make_property_writable)(AVS_ScriptEnvironment*, AVS_VideoFrame** pvf);\n\nAVSC_API(void, avs_bit_blt)(AVS_ScriptEnvironment *, BYTE* dstp, int dst_pitch, const BYTE* srcp, int src_pitch, int row_size, int height);\n\ntypedef void (AVSC_CC *AVS_ShutdownFunc)(void* user_data, AVS_ScriptEnvironment * env);\nAVSC_API(void, avs_at_exit)(AVS_ScriptEnvironment *, AVS_ShutdownFunc function, void * user_data);\n\nAVSC_API(AVS_VideoFrame *, avs_subframe)(AVS_ScriptEnvironment *, AVS_VideoFrame * src, int rel_offset, int new_pitch, int new_row_size, int new_height);\n// The returned video frame must be be released\nAVSC_API(AVS_VideoFrame*, avs_subframe_planar)(AVS_ScriptEnvironment*, AVS_VideoFrame* src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV);\n// The returned video frame must be be released\n// see also avs_subframe_planar_a in interface V8\n\nAVSC_API(int, avs_set_memory_max)(AVS_ScriptEnvironment *, int mem);\n\nAVSC_API(int, avs_set_working_dir)(AVS_ScriptEnvironment *, const char * newdir);\n\n// avisynth.dll exports this; it's a way to use it as a library, without\n// writing an AVS script or without going through AVIFile.\nAVSC_API(AVS_ScriptEnvironment *, avs_create_script_environment)(int version);\n\n// this symbol is the entry point for the plugin and must\n// be defined\nAVSC_EXPORT\nconst char * AVSC_CC avisynth_c_plugin_init(AVS_ScriptEnvironment* env);\n\n\nAVSC_API(void, avs_delete_script_environment)(AVS_ScriptEnvironment *);\n\n///////////////////////////////////////////////////////////////////////////////\n//\n// Avisynth+ V8 interface elements\n//\n\nAVSC_API(AVS_VideoFrame*, avs_subframe_planar_a)(AVS_ScriptEnvironment*, AVS_VideoFrame* src, int rel_offset, int new_pitch, int new_row_size, int new_height, int rel_offsetU, int rel_offsetV, int new_pitchUV, int rel_offsetA);\n// The returned video frame must be be released\n\nAVSC_API(void, avs_copy_frame_props)(AVS_ScriptEnvironment* p, const AVS_VideoFrame* src, AVS_VideoFrame* dst);\nAVSC_API(const AVS_Map*, avs_get_frame_props_ro)(AVS_ScriptEnvironment* p, const AVS_VideoFrame* frame);\nAVSC_API(AVS_Map*, avs_get_frame_props_rw)(AVS_ScriptEnvironment* p, AVS_VideoFrame* frame);\nAVSC_API(int, avs_prop_num_keys)(AVS_ScriptEnvironment* p, const AVS_Map* map);\nAVSC_API(const char*, avs_prop_get_key)(AVS_ScriptEnvironment* p, const AVS_Map* map, int index);\nAVSC_API(int, avs_prop_num_elements)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key);\n\n// see AVS_PROPTYPE_... enums\nAVSC_API(char, avs_prop_get_type)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key);\n\n// see AVS_GETPROPERROR_... enums\nAVSC_API(int64_t, avs_prop_get_int)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\nAVSC_API(double, avs_prop_get_float)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\n// Note: avs_prop_get_data was fixed in interface V9.1\nAVSC_API(const char*, avs_prop_get_data)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\nAVSC_API(int, avs_prop_get_data_size)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\nAVSC_API(AVS_Clip*, avs_prop_get_clip)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\nAVSC_API(const AVS_VideoFrame*, avs_prop_get_frame)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int index, int* error);\n\nAVSC_API(int, avs_prop_delete_key)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key);\n\n// see AVS_PROPAPPENDMODE_... enums\nAVSC_API(int, avs_prop_set_int)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, int64_t i, int append);\nAVSC_API(int, avs_prop_set_float)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, double d, int append);\nAVSC_API(int, avs_prop_set_data)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const char* d, int length, int append);\nAVSC_API(int, avs_prop_set_clip)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, AVS_Clip* clip, int append);\nAVSC_API(int, avs_prop_set_frame)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const AVS_VideoFrame* frame, int append);\n\nAVSC_API(const int64_t*, avs_prop_get_int_array)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int* error);\nAVSC_API(const double*, avs_prop_get_float_array)(AVS_ScriptEnvironment* p, const AVS_Map* map, const char* key, int* error);\nAVSC_API(int, avs_prop_set_int_array)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const int64_t* i, int size);\nAVSC_API(int, avs_prop_set_float_array)(AVS_ScriptEnvironment* p, AVS_Map* map, const char* key, const double* d, int size);\n\nAVSC_API(void, avs_clear_map)(AVS_ScriptEnvironment* p, AVS_Map* map);\n\n// with frame property source\nAVSC_API(AVS_VideoFrame*, avs_new_video_frame_p)(AVS_ScriptEnvironment*,\n  const AVS_VideoInfo* vi, const AVS_VideoFrame* prop_src);\n\n// with frame property source\nAVSC_API(AVS_VideoFrame*, avs_new_video_frame_p_a)(AVS_ScriptEnvironment*,\n  const AVS_VideoInfo* vi, const AVS_VideoFrame* prop_src, int align);\n\n// Generic query to ask for various system properties, see AVS_AEP_xxx enums\nAVSC_API(size_t, avs_get_env_property)(AVS_ScriptEnvironment*, int avs_aep_prop);\n\n// buffer pool, see AVS_ALLOCTYPE enums\nAVSC_API(void *, avs_pool_allocate)(AVS_ScriptEnvironment*, size_t nBytes, size_t alignment, int avs_alloc_type);\nAVSC_API(void, avs_pool_free)(AVS_ScriptEnvironment*, void *ptr);\n\n// Interface V8\n// Returns TRUE (1) and the requested variable. If the method fails, returns 0 (FALSE) and does not touch 'val'.\n// The returned AVS_Value *val value must be be released with avs_release_value only on success\n// AVS_Value *val is not caller allocated\nAVSC_API(int, avs_get_var_try)(AVS_ScriptEnvironment*, const char* name, AVS_Value* val);\n\n// Interface V8\n// Return the value of the requested variable.\n// If the variable was not found or had the wrong type,\n// return the supplied default value.\nAVSC_API(int, avs_get_var_bool)(AVS_ScriptEnvironment*, const char* name, int def);\nAVSC_API(int, avs_get_var_int)(AVS_ScriptEnvironment*, const char* name, int def);\nAVSC_API(double, avs_get_var_double)(AVS_ScriptEnvironment*, const char* name, double def);\nAVSC_API(const char*, avs_get_var_string)(AVS_ScriptEnvironment*, const char* name, const char* def);\nAVSC_API(int64_t, avs_get_var_long)(AVS_ScriptEnvironment*, const char* name, int64_t def);\n\n#if defined(AVS_WINDOWS)\n// The following stuff is only relevant for Windows DLL handling; Linux does it completely differently.\n#ifdef AVSC_NO_DECLSPEC\n// This part uses LoadLibrary and related functions to dynamically load Avisynth instead of declspec(dllimport)\n// When AVSC_NO_DECLSPEC is defined, you can use avs_load_library to populate API functions into a struct\n// AVSC_INLINE functions which call onto an API functions should be treated specially (todo)\n\n/*\n  The following functions needs to have been declared, probably from windows.h\n\n  void* malloc(size_t)\n  void free(void*);\n\n  HMODULE LoadLibraryA(const char*);\n  void* GetProcAddress(HMODULE, const char*);\n  FreeLibrary(HMODULE);\n*/\n\n\ntypedef struct AVS_Library AVS_Library;\n\n#define AVSC_DECLARE_FUNC(name) name##_func name\n\n// AVSC_DECLARE_FUNC helps keeping naming convention: type is xxxxx_func, function name is xxxxx\n// e.g. \"AVSC_DECLARE_FUNC(avs_add_function);\"\n// is a shortcut for \"avs_add_function_func avs_add_function;\"\n\n// Note: AVSC_INLINE functions, which call into API,\n// are guarded by #ifndef AVSC_NO_DECLSPEC.\n// They should call the appropriate library-> API entry.\n\nstruct AVS_Library {\n  HMODULE handle;\n\n  AVSC_DECLARE_FUNC(avs_add_function);\n  AVSC_DECLARE_FUNC(avs_at_exit);\n  AVSC_DECLARE_FUNC(avs_bit_blt);\n  AVSC_DECLARE_FUNC(avs_check_version);\n  AVSC_DECLARE_FUNC(avs_clip_get_error);\n  AVSC_DECLARE_FUNC(avs_copy_clip);\n  AVSC_DECLARE_FUNC(avs_copy_value);\n  AVSC_DECLARE_FUNC(avs_copy_video_frame);\n  AVSC_DECLARE_FUNC(avs_create_script_environment);\n  AVSC_DECLARE_FUNC(avs_delete_script_environment);\n  AVSC_DECLARE_FUNC(avs_function_exists);\n  AVSC_DECLARE_FUNC(avs_get_audio);\n  AVSC_DECLARE_FUNC(avs_get_cpu_flags);\n  AVSC_DECLARE_FUNC(avs_get_frame);\n  AVSC_DECLARE_FUNC(avs_get_parity);\n  AVSC_DECLARE_FUNC(avs_get_var);\n  AVSC_DECLARE_FUNC(avs_get_version);\n  AVSC_DECLARE_FUNC(avs_get_video_info);\n  AVSC_DECLARE_FUNC(avs_invoke);\n  AVSC_DECLARE_FUNC(avs_make_writable);\n  AVSC_DECLARE_FUNC(avs_new_c_filter);\n  AVSC_DECLARE_FUNC(avs_new_video_frame_a);\n  AVSC_DECLARE_FUNC(avs_release_clip);\n  AVSC_DECLARE_FUNC(avs_release_value);\n  AVSC_DECLARE_FUNC(avs_release_video_frame);\n  AVSC_DECLARE_FUNC(avs_save_string);\n  AVSC_DECLARE_FUNC(avs_set_cache_hints);\n  AVSC_DECLARE_FUNC(avs_set_global_var);\n  AVSC_DECLARE_FUNC(avs_set_memory_max);\n  AVSC_DECLARE_FUNC(avs_set_to_clip);\n  AVSC_DECLARE_FUNC(avs_set_var);\n  AVSC_DECLARE_FUNC(avs_set_working_dir);\n  AVSC_DECLARE_FUNC(avs_sprintf);\n  AVSC_DECLARE_FUNC(avs_subframe);\n  AVSC_DECLARE_FUNC(avs_subframe_planar);\n  AVSC_DECLARE_FUNC(avs_take_clip);\n  AVSC_DECLARE_FUNC(avs_vsprintf);\n\n  AVSC_DECLARE_FUNC(avs_get_error);\n  AVSC_DECLARE_FUNC(avs_is_yv24);\n  AVSC_DECLARE_FUNC(avs_is_yv16);\n  AVSC_DECLARE_FUNC(avs_is_yv12);\n  AVSC_DECLARE_FUNC(avs_is_yv411);\n  AVSC_DECLARE_FUNC(avs_is_y8);\n  AVSC_DECLARE_FUNC(avs_is_color_space);\n\n  AVSC_DECLARE_FUNC(avs_get_plane_width_subsampling);\n  AVSC_DECLARE_FUNC(avs_get_plane_height_subsampling);\n  AVSC_DECLARE_FUNC(avs_bits_per_pixel);\n  AVSC_DECLARE_FUNC(avs_bytes_from_pixels);\n  AVSC_DECLARE_FUNC(avs_row_size);\n  AVSC_DECLARE_FUNC(avs_bmp_size);\n  AVSC_DECLARE_FUNC(avs_get_pitch_p);\n  AVSC_DECLARE_FUNC(avs_get_row_size_p);\n  AVSC_DECLARE_FUNC(avs_get_height_p);\n  AVSC_DECLARE_FUNC(avs_get_read_ptr_p);\n  AVSC_DECLARE_FUNC(avs_is_writable);\n  AVSC_DECLARE_FUNC(avs_get_write_ptr_p);\n\n  // Avisynth+ specific\n  // Note: these functions are simulated/use fallback to existing functions\n  AVSC_DECLARE_FUNC(avs_is_rgb48);\n  AVSC_DECLARE_FUNC(avs_is_rgb64);\n  AVSC_DECLARE_FUNC(avs_is_yuv444p16);\n  AVSC_DECLARE_FUNC(avs_is_yuv422p16);\n  AVSC_DECLARE_FUNC(avs_is_yuv420p16);\n  AVSC_DECLARE_FUNC(avs_is_y16);\n  AVSC_DECLARE_FUNC(avs_is_yuv444ps);\n  AVSC_DECLARE_FUNC(avs_is_yuv422ps);\n  AVSC_DECLARE_FUNC(avs_is_yuv420ps);\n  AVSC_DECLARE_FUNC(avs_is_y32);\n  AVSC_DECLARE_FUNC(avs_is_444);\n  AVSC_DECLARE_FUNC(avs_is_422);\n  AVSC_DECLARE_FUNC(avs_is_420);\n  AVSC_DECLARE_FUNC(avs_is_y);\n  AVSC_DECLARE_FUNC(avs_is_yuva);\n  AVSC_DECLARE_FUNC(avs_is_planar_rgb);\n  AVSC_DECLARE_FUNC(avs_is_planar_rgba);\n  AVSC_DECLARE_FUNC(avs_num_components);\n  AVSC_DECLARE_FUNC(avs_component_size);\n  AVSC_DECLARE_FUNC(avs_bits_per_component);\n\n  ///////////////////////////////////////////////////////////////////////////////\n  // Avisynth+ new interface elements from interface version 8\n  // avs_subframe_planar with alpha support\n  AVSC_DECLARE_FUNC(avs_subframe_planar_a);\n\n  // frame properties\n  AVSC_DECLARE_FUNC(avs_copy_frame_props);\n  AVSC_DECLARE_FUNC(avs_get_frame_props_ro);\n  AVSC_DECLARE_FUNC(avs_get_frame_props_rw);\n  AVSC_DECLARE_FUNC(avs_prop_num_keys);\n  AVSC_DECLARE_FUNC(avs_prop_get_key);\n  AVSC_DECLARE_FUNC(avs_prop_num_elements);\n  AVSC_DECLARE_FUNC(avs_prop_get_type);\n  AVSC_DECLARE_FUNC(avs_prop_get_int);\n  AVSC_DECLARE_FUNC(avs_prop_get_float);\n  AVSC_DECLARE_FUNC(avs_prop_get_data);\n  AVSC_DECLARE_FUNC(avs_prop_get_data_size);\n  AVSC_DECLARE_FUNC(avs_prop_get_clip);\n  AVSC_DECLARE_FUNC(avs_prop_get_frame);\n  AVSC_DECLARE_FUNC(avs_prop_delete_key);\n  AVSC_DECLARE_FUNC(avs_prop_set_int);\n  AVSC_DECLARE_FUNC(avs_prop_set_float);\n  AVSC_DECLARE_FUNC(avs_prop_set_data);\n  AVSC_DECLARE_FUNC(avs_prop_set_clip);\n  AVSC_DECLARE_FUNC(avs_prop_set_frame);\n\n  AVSC_DECLARE_FUNC(avs_prop_get_int_array);\n  AVSC_DECLARE_FUNC(avs_prop_get_float_array);\n  AVSC_DECLARE_FUNC(avs_prop_set_int_array);\n  AVSC_DECLARE_FUNC(avs_prop_set_float_array);\n\n  AVSC_DECLARE_FUNC(avs_clear_map);\n\n  // NewVideoFrame with frame properties\n  AVSC_DECLARE_FUNC(avs_new_video_frame_p);\n  AVSC_DECLARE_FUNC(avs_new_video_frame_p_a);\n\n  AVSC_DECLARE_FUNC(avs_get_env_property);\n\n  AVSC_DECLARE_FUNC(avs_get_var_try);\n  AVSC_DECLARE_FUNC(avs_get_var_bool);\n  AVSC_DECLARE_FUNC(avs_get_var_int);\n  AVSC_DECLARE_FUNC(avs_get_var_double);\n  AVSC_DECLARE_FUNC(avs_get_var_string);\n  AVSC_DECLARE_FUNC(avs_get_var_long);\n\n  AVSC_DECLARE_FUNC(avs_pool_allocate);\n  AVSC_DECLARE_FUNC(avs_pool_free);\n\n  // V9\n  AVSC_DECLARE_FUNC(avs_is_property_writable);\n  AVSC_DECLARE_FUNC(avs_make_property_writable);\n\n  // V10\n  AVSC_DECLARE_FUNC(avs_video_frame_get_pixel_type);\n  AVSC_DECLARE_FUNC(avs_video_frame_amend_pixel_type);\n\n  // V10\n  AVSC_DECLARE_FUNC(avs_is_channel_mask_known);\n  AVSC_DECLARE_FUNC(avs_set_channel_mask);\n  AVSC_DECLARE_FUNC(avs_get_channel_mask);\n\n};\n\n#undef AVSC_DECLARE_FUNC\n\n#ifdef AVS26_FALLBACK_SIMULATION\n// Helper functions for fallback simulation\n// Avisynth+ extensions do not exist in classic Avisynth so they are simulated\nAVSC_INLINE int avs_is_xx_fallback_return_false(const AVS_VideoInfo * p)\n{\n  return 0;\n}\n\n// Avisynth+ extensions do not exist in classic Avisynth so they are simulated\nAVSC_INLINE int avs_num_components_fallback(const AVS_VideoInfo * p)\n{\n  switch (p->pixel_type) {\n  case AVS_CS_UNKNOWN:\n    return 0;\n  case AVS_CS_RAW32:\n  case AVS_CS_Y8:\n    return 1;\n  case AVS_CS_BGR32:\n    return 4; // not planar but return the count\n  default:\n    return 3;\n  }\n}\n\n// Avisynth+ extensions do not exist in classic Avisynth so they are simulated\nAVSC_INLINE int avs_component_size_fallback(const AVS_VideoInfo * p)\n{\n  return 1;\n}\n\n// Avisynth+ extensions do not exist in classic Avisynth so they are simulated\nAVSC_INLINE int avs_bits_per_component_fallback(const AVS_VideoInfo * p)\n{\n  return 8;\n}\n// End of helper functions for fallback simulation\n#endif // AVS26_FALLBACK_SIMULATION\n\n// avs_load_library() allocates an array for API procedure entries\n// reads and fills the entries with live procedure addresses.\n// AVSC_INLINE helpers which are calling into API procedures are not treated here (todo)\n\nAVSC_INLINE AVS_Library * avs_load_library() {\n  AVS_Library *library = (AVS_Library *)malloc(sizeof(AVS_Library));\n  if (library == NULL)\n    return NULL;\n  library->handle = LoadLibraryA(\"avisynth\");\n  if (library->handle == NULL)\n    goto fail;\n\n#define __AVSC_STRINGIFY(x) #x\n#define AVSC_STRINGIFY(x) __AVSC_STRINGIFY(x)\n#define AVSC_LOAD_FUNC(name) {\\\n  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\\\n  if (library->name == NULL)\\\n    goto fail;\\\n}\n\n#ifdef AVS26_FALLBACK_SIMULATION\n// When an API function is not loadable, let's try a replacement\n// Missing Avisynth+ functions will be substituted with classic Avisynth compatible methods\n/*\nAvisynth+                 When method is missing (classic Avisynth)\navs_is_rgb48              constant false\navs_is_rgb64              constant false\navs_is_444                avs_is_yv24\navs_is_422                avs_is_yv16\navs_is_420                avs_is_yv12\navs_is_y                  avs_is_y8\navs_is_yuva               constant false\navs_is_planar_rgb         constant false\navs_is_planar_rgba        constant false\navs_num_components        special: avs_num_components_fake Y8:1 RGB32:4 else 3\navs_component_size        constant 1 (1 bytes/component)\navs_bits_per_component    constant 8 (8 bits/component)\n*/\n\n  // try to load an alternative function\n#define AVSC_LOAD_FUNC_FALLBACK(name,name2) {\\\n  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\\\n  if (library->name == NULL)\\\n    library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name2));\\\n  if (library->name == NULL)\\\n    goto fail;\\\n}\n\n  // try to assign a replacement function\n#define AVSC_LOAD_FUNC_FALLBACK_SIMULATED(name,name2) {\\\n  library->name = (name##_func) GetProcAddress(library->handle, AVSC_STRINGIFY(name));\\\n  if (library->name == NULL)\\\n    library->name = name2;\\\n  if (library->name == NULL)\\\n    goto fail;\\\n}\n#endif // AVS26_FALLBACK_SIMULATION\n\n  AVSC_LOAD_FUNC(avs_add_function);\n  AVSC_LOAD_FUNC(avs_at_exit);\n  AVSC_LOAD_FUNC(avs_bit_blt);\n  AVSC_LOAD_FUNC(avs_check_version);\n  AVSC_LOAD_FUNC(avs_clip_get_error);\n  AVSC_LOAD_FUNC(avs_copy_clip);\n  AVSC_LOAD_FUNC(avs_copy_value);\n  AVSC_LOAD_FUNC(avs_copy_video_frame);\n  AVSC_LOAD_FUNC(avs_create_script_environment);\n  AVSC_LOAD_FUNC(avs_delete_script_environment);\n  AVSC_LOAD_FUNC(avs_function_exists);\n  AVSC_LOAD_FUNC(avs_get_audio);\n  AVSC_LOAD_FUNC(avs_get_cpu_flags);\n  AVSC_LOAD_FUNC(avs_get_frame);\n  AVSC_LOAD_FUNC(avs_get_parity);\n  AVSC_LOAD_FUNC(avs_get_var);\n  AVSC_LOAD_FUNC(avs_get_version);\n  AVSC_LOAD_FUNC(avs_get_video_info);\n  AVSC_LOAD_FUNC(avs_invoke);\n  AVSC_LOAD_FUNC(avs_make_writable);\n  AVSC_LOAD_FUNC(avs_new_c_filter);\n  AVSC_LOAD_FUNC(avs_new_video_frame_a);\n\n\n\n  AVSC_LOAD_FUNC(avs_release_clip);\n  AVSC_LOAD_FUNC(avs_release_value);\n  AVSC_LOAD_FUNC(avs_release_video_frame);\n  AVSC_LOAD_FUNC(avs_save_string);\n  AVSC_LOAD_FUNC(avs_set_cache_hints);\n  AVSC_LOAD_FUNC(avs_set_global_var);\n  AVSC_LOAD_FUNC(avs_set_memory_max);\n  AVSC_LOAD_FUNC(avs_set_to_clip);\n  AVSC_LOAD_FUNC(avs_set_var);\n  AVSC_LOAD_FUNC(avs_set_working_dir);\n  AVSC_LOAD_FUNC(avs_sprintf);\n  AVSC_LOAD_FUNC(avs_subframe);\n  AVSC_LOAD_FUNC(avs_subframe_planar);\n  AVSC_LOAD_FUNC(avs_take_clip);\n  AVSC_LOAD_FUNC(avs_vsprintf);\n\n  AVSC_LOAD_FUNC(avs_get_error);\n  AVSC_LOAD_FUNC(avs_is_yv24);\n  AVSC_LOAD_FUNC(avs_is_yv16);\n  AVSC_LOAD_FUNC(avs_is_yv12);\n  AVSC_LOAD_FUNC(avs_is_yv411);\n  AVSC_LOAD_FUNC(avs_is_y8);\n  AVSC_LOAD_FUNC(avs_is_color_space);\n\n  AVSC_LOAD_FUNC(avs_get_plane_width_subsampling);\n  AVSC_LOAD_FUNC(avs_get_plane_height_subsampling);\n  AVSC_LOAD_FUNC(avs_bits_per_pixel);\n  AVSC_LOAD_FUNC(avs_bytes_from_pixels);\n  AVSC_LOAD_FUNC(avs_row_size);\n  AVSC_LOAD_FUNC(avs_bmp_size);\n  AVSC_LOAD_FUNC(avs_get_pitch_p);\n  AVSC_LOAD_FUNC(avs_get_row_size_p);\n  AVSC_LOAD_FUNC(avs_get_height_p);\n  AVSC_LOAD_FUNC(avs_get_read_ptr_p);\n  AVSC_LOAD_FUNC(avs_is_writable);\n  AVSC_LOAD_FUNC(avs_get_write_ptr_p);\n\n  // Avisynth+ specific\n#ifdef AVS26_FALLBACK_SIMULATION\n  // replace with fallback fn when does not exist\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb48, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_rgb64, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK(avs_is_444, avs_is_yv24);\n  AVSC_LOAD_FUNC_FALLBACK(avs_is_422, avs_is_yv16);\n  AVSC_LOAD_FUNC_FALLBACK(avs_is_420, avs_is_yv12);\n  AVSC_LOAD_FUNC_FALLBACK(avs_is_y, avs_is_y8);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_yuva, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgb, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_is_planar_rgba, avs_is_xx_fallback_return_false);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_num_components, avs_num_components_fallback);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_component_size, avs_component_size_fallback);\n  AVSC_LOAD_FUNC_FALLBACK_SIMULATED(avs_bits_per_component, avs_bits_per_component_fallback);\n#else\n  // Avisynth+ specific\n  AVSC_LOAD_FUNC(avs_is_rgb48);\n  AVSC_LOAD_FUNC(avs_is_rgb64);\n  AVSC_LOAD_FUNC(avs_is_444);\n  AVSC_LOAD_FUNC(avs_is_422);\n  AVSC_LOAD_FUNC(avs_is_420);\n  AVSC_LOAD_FUNC(avs_is_y);\n  AVSC_LOAD_FUNC(avs_is_yuva);\n  AVSC_LOAD_FUNC(avs_is_planar_rgb);\n  AVSC_LOAD_FUNC(avs_is_planar_rgba);\n  AVSC_LOAD_FUNC(avs_num_components);\n  AVSC_LOAD_FUNC(avs_component_size);\n  AVSC_LOAD_FUNC(avs_bits_per_component);\n#endif\n  // Avisynth+ interface V8, no backward compatible simulation\n  AVSC_LOAD_FUNC(avs_subframe_planar_a);\n  // frame properties\n  AVSC_LOAD_FUNC(avs_copy_frame_props);\n  AVSC_LOAD_FUNC(avs_get_frame_props_ro);\n  AVSC_LOAD_FUNC(avs_get_frame_props_rw);\n  AVSC_LOAD_FUNC(avs_prop_num_keys);\n  AVSC_LOAD_FUNC(avs_prop_get_key);\n  AVSC_LOAD_FUNC(avs_prop_num_elements);\n  AVSC_LOAD_FUNC(avs_prop_get_type);\n  AVSC_LOAD_FUNC(avs_prop_get_int);\n  AVSC_LOAD_FUNC(avs_prop_get_float);\n  AVSC_LOAD_FUNC(avs_prop_get_data);\n  AVSC_LOAD_FUNC(avs_prop_get_data_size);\n  AVSC_LOAD_FUNC(avs_prop_get_clip);\n  AVSC_LOAD_FUNC(avs_prop_get_frame);\n  AVSC_LOAD_FUNC(avs_prop_delete_key);\n  AVSC_LOAD_FUNC(avs_prop_set_int);\n  AVSC_LOAD_FUNC(avs_prop_set_float);\n  AVSC_LOAD_FUNC(avs_prop_set_data);\n  AVSC_LOAD_FUNC(avs_prop_set_clip);\n  AVSC_LOAD_FUNC(avs_prop_set_frame);\n\n  AVSC_LOAD_FUNC(avs_prop_get_int_array);\n  AVSC_LOAD_FUNC(avs_prop_get_float_array);\n  AVSC_LOAD_FUNC(avs_prop_set_int_array);\n  AVSC_LOAD_FUNC(avs_prop_set_float_array);\n\n  AVSC_LOAD_FUNC(avs_clear_map);\n\n  // NewVideoFrame with frame properties\n  AVSC_LOAD_FUNC(avs_new_video_frame_p);\n  AVSC_LOAD_FUNC(avs_new_video_frame_p_a);\n\n  AVSC_LOAD_FUNC(avs_get_env_property);\n\n  AVSC_LOAD_FUNC(avs_get_var_try);\n  AVSC_LOAD_FUNC(avs_get_var_bool);\n  AVSC_LOAD_FUNC(avs_get_var_int);\n  AVSC_LOAD_FUNC(avs_get_var_double);\n  AVSC_LOAD_FUNC(avs_get_var_string);\n  AVSC_LOAD_FUNC(avs_get_var_long);\n\n  AVSC_LOAD_FUNC(avs_pool_allocate);\n  AVSC_LOAD_FUNC(avs_pool_free);\n\n  // V9\n  AVSC_LOAD_FUNC(avs_make_property_writable);\n  AVSC_LOAD_FUNC(avs_is_property_writable);\n\n  // V10\n  AVSC_LOAD_FUNC(avs_video_frame_get_pixel_type);\n  AVSC_LOAD_FUNC(avs_video_frame_amend_pixel_type);\n\n  // V10\n  AVSC_LOAD_FUNC(avs_is_channel_mask_known);\n  AVSC_LOAD_FUNC(avs_set_channel_mask);\n  AVSC_LOAD_FUNC(avs_get_channel_mask);\n\n#undef __AVSC_STRINGIFY\n#undef AVSC_STRINGIFY\n#undef AVSC_LOAD_FUNC\n#undef AVSC_LOAD_FUNC_FALLBACK\n#undef AVSC_LOAD_FUNC_FALLBACK_SIMULATED\n\n  return library;\n\nfail:\n  free(library);\n  return NULL;\n}\n\nAVSC_INLINE void avs_free_library(AVS_Library *library) {\n  if (library == NULL)\n    return;\n  FreeLibrary(library->handle);\n  free(library);\n}\n#endif\n\n#endif // AVS_WINDOWS\n\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/alignment.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n#ifndef AVS_ALIGNMENT_H\n#define AVS_ALIGNMENT_H\n\n// Functions and macros to help work with alignment requirements.\n\n// Tells if a number is a power of two.\n#define IS_POWER2(n) ((n) && !((n) & ((n) - 1)))\n\n// Tells if the pointer \"ptr\" is aligned to \"align\" bytes.\n#define IS_PTR_ALIGNED(ptr, align) (((uintptr_t)ptr & ((uintptr_t)(align-1))) == 0)\n\n// Rounds up the number \"n\" to the next greater multiple of \"align\"\n#define ALIGN_NUMBER(n, align) (((n) + (align)-1) & (~((align)-1)))\n\n// Rounds up the pointer address \"ptr\" to the next greater multiple of \"align\"\n#define ALIGN_POINTER(ptr, align) (((uintptr_t)(ptr) + (align)-1) & (~(uintptr_t)((align)-1)))\n\n#ifdef __cplusplus\n\n#include <cassert>\n#include <cstdlib>\n#include <cstdint>\n#include \"config.h\"\n\n#if defined(MSVC) && _MSC_VER<1400\n    // needed for VS2013, otherwise C++11 'alignas' works\n    #define avs_alignas(x) __declspec(align(x))\n#else\n    // assumes C++11 support\n    #define avs_alignas(x) alignas(x)\n#endif\n\ntemplate<typename T>\nstatic bool IsPtrAligned(T* ptr, size_t align)\n{\n  assert(IS_POWER2(align));\n  return (bool)IS_PTR_ALIGNED(ptr, align);\n}\n\ntemplate<typename T>\nstatic T AlignNumber(T n, T align)\n{\n  assert(IS_POWER2(align));\n  return ALIGN_NUMBER(n, align);\n}\n\ntemplate<typename T>\nstatic T* AlignPointer(T* ptr, size_t align)\n{\n  assert(IS_POWER2(align));\n  return (T*)ALIGN_POINTER(ptr, align);\n}\n\nextern \"C\"\n{\n#else\n#include <stdlib.h>\n#endif  // __cplusplus\n\n// Returns a new buffer that is at least the size \"nbytes\".\n// The buffer will be aligned to \"align\" bytes.\n// Returns NULL on error. On successful allocation,\n// the returned buffer must be freed using \"avs_free\".\ninline void* avs_malloc(size_t nbytes, size_t align)\n{\n  if (!IS_POWER2(align))\n    return NULL;\n\n  size_t offset = sizeof(void*) + align - 1;\n\n  void *orig = malloc(nbytes + offset);\n  if (orig == NULL)\n   return NULL;\n\n  void **aligned = (void**)(((uintptr_t)orig + (uintptr_t)offset) & (~(uintptr_t)(align-1)));\n  aligned[-1] = orig;\n  return aligned;\n}\n\n// Buffers allocated using \"avs_malloc\" must be freed\n// using \"avs_free\" instead of \"free\".\ninline void avs_free(void *ptr)\n{\n  // Mirroring free()'s semantic requires us to accept NULLs\n  if (ptr == NULL)\n    return;\n\n  free(((void**)ptr)[-1]);\n}\n\n#ifdef __cplusplus\n} // extern \"C\"\n\n// The point of these undef's is to force using the template functions\n// if we are in C++ mode. For C, the user can rely only on the macros.\n#undef IS_PTR_ALIGNED\n#undef ALIGN_NUMBER\n#undef ALIGN_POINTER\n\n#endif  // __cplusplus\n\n#endif  //AVS_ALIGNMENT_H\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/arch.h",
    "content": "#ifndef _AVS_ARCH_H_\n#define _AVS_ARCH_H_\n\n#define       AVS_ARCH          x86_64\t    \t// e.g. i386\n\n#endif  //  _AVS_ARCH_H_\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/capi.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n#ifndef AVS_CAPI_H\n#define AVS_CAPI_H\n\n#include \"config.h\"\n\n#ifdef AVS_POSIX\n// this is also defined in avs/posix.h\n#ifndef AVS_HAIKU\n#define __declspec(x)\n#endif\n#endif\n\n#ifdef __cplusplus\n#  define EXTERN_C extern \"C\"\n#else\n#  define EXTERN_C\n#endif\n\n#ifdef AVS_WINDOWS\n#ifdef BUILDING_AVSCORE\n#  if defined(GCC) && defined(X86_32)\n#    define AVSC_CC\n#  else // MSVC builds and 64-bit GCC\n#    ifndef AVSC_USE_STDCALL\n#      define AVSC_CC __cdecl\n#    else\n#      define AVSC_CC __stdcall\n#    endif\n#  endif\n#else // needed for programs that talk to AviSynth+\n#  ifndef AVSC_WIN32_GCC32 // see comment below\n#    ifndef AVSC_USE_STDCALL\n#      define AVSC_CC __cdecl\n#    else\n#      define AVSC_CC __stdcall\n#    endif\n#  else\n#    define AVSC_CC\n#  endif\n#endif\n#  else\n#    define AVSC_CC\n#endif\n\n// On 64-bit Windows, there's only one calling convention,\n// so there is no difference between MSVC and GCC. On 32-bit,\n// this isn't true. The convention that GCC needs to use to\n// even build AviSynth+ as 32-bit makes anything that uses\n// it incompatible with 32-bit MSVC builds of AviSynth+.\n// The AVSC_WIN32_GCC32 define is meant to provide a user\n// switchable way to make builds of FFmpeg to test 32-bit\n// GCC builds of AviSynth+ without having to screw around\n// with alternate headers, while still default to the usual\n// situation of using 32-bit MSVC builds of AviSynth+.\n\n// Hopefully, this situation will eventually be resolved\n// and a broadly compatible solution will arise so the\n// same 32-bit FFmpeg build can handle either MSVC or GCC\n// builds of AviSynth+.\n\n#define AVSC_INLINE static __inline\n\n#ifdef BUILDING_AVSCORE\n#ifdef AVS_WINDOWS\n#  ifndef AVS_STATIC_LIB\n#    define AVSC_EXPORT __declspec(dllexport)\n#  else\n#    define AVSC_EXPORT\n#  endif\n#  define AVSC_API(ret, name) EXTERN_C AVSC_EXPORT ret AVSC_CC name\n#else\n#  define AVSC_EXPORT EXTERN_C\n#  define AVSC_API(ret, name) EXTERN_C ret AVSC_CC name\n#endif\n#else\n#  define AVSC_EXPORT EXTERN_C __declspec(dllexport)\n#  ifndef AVS_STATIC_LIB\n#    define AVSC_IMPORT __declspec(dllimport)\n#  else\n#    define AVSC_IMPORT\n#  endif\n#  ifndef AVSC_NO_DECLSPEC\n#    define AVSC_API(ret, name) EXTERN_C AVSC_IMPORT ret AVSC_CC name\n#  else\n#    define AVSC_API(ret, name) typedef ret (AVSC_CC *name##_func)\n#  endif\n#endif\n\n#endif //AVS_CAPI_H\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/config.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n#ifndef AVS_CONFIG_H\n#define AVS_CONFIG_H\n\n// Undefine this to get cdecl calling convention\n#define AVSC_USE_STDCALL 1\n\n// NOTE TO PLUGIN AUTHORS:\n// Because FRAME_ALIGN can be substantially higher than the alignment\n// a plugin actually needs, plugins should not use FRAME_ALIGN to check for\n// alignment. They should always request the exact alignment value they need.\n// This is to make sure that plugins work over the widest range of AviSynth\n// builds possible.\n#define FRAME_ALIGN 64\n\n#if   defined(_M_AMD64) || defined(__x86_64)\n#   define X86_64\n#elif defined(_M_IX86) || defined(__i386__)\n#   define X86_32\n// VS2017 introduced _M_ARM64\n#elif defined(_M_ARM64) || defined(__aarch64__)\n#   define ARM64\n#elif defined(_M_ARM) || defined(__arm__)\n#   define ARM32\n#elif defined(__PPC64__)\n#   define PPC64\n#elif defined(_M_PPC) || defined(__PPC__) || defined(__POWERPC__)\n#   define PPC32\n#elif defined(__riscv)\n#   define RISCV\n#elif defined(__sparc_v9__)\n#   define SPARC\n#elif defined(__mips__)\n#   define MIPS\n#else\n#   error Unsupported CPU architecture.\n#endif\n\n//            VC++  LLVM-Clang-cl   MinGW-Gnu\n// MSVC        x          x\n// MSVC_PURE   x\n// CLANG                  x\n// GCC                                  x\n\n#if defined(__clang__)\n// Check clang first. clang-cl also defines __MSC_VER\n// We set MSVC because they are mostly compatible\n#   define CLANG\n#if defined(_MSC_VER)\n#   define MSVC\n#   define AVS_FORCEINLINE __attribute__((always_inline))\n#else\n#   define AVS_FORCEINLINE __attribute__((always_inline)) inline\n#endif\n#elif   defined(_MSC_VER)\n#   define MSVC\n#   define MSVC_PURE\n#   define AVS_FORCEINLINE __forceinline\n#elif defined(__GNUC__)\n#   define GCC\n#   define AVS_FORCEINLINE __attribute__((always_inline)) inline\n#elif defined(__INTEL_COMPILER) || defined(__INTEL_LLVM_COMPILER)\n// Intel C++ Compilers with MSVC command line interface will not appear here rather at _MSC_VER\n#   define AVS_FORCEINLINE inline\n#   undef __forceinline\n#   define __forceinline inline\n#else\n#   error Unsupported compiler.\n#   define AVS_FORCEINLINE inline\n#   undef __forceinline\n#   define __forceinline inline\n#endif\n\n#if defined(_WIN32)\n#   define AVS_WINDOWS\n#elif defined(__linux__)\n#   define AVS_LINUX\n#   define AVS_POSIX\n#elif defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || defined(__DragonFly__)\n#   define AVS_BSD\n#   define AVS_POSIX\n#elif defined(__APPLE__)\n#   define AVS_MACOS\n#   define AVS_POSIX\n#elif defined(__HAIKU__)\n#   define AVS_HAIKU\n#   define AVS_POSIX\n#else\n#   error Operating system unsupported.\n#endif\n\n// useful warnings disabler macros for supported compilers\n\n#if defined(_MSC_VER)\n#define DISABLE_WARNING_PUSH           __pragma(warning( push ))\n#define DISABLE_WARNING_POP            __pragma(warning( pop ))\n#define DISABLE_WARNING(warningNumber) __pragma(warning( disable : warningNumber ))\n\n#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE      DISABLE_WARNING(4101)\n#define DISABLE_WARNING_UNREFERENCED_FUNCTION            DISABLE_WARNING(4505)\n// other warnings you want to deactivate...\n\n#elif defined(__GNUC__) || defined(__clang__)\n#define DO_PRAGMA(X) _Pragma(#X)\n#define DISABLE_WARNING_PUSH           DO_PRAGMA(GCC diagnostic push)\n#define DISABLE_WARNING_POP            DO_PRAGMA(GCC diagnostic pop)\n#define DISABLE_WARNING(warningName)   DO_PRAGMA(GCC diagnostic ignored #warningName)\n\n#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE      DISABLE_WARNING(-Wunused-variable)\n#define DISABLE_WARNING_UNREFERENCED_FUNCTION            DISABLE_WARNING(-Wunused-function)\n// other warnings you want to deactivate...\n\n#else\n#define DISABLE_WARNING_PUSH\n#define DISABLE_WARNING_POP\n#define DISABLE_WARNING_UNREFERENCED_LOCAL_VARIABLE\n#define DISABLE_WARNING_UNREFERENCED_FUNCTION\n// other warnings you want to deactivate...\n\n#endif\n\n#if defined(AVS_WINDOWS) && defined(_USING_V110_SDK71_)\n// Windows XP does not have proper initialization for\n// thread local variables.\n// Use workaround instead __declspec(thread)\n#define XP_TLS\n#endif\n\n#ifndef MSVC\n// GCC and Clang can be used on big endian systems, MSVC can't.\n#  if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__\n#    define AVS_ENDIANNESS \"little\"\n#  elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__\n#    define AVS_ENDIANNESS \"big\"\n#  else\n#    define AVS_ENDIANNESS \"middle\"\n#  endif\n#else\n#define AVS_ENDIANNESS \"little\"\n#endif\n\n#endif //AVS_CONFIG_H\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/cpuid.h",
    "content": "// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making a\n// combined work based on Avisynth.  Thus, the terms and conditions of the GNU\n// General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate with\n// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license\n// terms of these independent modules, and to copy and distribute the\n// resulting combined work under terms of your choice, provided that\n// every copy of the combined work is accompanied by a complete copy of\n// the source code of Avisynth (the version of Avisynth used to produce the\n// combined work), being distributed under the terms of the GNU General\n// Public License plus this exception.  An independent module is a module\n// which is not derived from or based on Avisynth, such as 3rd-party filters,\n// import and export plugins, or graphical user interfaces.\n\n#ifndef AVSCORE_CPUID_H\n#define AVSCORE_CPUID_H\n\n// For GetCPUFlags.  These are backwards-compatible with those in VirtualDub.\n// ending with SSE4_2\n// For emulation see https://software.intel.com/en-us/articles/intel-software-development-emulator\nenum {\n                    /* oldest CPU to support extension */\n  CPUF_FORCE        =  0x01,   //  N/A\n  CPUF_FPU          =  0x02,   //  386/486DX\n  CPUF_MMX          =  0x04,   //  P55C, K6, PII\n  CPUF_INTEGER_SSE  =  0x08,   //  PIII, Athlon\n  CPUF_SSE          =  0x10,   //  PIII, Athlon XP/MP\n  CPUF_SSE2         =  0x20,   //  PIV, K8\n  CPUF_3DNOW        =  0x40,   //  K6-2\n  CPUF_3DNOW_EXT    =  0x80,   //  Athlon\n  CPUF_X86_64       =  0xA0,   //  Hammer (note: equiv. to 3DNow + SSE2, which\n                               //          only Hammer will have anyway)\n  CPUF_SSE3         = 0x100,   //  PIV+, K8 Venice\n  CPUF_SSSE3        = 0x200,   //  Core 2\n  CPUF_SSE4         = 0x400,\n  CPUF_SSE4_1       = 0x400,   //  Penryn, Wolfdale, Yorkfield\n  CPUF_AVX          = 0x800,   //  Sandy Bridge, Bulldozer\n  CPUF_SSE4_2       = 0x1000,  //  Nehalem\n  // AVS+\n  CPUF_AVX2         = 0x2000,   //  Haswell\n  CPUF_FMA3         = 0x4000,\n  CPUF_F16C         = 0x8000,\n  CPUF_MOVBE        = 0x10000,  // Big Endian move\n  CPUF_POPCNT       = 0x20000,\n  CPUF_AES          = 0x40000,\n  CPUF_FMA4         = 0x80000,\n\n  CPUF_AVX512F      = 0x100000,  // AVX-512 Foundation.\n  CPUF_AVX512DQ     = 0x200000,  // AVX-512 DQ (Double/Quad granular) Instructions\n  CPUF_AVX512PF     = 0x400000,  // AVX-512 Prefetch\n  CPUF_AVX512ER     = 0x800000,  // AVX-512 Exponential and Reciprocal\n  CPUF_AVX512CD     = 0x1000000, // AVX-512 Conflict Detection\n  CPUF_AVX512BW     = 0x2000000, // AVX-512 BW (Byte/Word granular) Instructions\n  CPUF_AVX512VL     = 0x4000000, // AVX-512 VL (128/256 Vector Length) Extensions\n  CPUF_AVX512IFMA   = 0x8000000, // AVX-512 IFMA integer 52 bit\n  CPUF_AVX512VBMI   = 0x10000000,// AVX-512 VBMI\n};\n\n#ifdef BUILDING_AVSCORE\nint GetCPUFlags();\nvoid SetMaxCPU(int new_flags);\n#endif\n\n#endif // AVSCORE_CPUID_H\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/filesystem.h",
    "content": "#pragma once\n\n// Snippet copied from filesystem/README.md\n\n#if defined(__cplusplus) && __cplusplus >= 201703L && defined(__has_include)\n#if __has_include(<filesystem>)\n#define GHC_USE_STD_FS\n#include <filesystem>\nnamespace fs = std::filesystem;\n#endif\n#endif\n#ifndef GHC_USE_STD_FS\n#include <ghc/filesystem.hpp>\nnamespace fs = ghc::filesystem;\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/minmax.h",
    "content": "// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making a\n// combined work based on Avisynth.  Thus, the terms and conditions of the GNU\n// General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate with\n// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license\n// terms of these independent modules, and to copy and distribute the\n// resulting combined work under terms of your choice, provided that\n// every copy of the combined work is accompanied by a complete copy of\n// the source code of Avisynth (the version of Avisynth used to produce the\n// combined work), being distributed under the terms of the GNU General\n// Public License plus this exception.  An independent module is a module\n// which is not derived from or based on Avisynth, such as 3rd-party filters,\n// import and export plugins, or graphical user interfaces.\n\n#ifndef AVSCORE_MINMAX_H\n#define AVSCORE_MINMAX_H\n\ntemplate<typename T>\nT min(T v1, T v2)\n{\n  return v1 < v2 ? v1 : v2;\n}\n\ntemplate<typename T>\nT max(T v1, T v2)\n{\n  return v1 > v2 ? v1 : v2;\n}\n\ntemplate<typename T>\nT clamp(T n, T min, T max)\n{\n    n = n > max ? max : n;\n    return n < min ? min : n;\n}\n\n#endif // AVSCORE_MINMAX_H\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/posix.h",
    "content": "// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making a\n// combined work based on Avisynth.  Thus, the terms and conditions of the GNU\n// General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate with\n// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license\n// terms of these independent modules, and to copy and distribute the\n// resulting combined work under terms of your choice, provided that\n// every copy of the combined work is accompanied by a complete copy of\n// the source code of Avisynth (the version of Avisynth used to produce the\n// combined work), being distributed under the terms of the GNU General\n// Public License plus this exception.  An independent module is a module\n// which is not derived from or based on Avisynth, such as 3rd-party filters,\n// import and export plugins, or graphical user interfaces.\n\n#ifdef AVS_POSIX\n#ifndef AVSCORE_POSIX_H\n#define AVSCORE_POSIX_H\n\n#ifdef __cplusplus\n#include <cstring>\n#endif\n#include <strings.h>\n#include <unistd.h>\n\n// Define these MSVC-extension used in Avisynth\n#define __single_inheritance\n\n// These things don't exist in Linux\n#if defined(AVS_HAIKU)\n#undef __declspec\n#endif\n#define __declspec(x)\n#define lstrlen strlen\n#define lstrcmp strcmp\n#define lstrcmpi strcasecmp\n#define _stricmp strcasecmp\n#define _strnicmp strncasecmp\n#define _strdup strdup\n#define SetCurrentDirectory(x) chdir(x)\n#define SetCurrentDirectoryW(x) chdir(x)\n#define GetCurrentDirectoryW(x) getcwd(x)\n#define _putenv putenv\n#define _alloca alloca\n\n// Borrowing some compatibility macros from AvxSynth, slightly modified\n#define UInt32x32To64(a, b) ((uint64_t)(((uint64_t)((uint32_t)(a))) * ((uint32_t)(b))))\n#define Int64ShrlMod32(a, b) ((uint64_t)((uint64_t)(a) >> (b)))\n#define Int32x32To64(a, b)  ((int64_t)(((int64_t)((long)(a))) * ((long)(b))))\n\n#define InterlockedIncrement(x) __sync_add_and_fetch((x), 1)\n#define InterlockedDecrement(x) __sync_sub_and_fetch((x), 1)\n#define InterlockedExchangeAdd(x, v) __sync_add_and_fetch((x), (v))\n\n#define MulDiv(nNumber, nNumerator, nDenominator)   (int32_t) (((int64_t) (nNumber) * (int64_t) (nNumerator) + (int64_t) ((nDenominator)/2)) / (int64_t) (nDenominator))\n\n#ifndef TRUE\n#define TRUE  true\n#endif\n\n#ifndef FALSE\n#define FALSE false\n#endif\n\n#define S_FALSE       (0x00000001)\n#define E_FAIL        (0x80004005)\n#define FAILED(hr)    ((hr) & 0x80000000)\n#define SUCCEEDED(hr) (!FAILED(hr))\n\n// Statuses copied from comments in exception.cpp\n#define STATUS_GUARD_PAGE_VIOLATION 0x80000001\n#define STATUS_DATATYPE_MISALIGNMENT 0x80000002\n#define STATUS_BREAKPOINT 0x80000003\n#define STATUS_SINGLE_STEP 0x80000004\n#define STATUS_ACCESS_VIOLATION 0xc0000005\n#define STATUS_IN_PAGE_ERROR 0xc0000006\n#define STATUS_INVALID_HANDLE 0xc0000008\n#define STATUS_NO_MEMORY 0xc0000017\n#define STATUS_ILLEGAL_INSTRUCTION 0xc000001d\n#define STATUS_NONCONTINUABLE_EXCEPTION 0xc0000025\n#define STATUS_INVALID_DISPOSITION 0xc0000026\n#define STATUS_ARRAY_BOUNDS_EXCEEDED 0xc000008c\n#define STATUS_FLOAT_DENORMAL_OPERAND 0xc000008d\n#define STATUS_FLOAT_DIVIDE_BY_ZERO 0xc000008e\n#define STATUS_FLOAT_INEXACT_RESULT 0xc000008f\n#define STATUS_FLOAT_INVALID_OPERATION 0xc0000090\n#define STATUS_FLOAT_OVERFLOW 0xc0000091\n#define STATUS_FLOAT_STACK_CHECK 0xc0000092\n#define STATUS_FLOAT_UNDERFLOW 0xc0000093\n#define STATUS_INTEGER_DIVIDE_BY_ZERO 0xc0000094\n#define STATUS_INTEGER_OVERFLOW 0xc0000095\n#define STATUS_PRIVILEGED_INSTRUCTION 0xc0000096\n#define STATUS_STACK_OVERFLOW 0xc00000fd\n\n// Calling convension\n#ifndef AVS_HAIKU\n#define __stdcall\n#define __cdecl\n#endif\n\n// PowerPC OS X is really niche these days, but this painless equivocation\n// of the function/macro names used in posix_get_available_memory()\n// is all it takes to let it work.  The G5 was 64-bit, and if 10.5 Leopard\n// can run in native 64-bit, it probably uses the names in that block as-is.\n#ifdef AVS_MACOS\n#ifdef PPC32\n#define vm_statistics64_data_t vm_statistics_data_t\n#define HOST_VM_INFO64_COUNT HOST_VM_INFO_COUNT\n#define HOST_VM_INFO64 HOST_VM_INFO\n#define host_statistics64 host_statistics\n#endif // PPC32\n#endif // AVS_MACOS\n\n#endif // AVSCORE_POSIX_H\n#endif // AVS_POSIX\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/types.h",
    "content": "// Avisynth C Interface Version 0.20\n// Copyright 2003 Kevin Atkinson\n\n// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// As a special exception, I give you permission to link to the\n// Avisynth C interface with independent modules that communicate with\n// the Avisynth C interface solely through the interfaces defined in\n// avisynth_c.h, regardless of the license terms of these independent\n// modules, and to copy and distribute the resulting combined work\n// under terms of your choice, provided that every copy of the\n// combined work is accompanied by a complete copy of the source code\n// of the Avisynth C interface and Avisynth itself (with the version\n// used to produce the combined work), being distributed under the\n// terms of the GNU General Public License plus this exception.  An\n// independent module is a module which is not derived from or based\n// on Avisynth C Interface, such as 3rd-party filters, import and\n// export plugins, or graphical user interfaces.\n\n#ifndef AVS_TYPES_H\n#define AVS_TYPES_H\n\n// Define all types necessary for interfacing with avisynth.dll\n#include <stdint.h>\n#include <stdbool.h>\n#ifdef __cplusplus\n  #include <cstddef>\n  #include <cstdarg>\n#else\n  #include <stddef.h>\n  #include <stdarg.h>\n#endif\n\n// Raster types used by VirtualDub & Avisynth\ntypedef uint32_t Pixel32;\ntypedef uint8_t  BYTE;\n\n// Audio Sample information\ntypedef float SFLOAT;\n\n#endif //AVS_TYPES_H\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/version.h",
    "content": "#ifndef _AVS_VERSION_H_\n#define _AVS_VERSION_H_\n\n#include \"arch.h\"\n\n#define       AVS_PPSTR_(x)    \t#x\n#define       AVS_PPSTR(x)    \tAVS_PPSTR_(x)\n\n#define       AVS_PROJECT       AviSynth+\n#define       AVS_MAJOR_VER     3\n#define       AVS_MINOR_VER     7\n#define       AVS_BUGFIX_VER    3\n#ifdef RELEASE_TARBALL\n#define       AVS_FULLVERSION\tAVS_PPSTR(AVS_PROJECT) \" \" AVS_PPSTR(AVS_MAJOR_VER) \".\" AVS_PPSTR(AVS_MINOR_VER) \".\" AVS_PPSTR(AVS_BUGFIX_VER) \" (\" AVS_PPSTR(AVS_ARCH) \")\"\n#else\n#define       AVS_DEVNEXT_REV   \n#define       AVS_DEV_REVDATE   \n#define       AVS_DEV_GITHASH   \n#define       AVS_SEQREV        \t\t// e.g. 1576\n#define       AVS_BRANCH        \t\t// e.g. master\n#define       AVS_FULLVERSION\tAVS_PPSTR(AVS_PROJECT) \" \" AVS_PPSTR(AVS_MAJOR_VER) \".\" AVS_PPSTR(AVS_MINOR_VER) \".\" AVS_PPSTR(AVS_BUGFIX_VER) \" (r\" AVS_PPSTR(AVS_SEQREV) \", \" AVS_PPSTR(AVS_BRANCH) \", \" AVS_PPSTR(AVS_ARCH) \")\"\n#endif\n\n#endif  //  _AVS_VERSION_H_\n"
  },
  {
    "path": "thirdparty/64/include/avisynth/avs/win.h",
    "content": "// This program is free software; you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation; either version 2 of the License, or\n// (at your option) any later version.\n//\n// This program is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with this program; if not, write to the Free Software\n// Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA, or visit\n// http://www.gnu.org/copyleft/gpl.html .\n//\n// Linking Avisynth statically or dynamically with other modules is making a\n// combined work based on Avisynth.  Thus, the terms and conditions of the GNU\n// General Public License cover the whole combination.\n//\n// As a special exception, the copyright holders of Avisynth give you\n// permission to link Avisynth with independent modules that communicate with\n// Avisynth solely through the interfaces defined in avisynth.h, regardless of the license\n// terms of these independent modules, and to copy and distribute the\n// resulting combined work under terms of your choice, provided that\n// every copy of the combined work is accompanied by a complete copy of\n// the source code of Avisynth (the version of Avisynth used to produce the\n// combined work), being distributed under the terms of the GNU General\n// Public License plus this exception.  An independent module is a module\n// which is not derived from or based on Avisynth, such as 3rd-party filters,\n// import and export plugins, or graphical user interfaces.\n\n#ifndef AVSCORE_WIN_H\n#define AVSCORE_WIN_H\n\n// Whenever you need windows headers, start by including this file, then the rest.\n\n// WWUUT? We require XP now?\n#if !defined(NTDDI_VERSION) && !defined(_WIN32_WINNT)\n  #define NTDDI_VERSION 0x05020000\n  #define _WIN32_WINNT  0x0502\n#endif\n\n#define WIN32_LEAN_AND_MEAN\n#define STRICT\n#if !defined(NOMINMAX)\n    #define NOMINMAX\n#endif\n\n#include <windows.h>\n\n// Provision for UTF-8 max 4 bytes per code point\n#define AVS_MAX_PATH MAX_PATH*4\n\n#endif // AVSCORE_WIN_H\n"
  },
  {
    "path": "thirdparty/64/include/dav1d/common.h",
    "content": "/*\n * Copyright © 2018, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_COMMON_H\n#define DAV1D_COMMON_H\n\n#include <errno.h>\n#include <stddef.h>\n#include <stdint.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef DAV1D_API\n    #if defined _WIN32\n      #if defined DAV1D_BUILDING_DLL\n        #define DAV1D_API __declspec(dllexport)\n      #else\n        #define DAV1D_API\n      #endif\n    #else\n      #if __GNUC__ >= 4\n        #define DAV1D_API __attribute__ ((visibility (\"default\")))\n      #else\n        #define DAV1D_API\n      #endif\n    #endif\n#endif\n\n#if EPERM > 0\n#define DAV1D_ERR(e) (-(e)) ///< Negate POSIX error code.\n#else\n#define DAV1D_ERR(e) (e)\n#endif\n\n/**\n * A reference-counted object wrapper for a user-configurable pointer.\n */\ntypedef struct Dav1dUserData {\n    const uint8_t *data; ///< data pointer\n    struct Dav1dRef *ref; ///< allocation origin\n} Dav1dUserData;\n\n/**\n * Input packet metadata which are copied from the input data used to\n * decode each image into the matching structure of the output image\n * returned back to the user. Since these are metadata fields, they\n * can be used for other purposes than the documented ones, they will\n * still be passed from input data to output picture without being\n * used internally.\n */\ntypedef struct Dav1dDataProps {\n    int64_t timestamp; ///< container timestamp of input data, INT64_MIN if unknown (default)\n    int64_t duration; ///< container duration of input data, 0 if unknown (default)\n    int64_t offset; ///< stream offset of input data, -1 if unknown (default)\n    size_t size; ///< packet size, default Dav1dData.sz\n    struct Dav1dUserData user_data; ///< user-configurable data, default NULL members\n} Dav1dDataProps;\n\n/**\n * Release reference to a Dav1dDataProps.\n */\nDAV1D_API void dav1d_data_props_unref(Dav1dDataProps *props);\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_COMMON_H */\n"
  },
  {
    "path": "thirdparty/64/include/dav1d/data.h",
    "content": "/*\n * Copyright © 2018, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_DATA_H\n#define DAV1D_DATA_H\n\n#include <stddef.h>\n#include <stdint.h>\n\n#include \"common.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct Dav1dData {\n    const uint8_t *data; ///< data pointer\n    size_t sz; ///< data size\n    struct Dav1dRef *ref; ///< allocation origin\n    Dav1dDataProps m; ///< user provided metadata passed to the output picture\n} Dav1dData;\n\n/**\n * Allocate data.\n *\n * @param data Input context.\n * @param   sz Size of the data that should be allocated.\n *\n * @return Pointer to the allocated buffer on success. NULL on error.\n */\nDAV1D_API uint8_t * dav1d_data_create(Dav1dData *data, size_t sz);\n\n/**\n * Wrap an existing data array.\n *\n * @param          data Input context.\n * @param           buf The data to be wrapped.\n * @param            sz Size of the data.\n * @param free_callback Function to be called when we release our last\n *                      reference to this data. In this callback, $buf will be\n *                      the $buf argument to this function, and $cookie will\n *                      be the $cookie input argument to this function.\n * @param        cookie Opaque parameter passed to free_callback().\n *\n * @return 0 on success. A negative DAV1D_ERR value on error.\n */\nDAV1D_API int dav1d_data_wrap(Dav1dData *data, const uint8_t *buf, size_t sz,\n                              void (*free_callback)(const uint8_t *buf, void *cookie),\n                              void *cookie);\n\n/**\n * Wrap a user-provided data pointer into a reference counted object.\n *\n * data->m.user_data field will initialized to wrap the provided $user_data\n * pointer.\n *\n * $free_callback will be called on the same thread that released the last\n * reference. If frame threading is used, make sure $free_callback is\n * thread-safe.\n *\n * @param          data Input context.\n * @param     user_data The user data to be wrapped.\n * @param free_callback Function to be called when we release our last\n *                      reference to this data. In this callback, $user_data\n *                      will be the $user_data argument to this function, and\n *                      $cookie will be the $cookie input argument to this\n *                      function.\n * @param        cookie Opaque parameter passed to $free_callback.\n *\n * @return 0 on success. A negative DAV1D_ERR value on error.\n */\nDAV1D_API int dav1d_data_wrap_user_data(Dav1dData *data,\n                                        const uint8_t *user_data,\n                                        void (*free_callback)(const uint8_t *user_data,\n                                                              void *cookie),\n                                        void *cookie);\n\n/**\n * Free the data reference.\n *\n * The reference count for data->m.user_data will be decremented (if it has been\n * initialized with dav1d_data_wrap_user_data). The $data object will be memset\n * to 0.\n *\n * @param data Input context.\n */\nDAV1D_API void dav1d_data_unref(Dav1dData *data);\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_DATA_H */\n"
  },
  {
    "path": "thirdparty/64/include/dav1d/dav1d.h",
    "content": "/*\n * Copyright © 2018-2021, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_H\n#define DAV1D_H\n\n#include <errno.h>\n#include <stdarg.h>\n\n#include \"common.h\"\n#include \"picture.h\"\n#include \"data.h\"\n#include \"version.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct Dav1dContext Dav1dContext;\ntypedef struct Dav1dRef Dav1dRef;\n\n#define DAV1D_MAX_THREADS 256\n#define DAV1D_MAX_FRAME_DELAY 256\n\ntypedef struct Dav1dLogger {\n    void *cookie; ///< Custom data to pass to the callback.\n    /**\n     * Logger callback. May be NULL to disable logging.\n     *\n     * @param cookie Custom pointer passed to all calls.\n     * @param format The vprintf compatible format string.\n     * @param     ap List of arguments referenced by the format string.\n     */\n    void (*callback)(void *cookie, const char *format, va_list ap);\n} Dav1dLogger;\n\nenum Dav1dInloopFilterType {\n    DAV1D_INLOOPFILTER_NONE        = 0,\n    DAV1D_INLOOPFILTER_DEBLOCK     = 1 << 0,\n    DAV1D_INLOOPFILTER_CDEF        = 1 << 1,\n    DAV1D_INLOOPFILTER_RESTORATION = 1 << 2,\n    DAV1D_INLOOPFILTER_ALL = DAV1D_INLOOPFILTER_DEBLOCK |\n                             DAV1D_INLOOPFILTER_CDEF |\n                             DAV1D_INLOOPFILTER_RESTORATION,\n};\n\nenum Dav1dDecodeFrameType {\n    DAV1D_DECODEFRAMETYPE_ALL   = 0, ///< decode and return all frames\n    DAV1D_DECODEFRAMETYPE_REFERENCE = 1,///< decode and return frames referenced by other frames only\n    DAV1D_DECODEFRAMETYPE_INTRA = 2, ///< decode and return intra frames only (includes keyframes)\n    DAV1D_DECODEFRAMETYPE_KEY   = 3, ///< decode and return keyframes only\n};\n\ntypedef struct Dav1dSettings {\n    int n_threads; ///< number of threads (0 = number of logical cores in host system, default 0)\n    int max_frame_delay; ///< Set to 1 for low-latency decoding (0 = ceil(sqrt(n_threads)), default 0)\n    int apply_grain; ///< whether to apply film grain on output frames (default 1)\n    int operating_point; ///< select an operating point for scalable AV1 bitstreams (0 - 31, default 0)\n    int all_layers; ///< output all spatial layers of a scalable AV1 biststream (default 1)\n    unsigned frame_size_limit; ///< maximum frame size, in pixels (0 = unlimited, default 0)\n    Dav1dPicAllocator allocator; ///< Picture allocator callback.\n    Dav1dLogger logger; ///< Logger callback.\n    int strict_std_compliance; ///< whether to abort decoding on standard compliance violations\n                               ///< that don't affect actual bitstream decoding (e.g. inconsistent\n                               ///< or invalid metadata, default 0)\n    int output_invisible_frames; ///< output invisibly coded frames (in coding order) in addition\n                                 ///< to all visible frames. Because of show-existing-frame, this\n                                 ///< means some frames may appear twice (once when coded,\n                                 ///< once when shown, default 0)\n    enum Dav1dInloopFilterType inloop_filters; ///< postfilters to enable during decoding (default\n                                               ///< DAV1D_INLOOPFILTER_ALL)\n    enum Dav1dDecodeFrameType decode_frame_type; ///< frame types to decode (default\n                                                 ///< DAV1D_DECODEFRAMETYPE_ALL)\n    uint8_t reserved[16]; ///< reserved for future use\n} Dav1dSettings;\n\n/**\n * Get library version.\n */\nDAV1D_API const char *dav1d_version(void);\n\n/**\n * Get library API version.\n *\n * @return A value in the format 0x00XXYYZZ, where XX is the major version,\n *         YY the minor version, and ZZ the patch version.\n * @see DAV1D_API_MAJOR, DAV1D_API_MINOR, DAV1D_API_PATCH\n */\nDAV1D_API unsigned dav1d_version_api(void);\n\n/**\n * Initialize settings to default values.\n *\n * @param s Input settings context.\n */\nDAV1D_API void dav1d_default_settings(Dav1dSettings *s);\n\n/**\n * Allocate and open a decoder instance.\n *\n * @param c_out The decoder instance to open. *c_out will be set to the\n *              allocated context.\n * @param     s Input settings context.\n *\n * @note The context must be freed using dav1d_close() when decoding is\n *       finished.\n *\n * @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error.\n */\nDAV1D_API int dav1d_open(Dav1dContext **c_out, const Dav1dSettings *s);\n\n/**\n * Parse a Sequence Header OBU from bitstream data.\n *\n * @param out Output Sequence Header.\n * @param buf The data to be parser.\n * @param sz  Size of the data.\n *\n * @return\n *                  0: Success, and out is filled with the parsed Sequence Header\n *                     OBU parameters.\n *  DAV1D_ERR(ENOENT): No Sequence Header OBUs were found in the buffer.\n *  Other negative DAV1D_ERR codes: Invalid data in the buffer, invalid passed-in\n *                                  arguments, and other errors during parsing.\n *\n * @note It is safe to feed this function data containing other OBUs than a\n *       Sequence Header, as they will simply be ignored. If there is more than\n *       one Sequence Header OBU present, only the last will be returned.\n */\nDAV1D_API int dav1d_parse_sequence_header(Dav1dSequenceHeader *out,\n                                          const uint8_t *buf, const size_t sz);\n\n/**\n * Feed bitstream data to the decoder, in the form of one or multiple AV1\n * Open Bitstream Units (OBUs).\n *\n * @param   c Input decoder instance.\n * @param  in Input bitstream data. On success, ownership of the reference is\n *            passed to the library.\n *\n * @return\n *         0: Success, and the data was consumed.\n *  DAV1D_ERR(EAGAIN): The data can't be consumed. dav1d_get_picture() should\n *                     be called to get one or more frames before the function\n *                     can consume new data.\n *  Other negative DAV1D_ERR codes: Error during decoding or because of invalid\n *                                  passed-in arguments. The reference remains\n *                                  owned by the caller.\n */\nDAV1D_API int dav1d_send_data(Dav1dContext *c, Dav1dData *in);\n\n/**\n * Return a decoded picture.\n *\n * @param   c Input decoder instance.\n * @param out Output frame. The caller assumes ownership of the returned\n *            reference.\n *\n * @return\n *         0: Success, and a frame is returned.\n *  DAV1D_ERR(EAGAIN): Not enough data to output a frame. dav1d_send_data()\n *                     should be called with new input.\n *  Other negative DAV1D_ERR codes: Error during decoding or because of invalid\n *                                  passed-in arguments.\n *\n * @note To drain buffered frames from the decoder (i.e. on end of stream),\n *       call this function until it returns DAV1D_ERR(EAGAIN).\n *\n * @code{.c}\n *  Dav1dData data = { 0 };\n *  Dav1dPicture p = { 0 };\n *  int res;\n *\n *  read_data(&data);\n *  do {\n *      res = dav1d_send_data(c, &data);\n *      // Keep going even if the function can't consume the current data\n *         packet. It eventually will after one or more frames have been\n *         returned in this loop.\n *      if (res < 0 && res != DAV1D_ERR(EAGAIN))\n *          free_and_abort();\n *      res = dav1d_get_picture(c, &p);\n *      if (res < 0) {\n *          if (res != DAV1D_ERR(EAGAIN))\n *              free_and_abort();\n *      } else\n *          output_and_unref_picture(&p);\n *  // Stay in the loop as long as there's data to consume.\n *  } while (data.sz || read_data(&data) == SUCCESS);\n *\n *  // Handle EOS by draining all buffered frames.\n *  do {\n *      res = dav1d_get_picture(c, &p);\n *      if (res < 0) {\n *          if (res != DAV1D_ERR(EAGAIN))\n *              free_and_abort();\n *      } else\n *          output_and_unref_picture(&p);\n *  } while (res == 0);\n * @endcode\n */\nDAV1D_API int dav1d_get_picture(Dav1dContext *c, Dav1dPicture *out);\n\n/**\n * Apply film grain to a previously decoded picture. If the picture contains no\n * film grain metadata, then this function merely returns a new reference.\n *\n * @param   c Input decoder instance.\n * @param out Output frame. The caller assumes ownership of the returned\n *            reference.\n * @param  in Input frame. No ownership is transferred.\n *\n * @return\n *         0: Success, and a frame is returned.\n *  Other negative DAV1D_ERR codes: Error due to lack of memory or because of\n *                                  invalid passed-in arguments.\n *\n * @note If `Dav1dSettings.apply_grain` is true, film grain was already applied\n *       by `dav1d_get_picture`, and so calling this function leads to double\n *       application of film grain. Users should only call this when needed.\n */\nDAV1D_API int dav1d_apply_grain(Dav1dContext *c, Dav1dPicture *out,\n                                const Dav1dPicture *in);\n\n/**\n * Close a decoder instance and free all associated memory.\n *\n * @param c_out The decoder instance to close. *c_out will be set to NULL.\n */\nDAV1D_API void dav1d_close(Dav1dContext **c_out);\n\n/**\n * Flush all delayed frames in decoder and clear internal decoder state,\n * to be used when seeking.\n *\n * @param c Input decoder instance.\n *\n * @note Decoding will start only after a valid sequence header OBU is\n *       delivered to dav1d_send_data().\n *\n */\nDAV1D_API void dav1d_flush(Dav1dContext *c);\n\nenum Dav1dEventFlags {\n    /**\n     * The last returned picture contains a reference to a new Sequence Header,\n     * either because it's the start of a new coded sequence, or the decoder was\n     * flushed before it was generated.\n     */\n    DAV1D_EVENT_FLAG_NEW_SEQUENCE =       1 << 0,\n    /**\n     * The last returned picture contains a reference to a Sequence Header with\n     * new operating parameters information for the current coded sequence.\n     */\n    DAV1D_EVENT_FLAG_NEW_OP_PARAMS_INFO = 1 << 1,\n};\n\n/**\n * Fetch a combination of DAV1D_EVENT_FLAG_* event flags generated by the decoding\n * process.\n *\n * @param c Input decoder instance.\n * @param flags Where to write the flags.\n *\n * @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error.\n *\n * @note Calling this function will clear all the event flags currently stored in\n *       the decoder.\n *\n */\nDAV1D_API int dav1d_get_event_flags(Dav1dContext *c, enum Dav1dEventFlags *flags);\n\n/**\n * Retrieve the user-provided metadata associated with the input data packet\n * for the last decoding error reported to the user, i.e. a negative return\n * value (not EAGAIN) from dav1d_send_data() or dav1d_get_picture().\n *\n * @param   c Input decoder instance.\n * @param out Output Dav1dDataProps. On success, the caller assumes ownership of\n *            the returned reference.\n *\n * @return 0 on success, or < 0 (a negative DAV1D_ERR code) on error.\n */\nDAV1D_API int dav1d_get_decode_error_data_props(Dav1dContext *c, Dav1dDataProps *out);\n\n/**\n * Get the decoder delay, which is the number of internally buffered frames, not\n * including reference frames.\n * This value is guaranteed to be >= 1 and <= max_frame_delay.\n *\n * @param s Input settings context.\n *\n * @return Decoder frame delay on success, or < 0 (a negative DAV1D_ERR code) on\n *         error.\n *\n * @note The returned delay is valid only for a Dav1dContext initialized with the\n *       provided Dav1dSettings.\n */\nDAV1D_API int dav1d_get_frame_delay(const Dav1dSettings *s);\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_H */\n"
  },
  {
    "path": "thirdparty/64/include/dav1d/headers.h",
    "content": "/*\n * Copyright © 2018-2020, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_HEADERS_H\n#define DAV1D_HEADERS_H\n\n#include <stdint.h>\n#include <stddef.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n// Constants from Section 3. \"Symbols and abbreviated terms\"\n#define DAV1D_MAX_CDEF_STRENGTHS 8\n#define DAV1D_MAX_OPERATING_POINTS 32\n#define DAV1D_MAX_TILE_COLS 64\n#define DAV1D_MAX_TILE_ROWS 64\n#define DAV1D_MAX_SEGMENTS 8\n#define DAV1D_NUM_REF_FRAMES 8\n#define DAV1D_PRIMARY_REF_NONE 7\n#define DAV1D_REFS_PER_FRAME 7\n#define DAV1D_TOTAL_REFS_PER_FRAME (DAV1D_REFS_PER_FRAME + 1)\n\nenum Dav1dObuType {\n    DAV1D_OBU_SEQ_HDR   = 1,\n    DAV1D_OBU_TD        = 2,\n    DAV1D_OBU_FRAME_HDR = 3,\n    DAV1D_OBU_TILE_GRP  = 4,\n    DAV1D_OBU_METADATA  = 5,\n    DAV1D_OBU_FRAME     = 6,\n    DAV1D_OBU_REDUNDANT_FRAME_HDR = 7,\n    DAV1D_OBU_PADDING   = 15,\n};\n\nenum Dav1dTxfmMode {\n    DAV1D_TX_4X4_ONLY,\n    DAV1D_TX_LARGEST,\n    DAV1D_TX_SWITCHABLE,\n    DAV1D_N_TX_MODES,\n};\n\nenum Dav1dFilterMode {\n    DAV1D_FILTER_8TAP_REGULAR,\n    DAV1D_FILTER_8TAP_SMOOTH,\n    DAV1D_FILTER_8TAP_SHARP,\n    DAV1D_N_SWITCHABLE_FILTERS,\n    DAV1D_FILTER_BILINEAR = DAV1D_N_SWITCHABLE_FILTERS,\n    DAV1D_N_FILTERS,\n    DAV1D_FILTER_SWITCHABLE = DAV1D_N_FILTERS,\n};\n\nenum Dav1dAdaptiveBoolean {\n    DAV1D_OFF = 0,\n    DAV1D_ON = 1,\n    DAV1D_ADAPTIVE = 2,\n};\n\nenum Dav1dRestorationType {\n    DAV1D_RESTORATION_NONE,\n    DAV1D_RESTORATION_SWITCHABLE,\n    DAV1D_RESTORATION_WIENER,\n    DAV1D_RESTORATION_SGRPROJ,\n};\n\nenum Dav1dWarpedMotionType {\n    DAV1D_WM_TYPE_IDENTITY,\n    DAV1D_WM_TYPE_TRANSLATION,\n    DAV1D_WM_TYPE_ROT_ZOOM,\n    DAV1D_WM_TYPE_AFFINE,\n};\n\ntypedef struct Dav1dWarpedMotionParams {\n    enum Dav1dWarpedMotionType type;\n    int32_t matrix[6];\n    union {\n        struct {\n            int16_t alpha, beta, gamma, delta;\n        } p;\n        int16_t abcd[4];\n    } u;\n} Dav1dWarpedMotionParams;\n\nenum Dav1dPixelLayout {\n    DAV1D_PIXEL_LAYOUT_I400, ///< monochrome\n    DAV1D_PIXEL_LAYOUT_I420, ///< 4:2:0 planar\n    DAV1D_PIXEL_LAYOUT_I422, ///< 4:2:2 planar\n    DAV1D_PIXEL_LAYOUT_I444, ///< 4:4:4 planar\n};\n\nenum Dav1dFrameType {\n    DAV1D_FRAME_TYPE_KEY = 0,    ///< Key Intra frame\n    DAV1D_FRAME_TYPE_INTER = 1,  ///< Inter frame\n    DAV1D_FRAME_TYPE_INTRA = 2,  ///< Non key Intra frame\n    DAV1D_FRAME_TYPE_SWITCH = 3, ///< Switch Inter frame\n};\n\nenum Dav1dColorPrimaries {\n    DAV1D_COLOR_PRI_BT709 = 1,\n    DAV1D_COLOR_PRI_UNKNOWN = 2,\n    DAV1D_COLOR_PRI_BT470M = 4,\n    DAV1D_COLOR_PRI_BT470BG = 5,\n    DAV1D_COLOR_PRI_BT601 = 6,\n    DAV1D_COLOR_PRI_SMPTE240 = 7,\n    DAV1D_COLOR_PRI_FILM = 8,\n    DAV1D_COLOR_PRI_BT2020 = 9,\n    DAV1D_COLOR_PRI_XYZ = 10,\n    DAV1D_COLOR_PRI_SMPTE431 = 11,\n    DAV1D_COLOR_PRI_SMPTE432 = 12,\n    DAV1D_COLOR_PRI_EBU3213 = 22,\n    DAV1D_COLOR_PRI_RESERVED = 255,\n};\n\nenum Dav1dTransferCharacteristics {\n    DAV1D_TRC_BT709 = 1,\n    DAV1D_TRC_UNKNOWN = 2,\n    DAV1D_TRC_BT470M = 4,\n    DAV1D_TRC_BT470BG = 5,\n    DAV1D_TRC_BT601 = 6,\n    DAV1D_TRC_SMPTE240 = 7,\n    DAV1D_TRC_LINEAR = 8,\n    DAV1D_TRC_LOG100 = 9,         ///< logarithmic (100:1 range)\n    DAV1D_TRC_LOG100_SQRT10 = 10, ///< lograithmic (100*sqrt(10):1 range)\n    DAV1D_TRC_IEC61966 = 11,\n    DAV1D_TRC_BT1361 = 12,\n    DAV1D_TRC_SRGB = 13,\n    DAV1D_TRC_BT2020_10BIT = 14,\n    DAV1D_TRC_BT2020_12BIT = 15,\n    DAV1D_TRC_SMPTE2084 = 16,     ///< PQ\n    DAV1D_TRC_SMPTE428 = 17,\n    DAV1D_TRC_HLG = 18,           ///< hybrid log/gamma (BT.2100 / ARIB STD-B67)\n    DAV1D_TRC_RESERVED = 255,\n};\n\nenum Dav1dMatrixCoefficients {\n    DAV1D_MC_IDENTITY = 0,\n    DAV1D_MC_BT709 = 1,\n    DAV1D_MC_UNKNOWN = 2,\n    DAV1D_MC_FCC = 4,\n    DAV1D_MC_BT470BG = 5,\n    DAV1D_MC_BT601 = 6,\n    DAV1D_MC_SMPTE240 = 7,\n    DAV1D_MC_SMPTE_YCGCO = 8,\n    DAV1D_MC_BT2020_NCL = 9,\n    DAV1D_MC_BT2020_CL = 10,\n    DAV1D_MC_SMPTE2085 = 11,\n    DAV1D_MC_CHROMAT_NCL = 12, ///< Chromaticity-derived\n    DAV1D_MC_CHROMAT_CL = 13,\n    DAV1D_MC_ICTCP = 14,\n    DAV1D_MC_RESERVED = 255,\n};\n\nenum Dav1dChromaSamplePosition {\n    DAV1D_CHR_UNKNOWN = 0,\n    DAV1D_CHR_VERTICAL = 1,  ///< Horizontally co-located with luma(0, 0)\n                           ///< sample, between two vertical samples\n    DAV1D_CHR_COLOCATED = 2, ///< Co-located with luma(0, 0) sample\n};\n\ntypedef struct Dav1dContentLightLevel {\n    uint16_t max_content_light_level;\n    uint16_t max_frame_average_light_level;\n} Dav1dContentLightLevel;\n\ntypedef struct Dav1dMasteringDisplay {\n    uint16_t primaries[3][2]; ///< 0.16 fixed point\n    uint16_t white_point[2]; ///< 0.16 fixed point\n    uint32_t max_luminance; ///< 24.8 fixed point\n    uint32_t min_luminance; ///< 18.14 fixed point\n} Dav1dMasteringDisplay;\n\ntypedef struct Dav1dITUTT35 {\n    uint8_t  country_code;\n    uint8_t  country_code_extension_byte;\n    size_t   payload_size;\n    uint8_t *payload;\n} Dav1dITUTT35;\n\ntypedef struct Dav1dSequenceHeader {\n    /**\n     * Stream profile, 0 for 8-10 bits/component 4:2:0 or monochrome;\n     * 1 for 8-10 bits/component 4:4:4; 2 for 4:2:2 at any bits/component,\n     * or 12 bits/component at any chroma subsampling.\n     */\n    uint8_t profile;\n    /**\n     * Maximum dimensions for this stream. In non-scalable streams, these\n     * are often the actual dimensions of the stream, although that is not\n     * a normative requirement.\n     */\n    int max_width, max_height;\n    enum Dav1dPixelLayout layout; ///< format of the picture\n    enum Dav1dColorPrimaries pri; ///< color primaries (av1)\n    enum Dav1dTransferCharacteristics trc; ///< transfer characteristics (av1)\n    enum Dav1dMatrixCoefficients mtrx; ///< matrix coefficients (av1)\n    enum Dav1dChromaSamplePosition chr; ///< chroma sample position (av1)\n    /**\n     * 0, 1 and 2 mean 8, 10 or 12 bits/component, respectively. This is not\n     * exactly the same as 'hbd' from the spec; the spec's hbd distinguishes\n     * between 8 (0) and 10-12 (1) bits/component, and another element\n     * (twelve_bit) to distinguish between 10 and 12 bits/component. To get\n     * the spec's hbd, use !!our_hbd, and to get twelve_bit, use hbd == 2.\n     */\n    uint8_t hbd;\n    /**\n     * Pixel data uses JPEG pixel range ([0,255] for 8bits) instead of\n     * MPEG pixel range ([16,235] for 8bits luma, [16,240] for 8bits chroma).\n     */\n    uint8_t color_range;\n\n    uint8_t num_operating_points;\n    struct Dav1dSequenceHeaderOperatingPoint {\n        uint8_t major_level, minor_level;\n        uint8_t initial_display_delay;\n        uint16_t idc;\n        uint8_t tier;\n        uint8_t decoder_model_param_present;\n        uint8_t display_model_param_present;\n    } operating_points[DAV1D_MAX_OPERATING_POINTS];\n\n    uint8_t still_picture;\n    uint8_t reduced_still_picture_header;\n    uint8_t timing_info_present;\n    uint32_t num_units_in_tick;\n    uint32_t time_scale;\n    uint8_t equal_picture_interval;\n    uint32_t num_ticks_per_picture;\n    uint8_t decoder_model_info_present;\n    uint8_t encoder_decoder_buffer_delay_length;\n    uint32_t num_units_in_decoding_tick;\n    uint8_t buffer_removal_delay_length;\n    uint8_t frame_presentation_delay_length;\n    uint8_t display_model_info_present;\n    uint8_t width_n_bits, height_n_bits;\n    uint8_t frame_id_numbers_present;\n    uint8_t delta_frame_id_n_bits;\n    uint8_t frame_id_n_bits;\n    uint8_t sb128;\n    uint8_t filter_intra;\n    uint8_t intra_edge_filter;\n    uint8_t inter_intra;\n    uint8_t masked_compound;\n    uint8_t warped_motion;\n    uint8_t dual_filter;\n    uint8_t order_hint;\n    uint8_t jnt_comp;\n    uint8_t ref_frame_mvs;\n    enum Dav1dAdaptiveBoolean screen_content_tools;\n    enum Dav1dAdaptiveBoolean force_integer_mv;\n    uint8_t order_hint_n_bits;\n    uint8_t super_res;\n    uint8_t cdef;\n    uint8_t restoration;\n    uint8_t ss_hor, ss_ver, monochrome;\n    uint8_t color_description_present;\n    uint8_t separate_uv_delta_q;\n    uint8_t film_grain_present;\n\n    // Dav1dSequenceHeaders of the same sequence are required to be\n    // bit-identical until this offset. See 7.5 \"Ordering of OBUs\":\n    //   Within a particular coded video sequence, the contents of\n    //   sequence_header_obu must be bit-identical each time the\n    //   sequence header appears except for the contents of\n    //   operating_parameters_info.\n    struct Dav1dSequenceHeaderOperatingParameterInfo {\n        uint32_t decoder_buffer_delay;\n        uint32_t encoder_buffer_delay;\n        uint8_t low_delay_mode;\n    } operating_parameter_info[DAV1D_MAX_OPERATING_POINTS];\n} Dav1dSequenceHeader;\n\ntypedef struct Dav1dSegmentationData {\n    int16_t delta_q;\n    int8_t delta_lf_y_v, delta_lf_y_h, delta_lf_u, delta_lf_v;\n    int8_t ref;\n    uint8_t skip;\n    uint8_t globalmv;\n} Dav1dSegmentationData;\n\ntypedef struct Dav1dSegmentationDataSet {\n    Dav1dSegmentationData d[DAV1D_MAX_SEGMENTS];\n    uint8_t preskip;\n    int8_t last_active_segid;\n} Dav1dSegmentationDataSet;\n\ntypedef struct Dav1dLoopfilterModeRefDeltas {\n    int8_t mode_delta[2 /* is_zeromv */];\n    int8_t ref_delta[DAV1D_TOTAL_REFS_PER_FRAME];\n} Dav1dLoopfilterModeRefDeltas;\n\ntypedef struct Dav1dFilmGrainData {\n    unsigned seed;\n    int num_y_points;\n    uint8_t y_points[14][2 /* value, scaling */];\n    int chroma_scaling_from_luma;\n    int num_uv_points[2];\n    uint8_t uv_points[2][10][2 /* value, scaling */];\n    int scaling_shift;\n    int ar_coeff_lag;\n    int8_t ar_coeffs_y[24];\n    int8_t ar_coeffs_uv[2][25 + 3 /* padding for alignment purposes */];\n    uint64_t ar_coeff_shift;\n    int grain_scale_shift;\n    int uv_mult[2];\n    int uv_luma_mult[2];\n    int uv_offset[2];\n    int overlap_flag;\n    int clip_to_restricted_range;\n} Dav1dFilmGrainData;\n\ntypedef struct Dav1dFrameHeader {\n    struct {\n        Dav1dFilmGrainData data;\n        uint8_t present, update;\n    } film_grain; ///< film grain parameters\n    enum Dav1dFrameType frame_type; ///< type of the picture\n    int width[2 /* { coded_width, superresolution_upscaled_width } */], height;\n    uint8_t frame_offset; ///< frame number\n    uint8_t temporal_id; ///< temporal id of the frame for SVC\n    uint8_t spatial_id; ///< spatial id of the frame for SVC\n\n    uint8_t show_existing_frame;\n    uint8_t existing_frame_idx;\n    uint32_t frame_id;\n    uint32_t frame_presentation_delay;\n    uint8_t show_frame;\n    uint8_t showable_frame;\n    uint8_t error_resilient_mode;\n    uint8_t disable_cdf_update;\n    uint8_t allow_screen_content_tools;\n    uint8_t force_integer_mv;\n    uint8_t frame_size_override;\n    uint8_t primary_ref_frame;\n    uint8_t buffer_removal_time_present;\n    struct Dav1dFrameHeaderOperatingPoint {\n        uint32_t buffer_removal_time;\n    } operating_points[DAV1D_MAX_OPERATING_POINTS];\n    uint8_t refresh_frame_flags;\n    int render_width, render_height;\n    struct {\n        uint8_t width_scale_denominator;\n        uint8_t enabled;\n    } super_res;\n    uint8_t have_render_size;\n    uint8_t allow_intrabc;\n    uint8_t frame_ref_short_signaling;\n    int8_t refidx[DAV1D_REFS_PER_FRAME];\n    uint8_t hp;\n    enum Dav1dFilterMode subpel_filter_mode;\n    uint8_t switchable_motion_mode;\n    uint8_t use_ref_frame_mvs;\n    uint8_t refresh_context;\n    struct {\n        uint8_t uniform;\n        uint8_t n_bytes;\n        uint8_t min_log2_cols, max_log2_cols, log2_cols, cols;\n        uint8_t min_log2_rows, max_log2_rows, log2_rows, rows;\n        uint16_t col_start_sb[DAV1D_MAX_TILE_COLS + 1];\n        uint16_t row_start_sb[DAV1D_MAX_TILE_ROWS + 1];\n        uint16_t update;\n    } tiling;\n    struct {\n        uint8_t yac;\n        int8_t ydc_delta;\n        int8_t udc_delta, uac_delta, vdc_delta, vac_delta;\n        uint8_t qm, qm_y, qm_u, qm_v;\n    } quant;\n    struct {\n        uint8_t enabled, update_map, temporal, update_data;\n        Dav1dSegmentationDataSet seg_data;\n        uint8_t lossless[DAV1D_MAX_SEGMENTS], qidx[DAV1D_MAX_SEGMENTS];\n    } segmentation;\n    struct {\n        struct {\n            uint8_t present;\n            uint8_t res_log2;\n        } q;\n        struct {\n            uint8_t present;\n            uint8_t res_log2;\n            uint8_t multi;\n        } lf;\n    } delta;\n    uint8_t all_lossless;\n    struct {\n        uint8_t level_y[2 /* dir */];\n        uint8_t level_u, level_v;\n        uint8_t mode_ref_delta_enabled;\n        uint8_t mode_ref_delta_update;\n        Dav1dLoopfilterModeRefDeltas mode_ref_deltas;\n        uint8_t sharpness;\n    } loopfilter;\n    struct {\n        uint8_t damping;\n        uint8_t n_bits;\n        uint8_t y_strength[DAV1D_MAX_CDEF_STRENGTHS];\n        uint8_t uv_strength[DAV1D_MAX_CDEF_STRENGTHS];\n    } cdef;\n    struct {\n        enum Dav1dRestorationType type[3 /* plane */];\n        uint8_t unit_size[2 /* y, uv */];\n    } restoration;\n    enum Dav1dTxfmMode txfm_mode;\n    uint8_t switchable_comp_refs;\n    uint8_t skip_mode_allowed, skip_mode_enabled;\n    int8_t skip_mode_refs[2];\n    uint8_t warp_motion;\n    uint8_t reduced_txtp_set;\n    Dav1dWarpedMotionParams gmv[DAV1D_REFS_PER_FRAME];\n} Dav1dFrameHeader;\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_HEADERS_H */\n"
  },
  {
    "path": "thirdparty/64/include/dav1d/picture.h",
    "content": "/*\n * Copyright © 2018-2020, VideoLAN and dav1d authors\n * Copyright © 2018, Two Orioles, LLC\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_PICTURE_H\n#define DAV1D_PICTURE_H\n\n#include <stddef.h>\n#include <stdint.h>\n\n#include \"common.h\"\n#include \"headers.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Number of bytes to align AND pad picture memory buffers by, so that SIMD\n * implementations can over-read by a few bytes, and use aligned read/write\n * instructions. */\n#define DAV1D_PICTURE_ALIGNMENT 64\n\ntypedef struct Dav1dPictureParameters {\n    int w; ///< width (in pixels)\n    int h; ///< height (in pixels)\n    enum Dav1dPixelLayout layout; ///< format of the picture\n    int bpc; ///< bits per pixel component (8 or 10)\n} Dav1dPictureParameters;\n\ntypedef struct Dav1dPicture {\n    Dav1dSequenceHeader *seq_hdr;\n    Dav1dFrameHeader *frame_hdr;\n\n    /**\n     * Pointers to planar image data (Y is [0], U is [1], V is [2]). The data\n     * should be bytes (for 8 bpc) or words (for 10 bpc). In case of words\n     * containing 10 bpc image data, the pixels should be located in the LSB\n     * bits, so that values range between [0, 1023]; the upper bits should be\n     * zero'ed out.\n     */\n    void *data[3];\n\n    /**\n     * Number of bytes between 2 lines in data[] for luma [0] or chroma [1].\n     */\n    ptrdiff_t stride[2];\n\n    Dav1dPictureParameters p;\n    Dav1dDataProps m;\n\n    /**\n     * High Dynamic Range Content Light Level metadata applying to this picture,\n     * as defined in section 5.8.3 and 6.7.3\n     */\n    Dav1dContentLightLevel *content_light;\n    /**\n     * High Dynamic Range Mastering Display Color Volume metadata applying to\n     * this picture, as defined in section 5.8.4 and 6.7.4\n     */\n    Dav1dMasteringDisplay *mastering_display;\n    /**\n     * Array of ITU-T T.35 metadata as defined in section 5.8.2 and 6.7.2\n     */\n    Dav1dITUTT35 *itut_t35;\n\n    /**\n     * Number of ITU-T T35 metadata entries in the array\n     */\n    size_t n_itut_t35;\n\n    uintptr_t reserved[4]; ///< reserved for future use\n\n    struct Dav1dRef *frame_hdr_ref; ///< Dav1dFrameHeader allocation origin\n    struct Dav1dRef *seq_hdr_ref; ///< Dav1dSequenceHeader allocation origin\n    struct Dav1dRef *content_light_ref; ///< Dav1dContentLightLevel allocation origin\n    struct Dav1dRef *mastering_display_ref; ///< Dav1dMasteringDisplay allocation origin\n    struct Dav1dRef *itut_t35_ref; ///< Dav1dITUTT35 allocation origin\n    uintptr_t reserved_ref[4]; ///< reserved for future use\n    struct Dav1dRef *ref; ///< Frame data allocation origin\n\n    void *allocator_data; ///< pointer managed by the allocator\n} Dav1dPicture;\n\ntypedef struct Dav1dPicAllocator {\n    void *cookie; ///< custom data to pass to the allocator callbacks.\n    /**\n     * Allocate the picture buffer based on the Dav1dPictureParameters.\n     *\n     * The data[0], data[1] and data[2] must be DAV1D_PICTURE_ALIGNMENT byte\n     * aligned and with a pixel width/height multiple of 128 pixels. Any\n     * allocated memory area should also be padded by DAV1D_PICTURE_ALIGNMENT\n     * bytes.\n     * data[1] and data[2] must share the same stride[1].\n     *\n     * This function will be called on the main thread (the thread which calls\n     * dav1d_get_picture()).\n     *\n     * @param  pic The picture to allocate the buffer for. The callback needs to\n     *             fill the picture data[0], data[1], data[2], stride[0] and\n     *             stride[1].\n     *             The allocator can fill the pic allocator_data pointer with\n     *             a custom pointer that will be passed to\n     *             release_picture_callback().\n     * @param cookie Custom pointer passed to all calls.\n     *\n     * @note No fields other than data, stride and allocator_data must be filled\n     *       by this callback.\n     * @return 0 on success. A negative DAV1D_ERR value on error.\n     */\n    int (*alloc_picture_callback)(Dav1dPicture *pic, void *cookie);\n    /**\n     * Release the picture buffer.\n     *\n     * If frame threading is used, this function may be called by the main\n     * thread (the thread which calls dav1d_get_picture()) or any of the frame\n     * threads and thus must be thread-safe. If frame threading is not used,\n     * this function will only be called on the main thread.\n     *\n     * @param pic    The picture that was filled by alloc_picture_callback().\n     * @param cookie Custom pointer passed to all calls.\n     */\n    void (*release_picture_callback)(Dav1dPicture *pic, void *cookie);\n} Dav1dPicAllocator;\n\n/**\n * Release reference to a picture.\n */\nDAV1D_API void dav1d_picture_unref(Dav1dPicture *p);\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_PICTURE_H */\n"
  },
  {
    "path": "thirdparty/64/include/dav1d/version.h",
    "content": "/*\n * Copyright © 2019-2024, VideoLAN and dav1d authors\n * All rights reserved.\n *\n * Redistribution and use in source and binary forms, with or without\n * modification, are permitted provided that the following conditions are met:\n *\n * 1. Redistributions of source code must retain the above copyright notice, this\n *    list of conditions and the following disclaimer.\n *\n * 2. Redistributions in binary form must reproduce the above copyright notice,\n *    this list of conditions and the following disclaimer in the documentation\n *    and/or other materials provided with the distribution.\n *\n * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND\n * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED\n * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE\n * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR\n * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES\n * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;\n * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND\n * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT\n * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n */\n\n#ifndef DAV1D_VERSION_H\n#define DAV1D_VERSION_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define DAV1D_API_VERSION_MAJOR 7\n#define DAV1D_API_VERSION_MINOR 0\n#define DAV1D_API_VERSION_PATCH 0\n\n/**\n * Extract version components from the value returned by\n * dav1d_version_int()\n */\n#define DAV1D_API_MAJOR(v) (((v) >> 16) & 0xFF)\n#define DAV1D_API_MINOR(v) (((v) >>  8) & 0xFF)\n#define DAV1D_API_PATCH(v) (((v) >>  0) & 0xFF)\n\n#ifdef __cplusplus\n} /* extern \"C\" */\n#endif\n\n#endif /* DAV1D_VERSION_H */\n"
  },
  {
    "path": "thirdparty/64/include/gmp.h",
    "content": "/* Definitions for GNU multiple precision functions.   -*- mode: c -*-\n\nCopyright 1991, 1993-1997, 1999-2016, 2020, 2021 Free Software\nFoundation, Inc.\n\nThis file is part of the GNU MP Library.\n\nThe GNU MP Library is free software; you can redistribute it and/or modify\nit under the terms of either:\n\n  * the GNU Lesser General Public License as published by the Free\n    Software Foundation; either version 3 of the License, or (at your\n    option) any later version.\n\nor\n\n  * the GNU General Public License as published by the Free Software\n    Foundation; either version 2 of the License, or (at your option) any\n    later version.\n\nor both in parallel, as here.\n\nThe GNU MP Library is distributed in the hope that it will be useful, but\nWITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY\nor FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License\nfor more details.\n\nYou should have received copies of the GNU General Public License and the\nGNU Lesser General Public License along with the GNU MP Library.  If not,\nsee https://www.gnu.org/licenses/.  */\n\n#ifndef __GMP_H__\n\n#if defined (__cplusplus)\n#include <iosfwd>   /* for std::istream, std::ostream, std::string */\n#include <cstdio>\n#endif\n\n\n/* Instantiated by configure. */\n#if ! defined (__GMP_WITHIN_CONFIGURE)\n#define __GMP_HAVE_HOST_CPU_FAMILY_power   0\n#define __GMP_HAVE_HOST_CPU_FAMILY_powerpc 0\n#define GMP_LIMB_BITS                      64\n#define GMP_NAIL_BITS                      0\n#endif\n#define GMP_NUMB_BITS     (GMP_LIMB_BITS - GMP_NAIL_BITS)\n#define GMP_NUMB_MASK     ((~ __GMP_CAST (mp_limb_t, 0)) >> GMP_NAIL_BITS)\n#define GMP_NUMB_MAX      GMP_NUMB_MASK\n#define GMP_NAIL_MASK     (~ GMP_NUMB_MASK)\n\n\n#ifndef __GNU_MP__\n#define __GNU_MP__ 6\n\n#include <stddef.h>    /* for size_t */\n#include <limits.h>\n\n/* Instantiated by configure. */\n#if ! defined (__GMP_WITHIN_CONFIGURE)\n#define _LONG_LONG_LIMB 1\n#define __GMP_LIBGMP_DLL  0\n#endif\n\n\n/* __GMP_DECLSPEC supports Windows DLL versions of libgmp, and is empty in\n   all other circumstances.\n\n   When compiling objects for libgmp, __GMP_DECLSPEC is an export directive,\n   or when compiling for an application it's an import directive.  The two\n   cases are differentiated by __GMP_WITHIN_GMP defined by the GMP Makefiles\n   (and not defined from an application).\n\n   __GMP_DECLSPEC_XX is similarly used for libgmpxx.  __GMP_WITHIN_GMPXX\n   indicates when building libgmpxx, and in that case libgmpxx functions are\n   exports, but libgmp functions which might get called are imports.\n\n   Libtool DLL_EXPORT define is not used.\n\n   There's no attempt to support GMP built both static and DLL.  Doing so\n   would mean applications would have to tell us which of the two is going\n   to be used when linking, and that seems very tedious and error prone if\n   using GMP by hand, and equally tedious from a package since autoconf and\n   automake don't give much help.\n\n   __GMP_DECLSPEC is required on all documented global functions and\n   variables, the various internals in gmp-impl.h etc can be left unadorned.\n   But internals used by the test programs or speed measuring programs\n   should have __GMP_DECLSPEC, and certainly constants or variables must\n   have it or the wrong address will be resolved.\n\n   In gcc __declspec can go at either the start or end of a prototype.\n\n   In Microsoft C __declspec must go at the start, or after the type like\n   void __declspec(...) *foo()\".  There's no __dllexport or anything to\n   guard against someone foolish #defining dllexport.  _export used to be\n   available, but no longer.\n\n   In Borland C _export still exists, but needs to go after the type, like\n   \"void _export foo();\".  Would have to change the __GMP_DECLSPEC syntax to\n   make use of that.  Probably more trouble than it's worth.  */\n\n#if defined (__GNUC__)\n#define __GMP_DECLSPEC_EXPORT  __declspec(__dllexport__)\n#define __GMP_DECLSPEC_IMPORT  __declspec(__dllimport__)\n#endif\n#if defined (_MSC_VER) || defined (__BORLANDC__)\n#define __GMP_DECLSPEC_EXPORT  __declspec(dllexport)\n#define __GMP_DECLSPEC_IMPORT  __declspec(dllimport)\n#endif\n#ifdef __WATCOMC__\n#define __GMP_DECLSPEC_EXPORT  __export\n#define __GMP_DECLSPEC_IMPORT  __import\n#endif\n#ifdef __IBMC__\n#define __GMP_DECLSPEC_EXPORT  _Export\n#define __GMP_DECLSPEC_IMPORT  _Import\n#endif\n\n#if __GMP_LIBGMP_DLL\n#ifdef __GMP_WITHIN_GMP\n/* compiling to go into a DLL libgmp */\n#define __GMP_DECLSPEC  __GMP_DECLSPEC_EXPORT\n#else\n/* compiling to go into an application which will link to a DLL libgmp */\n#define __GMP_DECLSPEC  __GMP_DECLSPEC_IMPORT\n#endif\n#else\n/* all other cases */\n#define __GMP_DECLSPEC\n#endif\n\n\n#ifdef __GMP_SHORT_LIMB\ntypedef unsigned int\t\tmp_limb_t;\ntypedef int\t\t\tmp_limb_signed_t;\n#else\n#ifdef _LONG_LONG_LIMB\ntypedef unsigned long long int\tmp_limb_t;\ntypedef long long int\t\tmp_limb_signed_t;\n#else\ntypedef unsigned long int\tmp_limb_t;\ntypedef long int\t\tmp_limb_signed_t;\n#endif\n#endif\ntypedef unsigned long int\tmp_bitcnt_t;\n\n/* For reference, note that the name __mpz_struct gets into C++ mangled\n   function names, which means although the \"__\" suggests an internal, we\n   must leave this name for binary compatibility.  */\ntypedef struct\n{\n  int _mp_alloc;\t\t/* Number of *limbs* allocated and pointed\n\t\t\t\t   to by the _mp_d field.  */\n  int _mp_size;\t\t\t/* abs(_mp_size) is the number of limbs the\n\t\t\t\t   last field points to.  If _mp_size is\n\t\t\t\t   negative this is a negative number.  */\n  mp_limb_t *_mp_d;\t\t/* Pointer to the limbs.  */\n} __mpz_struct;\n\n#endif /* __GNU_MP__ */\n\n\ntypedef __mpz_struct MP_INT;    /* gmp 1 source compatibility */\ntypedef __mpz_struct mpz_t[1];\n\ntypedef mp_limb_t *\t\tmp_ptr;\ntypedef const mp_limb_t *\tmp_srcptr;\n#if defined (_CRAY) && ! defined (_CRAYMPP)\n/* plain `int' is much faster (48 bits) */\n#define __GMP_MP_SIZE_T_INT     1\ntypedef int\t\t\tmp_size_t;\ntypedef int\t\t\tmp_exp_t;\n#else\n#define __GMP_MP_SIZE_T_INT     0\ntypedef long int\t\tmp_size_t;\ntypedef long int\t\tmp_exp_t;\n#endif\n\ntypedef struct\n{\n  __mpz_struct _mp_num;\n  __mpz_struct _mp_den;\n} __mpq_struct;\n\ntypedef __mpq_struct MP_RAT;    /* gmp 1 source compatibility */\ntypedef __mpq_struct mpq_t[1];\n\ntypedef struct\n{\n  int _mp_prec;\t\t\t/* Max precision, in number of `mp_limb_t's.\n\t\t\t\t   Set by mpf_init and modified by\n\t\t\t\t   mpf_set_prec.  The area pointed to by the\n\t\t\t\t   _mp_d field contains `prec' + 1 limbs.  */\n  int _mp_size;\t\t\t/* abs(_mp_size) is the number of limbs the\n\t\t\t\t   last field points to.  If _mp_size is\n\t\t\t\t   negative this is a negative number.  */\n  mp_exp_t _mp_exp;\t\t/* Exponent, in the base of `mp_limb_t'.  */\n  mp_limb_t *_mp_d;\t\t/* Pointer to the limbs.  */\n} __mpf_struct;\n\n/* typedef __mpf_struct MP_FLOAT; */\ntypedef __mpf_struct mpf_t[1];\n\n/* Available random number generation algorithms.  */\ntypedef enum\n{\n  GMP_RAND_ALG_DEFAULT = 0,\n  GMP_RAND_ALG_LC = GMP_RAND_ALG_DEFAULT /* Linear congruential.  */\n} gmp_randalg_t;\n\n/* Random state struct.  */\ntypedef struct\n{\n  mpz_t _mp_seed;\t  /* _mp_d member points to state of the generator. */\n  gmp_randalg_t _mp_alg;  /* Currently unused. */\n  union {\n    void *_mp_lc;         /* Pointer to function pointers structure.  */\n  } _mp_algdata;\n} __gmp_randstate_struct;\ntypedef __gmp_randstate_struct gmp_randstate_t[1];\n\n/* Types for function declarations in gmp files.  */\n/* ??? Should not pollute user name space with these ??? */\ntypedef const __mpz_struct *mpz_srcptr;\ntypedef __mpz_struct *mpz_ptr;\ntypedef const __mpf_struct *mpf_srcptr;\ntypedef __mpf_struct *mpf_ptr;\ntypedef const __mpq_struct *mpq_srcptr;\ntypedef __mpq_struct *mpq_ptr;\ntypedef __gmp_randstate_struct *gmp_randstate_ptr;\ntypedef const __gmp_randstate_struct *gmp_randstate_srcptr;\n\n\n#if __GMP_LIBGMP_DLL\n#ifdef __GMP_WITHIN_GMPXX\n/* compiling to go into a DLL libgmpxx */\n#define __GMP_DECLSPEC_XX  __GMP_DECLSPEC_EXPORT\n#else\n/* compiling to go into a application which will link to a DLL libgmpxx */\n#define __GMP_DECLSPEC_XX  __GMP_DECLSPEC_IMPORT\n#endif\n#else\n/* all other cases */\n#define __GMP_DECLSPEC_XX\n#endif\n\n\n#ifndef __MPN\n#define __MPN(x) __gmpn_##x\n#endif\n\n/* For reference, \"defined(EOF)\" cannot be used here.  In g++ 2.95.4,\n   <iostream> defines EOF but not FILE.  */\n#if defined (FILE)                                              \\\n  || defined (H_STDIO)                                          \\\n  || defined (_H_STDIO)               /* AIX */                 \\\n  || defined (_STDIO_H)               /* glibc, Sun, SCO */     \\\n  || defined (_STDIO_H_)              /* BSD, OSF */            \\\n  || defined (__STDIO_H)              /* Borland */             \\\n  || defined (__STDIO_H__)            /* IRIX */                \\\n  || defined (_STDIO_INCLUDED)        /* HPUX */                \\\n  || defined (__dj_include_stdio_h_)  /* DJGPP */               \\\n  || defined (_FILE_DEFINED)          /* Microsoft */           \\\n  || defined (__STDIO__)              /* Apple MPW MrC */       \\\n  || defined (_MSL_STDIO_H)           /* Metrowerks */          \\\n  || defined (_STDIO_H_INCLUDED)      /* QNX4 */\t\t\\\n  || defined (_ISO_STDIO_ISO_H)       /* Sun C++ */\t\t\\\n  || defined (__STDIO_LOADED)         /* VMS */\t\t\t\\\n  || defined (_STDIO)                 /* HPE NonStop */         \\\n  || defined (__DEFINED_FILE)         /* musl */\n#define _GMP_H_HAVE_FILE 1\n#endif\n\n/* In ISO C, if a prototype involving \"struct obstack *\" is given without\n   that structure defined, then the struct is scoped down to just the\n   prototype, causing a conflict if it's subsequently defined for real.  So\n   only give prototypes if we've got obstack.h.  */\n#if defined (_OBSTACK_H)   /* glibc <obstack.h> */\n#define _GMP_H_HAVE_OBSTACK 1\n#endif\n\n/* The prototypes for gmp_vprintf etc are provided only if va_list is defined,\n   via an application having included <stdarg.h>.  Usually va_list is a typedef\n   so can't be tested directly, but C99 specifies that va_start is a macro.\n\n   <stdio.h> will define some sort of va_list for vprintf and vfprintf, but\n   let's not bother trying to use that since it's not standard and since\n   application uses for gmp_vprintf etc will almost certainly require the\n   whole <stdarg.h> anyway.  */\n\n#ifdef va_start\n#define _GMP_H_HAVE_VA_LIST 1\n#endif\n\n/* Test for gcc >= maj.min, as per __GNUC_PREREQ in glibc */\n#if defined (__GNUC__) && defined (__GNUC_MINOR__)\n#define __GMP_GNUC_PREREQ(maj, min) \\\n  ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))\n#else\n#define __GMP_GNUC_PREREQ(maj, min)  0\n#endif\n\n/* \"pure\" is in gcc 2.96 and up, see \"(gcc)Function Attributes\".  Basically\n   it means a function does nothing but examine its arguments and memory\n   (global or via arguments) to generate a return value, but changes nothing\n   and has no side-effects.  __GMP_NO_ATTRIBUTE_CONST_PURE lets\n   tune/common.c etc turn this off when trying to write timing loops.  */\n#if __GMP_GNUC_PREREQ (2,96) && ! defined (__GMP_NO_ATTRIBUTE_CONST_PURE)\n#define __GMP_ATTRIBUTE_PURE   __attribute__ ((__pure__))\n#else\n#define __GMP_ATTRIBUTE_PURE\n#endif\n\n\n/* __GMP_CAST allows us to use static_cast in C++, so our macros are clean\n   to \"g++ -Wold-style-cast\".\n\n   Casts in \"extern inline\" code within an extern \"C\" block don't induce\n   these warnings, so __GMP_CAST only needs to be used on documented\n   macros.  */\n\n#ifdef __cplusplus\n#define __GMP_CAST(type, expr)  (static_cast<type> (expr))\n#else\n#define __GMP_CAST(type, expr)  ((type) (expr))\n#endif\n\n\n/* An empty \"throw ()\" means the function doesn't throw any C++ exceptions,\n   this can save some stack frame info in applications.\n\n   Currently it's given only on functions which never divide-by-zero etc,\n   don't allocate memory, and are expected to never need to allocate memory.\n   This leaves open the possibility of a C++ throw from a future GMP\n   exceptions scheme.\n\n   mpz_set_ui etc are omitted to leave open the lazy allocation scheme\n   described in doc/tasks.html.  mpz_get_d etc are omitted to leave open\n   exceptions for float overflows.\n\n   Note that __GMP_NOTHROW must be given on any inlines the same as on their\n   prototypes (for g++ at least, where they're used together).  Note also\n   that g++ 3.0 demands that __GMP_NOTHROW is before other attributes like\n   __GMP_ATTRIBUTE_PURE.  */\n\n#if defined (__cplusplus)\n#if __cplusplus >= 201103L\n#define __GMP_NOTHROW  noexcept\n#else\n#define __GMP_NOTHROW  throw ()\n#endif\n#else\n#define __GMP_NOTHROW\n#endif\n\n\n/* PORTME: What other compilers have a useful \"extern inline\"?  \"static\n   inline\" would be an acceptable substitute if the compiler (or linker)\n   discards unused statics.  */\n\n /* gcc has __inline__ in all modes, including strict ansi.  Give a prototype\n    for an inline too, so as to correctly specify \"dllimport\" on windows, in\n    case the function is called rather than inlined.\n    GCC 4.3 and above with -std=c99 or -std=gnu99 implements ISO C99\n    inline semantics, unless -fgnu89-inline is used.  */\n#ifdef __GNUC__\n#if (defined __GNUC_STDC_INLINE__) || (__GNUC__ == 4 && __GNUC_MINOR__ == 2) \\\n  || (defined __GNUC_GNU_INLINE__ && defined __cplusplus)\n#define __GMP_EXTERN_INLINE extern __inline__ __attribute__ ((__gnu_inline__))\n#else\n#define __GMP_EXTERN_INLINE      extern __inline__\n#endif\n#define __GMP_INLINE_PROTOTYPES  1\n#endif\n\n/* DEC C (eg. version 5.9) supports \"static __inline foo()\", even in -std1\n   strict ANSI mode.  Inlining is done even when not optimizing (ie. -O0\n   mode, which is the default), but an unnecessary local copy of foo is\n   emitted unless -O is used.  \"extern __inline\" is accepted, but the\n   \"extern\" appears to be ignored, ie. it becomes a plain global function\n   but which is inlined within its file.  Don't know if all old versions of\n   DEC C supported __inline, but as a start let's do the right thing for\n   current versions.  */\n#ifdef __DECC\n#define __GMP_EXTERN_INLINE  static __inline\n#endif\n\n/* SCO OpenUNIX 8 cc supports \"static inline foo()\" but not in -Xc strict\n   ANSI mode (__STDC__ is 1 in that mode).  Inlining only actually takes\n   place under -O.  Without -O \"foo\" seems to be emitted whether it's used\n   or not, which is wasteful.  \"extern inline foo()\" isn't useful, the\n   \"extern\" is apparently ignored, so foo is inlined if possible but also\n   emitted as a global, which causes multiple definition errors when\n   building a shared libgmp.  */\n#ifdef __SCO_VERSION__\n#if __SCO_VERSION__ > 400000000 && __STDC__ != 1 \\\n  && ! defined (__GMP_EXTERN_INLINE)\n#define __GMP_EXTERN_INLINE  static inline\n#endif\n#endif\n\n/* Microsoft's C compiler accepts __inline */\n#ifdef _MSC_VER\n#define __GMP_EXTERN_INLINE  __inline\n#endif\n\n/* Recent enough Sun C compilers want \"inline\" */\n#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x560 \\\n  && ! defined (__GMP_EXTERN_INLINE)\n#define __GMP_EXTERN_INLINE  inline\n#endif\n\n/* Somewhat older Sun C compilers want \"static inline\" */\n#if defined (__SUNPRO_C) && __SUNPRO_C >= 0x540 \\\n  && ! defined (__GMP_EXTERN_INLINE)\n#define __GMP_EXTERN_INLINE  static inline\n#endif\n\n\n/* C++ always has \"inline\" and since it's a normal feature the linker should\n   discard duplicate non-inlined copies, or if it doesn't then that's a\n   problem for everyone, not just GMP.  */\n#if defined (__cplusplus) && ! defined (__GMP_EXTERN_INLINE)\n#define __GMP_EXTERN_INLINE  inline\n#endif\n\n/* Don't do any inlining within a configure run, since if the compiler ends\n   up emitting copies of the code into the object file it can end up\n   demanding the various support routines (like mpn_popcount) for linking,\n   making the \"alloca\" test and perhaps others fail.  And on hppa ia64 a\n   pre-release gcc 3.2 was seen not respecting the \"extern\" in \"extern\n   __inline__\", triggering this problem too.  */\n#if defined (__GMP_WITHIN_CONFIGURE) && ! __GMP_WITHIN_CONFIGURE_INLINE\n#undef __GMP_EXTERN_INLINE\n#endif\n\n/* By default, don't give a prototype when there's going to be an inline\n   version.  Note in particular that Cray C++ objects to the combination of\n   prototype and inline.  */\n#ifdef __GMP_EXTERN_INLINE\n#ifndef __GMP_INLINE_PROTOTYPES\n#define __GMP_INLINE_PROTOTYPES  0\n#endif\n#else\n#define __GMP_INLINE_PROTOTYPES  1\n#endif\n\n\n#define __GMP_ABS(x)   ((x) >= 0 ? (x) : -(x))\n#define __GMP_MAX(h,i) ((h) > (i) ? (h) : (i))\n\n\n/* __builtin_expect is in gcc 3.0, and not in 2.95. */\n#if __GMP_GNUC_PREREQ (3,0)\n#define __GMP_LIKELY(cond)    __builtin_expect ((cond) != 0, 1)\n#define __GMP_UNLIKELY(cond)  __builtin_expect ((cond) != 0, 0)\n#else\n#define __GMP_LIKELY(cond)    (cond)\n#define __GMP_UNLIKELY(cond)  (cond)\n#endif\n\n#ifdef _CRAY\n#define __GMP_CRAY_Pragma(str)  _Pragma (str)\n#else\n#define __GMP_CRAY_Pragma(str)\n#endif\n\n\n/* Allow direct user access to numerator and denominator of an mpq_t object.  */\n#define mpq_numref(Q) (&((Q)->_mp_num))\n#define mpq_denref(Q) (&((Q)->_mp_den))\n\n\n#if defined (__cplusplus)\nextern \"C\" {\nusing std::FILE;\n#endif\n\n#define mp_set_memory_functions __gmp_set_memory_functions\n__GMP_DECLSPEC void mp_set_memory_functions (void *(*) (size_t),\n\t\t\t\t      void *(*) (void *, size_t, size_t),\n\t\t\t\t      void (*) (void *, size_t)) __GMP_NOTHROW;\n\n#define mp_get_memory_functions __gmp_get_memory_functions\n__GMP_DECLSPEC void mp_get_memory_functions (void *(**) (size_t),\n\t\t\t\t      void *(**) (void *, size_t, size_t),\n\t\t\t\t      void (**) (void *, size_t)) __GMP_NOTHROW;\n\n#define mp_bits_per_limb __gmp_bits_per_limb\n__GMP_DECLSPEC extern const int mp_bits_per_limb;\n\n#define gmp_errno __gmp_errno\n__GMP_DECLSPEC extern int gmp_errno;\n\n#define gmp_version __gmp_version\n__GMP_DECLSPEC extern const char * const gmp_version;\n\n\n/**************** Random number routines.  ****************/\n\n/* obsolete */\n#define gmp_randinit __gmp_randinit\n__GMP_DECLSPEC void gmp_randinit (gmp_randstate_ptr, gmp_randalg_t, ...);\n\n#define gmp_randinit_default __gmp_randinit_default\n__GMP_DECLSPEC void gmp_randinit_default (gmp_randstate_ptr);\n\n#define gmp_randinit_lc_2exp __gmp_randinit_lc_2exp\n__GMP_DECLSPEC void gmp_randinit_lc_2exp (gmp_randstate_ptr, mpz_srcptr, unsigned long int, mp_bitcnt_t);\n\n#define gmp_randinit_lc_2exp_size __gmp_randinit_lc_2exp_size\n__GMP_DECLSPEC int gmp_randinit_lc_2exp_size (gmp_randstate_ptr, mp_bitcnt_t);\n\n#define gmp_randinit_mt __gmp_randinit_mt\n__GMP_DECLSPEC void gmp_randinit_mt (gmp_randstate_ptr);\n\n#define gmp_randinit_set __gmp_randinit_set\n__GMP_DECLSPEC void gmp_randinit_set (gmp_randstate_ptr, gmp_randstate_srcptr);\n\n#define gmp_randseed __gmp_randseed\n__GMP_DECLSPEC void gmp_randseed (gmp_randstate_ptr, mpz_srcptr);\n\n#define gmp_randseed_ui __gmp_randseed_ui\n__GMP_DECLSPEC void gmp_randseed_ui (gmp_randstate_ptr, unsigned long int);\n\n#define gmp_randclear __gmp_randclear\n__GMP_DECLSPEC void gmp_randclear (gmp_randstate_ptr);\n\n#define gmp_urandomb_ui __gmp_urandomb_ui\n__GMP_DECLSPEC unsigned long gmp_urandomb_ui (gmp_randstate_ptr, unsigned long);\n\n#define gmp_urandomm_ui __gmp_urandomm_ui\n__GMP_DECLSPEC unsigned long gmp_urandomm_ui (gmp_randstate_ptr, unsigned long);\n\n\n/**************** Formatted output routines.  ****************/\n\n#define gmp_asprintf __gmp_asprintf\n__GMP_DECLSPEC int gmp_asprintf (char **, const char *, ...);\n\n#define gmp_fprintf __gmp_fprintf\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC int gmp_fprintf (FILE *, const char *, ...);\n#endif\n\n#define gmp_obstack_printf __gmp_obstack_printf\n#if defined (_GMP_H_HAVE_OBSTACK)\n__GMP_DECLSPEC int gmp_obstack_printf (struct obstack *, const char *, ...);\n#endif\n\n#define gmp_obstack_vprintf __gmp_obstack_vprintf\n#if defined (_GMP_H_HAVE_OBSTACK) && defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_obstack_vprintf (struct obstack *, const char *, va_list);\n#endif\n\n#define gmp_printf __gmp_printf\n__GMP_DECLSPEC int gmp_printf (const char *, ...);\n\n#define gmp_snprintf __gmp_snprintf\n__GMP_DECLSPEC int gmp_snprintf (char *, size_t, const char *, ...);\n\n#define gmp_sprintf __gmp_sprintf\n__GMP_DECLSPEC int gmp_sprintf (char *, const char *, ...);\n\n#define gmp_vasprintf __gmp_vasprintf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vasprintf (char **, const char *, va_list);\n#endif\n\n#define gmp_vfprintf __gmp_vfprintf\n#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vfprintf (FILE *, const char *, va_list);\n#endif\n\n#define gmp_vprintf __gmp_vprintf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vprintf (const char *, va_list);\n#endif\n\n#define gmp_vsnprintf __gmp_vsnprintf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vsnprintf (char *, size_t, const char *, va_list);\n#endif\n\n#define gmp_vsprintf __gmp_vsprintf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vsprintf (char *, const char *, va_list);\n#endif\n\n\n/**************** Formatted input routines.  ****************/\n\n#define gmp_fscanf __gmp_fscanf\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC int gmp_fscanf (FILE *, const char *, ...);\n#endif\n\n#define gmp_scanf __gmp_scanf\n__GMP_DECLSPEC int gmp_scanf (const char *, ...);\n\n#define gmp_sscanf __gmp_sscanf\n__GMP_DECLSPEC int gmp_sscanf (const char *, const char *, ...);\n\n#define gmp_vfscanf __gmp_vfscanf\n#if defined (_GMP_H_HAVE_FILE) && defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vfscanf (FILE *, const char *, va_list);\n#endif\n\n#define gmp_vscanf __gmp_vscanf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vscanf (const char *, va_list);\n#endif\n\n#define gmp_vsscanf __gmp_vsscanf\n#if defined (_GMP_H_HAVE_VA_LIST)\n__GMP_DECLSPEC int gmp_vsscanf (const char *, const char *, va_list);\n#endif\n\n\n/**************** Integer (i.e. Z) routines.  ****************/\n\n#define _mpz_realloc __gmpz_realloc\n#define mpz_realloc __gmpz_realloc\n__GMP_DECLSPEC void *_mpz_realloc (mpz_ptr, mp_size_t);\n\n#define mpz_abs __gmpz_abs\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_abs)\n__GMP_DECLSPEC void mpz_abs (mpz_ptr, mpz_srcptr);\n#endif\n\n#define mpz_add __gmpz_add\n__GMP_DECLSPEC void mpz_add (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_add_ui __gmpz_add_ui\n__GMP_DECLSPEC void mpz_add_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_addmul __gmpz_addmul\n__GMP_DECLSPEC void mpz_addmul (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_addmul_ui __gmpz_addmul_ui\n__GMP_DECLSPEC void mpz_addmul_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_and __gmpz_and\n__GMP_DECLSPEC void mpz_and (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_array_init __gmpz_array_init\n__GMP_DECLSPEC void mpz_array_init (mpz_ptr, mp_size_t, mp_size_t);\n\n#define mpz_bin_ui __gmpz_bin_ui\n__GMP_DECLSPEC void mpz_bin_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_bin_uiui __gmpz_bin_uiui\n__GMP_DECLSPEC void mpz_bin_uiui (mpz_ptr, unsigned long int, unsigned long int);\n\n#define mpz_cdiv_q __gmpz_cdiv_q\n__GMP_DECLSPEC void mpz_cdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_cdiv_q_2exp __gmpz_cdiv_q_2exp\n__GMP_DECLSPEC void mpz_cdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_cdiv_q_ui __gmpz_cdiv_q_ui\n__GMP_DECLSPEC unsigned long int mpz_cdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_cdiv_qr __gmpz_cdiv_qr\n__GMP_DECLSPEC void mpz_cdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_cdiv_qr_ui __gmpz_cdiv_qr_ui\n__GMP_DECLSPEC unsigned long int mpz_cdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_cdiv_r __gmpz_cdiv_r\n__GMP_DECLSPEC void mpz_cdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_cdiv_r_2exp __gmpz_cdiv_r_2exp\n__GMP_DECLSPEC void mpz_cdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_cdiv_r_ui __gmpz_cdiv_r_ui\n__GMP_DECLSPEC unsigned long int mpz_cdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_cdiv_ui __gmpz_cdiv_ui\n__GMP_DECLSPEC unsigned long int mpz_cdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_clear __gmpz_clear\n__GMP_DECLSPEC void mpz_clear (mpz_ptr);\n\n#define mpz_clears __gmpz_clears\n__GMP_DECLSPEC void mpz_clears (mpz_ptr, ...);\n\n#define mpz_clrbit __gmpz_clrbit\n__GMP_DECLSPEC void mpz_clrbit (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_cmp __gmpz_cmp\n__GMP_DECLSPEC int mpz_cmp (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_cmp_d __gmpz_cmp_d\n__GMP_DECLSPEC int mpz_cmp_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE;\n\n#define _mpz_cmp_si __gmpz_cmp_si\n__GMP_DECLSPEC int _mpz_cmp_si (mpz_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define _mpz_cmp_ui __gmpz_cmp_ui\n__GMP_DECLSPEC int _mpz_cmp_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_cmpabs __gmpz_cmpabs\n__GMP_DECLSPEC int mpz_cmpabs (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_cmpabs_d __gmpz_cmpabs_d\n__GMP_DECLSPEC int mpz_cmpabs_d (mpz_srcptr, double) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_cmpabs_ui __gmpz_cmpabs_ui\n__GMP_DECLSPEC int mpz_cmpabs_ui (mpz_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_com __gmpz_com\n__GMP_DECLSPEC void mpz_com (mpz_ptr, mpz_srcptr);\n\n#define mpz_combit __gmpz_combit\n__GMP_DECLSPEC void mpz_combit (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_congruent_p __gmpz_congruent_p\n__GMP_DECLSPEC int mpz_congruent_p (mpz_srcptr, mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_congruent_2exp_p __gmpz_congruent_2exp_p\n__GMP_DECLSPEC int mpz_congruent_2exp_p (mpz_srcptr, mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_congruent_ui_p __gmpz_congruent_ui_p\n__GMP_DECLSPEC int mpz_congruent_ui_p (mpz_srcptr, unsigned long, unsigned long) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_divexact __gmpz_divexact\n__GMP_DECLSPEC void mpz_divexact (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_divexact_ui __gmpz_divexact_ui\n__GMP_DECLSPEC void mpz_divexact_ui (mpz_ptr, mpz_srcptr, unsigned long);\n\n#define mpz_divisible_p __gmpz_divisible_p\n__GMP_DECLSPEC int mpz_divisible_p (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_divisible_ui_p __gmpz_divisible_ui_p\n__GMP_DECLSPEC int mpz_divisible_ui_p (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_divisible_2exp_p __gmpz_divisible_2exp_p\n__GMP_DECLSPEC int mpz_divisible_2exp_p (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_dump __gmpz_dump\n__GMP_DECLSPEC void mpz_dump (mpz_srcptr);\n\n#define mpz_export __gmpz_export\n__GMP_DECLSPEC void *mpz_export (void *, size_t *, int, size_t, int, size_t, mpz_srcptr);\n\n#define mpz_fac_ui __gmpz_fac_ui\n__GMP_DECLSPEC void mpz_fac_ui (mpz_ptr, unsigned long int);\n\n#define mpz_2fac_ui __gmpz_2fac_ui\n__GMP_DECLSPEC void mpz_2fac_ui (mpz_ptr, unsigned long int);\n\n#define mpz_mfac_uiui __gmpz_mfac_uiui\n__GMP_DECLSPEC void mpz_mfac_uiui (mpz_ptr, unsigned long int, unsigned long int);\n\n#define mpz_primorial_ui __gmpz_primorial_ui\n__GMP_DECLSPEC void mpz_primorial_ui (mpz_ptr, unsigned long int);\n\n#define mpz_fdiv_q __gmpz_fdiv_q\n__GMP_DECLSPEC void mpz_fdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_fdiv_q_2exp __gmpz_fdiv_q_2exp\n__GMP_DECLSPEC void mpz_fdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_fdiv_q_ui __gmpz_fdiv_q_ui\n__GMP_DECLSPEC unsigned long int mpz_fdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_fdiv_qr __gmpz_fdiv_qr\n__GMP_DECLSPEC void mpz_fdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_fdiv_qr_ui __gmpz_fdiv_qr_ui\n__GMP_DECLSPEC unsigned long int mpz_fdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_fdiv_r __gmpz_fdiv_r\n__GMP_DECLSPEC void mpz_fdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_fdiv_r_2exp __gmpz_fdiv_r_2exp\n__GMP_DECLSPEC void mpz_fdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_fdiv_r_ui __gmpz_fdiv_r_ui\n__GMP_DECLSPEC unsigned long int mpz_fdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_fdiv_ui __gmpz_fdiv_ui\n__GMP_DECLSPEC unsigned long int mpz_fdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_fib_ui __gmpz_fib_ui\n__GMP_DECLSPEC void mpz_fib_ui (mpz_ptr, unsigned long int);\n\n#define mpz_fib2_ui __gmpz_fib2_ui\n__GMP_DECLSPEC void mpz_fib2_ui (mpz_ptr, mpz_ptr, unsigned long int);\n\n#define mpz_fits_sint_p __gmpz_fits_sint_p\n__GMP_DECLSPEC int mpz_fits_sint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_fits_slong_p __gmpz_fits_slong_p\n__GMP_DECLSPEC int mpz_fits_slong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_fits_sshort_p __gmpz_fits_sshort_p\n__GMP_DECLSPEC int mpz_fits_sshort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_fits_uint_p __gmpz_fits_uint_p\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_uint_p)\n__GMP_DECLSPEC int mpz_fits_uint_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_fits_ulong_p __gmpz_fits_ulong_p\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ulong_p)\n__GMP_DECLSPEC int mpz_fits_ulong_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_fits_ushort_p __gmpz_fits_ushort_p\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_fits_ushort_p)\n__GMP_DECLSPEC int mpz_fits_ushort_p (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_gcd __gmpz_gcd\n__GMP_DECLSPEC void mpz_gcd (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_gcd_ui __gmpz_gcd_ui\n__GMP_DECLSPEC unsigned long int mpz_gcd_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_gcdext __gmpz_gcdext\n__GMP_DECLSPEC void mpz_gcdext (mpz_ptr, mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_get_d __gmpz_get_d\n__GMP_DECLSPEC double mpz_get_d (mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_get_d_2exp __gmpz_get_d_2exp\n__GMP_DECLSPEC double mpz_get_d_2exp (signed long int *, mpz_srcptr);\n\n#define mpz_get_si __gmpz_get_si\n__GMP_DECLSPEC /* signed */ long int mpz_get_si (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_get_str __gmpz_get_str\n__GMP_DECLSPEC char *mpz_get_str (char *, int, mpz_srcptr);\n\n#define mpz_get_ui __gmpz_get_ui\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_get_ui)\n__GMP_DECLSPEC unsigned long int mpz_get_ui (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_getlimbn __gmpz_getlimbn\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_getlimbn)\n__GMP_DECLSPEC mp_limb_t mpz_getlimbn (mpz_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_hamdist __gmpz_hamdist\n__GMP_DECLSPEC mp_bitcnt_t mpz_hamdist (mpz_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_import __gmpz_import\n__GMP_DECLSPEC void mpz_import (mpz_ptr, size_t, int, size_t, int, size_t, const void *);\n\n#define mpz_init __gmpz_init\n__GMP_DECLSPEC void mpz_init (mpz_ptr) __GMP_NOTHROW;\n\n#define mpz_init2 __gmpz_init2\n__GMP_DECLSPEC void mpz_init2 (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_inits __gmpz_inits\n__GMP_DECLSPEC void mpz_inits (mpz_ptr, ...) __GMP_NOTHROW;\n\n#define mpz_init_set __gmpz_init_set\n__GMP_DECLSPEC void mpz_init_set (mpz_ptr, mpz_srcptr);\n\n#define mpz_init_set_d __gmpz_init_set_d\n__GMP_DECLSPEC void mpz_init_set_d (mpz_ptr, double);\n\n#define mpz_init_set_si __gmpz_init_set_si\n__GMP_DECLSPEC void mpz_init_set_si (mpz_ptr, signed long int);\n\n#define mpz_init_set_str __gmpz_init_set_str\n__GMP_DECLSPEC int mpz_init_set_str (mpz_ptr, const char *, int);\n\n#define mpz_init_set_ui __gmpz_init_set_ui\n__GMP_DECLSPEC void mpz_init_set_ui (mpz_ptr, unsigned long int);\n\n#define mpz_inp_raw __gmpz_inp_raw\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpz_inp_raw (mpz_ptr, FILE *);\n#endif\n\n#define mpz_inp_str __gmpz_inp_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpz_inp_str (mpz_ptr, FILE *, int);\n#endif\n\n#define mpz_invert __gmpz_invert\n__GMP_DECLSPEC int mpz_invert (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_ior __gmpz_ior\n__GMP_DECLSPEC void mpz_ior (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_jacobi __gmpz_jacobi\n__GMP_DECLSPEC int mpz_jacobi (mpz_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_kronecker mpz_jacobi  /* alias */\n\n#define mpz_kronecker_si __gmpz_kronecker_si\n__GMP_DECLSPEC int mpz_kronecker_si (mpz_srcptr, long) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_kronecker_ui __gmpz_kronecker_ui\n__GMP_DECLSPEC int mpz_kronecker_ui (mpz_srcptr, unsigned long) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_si_kronecker __gmpz_si_kronecker\n__GMP_DECLSPEC int mpz_si_kronecker (long, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_ui_kronecker __gmpz_ui_kronecker\n__GMP_DECLSPEC int mpz_ui_kronecker (unsigned long, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_lcm __gmpz_lcm\n__GMP_DECLSPEC void mpz_lcm (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_lcm_ui __gmpz_lcm_ui\n__GMP_DECLSPEC void mpz_lcm_ui (mpz_ptr, mpz_srcptr, unsigned long);\n\n#define mpz_legendre mpz_jacobi  /* alias */\n\n#define mpz_lucnum_ui __gmpz_lucnum_ui\n__GMP_DECLSPEC void mpz_lucnum_ui (mpz_ptr, unsigned long int);\n\n#define mpz_lucnum2_ui __gmpz_lucnum2_ui\n__GMP_DECLSPEC void mpz_lucnum2_ui (mpz_ptr, mpz_ptr, unsigned long int);\n\n#define mpz_millerrabin __gmpz_millerrabin\n__GMP_DECLSPEC int mpz_millerrabin (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_mod __gmpz_mod\n__GMP_DECLSPEC void mpz_mod (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_mod_ui mpz_fdiv_r_ui /* same as fdiv_r because divisor unsigned */\n\n#define mpz_mul __gmpz_mul\n__GMP_DECLSPEC void mpz_mul (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_mul_2exp __gmpz_mul_2exp\n__GMP_DECLSPEC void mpz_mul_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_mul_si __gmpz_mul_si\n__GMP_DECLSPEC void mpz_mul_si (mpz_ptr, mpz_srcptr, long int);\n\n#define mpz_mul_ui __gmpz_mul_ui\n__GMP_DECLSPEC void mpz_mul_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_neg __gmpz_neg\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_neg)\n__GMP_DECLSPEC void mpz_neg (mpz_ptr, mpz_srcptr);\n#endif\n\n#define mpz_nextprime __gmpz_nextprime\n__GMP_DECLSPEC void mpz_nextprime (mpz_ptr, mpz_srcptr);\n\n#define mpz_prevprime __gmpz_prevprime\n__GMP_DECLSPEC int mpz_prevprime (mpz_ptr, mpz_srcptr);\n\n#define mpz_out_raw __gmpz_out_raw\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpz_out_raw (FILE *, mpz_srcptr);\n#endif\n\n#define mpz_out_str __gmpz_out_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpz_out_str (FILE *, int, mpz_srcptr);\n#endif\n\n#define mpz_perfect_power_p __gmpz_perfect_power_p\n__GMP_DECLSPEC int mpz_perfect_power_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_perfect_square_p __gmpz_perfect_square_p\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_perfect_square_p)\n__GMP_DECLSPEC int mpz_perfect_square_p (mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_popcount __gmpz_popcount\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_popcount)\n__GMP_DECLSPEC mp_bitcnt_t mpz_popcount (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_pow_ui __gmpz_pow_ui\n__GMP_DECLSPEC void mpz_pow_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_powm __gmpz_powm\n__GMP_DECLSPEC void mpz_powm (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_powm_sec __gmpz_powm_sec\n__GMP_DECLSPEC void mpz_powm_sec (mpz_ptr, mpz_srcptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_powm_ui __gmpz_powm_ui\n__GMP_DECLSPEC void mpz_powm_ui (mpz_ptr, mpz_srcptr, unsigned long int, mpz_srcptr);\n\n#define mpz_probab_prime_p __gmpz_probab_prime_p\n__GMP_DECLSPEC int mpz_probab_prime_p (mpz_srcptr, int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_random __gmpz_random\n__GMP_DECLSPEC void mpz_random (mpz_ptr, mp_size_t);\n\n#define mpz_random2 __gmpz_random2\n__GMP_DECLSPEC void mpz_random2 (mpz_ptr, mp_size_t);\n\n#define mpz_realloc2 __gmpz_realloc2\n__GMP_DECLSPEC void mpz_realloc2 (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_remove __gmpz_remove\n__GMP_DECLSPEC mp_bitcnt_t mpz_remove (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_root __gmpz_root\n__GMP_DECLSPEC int mpz_root (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_rootrem __gmpz_rootrem\n__GMP_DECLSPEC void mpz_rootrem (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_rrandomb __gmpz_rrandomb\n__GMP_DECLSPEC void mpz_rrandomb (mpz_ptr, gmp_randstate_ptr, mp_bitcnt_t);\n\n#define mpz_scan0 __gmpz_scan0\n__GMP_DECLSPEC mp_bitcnt_t mpz_scan0 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_scan1 __gmpz_scan1\n__GMP_DECLSPEC mp_bitcnt_t mpz_scan1 (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_set __gmpz_set\n__GMP_DECLSPEC void mpz_set (mpz_ptr, mpz_srcptr);\n\n#define mpz_set_d __gmpz_set_d\n__GMP_DECLSPEC void mpz_set_d (mpz_ptr, double);\n\n#define mpz_set_f __gmpz_set_f\n__GMP_DECLSPEC void mpz_set_f (mpz_ptr, mpf_srcptr);\n\n#define mpz_set_q __gmpz_set_q\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_set_q)\n__GMP_DECLSPEC void mpz_set_q (mpz_ptr, mpq_srcptr);\n#endif\n\n#define mpz_set_si __gmpz_set_si\n__GMP_DECLSPEC void mpz_set_si (mpz_ptr, signed long int);\n\n#define mpz_set_str __gmpz_set_str\n__GMP_DECLSPEC int mpz_set_str (mpz_ptr, const char *, int);\n\n#define mpz_set_ui __gmpz_set_ui\n__GMP_DECLSPEC void mpz_set_ui (mpz_ptr, unsigned long int);\n\n#define mpz_setbit __gmpz_setbit\n__GMP_DECLSPEC void mpz_setbit (mpz_ptr, mp_bitcnt_t);\n\n#define mpz_size __gmpz_size\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpz_size)\n__GMP_DECLSPEC size_t mpz_size (mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpz_sizeinbase __gmpz_sizeinbase\n__GMP_DECLSPEC size_t mpz_sizeinbase (mpz_srcptr, int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_sqrt __gmpz_sqrt\n__GMP_DECLSPEC void mpz_sqrt (mpz_ptr, mpz_srcptr);\n\n#define mpz_sqrtrem __gmpz_sqrtrem\n__GMP_DECLSPEC void mpz_sqrtrem (mpz_ptr, mpz_ptr, mpz_srcptr);\n\n#define mpz_sub __gmpz_sub\n__GMP_DECLSPEC void mpz_sub (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_sub_ui __gmpz_sub_ui\n__GMP_DECLSPEC void mpz_sub_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_ui_sub __gmpz_ui_sub\n__GMP_DECLSPEC void mpz_ui_sub (mpz_ptr, unsigned long int, mpz_srcptr);\n\n#define mpz_submul __gmpz_submul\n__GMP_DECLSPEC void mpz_submul (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_submul_ui __gmpz_submul_ui\n__GMP_DECLSPEC void mpz_submul_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_swap __gmpz_swap\n__GMP_DECLSPEC void mpz_swap (mpz_ptr, mpz_ptr) __GMP_NOTHROW;\n\n#define mpz_tdiv_ui __gmpz_tdiv_ui\n__GMP_DECLSPEC unsigned long int mpz_tdiv_ui (mpz_srcptr, unsigned long int) __GMP_ATTRIBUTE_PURE;\n\n#define mpz_tdiv_q __gmpz_tdiv_q\n__GMP_DECLSPEC void mpz_tdiv_q (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_tdiv_q_2exp __gmpz_tdiv_q_2exp\n__GMP_DECLSPEC void mpz_tdiv_q_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_tdiv_q_ui __gmpz_tdiv_q_ui\n__GMP_DECLSPEC unsigned long int mpz_tdiv_q_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_tdiv_qr __gmpz_tdiv_qr\n__GMP_DECLSPEC void mpz_tdiv_qr (mpz_ptr, mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_tdiv_qr_ui __gmpz_tdiv_qr_ui\n__GMP_DECLSPEC unsigned long int mpz_tdiv_qr_ui (mpz_ptr, mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_tdiv_r __gmpz_tdiv_r\n__GMP_DECLSPEC void mpz_tdiv_r (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_tdiv_r_2exp __gmpz_tdiv_r_2exp\n__GMP_DECLSPEC void mpz_tdiv_r_2exp (mpz_ptr, mpz_srcptr, mp_bitcnt_t);\n\n#define mpz_tdiv_r_ui __gmpz_tdiv_r_ui\n__GMP_DECLSPEC unsigned long int mpz_tdiv_r_ui (mpz_ptr, mpz_srcptr, unsigned long int);\n\n#define mpz_tstbit __gmpz_tstbit\n__GMP_DECLSPEC int mpz_tstbit (mpz_srcptr, mp_bitcnt_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpz_ui_pow_ui __gmpz_ui_pow_ui\n__GMP_DECLSPEC void mpz_ui_pow_ui (mpz_ptr, unsigned long int, unsigned long int);\n\n#define mpz_urandomb __gmpz_urandomb\n__GMP_DECLSPEC void mpz_urandomb (mpz_ptr, gmp_randstate_ptr, mp_bitcnt_t);\n\n#define mpz_urandomm __gmpz_urandomm\n__GMP_DECLSPEC void mpz_urandomm (mpz_ptr, gmp_randstate_ptr, mpz_srcptr);\n\n#define mpz_xor __gmpz_xor\n#define mpz_eor __gmpz_xor\n__GMP_DECLSPEC void mpz_xor (mpz_ptr, mpz_srcptr, mpz_srcptr);\n\n#define mpz_limbs_read __gmpz_limbs_read\n__GMP_DECLSPEC mp_srcptr mpz_limbs_read (mpz_srcptr);\n\n#define mpz_limbs_write __gmpz_limbs_write\n__GMP_DECLSPEC mp_ptr mpz_limbs_write (mpz_ptr, mp_size_t);\n\n#define mpz_limbs_modify __gmpz_limbs_modify\n__GMP_DECLSPEC mp_ptr mpz_limbs_modify (mpz_ptr, mp_size_t);\n\n#define mpz_limbs_finish __gmpz_limbs_finish\n__GMP_DECLSPEC void mpz_limbs_finish (mpz_ptr, mp_size_t);\n\n#define mpz_roinit_n __gmpz_roinit_n\n__GMP_DECLSPEC mpz_srcptr mpz_roinit_n (mpz_ptr, mp_srcptr, mp_size_t);\n\n#define MPZ_ROINIT_N(xp, xs) {{0, (xs),(xp) }}\n\n/**************** Rational (i.e. Q) routines.  ****************/\n\n#define mpq_abs __gmpq_abs\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_abs)\n__GMP_DECLSPEC void mpq_abs (mpq_ptr, mpq_srcptr);\n#endif\n\n#define mpq_add __gmpq_add\n__GMP_DECLSPEC void mpq_add (mpq_ptr, mpq_srcptr, mpq_srcptr);\n\n#define mpq_canonicalize __gmpq_canonicalize\n__GMP_DECLSPEC void mpq_canonicalize (mpq_ptr);\n\n#define mpq_clear __gmpq_clear\n__GMP_DECLSPEC void mpq_clear (mpq_ptr);\n\n#define mpq_clears __gmpq_clears\n__GMP_DECLSPEC void mpq_clears (mpq_ptr, ...);\n\n#define mpq_cmp __gmpq_cmp\n__GMP_DECLSPEC int mpq_cmp (mpq_srcptr, mpq_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define _mpq_cmp_si __gmpq_cmp_si\n__GMP_DECLSPEC int _mpq_cmp_si (mpq_srcptr, long, unsigned long) __GMP_ATTRIBUTE_PURE;\n\n#define _mpq_cmp_ui __gmpq_cmp_ui\n__GMP_DECLSPEC int _mpq_cmp_ui (mpq_srcptr, unsigned long int, unsigned long int) __GMP_ATTRIBUTE_PURE;\n\n#define mpq_cmp_z __gmpq_cmp_z\n__GMP_DECLSPEC int mpq_cmp_z (mpq_srcptr, mpz_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpq_div __gmpq_div\n__GMP_DECLSPEC void mpq_div (mpq_ptr, mpq_srcptr, mpq_srcptr);\n\n#define mpq_div_2exp __gmpq_div_2exp\n__GMP_DECLSPEC void mpq_div_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t);\n\n#define mpq_equal __gmpq_equal\n__GMP_DECLSPEC int mpq_equal (mpq_srcptr, mpq_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpq_get_num __gmpq_get_num\n__GMP_DECLSPEC void mpq_get_num (mpz_ptr, mpq_srcptr);\n\n#define mpq_get_den __gmpq_get_den\n__GMP_DECLSPEC void mpq_get_den (mpz_ptr, mpq_srcptr);\n\n#define mpq_get_d __gmpq_get_d\n__GMP_DECLSPEC double mpq_get_d (mpq_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpq_get_str __gmpq_get_str\n__GMP_DECLSPEC char *mpq_get_str (char *, int, mpq_srcptr);\n\n#define mpq_init __gmpq_init\n__GMP_DECLSPEC void mpq_init (mpq_ptr);\n\n#define mpq_inits __gmpq_inits\n__GMP_DECLSPEC void mpq_inits (mpq_ptr, ...);\n\n#define mpq_inp_str __gmpq_inp_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpq_inp_str (mpq_ptr, FILE *, int);\n#endif\n\n#define mpq_inv __gmpq_inv\n__GMP_DECLSPEC void mpq_inv (mpq_ptr, mpq_srcptr);\n\n#define mpq_mul __gmpq_mul\n__GMP_DECLSPEC void mpq_mul (mpq_ptr, mpq_srcptr, mpq_srcptr);\n\n#define mpq_mul_2exp __gmpq_mul_2exp\n__GMP_DECLSPEC void mpq_mul_2exp (mpq_ptr, mpq_srcptr, mp_bitcnt_t);\n\n#define mpq_neg __gmpq_neg\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpq_neg)\n__GMP_DECLSPEC void mpq_neg (mpq_ptr, mpq_srcptr);\n#endif\n\n#define mpq_out_str __gmpq_out_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpq_out_str (FILE *, int, mpq_srcptr);\n#endif\n\n#define mpq_set __gmpq_set\n__GMP_DECLSPEC void mpq_set (mpq_ptr, mpq_srcptr);\n\n#define mpq_set_d __gmpq_set_d\n__GMP_DECLSPEC void mpq_set_d (mpq_ptr, double);\n\n#define mpq_set_den __gmpq_set_den\n__GMP_DECLSPEC void mpq_set_den (mpq_ptr, mpz_srcptr);\n\n#define mpq_set_f __gmpq_set_f\n__GMP_DECLSPEC void mpq_set_f (mpq_ptr, mpf_srcptr);\n\n#define mpq_set_num __gmpq_set_num\n__GMP_DECLSPEC void mpq_set_num (mpq_ptr, mpz_srcptr);\n\n#define mpq_set_si __gmpq_set_si\n__GMP_DECLSPEC void mpq_set_si (mpq_ptr, signed long int, unsigned long int);\n\n#define mpq_set_str __gmpq_set_str\n__GMP_DECLSPEC int mpq_set_str (mpq_ptr, const char *, int);\n\n#define mpq_set_ui __gmpq_set_ui\n__GMP_DECLSPEC void mpq_set_ui (mpq_ptr, unsigned long int, unsigned long int);\n\n#define mpq_set_z __gmpq_set_z\n__GMP_DECLSPEC void mpq_set_z (mpq_ptr, mpz_srcptr);\n\n#define mpq_sub __gmpq_sub\n__GMP_DECLSPEC void mpq_sub (mpq_ptr, mpq_srcptr, mpq_srcptr);\n\n#define mpq_swap __gmpq_swap\n__GMP_DECLSPEC void mpq_swap (mpq_ptr, mpq_ptr) __GMP_NOTHROW;\n\n\n/**************** Float (i.e. F) routines.  ****************/\n\n#define mpf_abs __gmpf_abs\n__GMP_DECLSPEC void mpf_abs (mpf_ptr, mpf_srcptr);\n\n#define mpf_add __gmpf_add\n__GMP_DECLSPEC void mpf_add (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_add_ui __gmpf_add_ui\n__GMP_DECLSPEC void mpf_add_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n#define mpf_ceil __gmpf_ceil\n__GMP_DECLSPEC void mpf_ceil (mpf_ptr, mpf_srcptr);\n\n#define mpf_clear __gmpf_clear\n__GMP_DECLSPEC void mpf_clear (mpf_ptr);\n\n#define mpf_clears __gmpf_clears\n__GMP_DECLSPEC void mpf_clears (mpf_ptr, ...);\n\n#define mpf_cmp __gmpf_cmp\n__GMP_DECLSPEC int mpf_cmp (mpf_srcptr, mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_cmp_z __gmpf_cmp_z\n__GMP_DECLSPEC int mpf_cmp_z (mpf_srcptr, mpz_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_cmp_d __gmpf_cmp_d\n__GMP_DECLSPEC int mpf_cmp_d (mpf_srcptr, double) __GMP_ATTRIBUTE_PURE;\n\n#define mpf_cmp_si __gmpf_cmp_si\n__GMP_DECLSPEC int mpf_cmp_si (mpf_srcptr, signed long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_cmp_ui __gmpf_cmp_ui\n__GMP_DECLSPEC int mpf_cmp_ui (mpf_srcptr, unsigned long int) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_div __gmpf_div\n__GMP_DECLSPEC void mpf_div (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_div_2exp __gmpf_div_2exp\n__GMP_DECLSPEC void mpf_div_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t);\n\n#define mpf_div_ui __gmpf_div_ui\n__GMP_DECLSPEC void mpf_div_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n\n#define mpf_dump __gmpf_dump\n__GMP_DECLSPEC void mpf_dump (mpf_srcptr);\n\n#define mpf_eq __gmpf_eq\n__GMP_DECLSPEC int mpf_eq (mpf_srcptr, mpf_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_sint_p __gmpf_fits_sint_p\n__GMP_DECLSPEC int mpf_fits_sint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_slong_p __gmpf_fits_slong_p\n__GMP_DECLSPEC int mpf_fits_slong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_sshort_p __gmpf_fits_sshort_p\n__GMP_DECLSPEC int mpf_fits_sshort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_uint_p __gmpf_fits_uint_p\n__GMP_DECLSPEC int mpf_fits_uint_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_ulong_p __gmpf_fits_ulong_p\n__GMP_DECLSPEC int mpf_fits_ulong_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_fits_ushort_p __gmpf_fits_ushort_p\n__GMP_DECLSPEC int mpf_fits_ushort_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_floor __gmpf_floor\n__GMP_DECLSPEC void mpf_floor (mpf_ptr, mpf_srcptr);\n\n#define mpf_get_d __gmpf_get_d\n__GMP_DECLSPEC double mpf_get_d (mpf_srcptr) __GMP_ATTRIBUTE_PURE;\n\n#define mpf_get_d_2exp __gmpf_get_d_2exp\n__GMP_DECLSPEC double mpf_get_d_2exp (signed long int *, mpf_srcptr);\n\n#define mpf_get_default_prec __gmpf_get_default_prec\n__GMP_DECLSPEC mp_bitcnt_t mpf_get_default_prec (void) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_get_prec __gmpf_get_prec\n__GMP_DECLSPEC mp_bitcnt_t mpf_get_prec (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_get_si __gmpf_get_si\n__GMP_DECLSPEC long mpf_get_si (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_get_str __gmpf_get_str\n__GMP_DECLSPEC char *mpf_get_str (char *, mp_exp_t *, int, size_t, mpf_srcptr);\n\n#define mpf_get_ui __gmpf_get_ui\n__GMP_DECLSPEC unsigned long mpf_get_ui (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_init __gmpf_init\n__GMP_DECLSPEC void mpf_init (mpf_ptr);\n\n#define mpf_init2 __gmpf_init2\n__GMP_DECLSPEC void mpf_init2 (mpf_ptr, mp_bitcnt_t);\n\n#define mpf_inits __gmpf_inits\n__GMP_DECLSPEC void mpf_inits (mpf_ptr, ...);\n\n#define mpf_init_set __gmpf_init_set\n__GMP_DECLSPEC void mpf_init_set (mpf_ptr, mpf_srcptr);\n\n#define mpf_init_set_d __gmpf_init_set_d\n__GMP_DECLSPEC void mpf_init_set_d (mpf_ptr, double);\n\n#define mpf_init_set_si __gmpf_init_set_si\n__GMP_DECLSPEC void mpf_init_set_si (mpf_ptr, signed long int);\n\n#define mpf_init_set_str __gmpf_init_set_str\n__GMP_DECLSPEC int mpf_init_set_str (mpf_ptr, const char *, int);\n\n#define mpf_init_set_ui __gmpf_init_set_ui\n__GMP_DECLSPEC void mpf_init_set_ui (mpf_ptr, unsigned long int);\n\n#define mpf_inp_str __gmpf_inp_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpf_inp_str (mpf_ptr, FILE *, int);\n#endif\n\n#define mpf_integer_p __gmpf_integer_p\n__GMP_DECLSPEC int mpf_integer_p (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_mul __gmpf_mul\n__GMP_DECLSPEC void mpf_mul (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_mul_2exp __gmpf_mul_2exp\n__GMP_DECLSPEC void mpf_mul_2exp (mpf_ptr, mpf_srcptr, mp_bitcnt_t);\n\n#define mpf_mul_ui __gmpf_mul_ui\n__GMP_DECLSPEC void mpf_mul_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n\n#define mpf_neg __gmpf_neg\n__GMP_DECLSPEC void mpf_neg (mpf_ptr, mpf_srcptr);\n\n#define mpf_out_str __gmpf_out_str\n#ifdef _GMP_H_HAVE_FILE\n__GMP_DECLSPEC size_t mpf_out_str (FILE *, int, size_t, mpf_srcptr);\n#endif\n\n#define mpf_pow_ui __gmpf_pow_ui\n__GMP_DECLSPEC void mpf_pow_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n\n#define mpf_random2 __gmpf_random2\n__GMP_DECLSPEC void mpf_random2 (mpf_ptr, mp_size_t, mp_exp_t);\n\n#define mpf_reldiff __gmpf_reldiff\n__GMP_DECLSPEC void mpf_reldiff (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_set __gmpf_set\n__GMP_DECLSPEC void mpf_set (mpf_ptr, mpf_srcptr);\n\n#define mpf_set_d __gmpf_set_d\n__GMP_DECLSPEC void mpf_set_d (mpf_ptr, double);\n\n#define mpf_set_default_prec __gmpf_set_default_prec\n__GMP_DECLSPEC void mpf_set_default_prec (mp_bitcnt_t) __GMP_NOTHROW;\n\n#define mpf_set_prec __gmpf_set_prec\n__GMP_DECLSPEC void mpf_set_prec (mpf_ptr, mp_bitcnt_t);\n\n#define mpf_set_prec_raw __gmpf_set_prec_raw\n__GMP_DECLSPEC void mpf_set_prec_raw (mpf_ptr, mp_bitcnt_t) __GMP_NOTHROW;\n\n#define mpf_set_q __gmpf_set_q\n__GMP_DECLSPEC void mpf_set_q (mpf_ptr, mpq_srcptr);\n\n#define mpf_set_si __gmpf_set_si\n__GMP_DECLSPEC void mpf_set_si (mpf_ptr, signed long int);\n\n#define mpf_set_str __gmpf_set_str\n__GMP_DECLSPEC int mpf_set_str (mpf_ptr, const char *, int);\n\n#define mpf_set_ui __gmpf_set_ui\n__GMP_DECLSPEC void mpf_set_ui (mpf_ptr, unsigned long int);\n\n#define mpf_set_z __gmpf_set_z\n__GMP_DECLSPEC void mpf_set_z (mpf_ptr, mpz_srcptr);\n\n#define mpf_size __gmpf_size\n__GMP_DECLSPEC size_t mpf_size (mpf_srcptr) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpf_sqrt __gmpf_sqrt\n__GMP_DECLSPEC void mpf_sqrt (mpf_ptr, mpf_srcptr);\n\n#define mpf_sqrt_ui __gmpf_sqrt_ui\n__GMP_DECLSPEC void mpf_sqrt_ui (mpf_ptr, unsigned long int);\n\n#define mpf_sub __gmpf_sub\n__GMP_DECLSPEC void mpf_sub (mpf_ptr, mpf_srcptr, mpf_srcptr);\n\n#define mpf_sub_ui __gmpf_sub_ui\n__GMP_DECLSPEC void mpf_sub_ui (mpf_ptr, mpf_srcptr, unsigned long int);\n\n#define mpf_swap __gmpf_swap\n__GMP_DECLSPEC void mpf_swap (mpf_ptr, mpf_ptr) __GMP_NOTHROW;\n\n#define mpf_trunc __gmpf_trunc\n__GMP_DECLSPEC void mpf_trunc (mpf_ptr, mpf_srcptr);\n\n#define mpf_ui_div __gmpf_ui_div\n__GMP_DECLSPEC void mpf_ui_div (mpf_ptr, unsigned long int, mpf_srcptr);\n\n#define mpf_ui_sub __gmpf_ui_sub\n__GMP_DECLSPEC void mpf_ui_sub (mpf_ptr, unsigned long int, mpf_srcptr);\n\n#define mpf_urandomb __gmpf_urandomb\n__GMP_DECLSPEC void mpf_urandomb (mpf_ptr, gmp_randstate_ptr, mp_bitcnt_t);\n\n\n/************ Low level positive-integer (i.e. N) routines.  ************/\n\n/* This is ugly, but we need to make user calls reach the prefixed function. */\n\n#define mpn_add __MPN(add)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add)\n__GMP_DECLSPEC mp_limb_t mpn_add (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);\n#endif\n\n#define mpn_add_1 __MPN(add_1)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_add_1)\n__GMP_DECLSPEC mp_limb_t mpn_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW;\n#endif\n\n#define mpn_add_n __MPN(add_n)\n__GMP_DECLSPEC mp_limb_t mpn_add_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_addmul_1 __MPN(addmul_1)\n__GMP_DECLSPEC mp_limb_t mpn_addmul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_cmp __MPN(cmp)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_cmp)\n__GMP_DECLSPEC int mpn_cmp (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpn_zero_p __MPN(zero_p)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_zero_p)\n__GMP_DECLSPEC int mpn_zero_p (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n#endif\n\n#define mpn_divexact_1 __MPN(divexact_1)\n__GMP_DECLSPEC void mpn_divexact_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_divexact_by3(dst,src,size) \\\n  mpn_divexact_by3c (dst, src, size, __GMP_CAST (mp_limb_t, 0))\n\n#define mpn_divexact_by3c __MPN(divexact_by3c)\n__GMP_DECLSPEC mp_limb_t mpn_divexact_by3c (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_divmod_1(qp,np,nsize,dlimb) \\\n  mpn_divrem_1 (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dlimb)\n\n#define mpn_divrem __MPN(divrem)\n__GMP_DECLSPEC mp_limb_t mpn_divrem (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr, mp_size_t);\n\n#define mpn_divrem_1 __MPN(divrem_1)\n__GMP_DECLSPEC mp_limb_t mpn_divrem_1 (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_divrem_2 __MPN(divrem_2)\n__GMP_DECLSPEC mp_limb_t mpn_divrem_2 (mp_ptr, mp_size_t, mp_ptr, mp_size_t, mp_srcptr);\n\n#define mpn_div_qr_1 __MPN(div_qr_1)\n__GMP_DECLSPEC mp_limb_t mpn_div_qr_1 (mp_ptr, mp_limb_t *, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_div_qr_2 __MPN(div_qr_2)\n__GMP_DECLSPEC mp_limb_t mpn_div_qr_2 (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_srcptr);\n\n#define mpn_gcd __MPN(gcd)\n__GMP_DECLSPEC mp_size_t mpn_gcd (mp_ptr, mp_ptr, mp_size_t, mp_ptr, mp_size_t);\n\n#define mpn_gcd_11 __MPN(gcd_11)\n__GMP_DECLSPEC mp_limb_t mpn_gcd_11 (mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_gcd_1 __MPN(gcd_1)\n__GMP_DECLSPEC mp_limb_t mpn_gcd_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_gcdext_1 __MPN(gcdext_1)\n__GMP_DECLSPEC mp_limb_t mpn_gcdext_1 (mp_limb_signed_t *, mp_limb_signed_t *, mp_limb_t, mp_limb_t);\n\n#define mpn_gcdext __MPN(gcdext)\n__GMP_DECLSPEC mp_size_t mpn_gcdext (mp_ptr, mp_ptr, mp_size_t *, mp_ptr, mp_size_t, mp_ptr, mp_size_t);\n\n#define mpn_get_str __MPN(get_str)\n__GMP_DECLSPEC size_t mpn_get_str (unsigned char *, int, mp_ptr, mp_size_t);\n\n#define mpn_hamdist __MPN(hamdist)\n__GMP_DECLSPEC mp_bitcnt_t mpn_hamdist (mp_srcptr, mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpn_lshift __MPN(lshift)\n__GMP_DECLSPEC mp_limb_t mpn_lshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);\n\n#define mpn_mod_1 __MPN(mod_1)\n__GMP_DECLSPEC mp_limb_t mpn_mod_1 (mp_srcptr, mp_size_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_mul __MPN(mul)\n__GMP_DECLSPEC mp_limb_t mpn_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);\n\n#define mpn_mul_1 __MPN(mul_1)\n__GMP_DECLSPEC mp_limb_t mpn_mul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_mul_n __MPN(mul_n)\n__GMP_DECLSPEC void mpn_mul_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_sqr __MPN(sqr)\n__GMP_DECLSPEC void mpn_sqr (mp_ptr, mp_srcptr, mp_size_t);\n\n#define mpn_neg __MPN(neg)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_neg)\n__GMP_DECLSPEC mp_limb_t mpn_neg (mp_ptr, mp_srcptr, mp_size_t);\n#endif\n\n#define mpn_com __MPN(com)\n__GMP_DECLSPEC void mpn_com (mp_ptr, mp_srcptr, mp_size_t);\n\n#define mpn_perfect_square_p __MPN(perfect_square_p)\n__GMP_DECLSPEC int mpn_perfect_square_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_perfect_power_p __MPN(perfect_power_p)\n__GMP_DECLSPEC int mpn_perfect_power_p (mp_srcptr, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_popcount __MPN(popcount)\n__GMP_DECLSPEC mp_bitcnt_t mpn_popcount (mp_srcptr, mp_size_t) __GMP_NOTHROW __GMP_ATTRIBUTE_PURE;\n\n#define mpn_pow_1 __MPN(pow_1)\n__GMP_DECLSPEC mp_size_t mpn_pow_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);\n\n/* undocumented now, but retained here for upward compatibility */\n#define mpn_preinv_mod_1 __MPN(preinv_mod_1)\n__GMP_DECLSPEC mp_limb_t mpn_preinv_mod_1 (mp_srcptr, mp_size_t, mp_limb_t, mp_limb_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_random __MPN(random)\n__GMP_DECLSPEC void mpn_random (mp_ptr, mp_size_t);\n\n#define mpn_random2 __MPN(random2)\n__GMP_DECLSPEC void mpn_random2 (mp_ptr, mp_size_t);\n\n#define mpn_rshift __MPN(rshift)\n__GMP_DECLSPEC mp_limb_t mpn_rshift (mp_ptr, mp_srcptr, mp_size_t, unsigned int);\n\n#define mpn_scan0 __MPN(scan0)\n__GMP_DECLSPEC mp_bitcnt_t mpn_scan0 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_scan1 __MPN(scan1)\n__GMP_DECLSPEC mp_bitcnt_t mpn_scan1 (mp_srcptr, mp_bitcnt_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_set_str __MPN(set_str)\n__GMP_DECLSPEC mp_size_t mpn_set_str (mp_ptr, const unsigned char *, size_t, int);\n\n#define mpn_sizeinbase __MPN(sizeinbase)\n__GMP_DECLSPEC size_t mpn_sizeinbase (mp_srcptr, mp_size_t, int);\n\n#define mpn_sqrtrem __MPN(sqrtrem)\n__GMP_DECLSPEC mp_size_t mpn_sqrtrem (mp_ptr, mp_ptr, mp_srcptr, mp_size_t);\n\n#define mpn_sub __MPN(sub)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub)\n__GMP_DECLSPEC mp_limb_t mpn_sub (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);\n#endif\n\n#define mpn_sub_1 __MPN(sub_1)\n#if __GMP_INLINE_PROTOTYPES || defined (__GMP_FORCE_mpn_sub_1)\n__GMP_DECLSPEC mp_limb_t mpn_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t) __GMP_NOTHROW;\n#endif\n\n#define mpn_sub_n __MPN(sub_n)\n__GMP_DECLSPEC mp_limb_t mpn_sub_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_submul_1 __MPN(submul_1)\n__GMP_DECLSPEC mp_limb_t mpn_submul_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t);\n\n#define mpn_tdiv_qr __MPN(tdiv_qr)\n__GMP_DECLSPEC void mpn_tdiv_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t);\n\n#define mpn_and_n __MPN(and_n)\n__GMP_DECLSPEC void mpn_and_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_andn_n __MPN(andn_n)\n__GMP_DECLSPEC void mpn_andn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_nand_n __MPN(nand_n)\n__GMP_DECLSPEC void mpn_nand_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_ior_n __MPN(ior_n)\n__GMP_DECLSPEC void mpn_ior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_iorn_n __MPN(iorn_n)\n__GMP_DECLSPEC void mpn_iorn_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_nior_n __MPN(nior_n)\n__GMP_DECLSPEC void mpn_nior_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_xor_n __MPN(xor_n)\n__GMP_DECLSPEC void mpn_xor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_xnor_n __MPN(xnor_n)\n__GMP_DECLSPEC void mpn_xnor_n (mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_copyi __MPN(copyi)\n__GMP_DECLSPEC void mpn_copyi (mp_ptr, mp_srcptr, mp_size_t);\n#define mpn_copyd __MPN(copyd)\n__GMP_DECLSPEC void mpn_copyd (mp_ptr, mp_srcptr, mp_size_t);\n#define mpn_zero __MPN(zero)\n__GMP_DECLSPEC void mpn_zero (mp_ptr, mp_size_t);\n\n#define mpn_cnd_add_n __MPN(cnd_add_n)\n__GMP_DECLSPEC mp_limb_t mpn_cnd_add_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n#define mpn_cnd_sub_n __MPN(cnd_sub_n)\n__GMP_DECLSPEC mp_limb_t mpn_cnd_sub_n (mp_limb_t, mp_ptr, mp_srcptr, mp_srcptr, mp_size_t);\n\n#define mpn_sec_add_1 __MPN(sec_add_1)\n__GMP_DECLSPEC mp_limb_t mpn_sec_add_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);\n#define mpn_sec_add_1_itch __MPN(sec_add_1_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_add_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_sub_1 __MPN(sec_sub_1)\n__GMP_DECLSPEC mp_limb_t mpn_sec_sub_1 (mp_ptr, mp_srcptr, mp_size_t, mp_limb_t, mp_ptr);\n#define mpn_sec_sub_1_itch __MPN(sec_sub_1_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_sub_1_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_cnd_swap  __MPN(cnd_swap)\n__GMP_DECLSPEC void mpn_cnd_swap (mp_limb_t, volatile mp_limb_t *, volatile mp_limb_t *, mp_size_t);\n\n#define mpn_sec_mul __MPN(sec_mul)\n__GMP_DECLSPEC void mpn_sec_mul (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_mul_itch __MPN(sec_mul_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_mul_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_sqr __MPN(sec_sqr)\n__GMP_DECLSPEC void mpn_sec_sqr (mp_ptr, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_sqr_itch __MPN(sec_sqr_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_sqr_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_powm __MPN(sec_powm)\n__GMP_DECLSPEC void mpn_sec_powm (mp_ptr, mp_srcptr, mp_size_t, mp_srcptr, mp_bitcnt_t, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_powm_itch __MPN(sec_powm_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_powm_itch (mp_size_t, mp_bitcnt_t, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_tabselect __MPN(sec_tabselect)\n__GMP_DECLSPEC void mpn_sec_tabselect (volatile mp_limb_t *, volatile const mp_limb_t *, mp_size_t, mp_size_t, mp_size_t);\n\n#define mpn_sec_div_qr __MPN(sec_div_qr)\n__GMP_DECLSPEC mp_limb_t mpn_sec_div_qr (mp_ptr, mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_div_qr_itch __MPN(sec_div_qr_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_div_qr_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;\n#define mpn_sec_div_r __MPN(sec_div_r)\n__GMP_DECLSPEC void mpn_sec_div_r (mp_ptr, mp_size_t, mp_srcptr, mp_size_t, mp_ptr);\n#define mpn_sec_div_r_itch __MPN(sec_div_r_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_div_r_itch (mp_size_t, mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n#define mpn_sec_invert __MPN(sec_invert)\n__GMP_DECLSPEC int mpn_sec_invert (mp_ptr, mp_ptr, mp_srcptr, mp_size_t, mp_bitcnt_t, mp_ptr);\n#define mpn_sec_invert_itch __MPN(sec_invert_itch)\n__GMP_DECLSPEC mp_size_t mpn_sec_invert_itch (mp_size_t) __GMP_ATTRIBUTE_PURE;\n\n\n/**************** mpz inlines ****************/\n\n/* The following are provided as inlines where possible, but always exist as\n   library functions too, for binary compatibility.\n\n   Within gmp itself this inlining generally isn't relied on, since it\n   doesn't get done for all compilers, whereas if something is worth\n   inlining then it's worth arranging always.\n\n   There are two styles of inlining here.  When the same bit of code is\n   wanted for the inline as for the library version, then __GMP_FORCE_foo\n   arranges for that code to be emitted and the __GMP_EXTERN_INLINE\n   directive suppressed, eg. mpz_fits_uint_p.  When a different bit of code\n   is wanted for the inline than for the library version, then\n   __GMP_FORCE_foo arranges the inline to be suppressed, eg. mpz_abs.  */\n\n#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_abs)\n__GMP_EXTERN_INLINE void\nmpz_abs (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)\n{\n  if (__gmp_w != __gmp_u)\n    mpz_set (__gmp_w, __gmp_u);\n  __gmp_w->_mp_size = __GMP_ABS (__gmp_w->_mp_size);\n}\n#endif\n\n#if GMP_NAIL_BITS == 0\n#define __GMPZ_FITS_UTYPE_P(z,maxval)\t\t\t\t\t\\\n  mp_size_t  __gmp_n = z->_mp_size;\t\t\t\t\t\\\n  mp_ptr  __gmp_p = z->_mp_d;\t\t\t\t\t\t\\\n  return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval));\n#else\n#define __GMPZ_FITS_UTYPE_P(z,maxval)\t\t\t\t\t\\\n  mp_size_t  __gmp_n = z->_mp_size;\t\t\t\t\t\\\n  mp_ptr  __gmp_p = z->_mp_d;\t\t\t\t\t\t\\\n  return (__gmp_n == 0 || (__gmp_n == 1 && __gmp_p[0] <= maxval)\t\\\n\t  || (__gmp_n == 2 && __gmp_p[1] <= ((mp_limb_t) maxval >> GMP_NUMB_BITS)));\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_uint_p)\n#if ! defined (__GMP_FORCE_mpz_fits_uint_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpz_fits_uint_p (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  __GMPZ_FITS_UTYPE_P (__gmp_z, UINT_MAX);\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ulong_p)\n#if ! defined (__GMP_FORCE_mpz_fits_ulong_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpz_fits_ulong_p (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  __GMPZ_FITS_UTYPE_P (__gmp_z, ULONG_MAX);\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_fits_ushort_p)\n#if ! defined (__GMP_FORCE_mpz_fits_ushort_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpz_fits_ushort_p (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  __GMPZ_FITS_UTYPE_P (__gmp_z, USHRT_MAX);\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_get_ui)\n#if ! defined (__GMP_FORCE_mpz_get_ui)\n__GMP_EXTERN_INLINE\n#endif\nunsigned long\nmpz_get_ui (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  mp_ptr __gmp_p = __gmp_z->_mp_d;\n  mp_size_t __gmp_n = __gmp_z->_mp_size;\n  mp_limb_t __gmp_l = __gmp_p[0];\n  /* This is a \"#if\" rather than a plain \"if\" so as to avoid gcc warnings\n     about \"<< GMP_NUMB_BITS\" exceeding the type size, and to avoid Borland\n     C++ 6.0 warnings about condition always true for something like\n     \"ULONG_MAX < GMP_NUMB_MASK\".  */\n#if GMP_NAIL_BITS == 0 || defined (_LONG_LONG_LIMB)\n  /* limb==long and no nails, or limb==longlong, one limb is enough */\n  return (__gmp_n != 0 ? __gmp_l : 0);\n#else\n  /* limb==long and nails, need two limbs when available */\n  __gmp_n = __GMP_ABS (__gmp_n);\n  if (__gmp_n <= 1)\n    return (__gmp_n != 0 ? __gmp_l : 0);\n  else\n    return __gmp_l + (__gmp_p[1] << GMP_NUMB_BITS);\n#endif\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_getlimbn)\n#if ! defined (__GMP_FORCE_mpz_getlimbn)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpz_getlimbn (mpz_srcptr __gmp_z, mp_size_t __gmp_n) __GMP_NOTHROW\n{\n  mp_limb_t  __gmp_result = 0;\n  if (__GMP_LIKELY (__gmp_n >= 0 && __gmp_n < __GMP_ABS (__gmp_z->_mp_size)))\n    __gmp_result = __gmp_z->_mp_d[__gmp_n];\n  return __gmp_result;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpz_neg)\n__GMP_EXTERN_INLINE void\nmpz_neg (mpz_ptr __gmp_w, mpz_srcptr __gmp_u)\n{\n  if (__gmp_w != __gmp_u)\n    mpz_set (__gmp_w, __gmp_u);\n  __gmp_w->_mp_size = - __gmp_w->_mp_size;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_perfect_square_p)\n#if ! defined (__GMP_FORCE_mpz_perfect_square_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpz_perfect_square_p (mpz_srcptr __gmp_a)\n{\n  mp_size_t __gmp_asize;\n  int       __gmp_result;\n\n  __gmp_asize = __gmp_a->_mp_size;\n  __gmp_result = (__gmp_asize >= 0);  /* zero is a square, negatives are not */\n  if (__GMP_LIKELY (__gmp_asize > 0))\n    __gmp_result = mpn_perfect_square_p (__gmp_a->_mp_d, __gmp_asize);\n  return __gmp_result;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_popcount)\n#if ! defined (__GMP_FORCE_mpz_popcount)\n__GMP_EXTERN_INLINE\n#endif\nmp_bitcnt_t\nmpz_popcount (mpz_srcptr __gmp_u) __GMP_NOTHROW\n{\n  mp_size_t      __gmp_usize;\n  mp_bitcnt_t    __gmp_result;\n\n  __gmp_usize = __gmp_u->_mp_size;\n  __gmp_result = (__gmp_usize < 0 ? ~ __GMP_CAST (mp_bitcnt_t, 0) : __GMP_CAST (mp_bitcnt_t, 0));\n  if (__GMP_LIKELY (__gmp_usize > 0))\n    __gmp_result =  mpn_popcount (__gmp_u->_mp_d, __gmp_usize);\n  return __gmp_result;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_set_q)\n#if ! defined (__GMP_FORCE_mpz_set_q)\n__GMP_EXTERN_INLINE\n#endif\nvoid\nmpz_set_q (mpz_ptr __gmp_w, mpq_srcptr __gmp_u)\n{\n  mpz_tdiv_q (__gmp_w, mpq_numref (__gmp_u), mpq_denref (__gmp_u));\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpz_size)\n#if ! defined (__GMP_FORCE_mpz_size)\n__GMP_EXTERN_INLINE\n#endif\nsize_t\nmpz_size (mpz_srcptr __gmp_z) __GMP_NOTHROW\n{\n  return __GMP_ABS (__gmp_z->_mp_size);\n}\n#endif\n\n\n/**************** mpq inlines ****************/\n\n#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_abs)\n__GMP_EXTERN_INLINE void\nmpq_abs (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)\n{\n  if (__gmp_w != __gmp_u)\n    mpq_set (__gmp_w, __gmp_u);\n  __gmp_w->_mp_num._mp_size = __GMP_ABS (__gmp_w->_mp_num._mp_size);\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) && ! defined (__GMP_FORCE_mpq_neg)\n__GMP_EXTERN_INLINE void\nmpq_neg (mpq_ptr __gmp_w, mpq_srcptr __gmp_u)\n{\n  if (__gmp_w != __gmp_u)\n    mpq_set (__gmp_w, __gmp_u);\n  __gmp_w->_mp_num._mp_size = - __gmp_w->_mp_num._mp_size;\n}\n#endif\n\n\n/**************** mpn inlines ****************/\n\n/* The comments with __GMPN_ADD_1 below apply here too.\n\n   The test for FUNCTION returning 0 should predict well.  If it's assumed\n   {yp,ysize} will usually have a random number of bits then the high limb\n   won't be full and a carry out will occur a good deal less than 50% of the\n   time.\n\n   ysize==0 isn't a documented feature, but is used internally in a few\n   places.\n\n   Producing cout last stops it using up a register during the main part of\n   the calculation, though gcc (as of 3.0) on an \"if (mpn_add (...))\"\n   doesn't seem able to move the true and false legs of the conditional up\n   to the two places cout is generated.  */\n\n#define __GMPN_AORS(cout, wp, xp, xsize, yp, ysize, FUNCTION, TEST)     \\\n  do {                                                                  \\\n    mp_size_t  __gmp_i;                                                 \\\n    mp_limb_t  __gmp_x;                                                 \\\n                                                                        \\\n    /* ASSERT ((ysize) >= 0); */                                        \\\n    /* ASSERT ((xsize) >= (ysize)); */                                  \\\n    /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, xp, xsize)); */      \\\n    /* ASSERT (MPN_SAME_OR_SEPARATE2_P (wp, xsize, yp, ysize)); */      \\\n                                                                        \\\n    __gmp_i = (ysize);                                                  \\\n    if (__gmp_i != 0)                                                   \\\n      {                                                                 \\\n        if (FUNCTION (wp, xp, yp, __gmp_i))                             \\\n          {                                                             \\\n            do                                                          \\\n              {                                                         \\\n                if (__gmp_i >= (xsize))                                 \\\n                  {                                                     \\\n                    (cout) = 1;                                         \\\n                    goto __gmp_done;                                    \\\n                  }                                                     \\\n                __gmp_x = (xp)[__gmp_i];                                \\\n              }                                                         \\\n            while (TEST);                                               \\\n          }                                                             \\\n      }                                                                 \\\n    if ((wp) != (xp))                                                   \\\n      __GMPN_COPY_REST (wp, xp, xsize, __gmp_i);                        \\\n    (cout) = 0;                                                         \\\n  __gmp_done:                                                           \\\n    ;                                                                   \\\n  } while (0)\n\n#define __GMPN_ADD(cout, wp, xp, xsize, yp, ysize)              \\\n  __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_add_n,       \\\n               (((wp)[__gmp_i++] = (__gmp_x + 1) & GMP_NUMB_MASK) == 0))\n#define __GMPN_SUB(cout, wp, xp, xsize, yp, ysize)              \\\n  __GMPN_AORS (cout, wp, xp, xsize, yp, ysize, mpn_sub_n,       \\\n               (((wp)[__gmp_i++] = (__gmp_x - 1) & GMP_NUMB_MASK), __gmp_x == 0))\n\n\n/* The use of __gmp_i indexing is designed to ensure a compile time src==dst\n   remains nice and clear to the compiler, so that __GMPN_COPY_REST can\n   disappear, and the load/add/store gets a chance to become a\n   read-modify-write on CISC CPUs.\n\n   Alternatives:\n\n   Using a pair of pointers instead of indexing would be possible, but gcc\n   isn't able to recognise compile-time src==dst in that case, even when the\n   pointers are incremented more or less together.  Other compilers would\n   very likely have similar difficulty.\n\n   gcc could use \"if (__builtin_constant_p(src==dst) && src==dst)\" or\n   similar to detect a compile-time src==dst.  This works nicely on gcc\n   2.95.x, it's not good on gcc 3.0 where __builtin_constant_p(p==p) seems\n   to be always false, for a pointer p.  But the current code form seems\n   good enough for src==dst anyway.\n\n   gcc on x86 as usual doesn't give particularly good flags handling for the\n   carry/borrow detection.  It's tempting to want some multi instruction asm\n   blocks to help it, and this was tried, but in truth there's only a few\n   instructions to save and any gain is all too easily lost by register\n   juggling setting up for the asm.  */\n\n#if GMP_NAIL_BITS == 0\n#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB)\t\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    mp_size_t  __gmp_i;\t\t\t\t\t\t\\\n    mp_limb_t  __gmp_x, __gmp_r;                                \\\n\t\t\t\t\t\t\t\t\\\n    /* ASSERT ((n) >= 1); */\t\t\t\t\t\\\n    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */\t\\\n\t\t\t\t\t\t\t\t\\\n    __gmp_x = (src)[0];\t\t\t\t\t\t\\\n    __gmp_r = __gmp_x OP (v);                                   \\\n    (dst)[0] = __gmp_r;\t\t\t\t\t\t\\\n    if (CB (__gmp_r, __gmp_x, (v)))                             \\\n      {\t\t\t\t\t\t\t\t\\\n\t(cout) = 1;\t\t\t\t\t\t\\\n\tfor (__gmp_i = 1; __gmp_i < (n);)                       \\\n\t  {\t\t\t\t\t\t\t\\\n\t    __gmp_x = (src)[__gmp_i];                           \\\n\t    __gmp_r = __gmp_x OP 1;                             \\\n\t    (dst)[__gmp_i] = __gmp_r;                           \\\n\t    ++__gmp_i;\t\t\t\t\t\t\\\n\t    if (!CB (__gmp_r, __gmp_x, 1))                      \\\n\t      {\t\t\t\t\t\t\t\\\n\t\tif ((src) != (dst))\t\t\t\t\\\n\t\t  __GMPN_COPY_REST (dst, src, n, __gmp_i);      \\\n\t\t(cout) = 0;\t\t\t\t\t\\\n\t\tbreak;\t\t\t\t\t\t\\\n\t      }\t\t\t\t\t\t\t\\\n\t  }\t\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\\\n    else\t\t\t\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\\\n\tif ((src) != (dst))\t\t\t\t\t\\\n\t  __GMPN_COPY_REST (dst, src, n, 1);\t\t\t\\\n\t(cout) = 0;\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\\\n  } while (0)\n#endif\n\n#if GMP_NAIL_BITS >= 1\n#define __GMPN_AORS_1(cout, dst, src, n, v, OP, CB)\t\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    mp_size_t  __gmp_i;\t\t\t\t\t\t\\\n    mp_limb_t  __gmp_x, __gmp_r;\t\t\t\t\\\n\t\t\t\t\t\t\t\t\\\n    /* ASSERT ((n) >= 1); */\t\t\t\t\t\\\n    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, n)); */\t\\\n\t\t\t\t\t\t\t\t\\\n    __gmp_x = (src)[0];\t\t\t\t\t\t\\\n    __gmp_r = __gmp_x OP (v);\t\t\t\t\t\\\n    (dst)[0] = __gmp_r & GMP_NUMB_MASK;\t\t\t\t\\\n    if (__gmp_r >> GMP_NUMB_BITS != 0)\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\\\n\t(cout) = 1;\t\t\t\t\t\t\\\n\tfor (__gmp_i = 1; __gmp_i < (n);)\t\t\t\\\n\t  {\t\t\t\t\t\t\t\\\n\t    __gmp_x = (src)[__gmp_i];\t\t\t\t\\\n\t    __gmp_r = __gmp_x OP 1;\t\t\t\t\\\n\t    (dst)[__gmp_i] = __gmp_r & GMP_NUMB_MASK;\t\t\\\n\t    ++__gmp_i;\t\t\t\t\t\t\\\n\t    if (__gmp_r >> GMP_NUMB_BITS == 0)\t\t\t\\\n\t      {\t\t\t\t\t\t\t\\\n\t\tif ((src) != (dst))\t\t\t\t\\\n\t\t  __GMPN_COPY_REST (dst, src, n, __gmp_i);\t\\\n\t\t(cout) = 0;\t\t\t\t\t\\\n\t\tbreak;\t\t\t\t\t\t\\\n\t      }\t\t\t\t\t\t\t\\\n\t  }\t\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\\\n    else\t\t\t\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\\\n\tif ((src) != (dst))\t\t\t\t\t\\\n\t  __GMPN_COPY_REST (dst, src, n, 1);\t\t\t\\\n\t(cout) = 0;\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\\\n  } while (0)\n#endif\n\n#define __GMPN_ADDCB(r,x,y) ((r) < (y))\n#define __GMPN_SUBCB(r,x,y) ((x) < (y))\n\n#define __GMPN_ADD_1(cout, dst, src, n, v)\t     \\\n  __GMPN_AORS_1(cout, dst, src, n, v, +, __GMPN_ADDCB)\n#define __GMPN_SUB_1(cout, dst, src, n, v)\t     \\\n  __GMPN_AORS_1(cout, dst, src, n, v, -, __GMPN_SUBCB)\n\n\n/* Compare {xp,size} and {yp,size}, setting \"result\" to positive, zero or\n   negative.  size==0 is allowed.  On random data usually only one limb will\n   need to be examined to get a result, so it's worth having it inline.  */\n#define __GMPN_CMP(result, xp, yp, size)                                \\\n  do {                                                                  \\\n    mp_size_t  __gmp_i;                                                 \\\n    mp_limb_t  __gmp_x, __gmp_y;                                        \\\n                                                                        \\\n    /* ASSERT ((size) >= 0); */                                         \\\n                                                                        \\\n    (result) = 0;                                                       \\\n    __gmp_i = (size);                                                   \\\n    while (--__gmp_i >= 0)                                              \\\n      {                                                                 \\\n        __gmp_x = (xp)[__gmp_i];                                        \\\n        __gmp_y = (yp)[__gmp_i];                                        \\\n        if (__gmp_x != __gmp_y)                                         \\\n          {                                                             \\\n            /* Cannot use __gmp_x - __gmp_y, may overflow an \"int\" */   \\\n            (result) = (__gmp_x > __gmp_y ? 1 : -1);                    \\\n            break;                                                      \\\n          }                                                             \\\n      }                                                                 \\\n  } while (0)\n\n\n#if defined (__GMPN_COPY) && ! defined (__GMPN_COPY_REST)\n#define __GMPN_COPY_REST(dst, src, size, start)                 \\\n  do {                                                          \\\n    /* ASSERT ((start) >= 0); */                                \\\n    /* ASSERT ((start) <= (size)); */                           \\\n    __GMPN_COPY ((dst)+(start), (src)+(start), (size)-(start)); \\\n  } while (0)\n#endif\n\n/* Copy {src,size} to {dst,size}, starting at \"start\".  This is designed to\n   keep the indexing dst[j] and src[j] nice and simple for __GMPN_ADD_1,\n   __GMPN_ADD, etc.  */\n#if ! defined (__GMPN_COPY_REST)\n#define __GMPN_COPY_REST(dst, src, size, start)                 \\\n  do {                                                          \\\n    mp_size_t __gmp_j;                                          \\\n    /* ASSERT ((size) >= 0); */                                 \\\n    /* ASSERT ((start) >= 0); */                                \\\n    /* ASSERT ((start) <= (size)); */                           \\\n    /* ASSERT (MPN_SAME_OR_SEPARATE_P (dst, src, size)); */     \\\n    __GMP_CRAY_Pragma (\"_CRI ivdep\");                           \\\n    for (__gmp_j = (start); __gmp_j < (size); __gmp_j++)        \\\n      (dst)[__gmp_j] = (src)[__gmp_j];                          \\\n  } while (0)\n#endif\n\n/* Enhancement: Use some of the smarter code from gmp-impl.h.  Maybe use\n   mpn_copyi if there's a native version, and if we don't mind demanding\n   binary compatibility for it (on targets which use it).  */\n\n#if ! defined (__GMPN_COPY)\n#define __GMPN_COPY(dst, src, size)   __GMPN_COPY_REST (dst, src, size, 0)\n#endif\n\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add)\n#if ! defined (__GMP_FORCE_mpn_add)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_add (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)\n{\n  mp_limb_t  __gmp_c;\n  __GMPN_ADD (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);\n  return __gmp_c;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_add_1)\n#if ! defined (__GMP_FORCE_mpn_add_1)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_add_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW\n{\n  mp_limb_t  __gmp_c;\n  __GMPN_ADD_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);\n  return __gmp_c;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_cmp)\n#if ! defined (__GMP_FORCE_mpn_cmp)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpn_cmp (mp_srcptr __gmp_xp, mp_srcptr __gmp_yp, mp_size_t __gmp_size) __GMP_NOTHROW\n{\n  int __gmp_result;\n  __GMPN_CMP (__gmp_result, __gmp_xp, __gmp_yp, __gmp_size);\n  return __gmp_result;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_zero_p)\n#if ! defined (__GMP_FORCE_mpn_zero_p)\n__GMP_EXTERN_INLINE\n#endif\nint\nmpn_zero_p (mp_srcptr __gmp_p, mp_size_t __gmp_n) __GMP_NOTHROW\n{\n  /* if (__GMP_LIKELY (__gmp_n > 0)) */\n    do {\n      if (__gmp_p[--__gmp_n] != 0)\n\treturn 0;\n    } while (__gmp_n != 0);\n  return 1;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub)\n#if ! defined (__GMP_FORCE_mpn_sub)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_sub (mp_ptr __gmp_wp, mp_srcptr __gmp_xp, mp_size_t __gmp_xsize, mp_srcptr __gmp_yp, mp_size_t __gmp_ysize)\n{\n  mp_limb_t  __gmp_c;\n  __GMPN_SUB (__gmp_c, __gmp_wp, __gmp_xp, __gmp_xsize, __gmp_yp, __gmp_ysize);\n  return __gmp_c;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_sub_1)\n#if ! defined (__GMP_FORCE_mpn_sub_1)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_sub_1 (mp_ptr __gmp_dst, mp_srcptr __gmp_src, mp_size_t __gmp_size, mp_limb_t __gmp_n) __GMP_NOTHROW\n{\n  mp_limb_t  __gmp_c;\n  __GMPN_SUB_1 (__gmp_c, __gmp_dst, __gmp_src, __gmp_size, __gmp_n);\n  return __gmp_c;\n}\n#endif\n\n#if defined (__GMP_EXTERN_INLINE) || defined (__GMP_FORCE_mpn_neg)\n#if ! defined (__GMP_FORCE_mpn_neg)\n__GMP_EXTERN_INLINE\n#endif\nmp_limb_t\nmpn_neg (mp_ptr __gmp_rp, mp_srcptr __gmp_up, mp_size_t __gmp_n)\n{\n  while (*__gmp_up == 0) /* Low zero limbs are unchanged by negation. */\n    {\n      *__gmp_rp = 0;\n      if (!--__gmp_n) /* All zero */\n\treturn 0;\n      ++__gmp_up; ++__gmp_rp;\n    }\n\n  *__gmp_rp = (- *__gmp_up) & GMP_NUMB_MASK;\n\n  if (--__gmp_n) /* Higher limbs get complemented. */\n    mpn_com (++__gmp_rp, ++__gmp_up, __gmp_n);\n\n  return 1;\n}\n#endif\n\n#if defined (__cplusplus)\n}\n#endif\n\n\n/* Allow faster testing for negative, zero, and positive.  */\n#define mpz_sgn(Z) ((Z)->_mp_size < 0 ? -1 : (Z)->_mp_size > 0)\n#define mpf_sgn(F) ((F)->_mp_size < 0 ? -1 : (F)->_mp_size > 0)\n#define mpq_sgn(Q) ((Q)->_mp_num._mp_size < 0 ? -1 : (Q)->_mp_num._mp_size > 0)\n\n/* When using GCC, optimize certain common comparisons.  */\n#if defined (__GNUC__) && __GNUC__ >= 2\n#define mpz_cmp_ui(Z,UI) \\\n  (__builtin_constant_p (UI) && (UI) == 0\t\t\t\t\\\n   ? mpz_sgn (Z) : _mpz_cmp_ui (Z,UI))\n#define mpz_cmp_si(Z,SI)\t\t\t\t\t\t\\\n  (__builtin_constant_p ((SI) >= 0) && (SI) >= 0\t\t\t\\\n   ? mpz_cmp_ui (Z, __GMP_CAST (unsigned long, SI))\t\t\t\\\n   : _mpz_cmp_si (Z,SI))\n#define mpq_cmp_ui(Q,NUI,DUI)\t\t\t\t\t\\\n  (__builtin_constant_p (NUI) && (NUI) == 0 ? mpq_sgn (Q)\t\\\n   : __builtin_constant_p ((NUI) == (DUI)) && (NUI) == (DUI)\t\\\n   ? mpz_cmp (mpq_numref (Q), mpq_denref (Q))\t\t\t\\\n   : _mpq_cmp_ui (Q,NUI,DUI))\n#define mpq_cmp_si(q,n,d)\t\t\t\t\\\n  (__builtin_constant_p ((n) >= 0) && (n) >= 0\t\t\\\n   ? mpq_cmp_ui (q, __GMP_CAST (unsigned long, n), d)\t\\\n   : _mpq_cmp_si (q, n, d))\n#else\n#define mpz_cmp_ui(Z,UI) _mpz_cmp_ui (Z,UI)\n#define mpz_cmp_si(Z,UI) _mpz_cmp_si (Z,UI)\n#define mpq_cmp_ui(Q,NUI,DUI) _mpq_cmp_ui (Q,NUI,DUI)\n#define mpq_cmp_si(q,n,d)  _mpq_cmp_si(q,n,d)\n#endif\n\n\n/* Using \"&\" rather than \"&&\" means these can come out branch-free.  Every\n   mpz_t has at least one limb allocated, so fetching the low limb is always\n   allowed.  */\n#define mpz_odd_p(z)   (((z)->_mp_size != 0) & __GMP_CAST (int, (z)->_mp_d[0]))\n#define mpz_even_p(z)  (! mpz_odd_p (z))\n\n\n/**************** C++ routines ****************/\n\n#ifdef __cplusplus\n__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpz_srcptr);\n__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpq_srcptr);\n__GMP_DECLSPEC_XX std::ostream& operator<< (std::ostream &, mpf_srcptr);\n__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpz_ptr);\n__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpq_ptr);\n__GMP_DECLSPEC_XX std::istream& operator>> (std::istream &, mpf_ptr);\n#endif\n\n\n/* Source-level compatibility with GMP 2 and earlier. */\n#define mpn_divmod(qp,np,nsize,dp,dsize) \\\n  mpn_divrem (qp, __GMP_CAST (mp_size_t, 0), np, nsize, dp, dsize)\n\n/* Source-level compatibility with GMP 1.  */\n#define mpz_mdiv\tmpz_fdiv_q\n#define mpz_mdivmod\tmpz_fdiv_qr\n#define mpz_mmod\tmpz_fdiv_r\n#define mpz_mdiv_ui\tmpz_fdiv_q_ui\n#define mpz_mdivmod_ui(q,r,n,d) \\\n  (((r) == 0) ? mpz_fdiv_q_ui (q,n,d) : mpz_fdiv_qr_ui (q,r,n,d))\n#define mpz_mmod_ui(r,n,d) \\\n  (((r) == 0) ? mpz_fdiv_ui (n,d) : mpz_fdiv_r_ui (r,n,d))\n\n/* Useful synonyms, but not quite compatible with GMP 1.  */\n#define mpz_div\t\tmpz_fdiv_q\n#define mpz_divmod\tmpz_fdiv_qr\n#define mpz_div_ui\tmpz_fdiv_q_ui\n#define mpz_divmod_ui\tmpz_fdiv_qr_ui\n#define mpz_div_2exp\tmpz_fdiv_q_2exp\n#define mpz_mod_2exp\tmpz_fdiv_r_2exp\n\nenum\n{\n  GMP_ERROR_NONE = 0,\n  GMP_ERROR_UNSUPPORTED_ARGUMENT = 1,\n  GMP_ERROR_DIVISION_BY_ZERO = 2,\n  GMP_ERROR_SQRT_OF_NEGATIVE = 4,\n  GMP_ERROR_INVALID_ARGUMENT = 8,\n  GMP_ERROR_MPZ_OVERFLOW = 16\n};\n\n/* Define CC and CFLAGS which were used to build this version of GMP */\n#define __GMP_CC \"x86_64-w64-mingw32-gcc\"\n#define __GMP_CFLAGS \"-O2 -pedantic -fomit-frame-pointer -m64 -mtune=k8 -march=k8\"\n\n/* Major version number is the value of __GNU_MP__ too, above. */\n#define __GNU_MP_VERSION            6\n#define __GNU_MP_VERSION_MINOR      3\n#define __GNU_MP_VERSION_PATCHLEVEL 0\n#define __GNU_MP_RELEASE (__GNU_MP_VERSION * 10000 + __GNU_MP_VERSION_MINOR * 100 + __GNU_MP_VERSION_PATCHLEVEL)\n\n#define __GMP_H__\n#endif /* __GMP_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/abstract.h",
    "content": "/*\n * Copyright (C) 2010-2012 Free Software Foundation, Inc.\n * Copyright (C) 2015-2017 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_ABSTRACT_H\n#define GNUTLS_ABSTRACT_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n#include <gnutls/pkcs11.h>\n#include <gnutls/openpgp.h>\n#include <gnutls/tpm.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/* Public key operations */\n\n#define GNUTLS_PUBKEY_VERIFY_FLAG_TLS_RSA GNUTLS_PUBKEY_VERIFY_FLAG_TLS1_RSA\n/**\n * gnutls_pubkey_flags:\n * @GNUTLS_PUBKEY_DISABLE_CALLBACKS: The following flag disables call to PIN callbacks. Only\n *   relevant to TPM keys.\n * @GNUTLS_PUBKEY_GET_OPENPGP_FINGERPRINT: request an OPENPGP fingerprint instead of the default.\n *\n * Enumeration of different certificate import flags.\n */\ntypedef enum gnutls_pubkey_flags {\n\tGNUTLS_PUBKEY_DISABLE_CALLBACKS = 1 << 2,\n\tGNUTLS_PUBKEY_GET_OPENPGP_FINGERPRINT = 1 << 3\n} gnutls_pubkey_flags_t;\n\n/**\n * gnutls_abstract_export_flags:\n * @GNUTLS_EXPORT_FLAG_NO_LZ: do not prepend a leading zero to exported values\n *\n * Enumeration of different certificate import flags.\n */\ntypedef enum gnutls_abstract_export_flags {\n\tGNUTLS_EXPORT_FLAG_NO_LZ = 1\n} gnutls_abstract_export_flags_t;\n\n#define GNUTLS_PUBKEY_VERIFY_FLAG_TLS1_RSA GNUTLS_VERIFY_USE_TLS1_RSA\n\ntypedef int (*gnutls_privkey_sign_func) (gnutls_privkey_t key,\n\t\t\t\t\t void *userdata,\n\t\t\t\t\t const gnutls_datum_t *raw_data,\n\t\t\t\t\t gnutls_datum_t * signature);\n\n\ntypedef int (*gnutls_privkey_decrypt_func) (gnutls_privkey_t key,\n\t\t\t\t\t    void *userdata,\n\t\t\t\t\t    const gnutls_datum_t *ciphertext,\n\t\t\t\t\t    gnutls_datum_t * plaintext);\n\ntypedef int (*gnutls_privkey_decrypt_func2) (gnutls_privkey_t key,\n\t\t\t\t\t     void *userdata,\n\t\t\t\t\t     const gnutls_datum_t *ciphertext,\n\t\t\t\t\t     unsigned char * plaintext,\n\t\t\t\t\t     size_t plaintext_size);\n\n/* to be called to sign pre-hashed data. The input will be\n * the output of the hash (such as SHA256) corresponding to\n * the signature algorithm. The algorithm GNUTLS_SIGN_RSA_RAW\n * will be provided when RSA PKCS#1 DigestInfo structure is provided\n * as data (when this is called from a TLS 1.0 or 1.1 session).\n */\ntypedef int (*gnutls_privkey_sign_hash_func) (gnutls_privkey_t key,\n\t\t\t\t\t      gnutls_sign_algorithm_t algo,\n\t\t\t\t\t      void *userdata,\n\t\t\t\t\t      unsigned int flags,\n\t\t\t\t\t      const gnutls_datum_t *hash,\n\t\t\t\t\t      gnutls_datum_t * signature);\n\n/* to be called to sign data. The input data will be\n * the data to be signed (and hashed), with the provided\n * signature algorithm. This function is used for algorithms\n * like ed25519 which cannot take pre-hashed data as input.\n */\ntypedef int (*gnutls_privkey_sign_data_func) (gnutls_privkey_t key,\n\t\t\t\t\t      gnutls_sign_algorithm_t algo,\n\t\t\t\t\t      void *userdata,\n\t\t\t\t\t      unsigned int flags,\n\t\t\t\t\t      const gnutls_datum_t *data,\n\t\t\t\t\t      gnutls_datum_t * signature);\n\ntypedef void (*gnutls_privkey_deinit_func) (gnutls_privkey_t key,\n\t\t\t\t\t    void *userdata);\n\n\n#define GNUTLS_SIGN_ALGO_TO_FLAGS(sig) (unsigned int)((sig)<<20)\n#define GNUTLS_FLAGS_TO_SIGN_ALGO(flags) (unsigned int)((flags)>>20)\n\n/* Should return the public key algorithm (gnutls_pk_algorithm_t) */\n#define GNUTLS_PRIVKEY_INFO_PK_ALGO 1\n/* Should return the preferred signature algorithm (gnutls_sign_algorithm_t) or 0. */\n#define GNUTLS_PRIVKEY_INFO_SIGN_ALGO (1<<1)\n/* Should return true (1) or false (0) if the provided sign algorithm\n * (obtained with GNUTLS_FLAGS_TO_SIGN_ALGO) is supported.\n */\n#define GNUTLS_PRIVKEY_INFO_HAVE_SIGN_ALGO (1<<2)\n/* Should return the number of bits of the public key algorithm (required for RSA-PSS)\n * It is the value that should be returned by gnutls_pubkey_get_pk_algorithm() */\n#define GNUTLS_PRIVKEY_INFO_PK_ALGO_BITS (1<<3)\n\n/* returns information on the public key associated with userdata */\ntypedef int (*gnutls_privkey_info_func) (gnutls_privkey_t key, unsigned int flags, void *userdata);\n\nint gnutls_pubkey_init(gnutls_pubkey_t * key);\nvoid gnutls_pubkey_deinit(gnutls_pubkey_t key);\n\nint gnutls_pubkey_verify_params(gnutls_pubkey_t key);\n\nvoid gnutls_pubkey_set_pin_function(gnutls_pubkey_t key,\n\t\t\t\t    gnutls_pin_callback_t fn,\n\t\t\t\t    void *userdata);\n\nint gnutls_pubkey_get_pk_algorithm(gnutls_pubkey_t key,\n\t\t\t\t   unsigned int *bits);\n\nint\ngnutls_pubkey_set_spki(gnutls_pubkey_t key,\n\t\t\tconst gnutls_x509_spki_t spki,\n\t\t\tunsigned int flags);\n\nint\ngnutls_pubkey_get_spki(gnutls_pubkey_t key,\n\t\t\tconst gnutls_x509_spki_t spki,\n\t\t\tunsigned int flags);\n\nint gnutls_pubkey_import_x509(gnutls_pubkey_t key,\n\t\t\t      gnutls_x509_crt_t crt, unsigned int flags);\nint gnutls_pubkey_import_x509_crq(gnutls_pubkey_t key,\n\t\t\t\t  gnutls_x509_crq_t crq,\n\t\t\t\t  unsigned int flags);\nint gnutls_pubkey_import_pkcs11(gnutls_pubkey_t key,\n\t\t\t\tgnutls_pkcs11_obj_t obj,\n\t\t\t\tunsigned int flags);\nint gnutls_pubkey_import_openpgp(gnutls_pubkey_t key,\n\t\t\t\t gnutls_openpgp_crt_t crt,\n\t\t\t\t unsigned int flags);\n\nint gnutls_pubkey_import_openpgp_raw(gnutls_pubkey_t pkey,\n\t\t\t\t     const gnutls_datum_t * data,\n\t\t\t\t     gnutls_openpgp_crt_fmt_t\n\t\t\t\t     format,\n\t\t\t\t     const gnutls_openpgp_keyid_t\n\t\t\t\t     keyid, unsigned int flags);\nint gnutls_pubkey_import_x509_raw(gnutls_pubkey_t pkey,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t\t  unsigned int flags);\n\nint\ngnutls_pubkey_import_privkey(gnutls_pubkey_t key,\n\t\t\t     gnutls_privkey_t pkey,\n\t\t\t     unsigned int usage, unsigned int flags);\n\nint\ngnutls_pubkey_import_tpm_url(gnutls_pubkey_t pkey,\n\t\t\t     const char *url,\n\t\t\t     const char *srk_password, unsigned int flags);\n\nint\ngnutls_pubkey_import_url(gnutls_pubkey_t key, const char *url,\n\t\t\t unsigned int flags);\n\nint\ngnutls_pubkey_import_tpm_raw(gnutls_pubkey_t pkey,\n\t\t\t     const gnutls_datum_t * fdata,\n\t\t\t     gnutls_tpmkey_fmt_t format,\n\t\t\t     const char *srk_password, unsigned int flags);\n\nint gnutls_pubkey_get_preferred_hash_algorithm(gnutls_pubkey_t key,\n\t\t\t\t\t       gnutls_digest_algorithm_t\n\t\t\t\t\t       * hash, unsigned int *mand);\n\n#define gnutls_pubkey_get_pk_rsa_raw gnutls_pubkey_export_rsa_raw\nint gnutls_pubkey_export_rsa_raw(gnutls_pubkey_t key,\n\t\t\t\t gnutls_datum_t * m, gnutls_datum_t * e);\n\nint gnutls_pubkey_export_rsa_raw2(gnutls_pubkey_t key,\n\t\t\t\t  gnutls_datum_t * m, gnutls_datum_t * e,\n\t\t\t\t  unsigned flags);\n\n#define gnutls_pubkey_get_pk_dsa_raw gnutls_pubkey_export_dsa_raw\nint gnutls_pubkey_export_dsa_raw(gnutls_pubkey_t key,\n\t\t\t\t gnutls_datum_t * p,\n\t\t\t\t gnutls_datum_t * q,\n\t\t\t\t gnutls_datum_t * g, gnutls_datum_t * y);\n\nint gnutls_pubkey_export_dsa_raw2(gnutls_pubkey_t key,\n\t\t\t\t gnutls_datum_t * p,\n\t\t\t\t gnutls_datum_t * q,\n\t\t\t\t gnutls_datum_t * g, gnutls_datum_t * y,\n\t\t\t\t unsigned flags);\n\nint gnutls_pubkey_export_ecc_raw2(gnutls_pubkey_t key,\n\t\t\t\t gnutls_ecc_curve_t * curve,\n\t\t\t\t gnutls_datum_t * x, gnutls_datum_t * y,\n\t\t\t\t unsigned flags);\n\nint gnutls_pubkey_export_gost_raw2(gnutls_pubkey_t key,\n\t\t\t\t   gnutls_ecc_curve_t * curve,\n\t\t\t\t   gnutls_digest_algorithm_t * digest,\n\t\t\t\t   gnutls_gost_paramset_t * paramset,\n\t\t\t\t   gnutls_datum_t * x, gnutls_datum_t * y,\n\t\t\t\t   unsigned int flags);\n\n#define gnutls_pubkey_get_pk_ecc_raw gnutls_pubkey_export_ecc_raw\nint gnutls_pubkey_export_ecc_raw(gnutls_pubkey_t key,\n\t\t\t\t gnutls_ecc_curve_t * curve,\n\t\t\t\t gnutls_datum_t * x, gnutls_datum_t * y);\n\n#define gnutls_pubkey_get_pk_ecc_x962 gnutls_pubkey_export_ecc_x962\nint gnutls_pubkey_export_ecc_x962(gnutls_pubkey_t key,\n\t\t\t\t  gnutls_datum_t * parameters,\n\t\t\t\t  gnutls_datum_t * ecpoint);\n\nint gnutls_pubkey_export(gnutls_pubkey_t key,\n\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t void *output_data, size_t * output_data_size);\n\nint gnutls_pubkey_export2(gnutls_pubkey_t key,\n\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t  gnutls_datum_t * out);\n\nint gnutls_pubkey_get_key_id(gnutls_pubkey_t key,\n\t\t\t     unsigned int flags,\n\t\t\t     unsigned char *output_data,\n\t\t\t     size_t * output_data_size);\n\nint\ngnutls_pubkey_get_openpgp_key_id(gnutls_pubkey_t key,\n\t\t\t\t unsigned int flags,\n\t\t\t\t unsigned char *output_data,\n\t\t\t\t size_t * output_data_size,\n\t\t\t\t unsigned int *subkey);\n\nint gnutls_pubkey_get_key_usage(gnutls_pubkey_t key, unsigned int *usage);\nint gnutls_pubkey_set_key_usage(gnutls_pubkey_t key, unsigned int usage);\n\nint gnutls_pubkey_import(gnutls_pubkey_t key,\n\t\t\t const gnutls_datum_t * data,\n\t\t\t gnutls_x509_crt_fmt_t format);\n\n\n#define gnutls_pubkey_import_pkcs11_url(key, url, flags) gnutls_pubkey_import_url(key, url, flags)\n\nint gnutls_pubkey_import_dsa_raw(gnutls_pubkey_t key,\n\t\t\t\t const gnutls_datum_t * p,\n\t\t\t\t const gnutls_datum_t * q,\n\t\t\t\t const gnutls_datum_t * g,\n\t\t\t\t const gnutls_datum_t * y);\nint gnutls_pubkey_import_rsa_raw(gnutls_pubkey_t key,\n\t\t\t\t const gnutls_datum_t * m,\n\t\t\t\t const gnutls_datum_t * e);\n\nint\ngnutls_pubkey_import_ecc_x962(gnutls_pubkey_t key,\n\t\t\t      const gnutls_datum_t * parameters,\n\t\t\t      const gnutls_datum_t * ecpoint);\n\nint\ngnutls_pubkey_import_ecc_raw(gnutls_pubkey_t key,\n\t\t\t     gnutls_ecc_curve_t curve,\n\t\t\t     const gnutls_datum_t * x,\n\t\t\t     const gnutls_datum_t * y);\n\nint\ngnutls_pubkey_import_gost_raw(gnutls_pubkey_t key,\n\t\t\t     gnutls_ecc_curve_t curve,\n\t\t\t     gnutls_digest_algorithm_t digest,\n\t\t\t     gnutls_gost_paramset_t paramset,\n\t\t\t     const gnutls_datum_t * x,\n\t\t\t     const gnutls_datum_t * y);\n\nint\ngnutls_pubkey_encrypt_data(gnutls_pubkey_t key,\n\t\t\t   unsigned int flags,\n\t\t\t   const gnutls_datum_t * plaintext,\n\t\t\t   gnutls_datum_t * ciphertext);\n\nint gnutls_x509_crt_set_pubkey(gnutls_x509_crt_t crt, gnutls_pubkey_t key);\n\nint gnutls_x509_crq_set_pubkey(gnutls_x509_crq_t crq, gnutls_pubkey_t key);\n\nint\ngnutls_pubkey_verify_hash2(gnutls_pubkey_t key,\n\t\t\t   gnutls_sign_algorithm_t algo,\n\t\t\t   unsigned int flags,\n\t\t\t   const gnutls_datum_t * hash,\n\t\t\t   const gnutls_datum_t * signature);\n\nint\ngnutls_pubkey_verify_data2(gnutls_pubkey_t pubkey,\n\t\t\t   gnutls_sign_algorithm_t algo,\n\t\t\t   unsigned int flags,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   const gnutls_datum_t * signature);\n\n/* Private key operations */\n\nint gnutls_privkey_init(gnutls_privkey_t * key);\nvoid gnutls_privkey_deinit(gnutls_privkey_t key);\n\n/* macros to allow specifying a subgroup and group size in gnutls_privkey_generate()\n * and gnutls_x509_privkey_generate() */\n#define GNUTLS_SUBGROUP_TO_BITS(group, subgroup) (unsigned int)((subgroup<<16)|(group))\n#define GNUTLS_BITS_TO_SUBGROUP(bits) ((bits >> 16) & 0xFFFF)\n#define GNUTLS_BITS_TO_GROUP(bits) (bits & 0xFFFF)\n#define GNUTLS_BITS_HAVE_SUBGROUP(bits) ((bits) & 0xFFFF0000)\n\nint\ngnutls_privkey_generate (gnutls_privkey_t key,\n                         gnutls_pk_algorithm_t algo, unsigned int bits,\n                         unsigned int flags);\nint\ngnutls_privkey_generate2(gnutls_privkey_t pkey,\n\t\t\t gnutls_pk_algorithm_t algo, unsigned int bits,\n\t\t\t unsigned int flags, const gnutls_keygen_data_st *data, unsigned data_size);\n\nint\ngnutls_privkey_set_spki(gnutls_privkey_t key,\n\t\t\tconst gnutls_x509_spki_t spki,\n\t\t\tunsigned int flags);\n\nint\ngnutls_privkey_get_spki(gnutls_privkey_t key,\n\t\t\tconst gnutls_x509_spki_t spki,\n\t\t\tunsigned int flags);\n\nint gnutls_privkey_verify_seed(gnutls_privkey_t key, gnutls_digest_algorithm_t, const void *seed, size_t seed_size);\nint gnutls_privkey_get_seed(gnutls_privkey_t key, gnutls_digest_algorithm_t*, void *seed, size_t *seed_size);\n\nint gnutls_privkey_verify_params(gnutls_privkey_t key);\n\nvoid gnutls_privkey_set_flags(gnutls_privkey_t key, unsigned int flags);\n\nvoid gnutls_privkey_set_pin_function (gnutls_privkey_t key,\n                                      gnutls_pin_callback_t fn, void *userdata);\n\nint gnutls_privkey_get_pk_algorithm(gnutls_privkey_t key,\n\t\t\t\t    unsigned int *bits);\ngnutls_privkey_type_t gnutls_privkey_get_type(gnutls_privkey_t key);\nint gnutls_privkey_status(gnutls_privkey_t key);\n\n/**\n * gnutls_privkey_flags:\n * @GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA: Make an RSA signature on the hashed data as in the TLS protocol.\n * @GNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS: Make an RSA signature on the hashed data with the PSS padding.\n * @GNUTLS_PRIVKEY_FLAG_REPRODUCIBLE: Make a signature on the hashed data with reproducible parameters.\n *   For RSA-PSS, that means to use empty salt instead of random value. To\n *   verify a signature created using this flag, the corresponding SPKI needs\n *   to be set on the public key. Use gnutls_pubkey_set_spki() for that.\n *   For ECDSA/DSA, it uses the deterministic construction of random parameter\n *   according to RFC 6979. Note that this only supports the NIST curves and DSA\n *   subgroup bits up to 512.\n * @GNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE: When importing a private key, automatically\n *   release it when the structure it was imported is released.\n * @GNUTLS_PRIVKEY_IMPORT_COPY: Copy required values during import.\n * @GNUTLS_PRIVKEY_DISABLE_CALLBACKS: The following flag disables call to PIN callbacks etc.\n *   Only relevant to TPM keys.\n * @GNUTLS_PRIVKEY_FLAG_PROVABLE: When generating a key involving prime numbers, use provable primes; a seed may be required.\n * @GNUTLS_PRIVKEY_FLAG_CA: The generated private key is going to be used as a CA (relevant for RSA-PSS keys).\n * @GNUTLS_PRIVKEY_FLAG_EXPORT_COMPAT: Keys generated or imported as provable require an extended format which cannot be read by previous versions\n *   of gnutls or other applications. By setting this flag the key will be exported in a backwards compatible way,\n *   even if the information about the seed used will be lost.\n * @GNUTLS_PRIVKEY_FLAG_RSA_PSS_FIXED_SALT_LENGTH: When making an RSA-PSS\n *   signature, use the salt whose length is equal to the digest length, as\n *   mandated in RFC 8446 4.2.3.\n *\n * Enumeration of different certificate import flags.\n */\ntypedef enum gnutls_privkey_flags {\n\tGNUTLS_PRIVKEY_IMPORT_AUTO_RELEASE = 1,\n\tGNUTLS_PRIVKEY_IMPORT_COPY = 1 << 1,\n\tGNUTLS_PRIVKEY_DISABLE_CALLBACKS = 1 << 2,\n\tGNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA = 1 << 4,\n\tGNUTLS_PRIVKEY_FLAG_PROVABLE = 1 << 5,\n\tGNUTLS_PRIVKEY_FLAG_EXPORT_COMPAT = 1 << 6,\n\tGNUTLS_PRIVKEY_SIGN_FLAG_RSA_PSS = 1 << 7,\n\tGNUTLS_PRIVKEY_FLAG_REPRODUCIBLE = 1 << 8,\n\tGNUTLS_PRIVKEY_FLAG_CA = 1 << 9,\n\tGNUTLS_PRIVKEY_FLAG_RSA_PSS_FIXED_SALT_LENGTH = 1 << 10\n} gnutls_privkey_flags_t;\n\nint gnutls_privkey_import_pkcs11(gnutls_privkey_t pkey,\n\t\t\t\t gnutls_pkcs11_privkey_t key,\n\t\t\t\t unsigned int flags);\nint gnutls_privkey_import_x509(gnutls_privkey_t pkey,\n\t\t\t       gnutls_x509_privkey_t key,\n\t\t\t       unsigned int flags);\nint gnutls_privkey_import_openpgp(gnutls_privkey_t pkey,\n\t\t\t\t  gnutls_openpgp_privkey_t key,\n\t\t\t\t  unsigned int flags);\n\nint gnutls_privkey_export_x509(gnutls_privkey_t pkey,\n                               gnutls_x509_privkey_t * key);\nint gnutls_privkey_export_openpgp(gnutls_privkey_t pkey,\n                                  gnutls_openpgp_privkey_t * key);\nint\ngnutls_privkey_export_pkcs11(gnutls_privkey_t pkey,\n                             gnutls_pkcs11_privkey_t *key);\n\nint gnutls_privkey_import_openpgp_raw(gnutls_privkey_t pkey,\n\t\t\t\t      const gnutls_datum_t * data,\n\t\t\t\t      gnutls_openpgp_crt_fmt_t\n\t\t\t\t      format,\n\t\t\t\t      const gnutls_openpgp_keyid_t\n\t\t\t\t      keyid, const char *password);\n\nint gnutls_privkey_import_x509_raw(gnutls_privkey_t pkey,\n\t\t\t\t   const gnutls_datum_t * data,\n\t\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t\t   const char *password,\n\t\t\t\t   unsigned int flags);\n\nint\ngnutls_privkey_import_tpm_raw(gnutls_privkey_t pkey,\n\t\t\t      const gnutls_datum_t * fdata,\n\t\t\t      gnutls_tpmkey_fmt_t format,\n\t\t\t      const char *srk_password,\n\t\t\t      const char *key_password,\n\t\t\t      unsigned int flags);\n\nint\ngnutls_privkey_import_tpm_url(gnutls_privkey_t pkey,\n\t\t\t      const char *url,\n\t\t\t      const char *srk_password,\n\t\t\t      const char *key_password,\n\t\t\t      unsigned int flags);\n\nint gnutls_privkey_import_url(gnutls_privkey_t key,\n\t\t\t      const char *url, unsigned int flags);\n\n#if 0\n/* for documentation purposes */\nint gnutls_privkey_import_pkcs11_url(gnutls_privkey_t key, const char *url);\n#endif\n\n#define gnutls_privkey_import_pkcs11_url(key, url) gnutls_privkey_import_url(key, url, 0)\n\nint\ngnutls_privkey_import_ext(gnutls_privkey_t pkey,\n\t\t\t  gnutls_pk_algorithm_t pk,\n\t\t\t  void *userdata,\n\t\t\t  gnutls_privkey_sign_func sign_func,\n\t\t\t  gnutls_privkey_decrypt_func\n\t\t\t  decrypt_func, unsigned int flags);\n\nint\ngnutls_privkey_import_ext2(gnutls_privkey_t pkey,\n\t\t\t   gnutls_pk_algorithm_t pk,\n\t\t\t   void *userdata,\n\t\t\t   gnutls_privkey_sign_func sign_func,\n\t\t\t   gnutls_privkey_decrypt_func\n\t\t\t   decrypt_func,\n\t\t\t   gnutls_privkey_deinit_func deinit_func,\n\t\t\t   unsigned int flags);\n\nint\ngnutls_privkey_import_ext3(gnutls_privkey_t pkey,\n                           void *userdata,\n                           gnutls_privkey_sign_func sign_func,\n                           gnutls_privkey_decrypt_func decrypt_func,\n                           gnutls_privkey_deinit_func deinit_func,\n                           gnutls_privkey_info_func info_func,\n                           unsigned int flags);\n\nint\ngnutls_privkey_import_ext4(gnutls_privkey_t pkey,\n                           void *userdata,\n                           gnutls_privkey_sign_data_func sign_data_func,\n                           gnutls_privkey_sign_hash_func sign_hash_func,\n                           gnutls_privkey_decrypt_func decrypt_func,\n                           gnutls_privkey_deinit_func deinit_func,\n                           gnutls_privkey_info_func info_func,\n                           unsigned int flags);\n\nint gnutls_privkey_import_dsa_raw(gnutls_privkey_t key,\n\t\t\t\t       const gnutls_datum_t * p,\n\t\t\t\t       const gnutls_datum_t * q,\n\t\t\t\t       const gnutls_datum_t * g,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * x);\n\nint gnutls_privkey_import_rsa_raw(gnutls_privkey_t key,\n\t\t\t\t\tconst gnutls_datum_t * m,\n\t\t\t\t\tconst gnutls_datum_t * e,\n\t\t\t\t\tconst gnutls_datum_t * d,\n\t\t\t\t\tconst gnutls_datum_t * p,\n\t\t\t\t\tconst gnutls_datum_t * q,\n\t\t\t\t\tconst gnutls_datum_t * u,\n\t\t\t\t\tconst gnutls_datum_t * e1,\n\t\t\t\t\tconst gnutls_datum_t * e2);\nint gnutls_privkey_import_ecc_raw(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t curve,\n\t\t\t\t       const gnutls_datum_t * x,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * k);\n\nint gnutls_privkey_import_gost_raw(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t curve,\n\t\t\t\t       gnutls_digest_algorithm_t digest,\n\t\t\t\t       gnutls_gost_paramset_t paramset,\n\t\t\t\t       const gnutls_datum_t * x,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * k);\n\n\nint gnutls_privkey_sign_data(gnutls_privkey_t signer,\n\t\t\t     gnutls_digest_algorithm_t hash,\n\t\t\t     unsigned int flags,\n\t\t\t     const gnutls_datum_t * data,\n\t\t\t     gnutls_datum_t * signature);\n\nint gnutls_privkey_sign_data2(gnutls_privkey_t signer,\n\t\t\t      gnutls_sign_algorithm_t algo,\n\t\t\t      unsigned int flags,\n\t\t\t      const gnutls_datum_t * data,\n\t\t\t      gnutls_datum_t * signature);\n\n#define gnutls_privkey_sign_raw_data(key, flags, data, sig) \\\n\tgnutls_privkey_sign_hash ( key, 0, GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA, data, sig)\n\nint gnutls_privkey_sign_hash(gnutls_privkey_t signer,\n\t\t\t     gnutls_digest_algorithm_t hash_algo,\n\t\t\t     unsigned int flags,\n\t\t\t     const gnutls_datum_t * hash_data,\n\t\t\t     gnutls_datum_t * signature);\n\nint gnutls_privkey_sign_hash2(gnutls_privkey_t signer,\n\t\t\t      gnutls_sign_algorithm_t algo,\n\t\t\t      unsigned int flags,\n\t\t\t      const gnutls_datum_t * hash_data,\n\t\t\t      gnutls_datum_t * signature);\n\nint gnutls_privkey_decrypt_data(gnutls_privkey_t key,\n\t\t\t\tunsigned int flags,\n\t\t\t\tconst gnutls_datum_t * ciphertext,\n\t\t\t\tgnutls_datum_t * plaintext);\n\nint gnutls_privkey_decrypt_data2(gnutls_privkey_t key,\n\t\t\t\t unsigned int flags,\n\t\t\t\t const gnutls_datum_t * ciphertext,\n\t\t\t\t unsigned char * plaintext,\n                                 size_t plaintext_size);\n\nint\ngnutls_privkey_export_rsa_raw(gnutls_privkey_t key,\n\t\t\t\t    gnutls_datum_t * m, gnutls_datum_t * e,\n\t\t\t\t    gnutls_datum_t * d, gnutls_datum_t * p,\n\t\t\t\t    gnutls_datum_t * q, gnutls_datum_t * u,\n\t\t\t\t    gnutls_datum_t * e1,\n\t\t\t\t    gnutls_datum_t * e2);\n\nint\ngnutls_privkey_export_rsa_raw2(gnutls_privkey_t key,\n\t\t\t\t    gnutls_datum_t * m, gnutls_datum_t * e,\n\t\t\t\t    gnutls_datum_t * d, gnutls_datum_t * p,\n\t\t\t\t    gnutls_datum_t * q, gnutls_datum_t * u,\n\t\t\t\t    gnutls_datum_t * e1,\n\t\t\t\t    gnutls_datum_t * e2, unsigned flags);\n\nint\ngnutls_privkey_export_dsa_raw(gnutls_privkey_t key,\n\t\t\t     gnutls_datum_t * p, gnutls_datum_t * q,\n\t\t\t     gnutls_datum_t * g, gnutls_datum_t * y,\n\t\t\t     gnutls_datum_t * x);\n\nint\ngnutls_privkey_export_dsa_raw2(gnutls_privkey_t key,\n\t\t\t     gnutls_datum_t * p, gnutls_datum_t * q,\n\t\t\t     gnutls_datum_t * g, gnutls_datum_t * y,\n\t\t\t     gnutls_datum_t * x, unsigned flags);\n\nint\ngnutls_privkey_export_ecc_raw(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k);\n\nint\ngnutls_privkey_export_ecc_raw2(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k,\n\t\t\t\t       unsigned flags);\n\nint\ngnutls_privkey_export_gost_raw2(gnutls_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_digest_algorithm_t * digest,\n\t\t\t\t       gnutls_gost_paramset_t * paramset,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k,\n\t\t\t\t       unsigned flags);\n\n\nint gnutls_x509_crt_privkey_sign(gnutls_x509_crt_t crt,\n\t\t\t\t gnutls_x509_crt_t issuer,\n\t\t\t\t gnutls_privkey_t issuer_key,\n\t\t\t\t gnutls_digest_algorithm_t dig,\n\t\t\t\t unsigned int flags);\n\nint gnutls_x509_crl_privkey_sign(gnutls_x509_crl_t crl,\n\t\t\t\t gnutls_x509_crt_t issuer,\n\t\t\t\t gnutls_privkey_t issuer_key,\n\t\t\t\t gnutls_digest_algorithm_t dig,\n\t\t\t\t unsigned int flags);\n\nint gnutls_x509_crq_privkey_sign(gnutls_x509_crq_t crq,\n\t\t\t\t gnutls_privkey_t key,\n\t\t\t\t gnutls_digest_algorithm_t dig,\n\t\t\t\t unsigned int flags);\n\n/**\n * gnutls_pcert_st:\n * @pubkey: public key of parsed certificate.\n * @cert: certificate itself of parsed certificate\n * @type: type of certificate, a #gnutls_certificate_type_t type.\n *\n * A parsed certificate.\n */\ntypedef struct gnutls_pcert_st {\n\tgnutls_pubkey_t pubkey;\n\tgnutls_datum_t cert;\n\tgnutls_certificate_type_t type;\n} gnutls_pcert_st;\n\n/* This flag is unused/ignored */\n#define GNUTLS_PCERT_NO_CERT 1\n\nint gnutls_pcert_import_x509(gnutls_pcert_st * pcert,\n\t\t\t     gnutls_x509_crt_t crt, unsigned int flags);\n\nint gnutls_pcert_import_x509_list(gnutls_pcert_st * pcert,\n\t\t\t\t  gnutls_x509_crt_t *crt, unsigned *ncrt,\n\t\t\t\t  unsigned int flags);\n\nint gnutls_pcert_export_x509(gnutls_pcert_st * pcert,\n                             gnutls_x509_crt_t * crt);\n\nint\ngnutls_pcert_list_import_x509_raw(gnutls_pcert_st * pcerts,\n\t\t\t\t  unsigned int *pcert_max,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t\t  unsigned int flags);\n\nint gnutls_pcert_list_import_x509_file(gnutls_pcert_st *pcert_list,\n\t\t\t\t       unsigned *pcert_list_size,\n\t\t\t\t       const char *file,\n\t\t\t\t       gnutls_x509_crt_fmt_t format,\n\t\t\t\t       gnutls_pin_callback_t pin_fn,\n\t\t\t\t       void *pin_fn_userdata,\n\t\t\t\t       unsigned int flags);\n\nint gnutls_pcert_import_x509_raw(gnutls_pcert_st * pcert,\n\t\t\t\t const gnutls_datum_t * cert,\n\t\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t\t unsigned int flags);\n\nint gnutls_pcert_import_openpgp_raw(gnutls_pcert_st * pcert,\n\t\t\t\t    const gnutls_datum_t * cert,\n\t\t\t\t    gnutls_openpgp_crt_fmt_t\n\t\t\t\t    format,\n\t\t\t\t    gnutls_openpgp_keyid_t keyid,\n\t\t\t\t    unsigned int flags);\n\nint gnutls_pcert_import_openpgp(gnutls_pcert_st * pcert,\n\t\t\t\tgnutls_openpgp_crt_t crt,\n\t\t\t\tunsigned int flags);\n\nint gnutls_pcert_export_openpgp(gnutls_pcert_st * pcert,\n                                gnutls_openpgp_crt_t * crt);\n\nvoid gnutls_pcert_deinit(gnutls_pcert_st * pcert);\n\nint gnutls_pcert_import_rawpk(gnutls_pcert_st* pcert,\n\t\t\t     gnutls_pubkey_t key, unsigned int flags);\n\nint gnutls_pcert_import_rawpk_raw(gnutls_pcert_st* pcert,\n\t\t\t\t    const gnutls_datum_t* rawpubkey,\n\t\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t\t    unsigned int key_usage, unsigned int flags);\n\n/* For certificate credentials */\n\t/* This is the same as gnutls_certificate_retrieve_function()\n\t * but retrieves a gnutls_pcert_st which requires much less processing\n\t * within the library.\n\t */\ntypedef int gnutls_certificate_retrieve_function2(gnutls_session_t,\n\t\t\t\t  const gnutls_datum_t *req_ca_rdn,\n\t\t\t\t  int nreqs,\n\t\t\t\t  const gnutls_pk_algorithm_t *pk_algos,\n\t\t\t\t  int pk_algos_length,\n\t\t\t\t  gnutls_pcert_st**,\n\t\t\t\t  unsigned int *pcert_length,\n\t\t\t\t  gnutls_privkey_t *privkey);\n\n\nvoid gnutls_certificate_set_retrieve_function2\n    (gnutls_certificate_credentials_t cred,\n     gnutls_certificate_retrieve_function2 *func);\n\nstruct gnutls_cert_retr_st {\n\tunsigned version; /* set to 1 */\n\tgnutls_certificate_credentials_t cred;\n\tconst gnutls_datum_t *req_ca_rdn;\n\tunsigned nreqs;\n\tconst gnutls_pk_algorithm_t *pk_algos;\n\tunsigned pk_algos_length;\n\n\t/* other fields may be added if version is > 1 */\n\tunsigned char padding[64];\n};\n\n/* When the callback sets this value, gnutls will deinitialize the given\n * values after use */\n#define GNUTLS_CERT_RETR_DEINIT_ALL 1\n\ntypedef int gnutls_certificate_retrieve_function3(\n\t\t\t\tgnutls_session_t,\n\t\t\t\tconst struct gnutls_cert_retr_st *info,\n\t\t\t\tgnutls_pcert_st **certs,\n\t\t\t\tunsigned int *certs_length,\n\t\t\t\tgnutls_ocsp_data_st **ocsp,\n\t\t\t\tunsigned int *ocsp_length,\n\t\t\t\tgnutls_privkey_t *privkey,\n\t\t\t\tunsigned int *flags);\n\n\nvoid gnutls_certificate_set_retrieve_function3\n    (gnutls_certificate_credentials_t cred,\n     gnutls_certificate_retrieve_function3 *func);\n\nint\ngnutls_certificate_set_key(gnutls_certificate_credentials_t res,\n\t\t\t   const char **names,\n\t\t\t   int names_size,\n\t\t\t   gnutls_pcert_st * pcert_list,\n\t\t\t   int pcert_list_size, gnutls_privkey_t key);\n\nint\ngnutls_pubkey_print(gnutls_pubkey_t pubkey,\n\t\t    gnutls_certificate_print_formats_t format,\n\t\t    gnutls_datum_t * out);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_ABSTRACT_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/compat.h",
    "content": "/*\n * Copyright (C) 2008-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* Typedefs for more compatibility with older GnuTLS. */\n\n#ifndef GNUTLS_COMPAT_H\n#define GNUTLS_COMPAT_H\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#ifdef __GNUC__\n\n#define _GNUTLS_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__)\n\n#if !defined GNUTLS_INTERNAL_BUILD\n#if _GNUTLS_GCC_VERSION >= 30100\n#define _GNUTLS_GCC_ATTR_DEPRECATED __attribute__ ((__deprecated__))\n#endif\n#endif\n\n#endif\t\t\t\t/* __GNUC__ */\n\n#ifndef _GNUTLS_GCC_ATTR_DEPRECATED\n#define _GNUTLS_GCC_ATTR_DEPRECATED\n#endif\n\n/* gnutls_connection_end_t was made redundant in 2.99.0 */\ntypedef unsigned int gnutls_connection_end_t _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* Stuff deprecated in 2.x */\ntypedef gnutls_cipher_algorithm_t gnutls_cipher_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_kx_algorithm_t gnutls_kx_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_mac_algorithm_t gnutls_mac_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_digest_algorithm_t gnutls_digest_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_compression_method_t gnutls_compression_method\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_connection_end_t gnutls_connection_end\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_crt_fmt_t gnutls_x509_crt_fmt\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_pk_algorithm_t gnutls_pk_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_sign_algorithm_t gnutls_sign_algorithm\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_close_request_t gnutls_close_request\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_certificate_request_t gnutls_certificate_request\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_certificate_status_t gnutls_certificate_status\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_session_t gnutls_session _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_alert_level_t gnutls_alert_level\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_alert_description_t gnutls_alert_description\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_subject_alt_name_t gnutls_x509_subject_alt_name\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_openpgp_privkey_t gnutls_openpgp_privkey\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_openpgp_keyring_t gnutls_openpgp_keyring\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_crt_t gnutls_x509_crt _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_privkey_t gnutls_x509_privkey\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_crl_t gnutls_x509_crl _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_x509_crq_t gnutls_x509_crq _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_certificate_credentials_t\n    gnutls_certificate_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_anon_server_credentials_t\n    gnutls_anon_server_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_anon_client_credentials_t\n    gnutls_anon_client_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_srp_client_credentials_t\n    gnutls_srp_client_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_srp_server_credentials_t\n    gnutls_srp_server_credentials _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_dh_params_t gnutls_dh_params _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_rsa_params_t gnutls_rsa_params _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_params_type_t gnutls_params_type\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_credentials_type_t gnutls_credentials_type\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_certificate_type_t gnutls_certificate_type\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_datum_t gnutls_datum _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_transport_ptr_t gnutls_transport_ptr\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* Old verification flags */\n#define GNUTLS_VERIFY_ALLOW_X509_V1_CA_CRT  (0)\n\n/* Old SRP alerts removed in 2.1.x because the TLS-SRP RFC was\n   modified to use the PSK alert. */\n#define GNUTLS_A_MISSING_SRP_USERNAME GNUTLS_A_UNKNOWN_PSK_IDENTITY\n#define GNUTLS_A_UNKNOWN_SRP_USERNAME GNUTLS_A_UNKNOWN_PSK_IDENTITY\n\n/* OpenPGP stuff renamed in 2.1.x. */\n#define GNUTLS_OPENPGP_KEY GNUTLS_OPENPGP_CERT\n#define GNUTLS_OPENPGP_KEY_FINGERPRINT GNUTLS_OPENPGP_CERT_FINGERPRINT\n#define gnutls_openpgp_send_key gnutls_openpgp_send_cert\ntypedef gnutls_openpgp_crt_status_t gnutls_openpgp_key_status_t\n    _GNUTLS_GCC_ATTR_DEPRECATED;\ntypedef gnutls_openpgp_crt_t gnutls_openpgp_key_t\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n#define gnutls_openpgp_key_init gnutls_openpgp_crt_init\n#define gnutls_openpgp_key_deinit gnutls_openpgp_crt_deinit\n#define gnutls_openpgp_key_import gnutls_openpgp_crt_import\n#define gnutls_openpgp_key_export gnutls_openpgp_crt_export\n#define gnutls_openpgp_key_get_key_usage gnutls_openpgp_crt_get_key_usage\n#define gnutls_openpgp_key_get_fingerprint gnutls_openpgp_crt_get_fingerprint\n#define gnutls_openpgp_key_get_pk_algorithm gnutls_openpgp_crt_get_pk_algorithm\n#define gnutls_openpgp_key_get_name gnutls_openpgp_crt_get_name\n#define gnutls_openpgp_key_get_version gnutls_openpgp_crt_get_version\n#define gnutls_openpgp_key_get_creation_time gnutls_openpgp_crt_get_creation_time\n#define gnutls_openpgp_key_get_expiration_time gnutls_openpgp_crt_get_expiration_time\n#define gnutls_openpgp_key_get_id gnutls_openpgp_crt_get_id\n#define gnutls_openpgp_key_check_hostname gnutls_openpgp_crt_check_hostname\n\n/* OpenPGP stuff renamed in 2.3.x. */\n#define gnutls_openpgp_crt_get_id gnutls_openpgp_crt_get_key_id\n\n/* New better names renamed in 2.3.x, add these for backwards\n   compatibility with old poor names.*/\n#define GNUTLS_X509_CRT_FULL GNUTLS_CRT_PRINT_FULL\n#define GNUTLS_X509_CRT_ONELINE GNUTLS_CRT_PRINT_ONELINE\n#define GNUTLS_X509_CRT_UNSIGNED_FULL GNUTLS_CRT_PRINT_UNSIGNED_FULL\n\n/* Namespace problems. */\n#define LIBGNUTLS_VERSION GNUTLS_VERSION\n#define LIBGNUTLS_VERSION_MAJOR GNUTLS_VERSION_MAJOR\n#define LIBGNUTLS_VERSION_MINOR GNUTLS_VERSION_MINOR\n#define LIBGNUTLS_VERSION_PATCH GNUTLS_VERSION_PATCH\n#define LIBGNUTLS_VERSION_NUMBER GNUTLS_VERSION_NUMBER\n#define LIBGNUTLS_EXTRA_VERSION GNUTLS_VERSION\n\n/* This is a very dangerous and error-prone function.\n * Use gnutls_privkey_sign_hash() instead.\n */\nint gnutls_x509_privkey_sign_hash(gnutls_x509_privkey_t key,\n\t\t\t\t  const gnutls_datum_t * hash,\n\t\t\t\t  gnutls_datum_t * signature)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_sign_hash(gnutls_openpgp_privkey_t key,\n\t\t\t\t     const gnutls_datum_t * hash,\n\t\t\t\t     gnutls_datum_t * signature)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\t/* gnutls_pubkey_get_preferred_hash_algorithm() */\nint gnutls_x509_crt_get_preferred_hash_algorithm(gnutls_x509_crt_t\n\t\t\t\t\t\t crt,\n\t\t\t\t\t\t gnutls_digest_algorithm_t\n\t\t\t\t\t\t * hash, unsigned int\n\t\t\t\t\t\t *mand)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\t/* use gnutls_privkey_sign_hash() with the GNUTLS_PRIVKEY_SIGN_FLAG_TLS1_RSA flag */\n\n#ifdef _ISOC99_SOURCE\n/* we provide older functions for compatibility as inline functions that\n * depend on gnutls_session_get_random. */\n\nstatic inline const void\n*gnutls_session_get_server_random(gnutls_session_t session)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\nstatic inline const void\n*gnutls_session_get_server_random(gnutls_session_t session)\n{\n\tgnutls_datum_t rnd;\n\tgnutls_session_get_random(session, NULL, &rnd);\t/*doc-skip */\n\treturn rnd.data;\n}\n\nstatic inline const void\n*gnutls_session_get_client_random(gnutls_session_t session)\n    _GNUTLS_GCC_ATTR_DEPRECATED;\nstatic inline const void\n*gnutls_session_get_client_random(gnutls_session_t session)\n{\n\tgnutls_datum_t rnd;\n\tgnutls_session_get_random(session, &rnd, NULL);\t/*doc-skip */\n\treturn rnd.data;\n}\n#endif\n\nvoid\ngnutls_global_set_mem_functions(gnutls_alloc_function alloc_func,\n\t\t\t\tgnutls_alloc_function secure_alloc_func,\n\t\t\t\tgnutls_is_secure_function is_secure_func,\n\t\t\t\tgnutls_realloc_function realloc_func,\n\t\t\t\tgnutls_free_function free_func) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* defined in old headers - unused nevertheless */\n#define GNUTLS_SUPPLEMENTAL_USER_MAPPING_DATA 0\n\n/* old compression related functions */\ngnutls_compression_method_t\ngnutls_compression_get(gnutls_session_t session) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nconst char *\ngnutls_compression_get_name(gnutls_compression_method_t\n\t\t\t    algorithm) __GNUTLS_CONST__ _GNUTLS_GCC_ATTR_DEPRECATED;\n\ngnutls_compression_method_t\n\tgnutls_compression_get_id(const char *name) __GNUTLS_CONST__ _GNUTLS_GCC_ATTR_DEPRECATED;\n\nconst gnutls_compression_method_t *\n\tgnutls_compression_list(void) __GNUTLS_PURE__ _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_priority_compression_list(gnutls_priority_t pcache,\n\t\t\t\t     const unsigned int **list) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_COMPAT_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/crypto.h",
    "content": "/*\n * Copyright (C) 2008-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_CRYPTO_H\n#define GNUTLS_CRYPTO_H\n\n#include <gnutls/gnutls.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\ntypedef struct api_cipher_hd_st *gnutls_cipher_hd_t;\n\nint gnutls_cipher_init(gnutls_cipher_hd_t * handle,\n\t\t       gnutls_cipher_algorithm_t cipher,\n\t\t       const gnutls_datum_t * key,\n\t\t       const gnutls_datum_t * iv);\nint gnutls_cipher_encrypt(const gnutls_cipher_hd_t handle,\n\t\t\t  void *text, size_t textlen);\nint gnutls_cipher_decrypt(const gnutls_cipher_hd_t handle,\n\t\t\t  void *ciphertext, size_t ciphertextlen);\nint gnutls_cipher_decrypt2(gnutls_cipher_hd_t handle,\n\t\t\t   const void *ciphertext,\n\t\t\t   size_t ciphertextlen, void *text,\n\t\t\t   size_t textlen);\nint gnutls_cipher_encrypt2(gnutls_cipher_hd_t handle,\n\t\t\t   const void *text, size_t textlen,\n\t\t\t   void *ciphertext, size_t ciphertextlen);\n\n/**\n * gnutls_cipher_flags_t:\n * @GNUTLS_CIPHER_PADDING_PKCS7: Flag to indicate PKCS#7 padding\n *\n * Enumeration of flags to control block cipher padding, used by\n * gnutls_cipher_encrypt3() and gnutls_cipher_decrypt3().\n *\n * Since: 3.7.7\n */\ntypedef enum gnutls_cipher_flags_t {\n\tGNUTLS_CIPHER_PADDING_PKCS7 = 1\n} gnutls_cipher_flags_t;\n\nint gnutls_cipher_encrypt3(gnutls_cipher_hd_t handle,\n\t\t\t   const void *ptext, size_t ptext_len,\n\t\t\t   void *ctext, size_t *ctext_len,\n\t\t\t   unsigned flags);\nint gnutls_cipher_decrypt3(gnutls_cipher_hd_t handle,\n\t\t\t   const void *ctext, size_t ctext_len,\n\t\t\t   void *ptext, size_t *ptext_len,\n\t\t\t   unsigned flags);\n\nvoid gnutls_cipher_set_iv(gnutls_cipher_hd_t handle, void *iv,\n\t\t\t  size_t ivlen);\n\nint gnutls_cipher_tag(gnutls_cipher_hd_t handle, void *tag,\n\t\t      size_t tag_size);\nint gnutls_cipher_add_auth(gnutls_cipher_hd_t handle,\n\t\t\t   const void *text, size_t text_size);\n\nvoid gnutls_cipher_deinit(gnutls_cipher_hd_t handle);\nunsigned gnutls_cipher_get_block_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\nunsigned gnutls_cipher_get_iv_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\nunsigned gnutls_cipher_get_tag_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\n\n/* AEAD API\n */\ntypedef struct api_aead_cipher_hd_st *gnutls_aead_cipher_hd_t;\n\nint gnutls_aead_cipher_init(gnutls_aead_cipher_hd_t * handle,\n\t\t\t    gnutls_cipher_algorithm_t cipher,\n\t\t\t    const gnutls_datum_t * key);\n\nint gnutls_aead_cipher_set_key(gnutls_aead_cipher_hd_t handle,\n\t\t\t       const gnutls_datum_t *key);\n\nint\ngnutls_aead_cipher_decrypt(gnutls_aead_cipher_hd_t handle,\n\t\t\t   const void *nonce, size_t nonce_len,\n\t\t\t   const void *auth, size_t auth_len,\n\t\t\t   size_t tag_size,\n\t\t\t   const void *ctext, size_t ctext_len,\n\t\t\t   void *ptext, size_t *ptext_len);\nint\ngnutls_aead_cipher_encrypt(gnutls_aead_cipher_hd_t handle,\n\t\t\t   const void *nonce, size_t nonce_len,\n\t\t\t   const void *auth, size_t auth_len,\n\t\t\t   size_t tag_size,\n\t\t\t   const void *ptext, size_t ptext_len,\n\t\t\t   void *ctext, size_t *ctext_len);\n\nint\ngnutls_aead_cipher_encryptv(gnutls_aead_cipher_hd_t handle,\n\t\t\t    const void *nonce, size_t nonce_len,\n\t\t\t    const giovec_t *auth_iov, int auth_iovcnt,\n\t\t\t    size_t tag_size,\n\t\t\t    const giovec_t *iov, int iovcnt,\n\t\t\t    void *ctext, size_t *ctext_len);\n\nint\ngnutls_aead_cipher_encryptv2(gnutls_aead_cipher_hd_t handle,\n\t\t\t     const void *nonce, size_t nonce_len,\n\t\t\t     const giovec_t *auth_iov, int auth_iovcnt,\n\t\t\t     const giovec_t *iov, int iovcnt,\n\t\t\t     void *tag, size_t *tag_size);\n\nint\ngnutls_aead_cipher_decryptv2(gnutls_aead_cipher_hd_t handle,\n\t\t\t     const void *nonce, size_t nonce_len,\n\t\t\t     const giovec_t *auth_iov, int auth_iovcnt,\n\t\t\t     const giovec_t *iov, int iovcnt,\n\t\t\t     void *tag, size_t tag_size);\n\nvoid gnutls_aead_cipher_deinit(gnutls_aead_cipher_hd_t handle);\n\n/* Hash - MAC API */\n\ntypedef struct hash_hd_st *gnutls_hash_hd_t;\ntypedef struct hmac_hd_st *gnutls_hmac_hd_t;\n\nsize_t gnutls_mac_get_nonce_size(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\nint gnutls_hmac_init(gnutls_hmac_hd_t * dig,\n\t\t     gnutls_mac_algorithm_t algorithm,\n\t\t     const void *key, size_t keylen);\nvoid gnutls_hmac_set_nonce(gnutls_hmac_hd_t handle,\n\t\t\t   const void *nonce, size_t nonce_len);\nint gnutls_hmac(gnutls_hmac_hd_t handle, const void *text, size_t textlen);\nvoid gnutls_hmac_output(gnutls_hmac_hd_t handle, void *digest);\nvoid gnutls_hmac_deinit(gnutls_hmac_hd_t handle, void *digest);\nunsigned gnutls_hmac_get_len(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\nunsigned gnutls_hmac_get_key_size(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\nint gnutls_hmac_fast(gnutls_mac_algorithm_t algorithm,\n\t\t     const void *key, size_t keylen,\n\t\t     const void *text, size_t textlen, void *digest);\ngnutls_hmac_hd_t gnutls_hmac_copy(gnutls_hmac_hd_t handle);\n\nint gnutls_hash_init(gnutls_hash_hd_t * dig,\n\t\t     gnutls_digest_algorithm_t algorithm);\nint gnutls_hash(gnutls_hash_hd_t handle, const void *text, size_t textlen);\nvoid gnutls_hash_output(gnutls_hash_hd_t handle, void *digest);\nvoid gnutls_hash_deinit(gnutls_hash_hd_t handle, void *digest);\nunsigned gnutls_hash_get_len(gnutls_digest_algorithm_t algorithm) __GNUTLS_CONST__;\nint gnutls_hash_fast(gnutls_digest_algorithm_t algorithm,\n\t\t     const void *text, size_t textlen, void *digest);\ngnutls_hash_hd_t gnutls_hash_copy(gnutls_hash_hd_t handle);\n\n/* KDF API */\n\nint gnutls_hkdf_extract(gnutls_mac_algorithm_t mac,\n\t\t\tconst gnutls_datum_t *key,\n\t\t\tconst gnutls_datum_t *salt,\n\t\t\tvoid *output);\n\nint gnutls_hkdf_expand(gnutls_mac_algorithm_t mac,\n\t\t       const gnutls_datum_t *key,\n\t\t       const gnutls_datum_t *info,\n\t\t       void *output, size_t length);\n\nint gnutls_pbkdf2(gnutls_mac_algorithm_t mac,\n\t\t  const gnutls_datum_t *key,\n\t\t  const gnutls_datum_t *salt,\n\t\t  unsigned iter_count,\n\t\t  void *output, size_t length);\n\n/* register ciphers */\n\n\n/**\n * gnutls_rnd_level_t:\n * @GNUTLS_RND_NONCE: Non-predictable random number.  Fatal in parts\n *   of session if broken, i.e., vulnerable to statistical analysis.\n * @GNUTLS_RND_RANDOM: Pseudo-random cryptographic random number.\n *   Fatal in session if broken. Example use: temporal keys.\n * @GNUTLS_RND_KEY: Fatal in many sessions if broken. Example use:\n *   Long-term keys.\n *\n * Enumeration of random quality levels.\n */\ntypedef enum gnutls_rnd_level {\n\tGNUTLS_RND_NONCE = 0,\n\tGNUTLS_RND_RANDOM = 1,\n\tGNUTLS_RND_KEY = 2\n} gnutls_rnd_level_t;\n\nint gnutls_rnd(gnutls_rnd_level_t level, void *data, size_t len);\n\nvoid gnutls_rnd_refresh(void);\n\n\n/* API to override ciphers and MAC algorithms \n */\n\ntypedef int (*gnutls_cipher_init_func) (gnutls_cipher_algorithm_t, void **ctx, int enc);\ntypedef int (*gnutls_cipher_setkey_func) (void *ctx, const void *key, size_t keysize);\n/* old style ciphers */\ntypedef int (*gnutls_cipher_setiv_func) (void *ctx, const void *iv, size_t ivsize);\ntypedef int (*gnutls_cipher_getiv_func) (void *ctx, void *iv, size_t ivsize);\ntypedef int (*gnutls_cipher_encrypt_func) (void *ctx, const void *plain, size_t plainsize,\n\t\t\t\tvoid *encr, size_t encrsize);\ntypedef int (*gnutls_cipher_decrypt_func) (void *ctx, const void *encr, size_t encrsize,\n\t\t\tvoid *plain, size_t plainsize);\n\n/* aead ciphers */\ntypedef int (*gnutls_cipher_auth_func) (void *ctx, const void *data, size_t datasize);\ntypedef void (*gnutls_cipher_tag_func) (void *ctx, void *tag, size_t tagsize);\n\ntypedef int (*gnutls_cipher_aead_encrypt_func) (void *ctx,\n\t\t\tconst void *nonce, size_t noncesize,\n\t\t\tconst void *auth, size_t authsize,\n\t\t\tsize_t tag_size,\n\t\t\tconst void *plain, size_t plainsize,\n\t\t\tvoid *encr, size_t encrsize);\ntypedef int (*gnutls_cipher_aead_decrypt_func) (void *ctx,\n\t\t\tconst void *nonce, size_t noncesize,\n\t\t\tconst void *auth, size_t authsize,\n\t\t\tsize_t tag_size,\n\t\t\tconst void *encr, size_t encrsize,\n\t\t\tvoid *plain, size_t plainsize);\ntypedef void (*gnutls_cipher_deinit_func) (void *ctx);\n\nint\ngnutls_crypto_register_cipher(gnutls_cipher_algorithm_t algorithm,\n\t\t\t      int priority,\n\t\t\t      gnutls_cipher_init_func init,\n\t\t\t      gnutls_cipher_setkey_func setkey,\n\t\t\t      gnutls_cipher_setiv_func setiv,\n\t\t\t      gnutls_cipher_encrypt_func encrypt,\n\t\t\t      gnutls_cipher_decrypt_func decrypt,\n\t\t\t      gnutls_cipher_deinit_func deinit)\n\t\t\t      _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint\ngnutls_crypto_register_aead_cipher(gnutls_cipher_algorithm_t algorithm,\n\t\t\t      int priority,\n\t\t\t      gnutls_cipher_init_func init,\n\t\t\t      gnutls_cipher_setkey_func setkey,\n\t\t\t      gnutls_cipher_aead_encrypt_func aead_encrypt,\n\t\t\t      gnutls_cipher_aead_decrypt_func aead_decrypt,\n\t\t\t      gnutls_cipher_deinit_func deinit)\n\t\t\t      _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntypedef int (*gnutls_mac_init_func) (gnutls_mac_algorithm_t, void **ctx);\ntypedef int (*gnutls_mac_setkey_func) (void *ctx, const void *key, size_t keysize);\ntypedef int (*gnutls_mac_setnonce_func) (void *ctx, const void *nonce, size_t noncesize);\ntypedef int (*gnutls_mac_hash_func) (void *ctx, const void *text, size_t textsize);\ntypedef int (*gnutls_mac_output_func) (void *src_ctx, void *digest, size_t digestsize);\ntypedef void (*gnutls_mac_deinit_func) (void *ctx);\ntypedef int (*gnutls_mac_fast_func) (gnutls_mac_algorithm_t, const void *nonce,\n\t\t     size_t nonce_size, const void *key, size_t keysize,\n\t\t     const void *text, size_t textsize, void *digest);\ntypedef void *(*gnutls_mac_copy_func) (const void *ctx);\n\nint\ngnutls_crypto_register_mac(gnutls_mac_algorithm_t mac,\n\t\t\t   int priority,\n\t\t\t   gnutls_mac_init_func init,\n\t\t\t   gnutls_mac_setkey_func setkey,\n\t\t\t   gnutls_mac_setnonce_func setnonce,\n\t\t\t   gnutls_mac_hash_func hash,\n\t\t\t   gnutls_mac_output_func output,\n\t\t\t   gnutls_mac_deinit_func deinit,\n\t\t\t   gnutls_mac_fast_func hash_fast)\n\t\t\t   _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntypedef int (*gnutls_digest_init_func) (gnutls_digest_algorithm_t, void **ctx);\ntypedef int (*gnutls_digest_hash_func) (void *ctx, const void *text, size_t textsize);\ntypedef int (*gnutls_digest_output_func) (void *src_ctx, void *digest, size_t digestsize);\ntypedef void (*gnutls_digest_deinit_func) (void *ctx);\ntypedef int (*gnutls_digest_fast_func) (gnutls_digest_algorithm_t,\n\t\t     const void *text, size_t textsize, void *digest);\ntypedef void *(*gnutls_digest_copy_func) (const void *ctx);\n\nint\ngnutls_crypto_register_digest(gnutls_digest_algorithm_t digest,\n\t\t\t   int priority,\n\t\t\t   gnutls_digest_init_func init,\n\t\t\t   gnutls_digest_hash_func hash,\n\t\t\t   gnutls_digest_output_func output,\n\t\t\t   gnutls_digest_deinit_func deinit,\n\t\t\t   gnutls_digest_fast_func hash_fast)\n\t\t\t   _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* RSA-PKCS#1 1.5 helper functions */\nint\ngnutls_encode_ber_digest_info(gnutls_digest_algorithm_t hash,\n\t\t\t      const gnutls_datum_t * digest,\n\t\t\t      gnutls_datum_t * output);\n\nint\ngnutls_decode_ber_digest_info(const gnutls_datum_t * info,\n\t\t\t      gnutls_digest_algorithm_t *hash,\n\t\t\t      unsigned char *digest, unsigned int *digest_size);\n\nint gnutls_decode_rs_value(const gnutls_datum_t * sig_value, gnutls_datum_t *r, gnutls_datum_t *s);\nint gnutls_encode_rs_value(gnutls_datum_t * sig_value, const gnutls_datum_t * r, const gnutls_datum_t * s);\n\nint gnutls_encode_gost_rs_value(gnutls_datum_t * sig_value, const gnutls_datum_t * r, const gnutls_datum_t  *s);\nint gnutls_decode_gost_rs_value(const gnutls_datum_t * sig_value, gnutls_datum_t * r, gnutls_datum_t * s);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_CRYPTO_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/dtls.h",
    "content": "/*\n * Copyright (C) 2011-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for the X.509\n * certificate and CRL handling functions.\n */\n\n#ifndef GNUTLS_DTLS_H\n#define GNUTLS_DTLS_H\n\n#include <gnutls/gnutls.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#define GNUTLS_COOKIE_KEY_SIZE 16\n\nvoid gnutls_dtls_set_timeouts(gnutls_session_t session,\n\t\t\t      unsigned int retrans_timeout,\n\t\t\t      unsigned int total_timeout);\n\nunsigned int gnutls_dtls_get_mtu(gnutls_session_t session);\nunsigned int gnutls_dtls_get_data_mtu(gnutls_session_t session);\n\nvoid gnutls_dtls_set_mtu(gnutls_session_t session, unsigned int mtu);\nint gnutls_dtls_set_data_mtu(gnutls_session_t session, unsigned int mtu);\n\nunsigned int gnutls_dtls_get_timeout(gnutls_session_t session);\n\n/**\n * gnutls_dtls_prestate_st:\n * @record_seq: record sequence number\n * @hsk_read_seq: handshake read sequence number\n * @hsk_write_seq: handshake write sequence number\n *\n * DTLS cookie prestate struct.  This is usually never modified by\n * the application, it is used to carry the cookie data between\n * gnutls_dtls_cookie_send(), gnutls_dtls_cookie_verify() and\n * gnutls_dtls_prestate_set().\n */\ntypedef struct {\n\tunsigned int record_seq;\n\tunsigned int hsk_read_seq;\n\tunsigned int hsk_write_seq;\n} gnutls_dtls_prestate_st;\n\nint gnutls_dtls_cookie_send(gnutls_datum_t * key,\n\t\t\t    void *client_data,\n\t\t\t    size_t client_data_size,\n\t\t\t    gnutls_dtls_prestate_st * prestate,\n\t\t\t    gnutls_transport_ptr_t ptr,\n\t\t\t    gnutls_push_func push_func);\n\nint gnutls_dtls_cookie_verify(gnutls_datum_t * key,\n\t\t\t      void *client_data,\n\t\t\t      size_t client_data_size, void *_msg,\n\t\t\t      size_t msg_size,\n\t\t\t      gnutls_dtls_prestate_st * prestate);\n\nvoid gnutls_dtls_prestate_set(gnutls_session_t session,\n\t\t\t      gnutls_dtls_prestate_st * prestate);\n\nunsigned int gnutls_record_get_discarded(gnutls_session_t session);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_DTLS_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/gnutls.h",
    "content": "/* -*- c -*-\n * Copyright (C) 2000-2016 Free Software Foundation, Inc.\n * Copyright (C) 2015-2017 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for all the\n * high level functionality of the gnutls main library.\n *\n * If the optional C++ binding was built, it is available in\n * gnutls/gnutlsxx.h.\n *\n * The openssl compatibility layer (which is under the GNU GPL\n * license) is in gnutls/openssl.h.\n *\n * The low level cipher functionality is in gnutls/crypto.h.\n */\n\n#ifndef GNUTLS_GNUTLS_H\n#define GNUTLS_GNUTLS_H\n\n/* Get ssize_t. */\n#include <sys/types.h>\n\n/* Get size_t. */\n#include <stddef.h>\n\n/* Get time_t. */\n#include <time.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#define GNUTLS_VERSION \"3.7.10\"\n\n#define GNUTLS_VERSION_MAJOR 3\n#define GNUTLS_VERSION_MINOR 7\n#define GNUTLS_VERSION_PATCH 10\n\n#define GNUTLS_VERSION_NUMBER 0x03070a\n\n#define GNUTLS_CIPHER_RIJNDAEL_128_CBC GNUTLS_CIPHER_AES_128_CBC\n#define GNUTLS_CIPHER_RIJNDAEL_256_CBC GNUTLS_CIPHER_AES_256_CBC\n#define GNUTLS_CIPHER_RIJNDAEL_CBC GNUTLS_CIPHER_AES_128_CBC\n#define GNUTLS_CIPHER_ARCFOUR GNUTLS_CIPHER_ARCFOUR_128\n\n#if !defined(GNUTLS_INTERNAL_BUILD) && defined(_WIN32)\n# define _SYM_EXPORT __declspec(dllimport)\n#else\n# define _SYM_EXPORT\n#endif\n\n#ifdef __GNUC__\n# define __GNUTLS_CONST__  __attribute__((const))\n# define __GNUTLS_PURE__  __attribute__((pure))\n#else\n# define __GNUTLS_CONST__\n# define __GNUTLS_PURE__\n#endif\n\n\n/* Use the following definition globally in your program to disable\n * implicit initialization of gnutls. */\n#define GNUTLS_SKIP_GLOBAL_INIT int _gnutls_global_init_skip(void); \\\n    int _gnutls_global_init_skip(void) {return 1;}\n\n/**\n * gnutls_cipher_algorithm_t:\n * @GNUTLS_CIPHER_UNKNOWN: Value to identify an unknown/unsupported algorithm.\n * @GNUTLS_CIPHER_NULL: The NULL (identity) encryption algorithm.\n * @GNUTLS_CIPHER_ARCFOUR_128: ARCFOUR stream cipher with 128-bit keys.\n * @GNUTLS_CIPHER_3DES_CBC: 3DES in CBC mode.\n * @GNUTLS_CIPHER_AES_128_CBC: AES in CBC mode with 128-bit keys.\n * @GNUTLS_CIPHER_AES_192_CBC: AES in CBC mode with 192-bit keys.\n * @GNUTLS_CIPHER_AES_256_CBC: AES in CBC mode with 256-bit keys.\n * @GNUTLS_CIPHER_AES_128_CFB8: AES in CFB8 mode with 128-bit keys.\n * @GNUTLS_CIPHER_AES_192_CFB8: AES in CFB8 mode with 192-bit keys.\n * @GNUTLS_CIPHER_AES_256_CFB8: AES in CFB8 mode with 256-bit keys.\n * @GNUTLS_CIPHER_ARCFOUR_40: ARCFOUR stream cipher with 40-bit keys.\n * @GNUTLS_CIPHER_CAMELLIA_128_CBC: Camellia in CBC mode with 128-bit keys.\n * @GNUTLS_CIPHER_CAMELLIA_192_CBC: Camellia in CBC mode with 192-bit keys.\n * @GNUTLS_CIPHER_CAMELLIA_256_CBC: Camellia in CBC mode with 256-bit keys.\n * @GNUTLS_CIPHER_RC2_40_CBC: RC2 in CBC mode with 40-bit keys.\n * @GNUTLS_CIPHER_DES_CBC: DES in CBC mode (56-bit keys).\n * @GNUTLS_CIPHER_AES_128_GCM: AES in GCM mode with 128-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_256_GCM: AES in GCM mode with 256-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_128_CCM: AES in CCM mode with 128-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_256_CCM: AES in CCM mode with 256-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_128_CCM_8: AES in CCM mode with 64-bit tag and 128-bit keys (AEAD).\n * @GNUTLS_CIPHER_AES_256_CCM_8: AES in CCM mode with 64-bit tag and 256-bit keys (AEAD).\n * @GNUTLS_CIPHER_CAMELLIA_128_GCM: CAMELLIA in GCM mode with 128-bit keys (AEAD).\n * @GNUTLS_CIPHER_CAMELLIA_256_GCM: CAMELLIA in GCM mode with 256-bit keys (AEAD).\n * @GNUTLS_CIPHER_SALSA20_256: Salsa20 with 256-bit keys.\n * @GNUTLS_CIPHER_ESTREAM_SALSA20_256: Estream's Salsa20 variant with 256-bit keys.\n * @GNUTLS_CIPHER_CHACHA20_32: Chacha20 cipher with 96-bit nonces and 32-bit block counters.\n * @GNUTLS_CIPHER_CHACHA20_64: Chacha20 cipher with 64-bit nonces and 64-bit block counters.\n * @GNUTLS_CIPHER_CHACHA20_POLY1305: The Chacha20 cipher with the Poly1305 authenticator (AEAD).\n * @GNUTLS_CIPHER_GOST28147_TC26Z_CFB: GOST 28147-89 (Magma) cipher in CFB mode with TC26 Z S-box.\n * @GNUTLS_CIPHER_GOST28147_CPA_CFB: GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro A S-box.\n * @GNUTLS_CIPHER_GOST28147_CPB_CFB: GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro B S-box.\n * @GNUTLS_CIPHER_GOST28147_CPC_CFB: GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro C S-box.\n * @GNUTLS_CIPHER_GOST28147_CPD_CFB: GOST 28147-89 (Magma) cipher in CFB mode with CryptoPro D S-box.\n * @GNUTLS_CIPHER_AES_128_XTS: AES in XTS mode with 128-bit key + 128bit tweak key.\n * @GNUTLS_CIPHER_AES_256_XTS: AES in XTS mode with 256-bit key + 256bit tweak key.\n *                             Note that the XTS ciphers are message oriented.\n *                             The whole message needs to be provided with a single call, because\n *                             cipher-stealing requires to know where the message actually terminates\n *                             in order to be able to compute where the stealing occurs.\n * @GNUTLS_CIPHER_GOST28147_TC26Z_CNT: GOST 28147-89 (Magma) cipher in CNT mode with TC26 Z S-box.\n * @GNUTLS_CIPHER_MAGMA_CTR_ACPKM: GOST R 34.12-2015 (Magma) cipher in CTR-ACPKM mode.\n * @GNUTLS_CIPHER_KUZNYECHIK_CTR_ACPKM: GOST R 34.12-2015 (Kuznyechik) cipher in CTR-ACPKM mode.\n * @GNUTLS_CIPHER_IDEA_PGP_CFB: IDEA in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_3DES_PGP_CFB: 3DES in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_CAST5_PGP_CFB: CAST5 in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_BLOWFISH_PGP_CFB: Blowfish in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_SAFER_SK128_PGP_CFB: Safer-SK in CFB mode with 128-bit keys (placeholder - unsupported).\n * @GNUTLS_CIPHER_AES128_PGP_CFB: AES in CFB mode with 128-bit keys (placeholder - unsupported).\n * @GNUTLS_CIPHER_AES192_PGP_CFB: AES in CFB mode with 192-bit keys (placeholder - unsupported).\n * @GNUTLS_CIPHER_AES256_PGP_CFB: AES in CFB mode with 256-bit keys (placeholder - unsupported).\n * @GNUTLS_CIPHER_TWOFISH_PGP_CFB: Twofish in CFB mode (placeholder - unsupported).\n * @GNUTLS_CIPHER_AES_128_SIV: AES in SIV mode with 128-bit key.\n * @GNUTLS_CIPHER_AES_256_SIV: AES in SIV mode with 256-bit key.\n *                             Note that the SIV ciphers can only be used with\n *                             the AEAD interface, and the IV plays a role as\n *                             the authentication tag while it is prepended to\n *                             the cipher text.\n * @GNUTLS_CIPHER_AES_192_GCM: AES in GCM mode with 192-bit keys (AEAD).\n *\n * Enumeration of different symmetric encryption algorithms.\n */\ntypedef enum gnutls_cipher_algorithm {\n\tGNUTLS_CIPHER_UNKNOWN = 0,\n\tGNUTLS_CIPHER_NULL = 1,\n\tGNUTLS_CIPHER_ARCFOUR_128 = 2,\n\tGNUTLS_CIPHER_3DES_CBC = 3,\n\tGNUTLS_CIPHER_AES_128_CBC = 4,\n\tGNUTLS_CIPHER_AES_256_CBC = 5,\n\tGNUTLS_CIPHER_ARCFOUR_40 = 6,\n\tGNUTLS_CIPHER_CAMELLIA_128_CBC = 7,\n\tGNUTLS_CIPHER_CAMELLIA_256_CBC = 8,\n\tGNUTLS_CIPHER_AES_192_CBC = 9,\n\tGNUTLS_CIPHER_AES_128_GCM = 10,\n\tGNUTLS_CIPHER_AES_256_GCM = 11,\n\tGNUTLS_CIPHER_CAMELLIA_192_CBC = 12,\n\tGNUTLS_CIPHER_SALSA20_256 = 13,\n\tGNUTLS_CIPHER_ESTREAM_SALSA20_256 = 14,\n\tGNUTLS_CIPHER_CAMELLIA_128_GCM = 15,\n\tGNUTLS_CIPHER_CAMELLIA_256_GCM = 16,\n\tGNUTLS_CIPHER_RC2_40_CBC = 17,\n\tGNUTLS_CIPHER_DES_CBC = 18,\n\tGNUTLS_CIPHER_AES_128_CCM = 19,\n\tGNUTLS_CIPHER_AES_256_CCM = 20,\n\tGNUTLS_CIPHER_AES_128_CCM_8 = 21,\n\tGNUTLS_CIPHER_AES_256_CCM_8 = 22,\n\tGNUTLS_CIPHER_CHACHA20_POLY1305 = 23,\n\tGNUTLS_CIPHER_GOST28147_TC26Z_CFB = 24,\n\tGNUTLS_CIPHER_GOST28147_CPA_CFB = 25,\n\tGNUTLS_CIPHER_GOST28147_CPB_CFB = 26,\n\tGNUTLS_CIPHER_GOST28147_CPC_CFB = 27,\n\tGNUTLS_CIPHER_GOST28147_CPD_CFB = 28,\n\tGNUTLS_CIPHER_AES_128_CFB8 = 29,\n\tGNUTLS_CIPHER_AES_192_CFB8 = 30,\n\tGNUTLS_CIPHER_AES_256_CFB8 = 31,\n\tGNUTLS_CIPHER_AES_128_XTS = 32,\n\tGNUTLS_CIPHER_AES_256_XTS = 33,\n\tGNUTLS_CIPHER_GOST28147_TC26Z_CNT = 34,\n\tGNUTLS_CIPHER_CHACHA20_64 = 35,\n\tGNUTLS_CIPHER_CHACHA20_32 = 36,\n\tGNUTLS_CIPHER_AES_128_SIV = 37,\n\tGNUTLS_CIPHER_AES_256_SIV = 38,\n\tGNUTLS_CIPHER_AES_192_GCM = 39,\n\tGNUTLS_CIPHER_MAGMA_CTR_ACPKM = 40,\n\tGNUTLS_CIPHER_KUZNYECHIK_CTR_ACPKM = 41,\n\n\t/* used only for PGP internals. Ignored in TLS/SSL\n\t */\n\tGNUTLS_CIPHER_IDEA_PGP_CFB = 200,\n\tGNUTLS_CIPHER_3DES_PGP_CFB = 201,\n\tGNUTLS_CIPHER_CAST5_PGP_CFB = 202,\n\tGNUTLS_CIPHER_BLOWFISH_PGP_CFB = 203,\n\tGNUTLS_CIPHER_SAFER_SK128_PGP_CFB = 204,\n\tGNUTLS_CIPHER_AES128_PGP_CFB = 205,\n\tGNUTLS_CIPHER_AES192_PGP_CFB = 206,\n\tGNUTLS_CIPHER_AES256_PGP_CFB = 207,\n\tGNUTLS_CIPHER_TWOFISH_PGP_CFB = 208\n} gnutls_cipher_algorithm_t;\n\n/**\n * gnutls_kx_algorithm_t:\n * @GNUTLS_KX_UNKNOWN: Unknown key-exchange algorithm.\n * @GNUTLS_KX_RSA: RSA key-exchange algorithm.\n * @GNUTLS_KX_DHE_DSS: DHE-DSS key-exchange algorithm.\n * @GNUTLS_KX_DHE_RSA: DHE-RSA key-exchange algorithm.\n * @GNUTLS_KX_ECDHE_RSA: ECDHE-RSA key-exchange algorithm.\n * @GNUTLS_KX_ECDHE_ECDSA: ECDHE-ECDSA key-exchange algorithm.\n * @GNUTLS_KX_ANON_DH: Anon-DH key-exchange algorithm.\n * @GNUTLS_KX_ANON_ECDH: Anon-ECDH key-exchange algorithm.\n * @GNUTLS_KX_SRP: SRP key-exchange algorithm.\n * @GNUTLS_KX_RSA_EXPORT: RSA-EXPORT key-exchange algorithm (defunc).\n * @GNUTLS_KX_SRP_RSA: SRP-RSA key-exchange algorithm.\n * @GNUTLS_KX_SRP_DSS: SRP-DSS key-exchange algorithm.\n * @GNUTLS_KX_PSK: PSK key-exchange algorithm.\n * @GNUTLS_KX_DHE_PSK: DHE-PSK key-exchange algorithm.\n * @GNUTLS_KX_ECDHE_PSK: ECDHE-PSK key-exchange algorithm.\n * @GNUTLS_KX_RSA_PSK: RSA-PSK key-exchange algorithm.\n * @GNUTLS_KX_VKO_GOST_12: VKO GOST R 34.10-2012 key-exchange algorithm.\n *\n * Enumeration of different key exchange algorithms.\n */\ntypedef enum {\n\tGNUTLS_KX_UNKNOWN = 0,\n\tGNUTLS_KX_RSA = 1,\n\tGNUTLS_KX_DHE_DSS = 2,\n\tGNUTLS_KX_DHE_RSA = 3,\n\tGNUTLS_KX_ANON_DH = 4,\n\tGNUTLS_KX_SRP = 5,\n\tGNUTLS_KX_RSA_EXPORT = 6,\n\tGNUTLS_KX_SRP_RSA = 7,\n\tGNUTLS_KX_SRP_DSS = 8,\n\tGNUTLS_KX_PSK = 9,\n\tGNUTLS_KX_DHE_PSK = 10,\n\tGNUTLS_KX_ANON_ECDH = 11,\n\tGNUTLS_KX_ECDHE_RSA = 12,\n\tGNUTLS_KX_ECDHE_ECDSA = 13,\n\tGNUTLS_KX_ECDHE_PSK = 14,\n\tGNUTLS_KX_RSA_PSK = 15,\n\tGNUTLS_KX_VKO_GOST_12 = 16\n} gnutls_kx_algorithm_t;\n\n/**\n * gnutls_params_type_t:\n * @GNUTLS_PARAMS_RSA_EXPORT: Session RSA-EXPORT parameters (defunc).\n * @GNUTLS_PARAMS_DH: Session Diffie-Hellman parameters.\n * @GNUTLS_PARAMS_ECDH: Session Elliptic-Curve Diffie-Hellman parameters.\n *\n * Enumeration of different TLS session parameter types.\n */\ntypedef enum {\n\tGNUTLS_PARAMS_RSA_EXPORT = 1,\n\tGNUTLS_PARAMS_DH = 2,\n\tGNUTLS_PARAMS_ECDH = 3\n} gnutls_params_type_t;\n\n/**\n * gnutls_credentials_type_t:\n * @GNUTLS_CRD_CERTIFICATE: Certificate credential.\n * @GNUTLS_CRD_ANON: Anonymous credential.\n * @GNUTLS_CRD_SRP: SRP credential.\n * @GNUTLS_CRD_PSK: PSK credential.\n * @GNUTLS_CRD_IA: IA credential.\n *\n * Enumeration of different credential types.\n */\ntypedef enum {\n\tGNUTLS_CRD_CERTIFICATE = 1,\n\tGNUTLS_CRD_ANON,\n\tGNUTLS_CRD_SRP,\n\tGNUTLS_CRD_PSK,\n\tGNUTLS_CRD_IA\n} gnutls_credentials_type_t;\n\n#define GNUTLS_MAC_SHA GNUTLS_MAC_SHA1\n#define GNUTLS_DIG_SHA GNUTLS_DIG_SHA1\n\n/**\n * gnutls_mac_algorithm_t:\n * @GNUTLS_MAC_UNKNOWN: Unknown MAC algorithm.\n * @GNUTLS_MAC_NULL: NULL MAC algorithm (empty output).\n * @GNUTLS_MAC_MD5: HMAC-MD5 algorithm.\n * @GNUTLS_MAC_SHA1: HMAC-SHA-1 algorithm.\n * @GNUTLS_MAC_RMD160: HMAC-RMD160 algorithm.\n * @GNUTLS_MAC_MD2: HMAC-MD2 algorithm.\n * @GNUTLS_MAC_SHA256: HMAC-SHA-256 algorithm.\n * @GNUTLS_MAC_SHA384: HMAC-SHA-384 algorithm.\n * @GNUTLS_MAC_SHA512: HMAC-SHA-512 algorithm.\n * @GNUTLS_MAC_SHA224: HMAC-SHA-224 algorithm.\n * @GNUTLS_MAC_MD5_SHA1: Combined MD5+SHA1 MAC placeholder.\n * @GNUTLS_MAC_GOSTR_94: HMAC GOST R 34.11-94 algorithm.\n * @GNUTLS_MAC_STREEBOG_256: HMAC GOST R 34.11-2001 (Streebog) algorithm, 256 bit.\n * @GNUTLS_MAC_STREEBOG_512: HMAC GOST R 34.11-2001 (Streebog) algorithm, 512 bit.\n * @GNUTLS_MAC_AEAD: MAC implicit through AEAD cipher.\n * @GNUTLS_MAC_UMAC_96: The UMAC-96 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_UMAC_128: The UMAC-128 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_AES_CMAC_128: The AES-CMAC-128 MAC algorithm.\n * @GNUTLS_MAC_AES_CMAC_256: The AES-CMAC-256 MAC algorithm.\n * @GNUTLS_MAC_AES_GMAC_128: The AES-GMAC-128 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_AES_GMAC_192: The AES-GMAC-192 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_AES_GMAC_256: The AES-GMAC-256 MAC algorithm (requires nonce).\n * @GNUTLS_MAC_SHA3_224: Reserved; unimplemented.\n * @GNUTLS_MAC_SHA3_256: Reserved; unimplemented.\n * @GNUTLS_MAC_SHA3_384: Reserved; unimplemented.\n * @GNUTLS_MAC_SHA3_512: Reserved; unimplemented.\n * @GNUTLS_MAC_GOST28147_TC26Z_IMIT: The GOST 28147-89 working in IMIT mode with TC26 Z S-box.\n * @GNUTLS_MAC_SHAKE_128: Reserved; unimplemented.\n * @GNUTLS_MAC_SHAKE_256: Reserved; unimplemented.\n * @GNUTLS_MAC_MAGMA_OMAC: GOST R 34.12-2015 (Magma) in OMAC (CMAC) mode.\n * @GNUTLS_MAC_KUZNYECHIK_OMAC: GOST R 34.12-2015 (Kuznyechik) in OMAC (CMAC) mode.\n *\n * Enumeration of different Message Authentication Code (MAC)\n * algorithms.\n */\ntypedef enum {\n\tGNUTLS_MAC_UNKNOWN = 0,\n\tGNUTLS_MAC_NULL = 1,\n\tGNUTLS_MAC_MD5 = 2,\n\tGNUTLS_MAC_SHA1 = 3,\n\tGNUTLS_MAC_RMD160 = 4,\n\tGNUTLS_MAC_MD2 = 5,\n\tGNUTLS_MAC_SHA256 = 6,\n\tGNUTLS_MAC_SHA384 = 7,\n\tGNUTLS_MAC_SHA512 = 8,\n\tGNUTLS_MAC_SHA224 = 9,\n\tGNUTLS_MAC_SHA3_224 = 10, /* reserved: no implementation */\n\tGNUTLS_MAC_SHA3_256 = 11, /* reserved: no implementation */\n\tGNUTLS_MAC_SHA3_384 = 12, /* reserved: no implementation */\n\tGNUTLS_MAC_SHA3_512 = 13, /* reserved: no implementation */\n\tGNUTLS_MAC_MD5_SHA1 = 14, /* reserved: no implementation */\n\tGNUTLS_MAC_GOSTR_94 = 15,\n\tGNUTLS_MAC_STREEBOG_256 = 16,\n\tGNUTLS_MAC_STREEBOG_512 = 17,\n\t/* If you add anything here, make sure you align with\n\t   gnutls_digest_algorithm_t. */\n\tGNUTLS_MAC_AEAD = 200,\t/* indicates that MAC is on the cipher */\n\tGNUTLS_MAC_UMAC_96 = 201,\n\tGNUTLS_MAC_UMAC_128 = 202,\n\tGNUTLS_MAC_AES_CMAC_128 = 203,\n\tGNUTLS_MAC_AES_CMAC_256 = 204,\n\tGNUTLS_MAC_AES_GMAC_128 = 205,\n\tGNUTLS_MAC_AES_GMAC_192 = 206,\n\tGNUTLS_MAC_AES_GMAC_256 = 207,\n\tGNUTLS_MAC_GOST28147_TC26Z_IMIT = 208,\n\tGNUTLS_MAC_SHAKE_128 = 209,\n\tGNUTLS_MAC_SHAKE_256 = 210,\n\tGNUTLS_MAC_MAGMA_OMAC = 211,\n\tGNUTLS_MAC_KUZNYECHIK_OMAC = 212\n} gnutls_mac_algorithm_t;\n\n/**\n * gnutls_digest_algorithm_t:\n * @GNUTLS_DIG_UNKNOWN: Unknown hash algorithm.\n * @GNUTLS_DIG_NULL: NULL hash algorithm (empty output).\n * @GNUTLS_DIG_MD5: MD5 algorithm.\n * @GNUTLS_DIG_SHA1: SHA-1 algorithm.\n * @GNUTLS_DIG_RMD160: RMD160 algorithm.\n * @GNUTLS_DIG_MD2: MD2 algorithm.\n * @GNUTLS_DIG_SHA256: SHA-256 algorithm.\n * @GNUTLS_DIG_SHA384: SHA-384 algorithm.\n * @GNUTLS_DIG_SHA512: SHA-512 algorithm.\n * @GNUTLS_DIG_SHA224: SHA-224 algorithm.\n * @GNUTLS_DIG_SHA3_224: SHA3-224 algorithm.\n * @GNUTLS_DIG_SHA3_256: SHA3-256 algorithm.\n * @GNUTLS_DIG_SHA3_384: SHA3-384 algorithm.\n * @GNUTLS_DIG_SHA3_512: SHA3-512 algorithm.\n * @GNUTLS_DIG_MD5_SHA1: Combined MD5+SHA1 algorithm.\n * @GNUTLS_DIG_GOSTR_94: GOST R 34.11-94 algorithm.\n * @GNUTLS_DIG_STREEBOG_256: GOST R 34.11-2001 (Streebog) algorithm, 256 bit.\n * @GNUTLS_DIG_STREEBOG_512: GOST R 34.11-2001 (Streebog) algorithm, 512 bit.\n * @GNUTLS_DIG_SHAKE_128: Reserved; unimplemented.\n * @GNUTLS_DIG_SHAKE_256: Reserved; unimplemented.\n *\n * Enumeration of different digest (hash) algorithms.\n */\ntypedef enum {\n\tGNUTLS_DIG_UNKNOWN = GNUTLS_MAC_UNKNOWN,\n\tGNUTLS_DIG_NULL = GNUTLS_MAC_NULL,\n\tGNUTLS_DIG_MD5 = GNUTLS_MAC_MD5,\n\tGNUTLS_DIG_SHA1 = GNUTLS_MAC_SHA1,\n\tGNUTLS_DIG_RMD160 = GNUTLS_MAC_RMD160,\n\tGNUTLS_DIG_MD2 = GNUTLS_MAC_MD2,\n\tGNUTLS_DIG_SHA256 = GNUTLS_MAC_SHA256,\n\tGNUTLS_DIG_SHA384 = GNUTLS_MAC_SHA384,\n\tGNUTLS_DIG_SHA512 = GNUTLS_MAC_SHA512,\n\tGNUTLS_DIG_SHA224 = GNUTLS_MAC_SHA224,\n\tGNUTLS_DIG_SHA3_224 = GNUTLS_MAC_SHA3_224,\n\tGNUTLS_DIG_SHA3_256 = GNUTLS_MAC_SHA3_256,\n\tGNUTLS_DIG_SHA3_384 = GNUTLS_MAC_SHA3_384,\n\tGNUTLS_DIG_SHA3_512 = GNUTLS_MAC_SHA3_512,\n\tGNUTLS_DIG_MD5_SHA1 = GNUTLS_MAC_MD5_SHA1,\n\tGNUTLS_DIG_GOSTR_94 = GNUTLS_MAC_GOSTR_94,\n\tGNUTLS_DIG_STREEBOG_256 = GNUTLS_MAC_STREEBOG_256,\n\tGNUTLS_DIG_STREEBOG_512 = GNUTLS_MAC_STREEBOG_512,\n\tGNUTLS_DIG_SHAKE_128 = GNUTLS_MAC_SHAKE_128,\n\tGNUTLS_DIG_SHAKE_256 = GNUTLS_MAC_SHAKE_256\n\t    /* If you add anything here, make sure you align with\n\t       gnutls_mac_algorithm_t. */\n} gnutls_digest_algorithm_t;\n\n  /* exported for other gnutls headers. This is the maximum number of\n   * algorithms (ciphers, kx or macs).\n   */\n#define GNUTLS_MAX_ALGORITHM_NUM 128\n#define GNUTLS_MAX_SESSION_ID_SIZE 32\n\n\n/**\n * gnutls_compression_method_t:\n * @GNUTLS_COMP_UNKNOWN: Unknown compression method.\n * @GNUTLS_COMP_NULL: The NULL compression method (no compression).\n * @GNUTLS_COMP_DEFLATE: The DEFLATE compression method from zlib.\n * @GNUTLS_COMP_ZLIB: Same as %GNUTLS_COMP_DEFLATE.\n * @GNUTLS_COMP_BROTLI: Brotli compression method.\n * @GNUTLS_COMP_ZSTD: Zstandard compression method.\n *\n * Enumeration of different TLS compression methods.\n */\ntypedef enum {\n\tGNUTLS_COMP_UNKNOWN = 0,\n\tGNUTLS_COMP_NULL = 1,\n\tGNUTLS_COMP_DEFLATE = 2,\n\tGNUTLS_COMP_ZLIB = GNUTLS_COMP_DEFLATE,\n\tGNUTLS_COMP_BROTLI = 3,\n\tGNUTLS_COMP_ZSTD = 4\n} gnutls_compression_method_t;\n\n\n/**\n * gnutls_init_flags_t:\n *\n * @GNUTLS_SERVER: Connection end is a server.\n * @GNUTLS_CLIENT: Connection end is a client.\n * @GNUTLS_DATAGRAM: Connection is datagram oriented (DTLS). Since 3.0.0.\n * @GNUTLS_NONBLOCK: Connection should not block. Since 3.0.0.\n * @GNUTLS_NO_SIGNAL: In systems where SIGPIPE is delivered on send, it will be disabled. That flag has effect in systems which support the MSG_NOSIGNAL sockets flag (since 3.4.2).\n * @GNUTLS_NO_EXTENSIONS: Do not enable any TLS extensions by default (since 3.1.2). As TLS 1.2 and later require extensions this option is considered obsolete and should not be used.\n * @GNUTLS_NO_REPLAY_PROTECTION: Disable any replay protection in DTLS. This must only be used if  replay protection is achieved using other means. Since 3.2.2.\n * @GNUTLS_ALLOW_ID_CHANGE: Allow the peer to replace its certificate, or change its ID during a rehandshake. This change is often used in attacks and thus prohibited by default. Since 3.5.0.\n * @GNUTLS_ENABLE_FALSE_START: Enable the TLS false start on client side if the negotiated ciphersuites allow it. This will enable sending data prior to the handshake being complete, and may introduce a risk of crypto failure when combined with certain key exchanged; for that GnuTLS may not enable that option in ciphersuites that are known to be not safe for false start. Since 3.5.0.\n * @GNUTLS_ENABLE_EARLY_START: Under TLS1.3 allow the server to return earlier than the full handshake\n *   finish; similarly to false start the handshake will be completed once data are received by the\n *   client, while the server is able to transmit sooner. This is not enabled by default as it could\n *   break certain existing server assumptions and use-cases. Since 3.6.4.\n * @GNUTLS_ENABLE_EARLY_DATA: Under TLS1.3 allow the server to receive early data sent as part of the initial ClientHello (0-RTT).\n *   This can also be used to explicitly indicate that the client will send early data.\n *   This is not enabled by default as early data has weaker security properties than other data. Since 3.6.5.\n * @GNUTLS_FORCE_CLIENT_CERT: When in client side and only a single cert is specified, send that certificate irrespective of the issuers expected by the server. Since 3.5.0.\n * @GNUTLS_NO_TICKETS: Flag to indicate that the session should not use resumption with session tickets.\n * @GNUTLS_NO_TICKETS_TLS12: Flag to indicate that the session should not use resumption with session tickets. This flag only has effect if TLS 1.2 is used.\n * @GNUTLS_KEY_SHARE_TOP3: Generate key shares for the top-3 different groups which are enabled.\n *   That is, as each group is associated with a key type (EC, finite field, x25519), generate\n *   three keys using %GNUTLS_PK_DH, %GNUTLS_PK_EC, %GNUTLS_PK_ECDH_X25519 if all of them are enabled.\n * @GNUTLS_KEY_SHARE_TOP2: Generate key shares for the top-2 different groups which are enabled.\n *   For example (ECDH + x25519). This is the default.\n * @GNUTLS_KEY_SHARE_TOP: Generate key share for the first group which is enabled.\n *   For example x25519. This option is the most performant for client (less CPU spent\n *   generating keys), but if the server doesn't support the advertized option it may\n *   result to more roundtrips needed to discover the server's choice.\n * @GNUTLS_NO_AUTO_REKEY: Disable auto-rekeying under TLS1.3. If this option is not specified\n *   gnutls will force a rekey after 2^24 records have been sent.\n * @GNUTLS_POST_HANDSHAKE_AUTH: Enable post handshake authentication for server and client. When set and\n *   a server requests authentication after handshake %GNUTLS_E_REAUTH_REQUEST will be returned\n *   by gnutls_record_recv(). A client should then call gnutls_reauth() to re-authenticate.\n * @GNUTLS_SAFE_PADDING_CHECK: Flag to indicate that the TLS 1.3 padding check will be done in a\n *   safe way which doesn't leak the pad size based on GnuTLS processing time. This is of use to\n *   applications which hide the length of transferred data via the TLS1.3 padding mechanism and\n *   are already taking steps to hide the data processing time. This comes at a performance\n *   penalty.\n * @GNUTLS_AUTO_REAUTH: Enable transparent re-authentication in client side when the server\n *    requests to. That is, reauthentication is handled within gnutls_record_recv(), and\n *    the %GNUTLS_E_REHANDSHAKE or %GNUTLS_E_REAUTH_REQUEST are not returned. This must be\n *    enabled with %GNUTLS_POST_HANDSHAKE_AUTH for TLS1.3. Enabling this flag requires to restore\n *    interrupted calls to gnutls_record_recv() based on the output of gnutls_record_get_direction(),\n *    since gnutls_record_recv() could be interrupted when sending when this flag is enabled.\n *    Note this flag may not be used if you are using the same session for sending and receiving\n *    in different threads.\n * @GNUTLS_ENABLE_RAWPK: Allows raw public-keys to be negotiated during the handshake. Since 3.6.6.\n * @GNUTLS_NO_AUTO_SEND_TICKET: Under TLS1.3 disable auto-sending of\n *    session tickets during the handshake.\n * @GNUTLS_NO_END_OF_EARLY_DATA: Under TLS1.3 suppress sending EndOfEarlyData message. Since 3.7.2.\n *\n * Enumeration of different flags for gnutls_init() function. All the flags\n * can be combined except @GNUTLS_SERVER and @GNUTLS_CLIENT which are mutually\n * exclusive.\n *\n * The key share options relate to the TLS 1.3 key share extension\n * which is a speculative key generation expecting that the server\n * would support the generated key.\n */\ntypedef enum {\n\tGNUTLS_SERVER = 1,\n\tGNUTLS_CLIENT = (1<<1),\n\tGNUTLS_DATAGRAM = (1<<2),\n\tGNUTLS_NONBLOCK = (1<<3),\n\tGNUTLS_NO_EXTENSIONS = (1<<4),\n\tGNUTLS_NO_REPLAY_PROTECTION = (1<<5),\n\tGNUTLS_NO_SIGNAL = (1<<6),\n\tGNUTLS_ALLOW_ID_CHANGE = (1<<7),\n\tGNUTLS_ENABLE_FALSE_START = (1<<8),\n\tGNUTLS_FORCE_CLIENT_CERT = (1<<9),\n\tGNUTLS_NO_TICKETS = (1<<10),\n\tGNUTLS_KEY_SHARE_TOP = (1<<11),\n\tGNUTLS_KEY_SHARE_TOP2 = (1<<12),\n\tGNUTLS_KEY_SHARE_TOP3 = (1<<13),\n\tGNUTLS_POST_HANDSHAKE_AUTH = (1<<14),\n\tGNUTLS_NO_AUTO_REKEY = (1<<15),\n\tGNUTLS_SAFE_PADDING_CHECK = (1<<16),\n\tGNUTLS_ENABLE_EARLY_START = (1<<17),\n\tGNUTLS_ENABLE_RAWPK = (1<<18),\n\tGNUTLS_AUTO_REAUTH = (1<<19),\n\tGNUTLS_ENABLE_EARLY_DATA = (1<<20),\n\tGNUTLS_NO_AUTO_SEND_TICKET = (1<<21),\n\tGNUTLS_NO_END_OF_EARLY_DATA = (1<<22),\n\tGNUTLS_NO_TICKETS_TLS12 = (1<<23)\n} gnutls_init_flags_t;\n\n/* compatibility defines (previous versions of gnutls\n * used defines instead of enumerated values). */\n#define GNUTLS_SERVER (1)\n#define GNUTLS_CLIENT (1<<1)\n#define GNUTLS_DATAGRAM (1<<2)\n#define GNUTLS_NONBLOCK (1<<3)\n#define GNUTLS_NO_EXTENSIONS (1<<4)\n#define GNUTLS_NO_REPLAY_PROTECTION (1<<5)\n#define GNUTLS_NO_SIGNAL (1<<6)\n#define GNUTLS_ALLOW_ID_CHANGE (1<<7)\n#define GNUTLS_ENABLE_FALSE_START (1<<8)\n#define GNUTLS_FORCE_CLIENT_CERT (1<<9)\n#define GNUTLS_NO_TICKETS (1<<10)\n#define GNUTLS_ENABLE_CERT_TYPE_NEG 0\n\t// Here for compatibility reasons\n\n/**\n * gnutls_alert_level_t:\n * @GNUTLS_AL_WARNING: Alert of warning severity.\n * @GNUTLS_AL_FATAL: Alert of fatal severity.\n *\n * Enumeration of different TLS alert severities.\n */\ntypedef enum {\n\tGNUTLS_AL_WARNING = 1,\n\tGNUTLS_AL_FATAL\n} gnutls_alert_level_t;\n\n/**\n * gnutls_alert_description_t:\n * @GNUTLS_A_CLOSE_NOTIFY: Close notify.\n * @GNUTLS_A_UNEXPECTED_MESSAGE: Unexpected message.\n * @GNUTLS_A_BAD_RECORD_MAC: Bad record MAC.\n * @GNUTLS_A_DECRYPTION_FAILED: Decryption failed.\n * @GNUTLS_A_RECORD_OVERFLOW: Record overflow.\n * @GNUTLS_A_DECOMPRESSION_FAILURE: Decompression failed.\n * @GNUTLS_A_HANDSHAKE_FAILURE: Handshake failed.\n * @GNUTLS_A_SSL3_NO_CERTIFICATE: No certificate.\n * @GNUTLS_A_BAD_CERTIFICATE: Certificate is bad.\n * @GNUTLS_A_UNSUPPORTED_CERTIFICATE: Certificate is not supported.\n * @GNUTLS_A_CERTIFICATE_REVOKED: Certificate was revoked.\n * @GNUTLS_A_CERTIFICATE_EXPIRED: Certificate is expired.\n * @GNUTLS_A_CERTIFICATE_UNKNOWN: Unknown certificate.\n * @GNUTLS_A_ILLEGAL_PARAMETER: Illegal parameter.\n * @GNUTLS_A_UNKNOWN_CA: CA is unknown.\n * @GNUTLS_A_ACCESS_DENIED: Access was denied.\n * @GNUTLS_A_DECODE_ERROR: Decode error.\n * @GNUTLS_A_DECRYPT_ERROR: Decrypt error.\n * @GNUTLS_A_EXPORT_RESTRICTION: Export restriction.\n * @GNUTLS_A_PROTOCOL_VERSION: Error in protocol version.\n * @GNUTLS_A_INSUFFICIENT_SECURITY: Insufficient security.\n * @GNUTLS_A_INTERNAL_ERROR: Internal error.\n * @GNUTLS_A_INAPPROPRIATE_FALLBACK: Inappropriate fallback,\n * @GNUTLS_A_USER_CANCELED: User canceled.\n * @GNUTLS_A_NO_RENEGOTIATION: No renegotiation is allowed.\n * @GNUTLS_A_MISSING_EXTENSION: An extension was expected but was not seen\n * @GNUTLS_A_UNSUPPORTED_EXTENSION: An unsupported extension was\n *   sent.\n * @GNUTLS_A_CERTIFICATE_UNOBTAINABLE: Could not retrieve the\n *   specified certificate.\n * @GNUTLS_A_UNRECOGNIZED_NAME: The server name sent was not\n *   recognized.\n * @GNUTLS_A_UNKNOWN_PSK_IDENTITY: The SRP/PSK username is missing\n *   or not known.\n * @GNUTLS_A_CERTIFICATE_REQUIRED: Certificate is required.\n * @GNUTLS_A_NO_APPLICATION_PROTOCOL: The ALPN protocol requested is\n *   not supported by the peer.\n *\n * Enumeration of different TLS alerts.\n */\ntypedef enum {\n\tGNUTLS_A_CLOSE_NOTIFY,\n\tGNUTLS_A_UNEXPECTED_MESSAGE = 10,\n\tGNUTLS_A_BAD_RECORD_MAC = 20,\n\tGNUTLS_A_DECRYPTION_FAILED,\n\tGNUTLS_A_RECORD_OVERFLOW,\n\tGNUTLS_A_DECOMPRESSION_FAILURE = 30,\n\tGNUTLS_A_HANDSHAKE_FAILURE = 40,\n\tGNUTLS_A_SSL3_NO_CERTIFICATE = 41,\n\tGNUTLS_A_BAD_CERTIFICATE = 42,\n\tGNUTLS_A_UNSUPPORTED_CERTIFICATE,\n\tGNUTLS_A_CERTIFICATE_REVOKED,\n\tGNUTLS_A_CERTIFICATE_EXPIRED,\n\tGNUTLS_A_CERTIFICATE_UNKNOWN,\n\tGNUTLS_A_ILLEGAL_PARAMETER,\n\tGNUTLS_A_UNKNOWN_CA,\n\tGNUTLS_A_ACCESS_DENIED,\n\tGNUTLS_A_DECODE_ERROR = 50,\n\tGNUTLS_A_DECRYPT_ERROR,\n\tGNUTLS_A_EXPORT_RESTRICTION = 60,\n\tGNUTLS_A_PROTOCOL_VERSION = 70,\n\tGNUTLS_A_INSUFFICIENT_SECURITY,\n\tGNUTLS_A_INTERNAL_ERROR = 80,\n\tGNUTLS_A_INAPPROPRIATE_FALLBACK = 86,\n\tGNUTLS_A_USER_CANCELED = 90,\n\tGNUTLS_A_NO_RENEGOTIATION = 100,\n\tGNUTLS_A_MISSING_EXTENSION = 109,\n\tGNUTLS_A_UNSUPPORTED_EXTENSION = 110,\n\tGNUTLS_A_CERTIFICATE_UNOBTAINABLE = 111,\n\tGNUTLS_A_UNRECOGNIZED_NAME = 112,\n\tGNUTLS_A_UNKNOWN_PSK_IDENTITY = 115,\n\tGNUTLS_A_CERTIFICATE_REQUIRED = 116,\n\tGNUTLS_A_NO_APPLICATION_PROTOCOL = 120,\n\tGNUTLS_A_MAX = GNUTLS_A_NO_APPLICATION_PROTOCOL\n} gnutls_alert_description_t;\n\n/**\n * gnutls_handshake_description_t:\n * @GNUTLS_HANDSHAKE_HELLO_REQUEST: Hello request.\n * @GNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST: DTLS Hello verify request.\n * @GNUTLS_HANDSHAKE_CLIENT_HELLO: Client hello.\n * @GNUTLS_HANDSHAKE_SERVER_HELLO: Server hello.\n * @GNUTLS_HANDSHAKE_END_OF_EARLY_DATA: End of early data.\n * @GNUTLS_HANDSHAKE_HELLO_RETRY_REQUEST: Hello retry request.\n * @GNUTLS_HANDSHAKE_NEW_SESSION_TICKET: New session ticket.\n * @GNUTLS_HANDSHAKE_CERTIFICATE_PKT: Certificate packet.\n * @GNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE: Server key exchange.\n * @GNUTLS_HANDSHAKE_CERTIFICATE_REQUEST: Certificate request.\n * @GNUTLS_HANDSHAKE_SERVER_HELLO_DONE: Server hello done.\n * @GNUTLS_HANDSHAKE_CERTIFICATE_VERIFY: Certificate verify.\n * @GNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE: Client key exchange.\n * @GNUTLS_HANDSHAKE_FINISHED: Finished.\n * @GNUTLS_HANDSHAKE_CERTIFICATE_STATUS: Certificate status (OCSP).\n * @GNUTLS_HANDSHAKE_KEY_UPDATE: TLS1.3 key update message.\n * @GNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT: Compressed certificate packet.\n * @GNUTLS_HANDSHAKE_SUPPLEMENTAL: Supplemental.\n * @GNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC: Change Cipher Spec.\n * @GNUTLS_HANDSHAKE_CLIENT_HELLO_V2: SSLv2 Client Hello.\n * @GNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS: Encrypted extensions message.\n *\n * Enumeration of different TLS handshake packets.\n */\ntypedef enum {\n\tGNUTLS_HANDSHAKE_HELLO_REQUEST = 0,\n\tGNUTLS_HANDSHAKE_CLIENT_HELLO = 1,\n\tGNUTLS_HANDSHAKE_SERVER_HELLO = 2,\n\tGNUTLS_HANDSHAKE_HELLO_VERIFY_REQUEST = 3,\n\tGNUTLS_HANDSHAKE_NEW_SESSION_TICKET = 4,\n\tGNUTLS_HANDSHAKE_END_OF_EARLY_DATA = 5,\n\tGNUTLS_HANDSHAKE_ENCRYPTED_EXTENSIONS = 8,\n\tGNUTLS_HANDSHAKE_CERTIFICATE_PKT = 11,\n\tGNUTLS_HANDSHAKE_SERVER_KEY_EXCHANGE = 12,\n\tGNUTLS_HANDSHAKE_CERTIFICATE_REQUEST = 13,\n\tGNUTLS_HANDSHAKE_SERVER_HELLO_DONE = 14,\n\tGNUTLS_HANDSHAKE_CERTIFICATE_VERIFY = 15,\n\tGNUTLS_HANDSHAKE_CLIENT_KEY_EXCHANGE = 16,\n\tGNUTLS_HANDSHAKE_FINISHED = 20,\n\tGNUTLS_HANDSHAKE_CERTIFICATE_STATUS = 22,\n\tGNUTLS_HANDSHAKE_SUPPLEMENTAL = 23,\n\tGNUTLS_HANDSHAKE_KEY_UPDATE = 24,\n\tGNUTLS_HANDSHAKE_COMPRESSED_CERTIFICATE_PKT = 25,\n\tGNUTLS_HANDSHAKE_CHANGE_CIPHER_SPEC = 254,\n\tGNUTLS_HANDSHAKE_CLIENT_HELLO_V2 = 1024,\n\tGNUTLS_HANDSHAKE_HELLO_RETRY_REQUEST = 1025,\n} gnutls_handshake_description_t;\n\n#define GNUTLS_HANDSHAKE_ANY ((unsigned int)-1)\n\nconst char\n    *gnutls_handshake_description_get_name(gnutls_handshake_description_t\n\t\t\t\t\t   type);\n\n/**\n * gnutls_certificate_status_t:\n * @GNUTLS_CERT_INVALID: The certificate is not signed by one of the\n *   known authorities or the signature is invalid (deprecated by the flags \n *   %GNUTLS_CERT_SIGNATURE_FAILURE and %GNUTLS_CERT_SIGNER_NOT_FOUND).\n * @GNUTLS_CERT_SIGNATURE_FAILURE: The signature verification failed.\n * @GNUTLS_CERT_REVOKED: Certificate is revoked by its authority.  In X.509 this will be\n *   set only if CRLs are checked.\n * @GNUTLS_CERT_SIGNER_NOT_FOUND: The certificate's issuer is not known. \n *   This is the case if the issuer is not included in the trusted certificate list.\n * @GNUTLS_CERT_SIGNER_NOT_CA: The certificate's signer was not a CA. This\n *   may happen if this was a version 1 certificate, which is common with\n *   some CAs, or a version 3 certificate without the basic constrains extension.\n * @GNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE: The certificate's signer constraints were\n *   violated.\n * @GNUTLS_CERT_INSECURE_ALGORITHM:  The certificate was signed using an insecure\n *   algorithm such as MD2 or MD5. These algorithms have been broken and\n *   should not be trusted.\n * @GNUTLS_CERT_NOT_ACTIVATED: The certificate is not yet activated.\n * @GNUTLS_CERT_EXPIRED: The certificate has expired.\n * @GNUTLS_CERT_REVOCATION_DATA_SUPERSEDED: The revocation data are old and have been superseded.\n * @GNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE: The revocation data have a future issue date.\n * @GNUTLS_CERT_UNEXPECTED_OWNER: The owner is not the expected one.\n * @GNUTLS_CERT_MISMATCH: The certificate presented isn't the expected one (TOFU)\n * @GNUTLS_CERT_PURPOSE_MISMATCH: The certificate or an intermediate does not match the intended purpose (extended key usage).\n * @GNUTLS_CERT_MISSING_OCSP_STATUS: The certificate requires the server to send the certificate status, but no status was received.\n * @GNUTLS_CERT_INVALID_OCSP_STATUS: The received OCSP status response is invalid.\n * @GNUTLS_CERT_UNKNOWN_CRIT_EXTENSIONS: The certificate has extensions marked as critical which are not supported.\n *\n * Enumeration of certificate status codes.  Note that the status\n * bits may have different meanings in OpenPGP keys and X.509\n * certificate verification.\n */\ntypedef enum {\n\tGNUTLS_CERT_INVALID = 1 << 1,\n\tGNUTLS_CERT_REVOKED = 1 << 5,\n\tGNUTLS_CERT_SIGNER_NOT_FOUND = 1 << 6,\n\tGNUTLS_CERT_SIGNER_NOT_CA = 1 << 7,\n\tGNUTLS_CERT_INSECURE_ALGORITHM = 1 << 8,\n\tGNUTLS_CERT_NOT_ACTIVATED = 1 << 9,\n\tGNUTLS_CERT_EXPIRED = 1 << 10,\n\tGNUTLS_CERT_SIGNATURE_FAILURE = 1 << 11,\n\tGNUTLS_CERT_REVOCATION_DATA_SUPERSEDED = 1 << 12,\n\tGNUTLS_CERT_UNEXPECTED_OWNER = 1 << 14,\n\tGNUTLS_CERT_REVOCATION_DATA_ISSUED_IN_FUTURE = 1 << 15,\n\tGNUTLS_CERT_SIGNER_CONSTRAINTS_FAILURE = 1 << 16,\n\tGNUTLS_CERT_MISMATCH = 1 << 17,\n\tGNUTLS_CERT_PURPOSE_MISMATCH = 1 << 18,\n\tGNUTLS_CERT_MISSING_OCSP_STATUS = 1 << 19,\n\tGNUTLS_CERT_INVALID_OCSP_STATUS = 1 << 20,\n\tGNUTLS_CERT_UNKNOWN_CRIT_EXTENSIONS = 1 << 21\n} gnutls_certificate_status_t;\n\n/**\n * gnutls_certificate_request_t:\n * @GNUTLS_CERT_IGNORE: Ignore certificate.\n * @GNUTLS_CERT_REQUEST: Request certificate.\n * @GNUTLS_CERT_REQUIRE: Require certificate.\n *\n * Enumeration of certificate request types.\n */\ntypedef enum {\n\tGNUTLS_CERT_IGNORE = 0,\n\tGNUTLS_CERT_REQUEST = 1,\n\tGNUTLS_CERT_REQUIRE = 2\n} gnutls_certificate_request_t;\n\n/**\n * gnutls_openpgp_crt_status_t:\n * @GNUTLS_OPENPGP_CERT: Send entire certificate.\n * @GNUTLS_OPENPGP_CERT_FINGERPRINT: Send only certificate fingerprint.\n *\n * Enumeration of ways to send OpenPGP certificate.\n */\ntypedef enum {\n\tGNUTLS_OPENPGP_CERT = 0,\n\tGNUTLS_OPENPGP_CERT_FINGERPRINT = 1\n} gnutls_openpgp_crt_status_t;\n\n/**\n * gnutls_close_request_t:\n * @GNUTLS_SHUT_RDWR: Disallow further receives/sends.\n * @GNUTLS_SHUT_WR: Disallow further sends.\n *\n * Enumeration of how TLS session should be terminated.  See gnutls_bye().\n */\ntypedef enum {\n\tGNUTLS_SHUT_RDWR = 0,\n\tGNUTLS_SHUT_WR = 1\n} gnutls_close_request_t;\n\n/**\n * gnutls_protocol_t:\n * @GNUTLS_SSL3: SSL version 3.0.\n * @GNUTLS_TLS1_0: TLS version 1.0.\n * @GNUTLS_TLS1: Same as %GNUTLS_TLS1_0.\n * @GNUTLS_TLS1_1: TLS version 1.1.\n * @GNUTLS_TLS1_2: TLS version 1.2.\n * @GNUTLS_TLS1_3: TLS version 1.3.\n * @GNUTLS_DTLS1_0: DTLS version 1.0.\n * @GNUTLS_DTLS1_2: DTLS version 1.2.\n * @GNUTLS_DTLS0_9: DTLS version 0.9 (Cisco AnyConnect / OpenSSL 0.9.8e).\n * @GNUTLS_TLS_VERSION_MAX: Maps to the highest supported TLS version.\n * @GNUTLS_DTLS_VERSION_MAX: Maps to the highest supported DTLS version.\n * @GNUTLS_VERSION_UNKNOWN: Unknown SSL/TLS version.\n *\n * Enumeration of different SSL/TLS protocol versions.\n */\ntypedef enum {\n\tGNUTLS_SSL3 = 1,\n\tGNUTLS_TLS1_0 = 2,\n\tGNUTLS_TLS1 = GNUTLS_TLS1_0,\n\tGNUTLS_TLS1_1 = 3,\n\tGNUTLS_TLS1_2 = 4,\n\tGNUTLS_TLS1_3 = 5,\n\n\tGNUTLS_DTLS0_9 = 200,\n\tGNUTLS_DTLS1_0 = 201,\t/* 201 */\n\tGNUTLS_DTLS1_2 = 202,\n\tGNUTLS_DTLS_VERSION_MIN = GNUTLS_DTLS0_9,\n\tGNUTLS_DTLS_VERSION_MAX = GNUTLS_DTLS1_2,\n\tGNUTLS_TLS_VERSION_MAX = GNUTLS_TLS1_3,\n\tGNUTLS_VERSION_UNKNOWN = 0xff\t/* change it to 0xffff */\n} gnutls_protocol_t;\n\n#define GNUTLS_CRT_RAW GNUTLS_CRT_RAWPK\n\n/**\n * gnutls_certificate_type_t:\n * @GNUTLS_CRT_UNKNOWN: Unknown certificate type.\n * @GNUTLS_CRT_X509: X.509 Certificate.\n * @GNUTLS_CRT_OPENPGP: OpenPGP certificate.\n * @GNUTLS_CRT_RAWPK: Raw public-key (SubjectPublicKeyInfo)\n *\n * Enumeration of different certificate types.\n */\ntypedef enum {\n\tGNUTLS_CRT_UNKNOWN = 0,\n\tGNUTLS_CRT_X509 = 1,\n\tGNUTLS_CRT_OPENPGP = 2,\n\tGNUTLS_CRT_RAWPK = 3,\n\tGNUTLS_CRT_MAX = GNUTLS_CRT_RAWPK\n} gnutls_certificate_type_t;\n\n/**\n * gnutls_x509_crt_fmt_t:\n * @GNUTLS_X509_FMT_DER: X.509 certificate in DER format (binary).\n * @GNUTLS_X509_FMT_PEM: X.509 certificate in PEM format (text).\n *\n * Enumeration of different certificate encoding formats.\n */\ntypedef enum {\n\tGNUTLS_X509_FMT_DER = 0,\n\tGNUTLS_X509_FMT_PEM = 1\n} gnutls_x509_crt_fmt_t;\n\n/**\n * gnutls_certificate_print_formats_t:\n * @GNUTLS_CRT_PRINT_FULL: Full information about certificate.\n * @GNUTLS_CRT_PRINT_FULL_NUMBERS: Full information about certificate and include easy to parse public key parameters.\n * @GNUTLS_CRT_PRINT_COMPACT: Information about certificate name in one line, plus identification of the public key.\n * @GNUTLS_CRT_PRINT_ONELINE: Information about certificate in one line.\n * @GNUTLS_CRT_PRINT_UNSIGNED_FULL: All info for an unsigned certificate.\n *\n * Enumeration of different certificate printing variants.\n */\ntypedef enum gnutls_certificate_print_formats {\n\tGNUTLS_CRT_PRINT_FULL = 0,\n\tGNUTLS_CRT_PRINT_ONELINE = 1,\n\tGNUTLS_CRT_PRINT_UNSIGNED_FULL = 2,\n\tGNUTLS_CRT_PRINT_COMPACT = 3,\n\tGNUTLS_CRT_PRINT_FULL_NUMBERS = 4\n} gnutls_certificate_print_formats_t;\n\n#define GNUTLS_PK_ECC GNUTLS_PK_ECDSA\n#define GNUTLS_PK_EC GNUTLS_PK_ECDSA\n\n#define GNUTLS_PK_ECDHX GNUTLS_PK_ECDH_X25519\n/**\n * gnutls_pk_algorithm_t:\n * @GNUTLS_PK_UNKNOWN: Unknown public-key algorithm.\n * @GNUTLS_PK_RSA: RSA public-key algorithm.\n * @GNUTLS_PK_RSA_PSS: RSA public-key algorithm, with PSS padding.\n * @GNUTLS_PK_DSA: DSA public-key algorithm.\n * @GNUTLS_PK_DH: Diffie-Hellman algorithm. Used to generate parameters.\n * @GNUTLS_PK_ECDSA: Elliptic curve algorithm. These parameters are compatible with the ECDSA and ECDH algorithm.\n * @GNUTLS_PK_ECDH_X25519: Elliptic curve algorithm, restricted to ECDH as per rfc7748.\n * @GNUTLS_PK_EDDSA_ED25519: Edwards curve Digital signature algorithm. Used with SHA512 on signatures.\n * @GNUTLS_PK_GOST_01: GOST R 34.10-2001 algorithm per rfc5832.\n * @GNUTLS_PK_GOST_12_256: GOST R 34.10-2012 algorithm, 256-bit key per rfc7091.\n * @GNUTLS_PK_GOST_12_512: GOST R 34.10-2012 algorithm, 512-bit key per rfc7091.\n * @GNUTLS_PK_ECDH_X448: Elliptic curve algorithm, restricted to ECDH as per rfc7748.\n * @GNUTLS_PK_EDDSA_ED448: Edwards curve Digital signature algorithm. Used with SHAKE256 on signatures.\n *\n * Enumeration of different public-key algorithms.\n */\ntypedef enum {\n\tGNUTLS_PK_UNKNOWN = 0,\n\tGNUTLS_PK_RSA = 1,\n\tGNUTLS_PK_DSA = 2,\n\tGNUTLS_PK_DH = 3,\n\tGNUTLS_PK_ECDSA = 4,\n\tGNUTLS_PK_ECDH_X25519 = 5,\n\tGNUTLS_PK_RSA_PSS = 6,\n\tGNUTLS_PK_EDDSA_ED25519 = 7,\n\tGNUTLS_PK_GOST_01 = 8,\n\tGNUTLS_PK_GOST_12_256 = 9,\n\tGNUTLS_PK_GOST_12_512 = 10,\n\tGNUTLS_PK_ECDH_X448 = 11,\n\tGNUTLS_PK_EDDSA_ED448 = 12,\n\tGNUTLS_PK_MAX = GNUTLS_PK_EDDSA_ED448\n} gnutls_pk_algorithm_t;\n\n\nconst char *gnutls_pk_algorithm_get_name(gnutls_pk_algorithm_t algorithm);\n\n/**\n * gnutls_sign_algorithm_t:\n * @GNUTLS_SIGN_UNKNOWN: Unknown signature algorithm.\n * @GNUTLS_SIGN_RSA_RAW: Digital signature algorithm RSA with DigestInfo formatted data\n * @GNUTLS_SIGN_RSA_SHA1: Digital signature algorithm RSA with SHA-1\n * @GNUTLS_SIGN_RSA_SHA: Same as %GNUTLS_SIGN_RSA_SHA1.\n * @GNUTLS_SIGN_DSA_SHA1: Digital signature algorithm DSA with SHA-1\n * @GNUTLS_SIGN_DSA_SHA224: Digital signature algorithm DSA with SHA-224\n * @GNUTLS_SIGN_DSA_SHA256: Digital signature algorithm DSA with SHA-256\n * @GNUTLS_SIGN_DSA_SHA384: Digital signature algorithm DSA with SHA-384\n * @GNUTLS_SIGN_DSA_SHA512: Digital signature algorithm DSA with SHA-512\n * @GNUTLS_SIGN_DSA_SHA: Same as %GNUTLS_SIGN_DSA_SHA1.\n * @GNUTLS_SIGN_RSA_MD5: Digital signature algorithm RSA with MD5.\n * @GNUTLS_SIGN_RSA_MD2: Digital signature algorithm RSA with MD2.\n * @GNUTLS_SIGN_RSA_RMD160: Digital signature algorithm RSA with RMD-160.\n * @GNUTLS_SIGN_RSA_SHA256: Digital signature algorithm RSA with SHA-256.\n * @GNUTLS_SIGN_RSA_SHA384: Digital signature algorithm RSA with SHA-384.\n * @GNUTLS_SIGN_RSA_SHA512: Digital signature algorithm RSA with SHA-512.\n * @GNUTLS_SIGN_RSA_SHA224: Digital signature algorithm RSA with SHA-224.\n * @GNUTLS_SIGN_ECDSA_SHA1: ECDSA with SHA1.\n * @GNUTLS_SIGN_ECDSA_SHA224: Digital signature algorithm ECDSA with SHA-224.\n * @GNUTLS_SIGN_ECDSA_SHA256: Digital signature algorithm ECDSA with SHA-256.\n * @GNUTLS_SIGN_ECDSA_SHA384: Digital signature algorithm ECDSA with SHA-384.\n * @GNUTLS_SIGN_ECDSA_SHA512: Digital signature algorithm ECDSA with SHA-512.\n * @GNUTLS_SIGN_ECDSA_SECP256R1_SHA256: Digital signature algorithm ECDSA-SECP256R1 with SHA-256 (used in TLS 1.3 but not PKIX).\n * @GNUTLS_SIGN_ECDSA_SECP384R1_SHA384: Digital signature algorithm ECDSA-SECP384R1 with SHA-384 (used in TLS 1.3 but not PKIX).\n * @GNUTLS_SIGN_ECDSA_SECP521R1_SHA512: Digital signature algorithm ECDSA-SECP521R1 with SHA-512 (used in TLS 1.3 but not PKIX).\n * @GNUTLS_SIGN_ECDSA_SHA3_224: Digital signature algorithm ECDSA with SHA3-224.\n * @GNUTLS_SIGN_ECDSA_SHA3_256: Digital signature algorithm ECDSA with SHA3-256.\n * @GNUTLS_SIGN_ECDSA_SHA3_384: Digital signature algorithm ECDSA with SHA3-384.\n * @GNUTLS_SIGN_ECDSA_SHA3_512: Digital signature algorithm ECDSA with SHA3-512.\n * @GNUTLS_SIGN_DSA_SHA3_224: Digital signature algorithm DSA with SHA3-224.\n * @GNUTLS_SIGN_DSA_SHA3_256: Digital signature algorithm DSA with SHA3-256.\n * @GNUTLS_SIGN_DSA_SHA3_384: Digital signature algorithm DSA with SHA3-384.\n * @GNUTLS_SIGN_DSA_SHA3_512: Digital signature algorithm DSA with SHA3-512.\n * @GNUTLS_SIGN_RSA_SHA3_224: Digital signature algorithm RSA with SHA3-224.\n * @GNUTLS_SIGN_RSA_SHA3_256: Digital signature algorithm RSA with SHA3-256.\n * @GNUTLS_SIGN_RSA_SHA3_384: Digital signature algorithm RSA with SHA3-384.\n * @GNUTLS_SIGN_RSA_SHA3_512: Digital signature algorithm RSA with SHA3-512.\n * @GNUTLS_SIGN_RSA_PSS_RSAE_SHA256: Digital signature algorithm RSA with SHA-256,\n *      with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical\n *      to #GNUTLS_SIGN_RSA_PSS_SHA256, but they are distinct as the TLS1.3 protocol\n *      treats them differently.\n * @GNUTLS_SIGN_RSA_PSS_RSAE_SHA384: Digital signature algorithm RSA with SHA-384,\n *      with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical\n *      to #GNUTLS_SIGN_RSA_PSS_SHA384, but they are distinct as the TLS1.3 protocol\n *      treats them differently.\n * @GNUTLS_SIGN_RSA_PSS_RSAE_SHA512: Digital signature algorithm RSA with SHA-512,\n *      with PSS padding (RSA PKCS#1 1.5 certificate). This signature is identical\n *      to #GNUTLS_SIGN_RSA_PSS_SHA512, but they are distinct as the TLS1.3 protocol\n *      treats them differently.\n * @GNUTLS_SIGN_RSA_PSS_SHA256: Digital signature algorithm RSA with SHA-256, with PSS padding (RSA-PSS certificate).\n * @GNUTLS_SIGN_RSA_PSS_SHA384: Digital signature algorithm RSA with SHA-384, with PSS padding (RSA-PSS certificate).\n * @GNUTLS_SIGN_RSA_PSS_SHA512: Digital signature algorithm RSA with SHA-512, with PSS padding (RSA-PSS certificate).\n * @GNUTLS_SIGN_EDDSA_ED25519: Digital signature algorithm EdDSA with Ed25519 curve.\n * @GNUTLS_SIGN_GOST_94: Digital signature algorithm GOST R 34.10-2001 with GOST R 34.11-94\n * @GNUTLS_SIGN_GOST_256: Digital signature algorithm GOST R 34.10-2012 with GOST R 34.11-2012 256 bit\n * @GNUTLS_SIGN_GOST_512: Digital signature algorithm GOST R 34.10-2012 with GOST R 34.11-2012 512 bit\n * @GNUTLS_SIGN_EDDSA_ED448: Digital signature algorithm EdDSA with Ed448 curve.\n *\n * Enumeration of different digital signature algorithms.\n */\ntypedef enum {\n\tGNUTLS_SIGN_UNKNOWN = 0,\n\tGNUTLS_SIGN_RSA_SHA1 = 1,\n\tGNUTLS_SIGN_RSA_SHA = GNUTLS_SIGN_RSA_SHA1,\n\tGNUTLS_SIGN_DSA_SHA1 = 2,\n\tGNUTLS_SIGN_DSA_SHA = GNUTLS_SIGN_DSA_SHA1,\n\tGNUTLS_SIGN_RSA_MD5 = 3,\n\tGNUTLS_SIGN_RSA_MD2 = 4,\n\tGNUTLS_SIGN_RSA_RMD160 = 5,\n\tGNUTLS_SIGN_RSA_SHA256 = 6,\n\tGNUTLS_SIGN_RSA_SHA384 = 7,\n\tGNUTLS_SIGN_RSA_SHA512 = 8,\n\tGNUTLS_SIGN_RSA_SHA224 = 9,\n\tGNUTLS_SIGN_DSA_SHA224 = 10,\n\tGNUTLS_SIGN_DSA_SHA256 = 11,\n\tGNUTLS_SIGN_ECDSA_SHA1 = 12,\n\tGNUTLS_SIGN_ECDSA_SHA224 = 13,\n\tGNUTLS_SIGN_ECDSA_SHA256 = 14,\n\tGNUTLS_SIGN_ECDSA_SHA384 = 15,\n\tGNUTLS_SIGN_ECDSA_SHA512 = 16,\n\tGNUTLS_SIGN_DSA_SHA384 = 17,\n\tGNUTLS_SIGN_DSA_SHA512 = 18,\n\tGNUTLS_SIGN_ECDSA_SHA3_224 = 20,\n\tGNUTLS_SIGN_ECDSA_SHA3_256 = 21,\n\tGNUTLS_SIGN_ECDSA_SHA3_384 = 22,\n\tGNUTLS_SIGN_ECDSA_SHA3_512 = 23,\n\n\tGNUTLS_SIGN_DSA_SHA3_224 = 24,\n\tGNUTLS_SIGN_DSA_SHA3_256 = 25,\n\tGNUTLS_SIGN_DSA_SHA3_384 = 26,\n\tGNUTLS_SIGN_DSA_SHA3_512 = 27,\n\tGNUTLS_SIGN_RSA_SHA3_224 = 28,\n\tGNUTLS_SIGN_RSA_SHA3_256 = 29,\n\tGNUTLS_SIGN_RSA_SHA3_384 = 30,\n\tGNUTLS_SIGN_RSA_SHA3_512 = 31,\n\n\tGNUTLS_SIGN_RSA_PSS_SHA256 = 32,\n\tGNUTLS_SIGN_RSA_PSS_SHA384 = 33,\n\tGNUTLS_SIGN_RSA_PSS_SHA512 = 34,\n\tGNUTLS_SIGN_EDDSA_ED25519 = 35,\n\tGNUTLS_SIGN_RSA_RAW = 36,\n\n\tGNUTLS_SIGN_ECDSA_SECP256R1_SHA256 = 37,\n\tGNUTLS_SIGN_ECDSA_SECP384R1_SHA384 = 38,\n\tGNUTLS_SIGN_ECDSA_SECP521R1_SHA512 = 39,\n\n\tGNUTLS_SIGN_RSA_PSS_RSAE_SHA256 = 40,\n\tGNUTLS_SIGN_RSA_PSS_RSAE_SHA384 = 41,\n\tGNUTLS_SIGN_RSA_PSS_RSAE_SHA512 = 42,\n\n\tGNUTLS_SIGN_GOST_94 = 43,\n\tGNUTLS_SIGN_GOST_256 = 44,\n\tGNUTLS_SIGN_GOST_512 = 45,\n\tGNUTLS_SIGN_EDDSA_ED448 = 46,\n\tGNUTLS_SIGN_MAX = GNUTLS_SIGN_EDDSA_ED448\n} gnutls_sign_algorithm_t;\n\n/**\n * gnutls_ecc_curve_t:\n * @GNUTLS_ECC_CURVE_INVALID: Cannot be known\n * @GNUTLS_ECC_CURVE_SECP192R1: the SECP192R1 curve\n * @GNUTLS_ECC_CURVE_SECP224R1: the SECP224R1 curve\n * @GNUTLS_ECC_CURVE_SECP256R1: the SECP256R1 curve\n * @GNUTLS_ECC_CURVE_SECP384R1: the SECP384R1 curve\n * @GNUTLS_ECC_CURVE_SECP521R1: the SECP521R1 curve\n * @GNUTLS_ECC_CURVE_X25519: the X25519 curve (ECDH only)\n * @GNUTLS_ECC_CURVE_ED25519: the Ed25519 curve\n * @GNUTLS_ECC_CURVE_GOST256CPA: GOST R 34.10 CryptoPro 256 A curve\n * @GNUTLS_ECC_CURVE_GOST256CPB: GOST R 34.10 CryptoPro 256 B curve\n * @GNUTLS_ECC_CURVE_GOST256CPC: GOST R 34.10 CryptoPro 256 C curve\n * @GNUTLS_ECC_CURVE_GOST256CPXA: GOST R 34.10 CryptoPro 256 XchA curve\n * @GNUTLS_ECC_CURVE_GOST256CPXB: GOST R 34.10 CryptoPro 256 XchB curve\n * @GNUTLS_ECC_CURVE_GOST512A: GOST R 34.10 TC26 512 A curve\n * @GNUTLS_ECC_CURVE_GOST512B: GOST R 34.10 TC26 512 B curve\n * @GNUTLS_ECC_CURVE_GOST512C: GOST R 34.10 TC26 512 C curve\n * @GNUTLS_ECC_CURVE_GOST256A: GOST R 34.10 TC26 256 A curve\n * @GNUTLS_ECC_CURVE_GOST256B: GOST R 34.10 TC26 256 B curve\n * @GNUTLS_ECC_CURVE_GOST256C: GOST R 34.10 TC26 256 C curve\n * @GNUTLS_ECC_CURVE_GOST256D: GOST R 34.10 TC26 256 D curve\n * @GNUTLS_ECC_CURVE_X448: the X448 curve (ECDH only)\n * @GNUTLS_ECC_CURVE_ED448: the Ed448 curve\n *\n * Enumeration of ECC curves.\n */\ntypedef enum {\n\tGNUTLS_ECC_CURVE_INVALID = 0,\n\tGNUTLS_ECC_CURVE_SECP224R1,\n\tGNUTLS_ECC_CURVE_SECP256R1,\n\tGNUTLS_ECC_CURVE_SECP384R1,\n\tGNUTLS_ECC_CURVE_SECP521R1,\n\tGNUTLS_ECC_CURVE_SECP192R1,\n\tGNUTLS_ECC_CURVE_X25519,\n\tGNUTLS_ECC_CURVE_ED25519,\n\tGNUTLS_ECC_CURVE_GOST256CPA,\n\tGNUTLS_ECC_CURVE_GOST256CPB,\n\tGNUTLS_ECC_CURVE_GOST256CPC,\n\tGNUTLS_ECC_CURVE_GOST256CPXA,\n\tGNUTLS_ECC_CURVE_GOST256CPXB,\n\tGNUTLS_ECC_CURVE_GOST512A,\n\tGNUTLS_ECC_CURVE_GOST512B,\n\tGNUTLS_ECC_CURVE_GOST512C,\n\tGNUTLS_ECC_CURVE_GOST256A,\n\tGNUTLS_ECC_CURVE_GOST256B,\n\tGNUTLS_ECC_CURVE_GOST256C,\n\tGNUTLS_ECC_CURVE_GOST256D,\n\tGNUTLS_ECC_CURVE_X448,\n\tGNUTLS_ECC_CURVE_ED448,\n\tGNUTLS_ECC_CURVE_MAX = GNUTLS_ECC_CURVE_ED448\n} gnutls_ecc_curve_t;\n\n/**\n * gnutls_group_t:\n * @GNUTLS_GROUP_INVALID: Indicates unknown/invalid group\n * @GNUTLS_GROUP_SECP192R1: the SECP192R1 curve group (legacy, only for TLS 1.2 compatibility)\n * @GNUTLS_GROUP_SECP224R1: the SECP224R1 curve group (legacy, only for TLS 1.2 compatibility)\n * @GNUTLS_GROUP_SECP256R1: the SECP256R1 curve group\n * @GNUTLS_GROUP_SECP384R1: the SECP384R1 curve group\n * @GNUTLS_GROUP_SECP521R1: the SECP521R1 curve group\n * @GNUTLS_GROUP_X25519: the X25519 curve group\n * @GNUTLS_GROUP_GC256A: the GOST R 34.10 TC26 256 A curve group\n * @GNUTLS_GROUP_GC256B: the GOST R 34.10 TC26 256 B curve group\n * @GNUTLS_GROUP_GC256C: the GOST R 34.10 TC26 256 C curve group\n * @GNUTLS_GROUP_GC256D: the GOST R 34.10 TC26 256 D curve group\n * @GNUTLS_GROUP_GC512A: the GOST R 34.10 TC26 512 A curve group\n * @GNUTLS_GROUP_GC512B: the GOST R 34.10 TC26 512 B curve group\n * @GNUTLS_GROUP_GC512C: the GOST R 34.10 TC26 512 C curve group\n * @GNUTLS_GROUP_FFDHE2048: the FFDHE2048 group\n * @GNUTLS_GROUP_FFDHE3072: the FFDHE3072 group\n * @GNUTLS_GROUP_FFDHE4096: the FFDHE4096 group\n * @GNUTLS_GROUP_FFDHE6144: the FFDHE6144 group\n * @GNUTLS_GROUP_FFDHE8192: the FFDHE8192 group\n * @GNUTLS_GROUP_X448: the X448 curve group\n *\n * Enumeration of supported groups. It is intended to be backwards\n * compatible with the enumerations in %gnutls_ecc_curve_t for the groups\n * which are valid elliptic curves.\n */\ntypedef enum {\n\tGNUTLS_GROUP_INVALID = 0,\n\tGNUTLS_GROUP_SECP192R1 = GNUTLS_ECC_CURVE_SECP192R1,\n\tGNUTLS_GROUP_SECP224R1 = GNUTLS_ECC_CURVE_SECP224R1,\n\tGNUTLS_GROUP_SECP256R1 = GNUTLS_ECC_CURVE_SECP256R1,\n\tGNUTLS_GROUP_SECP384R1 = GNUTLS_ECC_CURVE_SECP384R1,\n\tGNUTLS_GROUP_SECP521R1 = GNUTLS_ECC_CURVE_SECP521R1,\n\tGNUTLS_GROUP_X25519 = GNUTLS_ECC_CURVE_X25519,\n\tGNUTLS_GROUP_X448 = GNUTLS_ECC_CURVE_X448,\n\n\tGNUTLS_GROUP_GC256A = GNUTLS_ECC_CURVE_GOST256A,\n\tGNUTLS_GROUP_GC256B = GNUTLS_ECC_CURVE_GOST256B,\n\tGNUTLS_GROUP_GC256C = GNUTLS_ECC_CURVE_GOST256C,\n\tGNUTLS_GROUP_GC256D = GNUTLS_ECC_CURVE_GOST256D,\n\tGNUTLS_GROUP_GC512A = GNUTLS_ECC_CURVE_GOST512A,\n\tGNUTLS_GROUP_GC512B = GNUTLS_ECC_CURVE_GOST512B,\n\tGNUTLS_GROUP_GC512C = GNUTLS_ECC_CURVE_GOST512C,\n\n\tGNUTLS_GROUP_FFDHE2048 = 256,\n\tGNUTLS_GROUP_FFDHE3072,\n\tGNUTLS_GROUP_FFDHE4096,\n\tGNUTLS_GROUP_FFDHE8192,\n\tGNUTLS_GROUP_FFDHE6144,\n\tGNUTLS_GROUP_MAX = GNUTLS_GROUP_FFDHE6144,\n} gnutls_group_t;\n\n/* macros to allow specifying a specific curve in gnutls_privkey_generate()\n * and gnutls_x509_privkey_generate() */\n#define GNUTLS_CURVE_TO_BITS(curve) (unsigned int)(((unsigned int)1<<31)|((unsigned int)(curve)))\n#define GNUTLS_BITS_TO_CURVE(bits) (((unsigned int)(bits)) & 0x7FFFFFFF)\n#define GNUTLS_BITS_ARE_CURVE(bits) (((unsigned int)(bits)) & 0x80000000)\n\n/**\n * gnutls_sec_param_t:\n * @GNUTLS_SEC_PARAM_UNKNOWN: Cannot be known\n * @GNUTLS_SEC_PARAM_INSECURE: Less than 42 bits of security\n * @GNUTLS_SEC_PARAM_EXPORT: 42 bits of security\n * @GNUTLS_SEC_PARAM_VERY_WEAK: 64 bits of security\n * @GNUTLS_SEC_PARAM_WEAK: 72 bits of security\n * @GNUTLS_SEC_PARAM_LOW: 80 bits of security\n * @GNUTLS_SEC_PARAM_LEGACY: 96 bits of security\n * @GNUTLS_SEC_PARAM_MEDIUM: 112 bits of security (used to be %GNUTLS_SEC_PARAM_NORMAL)\n * @GNUTLS_SEC_PARAM_HIGH: 128 bits of security\n * @GNUTLS_SEC_PARAM_ULTRA: 192 bits of security\n * @GNUTLS_SEC_PARAM_FUTURE: 256 bits of security\n *\n * Enumeration of security parameters for passive attacks.\n */\ntypedef enum {\n\tGNUTLS_SEC_PARAM_UNKNOWN = 0,\n\tGNUTLS_SEC_PARAM_INSECURE = 5,\n\tGNUTLS_SEC_PARAM_EXPORT = 10,\n\tGNUTLS_SEC_PARAM_VERY_WEAK = 15,\n\tGNUTLS_SEC_PARAM_WEAK = 20,\n\tGNUTLS_SEC_PARAM_LOW = 25,\n\tGNUTLS_SEC_PARAM_LEGACY = 30,\n\tGNUTLS_SEC_PARAM_MEDIUM = 35,\n\tGNUTLS_SEC_PARAM_HIGH = 40,\n\tGNUTLS_SEC_PARAM_ULTRA = 45,\n\tGNUTLS_SEC_PARAM_FUTURE = 50,\n\tGNUTLS_SEC_PARAM_MAX = GNUTLS_SEC_PARAM_FUTURE\n} gnutls_sec_param_t;\n\n/* old name */\n#define GNUTLS_SEC_PARAM_NORMAL GNUTLS_SEC_PARAM_MEDIUM\n\n/**\n * gnutls_channel_binding_t:\n * @GNUTLS_CB_TLS_UNIQUE: \"tls-unique\" (RFC 5929) channel binding\n * @GNUTLS_CB_TLS_SERVER_END_POINT: \"tls-server-end-point\" (RFC 5929) channel binding\n * @GNUTLS_CB_TLS_EXPORTER: \"tls-exporter\" (RFC 9266) channel binding\n *\n * Enumeration of supported channel binding types.\n */\ntypedef enum {\n\tGNUTLS_CB_TLS_UNIQUE,\n\tGNUTLS_CB_TLS_SERVER_END_POINT,\n\tGNUTLS_CB_TLS_EXPORTER\n} gnutls_channel_binding_t;\n\n/**\n * gnutls_gost_paramset_t:\n * @GNUTLS_GOST_PARAMSET_UNKNOWN: Unknown/default parameter set\n * @GNUTLS_GOST_PARAMSET_TC26_Z: Specified by TC26, see rfc7836\n * @GNUTLS_GOST_PARAMSET_CP_A: CryptoPro-A, see rfc4357\n * @GNUTLS_GOST_PARAMSET_CP_B: CryptoPro-B, see rfc4357\n * @GNUTLS_GOST_PARAMSET_CP_C: CryptoPro-C, see rfc4357\n * @GNUTLS_GOST_PARAMSET_CP_D: CryptoPro-D, see rfc4357\n *\n * Enumeration of different GOST 28147 parameter sets.\n */\ntypedef enum {\n\tGNUTLS_GOST_PARAMSET_UNKNOWN = 0,\n\tGNUTLS_GOST_PARAMSET_TC26_Z,\n\tGNUTLS_GOST_PARAMSET_CP_A,\n\tGNUTLS_GOST_PARAMSET_CP_B,\n\tGNUTLS_GOST_PARAMSET_CP_C,\n\tGNUTLS_GOST_PARAMSET_CP_D\n} gnutls_gost_paramset_t;\n\n/**\n * gnutls_ctype_target_t:\n * @GNUTLS_CTYPE_CLIENT: for requesting client certificate type values.\n * @GNUTLS_CTYPE_SERVER: for requesting server certificate type values.\n * @GNUTLS_CTYPE_OURS: for requesting our certificate type values.\n * @GNUTLS_CTYPE_PEERS: for requesting the peers' certificate type values.\n *\n * Enumeration of certificate type targets with respect to asymmetric\n * certificate types as specified in RFC7250 and P2P connection set up\n * as specified in draft-vanrein-tls-symmetry-02.\n */\ntypedef enum {\n\tGNUTLS_CTYPE_CLIENT,\n\tGNUTLS_CTYPE_SERVER,\n\tGNUTLS_CTYPE_OURS,\n\tGNUTLS_CTYPE_PEERS\n} gnutls_ctype_target_t;\n\n/* If you want to change this, then also change the define in\n * gnutls_int.h, and recompile.\n */\ntypedef void *gnutls_transport_ptr_t;\n\nstruct gnutls_session_int;\ntypedef struct gnutls_session_int *gnutls_session_t;\n\nstruct gnutls_dh_params_int;\ntypedef struct gnutls_dh_params_int *gnutls_dh_params_t;\n\n  /* XXX ugly. */\nstruct gnutls_x509_privkey_int;\ntypedef struct gnutls_x509_privkey_int *gnutls_rsa_params_t;\n\nstruct gnutls_priority_st;\ntypedef struct gnutls_priority_st *gnutls_priority_t;\n\ntypedef struct {\n\tunsigned char *data;\n\tunsigned int size;\n} gnutls_datum_t;\n\ntypedef struct gnutls_library_config_st {\n\tconst char *name;\n\tconst char *value;\n} gnutls_library_config_st;\n\n\ntypedef struct gnutls_params_st {\n\tgnutls_params_type_t type;\n\tunion params {\n\t\tgnutls_dh_params_t dh;\n\t\tgnutls_rsa_params_t rsa_export;\n\t} params;\n\tint deinit;\n} gnutls_params_st;\n\ntypedef int gnutls_params_function(gnutls_session_t, gnutls_params_type_t,\n\t\t\t\t   gnutls_params_st *);\n\n/* internal functions */\n\nint gnutls_init(gnutls_session_t * session, unsigned int flags);\nvoid gnutls_deinit(gnutls_session_t session);\n#define _gnutls_deinit(x) gnutls_deinit(x)\n\nint gnutls_bye(gnutls_session_t session, gnutls_close_request_t how);\n\nint gnutls_handshake(gnutls_session_t session);\n\nint gnutls_reauth(gnutls_session_t session, unsigned int flags);\n\n#define GNUTLS_DEFAULT_HANDSHAKE_TIMEOUT ((unsigned int)-1)\n#define GNUTLS_INDEFINITE_TIMEOUT ((unsigned int)-2)\nvoid gnutls_handshake_set_timeout(gnutls_session_t session,\n\t\t\t\t  unsigned int ms);\nint gnutls_rehandshake(gnutls_session_t session);\n\n#define GNUTLS_KU_PEER 1\nint gnutls_session_key_update(gnutls_session_t session, unsigned flags);\n\ngnutls_alert_description_t gnutls_alert_get(gnutls_session_t session);\nint gnutls_alert_send(gnutls_session_t session,\n\t\t      gnutls_alert_level_t level,\n\t\t      gnutls_alert_description_t desc);\nint gnutls_alert_send_appropriate(gnutls_session_t session, int err);\nconst char *gnutls_alert_get_name(gnutls_alert_description_t alert);\nconst char *gnutls_alert_get_strname(gnutls_alert_description_t alert);\n\ngnutls_sec_param_t gnutls_pk_bits_to_sec_param(gnutls_pk_algorithm_t algo,\n\t\t\t\t\t       unsigned int bits);\nconst char *gnutls_sec_param_get_name(gnutls_sec_param_t param);\nunsigned int gnutls_sec_param_to_pk_bits(gnutls_pk_algorithm_t algo,\n\t\t\t\t\t gnutls_sec_param_t param);\nunsigned int\n\tgnutls_sec_param_to_symmetric_bits(gnutls_sec_param_t param) __GNUTLS_CONST__;\n\n/* Elliptic curves */\nconst char *\n\tgnutls_ecc_curve_get_name(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;\nconst char *\n\tgnutls_ecc_curve_get_oid(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_group_get_name(gnutls_group_t group) __GNUTLS_CONST__;\n\nint\n\tgnutls_ecc_curve_get_size(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;\ngnutls_ecc_curve_t gnutls_ecc_curve_get(gnutls_session_t session);\n\ngnutls_group_t gnutls_group_get(gnutls_session_t session);\n\n/* get information on the current session */\ngnutls_cipher_algorithm_t gnutls_cipher_get(gnutls_session_t session);\ngnutls_cipher_algorithm_t gnutls_early_cipher_get(gnutls_session_t session);\ngnutls_kx_algorithm_t gnutls_kx_get(gnutls_session_t session);\ngnutls_mac_algorithm_t gnutls_mac_get(gnutls_session_t session);\ngnutls_digest_algorithm_t gnutls_prf_hash_get(const gnutls_session_t session);\ngnutls_digest_algorithm_t\ngnutls_early_prf_hash_get(const gnutls_session_t session);\ngnutls_certificate_type_t\ngnutls_certificate_type_get(gnutls_session_t session);\ngnutls_certificate_type_t\ngnutls_certificate_type_get2(gnutls_session_t session,\n\t\t\t     gnutls_ctype_target_t target);\n\nint gnutls_sign_algorithm_get(gnutls_session_t session);\nint gnutls_sign_algorithm_get_client(gnutls_session_t session);\n\nint gnutls_sign_algorithm_get_requested(gnutls_session_t session,\n\t\t\t\t\tsize_t indx,\n\t\t\t\t\tgnutls_sign_algorithm_t * algo);\n\n/* the name of the specified algorithms */\nconst char *\n\tgnutls_cipher_get_name(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\nconst char *\n\tgnutls_mac_get_name(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_digest_get_name(gnutls_digest_algorithm_t algorithm) __GNUTLS_CONST__;\nconst char *\n\tgnutls_digest_get_oid(gnutls_digest_algorithm_t algorithm) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_kx_get_name(gnutls_kx_algorithm_t algorithm) __GNUTLS_CONST__;\nconst char *\n\tgnutls_certificate_type_get_name(gnutls_certificate_type_t\n\t\t\t\t\t     type) __GNUTLS_CONST__;\nconst char *\n\tgnutls_pk_get_name(gnutls_pk_algorithm_t algorithm) __GNUTLS_CONST__;\nconst char *\n\tgnutls_pk_get_oid(gnutls_pk_algorithm_t algorithm) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_sign_get_name(gnutls_sign_algorithm_t algorithm) __GNUTLS_CONST__;\n\nconst char *gnutls_sign_get_oid(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;\n\nconst char *\n\tgnutls_gost_paramset_get_name(gnutls_gost_paramset_t param) __GNUTLS_CONST__;\nconst char *\n\tgnutls_gost_paramset_get_oid(gnutls_gost_paramset_t param) __GNUTLS_CONST__;\n\nsize_t\n\tgnutls_cipher_get_key_size(gnutls_cipher_algorithm_t algorithm) __GNUTLS_CONST__;\nsize_t\n\tgnutls_mac_get_key_size(gnutls_mac_algorithm_t algorithm) __GNUTLS_CONST__;\n\nunsigned gnutls_sign_is_secure(gnutls_sign_algorithm_t algorithm) __GNUTLS_CONST__;\n\n/* It is possible that a signature algorithm is ok to use for short-lived\n * data (e.g., to sign a TLS session), but not for data that are long-lived\n * like certificates. This flag is about checking the security of the algorithm\n * for long-lived data. */\n#define GNUTLS_SIGN_FLAG_SECURE_FOR_CERTS 1\nunsigned gnutls_sign_is_secure2(gnutls_sign_algorithm_t algorithm, unsigned int flags) __GNUTLS_CONST__;\n\ngnutls_digest_algorithm_t\n\tgnutls_sign_get_hash_algorithm(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;\ngnutls_pk_algorithm_t\n\tgnutls_sign_get_pk_algorithm(gnutls_sign_algorithm_t sign) __GNUTLS_CONST__;\ngnutls_sign_algorithm_t\n\tgnutls_pk_to_sign(gnutls_pk_algorithm_t pk,\n\t\t  gnutls_digest_algorithm_t hash) __GNUTLS_CONST__;\n\nunsigned\ngnutls_sign_supports_pk_algorithm(gnutls_sign_algorithm_t sign, gnutls_pk_algorithm_t pk) __GNUTLS_CONST__;\n\n#define gnutls_sign_algorithm_get_name gnutls_sign_get_name\n\ngnutls_mac_algorithm_t gnutls_mac_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_digest_algorithm_t gnutls_digest_get_id(const char *name) __GNUTLS_CONST__;\n\ngnutls_cipher_algorithm_t\n\tgnutls_cipher_get_id(const char *name) __GNUTLS_CONST__;\n\ngnutls_kx_algorithm_t\n\tgnutls_kx_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_protocol_t\n\tgnutls_protocol_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_certificate_type_t\n\tgnutls_certificate_type_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_pk_algorithm_t\n\tgnutls_pk_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_sign_algorithm_t\n\tgnutls_sign_get_id(const char *name) __GNUTLS_CONST__;\ngnutls_ecc_curve_t gnutls_ecc_curve_get_id(const char *name)  __GNUTLS_CONST__;\ngnutls_pk_algorithm_t gnutls_ecc_curve_get_pk(gnutls_ecc_curve_t curve) __GNUTLS_CONST__;\ngnutls_group_t gnutls_group_get_id(const char *name);\n\ngnutls_digest_algorithm_t\n\tgnutls_oid_to_digest(const char *oid)  __GNUTLS_CONST__;\ngnutls_mac_algorithm_t\n\tgnutls_oid_to_mac(const char *oid)  __GNUTLS_CONST__;\ngnutls_pk_algorithm_t\n\tgnutls_oid_to_pk(const char *oid) __GNUTLS_CONST__;\ngnutls_sign_algorithm_t\n\tgnutls_oid_to_sign(const char *oid) __GNUTLS_CONST__;\ngnutls_ecc_curve_t\n\tgnutls_oid_to_ecc_curve(const char *oid) __GNUTLS_CONST__;\ngnutls_gost_paramset_t\n\tgnutls_oid_to_gost_paramset(const char *oid) __GNUTLS_CONST__;\n\n  /* list supported algorithms */\nconst gnutls_ecc_curve_t *\n\tgnutls_ecc_curve_list(void)  __GNUTLS_PURE__;\nconst gnutls_group_t *\n\tgnutls_group_list(void)  __GNUTLS_PURE__;\nconst gnutls_cipher_algorithm_t *\n\tgnutls_cipher_list(void) __GNUTLS_PURE__;\nconst gnutls_mac_algorithm_t *\n\tgnutls_mac_list(void) __GNUTLS_PURE__;\nconst gnutls_digest_algorithm_t *\n\tgnutls_digest_list(void) __GNUTLS_PURE__;\nconst gnutls_protocol_t *\n\tgnutls_protocol_list(void) __GNUTLS_PURE__;\nconst gnutls_certificate_type_t *\n\tgnutls_certificate_type_list(void) __GNUTLS_PURE__;\nconst gnutls_kx_algorithm_t *\n\tgnutls_kx_list(void) __GNUTLS_PURE__;\nconst gnutls_pk_algorithm_t *\n\tgnutls_pk_list(void) __GNUTLS_PURE__;\nconst gnutls_sign_algorithm_t *\n\tgnutls_sign_list(void) __GNUTLS_PURE__;\nconst char *\n\tgnutls_cipher_suite_info(size_t idx,\n\t\t\t         unsigned char *cs_id,\n\t\t\t\t gnutls_kx_algorithm_t * kx,\n\t\t\t\t gnutls_cipher_algorithm_t * cipher,\n\t\t\t\t gnutls_mac_algorithm_t * mac,\n\t\t\t\t gnutls_protocol_t * min_version);\n\n  /* functions for run-time enablement of algorithms */\nint gnutls_ecc_curve_set_enabled(gnutls_ecc_curve_t curve,\n\t\t\t\t unsigned int enabled);\nint gnutls_sign_set_secure(gnutls_sign_algorithm_t sign, unsigned int secure);\nint gnutls_sign_set_secure_for_certs(gnutls_sign_algorithm_t sign,\n\t\t\t\t     unsigned int secure);\nint gnutls_digest_set_secure(gnutls_digest_algorithm_t dig,\n\t\t\t     unsigned int secure);\nint gnutls_protocol_set_enabled(gnutls_protocol_t version,\n\t\t\t\tunsigned int enabled);\n\n  /* error functions */\nint gnutls_error_is_fatal(int error) __GNUTLS_CONST__;\nint gnutls_error_to_alert(int err, int *level);\n\nvoid gnutls_perror(int error);\nconst char * gnutls_strerror(int error) __GNUTLS_CONST__;\nconst char * gnutls_strerror_name(int error) __GNUTLS_CONST__;\n\n/* Semi-internal functions.\n */\nvoid gnutls_handshake_set_private_extensions(gnutls_session_t session,\n\t\t\t\t\t     int allow);\nint gnutls_handshake_set_random(gnutls_session_t session,\n\t\t\t\tconst gnutls_datum_t * random);\n\ngnutls_handshake_description_t\ngnutls_handshake_get_last_out(gnutls_session_t session);\ngnutls_handshake_description_t\ngnutls_handshake_get_last_in(gnutls_session_t session);\n\n/* Record layer functions.\n */\n#define GNUTLS_HEARTBEAT_WAIT 1\nint gnutls_heartbeat_ping(gnutls_session_t session, size_t data_size,\n\t\t\t  unsigned int max_tries, unsigned int flags);\nint gnutls_heartbeat_pong(gnutls_session_t session, unsigned int flags);\n\nvoid gnutls_record_set_timeout(gnutls_session_t session, unsigned int ms);\nvoid gnutls_record_disable_padding(gnutls_session_t session);\n\nvoid gnutls_record_cork(gnutls_session_t session);\n#define GNUTLS_RECORD_WAIT 1\nint gnutls_record_uncork(gnutls_session_t session, unsigned int flags);\nsize_t gnutls_record_discard_queued(gnutls_session_t session);\n\nint\ngnutls_record_get_state(gnutls_session_t session,\n\t\t\tunsigned read,\n\t\t\tgnutls_datum_t *mac_key,\n\t\t\tgnutls_datum_t *IV,\n\t\t\tgnutls_datum_t *cipher_key,\n\t\t\tunsigned char seq_number[8]);\n\nint\ngnutls_record_set_state(gnutls_session_t session,\n\t\t\tunsigned read,\n\t\t\tconst unsigned char seq_number[8]);\n\ntypedef struct {\n\tsize_t low;\n\tsize_t high;\n} gnutls_range_st;\n\nint gnutls_range_split(gnutls_session_t session,\n\t\t       const gnutls_range_st * orig,\n\t\t       gnutls_range_st * small_range,\n\t\t       gnutls_range_st * rem_range);\n\nssize_t gnutls_record_send(gnutls_session_t session, const void *data,\n\t\t\t   size_t data_size);\nssize_t gnutls_record_send2(gnutls_session_t session, const void *data,\n\t\t\t    size_t data_size, size_t pad, unsigned flags);\nssize_t gnutls_record_send_range(gnutls_session_t session,\n\t\t\t\t const void *data, size_t data_size,\n\t\t\t\t const gnutls_range_st * range);\nssize_t gnutls_record_send_file(gnutls_session_t session, int fd,\n\t\toff_t *offset, size_t count);\nssize_t gnutls_record_recv(gnutls_session_t session, void *data,\n\t\t\t   size_t data_size);\n\ntypedef struct mbuffer_st *gnutls_packet_t;\n\nssize_t\ngnutls_record_recv_packet(gnutls_session_t session,\n\t\t\t  gnutls_packet_t *packet);\n\nvoid gnutls_packet_get(gnutls_packet_t packet, gnutls_datum_t *data, unsigned char *sequence);\nvoid gnutls_packet_deinit(gnutls_packet_t packet);\n\n#define gnutls_read gnutls_record_recv\n#define gnutls_write gnutls_record_send\nssize_t gnutls_record_recv_seq(gnutls_session_t session, void *data,\n\t\t\t       size_t data_size, unsigned char *seq);\n\nsize_t gnutls_record_overhead_size(gnutls_session_t session);\n\nsize_t\n\tgnutls_est_record_overhead_size(gnutls_protocol_t version,\n\t\t\t\t        gnutls_cipher_algorithm_t cipher,\n\t\t\t\t        gnutls_mac_algorithm_t mac,\n\t\t\t\t        gnutls_compression_method_t comp,\n\t\t\t\t        unsigned int flags) __GNUTLS_CONST__;\n\nvoid gnutls_session_enable_compatibility_mode(gnutls_session_t session);\n#define gnutls_record_set_max_empty_records(session, x)\n\nunsigned gnutls_record_can_use_length_hiding(gnutls_session_t session);\n\nint gnutls_record_get_direction(gnutls_session_t session);\n\nsize_t gnutls_record_get_max_size(gnutls_session_t session);\nssize_t gnutls_record_set_max_size(gnutls_session_t session, size_t size);\nssize_t gnutls_record_set_max_recv_size(gnutls_session_t session, size_t size);\n\nsize_t gnutls_record_check_pending(gnutls_session_t session);\nsize_t gnutls_record_check_corked(gnutls_session_t session);\n\nsize_t gnutls_record_get_max_early_data_size(gnutls_session_t session);\nint gnutls_record_set_max_early_data_size(gnutls_session_t session, size_t size);\nssize_t gnutls_record_send_early_data(gnutls_session_t session,\n\t\t\t\t      const void *data,\n\t\t\t\t      size_t length);\nssize_t gnutls_record_recv_early_data(gnutls_session_t session,\n\t\t\t\t      void *data,\n\t\t\t\t      size_t data_size);\n\nvoid gnutls_session_force_valid(gnutls_session_t session);\n\nint gnutls_prf(gnutls_session_t session,\n\t       size_t label_size, const char *label,\n\t       int server_random_first,\n\t       size_t extra_size, const char *extra,\n\t       size_t outsize, char *out);\nint gnutls_prf_rfc5705(gnutls_session_t session,\n\t       size_t label_size, const char *label,\n\t       size_t context_size, const char *context,\n\t       size_t outsize, char *out);\nint gnutls_prf_early(gnutls_session_t session,\n\t\t     size_t label_size, const char *label,\n\t\t     size_t context_size, const char *context,\n\t\t     size_t outsize, char *out);\n\nint gnutls_prf_raw(gnutls_session_t session,\n\t\t   size_t label_size, const char *label,\n\t\t   size_t seed_size, const char *seed,\n\t\t   size_t outsize, char *out);\n\n/**\n * gnutls_server_name_type_t:\n * @GNUTLS_NAME_DNS: Domain Name System name type.\n *\n * Enumeration of different server name types.\n */\ntypedef enum {\n\tGNUTLS_NAME_DNS = 1\n} gnutls_server_name_type_t;\n\nint gnutls_server_name_set(gnutls_session_t session,\n\t\t\t   gnutls_server_name_type_t type,\n\t\t\t   const void *name, size_t name_length);\n\nint gnutls_server_name_get(gnutls_session_t session,\n\t\t\t   void *data, size_t * data_length,\n\t\t\t   unsigned int *type, unsigned int indx);\n\nunsigned int gnutls_heartbeat_get_timeout(gnutls_session_t session);\nvoid gnutls_heartbeat_set_timeouts(gnutls_session_t session,\n\t\t\t\t   unsigned int retrans_timeout,\n\t\t\t\t   unsigned int total_timeout);\n\n#define GNUTLS_HB_PEER_ALLOWED_TO_SEND (1)\n#define GNUTLS_HB_PEER_NOT_ALLOWED_TO_SEND (1<<1)\n\n  /* Heartbeat */\nvoid gnutls_heartbeat_enable(gnutls_session_t session, unsigned int type);\n\n#define GNUTLS_HB_LOCAL_ALLOWED_TO_SEND (1<<2)\nunsigned gnutls_heartbeat_allowed(gnutls_session_t session, unsigned int type);\n\n  /* Safe renegotiation */\nunsigned gnutls_safe_renegotiation_status(gnutls_session_t session);\nunsigned gnutls_session_ext_master_secret_status(gnutls_session_t session);\nunsigned gnutls_session_etm_status(gnutls_session_t session);\n\n/**\n * gnutls_session_flags_t:\n * @GNUTLS_SFLAGS_SAFE_RENEGOTIATION: Safe renegotiation (RFC5746) was used\n * @GNUTLS_SFLAGS_EXT_MASTER_SECRET: The extended master secret (RFC7627) extension was used\n * @GNUTLS_SFLAGS_ETM: The encrypt then MAC (RFC7366) extension was used\n * @GNUTLS_SFLAGS_RFC7919: The RFC7919 Diffie-Hellman parameters were negotiated\n * @GNUTLS_SFLAGS_HB_LOCAL_SEND: The heartbeat negotiation allows the local side to send heartbeat messages\n * @GNUTLS_SFLAGS_HB_PEER_SEND: The heartbeat negotiation allows the peer to send heartbeat messages\n * @GNUTLS_SFLAGS_FALSE_START: False start was used in this client session.\n * @GNUTLS_SFLAGS_SESSION_TICKET: A session ticket has been received by the server.\n * @GNUTLS_SFLAGS_POST_HANDSHAKE_AUTH: Indicates client capability for post-handshake auth; set only on server side.\n * @GNUTLS_SFLAGS_EARLY_START: The TLS1.3 server session returned early.\n * @GNUTLS_SFLAGS_EARLY_DATA: The TLS1.3 early data has been received by the server.\n * @GNUTLS_SFLAGS_CLI_REQUESTED_OCSP: Set when the client has requested OCSP staple during handshake.\n * @GNUTLS_SFLAGS_SERV_REQUESTED_OCSP: Set when the server has requested OCSP staple during handshake.\n *\n * Enumeration of different session parameters.\n */\ntypedef enum {\n\tGNUTLS_SFLAGS_SAFE_RENEGOTIATION = 1,\n\tGNUTLS_SFLAGS_EXT_MASTER_SECRET = 1<<1,\n\tGNUTLS_SFLAGS_ETM = 1<<2,\n\tGNUTLS_SFLAGS_HB_LOCAL_SEND = 1<<3,\n\tGNUTLS_SFLAGS_HB_PEER_SEND = 1<<4,\n\tGNUTLS_SFLAGS_FALSE_START = 1<<5,\n\tGNUTLS_SFLAGS_RFC7919 = 1<<6,\n\tGNUTLS_SFLAGS_SESSION_TICKET = 1<<7,\n\tGNUTLS_SFLAGS_POST_HANDSHAKE_AUTH = 1<<8,\n\tGNUTLS_SFLAGS_EARLY_START = 1<<9,\n\tGNUTLS_SFLAGS_EARLY_DATA = 1<<10,\n\tGNUTLS_SFLAGS_CLI_REQUESTED_OCSP = 1<<11,\n\tGNUTLS_SFLAGS_SERV_REQUESTED_OCSP = 1<<12\n} gnutls_session_flags_t;\n\nunsigned gnutls_session_get_flags(gnutls_session_t session);\n\n/**\n * gnutls_supplemental_data_format_type_t:\n * @GNUTLS_SUPPLEMENTAL_UNKNOWN: Unknown data format\n *\n * Enumeration of different supplemental data types (RFC 4680).\n */\ntypedef enum {\n\tGNUTLS_SUPPLEMENTAL_UNKNOWN = 0,\n} gnutls_supplemental_data_format_type_t;\n\nconst char\n*gnutls_supplemental_get_name(gnutls_supplemental_data_format_type_t type);\n\n  /* SessionTicket, RFC 5077. */\nint gnutls_session_ticket_key_generate(gnutls_datum_t * key);\nint gnutls_session_ticket_enable_client(gnutls_session_t session);\nint gnutls_session_ticket_enable_server(gnutls_session_t session,\n\t\t\t\t\tconst gnutls_datum_t * key);\n\nint gnutls_session_ticket_send(gnutls_session_t session, unsigned nr, unsigned flags);\n\n  /* SRTP, RFC 5764 */\n\n/**\n * gnutls_srtp_profile_t:\n * @GNUTLS_SRTP_AES128_CM_HMAC_SHA1_80: 128 bit AES with a 80 bit HMAC-SHA1\n * @GNUTLS_SRTP_AES128_CM_HMAC_SHA1_32: 128 bit AES with a 32 bit HMAC-SHA1\n * @GNUTLS_SRTP_NULL_HMAC_SHA1_80: NULL cipher with a 80 bit HMAC-SHA1\n * @GNUTLS_SRTP_NULL_HMAC_SHA1_32: NULL cipher with a 32 bit HMAC-SHA1\n *\n * Enumeration of different SRTP protection profiles.\n */\ntypedef enum {\n\tGNUTLS_SRTP_AES128_CM_HMAC_SHA1_80 = 0x0001,\n\tGNUTLS_SRTP_AES128_CM_HMAC_SHA1_32 = 0x0002,\n\tGNUTLS_SRTP_NULL_HMAC_SHA1_80 = 0x0005,\n\tGNUTLS_SRTP_NULL_HMAC_SHA1_32 = 0x0006\n} gnutls_srtp_profile_t;\n\nint gnutls_srtp_set_profile(gnutls_session_t session,\n\t\t\t    gnutls_srtp_profile_t profile);\nint gnutls_srtp_set_profile_direct(gnutls_session_t session,\n\t\t\t\t   const char *profiles,\n\t\t\t\t   const char **err_pos);\nint gnutls_srtp_get_selected_profile(gnutls_session_t session,\n\t\t\t\t     gnutls_srtp_profile_t * profile);\n\nconst char *gnutls_srtp_get_profile_name(gnutls_srtp_profile_t profile);\nint gnutls_srtp_get_profile_id(const char *name,\n\t\t\t       gnutls_srtp_profile_t * profile);\nint gnutls_srtp_get_keys(gnutls_session_t session,\n\t\t\t void *key_material,\n\t\t\t unsigned int key_material_size,\n\t\t\t gnutls_datum_t * client_key,\n\t\t\t gnutls_datum_t * client_salt,\n\t\t\t gnutls_datum_t * server_key,\n\t\t\t gnutls_datum_t * server_salt);\n\nint gnutls_srtp_set_mki(gnutls_session_t session,\n\t\t\tconst gnutls_datum_t * mki);\nint gnutls_srtp_get_mki(gnutls_session_t session, gnutls_datum_t * mki);\n\n/* COMPRESS_CERTIFICATE extension, RFC8879 */\ngnutls_compression_method_t\ngnutls_compress_certificate_get_selected_method(gnutls_session_t session);\nint gnutls_compress_certificate_set_methods(gnutls_session_t session,\n\t\t\t\t\t    const gnutls_compression_method_t * methods,\n\t\t\t\t\t    size_t methods_len);\n\n/* ALPN TLS extension */\n\n/**\n * gnutls_alpn_flags_t:\n * @GNUTLS_ALPN_MANDATORY: Require ALPN negotiation. The connection will be\n *   aborted if no matching ALPN protocol is found.\n * @GNUTLS_ALPN_SERVER_PRECEDENCE: The choices set by the server\n *   will take precedence over the client's.\n *\n * Enumeration of different ALPN flags. These are used by gnutls_alpn_set_protocols().\n */\ntypedef enum {\n\tGNUTLS_ALPN_MANDATORY = 1,\n\tGNUTLS_ALPN_SERVER_PRECEDENCE = (1<<1)\n} gnutls_alpn_flags_t;\n\n#define GNUTLS_ALPN_MAND GNUTLS_ALPN_MANDATORY\nint gnutls_alpn_get_selected_protocol(gnutls_session_t session,\n\t\t\t\t      gnutls_datum_t * protocol);\nint gnutls_alpn_set_protocols(gnutls_session_t session,\n\t\t\t      const gnutls_datum_t * protocols,\n\t\t\t      unsigned protocols_size, unsigned flags);\n\nint gnutls_key_generate(gnutls_datum_t * key, unsigned int key_size);\n\n\n#define GNUTLS_PRIORITY_INIT_DEF_APPEND 1\nint gnutls_priority_init(gnutls_priority_t * priority_cache,\n\t\t\t const char *priorities, const char **err_pos);\nint gnutls_priority_init2(gnutls_priority_t * priority_cache,\n\t\t\t  const char *priorities, const char **err_pos,\n\t\t\t  unsigned flags);\nvoid gnutls_priority_deinit(gnutls_priority_t priority_cache);\nint gnutls_priority_get_cipher_suite_index(gnutls_priority_t pcache,\n\t\t\t\t\t   unsigned int idx,\n\t\t\t\t\t   unsigned int *sidx);\n\n#define GNUTLS_PRIORITY_LIST_INIT_KEYWORDS 1\n#define GNUTLS_PRIORITY_LIST_SPECIAL 2\nconst char *\ngnutls_priority_string_list(unsigned iter, unsigned int flags);\n\nint gnutls_priority_set(gnutls_session_t session,\n\t\t\tgnutls_priority_t priority);\n\nint gnutls_priority_set_direct(gnutls_session_t session,\n\t\t\t       const char *priorities,\n\t\t\t       const char **err_pos);\n\nint gnutls_priority_certificate_type_list(gnutls_priority_t pcache,\n\t\t\t\t\t  const unsigned int **list);\nint gnutls_priority_certificate_type_list2(gnutls_priority_t pcache,\n\t\t\t\t\t  const unsigned int **list,\n\t\t\t\t\t  gnutls_ctype_target_t target);\nint gnutls_priority_sign_list(gnutls_priority_t pcache,\n\t\t\t      const unsigned int **list);\nint gnutls_priority_protocol_list(gnutls_priority_t pcache,\n\t\t\t\t  const unsigned int **list);\nint gnutls_priority_ecc_curve_list(gnutls_priority_t pcache,\n\t\t\t\t   const unsigned int **list);\nint\ngnutls_priority_group_list(gnutls_priority_t pcache,\n\t\t\t   const unsigned int **list);\n\nint gnutls_priority_kx_list(gnutls_priority_t pcache,\n\t\t\t    const unsigned int **list);\nint gnutls_priority_cipher_list(gnutls_priority_t pcache,\n\t\t\t\tconst unsigned int **list);\nint gnutls_priority_mac_list(gnutls_priority_t pcache,\n\t\t\t     const unsigned int **list);\n\nconst char *gnutls_get_system_config_file(void);\n\nint gnutls_set_default_priority(gnutls_session_t session);\nint gnutls_set_default_priority_append(gnutls_session_t session,\n\t\t\t\t       const char *add_prio,\n\t\t\t\t       const char **err_pos,\n\t\t\t\t       unsigned flags);\n\n/* Returns the name of a cipher suite */\nconst char *\n\tgnutls_cipher_suite_get_name(gnutls_kx_algorithm_t kx_algorithm,\n\t\t\t\t     gnutls_cipher_algorithm_t cipher_algorithm,\n\t\t\t\t     gnutls_mac_algorithm_t mac_algorithm) __GNUTLS_CONST__;\n\nconst char *\ngnutls_ciphersuite_get(gnutls_session_t session) __GNUTLS_CONST__;\n\n/* get the currently used protocol version */\ngnutls_protocol_t gnutls_protocol_get_version(gnutls_session_t session);\n\nconst char *\n\tgnutls_protocol_get_name(gnutls_protocol_t version) __GNUTLS_CONST__;\n\n\n/* get/set session\n */\nint gnutls_session_set_data(gnutls_session_t session,\n\t\t\t    const void *session_data,\n\t\t\t    size_t session_data_size);\nint gnutls_session_get_data(gnutls_session_t session, void *session_data,\n\t\t\t    size_t * session_data_size);\nint gnutls_session_get_data2(gnutls_session_t session,\n\t\t\t     gnutls_datum_t * data);\nvoid gnutls_session_get_random(gnutls_session_t session,\n\t\t\t       gnutls_datum_t * client,\n\t\t\t       gnutls_datum_t * server);\n\nvoid gnutls_session_get_master_secret(gnutls_session_t session,\n\t\t\t              gnutls_datum_t * secret);\n\nchar *gnutls_session_get_desc(gnutls_session_t session);\n\ntypedef int gnutls_certificate_verify_function(gnutls_session_t);\nvoid gnutls_session_set_verify_function(gnutls_session_t session, gnutls_certificate_verify_function * func);\n\n/**\n * gnutls_vdata_types_t:\n * @GNUTLS_DT_UNKNOWN: Unknown data type.\n * @GNUTLS_DT_DNS_HOSTNAME: The data contain a null-terminated DNS hostname; the hostname will be \n *   matched using the RFC6125 rules. If the data contain a textual IP (v4 or v6) address it will\n *   be marched against the IPAddress Alternative name, unless the verification flag %GNUTLS_VERIFY_DO_NOT_ALLOW_IP_MATCHES\n *   is specified.\n * @GNUTLS_DT_IP_ADDRESS: The data contain a raw IP address (4 or 16 bytes). If will be matched\n *   against the IPAddress Alternative name; option available since 3.6.0.\n * @GNUTLS_DT_RFC822NAME: The data contain a null-terminated email address; the email will be\n *   matched against the RFC822Name Alternative name of the certificate, or the EMAIL DN component if the\n *   former isn't available. Prior to matching the email address will be converted to ACE\n *   (ASCII-compatible-encoding).\n * @GNUTLS_DT_KEY_PURPOSE_OID: The data contain a null-terminated key purpose OID. It will be matched\n *   against the certificate's Extended Key Usage extension.\n *\n * Enumeration of different typed-data options. They are used as input to certificate\n * verification functions to provide information about the name and purpose of the\n * certificate. Only a single option of a type can be provided to the relevant functions\n * (i.e., options %GNUTLS_DT_DNS_HOSTNAME, %GNUTLS_DT_IP_ADDRESS and\n * %GNUTLS_DT_RFC822NAME cannot be combined).\n */\ntypedef enum {\n\tGNUTLS_DT_UNKNOWN = 0,\n\tGNUTLS_DT_DNS_HOSTNAME = 1,\n\tGNUTLS_DT_KEY_PURPOSE_OID = 2,\n\tGNUTLS_DT_RFC822NAME = 3,\n\tGNUTLS_DT_IP_ADDRESS = 4\n} gnutls_vdata_types_t;\n\ntypedef struct {\n\tgnutls_vdata_types_t type;\n\tunsigned char *data;\n\tunsigned int size;\n} gnutls_typed_vdata_st;\n\nvoid gnutls_session_set_verify_cert(gnutls_session_t session,\n\t\t\t       const char *hostname, unsigned flags);\n\nvoid\ngnutls_session_set_verify_cert2(gnutls_session_t session,\n\t\t\t\tgnutls_typed_vdata_st * data,\n\t\t\t\tunsigned elements, unsigned flags);\n\nunsigned int gnutls_session_get_verify_cert_status(gnutls_session_t);\n\nint gnutls_session_set_premaster(gnutls_session_t session,\n\t\t\t\t unsigned int entity,\n\t\t\t\t gnutls_protocol_t version,\n\t\t\t\t gnutls_kx_algorithm_t kx,\n\t\t\t\t gnutls_cipher_algorithm_t cipher,\n\t\t\t\t gnutls_mac_algorithm_t mac,\n\t\t\t\t gnutls_compression_method_t comp,\n\t\t\t\t const gnutls_datum_t * master,\n\t\t\t\t const gnutls_datum_t * session_id);\n\n/* returns the session ID */\n#define GNUTLS_MAX_SESSION_ID 32\nint gnutls_session_get_id(gnutls_session_t session, void *session_id,\n\t\t\t  size_t * session_id_size);\nint gnutls_session_get_id2(gnutls_session_t session,\n\t\t\t   gnutls_datum_t * session_id);\n\nint gnutls_session_set_id(gnutls_session_t session,\n\t\t\t  const gnutls_datum_t * sid);\n\nint gnutls_session_channel_binding(gnutls_session_t session,\n\t\t\t\t   gnutls_channel_binding_t cbtype,\n\t\t\t\t   gnutls_datum_t * cb);\n\n/* checks if this session is a resumed one\n */\nint gnutls_session_is_resumed(gnutls_session_t session);\nint gnutls_session_resumption_requested(gnutls_session_t session);\n\ntypedef int (*gnutls_db_store_func) (void *, gnutls_datum_t key,\n\t\t\t\t     gnutls_datum_t data);\ntypedef int (*gnutls_db_remove_func) (void *, gnutls_datum_t key);\ntypedef gnutls_datum_t(*gnutls_db_retr_func) (void *, gnutls_datum_t key);\n\nvoid gnutls_db_set_cache_expiration(gnutls_session_t session, int seconds);\nunsigned gnutls_db_get_default_cache_expiration(void);\n\nvoid gnutls_db_remove_session(gnutls_session_t session);\nvoid gnutls_db_set_retrieve_function(gnutls_session_t session,\n\t\t\t\t     gnutls_db_retr_func retr_func);\nvoid gnutls_db_set_remove_function(gnutls_session_t session,\n\t\t\t\t   gnutls_db_remove_func rem_func);\nvoid gnutls_db_set_store_function(gnutls_session_t session,\n\t\t\t\t  gnutls_db_store_func store_func);\nvoid gnutls_db_set_ptr(gnutls_session_t session, void *ptr);\nvoid *gnutls_db_get_ptr(gnutls_session_t session);\nint gnutls_db_check_entry(gnutls_session_t session,\n\t\t\t  gnutls_datum_t session_entry);\ntime_t gnutls_db_check_entry_time(gnutls_datum_t * entry);\ntime_t gnutls_db_check_entry_expire_time(gnutls_datum_t * entry);\n\n  /**\n   * gnutls_handshake_hook_func:\n   * @session: the current session\n   * @htype: the type of the handshake message (%gnutls_handshake_description_t)\n   * @when: non zero if this is a post-process/generation call and zero otherwise\n   * @incoming: non zero if this is an incoming message and zero if this is an outgoing message\n   * @msg: the (const) data of the handshake message without the handshake headers.\n   *\n   * Function prototype for handshake hooks. It is set using\n   * gnutls_handshake_set_hook_function().\n   *\n   * Returns: Non zero on error.\n   */\n#define GNUTLS_HOOK_POST (1)\n#define GNUTLS_HOOK_PRE (0)\n#define GNUTLS_HOOK_BOTH (-1)\n\ntypedef int (*gnutls_handshake_hook_func) (gnutls_session_t,\n\t\t\t\t\t   unsigned int htype,\n\t\t\t\t\t   unsigned when,\n\t\t\t\t\t   unsigned int incoming,\n\t\t\t\t\t   const gnutls_datum_t *msg);\nvoid gnutls_handshake_set_hook_function(gnutls_session_t session,\n\t\t\t\t\tunsigned int htype, int when,\n\t\t\t\t\tgnutls_handshake_hook_func func);\n\n#define gnutls_handshake_post_client_hello_func gnutls_handshake_simple_hook_func\ntypedef int (*gnutls_handshake_simple_hook_func) (gnutls_session_t);\nvoid\ngnutls_handshake_set_post_client_hello_function(gnutls_session_t session,\n\t\t\t\t\t\tgnutls_handshake_simple_hook_func func);\n\nvoid gnutls_handshake_set_max_packet_length(gnutls_session_t session,\n\t\t\t\t\t    size_t max);\n\n/* returns libgnutls version (call it with a NULL argument)\n */\nconst char * gnutls_check_version(const char *req_version) __GNUTLS_CONST__;\n\n/* A macro which will allow optimizing out calls to gnutls_check_version()\n * when the version being compiled with is sufficient.\n * Used as:\n *   if (gnutls_check_version_numerc(3,3,16)) {\n */\n#define gnutls_check_version_numeric(a,b,c) \\\n\t((GNUTLS_VERSION_MAJOR >= (a)) &&  \\\n\t ((GNUTLS_VERSION_NUMBER >= ( ((a) << 16) + ((b) << 8) + (c) )) || \\\n\t gnutls_check_version(#a \".\" #b \".\" #c)))\n\n/* Functions for setting/clearing credentials\n */\nvoid gnutls_credentials_clear(gnutls_session_t session);\n\n/* cred is a structure defined by the kx algorithm\n */\nint gnutls_credentials_set(gnutls_session_t session,\n\t\t\t   gnutls_credentials_type_t type, void *cred);\nint gnutls_credentials_get(gnutls_session_t session,\n\t\t\t   gnutls_credentials_type_t type, void **cred);\n#define gnutls_cred_set\tgnutls_credentials_set\n\n/* x.509 types */\n\nstruct gnutls_pubkey_st;\ntypedef struct gnutls_pubkey_st *gnutls_pubkey_t;\n\nstruct gnutls_privkey_st;\ntypedef struct gnutls_privkey_st *gnutls_privkey_t;\n\nstruct gnutls_x509_privkey_int;\ntypedef struct gnutls_x509_privkey_int *gnutls_x509_privkey_t;\n\nstruct gnutls_x509_crl_int;\ntypedef struct gnutls_x509_crl_int *gnutls_x509_crl_t;\n\nstruct gnutls_x509_crt_int;\ntypedef struct gnutls_x509_crt_int *gnutls_x509_crt_t;\n\nstruct gnutls_x509_crq_int;\ntypedef struct gnutls_x509_crq_int *gnutls_x509_crq_t;\n\nstruct gnutls_openpgp_keyring_int;\ntypedef struct gnutls_openpgp_keyring_int *gnutls_openpgp_keyring_t;\n\n\n/* Credential structures - used in gnutls_credentials_set(); */\n\nstruct gnutls_certificate_credentials_st;\ntypedef struct gnutls_certificate_credentials_st\n*gnutls_certificate_credentials_t;\ntypedef gnutls_certificate_credentials_t\n    gnutls_certificate_server_credentials;\ntypedef gnutls_certificate_credentials_t\n    gnutls_certificate_client_credentials;\n\ntypedef struct gnutls_anon_server_credentials_st\n*gnutls_anon_server_credentials_t;\ntypedef struct gnutls_anon_client_credentials_st\n*gnutls_anon_client_credentials_t;\n\nvoid gnutls_anon_free_server_credentials(gnutls_anon_server_credentials_t\n\t\t\t\t\t sc);\nint\ngnutls_anon_allocate_server_credentials(gnutls_anon_server_credentials_t\n\t\t\t\t\t* sc);\n\nvoid gnutls_anon_set_server_dh_params(gnutls_anon_server_credentials_t res,\n\t\t\t\t      gnutls_dh_params_t dh_params);\n\nint\ngnutls_anon_set_server_known_dh_params(gnutls_anon_server_credentials_t res,\n\t\t\t\t\tgnutls_sec_param_t sec_param);\n\nvoid\ngnutls_anon_set_server_params_function(gnutls_anon_server_credentials_t\n\t\t\t\t       res, gnutls_params_function * func);\n\nvoid\ngnutls_anon_free_client_credentials(gnutls_anon_client_credentials_t sc);\nint\ngnutls_anon_allocate_client_credentials(gnutls_anon_client_credentials_t\n\t\t\t\t\t* sc);\n\n/* CERTFILE is an x509 certificate in PEM form.\n * KEYFILE is a pkcs-1 private key in PEM form (for RSA keys).\n */\nvoid\ngnutls_certificate_free_credentials(gnutls_certificate_credentials_t sc);\nint\ngnutls_certificate_allocate_credentials(gnutls_certificate_credentials_t\n\t\t\t\t\t* res);\n\nint\ngnutls_certificate_get_issuer(gnutls_certificate_credentials_t sc,\n\t\t\t      gnutls_x509_crt_t cert,\n\t\t\t      gnutls_x509_crt_t * issuer,\n\t\t\t      unsigned int flags);\n\nint gnutls_certificate_get_crt_raw(gnutls_certificate_credentials_t sc,\n\t\t\t\t   unsigned idx1, unsigned idx2,\n\t\t\t\t   gnutls_datum_t * cert);\n\nvoid gnutls_certificate_free_keys(gnutls_certificate_credentials_t sc);\nvoid gnutls_certificate_free_cas(gnutls_certificate_credentials_t sc);\nvoid gnutls_certificate_free_ca_names(gnutls_certificate_credentials_t sc);\nvoid gnutls_certificate_free_crls(gnutls_certificate_credentials_t sc);\n\nvoid gnutls_certificate_set_dh_params(gnutls_certificate_credentials_t res,\n\t\t\t\t      gnutls_dh_params_t dh_params);\n\nint gnutls_certificate_set_known_dh_params(gnutls_certificate_credentials_t res,\n\t\t\t\t\t   gnutls_sec_param_t sec_param);\nvoid gnutls_certificate_set_verify_flags(gnutls_certificate_credentials_t\n\t\t\t\t\t res, unsigned int flags);\nunsigned int\ngnutls_certificate_get_verify_flags(gnutls_certificate_credentials_t res);\n\n/**\n * gnutls_certificate_flags:\n * @GNUTLS_CERTIFICATE_SKIP_KEY_CERT_MATCH: Skip the key and certificate matching check.\n * @GNUTLS_CERTIFICATE_API_V2: If set the gnutls_certificate_set_*key* functions will return an index of the added key pair instead of zero.\n * @GNUTLS_CERTIFICATE_SKIP_OCSP_RESPONSE_CHECK: If set, the gnutls_certificate_set_ocsp_status_request_file\n *    function, will not check whether the response set matches any of the certificates.\n * @GNUTLS_CERTIFICATE_VERIFY_CRLS: This will enable CRL verification when added in the certificate structure.\n *    When used, it requires CAs to be added before CRLs.\n *\n * Enumeration of different certificate credentials flags.\n */\ntypedef enum gnutls_certificate_flags {\n\tGNUTLS_CERTIFICATE_SKIP_KEY_CERT_MATCH = 1,\n\tGNUTLS_CERTIFICATE_API_V2 = (1<<1),\n\tGNUTLS_CERTIFICATE_SKIP_OCSP_RESPONSE_CHECK = (1<<2),\n\tGNUTLS_CERTIFICATE_VERIFY_CRLS = (1<<3)\n} gnutls_certificate_flags;\n\nvoid gnutls_certificate_set_flags(gnutls_certificate_credentials_t,\n\t\t\t\t  unsigned flags);\n\nvoid gnutls_certificate_set_verify_limits(gnutls_certificate_credentials_t\n\t\t\t\t\t  res, unsigned int max_bits,\n\t\t\t\t\t  unsigned int max_depth);\n\nint\ngnutls_certificate_set_x509_system_trust(gnutls_certificate_credentials_t\n\t\t\t\t\t cred);\n\nint\ngnutls_certificate_set_x509_trust_file(gnutls_certificate_credentials_t\n\t\t\t\t       cred, const char *cafile,\n\t\t\t\t       gnutls_x509_crt_fmt_t type);\nint\ngnutls_certificate_set_x509_trust_dir(gnutls_certificate_credentials_t cred,\n\t\t\t\t      const char *ca_dir,\n\t\t\t\t      gnutls_x509_crt_fmt_t type);\n\nint gnutls_certificate_set_x509_trust_mem(gnutls_certificate_credentials_t\n\t\t\t\t\t  res, const gnutls_datum_t * ca,\n\t\t\t\t\t  gnutls_x509_crt_fmt_t type);\n\nint\ngnutls_certificate_set_x509_crl_file(gnutls_certificate_credentials_t\n\t\t\t\t     res, const char *crlfile,\n\t\t\t\t     gnutls_x509_crt_fmt_t type);\nint gnutls_certificate_set_x509_crl_mem(gnutls_certificate_credentials_t\n\t\t\t\t\tres, const gnutls_datum_t * CRL,\n\t\t\t\t\tgnutls_x509_crt_fmt_t type);\n\nint\ngnutls_certificate_set_x509_key_file(gnutls_certificate_credentials_t\n\t\t\t\t     res, const char *certfile,\n\t\t\t\t     const char *keyfile,\n\t\t\t\t     gnutls_x509_crt_fmt_t type);\n\nint\ngnutls_certificate_set_x509_key_file2(gnutls_certificate_credentials_t\n\t\t\t\t      res, const char *certfile,\n\t\t\t\t      const char *keyfile,\n\t\t\t\t      gnutls_x509_crt_fmt_t type,\n\t\t\t\t      const char *pass,\n\t\t\t\t      unsigned int flags);\n\nint gnutls_certificate_set_x509_key_mem(gnutls_certificate_credentials_t\n\t\t\t\t\tres, const gnutls_datum_t * cert,\n\t\t\t\t\tconst gnutls_datum_t * key,\n\t\t\t\t\tgnutls_x509_crt_fmt_t type);\n\nint gnutls_certificate_set_x509_key_mem2(gnutls_certificate_credentials_t\n\t\t\t\t\t res, const gnutls_datum_t * cert,\n\t\t\t\t\t const gnutls_datum_t * key,\n\t\t\t\t\t gnutls_x509_crt_fmt_t type,\n\t\t\t\t\t const char *pass,\n\t\t\t\t\t unsigned int flags);\n\nvoid gnutls_certificate_send_x509_rdn_sequence(gnutls_session_t session,\n\t\t\t\t\t       int status);\n\nint\ngnutls_certificate_set_x509_simple_pkcs12_file\n(gnutls_certificate_credentials_t res, const char *pkcs12file,\n gnutls_x509_crt_fmt_t type, const char *password);\nint\ngnutls_certificate_set_x509_simple_pkcs12_mem\n(gnutls_certificate_credentials_t res, const gnutls_datum_t * p12blob,\n gnutls_x509_crt_fmt_t type, const char *password);\n\n/* New functions to allow setting already parsed X.509 stuff.\n */\n\nint gnutls_certificate_set_x509_key(gnutls_certificate_credentials_t res,\n\t\t\t\t    gnutls_x509_crt_t * cert_list,\n\t\t\t\t    int cert_list_size,\n\t\t\t\t    gnutls_x509_privkey_t key);\nint gnutls_certificate_set_x509_trust(gnutls_certificate_credentials_t res,\n\t\t\t\t      gnutls_x509_crt_t * ca_list,\n\t\t\t\t      int ca_list_size);\nint gnutls_certificate_set_x509_crl(gnutls_certificate_credentials_t res,\n\t\t\t\t    gnutls_x509_crl_t * crl_list,\n\t\t\t\t    int crl_list_size);\n\nint gnutls_certificate_get_x509_key(gnutls_certificate_credentials_t res,\n                                    unsigned index,\n                                    gnutls_x509_privkey_t *key);\nint gnutls_certificate_get_x509_crt(gnutls_certificate_credentials_t res,\n                                    unsigned index,\n                                    gnutls_x509_crt_t **crt_list,\n                                    unsigned *crt_list_size);\n\n  /* OCSP status request extension, RFC 6066 */\ntypedef int (*gnutls_status_request_ocsp_func)\n (gnutls_session_t session, void *ptr, gnutls_datum_t *ocsp_response);\n\nvoid\ngnutls_certificate_set_ocsp_status_request_function\n(gnutls_certificate_credentials_t res,\ngnutls_status_request_ocsp_func ocsp_func, void *ptr);\n\nint\ngnutls_certificate_set_ocsp_status_request_function2\n(gnutls_certificate_credentials_t res, unsigned idx,\ngnutls_status_request_ocsp_func ocsp_func, void *ptr);\n\nint\ngnutls_certificate_set_ocsp_status_request_file\n(gnutls_certificate_credentials_t res, const char *response_file,\n unsigned idx);\n\nint\ngnutls_certificate_set_ocsp_status_request_file2\n(gnutls_certificate_credentials_t res, const char *response_file,\n unsigned idx, gnutls_x509_crt_fmt_t fmt);\n\nint\ngnutls_certificate_set_ocsp_status_request_mem\n(gnutls_certificate_credentials_t res, const gnutls_datum_t *resp,\n unsigned idx, gnutls_x509_crt_fmt_t fmt);\n\ntypedef struct gnutls_ocsp_data_st {\n\tunsigned int version; /* must be zero */\n\tgnutls_datum_t response;\n\ttime_t exptime;\n\tunsigned char padding[32];\n} gnutls_ocsp_data_st;\n\ntime_t\ngnutls_certificate_get_ocsp_expiration(gnutls_certificate_credentials_t sc,\n\t\t\t\t       unsigned idx,\n\t\t\t\t       int oidx,\n\t\t\t\t       unsigned flags);\n\nint gnutls_ocsp_status_request_enable_client(gnutls_session_t session,\n\t\t\t\t\t     gnutls_datum_t * responder_id,\n\t\t\t\t\t     size_t responder_id_size,\n\t\t\t\t\t     gnutls_datum_t *\n\t\t\t\t\t     request_extensions);\n\nint gnutls_ocsp_status_request_get(gnutls_session_t session,\n\t\t\t\t   gnutls_datum_t * response);\n\n#define GNUTLS_OCSP_SR_IS_AVAIL 1\nunsigned gnutls_ocsp_status_request_is_checked(gnutls_session_t session,\n\t\t\t\t\t       unsigned int flags);\n\nint\ngnutls_ocsp_status_request_get2(gnutls_session_t session,\n\t\t\t        unsigned idx,\n\t\t\t        gnutls_datum_t * response);\n\n/* RAW public key functions (RFC7250) */\nint gnutls_certificate_set_rawpk_key_mem(gnutls_certificate_credentials_t cred,\n\t\t\t\t    const gnutls_datum_t* spki,\n\t\t\t\t    const gnutls_datum_t* pkey,\n\t\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t\t    const char* pass,\n\t\t\t\t    unsigned int key_usage,\n\t\t\t\t    const char **names,\n\t\t\t\t    unsigned int names_length,\n\t\t\t\t    unsigned int flags);\n\nint gnutls_certificate_set_rawpk_key_file(gnutls_certificate_credentials_t cred,\n\t\t\t\t      const char* rawpkfile,\n\t\t\t\t      const char* privkeyfile,\n\t\t\t\t      gnutls_x509_crt_fmt_t format,\n\t\t\t\t      const char *pass,\n\t\t\t\t      unsigned int key_usage,\n\t\t\t\t      const char **names,\n\t\t\t\t      unsigned int names_length,\n\t\t\t\t      unsigned int privkey_flags,\n\t\t\t\t      unsigned int pkcs11_flags);\n\n\n/* global state functions\n */\nint gnutls_global_init(void);\nvoid gnutls_global_deinit(void);\n\nconst gnutls_library_config_st *gnutls_get_library_config(void);\n\n  /**\n   * gnutls_time_func:\n   * @t: where to store time.\n   *\n   * Function prototype for time()-like function.  Set with\n   * gnutls_global_set_time_function().\n   *\n   * Returns: Number of seconds since the epoch, or (time_t)-1 on errors.\n   */\ntypedef time_t(*gnutls_time_func) (time_t * t);\n\ntypedef int (*mutex_init_func) (void **mutex);\ntypedef int (*mutex_lock_func) (void **mutex);\ntypedef int (*mutex_unlock_func) (void **mutex);\ntypedef int (*mutex_deinit_func) (void **mutex);\n\nvoid gnutls_global_set_mutex(mutex_init_func init,\n\t\t\t     mutex_deinit_func deinit,\n\t\t\t     mutex_lock_func lock,\n\t\t\t     mutex_unlock_func unlock);\n\ntypedef void *(*gnutls_alloc_function) (size_t);\ntypedef void *(*gnutls_calloc_function) (size_t, size_t);\ntypedef int (*gnutls_is_secure_function) (const void *);\ntypedef void (*gnutls_free_function) (void *);\ntypedef void *(*gnutls_realloc_function) (void *, size_t);\n\nvoid gnutls_global_set_time_function(gnutls_time_func time_func);\n\n/* For use in callbacks */\nextern _SYM_EXPORT gnutls_alloc_function gnutls_malloc;\nextern _SYM_EXPORT gnutls_realloc_function gnutls_realloc;\nextern _SYM_EXPORT gnutls_calloc_function gnutls_calloc;\nextern _SYM_EXPORT gnutls_free_function gnutls_free;\n\n#ifdef GNUTLS_INTERNAL_BUILD\n#define gnutls_free(a) gnutls_free((void *) (a)), a=NULL\n#endif\n\nextern _SYM_EXPORT char *(*gnutls_strdup) (const char *);\n\n/* a variant of memset that doesn't get optimized out */\nvoid gnutls_memset(void *data, int c, size_t size);\n\n/* constant time memcmp */\nint gnutls_memcmp(const void *s1, const void *s2, size_t n);\n\ntypedef void (*gnutls_log_func) (int, const char *);\ntypedef void (*gnutls_audit_log_func) (gnutls_session_t, const char *);\nvoid gnutls_global_set_log_function(gnutls_log_func log_func);\nvoid gnutls_global_set_audit_log_function(gnutls_audit_log_func log_func);\nvoid gnutls_global_set_log_level(int level);\n\n  /**\n   * gnutls_keylog_func:\n   * @session: the current session\n   * @label: the keylog label\n   * @secret: the (const) data of the derived secret.\n   *\n   * Function prototype for keylog hooks. It is set using\n   * gnutls_session_set_keylog_function().\n   *\n   * Returns: Non zero on error.\n   * Since: 3.6.13\n   */\ntypedef int (*gnutls_keylog_func) (gnutls_session_t session,\n\t\t\t\t   const char *label,\n\t\t\t\t   const gnutls_datum_t *secret);\ngnutls_keylog_func gnutls_session_get_keylog_function(const gnutls_session_t session);\nvoid gnutls_session_set_keylog_function(gnutls_session_t session,\n\t\t\t\t\tgnutls_keylog_func func);\n\n/* Diffie-Hellman parameter handling.\n */\nint gnutls_dh_params_init(gnutls_dh_params_t * dh_params);\nvoid gnutls_dh_params_deinit(gnutls_dh_params_t dh_params);\nint gnutls_dh_params_import_raw(gnutls_dh_params_t dh_params,\n\t\t\t\tconst gnutls_datum_t * prime,\n\t\t\t\tconst gnutls_datum_t * generator);\nint gnutls_dh_params_import_dsa(gnutls_dh_params_t dh_params, gnutls_x509_privkey_t key);\nint gnutls_dh_params_import_raw2(gnutls_dh_params_t dh_params,\n\t\t\t\t const gnutls_datum_t * prime,\n\t\t\t\t const gnutls_datum_t * generator,\n\t\t\t\t unsigned key_bits);\nint gnutls_dh_params_import_raw3(gnutls_dh_params_t dh_params,\n\t\t\t\t const gnutls_datum_t * prime,\n\t\t\t\t const gnutls_datum_t * q,\n\t\t\t\t const gnutls_datum_t * generator);\nint gnutls_dh_params_import_pkcs3(gnutls_dh_params_t params,\n\t\t\t\t  const gnutls_datum_t * pkcs3_params,\n\t\t\t\t  gnutls_x509_crt_fmt_t format);\nint gnutls_dh_params_generate2(gnutls_dh_params_t params,\n\t\t\t       unsigned int bits);\nint gnutls_dh_params_export_pkcs3(gnutls_dh_params_t params,\n\t\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t\t  unsigned char *params_data,\n\t\t\t\t  size_t * params_data_size);\nint gnutls_dh_params_export2_pkcs3(gnutls_dh_params_t params,\n\t\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t\t   gnutls_datum_t * out);\nint gnutls_dh_params_export_raw(gnutls_dh_params_t params,\n\t\t\t\tgnutls_datum_t * prime,\n\t\t\t\tgnutls_datum_t * generator,\n\t\t\t\tunsigned int *bits);\nint gnutls_dh_params_cpy(gnutls_dh_params_t dst, gnutls_dh_params_t src);\n\n\n\n/* Session stuff\n */\ntypedef struct {\n    void *iov_base;\n    size_t iov_len;\n} giovec_t;\n\ntypedef ssize_t(*gnutls_pull_func) (gnutls_transport_ptr_t, void *,\n\t\t\t\t    size_t);\ntypedef ssize_t(*gnutls_push_func) (gnutls_transport_ptr_t, const void *,\n\t\t\t\t    size_t);\n\nint gnutls_system_recv_timeout(gnutls_transport_ptr_t ptr, unsigned int ms);\ntypedef int (*gnutls_pull_timeout_func) (gnutls_transport_ptr_t,\n\t\t\t\t\t unsigned int ms);\n\ntypedef ssize_t(*gnutls_vec_push_func) (gnutls_transport_ptr_t,\n\t\t\t\t\tconst giovec_t * iov, int iovcnt);\n\ntypedef int (*gnutls_errno_func) (gnutls_transport_ptr_t);\n\n#if 0\n /* This will be defined as macro. */\n  void gnutls_transport_set_int (gnutls_session_t session, int r);\n#endif\n\nvoid gnutls_transport_set_int2(gnutls_session_t session, int r, int s);\n#define gnutls_transport_set_int(s, i) gnutls_transport_set_int2(s, i, i)\n\nvoid gnutls_transport_get_int2(gnutls_session_t session, int *r, int *s);\nint gnutls_transport_get_int(gnutls_session_t session);\n\nvoid gnutls_transport_set_ptr(gnutls_session_t session,\n\t\t\t      gnutls_transport_ptr_t ptr);\nvoid gnutls_transport_set_ptr2(gnutls_session_t session,\n\t\t\t       gnutls_transport_ptr_t recv_ptr,\n\t\t\t       gnutls_transport_ptr_t send_ptr);\n\ngnutls_transport_ptr_t gnutls_transport_get_ptr(gnutls_session_t session);\nvoid gnutls_transport_get_ptr2(gnutls_session_t session,\n\t\t\t       gnutls_transport_ptr_t * recv_ptr,\n\t\t\t       gnutls_transport_ptr_t * send_ptr);\n\nvoid gnutls_transport_set_vec_push_function(gnutls_session_t session,\n\t\t\t\t\t    gnutls_vec_push_func vec_func);\nvoid gnutls_transport_set_push_function(gnutls_session_t session,\n\t\t\t\t\tgnutls_push_func push_func);\nvoid gnutls_transport_set_pull_function(gnutls_session_t session,\n\t\t\t\t\tgnutls_pull_func pull_func);\n\nvoid gnutls_transport_set_pull_timeout_function(gnutls_session_t session,\n\t\t\t\t\t\tgnutls_pull_timeout_func\n\t\t\t\t\t\tfunc);\n\nvoid gnutls_transport_set_errno_function(gnutls_session_t session,\n\t\t\t\t\t gnutls_errno_func errno_func);\n\nvoid gnutls_transport_set_errno(gnutls_session_t session, int err);\n\n/* session specific\n */\nvoid gnutls_session_set_ptr(gnutls_session_t session, void *ptr);\nvoid *gnutls_session_get_ptr(gnutls_session_t session);\n\nvoid gnutls_openpgp_send_cert(gnutls_session_t session,\n\t\t\t      gnutls_openpgp_crt_status_t status);\n\n/* This function returns the hash of the given data.\n */\nint gnutls_fingerprint(gnutls_digest_algorithm_t algo,\n\t\t       const gnutls_datum_t * data, void *result,\n\t\t       size_t * result_size);\n\n  /**\n   * gnutls_random_art_t:\n   * @GNUTLS_RANDOM_ART_OPENSSH: OpenSSH-style random art.\n   *\n   * Enumeration of different random art types.\n   */\ntypedef enum gnutls_random_art {\n\tGNUTLS_RANDOM_ART_OPENSSH = 1\n} gnutls_random_art_t;\n\nint gnutls_random_art(gnutls_random_art_t type,\n\t\t      const char *key_type, unsigned int key_size,\n\t\t      void *fpr, size_t fpr_size, gnutls_datum_t * art);\n\n/* IDNA */\n#define GNUTLS_IDNA_FORCE_2008 (1<<1)\nint gnutls_idna_map(const char * input, unsigned ilen, gnutls_datum_t *out, unsigned flags);\nint gnutls_idna_reverse_map(const char *input, unsigned ilen, gnutls_datum_t *out, unsigned flags);\n\n/* SRP\n */\n\ntypedef struct gnutls_srp_server_credentials_st\n*gnutls_srp_server_credentials_t;\ntypedef struct gnutls_srp_client_credentials_st\n*gnutls_srp_client_credentials_t;\n\nvoid\ngnutls_srp_free_client_credentials(gnutls_srp_client_credentials_t sc);\nint\ngnutls_srp_allocate_client_credentials(gnutls_srp_client_credentials_t *\n\t\t\t\t       sc);\nint gnutls_srp_set_client_credentials(gnutls_srp_client_credentials_t res,\n\t\t\t\t      const char *username,\n\t\t\t\t      const char *password);\n\nvoid\ngnutls_srp_free_server_credentials(gnutls_srp_server_credentials_t sc);\nint\ngnutls_srp_allocate_server_credentials(gnutls_srp_server_credentials_t *\n\t\t\t\t       sc);\nint gnutls_srp_set_server_credentials_file(gnutls_srp_server_credentials_t\n\t\t\t\t\t   res, const char *password_file,\n\t\t\t\t\t   const char *password_conf_file);\n\nconst char *gnutls_srp_server_get_username(gnutls_session_t session);\n\nvoid gnutls_srp_set_prime_bits(gnutls_session_t session,\n                               unsigned int bits);\n\nint gnutls_srp_verifier(const char *username,\n\t\t\tconst char *password,\n\t\t\tconst gnutls_datum_t * salt,\n\t\t\tconst gnutls_datum_t * generator,\n\t\t\tconst gnutls_datum_t * prime,\n\t\t\tgnutls_datum_t * res);\n\n/* The static parameters defined in draft-ietf-tls-srp-05\n * Those should be used as input to gnutls_srp_verifier().\n */\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_8192_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_8192_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_4096_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_4096_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_3072_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_3072_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_2048_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_2048_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1536_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1536_group_generator;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1024_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_srp_1024_group_generator;\n\n/* The static parameters defined in rfc7919\n */\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_8192_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_8192_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_8192_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_8192_key_bits;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_6144_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_6144_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_6144_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_6144_key_bits;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_4096_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_4096_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_4096_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_4096_key_bits;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_3072_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_3072_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_3072_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_3072_key_bits;\n\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_2048_group_prime;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_2048_group_q;\nextern _SYM_EXPORT const gnutls_datum_t gnutls_ffdhe_2048_group_generator;\nextern _SYM_EXPORT const unsigned int gnutls_ffdhe_2048_key_bits;\n\ntypedef int gnutls_srp_server_credentials_function(gnutls_session_t,\n\t\t\t\t\t\t   const char *username,\n\t\t\t\t\t\t   gnutls_datum_t * salt,\n\t\t\t\t\t\t   gnutls_datum_t *\n\t\t\t\t\t\t   verifier,\n\t\t\t\t\t\t   gnutls_datum_t *\n\t\t\t\t\t\t   generator,\n\t\t\t\t\t\t   gnutls_datum_t * prime);\nvoid\ngnutls_srp_set_server_credentials_function(gnutls_srp_server_credentials_t\n\t\t\t\t\t   cred,\n\t\t\t\t\t   gnutls_srp_server_credentials_function\n\t\t\t\t\t   * func);\n\ntypedef int gnutls_srp_client_credentials_function(gnutls_session_t,\n\t\t\t\t\t\t   char **, char **);\nvoid\ngnutls_srp_set_client_credentials_function(gnutls_srp_client_credentials_t\n\t\t\t\t\t   cred,\n\t\t\t\t\t   gnutls_srp_client_credentials_function\n\t\t\t\t\t   * func);\n\nint gnutls_srp_base64_encode(const gnutls_datum_t * data, char *result,\n\t\t\t     size_t * result_size);\nint gnutls_srp_base64_encode2(const gnutls_datum_t * data,\n\t\t\t\t   gnutls_datum_t * result);\n\nint gnutls_srp_base64_decode(const gnutls_datum_t * b64_data, char *result,\n\t\t\t     size_t * result_size);\nint gnutls_srp_base64_decode2(const gnutls_datum_t * b64_data,\n\t\t\t\t   gnutls_datum_t * result);\n\n#define gnutls_srp_base64_encode_alloc gnutls_srp_base64_encode2\n#define gnutls_srp_base64_decode_alloc gnutls_srp_base64_decode2\n\nvoid\ngnutls_srp_set_server_fake_salt_seed(gnutls_srp_server_credentials_t\n\t\t\t\t     sc,\n\t\t\t\t     const gnutls_datum_t * seed,\n\t\t\t\t     unsigned int salt_length);\n\n/* PSK stuff */\ntypedef struct gnutls_psk_server_credentials_st\n*gnutls_psk_server_credentials_t;\ntypedef struct gnutls_psk_client_credentials_st\n*gnutls_psk_client_credentials_t;\n\n/**\n * gnutls_psk_key_flags:\n * @GNUTLS_PSK_KEY_RAW: PSK-key in raw format.\n * @GNUTLS_PSK_KEY_HEX: PSK-key in hex format.\n *\n * Enumeration of different PSK key flags.\n */\ntypedef enum gnutls_psk_key_flags {\n\tGNUTLS_PSK_KEY_RAW = 0,\n\tGNUTLS_PSK_KEY_HEX\n} gnutls_psk_key_flags;\n\nvoid\ngnutls_psk_free_client_credentials(gnutls_psk_client_credentials_t sc);\nint\ngnutls_psk_allocate_client_credentials(gnutls_psk_client_credentials_t *\n\t\t\t\t       sc);\nint gnutls_psk_set_client_credentials(gnutls_psk_client_credentials_t res,\n\t\t\t\t      const char *username,\n\t\t\t\t      const gnutls_datum_t * key,\n\t\t\t\t      gnutls_psk_key_flags flags);\nint gnutls_psk_set_client_credentials2(gnutls_psk_client_credentials_t res,\n\t\t\t\t       const gnutls_datum_t *username,\n\t\t\t\t       const gnutls_datum_t *key,\n\t\t\t\t       gnutls_psk_key_flags flags);\n\nvoid\ngnutls_psk_free_server_credentials(gnutls_psk_server_credentials_t sc);\nint\ngnutls_psk_allocate_server_credentials(gnutls_psk_server_credentials_t *\n\t\t\t\t       sc);\nint gnutls_psk_set_server_credentials_file(gnutls_psk_server_credentials_t\n\t\t\t\t\t   res, const char *password_file);\n\nint\ngnutls_psk_set_server_credentials_hint(gnutls_psk_server_credentials_t\n\t\t\t\t       res, const char *hint);\n\nconst char *gnutls_psk_server_get_username(gnutls_session_t session);\nint gnutls_psk_server_get_username2(gnutls_session_t session,\n\t\t\t\t    gnutls_datum_t *out);\nconst char *gnutls_psk_client_get_hint(gnutls_session_t session);\n\ntypedef int gnutls_psk_server_credentials_function(gnutls_session_t,\n\t\t\t\t\t\t   const char *username,\n\t\t\t\t\t\t   gnutls_datum_t * key);\ntypedef int gnutls_psk_server_credentials_function2(gnutls_session_t,\n\t\t\t\t\t\t    const gnutls_datum_t *username,\n\t\t\t\t\t\t    gnutls_datum_t *key);\nvoid\ngnutls_psk_set_server_credentials_function(gnutls_psk_server_credentials_t\n\t\t\t\t\t   cred,\n\t\t\t\t\t   gnutls_psk_server_credentials_function\n\t\t\t\t\t   * func);\nvoid\ngnutls_psk_set_server_credentials_function2(gnutls_psk_server_credentials_t cred,\n\t\t\t\t\t    gnutls_psk_server_credentials_function2 *func);\n\ntypedef int gnutls_psk_client_credentials_function(gnutls_session_t,\n\t\t\t\t\t\t   char **username,\n\t\t\t\t\t\t   gnutls_datum_t * key);\ntypedef int gnutls_psk_client_credentials_function2(gnutls_session_t,\n\t\t\t\t\t\t    gnutls_datum_t *username,\n\t\t\t\t\t\t    gnutls_datum_t *key);\nvoid\ngnutls_psk_set_client_credentials_function(gnutls_psk_client_credentials_t\n\t\t\t\t\t   cred,\n\t\t\t\t\t   gnutls_psk_client_credentials_function\n\t\t\t\t\t   * func);\nvoid\ngnutls_psk_set_client_credentials_function2(gnutls_psk_client_credentials_t cred,\n\t\t\t\t\t    gnutls_psk_client_credentials_function2 *func);\n\nint gnutls_hex_encode(const gnutls_datum_t * data, char *result,\n\t\t      size_t * result_size);\nint gnutls_hex_decode(const gnutls_datum_t * hex_data, void *result,\n\t\t      size_t * result_size);\n\nint gnutls_hex_encode2(const gnutls_datum_t * data, gnutls_datum_t *result);\nint gnutls_hex_decode2(const gnutls_datum_t * data, gnutls_datum_t *result);\n\nvoid\ngnutls_psk_set_server_dh_params(gnutls_psk_server_credentials_t res,\n\t\t\t\tgnutls_dh_params_t dh_params);\n\nint\ngnutls_psk_set_server_known_dh_params(gnutls_psk_server_credentials_t res,\n\t\t\t\t      gnutls_sec_param_t sec_param);\n\nvoid\ngnutls_psk_set_server_params_function(gnutls_psk_server_credentials_t\n\t\t\t\t      res, gnutls_params_function * func);\n\n/**\n * gnutls_x509_subject_alt_name_t:\n * @GNUTLS_SAN_DNSNAME: DNS-name SAN.\n * @GNUTLS_SAN_RFC822NAME: E-mail address SAN.\n * @GNUTLS_SAN_URI: URI SAN.\n * @GNUTLS_SAN_IPADDRESS: IP address SAN.\n * @GNUTLS_SAN_OTHERNAME: OtherName SAN.\n * @GNUTLS_SAN_DN: DN SAN.\n * @GNUTLS_SAN_REGISTERED_ID: RegisteredID.\n * @GNUTLS_SAN_OTHERNAME_XMPP: Virtual SAN, used by certain functions for convenience.\n * @GNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL: Virtual SAN, used by certain functions for convenience.\n * @GNUTLS_SAN_OTHERNAME_MSUSERPRINCIPAL: Virtual SAN, used by certain functions for convenience.\n *\n * Enumeration of different subject alternative names types.\n */\ntypedef enum gnutls_x509_subject_alt_name_t {\n\tGNUTLS_SAN_DNSNAME = 1,\n\tGNUTLS_SAN_RFC822NAME = 2,\n\tGNUTLS_SAN_URI = 3,\n\tGNUTLS_SAN_IPADDRESS = 4,\n\tGNUTLS_SAN_OTHERNAME = 5,\n\tGNUTLS_SAN_DN = 6,\n\tGNUTLS_SAN_REGISTERED_ID = 7,\n\tGNUTLS_SAN_MAX = GNUTLS_SAN_REGISTERED_ID,\n\t/* The following are \"virtual\" subject alternative name types, in\n\t   that they are represented by an otherName value and an OID.\n\t   Used by gnutls_x509_crt_get_subject_alt_othername_oid.  */\n\tGNUTLS_SAN_OTHERNAME_XMPP = 1000,\n\tGNUTLS_SAN_OTHERNAME_KRB5PRINCIPAL,\n\tGNUTLS_SAN_OTHERNAME_MSUSERPRINCIPAL\n} gnutls_x509_subject_alt_name_t;\n\nstruct gnutls_openpgp_crt_int;\ntypedef struct gnutls_openpgp_crt_int *gnutls_openpgp_crt_t;\n\nstruct gnutls_openpgp_privkey_int;\ntypedef struct gnutls_openpgp_privkey_int *gnutls_openpgp_privkey_t;\n\nstruct gnutls_pkcs11_privkey_st;\ntypedef struct gnutls_pkcs11_privkey_st *gnutls_pkcs11_privkey_t;\n\n/**\n * gnutls_privkey_type_t:\n * @GNUTLS_PRIVKEY_X509: X.509 private key, #gnutls_x509_privkey_t.\n * @GNUTLS_PRIVKEY_OPENPGP: OpenPGP private key, #gnutls_openpgp_privkey_t.\n * @GNUTLS_PRIVKEY_PKCS11: PKCS11 private key, #gnutls_pkcs11_privkey_t.\n * @GNUTLS_PRIVKEY_EXT: External private key, operating using callbacks.\n *\n * Enumeration of different private key types.\n */\ntypedef enum {\n\tGNUTLS_PRIVKEY_X509,\n\tGNUTLS_PRIVKEY_OPENPGP,\n\tGNUTLS_PRIVKEY_PKCS11,\n\tGNUTLS_PRIVKEY_EXT\n} gnutls_privkey_type_t;\n\ntypedef struct gnutls_retr2_st {\n\tgnutls_certificate_type_t cert_type;\n\tgnutls_privkey_type_t key_type;\n\n\tunion {\n\t\tgnutls_x509_crt_t *x509;\n\t\tgnutls_openpgp_crt_t pgp;\n\t} cert;\n\tunsigned int ncerts;\t/* one for pgp keys */\n\n\tunion {\n\t\tgnutls_x509_privkey_t x509;\n\t\tgnutls_openpgp_privkey_t pgp;\n\t\tgnutls_pkcs11_privkey_t pkcs11;\n\t} key;\n\n\tunsigned int deinit_all;\t/* if non zero all keys will be deinited */\n} gnutls_retr2_st;\n\n\n  /* Functions that allow auth_info_t structures handling\n   */\n\ngnutls_credentials_type_t gnutls_auth_get_type(gnutls_session_t session);\ngnutls_credentials_type_t\ngnutls_auth_server_get_type(gnutls_session_t session);\ngnutls_credentials_type_t\ngnutls_auth_client_get_type(gnutls_session_t session);\n\n  /* DH */\n\nvoid gnutls_dh_set_prime_bits(gnutls_session_t session, unsigned int bits);\nint gnutls_dh_get_secret_bits(gnutls_session_t session);\nint gnutls_dh_get_peers_public_bits(gnutls_session_t session);\nint gnutls_dh_get_prime_bits(gnutls_session_t session);\n\nint gnutls_dh_get_group(gnutls_session_t session, gnutls_datum_t * raw_gen,\n\t\t\tgnutls_datum_t * raw_prime);\nint gnutls_dh_get_pubkey(gnutls_session_t session,\n\t\t\t gnutls_datum_t * raw_key);\n\n  /* X509PKI */\n\n\n  /* These are set on the credentials structure.\n   */\n\n  /* use gnutls_certificate_set_retrieve_function2() in abstract.h\n   * instead. It's much more efficient.\n   */\n\ntypedef int gnutls_certificate_retrieve_function(gnutls_session_t,\n\t\t\t\t\t\t const\n\t\t\t\t\t\t gnutls_datum_t *\n\t\t\t\t\t\t req_ca_rdn,\n\t\t\t\t\t\t int nreqs,\n\t\t\t\t\t\t const\n\t\t\t\t\t\t gnutls_pk_algorithm_t\n\t\t\t\t\t\t * pk_algos,\n\t\t\t\t\t\t int\n\t\t\t\t\t\t pk_algos_length,\n\t\t\t\t\t\t gnutls_retr2_st *);\n\n\nvoid\ngnutls_certificate_set_retrieve_function(gnutls_certificate_credentials_t\n\t\t\t\t\t cred,\n\t\t\t\t\t gnutls_certificate_retrieve_function\n\t\t\t\t\t * func);\n\nvoid\ngnutls_certificate_set_verify_function(gnutls_certificate_credentials_t\n\t\t\t\t       cred,\n\t\t\t\t       gnutls_certificate_verify_function\n\t\t\t\t       * func);\n\nvoid\ngnutls_certificate_server_set_request(gnutls_session_t session,\n\t\t\t\t      gnutls_certificate_request_t req);\n\n  /* get data from the session\n   */\nconst gnutls_datum_t *gnutls_certificate_get_peers(gnutls_session_t\n\t\t\t\t\t\t   session, unsigned int\n\t\t\t\t\t\t   *list_size);\nconst gnutls_datum_t *gnutls_certificate_get_ours(gnutls_session_t\n\t\t\t\t\t\t  session);\n\nint gnutls_certificate_get_peers_subkey_id(gnutls_session_t session,\n\t\t\t\t\t   gnutls_datum_t * id);\n\ntime_t gnutls_certificate_activation_time_peers(gnutls_session_t session);\ntime_t gnutls_certificate_expiration_time_peers(gnutls_session_t session);\n\nunsigned gnutls_certificate_client_get_request_status(gnutls_session_t session);\nint gnutls_certificate_verify_peers2(gnutls_session_t session,\n\t\t\t\t     unsigned int *status);\nint gnutls_certificate_verify_peers3(gnutls_session_t session,\n\t\t\t\t     const char *hostname,\n\t\t\t\t     unsigned int *status);\n\nint\ngnutls_certificate_verify_peers(gnutls_session_t session,\n\t\t\t\tgnutls_typed_vdata_st * data,\n\t\t\t\tunsigned int elements,\n\t\t\t\tunsigned int *status);\n\nint gnutls_certificate_verification_status_print(unsigned int status,\n\t\t\t\t\t\t gnutls_certificate_type_t\n\t\t\t\t\t\t type,\n\t\t\t\t\t\t gnutls_datum_t * out,\n\t\t\t\t\t\t unsigned int flags);\n\nint gnutls_pem_base64_encode(const char *msg, const gnutls_datum_t * data,\n\t\t\t     char *result, size_t * result_size);\nint gnutls_pem_base64_decode(const char *header,\n\t\t\t     const gnutls_datum_t * b64_data,\n\t\t\t     unsigned char *result, size_t * result_size);\n\nint gnutls_pem_base64_encode2(const char *msg,\n\t\t\t\t   const gnutls_datum_t * data,\n\t\t\t\t   gnutls_datum_t * result);\nint gnutls_pem_base64_decode2(const char *header,\n\t\t\t\t   const gnutls_datum_t * b64_data,\n\t\t\t\t   gnutls_datum_t * result);\n\nint gnutls_base64_encode2(const gnutls_datum_t * data,\n\t\t\t  gnutls_datum_t * result);\nint gnutls_base64_decode2(const gnutls_datum_t * b64_data,\n\t\t\t  gnutls_datum_t * result);\n\n#define gnutls_pem_base64_encode_alloc gnutls_pem_base64_encode2\n#define gnutls_pem_base64_decode_alloc gnutls_pem_base64_decode2\n\n  /* key_usage will be an OR of the following values:\n   */\n\n  /* when the key is to be used for signing: */\n#define GNUTLS_KEY_DIGITAL_SIGNATURE\t128\n#define GNUTLS_KEY_NON_REPUDIATION\t64\n  /* when the key is to be used for encryption: */\n#define GNUTLS_KEY_KEY_ENCIPHERMENT\t32\n#define GNUTLS_KEY_DATA_ENCIPHERMENT\t16\n#define GNUTLS_KEY_KEY_AGREEMENT\t8\n#define GNUTLS_KEY_KEY_CERT_SIGN\t4\n#define GNUTLS_KEY_CRL_SIGN\t\t2\n#define GNUTLS_KEY_ENCIPHER_ONLY\t1\n#define GNUTLS_KEY_DECIPHER_ONLY\t32768\n\nvoid\ngnutls_certificate_set_params_function(gnutls_certificate_credentials_t\n\t\t\t\t       res, gnutls_params_function * func);\nvoid gnutls_anon_set_params_function(gnutls_anon_server_credentials_t res,\n\t\t\t\t     gnutls_params_function * func);\nvoid gnutls_psk_set_params_function(gnutls_psk_server_credentials_t res,\n\t\t\t\t    gnutls_params_function * func);\n\nint gnutls_hex2bin(const char *hex_data, size_t hex_size,\n\t\t   void *bin_data, size_t * bin_size);\n\n  /* Trust on first use (or ssh like) functions */\n\n  /* stores the provided information to a database\n   */\ntypedef int (*gnutls_tdb_store_func) (const char *db_name,\n\t\t\t\t      const char *host,\n\t\t\t\t      const char *service,\n\t\t\t\t      time_t expiration,\n\t\t\t\t      const gnutls_datum_t * pubkey);\n\ntypedef int (*gnutls_tdb_store_commitment_func) (const char *db_name,\n\t\t\t\t\t\t const char *host,\n\t\t\t\t\t\t const char *service,\n\t\t\t\t\t\t time_t expiration,\n\t\t\t\t\t\t gnutls_digest_algorithm_t\n\t\t\t\t\t\t hash_algo,\n\t\t\t\t\t\t const gnutls_datum_t *\n\t\t\t\t\t\t hash);\n\n  /* searches for the provided host/service pair that match the\n   * provided public key in the database. */\ntypedef int (*gnutls_tdb_verify_func) (const char *db_name,\n\t\t\t\t       const char *host,\n\t\t\t\t       const char *service,\n\t\t\t\t       const gnutls_datum_t * pubkey);\n\n\nstruct gnutls_tdb_int;\ntypedef struct gnutls_tdb_int *gnutls_tdb_t;\n\nint gnutls_tdb_init(gnutls_tdb_t * tdb);\nvoid gnutls_tdb_set_store_func(gnutls_tdb_t tdb,\n\t\t\t       gnutls_tdb_store_func store);\nvoid gnutls_tdb_set_store_commitment_func(gnutls_tdb_t tdb,\n\t\t\t\t\t  gnutls_tdb_store_commitment_func\n\t\t\t\t\t  cstore);\nvoid gnutls_tdb_set_verify_func(gnutls_tdb_t tdb,\n\t\t\t\tgnutls_tdb_verify_func verify);\nvoid gnutls_tdb_deinit(gnutls_tdb_t tdb);\n\nint gnutls_verify_stored_pubkey(const char *db_name,\n\t\t\t\tgnutls_tdb_t tdb,\n\t\t\t\tconst char *host,\n\t\t\t\tconst char *service,\n\t\t\t\tgnutls_certificate_type_t cert_type,\n\t\t\t\tconst gnutls_datum_t * cert,\n\t\t\t\tunsigned int flags);\n\n#define GNUTLS_SCOMMIT_FLAG_ALLOW_BROKEN 1\nint gnutls_store_commitment(const char *db_name,\n\t\t\t    gnutls_tdb_t tdb,\n\t\t\t    const char *host,\n\t\t\t    const char *service,\n\t\t\t    gnutls_digest_algorithm_t hash_algo,\n\t\t\t    const gnutls_datum_t * hash,\n\t\t\t    time_t expiration, unsigned int flags);\n\nint gnutls_store_pubkey(const char *db_name,\n\t\t\tgnutls_tdb_t tdb,\n\t\t\tconst char *host,\n\t\t\tconst char *service,\n\t\t\tgnutls_certificate_type_t cert_type,\n\t\t\tconst gnutls_datum_t * cert,\n\t\t\ttime_t expiration, unsigned int flags);\n\n  /* Other helper functions */\nint gnutls_load_file(const char *filename, gnutls_datum_t * data);\n\nunsigned gnutls_url_is_supported(const char *url);\n\n  /* PIN callback */\n\n/**\n * gnutls_pin_flag_t:\n * @GNUTLS_PIN_USER: The PIN for the user.\n * @GNUTLS_PIN_SO: The PIN for the security officer (admin).\n * @GNUTLS_PIN_CONTEXT_SPECIFIC: The PIN is for a specific action and key like signing.\n * @GNUTLS_PIN_FINAL_TRY: This is the final try before blocking.\n * @GNUTLS_PIN_COUNT_LOW: Few tries remain before token blocks.\n * @GNUTLS_PIN_WRONG: Last given PIN was not correct.\n *\n * Enumeration of different flags that are input to the PIN function.\n */\ntypedef enum {\n\tGNUTLS_PIN_USER = (1 << 0),\n\tGNUTLS_PIN_SO = (1 << 1),\n\tGNUTLS_PIN_FINAL_TRY = (1 << 2),\n\tGNUTLS_PIN_COUNT_LOW = (1 << 3),\n\tGNUTLS_PIN_CONTEXT_SPECIFIC = (1 << 4),\n\tGNUTLS_PIN_WRONG = (1 << 5)\n} gnutls_pin_flag_t;\n\n#define GNUTLS_PKCS11_PIN_USER GNUTLS_PIN_USER\n#define GNUTLS_PKCS11_PIN_SO GNUTLS_PIN_SO\n#define GNUTLS_PKCS11_PIN_FINAL_TRY GNUTLS_PIN_FINAL_TRY\n#define GNUTLS_PKCS11_PIN_COUNT_LOW  GNUTLS_PIN_COUNT_LOW\n#define GNUTLS_PKCS11_PIN_CONTEXT_SPECIFIC GNUTLS_PIN_CONTEXT_SPECIFIC\n#define GNUTLS_PKCS11_PIN_WRONG GNUTLS_PIN_WRONG\n\n/**\n * gnutls_pin_callback_t:\n * @userdata: user-controlled data from gnutls_pkcs11_set_pin_function().\n * @attempt: pin-attempt counter, initially 0.\n * @token_url: URL of token.\n * @token_label: label of token.\n * @flags: a #gnutls_pin_flag_t flag.\n * @pin: buffer to hold PIN, of size @pin_max.\n * @pin_max: size of @pin buffer.\n *\n * Callback function type for PKCS#11 or TPM PIN entry.  It is set by\n * functions like gnutls_pkcs11_set_pin_function().\n *\n * The callback should provides the PIN code to unlock the token with\n * label @token_label, specified by the URL @token_url.\n *\n * The PIN code, as a NUL-terminated ASCII string, should be copied\n * into the @pin buffer (of maximum size @pin_max), and return 0 to\n * indicate success.  Alternatively, the callback may return a\n * negative gnutls error code to indicate failure and cancel PIN entry\n * (in which case, the contents of the @pin parameter are ignored).\n *\n * When a PIN is required, the callback will be invoked repeatedly\n * (and indefinitely) until either the returned PIN code is correct,\n * the callback returns failure, or the token refuses login (e.g. when\n * the token is locked due to too many incorrect PINs!).  For the\n * first such invocation, the @attempt counter will have value zero;\n * it will increase by one for each subsequent attempt.\n *\n * Returns: %GNUTLS_E_SUCCESS (0) on success or a negative error code on error.\n *\n * Since: 2.12.0\n **/\ntypedef int (*gnutls_pin_callback_t) (void *userdata, int attempt,\n\t\t\t\t      const char *token_url,\n\t\t\t\t      const char *token_label,\n\t\t\t\t      unsigned int flags,\n\t\t\t\t      char *pin, size_t pin_max);\n\nvoid gnutls_certificate_set_pin_function(gnutls_certificate_credentials_t,\n\t\t\t\t\t gnutls_pin_callback_t fn,\n\t\t\t\t\t void *userdata);\n\n/* Public string related functions */\ntypedef struct gnutls_buffer_st *gnutls_buffer_t;\n\nint gnutls_buffer_append_data(gnutls_buffer_t, const void *data, size_t data_size);\n\n#define GNUTLS_UTF8_IGNORE_ERRS 1\nint gnutls_utf8_password_normalize(const unsigned char *password, unsigned password_len,\n\t\t\t\t   gnutls_datum_t *out, unsigned flags);\n\n/* Public extensions related functions */\n\ntypedef void *gnutls_ext_priv_data_t;\n\nvoid gnutls_ext_set_data(gnutls_session_t session, unsigned type,\n\t\t\t gnutls_ext_priv_data_t);\nint gnutls_ext_get_data(gnutls_session_t session, unsigned type,\n\t\t\tgnutls_ext_priv_data_t *);\n\nunsigned gnutls_ext_get_current_msg(gnutls_session_t session);\n\ntypedef int (*gnutls_ext_recv_func) (gnutls_session_t session,\n\t\t\t\t     const unsigned char *data,\n\t\t\t\t     size_t len);\n\ntypedef int (*gnutls_ext_send_func) (gnutls_session_t session,\n\t\t\t\t     gnutls_buffer_t extdata);\n\ntypedef void (*gnutls_ext_deinit_data_func) (gnutls_ext_priv_data_t data);\n\ntypedef int (*gnutls_ext_pack_func) (gnutls_ext_priv_data_t data,\n\t\t\t\t     gnutls_buffer_t packed_data);\n\ntypedef int (*gnutls_ext_unpack_func) (gnutls_buffer_t packed_data,\n\t\t\t\t       gnutls_ext_priv_data_t *data);\n\n#define GNUTLS_EXT_RAW_FLAG_TLS_CLIENT_HELLO 1\n#define GNUTLS_EXT_RAW_FLAG_DTLS_CLIENT_HELLO (1<<1)\ntypedef int (*gnutls_ext_raw_process_func)(void *ctx, unsigned tls_id, const unsigned char *data, unsigned data_size);\nint gnutls_ext_raw_parse(void *ctx, gnutls_ext_raw_process_func cb,\n\t\t\t const gnutls_datum_t *data, unsigned int flags);\n\n/**\n * gnutls_ext_parse_type_t:\n * @GNUTLS_EXT_NONE: Never to be parsed\n * @GNUTLS_EXT_ANY: Any extension type (should not be used as it is used only internally).\n * @GNUTLS_EXT_VERSION_NEG: Extensions to be parsed first for TLS version negotiation.\n * @GNUTLS_EXT_MANDATORY: Parsed after @GNUTLS_EXT_VERSION_NEG and even when resuming.\n * @GNUTLS_EXT_APPLICATION: Parsed after @GNUTLS_EXT_MANDATORY\n * @GNUTLS_EXT_TLS: TLS-internal extensions, parsed after @GNUTLS_EXT_APPLICATION.\n *\n * Enumeration of different TLS extension parsing phases.  The @gnutls_ext_parse_type_t\n * indicates the time/phase an extension is parsed during Client or Server hello parsing.\n *\n */\ntypedef enum {\n  GNUTLS_EXT_ANY = 0,\n  GNUTLS_EXT_APPLICATION = 1,\n  GNUTLS_EXT_TLS = 2,\n  GNUTLS_EXT_MANDATORY = 3,\n  GNUTLS_EXT_NONE = 4,\n  GNUTLS_EXT_VERSION_NEG = 5\n} gnutls_ext_parse_type_t;\n\n/**\n * gnutls_ext_flags_t:\n * @GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL: If specified the extension registered will override the internal; this does not work with extensions existing prior to 3.6.0.\n * @GNUTLS_EXT_FLAG_CLIENT_HELLO: This extension can be present in a client hello\n * @GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO: This extension can be present in a TLS1.2 or earlier server hello\n * @GNUTLS_EXT_FLAG_TLS13_SERVER_HELLO: This extension can be present in a TLS1.3 server hello\n * @GNUTLS_EXT_FLAG_EE: This extension can be present in encrypted extensions message\n * @GNUTLS_EXT_FLAG_HRR: This extension can be present in hello retry request message\n * @GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST: When flag is present, this extension will be send even if the client didn't advertise it. An extension of this type is the Cookie TLS1.3 extension.\n * @GNUTLS_EXT_FLAG_DTLS: This extension can be present under DTLS; otherwise ignored.\n * @GNUTLS_EXT_FLAG_TLS: This extension can be present under TLS; otherwise ignored.\n *\n * Enumeration of different TLS extension registration flags.\n */\ntypedef enum {\n  GNUTLS_EXT_FLAG_OVERRIDE_INTERNAL = 1,\n  GNUTLS_EXT_FLAG_CLIENT_HELLO = (1<<1),\n  GNUTLS_EXT_FLAG_TLS12_SERVER_HELLO = (1<<2),\n  GNUTLS_EXT_FLAG_TLS13_SERVER_HELLO = (1<<3),\n  GNUTLS_EXT_FLAG_EE = (1<<4), /* ENCRYPTED */\n  GNUTLS_EXT_FLAG_HRR = (1<<5),\n  GNUTLS_EXT_FLAG_IGNORE_CLIENT_REQUEST = (1<<6),\n  GNUTLS_EXT_FLAG_TLS = (1<<7),\n  GNUTLS_EXT_FLAG_DTLS = (1<<8)\n} gnutls_ext_flags_t;\n\n/* Register a custom tls extension\n */\nint gnutls_ext_register(const char *name, int type, gnutls_ext_parse_type_t parse_point,\n\t\t\t\tgnutls_ext_recv_func recv_func, gnutls_ext_send_func send_func, \n\t\t\t\tgnutls_ext_deinit_data_func deinit_func, gnutls_ext_pack_func pack_func,\n\t\t\t\tgnutls_ext_unpack_func unpack_func);\n\nint gnutls_session_ext_register(gnutls_session_t, const char *name, int type, gnutls_ext_parse_type_t parse_point,\n\t\t\t\tgnutls_ext_recv_func recv_func, gnutls_ext_send_func send_func, \n\t\t\t\tgnutls_ext_deinit_data_func deinit_func, gnutls_ext_pack_func pack_func,\n\t\t\t\tgnutls_ext_unpack_func unpack_func, unsigned flags);\n\nconst char *gnutls_ext_get_name(unsigned int ext);\nconst char *gnutls_ext_get_name2(gnutls_session_t session, unsigned int tls_id,\n\t\t\t\t gnutls_ext_parse_type_t parse_point);\n\n/* Public supplemental data related functions */\n\ntypedef int (*gnutls_supp_recv_func) (gnutls_session_t session,\n\t\t\t       const unsigned char * data, size_t data_size);\ntypedef int (*gnutls_supp_send_func) (gnutls_session_t session,\n\t\t\t       gnutls_buffer_t buf);\n\nint gnutls_supplemental_register(const char *name,\n\t\t\t\tgnutls_supplemental_data_format_type_t type,\n\t\t\t\tgnutls_supp_recv_func supp_recv_func,\n\t\t\t\tgnutls_supp_send_func supp_send_func);\n\nint gnutls_session_supplemental_register(gnutls_session_t session, const char *name,\n\t\t\t\tgnutls_supplemental_data_format_type_t type,\n\t\t\t\tgnutls_supp_recv_func supp_recv_func,\n\t\t\t\tgnutls_supp_send_func supp_send_func,\n\t\t\t\tunsigned int flags);\n\nvoid gnutls_supplemental_recv(gnutls_session_t session, unsigned do_recv_supplemental);\n\nvoid gnutls_supplemental_send(gnutls_session_t session, unsigned do_send_supplemental);\n\n/* Anti-replay related functions */\n\ntypedef struct gnutls_anti_replay_st *gnutls_anti_replay_t;\n\nint gnutls_anti_replay_init(gnutls_anti_replay_t *anti_replay);\nvoid gnutls_anti_replay_deinit(gnutls_anti_replay_t anti_replay);\nvoid gnutls_anti_replay_set_window(gnutls_anti_replay_t anti_replay,\n\t\t\t\t   unsigned int window);\nvoid gnutls_anti_replay_enable(gnutls_session_t session,\n\t\t\t       gnutls_anti_replay_t anti_replay);\n\ntypedef int (*gnutls_db_add_func) (void *, time_t exp_time, const gnutls_datum_t *key,\n\t\t\t\t   const gnutls_datum_t *data);\n\nvoid gnutls_anti_replay_set_add_function(gnutls_anti_replay_t,\n\t\t\t\t\t gnutls_db_add_func add_func);\n\nvoid gnutls_anti_replay_set_ptr(gnutls_anti_replay_t, void *ptr);\n\n\n/**\n * gnutls_record_encryption_level_t:\n * @GNUTLS_ENCRYPTION_LEVEL_INITIAL: initial level that doesn't involve any\n *    encryption\n * @GNUTLS_ENCRYPTION_LEVEL_EARLY: early traffic secret is installed\n * @GNUTLS_ENCRYPTION_LEVEL_HANDSHAKE: handshake traffic secret is installed\n * @GNUTLS_ENCRYPTION_LEVEL_APPLICATION: application traffic secret is installed\n *\n * Enumeration of different levels of record encryption currently in place.\n * This is used by gnutls_handshake_set_read_function() and\n * gnutls_handshake_write().\n *\n * Since: 3.7.0\n */\ntypedef enum {\n\tGNUTLS_ENCRYPTION_LEVEL_INITIAL,\n\tGNUTLS_ENCRYPTION_LEVEL_EARLY,\n\tGNUTLS_ENCRYPTION_LEVEL_HANDSHAKE,\n\tGNUTLS_ENCRYPTION_LEVEL_APPLICATION\n} gnutls_record_encryption_level_t;\n\n  /**\n   * gnutls_handshake_read_func:\n   * @session: the current session\n   * @htype: the type of the handshake message (#gnutls_handshake_description_t)\n   * @level: #gnutls_record_encryption_level_t\n   * @data: the (const) data that was being sent\n   * @data_size: the size of data\n   *\n   * Function prototype for handshake intercepting hooks. It is set using\n   * gnutls_handshake_set_read_function().\n   *\n   * Returns: Non zero on error.\n   * Since: 3.7.0\n   */\ntypedef int (*gnutls_handshake_read_func) (gnutls_session_t session,\n\t\t\t\t\t   gnutls_record_encryption_level_t level,\n\t\t\t\t\t   gnutls_handshake_description_t htype,\n\t\t\t\t\t   const void *data, size_t data_size);\n\nvoid\ngnutls_handshake_set_read_function(gnutls_session_t session,\n\t\t\t\t   gnutls_handshake_read_func func);\n\nint\ngnutls_handshake_write(gnutls_session_t session,\n\t\t       gnutls_record_encryption_level_t level,\n\t\t       const void *data, size_t data_size);\n\n  /**\n   * gnutls_handshake_secret_func:\n   * @session: the current session\n   * @level: the encryption level\n   * @secret_read: the secret used for reading, can be %NULL if not set\n   * @secret_write: the secret used for writing, can be %NULL if not set\n   * @secret_size: the size of the secrets\n   *\n   * Function prototype for secret hooks. It is set using\n   * gnutls_handshake_set_secret_function().\n   *\n   * Returns: Non zero on error.\n   * Since: 3.7.0\n   */\ntypedef int (*gnutls_handshake_secret_func) (gnutls_session_t session,\n\t\t\t\t\t     gnutls_record_encryption_level_t level,\n\t\t\t\t\t     const void *secret_read,\n\t\t\t\t\t     const void *secret_write,\n\t\t\t\t\t     size_t secret_size);\n\nvoid\ngnutls_handshake_set_secret_function(gnutls_session_t session,\n\t\t\t\t     gnutls_handshake_secret_func func);\n\n  /**\n   * gnutls_alert_read_func:\n   * @session: the current session\n   * @level: #gnutls_record_encryption_level_t\n   * @alert_level: the level of the alert\n   * @alert_desc: the alert description\n   *\n   * Function prototype for alert intercepting hooks. It is set using\n   * gnutls_alert_set_read_function().\n   *\n   * Returns: Non zero on error.\n   * Since: 3.7.0\n   */\ntypedef int (*gnutls_alert_read_func) (gnutls_session_t session,\n\t\t\t\t       gnutls_record_encryption_level_t level,\n\t\t\t\t       gnutls_alert_level_t alert_level,\n\t\t\t\t       gnutls_alert_description_t alert_desc);\n\nvoid\ngnutls_alert_set_read_function(gnutls_session_t session,\n\t\t\t       gnutls_alert_read_func func);\n\n/* FIPS140-2 related functions */\nunsigned gnutls_fips140_mode_enabled(void);\n\n/**\n * gnutls_fips_mode_t:\n * @GNUTLS_FIPS140_DISABLED: The FIPS140-2 mode is disabled.\n * @GNUTLS_FIPS140_STRICT: The default mode; all forbidden operations will cause an\n *                         operation failure via error code.\n * @GNUTLS_FIPS140_LAX: The library still uses the FIPS140-2 relevant algorithms but all\n *                      forbidden by FIPS140-2 operations are allowed; this is useful when the\n *                      application is aware of the followed security policy, and needs\n *                      to utilize disallowed operations for other reasons (e.g., compatibility).\n * @GNUTLS_FIPS140_LOG: Similarly to %GNUTLS_FIPS140_LAX, it allows forbidden operations; any use of them results\n *                      to a message to the audit callback functions.\n * @GNUTLS_FIPS140_SELFTESTS: A transient state during library initialization. That state\n *\t\t\tcannot be set or seen by applications.\n *\n * Enumeration of different operational modes under FIPS140-2.\n */\ntypedef enum gnutls_fips_mode_t {\n  GNUTLS_FIPS140_DISABLED = 0,\n  GNUTLS_FIPS140_STRICT = 1,\n  GNUTLS_FIPS140_SELFTESTS = 2,\n  GNUTLS_FIPS140_LAX = 3,\n  GNUTLS_FIPS140_LOG = 4\n} gnutls_fips_mode_t;\n\n#define GNUTLS_FIPS140_SET_MODE_THREAD 1\n\nvoid gnutls_fips140_set_mode(gnutls_fips_mode_t mode, unsigned flags);\n\n#define GNUTLS_FIPS140_SET_LAX_MODE() do { \\\n\tif (gnutls_fips140_mode_enabled()) \\\n\t\tgnutls_fips140_set_mode(GNUTLS_FIPS140_LAX, GNUTLS_FIPS140_SET_MODE_THREAD); \\\n\t} while(0)\n\n#define GNUTLS_FIPS140_SET_STRICT_MODE() do { \\\n\tif (gnutls_fips140_mode_enabled()) \\\n\t\tgnutls_fips140_set_mode(GNUTLS_FIPS140_STRICT, GNUTLS_FIPS140_SET_MODE_THREAD); \\\n\t} while(0)\n\ntypedef struct gnutls_fips140_context_st *gnutls_fips140_context_t;\n\nint gnutls_fips140_context_init(gnutls_fips140_context_t *context);\nvoid gnutls_fips140_context_deinit(gnutls_fips140_context_t context);\n\n/**\n * gnutls_fips140_operation_state_t:\n * @GNUTLS_FIPS140_OP_INITIAL: no previous operation has done\n * @GNUTLS_FIPS140_OP_APPROVED: the previous operation was FIPS approved\n * @GNUTLS_FIPS140_OP_NOT_APPROVED: the previous operation was not FIPS approved\n * @GNUTLS_FIPS140_OP_ERROR: the previous operation caused an error regardless of FIPS\n *\n * The FIPS operation state set by the preceding operation.\n *\n * There are state transition rules among the enum values:\n * - When the context is attached to a thread, it will be set to reset\n *   to the %GNUTLS_FIPS140_OP_INITIAL state\n * - From the %GNUTLS_FIPS140_OP_INITIAL state, the context can\n *   transition to either %GNUTLS_FIPS140_OP_APPROVED,\n *   %GNUTLS_FIPS140_OP_NOT_APPROVED, or %GNUTLS_FIPS140_OP_ERROR\n * - From the %GNUTLS_FIPS140_OP_APPROVED state, the context can\n *   transition to %GNUTLS_FIPS140_OP_NOT_APPROVED\n * - All other transitions are prohibited.\n *\n * Since: 3.7.3\n */\ntypedef enum {\n        GNUTLS_FIPS140_OP_INITIAL,\n        GNUTLS_FIPS140_OP_APPROVED,\n        GNUTLS_FIPS140_OP_NOT_APPROVED,\n        GNUTLS_FIPS140_OP_ERROR\n} gnutls_fips140_operation_state_t;\n\ngnutls_fips140_operation_state_t\ngnutls_fips140_get_operation_state(gnutls_fips140_context_t context);\n\nint gnutls_fips140_push_context(gnutls_fips140_context_t context);\nint gnutls_fips140_pop_context(void);\n\nint gnutls_fips140_run_self_tests(void);\n\n  /* Gnutls error codes. The mapping to a TLS alert is also shown in\n   * comments.\n   */\n\n#define GNUTLS_E_SUCCESS 0\n#define\tGNUTLS_E_UNKNOWN_COMPRESSION_ALGORITHM -3\n#define\tGNUTLS_E_UNKNOWN_CIPHER_TYPE -6\n#define\tGNUTLS_E_LARGE_PACKET -7\n#define GNUTLS_E_UNSUPPORTED_VERSION_PACKET -8\t/* GNUTLS_A_PROTOCOL_VERSION */\n#define GNUTLS_E_TLS_PACKET_DECODING_ERROR GNUTLS_E_UNEXPECTED_PACKET_LENGTH\n#define GNUTLS_E_UNEXPECTED_PACKET_LENGTH -9\t/* GNUTLS_A_DECODE_ERROR */\n#define GNUTLS_E_INVALID_SESSION -10\n#define GNUTLS_E_FATAL_ALERT_RECEIVED -12\n#define GNUTLS_E_UNEXPECTED_PACKET -15\t/* GNUTLS_A_UNEXPECTED_MESSAGE */\n#define GNUTLS_E_WARNING_ALERT_RECEIVED -16\n#define GNUTLS_E_ERROR_IN_FINISHED_PACKET -18\n#define GNUTLS_E_UNEXPECTED_HANDSHAKE_PACKET -19\n#define\tGNUTLS_E_UNKNOWN_CIPHER_SUITE -21\t/* GNUTLS_A_HANDSHAKE_FAILURE */\n#define\tGNUTLS_E_UNWANTED_ALGORITHM -22\n#define\tGNUTLS_E_MPI_SCAN_FAILED -23\n#define GNUTLS_E_DECRYPTION_FAILED -24\t/* GNUTLS_A_DECRYPTION_FAILED, GNUTLS_A_BAD_RECORD_MAC */\n#define GNUTLS_E_MEMORY_ERROR -25\n#define GNUTLS_E_DECOMPRESSION_FAILED -26\t/* GNUTLS_A_DECOMPRESSION_FAILURE */\n#define GNUTLS_E_COMPRESSION_FAILED -27\n#define GNUTLS_E_AGAIN -28\n#define GNUTLS_E_EXPIRED -29\n#define GNUTLS_E_DB_ERROR -30\n#define GNUTLS_E_SRP_PWD_ERROR GNUTLS_E_KEYFILE_ERROR\n#define GNUTLS_E_KEYFILE_ERROR -31\n#define GNUTLS_E_INSUFFICIENT_CREDENTIALS -32\n#define GNUTLS_E_INSUFICIENT_CREDENTIALS GNUTLS_E_INSUFFICIENT_CREDENTIALS\t/* for backwards compatibility only */\n#define GNUTLS_E_INSUFFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS\n#define GNUTLS_E_INSUFICIENT_CRED GNUTLS_E_INSUFFICIENT_CREDENTIALS\t/* for backwards compatibility only */\n\n#define GNUTLS_E_HASH_FAILED -33\n#define GNUTLS_E_BASE64_DECODING_ERROR -34\n\n#define\tGNUTLS_E_MPI_PRINT_FAILED -35\n#define GNUTLS_E_REHANDSHAKE -37\t/* GNUTLS_A_NO_RENEGOTIATION */\n#define GNUTLS_E_GOT_APPLICATION_DATA -38\n#define GNUTLS_E_RECORD_LIMIT_REACHED -39\n#define GNUTLS_E_ENCRYPTION_FAILED -40\n\n#define GNUTLS_E_PK_ENCRYPTION_FAILED -44\n#define GNUTLS_E_PK_DECRYPTION_FAILED -45\n#define GNUTLS_E_PK_SIGN_FAILED -46\n#define GNUTLS_E_X509_UNSUPPORTED_CRITICAL_EXTENSION -47\n#define GNUTLS_E_KEY_USAGE_VIOLATION -48\n#define GNUTLS_E_NO_CERTIFICATE_FOUND -49\t/* GNUTLS_A_BAD_CERTIFICATE */\n#define GNUTLS_E_INVALID_REQUEST -50\n#define GNUTLS_E_SHORT_MEMORY_BUFFER -51\n#define GNUTLS_E_INTERRUPTED -52\n#define GNUTLS_E_PUSH_ERROR -53\n#define GNUTLS_E_PULL_ERROR -54\n#define GNUTLS_E_RECEIVED_ILLEGAL_PARAMETER -55\t/* GNUTLS_A_ILLEGAL_PARAMETER */\n#define GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE -56\n#define GNUTLS_E_PKCS1_WRONG_PAD -57\n#define GNUTLS_E_RECEIVED_ILLEGAL_EXTENSION -58\n#define GNUTLS_E_INTERNAL_ERROR -59\n#define GNUTLS_E_DH_PRIME_UNACCEPTABLE -63\n#define GNUTLS_E_FILE_ERROR -64\n#define GNUTLS_E_TOO_MANY_EMPTY_PACKETS -78\n#define GNUTLS_E_UNKNOWN_PK_ALGORITHM -80\n#define GNUTLS_E_TOO_MANY_HANDSHAKE_PACKETS -81\n#define GNUTLS_E_RECEIVED_DISALLOWED_NAME -82 /* GNUTLS_A_ILLEGAL_PARAMETER */\n#define GNUTLS_E_CERTIFICATE_REQUIRED -112 /* GNUTLS_A_CERTIFICATE_REQUIRED */\n\n  /* returned if you need to generate temporary RSA\n   * parameters. These are needed for export cipher suites.\n   */\n#define GNUTLS_E_NO_TEMPORARY_RSA_PARAMS -84\n\n#define GNUTLS_E_NO_COMPRESSION_ALGORITHMS -86\n#define GNUTLS_E_NO_CIPHER_SUITES -87\n\n#define GNUTLS_E_OPENPGP_GETKEY_FAILED -88\n#define GNUTLS_E_PK_SIG_VERIFY_FAILED -89\n\n#define GNUTLS_E_ILLEGAL_SRP_USERNAME -90\n#define GNUTLS_E_SRP_PWD_PARSING_ERROR GNUTLS_E_KEYFILE_PARSING_ERROR\n#define GNUTLS_E_KEYFILE_PARSING_ERROR -91\n#define GNUTLS_E_NO_TEMPORARY_DH_PARAMS -93\n\n  /* For certificate and key stuff\n   */\n#define GNUTLS_E_ASN1_ELEMENT_NOT_FOUND -67\n#define GNUTLS_E_ASN1_IDENTIFIER_NOT_FOUND -68\n#define GNUTLS_E_ASN1_DER_ERROR -69\n#define GNUTLS_E_ASN1_VALUE_NOT_FOUND -70\n#define GNUTLS_E_ASN1_GENERIC_ERROR -71\n#define GNUTLS_E_ASN1_VALUE_NOT_VALID -72\n#define GNUTLS_E_ASN1_TAG_ERROR -73\n#define GNUTLS_E_ASN1_TAG_IMPLICIT -74\n#define GNUTLS_E_ASN1_TYPE_ANY_ERROR -75\n#define GNUTLS_E_ASN1_SYNTAX_ERROR -76\n#define GNUTLS_E_ASN1_DER_OVERFLOW -77\n#define GNUTLS_E_OPENPGP_UID_REVOKED -79\n#define GNUTLS_E_CERTIFICATE_ERROR -43\n#define GNUTLS_E_X509_CERTIFICATE_ERROR GNUTLS_E_CERTIFICATE_ERROR\n#define GNUTLS_E_CERTIFICATE_KEY_MISMATCH -60\n#define GNUTLS_E_UNSUPPORTED_CERTIFICATE_TYPE -61\t/* GNUTLS_A_UNSUPPORTED_CERTIFICATE */\n#define GNUTLS_E_X509_UNKNOWN_SAN -62\n#define GNUTLS_E_OPENPGP_FINGERPRINT_UNSUPPORTED -94\n#define GNUTLS_E_X509_UNSUPPORTED_ATTRIBUTE -95\n#define GNUTLS_E_UNKNOWN_HASH_ALGORITHM -96\n#define GNUTLS_E_UNKNOWN_PKCS_CONTENT_TYPE -97\n#define GNUTLS_E_UNKNOWN_PKCS_BAG_TYPE -98\n#define GNUTLS_E_INVALID_PASSWORD -99\n#define GNUTLS_E_MAC_VERIFY_FAILED -100\t/* for PKCS #12 MAC */\n#define GNUTLS_E_CONSTRAINT_ERROR -101\n\n#define GNUTLS_E_WARNING_IA_IPHF_RECEIVED -102\n#define GNUTLS_E_WARNING_IA_FPHF_RECEIVED -103\n\n#define GNUTLS_E_IA_VERIFY_FAILED -104\n#define GNUTLS_E_UNKNOWN_ALGORITHM -105\n#define GNUTLS_E_UNSUPPORTED_SIGNATURE_ALGORITHM -106\n#define GNUTLS_E_SAFE_RENEGOTIATION_FAILED -107\n#define GNUTLS_E_UNSAFE_RENEGOTIATION_DENIED -108\n#define GNUTLS_E_UNKNOWN_SRP_USERNAME -109\n#define GNUTLS_E_PREMATURE_TERMINATION -110\n\n#define GNUTLS_E_MALFORMED_CIDR -111\n\n#define GNUTLS_E_BASE64_ENCODING_ERROR -201\n#define GNUTLS_E_INCOMPATIBLE_GCRYPT_LIBRARY -202\t/* obsolete */\n#define GNUTLS_E_INCOMPATIBLE_CRYPTO_LIBRARY -202\n#define GNUTLS_E_INCOMPATIBLE_LIBTASN1_LIBRARY -203\n\n#define GNUTLS_E_OPENPGP_KEYRING_ERROR -204\n#define GNUTLS_E_X509_UNSUPPORTED_OID -205\n\n#define GNUTLS_E_RANDOM_FAILED -206\n#define GNUTLS_E_BASE64_UNEXPECTED_HEADER_ERROR -207\n\n#define GNUTLS_E_OPENPGP_SUBKEY_ERROR -208\n\n#define GNUTLS_E_CRYPTO_ALREADY_REGISTERED GNUTLS_E_ALREADY_REGISTERED\n#define GNUTLS_E_ALREADY_REGISTERED -209\n\n#define GNUTLS_E_HANDSHAKE_TOO_LARGE -210\n\n#define GNUTLS_E_CRYPTODEV_IOCTL_ERROR -211\n#define GNUTLS_E_CRYPTODEV_DEVICE_ERROR -212\n\n#define GNUTLS_E_CHANNEL_BINDING_NOT_AVAILABLE -213\n#define GNUTLS_E_BAD_COOKIE -214\n#define GNUTLS_E_OPENPGP_PREFERRED_KEY_ERROR -215\n#define GNUTLS_E_INCOMPAT_DSA_KEY_WITH_TLS_PROTOCOL -216\n#define GNUTLS_E_INSUFFICIENT_SECURITY -217\n\n#define GNUTLS_E_HEARTBEAT_PONG_RECEIVED -292\n#define GNUTLS_E_HEARTBEAT_PING_RECEIVED -293\n\n#define GNUTLS_E_UNRECOGNIZED_NAME -294\n\n/* PKCS11 related */\n#define GNUTLS_E_PKCS11_ERROR -300\n#define GNUTLS_E_PKCS11_LOAD_ERROR -301\n#define GNUTLS_E_PARSING_ERROR -302\n#define GNUTLS_E_PKCS11_PIN_ERROR -303\n\n#define GNUTLS_E_PKCS11_SLOT_ERROR -305\n#define GNUTLS_E_LOCKING_ERROR -306\n#define GNUTLS_E_PKCS11_ATTRIBUTE_ERROR -307\n#define GNUTLS_E_PKCS11_DEVICE_ERROR -308\n#define GNUTLS_E_PKCS11_DATA_ERROR -309\n#define GNUTLS_E_PKCS11_UNSUPPORTED_FEATURE_ERROR -310\n#define GNUTLS_E_PKCS11_KEY_ERROR -311\n#define GNUTLS_E_PKCS11_PIN_EXPIRED -312\n#define GNUTLS_E_PKCS11_PIN_LOCKED -313\n#define GNUTLS_E_PKCS11_SESSION_ERROR -314\n#define GNUTLS_E_PKCS11_SIGNATURE_ERROR -315\n#define GNUTLS_E_PKCS11_TOKEN_ERROR -316\n#define GNUTLS_E_PKCS11_USER_ERROR -317\n\n#define GNUTLS_E_CRYPTO_INIT_FAILED -318\n#define GNUTLS_E_TIMEDOUT -319\n#define GNUTLS_E_USER_ERROR -320\n#define GNUTLS_E_ECC_NO_SUPPORTED_CURVES -321\n#define GNUTLS_E_ECC_UNSUPPORTED_CURVE -322\n#define GNUTLS_E_PKCS11_REQUESTED_OBJECT_NOT_AVAILBLE -323\n#define GNUTLS_E_CERTIFICATE_LIST_UNSORTED -324\n#define GNUTLS_E_ILLEGAL_PARAMETER -325 /* GNUTLS_A_ILLEGAL_PARAMETER */\n#define GNUTLS_E_NO_PRIORITIES_WERE_SET -326\n#define GNUTLS_E_X509_UNSUPPORTED_EXTENSION -327\n#define GNUTLS_E_SESSION_EOF -328\n\n#define GNUTLS_E_TPM_ERROR -329\n#define GNUTLS_E_TPM_KEY_PASSWORD_ERROR -330\n#define GNUTLS_E_TPM_SRK_PASSWORD_ERROR -331\n#define GNUTLS_E_TPM_SESSION_ERROR -332\n#define GNUTLS_E_TPM_KEY_NOT_FOUND -333\n#define GNUTLS_E_TPM_UNINITIALIZED -334\n#define GNUTLS_E_TPM_NO_LIB -335\n\n#define GNUTLS_E_NO_CERTIFICATE_STATUS -340\n#define GNUTLS_E_OCSP_RESPONSE_ERROR -341\n#define GNUTLS_E_RANDOM_DEVICE_ERROR -342\n#define GNUTLS_E_AUTH_ERROR -343\n#define GNUTLS_E_NO_APPLICATION_PROTOCOL -344\n#define GNUTLS_E_SOCKETS_INIT_ERROR -345\n#define GNUTLS_E_KEY_IMPORT_FAILED -346\n#define GNUTLS_E_INAPPROPRIATE_FALLBACK -347 /*GNUTLS_A_INAPPROPRIATE_FALLBACK*/\n#define GNUTLS_E_CERTIFICATE_VERIFICATION_ERROR -348\n#define GNUTLS_E_PRIVKEY_VERIFICATION_ERROR -349\n#define GNUTLS_E_UNEXPECTED_EXTENSIONS_LENGTH -350 /*GNUTLS_A_DECODE_ERROR*/\n#define GNUTLS_E_ASN1_EMBEDDED_NULL_IN_STRING -351\n\n#define GNUTLS_E_SELF_TEST_ERROR -400\n#define GNUTLS_E_NO_SELF_TEST -401\n#define GNUTLS_E_LIB_IN_ERROR_STATE -402\n#define GNUTLS_E_PK_GENERATION_ERROR -403\n#define GNUTLS_E_IDNA_ERROR -404\n\n#define GNUTLS_E_NEED_FALLBACK -405\n#define GNUTLS_E_SESSION_USER_ID_CHANGED -406\n#define GNUTLS_E_HANDSHAKE_DURING_FALSE_START -407\n#define GNUTLS_E_UNAVAILABLE_DURING_HANDSHAKE -408\n#define GNUTLS_E_PK_INVALID_PUBKEY -409\n#define GNUTLS_E_PK_INVALID_PRIVKEY -410\n#define GNUTLS_E_NOT_YET_ACTIVATED -411\n#define GNUTLS_E_INVALID_UTF8_STRING -412\n#define GNUTLS_E_NO_EMBEDDED_DATA -413\n#define GNUTLS_E_INVALID_UTF8_EMAIL -414\n#define GNUTLS_E_INVALID_PASSWORD_STRING -415\n#define GNUTLS_E_CERTIFICATE_TIME_ERROR -416\n#define GNUTLS_E_RECORD_OVERFLOW -417\t/* GNUTLS_A_RECORD_OVERFLOW */\n#define GNUTLS_E_ASN1_TIME_ERROR -418\n#define GNUTLS_E_INCOMPATIBLE_SIG_WITH_KEY -419\n#define GNUTLS_E_PK_INVALID_PUBKEY_PARAMS -420\n#define GNUTLS_E_PK_NO_VALIDATION_PARAMS -421\n#define GNUTLS_E_OCSP_MISMATCH_WITH_CERTS -422\n\n#define GNUTLS_E_NO_COMMON_KEY_SHARE -423\n#define GNUTLS_E_REAUTH_REQUEST -424\n#define GNUTLS_E_TOO_MANY_MATCHES -425\n#define GNUTLS_E_CRL_VERIFICATION_ERROR -426\n#define GNUTLS_E_MISSING_EXTENSION -427\n#define GNUTLS_E_DB_ENTRY_EXISTS -428\n#define GNUTLS_E_EARLY_DATA_REJECTED -429\n#define GNUTLS_E_X509_DUPLICATE_EXTENSION -430\n\n#define GNUTLS_E_UNIMPLEMENTED_FEATURE -1250\n\n/* Internal errors of the library; will never be returned\n * to a calling application */\n#define GNUTLS_E_INT_RET_0 -1251\n#define GNUTLS_E_INT_CHECK_AGAIN -1252\n\n#define GNUTLS_E_APPLICATION_ERROR_MAX -65000\n#define GNUTLS_E_APPLICATION_ERROR_MIN -65500\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#include <gnutls/compat.h>\n\n#endif /* GNUTLS_GNUTLS_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/ocsp.h",
    "content": "/*\n * Copyright (C) 2011-2012 Free Software Foundation, Inc.\n *\n * Author: Simon Josefsson\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* Online Certificate Status Protocol - RFC 2560\n */\n\n#ifndef GNUTLS_OCSP_H\n#define GNUTLS_OCSP_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#define GNUTLS_OCSP_NONCE \"1.3.6.1.5.5.7.48.1.2\"\n\n/**\n * gnutls_ocsp_print_formats_t:\n * @GNUTLS_OCSP_PRINT_FULL: Full information about OCSP request/response.\n * @GNUTLS_OCSP_PRINT_COMPACT: More compact information about OCSP request/response.\n *\n * Enumeration of different OCSP printing variants.\n */\ntypedef enum gnutls_ocsp_print_formats_t {\n\tGNUTLS_OCSP_PRINT_FULL = 0,\n\tGNUTLS_OCSP_PRINT_COMPACT = 1\n} gnutls_ocsp_print_formats_t;\n\n/**\n * gnutls_ocsp_resp_status_t:\n * @GNUTLS_OCSP_RESP_SUCCESSFUL: Response has valid confirmations.\n * @GNUTLS_OCSP_RESP_MALFORMEDREQUEST: Illegal confirmation request\n * @GNUTLS_OCSP_RESP_INTERNALERROR: Internal error in issuer\n * @GNUTLS_OCSP_RESP_TRYLATER: Try again later\n * @GNUTLS_OCSP_RESP_SIGREQUIRED: Must sign the request\n * @GNUTLS_OCSP_RESP_UNAUTHORIZED: Request unauthorized\n *\n * Enumeration of different OCSP response status codes.\n */\ntypedef enum gnutls_ocsp_resp_status_t {\n\tGNUTLS_OCSP_RESP_SUCCESSFUL = 0,\n\tGNUTLS_OCSP_RESP_MALFORMEDREQUEST = 1,\n\tGNUTLS_OCSP_RESP_INTERNALERROR = 2,\n\tGNUTLS_OCSP_RESP_TRYLATER = 3,\n\tGNUTLS_OCSP_RESP_SIGREQUIRED = 5,\n\tGNUTLS_OCSP_RESP_UNAUTHORIZED = 6\n} gnutls_ocsp_resp_status_t;\n\n/**\n * gnutls_ocsp_cert_status_t:\n * @GNUTLS_OCSP_CERT_GOOD: Positive response to status inquiry.\n * @GNUTLS_OCSP_CERT_REVOKED: Certificate has been revoked.\n * @GNUTLS_OCSP_CERT_UNKNOWN: The responder doesn't know about the\n *   certificate.\n *\n * Enumeration of different OCSP response certificate status codes.\n */\ntypedef enum gnutls_ocsp_cert_status_t {\n\tGNUTLS_OCSP_CERT_GOOD = 0,\n\tGNUTLS_OCSP_CERT_REVOKED = 1,\n\tGNUTLS_OCSP_CERT_UNKNOWN = 2\n} gnutls_ocsp_cert_status_t;\n\n/**\n * gnutls_x509_crl_reason_t:\n * @GNUTLS_X509_CRLREASON_UNSPECIFIED: Unspecified reason.\n * @GNUTLS_X509_CRLREASON_KEYCOMPROMISE: Private key compromised.\n * @GNUTLS_X509_CRLREASON_CACOMPROMISE: CA compromised.\n * @GNUTLS_X509_CRLREASON_AFFILIATIONCHANGED: Affiliation has changed.\n * @GNUTLS_X509_CRLREASON_SUPERSEDED: Certificate superseded.\n * @GNUTLS_X509_CRLREASON_CESSATIONOFOPERATION: Operation has ceased.\n * @GNUTLS_X509_CRLREASON_CERTIFICATEHOLD: Certificate is on hold.\n * @GNUTLS_X509_CRLREASON_REMOVEFROMCRL: Will be removed from delta CRL.\n * @GNUTLS_X509_CRLREASON_PRIVILEGEWITHDRAWN: Privilege withdrawn.\n * @GNUTLS_X509_CRLREASON_AACOMPROMISE: AA compromised.\n *\n * Enumeration of different reason codes.  Note that this\n * corresponds to the CRLReason ASN.1 enumeration type, and not the\n * ReasonFlags ASN.1 bit string.\n */\ntypedef enum gnutls_x509_crl_reason_t {\n\tGNUTLS_X509_CRLREASON_UNSPECIFIED = 0,\n\tGNUTLS_X509_CRLREASON_KEYCOMPROMISE = 1,\n\tGNUTLS_X509_CRLREASON_CACOMPROMISE = 2,\n\tGNUTLS_X509_CRLREASON_AFFILIATIONCHANGED = 3,\n\tGNUTLS_X509_CRLREASON_SUPERSEDED = 4,\n\tGNUTLS_X509_CRLREASON_CESSATIONOFOPERATION = 5,\n\tGNUTLS_X509_CRLREASON_CERTIFICATEHOLD = 6,\n\tGNUTLS_X509_CRLREASON_REMOVEFROMCRL = 8,\n\tGNUTLS_X509_CRLREASON_PRIVILEGEWITHDRAWN = 9,\n\tGNUTLS_X509_CRLREASON_AACOMPROMISE = 10\n} gnutls_x509_crl_reason_t;\n\n/* When adding a verify failure reason update:\n * _gnutls_ocsp_verify_status_to_str()\n */\n/**\n * gnutls_ocsp_verify_reason_t:\n * @GNUTLS_OCSP_VERIFY_SIGNER_NOT_FOUND: Signer cert not found.\n * @GNUTLS_OCSP_VERIFY_SIGNER_KEYUSAGE_ERROR: Signer keyusage bits incorrect.\n * @GNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER: Signer is not trusted.\n * @GNUTLS_OCSP_VERIFY_INSECURE_ALGORITHM: Signature using insecure algorithm.\n * @GNUTLS_OCSP_VERIFY_SIGNATURE_FAILURE: Signature mismatch.\n * @GNUTLS_OCSP_VERIFY_CERT_NOT_ACTIVATED: Signer cert is not yet activated.\n * @GNUTLS_OCSP_VERIFY_CERT_EXPIRED: Signer cert has expired.\n *\n * Enumeration of OCSP verify status codes, used by\n * gnutls_ocsp_resp_verify() and gnutls_ocsp_resp_verify_direct().\n */\ntypedef enum gnutls_ocsp_verify_reason_t {\n\tGNUTLS_OCSP_VERIFY_SIGNER_NOT_FOUND = 1,\n\tGNUTLS_OCSP_VERIFY_SIGNER_KEYUSAGE_ERROR = 2,\n\tGNUTLS_OCSP_VERIFY_UNTRUSTED_SIGNER = 4,\n\tGNUTLS_OCSP_VERIFY_INSECURE_ALGORITHM = 8,\n\tGNUTLS_OCSP_VERIFY_SIGNATURE_FAILURE = 16,\n\tGNUTLS_OCSP_VERIFY_CERT_NOT_ACTIVATED = 32,\n\tGNUTLS_OCSP_VERIFY_CERT_EXPIRED = 64\n} gnutls_ocsp_verify_reason_t;\n\nstruct gnutls_ocsp_req_int;\ntypedef struct gnutls_ocsp_req_int *gnutls_ocsp_req_t;\ntypedef const struct gnutls_ocsp_req_int *gnutls_ocsp_req_const_t;\n\nint gnutls_ocsp_req_init(gnutls_ocsp_req_t * req);\nvoid gnutls_ocsp_req_deinit(gnutls_ocsp_req_t req);\n\nint gnutls_ocsp_req_import(gnutls_ocsp_req_t req,\n\t\t\t   const gnutls_datum_t * data);\nint gnutls_ocsp_req_export(gnutls_ocsp_req_const_t req, gnutls_datum_t * data);\nint gnutls_ocsp_req_print(gnutls_ocsp_req_const_t req,\n\t\t\t  gnutls_ocsp_print_formats_t format,\n\t\t\t  gnutls_datum_t * out);\n\nint gnutls_ocsp_req_get_version(gnutls_ocsp_req_const_t req);\n\nint gnutls_ocsp_req_get_cert_id(gnutls_ocsp_req_const_t req,\n\t\t\t\tunsigned indx,\n\t\t\t\tgnutls_digest_algorithm_t * digest,\n\t\t\t\tgnutls_datum_t * issuer_name_hash,\n\t\t\t\tgnutls_datum_t * issuer_key_hash,\n\t\t\t\tgnutls_datum_t * serial_number);\nint gnutls_ocsp_req_add_cert_id(gnutls_ocsp_req_t req,\n\t\t\t\tgnutls_digest_algorithm_t digest,\n\t\t\t\tconst gnutls_datum_t *\n\t\t\t\tissuer_name_hash,\n\t\t\t\tconst gnutls_datum_t *\n\t\t\t\tissuer_key_hash,\n\t\t\t\tconst gnutls_datum_t * serial_number);\nint gnutls_ocsp_req_add_cert(gnutls_ocsp_req_t req,\n\t\t\t     gnutls_digest_algorithm_t digest,\n\t\t\t     gnutls_x509_crt_t issuer,\n\t\t\t     gnutls_x509_crt_t cert);\n\nint gnutls_ocsp_req_get_extension(gnutls_ocsp_req_const_t req,\n\t\t\t\t  unsigned indx,\n\t\t\t\t  gnutls_datum_t * oid,\n\t\t\t\t  unsigned int *critical,\n\t\t\t\t  gnutls_datum_t * data);\nint gnutls_ocsp_req_set_extension(gnutls_ocsp_req_t req,\n\t\t\t\t  const char *oid,\n\t\t\t\t  unsigned int critical,\n\t\t\t\t  const gnutls_datum_t * data);\n\nint gnutls_ocsp_req_get_nonce(gnutls_ocsp_req_const_t req,\n\t\t\t      unsigned int *critical,\n\t\t\t      gnutls_datum_t * nonce);\nint gnutls_ocsp_req_set_nonce(gnutls_ocsp_req_t req,\n\t\t\t      unsigned int critical,\n\t\t\t      const gnutls_datum_t * nonce);\nint gnutls_ocsp_req_randomize_nonce(gnutls_ocsp_req_t req);\n\nstruct gnutls_ocsp_resp_int;\ntypedef struct gnutls_ocsp_resp_int *gnutls_ocsp_resp_t;\ntypedef const struct gnutls_ocsp_resp_int *gnutls_ocsp_resp_const_t;\n\nint gnutls_ocsp_resp_init(gnutls_ocsp_resp_t * resp);\nvoid gnutls_ocsp_resp_deinit(gnutls_ocsp_resp_t resp);\n\nint gnutls_ocsp_resp_import(gnutls_ocsp_resp_t resp,\n\t\t\t    const gnutls_datum_t * data);\nint gnutls_ocsp_resp_import2(gnutls_ocsp_resp_t resp,\n\t\t\t     const gnutls_datum_t * data,\n\t\t\t     gnutls_x509_crt_fmt_t fmt);\nint gnutls_ocsp_resp_export(gnutls_ocsp_resp_const_t resp,\n\t\t\t    gnutls_datum_t * data);\nint gnutls_ocsp_resp_export2(gnutls_ocsp_resp_const_t resp,\n\t\t\t     gnutls_datum_t * data,\n\t\t\t     gnutls_x509_crt_fmt_t fmt);\nint gnutls_ocsp_resp_print(gnutls_ocsp_resp_const_t resp,\n\t\t\t   gnutls_ocsp_print_formats_t format,\n\t\t\t   gnutls_datum_t * out);\n\nint gnutls_ocsp_resp_get_status(gnutls_ocsp_resp_const_t resp);\nint gnutls_ocsp_resp_get_response(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t  gnutls_datum_t *\n\t\t\t\t  response_type_oid,\n\t\t\t\t  gnutls_datum_t * response);\n\nint gnutls_ocsp_resp_get_version(gnutls_ocsp_resp_const_t resp);\nint gnutls_ocsp_resp_get_responder(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t   gnutls_datum_t * dn);\nint gnutls_ocsp_resp_get_responder2(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t    gnutls_datum_t * dn,\n\t\t\t\t    unsigned flags);\n\n/* the raw key ID of the responder */\n#define GNUTLS_OCSP_RESP_ID_KEY 1\n/* the raw DN of the responder */\n#define GNUTLS_OCSP_RESP_ID_DN 2\nint\ngnutls_ocsp_resp_get_responder_raw_id(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t      unsigned type,\n\t\t\t\t      gnutls_datum_t * raw);\n\ntime_t gnutls_ocsp_resp_get_produced(gnutls_ocsp_resp_const_t resp);\nint gnutls_ocsp_resp_get_single(gnutls_ocsp_resp_const_t resp,\n\t\t\t\tunsigned indx,\n\t\t\t\tgnutls_digest_algorithm_t * digest,\n\t\t\t\tgnutls_datum_t * issuer_name_hash,\n\t\t\t\tgnutls_datum_t * issuer_key_hash,\n\t\t\t\tgnutls_datum_t * serial_number,\n\t\t\t\tunsigned int *cert_status,\n\t\t\t\ttime_t * this_update,\n\t\t\t\ttime_t * next_update,\n\t\t\t\ttime_t * revocation_time,\n\t\t\t\tunsigned int *revocation_reason);\nint gnutls_ocsp_resp_get_extension(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t   unsigned indx,\n\t\t\t\t   gnutls_datum_t * oid,\n\t\t\t\t   unsigned int *critical,\n\t\t\t\t   gnutls_datum_t * data);\nint gnutls_ocsp_resp_get_nonce(gnutls_ocsp_resp_const_t resp,\n\t\t\t       unsigned int *critical,\n\t\t\t       gnutls_datum_t * nonce);\nint gnutls_ocsp_resp_get_signature_algorithm(gnutls_ocsp_resp_const_t resp);\nint gnutls_ocsp_resp_get_signature(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t   gnutls_datum_t * sig);\nint gnutls_ocsp_resp_get_certs(gnutls_ocsp_resp_const_t resp,\n\t\t\t       gnutls_x509_crt_t ** certs,\n\t\t\t       size_t * ncerts);\n\nint gnutls_ocsp_resp_verify_direct(gnutls_ocsp_resp_const_t resp,\n\t\t\t\t   gnutls_x509_crt_t issuer,\n\t\t\t\t   unsigned int *verify,\n\t\t\t\t   unsigned int flags);\nint gnutls_ocsp_resp_verify(gnutls_ocsp_resp_const_t resp,\n\t\t\t    gnutls_x509_trust_list_t trustlist,\n\t\t\t    unsigned int *verify, unsigned int flags);\n\nint gnutls_ocsp_resp_check_crt(gnutls_ocsp_resp_const_t resp,\n\t\t\t       unsigned int indx, gnutls_x509_crt_t crt);\n\nint\ngnutls_ocsp_resp_list_import2(gnutls_ocsp_resp_t **ocsps,\n\t\t\t     unsigned int *size,\n\t\t\t     const gnutls_datum_t *resp_data,\n\t\t\t     gnutls_x509_crt_fmt_t format,\n\t\t\t     unsigned int flags);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_OCSP_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/openpgp.h",
    "content": "/*\n * Copyright (C) 2003-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for the OpenPGP\n * key and private key parsing functions.\n */\n\n#ifndef GNUTLS_OPENPGP_H\n#define GNUTLS_OPENPGP_H\n\n#include <gnutls/gnutls.h>\n#include <limits.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/* Openpgp certificate stuff\n */\n\n/**\n * gnutls_openpgp_crt_fmt_t:\n * @GNUTLS_OPENPGP_FMT_RAW: OpenPGP certificate in raw format.\n * @GNUTLS_OPENPGP_FMT_BASE64: OpenPGP certificate in base64 format.\n *\n * Enumeration of different OpenPGP key formats.\n */\ntypedef enum gnutls_openpgp_crt_fmt {\n\tGNUTLS_OPENPGP_FMT_RAW,\n\tGNUTLS_OPENPGP_FMT_BASE64\n} gnutls_openpgp_crt_fmt_t;\n\n#define GNUTLS_OPENPGP_KEYID_SIZE 8\n#define GNUTLS_OPENPGP_V4_FINGERPRINT_SIZE 20\ntypedef unsigned char\n gnutls_openpgp_keyid_t[GNUTLS_OPENPGP_KEYID_SIZE];\n\n/* gnutls_openpgp_cert_t should be defined in gnutls.h\n */\n\n\t/* initializes the memory for gnutls_openpgp_crt_t struct */\nint gnutls_openpgp_crt_init(gnutls_openpgp_crt_t * key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\t/* frees all memory */\nvoid gnutls_openpgp_crt_deinit(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_import(gnutls_openpgp_crt_t key,\n\t\t\t      const gnutls_datum_t * data,\n\t\t\t      gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_export(gnutls_openpgp_crt_t key,\n\t\t\t      gnutls_openpgp_crt_fmt_t format,\n\t\t\t      void *output_data,\n\t\t\t      size_t * output_data_size) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_export2(gnutls_openpgp_crt_t key,\n\t\t\t       gnutls_openpgp_crt_fmt_t format,\n\t\t\t       gnutls_datum_t * out) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_print(gnutls_openpgp_crt_t cert,\n\t\t\t     gnutls_certificate_print_formats_t\n\t\t\t     format, gnutls_datum_t * out) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* The key_usage flags are defined in gnutls.h. They are\n * the GNUTLS_KEY_* definitions.\n */\n#define GNUTLS_OPENPGP_MASTER_KEYID_IDX INT_MAX\n\nint gnutls_openpgp_crt_get_key_usage(gnutls_openpgp_crt_t key,\n\t\t\t\t     unsigned int *key_usage) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_fingerprint(gnutls_openpgp_crt_t key,\n\t\t\t\t       void *fpr, size_t * fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_fingerprint(gnutls_openpgp_crt_t\n\t\t\t\t\t      key,\n\t\t\t\t\t      unsigned int idx,\n\t\t\t\t\t      void *fpr, size_t * fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_name(gnutls_openpgp_crt_t key,\n\t\t\t\tint idx, char *buf, size_t * sizeof_buf) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ngnutls_pk_algorithm_t\ngnutls_openpgp_crt_get_pk_algorithm(gnutls_openpgp_crt_t key,\n\t\t\t\t    unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_version(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntime_t gnutls_openpgp_crt_get_creation_time(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\ntime_t gnutls_openpgp_crt_get_expiration_time(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_key_id(gnutls_openpgp_crt_t key,\n\t\t\t\t  gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_check_hostname(gnutls_openpgp_crt_t key,\n\t\t\t\t      const char *hostname) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_check_hostname2(gnutls_openpgp_crt_t key,\n\t\t\t\t      const char *hostname, unsigned int flags) _GNUTLS_GCC_ATTR_DEPRECATED;\nint\ngnutls_openpgp_crt_check_email(gnutls_openpgp_crt_t key, const char *email, unsigned flags) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_revoked_status(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_subkey_count(gnutls_openpgp_crt_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_idx(gnutls_openpgp_crt_t key,\n\t\t\t\t      const gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_revoked_status\n    (gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\ngnutls_pk_algorithm_t\ngnutls_openpgp_crt_get_subkey_pk_algorithm(gnutls_openpgp_crt_t\n\t\t\t\t\t   key,\n\t\t\t\t\t   unsigned int idx,\n\t\t\t\t\t   unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;\ntime_t\n    gnutls_openpgp_crt_get_subkey_creation_time\n    (gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\ntime_t\n    gnutls_openpgp_crt_get_subkey_expiration_time\n    (gnutls_openpgp_crt_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_id(gnutls_openpgp_crt_t key,\n\t\t\t\t     unsigned int idx,\n\t\t\t\t     gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_usage(gnutls_openpgp_crt_t key,\n\t\t\t\t\tunsigned int idx,\n\t\t\t\t\tunsigned int *key_usage) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_subkey_pk_dsa_raw(gnutls_openpgp_crt_t\n\t\t\t\t\t     crt, unsigned int idx,\n\t\t\t\t\t     gnutls_datum_t * p,\n\t\t\t\t\t     gnutls_datum_t * q,\n\t\t\t\t\t     gnutls_datum_t * g,\n\t\t\t\t\t     gnutls_datum_t * y) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_subkey_pk_rsa_raw(gnutls_openpgp_crt_t\n\t\t\t\t\t     crt, unsigned int idx,\n\t\t\t\t\t     gnutls_datum_t * m,\n\t\t\t\t\t     gnutls_datum_t * e) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_pk_dsa_raw(gnutls_openpgp_crt_t crt,\n\t\t\t\t      gnutls_datum_t * p,\n\t\t\t\t      gnutls_datum_t * q,\n\t\t\t\t      gnutls_datum_t * g,\n\t\t\t\t      gnutls_datum_t * y) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_crt_get_pk_rsa_raw(gnutls_openpgp_crt_t crt,\n\t\t\t\t      gnutls_datum_t * m,\n\t\t\t\t      gnutls_datum_t * e) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_preferred_key_id(gnutls_openpgp_crt_t\n\t\t\t\t\t    key,\n\t\t\t\t\t    gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint\ngnutls_openpgp_crt_set_preferred_key_id(gnutls_openpgp_crt_t key,\n\t\t\t\t\tconst\n\t\t\t\t\tgnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* privkey stuff.\n */\nint gnutls_openpgp_privkey_init(gnutls_openpgp_privkey_t * key) _GNUTLS_GCC_ATTR_DEPRECATED;\nvoid gnutls_openpgp_privkey_deinit(gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\ngnutls_pk_algorithm_t\n    gnutls_openpgp_privkey_get_pk_algorithm\n    (gnutls_openpgp_privkey_t key, unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ngnutls_sec_param_t\ngnutls_openpgp_privkey_sec_param(gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_import(gnutls_openpgp_privkey_t key,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  gnutls_openpgp_crt_fmt_t format,\n\t\t\t\t  const char *password,\n\t\t\t\t  unsigned int flags) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_get_fingerprint(gnutls_openpgp_privkey_t\n\t\t\t\t\t   key, void *fpr,\n\t\t\t\t\t   size_t * fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_subkey_fingerprint\n    (gnutls_openpgp_privkey_t key, unsigned int idx, void *fpr,\n     size_t * fprlen) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_key_id(gnutls_openpgp_privkey_t key,\n\t\t\t\t      gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_subkey_count(gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_subkey_idx(gnutls_openpgp_privkey_t\n\t\t\t\t\t  key,\n\t\t\t\t\t  const\n\t\t\t\t\t  gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_get_subkey_revoked_status\n    (gnutls_openpgp_privkey_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_get_revoked_status\n    (gnutls_openpgp_privkey_t key) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ngnutls_pk_algorithm_t\n    gnutls_openpgp_privkey_get_subkey_pk_algorithm\n    (gnutls_openpgp_privkey_t key, unsigned int idx, unsigned int *bits) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntime_t\n    gnutls_openpgp_privkey_get_subkey_expiration_time\n    (gnutls_openpgp_privkey_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_get_subkey_id(gnutls_openpgp_privkey_t\n\t\t\t\t\t key, unsigned int idx,\n\t\t\t\t\t gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\ntime_t\n    gnutls_openpgp_privkey_get_subkey_creation_time\n    (gnutls_openpgp_privkey_t key, unsigned int idx) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_export_subkey_dsa_raw\n    (gnutls_openpgp_privkey_t pkey, unsigned int idx,\n     gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * g,\n     gnutls_datum_t * y, gnutls_datum_t * x) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_export_subkey_rsa_raw\n    (gnutls_openpgp_privkey_t pkey, unsigned int idx,\n     gnutls_datum_t * m, gnutls_datum_t * e, gnutls_datum_t * d,\n     gnutls_datum_t * p, gnutls_datum_t * q, gnutls_datum_t * u) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_export_dsa_raw(gnutls_openpgp_privkey_t\n\t\t\t\t\t  pkey, gnutls_datum_t * p,\n\t\t\t\t\t  gnutls_datum_t * q,\n\t\t\t\t\t  gnutls_datum_t * g,\n\t\t\t\t\t  gnutls_datum_t * y,\n\t\t\t\t\t  gnutls_datum_t * x) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_export_rsa_raw(gnutls_openpgp_privkey_t\n\t\t\t\t\t  pkey, gnutls_datum_t * m,\n\t\t\t\t\t  gnutls_datum_t * e,\n\t\t\t\t\t  gnutls_datum_t * d,\n\t\t\t\t\t  gnutls_datum_t * p,\n\t\t\t\t\t  gnutls_datum_t * q,\n\t\t\t\t\t  gnutls_datum_t * u) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_export(gnutls_openpgp_privkey_t key,\n\t\t\t\t  gnutls_openpgp_crt_fmt_t format,\n\t\t\t\t  const char *password,\n\t\t\t\t  unsigned int flags,\n\t\t\t\t  void *output_data,\n\t\t\t\t  size_t * output_data_size) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_export2(gnutls_openpgp_privkey_t key,\n\t\t\t\t   gnutls_openpgp_crt_fmt_t format,\n\t\t\t\t   const char *password,\n\t\t\t\t   unsigned int flags,\n\t\t\t\t   gnutls_datum_t * out) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_privkey_set_preferred_key_id\n    (gnutls_openpgp_privkey_t key, const gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_openpgp_privkey_get_preferred_key_id\n    (gnutls_openpgp_privkey_t key, gnutls_openpgp_keyid_t keyid) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_get_auth_subkey(gnutls_openpgp_crt_t crt,\n\t\t\t\t       gnutls_openpgp_keyid_t\n\t\t\t\t       keyid, unsigned int flag) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* Keyring stuff.\n */\n\nint gnutls_openpgp_keyring_init(gnutls_openpgp_keyring_t * keyring) _GNUTLS_GCC_ATTR_DEPRECATED;\nvoid gnutls_openpgp_keyring_deinit(gnutls_openpgp_keyring_t keyring) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_keyring_import(gnutls_openpgp_keyring_t keyring,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_keyring_check_id(gnutls_openpgp_keyring_t ring,\n\t\t\t\t    const gnutls_openpgp_keyid_t\n\t\t\t\t    keyid, unsigned int flags) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\nint gnutls_openpgp_crt_verify_ring(gnutls_openpgp_crt_t key,\n\t\t\t\t   gnutls_openpgp_keyring_t\n\t\t\t\t   keyring, unsigned int flags,\n\t\t\t\t   unsigned int *verify\n\t\t\t\t   /* the output of the verification */\n    ) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_crt_verify_self(gnutls_openpgp_crt_t key,\n\t\t\t\t   unsigned int flags,\n\t\t\t\t   unsigned int *verify) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_keyring_get_crt(gnutls_openpgp_keyring_t ring,\n\t\t\t\t   unsigned int idx,\n\t\t\t\t   gnutls_openpgp_crt_t * cert) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_openpgp_keyring_get_crt_count(gnutls_openpgp_keyring_t ring) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\n\n/**\n * gnutls_openpgp_recv_key_func:\n * @session: a TLS session\n * @keyfpr: key fingerprint\n * @keyfpr_length: length of key fingerprint\n * @key: output key.\n *\n * A callback of this type is used to retrieve OpenPGP keys.  Only\n * useful on the server, and will only be used if the peer send a key\n * fingerprint instead of a full key.  See also\n * gnutls_openpgp_set_recv_key_function().\n *\n * The variable @key must be allocated using gnutls_malloc().\n *\n * Returns: On success, %GNUTLS_E_SUCCESS (zero) is returned,\n *   otherwise an error code is returned.\n */\ntypedef int (*gnutls_openpgp_recv_key_func) (gnutls_session_t\n\t\t\t\t\t     session,\n\t\t\t\t\t     const unsigned char\n\t\t\t\t\t     *keyfpr,\n\t\t\t\t\t     unsigned int\n\t\t\t\t\t     keyfpr_length,\n\t\t\t\t\t     gnutls_datum_t * key);\n\nvoid\ngnutls_openpgp_set_recv_key_function(gnutls_session_t session,\n\t\t\t\t     gnutls_openpgp_recv_key_func func) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n\n\n/* certificate authentication stuff.\n */\nint gnutls_certificate_set_openpgp_key\n    (gnutls_certificate_credentials_t res,\n     gnutls_openpgp_crt_t crt, gnutls_openpgp_privkey_t pkey) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint\ngnutls_certificate_get_openpgp_key(gnutls_certificate_credentials_t res,\n                                   unsigned index,\n                                   gnutls_openpgp_privkey_t *key) _GNUTLS_GCC_ATTR_DEPRECATED;\nint\ngnutls_certificate_get_openpgp_crt(gnutls_certificate_credentials_t res,\n                                   unsigned index,\n                                   gnutls_openpgp_crt_t **crt_list,\n                                   unsigned *crt_list_size) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint\n gnutls_certificate_set_openpgp_key_file\n    (gnutls_certificate_credentials_t res, const char *certfile,\n     const char *keyfile, gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\nint gnutls_certificate_set_openpgp_key_mem\n    (gnutls_certificate_credentials_t res,\n     const gnutls_datum_t * cert, const gnutls_datum_t * key,\n     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint\n gnutls_certificate_set_openpgp_key_file2\n    (gnutls_certificate_credentials_t res, const char *certfile,\n     const char *keyfile, const char *subkey_id,\n     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\nint\n gnutls_certificate_set_openpgp_key_mem2\n    (gnutls_certificate_credentials_t res,\n     const gnutls_datum_t * cert, const gnutls_datum_t * key,\n     const char *subkey_id, gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_certificate_set_openpgp_keyring_mem\n    (gnutls_certificate_credentials_t c, const unsigned char *data,\n     size_t dlen, gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\nint gnutls_certificate_set_openpgp_keyring_file\n    (gnutls_certificate_credentials_t c, const char *file,\n     gnutls_openpgp_crt_fmt_t format) _GNUTLS_GCC_ATTR_DEPRECATED;\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_OPENPGP_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/pkcs11.h",
    "content": "/*\n * Copyright (C) 2010-2012 Free Software Foundation, Inc.\n * Copyright (C) 2016-2018 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_PKCS11_H\n#define GNUTLS_PKCS11_H\n\n#include <stdarg.h>\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n#define GNUTLS_PKCS11_MAX_PIN_LEN 256\n\n/**\n * gnutls_pkcs11_token_callback_t:\n * @userdata: user-controlled data from gnutls_pkcs11_set_token_function().\n * @label: token label.\n * @retry: retry counter, initially 0.\n *\n * Token callback function. The callback will be used to ask the user\n * to re-insert the token with given (null terminated) label.  The\n * callback should return zero if token has been inserted by user and\n * a negative error code otherwise.  It might be called multiple times\n * if the token is not detected and the retry counter will be\n * increased.\n *\n * Returns: %GNUTLS_E_SUCCESS (0) on success or a negative error code\n * on error.\n *\n * Since: 2.12.0\n **/\ntypedef int (*gnutls_pkcs11_token_callback_t) (void *const\n\t\t\t\t\t       userdata,\n\t\t\t\t\t       const char *const\n\t\t\t\t\t       label, unsigned retry);\n\n\nstruct gnutls_pkcs11_obj_st;\ntypedef struct gnutls_pkcs11_obj_st *gnutls_pkcs11_obj_t;\n\n\n#define GNUTLS_PKCS11_FLAG_MANUAL 0\t/* Manual loading of libraries */\n#define GNUTLS_PKCS11_FLAG_AUTO 1\t/* Automatically load libraries by reading /etc/gnutls/pkcs11.conf */\n#define GNUTLS_PKCS11_FLAG_AUTO_TRUSTED (1<<1)\t/* Automatically load trusted libraries by reading /etc/gnutls/pkcs11.conf */\n\n/* pkcs11.conf format:\n * load = /lib/xxx-pkcs11.so\n * load = /lib/yyy-pkcs11.so\n */\n\nint gnutls_pkcs11_init(unsigned int flags,\n\t\t       const char *deprecated_config_file);\nint gnutls_pkcs11_reinit(void);\nvoid gnutls_pkcs11_deinit(void);\nvoid gnutls_pkcs11_set_token_function\n    (gnutls_pkcs11_token_callback_t fn, void *userdata);\n\nvoid gnutls_pkcs11_set_pin_function(gnutls_pin_callback_t fn,\n\t\t\t\t    void *userdata);\n\ngnutls_pin_callback_t gnutls_pkcs11_get_pin_function(void\n\t\t\t\t\t\t     **userdata);\n\nint gnutls_pkcs11_add_provider(const char *name, const char *params);\nint gnutls_pkcs11_obj_init(gnutls_pkcs11_obj_t * obj);\nvoid gnutls_pkcs11_obj_set_pin_function(gnutls_pkcs11_obj_t obj,\n\t\t\t\t\tgnutls_pin_callback_t fn,\n\t\t\t\t\tvoid *userdata);\n\n/**\n * gnutls_pkcs11_obj_flags:\n * @GNUTLS_PKCS11_OBJ_FLAG_LOGIN: Force login in the token for the operation (seek+store). \n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED: object marked as trusted (seek+store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE: object is explicitly marked as sensitive -unexportable (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_LOGIN_SO: force login as a security officer in the token for the operation (seek+store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE: marked as private -requires PIN to access (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_PRIVATE: marked as not private (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_ANY: When retrieving an object, do not set any requirements (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_TRUSTED: When retrieving an object, only retrieve the marked as trusted (alias to %GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED).\n *   In gnutls_pkcs11_crt_is_known() it implies %GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_COMPARE if %GNUTLS_PKCS11_OBJ_FLAG_COMPARE_KEY is not given.\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_DISTRUSTED: When writing an object, mark it as distrusted (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_DISTRUSTED: When retrieving an object, only retrieve the marked as distrusted (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_COMPARE: When checking an object's presence, fully compare it before returning any result (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_COMPARE_KEY: When checking an object's presence, compare the key before returning any result (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_PRESENT_IN_TRUSTED_MODULE: The object must be present in a marked as trusted module (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_CA: Mark the object as a CA (seek+store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_KEY_WRAP: Mark the generated key pair as wrapping and unwrapping keys (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_OVERWRITE_TRUSTMOD_EXT: When an issuer is requested, override its extensions with the ones present in the trust module (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_ALWAYS_AUTH: Mark the key pair as requiring authentication (pin entry) before every operation (seek+store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_EXTRACTABLE: Mark the key pair as being extractable (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_NEVER_EXTRACTABLE: If set, the object was never marked as extractable (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_CRT: When searching, restrict to certificates only (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_PUBKEY: When searching, restrict to public key objects only (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_PRIVKEY: When searching, restrict to private key objects only (seek).\n * @GNUTLS_PKCS11_OBJ_FLAG_NO_STORE_PUBKEY: When generating a keypair don't store the public key (store).\n * @GNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_SENSITIVE: object marked as not sensitive -exportable (store).\n *\n * Enumeration of different PKCS #11 object flags. Some flags are used\n * to mark objects when storing, while others are also used while seeking\n * or retrieving objects.\n */\ntypedef enum gnutls_pkcs11_obj_flags {\n\tGNUTLS_PKCS11_OBJ_FLAG_LOGIN = (1<<0),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED = (1<<1),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_SENSITIVE = (1<<2),\n\tGNUTLS_PKCS11_OBJ_FLAG_LOGIN_SO = (1<<3),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_PRIVATE = (1<<4),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_PRIVATE = (1<<5),\n\tGNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_ANY = (1<<6),\n\tGNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_TRUSTED = GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED,\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_DISTRUSTED = (1<<8),\n\tGNUTLS_PKCS11_OBJ_FLAG_RETRIEVE_DISTRUSTED = GNUTLS_PKCS11_OBJ_FLAG_MARK_DISTRUSTED,\n\tGNUTLS_PKCS11_OBJ_FLAG_COMPARE = (1<<9),\n\tGNUTLS_PKCS11_OBJ_FLAG_PRESENT_IN_TRUSTED_MODULE = (1<<10),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_CA = (1<<11),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_KEY_WRAP = (1<<12),\n\tGNUTLS_PKCS11_OBJ_FLAG_COMPARE_KEY = (1<<13),\n\tGNUTLS_PKCS11_OBJ_FLAG_OVERWRITE_TRUSTMOD_EXT = (1<<14),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_ALWAYS_AUTH = (1<<15),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_EXTRACTABLE = (1<<16),\n\tGNUTLS_PKCS11_OBJ_FLAG_NEVER_EXTRACTABLE = (1<<17),\n\tGNUTLS_PKCS11_OBJ_FLAG_CRT = (1<<18),\n\tGNUTLS_PKCS11_OBJ_FLAG_WITH_PRIVKEY = (1<<19),\n\tGNUTLS_PKCS11_OBJ_FLAG_PUBKEY = (1<<20),\n\tGNUTLS_PKCS11_OBJ_FLAG_NO_STORE_PUBKEY = GNUTLS_PKCS11_OBJ_FLAG_PUBKEY,\n\tGNUTLS_PKCS11_OBJ_FLAG_PRIVKEY = (1<<21),\n\tGNUTLS_PKCS11_OBJ_FLAG_MARK_NOT_SENSITIVE = (1<<22),\n\t/* flags 1<<29 and later are reserved - see pkcs11_int.h */\n} gnutls_pkcs11_obj_flags;\n\n#define gnutls_pkcs11_obj_attr_t gnutls_pkcs11_obj_flags\n\n/**\n * gnutls_pkcs11_url_type_t:\n * @GNUTLS_PKCS11_URL_GENERIC: A generic-purpose URL.\n * @GNUTLS_PKCS11_URL_LIB: A URL that specifies the library used as well.\n * @GNUTLS_PKCS11_URL_LIB_VERSION: A URL that specifies the library and its version.\n *\n * Enumeration of different URL extraction flags.\n */\ntypedef enum {\n\tGNUTLS_PKCS11_URL_GENERIC,\t/* URL specifies the object on token level */\n\tGNUTLS_PKCS11_URL_LIB,\t/* URL specifies the object on module level */\n\tGNUTLS_PKCS11_URL_LIB_VERSION\t/* URL specifies the object on module and version level */\n} gnutls_pkcs11_url_type_t;\n\nint gnutls_pkcs11_obj_import_url(gnutls_pkcs11_obj_t obj,\n\t\t\t\t const char *url, unsigned int flags\n\t\t\t\t /* GNUTLS_PKCS11_OBJ_FLAG_* */ );\nint gnutls_pkcs11_obj_export_url(gnutls_pkcs11_obj_t obj,\n\t\t\t\t gnutls_pkcs11_url_type_t detailed,\n\t\t\t\t char **url);\nvoid gnutls_pkcs11_obj_deinit(gnutls_pkcs11_obj_t obj);\n\nint gnutls_pkcs11_obj_export(gnutls_pkcs11_obj_t obj,\n\t\t\t     void *output_data, size_t * output_data_size);\nint gnutls_pkcs11_obj_export2(gnutls_pkcs11_obj_t obj,\n\t\t\t      gnutls_datum_t * out);\n\nint gnutls_pkcs11_obj_export3(gnutls_pkcs11_obj_t obj, gnutls_x509_crt_fmt_t fmt,\n\t\t\t      gnutls_datum_t * out);\n\nint gnutls_pkcs11_get_raw_issuer(const char *url, gnutls_x509_crt_t cert,\n\t\t\t     gnutls_datum_t * issuer,\n\t\t\t     gnutls_x509_crt_fmt_t fmt,\n\t\t\t     unsigned int flags);\n\nint gnutls_pkcs11_get_raw_issuer_by_dn (const char *url, const gnutls_datum_t *dn,\n\t\t\t\t\tgnutls_datum_t *issuer,\n\t\t\t\t\tgnutls_x509_crt_fmt_t fmt,\n\t\t\t\t\tunsigned int flags);\n\nint gnutls_pkcs11_get_raw_issuer_by_subject_key_id (const char *url, \n\t\t\t\t\tconst gnutls_datum_t *dn,\n\t\t\t\t\tconst gnutls_datum_t *spki,\n\t\t\t\t\tgnutls_datum_t *issuer,\n\t\t\t\t\tgnutls_x509_crt_fmt_t fmt,\n\t\t\t\t\tunsigned int flags);\n\nunsigned gnutls_pkcs11_crt_is_known(const char *url, gnutls_x509_crt_t cert,\n\t\t\t     unsigned int flags);\n\n#if 0\n/* for documentation */\nint gnutls_pkcs11_copy_x509_crt(const char *token_url,\n\t\t\t\tgnutls_x509_crt_t crt,\n\t\t\t\tconst char *label, unsigned int flags\n\t\t\t\t/* GNUTLS_PKCS11_OBJ_FLAG_* */ );\n\nint gnutls_pkcs11_copy_x509_privkey(const char *token_url,\n\t\t\t\t    gnutls_x509_privkey_t key,\n\t\t\t\t    const char *label,\n\t\t\t\t    unsigned int key_usage,\n\t\t\t\t    unsigned int flags);\nint\ngnutls_pkcs11_privkey_generate2(const char *url, gnutls_pk_algorithm_t pk,\n\t\t\t\tunsigned int bits, const char *label,\n\t\t\t\tgnutls_x509_crt_fmt_t fmt,\n\t\t\t\tgnutls_datum_t * pubkey,\n\t\t\t\tunsigned int flags);\nint\ngnutls_pkcs11_privkey_generate(const char *url, gnutls_pk_algorithm_t pk,\n\t\t\t       unsigned int bits, const char *label,\n\t\t\t       unsigned int flags);\n#endif\n\nint\ngnutls_pkcs11_copy_pubkey(const char *token_url,\n\t\t\t  gnutls_pubkey_t crt, const char *label,\n\t\t\t  const gnutls_datum_t *cid,\n\t\t\t  unsigned int key_usage, unsigned int flags);\n\n#define gnutls_pkcs11_copy_x509_crt(url, crt, label, flags) \\\n\tgnutls_pkcs11_copy_x509_crt2(url, crt, label, NULL, flags)\n\nint gnutls_pkcs11_copy_x509_crt2(const char *token_url,\n\t\t\t\tgnutls_x509_crt_t crt,\n\t\t\t\tconst char *label,\n\t\t\t\tconst gnutls_datum_t *id,\n\t\t\t\tunsigned int flags /* GNUTLS_PKCS11_OBJ_FLAG_* */);\n\n#define gnutls_pkcs11_copy_x509_privkey(url, key, label, usage, flags) \\\n\tgnutls_pkcs11_copy_x509_privkey2(url, key, label, NULL, usage, flags)\nint gnutls_pkcs11_copy_x509_privkey2(const char *token_url,\n\t\t\t\t    gnutls_x509_privkey_t key,\n\t\t\t\t    const char *label,\n\t\t\t\t    const gnutls_datum_t *cid,\n\t\t\t\t    unsigned int key_usage\n\t\t\t\t    /*GNUTLS_KEY_* */ ,\n\t\t\t\t    unsigned int flags\n\t\t\t\t    /* GNUTLS_PKCS11_OBJ_FLAG_* */\n);\n\nint gnutls_pkcs11_delete_url(const char *object_url, unsigned int flags\n\t\t\t     /* GNUTLS_PKCS11_OBJ_FLAG_* */ );\n\nint gnutls_pkcs11_copy_secret_key(const char *token_url,\n\t\t\t\t  gnutls_datum_t * key,\n\t\t\t\t  const char *label, unsigned int key_usage\n\t\t\t\t  /* GNUTLS_KEY_* */ ,\n\t\t\t\t  unsigned int flags\n\t\t\t\t  /* GNUTLS_PKCS11_OBJ_FLAG_* */ );\n\n/**\n * gnutls_pkcs11_obj_info_t:\n * @GNUTLS_PKCS11_OBJ_ID_HEX: The object ID in hex. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_LABEL: The object label. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_TOKEN_LABEL: The token's label. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_TOKEN_SERIAL: The token's serial number. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_TOKEN_MANUFACTURER: The token's manufacturer. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_TOKEN_MODEL: The token's model. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_ID: The object ID. Raw bytes.\n * @GNUTLS_PKCS11_OBJ_LIBRARY_VERSION: The library's version. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_LIBRARY_DESCRIPTION: The library's description. Null-terminated text.\n * @GNUTLS_PKCS11_OBJ_LIBRARY_MANUFACTURER: The library's manufacturer name. Null-terminated text.\n *\n * Enumeration of several object information types.\n */\ntypedef enum {\n\tGNUTLS_PKCS11_OBJ_ID_HEX = 1,\n\tGNUTLS_PKCS11_OBJ_LABEL,\n\tGNUTLS_PKCS11_OBJ_TOKEN_LABEL,\n\tGNUTLS_PKCS11_OBJ_TOKEN_SERIAL,\n\tGNUTLS_PKCS11_OBJ_TOKEN_MANUFACTURER,\n\tGNUTLS_PKCS11_OBJ_TOKEN_MODEL,\n\tGNUTLS_PKCS11_OBJ_ID,\n\t/* the pkcs11 provider library info  */\n\tGNUTLS_PKCS11_OBJ_LIBRARY_VERSION,\n\tGNUTLS_PKCS11_OBJ_LIBRARY_DESCRIPTION,\n\tGNUTLS_PKCS11_OBJ_LIBRARY_MANUFACTURER\n} gnutls_pkcs11_obj_info_t;\n\nint\ngnutls_pkcs11_obj_get_ptr(gnutls_pkcs11_obj_t obj, void **ptr,\n\t\t\t  void **session, void **ohandle,\n\t\t\t  unsigned long *slot_id,\n\t\t\t  unsigned int flags);\n\nint gnutls_pkcs11_obj_get_info(gnutls_pkcs11_obj_t obj,\n\t\t\t       gnutls_pkcs11_obj_info_t itype,\n\t\t\t       void *output, size_t * output_size);\nint gnutls_pkcs11_obj_set_info(gnutls_pkcs11_obj_t obj,\n\t\t\t       gnutls_pkcs11_obj_info_t itype,\n\t\t\t       const void *data, size_t data_size,\n\t\t\t       unsigned flags);\n\n#define GNUTLS_PKCS11_OBJ_ATTR_CRT_ALL GNUTLS_PKCS11_OBJ_FLAG_CRT\n#define GNUTLS_PKCS11_OBJ_ATTR_MATCH 0 /* always match the given URL */\n#define GNUTLS_PKCS11_OBJ_ATTR_ALL 0 /* match everything! */\n#define GNUTLS_PKCS11_OBJ_ATTR_CRT_TRUSTED (GNUTLS_PKCS11_OBJ_FLAG_CRT|GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED)\n#define GNUTLS_PKCS11_OBJ_ATTR_CRT_WITH_PRIVKEY (GNUTLS_PKCS11_OBJ_FLAG_CRT|GNUTLS_PKCS11_OBJ_FLAG_WITH_PRIVKEY)\n#define GNUTLS_PKCS11_OBJ_ATTR_CRT_TRUSTED_CA (GNUTLS_PKCS11_OBJ_FLAG_CRT|GNUTLS_PKCS11_OBJ_FLAG_MARK_CA|GNUTLS_PKCS11_OBJ_FLAG_MARK_TRUSTED)\n#define GNUTLS_PKCS11_OBJ_ATTR_PUBKEY GNUTLS_PKCS11_OBJ_FLAG_PUBKEY\n#define GNUTLS_PKCS11_OBJ_ATTR_PRIVKEY GNUTLS_PKCS11_OBJ_FLAG_PRIVKEY\n\n/**\n * gnutls_pkcs11_token_info_t:\n * @GNUTLS_PKCS11_TOKEN_LABEL: The token's label (string)\n * @GNUTLS_PKCS11_TOKEN_SERIAL: The token's serial number (string)\n * @GNUTLS_PKCS11_TOKEN_MANUFACTURER: The token's manufacturer (string)\n * @GNUTLS_PKCS11_TOKEN_MODEL: The token's model (string)\n * @GNUTLS_PKCS11_TOKEN_MODNAME: The token's module name (string - since 3.4.3). This value is\n *   unavailable for providers which were manually loaded.\n *\n * Enumeration of types for retrieving token information.\n */\ntypedef enum {\n\tGNUTLS_PKCS11_TOKEN_LABEL,\n\tGNUTLS_PKCS11_TOKEN_SERIAL,\n\tGNUTLS_PKCS11_TOKEN_MANUFACTURER,\n\tGNUTLS_PKCS11_TOKEN_MODEL,\n\tGNUTLS_PKCS11_TOKEN_MODNAME\n} gnutls_pkcs11_token_info_t;\n\n/**\n * gnutls_pkcs11_obj_type_t:\n * @GNUTLS_PKCS11_OBJ_UNKNOWN: Unknown PKCS11 object.\n * @GNUTLS_PKCS11_OBJ_X509_CRT: X.509 certificate.\n * @GNUTLS_PKCS11_OBJ_PUBKEY: Public key.\n * @GNUTLS_PKCS11_OBJ_PRIVKEY: Private key.\n * @GNUTLS_PKCS11_OBJ_SECRET_KEY: Secret key.\n * @GNUTLS_PKCS11_OBJ_DATA: Data object.\n * @GNUTLS_PKCS11_OBJ_X509_CRT_EXTENSION: X.509 certificate extension (supported by p11-kit trust module only).\n *\n * Enumeration of object types.\n */\ntypedef enum {\n\tGNUTLS_PKCS11_OBJ_UNKNOWN,\n\tGNUTLS_PKCS11_OBJ_X509_CRT,\n\tGNUTLS_PKCS11_OBJ_PUBKEY,\n\tGNUTLS_PKCS11_OBJ_PRIVKEY,\n\tGNUTLS_PKCS11_OBJ_SECRET_KEY,\n\tGNUTLS_PKCS11_OBJ_DATA,\n\tGNUTLS_PKCS11_OBJ_X509_CRT_EXTENSION\n} gnutls_pkcs11_obj_type_t;\n\nint\ngnutls_pkcs11_token_init(const char *token_url,\n\t\t\t const char *so_pin, const char *label);\n\nint\ngnutls_pkcs11_token_get_ptr(const char *url, void **ptr, unsigned long *slot_id,\n\t\t\t    unsigned int flags);\n\nint\ngnutls_pkcs11_token_get_mechanism(const char *url,\n\t\t\t\t  unsigned int idx,\n\t\t\t\t  unsigned long *mechanism);\n\nunsigned\ngnutls_pkcs11_token_check_mechanism(const char *url,\n\t\t\t\t    unsigned long mechanism,\n\t\t\t\t    void *ptr, unsigned psize, unsigned flags);\n\nint gnutls_pkcs11_token_set_pin(const char *token_url, const char *oldpin, const char *newpin, unsigned int flags\t/*gnutls_pin_flag_t */);\n\nint gnutls_pkcs11_token_get_url(unsigned int seq,\n\t\t\t\tgnutls_pkcs11_url_type_t detailed,\n\t\t\t\tchar **url);\nint gnutls_pkcs11_token_get_info(const char *url,\n\t\t\t\t gnutls_pkcs11_token_info_t ttype,\n\t\t\t\t void *output, size_t * output_size);\n\n#define GNUTLS_PKCS11_TOKEN_HW 1\n#define GNUTLS_PKCS11_TOKEN_TRUSTED (1<<1) /* p11-kit trusted */\n#define GNUTLS_PKCS11_TOKEN_RNG (1<<2) /* CKF_RNG */\n#define GNUTLS_PKCS11_TOKEN_LOGIN_REQUIRED (1<<3) /* CKF_LOGIN_REQUIRED */\n#define GNUTLS_PKCS11_TOKEN_PROTECTED_AUTHENTICATION_PATH (1<<4) /* CKF_PROTECTED_AUTHENTICATION_PATH */\n#define GNUTLS_PKCS11_TOKEN_INITIALIZED (1<<5) /* CKF_TOKEN_INITIALIZED */\n#define GNUTLS_PKCS11_TOKEN_USER_PIN_COUNT_LOW (1<<6) /* CKF_USER_PIN_COUNT_LOW */\n#define GNUTLS_PKCS11_TOKEN_USER_PIN_FINAL_TRY (1<<7) /* CKF_USER_PIN_FINAL_TRY */\n#define GNUTLS_PKCS11_TOKEN_USER_PIN_LOCKED (1<<8) /* CKF_USER_PIN_LOCKED */\n#define GNUTLS_PKCS11_TOKEN_SO_PIN_COUNT_LOW (1<<9) /* CKF_SO_PIN_COUNT_LOW */\n#define GNUTLS_PKCS11_TOKEN_SO_PIN_FINAL_TRY (1<<10) /* CKF_SO_PIN_FINAL_TRY */\n#define GNUTLS_PKCS11_TOKEN_SO_PIN_LOCKED (1<<11) /* CKF_SO_PIN_LOCKED */\n#define GNUTLS_PKCS11_TOKEN_USER_PIN_INITIALIZED (1<<12) /* CKF_USER_PIN_INITIALIZED */\n#define GNUTLS_PKCS11_TOKEN_ERROR_STATE (1<<13) /* CKF_ERROR_STATE */\n\nint gnutls_pkcs11_token_get_flags(const char *url, unsigned int *flags);\n\n#define gnutls_pkcs11_obj_list_import_url(p_list, n_list, url, attrs, flags) gnutls_pkcs11_obj_list_import_url3(p_list, n_list, url, attrs|flags)\n#define gnutls_pkcs11_obj_list_import_url2(p_list, n_list, url, attrs, flags) gnutls_pkcs11_obj_list_import_url4(p_list, n_list, url, attrs|flags)\n\nint gnutls_pkcs11_obj_list_import_url3(gnutls_pkcs11_obj_t * p_list,\n\t\t\t\t      unsigned int *const n_list,\n\t\t\t\t      const char *url,\n\t\t\t\t      unsigned int flags\n\t\t\t\t      /* GNUTLS_PKCS11_OBJ_FLAG_* */\n    );\n\nint\ngnutls_pkcs11_obj_list_import_url4(gnutls_pkcs11_obj_t ** p_list,\n\t\t\t\t   unsigned int *n_list,\n\t\t\t\t   const char *url,\n\t\t\t\t   unsigned int flags\n\t\t\t\t   /* GNUTLS_PKCS11_OBJ_FLAG_* */\n    );\n\nint gnutls_x509_crt_import_pkcs11(gnutls_x509_crt_t crt,\n\t\t\t\t  gnutls_pkcs11_obj_t pkcs11_crt);\n\ngnutls_pkcs11_obj_type_t\ngnutls_pkcs11_obj_get_type(gnutls_pkcs11_obj_t obj);\nconst char *gnutls_pkcs11_type_get_name(gnutls_pkcs11_obj_type_t type);\n\nint\ngnutls_pkcs11_obj_get_exts(gnutls_pkcs11_obj_t obj,\n\t\t\t   struct gnutls_x509_ext_st **exts, unsigned int *exts_size,\n\t\t\t   unsigned int flags);\n\nint\ngnutls_pkcs11_obj_get_flags(gnutls_pkcs11_obj_t obj, unsigned int *oflags);\nchar *gnutls_pkcs11_obj_flags_get_str(unsigned int flags);\n\nint gnutls_x509_crt_list_import_pkcs11(gnutls_x509_crt_t * certs,\n\t\t\t\t       unsigned int cert_max,\n\t\t\t\t       gnutls_pkcs11_obj_t *\n\t\t\t\t       const objs, unsigned int flags\n\t\t\t\t       /* must be zero */ );\n\n/* private key functions...*/\nint gnutls_pkcs11_privkey_init(gnutls_pkcs11_privkey_t * key);\n\nint\ngnutls_pkcs11_privkey_cpy(gnutls_pkcs11_privkey_t dst,\n\t\t\t  gnutls_pkcs11_privkey_t src);\n\nvoid gnutls_pkcs11_privkey_set_pin_function(gnutls_pkcs11_privkey_t\n\t\t\t\t\t    key,\n\t\t\t\t\t    gnutls_pin_callback_t\n\t\t\t\t\t    fn, void *userdata);\nvoid gnutls_pkcs11_privkey_deinit(gnutls_pkcs11_privkey_t key);\nint gnutls_pkcs11_privkey_get_pk_algorithm(gnutls_pkcs11_privkey_t\n\t\t\t\t\t   key, unsigned int *bits);\nint gnutls_pkcs11_privkey_get_info(gnutls_pkcs11_privkey_t pkey,\n\t\t\t\t   gnutls_pkcs11_obj_info_t itype,\n\t\t\t\t   void *output, size_t * output_size);\n\nint gnutls_pkcs11_privkey_import_url(gnutls_pkcs11_privkey_t pkey,\n\t\t\t\t     const char *url, unsigned int flags);\n\nint gnutls_pkcs11_privkey_export_url(gnutls_pkcs11_privkey_t key,\n\t\t\t\t     gnutls_pkcs11_url_type_t\n\t\t\t\t     detailed, char **url);\nunsigned gnutls_pkcs11_privkey_status(gnutls_pkcs11_privkey_t key);\n\n#define gnutls_pkcs11_privkey_generate(url, pk, bits, label, flags) \\\n\tgnutls_pkcs11_privkey_generate3(url, pk, bits, label, NULL, 0, NULL, 0, flags)\n\n#define gnutls_pkcs11_privkey_generate2(url, pk, bits, label, fmt, pubkey, flags) \\\n\tgnutls_pkcs11_privkey_generate3(url, pk, bits, label, NULL, fmt, pubkey, 0, flags)\n\nint\ngnutls_pkcs11_privkey_generate3(const char *url,\n\t\t\t\tgnutls_pk_algorithm_t pk,\n\t\t\t\tunsigned int bits,\n\t\t\t\tconst char *label,\n\t\t\t\tconst gnutls_datum_t *cid,\n\t\t\t\tgnutls_x509_crt_fmt_t fmt,\n\t\t\t\tgnutls_datum_t * pubkey,\n\t\t\t\tunsigned int key_usage,\n\t\t\t\tunsigned int flags);\n\nint\ngnutls_pkcs11_privkey_export_pubkey(gnutls_pkcs11_privkey_t pkey,\n\t\t\t      gnutls_x509_crt_fmt_t fmt,\n\t\t\t      gnutls_datum_t * pubkey,\n\t\t\t      unsigned int flags);\n\nint\ngnutls_pkcs11_token_get_random(const char *token_url,\n\t\t\t       void *data, size_t len);\n\nint\ngnutls_pkcs11_copy_attached_extension(const char *token_url,\n\t\t\t\t      gnutls_x509_crt_t crt,\n\t\t\t\t      gnutls_datum_t *data,\n\t\t\t\t      const char *label,\n\t\t\t\t      unsigned int flags);\n\n#define gnutls_x509_crt_import_pkcs11_url gnutls_x509_crt_import_url\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_PKCS11_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/pkcs12.h",
    "content": "/*\n * Copyright (C) 2003-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_PKCS12_H\n#define GNUTLS_PKCS12_H\n\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n\t/* PKCS12 structures handling\n\t */\nstruct gnutls_pkcs12_int;\ntypedef struct gnutls_pkcs12_int *gnutls_pkcs12_t;\n\nstruct gnutls_pkcs12_bag_int;\ntypedef struct gnutls_pkcs12_bag_int *gnutls_pkcs12_bag_t;\n\nint gnutls_pkcs12_init(gnutls_pkcs12_t * pkcs12);\nvoid gnutls_pkcs12_deinit(gnutls_pkcs12_t pkcs12);\nint gnutls_pkcs12_import(gnutls_pkcs12_t pkcs12,\n\t\t\t const gnutls_datum_t * data,\n\t\t\t gnutls_x509_crt_fmt_t format, unsigned int flags);\nint gnutls_pkcs12_export(gnutls_pkcs12_t pkcs12,\n\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t void *output_data, size_t * output_data_size);\nint gnutls_pkcs12_export2(gnutls_pkcs12_t pkcs12,\n\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t  gnutls_datum_t * out);\n\nint gnutls_pkcs12_get_bag(gnutls_pkcs12_t pkcs12,\n\t\t\t  int indx, gnutls_pkcs12_bag_t bag);\nint gnutls_pkcs12_set_bag(gnutls_pkcs12_t pkcs12, gnutls_pkcs12_bag_t bag);\n\nint gnutls_pkcs12_generate_mac(gnutls_pkcs12_t pkcs12, const char *pass);\nint gnutls_pkcs12_generate_mac2(gnutls_pkcs12_t pkcs12, gnutls_mac_algorithm_t mac, const char *pass);\nint gnutls_pkcs12_verify_mac(gnutls_pkcs12_t pkcs12, const char *pass);\n\nint gnutls_pkcs12_bag_decrypt(gnutls_pkcs12_bag_t bag, const char *pass);\nint gnutls_pkcs12_bag_encrypt(gnutls_pkcs12_bag_t bag,\n\t\t\t      const char *pass, unsigned int flags);\n\nint\ngnutls_pkcs12_bag_enc_info(gnutls_pkcs12_bag_t bag, unsigned int *schema, unsigned int *cipher,\n\tvoid *salt, unsigned int *salt_size, unsigned int *iter_count, char **oid);\nint\ngnutls_pkcs12_mac_info(gnutls_pkcs12_t pkcs12, unsigned int *mac,\n\tvoid *salt, unsigned int *salt_size, unsigned int *iter_count, char **oid);\n\n#define GNUTLS_PKCS12_SP_INCLUDE_SELF_SIGNED 1\nint gnutls_pkcs12_simple_parse(gnutls_pkcs12_t p12,\n\t\t\t       const char *password,\n\t\t\t       gnutls_x509_privkey_t * key,\n\t\t\t       gnutls_x509_crt_t ** chain,\n\t\t\t       unsigned int *chain_len,\n\t\t\t       gnutls_x509_crt_t ** extra_certs,\n\t\t\t       unsigned int *extra_certs_len,\n\t\t\t       gnutls_x509_crl_t * crl,\n\t\t\t       unsigned int flags);\n\n/**\n * gnutls_pkcs12_bag_type_t:\n * @GNUTLS_BAG_EMPTY: Empty PKCS-12 bag.\n * @GNUTLS_BAG_PKCS8_ENCRYPTED_KEY: PKCS-12 bag with PKCS-8 encrypted key.\n * @GNUTLS_BAG_PKCS8_KEY: PKCS-12 bag with PKCS-8 key.\n * @GNUTLS_BAG_CERTIFICATE: PKCS-12 bag with certificate.\n * @GNUTLS_BAG_CRL: PKCS-12 bag with CRL.\n * @GNUTLS_BAG_SECRET: PKCS-12 bag with secret PKCS-9 keys.\n * @GNUTLS_BAG_ENCRYPTED: Encrypted PKCS-12 bag.\n * @GNUTLS_BAG_UNKNOWN: Unknown PKCS-12 bag.\n *\n * Enumeration of different PKCS 12 bag types.\n */\ntypedef enum gnutls_pkcs12_bag_type_t {\n\tGNUTLS_BAG_EMPTY = 0,\n\tGNUTLS_BAG_PKCS8_ENCRYPTED_KEY = 1,\n\tGNUTLS_BAG_PKCS8_KEY = 2,\n\tGNUTLS_BAG_CERTIFICATE = 3,\n\tGNUTLS_BAG_CRL = 4,\n\tGNUTLS_BAG_SECRET = 5,\t/* Secret data. Underspecified in pkcs-12,\n\t\t\t\t * gnutls extension. We use the PKCS-9\n\t\t\t\t * random nonce ID 1.2.840.113549.1.9.25.3\n\t\t\t\t * to store randomly generated keys.\n\t\t\t\t */\n\tGNUTLS_BAG_ENCRYPTED = 10,\n\tGNUTLS_BAG_UNKNOWN = 20\n} gnutls_pkcs12_bag_type_t;\n\nint\ngnutls_pkcs12_bag_get_type(gnutls_pkcs12_bag_t bag, unsigned indx);\nint gnutls_pkcs12_bag_get_data(gnutls_pkcs12_bag_t bag, unsigned indx,\n\t\t\t       gnutls_datum_t * data);\nint gnutls_pkcs12_bag_set_data(gnutls_pkcs12_bag_t bag,\n\t\t\t       gnutls_pkcs12_bag_type_t type,\n\t\t\t       const gnutls_datum_t * data);\nint gnutls_pkcs12_bag_set_crl(gnutls_pkcs12_bag_t bag,\n\t\t\t      gnutls_x509_crl_t crl);\nint gnutls_pkcs12_bag_set_crt(gnutls_pkcs12_bag_t bag,\n\t\t\t      gnutls_x509_crt_t crt);\n\nint\ngnutls_pkcs12_bag_set_privkey(gnutls_pkcs12_bag_t bag,\n\t\t\t      gnutls_x509_privkey_t privkey,\n\t\t\t      const char *password, unsigned flags);\n\nint gnutls_pkcs12_bag_init(gnutls_pkcs12_bag_t * bag);\nvoid gnutls_pkcs12_bag_deinit(gnutls_pkcs12_bag_t bag);\nint gnutls_pkcs12_bag_get_count(gnutls_pkcs12_bag_t bag);\n\nint gnutls_pkcs12_bag_get_key_id(gnutls_pkcs12_bag_t bag, unsigned indx,\n\t\t\t\t gnutls_datum_t * id);\nint gnutls_pkcs12_bag_set_key_id(gnutls_pkcs12_bag_t bag, unsigned indx,\n\t\t\t\t const gnutls_datum_t * id);\n\nint gnutls_pkcs12_bag_get_friendly_name(gnutls_pkcs12_bag_t bag,\n\t\t\t\t\tunsigned indx, char **name);\nint gnutls_pkcs12_bag_set_friendly_name(gnutls_pkcs12_bag_t bag,\n\t\t\t\t\tunsigned indx, const char *name);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_PKCS12_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/pkcs7.h",
    "content": "/*\n * Copyright (C) 2003-2012 Free Software Foundation, Inc.\n * Copyright (C) 2015 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for the X.509\n * certificate and CRL handling functions.\n */\n\n#ifndef GNUTLS_PKCS7_H\n#define GNUTLS_PKCS7_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/* PKCS7 structures handling\n */\nstruct gnutls_pkcs7_int;\ntypedef struct gnutls_pkcs7_int *gnutls_pkcs7_t;\n\nint gnutls_pkcs7_init(gnutls_pkcs7_t * pkcs7);\nvoid gnutls_pkcs7_deinit(gnutls_pkcs7_t pkcs7);\nint gnutls_pkcs7_import(gnutls_pkcs7_t pkcs7,\n\t\t\tconst gnutls_datum_t * data,\n\t\t\tgnutls_x509_crt_fmt_t format);\nint gnutls_pkcs7_export(gnutls_pkcs7_t pkcs7,\n\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\tvoid *output_data, size_t * output_data_size);\nint gnutls_pkcs7_export2(gnutls_pkcs7_t pkcs7,\n\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t gnutls_datum_t * out);\n\nint gnutls_pkcs7_get_signature_count(gnutls_pkcs7_t pkcs7);\n\n#define GNUTLS_PKCS7_EDATA_GET_RAW (1<<24)\nint gnutls_pkcs7_get_embedded_data(gnutls_pkcs7_t pkcs7, unsigned flags, gnutls_datum_t *data);\n\nconst char *\ngnutls_pkcs7_get_embedded_data_oid(gnutls_pkcs7_t pkcs7);\n\nint gnutls_pkcs7_get_crt_count(gnutls_pkcs7_t pkcs7);\nint gnutls_pkcs7_get_crt_raw(gnutls_pkcs7_t pkcs7, unsigned indx,\n\t\t\t     void *certificate, size_t * certificate_size);\n\nint gnutls_pkcs7_set_crt_raw(gnutls_pkcs7_t pkcs7,\n\t\t\t     const gnutls_datum_t * crt);\nint gnutls_pkcs7_set_crt(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t crt);\nint gnutls_pkcs7_delete_crt(gnutls_pkcs7_t pkcs7, int indx);\n\nint gnutls_pkcs7_get_crl_raw(gnutls_pkcs7_t pkcs7,\n\t\t\t     unsigned indx, void *crl, size_t * crl_size);\nint gnutls_pkcs7_get_crl_count(gnutls_pkcs7_t pkcs7);\n\nint gnutls_pkcs7_set_crl_raw(gnutls_pkcs7_t pkcs7,\n\t\t\t     const gnutls_datum_t * crl);\nint gnutls_pkcs7_set_crl(gnutls_pkcs7_t pkcs7, gnutls_x509_crl_t crl);\nint gnutls_pkcs7_delete_crl(gnutls_pkcs7_t pkcs7, int indx);\n\ntypedef struct gnutls_pkcs7_attrs_st *gnutls_pkcs7_attrs_t;\n\ntypedef struct gnutls_pkcs7_signature_info_st {\n\tgnutls_sign_algorithm_t algo;\n\tgnutls_datum_t sig;\n\tgnutls_datum_t issuer_dn;\n\tgnutls_datum_t signer_serial;\n\tgnutls_datum_t issuer_keyid;\n\ttime_t signing_time;\n\tgnutls_pkcs7_attrs_t signed_attrs;\n\tgnutls_pkcs7_attrs_t unsigned_attrs;\n\tchar pad[64];\n} gnutls_pkcs7_signature_info_st;\n\nvoid gnutls_pkcs7_signature_info_deinit(gnutls_pkcs7_signature_info_st *info);\nint gnutls_pkcs7_get_signature_info(gnutls_pkcs7_t pkcs7, unsigned idx, gnutls_pkcs7_signature_info_st *info);\n\nint gnutls_pkcs7_verify_direct(gnutls_pkcs7_t pkcs7, gnutls_x509_crt_t signer,\n\t\t\t       unsigned idx, const gnutls_datum_t *data, unsigned flags);\nint gnutls_pkcs7_verify(gnutls_pkcs7_t pkcs7, gnutls_x509_trust_list_t tl,\n\t\t\tgnutls_typed_vdata_st * vdata, unsigned int vdata_size,\n\t\t\tunsigned idx, const gnutls_datum_t *data, unsigned flags);\n\n#define GNUTLS_PKCS7_ATTR_ENCODE_OCTET_STRING 1\nint gnutls_pkcs7_add_attr(gnutls_pkcs7_attrs_t *list, const char *oid, gnutls_datum_t *data, unsigned flags);\nvoid gnutls_pkcs7_attrs_deinit(gnutls_pkcs7_attrs_t list);\nint gnutls_pkcs7_get_attr(gnutls_pkcs7_attrs_t list, unsigned idx, char **oid, gnutls_datum_t *data, unsigned flags);\n\n/**\n * gnutls_pkcs7_sign_flags:\n * @GNUTLS_PKCS7_EMBED_DATA: The signed data will be embedded in the structure.\n * @GNUTLS_PKCS7_INCLUDE_TIME: The signing time will be included in the structure.\n * @GNUTLS_PKCS7_INCLUDE_CERT: The signer's certificate will be included in the cert list.\n * @GNUTLS_PKCS7_WRITE_SPKI: Use the signer's key identifier instead of name.\n *\n * Enumeration of the different PKCS #7 signature flags.\n */\ntypedef enum gnutls_pkcs7_sign_flags {\n\tGNUTLS_PKCS7_EMBED_DATA = 1,\n\tGNUTLS_PKCS7_INCLUDE_TIME = (1<<1),\n\tGNUTLS_PKCS7_INCLUDE_CERT = (1<<2),\n\tGNUTLS_PKCS7_WRITE_SPKI = (1<<3)\n} gnutls_pkcs7_sign_flags;\n\nint gnutls_pkcs7_sign(gnutls_pkcs7_t pkcs7,\n\t\t      gnutls_x509_crt_t signer,\n\t\t      gnutls_privkey_t signer_key,\n\t\t      const gnutls_datum_t *data,\n\t\t      gnutls_pkcs7_attrs_t signed_attrs,\n\t\t      gnutls_pkcs7_attrs_t unsigned_attrs,\n\t\t      gnutls_digest_algorithm_t dig,\n\t\t      unsigned flags);\n\nint\ngnutls_pkcs7_get_crt_raw2(gnutls_pkcs7_t pkcs7,\n\t\t\t  unsigned indx, gnutls_datum_t *cert);\nint\ngnutls_pkcs7_get_crl_raw2(gnutls_pkcs7_t pkcs7,\n\t\t\t  unsigned indx, gnutls_datum_t *crl);\n\nint gnutls_pkcs7_print(gnutls_pkcs7_t pkcs7,\n\t\t       gnutls_certificate_print_formats_t format,\n\t\t       gnutls_datum_t * out);\n\nint gnutls_pkcs7_print_signature_info(gnutls_pkcs7_signature_info_st * info,\n\t\t\t\t      gnutls_certificate_print_formats_t format,\n\t\t\t\t      gnutls_datum_t * out);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_PKCS7_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/self-test.h",
    "content": "/*\n * Copyright (C) 2014 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_SELF_TEST_H\n#define GNUTLS_SELF_TEST_H\n\n#include <gnutls/gnutls.h>\n\n /* Self checking functions */\n \n#define GNUTLS_SELF_TEST_FLAG_ALL 1\n#define GNUTLS_SELF_TEST_FLAG_NO_COMPAT (1<<1)\n\nint gnutls_cipher_self_test(unsigned flags, gnutls_cipher_algorithm_t cipher);\nint gnutls_mac_self_test(unsigned flags, gnutls_mac_algorithm_t mac);\nint gnutls_digest_self_test(unsigned flags, gnutls_digest_algorithm_t digest);\nint gnutls_pk_self_test(unsigned flags, gnutls_pk_algorithm_t pk);\nint gnutls_hkdf_self_test(unsigned flags, gnutls_mac_algorithm_t mac);\nint gnutls_pbkdf2_self_test(unsigned flags, gnutls_mac_algorithm_t mac);\nint gnutls_tlsprf_self_test(unsigned flags, gnutls_mac_algorithm_t mac);\n\n#endif /* GNUTLS_SELF_TEST_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/socket.h",
    "content": "/*\n * Copyright (C) 2016 Free Software Foundation, Inc.\n *\n * Author: Tim Ruehsen\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains socket related types, prototypes and includes.\n */\n\n#ifndef GNUTLS_SOCKET_H\n#define GNUTLS_SOCKET_H\n\n#include <gnutls/gnutls.h>\n\n/* Get socklen_t */\n#include <sys/socket.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/**\n * gnutls_transport_ktls_enable_flags_t:\n * @GNUTLS_KTLS_RECV: ktls enabled for recv function.\n * @GNUTLS_KTLS_SEND: ktls enabled for send function.\n * @GNUTLS_KTLS_DUPLEX: ktls enabled for both recv and send functions.\n *\n * Flag enumeration of ktls enable status for recv and send functions.\n * This is used by gnutls_transport_is_ktls_enabled().\n *\n * Since: 3.7.3\n */\ntypedef enum {\n\tGNUTLS_KTLS_RECV = 1 << 0,\n\tGNUTLS_KTLS_SEND = 1 << 1,\n\tGNUTLS_KTLS_DUPLEX = GNUTLS_KTLS_RECV | GNUTLS_KTLS_SEND,\n} gnutls_transport_ktls_enable_flags_t;\n\n\ngnutls_transport_ktls_enable_flags_t\ngnutls_transport_is_ktls_enabled(gnutls_session_t session);\n\nvoid gnutls_transport_set_fastopen(gnutls_session_t session,\n                                   int fd,\n                                   struct sockaddr *connect_addr,\n                                   socklen_t connect_addrlen,\n                                   unsigned int flags);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_SOCKET_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/system-keys.h",
    "content": "/*\n * Copyright (C) 2014 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_SYSTEM_KEYS_H\n#define GNUTLS_SYSTEM_KEYS_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* This API allows to access user key and certificate pairs that are\n * available in the current system. If any passwords are required,\n * they will be requested through the pin callbacks.\n */\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\nstruct system_key_iter_st;\ntypedef struct system_key_iter_st *gnutls_system_key_iter_t;\n\nvoid gnutls_system_key_iter_deinit(gnutls_system_key_iter_t iter);\nint\ngnutls_system_key_iter_get_info(gnutls_system_key_iter_t *iter,\n\t\t\t       unsigned cert_type /* gnutls_certificate_type_t */,\n\t\t\t       char **cert_url,\n\t\t\t       char **key_url,\n\t\t\t       char **label,\n\t\t\t       gnutls_datum_t *der,\n\t\t\t       unsigned int flags);\n\nint gnutls_system_key_delete(const char *cert_url, const char *key_url);\n\nint gnutls_system_key_add_x509(gnutls_x509_crt_t crt, gnutls_x509_privkey_t privkey,\n\t\t\t\tconst char *label, char **cert_url, char **key_url);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_SYSTEM_KEYS_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/tpm.h",
    "content": "/*\n * Copyright (C) 2010-2012 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_TPM_H\n#define GNUTLS_TPM_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\nstruct tpm_key_list_st;\ntypedef struct tpm_key_list_st *gnutls_tpm_key_list_t;\n\n#define GNUTLS_TPM_KEY_SIGNING (1<<1)\n#define GNUTLS_TPM_REGISTER_KEY (1<<2)\n#define GNUTLS_TPM_KEY_USER (1<<3)\n\n/**\n * gnutls_tpmkey_fmt_t:\n * @GNUTLS_TPMKEY_FMT_RAW: The portable data format.\n * @GNUTLS_TPMKEY_FMT_DER: An alias for the raw format.\n * @GNUTLS_TPMKEY_FMT_CTK_PEM: A custom data format used by some TPM tools.\n *\n * Enumeration of different certificate encoding formats.\n */\ntypedef enum {\n\tGNUTLS_TPMKEY_FMT_RAW = 0,\n\tGNUTLS_TPMKEY_FMT_DER = GNUTLS_TPMKEY_FMT_RAW,\n\tGNUTLS_TPMKEY_FMT_CTK_PEM = 1\n} gnutls_tpmkey_fmt_t;\n\nint\ngnutls_tpm_privkey_generate(gnutls_pk_algorithm_t pk,\n\t\t\t    unsigned int bits,\n\t\t\t    const char *srk_password,\n\t\t\t    const char *key_password,\n\t\t\t    gnutls_tpmkey_fmt_t format,\n\t\t\t    gnutls_x509_crt_fmt_t pub_format,\n\t\t\t    gnutls_datum_t * privkey,\n\t\t\t    gnutls_datum_t * pubkey, unsigned int flags);\n\nvoid gnutls_tpm_key_list_deinit(gnutls_tpm_key_list_t list);\nint gnutls_tpm_key_list_get_url(gnutls_tpm_key_list_t list,\n\t\t\t\tunsigned int idx, char **url,\n\t\t\t\tunsigned int flags);\nint gnutls_tpm_get_registered(gnutls_tpm_key_list_t * list);\nint gnutls_tpm_privkey_delete(const char *url, const char *srk_password);\n\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_TPM_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/urls.h",
    "content": "/*\n * Copyright (C) 2014 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n#ifndef GNUTLS_URLS_H\n#define GNUTLS_URLS_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n#include <gnutls/abstract.h>\n\n/* This API allows to register application specific URLs for\n * keys and certificates.\n */\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\ntypedef int (*gnutls_privkey_import_url_func)(gnutls_privkey_t pkey,\n\t\t\t\t\t       const char *url, unsigned flags);\n\ntypedef int (*gnutls_x509_crt_import_url_func)(gnutls_x509_crt_t pkey,\n\t\t\t\t\t        const char *url, unsigned flags);\n\n/* The following callbacks are optional */\n\n/* This is to enable gnutls_pubkey_import_url() */\ntypedef int (*gnutls_pubkey_import_url_func)(gnutls_pubkey_t pkey,\n\t\t\t\t\t     const char *url, unsigned flags);\n\n/* This is to allow constructing a certificate chain. It will be provided\n * the initial certificate URL and the certificate to find its issuer, and must\n * return zero and the DER encoding of the issuer's certificate. If not available,\n * it should return GNUTLS_E_REQUESTED_DATA_NOT_AVAILABLE. */\ntypedef int (*gnutls_get_raw_issuer_func)(const char *url, gnutls_x509_crt_t crt,\n\t\t\t\t\t  gnutls_datum_t *issuer_der, unsigned flags);\n\ntypedef struct gnutls_custom_url_st {\n\tconst char *name;\n\tunsigned name_size;\n\tgnutls_privkey_import_url_func import_key;\n\tgnutls_x509_crt_import_url_func import_crt;\n\tgnutls_pubkey_import_url_func import_pubkey;\n\tgnutls_get_raw_issuer_func get_issuer;\n\tvoid *future1; /* replace in a future extension */\n\tvoid *future2; /* replace in a future extension */\n} gnutls_custom_url_st;\n\nint gnutls_register_custom_url(const gnutls_custom_url_st *st);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_URLS_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/x509-ext.h",
    "content": "/*\n * Copyright (C) 2014 Free Software Foundation, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* Prototypes for direct handling of extension data */\n\n#ifndef GNUTLS_X509_EXT_H\n#define GNUTLS_X509_EXT_H\n\n#include <gnutls/gnutls.h>\n#include <gnutls/x509.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\ntypedef struct gnutls_subject_alt_names_st *gnutls_subject_alt_names_t;\n\nint gnutls_subject_alt_names_init(gnutls_subject_alt_names_t *);\nvoid gnutls_subject_alt_names_deinit(gnutls_subject_alt_names_t sans);\nint gnutls_subject_alt_names_get(gnutls_subject_alt_names_t sans, unsigned int seq,\n\t\t\t\t unsigned int *san_type, gnutls_datum_t * san,\n\t\t\t\t gnutls_datum_t * othername_oid);\nint gnutls_subject_alt_names_set(gnutls_subject_alt_names_t sans,\n\t\t\t\t unsigned int san_type,\n\t\t\t\t const gnutls_datum_t * san,\n\t\t\t\t const char* othername_oid);\n\n\nint gnutls_x509_ext_import_subject_alt_names(const gnutls_datum_t * ext,\n\t\t\t\t\t gnutls_subject_alt_names_t,\n\t\t\t\t\t unsigned int flags);\nint gnutls_x509_ext_export_subject_alt_names(gnutls_subject_alt_names_t,\n\t\t\t\t\t  gnutls_datum_t * ext);\n\n/* They are exactly the same */\n#define gnutls_x509_ext_import_issuer_alt_name gnutls_x509_ext_import_subject_alt_name\n#define gnutls_x509_ext_export_issuer_alt_name gnutls_x509_ext_export_subject_alt_name\n\ntypedef struct gnutls_x509_crl_dist_points_st *gnutls_x509_crl_dist_points_t;\n\nint gnutls_x509_crl_dist_points_init(gnutls_x509_crl_dist_points_t *);\nvoid gnutls_x509_crl_dist_points_deinit(gnutls_x509_crl_dist_points_t);\nint gnutls_x509_crl_dist_points_get(gnutls_x509_crl_dist_points_t, unsigned int seq,\n\t\t\t\t  unsigned int *type,\n\t\t\t\t  gnutls_datum_t *dist, unsigned int *reason_flags);\nint gnutls_x509_crl_dist_points_set(gnutls_x509_crl_dist_points_t,\n\t\t\t\t gnutls_x509_subject_alt_name_t type,\n\t\t\t\t const gnutls_datum_t *dist, unsigned int reason_flags);\n\nint gnutls_x509_ext_import_crl_dist_points(const gnutls_datum_t * ext,\n\t\t\t\t\tgnutls_x509_crl_dist_points_t dp,\n\t\t\t\t\tunsigned int flags);\nint gnutls_x509_ext_export_crl_dist_points(gnutls_x509_crl_dist_points_t dp,\n\t\t\t\t\tgnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_name_constraints(const gnutls_datum_t * ext,\n\t\t\t\t\t gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t unsigned int flags);\nint gnutls_x509_ext_export_name_constraints(gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t gnutls_datum_t * ext);\n\ntypedef struct gnutls_x509_aia_st *gnutls_x509_aia_t;\n\nint gnutls_x509_aia_init(gnutls_x509_aia_t *);\nvoid gnutls_x509_aia_deinit(gnutls_x509_aia_t);\nint gnutls_x509_aia_get(gnutls_x509_aia_t aia, unsigned int seq,\n\t\t\tgnutls_datum_t *oid,\n\t\t\tunsigned *san_type,\n\t\t\tgnutls_datum_t *san);\nint gnutls_x509_aia_set(gnutls_x509_aia_t aia,\n\t\t\tconst char *oid,\n\t\t\tunsigned san_type,\n\t\t\tconst gnutls_datum_t * san);\n\nint gnutls_x509_ext_import_aia(const gnutls_datum_t * ext,\n\t\t\t\tgnutls_x509_aia_t,\n\t\t\t\tunsigned int flags);\nint gnutls_x509_ext_export_aia(gnutls_x509_aia_t aia,\n\t\t\t\t\t      gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_subject_key_id(const gnutls_datum_t * ext,\n\t\t\t\t       gnutls_datum_t * id);\nint gnutls_x509_ext_export_subject_key_id(const gnutls_datum_t * id,\n\t\t\t\t       gnutls_datum_t * ext);\n\ntypedef struct gnutls_x509_aki_st *gnutls_x509_aki_t;\n\nint gnutls_x509_ext_export_authority_key_id(gnutls_x509_aki_t,\n\t\t\t\t\t gnutls_datum_t * ext);\nint gnutls_x509_ext_import_authority_key_id(const gnutls_datum_t * ext,\n\t\t\t\t\t gnutls_x509_aki_t,\n\t\t\t\t\t unsigned int flags);\n\nint gnutls_x509_othername_to_virtual(const char *oid, \n\t\t\t\t     const gnutls_datum_t *othername,\n\t\t\t\t     unsigned int *virt_type,\n\t\t\t\t     gnutls_datum_t *virt);\n\nint gnutls_x509_aki_init(gnutls_x509_aki_t *);\nint gnutls_x509_aki_get_id(gnutls_x509_aki_t, gnutls_datum_t *id);\nint gnutls_x509_aki_get_cert_issuer(gnutls_x509_aki_t aki, unsigned int seq,\n\t\t\t\t unsigned int *san_type, gnutls_datum_t * san,\n\t\t\t\t gnutls_datum_t *othername_oid,\n\t\t\t\t gnutls_datum_t *serial);\nint gnutls_x509_aki_set_id(gnutls_x509_aki_t aki, const gnutls_datum_t *id);\nint gnutls_x509_aki_set_cert_issuer(gnutls_x509_aki_t aki, \n\t\t\t\t unsigned int san_type, \n\t\t\t\t const gnutls_datum_t * san,\n\t\t\t\t const char *othername_oid,\n\t\t\t\t const gnutls_datum_t * serial);\nvoid gnutls_x509_aki_deinit(gnutls_x509_aki_t);\n\nint gnutls_x509_ext_import_private_key_usage_period(const gnutls_datum_t * ext,\n\t\t\t\t\t\t time_t * activation,\n\t\t\t\t\t\t time_t * expiration);\nint gnutls_x509_ext_export_private_key_usage_period(time_t activation,\n\t\t\t\t\t\t time_t expiration,\n\t\t\t\t\t\t gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_basic_constraints(const gnutls_datum_t * ext,\n\t\t\t\t\t  unsigned int *ca, int *pathlen);\nint gnutls_x509_ext_export_basic_constraints(unsigned int ca, int pathlen,\n\t\t\t\t\t  gnutls_datum_t * ext);\n\ntypedef struct gnutls_x509_key_purposes_st *gnutls_x509_key_purposes_t;\n\nint gnutls_x509_key_purpose_init(gnutls_x509_key_purposes_t *p);\nvoid gnutls_x509_key_purpose_deinit(gnutls_x509_key_purposes_t p);\nint gnutls_x509_key_purpose_set(gnutls_x509_key_purposes_t p, const char *oid);\nint gnutls_x509_key_purpose_get(gnutls_x509_key_purposes_t p, unsigned idx, gnutls_datum_t *oid);\n\nint gnutls_x509_ext_import_key_purposes(const gnutls_datum_t * ext,\n\t\t\t\t     gnutls_x509_key_purposes_t,\n\t\t\t\t     unsigned int flags);\nint gnutls_x509_ext_export_key_purposes(gnutls_x509_key_purposes_t,\n\t\t\t\t     gnutls_datum_t * ext);\n\n\nint gnutls_x509_ext_import_key_usage(const gnutls_datum_t * ext,\n\t\t\t\t  unsigned int *key_usage);\nint gnutls_x509_ext_export_key_usage(unsigned int key_usage,\n\t\t\t\t  gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_inhibit_anypolicy(const gnutls_datum_t * ext,\n\t\t\t\t  unsigned int *skipcerts);\nint gnutls_x509_ext_export_inhibit_anypolicy(unsigned int skipcerts,\n\t\t\t\t  gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_proxy(const gnutls_datum_t * ext, int *pathlen,\n\t\t\t      char **policyLanguage, char **policy,\n\t\t\t      size_t * sizeof_policy);\nint gnutls_x509_ext_export_proxy(int pathLenConstraint, const char *policyLanguage,\n\t\t\t      const char *policy, size_t sizeof_policy,\n\t\t\t      gnutls_datum_t * ext);\n\ntypedef struct gnutls_x509_policies_st *gnutls_x509_policies_t;\n\nint gnutls_x509_policies_init(gnutls_x509_policies_t *);\nvoid gnutls_x509_policies_deinit(gnutls_x509_policies_t);\n\nint gnutls_x509_policies_get(gnutls_x509_policies_t policies, unsigned int seq,\n\t\t\t\t struct gnutls_x509_policy_st *policy);\nint gnutls_x509_policies_set(gnutls_x509_policies_t policies,\n\t\t\t\t const struct gnutls_x509_policy_st *policy);\n\nint gnutls_x509_ext_import_policies(const gnutls_datum_t * ext, gnutls_x509_policies_t\n\t\t\t\t policies,\n\t\t\t\t unsigned int flags);\nint gnutls_x509_ext_export_policies(gnutls_x509_policies_t policies,\n\t\t\t\t gnutls_datum_t * ext);\n\nint gnutls_x509_ext_import_tlsfeatures(const gnutls_datum_t * ext,\n\t\t\t\t\t\t\t\t\t   gnutls_x509_tlsfeatures_t,\n\t\t\t\t\t\t\t\t\t   unsigned int flags);\n\nint gnutls_x509_ext_export_tlsfeatures(gnutls_x509_tlsfeatures_t f,\n\t\t\t\t\t  gnutls_datum_t * ext);\n\nint gnutls_x509_tlsfeatures_add(gnutls_x509_tlsfeatures_t f, unsigned int feature);\n\ntypedef struct gnutls_x509_ct_scts_st *gnutls_x509_ct_scts_t;\n\nint gnutls_x509_ext_ct_scts_init(gnutls_x509_ct_scts_t * scts);\nvoid gnutls_x509_ext_ct_scts_deinit(gnutls_x509_ct_scts_t scts);\nint gnutls_x509_ext_ct_import_scts(const gnutls_datum_t * ext,\n\t\t\t\t   gnutls_x509_ct_scts_t scts, unsigned int flags);\nint gnutls_x509_ext_ct_export_scts(const gnutls_x509_ct_scts_t scts, gnutls_datum_t * ext);\nint gnutls_x509_ct_sct_get_version(const gnutls_x509_ct_scts_t scts, unsigned idx,\n\t\t\t\t   unsigned int *version_out);\nint gnutls_x509_ct_sct_get(const gnutls_x509_ct_scts_t scts,\n\t\t\t   unsigned idx,\n\t\t\t   time_t *timestamp,\n\t\t\t   gnutls_datum_t *logid,\n\t\t\t   gnutls_sign_algorithm_t *sigalg,\n\t\t\t   gnutls_datum_t *signature);\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_X509_EXT_H */\n"
  },
  {
    "path": "thirdparty/64/include/gnutls/x509.h",
    "content": "/*\n * Copyright (C) 2003-2016 Free Software Foundation, Inc.\n * Copyright (C) 2015-2016 Red Hat, Inc.\n *\n * Author: Nikos Mavrogiannopoulos\n *\n * This file is part of GnuTLS.\n *\n * The GnuTLS is free software; you can redistribute it and/or\n * modify it under the terms of the GNU Lesser General Public License\n * as published by the Free Software Foundation; either version 2.1 of\n * the License, or (at your option) any later version.\n *\n * This library is distributed in the hope that it will be useful, but\n * WITHOUT ANY WARRANTY; without even the implied warranty of\n * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n * Lesser General Public License for more details.\n *\n * You should have received a copy of the GNU Lesser General Public License\n * along with this program.  If not, see <https://www.gnu.org/licenses/>\n *\n */\n\n/* This file contains the types and prototypes for the X.509\n * certificate and CRL handling functions.\n */\n\n#ifndef GNUTLS_X509_H\n#define GNUTLS_X509_H\n\n#include <gnutls/gnutls.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n/* *INDENT-ON* */\n\n/* Some OIDs usually found in Distinguished names, or\n * in Subject Directory Attribute extensions.\n */\n#define GNUTLS_OID_X520_COUNTRY_NAME\t\t\"2.5.4.6\"\n#define GNUTLS_OID_X520_ORGANIZATION_NAME\t\"2.5.4.10\"\n#define GNUTLS_OID_X520_ORGANIZATIONAL_UNIT_NAME \"2.5.4.11\"\n#define GNUTLS_OID_X520_COMMON_NAME\t\t\"2.5.4.3\"\n#define GNUTLS_OID_X520_LOCALITY_NAME\t\t\"2.5.4.7\"\n#define GNUTLS_OID_X520_STATE_OR_PROVINCE_NAME\t\"2.5.4.8\"\n\n#define GNUTLS_OID_X520_INITIALS\t\t\"2.5.4.43\"\n#define GNUTLS_OID_X520_GENERATION_QUALIFIER\t\"2.5.4.44\"\n#define GNUTLS_OID_X520_SURNAME\t\t\t\"2.5.4.4\"\n#define GNUTLS_OID_X520_GIVEN_NAME\t\t\"2.5.4.42\"\n#define GNUTLS_OID_X520_TITLE\t\t\t\"2.5.4.12\"\n#define GNUTLS_OID_X520_DN_QUALIFIER\t\t\"2.5.4.46\"\n#define GNUTLS_OID_X520_PSEUDONYM\t\t\"2.5.4.65\"\n#define GNUTLS_OID_X520_POSTALCODE              \"2.5.4.17\"\n#define GNUTLS_OID_X520_NAME                    \"2.5.4.41\"\n\n#define GNUTLS_OID_LDAP_DC\t\t\t\"0.9.2342.19200300.100.1.25\"\n#define GNUTLS_OID_LDAP_UID\t\t\t\"0.9.2342.19200300.100.1.1\"\n\n/* The following should not be included in DN.\n */\n#define GNUTLS_OID_PKCS9_EMAIL\t\t\t\"1.2.840.113549.1.9.1\"\n\n#define GNUTLS_OID_PKIX_DATE_OF_BIRTH\t\t\"1.3.6.1.5.5.7.9.1\"\n#define GNUTLS_OID_PKIX_PLACE_OF_BIRTH\t\t\"1.3.6.1.5.5.7.9.2\"\n#define GNUTLS_OID_PKIX_GENDER\t\t\t\"1.3.6.1.5.5.7.9.3\"\n#define GNUTLS_OID_PKIX_COUNTRY_OF_CITIZENSHIP\t\"1.3.6.1.5.5.7.9.4\"\n#define GNUTLS_OID_PKIX_COUNTRY_OF_RESIDENCE\t\"1.3.6.1.5.5.7.9.5\"\n\n/* Key purpose Object Identifiers.\n */\n#define GNUTLS_KP_TLS_WWW_SERVER\t\t\"1.3.6.1.5.5.7.3.1\"\n#define GNUTLS_KP_TLS_WWW_CLIENT                \"1.3.6.1.5.5.7.3.2\"\n#define GNUTLS_KP_CODE_SIGNING\t\t\t\"1.3.6.1.5.5.7.3.3\"\n#define GNUTLS_KP_MS_SMART_CARD_LOGON\t\t\"1.3.6.1.4.1.311.20.2.2\"\n#define GNUTLS_KP_EMAIL_PROTECTION\t\t\"1.3.6.1.5.5.7.3.4\"\n#define GNUTLS_KP_TIME_STAMPING\t\t\t\"1.3.6.1.5.5.7.3.8\"\n#define GNUTLS_KP_OCSP_SIGNING\t\t\t\"1.3.6.1.5.5.7.3.9\"\n#define GNUTLS_KP_IPSEC_IKE\t\t\t\"1.3.6.1.5.5.7.3.17\"\n#define GNUTLS_KP_ANY\t\t\t\t\"2.5.29.37.0\"\n\n#define GNUTLS_KP_FLAG_DISALLOW_ANY\t\t1\n\n#define GNUTLS_OID_AIA\t\t\t\t\"1.3.6.1.5.5.7.1.1\"\n#define GNUTLS_OID_AD_OCSP\t\t\t\"1.3.6.1.5.5.7.48.1\"\n#define GNUTLS_OID_AD_CAISSUERS\t\t\t\"1.3.6.1.5.5.7.48.2\"\n\n#define GNUTLS_FSAN_SET 0\n#define GNUTLS_FSAN_APPEND 1\n#define GNUTLS_FSAN_ENCODE_OCTET_STRING (1<<1)\n#define GNUTLS_FSAN_ENCODE_UTF8_STRING (1<<2)\n\n#define GNUTLS_X509EXT_OID_SUBJECT_KEY_ID \"2.5.29.14\"\n#define GNUTLS_X509EXT_OID_KEY_USAGE \"2.5.29.15\"\n#define GNUTLS_X509EXT_OID_PRIVATE_KEY_USAGE_PERIOD \"2.5.29.16\"\n#define GNUTLS_X509EXT_OID_SAN \"2.5.29.17\"\n#define GNUTLS_X509EXT_OID_IAN \"2.5.29.18\"\n#define GNUTLS_X509EXT_OID_BASIC_CONSTRAINTS \"2.5.29.19\"\n#define GNUTLS_X509EXT_OID_NAME_CONSTRAINTS \"2.5.29.30\"\n#define GNUTLS_X509EXT_OID_CRL_DIST_POINTS \"2.5.29.31\"\n#define GNUTLS_X509EXT_OID_CRT_POLICY \"2.5.29.32\"\n#define GNUTLS_X509EXT_OID_AUTHORITY_KEY_ID \"2.5.29.35\"\n#define GNUTLS_X509EXT_OID_EXTENDED_KEY_USAGE \"2.5.29.37\"\n#define GNUTLS_X509EXT_OID_INHIBIT_ANYPOLICY \"2.5.29.52\"\n#define GNUTLS_X509EXT_OID_AUTHORITY_INFO_ACCESS \"1.3.6.1.5.5.7.1.1\"\n#define GNUTLS_X509EXT_OID_PROXY_CRT_INFO \"1.3.6.1.5.5.7.1.14\"\n#define GNUTLS_X509EXT_OID_TLSFEATURES \"1.3.6.1.5.5.7.1.24\"\n#define GNUTLS_X509EXT_OID_CT_SCT_V1 \"1.3.6.1.4.1.11129.2.4.2\"\n\n#define GNUTLS_X509_OID_POLICY_ANY \"2.5.29.54\"\n\n/* Certificate handling functions.\n */\n\n/**\n * gnutls_certificate_import_flags:\n * @GNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED: Fail if the\n *   certificates in the buffer are more than the space allocated for\n *   certificates. The error code will be %GNUTLS_E_SHORT_MEMORY_BUFFER.\n * @GNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED: Fail if the certificates\n *   in the buffer are not ordered starting from subject to issuer.\n *   The error code will be %GNUTLS_E_CERTIFICATE_LIST_UNSORTED.\n * @GNUTLS_X509_CRT_LIST_SORT: Sort the certificate chain if unsorted.\n *\n * Enumeration of different certificate import flags.\n */\ntypedef enum gnutls_certificate_import_flags {\n\tGNUTLS_X509_CRT_LIST_IMPORT_FAIL_IF_EXCEED = 1,\n\tGNUTLS_X509_CRT_LIST_FAIL_IF_UNSORTED = 1<<1,\n\tGNUTLS_X509_CRT_LIST_SORT = 1<<2\n} gnutls_certificate_import_flags;\n\nint gnutls_x509_crt_init(gnutls_x509_crt_t * cert);\nvoid gnutls_x509_crt_deinit(gnutls_x509_crt_t cert);\n\n/**\n * gnutls_certificate_import_flags:\n * @GNUTLS_X509_CRT_FLAG_IGNORE_SANITY: Ignore any sanity checks at the\n *   import of the certificate; i.e., ignore checks such as version/field\n *   matching and strict time field checks. Intended to be used for debugging.\n *\n * Enumeration of different certificate flags.\n */\ntypedef enum gnutls_x509_crt_flags {\n\tGNUTLS_X509_CRT_FLAG_IGNORE_SANITY = 1\n} gnutls_x509_crt_flags;\nvoid gnutls_x509_crt_set_flags(gnutls_x509_crt_t cert, unsigned flags);\n\nunsigned gnutls_x509_crt_equals(gnutls_x509_crt_t cert1, gnutls_x509_crt_t cert2);\nunsigned gnutls_x509_crt_equals2(gnutls_x509_crt_t cert1, const gnutls_datum_t * der);\n\nint gnutls_x509_crt_import(gnutls_x509_crt_t cert,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   gnutls_x509_crt_fmt_t format);\nint gnutls_x509_crt_list_import2(gnutls_x509_crt_t ** certs,\n\t\t\t\t unsigned int *size,\n\t\t\t\t const gnutls_datum_t * data,\n\t\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t\t unsigned int flags);\nint gnutls_x509_crt_list_import(gnutls_x509_crt_t * certs,\n\t\t\t\tunsigned int *cert_max,\n\t\t\t\tconst gnutls_datum_t * data,\n\t\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\t\tunsigned int flags);\n\nint gnutls_x509_crt_import_url(gnutls_x509_crt_t crt,\n\t\t\t\t      const char *url, unsigned int flags\n\t\t\t\t      /* GNUTLS_PKCS11_OBJ_FLAG_* */\n    );\n\nint\ngnutls_x509_crt_list_import_url(gnutls_x509_crt_t **certs,\n\t\t\t\tunsigned int *size,\n\t\t\t\tconst char *url,\n\t\t\t\tgnutls_pin_callback_t pin_fn,\n\t\t\t\tvoid *pin_fn_userdata,\n\t\t\t\tunsigned int flags);\n\nint gnutls_x509_crt_export(gnutls_x509_crt_t cert,\n\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t   void *output_data, size_t * output_data_size);\nint gnutls_x509_crt_export2(gnutls_x509_crt_t cert,\n\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t    gnutls_datum_t * out);\nint gnutls_x509_crt_get_private_key_usage_period(gnutls_x509_crt_t\n\t\t\t\t\t\t cert,\n\t\t\t\t\t\t time_t *\n\t\t\t\t\t\t activation,\n\t\t\t\t\t\t time_t *\n\t\t\t\t\t\t expiration, unsigned int\n\t\t\t\t\t\t *critical);\n\nint gnutls_x509_crt_get_issuer_dn(gnutls_x509_crt_t cert,\n\t\t\t\t  char *buf, size_t * buf_size);\nint gnutls_x509_crt_get_issuer_dn2(gnutls_x509_crt_t cert,\n\t\t\t\t   gnutls_datum_t * dn);\nint gnutls_x509_crt_get_issuer_dn3(gnutls_x509_crt_t cert,\n\t\t\t\t   gnutls_datum_t * dn, unsigned flags);\nint gnutls_x509_crt_get_issuer_dn_oid(gnutls_x509_crt_t cert,\n\t\t\t\t      unsigned indx, void *oid,\n\t\t\t\t      size_t * oid_size);\nint gnutls_x509_crt_get_issuer_dn_by_oid(gnutls_x509_crt_t cert,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t unsigned int raw_flag,\n\t\t\t\t\t void *buf, size_t * buf_size);\n\nint gnutls_x509_crt_get_dn(gnutls_x509_crt_t cert, char *buf,\n\t\t\t   size_t * buf_size);\nint gnutls_x509_crt_get_dn2(gnutls_x509_crt_t cert, gnutls_datum_t * dn);\nint gnutls_x509_crt_get_dn3(gnutls_x509_crt_t cert, gnutls_datum_t * dn, unsigned flags);\n\nint gnutls_x509_crt_get_dn_oid(gnutls_x509_crt_t cert, unsigned indx,\n\t\t\t       void *oid, size_t * oid_size);\nint gnutls_x509_crt_get_dn_by_oid(gnutls_x509_crt_t cert,\n\t\t\t\t  const char *oid, unsigned indx,\n\t\t\t\t  unsigned int raw_flag, void *buf,\n\t\t\t\t  size_t * buf_size);\nunsigned gnutls_x509_crt_check_hostname(gnutls_x509_crt_t cert,\n\t\t\t\t   const char *hostname);\nunsigned gnutls_x509_crt_check_hostname2(gnutls_x509_crt_t cert,\n\t\t\t\t\t const char *hostname, unsigned int flags);\nunsigned\ngnutls_x509_crt_check_email(gnutls_x509_crt_t cert,\n\t\t\t    const char *email, unsigned int flags);\n\nunsigned\ngnutls_x509_crt_check_ip(gnutls_x509_crt_t cert,\n\t\t\t const unsigned char *ip, unsigned int ip_size,\n\t\t\t unsigned int flags);\n\nint gnutls_x509_crt_get_signature_algorithm(gnutls_x509_crt_t cert);\nint gnutls_x509_crt_get_signature(gnutls_x509_crt_t cert,\n\t\t\t\t  char *sig, size_t * sizeof_sig);\nint gnutls_x509_crt_get_version(gnutls_x509_crt_t cert);\n\nint gnutls_x509_crt_get_pk_oid(gnutls_x509_crt_t cert, char *oid, size_t *oid_size);\nint gnutls_x509_crt_get_signature_oid(gnutls_x509_crt_t cert, char *oid, size_t *oid_size);\n\n/**\n * gnutls_keyid_flags_t:\n * @GNUTLS_KEYID_USE_SHA1: Use SHA1 as the key ID algorithm (default).\n * @GNUTLS_KEYID_USE_SHA256: Use SHA256 as the key ID algorithm.\n * @GNUTLS_KEYID_USE_SHA512: Use SHA512 as the key ID algorithm.\n * @GNUTLS_KEYID_USE_BEST_KNOWN: Use the best known algorithm to calculate key ID. Using that option will make your program behavior depend on the version of gnutls linked with. That option has a cap of 64-bytes key IDs.\n *\n * Enumeration of different flags for the key ID functions.\n \n */\ntypedef enum {\n\tGNUTLS_KEYID_USE_SHA1 = 0,\n\tGNUTLS_KEYID_USE_SHA256 = (1<<0),\n\tGNUTLS_KEYID_USE_SHA512 = (1<<1),\n\tGNUTLS_KEYID_USE_BEST_KNOWN = (1<<30)\n} gnutls_keyid_flags_t;\nint gnutls_x509_crt_get_key_id(gnutls_x509_crt_t crt,\n\t\t\t       unsigned int flags,\n\t\t\t       unsigned char *output_data,\n\t\t\t       size_t * output_data_size);\n\nint gnutls_x509_crt_set_private_key_usage_period(gnutls_x509_crt_t\n\t\t\t\t\t\t crt,\n\t\t\t\t\t\t time_t activation,\n\t\t\t\t\t\t time_t expiration);\nint gnutls_x509_crt_set_authority_key_id(gnutls_x509_crt_t cert,\n\t\t\t\t\t const void *id, size_t id_size);\nint gnutls_x509_crt_get_authority_key_id(gnutls_x509_crt_t cert,\n\t\t\t\t\t void *id,\n\t\t\t\t\t size_t * id_size,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_crt_get_authority_key_gn_serial(gnutls_x509_crt_t\n\t\t\t\t\t\tcert,\n\t\t\t\t\t\tunsigned int seq,\n\t\t\t\t\t\tvoid *alt,\n\t\t\t\t\t\tsize_t * alt_size,\n\t\t\t\t\t\tunsigned int\n\t\t\t\t\t\t*alt_type,\n\t\t\t\t\t\tvoid *serial,\n\t\t\t\t\t\tsize_t *\n\t\t\t\t\t\tserial_size, unsigned int\n\t\t\t\t\t\t*critical);\n\nint gnutls_x509_crt_get_subject_key_id(gnutls_x509_crt_t cert,\n\t\t\t\t       void *ret,\n\t\t\t\t       size_t * ret_size,\n\t\t\t\t       unsigned int *critical);\n\nint gnutls_x509_crt_get_subject_unique_id(gnutls_x509_crt_t crt,\n\t\t\t\t\t  char *buf, size_t * buf_size);\n\nint gnutls_x509_crt_get_issuer_unique_id(gnutls_x509_crt_t crt,\n\t\t\t\t\t char *buf, size_t * buf_size);\n\nvoid gnutls_x509_crt_set_pin_function(gnutls_x509_crt_t crt,\n\t\t\t\t      gnutls_pin_callback_t fn,\n\t\t\t\t      void *userdata);\n\n  /**\n   * gnutls_info_access_what_t:\n   * @GNUTLS_IA_ACCESSMETHOD_OID: Get accessMethod OID.\n   * @GNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE: Get accessLocation name type.\n   * @GNUTLS_IA_URI: Get accessLocation URI value.\n   * @GNUTLS_IA_OCSP_URI: get accessLocation URI value for OCSP.\n   * @GNUTLS_IA_CAISSUERS_URI: get accessLocation URI value for caIssuers.\n   *\n   * Enumeration of types for the @what parameter of\n   * gnutls_x509_crt_get_authority_info_access().\n   */\ntypedef enum gnutls_info_access_what_t {\n\tGNUTLS_IA_ACCESSMETHOD_OID = 1,\n\tGNUTLS_IA_ACCESSLOCATION_GENERALNAME_TYPE = 2,\n\t/* use 100-108 for the generalName types, populate as needed */\n\tGNUTLS_IA_URI = 106,\n\t/* quick-access variants that match both OID and name type. */\n\tGNUTLS_IA_UNKNOWN = 10000,\n\tGNUTLS_IA_OCSP_URI = 10006,\n\tGNUTLS_IA_CAISSUERS_URI = 10106\n} gnutls_info_access_what_t;\n\nint gnutls_x509_crt_get_authority_info_access(gnutls_x509_crt_t\n\t\t\t\t\t      crt,\n\t\t\t\t\t      unsigned int seq,\n\t\t\t\t\t      int what,\n\t\t\t\t\t      gnutls_datum_t *\n\t\t\t\t\t      data, unsigned int\n\t\t\t\t\t      *critical);\n\ntypedef struct gnutls_name_constraints_st *gnutls_x509_name_constraints_t;\n\nunsigned gnutls_x509_name_constraints_check(gnutls_x509_name_constraints_t nc,\n\t\t\t\t       gnutls_x509_subject_alt_name_t type,\n\t\t\t\t       const gnutls_datum_t * name);\nunsigned gnutls_x509_name_constraints_check_crt(gnutls_x509_name_constraints_t nc,\n\t\t\t\t       gnutls_x509_subject_alt_name_t type,\n\t\t\t\t       gnutls_x509_crt_t crt);\n\nint gnutls_x509_name_constraints_init(gnutls_x509_name_constraints_t *nc);\nvoid gnutls_x509_name_constraints_deinit(gnutls_x509_name_constraints_t nc);\n\n#define GNUTLS_EXT_FLAG_APPEND 1\n\n#define GNUTLS_NAME_CONSTRAINTS_FLAG_APPEND GNUTLS_EXT_FLAG_APPEND\nint gnutls_x509_crt_get_name_constraints(gnutls_x509_crt_t crt,\n\t\t\t\t\t gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t unsigned int flags,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_name_constraints_add_permitted(gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t       gnutls_x509_subject_alt_name_t type,\n\t\t\t\t\t       const gnutls_datum_t * name);\nint gnutls_x509_name_constraints_add_excluded(gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t      gnutls_x509_subject_alt_name_t type,\n\t\t\t\t\t      const gnutls_datum_t * name);\nint gnutls_x509_crt_set_name_constraints(gnutls_x509_crt_t crt, \n\t\t\t\t\t gnutls_x509_name_constraints_t nc,\n\t\t\t\t\t unsigned int critical);\nint gnutls_x509_name_constraints_get_permitted(gnutls_x509_name_constraints_t nc,\n\t\t\t\t     unsigned idx,\n\t\t\t\t     unsigned *type, gnutls_datum_t * name);\nint gnutls_x509_name_constraints_get_excluded(gnutls_x509_name_constraints_t nc,\n\t\t\t\t     unsigned idx,\n\t\t\t\t     unsigned *type, gnutls_datum_t * name);\nint gnutls_x509_cidr_to_rfc5280(const char *cidr, gnutls_datum_t *cidr_rfc5280);\n\n\n#define GNUTLS_CRL_REASON_SUPERSEEDED GNUTLS_CRL_REASON_SUPERSEDED,\n  /**\n   * gnutls_x509_crl_reason_flags_t:\n   * @GNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN: The privileges were withdrawn from the owner.\n   * @GNUTLS_CRL_REASON_CERTIFICATE_HOLD: The certificate is on hold.\n   * @GNUTLS_CRL_REASON_CESSATION_OF_OPERATION: The end-entity is no longer operating.\n   * @GNUTLS_CRL_REASON_SUPERSEDED: There is a newer certificate of the owner.\n   * @GNUTLS_CRL_REASON_AFFILIATION_CHANGED: The end-entity affiliation has changed.\n   * @GNUTLS_CRL_REASON_CA_COMPROMISE: The CA was compromised.\n   * @GNUTLS_CRL_REASON_KEY_COMPROMISE: The certificate's key was compromised.\n   * @GNUTLS_CRL_REASON_UNUSED: The key was never used.\n   * @GNUTLS_CRL_REASON_AA_COMPROMISE: AA compromised.\n   *\n   * Enumeration of types for the CRL revocation reasons. \n   */\ntypedef enum gnutls_x509_crl_reason_flags_t {\n\tGNUTLS_CRL_REASON_UNSPECIFIED = 0,\n\tGNUTLS_CRL_REASON_PRIVILEGE_WITHDRAWN = 1,\n\tGNUTLS_CRL_REASON_CERTIFICATE_HOLD = 2,\n\tGNUTLS_CRL_REASON_CESSATION_OF_OPERATION = 4,\n\tGNUTLS_CRL_REASON_SUPERSEDED = 8,\n\tGNUTLS_CRL_REASON_AFFILIATION_CHANGED = 16,\n\tGNUTLS_CRL_REASON_CA_COMPROMISE = 32,\n\tGNUTLS_CRL_REASON_KEY_COMPROMISE = 64,\n\tGNUTLS_CRL_REASON_UNUSED = 128,\n\tGNUTLS_CRL_REASON_AA_COMPROMISE = 32768\n} gnutls_x509_crl_reason_flags_t;\n\nint gnutls_x509_crt_get_crl_dist_points(gnutls_x509_crt_t cert,\n\t\t\t\t\tunsigned int seq,\n\t\t\t\t\tvoid *ret,\n\t\t\t\t\tsize_t * ret_size,\n\t\t\t\t\tunsigned int *reason_flags,\n\t\t\t\t\tunsigned int *critical);\nint gnutls_x509_crt_set_crl_dist_points2(gnutls_x509_crt_t crt,\n\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t type, const void *data,\n\t\t\t\t\t unsigned int data_size,\n\t\t\t\t\t unsigned int reason_flags);\nint gnutls_x509_crt_set_crl_dist_points(gnutls_x509_crt_t crt,\n\t\t\t\t\tgnutls_x509_subject_alt_name_t\n\t\t\t\t\ttype,\n\t\t\t\t\tconst void *data_string,\n\t\t\t\t\tunsigned int reason_flags);\nint gnutls_x509_crt_cpy_crl_dist_points(gnutls_x509_crt_t dst,\n\t\t\t\t\tgnutls_x509_crt_t src);\n\nint gnutls_x509_crl_sign(gnutls_x509_crl_t crl,\n\t\t\t gnutls_x509_crt_t issuer,\n\t\t\t gnutls_x509_privkey_t issuer_key);\n\nint gnutls_x509_crl_sign2(gnutls_x509_crl_t crl,\n\t\t\t  gnutls_x509_crt_t issuer,\n\t\t\t  gnutls_x509_privkey_t issuer_key,\n\t\t\t  gnutls_digest_algorithm_t dig,\n\t\t\t  unsigned int flags);\n\ntime_t gnutls_x509_crt_get_activation_time(gnutls_x509_crt_t cert);\n\n/* This macro is deprecated and defunc; do not use */\n#define GNUTLS_X509_NO_WELL_DEFINED_EXPIRATION ((time_t)4294197631)\n\ntime_t gnutls_x509_crt_get_expiration_time(gnutls_x509_crt_t cert);\nint gnutls_x509_crt_get_serial(gnutls_x509_crt_t cert,\n\t\t\t       void *result, size_t * result_size);\n\ntypedef struct gnutls_x509_spki_st *gnutls_x509_spki_t;\n\nint gnutls_x509_spki_init(gnutls_x509_spki_t *spki);\nvoid gnutls_x509_spki_deinit(gnutls_x509_spki_t spki);\n\nint gnutls_x509_spki_get_rsa_pss_params(gnutls_x509_spki_t spki,\n\t\t\tgnutls_digest_algorithm_t *dig, unsigned int *salt_size);\n\nvoid gnutls_x509_spki_set_rsa_pss_params(gnutls_x509_spki_t spki,\n\t\t\tgnutls_digest_algorithm_t dig, unsigned int salt_size);\n\nint gnutls_x509_crt_get_pk_algorithm(gnutls_x509_crt_t cert,\n\t\t\t\t     unsigned int *bits);\nint gnutls_x509_crt_set_spki(gnutls_x509_crt_t crt, const gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\nint gnutls_x509_crt_get_spki(gnutls_x509_crt_t cert, gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\n\nint gnutls_x509_crt_get_pk_rsa_raw(gnutls_x509_crt_t crt,\n\t\t\t\t   gnutls_datum_t * m, gnutls_datum_t * e);\nint gnutls_x509_crt_get_pk_dsa_raw(gnutls_x509_crt_t crt,\n\t\t\t\t   gnutls_datum_t * p,\n\t\t\t\t   gnutls_datum_t * q,\n\t\t\t\t   gnutls_datum_t * g, gnutls_datum_t * y);\nint gnutls_x509_crt_get_pk_ecc_raw(gnutls_x509_crt_t crt,\n\t\t\t\t   gnutls_ecc_curve_t * curve,\n\t\t\t\t   gnutls_datum_t * x,\n\t\t\t\t   gnutls_datum_t * y);\nint gnutls_x509_crt_get_pk_gost_raw(gnutls_x509_crt_t crt,\n\t\t\t\t    gnutls_ecc_curve_t * curve,\n\t\t\t\t    gnutls_digest_algorithm_t * digest,\n\t\t\t\t    gnutls_gost_paramset_t *paramset,\n\t\t\t\t    gnutls_datum_t * x, gnutls_datum_t * y);\n\nint gnutls_x509_crt_get_subject_alt_name(gnutls_x509_crt_t cert,\n\t\t\t\t\t unsigned int seq,\n\t\t\t\t\t void *san,\n\t\t\t\t\t size_t * san_size,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_crt_get_subject_alt_name2(gnutls_x509_crt_t cert,\n\t\t\t\t\t  unsigned int seq,\n\t\t\t\t\t  void *san,\n\t\t\t\t\t  size_t * san_size,\n\t\t\t\t\t  unsigned int *san_type,\n\t\t\t\t\t  unsigned int *critical);\n\nint gnutls_x509_crt_get_subject_alt_othername_oid(gnutls_x509_crt_t\n\t\t\t\t\t\t  cert,\n\t\t\t\t\t\t  unsigned int seq,\n\t\t\t\t\t\t  void *oid,\n\t\t\t\t\t\t  size_t * oid_size);\n\nint gnutls_x509_crt_get_issuer_alt_name(gnutls_x509_crt_t cert,\n\t\t\t\t\tunsigned int seq,\n\t\t\t\t\tvoid *ian,\n\t\t\t\t\tsize_t * ian_size,\n\t\t\t\t\tunsigned int *critical);\nint gnutls_x509_crt_get_issuer_alt_name2(gnutls_x509_crt_t cert,\n\t\t\t\t\t unsigned int seq,\n\t\t\t\t\t void *ian,\n\t\t\t\t\t size_t * ian_size,\n\t\t\t\t\t unsigned int *ian_type,\n\t\t\t\t\t unsigned int *critical);\n\nint gnutls_x509_crt_get_issuer_alt_othername_oid(gnutls_x509_crt_t\n\t\t\t\t\t\t cert,\n\t\t\t\t\t\t unsigned int seq,\n\t\t\t\t\t\t void *ret,\n\t\t\t\t\t\t size_t * ret_size);\n\nint gnutls_x509_crt_get_ca_status(gnutls_x509_crt_t cert,\n\t\t\t\t  unsigned int *critical);\nint gnutls_x509_crt_get_basic_constraints(gnutls_x509_crt_t cert,\n\t\t\t\t\t  unsigned int *critical,\n\t\t\t\t\t  unsigned int *ca, int *pathlen);\n\n/* The key_usage flags are defined in gnutls.h. They are the\n * GNUTLS_KEY_* definitions.\n */\nint gnutls_x509_crt_get_key_usage(gnutls_x509_crt_t cert,\n\t\t\t\t  unsigned int *key_usage,\n\t\t\t\t  unsigned int *critical);\nint gnutls_x509_crt_set_key_usage(gnutls_x509_crt_t crt,\n\t\t\t\t  unsigned int usage);\nint gnutls_x509_crt_set_authority_info_access(gnutls_x509_crt_t\n\t\t\t\t\t      crt, int what,\n\t\t\t\t\t      gnutls_datum_t * data);\n\nint gnutls_x509_crt_get_inhibit_anypolicy(gnutls_x509_crt_t cert,\n\t\t\t\t  unsigned int *skipcerts,\n\t\t\t\t  unsigned int *critical);\nint\ngnutls_x509_crt_set_inhibit_anypolicy(gnutls_x509_crt_t crt, unsigned int skipcerts);\n\nint gnutls_x509_crt_get_proxy(gnutls_x509_crt_t cert,\n\t\t\t      unsigned int *critical,\n\t\t\t      int *pathlen,\n\t\t\t      char **policyLanguage,\n\t\t\t      char **policy, size_t * sizeof_policy);\n\n\ntypedef struct gnutls_x509_tlsfeatures_st *gnutls_x509_tlsfeatures_t;\n\nint gnutls_x509_tlsfeatures_init(gnutls_x509_tlsfeatures_t *features);\nvoid gnutls_x509_tlsfeatures_deinit(gnutls_x509_tlsfeatures_t);\nint gnutls_x509_tlsfeatures_get(gnutls_x509_tlsfeatures_t f, unsigned idx, unsigned int *feature);\n\nint gnutls_x509_crt_set_tlsfeatures(gnutls_x509_crt_t crt,\n\t\t\t\t    gnutls_x509_tlsfeatures_t features);\n\nint gnutls_x509_crt_get_tlsfeatures(gnutls_x509_crt_t cert,\n\t\t\t\t    gnutls_x509_tlsfeatures_t features,\n\t\t\t\t    unsigned int flags,\n\t\t\t\t    unsigned int *critical);\n\nunsigned gnutls_x509_tlsfeatures_check_crt(gnutls_x509_tlsfeatures_t feat,\n\t\t\t\t           gnutls_x509_crt_t crt);\n\n\n#define GNUTLS_MAX_QUALIFIERS 8\n\n  /**\n   * gnutls_x509_qualifier_t:\n   * @GNUTLS_X509_QUALIFIER_UNKNOWN: Unknown qualifier.\n   * @GNUTLS_X509_QUALIFIER_URI: A URL\n   * @GNUTLS_X509_QUALIFIER_NOICE: A text notice.\n   *\n   * Enumeration of types for the X.509 qualifiers, of the certificate policy extension. \n   */\ntypedef enum gnutls_x509_qualifier_t {\n\tGNUTLS_X509_QUALIFIER_UNKNOWN = 0, GNUTLS_X509_QUALIFIER_URI,\n\tGNUTLS_X509_QUALIFIER_NOTICE\n} gnutls_x509_qualifier_t;\n\ntypedef struct gnutls_x509_policy_st {\n\tchar *oid;\n\tunsigned int qualifiers;\n\tstruct {\n\t\tgnutls_x509_qualifier_t type;\n\t\tchar *data;\n\t\tunsigned int size;\n\t} qualifier[GNUTLS_MAX_QUALIFIERS];\n} gnutls_x509_policy_st;\n\nvoid gnutls_x509_policy_release(struct gnutls_x509_policy_st\n\t\t\t\t*policy);\nint gnutls_x509_crt_get_policy(gnutls_x509_crt_t crt, unsigned indx, struct gnutls_x509_policy_st\n\t\t\t       *policy, unsigned int *critical);\nint gnutls_x509_crt_set_policy(gnutls_x509_crt_t crt, const struct gnutls_x509_policy_st\n\t\t\t       *policy, unsigned int critical);\n\nint gnutls_x509_dn_oid_known(const char *oid);\n\n#define GNUTLS_X509_DN_OID_RETURN_OID 1\nconst char *gnutls_x509_dn_oid_name(const char *oid, unsigned int flags);\n\n\t/* Read extensions by OID. */\nint gnutls_x509_crt_get_extension_oid(gnutls_x509_crt_t cert,\n\t\t\t\t      unsigned indx, void *oid,\n\t\t\t\t      size_t * oid_size);\nint gnutls_x509_crt_get_extension_by_oid(gnutls_x509_crt_t cert,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t void *buf,\n\t\t\t\t\t size_t * buf_size,\n\t\t\t\t\t unsigned int *critical);\n\nint gnutls_x509_crq_get_signature_algorithm(gnutls_x509_crq_t crq);\nint\ngnutls_x509_crq_get_extension_by_oid2(gnutls_x509_crq_t crq,\n\t\t\t\t     const char *oid, unsigned indx,\n\t\t\t\t     gnutls_datum_t *output,\n\t\t\t\t     unsigned int *critical);\n\n\t/* Read extensions by sequence number. */\nint gnutls_x509_crt_get_extension_info(gnutls_x509_crt_t cert,\n\t\t\t\t       unsigned indx, void *oid,\n\t\t\t\t       size_t * oid_size,\n\t\t\t\t       unsigned int *critical);\nint gnutls_x509_crt_get_extension_data(gnutls_x509_crt_t cert,\n\t\t\t\t       unsigned indx, void *data,\n\t\t\t\t       size_t * sizeof_data);\nint\ngnutls_x509_crt_get_extension_data2(gnutls_x509_crt_t cert,\n\t\t\t       unsigned indx, gnutls_datum_t * data);\n\n\nint gnutls_x509_crt_set_extension_by_oid(gnutls_x509_crt_t crt,\n\t\t\t\t\t const char *oid,\n\t\t\t\t\t const void *buf,\n\t\t\t\t\t size_t sizeof_buf,\n\t\t\t\t\t unsigned int critical);\n\n/* X.509 Certificate writing.\n */\nint gnutls_x509_crt_set_dn(gnutls_x509_crt_t crt, const char *dn,\n\t\t\t   const char **err);\n\nint gnutls_x509_crt_set_dn_by_oid(gnutls_x509_crt_t crt,\n\t\t\t\t  const char *oid,\n\t\t\t\t  unsigned int raw_flag,\n\t\t\t\t  const void *name,\n\t\t\t\t  unsigned int sizeof_name);\nint gnutls_x509_crt_set_issuer_dn_by_oid(gnutls_x509_crt_t crt,\n\t\t\t\t\t const char *oid,\n\t\t\t\t\t unsigned int raw_flag,\n\t\t\t\t\t const void *name,\n\t\t\t\t\t unsigned int sizeof_name);\nint gnutls_x509_crt_set_issuer_dn(gnutls_x509_crt_t crt,\n\t\t\t\t  const char *dn, const char **err);\n\nint gnutls_x509_crt_set_version(gnutls_x509_crt_t crt,\n\t\t\t\tunsigned int version);\nint gnutls_x509_crt_set_key(gnutls_x509_crt_t crt,\n\t\t\t    gnutls_x509_privkey_t key);\nint gnutls_x509_crt_set_ca_status(gnutls_x509_crt_t crt, unsigned int ca);\nint gnutls_x509_crt_set_basic_constraints(gnutls_x509_crt_t crt,\n\t\t\t\t\t  unsigned int ca,\n\t\t\t\t\t  int pathLenConstraint);\n\nint\ngnutls_x509_crt_set_subject_unique_id(gnutls_x509_crt_t cert, const void *id,\n\t\t\t   size_t id_size);\nint\ngnutls_x509_crt_set_issuer_unique_id(gnutls_x509_crt_t cert, const void *id,\n\t\t\t   size_t id_size);\n\nint gnutls_x509_crt_set_subject_alternative_name(gnutls_x509_crt_t\n\t\t\t\t\t\t crt,\n\t\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t\t type, const char\n\t\t\t\t\t\t *data_string);\nint gnutls_x509_crt_set_subject_alt_name(gnutls_x509_crt_t crt,\n\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t type, const void *data,\n\t\t\t\t\t unsigned int data_size,\n\t\t\t\t\t unsigned int flags);\n\nint\ngnutls_x509_crt_set_subject_alt_othername(gnutls_x509_crt_t crt,\n\t\t\t\t     const char *oid,\n\t\t\t\t     const void *data,\n\t\t\t\t     unsigned int data_size,\n\t\t\t\t     unsigned int flags);\n\nint gnutls_x509_crt_set_issuer_alt_name(gnutls_x509_crt_t crt,\n\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t type, const void *data,\n\t\t\t\t\t unsigned int data_size,\n\t\t\t\t\t unsigned int flags);\n\nint\ngnutls_x509_crt_set_issuer_alt_othername(gnutls_x509_crt_t crt,\n\t\t\t\t     const char *oid,\n\t\t\t\t     const void *data,\n\t\t\t\t     unsigned int data_size,\n\t\t\t\t     unsigned int flags);\n\nint gnutls_x509_crt_sign(gnutls_x509_crt_t crt,\n\t\t\t gnutls_x509_crt_t issuer,\n\t\t\t gnutls_x509_privkey_t issuer_key);\nint gnutls_x509_crt_sign2(gnutls_x509_crt_t crt,\n\t\t\t  gnutls_x509_crt_t issuer,\n\t\t\t  gnutls_x509_privkey_t issuer_key,\n\t\t\t  gnutls_digest_algorithm_t dig,\n\t\t\t  unsigned int flags);\nint gnutls_x509_crt_set_activation_time(gnutls_x509_crt_t cert,\n\t\t\t\t\ttime_t act_time);\nint gnutls_x509_crt_set_expiration_time(gnutls_x509_crt_t cert,\n\t\t\t\t\ttime_t exp_time);\nint gnutls_x509_crt_set_serial(gnutls_x509_crt_t cert,\n\t\t\t       const void *serial, size_t serial_size);\n\nint gnutls_x509_crt_set_subject_key_id(gnutls_x509_crt_t cert,\n\t\t\t\t       const void *id, size_t id_size);\n\nint gnutls_x509_crt_set_proxy_dn(gnutls_x509_crt_t crt,\n\t\t\t\t gnutls_x509_crt_t eecrt,\n\t\t\t\t unsigned int raw_flag,\n\t\t\t\t const void *name,\n\t\t\t\t unsigned int sizeof_name);\nint gnutls_x509_crt_set_proxy(gnutls_x509_crt_t crt,\n\t\t\t      int pathLenConstraint,\n\t\t\t      const char *policyLanguage,\n\t\t\t      const char *policy, size_t sizeof_policy);\n\nint gnutls_x509_crt_print(gnutls_x509_crt_t cert,\n\t\t\t  gnutls_certificate_print_formats_t\n\t\t\t  format, gnutls_datum_t * out);\nint gnutls_x509_crl_print(gnutls_x509_crl_t crl,\n\t\t\t  gnutls_certificate_print_formats_t\n\t\t\t  format, gnutls_datum_t * out);\n\n\t/* Access to internal Certificate fields.\n\t */\nint gnutls_x509_crt_get_raw_issuer_dn(gnutls_x509_crt_t cert,\n\t\t\t\t      gnutls_datum_t * start);\nint gnutls_x509_crt_get_raw_dn(gnutls_x509_crt_t cert,\n\t\t\t       gnutls_datum_t * start);\n\n/* RDN handling.\n */\nint gnutls_x509_rdn_get(const gnutls_datum_t * idn,\n\t\t\tchar *buf, size_t * sizeof_buf);\nint\ngnutls_x509_rdn_get2(const gnutls_datum_t * idn,\n                     gnutls_datum_t *str, unsigned flags);\n\nint gnutls_x509_rdn_get_oid(const gnutls_datum_t * idn,\n\t\t\t    unsigned indx, void *buf, size_t * sizeof_buf);\n\nint gnutls_x509_rdn_get_by_oid(const gnutls_datum_t * idn,\n\t\t\t       const char *oid, unsigned indx,\n\t\t\t       unsigned int raw_flag, void *buf,\n\t\t\t       size_t * sizeof_buf);\n\ntypedef struct gnutls_x509_dn_st *gnutls_x509_dn_t;\n\ntypedef struct gnutls_x509_ava_st {\n\tgnutls_datum_t oid;\n\tgnutls_datum_t value;\n\tunsigned long value_tag;\n} gnutls_x509_ava_st;\n\nint gnutls_x509_crt_get_subject(gnutls_x509_crt_t cert,\n\t\t\t\tgnutls_x509_dn_t * dn);\nint gnutls_x509_crt_get_issuer(gnutls_x509_crt_t cert,\n\t\t\t       gnutls_x509_dn_t * dn);\nint gnutls_x509_dn_get_rdn_ava(gnutls_x509_dn_t dn, int irdn,\n\t\t\t       int iava, gnutls_x509_ava_st * ava);\n\nint gnutls_x509_dn_get_str(gnutls_x509_dn_t dn, gnutls_datum_t *str);\n\n#define GNUTLS_X509_DN_FLAG_COMPAT 1\nint gnutls_x509_dn_get_str2(gnutls_x509_dn_t dn, gnutls_datum_t *str, unsigned flags);\n\nint\ngnutls_x509_dn_set_str(gnutls_x509_dn_t dn, const char *str, const char **err);\n\nint gnutls_x509_dn_init(gnutls_x509_dn_t * dn);\n\nint gnutls_x509_dn_import(gnutls_x509_dn_t dn,\n\t\t\t  const gnutls_datum_t * data);\n\nint gnutls_x509_dn_export(gnutls_x509_dn_t dn,\n\t\t\t  gnutls_x509_crt_fmt_t format,\n\t\t\t  void *output_data, size_t * output_data_size);\nint gnutls_x509_dn_export2(gnutls_x509_dn_t dn,\n\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t   gnutls_datum_t * out);\n\nvoid gnutls_x509_dn_deinit(gnutls_x509_dn_t dn);\n\n\n/* CRL handling functions.\n */\nint gnutls_x509_crl_init(gnutls_x509_crl_t * crl);\nvoid gnutls_x509_crl_deinit(gnutls_x509_crl_t crl);\n\nint gnutls_x509_crl_import(gnutls_x509_crl_t crl,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   gnutls_x509_crt_fmt_t format);\nint gnutls_x509_crl_export(gnutls_x509_crl_t crl,\n\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t   void *output_data, size_t * output_data_size);\nint gnutls_x509_crl_export2(gnutls_x509_crl_t crl,\n\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t    gnutls_datum_t * out);\n\nint\ngnutls_x509_crl_get_raw_issuer_dn(gnutls_x509_crl_t crl,\n\t\t\t\t  gnutls_datum_t * dn);\n\nint gnutls_x509_crl_get_issuer_dn(gnutls_x509_crl_t crl,\n\t\t\t\t  char *buf, size_t * sizeof_buf);\nint gnutls_x509_crl_get_issuer_dn2(gnutls_x509_crl_t crl,\n\t\t\t\t   gnutls_datum_t * dn);\nint gnutls_x509_crl_get_issuer_dn3(gnutls_x509_crl_t crl,\n\t\t\t\t   gnutls_datum_t * dn, unsigned flags);\n\nint gnutls_x509_crl_get_issuer_dn_by_oid(gnutls_x509_crl_t crl,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t unsigned int raw_flag,\n\t\t\t\t\t void *buf, size_t * sizeof_buf);\nint gnutls_x509_crl_get_dn_oid(gnutls_x509_crl_t crl, unsigned indx,\n\t\t\t       void *oid, size_t * sizeof_oid);\n\nint gnutls_x509_crl_get_signature_algorithm(gnutls_x509_crl_t crl);\nint gnutls_x509_crl_get_signature(gnutls_x509_crl_t crl,\n\t\t\t\t  char *sig, size_t * sizeof_sig);\nint gnutls_x509_crl_get_version(gnutls_x509_crl_t crl);\n\nint gnutls_x509_crl_get_signature_oid(gnutls_x509_crl_t crl, char *oid, size_t *oid_size);\n\ntime_t gnutls_x509_crl_get_this_update(gnutls_x509_crl_t crl);\ntime_t gnutls_x509_crl_get_next_update(gnutls_x509_crl_t crl);\n\nint gnutls_x509_crl_get_crt_count(gnutls_x509_crl_t crl);\nint gnutls_x509_crl_get_crt_serial(gnutls_x509_crl_t crl, unsigned indx,\n\t\t\t\t   unsigned char *serial,\n\t\t\t\t   size_t * serial_size, time_t * t);\n\ntypedef struct gnutls_x509_crl_iter * gnutls_x509_crl_iter_t;\n\nint gnutls_x509_crl_iter_crt_serial(gnutls_x509_crl_t crl,\n\t\t\t\t    gnutls_x509_crl_iter_t *,\n\t\t\t\t    unsigned char *serial,\n\t\t\t\t    size_t * serial_size, time_t * t);\n\nvoid gnutls_x509_crl_iter_deinit(gnutls_x509_crl_iter_t);\n\n#define gnutls_x509_crl_get_certificate_count gnutls_x509_crl_get_crt_count\n#define gnutls_x509_crl_get_certificate gnutls_x509_crl_get_crt_serial\n\nunsigned gnutls_x509_crl_check_issuer(gnutls_x509_crl_t crl,\n\t\t\t\t gnutls_x509_crt_t issuer);\n\nint gnutls_x509_crl_list_import2(gnutls_x509_crl_t ** crls,\n\t\t\t\t unsigned int *size,\n\t\t\t\t const gnutls_datum_t * data,\n\t\t\t\t gnutls_x509_crt_fmt_t format,\n\t\t\t\t unsigned int flags);\n\nint gnutls_x509_crl_list_import(gnutls_x509_crl_t * crls,\n\t\t\t\tunsigned int *crl_max,\n\t\t\t\tconst gnutls_datum_t * data,\n\t\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\t\tunsigned int flags);\n/* CRL writing.\n */\nint gnutls_x509_crl_set_version(gnutls_x509_crl_t crl,\n\t\t\t\tunsigned int version);\nint gnutls_x509_crl_set_this_update(gnutls_x509_crl_t crl,\n\t\t\t\t    time_t act_time);\nint gnutls_x509_crl_set_next_update(gnutls_x509_crl_t crl,\n\t\t\t\t    time_t exp_time);\nint gnutls_x509_crl_set_crt_serial(gnutls_x509_crl_t crl,\n\t\t\t\t   const void *serial,\n\t\t\t\t   size_t serial_size,\n\t\t\t\t   time_t revocation_time);\nint gnutls_x509_crl_set_crt(gnutls_x509_crl_t crl,\n\t\t\t    gnutls_x509_crt_t crt, time_t revocation_time);\n\nint gnutls_x509_crl_get_authority_key_id(gnutls_x509_crl_t crl,\n\t\t\t\t\t void *id,\n\t\t\t\t\t size_t * id_size,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_crl_get_authority_key_gn_serial(gnutls_x509_crl_t\n\t\t\t\t\t\tcrl,\n\t\t\t\t\t\tunsigned int seq,\n\t\t\t\t\t\tvoid *alt,\n\t\t\t\t\t\tsize_t * alt_size,\n\t\t\t\t\t\tunsigned int\n\t\t\t\t\t\t*alt_type,\n\t\t\t\t\t\tvoid *serial,\n\t\t\t\t\t\tsize_t *\n\t\t\t\t\t\tserial_size, unsigned int\n\t\t\t\t\t\t*critical);\n\nint gnutls_x509_crl_get_number(gnutls_x509_crl_t crl, void *ret,\n\t\t\t       size_t * ret_size, unsigned int *critical);\n\nint gnutls_x509_crl_get_extension_oid(gnutls_x509_crl_t crl,\n\t\t\t\t      unsigned indx, void *oid,\n\t\t\t\t      size_t * sizeof_oid);\n\nint gnutls_x509_crl_get_extension_info(gnutls_x509_crl_t crl,\n\t\t\t\t       unsigned indx, void *oid,\n\t\t\t\t       size_t * sizeof_oid,\n\t\t\t\t       unsigned int *critical);\n\nint gnutls_x509_crl_get_extension_data(gnutls_x509_crl_t crl,\n\t\t\t\t       unsigned indx, void *data,\n\t\t\t\t       size_t * sizeof_data);\nint\ngnutls_x509_crl_get_extension_data2(gnutls_x509_crl_t crl,\n\t\t\t       unsigned indx, gnutls_datum_t * data);\n\nint gnutls_x509_crl_set_authority_key_id(gnutls_x509_crl_t crl,\n\t\t\t\t\t const void *id, size_t id_size);\n\nint gnutls_x509_crl_set_number(gnutls_x509_crl_t crl,\n\t\t\t       const void *nr, size_t nr_size);\n\n\n/* X.509 Certificate verification functions.\n */\n\n/**\n * gnutls_certificate_verify_flags:\n * @GNUTLS_VERIFY_DISABLE_CA_SIGN: If set a signer does not have to be\n *   a certificate authority. This flag should normally be disabled,\n *   unless you know what this means.\n * @GNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS: If set a signer in the trusted\n *   list is never checked for expiration or activation.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT: Do not allow trusted CA\n *   certificates that have version 1.  This option is to be used\n *   to deprecate all certificates of version 1.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_SAME: If a certificate is not signed by\n *   anyone trusted but exists in the trusted CA list do not treat it\n *   as trusted.\n * @GNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN: A certificate chain is tolerated\n *   if unsorted (the case with many TLS servers out there). This is the\n *   default since GnuTLS 3.1.4.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN: Do not tolerate an unsorted\n *   certificate chain.\n * @GNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT: Allow CA certificates that\n *   have version 1 (both root and intermediate). This might be\n *   dangerous since those haven't the basicConstraints\n *   extension. \n * @GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2: Allow certificates to be signed\n *   using the broken MD2 algorithm.\n * @GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5: Allow certificates to be signed\n *   using the broken MD5 algorithm.\n * @GNUTLS_VERIFY_ALLOW_SIGN_WITH_SHA1: Allow certificates to be signed\n *   using the broken SHA1 hash algorithm.\n * @GNUTLS_VERIFY_ALLOW_BROKEN: Allow certificates to be signed\n *   using any broken algorithm.\n * @GNUTLS_VERIFY_DISABLE_TIME_CHECKS: Disable checking of activation\n *   and expiration validity periods of certificate chains. Don't set\n *   this unless you understand the security implications.\n * @GNUTLS_VERIFY_DISABLE_CRL_CHECKS: Disable checking for validity\n *   using certificate revocation lists or the available OCSP data.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_WILDCARDS: When including a hostname\n *   check in the verification, do not consider any wildcards.\n * @GNUTLS_VERIFY_DO_NOT_ALLOW_IP_MATCHES: When verifying a hostname\n *   prevent textual IP addresses from matching IP addresses in the\n *   certificate. Treat the input only as a DNS name.\n * @GNUTLS_VERIFY_USE_TLS1_RSA: This indicates that a (raw) RSA signature is provided\n *   as in the TLS 1.0 protocol. Not all functions accept this flag.\n * @GNUTLS_VERIFY_IGNORE_UNKNOWN_CRIT_EXTENSIONS: This signals the verification\n *   process, not to fail on unknown critical extensions.\n * @GNUTLS_VERIFY_RSA_PSS_FIXED_SALT_LENGTH: Disallow RSA-PSS signatures made\n *   with mismatching salt length with digest length, as mandated in RFC 8446\n *   4.2.3.\n *\n * Enumeration of different certificate verify flags. Additional\n * verification profiles can be set using GNUTLS_PROFILE_TO_VFLAGS()\n * and %gnutls_certificate_verification_profiles_t.\n */\ntypedef enum gnutls_certificate_verify_flags {\n\tGNUTLS_VERIFY_DISABLE_CA_SIGN = 1 << 0,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_IP_MATCHES = 1<<1,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_SAME = 1 << 2,\n\tGNUTLS_VERIFY_ALLOW_ANY_X509_V1_CA_CRT = 1 << 3,\n\tGNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2 = 1 << 4,\n\tGNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5 = 1 << 5,\n\tGNUTLS_VERIFY_DISABLE_TIME_CHECKS = 1 << 6,\n\tGNUTLS_VERIFY_DISABLE_TRUSTED_TIME_CHECKS = 1 << 7,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_X509_V1_CA_CRT = 1 << 8,\n\tGNUTLS_VERIFY_DISABLE_CRL_CHECKS = 1 << 9,\n\tGNUTLS_VERIFY_ALLOW_UNSORTED_CHAIN = 1 << 10,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_UNSORTED_CHAIN = 1 << 11,\n\tGNUTLS_VERIFY_DO_NOT_ALLOW_WILDCARDS = 1 << 12,\n\tGNUTLS_VERIFY_USE_TLS1_RSA = 1 << 13,\n\tGNUTLS_VERIFY_IGNORE_UNKNOWN_CRIT_EXTENSIONS = 1 << 14,\n\tGNUTLS_VERIFY_ALLOW_SIGN_WITH_SHA1 = 1 << 15,\n\tGNUTLS_VERIFY_RSA_PSS_FIXED_SALT_LENGTH = 1 << 16\n\t/* cannot exceed 2^24 due to GNUTLS_PROFILE_TO_VFLAGS() */\n} gnutls_certificate_verify_flags;\n\n#define GNUTLS_VERIFY_ALLOW_BROKEN (GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD2|GNUTLS_VERIFY_ALLOW_SIGN_RSA_MD5)\n\n/**\n * gnutls_certificate_verification_profiles_t:\n * @GNUTLS_PROFILE_UNKNOWN: An invalid/unknown profile.\n * @GNUTLS_PROFILE_VERY_WEAK: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_VERY_WEAK (64 bits)\n * @GNUTLS_PROFILE_LOW: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_LOW (80 bits)\n * @GNUTLS_PROFILE_LEGACY: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_LEGACY (96 bits)\n * @GNUTLS_PROFILE_MEDIUM: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_MEDIUM (112 bits)\n * @GNUTLS_PROFILE_HIGH: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_HIGH (128 bits)\n * @GNUTLS_PROFILE_ULTRA: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_ULTRA (192 bits)\n * @GNUTLS_PROFILE_FUTURE: A verification profile that\n *  corresponds to @GNUTLS_SEC_PARAM_FUTURE (256 bits)\n * @GNUTLS_PROFILE_SUITEB128: A verification profile that\n *  applies the SUITEB128 rules\n * @GNUTLS_PROFILE_SUITEB192: A verification profile that\n *  applies the SUITEB192 rules\n *\n * Enumeration of different certificate verification profiles.\n */\ntypedef enum gnutls_certificate_verification_profiles_t {\n\tGNUTLS_PROFILE_UNKNOWN = 0,\n\tGNUTLS_PROFILE_VERY_WEAK = 1,\n\tGNUTLS_PROFILE_LOW = 2,\n\tGNUTLS_PROFILE_LEGACY = 4,\n\tGNUTLS_PROFILE_MEDIUM = 5,\n\tGNUTLS_PROFILE_HIGH = 6,\n\tGNUTLS_PROFILE_ULTRA = 7,\n\tGNUTLS_PROFILE_FUTURE = 8,\n\t\n\tGNUTLS_PROFILE_SUITEB128=32,\n\tGNUTLS_PROFILE_SUITEB192=33\n\t/*GNUTLS_PROFILE_MAX=255*/\n} gnutls_certificate_verification_profiles_t;\n\n#define GNUTLS_PROFILE_TO_VFLAGS(x) \\\n\t(((unsigned)x)<<24)\n\n#define GNUTLS_VFLAGS_PROFILE_MASK (0xff000000)\n\n#define GNUTLS_VFLAGS_TO_PROFILE(x) \\\n\t((((unsigned)x)>>24)&0xff)\n\nconst char *\n\tgnutls_certificate_verification_profile_get_name(gnutls_certificate_verification_profiles_t id) __GNUTLS_CONST__;\ngnutls_certificate_verification_profiles_t gnutls_certificate_verification_profile_get_id(const char *name) __GNUTLS_CONST__;\n\nunsigned gnutls_x509_crt_check_issuer(gnutls_x509_crt_t cert,\n\t\t\t\t gnutls_x509_crt_t issuer);\n\nint gnutls_x509_crt_list_verify(const gnutls_x509_crt_t *\n\t\t\t\tcert_list, unsigned cert_list_length,\n\t\t\t\tconst gnutls_x509_crt_t * CA_list,\n\t\t\t\tunsigned CA_list_length,\n\t\t\t\tconst gnutls_x509_crl_t * CRL_list,\n\t\t\t\tunsigned CRL_list_length,\n\t\t\t\tunsigned int flags, unsigned int *verify);\n\nint gnutls_x509_crt_verify(gnutls_x509_crt_t cert,\n\t\t\t   const gnutls_x509_crt_t * CA_list,\n\t\t\t   unsigned CA_list_length, unsigned int flags,\n\t\t\t   unsigned int *verify);\nint gnutls_x509_crl_verify(gnutls_x509_crl_t crl,\n\t\t\t   const gnutls_x509_crt_t * CA_list,\n\t\t\t   unsigned CA_list_length, unsigned int flags,\n\t\t\t   unsigned int *verify);\n\nint\ngnutls_x509_crt_verify_data2(gnutls_x509_crt_t crt,\n\t\t\t   gnutls_sign_algorithm_t algo,\n\t\t\t   unsigned int flags,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   const gnutls_datum_t * signature);\n\nint gnutls_x509_crt_check_revocation(gnutls_x509_crt_t cert,\n\t\t\t\t     const gnutls_x509_crl_t *\n\t\t\t\t     crl_list, unsigned crl_list_length);\n\nint gnutls_x509_crt_get_fingerprint(gnutls_x509_crt_t cert,\n\t\t\t\t    gnutls_digest_algorithm_t algo,\n\t\t\t\t    void *buf, size_t * buf_size);\n\nint gnutls_x509_crt_get_key_purpose_oid(gnutls_x509_crt_t cert,\n\t\t\t\t\tunsigned indx, void *oid,\n\t\t\t\t\tsize_t * oid_size,\n\t\t\t\t\tunsigned int *critical);\nint gnutls_x509_crt_set_key_purpose_oid(gnutls_x509_crt_t cert,\n\t\t\t\t\tconst void *oid,\n\t\t\t\t\tunsigned int critical);\n\nunsigned gnutls_x509_crt_check_key_purpose(gnutls_x509_crt_t cert,\n\t\tconst char *purpose, unsigned flags);\n\n/* Private key handling.\n */\n\n/* Flags for the gnutls_x509_privkey_export_pkcs8() function.\n */\n\n#define GNUTLS_PKCS8_PLAIN GNUTLS_PKCS_PLAIN\n#define GNUTLS_PKCS8_USE_PKCS12_3DES GNUTLS_PKCS_PKCS12_3DES\n#define GNUTLS_PKCS8_USE_PKCS12_ARCFOUR GNUTLS_PKCS_PKCS12_ARCFOUR\n#define GNUTLS_PKCS8_USE_PKCS12_RC2_40 GNUTLS_PKCS_PKCS12_RC2_40\n\n/**\n * gnutls_pkcs_encrypt_flags_t:\n * @GNUTLS_PKCS_PLAIN: Unencrypted private key.\n * @GNUTLS_PKCS_NULL_PASSWORD: Some schemas distinguish between an empty and a NULL password.\n * @GNUTLS_PKCS_PKCS12_3DES: PKCS-12 3DES.\n * @GNUTLS_PKCS_PKCS12_ARCFOUR: PKCS-12 ARCFOUR.\n * @GNUTLS_PKCS_PKCS12_RC2_40: PKCS-12 RC2-40.\n * @GNUTLS_PKCS_PBES2_3DES: PBES2 3DES.\n * @GNUTLS_PKCS_PBES2_AES_128: PBES2 AES-128.\n * @GNUTLS_PKCS_PBES2_AES_192: PBES2 AES-192.\n * @GNUTLS_PKCS_PBES2_AES_256: PBES2 AES-256.\n * @GNUTLS_PKCS_PBES2_DES: PBES2 single DES.\n * @GNUTLS_PKCS_PBES1_DES_MD5: PBES1 with single DES; for compatibility with openssl only.\n * @GNUTLS_PKCS_PBES2_GOST_TC26Z: PBES2 GOST 28147-89 CFB with TC26-Z S-box.\n * @GNUTLS_PKCS_PBES2_GOST_CPA: PBES2 GOST 28147-89 CFB with CryptoPro-A S-box.\n * @GNUTLS_PKCS_PBES2_GOST_CPB: PBES2 GOST 28147-89 CFB with CryptoPro-B S-box.\n * @GNUTLS_PKCS_PBES2_GOST_CPC: PBES2 GOST 28147-89 CFB with CryptoPro-C S-box.\n * @GNUTLS_PKCS_PBES2_GOST_CPD: PBES2 GOST 28147-89 CFB with CryptoPro-D S-box.\n *\n * Enumeration of different PKCS encryption flags.\n */\ntypedef enum gnutls_pkcs_encrypt_flags_t {\n\tGNUTLS_PKCS_PLAIN = 1,\n\tGNUTLS_PKCS_PKCS12_3DES = 1<<1,\n\tGNUTLS_PKCS_PKCS12_ARCFOUR = 1<<2,\n\tGNUTLS_PKCS_PKCS12_RC2_40 = 1<<3,\n\tGNUTLS_PKCS_PBES2_3DES = 1<<4,\n\tGNUTLS_PKCS_PBES2_AES_128 = 1<<5,\n\tGNUTLS_PKCS_PBES2_AES_192 = 1<<6,\n\tGNUTLS_PKCS_PBES2_AES_256 = 1<<7,\n\tGNUTLS_PKCS_NULL_PASSWORD = 1<<8,\n\tGNUTLS_PKCS_PBES2_DES = 1<<9,\n\tGNUTLS_PKCS_PBES1_DES_MD5 = 1<<10,\n\tGNUTLS_PKCS_PBES2_GOST_TC26Z = 1<<11,\n\tGNUTLS_PKCS_PBES2_GOST_CPA = 1<<12,\n\tGNUTLS_PKCS_PBES2_GOST_CPB = 1<<13,\n\tGNUTLS_PKCS_PBES2_GOST_CPC = 1<<14,\n\tGNUTLS_PKCS_PBES2_GOST_CPD = 1<<15\n} gnutls_pkcs_encrypt_flags_t;\n\n#define GNUTLS_PKCS_CIPHER_MASK(x) ((x)&(~(GNUTLS_PKCS_NULL_PASSWORD)))\n\n#define GNUTLS_PKCS_USE_PKCS12_3DES GNUTLS_PKCS_PKCS12_3DES\n#define GNUTLS_PKCS_USE_PKCS12_ARCFOUR GNUTLS_PKCS_PKCS12_ARCFOUR\n#define GNUTLS_PKCS_USE_PKCS12_RC2_40 GNUTLS_PKCS_PKCS12_RC2_40\n#define GNUTLS_PKCS_USE_PBES2_3DES GNUTLS_PKCS_PBES2_3DES\n#define GNUTLS_PKCS_USE_PBES2_AES_128 GNUTLS_PKCS_PBES2_AES_128\n#define GNUTLS_PKCS_USE_PBES2_AES_192 GNUTLS_PKCS_PBES2_AES_192\n#define GNUTLS_PKCS_USE_PBES2_AES_256 GNUTLS_PKCS_PBES2_AES_256\n#define GNUTLS_PKCS_USE_PBES2_GOST_TC26Z GNUTLS_PKCS_PBES2_GOST_TC26Z\n#define GNUTLS_PKCS_USE_PBES2_GOST_CPA GNUTLS_PKCS_PBES2_GOST_CPA\n#define GNUTLS_PKCS_USE_PBES2_GOST_CPB GNUTLS_PKCS_PBES2_GOST_CPB\n#define GNUTLS_PKCS_USE_PBES2_GOST_CPC GNUTLS_PKCS_PBES2_GOST_CPC\n#define GNUTLS_PKCS_USE_PBES2_GOST_CPD GNUTLS_PKCS_PBES2_GOST_CPD\n\nconst char *gnutls_pkcs_schema_get_name(unsigned int schema);\nconst char *gnutls_pkcs_schema_get_oid(unsigned int schema);\n\nint gnutls_x509_privkey_init(gnutls_x509_privkey_t * key);\nvoid gnutls_x509_privkey_deinit(gnutls_x509_privkey_t key);\ngnutls_sec_param_t\ngnutls_x509_privkey_sec_param(gnutls_x509_privkey_t key);\n\nvoid gnutls_x509_privkey_set_pin_function(gnutls_x509_privkey_t key,\n\t\t\t\t      gnutls_pin_callback_t fn,\n\t\t\t\t      void *userdata);\n\nint gnutls_x509_privkey_cpy(gnutls_x509_privkey_t dst,\n\t\t\t    gnutls_x509_privkey_t src);\nint gnutls_x509_privkey_import(gnutls_x509_privkey_t key,\n\t\t\t       const gnutls_datum_t * data,\n\t\t\t       gnutls_x509_crt_fmt_t format);\nint gnutls_x509_privkey_import_pkcs8(gnutls_x509_privkey_t key,\n\t\t\t\t     const gnutls_datum_t * data,\n\t\t\t\t     gnutls_x509_crt_fmt_t format,\n\t\t\t\t     const char *password,\n\t\t\t\t     unsigned int flags);\nint gnutls_x509_privkey_import_openssl(gnutls_x509_privkey_t key,\n\t\t\t\t       const gnutls_datum_t * data,\n\t\t\t\t       const char *password);\n\nint\ngnutls_pkcs8_info(const gnutls_datum_t * data, gnutls_x509_crt_fmt_t format,\n\t\t  unsigned int *schema, unsigned int *cipher,\n\t\t  void *salt, unsigned int *salt_size,\n\t\t  unsigned int *iter_count, char **oid);\n\nint gnutls_x509_privkey_import2(gnutls_x509_privkey_t key,\n\t\t\t\tconst gnutls_datum_t * data,\n\t\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\t\tconst char *password, unsigned int flags);\n\nint gnutls_x509_privkey_import_rsa_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       const gnutls_datum_t * m,\n\t\t\t\t       const gnutls_datum_t * e,\n\t\t\t\t       const gnutls_datum_t * d,\n\t\t\t\t       const gnutls_datum_t * p,\n\t\t\t\t       const gnutls_datum_t * q,\n\t\t\t\t       const gnutls_datum_t * u);\nint gnutls_x509_privkey_import_rsa_raw2(gnutls_x509_privkey_t key,\n\t\t\t\t\tconst gnutls_datum_t * m,\n\t\t\t\t\tconst gnutls_datum_t * e,\n\t\t\t\t\tconst gnutls_datum_t * d,\n\t\t\t\t\tconst gnutls_datum_t * p,\n\t\t\t\t\tconst gnutls_datum_t * q,\n\t\t\t\t\tconst gnutls_datum_t * u,\n\t\t\t\t\tconst gnutls_datum_t * e1,\n\t\t\t\t\tconst gnutls_datum_t * e2);\nint gnutls_x509_privkey_import_ecc_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t curve,\n\t\t\t\t       const gnutls_datum_t * x,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * k);\nint gnutls_x509_privkey_import_gost_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t curve,\n\t\t\t\t       gnutls_digest_algorithm_t digest,\n\t\t\t\t       gnutls_gost_paramset_t paramset,\n\t\t\t\t       const gnutls_datum_t * x,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * k);\n\nint gnutls_x509_privkey_fix(gnutls_x509_privkey_t key);\n\nint gnutls_x509_privkey_export_dsa_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_datum_t * p,\n\t\t\t\t       gnutls_datum_t * q,\n\t\t\t\t       gnutls_datum_t * g,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * x);\nint gnutls_x509_privkey_import_dsa_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       const gnutls_datum_t * p,\n\t\t\t\t       const gnutls_datum_t * q,\n\t\t\t\t       const gnutls_datum_t * g,\n\t\t\t\t       const gnutls_datum_t * y,\n\t\t\t\t       const gnutls_datum_t * x);\n\nint gnutls_x509_privkey_get_pk_algorithm(gnutls_x509_privkey_t key);\nint gnutls_x509_privkey_get_pk_algorithm2(gnutls_x509_privkey_t\n\t\t\t\t\t  key, unsigned int *bits);\nint gnutls_x509_privkey_get_spki(gnutls_x509_privkey_t key,\n\t\t\t\t gnutls_x509_spki_t spki,\n\t\t\t\t unsigned int flags);\nint\ngnutls_x509_privkey_set_spki(gnutls_x509_privkey_t key,\n\t\t\t     const gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\n\nint gnutls_x509_privkey_get_key_id(gnutls_x509_privkey_t key,\n\t\t\t\t   unsigned int flags,\n\t\t\t\t   unsigned char *output_data,\n\t\t\t\t   size_t * output_data_size);\n\nint gnutls_x509_privkey_generate(gnutls_x509_privkey_t key,\n\t\t\t\t gnutls_pk_algorithm_t algo,\n\t\t\t\t unsigned int bits, unsigned int flags);\n\nvoid gnutls_x509_privkey_set_flags(gnutls_x509_privkey_t key, unsigned int flags);\n\n/**\n * gnutls_keygen_types_t:\n * @GNUTLS_KEYGEN_SEED: Specifies the seed to be used in key generation.\n * @GNUTLS_KEYGEN_DIGEST: The size field specifies the hash algorithm to be used in key generation.\n * @GNUTLS_KEYGEN_SPKI: data points to a %gnutls_x509_spki_t structure; it is not used after the key generation call.\n *\n * Enumeration of different key generation data options.\n */\ntypedef enum {\n\tGNUTLS_KEYGEN_SEED = 1,\n\tGNUTLS_KEYGEN_DIGEST = 2,\n\tGNUTLS_KEYGEN_SPKI = 3\n} gnutls_keygen_types_t;\n\ntypedef struct {\n\tgnutls_keygen_types_t type;\n\tunsigned char *data;\n\tunsigned int size;\n} gnutls_keygen_data_st;\n\nint\ngnutls_x509_privkey_generate2(gnutls_x509_privkey_t key,\n\t\t\t      gnutls_pk_algorithm_t algo, unsigned int bits,\n\t\t\t      unsigned int flags, const gnutls_keygen_data_st *data, unsigned data_size);\n\nint gnutls_x509_privkey_verify_seed(gnutls_x509_privkey_t key, gnutls_digest_algorithm_t, const void *seed, size_t seed_size);\nint gnutls_x509_privkey_get_seed(gnutls_x509_privkey_t key, gnutls_digest_algorithm_t*, void *seed, size_t *seed_size);\n\nint gnutls_x509_privkey_verify_params(gnutls_x509_privkey_t key);\n\nint gnutls_x509_privkey_export(gnutls_x509_privkey_t key,\n\t\t\t       gnutls_x509_crt_fmt_t format,\n\t\t\t       void *output_data,\n\t\t\t       size_t * output_data_size);\nint gnutls_x509_privkey_export2(gnutls_x509_privkey_t key,\n\t\t\t\tgnutls_x509_crt_fmt_t format,\n\t\t\t\tgnutls_datum_t * out);\nint gnutls_x509_privkey_export_pkcs8(gnutls_x509_privkey_t key,\n\t\t\t\t     gnutls_x509_crt_fmt_t format,\n\t\t\t\t     const char *password,\n\t\t\t\t     unsigned int flags,\n\t\t\t\t     void *output_data,\n\t\t\t\t     size_t * output_data_size);\nint gnutls_x509_privkey_export2_pkcs8(gnutls_x509_privkey_t key,\n\t\t\t\t      gnutls_x509_crt_fmt_t format,\n\t\t\t\t      const char *password,\n\t\t\t\t      unsigned int flags,\n\t\t\t\t      gnutls_datum_t * out);\nint gnutls_x509_privkey_export_rsa_raw2(gnutls_x509_privkey_t key,\n\t\t\t\t\tgnutls_datum_t * m,\n\t\t\t\t\tgnutls_datum_t * e,\n\t\t\t\t\tgnutls_datum_t * d,\n\t\t\t\t\tgnutls_datum_t * p,\n\t\t\t\t\tgnutls_datum_t * q,\n\t\t\t\t\tgnutls_datum_t * u,\n\t\t\t\t\tgnutls_datum_t * e1,\n\t\t\t\t\tgnutls_datum_t * e2);\nint gnutls_x509_privkey_export_rsa_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_datum_t * m,\n\t\t\t\t       gnutls_datum_t * e,\n\t\t\t\t       gnutls_datum_t * d,\n\t\t\t\t       gnutls_datum_t * p,\n\t\t\t\t       gnutls_datum_t * q,\n\t\t\t\t       gnutls_datum_t * u);\nint gnutls_x509_privkey_export_ecc_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k);\nint gnutls_x509_privkey_export_gost_raw(gnutls_x509_privkey_t key,\n\t\t\t\t       gnutls_ecc_curve_t * curve,\n\t\t\t\t       gnutls_digest_algorithm_t * digest,\n\t\t\t\t       gnutls_gost_paramset_t * paramset,\n\t\t\t\t       gnutls_datum_t * x,\n\t\t\t\t       gnutls_datum_t * y,\n\t\t\t\t       gnutls_datum_t * k);\n\nint gnutls_x509_privkey_sign_data(gnutls_x509_privkey_t key,\n\t\t\t\t  gnutls_digest_algorithm_t digest,\n\t\t\t\t  unsigned int flags,\n\t\t\t\t  const gnutls_datum_t * data,\n\t\t\t\t  void *signature,\n\t\t\t\t  size_t * signature_size);\n\n/* Certificate request stuff.\n */\nint gnutls_x509_crq_sign(gnutls_x509_crq_t crq,\n\t\t\t gnutls_x509_privkey_t key);\n\nint gnutls_x509_crq_sign2(gnutls_x509_crq_t crq,\n\t\t\t  gnutls_x509_privkey_t key,\n\t\t\t  gnutls_digest_algorithm_t dig,\n\t\t\t  unsigned int flags);\n\nint gnutls_x509_crq_print(gnutls_x509_crq_t crq,\n\t\t\t  gnutls_certificate_print_formats_t\n\t\t\t  format, gnutls_datum_t * out);\n\nint gnutls_x509_crq_verify(gnutls_x509_crq_t crq, unsigned int flags);\n\nint gnutls_x509_crq_init(gnutls_x509_crq_t * crq);\nvoid gnutls_x509_crq_deinit(gnutls_x509_crq_t crq);\nint gnutls_x509_crq_import(gnutls_x509_crq_t crq,\n\t\t\t   const gnutls_datum_t * data,\n\t\t\t   gnutls_x509_crt_fmt_t format);\n\nint gnutls_x509_crq_get_private_key_usage_period(gnutls_x509_crq_t\n\t\t\t\t\t\t cert,\n\t\t\t\t\t\t time_t *\n\t\t\t\t\t\t activation,\n\t\t\t\t\t\t time_t *\n\t\t\t\t\t\t expiration, unsigned int\n\t\t\t\t\t\t *critical);\n\nint gnutls_x509_crq_get_dn(gnutls_x509_crq_t crq, char *buf,\n\t\t\t   size_t * sizeof_buf);\nint gnutls_x509_crq_get_dn2(gnutls_x509_crq_t crq, gnutls_datum_t * dn);\nint gnutls_x509_crq_get_dn3(gnutls_x509_crq_t crq, gnutls_datum_t * dn, unsigned flags);\nint gnutls_x509_crq_get_dn_oid(gnutls_x509_crq_t crq, unsigned indx,\n\t\t\t       void *oid, size_t * sizeof_oid);\nint gnutls_x509_crq_get_dn_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t  const char *oid, unsigned indx,\n\t\t\t\t  unsigned int raw_flag, void *buf,\n\t\t\t\t  size_t * sizeof_buf);\nint gnutls_x509_crq_set_dn(gnutls_x509_crq_t crq, const char *dn,\n\t\t\t   const char **err);\nint gnutls_x509_crq_set_dn_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t  const char *oid,\n\t\t\t\t  unsigned int raw_flag,\n\t\t\t\t  const void *data,\n\t\t\t\t  unsigned int sizeof_data);\nint gnutls_x509_crq_set_version(gnutls_x509_crq_t crq,\n\t\t\t\tunsigned int version);\nint gnutls_x509_crq_get_version(gnutls_x509_crq_t crq);\nint gnutls_x509_crq_set_key(gnutls_x509_crq_t crq,\n\t\t\t    gnutls_x509_privkey_t key);\n\nint\ngnutls_x509_crq_set_extension_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t     const char *oid, const void *buf,\n\t\t\t\t     size_t sizeof_buf,\n\t\t\t\t     unsigned int critical);\n\nint gnutls_x509_crq_set_challenge_password(gnutls_x509_crq_t crq,\n\t\t\t\t\t   const char *pass);\nint gnutls_x509_crq_get_challenge_password(gnutls_x509_crq_t crq,\n\t\t\t\t\t   char *pass,\n\t\t\t\t\t   size_t * sizeof_pass);\n\nint gnutls_x509_crq_set_attribute_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\t const char *oid,\n\t\t\t\t\t void *buf, size_t sizeof_buf);\nint gnutls_x509_crq_get_attribute_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t void *buf, size_t * sizeof_buf);\n\nint gnutls_x509_crq_export(gnutls_x509_crq_t crq,\n\t\t\t   gnutls_x509_crt_fmt_t format,\n\t\t\t   void *output_data, size_t * output_data_size);\nint gnutls_x509_crq_export2(gnutls_x509_crq_t crq,\n\t\t\t    gnutls_x509_crt_fmt_t format,\n\t\t\t    gnutls_datum_t * out);\n\nint gnutls_x509_crt_set_crq(gnutls_x509_crt_t crt, gnutls_x509_crq_t crq);\nint gnutls_x509_crt_set_crq_extensions(gnutls_x509_crt_t crt,\n\t\t\t\t       gnutls_x509_crq_t crq);\n\nint\ngnutls_x509_crt_set_crq_extension_by_oid(gnutls_x509_crt_t crt,\n\t\t\t\t         gnutls_x509_crq_t crq, const char *oid,\n\t\t\t\t         unsigned flags);\n\nint gnutls_x509_crq_set_private_key_usage_period(gnutls_x509_crq_t\n\t\t\t\t\t\t crq,\n\t\t\t\t\t\t time_t activation,\n\t\t\t\t\t\t time_t expiration);\nint gnutls_x509_crq_set_key_rsa_raw(gnutls_x509_crq_t crq,\n\t\t\t\t    const gnutls_datum_t * m,\n\t\t\t\t    const gnutls_datum_t * e);\nint gnutls_x509_crq_set_subject_alt_name(gnutls_x509_crq_t crq,\n\t\t\t\t\t gnutls_x509_subject_alt_name_t\n\t\t\t\t\t nt, const void *data,\n\t\t\t\t\t unsigned int data_size,\n\t\t\t\t\t unsigned int flags);\n\nint\ngnutls_x509_crq_set_subject_alt_othername(gnutls_x509_crq_t crq,\n\t\t\t\t     const char *oid,\n\t\t\t\t     const void *data,\n\t\t\t\t     unsigned int data_size,\n\t\t\t\t     unsigned int flags);\n\nint gnutls_x509_crq_set_key_usage(gnutls_x509_crq_t crq,\n\t\t\t\t  unsigned int usage);\nint gnutls_x509_crq_set_basic_constraints(gnutls_x509_crq_t crq,\n\t\t\t\t\t  unsigned int ca,\n\t\t\t\t\t  int pathLenConstraint);\nint gnutls_x509_crq_set_key_purpose_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\tconst void *oid,\n\t\t\t\t\tunsigned int critical);\nint gnutls_x509_crq_get_key_purpose_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\tunsigned indx, void *oid,\n\t\t\t\t\tsize_t * sizeof_oid,\n\t\t\t\t\tunsigned int *critical);\n\nint gnutls_x509_crq_get_extension_data(gnutls_x509_crq_t crq,\n\t\t\t\t       unsigned indx, void *data,\n\t\t\t\t       size_t * sizeof_data);\nint\ngnutls_x509_crq_get_extension_data2(gnutls_x509_crq_t crq,\n\t\t\t       unsigned indx,\n\t\t\t       gnutls_datum_t * data);\nint gnutls_x509_crq_get_extension_info(gnutls_x509_crq_t crq,\n\t\t\t\t       unsigned indx, void *oid,\n\t\t\t\t       size_t * sizeof_oid,\n\t\t\t\t       unsigned int *critical);\nint gnutls_x509_crq_get_attribute_data(gnutls_x509_crq_t crq,\n\t\t\t\t       unsigned indx, void *data,\n\t\t\t\t       size_t * sizeof_data);\nint gnutls_x509_crq_get_attribute_info(gnutls_x509_crq_t crq,\n\t\t\t\t       unsigned indx, void *oid,\n\t\t\t\t       size_t * sizeof_oid);\nint gnutls_x509_crq_get_pk_algorithm(gnutls_x509_crq_t crq,\n\t\t\t\t     unsigned int *bits);\nint gnutls_x509_crq_get_spki(gnutls_x509_crq_t crq, gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\n\nint gnutls_x509_crq_set_spki(gnutls_x509_crq_t crq, const gnutls_x509_spki_t spki,\n\t\t\t     unsigned int flags);\n\nint gnutls_x509_crq_get_signature_oid(gnutls_x509_crq_t crq, char *oid, size_t *oid_size);\nint gnutls_x509_crq_get_pk_oid(gnutls_x509_crq_t crq, char *oid, size_t *oid_size);\n\nint gnutls_x509_crq_get_key_id(gnutls_x509_crq_t crq,\n\t\t\t       unsigned int flags,\n\t\t\t       unsigned char *output_data,\n\t\t\t       size_t * output_data_size);\nint gnutls_x509_crq_get_key_rsa_raw(gnutls_x509_crq_t crq,\n\t\t\t\t    gnutls_datum_t * m,\n\t\t\t\t    gnutls_datum_t * e);\n\nint gnutls_x509_crq_get_key_usage(gnutls_x509_crq_t crq,\n\t\t\t\t  unsigned int *key_usage,\n\t\t\t\t  unsigned int *critical);\nint gnutls_x509_crq_get_basic_constraints(gnutls_x509_crq_t crq,\n\t\t\t\t\t  unsigned int *critical,\n\t\t\t\t\t  unsigned int *ca, int *pathlen);\nint gnutls_x509_crq_get_subject_alt_name(gnutls_x509_crq_t crq,\n\t\t\t\t\t unsigned int seq,\n\t\t\t\t\t void *ret,\n\t\t\t\t\t size_t * ret_size,\n\t\t\t\t\t unsigned int *ret_type,\n\t\t\t\t\t unsigned int *critical);\nint gnutls_x509_crq_get_subject_alt_othername_oid(gnutls_x509_crq_t\n\t\t\t\t\t\t  crq,\n\t\t\t\t\t\t  unsigned int seq,\n\t\t\t\t\t\t  void *ret,\n\t\t\t\t\t\t  size_t * ret_size);\n\nint gnutls_x509_crq_get_extension_by_oid(gnutls_x509_crq_t crq,\n\t\t\t\t\t const char *oid, unsigned indx,\n\t\t\t\t\t void *buf,\n\t\t\t\t\t size_t * sizeof_buf,\n\t\t\t\t\t unsigned int *critical);\n\nint gnutls_x509_crq_get_tlsfeatures(gnutls_x509_crq_t crq,\n\t\t\t\t    gnutls_x509_tlsfeatures_t features,\n\t\t\t\t    unsigned flags,\n\t\t\t\t    unsigned int *critical);\nint gnutls_x509_crq_set_tlsfeatures(gnutls_x509_crq_t crq,\n\t\t\t\t    gnutls_x509_tlsfeatures_t features);\n\nint\ngnutls_x509_crt_get_extension_by_oid2(gnutls_x509_crt_t cert,\n\t\t\t\t     const char *oid, unsigned indx,\n\t\t\t\t     gnutls_datum_t *output,\n\t\t\t\t     unsigned int *critical);\n\ntypedef struct gnutls_x509_trust_list_st *gnutls_x509_trust_list_t;\ntypedef struct gnutls_x509_trust_list_iter *gnutls_x509_trust_list_iter_t;\n\nint\ngnutls_x509_trust_list_init(gnutls_x509_trust_list_t * list,\n\t\t\t    unsigned int size);\n\nvoid\ngnutls_x509_trust_list_deinit(gnutls_x509_trust_list_t list,\n\t\t\t      unsigned int all);\n\nint gnutls_x509_trust_list_get_issuer(gnutls_x509_trust_list_t\n\t\t\t\t      list, gnutls_x509_crt_t cert,\n\t\t\t\t      gnutls_x509_crt_t * issuer,\n\t\t\t\t      unsigned int flags);\n\nint gnutls_x509_trust_list_get_issuer_by_dn(gnutls_x509_trust_list_t list,\n\t\t\t\t      const gnutls_datum_t *dn,\n\t\t\t\t      gnutls_x509_crt_t *issuer,\n\t\t\t\t      unsigned int flags);\n\nint gnutls_x509_trust_list_get_issuer_by_subject_key_id(gnutls_x509_trust_list_t list,\n\t\t\t\t      const gnutls_datum_t *dn,\n\t\t\t\t      const gnutls_datum_t *spki,\n\t\t\t\t      gnutls_x509_crt_t *issuer,\n\t\t\t\t      unsigned int flags);\n/**\n * gnutls_trust_list_flags_t:\n * @GNUTLS_TL_VERIFY_CRL: If any CRLs are provided they will be verified for validity\n *   prior to be added. The CA certificates that will be used for verification are the\n *   ones already added in the trusted list.\n * @GNUTLS_TL_USE_IN_TLS: Internal flag used by GnuTLS. If provided the trust list\n *   structure will cache a copy of CA DNs to be used in the certificate request\n *   TLS message.\n * @GNUTLS_TL_NO_DUPLICATES: If this flag is specified, a function adding certificates\n *   will check and eliminate any duplicates.\n * @GNUTLS_TL_NO_DUPLICATE_KEY: If this flag is specified, a certificate sharing the\n *   same key as a previously added on will not be added.\n * @GNUTLS_TL_GET_COPY: The semantics of this flag are documented to the functions which\n *   are applicable. In general, on returned value, the function will provide a copy\n *   if this flag is provided, rather than a pointer to internal data.\n * @GNUTLS_TL_FAIL_ON_INVALID_CRL: If an CRL is added which cannot be validated return\n *   an error instead of ignoring (must be used with %GNUTLS_TL_VERIFY_CRL).\n *\n * Enumeration of different certificate trust list flags.\n */\ntypedef enum gnutls_trust_list_flags_t {\n\tGNUTLS_TL_VERIFY_CRL = 1,\n#define GNUTLS_TL_VERIFY_CRL 1\n\tGNUTLS_TL_USE_IN_TLS = (1<<1),\n#define GNUTLS_TL_USE_IN_TLS (1<<1)\n\tGNUTLS_TL_NO_DUPLICATES = (1<<2),\n#define GNUTLS_TL_NO_DUPLICATES (1<<2)\n\tGNUTLS_TL_NO_DUPLICATE_KEY = (1<<3),\n#define GNUTLS_TL_NO_DUPLICATE_KEY (1<<3)\n\tGNUTLS_TL_GET_COPY = (1<<4),\n#define GNUTLS_TL_GET_COPY (1<<4)\n\tGNUTLS_TL_FAIL_ON_INVALID_CRL = (1<<5)\n#define GNUTLS_TL_FAIL_ON_INVALID_CRL (1<<5)\n} gnutls_trust_list_flags_t;\n\nint\ngnutls_x509_trust_list_add_cas(gnutls_x509_trust_list_t list,\n\t\t\t       const gnutls_x509_crt_t * clist,\n\t\t\t       unsigned clist_size, unsigned int flags);\nint gnutls_x509_trust_list_remove_cas(gnutls_x509_trust_list_t\n\t\t\t\t      list,\n\t\t\t\t      const gnutls_x509_crt_t *\n\t\t\t\t      clist, unsigned clist_size);\n\nint gnutls_x509_trust_list_add_named_crt(gnutls_x509_trust_list_t\n\t\t\t\t\t list,\n\t\t\t\t\t gnutls_x509_crt_t cert,\n\t\t\t\t\t const void *name,\n\t\t\t\t\t size_t name_size,\n\t\t\t\t\t unsigned int flags);\n\nint\ngnutls_x509_trust_list_add_crls(gnutls_x509_trust_list_t list,\n\t\t\t\tconst gnutls_x509_crl_t *\n\t\t\t\tcrl_list, unsigned crl_size,\n\t\t\t\tunsigned int flags,\n\t\t\t\tunsigned int verification_flags);\n\n\nint\ngnutls_x509_trust_list_iter_get_ca(gnutls_x509_trust_list_t list,\n                                   gnutls_x509_trust_list_iter_t *iter,\n                                   gnutls_x509_crt_t *crt);\n\nvoid gnutls_x509_trust_list_iter_deinit(gnutls_x509_trust_list_iter_t iter);\n\ntypedef int gnutls_verify_output_function(gnutls_x509_crt_t cert, gnutls_x509_crt_t issuer,\n\t\t\t\t\t\t\t\t\t\t\t\t /* The issuer if verification failed\n\t\t\t\t\t\t\t\t\t\t\t\t * because of him. might be null.\n\t\t\t\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t  gnutls_x509_crl_t crl,\t/* The CRL that caused verification failure \n\t\t\t\t\t\t\t\t\t * if any. Might be null.\n\t\t\t\t\t\t\t\t\t */\n\t\t\t\t\t  unsigned int\n\t\t\t\t\t  verification_output);\n\nvoid gnutls_session_set_verify_output_function(gnutls_session_t session,\n\t\tgnutls_verify_output_function * func);\n\nint gnutls_x509_trust_list_verify_named_crt\n    (gnutls_x509_trust_list_t list, gnutls_x509_crt_t cert,\n     const void *name, size_t name_size, unsigned int flags,\n     unsigned int *verify, gnutls_verify_output_function func);\n\nint\ngnutls_x509_trust_list_verify_crt2(gnutls_x509_trust_list_t list,\n\t\t\t\t  gnutls_x509_crt_t * cert_list,\n\t\t\t\t  unsigned int cert_list_size,\n\t\t\t\t  gnutls_typed_vdata_st * data,\n\t\t\t\t  unsigned int elements,\n\t\t\t\t  unsigned int flags,\n\t\t\t\t  unsigned int *voutput,\n\t\t\t\t  gnutls_verify_output_function func);\n\nint\ngnutls_x509_trust_list_verify_crt(gnutls_x509_trust_list_t list,\n\t\t\t\t  gnutls_x509_crt_t * cert_list,\n\t\t\t\t  unsigned int cert_list_size,\n\t\t\t\t  unsigned int flags,\n\t\t\t\t  unsigned int *verify,\n\t\t\t\t  gnutls_verify_output_function func);\n\n\t/* trust list convenience functions */\nint\ngnutls_x509_trust_list_add_trust_mem(gnutls_x509_trust_list_t\n\t\t\t\t     list,\n\t\t\t\t     const gnutls_datum_t * cas,\n\t\t\t\t     const gnutls_datum_t * crls,\n\t\t\t\t     gnutls_x509_crt_fmt_t type,\n\t\t\t\t     unsigned int tl_flags,\n\t\t\t\t     unsigned int tl_vflags);\n\nint\ngnutls_x509_trust_list_add_trust_file(gnutls_x509_trust_list_t\n\t\t\t\t      list, const char *ca_file,\n\t\t\t\t      const char *crl_file,\n\t\t\t\t      gnutls_x509_crt_fmt_t type,\n\t\t\t\t      unsigned int tl_flags,\n\t\t\t\t      unsigned int tl_vflags);\n\nint\ngnutls_x509_trust_list_add_trust_dir(gnutls_x509_trust_list_t list,\n\t\t\t\t      const char *ca_dir,\n\t\t\t\t      const char *crl_dir,\n\t\t\t\t      gnutls_x509_crt_fmt_t type,\n\t\t\t\t      unsigned int tl_flags,\n\t\t\t\t      unsigned int tl_vflags);\n\nint\ngnutls_x509_trust_list_remove_trust_file(gnutls_x509_trust_list_t\n\t\t\t\t\t list,\n\t\t\t\t\t const char *ca_file,\n\t\t\t\t\t gnutls_x509_crt_fmt_t type);\n\nint\ngnutls_x509_trust_list_remove_trust_mem(gnutls_x509_trust_list_t\n\t\t\t\t\tlist,\n\t\t\t\t\tconst gnutls_datum_t *\n\t\t\t\t\tcas, gnutls_x509_crt_fmt_t type);\n\nint\ngnutls_x509_trust_list_add_system_trust(gnutls_x509_trust_list_t\n\t\t\t\t\tlist,\n\t\t\t\t\tunsigned int tl_flags,\n\t\t\t\t\tunsigned int tl_vflags);\n\ntypedef int gnutls_x509_trust_list_getissuer_function(gnutls_x509_trust_list_t list,\n\t\t\t\t\t\t      const gnutls_x509_crt_t cert,\n\t\t\t\t\t\t      gnutls_x509_crt_t **issuers,\n\t\t\t\t\t\t      unsigned int *issuers_size);\n\nvoid gnutls_x509_trust_list_set_getissuer_function(gnutls_x509_trust_list_t tlist,\n\t\t\t\tgnutls_x509_trust_list_getissuer_function *func);\n\nvoid gnutls_x509_trust_list_set_ptr(gnutls_x509_trust_list_t tlist, void *ptr);\n\nvoid *gnutls_x509_trust_list_get_ptr(gnutls_x509_trust_list_t tlist);\n\nvoid gnutls_certificate_set_trust_list\n    (gnutls_certificate_credentials_t res,\n     gnutls_x509_trust_list_t tlist, unsigned flags);\nvoid gnutls_certificate_get_trust_list\n    (gnutls_certificate_credentials_t res,\n     gnutls_x509_trust_list_t *tlist);\n\ntypedef struct gnutls_x509_ext_st {\n\tchar *oid;\n\tunsigned int critical;\n\tgnutls_datum_t data;\n} gnutls_x509_ext_st;\n\nvoid gnutls_x509_ext_deinit(gnutls_x509_ext_st *ext);\n\nint\ngnutls_x509_ext_print(gnutls_x509_ext_st *exts, unsigned int exts_size,\n\t\t      gnutls_certificate_print_formats_t format,\n\t\t      gnutls_datum_t * out);\n\n#include <gnutls/pkcs7.h>\n\n/* *INDENT-OFF* */\n#ifdef __cplusplus\n}\n#endif\n/* *INDENT-ON* */\n\n#endif /* GNUTLS_X509_H */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/HTMLparser.h",
    "content": "/*\n * Summary: interface for an HTML 4.0 non-verifying parser\n * Description: this module implements an HTML 4.0 non-verifying parser\n *              with API compatible with the XML parser ones. It should\n *              be able to parse \"real world\" HTML, even if severely\n *              broken from a specification point of view.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __HTML_PARSER_H__\n#define __HTML_PARSER_H__\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n\n#ifdef LIBXML_HTML_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Most of the back-end structures from XML and HTML are shared.\n */\ntypedef xmlParserCtxt htmlParserCtxt;\ntypedef xmlParserCtxtPtr htmlParserCtxtPtr;\ntypedef xmlParserNodeInfo htmlParserNodeInfo;\ntypedef xmlSAXHandler htmlSAXHandler;\ntypedef xmlSAXHandlerPtr htmlSAXHandlerPtr;\ntypedef xmlParserInput htmlParserInput;\ntypedef xmlParserInputPtr htmlParserInputPtr;\ntypedef xmlDocPtr htmlDocPtr;\ntypedef xmlNodePtr htmlNodePtr;\n\n/*\n * Internal description of an HTML element, representing HTML 4.01\n * and XHTML 1.0 (which share the same structure).\n */\ntypedef struct _htmlElemDesc htmlElemDesc;\ntypedef htmlElemDesc *htmlElemDescPtr;\nstruct _htmlElemDesc {\n    const char *name;\t/* The tag name */\n    char startTag;      /* Whether the start tag can be implied */\n    char endTag;        /* Whether the end tag can be implied */\n    char saveEndTag;    /* Whether the end tag should be saved */\n    char empty;         /* Is this an empty element ? */\n    char depr;          /* Is this a deprecated element ? */\n    char dtd;           /* 1: only in Loose DTD, 2: only Frameset one */\n    char isinline;      /* is this a block 0 or inline 1 element */\n    const char *desc;   /* the description */\n\n/* NRK Jan.2003\n * New fields encapsulating HTML structure\n *\n * Bugs:\n *\tThis is a very limited representation.  It fails to tell us when\n *\tan element *requires* subelements (we only have whether they're\n *\tallowed or not), and it doesn't tell us where CDATA and PCDATA\n *\tare allowed.  Some element relationships are not fully represented:\n *\tthese are flagged with the word MODIFIER\n */\n    const char** subelts;\t\t/* allowed sub-elements of this element */\n    const char* defaultsubelt;\t/* subelement for suggested auto-repair\n\t\t\t\t\t   if necessary or NULL */\n    const char** attrs_opt;\t\t/* Optional Attributes */\n    const char** attrs_depr;\t\t/* Additional deprecated attributes */\n    const char** attrs_req;\t\t/* Required attributes */\n};\n\n/*\n * Internal description of an HTML entity.\n */\ntypedef struct _htmlEntityDesc htmlEntityDesc;\ntypedef htmlEntityDesc *htmlEntityDescPtr;\nstruct _htmlEntityDesc {\n    unsigned int value;\t/* the UNICODE value for the character */\n    const char *name;\t/* The entity name */\n    const char *desc;   /* the description */\n};\n\n/*\n * There is only few public functions.\n */\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\thtmlInitAutoClose\t(void);\nXMLPUBFUN const htmlElemDesc *\n\t\t\thtmlTagLookup\t(const xmlChar *tag);\nXMLPUBFUN const htmlEntityDesc *\n\t\t\thtmlEntityLookup(const xmlChar *name);\nXMLPUBFUN const htmlEntityDesc *\n\t\t\thtmlEntityValueLookup(unsigned int value);\n\nXMLPUBFUN int\n\t\t\thtmlIsAutoClosed(htmlDocPtr doc,\n\t\t\t\t\t htmlNodePtr elem);\nXMLPUBFUN int\n\t\t\thtmlAutoCloseTag(htmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t htmlNodePtr elem);\nXML_DEPRECATED\nXMLPUBFUN const htmlEntityDesc *\n\t\t\thtmlParseEntityRef(htmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar **str);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\thtmlParseCharRef(htmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\thtmlParseElement(htmlParserCtxtPtr ctxt);\n\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlNewParserCtxt(void);\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlNewSAXParserCtxt(const htmlSAXHandler *sax,\n\t\t\t\t\t     void *userData);\n\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlCreateMemoryParserCtxt(const char *buffer,\n\t\t\t\t\t\t   int size);\n\nXMLPUBFUN int\n\t\t\thtmlParseDocument(htmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN htmlDocPtr\n\t\t\thtmlSAXParseDoc\t(const xmlChar *cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t htmlSAXHandlerPtr sax,\n\t\t\t\t\t void *userData);\nXMLPUBFUN htmlDocPtr\n\t\t\thtmlParseDoc\t(const xmlChar *cur,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlCreateFileParserCtxt(const char *filename,\n\t                                         const char *encoding);\nXML_DEPRECATED\nXMLPUBFUN htmlDocPtr\n\t\t\thtmlSAXParseFile(const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t htmlSAXHandlerPtr sax,\n\t\t\t\t\t void *userData);\nXMLPUBFUN htmlDocPtr\n\t\t\thtmlParseFile\t(const char *filename,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN int\n\t\t\tUTF8ToHtml\t(unsigned char *out,\n\t\t\t\t\t int *outlen,\n\t\t\t\t\t const unsigned char *in,\n\t\t\t\t\t int *inlen);\nXMLPUBFUN int\n\t\t\thtmlEncodeEntities(unsigned char *out,\n\t\t\t\t\t int *outlen,\n\t\t\t\t\t const unsigned char *in,\n\t\t\t\t\t int *inlen, int quoteChar);\nXMLPUBFUN int\n\t\t\thtmlIsScriptAttribute(const xmlChar *name);\nXMLPUBFUN int\n\t\t\thtmlHandleOmittedElem(int val);\n\n#ifdef LIBXML_PUSH_ENABLED\n/**\n * Interfaces for the Push mode.\n */\nXMLPUBFUN htmlParserCtxtPtr\n\t\t\thtmlCreatePushParserCtxt(htmlSAXHandlerPtr sax,\n\t\t\t\t\t\t void *user_data,\n\t\t\t\t\t\t const char *chunk,\n\t\t\t\t\t\t int size,\n\t\t\t\t\t\t const char *filename,\n\t\t\t\t\t\t xmlCharEncoding enc);\nXMLPUBFUN int\n\t\t\thtmlParseChunk\t\t(htmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const char *chunk,\n\t\t\t\t\t\t int size,\n\t\t\t\t\t\t int terminate);\n#endif /* LIBXML_PUSH_ENABLED */\n\nXMLPUBFUN void\n\t\t\thtmlFreeParserCtxt\t(htmlParserCtxtPtr ctxt);\n\n/*\n * New set of simpler/more flexible APIs\n */\n/**\n * xmlParserOption:\n *\n * This is the set of XML parser options that can be passed down\n * to the xmlReadDoc() and similar calls.\n */\ntypedef enum {\n    HTML_PARSE_RECOVER  = 1<<0, /* Relaxed parsing */\n    HTML_PARSE_NODEFDTD = 1<<2, /* do not default a doctype if not found */\n    HTML_PARSE_NOERROR\t= 1<<5,\t/* suppress error reports */\n    HTML_PARSE_NOWARNING= 1<<6,\t/* suppress warning reports */\n    HTML_PARSE_PEDANTIC\t= 1<<7,\t/* pedantic error reporting */\n    HTML_PARSE_NOBLANKS\t= 1<<8,\t/* remove blank nodes */\n    HTML_PARSE_NONET\t= 1<<11,/* Forbid network access */\n    HTML_PARSE_NOIMPLIED= 1<<13,/* Do not add implied html/body... elements */\n    HTML_PARSE_COMPACT  = 1<<16,/* compact small text nodes */\n    HTML_PARSE_IGNORE_ENC=1<<21 /* ignore internal document encoding hint */\n} htmlParserOption;\n\nXMLPUBFUN void\n\t\thtmlCtxtReset\t\t(htmlParserCtxtPtr ctxt);\nXMLPUBFUN int\n\t\thtmlCtxtUseOptions\t(htmlParserCtxtPtr ctxt,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadDoc\t\t(const xmlChar *cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadFile\t\t(const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadMemory\t\t(const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadFd\t\t(int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlReadIO\t\t(xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadDoc\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadFile\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadMemory\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadFd\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN htmlDocPtr\n\t\thtmlCtxtReadIO\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\n/* NRK/Jan2003: further knowledge of HTML structure\n */\ntypedef enum {\n  HTML_NA = 0 ,\t\t/* something we don't check at all */\n  HTML_INVALID = 0x1 ,\n  HTML_DEPRECATED = 0x2 ,\n  HTML_VALID = 0x4 ,\n  HTML_REQUIRED = 0xc /* VALID bit set so ( & HTML_VALID ) is TRUE */\n} htmlStatus ;\n\n/* Using htmlElemDesc rather than name here, to emphasise the fact\n   that otherwise there's a lookup overhead\n*/\nXMLPUBFUN htmlStatus htmlAttrAllowed(const htmlElemDesc*, const xmlChar*, int) ;\nXMLPUBFUN int htmlElementAllowedHere(const htmlElemDesc*, const xmlChar*) ;\nXMLPUBFUN htmlStatus htmlElementStatusHere(const htmlElemDesc*, const htmlElemDesc*) ;\nXMLPUBFUN htmlStatus htmlNodeStatus(const htmlNodePtr, int) ;\n/**\n * htmlDefaultSubelement:\n * @elt: HTML element\n *\n * Returns the default subelement for this element\n */\n#define htmlDefaultSubelement(elt) elt->defaultsubelt\n/**\n * htmlElementAllowedHereDesc:\n * @parent: HTML parent element\n * @elt: HTML element\n *\n * Checks whether an HTML element description may be a\n * direct child of the specified element.\n *\n * Returns 1 if allowed; 0 otherwise.\n */\n#define htmlElementAllowedHereDesc(parent,elt) \\\n\thtmlElementAllowedHere((parent), (elt)->name)\n/**\n * htmlRequiredAttrs:\n * @elt: HTML element\n *\n * Returns the attributes required for the specified element.\n */\n#define htmlRequiredAttrs(elt) (elt)->attrs_req\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_HTML_ENABLED */\n#endif /* __HTML_PARSER_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/HTMLtree.h",
    "content": "/*\n * Summary: specific APIs to process HTML tree, especially serialization\n * Description: this module implements a few function needed to process\n *              tree in an HTML specific way.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __HTML_TREE_H__\n#define __HTML_TREE_H__\n\n#include <stdio.h>\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/HTMLparser.h>\n\n#ifdef LIBXML_HTML_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/**\n * HTML_TEXT_NODE:\n *\n * Macro. A text node in a HTML document is really implemented\n * the same way as a text node in an XML document.\n */\n#define HTML_TEXT_NODE\t\tXML_TEXT_NODE\n/**\n * HTML_ENTITY_REF_NODE:\n *\n * Macro. An entity reference in a HTML document is really implemented\n * the same way as an entity reference in an XML document.\n */\n#define HTML_ENTITY_REF_NODE\tXML_ENTITY_REF_NODE\n/**\n * HTML_COMMENT_NODE:\n *\n * Macro. A comment in a HTML document is really implemented\n * the same way as a comment in an XML document.\n */\n#define HTML_COMMENT_NODE\tXML_COMMENT_NODE\n/**\n * HTML_PRESERVE_NODE:\n *\n * Macro. A preserved node in a HTML document is really implemented\n * the same way as a CDATA section in an XML document.\n */\n#define HTML_PRESERVE_NODE\tXML_CDATA_SECTION_NODE\n/**\n * HTML_PI_NODE:\n *\n * Macro. A processing instruction in a HTML document is really implemented\n * the same way as a processing instruction in an XML document.\n */\n#define HTML_PI_NODE\t\tXML_PI_NODE\n\nXMLPUBFUN htmlDocPtr\n\t\thtmlNewDoc\t\t(const xmlChar *URI,\n\t\t\t\t\t const xmlChar *ExternalID);\nXMLPUBFUN htmlDocPtr\n\t\thtmlNewDocNoDtD\t\t(const xmlChar *URI,\n\t\t\t\t\t const xmlChar *ExternalID);\nXMLPUBFUN const xmlChar *\n\t\thtmlGetMetaEncoding\t(htmlDocPtr doc);\nXMLPUBFUN int\n\t\thtmlSetMetaEncoding\t(htmlDocPtr doc,\n\t\t\t\t\t const xmlChar *encoding);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\thtmlDocDumpMemory\t(xmlDocPtr cur,\n\t\t\t\t\t xmlChar **mem,\n\t\t\t\t\t int *size);\nXMLPUBFUN void\n\t\thtmlDocDumpMemoryFormat\t(xmlDocPtr cur,\n\t\t\t\t\t xmlChar **mem,\n\t\t\t\t\t int *size,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\thtmlDocDump\t\t(FILE *f,\n\t\t\t\t\t xmlDocPtr cur);\nXMLPUBFUN int\n\t\thtmlSaveFile\t\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur);\nXMLPUBFUN int\n\t\thtmlNodeDump\t\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur);\nXMLPUBFUN void\n\t\thtmlNodeDumpFile\t(FILE *out,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur);\nXMLPUBFUN int\n\t\thtmlNodeDumpFileFormat\t(FILE *out,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\thtmlSaveFileEnc\t\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN int\n\t\thtmlSaveFileFormat\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\n\nXMLPUBFUN void\n\t\thtmlNodeDumpFormatOutput(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\nXMLPUBFUN void\n\t\thtmlDocContentDumpOutput(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN void\n\t\thtmlDocContentDumpFormatOutput(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\nXMLPUBFUN void\n\t\thtmlNodeDumpOutput\t(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t const char *encoding);\n\n#endif /* LIBXML_OUTPUT_ENABLED */\n\nXMLPUBFUN int\n\t\thtmlIsBooleanAttr\t(const xmlChar *name);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_HTML_ENABLED */\n\n#endif /* __HTML_TREE_H__ */\n\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/SAX.h",
    "content": "/*\n * Summary: Old SAX version 1 handler, deprecated\n * Description: DEPRECATED set of SAX version 1 interfaces used to\n *              build the DOM tree.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SAX_H__\n#define __XML_SAX_H__\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n\n#ifdef LIBXML_LEGACY_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\tgetPublicId\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\tgetSystemId\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tsetDocumentLocator\t\t(void *ctx,\n\t\t\t\t\t\t xmlSAXLocatorPtr loc);\n\nXML_DEPRECATED\nXMLPUBFUN int\n\t\tgetLineNumber\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\tgetColumnNumber\t\t\t(void *ctx);\n\nXML_DEPRECATED\nXMLPUBFUN int\n\t\tisStandalone\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\thasInternalSubset\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\thasExternalSubset\t\t(void *ctx);\n\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tinternalSubset\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\texternalSubset\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\nXML_DEPRECATED\nXMLPUBFUN xmlEntityPtr\n\t\tgetEntity\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN xmlEntityPtr\n\t\tgetParameterEntity\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN xmlParserInputPtr\n\t\tresolveEntity\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId);\n\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tentityDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId,\n\t\t\t\t\t\t xmlChar *content);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tattributeDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t int def,\n\t\t\t\t\t\t const xmlChar *defaultValue,\n\t\t\t\t\t\t xmlEnumerationPtr tree);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\telementDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t xmlElementContentPtr content);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tnotationDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tunparsedEntityDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId,\n\t\t\t\t\t\t const xmlChar *notationName);\n\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tstartDocument\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tendDocument\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tattribute\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t const xmlChar *value);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tstartElement\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t const xmlChar **atts);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tendElement\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\treference\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tcharacters\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *ch,\n\t\t\t\t\t\t int len);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tignorableWhitespace\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *ch,\n\t\t\t\t\t\t int len);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tprocessingInstruction\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *target,\n\t\t\t\t\t\t const xmlChar *data);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tglobalNamespace\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *href,\n\t\t\t\t\t\t const xmlChar *prefix);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tsetNamespace\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXML_DEPRECATED\nXMLPUBFUN xmlNsPtr\n\t\tgetNamespace\t\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\tcheckNamespace\t\t\t(void *ctx,\n\t\t\t\t\t\t xmlChar *nameSpace);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tnamespaceDecl\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *href,\n\t\t\t\t\t\t const xmlChar *prefix);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tcomment\t\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *value);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tcdataBlock\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t int len);\n\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tinitxmlDefaultSAXHandler\t(xmlSAXHandlerV1 *hdlr,\n\t\t\t\t\t\t int warning);\n#ifdef LIBXML_HTML_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\tinithtmlDefaultSAXHandler\t(xmlSAXHandlerV1 *hdlr);\n#endif\n#endif /* LIBXML_SAX1_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_LEGACY_ENABLED */\n\n#endif /* __XML_SAX_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/SAX2.h",
    "content": "/*\n * Summary: SAX2 parser interface used to build the DOM tree\n * Description: those are the default SAX2 interfaces used by\n *              the library when building DOM tree.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SAX2_H__\n#define __XML_SAX2_H__\n\n#include <stdio.h>\n#include <stdlib.h>\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nXMLPUBFUN const xmlChar *\n\t\txmlSAX2GetPublicId\t\t(void *ctx);\nXMLPUBFUN const xmlChar *\n\t\txmlSAX2GetSystemId\t\t(void *ctx);\nXMLPUBFUN void\n\t\txmlSAX2SetDocumentLocator\t(void *ctx,\n\t\t\t\t\t\t xmlSAXLocatorPtr loc);\n\nXMLPUBFUN int\n\t\txmlSAX2GetLineNumber\t\t(void *ctx);\nXMLPUBFUN int\n\t\txmlSAX2GetColumnNumber\t\t(void *ctx);\n\nXMLPUBFUN int\n\t\txmlSAX2IsStandalone\t\t(void *ctx);\nXMLPUBFUN int\n\t\txmlSAX2HasInternalSubset\t(void *ctx);\nXMLPUBFUN int\n\t\txmlSAX2HasExternalSubset\t(void *ctx);\n\nXMLPUBFUN void\n\t\txmlSAX2InternalSubset\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN void\n\t\txmlSAX2ExternalSubset\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlEntityPtr\n\t\txmlSAX2GetEntity\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlEntityPtr\n\t\txmlSAX2GetParameterEntity\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlParserInputPtr\n\t\txmlSAX2ResolveEntity\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId);\n\nXMLPUBFUN void\n\t\txmlSAX2EntityDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId,\n\t\t\t\t\t\t xmlChar *content);\nXMLPUBFUN void\n\t\txmlSAX2AttributeDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t int def,\n\t\t\t\t\t\t const xmlChar *defaultValue,\n\t\t\t\t\t\t xmlEnumerationPtr tree);\nXMLPUBFUN void\n\t\txmlSAX2ElementDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t xmlElementContentPtr content);\nXMLPUBFUN void\n\t\txmlSAX2NotationDecl\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId);\nXMLPUBFUN void\n\t\txmlSAX2UnparsedEntityDecl\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *publicId,\n\t\t\t\t\t\t const xmlChar *systemId,\n\t\t\t\t\t\t const xmlChar *notationName);\n\nXMLPUBFUN void\n\t\txmlSAX2StartDocument\t\t(void *ctx);\nXMLPUBFUN void\n\t\txmlSAX2EndDocument\t\t(void *ctx);\n#if defined(LIBXML_SAX1_ENABLED) || defined(LIBXML_HTML_ENABLED) || \\\n    defined(LIBXML_WRITER_ENABLED) || defined(LIBXML_LEGACY_ENABLED)\nXMLPUBFUN void\n\t\txmlSAX2StartElement\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *fullname,\n\t\t\t\t\t\t const xmlChar **atts);\nXMLPUBFUN void\n\t\txmlSAX2EndElement\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\n#endif /* LIBXML_SAX1_ENABLED or LIBXML_HTML_ENABLED or LIBXML_LEGACY_ENABLED */\nXMLPUBFUN void\n\t\txmlSAX2StartElementNs\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *localname,\n\t\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t\t const xmlChar *URI,\n\t\t\t\t\t\t int nb_namespaces,\n\t\t\t\t\t\t const xmlChar **namespaces,\n\t\t\t\t\t\t int nb_attributes,\n\t\t\t\t\t\t int nb_defaulted,\n\t\t\t\t\t\t const xmlChar **attributes);\nXMLPUBFUN void\n\t\txmlSAX2EndElementNs\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *localname,\n\t\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t\t const xmlChar *URI);\nXMLPUBFUN void\n\t\txmlSAX2Reference\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN void\n\t\txmlSAX2Characters\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *ch,\n\t\t\t\t\t\t int len);\nXMLPUBFUN void\n\t\txmlSAX2IgnorableWhitespace\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *ch,\n\t\t\t\t\t\t int len);\nXMLPUBFUN void\n\t\txmlSAX2ProcessingInstruction\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *target,\n\t\t\t\t\t\t const xmlChar *data);\nXMLPUBFUN void\n\t\txmlSAX2Comment\t\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN void\n\t\txmlSAX2CDataBlock\t\t(void *ctx,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t int len);\n\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlSAXDefaultVersion\t\t(int version);\n#endif /* LIBXML_SAX1_ENABLED */\n\nXMLPUBFUN int\n\t\txmlSAXVersion\t\t\t(xmlSAXHandler *hdlr,\n\t\t\t\t\t\t int version);\nXMLPUBFUN void\n\t\txmlSAX2InitDefaultSAXHandler    (xmlSAXHandler *hdlr,\n\t\t\t\t\t\t int warning);\n#ifdef LIBXML_HTML_ENABLED\nXMLPUBFUN void\n\t\txmlSAX2InitHtmlDefaultSAXHandler(xmlSAXHandler *hdlr);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\thtmlDefaultSAXHandlerInit\t(void);\n#endif\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlDefaultSAXHandlerInit\t(void);\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_SAX2_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/c14n.h",
    "content": "/*\n * Summary: Provide Canonical XML and Exclusive XML Canonicalization\n * Description: the c14n modules provides a\n *\n * \"Canonical XML\" implementation\n * http://www.w3.org/TR/xml-c14n\n *\n * and an\n *\n * \"Exclusive XML Canonicalization\" implementation\n * http://www.w3.org/TR/xml-exc-c14n\n\n * Copy: See Copyright for the status of this software.\n *\n * Author: Aleksey Sanin <aleksey@aleksey.com>\n */\n#ifndef __XML_C14N_H__\n#define __XML_C14N_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_C14N_ENABLED\n#ifdef LIBXML_OUTPUT_ENABLED\n\n#include <libxml/tree.h>\n#include <libxml/xpath.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif /* __cplusplus */\n\n/*\n * XML Canonicalization\n * http://www.w3.org/TR/xml-c14n\n *\n * Exclusive XML Canonicalization\n * http://www.w3.org/TR/xml-exc-c14n\n *\n * Canonical form of an XML document could be created if and only if\n *  a) default attributes (if any) are added to all nodes\n *  b) all character and parsed entity references are resolved\n * In order to achieve this in libxml2 the document MUST be loaded with\n * following global settings:\n *\n *    xmlLoadExtDtdDefaultValue = XML_DETECT_IDS | XML_COMPLETE_ATTRS;\n *    xmlSubstituteEntitiesDefault(1);\n *\n * or corresponding parser context setting:\n *    xmlParserCtxtPtr ctxt;\n *\n *    ...\n *    ctxt->loadsubset = XML_DETECT_IDS | XML_COMPLETE_ATTRS;\n *    ctxt->replaceEntities = 1;\n *    ...\n */\n\n/*\n * xmlC14NMode:\n *\n * Predefined values for C14N modes\n *\n */\ntypedef enum {\n    XML_C14N_1_0            = 0,    /* Original C14N 1.0 spec */\n    XML_C14N_EXCLUSIVE_1_0  = 1,    /* Exclusive C14N 1.0 spec */\n    XML_C14N_1_1            = 2     /* C14N 1.1 spec */\n} xmlC14NMode;\n\nXMLPUBFUN int\n\t\txmlC14NDocSaveTo\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodeSetPtr nodes,\n\t\t\t\t\t int mode, /* a xmlC14NMode */\n\t\t\t\t\t xmlChar **inclusive_ns_prefixes,\n\t\t\t\t\t int with_comments,\n\t\t\t\t\t xmlOutputBufferPtr buf);\n\nXMLPUBFUN int\n\t\txmlC14NDocDumpMemory\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodeSetPtr nodes,\n\t\t\t\t\t int mode, /* a xmlC14NMode */\n\t\t\t\t\t xmlChar **inclusive_ns_prefixes,\n\t\t\t\t\t int with_comments,\n\t\t\t\t\t xmlChar **doc_txt_ptr);\n\nXMLPUBFUN int\n\t\txmlC14NDocSave\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodeSetPtr nodes,\n\t\t\t\t\t int mode, /* a xmlC14NMode */\n\t\t\t\t\t xmlChar **inclusive_ns_prefixes,\n\t\t\t\t\t int with_comments,\n\t\t\t\t\t const char* filename,\n\t\t\t\t\t int compression);\n\n\n/**\n * This is the core C14N function\n */\n/**\n * xmlC14NIsVisibleCallback:\n * @user_data: user data\n * @node: the current node\n * @parent: the parent node\n *\n * Signature for a C14N callback on visible nodes\n *\n * Returns 1 if the node should be included\n */\ntypedef int (*xmlC14NIsVisibleCallback)\t(void* user_data,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t xmlNodePtr parent);\n\nXMLPUBFUN int\n\t\txmlC14NExecute\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlC14NIsVisibleCallback is_visible_callback,\n\t\t\t\t\t void* user_data,\n\t\t\t\t\t int mode, /* a xmlC14NMode */\n\t\t\t\t\t xmlChar **inclusive_ns_prefixes,\n\t\t\t\t\t int with_comments,\n\t\t\t\t\t xmlOutputBufferPtr buf);\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#endif /* LIBXML_OUTPUT_ENABLED */\n#endif /* LIBXML_C14N_ENABLED */\n#endif /* __XML_C14N_H__ */\n\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/catalog.h",
    "content": "/**\n * Summary: interfaces to the Catalog handling system\n * Description: the catalog module implements the support for\n * XML Catalogs and SGML catalogs\n *\n * SGML Open Technical Resolution TR9401:1997.\n * http://www.jclark.com/sp/catalog.htm\n *\n * XML Catalogs Working Draft 06 August 2001\n * http://www.oasis-open.org/committees/entity/spec-2001-08-06.html\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_CATALOG_H__\n#define __XML_CATALOG_H__\n\n#include <stdio.h>\n\n#include <libxml/xmlversion.h>\n#include <libxml/xmlstring.h>\n#include <libxml/tree.h>\n\n#ifdef LIBXML_CATALOG_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * XML_CATALOGS_NAMESPACE:\n *\n * The namespace for the XML Catalogs elements.\n */\n#define XML_CATALOGS_NAMESPACE\t\t\t\t\t\\\n    (const xmlChar *) \"urn:oasis:names:tc:entity:xmlns:xml:catalog\"\n/**\n * XML_CATALOG_PI:\n *\n * The specific XML Catalog Processing Instruction name.\n */\n#define XML_CATALOG_PI\t\t\t\t\t\t\\\n    (const xmlChar *) \"oasis-xml-catalog\"\n\n/*\n * The API is voluntarily limited to general cataloging.\n */\ntypedef enum {\n    XML_CATA_PREFER_NONE = 0,\n    XML_CATA_PREFER_PUBLIC = 1,\n    XML_CATA_PREFER_SYSTEM\n} xmlCatalogPrefer;\n\ntypedef enum {\n    XML_CATA_ALLOW_NONE = 0,\n    XML_CATA_ALLOW_GLOBAL = 1,\n    XML_CATA_ALLOW_DOCUMENT = 2,\n    XML_CATA_ALLOW_ALL = 3\n} xmlCatalogAllow;\n\ntypedef struct _xmlCatalog xmlCatalog;\ntypedef xmlCatalog *xmlCatalogPtr;\n\n/*\n * Operations on a given catalog.\n */\nXMLPUBFUN xmlCatalogPtr\n\t\txmlNewCatalog\t\t(int sgml);\nXMLPUBFUN xmlCatalogPtr\n\t\txmlLoadACatalog\t\t(const char *filename);\nXMLPUBFUN xmlCatalogPtr\n\t\txmlLoadSGMLSuperCatalog\t(const char *filename);\nXMLPUBFUN int\n\t\txmlConvertSGMLCatalog\t(xmlCatalogPtr catal);\nXMLPUBFUN int\n\t\txmlACatalogAdd\t\t(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *type,\n\t\t\t\t\t const xmlChar *orig,\n\t\t\t\t\t const xmlChar *replace);\nXMLPUBFUN int\n\t\txmlACatalogRemove\t(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlChar *\n\t\txmlACatalogResolve\t(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *pubID,\n\t                                 const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlACatalogResolveSystem(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlACatalogResolvePublic(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *pubID);\nXMLPUBFUN xmlChar *\n\t\txmlACatalogResolveURI\t(xmlCatalogPtr catal,\n\t\t\t\t\t const xmlChar *URI);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlACatalogDump\t\t(xmlCatalogPtr catal,\n\t\t\t\t\t FILE *out);\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN void\n\t\txmlFreeCatalog\t\t(xmlCatalogPtr catal);\nXMLPUBFUN int\n\t\txmlCatalogIsEmpty\t(xmlCatalogPtr catal);\n\n/*\n * Global operations.\n */\nXMLPUBFUN void\n\t\txmlInitializeCatalog\t(void);\nXMLPUBFUN int\n\t\txmlLoadCatalog\t\t(const char *filename);\nXMLPUBFUN void\n\t\txmlLoadCatalogs\t\t(const char *paths);\nXMLPUBFUN void\n\t\txmlCatalogCleanup\t(void);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlCatalogDump\t\t(FILE *out);\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN xmlChar *\n\t\txmlCatalogResolve\t(const xmlChar *pubID,\n\t                                 const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogResolveSystem\t(const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogResolvePublic\t(const xmlChar *pubID);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogResolveURI\t(const xmlChar *URI);\nXMLPUBFUN int\n\t\txmlCatalogAdd\t\t(const xmlChar *type,\n\t\t\t\t\t const xmlChar *orig,\n\t\t\t\t\t const xmlChar *replace);\nXMLPUBFUN int\n\t\txmlCatalogRemove\t(const xmlChar *value);\nXMLPUBFUN xmlDocPtr\n\t\txmlParseCatalogFile\t(const char *filename);\nXMLPUBFUN int\n\t\txmlCatalogConvert\t(void);\n\n/*\n * Strictly minimal interfaces for per-document catalogs used\n * by the parser.\n */\nXMLPUBFUN void\n\t\txmlCatalogFreeLocal\t(void *catalogs);\nXMLPUBFUN void *\n\t\txmlCatalogAddLocal\t(void *catalogs,\n\t\t\t\t\t const xmlChar *URL);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogLocalResolve\t(void *catalogs,\n\t\t\t\t\t const xmlChar *pubID,\n\t                                 const xmlChar *sysID);\nXMLPUBFUN xmlChar *\n\t\txmlCatalogLocalResolveURI(void *catalogs,\n\t\t\t\t\t const xmlChar *URI);\n/*\n * Preference settings.\n */\nXMLPUBFUN int\n\t\txmlCatalogSetDebug\t(int level);\nXMLPUBFUN xmlCatalogPrefer\n\t\txmlCatalogSetDefaultPrefer(xmlCatalogPrefer prefer);\nXMLPUBFUN void\n\t\txmlCatalogSetDefaults\t(xmlCatalogAllow allow);\nXMLPUBFUN xmlCatalogAllow\n\t\txmlCatalogGetDefaults\t(void);\n\n\n/* DEPRECATED interfaces */\nXMLPUBFUN const xmlChar *\n\t\txmlCatalogGetSystem\t(const xmlChar *sysID);\nXMLPUBFUN const xmlChar *\n\t\txmlCatalogGetPublic\t(const xmlChar *pubID);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* LIBXML_CATALOG_ENABLED */\n#endif /* __XML_CATALOG_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/chvalid.h",
    "content": "/*\n * Summary: Unicode character range checking\n * Description: this module exports interfaces for the character\n *               range validation APIs\n *\n * This file is automatically generated from the cvs source\n * definition files using the genChRanges.py Python script\n *\n * Generation date: Mon Mar 27 11:09:48 2006\n * Sources: chvalid.def\n * Author: William Brack <wbrack@mmm.com.hk>\n */\n\n#ifndef __XML_CHVALID_H__\n#define __XML_CHVALID_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Define our typedefs and structures\n *\n */\ntypedef struct _xmlChSRange xmlChSRange;\ntypedef xmlChSRange *xmlChSRangePtr;\nstruct _xmlChSRange {\n    unsigned short\tlow;\n    unsigned short\thigh;\n};\n\ntypedef struct _xmlChLRange xmlChLRange;\ntypedef xmlChLRange *xmlChLRangePtr;\nstruct _xmlChLRange {\n    unsigned int\tlow;\n    unsigned int\thigh;\n};\n\ntypedef struct _xmlChRangeGroup xmlChRangeGroup;\ntypedef xmlChRangeGroup *xmlChRangeGroupPtr;\nstruct _xmlChRangeGroup {\n    int\t\t\tnbShortRange;\n    int\t\t\tnbLongRange;\n    const xmlChSRange\t*shortRange;\t/* points to an array of ranges */\n    const xmlChLRange\t*longRange;\n};\n\n/**\n * Range checking routine\n */\nXMLPUBFUN int\n\t\txmlCharInRange(unsigned int val, const xmlChRangeGroup *group);\n\n\n/**\n * xmlIsBaseChar_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsBaseChar_ch(c)\t(((0x41 <= (c)) && ((c) <= 0x5a)) || \\\n\t\t\t\t ((0x61 <= (c)) && ((c) <= 0x7a)) || \\\n\t\t\t\t ((0xc0 <= (c)) && ((c) <= 0xd6)) || \\\n\t\t\t\t ((0xd8 <= (c)) && ((c) <= 0xf6)) || \\\n\t\t\t\t  (0xf8 <= (c)))\n\n/**\n * xmlIsBaseCharQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsBaseCharQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsBaseChar_ch((c)) : \\\n\t\t\t\t xmlCharInRange((c), &xmlIsBaseCharGroup))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsBaseCharGroup;\n\n/**\n * xmlIsBlank_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsBlank_ch(c)\t(((c) == 0x20) || \\\n\t\t\t\t ((0x9 <= (c)) && ((c) <= 0xa)) || \\\n\t\t\t\t ((c) == 0xd))\n\n/**\n * xmlIsBlankQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsBlankQ(c)\t\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsBlank_ch((c)) : 0)\n\n\n/**\n * xmlIsChar_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsChar_ch(c)\t\t(((0x9 <= (c)) && ((c) <= 0xa)) || \\\n\t\t\t\t ((c) == 0xd) || \\\n\t\t\t\t  (0x20 <= (c)))\n\n/**\n * xmlIsCharQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsCharQ(c)\t\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsChar_ch((c)) :\\\n\t\t\t\t(((0x100 <= (c)) && ((c) <= 0xd7ff)) || \\\n\t\t\t\t ((0xe000 <= (c)) && ((c) <= 0xfffd)) || \\\n\t\t\t\t ((0x10000 <= (c)) && ((c) <= 0x10ffff))))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsCharGroup;\n\n/**\n * xmlIsCombiningQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsCombiningQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t 0 : \\\n\t\t\t\t xmlCharInRange((c), &xmlIsCombiningGroup))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsCombiningGroup;\n\n/**\n * xmlIsDigit_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsDigit_ch(c)\t(((0x30 <= (c)) && ((c) <= 0x39)))\n\n/**\n * xmlIsDigitQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsDigitQ(c)\t\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsDigit_ch((c)) : \\\n\t\t\t\t xmlCharInRange((c), &xmlIsDigitGroup))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsDigitGroup;\n\n/**\n * xmlIsExtender_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsExtender_ch(c)\t(((c) == 0xb7))\n\n/**\n * xmlIsExtenderQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsExtenderQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsExtender_ch((c)) : \\\n\t\t\t\t xmlCharInRange((c), &xmlIsExtenderGroup))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsExtenderGroup;\n\n/**\n * xmlIsIdeographicQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsIdeographicQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t 0 :\\\n\t\t\t\t(((0x4e00 <= (c)) && ((c) <= 0x9fa5)) || \\\n\t\t\t\t ((c) == 0x3007) || \\\n\t\t\t\t ((0x3021 <= (c)) && ((c) <= 0x3029))))\n\nXMLPUBVAR const xmlChRangeGroup xmlIsIdeographicGroup;\nXMLPUBVAR const unsigned char xmlIsPubidChar_tab[256];\n\n/**\n * xmlIsPubidChar_ch:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsPubidChar_ch(c)\t(xmlIsPubidChar_tab[(c)])\n\n/**\n * xmlIsPubidCharQ:\n * @c: char to validate\n *\n * Automatically generated by genChRanges.py\n */\n#define xmlIsPubidCharQ(c)\t(((c) < 0x100) ? \\\n\t\t\t\t xmlIsPubidChar_ch((c)) : 0)\n\nXMLPUBFUN int\n\t\txmlIsBaseChar(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsBlank(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsChar(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsCombining(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsDigit(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsExtender(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsIdeographic(unsigned int ch);\nXMLPUBFUN int\n\t\txmlIsPubidChar(unsigned int ch);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_CHVALID_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/debugXML.h",
    "content": "/*\n * Summary: Tree debugging APIs\n * Description: Interfaces to a set of routines used for debugging the tree\n *              produced by the XML parser.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __DEBUG_XML__\n#define __DEBUG_XML__\n#include <stdio.h>\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef LIBXML_DEBUG_ENABLED\n\n#include <libxml/xpath.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The standard Dump routines.\n */\nXMLPUBFUN void\n\txmlDebugDumpString\t(FILE *output,\n\t\t\t\t const xmlChar *str);\nXMLPUBFUN void\n\txmlDebugDumpAttr\t(FILE *output,\n\t\t\t\t xmlAttrPtr attr,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpAttrList\t(FILE *output,\n\t\t\t\t xmlAttrPtr attr,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpOneNode\t(FILE *output,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpNode\t(FILE *output,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpNodeList\t(FILE *output,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t int depth);\nXMLPUBFUN void\n\txmlDebugDumpDocumentHead(FILE *output,\n\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN void\n\txmlDebugDumpDocument\t(FILE *output,\n\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN void\n\txmlDebugDumpDTD\t\t(FILE *output,\n\t\t\t\t xmlDtdPtr dtd);\nXMLPUBFUN void\n\txmlDebugDumpEntities\t(FILE *output,\n\t\t\t\t xmlDocPtr doc);\n\n/****************************************************************\n *\t\t\t\t\t\t\t\t*\n *\t\t\tChecking routines\t\t\t*\n *\t\t\t\t\t\t\t\t*\n ****************************************************************/\n\nXMLPUBFUN int\n\txmlDebugCheckDocument\t(FILE * output,\n\t\t\t\t xmlDocPtr doc);\n\n/****************************************************************\n *\t\t\t\t\t\t\t\t*\n *\t\t\tXML shell helpers\t\t\t*\n *\t\t\t\t\t\t\t\t*\n ****************************************************************/\n\nXMLPUBFUN void\n\txmlLsOneNode\t\t(FILE *output, xmlNodePtr node);\nXMLPUBFUN int\n\txmlLsCountNode\t\t(xmlNodePtr node);\n\nXMLPUBFUN const char *\n\txmlBoolToText\t\t(int boolval);\n\n/****************************************************************\n *\t\t\t\t\t\t\t\t*\n *\t The XML shell related structures and functions\t\t*\n *\t\t\t\t\t\t\t\t*\n ****************************************************************/\n\n#ifdef LIBXML_XPATH_ENABLED\n/**\n * xmlShellReadlineFunc:\n * @prompt:  a string prompt\n *\n * This is a generic signature for the XML shell input function.\n *\n * Returns a string which will be freed by the Shell.\n */\ntypedef char * (* xmlShellReadlineFunc)(char *prompt);\n\n/**\n * xmlShellCtxt:\n *\n * A debugging shell context.\n * TODO: add the defined function tables.\n */\ntypedef struct _xmlShellCtxt xmlShellCtxt;\ntypedef xmlShellCtxt *xmlShellCtxtPtr;\nstruct _xmlShellCtxt {\n    char *filename;\n    xmlDocPtr doc;\n    xmlNodePtr node;\n    xmlXPathContextPtr pctxt;\n    int loaded;\n    FILE *output;\n    xmlShellReadlineFunc input;\n};\n\n/**\n * xmlShellCmd:\n * @ctxt:  a shell context\n * @arg:  a string argument\n * @node:  a first node\n * @node2:  a second node\n *\n * This is a generic signature for the XML shell functions.\n *\n * Returns an int, negative returns indicating errors.\n */\ntypedef int (* xmlShellCmd) (xmlShellCtxtPtr ctxt,\n                             char *arg,\n\t\t\t     xmlNodePtr node,\n\t\t\t     xmlNodePtr node2);\n\nXMLPUBFUN void\n\txmlShellPrintXPathError\t(int errorType,\n\t\t\t\t const char *arg);\nXMLPUBFUN void\n\txmlShellPrintXPathResult(xmlXPathObjectPtr list);\nXMLPUBFUN int\n\txmlShellList\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellBase\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellDir\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellLoad\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *filename,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\txmlShellPrintNode\t(xmlNodePtr node);\nXMLPUBFUN int\n\txmlShellCat\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellWrite\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *filename,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellSave\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *filename,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\n#endif /* LIBXML_OUTPUT_ENABLED */\n#ifdef LIBXML_VALID_ENABLED\nXMLPUBFUN int\n\txmlShellValidate\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *dtd,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\n#endif /* LIBXML_VALID_ENABLED */\nXMLPUBFUN int\n\txmlShellDu\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *arg,\n\t\t\t\t xmlNodePtr tree,\n\t\t\t\t xmlNodePtr node2);\nXMLPUBFUN int\n\txmlShellPwd\t\t(xmlShellCtxtPtr ctxt,\n\t\t\t\t char *buffer,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t xmlNodePtr node2);\n\n/*\n * The Shell interface.\n */\nXMLPUBFUN void\n\txmlShell\t\t(xmlDocPtr doc,\n\t\t\t\t char *filename,\n\t\t\t\t xmlShellReadlineFunc input,\n\t\t\t\t FILE *output);\n\n#endif /* LIBXML_XPATH_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_DEBUG_ENABLED */\n#endif /* __DEBUG_XML__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/dict.h",
    "content": "/*\n * Summary: string dictionary\n * Description: dictionary of reusable strings, just used to avoid allocation\n *         and freeing operations.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_DICT_H__\n#define __XML_DICT_H__\n\n#include <stddef.h>\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The dictionary.\n */\ntypedef struct _xmlDict xmlDict;\ntypedef xmlDict *xmlDictPtr;\n\n/*\n * Initializer\n */\nXML_DEPRECATED\nXMLPUBFUN int  xmlInitializeDict(void);\n\n/*\n * Constructor and destructor.\n */\nXMLPUBFUN xmlDictPtr\n\t\t\txmlDictCreate\t(void);\nXMLPUBFUN size_t\n\t\t\txmlDictSetLimit\t(xmlDictPtr dict,\n                                         size_t limit);\nXMLPUBFUN size_t\n\t\t\txmlDictGetUsage (xmlDictPtr dict);\nXMLPUBFUN xmlDictPtr\n\t\t\txmlDictCreateSub(xmlDictPtr sub);\nXMLPUBFUN int\n\t\t\txmlDictReference(xmlDictPtr dict);\nXMLPUBFUN void\n\t\t\txmlDictFree\t(xmlDictPtr dict);\n\n/*\n * Lookup of entry in the dictionary.\n */\nXMLPUBFUN const xmlChar *\n\t\t\txmlDictLookup\t(xmlDictPtr dict,\n\t\t                         const xmlChar *name,\n\t\t                         int len);\nXMLPUBFUN const xmlChar *\n\t\t\txmlDictExists\t(xmlDictPtr dict,\n\t\t                         const xmlChar *name,\n\t\t                         int len);\nXMLPUBFUN const xmlChar *\n\t\t\txmlDictQLookup\t(xmlDictPtr dict,\n\t\t                         const xmlChar *prefix,\n\t\t                         const xmlChar *name);\nXMLPUBFUN int\n\t\t\txmlDictOwns\t(xmlDictPtr dict,\n\t\t\t\t\t const xmlChar *str);\nXMLPUBFUN int\n\t\t\txmlDictSize\t(xmlDictPtr dict);\n\n/*\n * Cleanup function\n */\nXML_DEPRECATED\nXMLPUBFUN void\n                        xmlDictCleanup  (void);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* ! __XML_DICT_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/encoding.h",
    "content": "/*\n * Summary: interface for the encoding conversion functions\n * Description: interface for the encoding conversion functions needed for\n *              XML basic encoding and iconv() support.\n *\n * Related specs are\n * rfc2044        (UTF-8 and UTF-16) F. Yergeau Alis Technologies\n * [ISO-10646]    UTF-8 and UTF-16 in Annexes\n * [ISO-8859-1]   ISO Latin-1 characters codes.\n * [UNICODE]      The Unicode Consortium, \"The Unicode Standard --\n *                Worldwide Character Encoding -- Version 1.0\", Addison-\n *                Wesley, Volume 1, 1991, Volume 2, 1992.  UTF-8 is\n *                described in Unicode Technical Report #4.\n * [US-ASCII]     Coded Character Set--7-bit American Standard Code for\n *                Information Interchange, ANSI X3.4-1986.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_CHAR_ENCODING_H__\n#define __XML_CHAR_ENCODING_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_ICONV_ENABLED\n#include <iconv.h>\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * xmlCharEncoding:\n *\n * Predefined values for some standard encodings.\n * Libxml does not do beforehand translation on UTF8 and ISOLatinX.\n * It also supports ASCII, ISO-8859-1, and UTF16 (LE and BE) by default.\n *\n * Anything else would have to be translated to UTF8 before being\n * given to the parser itself. The BOM for UTF16 and the encoding\n * declaration are looked at and a converter is looked for at that\n * point. If not found the parser stops here as asked by the XML REC. A\n * converter can be registered by the user using xmlRegisterCharEncodingHandler\n * but the current form doesn't allow stateful transcoding (a serious\n * problem agreed !). If iconv has been found it will be used\n * automatically and allow stateful transcoding, the simplest is then\n * to be sure to enable iconv and to provide iconv libs for the encoding\n * support needed.\n *\n * Note that the generic \"UTF-16\" is not a predefined value.  Instead, only\n * the specific UTF-16LE and UTF-16BE are present.\n */\ntypedef enum {\n    XML_CHAR_ENCODING_ERROR=   -1, /* No char encoding detected */\n    XML_CHAR_ENCODING_NONE=\t0, /* No char encoding detected */\n    XML_CHAR_ENCODING_UTF8=\t1, /* UTF-8 */\n    XML_CHAR_ENCODING_UTF16LE=\t2, /* UTF-16 little endian */\n    XML_CHAR_ENCODING_UTF16BE=\t3, /* UTF-16 big endian */\n    XML_CHAR_ENCODING_UCS4LE=\t4, /* UCS-4 little endian */\n    XML_CHAR_ENCODING_UCS4BE=\t5, /* UCS-4 big endian */\n    XML_CHAR_ENCODING_EBCDIC=\t6, /* EBCDIC uh! */\n    XML_CHAR_ENCODING_UCS4_2143=7, /* UCS-4 unusual ordering */\n    XML_CHAR_ENCODING_UCS4_3412=8, /* UCS-4 unusual ordering */\n    XML_CHAR_ENCODING_UCS2=\t9, /* UCS-2 */\n    XML_CHAR_ENCODING_8859_1=\t10,/* ISO-8859-1 ISO Latin 1 */\n    XML_CHAR_ENCODING_8859_2=\t11,/* ISO-8859-2 ISO Latin 2 */\n    XML_CHAR_ENCODING_8859_3=\t12,/* ISO-8859-3 */\n    XML_CHAR_ENCODING_8859_4=\t13,/* ISO-8859-4 */\n    XML_CHAR_ENCODING_8859_5=\t14,/* ISO-8859-5 */\n    XML_CHAR_ENCODING_8859_6=\t15,/* ISO-8859-6 */\n    XML_CHAR_ENCODING_8859_7=\t16,/* ISO-8859-7 */\n    XML_CHAR_ENCODING_8859_8=\t17,/* ISO-8859-8 */\n    XML_CHAR_ENCODING_8859_9=\t18,/* ISO-8859-9 */\n    XML_CHAR_ENCODING_2022_JP=  19,/* ISO-2022-JP */\n    XML_CHAR_ENCODING_SHIFT_JIS=20,/* Shift_JIS */\n    XML_CHAR_ENCODING_EUC_JP=   21,/* EUC-JP */\n    XML_CHAR_ENCODING_ASCII=    22 /* pure ASCII */\n} xmlCharEncoding;\n\n/**\n * xmlCharEncodingInputFunc:\n * @out:  a pointer to an array of bytes to store the UTF-8 result\n * @outlen:  the length of @out\n * @in:  a pointer to an array of chars in the original encoding\n * @inlen:  the length of @in\n *\n * Take a block of chars in the original encoding and try to convert\n * it to an UTF-8 block of chars out.\n *\n * Returns the number of bytes written, -1 if lack of space, or -2\n *     if the transcoding failed.\n * The value of @inlen after return is the number of octets consumed\n *     if the return value is positive, else unpredictiable.\n * The value of @outlen after return is the number of octets consumed.\n */\ntypedef int (* xmlCharEncodingInputFunc)(unsigned char *out, int *outlen,\n                                         const unsigned char *in, int *inlen);\n\n\n/**\n * xmlCharEncodingOutputFunc:\n * @out:  a pointer to an array of bytes to store the result\n * @outlen:  the length of @out\n * @in:  a pointer to an array of UTF-8 chars\n * @inlen:  the length of @in\n *\n * Take a block of UTF-8 chars in and try to convert it to another\n * encoding.\n * Note: a first call designed to produce heading info is called with\n * in = NULL. If stateful this should also initialize the encoder state.\n *\n * Returns the number of bytes written, -1 if lack of space, or -2\n *     if the transcoding failed.\n * The value of @inlen after return is the number of octets consumed\n *     if the return value is positive, else unpredictiable.\n * The value of @outlen after return is the number of octets produced.\n */\ntypedef int (* xmlCharEncodingOutputFunc)(unsigned char *out, int *outlen,\n                                          const unsigned char *in, int *inlen);\n\n\n/*\n * Block defining the handlers for non UTF-8 encodings.\n * If iconv is supported, there are two extra fields.\n */\ntypedef struct _xmlCharEncodingHandler xmlCharEncodingHandler;\ntypedef xmlCharEncodingHandler *xmlCharEncodingHandlerPtr;\nstruct _xmlCharEncodingHandler {\n    char                       *name;\n    xmlCharEncodingInputFunc   input;\n    xmlCharEncodingOutputFunc  output;\n#ifdef LIBXML_ICONV_ENABLED\n    iconv_t                    iconv_in;\n    iconv_t                    iconv_out;\n#endif /* LIBXML_ICONV_ENABLED */\n#ifdef LIBXML_ICU_ENABLED\n    struct _uconv_t            *uconv_in;\n    struct _uconv_t            *uconv_out;\n#endif /* LIBXML_ICU_ENABLED */\n};\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/tree.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Interfaces for encoding handlers.\n */\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlInitCharEncodingHandlers\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlCleanupCharEncodingHandlers\t(void);\nXMLPUBFUN void\n\txmlRegisterCharEncodingHandler\t(xmlCharEncodingHandlerPtr handler);\nXMLPUBFUN xmlCharEncodingHandlerPtr\n\txmlGetCharEncodingHandler\t(xmlCharEncoding enc);\nXMLPUBFUN xmlCharEncodingHandlerPtr\n\txmlFindCharEncodingHandler\t(const char *name);\nXMLPUBFUN xmlCharEncodingHandlerPtr\n\txmlNewCharEncodingHandler\t(const char *name,\n\t\t\t\t\t xmlCharEncodingInputFunc input,\n\t\t\t\t\t xmlCharEncodingOutputFunc output);\n\n/*\n * Interfaces for encoding names and aliases.\n */\nXMLPUBFUN int\n\txmlAddEncodingAlias\t\t(const char *name,\n\t\t\t\t\t const char *alias);\nXMLPUBFUN int\n\txmlDelEncodingAlias\t\t(const char *alias);\nXMLPUBFUN const char *\n\txmlGetEncodingAlias\t\t(const char *alias);\nXMLPUBFUN void\n\txmlCleanupEncodingAliases\t(void);\nXMLPUBFUN xmlCharEncoding\n\txmlParseCharEncoding\t\t(const char *name);\nXMLPUBFUN const char *\n\txmlGetCharEncodingName\t\t(xmlCharEncoding enc);\n\n/*\n * Interfaces directly used by the parsers.\n */\nXMLPUBFUN xmlCharEncoding\n\txmlDetectCharEncoding\t\t(const unsigned char *in,\n\t\t\t\t\t int len);\n\nXMLPUBFUN int\n\txmlCharEncOutFunc\t\t(xmlCharEncodingHandler *handler,\n\t\t\t\t\t xmlBufferPtr out,\n\t\t\t\t\t xmlBufferPtr in);\n\nXMLPUBFUN int\n\txmlCharEncInFunc\t\t(xmlCharEncodingHandler *handler,\n\t\t\t\t\t xmlBufferPtr out,\n\t\t\t\t\t xmlBufferPtr in);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlCharEncFirstLine\t\t(xmlCharEncodingHandler *handler,\n\t\t\t\t\t xmlBufferPtr out,\n\t\t\t\t\t xmlBufferPtr in);\nXMLPUBFUN int\n\txmlCharEncCloseFunc\t\t(xmlCharEncodingHandler *handler);\n\n/*\n * Export a few useful functions\n */\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN int\n\tUTF8Toisolat1\t\t\t(unsigned char *out,\n\t\t\t\t\t int *outlen,\n\t\t\t\t\t const unsigned char *in,\n\t\t\t\t\t int *inlen);\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN int\n\tisolat1ToUTF8\t\t\t(unsigned char *out,\n\t\t\t\t\t int *outlen,\n\t\t\t\t\t const unsigned char *in,\n\t\t\t\t\t int *inlen);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_CHAR_ENCODING_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/entities.h",
    "content": "/*\n * Summary: interface for the XML entities handling\n * Description: this module provides some of the entity API needed\n *              for the parser and applications.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_ENTITIES_H__\n#define __XML_ENTITIES_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The different valid entity types.\n */\ntypedef enum {\n    XML_INTERNAL_GENERAL_ENTITY = 1,\n    XML_EXTERNAL_GENERAL_PARSED_ENTITY = 2,\n    XML_EXTERNAL_GENERAL_UNPARSED_ENTITY = 3,\n    XML_INTERNAL_PARAMETER_ENTITY = 4,\n    XML_EXTERNAL_PARAMETER_ENTITY = 5,\n    XML_INTERNAL_PREDEFINED_ENTITY = 6\n} xmlEntityType;\n\n/*\n * An unit of storage for an entity, contains the string, the value\n * and the linkind data needed for the linking in the hash table.\n */\n\nstruct _xmlEntity {\n    void           *_private;\t        /* application data */\n    xmlElementType          type;       /* XML_ENTITY_DECL, must be second ! */\n    const xmlChar          *name;\t/* Entity name */\n    struct _xmlNode    *children;\t/* First child link */\n    struct _xmlNode        *last;\t/* Last child link */\n    struct _xmlDtd       *parent;\t/* -> DTD */\n    struct _xmlNode        *next;\t/* next sibling link  */\n    struct _xmlNode        *prev;\t/* previous sibling link  */\n    struct _xmlDoc          *doc;       /* the containing document */\n\n    xmlChar                *orig;\t/* content without ref substitution */\n    xmlChar             *content;\t/* content or ndata if unparsed */\n    int                   length;\t/* the content length */\n    xmlEntityType          etype;\t/* The entity type */\n    const xmlChar    *ExternalID;\t/* External identifier for PUBLIC */\n    const xmlChar      *SystemID;\t/* URI for a SYSTEM or PUBLIC Entity */\n\n    struct _xmlEntity     *nexte;\t/* unused */\n    const xmlChar           *URI;\t/* the full URI as computed */\n    int                    owner;\t/* does the entity own the childrens */\n    int                    flags;       /* various flags */\n    unsigned long   expandedSize;       /* expanded size */\n};\n\n/*\n * All entities are stored in an hash table.\n * There is 2 separate hash tables for global and parameter entities.\n */\n\ntypedef struct _xmlHashTable xmlEntitiesTable;\ntypedef xmlEntitiesTable *xmlEntitiesTablePtr;\n\n/*\n * External functions:\n */\n\n#ifdef LIBXML_LEGACY_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlInitializePredefinedEntities\t(void);\n#endif /* LIBXML_LEGACY_ENABLED */\n\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlNewEntity\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID,\n\t\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlAddDocEntity\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID,\n\t\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlAddDtdEntity\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t int type,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID,\n\t\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlGetPredefinedEntity\t(const xmlChar *name);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlGetDocEntity\t\t(const xmlDoc *doc,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlGetDtdEntity\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlGetParameterEntity\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *name);\n#ifdef LIBXML_LEGACY_ENABLED\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlEncodeEntities\t(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *input);\n#endif /* LIBXML_LEGACY_ENABLED */\nXMLPUBFUN xmlChar *\n\t\t\txmlEncodeEntitiesReentrant(xmlDocPtr doc,\n\t\t\t\t\t\t const xmlChar *input);\nXMLPUBFUN xmlChar *\n\t\t\txmlEncodeSpecialChars\t(const xmlDoc *doc,\n\t\t\t\t\t\t const xmlChar *input);\nXMLPUBFUN xmlEntitiesTablePtr\n\t\t\txmlCreateEntitiesTable\t(void);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlEntitiesTablePtr\n\t\t\txmlCopyEntitiesTable\t(xmlEntitiesTablePtr table);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\t\txmlFreeEntitiesTable\t(xmlEntitiesTablePtr table);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\t\txmlDumpEntitiesTable\t(xmlBufferPtr buf,\n\t\t\t\t\t\t xmlEntitiesTablePtr table);\nXMLPUBFUN void\n\t\t\txmlDumpEntityDecl\t(xmlBufferPtr buf,\n\t\t\t\t\t\t xmlEntityPtr ent);\n#endif /* LIBXML_OUTPUT_ENABLED */\n#ifdef LIBXML_LEGACY_ENABLED\nXMLPUBFUN void\n\t\t\txmlCleanupPredefinedEntities(void);\n#endif /* LIBXML_LEGACY_ENABLED */\n\n\n#ifdef __cplusplus\n}\n#endif\n\n# endif /* __XML_ENTITIES_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/globals.h",
    "content": "/*\n * Summary: interface for all global variables of the library\n * Description: all the global variables and thread handling for\n *              those variables is handled by this module.\n *\n * The bottom of this file is automatically generated by build_glob.py\n * based on the description file global.data\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Gary Pennington <Gary.Pennington@uk.sun.com>, Daniel Veillard\n */\n\n#ifndef __XML_GLOBALS_H\n#define __XML_GLOBALS_H\n\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n#include <libxml/xmlerror.h>\n#include <libxml/SAX2.h>\n#include <libxml/xmlmemory.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN void xmlInitGlobals(void);\nXML_DEPRECATED\nXMLPUBFUN void xmlCleanupGlobals(void);\n\n/**\n * xmlParserInputBufferCreateFilenameFunc:\n * @URI: the URI to read from\n * @enc: the requested source encoding\n *\n * Signature for the function doing the lookup for a suitable input method\n * corresponding to an URI.\n *\n * Returns the new xmlParserInputBufferPtr in case of success or NULL if no\n *         method was found.\n */\ntypedef xmlParserInputBufferPtr (*xmlParserInputBufferCreateFilenameFunc) (const char *URI,\n\t\t\t\t\t\t\t\t\t   xmlCharEncoding enc);\n\n\n/**\n * xmlOutputBufferCreateFilenameFunc:\n * @URI: the URI to write to\n * @enc: the requested target encoding\n *\n * Signature for the function doing the lookup for a suitable output method\n * corresponding to an URI.\n *\n * Returns the new xmlOutputBufferPtr in case of success or NULL if no\n *         method was found.\n */\ntypedef xmlOutputBufferPtr (*xmlOutputBufferCreateFilenameFunc) (const char *URI,\n\t\t\t\t\t\t\t\t xmlCharEncodingHandlerPtr encoder,\n\t\t\t\t\t\t\t\t int compression);\n\nXMLPUBFUN xmlParserInputBufferCreateFilenameFunc\nxmlParserInputBufferCreateFilenameDefault (xmlParserInputBufferCreateFilenameFunc func);\nXMLPUBFUN xmlOutputBufferCreateFilenameFunc\nxmlOutputBufferCreateFilenameDefault (xmlOutputBufferCreateFilenameFunc func);\n\n/*\n * Externally global symbols which need to be protected for backwards\n * compatibility support.\n */\n\n#undef\thtmlDefaultSAXHandler\n#undef\toldXMLWDcompatibility\n#undef\txmlBufferAllocScheme\n#undef\txmlDefaultBufferSize\n#undef\txmlDefaultSAXHandler\n#undef\txmlDefaultSAXLocator\n#undef\txmlDoValidityCheckingDefaultValue\n#undef\txmlFree\n#undef\txmlGenericError\n#undef\txmlStructuredError\n#undef\txmlGenericErrorContext\n#undef\txmlStructuredErrorContext\n#undef\txmlGetWarningsDefaultValue\n#undef\txmlIndentTreeOutput\n#undef  xmlTreeIndentString\n#undef\txmlKeepBlanksDefaultValue\n#undef\txmlLineNumbersDefaultValue\n#undef\txmlLoadExtDtdDefaultValue\n#undef\txmlMalloc\n#undef\txmlMallocAtomic\n#undef\txmlMemStrdup\n#undef\txmlParserDebugEntities\n#undef\txmlParserVersion\n#undef\txmlPedanticParserDefaultValue\n#undef\txmlRealloc\n#undef\txmlSaveNoEmptyTags\n#undef\txmlSubstituteEntitiesDefaultValue\n#undef  xmlRegisterNodeDefaultValue\n#undef  xmlDeregisterNodeDefaultValue\n#undef  xmlLastError\n#undef  xmlParserInputBufferCreateFilenameValue\n#undef  xmlOutputBufferCreateFilenameValue\n\n/**\n * xmlRegisterNodeFunc:\n * @node: the current node\n *\n * Signature for the registration callback of a created node\n */\ntypedef void (*xmlRegisterNodeFunc) (xmlNodePtr node);\n/**\n * xmlDeregisterNodeFunc:\n * @node: the current node\n *\n * Signature for the deregistration callback of a discarded node\n */\ntypedef void (*xmlDeregisterNodeFunc) (xmlNodePtr node);\n\ntypedef struct _xmlGlobalState xmlGlobalState;\ntypedef xmlGlobalState *xmlGlobalStatePtr;\nstruct _xmlGlobalState\n{\n\tconst char *xmlParserVersion;\n\n\txmlSAXLocator xmlDefaultSAXLocator;\n\txmlSAXHandlerV1 xmlDefaultSAXHandler;\n\txmlSAXHandlerV1 docbDefaultSAXHandler; /* unused */\n\txmlSAXHandlerV1 htmlDefaultSAXHandler;\n\n\txmlFreeFunc xmlFree;\n\txmlMallocFunc xmlMalloc;\n\txmlStrdupFunc xmlMemStrdup;\n\txmlReallocFunc xmlRealloc;\n\n\txmlGenericErrorFunc xmlGenericError;\n\txmlStructuredErrorFunc xmlStructuredError;\n\tvoid *xmlGenericErrorContext;\n\n\tint oldXMLWDcompatibility;\n\n\txmlBufferAllocationScheme xmlBufferAllocScheme;\n\tint xmlDefaultBufferSize;\n\n\tint xmlSubstituteEntitiesDefaultValue;\n\tint xmlDoValidityCheckingDefaultValue;\n\tint xmlGetWarningsDefaultValue;\n\tint xmlKeepBlanksDefaultValue;\n\tint xmlLineNumbersDefaultValue;\n\tint xmlLoadExtDtdDefaultValue;\n\tint xmlParserDebugEntities;\n\tint xmlPedanticParserDefaultValue;\n\n\tint xmlSaveNoEmptyTags;\n\tint xmlIndentTreeOutput;\n\tconst char *xmlTreeIndentString;\n\n\txmlRegisterNodeFunc xmlRegisterNodeDefaultValue;\n\txmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;\n\n\txmlMallocFunc xmlMallocAtomic;\n\txmlError xmlLastError;\n\n\txmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;\n\txmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;\n\n\tvoid *xmlStructuredErrorContext;\n};\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/threads.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nXMLPUBFUN void\txmlInitializeGlobalState(xmlGlobalStatePtr gs);\n\nXMLPUBFUN void xmlThrDefSetGenericErrorFunc(void *ctx, xmlGenericErrorFunc handler);\n\nXMLPUBFUN void xmlThrDefSetStructuredErrorFunc(void *ctx, xmlStructuredErrorFunc handler);\n\nXMLPUBFUN xmlRegisterNodeFunc xmlRegisterNodeDefault(xmlRegisterNodeFunc func);\nXMLPUBFUN xmlRegisterNodeFunc xmlThrDefRegisterNodeDefault(xmlRegisterNodeFunc func);\nXMLPUBFUN xmlDeregisterNodeFunc xmlDeregisterNodeDefault(xmlDeregisterNodeFunc func);\nXMLPUBFUN xmlDeregisterNodeFunc xmlThrDefDeregisterNodeDefault(xmlDeregisterNodeFunc func);\n\nXMLPUBFUN xmlOutputBufferCreateFilenameFunc\n\txmlThrDefOutputBufferCreateFilenameDefault(xmlOutputBufferCreateFilenameFunc func);\nXMLPUBFUN xmlParserInputBufferCreateFilenameFunc\n\txmlThrDefParserInputBufferCreateFilenameDefault(\n\t\t\t\txmlParserInputBufferCreateFilenameFunc func);\n\n/*\n * In general the memory allocation entry points are not kept\n * thread specific but this can be overridden by LIBXML_THREAD_ALLOC_ENABLED\n *    - xmlMalloc\n *    - xmlMallocAtomic\n *    - xmlRealloc\n *    - xmlMemStrdup\n *    - xmlFree\n */\n\n#ifdef LIBXML_THREAD_ALLOC_ENABLED\n/** DOC_DISABLE */\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlMallocFunc * __xmlMalloc(void);\n#define xmlMalloc \\\n(*(__xmlMalloc()))\n#else\nXMLPUBVAR xmlMallocFunc xmlMalloc;\n#endif\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlMallocFunc * __xmlMallocAtomic(void);\n#define xmlMallocAtomic \\\n(*(__xmlMallocAtomic()))\n#else\nXMLPUBVAR xmlMallocFunc xmlMallocAtomic;\n#endif\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlReallocFunc * __xmlRealloc(void);\n#define xmlRealloc \\\n(*(__xmlRealloc()))\n#else\nXMLPUBVAR xmlReallocFunc xmlRealloc;\n#endif\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlFreeFunc * __xmlFree(void);\n#define xmlFree \\\n(*(__xmlFree()))\n#else\nXMLPUBVAR xmlFreeFunc xmlFree;\n#endif\n\n#ifdef LIBXML_THREAD_ENABLED\nXMLPUBFUN  xmlStrdupFunc * __xmlMemStrdup(void);\n#define xmlMemStrdup \\\n(*(__xmlMemStrdup()))\n#else\nXMLPUBVAR xmlStrdupFunc xmlMemStrdup;\n#endif\n\n/** DOC_ENABLE */\n#else /* !LIBXML_THREAD_ALLOC_ENABLED */\nXMLPUBVAR xmlMallocFunc xmlMalloc;\nXMLPUBVAR xmlMallocFunc xmlMallocAtomic;\nXMLPUBVAR xmlReallocFunc xmlRealloc;\nXMLPUBVAR xmlFreeFunc xmlFree;\nXMLPUBVAR xmlStrdupFunc xmlMemStrdup;\n#endif /* LIBXML_THREAD_ALLOC_ENABLED */\n\n#ifdef LIBXML_HTML_ENABLED\nXML_DEPRECATED\nXMLPUBFUN xmlSAXHandlerV1 * __htmlDefaultSAXHandler(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define htmlDefaultSAXHandler \\\n(*(__htmlDefaultSAXHandler()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlSAXHandlerV1 htmlDefaultSAXHandler;\n#endif\n#endif\n\nXMLPUBFUN xmlError * __xmlLastError(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlLastError \\\n(*(__xmlLastError()))\n#else\nXMLPUBVAR xmlError xmlLastError;\n#endif\n\n/*\n * Everything starting from the line below is\n * Automatically generated by build_glob.py.\n * Do not modify the previous line.\n */\n\n\nXML_DEPRECATED\nXMLPUBFUN int * __oldXMLWDcompatibility(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define oldXMLWDcompatibility \\\n(*(__oldXMLWDcompatibility()))\n#else\nXML_DEPRECATED\nXMLPUBVAR int oldXMLWDcompatibility;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlBufferAllocationScheme * __xmlBufferAllocScheme(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlBufferAllocScheme \\\n(*(__xmlBufferAllocScheme()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlBufferAllocationScheme xmlBufferAllocScheme;\n#endif\nXML_DEPRECATED\nXMLPUBFUN xmlBufferAllocationScheme\n\txmlThrDefBufferAllocScheme(xmlBufferAllocationScheme v);\n\nXML_DEPRECATED\nXMLPUBFUN int * __xmlDefaultBufferSize(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDefaultBufferSize \\\n(*(__xmlDefaultBufferSize()))\n#else\nXML_DEPRECATED\nXMLPUBVAR int xmlDefaultBufferSize;\n#endif\nXML_DEPRECATED\nXMLPUBFUN int xmlThrDefDefaultBufferSize(int v);\n\nXML_DEPRECATED\nXMLPUBFUN xmlSAXHandlerV1 * __xmlDefaultSAXHandler(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDefaultSAXHandler \\\n(*(__xmlDefaultSAXHandler()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlSAXHandlerV1 xmlDefaultSAXHandler;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlSAXLocator * __xmlDefaultSAXLocator(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDefaultSAXLocator \\\n(*(__xmlDefaultSAXLocator()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlSAXLocator xmlDefaultSAXLocator;\n#endif\n\nXMLPUBFUN int * __xmlDoValidityCheckingDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDoValidityCheckingDefaultValue \\\n(*(__xmlDoValidityCheckingDefaultValue()))\n#else\nXMLPUBVAR int xmlDoValidityCheckingDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefDoValidityCheckingDefaultValue(int v);\n\nXMLPUBFUN xmlGenericErrorFunc * __xmlGenericError(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlGenericError \\\n(*(__xmlGenericError()))\n#else\nXMLPUBVAR xmlGenericErrorFunc xmlGenericError;\n#endif\n\nXMLPUBFUN xmlStructuredErrorFunc * __xmlStructuredError(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlStructuredError \\\n(*(__xmlStructuredError()))\n#else\nXMLPUBVAR xmlStructuredErrorFunc xmlStructuredError;\n#endif\n\nXMLPUBFUN void * * __xmlGenericErrorContext(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlGenericErrorContext \\\n(*(__xmlGenericErrorContext()))\n#else\nXMLPUBVAR void * xmlGenericErrorContext;\n#endif\n\nXMLPUBFUN void * * __xmlStructuredErrorContext(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlStructuredErrorContext \\\n(*(__xmlStructuredErrorContext()))\n#else\nXMLPUBVAR void * xmlStructuredErrorContext;\n#endif\n\nXMLPUBFUN int * __xmlGetWarningsDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlGetWarningsDefaultValue \\\n(*(__xmlGetWarningsDefaultValue()))\n#else\nXMLPUBVAR int xmlGetWarningsDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefGetWarningsDefaultValue(int v);\n\nXMLPUBFUN int * __xmlIndentTreeOutput(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlIndentTreeOutput \\\n(*(__xmlIndentTreeOutput()))\n#else\nXMLPUBVAR int xmlIndentTreeOutput;\n#endif\nXMLPUBFUN int xmlThrDefIndentTreeOutput(int v);\n\nXMLPUBFUN const char * * __xmlTreeIndentString(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlTreeIndentString \\\n(*(__xmlTreeIndentString()))\n#else\nXMLPUBVAR const char * xmlTreeIndentString;\n#endif\nXMLPUBFUN const char * xmlThrDefTreeIndentString(const char * v);\n\nXMLPUBFUN int * __xmlKeepBlanksDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlKeepBlanksDefaultValue \\\n(*(__xmlKeepBlanksDefaultValue()))\n#else\nXMLPUBVAR int xmlKeepBlanksDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefKeepBlanksDefaultValue(int v);\n\nXML_DEPRECATED\nXMLPUBFUN int * __xmlLineNumbersDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlLineNumbersDefaultValue \\\n(*(__xmlLineNumbersDefaultValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR int xmlLineNumbersDefaultValue;\n#endif\nXML_DEPRECATED\nXMLPUBFUN int xmlThrDefLineNumbersDefaultValue(int v);\n\nXMLPUBFUN int * __xmlLoadExtDtdDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlLoadExtDtdDefaultValue \\\n(*(__xmlLoadExtDtdDefaultValue()))\n#else\nXMLPUBVAR int xmlLoadExtDtdDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefLoadExtDtdDefaultValue(int v);\n\nXMLPUBFUN int * __xmlParserDebugEntities(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlParserDebugEntities \\\n(*(__xmlParserDebugEntities()))\n#else\nXMLPUBVAR int xmlParserDebugEntities;\n#endif\nXMLPUBFUN int xmlThrDefParserDebugEntities(int v);\n\nXMLPUBFUN const char * * __xmlParserVersion(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlParserVersion \\\n(*(__xmlParserVersion()))\n#else\nXMLPUBVAR const char * xmlParserVersion;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN int * __xmlPedanticParserDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlPedanticParserDefaultValue \\\n(*(__xmlPedanticParserDefaultValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR int xmlPedanticParserDefaultValue;\n#endif\nXML_DEPRECATED\nXMLPUBFUN int xmlThrDefPedanticParserDefaultValue(int v);\n\nXMLPUBFUN int * __xmlSaveNoEmptyTags(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlSaveNoEmptyTags \\\n(*(__xmlSaveNoEmptyTags()))\n#else\nXMLPUBVAR int xmlSaveNoEmptyTags;\n#endif\nXMLPUBFUN int xmlThrDefSaveNoEmptyTags(int v);\n\nXMLPUBFUN int * __xmlSubstituteEntitiesDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlSubstituteEntitiesDefaultValue \\\n(*(__xmlSubstituteEntitiesDefaultValue()))\n#else\nXMLPUBVAR int xmlSubstituteEntitiesDefaultValue;\n#endif\nXMLPUBFUN int xmlThrDefSubstituteEntitiesDefaultValue(int v);\n\nXML_DEPRECATED\nXMLPUBFUN xmlRegisterNodeFunc * __xmlRegisterNodeDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlRegisterNodeDefaultValue \\\n(*(__xmlRegisterNodeDefaultValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlRegisterNodeFunc xmlRegisterNodeDefaultValue;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlDeregisterNodeFunc * __xmlDeregisterNodeDefaultValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlDeregisterNodeDefaultValue \\\n(*(__xmlDeregisterNodeDefaultValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlDeregisterNodeFunc xmlDeregisterNodeDefaultValue;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlParserInputBufferCreateFilenameFunc * \\\n\t\t\t\t__xmlParserInputBufferCreateFilenameValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlParserInputBufferCreateFilenameValue \\\n(*(__xmlParserInputBufferCreateFilenameValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlParserInputBufferCreateFilenameFunc xmlParserInputBufferCreateFilenameValue;\n#endif\n\nXML_DEPRECATED\nXMLPUBFUN xmlOutputBufferCreateFilenameFunc * __xmlOutputBufferCreateFilenameValue(void);\n#ifdef LIBXML_THREAD_ENABLED\n#define xmlOutputBufferCreateFilenameValue \\\n(*(__xmlOutputBufferCreateFilenameValue()))\n#else\nXML_DEPRECATED\nXMLPUBVAR xmlOutputBufferCreateFilenameFunc xmlOutputBufferCreateFilenameValue;\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_GLOBALS_H */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/hash.h",
    "content": "/*\n * Summary: Chained hash tables\n * Description: This module implements the hash table support used in\n *\t\tvarious places in the library.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Bjorn Reese <bjorn.reese@systematic.dk>\n */\n\n#ifndef __XML_HASH_H__\n#define __XML_HASH_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The hash table.\n */\ntypedef struct _xmlHashTable xmlHashTable;\ntypedef xmlHashTable *xmlHashTablePtr;\n\n#ifdef __cplusplus\n}\n#endif\n\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n#include <libxml/dict.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Recent version of gcc produce a warning when a function pointer is assigned\n * to an object pointer, or vice versa.  The following macro is a dirty hack\n * to allow suppression of the warning.  If your architecture has function\n * pointers which are a different size than a void pointer, there may be some\n * serious trouble within the library.\n */\n/**\n * XML_CAST_FPTR:\n * @fptr:  pointer to a function\n *\n * Macro to do a casting from an object pointer to a\n * function pointer without encountering a warning from\n * gcc\n *\n * #define XML_CAST_FPTR(fptr) (*(void **)(&fptr))\n * This macro violated ISO C aliasing rules (gcc4 on s390 broke)\n * so it is disabled now\n */\n\n#define XML_CAST_FPTR(fptr) fptr\n\n\n/*\n * function types:\n */\n/**\n * xmlHashDeallocator:\n * @payload:  the data in the hash\n * @name:  the name associated\n *\n * Callback to free data from a hash.\n */\ntypedef void (*xmlHashDeallocator)(void *payload, const xmlChar *name);\n/**\n * xmlHashCopier:\n * @payload:  the data in the hash\n * @name:  the name associated\n *\n * Callback to copy data from a hash.\n *\n * Returns a copy of the data or NULL in case of error.\n */\ntypedef void *(*xmlHashCopier)(void *payload, const xmlChar *name);\n/**\n * xmlHashScanner:\n * @payload:  the data in the hash\n * @data:  extra scanner data\n * @name:  the name associated\n *\n * Callback when scanning data in a hash with the simple scanner.\n */\ntypedef void (*xmlHashScanner)(void *payload, void *data, const xmlChar *name);\n/**\n * xmlHashScannerFull:\n * @payload:  the data in the hash\n * @data:  extra scanner data\n * @name:  the name associated\n * @name2:  the second name associated\n * @name3:  the third name associated\n *\n * Callback when scanning data in a hash with the full scanner.\n */\ntypedef void (*xmlHashScannerFull)(void *payload, void *data,\n\t\t\t\t   const xmlChar *name, const xmlChar *name2,\n\t\t\t\t   const xmlChar *name3);\n\n/*\n * Constructor and destructor.\n */\nXMLPUBFUN xmlHashTablePtr\n\t\t\txmlHashCreate\t(int size);\nXMLPUBFUN xmlHashTablePtr\n\t\t\txmlHashCreateDict(int size,\n\t\t\t\t\t xmlDictPtr dict);\nXMLPUBFUN void\n\t\t\txmlHashFree\t(xmlHashTablePtr table,\n\t\t\t\t\t xmlHashDeallocator f);\nXMLPUBFUN void\n\t\t\txmlHashDefaultDeallocator(void *entry,\n\t\t\t\t\t const xmlChar *name);\n\n/*\n * Add a new entry to the hash table.\n */\nXMLPUBFUN int\n\t\t\txmlHashAddEntry\t(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         void *userdata);\nXMLPUBFUN int\n\t\t\txmlHashUpdateEntry(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         void *userdata,\n\t\t\t\t\t xmlHashDeallocator f);\nXMLPUBFUN int\n\t\t\txmlHashAddEntry2(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         const xmlChar *name2,\n\t\t                         void *userdata);\nXMLPUBFUN int\n\t\t\txmlHashUpdateEntry2(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         const xmlChar *name2,\n\t\t                         void *userdata,\n\t\t\t\t\t xmlHashDeallocator f);\nXMLPUBFUN int\n\t\t\txmlHashAddEntry3(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         const xmlChar *name2,\n\t\t                         const xmlChar *name3,\n\t\t                         void *userdata);\nXMLPUBFUN int\n\t\t\txmlHashUpdateEntry3(xmlHashTablePtr table,\n\t\t                         const xmlChar *name,\n\t\t                         const xmlChar *name2,\n\t\t                         const xmlChar *name3,\n\t\t                         void *userdata,\n\t\t\t\t\t xmlHashDeallocator f);\n\n/*\n * Remove an entry from the hash table.\n */\nXMLPUBFUN int\n\t\t\txmlHashRemoveEntry(xmlHashTablePtr table, const xmlChar *name,\n                           xmlHashDeallocator f);\nXMLPUBFUN int\n\t\t\txmlHashRemoveEntry2(xmlHashTablePtr table, const xmlChar *name,\n                            const xmlChar *name2, xmlHashDeallocator f);\nXMLPUBFUN int \n\t\t\txmlHashRemoveEntry3(xmlHashTablePtr table, const xmlChar *name,\n                            const xmlChar *name2, const xmlChar *name3,\n                            xmlHashDeallocator f);\n\n/*\n * Retrieve the userdata.\n */\nXMLPUBFUN void *\n\t\t\txmlHashLookup\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN void *\n\t\t\txmlHashLookup2\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *name2);\nXMLPUBFUN void *\n\t\t\txmlHashLookup3\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *name3);\nXMLPUBFUN void *\n\t\t\txmlHashQLookup\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN void *\n\t\t\txmlHashQLookup2\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *prefix2);\nXMLPUBFUN void *\n\t\t\txmlHashQLookup3\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *prefix2,\n\t\t\t\t\t const xmlChar *name3,\n\t\t\t\t\t const xmlChar *prefix3);\n\n/*\n * Helpers.\n */\nXMLPUBFUN xmlHashTablePtr\n\t\t\txmlHashCopy\t(xmlHashTablePtr table,\n\t\t\t\t\t xmlHashCopier f);\nXMLPUBFUN int\n\t\t\txmlHashSize\t(xmlHashTablePtr table);\nXMLPUBFUN void\n\t\t\txmlHashScan\t(xmlHashTablePtr table,\n\t\t\t\t\t xmlHashScanner f,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\t\txmlHashScan3\t(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *name3,\n\t\t\t\t\t xmlHashScanner f,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\t\txmlHashScanFull\t(xmlHashTablePtr table,\n\t\t\t\t\t xmlHashScannerFull f,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\t\txmlHashScanFull3(xmlHashTablePtr table,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *name2,\n\t\t\t\t\t const xmlChar *name3,\n\t\t\t\t\t xmlHashScannerFull f,\n\t\t\t\t\t void *data);\n#ifdef __cplusplus\n}\n#endif\n#endif /* ! __XML_HASH_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/list.h",
    "content": "/*\n * Summary: lists interfaces\n * Description: this module implement the list support used in\n * various place in the library.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Gary Pennington <Gary.Pennington@uk.sun.com>\n */\n\n#ifndef __XML_LINK_INCLUDE__\n#define __XML_LINK_INCLUDE__\n\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct _xmlLink xmlLink;\ntypedef xmlLink *xmlLinkPtr;\n\ntypedef struct _xmlList xmlList;\ntypedef xmlList *xmlListPtr;\n\n/**\n * xmlListDeallocator:\n * @lk:  the data to deallocate\n *\n * Callback function used to free data from a list.\n */\ntypedef void (*xmlListDeallocator) (xmlLinkPtr lk);\n/**\n * xmlListDataCompare:\n * @data0: the first data\n * @data1: the second data\n *\n * Callback function used to compare 2 data.\n *\n * Returns 0 is equality, -1 or 1 otherwise depending on the ordering.\n */\ntypedef int  (*xmlListDataCompare) (const void *data0, const void *data1);\n/**\n * xmlListWalker:\n * @data: the data found in the list\n * @user: extra user provided data to the walker\n *\n * Callback function used when walking a list with xmlListWalk().\n *\n * Returns 0 to stop walking the list, 1 otherwise.\n */\ntypedef int (*xmlListWalker) (const void *data, void *user);\n\n/* Creation/Deletion */\nXMLPUBFUN xmlListPtr\n\t\txmlListCreate\t\t(xmlListDeallocator deallocator,\n\t                                 xmlListDataCompare compare);\nXMLPUBFUN void\n\t\txmlListDelete\t\t(xmlListPtr l);\n\n/* Basic Operators */\nXMLPUBFUN void *\n\t\txmlListSearch\t\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN void *\n\t\txmlListReverseSearch\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\txmlListInsert\t\t(xmlListPtr l,\n\t\t\t\t\t void *data) ;\nXMLPUBFUN int\n\t\txmlListAppend\t\t(xmlListPtr l,\n\t\t\t\t\t void *data) ;\nXMLPUBFUN int\n\t\txmlListRemoveFirst\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\txmlListRemoveLast\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\txmlListRemoveAll\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\txmlListClear\t\t(xmlListPtr l);\nXMLPUBFUN int\n\t\txmlListEmpty\t\t(xmlListPtr l);\nXMLPUBFUN xmlLinkPtr\n\t\txmlListFront\t\t(xmlListPtr l);\nXMLPUBFUN xmlLinkPtr\n\t\txmlListEnd\t\t(xmlListPtr l);\nXMLPUBFUN int\n\t\txmlListSize\t\t(xmlListPtr l);\n\nXMLPUBFUN void\n\t\txmlListPopFront\t\t(xmlListPtr l);\nXMLPUBFUN void\n\t\txmlListPopBack\t\t(xmlListPtr l);\nXMLPUBFUN int\n\t\txmlListPushFront\t(xmlListPtr l,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\txmlListPushBack\t\t(xmlListPtr l,\n\t\t\t\t\t void *data);\n\n/* Advanced Operators */\nXMLPUBFUN void\n\t\txmlListReverse\t\t(xmlListPtr l);\nXMLPUBFUN void\n\t\txmlListSort\t\t(xmlListPtr l);\nXMLPUBFUN void\n\t\txmlListWalk\t\t(xmlListPtr l,\n\t\t\t\t\t xmlListWalker walker,\n\t\t\t\t\t void *user);\nXMLPUBFUN void\n\t\txmlListReverseWalk\t(xmlListPtr l,\n\t\t\t\t\t xmlListWalker walker,\n\t\t\t\t\t void *user);\nXMLPUBFUN void\n\t\txmlListMerge\t\t(xmlListPtr l1,\n\t\t\t\t\t xmlListPtr l2);\nXMLPUBFUN xmlListPtr\n\t\txmlListDup\t\t(const xmlListPtr old);\nXMLPUBFUN int\n\t\txmlListCopy\t\t(xmlListPtr cur,\n\t\t\t\t\t const xmlListPtr old);\n/* Link operators */\nXMLPUBFUN void *\n\t\txmlLinkGetData          (xmlLinkPtr lk);\n\n/* xmlListUnique() */\n/* xmlListSwap */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_LINK_INCLUDE__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/nanoftp.h",
    "content": "/*\n * Summary: minimal FTP implementation\n * Description: minimal FTP implementation allowing to fetch resources\n *              like external subset. This module is DEPRECATED, do not\n *              use any of its functions.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __NANO_FTP_H__\n#define __NANO_FTP_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_FTP_ENABLED\n\n/* Needed for portability to Windows 64 bits */\n#if defined(_WIN32)\n#include <winsock2.h>\n#else\n/**\n * SOCKET:\n *\n * macro used to provide portability of code to windows sockets\n */\n#define SOCKET int\n/**\n * INVALID_SOCKET:\n *\n * macro used to provide portability of code to windows sockets\n * the value to be used when the socket is not valid\n */\n#undef  INVALID_SOCKET\n#define INVALID_SOCKET (-1)\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * ftpListCallback:\n * @userData:  user provided data for the callback\n * @filename:  the file name (including \"->\" when links are shown)\n * @attrib:  the attribute string\n * @owner:  the owner string\n * @group:  the group string\n * @size:  the file size\n * @links:  the link count\n * @year:  the year\n * @month:  the month\n * @day:  the day\n * @hour:  the hour\n * @minute:  the minute\n *\n * A callback for the xmlNanoFTPList command.\n * Note that only one of year and day:minute are specified.\n */\ntypedef void (*ftpListCallback) (void *userData,\n\t                         const char *filename, const char *attrib,\n\t                         const char *owner, const char *group,\n\t\t\t\t unsigned long size, int links, int year,\n\t\t\t\t const char *month, int day, int hour,\n\t\t\t\t int minute);\n/**\n * ftpDataCallback:\n * @userData: the user provided context\n * @data: the data received\n * @len: its size in bytes\n *\n * A callback for the xmlNanoFTPGet command.\n */\ntypedef void (*ftpDataCallback) (void *userData,\n\t\t\t\t const char *data,\n\t\t\t\t int len);\n\n/*\n * Init\n */\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPInit\t\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPCleanup\t(void);\n\n/*\n * Creating/freeing contexts.\n */\nXML_DEPRECATED\nXMLPUBFUN void *\n\txmlNanoFTPNewCtxt\t(const char *URL);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPFreeCtxt\t(void * ctx);\nXML_DEPRECATED\nXMLPUBFUN void *\n\txmlNanoFTPConnectTo\t(const char *server,\n\t\t\t\t int port);\n/*\n * Opening/closing session connections.\n */\nXML_DEPRECATED\nXMLPUBFUN void *\n\txmlNanoFTPOpen\t\t(const char *URL);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPConnect\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPClose\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPQuit\t\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPScanProxy\t(const char *URL);\nXML_DEPRECATED\nXMLPUBFUN void\n\txmlNanoFTPProxy\t\t(const char *host,\n\t\t\t\t int port,\n\t\t\t\t const char *user,\n\t\t\t\t const char *passwd,\n\t\t\t\t int type);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPUpdateURL\t(void *ctx,\n\t\t\t\t const char *URL);\n\n/*\n * Rather internal commands.\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPGetResponse\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPCheckResponse\t(void *ctx);\n\n/*\n * CD/DIR/GET handlers.\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPCwd\t\t(void *ctx,\n\t\t\t\t const char *directory);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPDele\t\t(void *ctx,\n\t\t\t\t const char *file);\n\nXML_DEPRECATED\nXMLPUBFUN SOCKET\n\txmlNanoFTPGetConnection\t(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPCloseConnection(void *ctx);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPList\t\t(void *ctx,\n\t\t\t\t ftpListCallback callback,\n\t\t\t\t void *userData,\n\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN SOCKET\n\txmlNanoFTPGetSocket\t(void *ctx,\n\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPGet\t\t(void *ctx,\n\t\t\t\t ftpDataCallback callback,\n\t\t\t\t void *userData,\n\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlNanoFTPRead\t\t(void *ctx,\n\t\t\t\t void *dest,\n\t\t\t\t int len);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* LIBXML_FTP_ENABLED */\n#endif /* __NANO_FTP_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/nanohttp.h",
    "content": "/*\n * Summary: minimal HTTP implementation\n * Description: minimal HTTP implementation allowing to fetch resources\n *              like external subset.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __NANO_HTTP_H__\n#define __NANO_HTTP_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_HTTP_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nXMLPUBFUN void\n\txmlNanoHTTPInit\t\t(void);\nXMLPUBFUN void\n\txmlNanoHTTPCleanup\t(void);\nXMLPUBFUN void\n\txmlNanoHTTPScanProxy\t(const char *URL);\nXMLPUBFUN int\n\txmlNanoHTTPFetch\t(const char *URL,\n\t\t\t\t const char *filename,\n\t\t\t\t char **contentType);\nXMLPUBFUN void *\n\txmlNanoHTTPMethod\t(const char *URL,\n\t\t\t\t const char *method,\n\t\t\t\t const char *input,\n\t\t\t\t char **contentType,\n\t\t\t\t const char *headers,\n\t\t\t\t int   ilen);\nXMLPUBFUN void *\n\txmlNanoHTTPMethodRedir\t(const char *URL,\n\t\t\t\t const char *method,\n\t\t\t\t const char *input,\n\t\t\t\t char **contentType,\n\t\t\t\t char **redir,\n\t\t\t\t const char *headers,\n\t\t\t\t int   ilen);\nXMLPUBFUN void *\n\txmlNanoHTTPOpen\t\t(const char *URL,\n\t\t\t\t char **contentType);\nXMLPUBFUN void *\n\txmlNanoHTTPOpenRedir\t(const char *URL,\n\t\t\t\t char **contentType,\n\t\t\t\t char **redir);\nXMLPUBFUN int\n\txmlNanoHTTPReturnCode\t(void *ctx);\nXMLPUBFUN const char *\n\txmlNanoHTTPAuthHeader\t(void *ctx);\nXMLPUBFUN const char *\n\txmlNanoHTTPRedir\t(void *ctx);\nXMLPUBFUN int\n\txmlNanoHTTPContentLength( void * ctx );\nXMLPUBFUN const char *\n\txmlNanoHTTPEncoding\t(void *ctx);\nXMLPUBFUN const char *\n\txmlNanoHTTPMimeType\t(void *ctx);\nXMLPUBFUN int\n\txmlNanoHTTPRead\t\t(void *ctx,\n\t\t\t\t void *dest,\n\t\t\t\t int len);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN int\n\txmlNanoHTTPSave\t\t(void *ctxt,\n\t\t\t\t const char *filename);\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN void\n\txmlNanoHTTPClose\t(void *ctx);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_HTTP_ENABLED */\n#endif /* __NANO_HTTP_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/parser.h",
    "content": "/*\n * Summary: the core parser module\n * Description: Interfaces, constants and types related to the XML parser\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_PARSER_H__\n#define __XML_PARSER_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/dict.h>\n#include <libxml/hash.h>\n#include <libxml/valid.h>\n#include <libxml/entities.h>\n#include <libxml/xmlerror.h>\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * XML_DEFAULT_VERSION:\n *\n * The default version of XML used: 1.0\n */\n#define XML_DEFAULT_VERSION\t\"1.0\"\n\n/**\n * xmlParserInput:\n *\n * An xmlParserInput is an input flow for the XML processor.\n * Each entity parsed is associated an xmlParserInput (except the\n * few predefined ones). This is the case both for internal entities\n * - in which case the flow is already completely in memory - or\n * external entities - in which case we use the buf structure for\n * progressive reading and I18N conversions to the internal UTF-8 format.\n */\n\n/**\n * xmlParserInputDeallocate:\n * @str:  the string to deallocate\n *\n * Callback for freeing some parser input allocations.\n */\ntypedef void (* xmlParserInputDeallocate)(xmlChar *str);\n\nstruct _xmlParserInput {\n    /* Input buffer */\n    xmlParserInputBufferPtr buf;      /* UTF-8 encoded buffer */\n\n    const char *filename;             /* The file analyzed, if any */\n    const char *directory;            /* the directory/base of the file */\n    const xmlChar *base;              /* Base of the array to parse */\n    const xmlChar *cur;               /* Current char being parsed */\n    const xmlChar *end;               /* end of the array to parse */\n    int length;                       /* length if known */\n    int line;                         /* Current line */\n    int col;                          /* Current column */\n    unsigned long consumed;           /* How many xmlChars already consumed */\n    xmlParserInputDeallocate free;    /* function to deallocate the base */\n    const xmlChar *encoding;          /* the encoding string for entity */\n    const xmlChar *version;           /* the version string for entity */\n    int standalone;                   /* Was that entity marked standalone */\n    int id;                           /* an unique identifier for the entity */\n    unsigned long parentConsumed;     /* consumed bytes from parents */\n    xmlEntityPtr entity;              /* entity, if any */\n};\n\n/**\n * xmlParserNodeInfo:\n *\n * The parser can be asked to collect Node information, i.e. at what\n * place in the file they were detected.\n * NOTE: This is off by default and not very well tested.\n */\ntypedef struct _xmlParserNodeInfo xmlParserNodeInfo;\ntypedef xmlParserNodeInfo *xmlParserNodeInfoPtr;\n\nstruct _xmlParserNodeInfo {\n  const struct _xmlNode* node;\n  /* Position & line # that text that created the node begins & ends on */\n  unsigned long begin_pos;\n  unsigned long begin_line;\n  unsigned long end_pos;\n  unsigned long end_line;\n};\n\ntypedef struct _xmlParserNodeInfoSeq xmlParserNodeInfoSeq;\ntypedef xmlParserNodeInfoSeq *xmlParserNodeInfoSeqPtr;\nstruct _xmlParserNodeInfoSeq {\n  unsigned long maximum;\n  unsigned long length;\n  xmlParserNodeInfo* buffer;\n};\n\n/**\n * xmlParserInputState:\n *\n * The parser is now working also as a state based parser.\n * The recursive one use the state info for entities processing.\n */\ntypedef enum {\n    XML_PARSER_EOF = -1,\t/* nothing is to be parsed */\n    XML_PARSER_START = 0,\t/* nothing has been parsed */\n    XML_PARSER_MISC,\t\t/* Misc* before int subset */\n    XML_PARSER_PI,\t\t/* Within a processing instruction */\n    XML_PARSER_DTD,\t\t/* within some DTD content */\n    XML_PARSER_PROLOG,\t\t/* Misc* after internal subset */\n    XML_PARSER_COMMENT,\t\t/* within a comment */\n    XML_PARSER_START_TAG,\t/* within a start tag */\n    XML_PARSER_CONTENT,\t\t/* within the content */\n    XML_PARSER_CDATA_SECTION,\t/* within a CDATA section */\n    XML_PARSER_END_TAG,\t\t/* within a closing tag */\n    XML_PARSER_ENTITY_DECL,\t/* within an entity declaration */\n    XML_PARSER_ENTITY_VALUE,\t/* within an entity value in a decl */\n    XML_PARSER_ATTRIBUTE_VALUE,\t/* within an attribute value */\n    XML_PARSER_SYSTEM_LITERAL,\t/* within a SYSTEM value */\n    XML_PARSER_EPILOG,\t\t/* the Misc* after the last end tag */\n    XML_PARSER_IGNORE,\t\t/* within an IGNORED section */\n    XML_PARSER_PUBLIC_LITERAL\t/* within a PUBLIC value */\n} xmlParserInputState;\n\n/**\n * XML_DETECT_IDS:\n *\n * Bit in the loadsubset context field to tell to do ID/REFs lookups.\n * Use it to initialize xmlLoadExtDtdDefaultValue.\n */\n#define XML_DETECT_IDS\t\t2\n\n/**\n * XML_COMPLETE_ATTRS:\n *\n * Bit in the loadsubset context field to tell to do complete the\n * elements attributes lists with the ones defaulted from the DTDs.\n * Use it to initialize xmlLoadExtDtdDefaultValue.\n */\n#define XML_COMPLETE_ATTRS\t4\n\n/**\n * XML_SKIP_IDS:\n *\n * Bit in the loadsubset context field to tell to not do ID/REFs registration.\n * Used to initialize xmlLoadExtDtdDefaultValue in some special cases.\n */\n#define XML_SKIP_IDS\t\t8\n\n/**\n * xmlParserMode:\n *\n * A parser can operate in various modes\n */\ntypedef enum {\n    XML_PARSE_UNKNOWN = 0,\n    XML_PARSE_DOM = 1,\n    XML_PARSE_SAX = 2,\n    XML_PARSE_PUSH_DOM = 3,\n    XML_PARSE_PUSH_SAX = 4,\n    XML_PARSE_READER = 5\n} xmlParserMode;\n\ntypedef struct _xmlStartTag xmlStartTag;\n\n/**\n * xmlParserCtxt:\n *\n * The parser context.\n * NOTE This doesn't completely define the parser state, the (current ?)\n *      design of the parser uses recursive function calls since this allow\n *      and easy mapping from the production rules of the specification\n *      to the actual code. The drawback is that the actual function call\n *      also reflect the parser state. However most of the parsing routines\n *      takes as the only argument the parser context pointer, so migrating\n *      to a state based parser for progressive parsing shouldn't be too hard.\n */\nstruct _xmlParserCtxt {\n    struct _xmlSAXHandler *sax;       /* The SAX handler */\n    void            *userData;        /* For SAX interface only, used by DOM build */\n    xmlDocPtr           myDoc;        /* the document being built */\n    int            wellFormed;        /* is the document well formed */\n    int       replaceEntities;        /* shall we replace entities ? */\n    const xmlChar    *version;        /* the XML version string */\n    const xmlChar   *encoding;        /* the declared encoding, if any */\n    int            standalone;        /* standalone document */\n    int                  html;        /* an HTML(1) document\n                                       * 3 is HTML after <head>\n                                       * 10 is HTML after <body>\n                                       */\n\n    /* Input stream stack */\n    xmlParserInputPtr  input;         /* Current input stream */\n    int                inputNr;       /* Number of current input streams */\n    int                inputMax;      /* Max number of input streams */\n    xmlParserInputPtr *inputTab;      /* stack of inputs */\n\n    /* Node analysis stack only used for DOM building */\n    xmlNodePtr         node;          /* Current parsed Node */\n    int                nodeNr;        /* Depth of the parsing stack */\n    int                nodeMax;       /* Max depth of the parsing stack */\n    xmlNodePtr        *nodeTab;       /* array of nodes */\n\n    int record_info;                  /* Whether node info should be kept */\n    xmlParserNodeInfoSeq node_seq;    /* info about each node parsed */\n\n    int errNo;                        /* error code */\n\n    int     hasExternalSubset;        /* reference and external subset */\n    int             hasPErefs;        /* the internal subset has PE refs */\n    int              external;        /* are we parsing an external entity */\n\n    int                 valid;        /* is the document valid */\n    int              validate;        /* shall we try to validate ? */\n    xmlValidCtxt        vctxt;        /* The validity context */\n\n    xmlParserInputState instate;      /* current type of input */\n    int                 token;        /* next char look-ahead */\n\n    char           *directory;        /* the data directory */\n\n    /* Node name stack */\n    const xmlChar     *name;          /* Current parsed Node */\n    int                nameNr;        /* Depth of the parsing stack */\n    int                nameMax;       /* Max depth of the parsing stack */\n    const xmlChar *   *nameTab;       /* array of nodes */\n\n    long               nbChars;       /* unused */\n    long            checkIndex;       /* used by progressive parsing lookup */\n    int             keepBlanks;       /* ugly but ... */\n    int             disableSAX;       /* SAX callbacks are disabled */\n    int               inSubset;       /* Parsing is in int 1/ext 2 subset */\n    const xmlChar *    intSubName;    /* name of subset */\n    xmlChar *          extSubURI;     /* URI of external subset */\n    xmlChar *          extSubSystem;  /* SYSTEM ID of external subset */\n\n    /* xml:space values */\n    int *              space;         /* Should the parser preserve spaces */\n    int                spaceNr;       /* Depth of the parsing stack */\n    int                spaceMax;      /* Max depth of the parsing stack */\n    int *              spaceTab;      /* array of space infos */\n\n    int                depth;         /* to prevent entity substitution loops */\n    xmlParserInputPtr  entity;        /* used to check entities boundaries */\n    int                charset;       /* encoding of the in-memory content\n\t\t\t\t         actually an xmlCharEncoding */\n    int                nodelen;       /* Those two fields are there to */\n    int                nodemem;       /* Speed up large node parsing */\n    int                pedantic;      /* signal pedantic warnings */\n    void              *_private;      /* For user data, libxml won't touch it */\n\n    int                loadsubset;    /* should the external subset be loaded */\n    int                linenumbers;   /* set line number in element content */\n    void              *catalogs;      /* document's own catalog */\n    int                recovery;      /* run in recovery mode */\n    int                progressive;   /* is this a progressive parsing */\n    xmlDictPtr         dict;          /* dictionary for the parser */\n    const xmlChar *   *atts;          /* array for the attributes callbacks */\n    int                maxatts;       /* the size of the array */\n    int                docdict;       /* use strings from dict to build tree */\n\n    /*\n     * pre-interned strings\n     */\n    const xmlChar *str_xml;\n    const xmlChar *str_xmlns;\n    const xmlChar *str_xml_ns;\n\n    /*\n     * Everything below is used only by the new SAX mode\n     */\n    int                sax2;          /* operating in the new SAX mode */\n    int                nsNr;          /* the number of inherited namespaces */\n    int                nsMax;         /* the size of the arrays */\n    const xmlChar *   *nsTab;         /* the array of prefix/namespace name */\n    int               *attallocs;     /* which attribute were allocated */\n    xmlStartTag       *pushTab;       /* array of data for push */\n    xmlHashTablePtr    attsDefault;   /* defaulted attributes if any */\n    xmlHashTablePtr    attsSpecial;   /* non-CDATA attributes if any */\n    int                nsWellFormed;  /* is the document XML Namespace okay */\n    int                options;       /* Extra options */\n\n    /*\n     * Those fields are needed only for streaming parsing so far\n     */\n    int               dictNames;    /* Use dictionary names for the tree */\n    int               freeElemsNr;  /* number of freed element nodes */\n    xmlNodePtr        freeElems;    /* List of freed element nodes */\n    int               freeAttrsNr;  /* number of freed attributes nodes */\n    xmlAttrPtr        freeAttrs;    /* List of freed attributes nodes */\n\n    /*\n     * the complete error information for the last error.\n     */\n    xmlError          lastError;\n    xmlParserMode     parseMode;    /* the parser mode */\n    unsigned long    nbentities;    /* unused */\n    unsigned long  sizeentities;    /* size of parsed entities */\n\n    /* for use by HTML non-recursive parser */\n    xmlParserNodeInfo *nodeInfo;      /* Current NodeInfo */\n    int                nodeInfoNr;    /* Depth of the parsing stack */\n    int                nodeInfoMax;   /* Max depth of the parsing stack */\n    xmlParserNodeInfo *nodeInfoTab;   /* array of nodeInfos */\n\n    int                input_id;      /* we need to label inputs */\n    unsigned long      sizeentcopy;   /* volume of entity copy */\n\n    int           endCheckState;    /* quote state for push parser */\n    unsigned short     nbErrors;    /* number of errors */\n    unsigned short   nbWarnings;    /* number of warnings */\n};\n\n/**\n * xmlSAXLocator:\n *\n * A SAX Locator.\n */\nstruct _xmlSAXLocator {\n    const xmlChar *(*getPublicId)(void *ctx);\n    const xmlChar *(*getSystemId)(void *ctx);\n    int (*getLineNumber)(void *ctx);\n    int (*getColumnNumber)(void *ctx);\n};\n\n/**\n * xmlSAXHandler:\n *\n * A SAX handler is bunch of callbacks called by the parser when processing\n * of the input generate data or structure information.\n */\n\n/**\n * resolveEntitySAXFunc:\n * @ctx:  the user data (XML parser context)\n * @publicId: The public ID of the entity\n * @systemId: The system ID of the entity\n *\n * Callback:\n * The entity loader, to control the loading of external entities,\n * the application can either:\n *    - override this resolveEntity() callback in the SAX block\n *    - or better use the xmlSetExternalEntityLoader() function to\n *      set up it's own entity resolution routine\n *\n * Returns the xmlParserInputPtr if inlined or NULL for DOM behaviour.\n */\ntypedef xmlParserInputPtr (*resolveEntitySAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *publicId,\n\t\t\t\tconst xmlChar *systemId);\n/**\n * internalSubsetSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  the root element name\n * @ExternalID:  the external ID\n * @SystemID:  the SYSTEM ID (e.g. filename or URL)\n *\n * Callback on internal subset declaration.\n */\ntypedef void (*internalSubsetSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *ExternalID,\n\t\t\t\tconst xmlChar *SystemID);\n/**\n * externalSubsetSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  the root element name\n * @ExternalID:  the external ID\n * @SystemID:  the SYSTEM ID (e.g. filename or URL)\n *\n * Callback on external subset declaration.\n */\ntypedef void (*externalSubsetSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *ExternalID,\n\t\t\t\tconst xmlChar *SystemID);\n/**\n * getEntitySAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name: The entity name\n *\n * Get an entity by name.\n *\n * Returns the xmlEntityPtr if found.\n */\ntypedef xmlEntityPtr (*getEntitySAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name);\n/**\n * getParameterEntitySAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name: The entity name\n *\n * Get a parameter entity by name.\n *\n * Returns the xmlEntityPtr if found.\n */\ntypedef xmlEntityPtr (*getParameterEntitySAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name);\n/**\n * entityDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  the entity name\n * @type:  the entity type\n * @publicId: The public ID of the entity\n * @systemId: The system ID of the entity\n * @content: the entity value (without processing).\n *\n * An entity definition has been parsed.\n */\ntypedef void (*entityDeclSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tint type,\n\t\t\t\tconst xmlChar *publicId,\n\t\t\t\tconst xmlChar *systemId,\n\t\t\t\txmlChar *content);\n/**\n * notationDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name: The name of the notation\n * @publicId: The public ID of the entity\n * @systemId: The system ID of the entity\n *\n * What to do when a notation declaration has been parsed.\n */\ntypedef void (*notationDeclSAXFunc)(void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *publicId,\n\t\t\t\tconst xmlChar *systemId);\n/**\n * attributeDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @elem:  the name of the element\n * @fullname:  the attribute name\n * @type:  the attribute type\n * @def:  the type of default value\n * @defaultValue: the attribute default value\n * @tree:  the tree of enumerated value set\n *\n * An attribute definition has been parsed.\n */\ntypedef void (*attributeDeclSAXFunc)(void *ctx,\n\t\t\t\tconst xmlChar *elem,\n\t\t\t\tconst xmlChar *fullname,\n\t\t\t\tint type,\n\t\t\t\tint def,\n\t\t\t\tconst xmlChar *defaultValue,\n\t\t\t\txmlEnumerationPtr tree);\n/**\n * elementDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  the element name\n * @type:  the element type\n * @content: the element value tree\n *\n * An element definition has been parsed.\n */\ntypedef void (*elementDeclSAXFunc)(void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tint type,\n\t\t\t\txmlElementContentPtr content);\n/**\n * unparsedEntityDeclSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name: The name of the entity\n * @publicId: The public ID of the entity\n * @systemId: The system ID of the entity\n * @notationName: the name of the notation\n *\n * What to do when an unparsed entity declaration is parsed.\n */\ntypedef void (*unparsedEntityDeclSAXFunc)(void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *publicId,\n\t\t\t\tconst xmlChar *systemId,\n\t\t\t\tconst xmlChar *notationName);\n/**\n * setDocumentLocatorSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @loc: A SAX Locator\n *\n * Receive the document locator at startup, actually xmlDefaultSAXLocator.\n * Everything is available on the context, so this is useless in our case.\n */\ntypedef void (*setDocumentLocatorSAXFunc) (void *ctx,\n\t\t\t\txmlSAXLocatorPtr loc);\n/**\n * startDocumentSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Called when the document start being processed.\n */\ntypedef void (*startDocumentSAXFunc) (void *ctx);\n/**\n * endDocumentSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Called when the document end has been detected.\n */\ntypedef void (*endDocumentSAXFunc) (void *ctx);\n/**\n * startElementSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  The element name, including namespace prefix\n * @atts:  An array of name/value attributes pairs, NULL terminated\n *\n * Called when an opening tag has been processed.\n */\ntypedef void (*startElementSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar **atts);\n/**\n * endElementSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  The element name\n *\n * Called when the end of an element has been detected.\n */\ntypedef void (*endElementSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name);\n/**\n * attributeSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  The attribute name, including namespace prefix\n * @value:  The attribute value\n *\n * Handle an attribute that has been read by the parser.\n * The default handling is to convert the attribute into an\n * DOM subtree and past it in a new xmlAttr element added to\n * the element.\n */\ntypedef void (*attributeSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name,\n\t\t\t\tconst xmlChar *value);\n/**\n * referenceSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @name:  The entity name\n *\n * Called when an entity reference is detected.\n */\ntypedef void (*referenceSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *name);\n/**\n * charactersSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @ch:  a xmlChar string\n * @len: the number of xmlChar\n *\n * Receiving some chars from the parser.\n */\ntypedef void (*charactersSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *ch,\n\t\t\t\tint len);\n/**\n * ignorableWhitespaceSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @ch:  a xmlChar string\n * @len: the number of xmlChar\n *\n * Receiving some ignorable whitespaces from the parser.\n * UNUSED: by default the DOM building will use characters.\n */\ntypedef void (*ignorableWhitespaceSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *ch,\n\t\t\t\tint len);\n/**\n * processingInstructionSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @target:  the target name\n * @data: the PI data's\n *\n * A processing instruction has been parsed.\n */\ntypedef void (*processingInstructionSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *target,\n\t\t\t\tconst xmlChar *data);\n/**\n * commentSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @value:  the comment content\n *\n * A comment has been parsed.\n */\ntypedef void (*commentSAXFunc) (void *ctx,\n\t\t\t\tconst xmlChar *value);\n/**\n * cdataBlockSAXFunc:\n * @ctx:  the user data (XML parser context)\n * @value:  The pcdata content\n * @len:  the block length\n *\n * Called when a pcdata block has been parsed.\n */\ntypedef void (*cdataBlockSAXFunc) (\n\t                        void *ctx,\n\t\t\t\tconst xmlChar *value,\n\t\t\t\tint len);\n/**\n * warningSAXFunc:\n * @ctx:  an XML parser context\n * @msg:  the message to display/transmit\n * @...:  extra parameters for the message display\n *\n * Display and format a warning messages, callback.\n */\ntypedef void (*warningSAXFunc) (void *ctx,\n\t\t\t\tconst char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n/**\n * errorSAXFunc:\n * @ctx:  an XML parser context\n * @msg:  the message to display/transmit\n * @...:  extra parameters for the message display\n *\n * Display and format an error messages, callback.\n */\ntypedef void (*errorSAXFunc) (void *ctx,\n\t\t\t\tconst char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n/**\n * fatalErrorSAXFunc:\n * @ctx:  an XML parser context\n * @msg:  the message to display/transmit\n * @...:  extra parameters for the message display\n *\n * Display and format fatal error messages, callback.\n * Note: so far fatalError() SAX callbacks are not used, error()\n *       get all the callbacks for errors.\n */\ntypedef void (*fatalErrorSAXFunc) (void *ctx,\n\t\t\t\tconst char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n/**\n * isStandaloneSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Is this document tagged standalone?\n *\n * Returns 1 if true\n */\ntypedef int (*isStandaloneSAXFunc) (void *ctx);\n/**\n * hasInternalSubsetSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Does this document has an internal subset.\n *\n * Returns 1 if true\n */\ntypedef int (*hasInternalSubsetSAXFunc) (void *ctx);\n\n/**\n * hasExternalSubsetSAXFunc:\n * @ctx:  the user data (XML parser context)\n *\n * Does this document has an external subset?\n *\n * Returns 1 if true\n */\ntypedef int (*hasExternalSubsetSAXFunc) (void *ctx);\n\n/************************************************************************\n *\t\t\t\t\t\t\t\t\t*\n *\t\t\tThe SAX version 2 API extensions\t\t*\n *\t\t\t\t\t\t\t\t\t*\n ************************************************************************/\n/**\n * XML_SAX2_MAGIC:\n *\n * Special constant found in SAX2 blocks initialized fields\n */\n#define XML_SAX2_MAGIC 0xDEEDBEAF\n\n/**\n * startElementNsSAX2Func:\n * @ctx:  the user data (XML parser context)\n * @localname:  the local name of the element\n * @prefix:  the element namespace prefix if available\n * @URI:  the element namespace name if available\n * @nb_namespaces:  number of namespace definitions on that node\n * @namespaces:  pointer to the array of prefix/URI pairs namespace definitions\n * @nb_attributes:  the number of attributes on that node\n * @nb_defaulted:  the number of defaulted attributes. The defaulted\n *                  ones are at the end of the array\n * @attributes:  pointer to the array of (localname/prefix/URI/value/end)\n *               attribute values.\n *\n * SAX2 callback when an element start has been detected by the parser.\n * It provides the namespace information for the element, as well as\n * the new namespace declarations on the element.\n */\n\ntypedef void (*startElementNsSAX2Func) (void *ctx,\n\t\t\t\t\tconst xmlChar *localname,\n\t\t\t\t\tconst xmlChar *prefix,\n\t\t\t\t\tconst xmlChar *URI,\n\t\t\t\t\tint nb_namespaces,\n\t\t\t\t\tconst xmlChar **namespaces,\n\t\t\t\t\tint nb_attributes,\n\t\t\t\t\tint nb_defaulted,\n\t\t\t\t\tconst xmlChar **attributes);\n\n/**\n * endElementNsSAX2Func:\n * @ctx:  the user data (XML parser context)\n * @localname:  the local name of the element\n * @prefix:  the element namespace prefix if available\n * @URI:  the element namespace name if available\n *\n * SAX2 callback when an element end has been detected by the parser.\n * It provides the namespace information for the element.\n */\n\ntypedef void (*endElementNsSAX2Func)   (void *ctx,\n\t\t\t\t\tconst xmlChar *localname,\n\t\t\t\t\tconst xmlChar *prefix,\n\t\t\t\t\tconst xmlChar *URI);\n\n\nstruct _xmlSAXHandler {\n    internalSubsetSAXFunc internalSubset;\n    isStandaloneSAXFunc isStandalone;\n    hasInternalSubsetSAXFunc hasInternalSubset;\n    hasExternalSubsetSAXFunc hasExternalSubset;\n    resolveEntitySAXFunc resolveEntity;\n    getEntitySAXFunc getEntity;\n    entityDeclSAXFunc entityDecl;\n    notationDeclSAXFunc notationDecl;\n    attributeDeclSAXFunc attributeDecl;\n    elementDeclSAXFunc elementDecl;\n    unparsedEntityDeclSAXFunc unparsedEntityDecl;\n    setDocumentLocatorSAXFunc setDocumentLocator;\n    startDocumentSAXFunc startDocument;\n    endDocumentSAXFunc endDocument;\n    startElementSAXFunc startElement;\n    endElementSAXFunc endElement;\n    referenceSAXFunc reference;\n    charactersSAXFunc characters;\n    ignorableWhitespaceSAXFunc ignorableWhitespace;\n    processingInstructionSAXFunc processingInstruction;\n    commentSAXFunc comment;\n    warningSAXFunc warning;\n    errorSAXFunc error;\n    fatalErrorSAXFunc fatalError; /* unused error() get all the errors */\n    getParameterEntitySAXFunc getParameterEntity;\n    cdataBlockSAXFunc cdataBlock;\n    externalSubsetSAXFunc externalSubset;\n    unsigned int initialized;\n    /* The following fields are extensions available only on version 2 */\n    void *_private;\n    startElementNsSAX2Func startElementNs;\n    endElementNsSAX2Func endElementNs;\n    xmlStructuredErrorFunc serror;\n};\n\n/*\n * SAX Version 1\n */\ntypedef struct _xmlSAXHandlerV1 xmlSAXHandlerV1;\ntypedef xmlSAXHandlerV1 *xmlSAXHandlerV1Ptr;\nstruct _xmlSAXHandlerV1 {\n    internalSubsetSAXFunc internalSubset;\n    isStandaloneSAXFunc isStandalone;\n    hasInternalSubsetSAXFunc hasInternalSubset;\n    hasExternalSubsetSAXFunc hasExternalSubset;\n    resolveEntitySAXFunc resolveEntity;\n    getEntitySAXFunc getEntity;\n    entityDeclSAXFunc entityDecl;\n    notationDeclSAXFunc notationDecl;\n    attributeDeclSAXFunc attributeDecl;\n    elementDeclSAXFunc elementDecl;\n    unparsedEntityDeclSAXFunc unparsedEntityDecl;\n    setDocumentLocatorSAXFunc setDocumentLocator;\n    startDocumentSAXFunc startDocument;\n    endDocumentSAXFunc endDocument;\n    startElementSAXFunc startElement;\n    endElementSAXFunc endElement;\n    referenceSAXFunc reference;\n    charactersSAXFunc characters;\n    ignorableWhitespaceSAXFunc ignorableWhitespace;\n    processingInstructionSAXFunc processingInstruction;\n    commentSAXFunc comment;\n    warningSAXFunc warning;\n    errorSAXFunc error;\n    fatalErrorSAXFunc fatalError; /* unused error() get all the errors */\n    getParameterEntitySAXFunc getParameterEntity;\n    cdataBlockSAXFunc cdataBlock;\n    externalSubsetSAXFunc externalSubset;\n    unsigned int initialized;\n};\n\n\n/**\n * xmlExternalEntityLoader:\n * @URL: The System ID of the resource requested\n * @ID: The Public ID of the resource requested\n * @context: the XML parser context\n *\n * External entity loaders types.\n *\n * Returns the entity input parser.\n */\ntypedef xmlParserInputPtr (*xmlExternalEntityLoader) (const char *URL,\n\t\t\t\t\t const char *ID,\n\t\t\t\t\t xmlParserCtxtPtr context);\n\n#ifdef __cplusplus\n}\n#endif\n\n#include <libxml/encoding.h>\n#include <libxml/xmlIO.h>\n#include <libxml/globals.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\n/*\n * Init/Cleanup\n */\nXMLPUBFUN void\n\t\txmlInitParser\t\t(void);\nXMLPUBFUN void\n\t\txmlCleanupParser\t(void);\n\n/*\n * Input functions\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlParserInputRead\t(xmlParserInputPtr in,\n\t\t\t\t\t int len);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlParserInputGrow\t(xmlParserInputPtr in,\n\t\t\t\t\t int len);\n\n/*\n * Basic parsing Interfaces\n */\n#ifdef LIBXML_SAX1_ENABLED\nXMLPUBFUN xmlDocPtr\n\t\txmlParseDoc\t\t(const xmlChar *cur);\nXMLPUBFUN xmlDocPtr\n\t\txmlParseFile\t\t(const char *filename);\nXMLPUBFUN xmlDocPtr\n\t\txmlParseMemory\t\t(const char *buffer,\n\t\t\t\t\t int size);\n#endif /* LIBXML_SAX1_ENABLED */\nXMLPUBFUN int\n\t\txmlSubstituteEntitiesDefault(int val);\nXMLPUBFUN int\n\t\txmlKeepBlanksDefault\t(int val);\nXMLPUBFUN void\n\t\txmlStopParser\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlPedanticParserDefault(int val);\nXMLPUBFUN int\n\t\txmlLineNumbersDefault\t(int val);\n\n#ifdef LIBXML_SAX1_ENABLED\n/*\n * Recovery mode\n */\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlRecoverDoc\t\t(const xmlChar *cur);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlRecoverMemory\t(const char *buffer,\n\t\t\t\t\t int size);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlRecoverFile\t\t(const char *filename);\n#endif /* LIBXML_SAX1_ENABLED */\n\n/*\n * Less common routines and SAX interfaces\n */\nXMLPUBFUN int\n\t\txmlParseDocument\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlParseExtParsedEnt\t(xmlParserCtxtPtr ctxt);\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlSAXUserParseFile\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlSAXUserParseMemory\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseDoc\t\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const xmlChar *cur,\n\t\t\t\t\t int recovery);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseMemory\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t int recovery);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseMemoryWithData (xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t int recovery,\n\t\t\t\t\t void *data);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseFile\t\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t int recovery);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseFileWithData\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t int recovery,\n\t\t\t\t\t void *data);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlSAXParseEntity\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const char *filename);\nXML_DEPRECATED\nXMLPUBFUN xmlDocPtr\n\t\txmlParseEntity\t\t(const char *filename);\n#endif /* LIBXML_SAX1_ENABLED */\n\n#ifdef LIBXML_VALID_ENABLED\nXML_DEPRECATED\nXMLPUBFUN xmlDtdPtr\n\t\txmlSAXParseDTD\t\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlDtdPtr\n\t\txmlParseDTD\t\t(const xmlChar *ExternalID,\n\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlDtdPtr\n\t\txmlIOParseDTD\t\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t xmlParserInputBufferPtr input,\n\t\t\t\t\t xmlCharEncoding enc);\n#endif /* LIBXML_VALID_ENABLE */\n#ifdef LIBXML_SAX1_ENABLED\nXMLPUBFUN int\n\t\txmlParseBalancedChunkMemory(xmlDocPtr doc,\n\t\t\t\t\t xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t int depth,\n\t\t\t\t\t const xmlChar *string,\n\t\t\t\t\t xmlNodePtr *lst);\n#endif /* LIBXML_SAX1_ENABLED */\nXMLPUBFUN xmlParserErrors\n\t\txmlParseInNodeContext\t(xmlNodePtr node,\n\t\t\t\t\t const char *data,\n\t\t\t\t\t int datalen,\n\t\t\t\t\t int options,\n\t\t\t\t\t xmlNodePtr *lst);\n#ifdef LIBXML_SAX1_ENABLED\nXMLPUBFUN int\n\t\txmlParseBalancedChunkMemoryRecover(xmlDocPtr doc,\n                     xmlSAXHandlerPtr sax,\n                     void *user_data,\n                     int depth,\n                     const xmlChar *string,\n                     xmlNodePtr *lst,\n                     int recover);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlParseExternalEntity\t(xmlDocPtr doc,\n\t\t\t\t\t xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t int depth,\n\t\t\t\t\t const xmlChar *URL,\n\t\t\t\t\t const xmlChar *ID,\n\t\t\t\t\t xmlNodePtr *lst);\n#endif /* LIBXML_SAX1_ENABLED */\nXMLPUBFUN int\n\t\txmlParseCtxtExternalEntity(xmlParserCtxtPtr ctx,\n\t\t\t\t\t const xmlChar *URL,\n\t\t\t\t\t const xmlChar *ID,\n\t\t\t\t\t xmlNodePtr *lst);\n\n/*\n * Parser contexts handling.\n */\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlNewParserCtxt\t(void);\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlNewSAXParserCtxt\t(const xmlSAXHandler *sax,\n\t\t\t\t\t void *userData);\nXMLPUBFUN int\n\t\txmlInitParserCtxt\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\txmlClearParserCtxt\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\txmlFreeParserCtxt\t(xmlParserCtxtPtr ctxt);\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlSetupParserForBuffer\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar* buffer,\n\t\t\t\t\t const char *filename);\n#endif /* LIBXML_SAX1_ENABLED */\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlCreateDocParserCtxt\t(const xmlChar *cur);\n\n#ifdef LIBXML_LEGACY_ENABLED\n/*\n * Reading/setting optional parsing features.\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlGetFeaturesList\t(int *len,\n\t\t\t\t\t const char **result);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlGetFeature\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *name,\n\t\t\t\t\t void *result);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlSetFeature\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *name,\n\t\t\t\t\t void *value);\n#endif /* LIBXML_LEGACY_ENABLED */\n\n#ifdef LIBXML_PUSH_ENABLED\n/*\n * Interfaces for the Push mode.\n */\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlCreatePushParserCtxt(xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t const char *chunk,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *filename);\nXMLPUBFUN int\n\t\txmlParseChunk\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *chunk,\n\t\t\t\t\t int size,\n\t\t\t\t\t int terminate);\n#endif /* LIBXML_PUSH_ENABLED */\n\n/*\n * Special I/O mode.\n */\n\nXMLPUBFUN xmlParserCtxtPtr\n\t\txmlCreateIOParserCtxt\t(xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data,\n\t\t\t\t\t xmlInputReadCallback   ioread,\n\t\t\t\t\t xmlInputCloseCallback  ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t xmlCharEncoding enc);\n\nXMLPUBFUN xmlParserInputPtr\n\t\txmlNewIOInputStream\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlParserInputBufferPtr input,\n\t\t\t\t\t xmlCharEncoding enc);\n\n/*\n * Node infos.\n */\nXMLPUBFUN const xmlParserNodeInfo*\n\t\txmlParserFindNodeInfo\t(const xmlParserCtxtPtr ctxt,\n\t\t\t\t         const xmlNodePtr node);\nXMLPUBFUN void\n\t\txmlInitNodeInfoSeq\t(xmlParserNodeInfoSeqPtr seq);\nXMLPUBFUN void\n\t\txmlClearNodeInfoSeq\t(xmlParserNodeInfoSeqPtr seq);\nXMLPUBFUN unsigned long\n\t\txmlParserFindNodeInfoIndex(const xmlParserNodeInfoSeqPtr seq,\n                                         const xmlNodePtr node);\nXMLPUBFUN void\n\t\txmlParserAddNodeInfo\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlParserNodeInfoPtr info);\n\n/*\n * External entities handling actually implemented in xmlIO.\n */\n\nXMLPUBFUN void\n\t\txmlSetExternalEntityLoader(xmlExternalEntityLoader f);\nXMLPUBFUN xmlExternalEntityLoader\n\t\txmlGetExternalEntityLoader(void);\nXMLPUBFUN xmlParserInputPtr\n\t\txmlLoadExternalEntity\t(const char *URL,\n\t\t\t\t\t const char *ID,\n\t\t\t\t\t xmlParserCtxtPtr ctxt);\n\n/*\n * Index lookup, actually implemented in the encoding module\n */\nXMLPUBFUN long\n\t\txmlByteConsumed\t\t(xmlParserCtxtPtr ctxt);\n\n/*\n * New set of simpler/more flexible APIs\n */\n/**\n * xmlParserOption:\n *\n * This is the set of XML parser options that can be passed down\n * to the xmlReadDoc() and similar calls.\n */\ntypedef enum {\n    XML_PARSE_RECOVER\t= 1<<0,\t/* recover on errors */\n    XML_PARSE_NOENT\t= 1<<1,\t/* substitute entities */\n    XML_PARSE_DTDLOAD\t= 1<<2,\t/* load the external subset */\n    XML_PARSE_DTDATTR\t= 1<<3,\t/* default DTD attributes */\n    XML_PARSE_DTDVALID\t= 1<<4,\t/* validate with the DTD */\n    XML_PARSE_NOERROR\t= 1<<5,\t/* suppress error reports */\n    XML_PARSE_NOWARNING\t= 1<<6,\t/* suppress warning reports */\n    XML_PARSE_PEDANTIC\t= 1<<7,\t/* pedantic error reporting */\n    XML_PARSE_NOBLANKS\t= 1<<8,\t/* remove blank nodes */\n    XML_PARSE_SAX1\t= 1<<9,\t/* use the SAX1 interface internally */\n    XML_PARSE_XINCLUDE\t= 1<<10,/* Implement XInclude substitution  */\n    XML_PARSE_NONET\t= 1<<11,/* Forbid network access */\n    XML_PARSE_NODICT\t= 1<<12,/* Do not reuse the context dictionary */\n    XML_PARSE_NSCLEAN\t= 1<<13,/* remove redundant namespaces declarations */\n    XML_PARSE_NOCDATA\t= 1<<14,/* merge CDATA as text nodes */\n    XML_PARSE_NOXINCNODE= 1<<15,/* do not generate XINCLUDE START/END nodes */\n    XML_PARSE_COMPACT   = 1<<16,/* compact small text nodes; no modification of\n                                   the tree allowed afterwards (will possibly\n\t\t\t\t   crash if you try to modify the tree) */\n    XML_PARSE_OLD10\t= 1<<17,/* parse using XML-1.0 before update 5 */\n    XML_PARSE_NOBASEFIX = 1<<18,/* do not fixup XINCLUDE xml:base uris */\n    XML_PARSE_HUGE      = 1<<19,/* relax any hardcoded limit from the parser */\n    XML_PARSE_OLDSAX    = 1<<20,/* parse using SAX2 interface before 2.7.0 */\n    XML_PARSE_IGNORE_ENC= 1<<21,/* ignore internal document encoding hint */\n    XML_PARSE_BIG_LINES = 1<<22 /* Store big lines numbers in text PSVI field */\n} xmlParserOption;\n\nXMLPUBFUN void\n\t\txmlCtxtReset\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlCtxtResetPush\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *chunk,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN int\n\t\txmlCtxtUseOptions\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadDoc\t\t(const xmlChar *cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadFile\t\t(const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadMemory\t\t(const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadFd\t\t(int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlReadIO\t\t(xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadDoc\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadFile\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadMemory\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadFd\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlDocPtr\n\t\txmlCtxtReadIO\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\n/*\n * Library wide options\n */\n/**\n * xmlFeature:\n *\n * Used to examine the existence of features that can be enabled\n * or disabled at compile-time.\n * They used to be called XML_FEATURE_xxx but this clashed with Expat\n */\ntypedef enum {\n    XML_WITH_THREAD = 1,\n    XML_WITH_TREE = 2,\n    XML_WITH_OUTPUT = 3,\n    XML_WITH_PUSH = 4,\n    XML_WITH_READER = 5,\n    XML_WITH_PATTERN = 6,\n    XML_WITH_WRITER = 7,\n    XML_WITH_SAX1 = 8,\n    XML_WITH_FTP = 9,\n    XML_WITH_HTTP = 10,\n    XML_WITH_VALID = 11,\n    XML_WITH_HTML = 12,\n    XML_WITH_LEGACY = 13,\n    XML_WITH_C14N = 14,\n    XML_WITH_CATALOG = 15,\n    XML_WITH_XPATH = 16,\n    XML_WITH_XPTR = 17,\n    XML_WITH_XINCLUDE = 18,\n    XML_WITH_ICONV = 19,\n    XML_WITH_ISO8859X = 20,\n    XML_WITH_UNICODE = 21,\n    XML_WITH_REGEXP = 22,\n    XML_WITH_AUTOMATA = 23,\n    XML_WITH_EXPR = 24,\n    XML_WITH_SCHEMAS = 25,\n    XML_WITH_SCHEMATRON = 26,\n    XML_WITH_MODULES = 27,\n    XML_WITH_DEBUG = 28,\n    XML_WITH_DEBUG_MEM = 29,\n    XML_WITH_DEBUG_RUN = 30,\n    XML_WITH_ZLIB = 31,\n    XML_WITH_ICU = 32,\n    XML_WITH_LZMA = 33,\n    XML_WITH_NONE = 99999 /* just to be sure of allocation size */\n} xmlFeature;\n\nXMLPUBFUN int\n\t\txmlHasFeature\t\t(xmlFeature feature);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_PARSER_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/parserInternals.h",
    "content": "/*\n * Summary: internals routines and limits exported by the parser.\n * Description: this module exports a number of internal parsing routines\n *              they are not really all intended for applications but\n *              can prove useful doing low level processing.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_PARSER_INTERNALS_H__\n#define __XML_PARSER_INTERNALS_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/parser.h>\n#include <libxml/HTMLparser.h>\n#include <libxml/chvalid.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlParserMaxDepth:\n *\n * arbitrary depth limit for the XML documents that we allow to\n * process. This is not a limitation of the parser but a safety\n * boundary feature, use XML_PARSE_HUGE option to override it.\n */\nXMLPUBVAR unsigned int xmlParserMaxDepth;\n\n/**\n * XML_MAX_TEXT_LENGTH:\n *\n * Maximum size allowed for a single text node when building a tree.\n * This is not a limitation of the parser but a safety boundary feature,\n * use XML_PARSE_HUGE option to override it.\n * Introduced in 2.9.0\n */\n#define XML_MAX_TEXT_LENGTH 10000000\n\n/**\n * XML_MAX_HUGE_LENGTH:\n *\n * Maximum size allowed when XML_PARSE_HUGE is set.\n */\n#define XML_MAX_HUGE_LENGTH 1000000000\n\n/**\n * XML_MAX_NAME_LENGTH:\n *\n * Maximum size allowed for a markup identifier.\n * This is not a limitation of the parser but a safety boundary feature,\n * use XML_PARSE_HUGE option to override it.\n * Note that with the use of parsing dictionaries overriding the limit\n * may result in more runtime memory usage in face of \"unfriendly' content\n * Introduced in 2.9.0\n */\n#define XML_MAX_NAME_LENGTH 50000\n\n/**\n * XML_MAX_DICTIONARY_LIMIT:\n *\n * Maximum size allowed by the parser for a dictionary by default\n * This is not a limitation of the parser but a safety boundary feature,\n * use XML_PARSE_HUGE option to override it.\n * Introduced in 2.9.0\n */\n#define XML_MAX_DICTIONARY_LIMIT 10000000\n\n/**\n * XML_MAX_LOOKUP_LIMIT:\n *\n * Maximum size allowed by the parser for ahead lookup\n * This is an upper boundary enforced by the parser to avoid bad\n * behaviour on \"unfriendly' content\n * Introduced in 2.9.0\n */\n#define XML_MAX_LOOKUP_LIMIT 10000000\n\n/**\n * XML_MAX_NAMELEN:\n *\n * Identifiers can be longer, but this will be more costly\n * at runtime.\n */\n#define XML_MAX_NAMELEN 100\n\n/**\n * INPUT_CHUNK:\n *\n * The parser tries to always have that amount of input ready.\n * One of the point is providing context when reporting errors.\n */\n#define INPUT_CHUNK\t250\n\n/************************************************************************\n *\t\t\t\t\t\t\t\t\t*\n * UNICODE version of the macros.\t\t\t\t\t*\n *\t\t\t\t\t\t\t\t\t*\n ************************************************************************/\n/**\n * IS_BYTE_CHAR:\n * @c:  an byte value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [2] Char ::= #x9 | #xA | #xD | [#x20...]\n * any byte character in the accepted range\n */\n#define IS_BYTE_CHAR(c)\t xmlIsChar_ch(c)\n\n/**\n * IS_CHAR:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [2] Char ::= #x9 | #xA | #xD | [#x20-#xD7FF] | [#xE000-#xFFFD]\n *                  | [#x10000-#x10FFFF]\n * any Unicode character, excluding the surrogate blocks, FFFE, and FFFF.\n */\n#define IS_CHAR(c)   xmlIsCharQ(c)\n\n/**\n * IS_CHAR_CH:\n * @c: an xmlChar (usually an unsigned char)\n *\n * Behaves like IS_CHAR on single-byte value\n */\n#define IS_CHAR_CH(c)  xmlIsChar_ch(c)\n\n/**\n * IS_BLANK:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [3] S ::= (#x20 | #x9 | #xD | #xA)+\n */\n#define IS_BLANK(c)  xmlIsBlankQ(c)\n\n/**\n * IS_BLANK_CH:\n * @c:  an xmlChar value (normally unsigned char)\n *\n * Behaviour same as IS_BLANK\n */\n#define IS_BLANK_CH(c)  xmlIsBlank_ch(c)\n\n/**\n * IS_BASECHAR:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [85] BaseChar ::= ... long list see REC ...\n */\n#define IS_BASECHAR(c) xmlIsBaseCharQ(c)\n\n/**\n * IS_DIGIT:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [88] Digit ::= ... long list see REC ...\n */\n#define IS_DIGIT(c) xmlIsDigitQ(c)\n\n/**\n * IS_DIGIT_CH:\n * @c:  an xmlChar value (usually an unsigned char)\n *\n * Behaves like IS_DIGIT but with a single byte argument\n */\n#define IS_DIGIT_CH(c)  xmlIsDigit_ch(c)\n\n/**\n * IS_COMBINING:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n * [87] CombiningChar ::= ... long list see REC ...\n */\n#define IS_COMBINING(c) xmlIsCombiningQ(c)\n\n/**\n * IS_COMBINING_CH:\n * @c:  an xmlChar (usually an unsigned char)\n *\n * Always false (all combining chars > 0xff)\n */\n#define IS_COMBINING_CH(c) 0\n\n/**\n * IS_EXTENDER:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n *\n * [89] Extender ::= #x00B7 | #x02D0 | #x02D1 | #x0387 | #x0640 |\n *                   #x0E46 | #x0EC6 | #x3005 | [#x3031-#x3035] |\n *                   [#x309D-#x309E] | [#x30FC-#x30FE]\n */\n#define IS_EXTENDER(c) xmlIsExtenderQ(c)\n\n/**\n * IS_EXTENDER_CH:\n * @c:  an xmlChar value (usually an unsigned char)\n *\n * Behaves like IS_EXTENDER but with a single-byte argument\n */\n#define IS_EXTENDER_CH(c)  xmlIsExtender_ch(c)\n\n/**\n * IS_IDEOGRAPHIC:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n *\n * [86] Ideographic ::= [#x4E00-#x9FA5] | #x3007 | [#x3021-#x3029]\n */\n#define IS_IDEOGRAPHIC(c) xmlIsIdeographicQ(c)\n\n/**\n * IS_LETTER:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n *\n * [84] Letter ::= BaseChar | Ideographic\n */\n#define IS_LETTER(c) (IS_BASECHAR(c) || IS_IDEOGRAPHIC(c))\n\n/**\n * IS_LETTER_CH:\n * @c:  an xmlChar value (normally unsigned char)\n *\n * Macro behaves like IS_LETTER, but only check base chars\n *\n */\n#define IS_LETTER_CH(c) xmlIsBaseChar_ch(c)\n\n/**\n * IS_ASCII_LETTER:\n * @c: an xmlChar value\n *\n * Macro to check [a-zA-Z]\n *\n */\n#define IS_ASCII_LETTER(c)\t(((0x41 <= (c)) && ((c) <= 0x5a)) || \\\n\t\t\t\t ((0x61 <= (c)) && ((c) <= 0x7a)))\n\n/**\n * IS_ASCII_DIGIT:\n * @c: an xmlChar value\n *\n * Macro to check [0-9]\n *\n */\n#define IS_ASCII_DIGIT(c)\t((0x30 <= (c)) && ((c) <= 0x39))\n\n/**\n * IS_PUBIDCHAR:\n * @c:  an UNICODE value (int)\n *\n * Macro to check the following production in the XML spec:\n *\n *\n * [13] PubidChar ::= #x20 | #xD | #xA | [a-zA-Z0-9] | [-'()+,./:=?;!*#@$_%]\n */\n#define IS_PUBIDCHAR(c)\txmlIsPubidCharQ(c)\n\n/**\n * IS_PUBIDCHAR_CH:\n * @c:  an xmlChar value (normally unsigned char)\n *\n * Same as IS_PUBIDCHAR but for single-byte value\n */\n#define IS_PUBIDCHAR_CH(c) xmlIsPubidChar_ch(c)\n\n/**\n * Global variables used for predefined strings.\n */\nXMLPUBVAR const xmlChar xmlStringText[];\nXMLPUBVAR const xmlChar xmlStringTextNoenc[];\nXMLPUBVAR const xmlChar xmlStringComment[];\n\n/*\n * Function to finish the work of the macros where needed.\n */\nXMLPUBFUN int                   xmlIsLetter     (int c);\n\n/**\n * Parser context.\n */\nXMLPUBFUN xmlParserCtxtPtr\n\t\t\txmlCreateFileParserCtxt\t(const char *filename);\nXMLPUBFUN xmlParserCtxtPtr\n\t\t\txmlCreateURLParserCtxt\t(const char *filename,\n\t\t\t\t\t\t int options);\nXMLPUBFUN xmlParserCtxtPtr\n\t\t\txmlCreateMemoryParserCtxt(const char *buffer,\n\t\t\t\t\t\t int size);\nXMLPUBFUN xmlParserCtxtPtr\n\t\t\txmlCreateEntityParserCtxt(const xmlChar *URL,\n\t\t\t\t\t\t const xmlChar *ID,\n\t\t\t\t\t\t const xmlChar *base);\nXMLPUBFUN int\n\t\t\txmlSwitchEncoding\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlCharEncoding enc);\nXMLPUBFUN int\n\t\t\txmlSwitchToEncoding\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlCharEncodingHandlerPtr handler);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlSwitchInputEncoding\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlParserInputPtr input,\n\t\t\t\t\t xmlCharEncodingHandlerPtr handler);\n\n/**\n * Input Streams.\n */\nXMLPUBFUN xmlParserInputPtr\n\t\t\txmlNewStringInputStream\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *buffer);\nXML_DEPRECATED\nXMLPUBFUN xmlParserInputPtr\n\t\t\txmlNewEntityInputStream\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlEntityPtr entity);\nXMLPUBFUN int\n\t\t\txmlPushInput\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlParserInputPtr input);\nXMLPUBFUN xmlChar\n\t\t\txmlPopInput\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t\txmlFreeInputStream\t(xmlParserInputPtr input);\nXMLPUBFUN xmlParserInputPtr\n\t\t\txmlNewInputFromFile\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const char *filename);\nXMLPUBFUN xmlParserInputPtr\n\t\t\txmlNewInputStream\t(xmlParserCtxtPtr ctxt);\n\n/**\n * Namespaces.\n */\nXMLPUBFUN xmlChar *\n\t\t\txmlSplitQName\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t xmlChar **prefix);\n\n/**\n * Generic production rules.\n */\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParseName\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseNmtoken\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseEntityValue\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **orig);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseAttValue\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseSystemLiteral\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParsePubidLiteral\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseCharData\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int cdata);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseExternalID\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **publicID,\n\t\t\t\t\t\t int strict);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseComment\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParsePITarget\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParsePI\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseNotationDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseEntityDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseDefaultDecl\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **value);\nXML_DEPRECATED\nXMLPUBFUN xmlEnumerationPtr\n\t\t\txmlParseNotationType\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlEnumerationPtr\n\t\t\txmlParseEnumerationType\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseEnumeratedType\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlEnumerationPtr *tree);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseAttributeType\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlEnumerationPtr *tree);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseAttributeListDecl(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlElementContentPtr\n\t\t\txmlParseElementMixedContentDecl\n\t\t\t\t\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int inputchk);\nXML_DEPRECATED\nXMLPUBFUN xmlElementContentPtr\n\t\t\txmlParseElementChildrenContentDecl\n\t\t\t\t\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int inputchk);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseElementContentDecl(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t xmlElementContentPtr *result);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseElementDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseMarkupDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseCharRef\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlEntityPtr\n\t\t\txmlParseEntityRef\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseReference\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParsePEReference\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseDocTypeDecl\t(xmlParserCtxtPtr ctxt);\n#ifdef LIBXML_SAX1_ENABLED\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParseAttribute\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **value);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParseStartTag\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseEndTag\t\t(xmlParserCtxtPtr ctxt);\n#endif /* LIBXML_SAX1_ENABLED */\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseCDSect\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t\txmlParseContent\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseElement\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseVersionNum\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseVersionInfo\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseEncName\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\n\t\t\txmlParseEncodingDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlParseSDDecl\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseXMLDecl\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseTextDecl\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlParseMisc\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t\txmlParseExternalSubset\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t\t const xmlChar *SystemID);\n/**\n * XML_SUBSTITUTE_NONE:\n *\n * If no entities need to be substituted.\n */\n#define XML_SUBSTITUTE_NONE\t0\n/**\n * XML_SUBSTITUTE_REF:\n *\n * Whether general entities need to be substituted.\n */\n#define XML_SUBSTITUTE_REF\t1\n/**\n * XML_SUBSTITUTE_PEREF:\n *\n * Whether parameter entities need to be substituted.\n */\n#define XML_SUBSTITUTE_PEREF\t2\n/**\n * XML_SUBSTITUTE_BOTH:\n *\n * Both general and parameter entities need to be substituted.\n */\n#define XML_SUBSTITUTE_BOTH\t3\n\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\txmlStringDecodeEntities\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t\t int what,\n\t\t\t\t\t\t xmlChar end,\n\t\t\t\t\t\t xmlChar  end2,\n\t\t\t\t\t\t xmlChar end3);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\txmlStringLenDecodeEntities\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t\t int len,\n\t\t\t\t\t\t int what,\n\t\t\t\t\t\t xmlChar end,\n\t\t\t\t\t\t xmlChar  end2,\n\t\t\t\t\t\t xmlChar end3);\n\n/*\n * Generated by MACROS on top of parser.c c.f. PUSH_AND_POP.\n */\nXML_DEPRECATED\nXMLPUBFUN int\t\t\tnodePush\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlNodePtr value);\nXML_DEPRECATED\nXMLPUBFUN xmlNodePtr\t\tnodePop\t\t\t(xmlParserCtxtPtr ctxt);\nXMLPUBFUN int\t\t\tinputPush\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlParserInputPtr value);\nXMLPUBFUN xmlParserInputPtr\tinputPop\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN const xmlChar *\tnamePop\t\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\t\t\tnamePush\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *value);\n\n/*\n * other commodities shared between parser.c and parserInternals.\n */\nXML_DEPRECATED\nXMLPUBFUN int\t\t\txmlSkipBlankChars\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\t\t\txmlStringCurrentChar\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *cur,\n\t\t\t\t\t\t int *len);\nXML_DEPRECATED\nXMLPUBFUN void\t\t\txmlParserHandlePEReference(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN int\t\t\txmlCheckLanguageID\t(const xmlChar *lang);\n\n/*\n * Really core function shared with HTML parser.\n */\nXML_DEPRECATED\nXMLPUBFUN int\t\t\txmlCurrentChar\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int *len);\nXMLPUBFUN int\t\txmlCopyCharMultiByte\t(xmlChar *out,\n\t\t\t\t\t\t int val);\nXMLPUBFUN int\t\t\txmlCopyChar\t\t(int len,\n\t\t\t\t\t\t xmlChar *out,\n\t\t\t\t\t\t int val);\nXML_DEPRECATED\nXMLPUBFUN void\t\t\txmlNextChar\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\t\t\txmlParserInputShrink\t(xmlParserInputPtr in);\n\n/*\n * Specific function to keep track of entities references\n * and used by the XSLT debugger.\n */\n#ifdef LIBXML_LEGACY_ENABLED\n/**\n * xmlEntityReferenceFunc:\n * @ent: the entity\n * @firstNode:  the fist node in the chunk\n * @lastNode:  the last nod in the chunk\n *\n * Callback function used when one needs to be able to track back the\n * provenance of a chunk of nodes inherited from an entity replacement.\n */\ntypedef\tvoid\t(*xmlEntityReferenceFunc)\t(xmlEntityPtr ent,\n\t\t\t\t\t\t xmlNodePtr firstNode,\n\t\t\t\t\t\t xmlNodePtr lastNode);\n\nXML_DEPRECATED\nXMLPUBFUN void\t\txmlSetEntityReferenceFunc\t(xmlEntityReferenceFunc func);\n\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlParseQuotedString\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\n                        xmlParseNamespace       (xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlNamespaceParseNSDef\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlScanName\t\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlNamespaceParseNCName\t(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN void\txmlParserHandleReference(xmlParserCtxtPtr ctxt);\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\t\txmlNamespaceParseQName\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlChar **prefix);\n/**\n * Entities\n */\nXML_DEPRECATED\nXMLPUBFUN xmlChar *\n\t\txmlDecodeEntities\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t int len,\n\t\t\t\t\t\t int what,\n\t\t\t\t\t\t xmlChar end,\n\t\t\t\t\t\t xmlChar  end2,\n\t\t\t\t\t\t xmlChar end3);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlHandleEntity\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t\t xmlEntityPtr entity);\n\n#endif /* LIBXML_LEGACY_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_PARSER_INTERNALS_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/pattern.h",
    "content": "/*\n * Summary: pattern expression handling\n * Description: allows to compile and test pattern expressions for nodes\n *              either in a tree or based on a parser state.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_PATTERN_H__\n#define __XML_PATTERN_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/dict.h>\n\n#ifdef LIBXML_PATTERN_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlPattern:\n *\n * A compiled (XPath based) pattern to select nodes\n */\ntypedef struct _xmlPattern xmlPattern;\ntypedef xmlPattern *xmlPatternPtr;\n\n/**\n * xmlPatternFlags:\n *\n * This is the set of options affecting the behaviour of pattern\n * matching with this module\n *\n */\ntypedef enum {\n    XML_PATTERN_DEFAULT\t\t= 0,\t/* simple pattern match */\n    XML_PATTERN_XPATH\t\t= 1<<0,\t/* standard XPath pattern */\n    XML_PATTERN_XSSEL\t\t= 1<<1,\t/* XPath subset for schema selector */\n    XML_PATTERN_XSFIELD\t\t= 1<<2\t/* XPath subset for schema field */\n} xmlPatternFlags;\n\nXMLPUBFUN void\n\t\t\txmlFreePattern\t\t(xmlPatternPtr comp);\n\nXMLPUBFUN void\n\t\t\txmlFreePatternList\t(xmlPatternPtr comp);\n\nXMLPUBFUN xmlPatternPtr\n\t\t\txmlPatterncompile\t(const xmlChar *pattern,\n\t\t\t\t\t\t xmlDict *dict,\n\t\t\t\t\t\t int flags,\n\t\t\t\t\t\t const xmlChar **namespaces);\nXMLPUBFUN int\n\t\t\txmlPatternMatch\t\t(xmlPatternPtr comp,\n\t\t\t\t\t\t xmlNodePtr node);\n\n/* streaming interfaces */\ntypedef struct _xmlStreamCtxt xmlStreamCtxt;\ntypedef xmlStreamCtxt *xmlStreamCtxtPtr;\n\nXMLPUBFUN int\n\t\t\txmlPatternStreamable\t(xmlPatternPtr comp);\nXMLPUBFUN int\n\t\t\txmlPatternMaxDepth\t(xmlPatternPtr comp);\nXMLPUBFUN int\n\t\t\txmlPatternMinDepth\t(xmlPatternPtr comp);\nXMLPUBFUN int\n\t\t\txmlPatternFromRoot\t(xmlPatternPtr comp);\nXMLPUBFUN xmlStreamCtxtPtr\n\t\t\txmlPatternGetStreamCtxt\t(xmlPatternPtr comp);\nXMLPUBFUN void\n\t\t\txmlFreeStreamCtxt\t(xmlStreamCtxtPtr stream);\nXMLPUBFUN int\n\t\t\txmlStreamPushNode\t(xmlStreamCtxtPtr stream,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns,\n\t\t\t\t\t\t int nodeType);\nXMLPUBFUN int\n\t\t\txmlStreamPush\t\t(xmlStreamCtxtPtr stream,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns);\nXMLPUBFUN int\n\t\t\txmlStreamPushAttr\t(xmlStreamCtxtPtr stream,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns);\nXMLPUBFUN int\n\t\t\txmlStreamPop\t\t(xmlStreamCtxtPtr stream);\nXMLPUBFUN int\n\t\t\txmlStreamWantsAnyNode\t(xmlStreamCtxtPtr stream);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_PATTERN_ENABLED */\n\n#endif /* __XML_PATTERN_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/relaxng.h",
    "content": "/*\n * Summary: implementation of the Relax-NG validation\n * Description: implementation of the Relax-NG validation\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_RELAX_NG__\n#define __XML_RELAX_NG__\n\n#include <libxml/xmlversion.h>\n#include <libxml/hash.h>\n#include <libxml/xmlstring.h>\n\n#ifdef LIBXML_SCHEMAS_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef struct _xmlRelaxNG xmlRelaxNG;\ntypedef xmlRelaxNG *xmlRelaxNGPtr;\n\n\n/**\n * xmlRelaxNGValidityErrorFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of an error callback from a Relax-NG validation\n */\ntypedef void (*xmlRelaxNGValidityErrorFunc) (void *ctx,\n\t\t\t\t\t\t      const char *msg,\n\t\t\t\t\t\t      ...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * xmlRelaxNGValidityWarningFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of a warning callback from a Relax-NG validation\n */\ntypedef void (*xmlRelaxNGValidityWarningFunc) (void *ctx,\n\t\t\t\t\t\t\tconst char *msg,\n\t\t\t\t\t\t\t...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * A schemas validation context\n */\ntypedef struct _xmlRelaxNGParserCtxt xmlRelaxNGParserCtxt;\ntypedef xmlRelaxNGParserCtxt *xmlRelaxNGParserCtxtPtr;\n\ntypedef struct _xmlRelaxNGValidCtxt xmlRelaxNGValidCtxt;\ntypedef xmlRelaxNGValidCtxt *xmlRelaxNGValidCtxtPtr;\n\n/*\n * xmlRelaxNGValidErr:\n *\n * List of possible Relax NG validation errors\n */\ntypedef enum {\n    XML_RELAXNG_OK = 0,\n    XML_RELAXNG_ERR_MEMORY,\n    XML_RELAXNG_ERR_TYPE,\n    XML_RELAXNG_ERR_TYPEVAL,\n    XML_RELAXNG_ERR_DUPID,\n    XML_RELAXNG_ERR_TYPECMP,\n    XML_RELAXNG_ERR_NOSTATE,\n    XML_RELAXNG_ERR_NODEFINE,\n    XML_RELAXNG_ERR_LISTEXTRA,\n    XML_RELAXNG_ERR_LISTEMPTY,\n    XML_RELAXNG_ERR_INTERNODATA,\n    XML_RELAXNG_ERR_INTERSEQ,\n    XML_RELAXNG_ERR_INTEREXTRA,\n    XML_RELAXNG_ERR_ELEMNAME,\n    XML_RELAXNG_ERR_ATTRNAME,\n    XML_RELAXNG_ERR_ELEMNONS,\n    XML_RELAXNG_ERR_ATTRNONS,\n    XML_RELAXNG_ERR_ELEMWRONGNS,\n    XML_RELAXNG_ERR_ATTRWRONGNS,\n    XML_RELAXNG_ERR_ELEMEXTRANS,\n    XML_RELAXNG_ERR_ATTREXTRANS,\n    XML_RELAXNG_ERR_ELEMNOTEMPTY,\n    XML_RELAXNG_ERR_NOELEM,\n    XML_RELAXNG_ERR_NOTELEM,\n    XML_RELAXNG_ERR_ATTRVALID,\n    XML_RELAXNG_ERR_CONTENTVALID,\n    XML_RELAXNG_ERR_EXTRACONTENT,\n    XML_RELAXNG_ERR_INVALIDATTR,\n    XML_RELAXNG_ERR_DATAELEM,\n    XML_RELAXNG_ERR_VALELEM,\n    XML_RELAXNG_ERR_LISTELEM,\n    XML_RELAXNG_ERR_DATATYPE,\n    XML_RELAXNG_ERR_VALUE,\n    XML_RELAXNG_ERR_LIST,\n    XML_RELAXNG_ERR_NOGRAMMAR,\n    XML_RELAXNG_ERR_EXTRADATA,\n    XML_RELAXNG_ERR_LACKDATA,\n    XML_RELAXNG_ERR_INTERNAL,\n    XML_RELAXNG_ERR_ELEMWRONG,\n    XML_RELAXNG_ERR_TEXTWRONG\n} xmlRelaxNGValidErr;\n\n/*\n * xmlRelaxNGParserFlags:\n *\n * List of possible Relax NG Parser flags\n */\ntypedef enum {\n    XML_RELAXNGP_NONE = 0,\n    XML_RELAXNGP_FREE_DOC = 1,\n    XML_RELAXNGP_CRNG = 2\n} xmlRelaxNGParserFlag;\n\nXMLPUBFUN int\n\t\t    xmlRelaxNGInitTypes\t\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlRelaxNGCleanupTypes\t(void);\n\n/*\n * Interfaces for parsing.\n */\nXMLPUBFUN xmlRelaxNGParserCtxtPtr\n\t\t    xmlRelaxNGNewParserCtxt\t(const char *URL);\nXMLPUBFUN xmlRelaxNGParserCtxtPtr\n\t\t    xmlRelaxNGNewMemParserCtxt\t(const char *buffer,\n\t\t\t\t\t\t int size);\nXMLPUBFUN xmlRelaxNGParserCtxtPtr\n\t\t    xmlRelaxNGNewDocParserCtxt\t(xmlDocPtr doc);\n\nXMLPUBFUN int\n\t\t    xmlRelaxParserSetFlag\t(xmlRelaxNGParserCtxtPtr ctxt,\n\t\t\t\t\t\t int flag);\n\nXMLPUBFUN void\n\t\t    xmlRelaxNGFreeParserCtxt\t(xmlRelaxNGParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t    xmlRelaxNGSetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,\n\t\t\t\t\t xmlRelaxNGValidityErrorFunc err,\n\t\t\t\t\t xmlRelaxNGValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t\t    xmlRelaxNGGetParserErrors(xmlRelaxNGParserCtxtPtr ctxt,\n\t\t\t\t\t xmlRelaxNGValidityErrorFunc *err,\n\t\t\t\t\t xmlRelaxNGValidityWarningFunc *warn,\n\t\t\t\t\t void **ctx);\nXMLPUBFUN void\n\t\t    xmlRelaxNGSetParserStructuredErrors(\n\t\t\t\t\t xmlRelaxNGParserCtxtPtr ctxt,\n\t\t\t\t\t xmlStructuredErrorFunc serror,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN xmlRelaxNGPtr\n\t\t    xmlRelaxNGParse\t\t(xmlRelaxNGParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t\t    xmlRelaxNGFree\t\t(xmlRelaxNGPtr schema);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\t    xmlRelaxNGDump\t\t(FILE *output,\n\t\t\t\t\t xmlRelaxNGPtr schema);\nXMLPUBFUN void\n\t\t    xmlRelaxNGDumpTree\t(FILE * output,\n\t\t\t\t\t xmlRelaxNGPtr schema);\n#endif /* LIBXML_OUTPUT_ENABLED */\n/*\n * Interfaces for validating\n */\nXMLPUBFUN void\n\t\t    xmlRelaxNGSetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlRelaxNGValidityErrorFunc err,\n\t\t\t\t\t xmlRelaxNGValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t\t    xmlRelaxNGGetValidErrors(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlRelaxNGValidityErrorFunc *err,\n\t\t\t\t\t xmlRelaxNGValidityWarningFunc *warn,\n\t\t\t\t\t void **ctx);\nXMLPUBFUN void\n\t\t\txmlRelaxNGSetValidStructuredErrors(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t  xmlStructuredErrorFunc serror, void *ctx);\nXMLPUBFUN xmlRelaxNGValidCtxtPtr\n\t\t    xmlRelaxNGNewValidCtxt\t(xmlRelaxNGPtr schema);\nXMLPUBFUN void\n\t\t    xmlRelaxNGFreeValidCtxt\t(xmlRelaxNGValidCtxtPtr ctxt);\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidateDoc\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t\t xmlDocPtr doc);\n/*\n * Interfaces for progressive validation when possible\n */\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidatePushElement\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidatePushCData\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *data,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidatePopElement\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN int\n\t\t    xmlRelaxNGValidateFullElement\t(xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMAS_ENABLED */\n\n#endif /* __XML_RELAX_NG__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/schemasInternals.h",
    "content": "/*\n * Summary: internal interfaces for XML Schemas\n * Description: internal interfaces for the XML Schemas handling\n *              and schema validity checking\n *\t\tThe Schemas development is a Work In Progress.\n *              Some of those interfaces are not guaranteed to be API or ABI stable !\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SCHEMA_INTERNALS_H__\n#define __XML_SCHEMA_INTERNALS_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_SCHEMAS_ENABLED\n\n#include <libxml/xmlregexp.h>\n#include <libxml/hash.h>\n#include <libxml/dict.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef enum {\n    XML_SCHEMAS_UNKNOWN = 0,\n    XML_SCHEMAS_STRING = 1,\n    XML_SCHEMAS_NORMSTRING = 2,\n    XML_SCHEMAS_DECIMAL = 3,\n    XML_SCHEMAS_TIME = 4,\n    XML_SCHEMAS_GDAY = 5,\n    XML_SCHEMAS_GMONTH = 6,\n    XML_SCHEMAS_GMONTHDAY = 7,\n    XML_SCHEMAS_GYEAR = 8,\n    XML_SCHEMAS_GYEARMONTH = 9,\n    XML_SCHEMAS_DATE = 10,\n    XML_SCHEMAS_DATETIME = 11,\n    XML_SCHEMAS_DURATION = 12,\n    XML_SCHEMAS_FLOAT = 13,\n    XML_SCHEMAS_DOUBLE = 14,\n    XML_SCHEMAS_BOOLEAN = 15,\n    XML_SCHEMAS_TOKEN = 16,\n    XML_SCHEMAS_LANGUAGE = 17,\n    XML_SCHEMAS_NMTOKEN = 18,\n    XML_SCHEMAS_NMTOKENS = 19,\n    XML_SCHEMAS_NAME = 20,\n    XML_SCHEMAS_QNAME = 21,\n    XML_SCHEMAS_NCNAME = 22,\n    XML_SCHEMAS_ID = 23,\n    XML_SCHEMAS_IDREF = 24,\n    XML_SCHEMAS_IDREFS = 25,\n    XML_SCHEMAS_ENTITY = 26,\n    XML_SCHEMAS_ENTITIES = 27,\n    XML_SCHEMAS_NOTATION = 28,\n    XML_SCHEMAS_ANYURI = 29,\n    XML_SCHEMAS_INTEGER = 30,\n    XML_SCHEMAS_NPINTEGER = 31,\n    XML_SCHEMAS_NINTEGER = 32,\n    XML_SCHEMAS_NNINTEGER = 33,\n    XML_SCHEMAS_PINTEGER = 34,\n    XML_SCHEMAS_INT = 35,\n    XML_SCHEMAS_UINT = 36,\n    XML_SCHEMAS_LONG = 37,\n    XML_SCHEMAS_ULONG = 38,\n    XML_SCHEMAS_SHORT = 39,\n    XML_SCHEMAS_USHORT = 40,\n    XML_SCHEMAS_BYTE = 41,\n    XML_SCHEMAS_UBYTE = 42,\n    XML_SCHEMAS_HEXBINARY = 43,\n    XML_SCHEMAS_BASE64BINARY = 44,\n    XML_SCHEMAS_ANYTYPE = 45,\n    XML_SCHEMAS_ANYSIMPLETYPE = 46\n} xmlSchemaValType;\n\n/*\n * XML Schemas defines multiple type of types.\n */\ntypedef enum {\n    XML_SCHEMA_TYPE_BASIC = 1, /* A built-in datatype */\n    XML_SCHEMA_TYPE_ANY,\n    XML_SCHEMA_TYPE_FACET,\n    XML_SCHEMA_TYPE_SIMPLE,\n    XML_SCHEMA_TYPE_COMPLEX,\n    XML_SCHEMA_TYPE_SEQUENCE = 6,\n    XML_SCHEMA_TYPE_CHOICE,\n    XML_SCHEMA_TYPE_ALL,\n    XML_SCHEMA_TYPE_SIMPLE_CONTENT,\n    XML_SCHEMA_TYPE_COMPLEX_CONTENT,\n    XML_SCHEMA_TYPE_UR,\n    XML_SCHEMA_TYPE_RESTRICTION,\n    XML_SCHEMA_TYPE_EXTENSION,\n    XML_SCHEMA_TYPE_ELEMENT,\n    XML_SCHEMA_TYPE_ATTRIBUTE,\n    XML_SCHEMA_TYPE_ATTRIBUTEGROUP,\n    XML_SCHEMA_TYPE_GROUP,\n    XML_SCHEMA_TYPE_NOTATION,\n    XML_SCHEMA_TYPE_LIST,\n    XML_SCHEMA_TYPE_UNION,\n    XML_SCHEMA_TYPE_ANY_ATTRIBUTE,\n    XML_SCHEMA_TYPE_IDC_UNIQUE,\n    XML_SCHEMA_TYPE_IDC_KEY,\n    XML_SCHEMA_TYPE_IDC_KEYREF,\n    XML_SCHEMA_TYPE_PARTICLE = 25,\n    XML_SCHEMA_TYPE_ATTRIBUTE_USE,\n    XML_SCHEMA_FACET_MININCLUSIVE = 1000,\n    XML_SCHEMA_FACET_MINEXCLUSIVE,\n    XML_SCHEMA_FACET_MAXINCLUSIVE,\n    XML_SCHEMA_FACET_MAXEXCLUSIVE,\n    XML_SCHEMA_FACET_TOTALDIGITS,\n    XML_SCHEMA_FACET_FRACTIONDIGITS,\n    XML_SCHEMA_FACET_PATTERN,\n    XML_SCHEMA_FACET_ENUMERATION,\n    XML_SCHEMA_FACET_WHITESPACE,\n    XML_SCHEMA_FACET_LENGTH,\n    XML_SCHEMA_FACET_MAXLENGTH,\n    XML_SCHEMA_FACET_MINLENGTH,\n    XML_SCHEMA_EXTRA_QNAMEREF = 2000,\n    XML_SCHEMA_EXTRA_ATTR_USE_PROHIB\n} xmlSchemaTypeType;\n\ntypedef enum {\n    XML_SCHEMA_CONTENT_UNKNOWN = 0,\n    XML_SCHEMA_CONTENT_EMPTY = 1,\n    XML_SCHEMA_CONTENT_ELEMENTS,\n    XML_SCHEMA_CONTENT_MIXED,\n    XML_SCHEMA_CONTENT_SIMPLE,\n    XML_SCHEMA_CONTENT_MIXED_OR_ELEMENTS, /* Obsolete */\n    XML_SCHEMA_CONTENT_BASIC,\n    XML_SCHEMA_CONTENT_ANY\n} xmlSchemaContentType;\n\ntypedef struct _xmlSchemaVal xmlSchemaVal;\ntypedef xmlSchemaVal *xmlSchemaValPtr;\n\ntypedef struct _xmlSchemaType xmlSchemaType;\ntypedef xmlSchemaType *xmlSchemaTypePtr;\n\ntypedef struct _xmlSchemaFacet xmlSchemaFacet;\ntypedef xmlSchemaFacet *xmlSchemaFacetPtr;\n\n/**\n * Annotation\n */\ntypedef struct _xmlSchemaAnnot xmlSchemaAnnot;\ntypedef xmlSchemaAnnot *xmlSchemaAnnotPtr;\nstruct _xmlSchemaAnnot {\n    struct _xmlSchemaAnnot *next;\n    xmlNodePtr content;         /* the annotation */\n};\n\n/**\n * XML_SCHEMAS_ANYATTR_SKIP:\n *\n * Skip unknown attribute from validation\n * Obsolete, not used anymore.\n */\n#define XML_SCHEMAS_ANYATTR_SKIP        1\n/**\n * XML_SCHEMAS_ANYATTR_LAX:\n *\n * Ignore validation non definition on attributes\n * Obsolete, not used anymore.\n */\n#define XML_SCHEMAS_ANYATTR_LAX                2\n/**\n * XML_SCHEMAS_ANYATTR_STRICT:\n *\n * Apply strict validation rules on attributes\n * Obsolete, not used anymore.\n */\n#define XML_SCHEMAS_ANYATTR_STRICT        3\n/**\n * XML_SCHEMAS_ANY_SKIP:\n *\n * Skip unknown attribute from validation\n */\n#define XML_SCHEMAS_ANY_SKIP        1\n/**\n * XML_SCHEMAS_ANY_LAX:\n *\n * Used by wildcards.\n * Validate if type found, don't worry if not found\n */\n#define XML_SCHEMAS_ANY_LAX                2\n/**\n * XML_SCHEMAS_ANY_STRICT:\n *\n * Used by wildcards.\n * Apply strict validation rules\n */\n#define XML_SCHEMAS_ANY_STRICT        3\n/**\n * XML_SCHEMAS_ATTR_USE_PROHIBITED:\n *\n * Used by wildcards.\n * The attribute is prohibited.\n */\n#define XML_SCHEMAS_ATTR_USE_PROHIBITED 0\n/**\n * XML_SCHEMAS_ATTR_USE_REQUIRED:\n *\n * The attribute is required.\n */\n#define XML_SCHEMAS_ATTR_USE_REQUIRED 1\n/**\n * XML_SCHEMAS_ATTR_USE_OPTIONAL:\n *\n * The attribute is optional.\n */\n#define XML_SCHEMAS_ATTR_USE_OPTIONAL 2\n/**\n * XML_SCHEMAS_ATTR_GLOBAL:\n *\n * allow elements in no namespace\n */\n#define XML_SCHEMAS_ATTR_GLOBAL        1 << 0\n/**\n * XML_SCHEMAS_ATTR_NSDEFAULT:\n *\n * allow elements in no namespace\n */\n#define XML_SCHEMAS_ATTR_NSDEFAULT        1 << 7\n/**\n * XML_SCHEMAS_ATTR_INTERNAL_RESOLVED:\n *\n * this is set when the \"type\" and \"ref\" references\n * have been resolved.\n */\n#define XML_SCHEMAS_ATTR_INTERNAL_RESOLVED        1 << 8\n/**\n * XML_SCHEMAS_ATTR_FIXED:\n *\n * the attribute has a fixed value\n */\n#define XML_SCHEMAS_ATTR_FIXED        1 << 9\n\n/**\n * xmlSchemaAttribute:\n * An attribute definition.\n */\n\ntypedef struct _xmlSchemaAttribute xmlSchemaAttribute;\ntypedef xmlSchemaAttribute *xmlSchemaAttributePtr;\nstruct _xmlSchemaAttribute {\n    xmlSchemaTypeType type;\n    struct _xmlSchemaAttribute *next; /* the next attribute (not used?) */\n    const xmlChar *name; /* the name of the declaration */\n    const xmlChar *id; /* Deprecated; not used */\n    const xmlChar *ref; /* Deprecated; not used */\n    const xmlChar *refNs; /* Deprecated; not used */\n    const xmlChar *typeName; /* the local name of the type definition */\n    const xmlChar *typeNs; /* the ns URI of the type definition */\n    xmlSchemaAnnotPtr annot;\n\n    xmlSchemaTypePtr base; /* Deprecated; not used */\n    int occurs; /* Deprecated; not used */\n    const xmlChar *defValue; /* The initial value of the value constraint */\n    xmlSchemaTypePtr subtypes; /* the type definition */\n    xmlNodePtr node;\n    const xmlChar *targetNamespace;\n    int flags;\n    const xmlChar *refPrefix; /* Deprecated; not used */\n    xmlSchemaValPtr defVal; /* The compiled value constraint */\n    xmlSchemaAttributePtr refDecl; /* Deprecated; not used */\n};\n\n/**\n * xmlSchemaAttributeLink:\n * Used to build a list of attribute uses on complexType definitions.\n * WARNING: Deprecated; not used.\n */\ntypedef struct _xmlSchemaAttributeLink xmlSchemaAttributeLink;\ntypedef xmlSchemaAttributeLink *xmlSchemaAttributeLinkPtr;\nstruct _xmlSchemaAttributeLink {\n    struct _xmlSchemaAttributeLink *next;/* the next attribute link ... */\n    struct _xmlSchemaAttribute *attr;/* the linked attribute */\n};\n\n/**\n * XML_SCHEMAS_WILDCARD_COMPLETE:\n *\n * If the wildcard is complete.\n */\n#define XML_SCHEMAS_WILDCARD_COMPLETE 1 << 0\n\n/**\n * xmlSchemaCharValueLink:\n * Used to build a list of namespaces on wildcards.\n */\ntypedef struct _xmlSchemaWildcardNs xmlSchemaWildcardNs;\ntypedef xmlSchemaWildcardNs *xmlSchemaWildcardNsPtr;\nstruct _xmlSchemaWildcardNs {\n    struct _xmlSchemaWildcardNs *next;/* the next constraint link ... */\n    const xmlChar *value;/* the value */\n};\n\n/**\n * xmlSchemaWildcard.\n * A wildcard.\n */\ntypedef struct _xmlSchemaWildcard xmlSchemaWildcard;\ntypedef xmlSchemaWildcard *xmlSchemaWildcardPtr;\nstruct _xmlSchemaWildcard {\n    xmlSchemaTypeType type;        /* The kind of type */\n    const xmlChar *id; /* Deprecated; not used */\n    xmlSchemaAnnotPtr annot;\n    xmlNodePtr node;\n    int minOccurs; /* Deprecated; not used */\n    int maxOccurs; /* Deprecated; not used */\n    int processContents;\n    int any; /* Indicates if the ns constraint is of ##any */\n    xmlSchemaWildcardNsPtr nsSet; /* The list of allowed namespaces */\n    xmlSchemaWildcardNsPtr negNsSet; /* The negated namespace */\n    int flags;\n};\n\n/**\n * XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED:\n *\n * The attribute wildcard has been built.\n */\n#define XML_SCHEMAS_ATTRGROUP_WILDCARD_BUILDED 1 << 0\n/**\n * XML_SCHEMAS_ATTRGROUP_GLOBAL:\n *\n * The attribute group has been defined.\n */\n#define XML_SCHEMAS_ATTRGROUP_GLOBAL 1 << 1\n/**\n * XML_SCHEMAS_ATTRGROUP_MARKED:\n *\n * Marks the attr group as marked; used for circular checks.\n */\n#define XML_SCHEMAS_ATTRGROUP_MARKED 1 << 2\n\n/**\n * XML_SCHEMAS_ATTRGROUP_REDEFINED:\n *\n * The attr group was redefined.\n */\n#define XML_SCHEMAS_ATTRGROUP_REDEFINED 1 << 3\n/**\n * XML_SCHEMAS_ATTRGROUP_HAS_REFS:\n *\n * Whether this attr. group contains attr. group references.\n */\n#define XML_SCHEMAS_ATTRGROUP_HAS_REFS 1 << 4\n\n/**\n * An attribute group definition.\n *\n * xmlSchemaAttribute and xmlSchemaAttributeGroup start of structures\n * must be kept similar\n */\ntypedef struct _xmlSchemaAttributeGroup xmlSchemaAttributeGroup;\ntypedef xmlSchemaAttributeGroup *xmlSchemaAttributeGroupPtr;\nstruct _xmlSchemaAttributeGroup {\n    xmlSchemaTypeType type;        /* The kind of type */\n    struct _xmlSchemaAttribute *next;/* the next attribute if in a group ... */\n    const xmlChar *name;\n    const xmlChar *id;\n    const xmlChar *ref; /* Deprecated; not used */\n    const xmlChar *refNs; /* Deprecated; not used */\n    xmlSchemaAnnotPtr annot;\n\n    xmlSchemaAttributePtr attributes; /* Deprecated; not used */\n    xmlNodePtr node;\n    int flags;\n    xmlSchemaWildcardPtr attributeWildcard;\n    const xmlChar *refPrefix; /* Deprecated; not used */\n    xmlSchemaAttributeGroupPtr refItem; /* Deprecated; not used */\n    const xmlChar *targetNamespace;\n    void *attrUses;\n};\n\n/**\n * xmlSchemaTypeLink:\n * Used to build a list of types (e.g. member types of\n * simpleType with variety \"union\").\n */\ntypedef struct _xmlSchemaTypeLink xmlSchemaTypeLink;\ntypedef xmlSchemaTypeLink *xmlSchemaTypeLinkPtr;\nstruct _xmlSchemaTypeLink {\n    struct _xmlSchemaTypeLink *next;/* the next type link ... */\n    xmlSchemaTypePtr type;/* the linked type */\n};\n\n/**\n * xmlSchemaFacetLink:\n * Used to build a list of facets.\n */\ntypedef struct _xmlSchemaFacetLink xmlSchemaFacetLink;\ntypedef xmlSchemaFacetLink *xmlSchemaFacetLinkPtr;\nstruct _xmlSchemaFacetLink {\n    struct _xmlSchemaFacetLink *next;/* the next facet link ... */\n    xmlSchemaFacetPtr facet;/* the linked facet */\n};\n\n/**\n * XML_SCHEMAS_TYPE_MIXED:\n *\n * the element content type is mixed\n */\n#define XML_SCHEMAS_TYPE_MIXED                1 << 0\n/**\n * XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION:\n *\n * the simple or complex type has a derivation method of \"extension\".\n */\n#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_EXTENSION                1 << 1\n/**\n * XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION:\n *\n * the simple or complex type has a derivation method of \"restriction\".\n */\n#define XML_SCHEMAS_TYPE_DERIVATION_METHOD_RESTRICTION                1 << 2\n/**\n * XML_SCHEMAS_TYPE_GLOBAL:\n *\n * the type is global\n */\n#define XML_SCHEMAS_TYPE_GLOBAL                1 << 3\n/**\n * XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD:\n *\n * the complexType owns an attribute wildcard, i.e.\n * it can be freed by the complexType\n */\n#define XML_SCHEMAS_TYPE_OWNED_ATTR_WILDCARD    1 << 4 /* Obsolete. */\n/**\n * XML_SCHEMAS_TYPE_VARIETY_ABSENT:\n *\n * the simpleType has a variety of \"absent\".\n * TODO: Actually not necessary :-/, since if\n * none of the variety flags occur then it's\n * automatically absent.\n */\n#define XML_SCHEMAS_TYPE_VARIETY_ABSENT    1 << 5\n/**\n * XML_SCHEMAS_TYPE_VARIETY_LIST:\n *\n * the simpleType has a variety of \"list\".\n */\n#define XML_SCHEMAS_TYPE_VARIETY_LIST    1 << 6\n/**\n * XML_SCHEMAS_TYPE_VARIETY_UNION:\n *\n * the simpleType has a variety of \"union\".\n */\n#define XML_SCHEMAS_TYPE_VARIETY_UNION    1 << 7\n/**\n * XML_SCHEMAS_TYPE_VARIETY_ATOMIC:\n *\n * the simpleType has a variety of \"union\".\n */\n#define XML_SCHEMAS_TYPE_VARIETY_ATOMIC    1 << 8\n/**\n * XML_SCHEMAS_TYPE_FINAL_EXTENSION:\n *\n * the complexType has a final of \"extension\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_EXTENSION    1 << 9\n/**\n * XML_SCHEMAS_TYPE_FINAL_RESTRICTION:\n *\n * the simpleType/complexType has a final of \"restriction\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_RESTRICTION    1 << 10\n/**\n * XML_SCHEMAS_TYPE_FINAL_LIST:\n *\n * the simpleType has a final of \"list\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_LIST    1 << 11\n/**\n * XML_SCHEMAS_TYPE_FINAL_UNION:\n *\n * the simpleType has a final of \"union\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_UNION    1 << 12\n/**\n * XML_SCHEMAS_TYPE_FINAL_DEFAULT:\n *\n * the simpleType has a final of \"default\".\n */\n#define XML_SCHEMAS_TYPE_FINAL_DEFAULT    1 << 13\n/**\n * XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE:\n *\n * Marks the item as a builtin primitive.\n */\n#define XML_SCHEMAS_TYPE_BUILTIN_PRIMITIVE    1 << 14\n/**\n * XML_SCHEMAS_TYPE_MARKED:\n *\n * Marks the item as marked; used for circular checks.\n */\n#define XML_SCHEMAS_TYPE_MARKED        1 << 16\n/**\n * XML_SCHEMAS_TYPE_BLOCK_DEFAULT:\n *\n * the complexType did not specify 'block' so use the default of the\n * <schema> item.\n */\n#define XML_SCHEMAS_TYPE_BLOCK_DEFAULT    1 << 17\n/**\n * XML_SCHEMAS_TYPE_BLOCK_EXTENSION:\n *\n * the complexType has a 'block' of \"extension\".\n */\n#define XML_SCHEMAS_TYPE_BLOCK_EXTENSION    1 << 18\n/**\n * XML_SCHEMAS_TYPE_BLOCK_RESTRICTION:\n *\n * the complexType has a 'block' of \"restriction\".\n */\n#define XML_SCHEMAS_TYPE_BLOCK_RESTRICTION    1 << 19\n/**\n * XML_SCHEMAS_TYPE_ABSTRACT:\n *\n * the simple/complexType is abstract.\n */\n#define XML_SCHEMAS_TYPE_ABSTRACT    1 << 20\n/**\n * XML_SCHEMAS_TYPE_FACETSNEEDVALUE:\n *\n * indicates if the facets need a computed value\n */\n#define XML_SCHEMAS_TYPE_FACETSNEEDVALUE    1 << 21\n/**\n * XML_SCHEMAS_TYPE_INTERNAL_RESOLVED:\n *\n * indicates that the type was typefixed\n */\n#define XML_SCHEMAS_TYPE_INTERNAL_RESOLVED    1 << 22\n/**\n * XML_SCHEMAS_TYPE_INTERNAL_INVALID:\n *\n * indicates that the type is invalid\n */\n#define XML_SCHEMAS_TYPE_INTERNAL_INVALID    1 << 23\n/**\n * XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE:\n *\n * a whitespace-facet value of \"preserve\"\n */\n#define XML_SCHEMAS_TYPE_WHITESPACE_PRESERVE    1 << 24\n/**\n * XML_SCHEMAS_TYPE_WHITESPACE_REPLACE:\n *\n * a whitespace-facet value of \"replace\"\n */\n#define XML_SCHEMAS_TYPE_WHITESPACE_REPLACE    1 << 25\n/**\n * XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE:\n *\n * a whitespace-facet value of \"collapse\"\n */\n#define XML_SCHEMAS_TYPE_WHITESPACE_COLLAPSE    1 << 26\n/**\n * XML_SCHEMAS_TYPE_HAS_FACETS:\n *\n * has facets\n */\n#define XML_SCHEMAS_TYPE_HAS_FACETS    1 << 27\n/**\n * XML_SCHEMAS_TYPE_NORMVALUENEEDED:\n *\n * indicates if the facets (pattern) need a normalized value\n */\n#define XML_SCHEMAS_TYPE_NORMVALUENEEDED    1 << 28\n\n/**\n * XML_SCHEMAS_TYPE_FIXUP_1:\n *\n * First stage of fixup was done.\n */\n#define XML_SCHEMAS_TYPE_FIXUP_1    1 << 29\n\n/**\n * XML_SCHEMAS_TYPE_REDEFINED:\n *\n * The type was redefined.\n */\n#define XML_SCHEMAS_TYPE_REDEFINED    1 << 30\n/**\n * XML_SCHEMAS_TYPE_REDEFINING:\n *\n * The type redefines an other type.\n */\n/* #define XML_SCHEMAS_TYPE_REDEFINING    1 << 31 */\n\n/**\n * _xmlSchemaType:\n *\n * Schemas type definition.\n */\nstruct _xmlSchemaType {\n    xmlSchemaTypeType type; /* The kind of type */\n    struct _xmlSchemaType *next; /* the next type if in a sequence ... */\n    const xmlChar *name;\n    const xmlChar *id ; /* Deprecated; not used */\n    const xmlChar *ref; /* Deprecated; not used */\n    const xmlChar *refNs; /* Deprecated; not used */\n    xmlSchemaAnnotPtr annot;\n    xmlSchemaTypePtr subtypes;\n    xmlSchemaAttributePtr attributes; /* Deprecated; not used */\n    xmlNodePtr node;\n    int minOccurs; /* Deprecated; not used */\n    int maxOccurs; /* Deprecated; not used */\n\n    int flags;\n    xmlSchemaContentType contentType;\n    const xmlChar *base; /* Base type's local name */\n    const xmlChar *baseNs; /* Base type's target namespace */\n    xmlSchemaTypePtr baseType; /* The base type component */\n    xmlSchemaFacetPtr facets; /* Local facets */\n    struct _xmlSchemaType *redef; /* Deprecated; not used */\n    int recurse; /* Obsolete */\n    xmlSchemaAttributeLinkPtr *attributeUses; /* Deprecated; not used */\n    xmlSchemaWildcardPtr attributeWildcard;\n    int builtInType; /* Type of built-in types. */\n    xmlSchemaTypeLinkPtr memberTypes; /* member-types if a union type. */\n    xmlSchemaFacetLinkPtr facetSet; /* All facets (incl. inherited) */\n    const xmlChar *refPrefix; /* Deprecated; not used */\n    xmlSchemaTypePtr contentTypeDef; /* Used for the simple content of complex types.\n                                        Could we use @subtypes for this? */\n    xmlRegexpPtr contModel; /* Holds the automaton of the content model */\n    const xmlChar *targetNamespace;\n    void *attrUses;\n};\n\n/*\n * xmlSchemaElement:\n * An element definition.\n *\n * xmlSchemaType, xmlSchemaFacet and xmlSchemaElement start of\n * structures must be kept similar\n */\n/**\n * XML_SCHEMAS_ELEM_NILLABLE:\n *\n * the element is nillable\n */\n#define XML_SCHEMAS_ELEM_NILLABLE        1 << 0\n/**\n * XML_SCHEMAS_ELEM_GLOBAL:\n *\n * the element is global\n */\n#define XML_SCHEMAS_ELEM_GLOBAL                1 << 1\n/**\n * XML_SCHEMAS_ELEM_DEFAULT:\n *\n * the element has a default value\n */\n#define XML_SCHEMAS_ELEM_DEFAULT        1 << 2\n/**\n * XML_SCHEMAS_ELEM_FIXED:\n *\n * the element has a fixed value\n */\n#define XML_SCHEMAS_ELEM_FIXED                1 << 3\n/**\n * XML_SCHEMAS_ELEM_ABSTRACT:\n *\n * the element is abstract\n */\n#define XML_SCHEMAS_ELEM_ABSTRACT        1 << 4\n/**\n * XML_SCHEMAS_ELEM_TOPLEVEL:\n *\n * the element is top level\n * obsolete: use XML_SCHEMAS_ELEM_GLOBAL instead\n */\n#define XML_SCHEMAS_ELEM_TOPLEVEL        1 << 5\n/**\n * XML_SCHEMAS_ELEM_REF:\n *\n * the element is a reference to a type\n */\n#define XML_SCHEMAS_ELEM_REF                1 << 6\n/**\n * XML_SCHEMAS_ELEM_NSDEFAULT:\n *\n * allow elements in no namespace\n * Obsolete, not used anymore.\n */\n#define XML_SCHEMAS_ELEM_NSDEFAULT        1 << 7\n/**\n * XML_SCHEMAS_ELEM_INTERNAL_RESOLVED:\n *\n * this is set when \"type\", \"ref\", \"substitutionGroup\"\n * references have been resolved.\n */\n#define XML_SCHEMAS_ELEM_INTERNAL_RESOLVED        1 << 8\n /**\n * XML_SCHEMAS_ELEM_CIRCULAR:\n *\n * a helper flag for the search of circular references.\n */\n#define XML_SCHEMAS_ELEM_CIRCULAR        1 << 9\n/**\n * XML_SCHEMAS_ELEM_BLOCK_ABSENT:\n *\n * the \"block\" attribute is absent\n */\n#define XML_SCHEMAS_ELEM_BLOCK_ABSENT        1 << 10\n/**\n * XML_SCHEMAS_ELEM_BLOCK_EXTENSION:\n *\n * disallowed substitutions are absent\n */\n#define XML_SCHEMAS_ELEM_BLOCK_EXTENSION        1 << 11\n/**\n * XML_SCHEMAS_ELEM_BLOCK_RESTRICTION:\n *\n * disallowed substitutions: \"restriction\"\n */\n#define XML_SCHEMAS_ELEM_BLOCK_RESTRICTION        1 << 12\n/**\n * XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION:\n *\n * disallowed substitutions: \"substitution\"\n */\n#define XML_SCHEMAS_ELEM_BLOCK_SUBSTITUTION        1 << 13\n/**\n * XML_SCHEMAS_ELEM_FINAL_ABSENT:\n *\n * substitution group exclusions are absent\n */\n#define XML_SCHEMAS_ELEM_FINAL_ABSENT        1 << 14\n/**\n * XML_SCHEMAS_ELEM_FINAL_EXTENSION:\n *\n * substitution group exclusions: \"extension\"\n */\n#define XML_SCHEMAS_ELEM_FINAL_EXTENSION        1 << 15\n/**\n * XML_SCHEMAS_ELEM_FINAL_RESTRICTION:\n *\n * substitution group exclusions: \"restriction\"\n */\n#define XML_SCHEMAS_ELEM_FINAL_RESTRICTION        1 << 16\n/**\n * XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD:\n *\n * the declaration is a substitution group head\n */\n#define XML_SCHEMAS_ELEM_SUBST_GROUP_HEAD        1 << 17\n/**\n * XML_SCHEMAS_ELEM_INTERNAL_CHECKED:\n *\n * this is set when the elem decl has been checked against\n * all constraints\n */\n#define XML_SCHEMAS_ELEM_INTERNAL_CHECKED        1 << 18\n\ntypedef struct _xmlSchemaElement xmlSchemaElement;\ntypedef xmlSchemaElement *xmlSchemaElementPtr;\nstruct _xmlSchemaElement {\n    xmlSchemaTypeType type; /* The kind of type */\n    struct _xmlSchemaType *next; /* Not used? */\n    const xmlChar *name;\n    const xmlChar *id; /* Deprecated; not used */\n    const xmlChar *ref; /* Deprecated; not used */\n    const xmlChar *refNs; /* Deprecated; not used */\n    xmlSchemaAnnotPtr annot;\n    xmlSchemaTypePtr subtypes; /* the type definition */\n    xmlSchemaAttributePtr attributes;\n    xmlNodePtr node;\n    int minOccurs; /* Deprecated; not used */\n    int maxOccurs; /* Deprecated; not used */\n\n    int flags;\n    const xmlChar *targetNamespace;\n    const xmlChar *namedType;\n    const xmlChar *namedTypeNs;\n    const xmlChar *substGroup;\n    const xmlChar *substGroupNs;\n    const xmlChar *scope;\n    const xmlChar *value; /* The original value of the value constraint. */\n    struct _xmlSchemaElement *refDecl; /* This will now be used for the\n                                          substitution group affiliation */\n    xmlRegexpPtr contModel; /* Obsolete for WXS, maybe used for RelaxNG */\n    xmlSchemaContentType contentType;\n    const xmlChar *refPrefix; /* Deprecated; not used */\n    xmlSchemaValPtr defVal; /* The compiled value constraint. */\n    void *idcs; /* The identity-constraint defs */\n};\n\n/*\n * XML_SCHEMAS_FACET_UNKNOWN:\n *\n * unknown facet handling\n */\n#define XML_SCHEMAS_FACET_UNKNOWN        0\n/*\n * XML_SCHEMAS_FACET_PRESERVE:\n *\n * preserve the type of the facet\n */\n#define XML_SCHEMAS_FACET_PRESERVE        1\n/*\n * XML_SCHEMAS_FACET_REPLACE:\n *\n * replace the type of the facet\n */\n#define XML_SCHEMAS_FACET_REPLACE        2\n/*\n * XML_SCHEMAS_FACET_COLLAPSE:\n *\n * collapse the types of the facet\n */\n#define XML_SCHEMAS_FACET_COLLAPSE        3\n/**\n * A facet definition.\n */\nstruct _xmlSchemaFacet {\n    xmlSchemaTypeType type;        /* The kind of type */\n    struct _xmlSchemaFacet *next;/* the next type if in a sequence ... */\n    const xmlChar *value; /* The original value */\n    const xmlChar *id; /* Obsolete */\n    xmlSchemaAnnotPtr annot;\n    xmlNodePtr node;\n    int fixed; /* XML_SCHEMAS_FACET_PRESERVE, etc. */\n    int whitespace;\n    xmlSchemaValPtr val; /* The compiled value */\n    xmlRegexpPtr    regexp; /* The regex for patterns */\n};\n\n/**\n * A notation definition.\n */\ntypedef struct _xmlSchemaNotation xmlSchemaNotation;\ntypedef xmlSchemaNotation *xmlSchemaNotationPtr;\nstruct _xmlSchemaNotation {\n    xmlSchemaTypeType type; /* The kind of type */\n    const xmlChar *name;\n    xmlSchemaAnnotPtr annot;\n    const xmlChar *identifier;\n    const xmlChar *targetNamespace;\n};\n\n/*\n* TODO: Actually all those flags used for the schema should sit\n* on the schema parser context, since they are used only\n* during parsing an XML schema document, and not available\n* on the component level as per spec.\n*/\n/**\n * XML_SCHEMAS_QUALIF_ELEM:\n *\n * Reflects elementFormDefault == qualified in\n * an XML schema document.\n */\n#define XML_SCHEMAS_QUALIF_ELEM                1 << 0\n/**\n * XML_SCHEMAS_QUALIF_ATTR:\n *\n * Reflects attributeFormDefault == qualified in\n * an XML schema document.\n */\n#define XML_SCHEMAS_QUALIF_ATTR            1 << 1\n/**\n * XML_SCHEMAS_FINAL_DEFAULT_EXTENSION:\n *\n * the schema has \"extension\" in the set of finalDefault.\n */\n#define XML_SCHEMAS_FINAL_DEFAULT_EXTENSION        1 << 2\n/**\n * XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION:\n *\n * the schema has \"restriction\" in the set of finalDefault.\n */\n#define XML_SCHEMAS_FINAL_DEFAULT_RESTRICTION            1 << 3\n/**\n * XML_SCHEMAS_FINAL_DEFAULT_LIST:\n *\n * the schema has \"list\" in the set of finalDefault.\n */\n#define XML_SCHEMAS_FINAL_DEFAULT_LIST            1 << 4\n/**\n * XML_SCHEMAS_FINAL_DEFAULT_UNION:\n *\n * the schema has \"union\" in the set of finalDefault.\n */\n#define XML_SCHEMAS_FINAL_DEFAULT_UNION            1 << 5\n/**\n * XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION:\n *\n * the schema has \"extension\" in the set of blockDefault.\n */\n#define XML_SCHEMAS_BLOCK_DEFAULT_EXTENSION            1 << 6\n/**\n * XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION:\n *\n * the schema has \"restriction\" in the set of blockDefault.\n */\n#define XML_SCHEMAS_BLOCK_DEFAULT_RESTRICTION            1 << 7\n/**\n * XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION:\n *\n * the schema has \"substitution\" in the set of blockDefault.\n */\n#define XML_SCHEMAS_BLOCK_DEFAULT_SUBSTITUTION            1 << 8\n/**\n * XML_SCHEMAS_INCLUDING_CONVERT_NS:\n *\n * the schema is currently including an other schema with\n * no target namespace.\n */\n#define XML_SCHEMAS_INCLUDING_CONVERT_NS            1 << 9\n/**\n * _xmlSchema:\n *\n * A Schemas definition\n */\nstruct _xmlSchema {\n    const xmlChar *name; /* schema name */\n    const xmlChar *targetNamespace; /* the target namespace */\n    const xmlChar *version;\n    const xmlChar *id; /* Obsolete */\n    xmlDocPtr doc;\n    xmlSchemaAnnotPtr annot;\n    int flags;\n\n    xmlHashTablePtr typeDecl;\n    xmlHashTablePtr attrDecl;\n    xmlHashTablePtr attrgrpDecl;\n    xmlHashTablePtr elemDecl;\n    xmlHashTablePtr notaDecl;\n\n    xmlHashTablePtr schemasImports;\n\n    void *_private;        /* unused by the library for users or bindings */\n    xmlHashTablePtr groupDecl;\n    xmlDictPtr      dict;\n    void *includes;     /* the includes, this is opaque for now */\n    int preserve;        /* whether to free the document */\n    int counter; /* used to give anonymous components unique names */\n    xmlHashTablePtr idcDef; /* All identity-constraint defs. */\n    void *volatiles; /* Obsolete */\n};\n\nXMLPUBFUN void         xmlSchemaFreeType        (xmlSchemaTypePtr type);\nXMLPUBFUN void         xmlSchemaFreeWildcard(xmlSchemaWildcardPtr wildcard);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMAS_ENABLED */\n#endif /* __XML_SCHEMA_INTERNALS_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/schematron.h",
    "content": "/*\n * Summary: XML Schematron implementation\n * Description: interface to the XML Schematron validity checking.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SCHEMATRON_H__\n#define __XML_SCHEMATRON_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_SCHEMATRON_ENABLED\n\n#include <libxml/tree.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef enum {\n    XML_SCHEMATRON_OUT_QUIET = 1 << 0,\t/* quiet no report */\n    XML_SCHEMATRON_OUT_TEXT = 1 << 1,\t/* build a textual report */\n    XML_SCHEMATRON_OUT_XML = 1 << 2,\t/* output SVRL */\n    XML_SCHEMATRON_OUT_ERROR = 1 << 3,  /* output via xmlStructuredErrorFunc */\n    XML_SCHEMATRON_OUT_FILE = 1 << 8,\t/* output to a file descriptor */\n    XML_SCHEMATRON_OUT_BUFFER = 1 << 9,\t/* output to a buffer */\n    XML_SCHEMATRON_OUT_IO = 1 << 10\t/* output to I/O mechanism */\n} xmlSchematronValidOptions;\n\n/**\n * The schemas related types are kept internal\n */\ntypedef struct _xmlSchematron xmlSchematron;\ntypedef xmlSchematron *xmlSchematronPtr;\n\n/**\n * xmlSchematronValidityErrorFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of an error callback from a Schematron validation\n */\ntypedef void (*xmlSchematronValidityErrorFunc) (void *ctx, const char *msg, ...);\n\n/**\n * xmlSchematronValidityWarningFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of a warning callback from a Schematron validation\n */\ntypedef void (*xmlSchematronValidityWarningFunc) (void *ctx, const char *msg, ...);\n\n/**\n * A schemas validation context\n */\ntypedef struct _xmlSchematronParserCtxt xmlSchematronParserCtxt;\ntypedef xmlSchematronParserCtxt *xmlSchematronParserCtxtPtr;\n\ntypedef struct _xmlSchematronValidCtxt xmlSchematronValidCtxt;\ntypedef xmlSchematronValidCtxt *xmlSchematronValidCtxtPtr;\n\n/*\n * Interfaces for parsing.\n */\nXMLPUBFUN xmlSchematronParserCtxtPtr\n\t    xmlSchematronNewParserCtxt\t(const char *URL);\nXMLPUBFUN xmlSchematronParserCtxtPtr\n\t    xmlSchematronNewMemParserCtxt(const char *buffer,\n\t\t\t\t\t int size);\nXMLPUBFUN xmlSchematronParserCtxtPtr\n\t    xmlSchematronNewDocParserCtxt(xmlDocPtr doc);\nXMLPUBFUN void\n\t    xmlSchematronFreeParserCtxt\t(xmlSchematronParserCtxtPtr ctxt);\n/*****\nXMLPUBFUN void\n\t    xmlSchematronSetParserErrors(xmlSchematronParserCtxtPtr ctxt,\n\t\t\t\t\t xmlSchematronValidityErrorFunc err,\n\t\t\t\t\t xmlSchematronValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t\txmlSchematronGetParserErrors(xmlSchematronParserCtxtPtr ctxt,\n\t\t\t\t\txmlSchematronValidityErrorFunc * err,\n\t\t\t\t\txmlSchematronValidityWarningFunc * warn,\n\t\t\t\t\tvoid **ctx);\nXMLPUBFUN int\n\t\txmlSchematronIsValid\t(xmlSchematronValidCtxtPtr ctxt);\n *****/\nXMLPUBFUN xmlSchematronPtr\n\t    xmlSchematronParse\t\t(xmlSchematronParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t    xmlSchematronFree\t\t(xmlSchematronPtr schema);\n/*\n * Interfaces for validating\n */\nXMLPUBFUN void\n\t    xmlSchematronSetValidStructuredErrors(\n\t                                  xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t  xmlStructuredErrorFunc serror,\n\t\t\t\t\t  void *ctx);\n/******\nXMLPUBFUN void\n\t    xmlSchematronSetValidErrors\t(xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSchematronValidityErrorFunc err,\n\t\t\t\t\t xmlSchematronValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t    xmlSchematronGetValidErrors\t(xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSchematronValidityErrorFunc *err,\n\t\t\t\t\t xmlSchematronValidityWarningFunc *warn,\n\t\t\t\t\t void **ctx);\nXMLPUBFUN int\n\t    xmlSchematronSetValidOptions(xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t    xmlSchematronValidCtxtGetOptions(xmlSchematronValidCtxtPtr ctxt);\nXMLPUBFUN int\n            xmlSchematronValidateOneElement (xmlSchematronValidCtxtPtr ctxt,\n\t\t\t                 xmlNodePtr elem);\n *******/\n\nXMLPUBFUN xmlSchematronValidCtxtPtr\n\t    xmlSchematronNewValidCtxt\t(xmlSchematronPtr schema,\n\t\t\t\t\t int options);\nXMLPUBFUN void\n\t    xmlSchematronFreeValidCtxt\t(xmlSchematronValidCtxtPtr ctxt);\nXMLPUBFUN int\n\t    xmlSchematronValidateDoc\t(xmlSchematronValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr instance);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMATRON_ENABLED */\n#endif /* __XML_SCHEMATRON_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/threads.h",
    "content": "/**\n * Summary: interfaces for thread handling\n * Description: set of generic threading related routines\n *              should work with pthreads, Windows native or TLS threads\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_THREADS_H__\n#define __XML_THREADS_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * xmlMutex are a simple mutual exception locks.\n */\ntypedef struct _xmlMutex xmlMutex;\ntypedef xmlMutex *xmlMutexPtr;\n\n/*\n * xmlRMutex are reentrant mutual exception locks.\n */\ntypedef struct _xmlRMutex xmlRMutex;\ntypedef xmlRMutex *xmlRMutexPtr;\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/globals.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nXMLPUBFUN xmlMutexPtr\n\t\t\txmlNewMutex\t(void);\nXMLPUBFUN void\n\t\t\txmlMutexLock\t(xmlMutexPtr tok);\nXMLPUBFUN void\n\t\t\txmlMutexUnlock\t(xmlMutexPtr tok);\nXMLPUBFUN void\n\t\t\txmlFreeMutex\t(xmlMutexPtr tok);\n\nXMLPUBFUN xmlRMutexPtr\n\t\t\txmlNewRMutex\t(void);\nXMLPUBFUN void\n\t\t\txmlRMutexLock\t(xmlRMutexPtr tok);\nXMLPUBFUN void\n\t\t\txmlRMutexUnlock\t(xmlRMutexPtr tok);\nXMLPUBFUN void\n\t\t\txmlFreeRMutex\t(xmlRMutexPtr tok);\n\n/*\n * Library wide APIs.\n */\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlInitThreads\t(void);\nXMLPUBFUN void\n\t\t\txmlLockLibrary\t(void);\nXMLPUBFUN void\n\t\t\txmlUnlockLibrary(void);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlGetThreadId\t(void);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\t\txmlIsMainThread\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t\txmlCleanupThreads(void);\nXML_DEPRECATED\nXMLPUBFUN xmlGlobalStatePtr\n\t\t\txmlGetGlobalState(void);\n\n/** DOC_DISABLE */\n#if defined(LIBXML_THREAD_ENABLED) && defined(_WIN32) && \\\n    !defined(HAVE_COMPILER_TLS) && defined(LIBXML_STATIC_FOR_DLL)\nint\nxmlDllMain(void *hinstDLL, unsigned long fdwReason,\n           void *lpvReserved);\n#endif\n/** DOC_ENABLE */\n\n#ifdef __cplusplus\n}\n#endif\n\n\n#endif /* __XML_THREADS_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/tree.h",
    "content": "/*\n * Summary: interfaces for tree manipulation\n * Description: this module describes the structures found in an tree resulting\n *              from an XML or HTML parsing, as well as the API provided for\n *              various processing on that tree\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_TREE_H__\n#define __XML_TREE_H__\n\n#include <stdio.h>\n#include <limits.h>\n#include <libxml/xmlversion.h>\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Some of the basic types pointer to structures:\n */\n/* xmlIO.h */\ntypedef struct _xmlParserInputBuffer xmlParserInputBuffer;\ntypedef xmlParserInputBuffer *xmlParserInputBufferPtr;\n\ntypedef struct _xmlOutputBuffer xmlOutputBuffer;\ntypedef xmlOutputBuffer *xmlOutputBufferPtr;\n\n/* parser.h */\ntypedef struct _xmlParserInput xmlParserInput;\ntypedef xmlParserInput *xmlParserInputPtr;\n\ntypedef struct _xmlParserCtxt xmlParserCtxt;\ntypedef xmlParserCtxt *xmlParserCtxtPtr;\n\ntypedef struct _xmlSAXLocator xmlSAXLocator;\ntypedef xmlSAXLocator *xmlSAXLocatorPtr;\n\ntypedef struct _xmlSAXHandler xmlSAXHandler;\ntypedef xmlSAXHandler *xmlSAXHandlerPtr;\n\n/* entities.h */\ntypedef struct _xmlEntity xmlEntity;\ntypedef xmlEntity *xmlEntityPtr;\n\n/**\n * BASE_BUFFER_SIZE:\n *\n * default buffer size 4000.\n */\n#define BASE_BUFFER_SIZE 4096\n\n/**\n * LIBXML_NAMESPACE_DICT:\n *\n * Defines experimental behaviour:\n * 1) xmlNs gets an additional field @context (a xmlDoc)\n * 2) when creating a tree, xmlNs->href is stored in the dict of xmlDoc.\n */\n/* #define LIBXML_NAMESPACE_DICT */\n\n/**\n * xmlBufferAllocationScheme:\n *\n * A buffer allocation scheme can be defined to either match exactly the\n * need or double it's allocated size each time it is found too small.\n */\n\ntypedef enum {\n    XML_BUFFER_ALLOC_DOUBLEIT,\t/* double each time one need to grow */\n    XML_BUFFER_ALLOC_EXACT,\t/* grow only to the minimal size */\n    XML_BUFFER_ALLOC_IMMUTABLE, /* immutable buffer, deprecated */\n    XML_BUFFER_ALLOC_IO,\t/* special allocation scheme used for I/O */\n    XML_BUFFER_ALLOC_HYBRID,\t/* exact up to a threshold, and doubleit thereafter */\n    XML_BUFFER_ALLOC_BOUNDED\t/* limit the upper size of the buffer */\n} xmlBufferAllocationScheme;\n\n/**\n * xmlBuffer:\n *\n * A buffer structure, this old construct is limited to 2GB and\n * is being deprecated, use API with xmlBuf instead\n */\ntypedef struct _xmlBuffer xmlBuffer;\ntypedef xmlBuffer *xmlBufferPtr;\nstruct _xmlBuffer {\n    xmlChar *content;\t\t/* The buffer content UTF8 */\n    unsigned int use;\t\t/* The buffer size used */\n    unsigned int size;\t\t/* The buffer size */\n    xmlBufferAllocationScheme alloc; /* The realloc method */\n    xmlChar *contentIO;\t\t/* in IO mode we may have a different base */\n};\n\n/**\n * xmlBuf:\n *\n * A buffer structure, new one, the actual structure internals are not public\n */\n\ntypedef struct _xmlBuf xmlBuf;\n\n/**\n * xmlBufPtr:\n *\n * A pointer to a buffer structure, the actual structure internals are not\n * public\n */\n\ntypedef xmlBuf *xmlBufPtr;\n\n/*\n * A few public routines for xmlBuf. As those are expected to be used\n * mostly internally the bulk of the routines are internal in buf.h\n */\nXMLPUBFUN xmlChar*       xmlBufContent\t(const xmlBuf* buf);\nXMLPUBFUN xmlChar*       xmlBufEnd      (xmlBufPtr buf);\nXMLPUBFUN size_t         xmlBufUse      (const xmlBufPtr buf);\nXMLPUBFUN size_t         xmlBufShrink\t(xmlBufPtr buf, size_t len);\n\n/*\n * LIBXML2_NEW_BUFFER:\n *\n * Macro used to express that the API use the new buffers for\n * xmlParserInputBuffer and xmlOutputBuffer. The change was\n * introduced in 2.9.0.\n */\n#define LIBXML2_NEW_BUFFER\n\n/**\n * XML_XML_NAMESPACE:\n *\n * This is the namespace for the special xml: prefix predefined in the\n * XML Namespace specification.\n */\n#define XML_XML_NAMESPACE \\\n    (const xmlChar *) \"http://www.w3.org/XML/1998/namespace\"\n\n/**\n * XML_XML_ID:\n *\n * This is the name for the special xml:id attribute\n */\n#define XML_XML_ID (const xmlChar *) \"xml:id\"\n\n/*\n * The different element types carried by an XML tree.\n *\n * NOTE: This is synchronized with DOM Level1 values\n *       See http://www.w3.org/TR/REC-DOM-Level-1/\n *\n * Actually this had diverged a bit, and now XML_DOCUMENT_TYPE_NODE should\n * be deprecated to use an XML_DTD_NODE.\n */\ntypedef enum {\n    XML_ELEMENT_NODE=\t\t1,\n    XML_ATTRIBUTE_NODE=\t\t2,\n    XML_TEXT_NODE=\t\t3,\n    XML_CDATA_SECTION_NODE=\t4,\n    XML_ENTITY_REF_NODE=\t5,\n    XML_ENTITY_NODE=\t\t6,\n    XML_PI_NODE=\t\t7,\n    XML_COMMENT_NODE=\t\t8,\n    XML_DOCUMENT_NODE=\t\t9,\n    XML_DOCUMENT_TYPE_NODE=\t10,\n    XML_DOCUMENT_FRAG_NODE=\t11,\n    XML_NOTATION_NODE=\t\t12,\n    XML_HTML_DOCUMENT_NODE=\t13,\n    XML_DTD_NODE=\t\t14,\n    XML_ELEMENT_DECL=\t\t15,\n    XML_ATTRIBUTE_DECL=\t\t16,\n    XML_ENTITY_DECL=\t\t17,\n    XML_NAMESPACE_DECL=\t\t18,\n    XML_XINCLUDE_START=\t\t19,\n    XML_XINCLUDE_END=\t\t20\n    /* XML_DOCB_DOCUMENT_NODE=\t21 */ /* removed */\n} xmlElementType;\n\n/** DOC_DISABLE */\n/* For backward compatibility */\n#define XML_DOCB_DOCUMENT_NODE 21\n/** DOC_ENABLE */\n\n/**\n * xmlNotation:\n *\n * A DTD Notation definition.\n */\n\ntypedef struct _xmlNotation xmlNotation;\ntypedef xmlNotation *xmlNotationPtr;\nstruct _xmlNotation {\n    const xmlChar               *name;\t        /* Notation name */\n    const xmlChar               *PublicID;\t/* Public identifier, if any */\n    const xmlChar               *SystemID;\t/* System identifier, if any */\n};\n\n/**\n * xmlAttributeType:\n *\n * A DTD Attribute type definition.\n */\n\ntypedef enum {\n    XML_ATTRIBUTE_CDATA = 1,\n    XML_ATTRIBUTE_ID,\n    XML_ATTRIBUTE_IDREF\t,\n    XML_ATTRIBUTE_IDREFS,\n    XML_ATTRIBUTE_ENTITY,\n    XML_ATTRIBUTE_ENTITIES,\n    XML_ATTRIBUTE_NMTOKEN,\n    XML_ATTRIBUTE_NMTOKENS,\n    XML_ATTRIBUTE_ENUMERATION,\n    XML_ATTRIBUTE_NOTATION\n} xmlAttributeType;\n\n/**\n * xmlAttributeDefault:\n *\n * A DTD Attribute default definition.\n */\n\ntypedef enum {\n    XML_ATTRIBUTE_NONE = 1,\n    XML_ATTRIBUTE_REQUIRED,\n    XML_ATTRIBUTE_IMPLIED,\n    XML_ATTRIBUTE_FIXED\n} xmlAttributeDefault;\n\n/**\n * xmlEnumeration:\n *\n * List structure used when there is an enumeration in DTDs.\n */\n\ntypedef struct _xmlEnumeration xmlEnumeration;\ntypedef xmlEnumeration *xmlEnumerationPtr;\nstruct _xmlEnumeration {\n    struct _xmlEnumeration    *next;\t/* next one */\n    const xmlChar            *name;\t/* Enumeration name */\n};\n\n/**\n * xmlAttribute:\n *\n * An Attribute declaration in a DTD.\n */\n\ntypedef struct _xmlAttribute xmlAttribute;\ntypedef xmlAttribute *xmlAttributePtr;\nstruct _xmlAttribute {\n    void           *_private;\t        /* application data */\n    xmlElementType          type;       /* XML_ATTRIBUTE_DECL, must be second ! */\n    const xmlChar          *name;\t/* Attribute name */\n    struct _xmlNode    *children;\t/* NULL */\n    struct _xmlNode        *last;\t/* NULL */\n    struct _xmlDtd       *parent;\t/* -> DTD */\n    struct _xmlNode        *next;\t/* next sibling link  */\n    struct _xmlNode        *prev;\t/* previous sibling link  */\n    struct _xmlDoc          *doc;       /* the containing document */\n\n    struct _xmlAttribute  *nexth;\t/* next in hash table */\n    xmlAttributeType       atype;\t/* The attribute type */\n    xmlAttributeDefault      def;\t/* the default */\n    const xmlChar  *defaultValue;\t/* or the default value */\n    xmlEnumerationPtr       tree;       /* or the enumeration tree if any */\n    const xmlChar        *prefix;\t/* the namespace prefix if any */\n    const xmlChar          *elem;\t/* Element holding the attribute */\n};\n\n/**\n * xmlElementContentType:\n *\n * Possible definitions of element content types.\n */\ntypedef enum {\n    XML_ELEMENT_CONTENT_PCDATA = 1,\n    XML_ELEMENT_CONTENT_ELEMENT,\n    XML_ELEMENT_CONTENT_SEQ,\n    XML_ELEMENT_CONTENT_OR\n} xmlElementContentType;\n\n/**\n * xmlElementContentOccur:\n *\n * Possible definitions of element content occurrences.\n */\ntypedef enum {\n    XML_ELEMENT_CONTENT_ONCE = 1,\n    XML_ELEMENT_CONTENT_OPT,\n    XML_ELEMENT_CONTENT_MULT,\n    XML_ELEMENT_CONTENT_PLUS\n} xmlElementContentOccur;\n\n/**\n * xmlElementContent:\n *\n * An XML Element content as stored after parsing an element definition\n * in a DTD.\n */\n\ntypedef struct _xmlElementContent xmlElementContent;\ntypedef xmlElementContent *xmlElementContentPtr;\nstruct _xmlElementContent {\n    xmlElementContentType     type;\t/* PCDATA, ELEMENT, SEQ or OR */\n    xmlElementContentOccur    ocur;\t/* ONCE, OPT, MULT or PLUS */\n    const xmlChar             *name;\t/* Element name */\n    struct _xmlElementContent *c1;\t/* first child */\n    struct _xmlElementContent *c2;\t/* second child */\n    struct _xmlElementContent *parent;\t/* parent */\n    const xmlChar             *prefix;\t/* Namespace prefix */\n};\n\n/**\n * xmlElementTypeVal:\n *\n * The different possibilities for an element content type.\n */\n\ntypedef enum {\n    XML_ELEMENT_TYPE_UNDEFINED = 0,\n    XML_ELEMENT_TYPE_EMPTY = 1,\n    XML_ELEMENT_TYPE_ANY,\n    XML_ELEMENT_TYPE_MIXED,\n    XML_ELEMENT_TYPE_ELEMENT\n} xmlElementTypeVal;\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/xmlregexp.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlElement:\n *\n * An XML Element declaration from a DTD.\n */\n\ntypedef struct _xmlElement xmlElement;\ntypedef xmlElement *xmlElementPtr;\nstruct _xmlElement {\n    void           *_private;\t        /* application data */\n    xmlElementType          type;       /* XML_ELEMENT_DECL, must be second ! */\n    const xmlChar          *name;\t/* Element name */\n    struct _xmlNode    *children;\t/* NULL */\n    struct _xmlNode        *last;\t/* NULL */\n    struct _xmlDtd       *parent;\t/* -> DTD */\n    struct _xmlNode        *next;\t/* next sibling link  */\n    struct _xmlNode        *prev;\t/* previous sibling link  */\n    struct _xmlDoc          *doc;       /* the containing document */\n\n    xmlElementTypeVal      etype;\t/* The type */\n    xmlElementContentPtr content;\t/* the allowed element content */\n    xmlAttributePtr   attributes;\t/* List of the declared attributes */\n    const xmlChar        *prefix;\t/* the namespace prefix if any */\n#ifdef LIBXML_REGEXP_ENABLED\n    xmlRegexpPtr       contModel;\t/* the validating regexp */\n#else\n    void\t      *contModel;\n#endif\n};\n\n\n/**\n * XML_LOCAL_NAMESPACE:\n *\n * A namespace declaration node.\n */\n#define XML_LOCAL_NAMESPACE XML_NAMESPACE_DECL\ntypedef xmlElementType xmlNsType;\n\n/**\n * xmlNs:\n *\n * An XML namespace.\n * Note that prefix == NULL is valid, it defines the default namespace\n * within the subtree (until overridden).\n *\n * xmlNsType is unified with xmlElementType.\n */\n\ntypedef struct _xmlNs xmlNs;\ntypedef xmlNs *xmlNsPtr;\nstruct _xmlNs {\n    struct _xmlNs  *next;\t/* next Ns link for this node  */\n    xmlNsType      type;\t/* global or local */\n    const xmlChar *href;\t/* URL for the namespace */\n    const xmlChar *prefix;\t/* prefix for the namespace */\n    void           *_private;   /* application data */\n    struct _xmlDoc *context;\t\t/* normally an xmlDoc */\n};\n\n/**\n * xmlDtd:\n *\n * An XML DTD, as defined by <!DOCTYPE ... There is actually one for\n * the internal subset and for the external subset.\n */\ntypedef struct _xmlDtd xmlDtd;\ntypedef xmlDtd *xmlDtdPtr;\nstruct _xmlDtd {\n    void           *_private;\t/* application data */\n    xmlElementType  type;       /* XML_DTD_NODE, must be second ! */\n    const xmlChar *name;\t/* Name of the DTD */\n    struct _xmlNode *children;\t/* the value of the property link */\n    struct _xmlNode *last;\t/* last child link */\n    struct _xmlDoc  *parent;\t/* child->parent link */\n    struct _xmlNode *next;\t/* next sibling link  */\n    struct _xmlNode *prev;\t/* previous sibling link  */\n    struct _xmlDoc  *doc;\t/* the containing document */\n\n    /* End of common part */\n    void          *notations;   /* Hash table for notations if any */\n    void          *elements;    /* Hash table for elements if any */\n    void          *attributes;  /* Hash table for attributes if any */\n    void          *entities;    /* Hash table for entities if any */\n    const xmlChar *ExternalID;\t/* External identifier for PUBLIC DTD */\n    const xmlChar *SystemID;\t/* URI for a SYSTEM or PUBLIC DTD */\n    void          *pentities;   /* Hash table for param entities if any */\n};\n\n/**\n * xmlAttr:\n *\n * An attribute on an XML node.\n */\ntypedef struct _xmlAttr xmlAttr;\ntypedef xmlAttr *xmlAttrPtr;\nstruct _xmlAttr {\n    void           *_private;\t/* application data */\n    xmlElementType   type;      /* XML_ATTRIBUTE_NODE, must be second ! */\n    const xmlChar   *name;      /* the name of the property */\n    struct _xmlNode *children;\t/* the value of the property */\n    struct _xmlNode *last;\t/* NULL */\n    struct _xmlNode *parent;\t/* child->parent link */\n    struct _xmlAttr *next;\t/* next sibling link  */\n    struct _xmlAttr *prev;\t/* previous sibling link  */\n    struct _xmlDoc  *doc;\t/* the containing document */\n    xmlNs           *ns;        /* pointer to the associated namespace */\n    xmlAttributeType atype;     /* the attribute type if validating */\n    void            *psvi;\t/* for type/PSVI information */\n};\n\n/**\n * xmlID:\n *\n * An XML ID instance.\n */\n\ntypedef struct _xmlID xmlID;\ntypedef xmlID *xmlIDPtr;\nstruct _xmlID {\n    struct _xmlID    *next;\t/* next ID */\n    const xmlChar    *value;\t/* The ID name */\n    xmlAttrPtr        attr;\t/* The attribute holding it */\n    const xmlChar    *name;\t/* The attribute if attr is not available */\n    int               lineno;\t/* The line number if attr is not available */\n    struct _xmlDoc   *doc;\t/* The document holding the ID */\n};\n\n/**\n * xmlRef:\n *\n * An XML IDREF instance.\n */\n\ntypedef struct _xmlRef xmlRef;\ntypedef xmlRef *xmlRefPtr;\nstruct _xmlRef {\n    struct _xmlRef    *next;\t/* next Ref */\n    const xmlChar     *value;\t/* The Ref name */\n    xmlAttrPtr        attr;\t/* The attribute holding it */\n    const xmlChar    *name;\t/* The attribute if attr is not available */\n    int               lineno;\t/* The line number if attr is not available */\n};\n\n/**\n * xmlNode:\n *\n * A node in an XML tree.\n */\ntypedef struct _xmlNode xmlNode;\ntypedef xmlNode *xmlNodePtr;\nstruct _xmlNode {\n    void           *_private;\t/* application data */\n    xmlElementType   type;\t/* type number, must be second ! */\n    const xmlChar   *name;      /* the name of the node, or the entity */\n    struct _xmlNode *children;\t/* parent->childs link */\n    struct _xmlNode *last;\t/* last child link */\n    struct _xmlNode *parent;\t/* child->parent link */\n    struct _xmlNode *next;\t/* next sibling link  */\n    struct _xmlNode *prev;\t/* previous sibling link  */\n    struct _xmlDoc  *doc;\t/* the containing document */\n\n    /* End of common part */\n    xmlNs           *ns;        /* pointer to the associated namespace */\n    xmlChar         *content;   /* the content */\n    struct _xmlAttr *properties;/* properties list */\n    xmlNs           *nsDef;     /* namespace definitions on this node */\n    void            *psvi;\t/* for type/PSVI information */\n    unsigned short   line;\t/* line number */\n    unsigned short   extra;\t/* extra data for XPath/XSLT */\n};\n\n/**\n * XML_GET_CONTENT:\n *\n * Macro to extract the content pointer of a node.\n */\n#define XML_GET_CONTENT(n)\t\t\t\t\t\\\n    ((n)->type == XML_ELEMENT_NODE ? NULL : (n)->content)\n\n/**\n * XML_GET_LINE:\n *\n * Macro to extract the line number of an element node.\n */\n#define XML_GET_LINE(n)\t\t\t\t\t\t\\\n    (xmlGetLineNo(n))\n\n/**\n * xmlDocProperty\n *\n * Set of properties of the document as found by the parser\n * Some of them are linked to similarly named xmlParserOption\n */\ntypedef enum {\n    XML_DOC_WELLFORMED\t\t= 1<<0, /* document is XML well formed */\n    XML_DOC_NSVALID\t\t= 1<<1, /* document is Namespace valid */\n    XML_DOC_OLD10\t\t= 1<<2, /* parsed with old XML-1.0 parser */\n    XML_DOC_DTDVALID\t\t= 1<<3, /* DTD validation was successful */\n    XML_DOC_XINCLUDE\t\t= 1<<4, /* XInclude substitution was done */\n    XML_DOC_USERBUILT\t\t= 1<<5, /* Document was built using the API\n                                           and not by parsing an instance */\n    XML_DOC_INTERNAL\t\t= 1<<6, /* built for internal processing */\n    XML_DOC_HTML\t\t= 1<<7  /* parsed or built HTML document */\n} xmlDocProperties;\n\n/**\n * xmlDoc:\n *\n * An XML document.\n */\ntypedef struct _xmlDoc xmlDoc;\ntypedef xmlDoc *xmlDocPtr;\nstruct _xmlDoc {\n    void           *_private;\t/* application data */\n    xmlElementType  type;       /* XML_DOCUMENT_NODE, must be second ! */\n    char           *name;\t/* name/filename/URI of the document */\n    struct _xmlNode *children;\t/* the document tree */\n    struct _xmlNode *last;\t/* last child link */\n    struct _xmlNode *parent;\t/* child->parent link */\n    struct _xmlNode *next;\t/* next sibling link  */\n    struct _xmlNode *prev;\t/* previous sibling link  */\n    struct _xmlDoc  *doc;\t/* autoreference to itself */\n\n    /* End of common part */\n    int             compression;/* level of zlib compression */\n    int             standalone; /* standalone document (no external refs)\n\t\t\t\t     1 if standalone=\"yes\"\n\t\t\t\t     0 if standalone=\"no\"\n\t\t\t\t    -1 if there is no XML declaration\n\t\t\t\t    -2 if there is an XML declaration, but no\n\t\t\t\t\tstandalone attribute was specified */\n    struct _xmlDtd  *intSubset;\t/* the document internal subset */\n    struct _xmlDtd  *extSubset;\t/* the document external subset */\n    struct _xmlNs   *oldNs;\t/* Global namespace, the old way */\n    const xmlChar  *version;\t/* the XML version string */\n    const xmlChar  *encoding;   /* external initial encoding, if any */\n    void           *ids;        /* Hash table for ID attributes if any */\n    void           *refs;       /* Hash table for IDREFs attributes if any */\n    const xmlChar  *URL;\t/* The URI for that document */\n    int             charset;    /* Internal flag for charset handling,\n\t\t\t\t   actually an xmlCharEncoding */\n    struct _xmlDict *dict;      /* dict used to allocate names or NULL */\n    void           *psvi;\t/* for type/PSVI information */\n    int             parseFlags;\t/* set of xmlParserOption used to parse the\n\t\t\t\t   document */\n    int             properties;\t/* set of xmlDocProperties for this document\n\t\t\t\t   set at the end of parsing */\n};\n\n\ntypedef struct _xmlDOMWrapCtxt xmlDOMWrapCtxt;\ntypedef xmlDOMWrapCtxt *xmlDOMWrapCtxtPtr;\n\n/**\n * xmlDOMWrapAcquireNsFunction:\n * @ctxt:  a DOM wrapper context\n * @node:  the context node (element or attribute)\n * @nsName:  the requested namespace name\n * @nsPrefix:  the requested namespace prefix\n *\n * A function called to acquire namespaces (xmlNs) from the wrapper.\n *\n * Returns an xmlNsPtr or NULL in case of an error.\n */\ntypedef xmlNsPtr (*xmlDOMWrapAcquireNsFunction) (xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t\t const xmlChar *nsName,\n\t\t\t\t\t\t const xmlChar *nsPrefix);\n\n/**\n * xmlDOMWrapCtxt:\n *\n * Context for DOM wrapper-operations.\n */\nstruct _xmlDOMWrapCtxt {\n    void * _private;\n    /*\n    * The type of this context, just in case we need specialized\n    * contexts in the future.\n    */\n    int type;\n    /*\n    * Internal namespace map used for various operations.\n    */\n    void * namespaceMap;\n    /*\n    * Use this one to acquire an xmlNsPtr intended for node->ns.\n    * (Note that this is not intended for elem->nsDef).\n    */\n    xmlDOMWrapAcquireNsFunction getNsForNodeFunc;\n};\n\n/**\n * xmlChildrenNode:\n *\n * Macro for compatibility naming layer with libxml1. Maps\n * to \"children.\"\n */\n#ifndef xmlChildrenNode\n#define xmlChildrenNode children\n#endif\n\n/**\n * xmlRootNode:\n *\n * Macro for compatibility naming layer with libxml1. Maps\n * to \"children\".\n */\n#ifndef xmlRootNode\n#define xmlRootNode children\n#endif\n\n/*\n * Variables.\n */\n\n/*\n * Some helper functions\n */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_DEBUG_ENABLED) || \\\n    defined (LIBXML_HTML_ENABLED) || defined(LIBXML_SAX1_ENABLED) || \\\n    defined(LIBXML_HTML_ENABLED) || defined(LIBXML_WRITER_ENABLED) || \\\n    defined(LIBXML_LEGACY_ENABLED)\nXMLPUBFUN int\n\t\txmlValidateNCName\t(const xmlChar *value,\n\t\t\t\t\t int space);\n#endif\n\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN int\n\t\txmlValidateQName\t(const xmlChar *value,\n\t\t\t\t\t int space);\nXMLPUBFUN int\n\t\txmlValidateName\t\t(const xmlChar *value,\n\t\t\t\t\t int space);\nXMLPUBFUN int\n\t\txmlValidateNMToken\t(const xmlChar *value,\n\t\t\t\t\t int space);\n#endif\n\nXMLPUBFUN xmlChar *\n\t\txmlBuildQName\t\t(const xmlChar *ncname,\n\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t xmlChar *memory,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlChar *\n\t\txmlSplitQName2\t\t(const xmlChar *name,\n\t\t\t\t\t xmlChar **prefix);\nXMLPUBFUN const xmlChar *\n\t\txmlSplitQName3\t\t(const xmlChar *name,\n\t\t\t\t\t int *len);\n\n/*\n * Handling Buffers, the old ones see @xmlBuf for the new ones.\n */\n\nXMLPUBFUN void\n\t\txmlSetBufferAllocationScheme(xmlBufferAllocationScheme scheme);\nXMLPUBFUN xmlBufferAllocationScheme\n\t\txmlGetBufferAllocationScheme(void);\n\nXMLPUBFUN xmlBufferPtr\n\t\txmlBufferCreate\t\t(void);\nXMLPUBFUN xmlBufferPtr\n\t\txmlBufferCreateSize\t(size_t size);\nXMLPUBFUN xmlBufferPtr\n\t\txmlBufferCreateStatic\t(void *mem,\n\t\t\t\t\t size_t size);\nXMLPUBFUN int\n\t\txmlBufferResize\t\t(xmlBufferPtr buf,\n\t\t\t\t\t unsigned int size);\nXMLPUBFUN void\n\t\txmlBufferFree\t\t(xmlBufferPtr buf);\nXMLPUBFUN int\n\t\txmlBufferDump\t\t(FILE *file,\n\t\t\t\t\t xmlBufferPtr buf);\nXMLPUBFUN int\n\t\txmlBufferAdd\t\t(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\txmlBufferAddHead\t(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\txmlBufferCat\t\t(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *str);\nXMLPUBFUN int\n\t\txmlBufferCCat\t\t(xmlBufferPtr buf,\n\t\t\t\t\t const char *str);\nXMLPUBFUN int\n\t\txmlBufferShrink\t\t(xmlBufferPtr buf,\n\t\t\t\t\t unsigned int len);\nXMLPUBFUN int\n\t\txmlBufferGrow\t\t(xmlBufferPtr buf,\n\t\t\t\t\t unsigned int len);\nXMLPUBFUN void\n\t\txmlBufferEmpty\t\t(xmlBufferPtr buf);\nXMLPUBFUN const xmlChar*\n\t\txmlBufferContent\t(const xmlBuffer *buf);\nXMLPUBFUN xmlChar*\n\t\txmlBufferDetach         (xmlBufferPtr buf);\nXMLPUBFUN void\n\t\txmlBufferSetAllocationScheme(xmlBufferPtr buf,\n\t\t\t\t\t xmlBufferAllocationScheme scheme);\nXMLPUBFUN int\n\t\txmlBufferLength\t\t(const xmlBuffer *buf);\n\n/*\n * Creating/freeing new structures.\n */\nXMLPUBFUN xmlDtdPtr\n\t\txmlCreateIntSubset\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlDtdPtr\n\t\txmlNewDtd\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *ExternalID,\n\t\t\t\t\t const xmlChar *SystemID);\nXMLPUBFUN xmlDtdPtr\n\t\txmlGetIntSubset\t\t(const xmlDoc *doc);\nXMLPUBFUN void\n\t\txmlFreeDtd\t\t(xmlDtdPtr cur);\n#ifdef LIBXML_LEGACY_ENABLED\nXML_DEPRECATED\nXMLPUBFUN xmlNsPtr\n\t\txmlNewGlobalNs\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *href,\n\t\t\t\t\t const xmlChar *prefix);\n#endif /* LIBXML_LEGACY_ENABLED */\nXMLPUBFUN xmlNsPtr\n\t\txmlNewNs\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *href,\n\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN void\n\t\txmlFreeNs\t\t(xmlNsPtr cur);\nXMLPUBFUN void\n\t\txmlFreeNsList\t\t(xmlNsPtr cur);\nXMLPUBFUN xmlDocPtr\n\t\txmlNewDoc\t\t(const xmlChar *version);\nXMLPUBFUN void\n\t\txmlFreeDoc\t\t(xmlDocPtr cur);\nXMLPUBFUN xmlAttrPtr\n\t\txmlNewDocProp\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN xmlAttrPtr\n\t\txmlNewProp\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\n#endif\nXMLPUBFUN xmlAttrPtr\n\t\txmlNewNsProp\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlAttrPtr\n\t\txmlNewNsPropEatName\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN void\n\t\txmlFreePropList\t\t(xmlAttrPtr cur);\nXMLPUBFUN void\n\t\txmlFreeProp\t\t(xmlAttrPtr cur);\nXMLPUBFUN xmlAttrPtr\n\t\txmlCopyProp\t\t(xmlNodePtr target,\n\t\t\t\t\t xmlAttrPtr cur);\nXMLPUBFUN xmlAttrPtr\n\t\txmlCopyPropList\t\t(xmlNodePtr target,\n\t\t\t\t\t xmlAttrPtr cur);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlDtdPtr\n\t\txmlCopyDtd\t\t(xmlDtdPtr dtd);\n#endif /* LIBXML_TREE_ENABLED */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN xmlDocPtr\n\t\txmlCopyDoc\t\t(xmlDocPtr doc,\n\t\t\t\t\t int recursive);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */\n/*\n * Creating new nodes.\n */\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocNode\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocNodeEatName\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewNode\t\t(xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewNodeEatName\t(xmlNsPtr ns,\n\t\t\t\t\t xmlChar *name);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN xmlNodePtr\n\t\txmlNewChild\t\t(xmlNodePtr parent,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\n#endif\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocText\t\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewText\t\t(const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocPI\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewPI\t\t(const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocTextLen\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewTextLen\t\t(const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocComment\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewComment\t\t(const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewCDataBlock\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewCharRef\t\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewReference\t\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlNodePtr\n\t\txmlCopyNode\t\t(xmlNodePtr node,\n\t\t\t\t\t int recursive);\nXMLPUBFUN xmlNodePtr\n\t\txmlDocCopyNode\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t int recursive);\nXMLPUBFUN xmlNodePtr\n\t\txmlDocCopyNodeList\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodePtr\n\t\txmlCopyNodeList\t\t(xmlNodePtr node);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlNodePtr\n\t\txmlNewTextChild\t\t(xmlNodePtr parent,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocRawNode\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN xmlNodePtr\n\t\txmlNewDocFragment\t(xmlDocPtr doc);\n#endif /* LIBXML_TREE_ENABLED */\n\n/*\n * Navigating.\n */\nXMLPUBFUN long\n\t\txmlGetLineNo\t\t(const xmlNode *node);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED)\nXMLPUBFUN xmlChar *\n\t\txmlGetNodePath\t\t(const xmlNode *node);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_DEBUG_ENABLED) */\nXMLPUBFUN xmlNodePtr\n\t\txmlDocGetRootElement\t(const xmlDoc *doc);\nXMLPUBFUN xmlNodePtr\n\t\txmlGetLastChild\t\t(const xmlNode *parent);\nXMLPUBFUN int\n\t\txmlNodeIsText\t\t(const xmlNode *node);\nXMLPUBFUN int\n\t\txmlIsBlankNode\t\t(const xmlNode *node);\n\n/*\n * Changing the structure.\n */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)\nXMLPUBFUN xmlNodePtr\n\t\txmlDocSetRootElement\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr root);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN void\n\t\txmlNodeSetName\t\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *name);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN xmlNodePtr\n\t\txmlAddChild\t\t(xmlNodePtr parent,\n\t\t\t\t\t xmlNodePtr cur);\nXMLPUBFUN xmlNodePtr\n\t\txmlAddChildList\t\t(xmlNodePtr parent,\n\t\t\t\t\t xmlNodePtr cur);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED)\nXMLPUBFUN xmlNodePtr\n\t\txmlReplaceNode\t\t(xmlNodePtr old,\n\t\t\t\t\t xmlNodePtr cur);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_WRITER_ENABLED) */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_HTML_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)\nXMLPUBFUN xmlNodePtr\n\t\txmlAddPrevSibling\t(xmlNodePtr cur,\n\t\t\t\t\t xmlNodePtr elem);\n#endif /* LIBXML_TREE_ENABLED || LIBXML_HTML_ENABLED || LIBXML_SCHEMAS_ENABLED */\nXMLPUBFUN xmlNodePtr\n\t\txmlAddSibling\t\t(xmlNodePtr cur,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN xmlNodePtr\n\t\txmlAddNextSibling\t(xmlNodePtr cur,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN void\n\t\txmlUnlinkNode\t\t(xmlNodePtr cur);\nXMLPUBFUN xmlNodePtr\n\t\txmlTextMerge\t\t(xmlNodePtr first,\n\t\t\t\t\t xmlNodePtr second);\nXMLPUBFUN int\n\t\txmlTextConcat\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN void\n\t\txmlFreeNodeList\t\t(xmlNodePtr cur);\nXMLPUBFUN void\n\t\txmlFreeNode\t\t(xmlNodePtr cur);\nXMLPUBFUN void\n\t\txmlSetTreeDoc\t\t(xmlNodePtr tree,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN void\n\t\txmlSetListDoc\t\t(xmlNodePtr list,\n\t\t\t\t\t xmlDocPtr doc);\n/*\n * Namespaces.\n */\nXMLPUBFUN xmlNsPtr\n\t\txmlSearchNs\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t const xmlChar *nameSpace);\nXMLPUBFUN xmlNsPtr\n\t\txmlSearchNsByHref\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t const xmlChar *href);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN xmlNsPtr *\n\t\txmlGetNsList\t\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlNode *node);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XPATH_ENABLED) */\n\nXMLPUBFUN void\n\t\txmlSetNs\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns);\nXMLPUBFUN xmlNsPtr\n\t\txmlCopyNamespace\t(xmlNsPtr cur);\nXMLPUBFUN xmlNsPtr\n\t\txmlCopyNamespaceList\t(xmlNsPtr cur);\n\n/*\n * Changing the content.\n */\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \\\n    defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED)\nXMLPUBFUN xmlAttrPtr\n\t\txmlSetProp\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlAttrPtr\n\t\txmlSetNsProp\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED) || \\\n\t  defined(LIBXML_SCHEMAS_ENABLED) || defined(LIBXML_HTML_ENABLED) */\nXMLPUBFUN xmlChar *\n\t\txmlGetNoNsProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlChar *\n\t\txmlGetProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlAttrPtr\n\t\txmlHasProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlAttrPtr\n\t\txmlHasNsProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *nameSpace);\nXMLPUBFUN xmlChar *\n\t\txmlGetNsProp\t\t(const xmlNode *node,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *nameSpace);\nXMLPUBFUN xmlNodePtr\n\t\txmlStringGetNodeList\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlNodePtr\n\t\txmlStringLenGetNodeList\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlChar *\n\t\txmlNodeListGetString\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlNode *list,\n\t\t\t\t\t int inLine);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlChar *\n\t\txmlNodeListGetRawString\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlNode *list,\n\t\t\t\t\t int inLine);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlNodeSetContent\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *content);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN void\n\t\txmlNodeSetContentLen\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlNodeAddContent\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *content);\nXMLPUBFUN void\n\t\txmlNodeAddContentLen\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *content,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlChar *\n\t\txmlNodeGetContent\t(const xmlNode *cur);\n\nXMLPUBFUN int\n\t\txmlNodeBufGetContent\t(xmlBufferPtr buffer,\n\t\t\t\t\t const xmlNode *cur);\nXMLPUBFUN int\n\t\txmlBufGetNodeContent\t(xmlBufPtr buf,\n\t\t\t\t\t const xmlNode *cur);\n\nXMLPUBFUN xmlChar *\n\t\txmlNodeGetLang\t\t(const xmlNode *cur);\nXMLPUBFUN int\n\t\txmlNodeGetSpacePreserve\t(const xmlNode *cur);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN void\n\t\txmlNodeSetLang\t\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *lang);\nXMLPUBFUN void\n\t\txmlNodeSetSpacePreserve (xmlNodePtr cur,\n\t\t\t\t\t int val);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN xmlChar *\n\t\txmlNodeGetBase\t\t(const xmlDoc *doc,\n\t\t\t\t\t const xmlNode *cur);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_XINCLUDE_ENABLED)\nXMLPUBFUN void\n\t\txmlNodeSetBase\t\t(xmlNodePtr cur,\n\t\t\t\t\t const xmlChar *uri);\n#endif\n\n/*\n * Removing content.\n */\nXMLPUBFUN int\n\t\txmlRemoveProp\t\t(xmlAttrPtr cur);\n#if defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN int\n\t\txmlUnsetNsProp\t\t(xmlNodePtr node,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN int\n\t\txmlUnsetProp\t\t(xmlNodePtr node,\n\t\t\t\t\t const xmlChar *name);\n#endif /* defined(LIBXML_TREE_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED) */\n\n/*\n * Internal, don't use.\n */\nXMLPUBFUN void\n\t\txmlBufferWriteCHAR\t(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *string);\nXMLPUBFUN void\n\t\txmlBufferWriteChar\t(xmlBufferPtr buf,\n\t\t\t\t\t const char *string);\nXMLPUBFUN void\n\t\txmlBufferWriteQuotedString(xmlBufferPtr buf,\n\t\t\t\t\t const xmlChar *string);\n\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void xmlAttrSerializeTxtContent(xmlBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlAttrPtr attr,\n\t\t\t\t\t const xmlChar *string);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n#ifdef LIBXML_TREE_ENABLED\n/*\n * Namespace handling.\n */\nXMLPUBFUN int\n\t\txmlReconciliateNs\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr tree);\n#endif\n\n#ifdef LIBXML_OUTPUT_ENABLED\n/*\n * Saving.\n */\nXMLPUBFUN void\n\t\txmlDocDumpFormatMemory\t(xmlDocPtr cur,\n\t\t\t\t\t xmlChar **mem,\n\t\t\t\t\t int *size,\n\t\t\t\t\t int format);\nXMLPUBFUN void\n\t\txmlDocDumpMemory\t(xmlDocPtr cur,\n\t\t\t\t\t xmlChar **mem,\n\t\t\t\t\t int *size);\nXMLPUBFUN void\n\t\txmlDocDumpMemoryEnc\t(xmlDocPtr out_doc,\n\t\t\t\t\t xmlChar **doc_txt_ptr,\n\t\t\t\t\t int * doc_txt_len,\n\t\t\t\t\t const char *txt_encoding);\nXMLPUBFUN void\n\t\txmlDocDumpFormatMemoryEnc(xmlDocPtr out_doc,\n\t\t\t\t\t xmlChar **doc_txt_ptr,\n\t\t\t\t\t int * doc_txt_len,\n\t\t\t\t\t const char *txt_encoding,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\txmlDocFormatDump\t(FILE *f,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\txmlDocDump\t\t(FILE *f,\n\t\t\t\t\t xmlDocPtr cur);\nXMLPUBFUN void\n\t\txmlElemDump\t\t(FILE *f,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur);\nXMLPUBFUN int\n\t\txmlSaveFile\t\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur);\nXMLPUBFUN int\n\t\txmlSaveFormatFile\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t int format);\nXMLPUBFUN size_t\n\t\txmlBufNodeDump\t\t(xmlBufPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t int level,\n\t\t\t\t\t int format);\nXMLPUBFUN int\n\t\txmlNodeDump\t\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t int level,\n\t\t\t\t\t int format);\n\nXMLPUBFUN int\n\t\txmlSaveFileTo\t\t(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding);\nXMLPUBFUN int\n\t\txmlSaveFormatFileTo     (xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t         const char *encoding,\n\t\t\t\t         int format);\nXMLPUBFUN void\n\t\txmlNodeDumpOutput\t(xmlOutputBufferPtr buf,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr cur,\n\t\t\t\t\t int level,\n\t\t\t\t\t int format,\n\t\t\t\t\t const char *encoding);\n\nXMLPUBFUN int\n\t\txmlSaveFormatFileEnc    (const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int format);\n\nXMLPUBFUN int\n\t\txmlSaveFileEnc\t\t(const char *filename,\n\t\t\t\t\t xmlDocPtr cur,\n\t\t\t\t\t const char *encoding);\n\n#endif /* LIBXML_OUTPUT_ENABLED */\n/*\n * XHTML\n */\nXMLPUBFUN int\n\t\txmlIsXHTML\t\t(const xmlChar *systemID,\n\t\t\t\t\t const xmlChar *publicID);\n\n/*\n * Compression.\n */\nXMLPUBFUN int\n\t\txmlGetDocCompressMode\t(const xmlDoc *doc);\nXMLPUBFUN void\n\t\txmlSetDocCompressMode\t(xmlDocPtr doc,\n\t\t\t\t\t int mode);\nXMLPUBFUN int\n\t\txmlGetCompressMode\t(void);\nXMLPUBFUN void\n\t\txmlSetCompressMode\t(int mode);\n\n/*\n* DOM-wrapper helper functions.\n*/\nXMLPUBFUN xmlDOMWrapCtxtPtr\n\t\txmlDOMWrapNewCtxt\t(void);\nXMLPUBFUN void\n\t\txmlDOMWrapFreeCtxt\t(xmlDOMWrapCtxtPtr ctxt);\nXMLPUBFUN int\n\t    xmlDOMWrapReconcileNamespaces(xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t    xmlDOMWrapAdoptNode\t\t(xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr sourceDoc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t xmlDocPtr destDoc,\n\t\t\t\t\t xmlNodePtr destParent,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t    xmlDOMWrapRemoveNode\t(xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t    xmlDOMWrapCloneNode\t\t(xmlDOMWrapCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr sourceDoc,\n\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t xmlNodePtr *clonedNode,\n\t\t\t\t\t xmlDocPtr destDoc,\n\t\t\t\t\t xmlNodePtr destParent,\n\t\t\t\t\t int deep,\n\t\t\t\t\t int options);\n\n#ifdef LIBXML_TREE_ENABLED\n/*\n * 5 interfaces from DOM ElementTraversal, but different in entities\n * traversal.\n */\nXMLPUBFUN unsigned long\n            xmlChildElementCount        (xmlNodePtr parent);\nXMLPUBFUN xmlNodePtr\n            xmlNextElementSibling       (xmlNodePtr node);\nXMLPUBFUN xmlNodePtr\n            xmlFirstElementChild        (xmlNodePtr parent);\nXMLPUBFUN xmlNodePtr\n            xmlLastElementChild         (xmlNodePtr parent);\nXMLPUBFUN xmlNodePtr\n            xmlPreviousElementSibling   (xmlNodePtr node);\n#endif\n#ifdef __cplusplus\n}\n#endif\n#ifndef __XML_PARSER_H__\n#include <libxml/xmlmemory.h>\n#endif\n\n#endif /* __XML_TREE_H__ */\n\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/uri.h",
    "content": "/**\n * Summary: library of generic URI related routines\n * Description: library of generic URI related routines\n *              Implements RFC 2396\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_URI_H__\n#define __XML_URI_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlURI:\n *\n * A parsed URI reference. This is a struct containing the various fields\n * as described in RFC 2396 but separated for further processing.\n *\n * Note: query is a deprecated field which is incorrectly unescaped.\n * query_raw takes precedence over query if the former is set.\n * See: http://mail.gnome.org/archives/xml/2007-April/thread.html#00127\n */\ntypedef struct _xmlURI xmlURI;\ntypedef xmlURI *xmlURIPtr;\nstruct _xmlURI {\n    char *scheme;\t/* the URI scheme */\n    char *opaque;\t/* opaque part */\n    char *authority;\t/* the authority part */\n    char *server;\t/* the server part */\n    char *user;\t\t/* the user part */\n    int port;\t\t/* the port number */\n    char *path;\t\t/* the path string */\n    char *query;\t/* the query string (deprecated - use with caution) */\n    char *fragment;\t/* the fragment identifier */\n    int  cleanup;\t/* parsing potentially unclean URI */\n    char *query_raw;\t/* the query string (as it appears in the URI) */\n};\n\n/*\n * This function is in tree.h:\n * xmlChar *\txmlNodeGetBase\t(xmlDocPtr doc,\n *                               xmlNodePtr cur);\n */\nXMLPUBFUN xmlURIPtr\n\t\txmlCreateURI\t\t(void);\nXMLPUBFUN xmlChar *\n\t\txmlBuildURI\t\t(const xmlChar *URI,\n\t\t\t\t\t const xmlChar *base);\nXMLPUBFUN xmlChar *\n\t\txmlBuildRelativeURI\t(const xmlChar *URI,\n\t\t\t\t\t const xmlChar *base);\nXMLPUBFUN xmlURIPtr\n\t\txmlParseURI\t\t(const char *str);\nXMLPUBFUN xmlURIPtr\n\t\txmlParseURIRaw\t\t(const char *str,\n\t\t\t\t\t int raw);\nXMLPUBFUN int\n\t\txmlParseURIReference\t(xmlURIPtr uri,\n\t\t\t\t\t const char *str);\nXMLPUBFUN xmlChar *\n\t\txmlSaveUri\t\t(xmlURIPtr uri);\nXMLPUBFUN void\n\t\txmlPrintURI\t\t(FILE *stream,\n\t\t\t\t\t xmlURIPtr uri);\nXMLPUBFUN xmlChar *\n\t\txmlURIEscapeStr         (const xmlChar *str,\n\t\t\t\t\t const xmlChar *list);\nXMLPUBFUN char *\n\t\txmlURIUnescapeString\t(const char *str,\n\t\t\t\t\t int len,\n\t\t\t\t\t char *target);\nXMLPUBFUN int\n\t\txmlNormalizeURIPath\t(char *path);\nXMLPUBFUN xmlChar *\n\t\txmlURIEscape\t\t(const xmlChar *str);\nXMLPUBFUN void\n\t\txmlFreeURI\t\t(xmlURIPtr uri);\nXMLPUBFUN xmlChar*\n\t\txmlCanonicPath\t\t(const xmlChar *path);\nXMLPUBFUN xmlChar*\n\t\txmlPathToURI\t\t(const xmlChar *path);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_URI_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/valid.h",
    "content": "/*\n * Summary: The DTD validation\n * Description: API for the DTD handling and the validity checking\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_VALID_H__\n#define __XML_VALID_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/xmlerror.h>\n#include <libxml/tree.h>\n#include <libxml/list.h>\n#include <libxml/xmlautomata.h>\n#include <libxml/xmlregexp.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Validation state added for non-determinist content model.\n */\ntypedef struct _xmlValidState xmlValidState;\ntypedef xmlValidState *xmlValidStatePtr;\n\n/**\n * xmlValidityErrorFunc:\n * @ctx:  usually an xmlValidCtxtPtr to a validity error context,\n *        but comes from ctxt->userData (which normally contains such\n *        a pointer); ctxt->userData can be changed by the user.\n * @msg:  the string to format *printf like vararg\n * @...:  remaining arguments to the format\n *\n * Callback called when a validity error is found. This is a message\n * oriented function similar to an *printf function.\n */\ntypedef void (*xmlValidityErrorFunc) (void *ctx,\n\t\t\t     const char *msg,\n\t\t\t     ...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * xmlValidityWarningFunc:\n * @ctx:  usually an xmlValidCtxtPtr to a validity error context,\n *        but comes from ctxt->userData (which normally contains such\n *        a pointer); ctxt->userData can be changed by the user.\n * @msg:  the string to format *printf like vararg\n * @...:  remaining arguments to the format\n *\n * Callback called when a validity warning is found. This is a message\n * oriented function similar to an *printf function.\n */\ntypedef void (*xmlValidityWarningFunc) (void *ctx,\n\t\t\t       const char *msg,\n\t\t\t       ...) LIBXML_ATTR_FORMAT(2,3);\n\n/*\n * xmlValidCtxt:\n * An xmlValidCtxt is used for error reporting when validating.\n */\ntypedef struct _xmlValidCtxt xmlValidCtxt;\ntypedef xmlValidCtxt *xmlValidCtxtPtr;\nstruct _xmlValidCtxt {\n    void *userData;\t\t\t/* user specific data block */\n    xmlValidityErrorFunc error;\t\t/* the callback in case of errors */\n    xmlValidityWarningFunc warning;\t/* the callback in case of warning */\n\n    /* Node analysis stack used when validating within entities */\n    xmlNodePtr         node;          /* Current parsed Node */\n    int                nodeNr;        /* Depth of the parsing stack */\n    int                nodeMax;       /* Max depth of the parsing stack */\n    xmlNodePtr        *nodeTab;       /* array of nodes */\n\n    unsigned int         flags;       /* internal flags */\n    xmlDocPtr              doc;       /* the document */\n    int                  valid;       /* temporary validity check result */\n\n    /* state state used for non-determinist content validation */\n    xmlValidState     *vstate;        /* current state */\n    int                vstateNr;      /* Depth of the validation stack */\n    int                vstateMax;     /* Max depth of the validation stack */\n    xmlValidState     *vstateTab;     /* array of validation states */\n\n#ifdef LIBXML_REGEXP_ENABLED\n    xmlAutomataPtr            am;     /* the automata */\n    xmlAutomataStatePtr    state;     /* used to build the automata */\n#else\n    void                     *am;\n    void                  *state;\n#endif\n};\n\n/*\n * ALL notation declarations are stored in a table.\n * There is one table per DTD.\n */\n\ntypedef struct _xmlHashTable xmlNotationTable;\ntypedef xmlNotationTable *xmlNotationTablePtr;\n\n/*\n * ALL element declarations are stored in a table.\n * There is one table per DTD.\n */\n\ntypedef struct _xmlHashTable xmlElementTable;\ntypedef xmlElementTable *xmlElementTablePtr;\n\n/*\n * ALL attribute declarations are stored in a table.\n * There is one table per DTD.\n */\n\ntypedef struct _xmlHashTable xmlAttributeTable;\ntypedef xmlAttributeTable *xmlAttributeTablePtr;\n\n/*\n * ALL IDs attributes are stored in a table.\n * There is one table per document.\n */\n\ntypedef struct _xmlHashTable xmlIDTable;\ntypedef xmlIDTable *xmlIDTablePtr;\n\n/*\n * ALL Refs attributes are stored in a table.\n * There is one table per document.\n */\n\ntypedef struct _xmlHashTable xmlRefTable;\ntypedef xmlRefTable *xmlRefTablePtr;\n\n/* Notation */\nXMLPUBFUN xmlNotationPtr\n\t\txmlAddNotationDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *PublicID,\n\t\t\t\t\t const xmlChar *SystemID);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlNotationTablePtr\n\t\txmlCopyNotationTable\t(xmlNotationTablePtr table);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlFreeNotationTable\t(xmlNotationTablePtr table);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlDumpNotationDecl\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlNotationPtr nota);\nXMLPUBFUN void\n\t\txmlDumpNotationTable\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlNotationTablePtr table);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n/* Element Content */\n/* the non Doc version are being deprecated */\nXMLPUBFUN xmlElementContentPtr\n\t\txmlNewElementContent\t(const xmlChar *name,\n\t\t\t\t\t xmlElementContentType type);\nXMLPUBFUN xmlElementContentPtr\n\t\txmlCopyElementContent\t(xmlElementContentPtr content);\nXMLPUBFUN void\n\t\txmlFreeElementContent\t(xmlElementContentPtr cur);\n/* the new versions with doc argument */\nXMLPUBFUN xmlElementContentPtr\n\t\txmlNewDocElementContent\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t xmlElementContentType type);\nXMLPUBFUN xmlElementContentPtr\n\t\txmlCopyDocElementContent(xmlDocPtr doc,\n\t\t\t\t\t xmlElementContentPtr content);\nXMLPUBFUN void\n\t\txmlFreeDocElementContent(xmlDocPtr doc,\n\t\t\t\t\t xmlElementContentPtr cur);\nXMLPUBFUN void\n\t\txmlSnprintfElementContent(char *buf,\n\t\t\t\t\t int size,\n\t                                 xmlElementContentPtr content,\n\t\t\t\t\t int englob);\n#ifdef LIBXML_OUTPUT_ENABLED\n/* DEPRECATED */\nXMLPUBFUN void\n\t\txmlSprintfElementContent(char *buf,\n\t                                 xmlElementContentPtr content,\n\t\t\t\t\t int englob);\n#endif /* LIBXML_OUTPUT_ENABLED */\n/* DEPRECATED */\n\n/* Element */\nXMLPUBFUN xmlElementPtr\n\t\txmlAddElementDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t xmlElementTypeVal type,\n\t\t\t\t\t xmlElementContentPtr content);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlElementTablePtr\n\t\txmlCopyElementTable\t(xmlElementTablePtr table);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlFreeElementTable\t(xmlElementTablePtr table);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlDumpElementTable\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlElementTablePtr table);\nXMLPUBFUN void\n\t\txmlDumpElementDecl\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlElementPtr elem);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n/* Enumeration */\nXMLPUBFUN xmlEnumerationPtr\n\t\txmlCreateEnumeration\t(const xmlChar *name);\nXMLPUBFUN void\n\t\txmlFreeEnumeration\t(xmlEnumerationPtr cur);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlEnumerationPtr\n\t\txmlCopyEnumeration\t(xmlEnumerationPtr cur);\n#endif /* LIBXML_TREE_ENABLED */\n\n/* Attribute */\nXMLPUBFUN xmlAttributePtr\n\t\txmlAddAttributeDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *ns,\n\t\t\t\t\t xmlAttributeType type,\n\t\t\t\t\t xmlAttributeDefault def,\n\t\t\t\t\t const xmlChar *defaultValue,\n\t\t\t\t\t xmlEnumerationPtr tree);\n#ifdef LIBXML_TREE_ENABLED\nXMLPUBFUN xmlAttributeTablePtr\n\t\txmlCopyAttributeTable  (xmlAttributeTablePtr table);\n#endif /* LIBXML_TREE_ENABLED */\nXMLPUBFUN void\n\t\txmlFreeAttributeTable  (xmlAttributeTablePtr table);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t\txmlDumpAttributeTable  (xmlBufferPtr buf,\n\t\t\t\t\txmlAttributeTablePtr table);\nXMLPUBFUN void\n\t\txmlDumpAttributeDecl   (xmlBufferPtr buf,\n\t\t\t\t\txmlAttributePtr attr);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n/* IDs */\nXMLPUBFUN xmlIDPtr\n\t\txmlAddID\t       (xmlValidCtxtPtr ctxt,\n\t\t\t\t\txmlDocPtr doc,\n\t\t\t\t\tconst xmlChar *value,\n\t\t\t\t\txmlAttrPtr attr);\nXMLPUBFUN void\n\t\txmlFreeIDTable\t       (xmlIDTablePtr table);\nXMLPUBFUN xmlAttrPtr\n\t\txmlGetID\t       (xmlDocPtr doc,\n\t\t\t\t\tconst xmlChar *ID);\nXMLPUBFUN int\n\t\txmlIsID\t\t       (xmlDocPtr doc,\n\t\t\t\t\txmlNodePtr elem,\n\t\t\t\t\txmlAttrPtr attr);\nXMLPUBFUN int\n\t\txmlRemoveID\t       (xmlDocPtr doc,\n\t\t\t\t\txmlAttrPtr attr);\n\n/* IDREFs */\nXML_DEPRECATED\nXMLPUBFUN xmlRefPtr\n\t\txmlAddRef\t       (xmlValidCtxtPtr ctxt,\n\t\t\t\t\txmlDocPtr doc,\n\t\t\t\t\tconst xmlChar *value,\n\t\t\t\t\txmlAttrPtr attr);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlFreeRefTable\t       (xmlRefTablePtr table);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlIsRef\t       (xmlDocPtr doc,\n\t\t\t\t\txmlNodePtr elem,\n\t\t\t\t\txmlAttrPtr attr);\nXML_DEPRECATED\nXMLPUBFUN int\n\t\txmlRemoveRef\t       (xmlDocPtr doc,\n\t\t\t\t\txmlAttrPtr attr);\nXML_DEPRECATED\nXMLPUBFUN xmlListPtr\n\t\txmlGetRefs\t       (xmlDocPtr doc,\n\t\t\t\t\tconst xmlChar *ID);\n\n/**\n * The public function calls related to validity checking.\n */\n#ifdef LIBXML_VALID_ENABLED\n/* Allocate/Release Validation Contexts */\nXMLPUBFUN xmlValidCtxtPtr\n\t\txmlNewValidCtxt(void);\nXMLPUBFUN void\n\t\txmlFreeValidCtxt(xmlValidCtxtPtr);\n\nXMLPUBFUN int\n\t\txmlValidateRoot\t\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlValidateElementDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t                         xmlElementPtr elem);\nXMLPUBFUN xmlChar *\n\t\txmlValidNormalizeAttributeValue(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlChar *\n\t\txmlValidCtxtNormalizeAttributeValue(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateAttributeDecl(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t                         xmlAttributePtr attr);\nXMLPUBFUN int\n\t\txmlValidateAttributeValue(xmlAttributeType type,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateNotationDecl\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t                         xmlNotationPtr nota);\nXMLPUBFUN int\n\t\txmlValidateDtd\t\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlDtdPtr dtd);\nXMLPUBFUN int\n\t\txmlValidateDtdFinal\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlValidateDocument\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlValidateElement\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem);\nXMLPUBFUN int\n\t\txmlValidateOneElement\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t                         xmlNodePtr elem);\nXMLPUBFUN int\n\t\txmlValidateOneAttribute\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr\telem,\n\t\t\t\t\t xmlAttrPtr attr,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateOneNamespace\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t xmlNsPtr ns,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateDocumentFinal(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\n#endif /* LIBXML_VALID_ENABLED */\n\n#if defined(LIBXML_VALID_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXMLPUBFUN int\n\t\txmlValidateNotationUse\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *notationName);\n#endif /* LIBXML_VALID_ENABLED or LIBXML_SCHEMAS_ENABLED */\n\nXMLPUBFUN int\n\t\txmlIsMixedElement\t(xmlDocPtr doc,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlAttributePtr\n\t\txmlGetDtdAttrDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlAttributePtr\n\t\txmlGetDtdQAttrDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *elem,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN xmlNotationPtr\n\t\txmlGetDtdNotationDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlElementPtr\n\t\txmlGetDtdQElementDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN xmlElementPtr\n\t\txmlGetDtdElementDesc\t(xmlDtdPtr dtd,\n\t\t\t\t\t const xmlChar *name);\n\n#ifdef LIBXML_VALID_ENABLED\n\nXMLPUBFUN int\n\t\txmlValidGetPotentialChildren(xmlElementContent *ctree,\n\t\t\t\t\t const xmlChar **names,\n\t\t\t\t\t int *len,\n\t\t\t\t\t int max);\n\nXMLPUBFUN int\n\t\txmlValidGetValidElements(xmlNode *prev,\n\t\t\t\t\t xmlNode *next,\n\t\t\t\t\t const xmlChar **names,\n\t\t\t\t\t int max);\nXMLPUBFUN int\n\t\txmlValidateNameValue\t(const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateNamesValue\t(const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateNmtokenValue\t(const xmlChar *value);\nXMLPUBFUN int\n\t\txmlValidateNmtokensValue(const xmlChar *value);\n\n#ifdef LIBXML_REGEXP_ENABLED\n/*\n * Validation based on the regexp support\n */\nXMLPUBFUN int\n\t\txmlValidBuildContentModel(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlElementPtr elem);\n\nXMLPUBFUN int\n\t\txmlValidatePushElement\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *qname);\nXMLPUBFUN int\n\t\txmlValidatePushCData\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *data,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\txmlValidatePopElement\t(xmlValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr elem,\n\t\t\t\t\t const xmlChar *qname);\n#endif /* LIBXML_REGEXP_ENABLED */\n#endif /* LIBXML_VALID_ENABLED */\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_VALID_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xinclude.h",
    "content": "/*\n * Summary: implementation of XInclude\n * Description: API to handle XInclude processing,\n * implements the\n * World Wide Web Consortium Last Call Working Draft 10 November 2003\n * http://www.w3.org/TR/2003/WD-xinclude-20031110\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XINCLUDE_H__\n#define __XML_XINCLUDE_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef LIBXML_XINCLUDE_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * XINCLUDE_NS:\n *\n * Macro defining the Xinclude namespace: http://www.w3.org/2003/XInclude\n */\n#define XINCLUDE_NS (const xmlChar *) \"http://www.w3.org/2003/XInclude\"\n/**\n * XINCLUDE_OLD_NS:\n *\n * Macro defining the draft Xinclude namespace: http://www.w3.org/2001/XInclude\n */\n#define XINCLUDE_OLD_NS (const xmlChar *) \"http://www.w3.org/2001/XInclude\"\n/**\n * XINCLUDE_NODE:\n *\n * Macro defining \"include\"\n */\n#define XINCLUDE_NODE (const xmlChar *) \"include\"\n/**\n * XINCLUDE_FALLBACK:\n *\n * Macro defining \"fallback\"\n */\n#define XINCLUDE_FALLBACK (const xmlChar *) \"fallback\"\n/**\n * XINCLUDE_HREF:\n *\n * Macro defining \"href\"\n */\n#define XINCLUDE_HREF (const xmlChar *) \"href\"\n/**\n * XINCLUDE_PARSE:\n *\n * Macro defining \"parse\"\n */\n#define XINCLUDE_PARSE (const xmlChar *) \"parse\"\n/**\n * XINCLUDE_PARSE_XML:\n *\n * Macro defining \"xml\"\n */\n#define XINCLUDE_PARSE_XML (const xmlChar *) \"xml\"\n/**\n * XINCLUDE_PARSE_TEXT:\n *\n * Macro defining \"text\"\n */\n#define XINCLUDE_PARSE_TEXT (const xmlChar *) \"text\"\n/**\n * XINCLUDE_PARSE_ENCODING:\n *\n * Macro defining \"encoding\"\n */\n#define XINCLUDE_PARSE_ENCODING (const xmlChar *) \"encoding\"\n/**\n * XINCLUDE_PARSE_XPOINTER:\n *\n * Macro defining \"xpointer\"\n */\n#define XINCLUDE_PARSE_XPOINTER (const xmlChar *) \"xpointer\"\n\ntypedef struct _xmlXIncludeCtxt xmlXIncludeCtxt;\ntypedef xmlXIncludeCtxt *xmlXIncludeCtxtPtr;\n\n/*\n * standalone processing\n */\nXMLPUBFUN int\n\t\txmlXIncludeProcess\t(xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlXIncludeProcessFlags\t(xmlDocPtr doc,\n\t\t\t\t\t int flags);\nXMLPUBFUN int\n\t\txmlXIncludeProcessFlagsData(xmlDocPtr doc,\n\t\t\t\t\t int flags,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n                xmlXIncludeProcessTreeFlagsData(xmlNodePtr tree,\n                                         int flags,\n                                         void *data);\nXMLPUBFUN int\n\t\txmlXIncludeProcessTree\t(xmlNodePtr tree);\nXMLPUBFUN int\n\t\txmlXIncludeProcessTreeFlags(xmlNodePtr tree,\n\t\t\t\t\t int flags);\n/*\n * contextual processing\n */\nXMLPUBFUN xmlXIncludeCtxtPtr\n\t\txmlXIncludeNewContext\t(xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlXIncludeSetFlags\t(xmlXIncludeCtxtPtr ctxt,\n\t\t\t\t\t int flags);\nXMLPUBFUN void\n\t\txmlXIncludeFreeContext\t(xmlXIncludeCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlXIncludeProcessNode\t(xmlXIncludeCtxtPtr ctxt,\n\t\t\t\t\t xmlNodePtr tree);\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XINCLUDE_ENABLED */\n\n#endif /* __XML_XINCLUDE_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xlink.h",
    "content": "/*\n * Summary: unfinished XLink detection module\n * Description: unfinished XLink detection module\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XLINK_H__\n#define __XML_XLINK_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n\n#ifdef LIBXML_XPTR_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * Various defines for the various Link properties.\n *\n * NOTE: the link detection layer will try to resolve QName expansion\n *       of namespaces. If \"foo\" is the prefix for \"http://foo.com/\"\n *       then the link detection layer will expand role=\"foo:myrole\"\n *       to \"http://foo.com/:myrole\".\n * NOTE: the link detection layer will expand URI-References found on\n *       href attributes by using the base mechanism if found.\n */\ntypedef xmlChar *xlinkHRef;\ntypedef xmlChar *xlinkRole;\ntypedef xmlChar *xlinkTitle;\n\ntypedef enum {\n    XLINK_TYPE_NONE = 0,\n    XLINK_TYPE_SIMPLE,\n    XLINK_TYPE_EXTENDED,\n    XLINK_TYPE_EXTENDED_SET\n} xlinkType;\n\ntypedef enum {\n    XLINK_SHOW_NONE = 0,\n    XLINK_SHOW_NEW,\n    XLINK_SHOW_EMBED,\n    XLINK_SHOW_REPLACE\n} xlinkShow;\n\ntypedef enum {\n    XLINK_ACTUATE_NONE = 0,\n    XLINK_ACTUATE_AUTO,\n    XLINK_ACTUATE_ONREQUEST\n} xlinkActuate;\n\n/**\n * xlinkNodeDetectFunc:\n * @ctx:  user data pointer\n * @node:  the node to check\n *\n * This is the prototype for the link detection routine.\n * It calls the default link detection callbacks upon link detection.\n */\ntypedef void (*xlinkNodeDetectFunc) (void *ctx, xmlNodePtr node);\n\n/*\n * The link detection module interact with the upper layers using\n * a set of callback registered at parsing time.\n */\n\n/**\n * xlinkSimpleLinkFunk:\n * @ctx:  user data pointer\n * @node:  the node carrying the link\n * @href:  the target of the link\n * @role:  the role string\n * @title:  the link title\n *\n * This is the prototype for a simple link detection callback.\n */\ntypedef void\n(*xlinkSimpleLinkFunk)\t(void *ctx,\n\t\t\t xmlNodePtr node,\n\t\t\t const xlinkHRef href,\n\t\t\t const xlinkRole role,\n\t\t\t const xlinkTitle title);\n\n/**\n * xlinkExtendedLinkFunk:\n * @ctx:  user data pointer\n * @node:  the node carrying the link\n * @nbLocators: the number of locators detected on the link\n * @hrefs:  pointer to the array of locator hrefs\n * @roles:  pointer to the array of locator roles\n * @nbArcs: the number of arcs detected on the link\n * @from:  pointer to the array of source roles found on the arcs\n * @to:  pointer to the array of target roles found on the arcs\n * @show:  array of values for the show attributes found on the arcs\n * @actuate:  array of values for the actuate attributes found on the arcs\n * @nbTitles: the number of titles detected on the link\n * @title:  array of titles detected on the link\n * @langs:  array of xml:lang values for the titles\n *\n * This is the prototype for a extended link detection callback.\n */\ntypedef void\n(*xlinkExtendedLinkFunk)(void *ctx,\n\t\t\t xmlNodePtr node,\n\t\t\t int nbLocators,\n\t\t\t const xlinkHRef *hrefs,\n\t\t\t const xlinkRole *roles,\n\t\t\t int nbArcs,\n\t\t\t const xlinkRole *from,\n\t\t\t const xlinkRole *to,\n\t\t\t xlinkShow *show,\n\t\t\t xlinkActuate *actuate,\n\t\t\t int nbTitles,\n\t\t\t const xlinkTitle *titles,\n\t\t\t const xmlChar **langs);\n\n/**\n * xlinkExtendedLinkSetFunk:\n * @ctx:  user data pointer\n * @node:  the node carrying the link\n * @nbLocators: the number of locators detected on the link\n * @hrefs:  pointer to the array of locator hrefs\n * @roles:  pointer to the array of locator roles\n * @nbTitles: the number of titles detected on the link\n * @title:  array of titles detected on the link\n * @langs:  array of xml:lang values for the titles\n *\n * This is the prototype for a extended link set detection callback.\n */\ntypedef void\n(*xlinkExtendedLinkSetFunk)\t(void *ctx,\n\t\t\t\t xmlNodePtr node,\n\t\t\t\t int nbLocators,\n\t\t\t\t const xlinkHRef *hrefs,\n\t\t\t\t const xlinkRole *roles,\n\t\t\t\t int nbTitles,\n\t\t\t\t const xlinkTitle *titles,\n\t\t\t\t const xmlChar **langs);\n\n/**\n * This is the structure containing a set of Links detection callbacks.\n *\n * There is no default xlink callbacks, if one want to get link\n * recognition activated, those call backs must be provided before parsing.\n */\ntypedef struct _xlinkHandler xlinkHandler;\ntypedef xlinkHandler *xlinkHandlerPtr;\nstruct _xlinkHandler {\n    xlinkSimpleLinkFunk simple;\n    xlinkExtendedLinkFunk extended;\n    xlinkExtendedLinkSetFunk set;\n};\n\n/*\n * The default detection routine, can be overridden, they call the default\n * detection callbacks.\n */\n\nXMLPUBFUN xlinkNodeDetectFunc\n\t\txlinkGetDefaultDetect\t(void);\nXMLPUBFUN void\n\t\txlinkSetDefaultDetect\t(xlinkNodeDetectFunc func);\n\n/*\n * Routines to set/get the default handlers.\n */\nXMLPUBFUN xlinkHandlerPtr\n\t\txlinkGetDefaultHandler\t(void);\nXMLPUBFUN void\n\t\txlinkSetDefaultHandler\t(xlinkHandlerPtr handler);\n\n/*\n * Link detection module itself.\n */\nXMLPUBFUN xlinkType\n\t\txlinkIsLink\t\t(xmlDocPtr doc,\n\t\t\t\t\t xmlNodePtr node);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XPTR_ENABLED */\n\n#endif /* __XML_XLINK_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlIO.h",
    "content": "/*\n * Summary: interface for the I/O interfaces used by the parser\n * Description: interface for the I/O interfaces used by the parser\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_IO_H__\n#define __XML_IO_H__\n\n#include <stdio.h>\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * Those are the functions and datatypes for the parser input\n * I/O structures.\n */\n\n/**\n * xmlInputMatchCallback:\n * @filename: the filename or URI\n *\n * Callback used in the I/O Input API to detect if the current handler\n * can provide input functionality for this resource.\n *\n * Returns 1 if yes and 0 if another Input module should be used\n */\ntypedef int (*xmlInputMatchCallback) (char const *filename);\n/**\n * xmlInputOpenCallback:\n * @filename: the filename or URI\n *\n * Callback used in the I/O Input API to open the resource\n *\n * Returns an Input context or NULL in case or error\n */\ntypedef void * (*xmlInputOpenCallback) (char const *filename);\n/**\n * xmlInputReadCallback:\n * @context:  an Input context\n * @buffer:  the buffer to store data read\n * @len:  the length of the buffer in bytes\n *\n * Callback used in the I/O Input API to read the resource\n *\n * Returns the number of bytes read or -1 in case of error\n */\ntypedef int (*xmlInputReadCallback) (void * context, char * buffer, int len);\n/**\n * xmlInputCloseCallback:\n * @context:  an Input context\n *\n * Callback used in the I/O Input API to close the resource\n *\n * Returns 0 or -1 in case of error\n */\ntypedef int (*xmlInputCloseCallback) (void * context);\n\n#ifdef LIBXML_OUTPUT_ENABLED\n/*\n * Those are the functions and datatypes for the library output\n * I/O structures.\n */\n\n/**\n * xmlOutputMatchCallback:\n * @filename: the filename or URI\n *\n * Callback used in the I/O Output API to detect if the current handler\n * can provide output functionality for this resource.\n *\n * Returns 1 if yes and 0 if another Output module should be used\n */\ntypedef int (*xmlOutputMatchCallback) (char const *filename);\n/**\n * xmlOutputOpenCallback:\n * @filename: the filename or URI\n *\n * Callback used in the I/O Output API to open the resource\n *\n * Returns an Output context or NULL in case or error\n */\ntypedef void * (*xmlOutputOpenCallback) (char const *filename);\n/**\n * xmlOutputWriteCallback:\n * @context:  an Output context\n * @buffer:  the buffer of data to write\n * @len:  the length of the buffer in bytes\n *\n * Callback used in the I/O Output API to write to the resource\n *\n * Returns the number of bytes written or -1 in case of error\n */\ntypedef int (*xmlOutputWriteCallback) (void * context, const char * buffer,\n                                       int len);\n/**\n * xmlOutputCloseCallback:\n * @context:  an Output context\n *\n * Callback used in the I/O Output API to close the resource\n *\n * Returns 0 or -1 in case of error\n */\ntypedef int (*xmlOutputCloseCallback) (void * context);\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#include <libxml/globals.h>\n#include <libxml/tree.h>\n#include <libxml/parser.h>\n#include <libxml/encoding.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\nstruct _xmlParserInputBuffer {\n    void*                  context;\n    xmlInputReadCallback   readcallback;\n    xmlInputCloseCallback  closecallback;\n\n    xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */\n\n    xmlBufPtr buffer;    /* Local buffer encoded in UTF-8 */\n    xmlBufPtr raw;       /* if encoder != NULL buffer for raw input */\n    int\tcompressed;\t    /* -1=unknown, 0=not compressed, 1=compressed */\n    int error;\n    unsigned long rawconsumed;/* amount consumed from raw */\n};\n\n\n#ifdef LIBXML_OUTPUT_ENABLED\nstruct _xmlOutputBuffer {\n    void*                   context;\n    xmlOutputWriteCallback  writecallback;\n    xmlOutputCloseCallback  closecallback;\n\n    xmlCharEncodingHandlerPtr encoder; /* I18N conversions to UTF-8 */\n\n    xmlBufPtr buffer;    /* Local buffer encoded in UTF-8 or ISOLatin */\n    xmlBufPtr conv;      /* if encoder != NULL buffer for output */\n    int written;            /* total number of byte written */\n    int error;\n};\n#endif /* LIBXML_OUTPUT_ENABLED */\n\n/*\n * Interfaces for input\n */\nXMLPUBFUN void\n\txmlCleanupInputCallbacks\t\t(void);\n\nXMLPUBFUN int\n\txmlPopInputCallbacks\t\t\t(void);\n\nXMLPUBFUN void\n\txmlRegisterDefaultInputCallbacks\t(void);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlAllocParserInputBuffer\t\t(xmlCharEncoding enc);\n\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateFilename\t(const char *URI,\n                                                 xmlCharEncoding enc);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateFile\t\t(FILE *file,\n                                                 xmlCharEncoding enc);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateFd\t\t(int fd,\n\t                                         xmlCharEncoding enc);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateMem\t\t(const char *mem, int size,\n\t                                         xmlCharEncoding enc);\nXML_DEPRECATED\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateStatic\t(const char *mem, int size,\n\t                                         xmlCharEncoding enc);\nXMLPUBFUN xmlParserInputBufferPtr\n\txmlParserInputBufferCreateIO\t\t(xmlInputReadCallback   ioread,\n\t\t\t\t\t\t xmlInputCloseCallback  ioclose,\n\t\t\t\t\t\t void *ioctx,\n\t                                         xmlCharEncoding enc);\nXMLPUBFUN int\n\txmlParserInputBufferRead\t\t(xmlParserInputBufferPtr in,\n\t\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlParserInputBufferGrow\t\t(xmlParserInputBufferPtr in,\n\t\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlParserInputBufferPush\t\t(xmlParserInputBufferPtr in,\n\t\t\t\t\t\t int len,\n\t\t\t\t\t\t const char *buf);\nXMLPUBFUN void\n\txmlFreeParserInputBuffer\t\t(xmlParserInputBufferPtr in);\nXMLPUBFUN char *\n\txmlParserGetDirectory\t\t\t(const char *filename);\n\nXMLPUBFUN int\n\txmlRegisterInputCallbacks\t\t(xmlInputMatchCallback matchFunc,\n\t\t\t\t\t\t xmlInputOpenCallback openFunc,\n\t\t\t\t\t\t xmlInputReadCallback readFunc,\n\t\t\t\t\t\t xmlInputCloseCallback closeFunc);\n\nxmlParserInputBufferPtr\n\t__xmlParserInputBufferCreateFilename(const char *URI,\n\t\t\t\t\t\txmlCharEncoding enc);\n\n#ifdef LIBXML_OUTPUT_ENABLED\n/*\n * Interfaces for output\n */\nXMLPUBFUN void\n\txmlCleanupOutputCallbacks\t\t(void);\nXMLPUBFUN int\n\txmlPopOutputCallbacks\t\t\t(void);\nXMLPUBFUN void\n\txmlRegisterDefaultOutputCallbacks(void);\nXMLPUBFUN xmlOutputBufferPtr\n\txmlAllocOutputBuffer\t\t(xmlCharEncodingHandlerPtr encoder);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateFilename\t(const char *URI,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder,\n\t\t\t\t\t int compression);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateFile\t(FILE *file,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateBuffer\t(xmlBufferPtr buffer,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateFd\t\t(int fd,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder);\n\nXMLPUBFUN xmlOutputBufferPtr\n\txmlOutputBufferCreateIO\t\t(xmlOutputWriteCallback   iowrite,\n\t\t\t\t\t xmlOutputCloseCallback  ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t xmlCharEncodingHandlerPtr encoder);\n\n/* Couple of APIs to get the output without digging into the buffers */\nXMLPUBFUN const xmlChar *\n        xmlOutputBufferGetContent       (xmlOutputBufferPtr out);\nXMLPUBFUN size_t\n        xmlOutputBufferGetSize          (xmlOutputBufferPtr out);\n\nXMLPUBFUN int\n\txmlOutputBufferWrite\t\t(xmlOutputBufferPtr out,\n\t\t\t\t\t int len,\n\t\t\t\t\t const char *buf);\nXMLPUBFUN int\n\txmlOutputBufferWriteString\t(xmlOutputBufferPtr out,\n\t\t\t\t\t const char *str);\nXMLPUBFUN int\n\txmlOutputBufferWriteEscape\t(xmlOutputBufferPtr out,\n\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t xmlCharEncodingOutputFunc escaping);\n\nXMLPUBFUN int\n\txmlOutputBufferFlush\t\t(xmlOutputBufferPtr out);\nXMLPUBFUN int\n\txmlOutputBufferClose\t\t(xmlOutputBufferPtr out);\n\nXMLPUBFUN int\n\txmlRegisterOutputCallbacks\t(xmlOutputMatchCallback matchFunc,\n\t\t\t\t\t xmlOutputOpenCallback openFunc,\n\t\t\t\t\t xmlOutputWriteCallback writeFunc,\n\t\t\t\t\t xmlOutputCloseCallback closeFunc);\n\nxmlOutputBufferPtr\n\t__xmlOutputBufferCreateFilename(const char *URI,\n                              xmlCharEncodingHandlerPtr encoder,\n                              int compression);\n\n#ifdef LIBXML_HTTP_ENABLED\n/*  This function only exists if HTTP support built into the library  */\nXMLPUBFUN void\n\txmlRegisterHTTPPostCallbacks\t(void );\n#endif /* LIBXML_HTTP_ENABLED */\n\n#endif /* LIBXML_OUTPUT_ENABLED */\n\nXMLPUBFUN xmlParserInputPtr\n\txmlCheckHTTPInput\t\t(xmlParserCtxtPtr ctxt,\n\t\t\t\t\t xmlParserInputPtr ret);\n\n/*\n * A predefined entity loader disabling network accesses\n */\nXMLPUBFUN xmlParserInputPtr\n\txmlNoNetExternalEntityLoader\t(const char *URL,\n\t\t\t\t\t const char *ID,\n\t\t\t\t\t xmlParserCtxtPtr ctxt);\n\n/*\n * xmlNormalizeWindowsPath is obsolete, don't use it.\n * Check xmlCanonicPath in uri.h for a better alternative.\n */\nXMLPUBFUN xmlChar *\n\txmlNormalizeWindowsPath\t\t(const xmlChar *path);\n\nXMLPUBFUN int\n\txmlCheckFilename\t\t(const char *path);\n/**\n * Default 'file://' protocol callbacks\n */\nXMLPUBFUN int\n\txmlFileMatch\t\t\t(const char *filename);\nXMLPUBFUN void *\n\txmlFileOpen\t\t\t(const char *filename);\nXMLPUBFUN int\n\txmlFileRead\t\t\t(void * context,\n\t\t\t\t\t char * buffer,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlFileClose\t\t\t(void * context);\n\n/**\n * Default 'http://' protocol callbacks\n */\n#ifdef LIBXML_HTTP_ENABLED\nXMLPUBFUN int\n\txmlIOHTTPMatch\t\t\t(const char *filename);\nXMLPUBFUN void *\n\txmlIOHTTPOpen\t\t\t(const char *filename);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void *\n\txmlIOHTTPOpenW\t\t\t(const char * post_uri,\n\t\t\t\t\t int   compression );\n#endif /* LIBXML_OUTPUT_ENABLED */\nXMLPUBFUN int\n\txmlIOHTTPRead\t\t\t(void * context,\n\t\t\t\t\t char * buffer,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlIOHTTPClose\t\t\t(void * context);\n#endif /* LIBXML_HTTP_ENABLED */\n\n/**\n * Default 'ftp://' protocol callbacks\n */\n#ifdef LIBXML_FTP_ENABLED\nXMLPUBFUN int\n\txmlIOFTPMatch\t\t\t(const char *filename);\nXMLPUBFUN void *\n\txmlIOFTPOpen\t\t\t(const char *filename);\nXMLPUBFUN int\n\txmlIOFTPRead\t\t\t(void * context,\n\t\t\t\t\t char * buffer,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\txmlIOFTPClose\t\t\t(void * context);\n#endif /* LIBXML_FTP_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_IO_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlautomata.h",
    "content": "/*\n * Summary: API to build regexp automata\n * Description: the API to build regexp automata\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_AUTOMATA_H__\n#define __XML_AUTOMATA_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_REGEXP_ENABLED\n#ifdef LIBXML_AUTOMATA_ENABLED\n\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlAutomataPtr:\n *\n * A libxml automata description, It can be compiled into a regexp\n */\ntypedef struct _xmlAutomata xmlAutomata;\ntypedef xmlAutomata *xmlAutomataPtr;\n\n/**\n * xmlAutomataStatePtr:\n *\n * A state int the automata description,\n */\ntypedef struct _xmlAutomataState xmlAutomataState;\ntypedef xmlAutomataState *xmlAutomataStatePtr;\n\n/*\n * Building API\n */\nXMLPUBFUN xmlAutomataPtr\n\t\t    xmlNewAutomata\t\t(void);\nXMLPUBFUN void\n\t\t    xmlFreeAutomata\t\t(xmlAutomataPtr am);\n\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataGetInitState\t(xmlAutomataPtr am);\nXMLPUBFUN int\n\t\t    xmlAutomataSetFinalState\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr state);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewState\t\t(xmlAutomataPtr am);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewTransition\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewTransition2\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t const xmlChar *token2,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n                    xmlAutomataNewNegTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t const xmlChar *token2,\n\t\t\t\t\t\t void *data);\n\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewCountTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewCountTrans2\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t const xmlChar *token2,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewOnceTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewOnceTrans2\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t const xmlChar *token,\n\t\t\t\t\t\t const xmlChar *token2,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max,\n\t\t\t\t\t\t void *data);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewAllTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t int lax);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewEpsilon\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewCountedTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t int counter);\nXMLPUBFUN xmlAutomataStatePtr\n\t\t    xmlAutomataNewCounterTrans\t(xmlAutomataPtr am,\n\t\t\t\t\t\t xmlAutomataStatePtr from,\n\t\t\t\t\t\t xmlAutomataStatePtr to,\n\t\t\t\t\t\t int counter);\nXMLPUBFUN int\n\t\t    xmlAutomataNewCounter\t(xmlAutomataPtr am,\n\t\t\t\t\t\t int min,\n\t\t\t\t\t\t int max);\n\nXMLPUBFUN struct _xmlRegexp *\n\t\t    xmlAutomataCompile\t\t(xmlAutomataPtr am);\nXMLPUBFUN int\n\t\t    xmlAutomataIsDeterminist\t(xmlAutomataPtr am);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_AUTOMATA_ENABLED */\n#endif /* LIBXML_REGEXP_ENABLED */\n\n#endif /* __XML_AUTOMATA_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlerror.h",
    "content": "/*\n * Summary: error handling\n * Description: the API used to report errors\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#include <libxml/parser.h>\n\n#ifndef __XML_ERROR_H__\n#define __XML_ERROR_H__\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlErrorLevel:\n *\n * Indicates the level of an error\n */\ntypedef enum {\n    XML_ERR_NONE = 0,\n    XML_ERR_WARNING = 1,\t/* A simple warning */\n    XML_ERR_ERROR = 2,\t\t/* A recoverable error */\n    XML_ERR_FATAL = 3\t\t/* A fatal error */\n} xmlErrorLevel;\n\n/**\n * xmlErrorDomain:\n *\n * Indicates where an error may have come from\n */\ntypedef enum {\n    XML_FROM_NONE = 0,\n    XML_FROM_PARSER,\t/* The XML parser */\n    XML_FROM_TREE,\t/* The tree module */\n    XML_FROM_NAMESPACE,\t/* The XML Namespace module */\n    XML_FROM_DTD,\t/* The XML DTD validation with parser context*/\n    XML_FROM_HTML,\t/* The HTML parser */\n    XML_FROM_MEMORY,\t/* The memory allocator */\n    XML_FROM_OUTPUT,\t/* The serialization code */\n    XML_FROM_IO,\t/* The Input/Output stack */\n    XML_FROM_FTP,\t/* The FTP module */\n    XML_FROM_HTTP,\t/* The HTTP module */\n    XML_FROM_XINCLUDE,\t/* The XInclude processing */\n    XML_FROM_XPATH,\t/* The XPath module */\n    XML_FROM_XPOINTER,\t/* The XPointer module */\n    XML_FROM_REGEXP,\t/* The regular expressions module */\n    XML_FROM_DATATYPE,\t/* The W3C XML Schemas Datatype module */\n    XML_FROM_SCHEMASP,\t/* The W3C XML Schemas parser module */\n    XML_FROM_SCHEMASV,\t/* The W3C XML Schemas validation module */\n    XML_FROM_RELAXNGP,\t/* The Relax-NG parser module */\n    XML_FROM_RELAXNGV,\t/* The Relax-NG validator module */\n    XML_FROM_CATALOG,\t/* The Catalog module */\n    XML_FROM_C14N,\t/* The Canonicalization module */\n    XML_FROM_XSLT,\t/* The XSLT engine from libxslt */\n    XML_FROM_VALID,\t/* The XML DTD validation with valid context */\n    XML_FROM_CHECK,\t/* The error checking module */\n    XML_FROM_WRITER,\t/* The xmlwriter module */\n    XML_FROM_MODULE,\t/* The dynamically loaded module module*/\n    XML_FROM_I18N,\t/* The module handling character conversion */\n    XML_FROM_SCHEMATRONV,/* The Schematron validator module */\n    XML_FROM_BUFFER,    /* The buffers module */\n    XML_FROM_URI        /* The URI module */\n} xmlErrorDomain;\n\n/**\n * xmlError:\n *\n * An XML Error instance.\n */\n\ntypedef struct _xmlError xmlError;\ntypedef xmlError *xmlErrorPtr;\nstruct _xmlError {\n    int\t\tdomain;\t/* What part of the library raised this error */\n    int\t\tcode;\t/* The error code, e.g. an xmlParserError */\n    char       *message;/* human-readable informative error message */\n    xmlErrorLevel level;/* how consequent is the error */\n    char       *file;\t/* the filename */\n    int\t\tline;\t/* the line number if available */\n    char       *str1;\t/* extra string information */\n    char       *str2;\t/* extra string information */\n    char       *str3;\t/* extra string information */\n    int\t\tint1;\t/* extra number information */\n    int\t\tint2;\t/* error column # or 0 if N/A (todo: rename field when we would brk ABI) */\n    void       *ctxt;   /* the parser context if available */\n    void       *node;   /* the node in the tree */\n};\n\n/**\n * xmlParserError:\n *\n * This is an error that the XML (or HTML) parser can generate\n */\ntypedef enum {\n    XML_ERR_OK = 0,\n    XML_ERR_INTERNAL_ERROR, /* 1 */\n    XML_ERR_NO_MEMORY, /* 2 */\n    XML_ERR_DOCUMENT_START, /* 3 */\n    XML_ERR_DOCUMENT_EMPTY, /* 4 */\n    XML_ERR_DOCUMENT_END, /* 5 */\n    XML_ERR_INVALID_HEX_CHARREF, /* 6 */\n    XML_ERR_INVALID_DEC_CHARREF, /* 7 */\n    XML_ERR_INVALID_CHARREF, /* 8 */\n    XML_ERR_INVALID_CHAR, /* 9 */\n    XML_ERR_CHARREF_AT_EOF, /* 10 */\n    XML_ERR_CHARREF_IN_PROLOG, /* 11 */\n    XML_ERR_CHARREF_IN_EPILOG, /* 12 */\n    XML_ERR_CHARREF_IN_DTD, /* 13 */\n    XML_ERR_ENTITYREF_AT_EOF, /* 14 */\n    XML_ERR_ENTITYREF_IN_PROLOG, /* 15 */\n    XML_ERR_ENTITYREF_IN_EPILOG, /* 16 */\n    XML_ERR_ENTITYREF_IN_DTD, /* 17 */\n    XML_ERR_PEREF_AT_EOF, /* 18 */\n    XML_ERR_PEREF_IN_PROLOG, /* 19 */\n    XML_ERR_PEREF_IN_EPILOG, /* 20 */\n    XML_ERR_PEREF_IN_INT_SUBSET, /* 21 */\n    XML_ERR_ENTITYREF_NO_NAME, /* 22 */\n    XML_ERR_ENTITYREF_SEMICOL_MISSING, /* 23 */\n    XML_ERR_PEREF_NO_NAME, /* 24 */\n    XML_ERR_PEREF_SEMICOL_MISSING, /* 25 */\n    XML_ERR_UNDECLARED_ENTITY, /* 26 */\n    XML_WAR_UNDECLARED_ENTITY, /* 27 */\n    XML_ERR_UNPARSED_ENTITY, /* 28 */\n    XML_ERR_ENTITY_IS_EXTERNAL, /* 29 */\n    XML_ERR_ENTITY_IS_PARAMETER, /* 30 */\n    XML_ERR_UNKNOWN_ENCODING, /* 31 */\n    XML_ERR_UNSUPPORTED_ENCODING, /* 32 */\n    XML_ERR_STRING_NOT_STARTED, /* 33 */\n    XML_ERR_STRING_NOT_CLOSED, /* 34 */\n    XML_ERR_NS_DECL_ERROR, /* 35 */\n    XML_ERR_ENTITY_NOT_STARTED, /* 36 */\n    XML_ERR_ENTITY_NOT_FINISHED, /* 37 */\n    XML_ERR_LT_IN_ATTRIBUTE, /* 38 */\n    XML_ERR_ATTRIBUTE_NOT_STARTED, /* 39 */\n    XML_ERR_ATTRIBUTE_NOT_FINISHED, /* 40 */\n    XML_ERR_ATTRIBUTE_WITHOUT_VALUE, /* 41 */\n    XML_ERR_ATTRIBUTE_REDEFINED, /* 42 */\n    XML_ERR_LITERAL_NOT_STARTED, /* 43 */\n    XML_ERR_LITERAL_NOT_FINISHED, /* 44 */\n    XML_ERR_COMMENT_NOT_FINISHED, /* 45 */\n    XML_ERR_PI_NOT_STARTED, /* 46 */\n    XML_ERR_PI_NOT_FINISHED, /* 47 */\n    XML_ERR_NOTATION_NOT_STARTED, /* 48 */\n    XML_ERR_NOTATION_NOT_FINISHED, /* 49 */\n    XML_ERR_ATTLIST_NOT_STARTED, /* 50 */\n    XML_ERR_ATTLIST_NOT_FINISHED, /* 51 */\n    XML_ERR_MIXED_NOT_STARTED, /* 52 */\n    XML_ERR_MIXED_NOT_FINISHED, /* 53 */\n    XML_ERR_ELEMCONTENT_NOT_STARTED, /* 54 */\n    XML_ERR_ELEMCONTENT_NOT_FINISHED, /* 55 */\n    XML_ERR_XMLDECL_NOT_STARTED, /* 56 */\n    XML_ERR_XMLDECL_NOT_FINISHED, /* 57 */\n    XML_ERR_CONDSEC_NOT_STARTED, /* 58 */\n    XML_ERR_CONDSEC_NOT_FINISHED, /* 59 */\n    XML_ERR_EXT_SUBSET_NOT_FINISHED, /* 60 */\n    XML_ERR_DOCTYPE_NOT_FINISHED, /* 61 */\n    XML_ERR_MISPLACED_CDATA_END, /* 62 */\n    XML_ERR_CDATA_NOT_FINISHED, /* 63 */\n    XML_ERR_RESERVED_XML_NAME, /* 64 */\n    XML_ERR_SPACE_REQUIRED, /* 65 */\n    XML_ERR_SEPARATOR_REQUIRED, /* 66 */\n    XML_ERR_NMTOKEN_REQUIRED, /* 67 */\n    XML_ERR_NAME_REQUIRED, /* 68 */\n    XML_ERR_PCDATA_REQUIRED, /* 69 */\n    XML_ERR_URI_REQUIRED, /* 70 */\n    XML_ERR_PUBID_REQUIRED, /* 71 */\n    XML_ERR_LT_REQUIRED, /* 72 */\n    XML_ERR_GT_REQUIRED, /* 73 */\n    XML_ERR_LTSLASH_REQUIRED, /* 74 */\n    XML_ERR_EQUAL_REQUIRED, /* 75 */\n    XML_ERR_TAG_NAME_MISMATCH, /* 76 */\n    XML_ERR_TAG_NOT_FINISHED, /* 77 */\n    XML_ERR_STANDALONE_VALUE, /* 78 */\n    XML_ERR_ENCODING_NAME, /* 79 */\n    XML_ERR_HYPHEN_IN_COMMENT, /* 80 */\n    XML_ERR_INVALID_ENCODING, /* 81 */\n    XML_ERR_EXT_ENTITY_STANDALONE, /* 82 */\n    XML_ERR_CONDSEC_INVALID, /* 83 */\n    XML_ERR_VALUE_REQUIRED, /* 84 */\n    XML_ERR_NOT_WELL_BALANCED, /* 85 */\n    XML_ERR_EXTRA_CONTENT, /* 86 */\n    XML_ERR_ENTITY_CHAR_ERROR, /* 87 */\n    XML_ERR_ENTITY_PE_INTERNAL, /* 88 */\n    XML_ERR_ENTITY_LOOP, /* 89 */\n    XML_ERR_ENTITY_BOUNDARY, /* 90 */\n    XML_ERR_INVALID_URI, /* 91 */\n    XML_ERR_URI_FRAGMENT, /* 92 */\n    XML_WAR_CATALOG_PI, /* 93 */\n    XML_ERR_NO_DTD, /* 94 */\n    XML_ERR_CONDSEC_INVALID_KEYWORD, /* 95 */\n    XML_ERR_VERSION_MISSING, /* 96 */\n    XML_WAR_UNKNOWN_VERSION, /* 97 */\n    XML_WAR_LANG_VALUE, /* 98 */\n    XML_WAR_NS_URI, /* 99 */\n    XML_WAR_NS_URI_RELATIVE, /* 100 */\n    XML_ERR_MISSING_ENCODING, /* 101 */\n    XML_WAR_SPACE_VALUE, /* 102 */\n    XML_ERR_NOT_STANDALONE, /* 103 */\n    XML_ERR_ENTITY_PROCESSING, /* 104 */\n    XML_ERR_NOTATION_PROCESSING, /* 105 */\n    XML_WAR_NS_COLUMN, /* 106 */\n    XML_WAR_ENTITY_REDEFINED, /* 107 */\n    XML_ERR_UNKNOWN_VERSION, /* 108 */\n    XML_ERR_VERSION_MISMATCH, /* 109 */\n    XML_ERR_NAME_TOO_LONG, /* 110 */\n    XML_ERR_USER_STOP, /* 111 */\n    XML_ERR_COMMENT_ABRUPTLY_ENDED, /* 112 */\n    XML_NS_ERR_XML_NAMESPACE = 200,\n    XML_NS_ERR_UNDEFINED_NAMESPACE, /* 201 */\n    XML_NS_ERR_QNAME, /* 202 */\n    XML_NS_ERR_ATTRIBUTE_REDEFINED, /* 203 */\n    XML_NS_ERR_EMPTY, /* 204 */\n    XML_NS_ERR_COLON, /* 205 */\n    XML_DTD_ATTRIBUTE_DEFAULT = 500,\n    XML_DTD_ATTRIBUTE_REDEFINED, /* 501 */\n    XML_DTD_ATTRIBUTE_VALUE, /* 502 */\n    XML_DTD_CONTENT_ERROR, /* 503 */\n    XML_DTD_CONTENT_MODEL, /* 504 */\n    XML_DTD_CONTENT_NOT_DETERMINIST, /* 505 */\n    XML_DTD_DIFFERENT_PREFIX, /* 506 */\n    XML_DTD_ELEM_DEFAULT_NAMESPACE, /* 507 */\n    XML_DTD_ELEM_NAMESPACE, /* 508 */\n    XML_DTD_ELEM_REDEFINED, /* 509 */\n    XML_DTD_EMPTY_NOTATION, /* 510 */\n    XML_DTD_ENTITY_TYPE, /* 511 */\n    XML_DTD_ID_FIXED, /* 512 */\n    XML_DTD_ID_REDEFINED, /* 513 */\n    XML_DTD_ID_SUBSET, /* 514 */\n    XML_DTD_INVALID_CHILD, /* 515 */\n    XML_DTD_INVALID_DEFAULT, /* 516 */\n    XML_DTD_LOAD_ERROR, /* 517 */\n    XML_DTD_MISSING_ATTRIBUTE, /* 518 */\n    XML_DTD_MIXED_CORRUPT, /* 519 */\n    XML_DTD_MULTIPLE_ID, /* 520 */\n    XML_DTD_NO_DOC, /* 521 */\n    XML_DTD_NO_DTD, /* 522 */\n    XML_DTD_NO_ELEM_NAME, /* 523 */\n    XML_DTD_NO_PREFIX, /* 524 */\n    XML_DTD_NO_ROOT, /* 525 */\n    XML_DTD_NOTATION_REDEFINED, /* 526 */\n    XML_DTD_NOTATION_VALUE, /* 527 */\n    XML_DTD_NOT_EMPTY, /* 528 */\n    XML_DTD_NOT_PCDATA, /* 529 */\n    XML_DTD_NOT_STANDALONE, /* 530 */\n    XML_DTD_ROOT_NAME, /* 531 */\n    XML_DTD_STANDALONE_WHITE_SPACE, /* 532 */\n    XML_DTD_UNKNOWN_ATTRIBUTE, /* 533 */\n    XML_DTD_UNKNOWN_ELEM, /* 534 */\n    XML_DTD_UNKNOWN_ENTITY, /* 535 */\n    XML_DTD_UNKNOWN_ID, /* 536 */\n    XML_DTD_UNKNOWN_NOTATION, /* 537 */\n    XML_DTD_STANDALONE_DEFAULTED, /* 538 */\n    XML_DTD_XMLID_VALUE, /* 539 */\n    XML_DTD_XMLID_TYPE, /* 540 */\n    XML_DTD_DUP_TOKEN, /* 541 */\n    XML_HTML_STRUCURE_ERROR = 800,\n    XML_HTML_UNKNOWN_TAG, /* 801 */\n    XML_HTML_INCORRECTLY_OPENED_COMMENT, /* 802 */\n    XML_RNGP_ANYNAME_ATTR_ANCESTOR = 1000,\n    XML_RNGP_ATTR_CONFLICT, /* 1001 */\n    XML_RNGP_ATTRIBUTE_CHILDREN, /* 1002 */\n    XML_RNGP_ATTRIBUTE_CONTENT, /* 1003 */\n    XML_RNGP_ATTRIBUTE_EMPTY, /* 1004 */\n    XML_RNGP_ATTRIBUTE_NOOP, /* 1005 */\n    XML_RNGP_CHOICE_CONTENT, /* 1006 */\n    XML_RNGP_CHOICE_EMPTY, /* 1007 */\n    XML_RNGP_CREATE_FAILURE, /* 1008 */\n    XML_RNGP_DATA_CONTENT, /* 1009 */\n    XML_RNGP_DEF_CHOICE_AND_INTERLEAVE, /* 1010 */\n    XML_RNGP_DEFINE_CREATE_FAILED, /* 1011 */\n    XML_RNGP_DEFINE_EMPTY, /* 1012 */\n    XML_RNGP_DEFINE_MISSING, /* 1013 */\n    XML_RNGP_DEFINE_NAME_MISSING, /* 1014 */\n    XML_RNGP_ELEM_CONTENT_EMPTY, /* 1015 */\n    XML_RNGP_ELEM_CONTENT_ERROR, /* 1016 */\n    XML_RNGP_ELEMENT_EMPTY, /* 1017 */\n    XML_RNGP_ELEMENT_CONTENT, /* 1018 */\n    XML_RNGP_ELEMENT_NAME, /* 1019 */\n    XML_RNGP_ELEMENT_NO_CONTENT, /* 1020 */\n    XML_RNGP_ELEM_TEXT_CONFLICT, /* 1021 */\n    XML_RNGP_EMPTY, /* 1022 */\n    XML_RNGP_EMPTY_CONSTRUCT, /* 1023 */\n    XML_RNGP_EMPTY_CONTENT, /* 1024 */\n    XML_RNGP_EMPTY_NOT_EMPTY, /* 1025 */\n    XML_RNGP_ERROR_TYPE_LIB, /* 1026 */\n    XML_RNGP_EXCEPT_EMPTY, /* 1027 */\n    XML_RNGP_EXCEPT_MISSING, /* 1028 */\n    XML_RNGP_EXCEPT_MULTIPLE, /* 1029 */\n    XML_RNGP_EXCEPT_NO_CONTENT, /* 1030 */\n    XML_RNGP_EXTERNALREF_EMTPY, /* 1031 */\n    XML_RNGP_EXTERNAL_REF_FAILURE, /* 1032 */\n    XML_RNGP_EXTERNALREF_RECURSE, /* 1033 */\n    XML_RNGP_FORBIDDEN_ATTRIBUTE, /* 1034 */\n    XML_RNGP_FOREIGN_ELEMENT, /* 1035 */\n    XML_RNGP_GRAMMAR_CONTENT, /* 1036 */\n    XML_RNGP_GRAMMAR_EMPTY, /* 1037 */\n    XML_RNGP_GRAMMAR_MISSING, /* 1038 */\n    XML_RNGP_GRAMMAR_NO_START, /* 1039 */\n    XML_RNGP_GROUP_ATTR_CONFLICT, /* 1040 */\n    XML_RNGP_HREF_ERROR, /* 1041 */\n    XML_RNGP_INCLUDE_EMPTY, /* 1042 */\n    XML_RNGP_INCLUDE_FAILURE, /* 1043 */\n    XML_RNGP_INCLUDE_RECURSE, /* 1044 */\n    XML_RNGP_INTERLEAVE_ADD, /* 1045 */\n    XML_RNGP_INTERLEAVE_CREATE_FAILED, /* 1046 */\n    XML_RNGP_INTERLEAVE_EMPTY, /* 1047 */\n    XML_RNGP_INTERLEAVE_NO_CONTENT, /* 1048 */\n    XML_RNGP_INVALID_DEFINE_NAME, /* 1049 */\n    XML_RNGP_INVALID_URI, /* 1050 */\n    XML_RNGP_INVALID_VALUE, /* 1051 */\n    XML_RNGP_MISSING_HREF, /* 1052 */\n    XML_RNGP_NAME_MISSING, /* 1053 */\n    XML_RNGP_NEED_COMBINE, /* 1054 */\n    XML_RNGP_NOTALLOWED_NOT_EMPTY, /* 1055 */\n    XML_RNGP_NSNAME_ATTR_ANCESTOR, /* 1056 */\n    XML_RNGP_NSNAME_NO_NS, /* 1057 */\n    XML_RNGP_PARAM_FORBIDDEN, /* 1058 */\n    XML_RNGP_PARAM_NAME_MISSING, /* 1059 */\n    XML_RNGP_PARENTREF_CREATE_FAILED, /* 1060 */\n    XML_RNGP_PARENTREF_NAME_INVALID, /* 1061 */\n    XML_RNGP_PARENTREF_NO_NAME, /* 1062 */\n    XML_RNGP_PARENTREF_NO_PARENT, /* 1063 */\n    XML_RNGP_PARENTREF_NOT_EMPTY, /* 1064 */\n    XML_RNGP_PARSE_ERROR, /* 1065 */\n    XML_RNGP_PAT_ANYNAME_EXCEPT_ANYNAME, /* 1066 */\n    XML_RNGP_PAT_ATTR_ATTR, /* 1067 */\n    XML_RNGP_PAT_ATTR_ELEM, /* 1068 */\n    XML_RNGP_PAT_DATA_EXCEPT_ATTR, /* 1069 */\n    XML_RNGP_PAT_DATA_EXCEPT_ELEM, /* 1070 */\n    XML_RNGP_PAT_DATA_EXCEPT_EMPTY, /* 1071 */\n    XML_RNGP_PAT_DATA_EXCEPT_GROUP, /* 1072 */\n    XML_RNGP_PAT_DATA_EXCEPT_INTERLEAVE, /* 1073 */\n    XML_RNGP_PAT_DATA_EXCEPT_LIST, /* 1074 */\n    XML_RNGP_PAT_DATA_EXCEPT_ONEMORE, /* 1075 */\n    XML_RNGP_PAT_DATA_EXCEPT_REF, /* 1076 */\n    XML_RNGP_PAT_DATA_EXCEPT_TEXT, /* 1077 */\n    XML_RNGP_PAT_LIST_ATTR, /* 1078 */\n    XML_RNGP_PAT_LIST_ELEM, /* 1079 */\n    XML_RNGP_PAT_LIST_INTERLEAVE, /* 1080 */\n    XML_RNGP_PAT_LIST_LIST, /* 1081 */\n    XML_RNGP_PAT_LIST_REF, /* 1082 */\n    XML_RNGP_PAT_LIST_TEXT, /* 1083 */\n    XML_RNGP_PAT_NSNAME_EXCEPT_ANYNAME, /* 1084 */\n    XML_RNGP_PAT_NSNAME_EXCEPT_NSNAME, /* 1085 */\n    XML_RNGP_PAT_ONEMORE_GROUP_ATTR, /* 1086 */\n    XML_RNGP_PAT_ONEMORE_INTERLEAVE_ATTR, /* 1087 */\n    XML_RNGP_PAT_START_ATTR, /* 1088 */\n    XML_RNGP_PAT_START_DATA, /* 1089 */\n    XML_RNGP_PAT_START_EMPTY, /* 1090 */\n    XML_RNGP_PAT_START_GROUP, /* 1091 */\n    XML_RNGP_PAT_START_INTERLEAVE, /* 1092 */\n    XML_RNGP_PAT_START_LIST, /* 1093 */\n    XML_RNGP_PAT_START_ONEMORE, /* 1094 */\n    XML_RNGP_PAT_START_TEXT, /* 1095 */\n    XML_RNGP_PAT_START_VALUE, /* 1096 */\n    XML_RNGP_PREFIX_UNDEFINED, /* 1097 */\n    XML_RNGP_REF_CREATE_FAILED, /* 1098 */\n    XML_RNGP_REF_CYCLE, /* 1099 */\n    XML_RNGP_REF_NAME_INVALID, /* 1100 */\n    XML_RNGP_REF_NO_DEF, /* 1101 */\n    XML_RNGP_REF_NO_NAME, /* 1102 */\n    XML_RNGP_REF_NOT_EMPTY, /* 1103 */\n    XML_RNGP_START_CHOICE_AND_INTERLEAVE, /* 1104 */\n    XML_RNGP_START_CONTENT, /* 1105 */\n    XML_RNGP_START_EMPTY, /* 1106 */\n    XML_RNGP_START_MISSING, /* 1107 */\n    XML_RNGP_TEXT_EXPECTED, /* 1108 */\n    XML_RNGP_TEXT_HAS_CHILD, /* 1109 */\n    XML_RNGP_TYPE_MISSING, /* 1110 */\n    XML_RNGP_TYPE_NOT_FOUND, /* 1111 */\n    XML_RNGP_TYPE_VALUE, /* 1112 */\n    XML_RNGP_UNKNOWN_ATTRIBUTE, /* 1113 */\n    XML_RNGP_UNKNOWN_COMBINE, /* 1114 */\n    XML_RNGP_UNKNOWN_CONSTRUCT, /* 1115 */\n    XML_RNGP_UNKNOWN_TYPE_LIB, /* 1116 */\n    XML_RNGP_URI_FRAGMENT, /* 1117 */\n    XML_RNGP_URI_NOT_ABSOLUTE, /* 1118 */\n    XML_RNGP_VALUE_EMPTY, /* 1119 */\n    XML_RNGP_VALUE_NO_CONTENT, /* 1120 */\n    XML_RNGP_XMLNS_NAME, /* 1121 */\n    XML_RNGP_XML_NS, /* 1122 */\n    XML_XPATH_EXPRESSION_OK = 1200,\n    XML_XPATH_NUMBER_ERROR, /* 1201 */\n    XML_XPATH_UNFINISHED_LITERAL_ERROR, /* 1202 */\n    XML_XPATH_START_LITERAL_ERROR, /* 1203 */\n    XML_XPATH_VARIABLE_REF_ERROR, /* 1204 */\n    XML_XPATH_UNDEF_VARIABLE_ERROR, /* 1205 */\n    XML_XPATH_INVALID_PREDICATE_ERROR, /* 1206 */\n    XML_XPATH_EXPR_ERROR, /* 1207 */\n    XML_XPATH_UNCLOSED_ERROR, /* 1208 */\n    XML_XPATH_UNKNOWN_FUNC_ERROR, /* 1209 */\n    XML_XPATH_INVALID_OPERAND, /* 1210 */\n    XML_XPATH_INVALID_TYPE, /* 1211 */\n    XML_XPATH_INVALID_ARITY, /* 1212 */\n    XML_XPATH_INVALID_CTXT_SIZE, /* 1213 */\n    XML_XPATH_INVALID_CTXT_POSITION, /* 1214 */\n    XML_XPATH_MEMORY_ERROR, /* 1215 */\n    XML_XPTR_SYNTAX_ERROR, /* 1216 */\n    XML_XPTR_RESOURCE_ERROR, /* 1217 */\n    XML_XPTR_SUB_RESOURCE_ERROR, /* 1218 */\n    XML_XPATH_UNDEF_PREFIX_ERROR, /* 1219 */\n    XML_XPATH_ENCODING_ERROR, /* 1220 */\n    XML_XPATH_INVALID_CHAR_ERROR, /* 1221 */\n    XML_TREE_INVALID_HEX = 1300,\n    XML_TREE_INVALID_DEC, /* 1301 */\n    XML_TREE_UNTERMINATED_ENTITY, /* 1302 */\n    XML_TREE_NOT_UTF8, /* 1303 */\n    XML_SAVE_NOT_UTF8 = 1400,\n    XML_SAVE_CHAR_INVALID, /* 1401 */\n    XML_SAVE_NO_DOCTYPE, /* 1402 */\n    XML_SAVE_UNKNOWN_ENCODING, /* 1403 */\n    XML_REGEXP_COMPILE_ERROR = 1450,\n    XML_IO_UNKNOWN = 1500,\n    XML_IO_EACCES, /* 1501 */\n    XML_IO_EAGAIN, /* 1502 */\n    XML_IO_EBADF, /* 1503 */\n    XML_IO_EBADMSG, /* 1504 */\n    XML_IO_EBUSY, /* 1505 */\n    XML_IO_ECANCELED, /* 1506 */\n    XML_IO_ECHILD, /* 1507 */\n    XML_IO_EDEADLK, /* 1508 */\n    XML_IO_EDOM, /* 1509 */\n    XML_IO_EEXIST, /* 1510 */\n    XML_IO_EFAULT, /* 1511 */\n    XML_IO_EFBIG, /* 1512 */\n    XML_IO_EINPROGRESS, /* 1513 */\n    XML_IO_EINTR, /* 1514 */\n    XML_IO_EINVAL, /* 1515 */\n    XML_IO_EIO, /* 1516 */\n    XML_IO_EISDIR, /* 1517 */\n    XML_IO_EMFILE, /* 1518 */\n    XML_IO_EMLINK, /* 1519 */\n    XML_IO_EMSGSIZE, /* 1520 */\n    XML_IO_ENAMETOOLONG, /* 1521 */\n    XML_IO_ENFILE, /* 1522 */\n    XML_IO_ENODEV, /* 1523 */\n    XML_IO_ENOENT, /* 1524 */\n    XML_IO_ENOEXEC, /* 1525 */\n    XML_IO_ENOLCK, /* 1526 */\n    XML_IO_ENOMEM, /* 1527 */\n    XML_IO_ENOSPC, /* 1528 */\n    XML_IO_ENOSYS, /* 1529 */\n    XML_IO_ENOTDIR, /* 1530 */\n    XML_IO_ENOTEMPTY, /* 1531 */\n    XML_IO_ENOTSUP, /* 1532 */\n    XML_IO_ENOTTY, /* 1533 */\n    XML_IO_ENXIO, /* 1534 */\n    XML_IO_EPERM, /* 1535 */\n    XML_IO_EPIPE, /* 1536 */\n    XML_IO_ERANGE, /* 1537 */\n    XML_IO_EROFS, /* 1538 */\n    XML_IO_ESPIPE, /* 1539 */\n    XML_IO_ESRCH, /* 1540 */\n    XML_IO_ETIMEDOUT, /* 1541 */\n    XML_IO_EXDEV, /* 1542 */\n    XML_IO_NETWORK_ATTEMPT, /* 1543 */\n    XML_IO_ENCODER, /* 1544 */\n    XML_IO_FLUSH, /* 1545 */\n    XML_IO_WRITE, /* 1546 */\n    XML_IO_NO_INPUT, /* 1547 */\n    XML_IO_BUFFER_FULL, /* 1548 */\n    XML_IO_LOAD_ERROR, /* 1549 */\n    XML_IO_ENOTSOCK, /* 1550 */\n    XML_IO_EISCONN, /* 1551 */\n    XML_IO_ECONNREFUSED, /* 1552 */\n    XML_IO_ENETUNREACH, /* 1553 */\n    XML_IO_EADDRINUSE, /* 1554 */\n    XML_IO_EALREADY, /* 1555 */\n    XML_IO_EAFNOSUPPORT, /* 1556 */\n    XML_XINCLUDE_RECURSION=1600,\n    XML_XINCLUDE_PARSE_VALUE, /* 1601 */\n    XML_XINCLUDE_ENTITY_DEF_MISMATCH, /* 1602 */\n    XML_XINCLUDE_NO_HREF, /* 1603 */\n    XML_XINCLUDE_NO_FALLBACK, /* 1604 */\n    XML_XINCLUDE_HREF_URI, /* 1605 */\n    XML_XINCLUDE_TEXT_FRAGMENT, /* 1606 */\n    XML_XINCLUDE_TEXT_DOCUMENT, /* 1607 */\n    XML_XINCLUDE_INVALID_CHAR, /* 1608 */\n    XML_XINCLUDE_BUILD_FAILED, /* 1609 */\n    XML_XINCLUDE_UNKNOWN_ENCODING, /* 1610 */\n    XML_XINCLUDE_MULTIPLE_ROOT, /* 1611 */\n    XML_XINCLUDE_XPTR_FAILED, /* 1612 */\n    XML_XINCLUDE_XPTR_RESULT, /* 1613 */\n    XML_XINCLUDE_INCLUDE_IN_INCLUDE, /* 1614 */\n    XML_XINCLUDE_FALLBACKS_IN_INCLUDE, /* 1615 */\n    XML_XINCLUDE_FALLBACK_NOT_IN_INCLUDE, /* 1616 */\n    XML_XINCLUDE_DEPRECATED_NS, /* 1617 */\n    XML_XINCLUDE_FRAGMENT_ID, /* 1618 */\n    XML_CATALOG_MISSING_ATTR = 1650,\n    XML_CATALOG_ENTRY_BROKEN, /* 1651 */\n    XML_CATALOG_PREFER_VALUE, /* 1652 */\n    XML_CATALOG_NOT_CATALOG, /* 1653 */\n    XML_CATALOG_RECURSION, /* 1654 */\n    XML_SCHEMAP_PREFIX_UNDEFINED = 1700,\n    XML_SCHEMAP_ATTRFORMDEFAULT_VALUE, /* 1701 */\n    XML_SCHEMAP_ATTRGRP_NONAME_NOREF, /* 1702 */\n    XML_SCHEMAP_ATTR_NONAME_NOREF, /* 1703 */\n    XML_SCHEMAP_COMPLEXTYPE_NONAME_NOREF, /* 1704 */\n    XML_SCHEMAP_ELEMFORMDEFAULT_VALUE, /* 1705 */\n    XML_SCHEMAP_ELEM_NONAME_NOREF, /* 1706 */\n    XML_SCHEMAP_EXTENSION_NO_BASE, /* 1707 */\n    XML_SCHEMAP_FACET_NO_VALUE, /* 1708 */\n    XML_SCHEMAP_FAILED_BUILD_IMPORT, /* 1709 */\n    XML_SCHEMAP_GROUP_NONAME_NOREF, /* 1710 */\n    XML_SCHEMAP_IMPORT_NAMESPACE_NOT_URI, /* 1711 */\n    XML_SCHEMAP_IMPORT_REDEFINE_NSNAME, /* 1712 */\n    XML_SCHEMAP_IMPORT_SCHEMA_NOT_URI, /* 1713 */\n    XML_SCHEMAP_INVALID_BOOLEAN, /* 1714 */\n    XML_SCHEMAP_INVALID_ENUM, /* 1715 */\n    XML_SCHEMAP_INVALID_FACET, /* 1716 */\n    XML_SCHEMAP_INVALID_FACET_VALUE, /* 1717 */\n    XML_SCHEMAP_INVALID_MAXOCCURS, /* 1718 */\n    XML_SCHEMAP_INVALID_MINOCCURS, /* 1719 */\n    XML_SCHEMAP_INVALID_REF_AND_SUBTYPE, /* 1720 */\n    XML_SCHEMAP_INVALID_WHITE_SPACE, /* 1721 */\n    XML_SCHEMAP_NOATTR_NOREF, /* 1722 */\n    XML_SCHEMAP_NOTATION_NO_NAME, /* 1723 */\n    XML_SCHEMAP_NOTYPE_NOREF, /* 1724 */\n    XML_SCHEMAP_REF_AND_SUBTYPE, /* 1725 */\n    XML_SCHEMAP_RESTRICTION_NONAME_NOREF, /* 1726 */\n    XML_SCHEMAP_SIMPLETYPE_NONAME, /* 1727 */\n    XML_SCHEMAP_TYPE_AND_SUBTYPE, /* 1728 */\n    XML_SCHEMAP_UNKNOWN_ALL_CHILD, /* 1729 */\n    XML_SCHEMAP_UNKNOWN_ANYATTRIBUTE_CHILD, /* 1730 */\n    XML_SCHEMAP_UNKNOWN_ATTR_CHILD, /* 1731 */\n    XML_SCHEMAP_UNKNOWN_ATTRGRP_CHILD, /* 1732 */\n    XML_SCHEMAP_UNKNOWN_ATTRIBUTE_GROUP, /* 1733 */\n    XML_SCHEMAP_UNKNOWN_BASE_TYPE, /* 1734 */\n    XML_SCHEMAP_UNKNOWN_CHOICE_CHILD, /* 1735 */\n    XML_SCHEMAP_UNKNOWN_COMPLEXCONTENT_CHILD, /* 1736 */\n    XML_SCHEMAP_UNKNOWN_COMPLEXTYPE_CHILD, /* 1737 */\n    XML_SCHEMAP_UNKNOWN_ELEM_CHILD, /* 1738 */\n    XML_SCHEMAP_UNKNOWN_EXTENSION_CHILD, /* 1739 */\n    XML_SCHEMAP_UNKNOWN_FACET_CHILD, /* 1740 */\n    XML_SCHEMAP_UNKNOWN_FACET_TYPE, /* 1741 */\n    XML_SCHEMAP_UNKNOWN_GROUP_CHILD, /* 1742 */\n    XML_SCHEMAP_UNKNOWN_IMPORT_CHILD, /* 1743 */\n    XML_SCHEMAP_UNKNOWN_LIST_CHILD, /* 1744 */\n    XML_SCHEMAP_UNKNOWN_NOTATION_CHILD, /* 1745 */\n    XML_SCHEMAP_UNKNOWN_PROCESSCONTENT_CHILD, /* 1746 */\n    XML_SCHEMAP_UNKNOWN_REF, /* 1747 */\n    XML_SCHEMAP_UNKNOWN_RESTRICTION_CHILD, /* 1748 */\n    XML_SCHEMAP_UNKNOWN_SCHEMAS_CHILD, /* 1749 */\n    XML_SCHEMAP_UNKNOWN_SEQUENCE_CHILD, /* 1750 */\n    XML_SCHEMAP_UNKNOWN_SIMPLECONTENT_CHILD, /* 1751 */\n    XML_SCHEMAP_UNKNOWN_SIMPLETYPE_CHILD, /* 1752 */\n    XML_SCHEMAP_UNKNOWN_TYPE, /* 1753 */\n    XML_SCHEMAP_UNKNOWN_UNION_CHILD, /* 1754 */\n    XML_SCHEMAP_ELEM_DEFAULT_FIXED, /* 1755 */\n    XML_SCHEMAP_REGEXP_INVALID, /* 1756 */\n    XML_SCHEMAP_FAILED_LOAD, /* 1757 */\n    XML_SCHEMAP_NOTHING_TO_PARSE, /* 1758 */\n    XML_SCHEMAP_NOROOT, /* 1759 */\n    XML_SCHEMAP_REDEFINED_GROUP, /* 1760 */\n    XML_SCHEMAP_REDEFINED_TYPE, /* 1761 */\n    XML_SCHEMAP_REDEFINED_ELEMENT, /* 1762 */\n    XML_SCHEMAP_REDEFINED_ATTRGROUP, /* 1763 */\n    XML_SCHEMAP_REDEFINED_ATTR, /* 1764 */\n    XML_SCHEMAP_REDEFINED_NOTATION, /* 1765 */\n    XML_SCHEMAP_FAILED_PARSE, /* 1766 */\n    XML_SCHEMAP_UNKNOWN_PREFIX, /* 1767 */\n    XML_SCHEMAP_DEF_AND_PREFIX, /* 1768 */\n    XML_SCHEMAP_UNKNOWN_INCLUDE_CHILD, /* 1769 */\n    XML_SCHEMAP_INCLUDE_SCHEMA_NOT_URI, /* 1770 */\n    XML_SCHEMAP_INCLUDE_SCHEMA_NO_URI, /* 1771 */\n    XML_SCHEMAP_NOT_SCHEMA, /* 1772 */\n    XML_SCHEMAP_UNKNOWN_MEMBER_TYPE, /* 1773 */\n    XML_SCHEMAP_INVALID_ATTR_USE, /* 1774 */\n    XML_SCHEMAP_RECURSIVE, /* 1775 */\n    XML_SCHEMAP_SUPERNUMEROUS_LIST_ITEM_TYPE, /* 1776 */\n    XML_SCHEMAP_INVALID_ATTR_COMBINATION, /* 1777 */\n    XML_SCHEMAP_INVALID_ATTR_INLINE_COMBINATION, /* 1778 */\n    XML_SCHEMAP_MISSING_SIMPLETYPE_CHILD, /* 1779 */\n    XML_SCHEMAP_INVALID_ATTR_NAME, /* 1780 */\n    XML_SCHEMAP_REF_AND_CONTENT, /* 1781 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_1, /* 1782 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_2, /* 1783 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_3, /* 1784 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_4, /* 1785 */\n    XML_SCHEMAP_CT_PROPS_CORRECT_5, /* 1786 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_1, /* 1787 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_1, /* 1788 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_2, /* 1789 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_2, /* 1790 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_3, /* 1791 */\n    XML_SCHEMAP_WILDCARD_INVALID_NS_MEMBER, /* 1792 */\n    XML_SCHEMAP_INTERSECTION_NOT_EXPRESSIBLE, /* 1793 */\n    XML_SCHEMAP_UNION_NOT_EXPRESSIBLE, /* 1794 */\n    XML_SCHEMAP_SRC_IMPORT_3_1, /* 1795 */\n    XML_SCHEMAP_SRC_IMPORT_3_2, /* 1796 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_1, /* 1797 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_2, /* 1798 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_4_3, /* 1799 */\n    XML_SCHEMAP_COS_CT_EXTENDS_1_3, /* 1800 */\n    XML_SCHEMAV_NOROOT = 1801,\n    XML_SCHEMAV_UNDECLAREDELEM, /* 1802 */\n    XML_SCHEMAV_NOTTOPLEVEL, /* 1803 */\n    XML_SCHEMAV_MISSING, /* 1804 */\n    XML_SCHEMAV_WRONGELEM, /* 1805 */\n    XML_SCHEMAV_NOTYPE, /* 1806 */\n    XML_SCHEMAV_NOROLLBACK, /* 1807 */\n    XML_SCHEMAV_ISABSTRACT, /* 1808 */\n    XML_SCHEMAV_NOTEMPTY, /* 1809 */\n    XML_SCHEMAV_ELEMCONT, /* 1810 */\n    XML_SCHEMAV_HAVEDEFAULT, /* 1811 */\n    XML_SCHEMAV_NOTNILLABLE, /* 1812 */\n    XML_SCHEMAV_EXTRACONTENT, /* 1813 */\n    XML_SCHEMAV_INVALIDATTR, /* 1814 */\n    XML_SCHEMAV_INVALIDELEM, /* 1815 */\n    XML_SCHEMAV_NOTDETERMINIST, /* 1816 */\n    XML_SCHEMAV_CONSTRUCT, /* 1817 */\n    XML_SCHEMAV_INTERNAL, /* 1818 */\n    XML_SCHEMAV_NOTSIMPLE, /* 1819 */\n    XML_SCHEMAV_ATTRUNKNOWN, /* 1820 */\n    XML_SCHEMAV_ATTRINVALID, /* 1821 */\n    XML_SCHEMAV_VALUE, /* 1822 */\n    XML_SCHEMAV_FACET, /* 1823 */\n    XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_1, /* 1824 */\n    XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_2, /* 1825 */\n    XML_SCHEMAV_CVC_DATATYPE_VALID_1_2_3, /* 1826 */\n    XML_SCHEMAV_CVC_TYPE_3_1_1, /* 1827 */\n    XML_SCHEMAV_CVC_TYPE_3_1_2, /* 1828 */\n    XML_SCHEMAV_CVC_FACET_VALID, /* 1829 */\n    XML_SCHEMAV_CVC_LENGTH_VALID, /* 1830 */\n    XML_SCHEMAV_CVC_MINLENGTH_VALID, /* 1831 */\n    XML_SCHEMAV_CVC_MAXLENGTH_VALID, /* 1832 */\n    XML_SCHEMAV_CVC_MININCLUSIVE_VALID, /* 1833 */\n    XML_SCHEMAV_CVC_MAXINCLUSIVE_VALID, /* 1834 */\n    XML_SCHEMAV_CVC_MINEXCLUSIVE_VALID, /* 1835 */\n    XML_SCHEMAV_CVC_MAXEXCLUSIVE_VALID, /* 1836 */\n    XML_SCHEMAV_CVC_TOTALDIGITS_VALID, /* 1837 */\n    XML_SCHEMAV_CVC_FRACTIONDIGITS_VALID, /* 1838 */\n    XML_SCHEMAV_CVC_PATTERN_VALID, /* 1839 */\n    XML_SCHEMAV_CVC_ENUMERATION_VALID, /* 1840 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_2_1, /* 1841 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_2_2, /* 1842 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_2_3, /* 1843 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_2_4, /* 1844 */\n    XML_SCHEMAV_CVC_ELT_1, /* 1845 */\n    XML_SCHEMAV_CVC_ELT_2, /* 1846 */\n    XML_SCHEMAV_CVC_ELT_3_1, /* 1847 */\n    XML_SCHEMAV_CVC_ELT_3_2_1, /* 1848 */\n    XML_SCHEMAV_CVC_ELT_3_2_2, /* 1849 */\n    XML_SCHEMAV_CVC_ELT_4_1, /* 1850 */\n    XML_SCHEMAV_CVC_ELT_4_2, /* 1851 */\n    XML_SCHEMAV_CVC_ELT_4_3, /* 1852 */\n    XML_SCHEMAV_CVC_ELT_5_1_1, /* 1853 */\n    XML_SCHEMAV_CVC_ELT_5_1_2, /* 1854 */\n    XML_SCHEMAV_CVC_ELT_5_2_1, /* 1855 */\n    XML_SCHEMAV_CVC_ELT_5_2_2_1, /* 1856 */\n    XML_SCHEMAV_CVC_ELT_5_2_2_2_1, /* 1857 */\n    XML_SCHEMAV_CVC_ELT_5_2_2_2_2, /* 1858 */\n    XML_SCHEMAV_CVC_ELT_6, /* 1859 */\n    XML_SCHEMAV_CVC_ELT_7, /* 1860 */\n    XML_SCHEMAV_CVC_ATTRIBUTE_1, /* 1861 */\n    XML_SCHEMAV_CVC_ATTRIBUTE_2, /* 1862 */\n    XML_SCHEMAV_CVC_ATTRIBUTE_3, /* 1863 */\n    XML_SCHEMAV_CVC_ATTRIBUTE_4, /* 1864 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_3_1, /* 1865 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_1, /* 1866 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_3_2_2, /* 1867 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_4, /* 1868 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_5_1, /* 1869 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_5_2, /* 1870 */\n    XML_SCHEMAV_ELEMENT_CONTENT, /* 1871 */\n    XML_SCHEMAV_DOCUMENT_ELEMENT_MISSING, /* 1872 */\n    XML_SCHEMAV_CVC_COMPLEX_TYPE_1, /* 1873 */\n    XML_SCHEMAV_CVC_AU, /* 1874 */\n    XML_SCHEMAV_CVC_TYPE_1, /* 1875 */\n    XML_SCHEMAV_CVC_TYPE_2, /* 1876 */\n    XML_SCHEMAV_CVC_IDC, /* 1877 */\n    XML_SCHEMAV_CVC_WILDCARD, /* 1878 */\n    XML_SCHEMAV_MISC, /* 1879 */\n    XML_XPTR_UNKNOWN_SCHEME = 1900,\n    XML_XPTR_CHILDSEQ_START, /* 1901 */\n    XML_XPTR_EVAL_FAILED, /* 1902 */\n    XML_XPTR_EXTRA_OBJECTS, /* 1903 */\n    XML_C14N_CREATE_CTXT = 1950,\n    XML_C14N_REQUIRES_UTF8, /* 1951 */\n    XML_C14N_CREATE_STACK, /* 1952 */\n    XML_C14N_INVALID_NODE, /* 1953 */\n    XML_C14N_UNKNOW_NODE, /* 1954 */\n    XML_C14N_RELATIVE_NAMESPACE, /* 1955 */\n    XML_FTP_PASV_ANSWER = 2000,\n    XML_FTP_EPSV_ANSWER, /* 2001 */\n    XML_FTP_ACCNT, /* 2002 */\n    XML_FTP_URL_SYNTAX, /* 2003 */\n    XML_HTTP_URL_SYNTAX = 2020,\n    XML_HTTP_USE_IP, /* 2021 */\n    XML_HTTP_UNKNOWN_HOST, /* 2022 */\n    XML_SCHEMAP_SRC_SIMPLE_TYPE_1 = 3000,\n    XML_SCHEMAP_SRC_SIMPLE_TYPE_2, /* 3001 */\n    XML_SCHEMAP_SRC_SIMPLE_TYPE_3, /* 3002 */\n    XML_SCHEMAP_SRC_SIMPLE_TYPE_4, /* 3003 */\n    XML_SCHEMAP_SRC_RESOLVE, /* 3004 */\n    XML_SCHEMAP_SRC_RESTRICTION_BASE_OR_SIMPLETYPE, /* 3005 */\n    XML_SCHEMAP_SRC_LIST_ITEMTYPE_OR_SIMPLETYPE, /* 3006 */\n    XML_SCHEMAP_SRC_UNION_MEMBERTYPES_OR_SIMPLETYPES, /* 3007 */\n    XML_SCHEMAP_ST_PROPS_CORRECT_1, /* 3008 */\n    XML_SCHEMAP_ST_PROPS_CORRECT_2, /* 3009 */\n    XML_SCHEMAP_ST_PROPS_CORRECT_3, /* 3010 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_1_1, /* 3011 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_1_2, /* 3012 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_1_3_1, /* 3013 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_1_3_2, /* 3014 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_1, /* 3015 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_1, /* 3016 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_1_2, /* 3017 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_1, /* 3018 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_2, /* 3019 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_3, /* 3020 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_4, /* 3021 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_2_3_2_5, /* 3022 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_1, /* 3023 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1, /* 3024 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_1_2, /* 3025 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_2, /* 3026 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_1, /* 3027 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_3, /* 3028 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_4, /* 3029 */\n    XML_SCHEMAP_COS_ST_RESTRICTS_3_3_2_5, /* 3030 */\n    XML_SCHEMAP_COS_ST_DERIVED_OK_2_1, /* 3031 */\n    XML_SCHEMAP_COS_ST_DERIVED_OK_2_2, /* 3032 */\n    XML_SCHEMAP_S4S_ELEM_NOT_ALLOWED, /* 3033 */\n    XML_SCHEMAP_S4S_ELEM_MISSING, /* 3034 */\n    XML_SCHEMAP_S4S_ATTR_NOT_ALLOWED, /* 3035 */\n    XML_SCHEMAP_S4S_ATTR_MISSING, /* 3036 */\n    XML_SCHEMAP_S4S_ATTR_INVALID_VALUE, /* 3037 */\n    XML_SCHEMAP_SRC_ELEMENT_1, /* 3038 */\n    XML_SCHEMAP_SRC_ELEMENT_2_1, /* 3039 */\n    XML_SCHEMAP_SRC_ELEMENT_2_2, /* 3040 */\n    XML_SCHEMAP_SRC_ELEMENT_3, /* 3041 */\n    XML_SCHEMAP_P_PROPS_CORRECT_1, /* 3042 */\n    XML_SCHEMAP_P_PROPS_CORRECT_2_1, /* 3043 */\n    XML_SCHEMAP_P_PROPS_CORRECT_2_2, /* 3044 */\n    XML_SCHEMAP_E_PROPS_CORRECT_2, /* 3045 */\n    XML_SCHEMAP_E_PROPS_CORRECT_3, /* 3046 */\n    XML_SCHEMAP_E_PROPS_CORRECT_4, /* 3047 */\n    XML_SCHEMAP_E_PROPS_CORRECT_5, /* 3048 */\n    XML_SCHEMAP_E_PROPS_CORRECT_6, /* 3049 */\n    XML_SCHEMAP_SRC_INCLUDE, /* 3050 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_1, /* 3051 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_2, /* 3052 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_3_1, /* 3053 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_3_2, /* 3054 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_4, /* 3055 */\n    XML_SCHEMAP_NO_XMLNS, /* 3056 */\n    XML_SCHEMAP_NO_XSI, /* 3057 */\n    XML_SCHEMAP_COS_VALID_DEFAULT_1, /* 3058 */\n    XML_SCHEMAP_COS_VALID_DEFAULT_2_1, /* 3059 */\n    XML_SCHEMAP_COS_VALID_DEFAULT_2_2_1, /* 3060 */\n    XML_SCHEMAP_COS_VALID_DEFAULT_2_2_2, /* 3061 */\n    XML_SCHEMAP_CVC_SIMPLE_TYPE, /* 3062 */\n    XML_SCHEMAP_COS_CT_EXTENDS_1_1, /* 3063 */\n    XML_SCHEMAP_SRC_IMPORT_1_1, /* 3064 */\n    XML_SCHEMAP_SRC_IMPORT_1_2, /* 3065 */\n    XML_SCHEMAP_SRC_IMPORT_2, /* 3066 */\n    XML_SCHEMAP_SRC_IMPORT_2_1, /* 3067 */\n    XML_SCHEMAP_SRC_IMPORT_2_2, /* 3068 */\n    XML_SCHEMAP_INTERNAL, /* 3069 non-W3C */\n    XML_SCHEMAP_NOT_DETERMINISTIC, /* 3070 non-W3C */\n    XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_1, /* 3071 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_2, /* 3072 */\n    XML_SCHEMAP_SRC_ATTRIBUTE_GROUP_3, /* 3073 */\n    XML_SCHEMAP_MG_PROPS_CORRECT_1, /* 3074 */\n    XML_SCHEMAP_MG_PROPS_CORRECT_2, /* 3075 */\n    XML_SCHEMAP_SRC_CT_1, /* 3076 */\n    XML_SCHEMAP_DERIVATION_OK_RESTRICTION_2_1_3, /* 3077 */\n    XML_SCHEMAP_AU_PROPS_CORRECT_2, /* 3078 */\n    XML_SCHEMAP_A_PROPS_CORRECT_2, /* 3079 */\n    XML_SCHEMAP_C_PROPS_CORRECT, /* 3080 */\n    XML_SCHEMAP_SRC_REDEFINE, /* 3081 */\n    XML_SCHEMAP_SRC_IMPORT, /* 3082 */\n    XML_SCHEMAP_WARN_SKIP_SCHEMA, /* 3083 */\n    XML_SCHEMAP_WARN_UNLOCATED_SCHEMA, /* 3084 */\n    XML_SCHEMAP_WARN_ATTR_REDECL_PROH, /* 3085 */\n    XML_SCHEMAP_WARN_ATTR_POINTLESS_PROH, /* 3085 */\n    XML_SCHEMAP_AG_PROPS_CORRECT, /* 3086 */\n    XML_SCHEMAP_COS_CT_EXTENDS_1_2, /* 3087 */\n    XML_SCHEMAP_AU_PROPS_CORRECT, /* 3088 */\n    XML_SCHEMAP_A_PROPS_CORRECT_3, /* 3089 */\n    XML_SCHEMAP_COS_ALL_LIMITED, /* 3090 */\n    XML_SCHEMATRONV_ASSERT = 4000, /* 4000 */\n    XML_SCHEMATRONV_REPORT,\n    XML_MODULE_OPEN = 4900, /* 4900 */\n    XML_MODULE_CLOSE, /* 4901 */\n    XML_CHECK_FOUND_ELEMENT = 5000,\n    XML_CHECK_FOUND_ATTRIBUTE, /* 5001 */\n    XML_CHECK_FOUND_TEXT, /* 5002 */\n    XML_CHECK_FOUND_CDATA, /* 5003 */\n    XML_CHECK_FOUND_ENTITYREF, /* 5004 */\n    XML_CHECK_FOUND_ENTITY, /* 5005 */\n    XML_CHECK_FOUND_PI, /* 5006 */\n    XML_CHECK_FOUND_COMMENT, /* 5007 */\n    XML_CHECK_FOUND_DOCTYPE, /* 5008 */\n    XML_CHECK_FOUND_FRAGMENT, /* 5009 */\n    XML_CHECK_FOUND_NOTATION, /* 5010 */\n    XML_CHECK_UNKNOWN_NODE, /* 5011 */\n    XML_CHECK_ENTITY_TYPE, /* 5012 */\n    XML_CHECK_NO_PARENT, /* 5013 */\n    XML_CHECK_NO_DOC, /* 5014 */\n    XML_CHECK_NO_NAME, /* 5015 */\n    XML_CHECK_NO_ELEM, /* 5016 */\n    XML_CHECK_WRONG_DOC, /* 5017 */\n    XML_CHECK_NO_PREV, /* 5018 */\n    XML_CHECK_WRONG_PREV, /* 5019 */\n    XML_CHECK_NO_NEXT, /* 5020 */\n    XML_CHECK_WRONG_NEXT, /* 5021 */\n    XML_CHECK_NOT_DTD, /* 5022 */\n    XML_CHECK_NOT_ATTR, /* 5023 */\n    XML_CHECK_NOT_ATTR_DECL, /* 5024 */\n    XML_CHECK_NOT_ELEM_DECL, /* 5025 */\n    XML_CHECK_NOT_ENTITY_DECL, /* 5026 */\n    XML_CHECK_NOT_NS_DECL, /* 5027 */\n    XML_CHECK_NO_HREF, /* 5028 */\n    XML_CHECK_WRONG_PARENT,/* 5029 */\n    XML_CHECK_NS_SCOPE, /* 5030 */\n    XML_CHECK_NS_ANCESTOR, /* 5031 */\n    XML_CHECK_NOT_UTF8, /* 5032 */\n    XML_CHECK_NO_DICT, /* 5033 */\n    XML_CHECK_NOT_NCNAME, /* 5034 */\n    XML_CHECK_OUTSIDE_DICT, /* 5035 */\n    XML_CHECK_WRONG_NAME, /* 5036 */\n    XML_CHECK_NAME_NOT_NULL, /* 5037 */\n    XML_I18N_NO_NAME = 6000,\n    XML_I18N_NO_HANDLER, /* 6001 */\n    XML_I18N_EXCESS_HANDLER, /* 6002 */\n    XML_I18N_CONV_FAILED, /* 6003 */\n    XML_I18N_NO_OUTPUT, /* 6004 */\n    XML_BUF_OVERFLOW = 7000\n} xmlParserErrors;\n\n/**\n * xmlGenericErrorFunc:\n * @ctx:  a parsing context\n * @msg:  the message\n * @...:  the extra arguments of the varargs to format the message\n *\n * Signature of the function to use when there is an error and\n * no parsing or validity context available .\n */\ntypedef void (*xmlGenericErrorFunc) (void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\n/**\n * xmlStructuredErrorFunc:\n * @userData:  user provided data for the error callback\n * @error:  the error being raised.\n *\n * Signature of the function to use when there is an error and\n * the module handles the new error reporting mechanism.\n */\ntypedef void (*xmlStructuredErrorFunc) (void *userData, xmlErrorPtr error);\n\n/*\n * Use the following function to reset the two global variables\n * xmlGenericError and xmlGenericErrorContext.\n */\nXMLPUBFUN void\n    xmlSetGenericErrorFunc\t(void *ctx,\n\t\t\t\t xmlGenericErrorFunc handler);\nXML_DEPRECATED\nXMLPUBFUN void\n    initGenericErrorDefaultFunc\t(xmlGenericErrorFunc *handler);\n\nXMLPUBFUN void\n    xmlSetStructuredErrorFunc\t(void *ctx,\n\t\t\t\t xmlStructuredErrorFunc handler);\n/*\n * Default message routines used by SAX and Valid context for error\n * and warning reporting.\n */\nXMLPUBFUN void\n    xmlParserError\t\t(void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\nXMLPUBFUN void\n    xmlParserWarning\t\t(void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\nXMLPUBFUN void\n    xmlParserValidityError\t(void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\nXMLPUBFUN void\n    xmlParserValidityWarning\t(void *ctx,\n\t\t\t\t const char *msg,\n\t\t\t\t ...) LIBXML_ATTR_FORMAT(2,3);\nXMLPUBFUN void\n    xmlParserPrintFileInfo\t(xmlParserInputPtr input);\nXMLPUBFUN void\n    xmlParserPrintFileContext\t(xmlParserInputPtr input);\n\n/*\n * Extended error information routines\n */\nXMLPUBFUN xmlErrorPtr\n    xmlGetLastError\t\t(void);\nXMLPUBFUN void\n    xmlResetLastError\t\t(void);\nXMLPUBFUN xmlErrorPtr\n    xmlCtxtGetLastError\t\t(void *ctx);\nXMLPUBFUN void\n    xmlCtxtResetLastError\t(void *ctx);\nXMLPUBFUN void\n    xmlResetError\t\t(xmlErrorPtr err);\nXMLPUBFUN int\n    xmlCopyError\t\t(xmlErrorPtr from,\n\t\t\t\t xmlErrorPtr to);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_ERROR_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlexports.h",
    "content": "/*\n * Summary: macros for marking symbols as exportable/importable.\n * Description: macros for marking symbols as exportable/importable.\n *\n * Copy: See Copyright for the status of this software.\n */\n\n#ifndef __XML_EXPORTS_H__\n#define __XML_EXPORTS_H__\n\n/** DOC_DISABLE */\n#if defined(_WIN32) || defined(__CYGWIN__)\n  #ifdef LIBXML_STATIC\n    #define XMLPUBLIC\n  #elif defined(IN_LIBXML)\n    #define XMLPUBLIC __declspec(dllexport)\n  #else\n    #define XMLPUBLIC __declspec(dllimport)\n  #endif\n#else /* not Windows */\n  #define XMLPUBLIC\n#endif /* platform switch */\n/** DOC_ENABLE */\n\n/*\n * XMLPUBFUN:\n *\n * Macro which declares an exportable function\n */\n#define XMLPUBFUN XMLPUBLIC\n\n/**\n * XMLPUBVAR:\n *\n * Macro which declares an exportable variable\n */\n#define XMLPUBVAR XMLPUBLIC extern\n\n/** DOC_DISABLE */\n/* Compatibility */\n#define XMLCALL\n#define XMLCDECL\n#if !defined(LIBXML_DLL_IMPORT)\n#define LIBXML_DLL_IMPORT XMLPUBVAR\n#endif\n/** DOC_ENABLE */\n\n#endif /* __XML_EXPORTS_H__ */\n\n\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlmemory.h",
    "content": "/*\n * Summary: interface for the memory allocator\n * Description: provides interfaces for the memory allocator,\n *              including debugging capabilities.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __DEBUG_MEMORY_ALLOC__\n#define __DEBUG_MEMORY_ALLOC__\n\n#include <stdio.h>\n#include <libxml/xmlversion.h>\n\n/**\n * DEBUG_MEMORY:\n *\n * DEBUG_MEMORY replaces the allocator with a collect and debug\n * shell to the libc allocator.\n * DEBUG_MEMORY should only be activated when debugging\n * libxml i.e. if libxml has been configured with --with-debug-mem too.\n */\n/* #define DEBUG_MEMORY_FREED */\n/* #define DEBUG_MEMORY_LOCATION */\n\n#ifdef DEBUG\n#ifndef DEBUG_MEMORY\n#define DEBUG_MEMORY\n#endif\n#endif\n\n/**\n * DEBUG_MEMORY_LOCATION:\n *\n * DEBUG_MEMORY_LOCATION should be activated only when debugging\n * libxml i.e. if libxml has been configured with --with-debug-mem too.\n */\n#ifdef DEBUG_MEMORY_LOCATION\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The XML memory wrapper support 4 basic overloadable functions.\n */\n/**\n * xmlFreeFunc:\n * @mem: an already allocated block of memory\n *\n * Signature for a free() implementation.\n */\ntypedef void (*xmlFreeFunc)(void *mem);\n/**\n * xmlMallocFunc:\n * @size:  the size requested in bytes\n *\n * Signature for a malloc() implementation.\n *\n * Returns a pointer to the newly allocated block or NULL in case of error.\n */\ntypedef void *(LIBXML_ATTR_ALLOC_SIZE(1) *xmlMallocFunc)(size_t size);\n\n/**\n * xmlReallocFunc:\n * @mem: an already allocated block of memory\n * @size:  the new size requested in bytes\n *\n * Signature for a realloc() implementation.\n *\n * Returns a pointer to the newly reallocated block or NULL in case of error.\n */\ntypedef void *(*xmlReallocFunc)(void *mem, size_t size);\n\n/**\n * xmlStrdupFunc:\n * @str: a zero terminated string\n *\n * Signature for an strdup() implementation.\n *\n * Returns the copy of the string or NULL in case of error.\n */\ntypedef char *(*xmlStrdupFunc)(const char *str);\n\n/*\n * The 4 interfaces used for all memory handling within libxml.\nLIBXML_DLL_IMPORT xmlFreeFunc xmlFree;\nLIBXML_DLL_IMPORT xmlMallocFunc xmlMalloc;\nLIBXML_DLL_IMPORT xmlMallocFunc xmlMallocAtomic;\nLIBXML_DLL_IMPORT xmlReallocFunc xmlRealloc;\nLIBXML_DLL_IMPORT xmlStrdupFunc xmlMemStrdup;\n */\n\n/*\n * The way to overload the existing functions.\n * The xmlGc function have an extra entry for atomic block\n * allocations useful for garbage collected memory allocators\n */\nXMLPUBFUN int\n\txmlMemSetup\t(xmlFreeFunc freeFunc,\n\t\t\t xmlMallocFunc mallocFunc,\n\t\t\t xmlReallocFunc reallocFunc,\n\t\t\t xmlStrdupFunc strdupFunc);\nXMLPUBFUN int\n\txmlMemGet\t(xmlFreeFunc *freeFunc,\n\t\t\t xmlMallocFunc *mallocFunc,\n\t\t\t xmlReallocFunc *reallocFunc,\n\t\t\t xmlStrdupFunc *strdupFunc);\nXMLPUBFUN int\n\txmlGcMemSetup\t(xmlFreeFunc freeFunc,\n\t\t\t xmlMallocFunc mallocFunc,\n\t\t\t xmlMallocFunc mallocAtomicFunc,\n\t\t\t xmlReallocFunc reallocFunc,\n\t\t\t xmlStrdupFunc strdupFunc);\nXMLPUBFUN int\n\txmlGcMemGet\t(xmlFreeFunc *freeFunc,\n\t\t\t xmlMallocFunc *mallocFunc,\n\t\t\t xmlMallocFunc *mallocAtomicFunc,\n\t\t\t xmlReallocFunc *reallocFunc,\n\t\t\t xmlStrdupFunc *strdupFunc);\n\n/*\n * Initialization of the memory layer.\n */\nXML_DEPRECATED\nXMLPUBFUN int\n\txmlInitMemory\t(void);\n\n/*\n * Cleanup of the memory layer.\n */\nXML_DEPRECATED\nXMLPUBFUN void\n                xmlCleanupMemory        (void);\n/*\n * These are specific to the XML debug memory wrapper.\n */\nXMLPUBFUN size_t\n\txmlMemSize\t(void *ptr);\nXMLPUBFUN int\n\txmlMemUsed\t(void);\nXMLPUBFUN int\n\txmlMemBlocks\t(void);\nXMLPUBFUN void\n\txmlMemDisplay\t(FILE *fp);\nXMLPUBFUN void\n\txmlMemDisplayLast(FILE *fp, long nbBytes);\nXMLPUBFUN void\n\txmlMemShow\t(FILE *fp, int nr);\nXMLPUBFUN void\n\txmlMemoryDump\t(void);\nXMLPUBFUN void *\n\txmlMemMalloc\t(size_t size) LIBXML_ATTR_ALLOC_SIZE(1);\nXMLPUBFUN void *\n\txmlMemRealloc\t(void *ptr,size_t size);\nXMLPUBFUN void\n\txmlMemFree\t(void *ptr);\nXMLPUBFUN char *\n\txmlMemoryStrdup\t(const char *str);\nXMLPUBFUN void *\n\txmlMallocLoc\t(size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);\nXMLPUBFUN void *\n\txmlReallocLoc\t(void *ptr, size_t size, const char *file, int line);\nXMLPUBFUN void *\n\txmlMallocAtomicLoc (size_t size, const char *file, int line) LIBXML_ATTR_ALLOC_SIZE(1);\nXMLPUBFUN char *\n\txmlMemStrdupLoc\t(const char *str, const char *file, int line);\n\n\n#ifdef DEBUG_MEMORY_LOCATION\n/**\n * xmlMalloc:\n * @size:  number of bytes to allocate\n *\n * Wrapper for the malloc() function used in the XML library.\n *\n * Returns the pointer to the allocated area or NULL in case of error.\n */\n#define xmlMalloc(size) xmlMallocLoc((size), __FILE__, __LINE__)\n/**\n * xmlMallocAtomic:\n * @size:  number of bytes to allocate\n *\n * Wrapper for the malloc() function used in the XML library for allocation\n * of block not containing pointers to other areas.\n *\n * Returns the pointer to the allocated area or NULL in case of error.\n */\n#define xmlMallocAtomic(size) xmlMallocAtomicLoc((size), __FILE__, __LINE__)\n/**\n * xmlRealloc:\n * @ptr:  pointer to the existing allocated area\n * @size:  number of bytes to allocate\n *\n * Wrapper for the realloc() function used in the XML library.\n *\n * Returns the pointer to the allocated area or NULL in case of error.\n */\n#define xmlRealloc(ptr, size) xmlReallocLoc((ptr), (size), __FILE__, __LINE__)\n/**\n * xmlMemStrdup:\n * @str:  pointer to the existing string\n *\n * Wrapper for the strdup() function, xmlStrdup() is usually preferred.\n *\n * Returns the pointer to the allocated area or NULL in case of error.\n */\n#define xmlMemStrdup(str) xmlMemStrdupLoc((str), __FILE__, __LINE__)\n\n#endif /* DEBUG_MEMORY_LOCATION */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n\n#ifndef __XML_GLOBALS_H\n#ifndef __XML_THREADS_H__\n#include <libxml/threads.h>\n#include <libxml/globals.h>\n#endif\n#endif\n\n#endif  /* __DEBUG_MEMORY_ALLOC__ */\n\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlmodule.h",
    "content": "/*\n * Summary: dynamic module loading\n * Description: basic API for dynamic module loading, used by\n *              libexslt added in 2.6.17\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Joel W. Reed\n */\n\n#ifndef __XML_MODULE_H__\n#define __XML_MODULE_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_MODULES_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlModulePtr:\n *\n * A handle to a dynamically loaded module\n */\ntypedef struct _xmlModule xmlModule;\ntypedef xmlModule *xmlModulePtr;\n\n/**\n * xmlModuleOption:\n *\n * enumeration of options that can be passed down to xmlModuleOpen()\n */\ntypedef enum {\n    XML_MODULE_LAZY = 1,\t/* lazy binding */\n    XML_MODULE_LOCAL= 2\t\t/* local binding */\n} xmlModuleOption;\n\nXMLPUBFUN xmlModulePtr xmlModuleOpen\t(const char *filename,\n\t\t\t\t\t\t int options);\n\nXMLPUBFUN int xmlModuleSymbol\t\t(xmlModulePtr module,\n\t\t\t\t\t\t const char* name,\n\t\t\t\t\t\t void **result);\n\nXMLPUBFUN int xmlModuleClose\t\t(xmlModulePtr module);\n\nXMLPUBFUN int xmlModuleFree\t\t(xmlModulePtr module);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_MODULES_ENABLED */\n\n#endif /*__XML_MODULE_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlreader.h",
    "content": "/*\n * Summary: the XMLReader implementation\n * Description: API of the XML streaming API based on C# interfaces.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XMLREADER_H__\n#define __XML_XMLREADER_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/xmlIO.h>\n#ifdef LIBXML_SCHEMAS_ENABLED\n#include <libxml/relaxng.h>\n#include <libxml/xmlschemas.h>\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlParserSeverities:\n *\n * How severe an error callback is when the per-reader error callback API\n * is used.\n */\ntypedef enum {\n    XML_PARSER_SEVERITY_VALIDITY_WARNING = 1,\n    XML_PARSER_SEVERITY_VALIDITY_ERROR = 2,\n    XML_PARSER_SEVERITY_WARNING = 3,\n    XML_PARSER_SEVERITY_ERROR = 4\n} xmlParserSeverities;\n\n#ifdef LIBXML_READER_ENABLED\n\n/**\n * xmlTextReaderMode:\n *\n * Internal state values for the reader.\n */\ntypedef enum {\n    XML_TEXTREADER_MODE_INITIAL = 0,\n    XML_TEXTREADER_MODE_INTERACTIVE = 1,\n    XML_TEXTREADER_MODE_ERROR = 2,\n    XML_TEXTREADER_MODE_EOF =3,\n    XML_TEXTREADER_MODE_CLOSED = 4,\n    XML_TEXTREADER_MODE_READING = 5\n} xmlTextReaderMode;\n\n/**\n * xmlParserProperties:\n *\n * Some common options to use with xmlTextReaderSetParserProp, but it\n * is better to use xmlParserOption and the xmlReaderNewxxx and\n * xmlReaderForxxx APIs now.\n */\ntypedef enum {\n    XML_PARSER_LOADDTD = 1,\n    XML_PARSER_DEFAULTATTRS = 2,\n    XML_PARSER_VALIDATE = 3,\n    XML_PARSER_SUBST_ENTITIES = 4\n} xmlParserProperties;\n\n/**\n * xmlReaderTypes:\n *\n * Predefined constants for the different types of nodes.\n */\ntypedef enum {\n    XML_READER_TYPE_NONE = 0,\n    XML_READER_TYPE_ELEMENT = 1,\n    XML_READER_TYPE_ATTRIBUTE = 2,\n    XML_READER_TYPE_TEXT = 3,\n    XML_READER_TYPE_CDATA = 4,\n    XML_READER_TYPE_ENTITY_REFERENCE = 5,\n    XML_READER_TYPE_ENTITY = 6,\n    XML_READER_TYPE_PROCESSING_INSTRUCTION = 7,\n    XML_READER_TYPE_COMMENT = 8,\n    XML_READER_TYPE_DOCUMENT = 9,\n    XML_READER_TYPE_DOCUMENT_TYPE = 10,\n    XML_READER_TYPE_DOCUMENT_FRAGMENT = 11,\n    XML_READER_TYPE_NOTATION = 12,\n    XML_READER_TYPE_WHITESPACE = 13,\n    XML_READER_TYPE_SIGNIFICANT_WHITESPACE = 14,\n    XML_READER_TYPE_END_ELEMENT = 15,\n    XML_READER_TYPE_END_ENTITY = 16,\n    XML_READER_TYPE_XML_DECLARATION = 17\n} xmlReaderTypes;\n\n/**\n * xmlTextReader:\n *\n * Structure for an xmlReader context.\n */\ntypedef struct _xmlTextReader xmlTextReader;\n\n/**\n * xmlTextReaderPtr:\n *\n * Pointer to an xmlReader context.\n */\ntypedef xmlTextReader *xmlTextReaderPtr;\n\n/*\n * Constructors & Destructor\n */\nXMLPUBFUN xmlTextReaderPtr\n\t\t\txmlNewTextReader\t(xmlParserInputBufferPtr input,\n\t                                         const char *URI);\nXMLPUBFUN xmlTextReaderPtr\n\t\t\txmlNewTextReaderFilename(const char *URI);\n\nXMLPUBFUN void\n\t\t\txmlFreeTextReader\t(xmlTextReaderPtr reader);\n\nXMLPUBFUN int\n            xmlTextReaderSetup(xmlTextReaderPtr reader,\n                   xmlParserInputBufferPtr input, const char *URL,\n                   const char *encoding, int options);\n\n/*\n * Iterators\n */\nXMLPUBFUN int\n\t\t\txmlTextReaderRead\t(xmlTextReaderPtr reader);\n\n#ifdef LIBXML_WRITER_ENABLED\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderReadInnerXml(xmlTextReaderPtr reader);\n\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderReadOuterXml(xmlTextReaderPtr reader);\n#endif\n\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderReadString\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderReadAttributeValue(xmlTextReaderPtr reader);\n\n/*\n * Attributes of the node\n */\nXMLPUBFUN int\n\t\t\txmlTextReaderAttributeCount(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderDepth\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderHasAttributes(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderHasValue(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderIsDefault\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderIsEmptyElement(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderNodeType\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderQuoteChar\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t\txmlTextReaderReadState\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n                        xmlTextReaderIsNamespaceDecl(xmlTextReaderPtr reader);\n\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstBaseUri\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstLocalName\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstName\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstNamespaceUri(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstPrefix\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstXmlLang\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstString\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *str);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstValue\t(xmlTextReaderPtr reader);\n\n/*\n * use the Const version of the routine for\n * better performance and simpler code\n */\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderBaseUri\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderLocalName\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderName\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderNamespaceUri(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderPrefix\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderXmlLang\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t\txmlTextReaderValue\t(xmlTextReaderPtr reader);\n\n/*\n * Methods of the XmlTextReader\n */\nXMLPUBFUN int\n\t\t    xmlTextReaderClose\t\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t    xmlTextReaderGetAttributeNo\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t int no);\nXMLPUBFUN xmlChar *\n\t\t    xmlTextReaderGetAttribute\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlChar *\n\t\t    xmlTextReaderGetAttributeNs\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *localName,\n\t\t\t\t\t\t const xmlChar *namespaceURI);\nXMLPUBFUN xmlParserInputBufferPtr\n\t\t    xmlTextReaderGetRemainder\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlChar *\n\t\t    xmlTextReaderLookupNamespace(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToAttributeNo(xmlTextReaderPtr reader,\n\t\t\t\t\t\t int no);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToAttribute(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToAttributeNs(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *localName,\n\t\t\t\t\t\t const xmlChar *namespaceURI);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToFirstAttribute(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToNextAttribute(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderMoveToElement\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderNormalization\t(xmlTextReaderPtr reader);\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstEncoding  (xmlTextReaderPtr reader);\n\n/*\n * Extensions\n */\nXMLPUBFUN int\n\t\t    xmlTextReaderSetParserProp\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t int prop,\n\t\t\t\t\t\t int value);\nXMLPUBFUN int\n\t\t    xmlTextReaderGetParserProp\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t int prop);\nXMLPUBFUN xmlNodePtr\n\t\t    xmlTextReaderCurrentNode\t(xmlTextReaderPtr reader);\n\nXMLPUBFUN int\n            xmlTextReaderGetParserLineNumber(xmlTextReaderPtr reader);\n\nXMLPUBFUN int\n            xmlTextReaderGetParserColumnNumber(xmlTextReaderPtr reader);\n\nXMLPUBFUN xmlNodePtr\n\t\t    xmlTextReaderPreserve\t(xmlTextReaderPtr reader);\n#ifdef LIBXML_PATTERN_ENABLED\nXMLPUBFUN int\n\t\t    xmlTextReaderPreservePattern(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const xmlChar *pattern,\n\t\t\t\t\t\t const xmlChar **namespaces);\n#endif /* LIBXML_PATTERN_ENABLED */\nXMLPUBFUN xmlDocPtr\n\t\t    xmlTextReaderCurrentDoc\t(xmlTextReaderPtr reader);\nXMLPUBFUN xmlNodePtr\n\t\t    xmlTextReaderExpand\t\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderNext\t\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderNextSibling\t(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderIsValid\t(xmlTextReaderPtr reader);\n#ifdef LIBXML_SCHEMAS_ENABLED\nXMLPUBFUN int\n\t\t    xmlTextReaderRelaxNGValidate(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const char *rng);\nXMLPUBFUN int\n\t\t    xmlTextReaderRelaxNGValidateCtxt(xmlTextReaderPtr reader,\n\t\t\t\t\t\t xmlRelaxNGValidCtxtPtr ctxt,\n\t\t\t\t\t\t int options);\n\nXMLPUBFUN int\n\t\t    xmlTextReaderRelaxNGSetSchema(xmlTextReaderPtr reader,\n\t\t\t\t\t\t xmlRelaxNGPtr schema);\nXMLPUBFUN int\n\t\t    xmlTextReaderSchemaValidate\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t const char *xsd);\nXMLPUBFUN int\n\t\t    xmlTextReaderSchemaValidateCtxt(xmlTextReaderPtr reader,\n\t\t\t\t\t\t xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\t    xmlTextReaderSetSchema\t(xmlTextReaderPtr reader,\n\t\t\t\t\t\t xmlSchemaPtr schema);\n#endif\nXMLPUBFUN const xmlChar *\n\t\t    xmlTextReaderConstXmlVersion(xmlTextReaderPtr reader);\nXMLPUBFUN int\n\t\t    xmlTextReaderStandalone     (xmlTextReaderPtr reader);\n\n\n/*\n * Index lookup\n */\nXMLPUBFUN long\n\t\txmlTextReaderByteConsumed\t(xmlTextReaderPtr reader);\n\n/*\n * New more complete APIs for simpler creation and reuse of readers\n */\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderWalker\t\t(xmlDocPtr doc);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForDoc\t\t(const xmlChar * cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForFile\t(const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForMemory\t(const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForFd\t\t(int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlTextReaderPtr\n\t\txmlReaderForIO\t\t(xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\nXMLPUBFUN int\n\t\txmlReaderNewWalker\t(xmlTextReaderPtr reader,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN int\n\t\txmlReaderNewDoc\t\t(xmlTextReaderPtr reader,\n\t\t\t\t\t const xmlChar * cur,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\txmlReaderNewFile\t(xmlTextReaderPtr reader,\n\t\t\t\t\t const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\txmlReaderNewMemory\t(xmlTextReaderPtr reader,\n\t\t\t\t\t const char *buffer,\n\t\t\t\t\t int size,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\txmlReaderNewFd\t\t(xmlTextReaderPtr reader,\n\t\t\t\t\t int fd,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN int\n\t\txmlReaderNewIO\t\t(xmlTextReaderPtr reader,\n\t\t\t\t\t xmlInputReadCallback ioread,\n\t\t\t\t\t xmlInputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *URL,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n/*\n * Error handling extensions\n */\ntypedef void *  xmlTextReaderLocatorPtr;\n\n/**\n * xmlTextReaderErrorFunc:\n * @arg: the user argument\n * @msg: the message\n * @severity: the severity of the error\n * @locator: a locator indicating where the error occurred\n *\n * Signature of an error callback from a reader parser\n */\ntypedef void (*xmlTextReaderErrorFunc)(void *arg,\n\t\t\t\t\t       const char *msg,\n\t\t\t\t\t       xmlParserSeverities severity,\n\t\t\t\t\t       xmlTextReaderLocatorPtr locator);\nXMLPUBFUN int\n\t    xmlTextReaderLocatorLineNumber(xmlTextReaderLocatorPtr locator);\nXMLPUBFUN xmlChar *\n\t    xmlTextReaderLocatorBaseURI (xmlTextReaderLocatorPtr locator);\nXMLPUBFUN void\n\t    xmlTextReaderSetErrorHandler(xmlTextReaderPtr reader,\n\t\t\t\t\t xmlTextReaderErrorFunc f,\n\t\t\t\t\t void *arg);\nXMLPUBFUN void\n\t    xmlTextReaderSetStructuredErrorHandler(xmlTextReaderPtr reader,\n\t\t\t\t\t\t   xmlStructuredErrorFunc f,\n\t\t\t\t\t\t   void *arg);\nXMLPUBFUN void\n\t    xmlTextReaderGetErrorHandler(xmlTextReaderPtr reader,\n\t\t\t\t\t xmlTextReaderErrorFunc *f,\n\t\t\t\t\t void **arg);\n\n#endif /* LIBXML_READER_ENABLED */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* __XML_XMLREADER_H__ */\n\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlregexp.h",
    "content": "/*\n * Summary: regular expressions handling\n * Description: basic API for libxml regular expressions handling used\n *              for XML Schemas and validation.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_REGEXP_H__\n#define __XML_REGEXP_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_REGEXP_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlRegexpPtr:\n *\n * A libxml regular expression, they can actually be far more complex\n * thank the POSIX regex expressions.\n */\ntypedef struct _xmlRegexp xmlRegexp;\ntypedef xmlRegexp *xmlRegexpPtr;\n\n/**\n * xmlRegExecCtxtPtr:\n *\n * A libxml progressive regular expression evaluation context\n */\ntypedef struct _xmlRegExecCtxt xmlRegExecCtxt;\ntypedef xmlRegExecCtxt *xmlRegExecCtxtPtr;\n\n#ifdef __cplusplus\n}\n#endif\n#include <libxml/tree.h>\n#include <libxml/dict.h>\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * The POSIX like API\n */\nXMLPUBFUN xmlRegexpPtr\n\t\t    xmlRegexpCompile\t(const xmlChar *regexp);\nXMLPUBFUN void\t\t\t xmlRegFreeRegexp(xmlRegexpPtr regexp);\nXMLPUBFUN int\n\t\t    xmlRegexpExec\t(xmlRegexpPtr comp,\n\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN void\n\t\t    xmlRegexpPrint\t(FILE *output,\n\t\t\t\t\t xmlRegexpPtr regexp);\nXMLPUBFUN int\n\t\t    xmlRegexpIsDeterminist(xmlRegexpPtr comp);\n\n/**\n * xmlRegExecCallbacks:\n * @exec: the regular expression context\n * @token: the current token string\n * @transdata: transition data\n * @inputdata: input data\n *\n * Callback function when doing a transition in the automata\n */\ntypedef void (*xmlRegExecCallbacks) (xmlRegExecCtxtPtr exec,\n\t                             const xmlChar *token,\n\t\t\t\t     void *transdata,\n\t\t\t\t     void *inputdata);\n\n/*\n * The progressive API\n */\nXMLPUBFUN xmlRegExecCtxtPtr\n\t\t    xmlRegNewExecCtxt\t(xmlRegexpPtr comp,\n\t\t\t\t\t xmlRegExecCallbacks callback,\n\t\t\t\t\t void *data);\nXMLPUBFUN void\n\t\t    xmlRegFreeExecCtxt\t(xmlRegExecCtxtPtr exec);\nXMLPUBFUN int\n\t\t    xmlRegExecPushString(xmlRegExecCtxtPtr exec,\n\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t void *data);\nXMLPUBFUN int\n\t\t    xmlRegExecPushString2(xmlRegExecCtxtPtr exec,\n\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t const xmlChar *value2,\n\t\t\t\t\t void *data);\n\nXMLPUBFUN int\n\t\t    xmlRegExecNextValues(xmlRegExecCtxtPtr exec,\n\t\t\t\t\t int *nbval,\n\t\t\t\t\t int *nbneg,\n\t\t\t\t\t xmlChar **values,\n\t\t\t\t\t int *terminal);\nXMLPUBFUN int\n\t\t    xmlRegExecErrInfo\t(xmlRegExecCtxtPtr exec,\n\t\t\t\t\t const xmlChar **string,\n\t\t\t\t\t int *nbval,\n\t\t\t\t\t int *nbneg,\n\t\t\t\t\t xmlChar **values,\n\t\t\t\t\t int *terminal);\n#ifdef LIBXML_EXPR_ENABLED\n/*\n * Formal regular expression handling\n * Its goal is to do some formal work on content models\n */\n\n/* expressions are used within a context */\ntypedef struct _xmlExpCtxt xmlExpCtxt;\ntypedef xmlExpCtxt *xmlExpCtxtPtr;\n\nXMLPUBFUN void\n\t\t\txmlExpFreeCtxt\t(xmlExpCtxtPtr ctxt);\nXMLPUBFUN xmlExpCtxtPtr\n\t\t\txmlExpNewCtxt\t(int maxNodes,\n\t\t\t\t\t xmlDictPtr dict);\n\nXMLPUBFUN int\n\t\t\txmlExpCtxtNbNodes(xmlExpCtxtPtr ctxt);\nXMLPUBFUN int\n\t\t\txmlExpCtxtNbCons(xmlExpCtxtPtr ctxt);\n\n/* Expressions are trees but the tree is opaque */\ntypedef struct _xmlExpNode xmlExpNode;\ntypedef xmlExpNode *xmlExpNodePtr;\n\ntypedef enum {\n    XML_EXP_EMPTY = 0,\n    XML_EXP_FORBID = 1,\n    XML_EXP_ATOM = 2,\n    XML_EXP_SEQ = 3,\n    XML_EXP_OR = 4,\n    XML_EXP_COUNT = 5\n} xmlExpNodeType;\n\n/*\n * 2 core expressions shared by all for the empty language set\n * and for the set with just the empty token\n */\nXMLPUBVAR xmlExpNodePtr forbiddenExp;\nXMLPUBVAR xmlExpNodePtr emptyExp;\n\n/*\n * Expressions are reference counted internally\n */\nXMLPUBFUN void\n\t\t\txmlExpFree\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr);\nXMLPUBFUN void\n\t\t\txmlExpRef\t(xmlExpNodePtr expr);\n\n/*\n * constructors can be either manual or from a string\n */\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpParse\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t const char *expr);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpNewAtom\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpNewOr\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr left,\n\t\t\t\t\t xmlExpNodePtr right);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpNewSeq\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr left,\n\t\t\t\t\t xmlExpNodePtr right);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpNewRange\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr subset,\n\t\t\t\t\t int min,\n\t\t\t\t\t int max);\n/*\n * The really interesting APIs\n */\nXMLPUBFUN int\n\t\t\txmlExpIsNillable(xmlExpNodePtr expr);\nXMLPUBFUN int\n\t\t\txmlExpMaxToken\t(xmlExpNodePtr expr);\nXMLPUBFUN int\n\t\t\txmlExpGetLanguage(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t const xmlChar**langList,\n\t\t\t\t\t int len);\nXMLPUBFUN int\n\t\t\txmlExpGetStart\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t const xmlChar**tokList,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpStringDerive(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t int len);\nXMLPUBFUN xmlExpNodePtr\n\t\t\txmlExpExpDerive\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t xmlExpNodePtr sub);\nXMLPUBFUN int\n\t\t\txmlExpSubsume\t(xmlExpCtxtPtr ctxt,\n\t\t\t\t\t xmlExpNodePtr expr,\n\t\t\t\t\t xmlExpNodePtr sub);\nXMLPUBFUN void\n\t\t\txmlExpDump\t(xmlBufferPtr buf,\n\t\t\t\t\t xmlExpNodePtr expr);\n#endif /* LIBXML_EXPR_ENABLED */\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_REGEXP_ENABLED */\n\n#endif /*__XML_REGEXP_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlsave.h",
    "content": "/*\n * Summary: the XML document serializer\n * Description: API to save document or subtree of document\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XMLSAVE_H__\n#define __XML_XMLSAVE_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/tree.h>\n#include <libxml/encoding.h>\n#include <libxml/xmlIO.h>\n\n#ifdef LIBXML_OUTPUT_ENABLED\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlSaveOption:\n *\n * This is the set of XML save options that can be passed down\n * to the xmlSaveToFd() and similar calls.\n */\ntypedef enum {\n    XML_SAVE_FORMAT     = 1<<0,\t/* format save output */\n    XML_SAVE_NO_DECL    = 1<<1,\t/* drop the xml declaration */\n    XML_SAVE_NO_EMPTY\t= 1<<2, /* no empty tags */\n    XML_SAVE_NO_XHTML\t= 1<<3, /* disable XHTML1 specific rules */\n    XML_SAVE_XHTML\t= 1<<4, /* force XHTML1 specific rules */\n    XML_SAVE_AS_XML     = 1<<5, /* force XML serialization on HTML doc */\n    XML_SAVE_AS_HTML    = 1<<6, /* force HTML serialization on XML doc */\n    XML_SAVE_WSNONSIG   = 1<<7  /* format with non-significant whitespace */\n} xmlSaveOption;\n\n\ntypedef struct _xmlSaveCtxt xmlSaveCtxt;\ntypedef xmlSaveCtxt *xmlSaveCtxtPtr;\n\nXMLPUBFUN xmlSaveCtxtPtr\n\t\txmlSaveToFd\t\t(int fd,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\nXMLPUBFUN xmlSaveCtxtPtr\n\t\txmlSaveToFilename\t(const char *filename,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\nXMLPUBFUN xmlSaveCtxtPtr\n\t\txmlSaveToBuffer\t\t(xmlBufferPtr buffer,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\nXMLPUBFUN xmlSaveCtxtPtr\n\t\txmlSaveToIO\t\t(xmlOutputWriteCallback iowrite,\n\t\t\t\t\t xmlOutputCloseCallback ioclose,\n\t\t\t\t\t void *ioctx,\n\t\t\t\t\t const char *encoding,\n\t\t\t\t\t int options);\n\nXMLPUBFUN long\n\t\txmlSaveDoc\t\t(xmlSaveCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr doc);\nXMLPUBFUN long\n\t\txmlSaveTree\t\t(xmlSaveCtxtPtr ctxt,\n\t\t\t\t\t xmlNodePtr node);\n\nXMLPUBFUN int\n\t\txmlSaveFlush\t\t(xmlSaveCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlSaveClose\t\t(xmlSaveCtxtPtr ctxt);\nXMLPUBFUN int\n\t\txmlSaveSetEscape\t(xmlSaveCtxtPtr ctxt,\n\t\t\t\t\t xmlCharEncodingOutputFunc escape);\nXMLPUBFUN int\n\t\txmlSaveSetAttrEscape\t(xmlSaveCtxtPtr ctxt,\n\t\t\t\t\t xmlCharEncodingOutputFunc escape);\n#ifdef __cplusplus\n}\n#endif\n#endif /* LIBXML_OUTPUT_ENABLED */\n#endif /* __XML_XMLSAVE_H__ */\n\n\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlschemas.h",
    "content": "/*\n * Summary: incomplete XML Schemas structure implementation\n * Description: interface to the XML Schemas handling and schema validity\n *              checking, it is incomplete right now.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SCHEMA_H__\n#define __XML_SCHEMA_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_SCHEMAS_ENABLED\n\n#include <libxml/tree.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * This error codes are obsolete; not used any more.\n */\ntypedef enum {\n    XML_SCHEMAS_ERR_OK\t\t= 0,\n    XML_SCHEMAS_ERR_NOROOT\t= 1,\n    XML_SCHEMAS_ERR_UNDECLAREDELEM,\n    XML_SCHEMAS_ERR_NOTTOPLEVEL,\n    XML_SCHEMAS_ERR_MISSING,\n    XML_SCHEMAS_ERR_WRONGELEM,\n    XML_SCHEMAS_ERR_NOTYPE,\n    XML_SCHEMAS_ERR_NOROLLBACK,\n    XML_SCHEMAS_ERR_ISABSTRACT,\n    XML_SCHEMAS_ERR_NOTEMPTY,\n    XML_SCHEMAS_ERR_ELEMCONT,\n    XML_SCHEMAS_ERR_HAVEDEFAULT,\n    XML_SCHEMAS_ERR_NOTNILLABLE,\n    XML_SCHEMAS_ERR_EXTRACONTENT,\n    XML_SCHEMAS_ERR_INVALIDATTR,\n    XML_SCHEMAS_ERR_INVALIDELEM,\n    XML_SCHEMAS_ERR_NOTDETERMINIST,\n    XML_SCHEMAS_ERR_CONSTRUCT,\n    XML_SCHEMAS_ERR_INTERNAL,\n    XML_SCHEMAS_ERR_NOTSIMPLE,\n    XML_SCHEMAS_ERR_ATTRUNKNOWN,\n    XML_SCHEMAS_ERR_ATTRINVALID,\n    XML_SCHEMAS_ERR_VALUE,\n    XML_SCHEMAS_ERR_FACET,\n    XML_SCHEMAS_ERR_,\n    XML_SCHEMAS_ERR_XXX\n} xmlSchemaValidError;\n\n/*\n* ATTENTION: Change xmlSchemaSetValidOptions's check\n* for invalid values, if adding to the validation\n* options below.\n*/\n/**\n * xmlSchemaValidOption:\n *\n * This is the set of XML Schema validation options.\n */\ntypedef enum {\n    XML_SCHEMA_VAL_VC_I_CREATE\t\t\t= 1<<0\n\t/* Default/fixed: create an attribute node\n\t* or an element's text node on the instance.\n\t*/\n} xmlSchemaValidOption;\n\n/*\n    XML_SCHEMA_VAL_XSI_ASSEMBLE\t\t\t= 1<<1,\n\t* assemble schemata using\n\t* xsi:schemaLocation and\n\t* xsi:noNamespaceSchemaLocation\n*/\n\n/**\n * The schemas related types are kept internal\n */\ntypedef struct _xmlSchema xmlSchema;\ntypedef xmlSchema *xmlSchemaPtr;\n\n/**\n * xmlSchemaValidityErrorFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of an error callback from an XSD validation\n */\ntypedef void (*xmlSchemaValidityErrorFunc)\n                 (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * xmlSchemaValidityWarningFunc:\n * @ctx: the validation context\n * @msg: the message\n * @...: extra arguments\n *\n * Signature of a warning callback from an XSD validation\n */\ntypedef void (*xmlSchemaValidityWarningFunc)\n                 (void *ctx, const char *msg, ...) LIBXML_ATTR_FORMAT(2,3);\n\n/**\n * A schemas validation context\n */\ntypedef struct _xmlSchemaParserCtxt xmlSchemaParserCtxt;\ntypedef xmlSchemaParserCtxt *xmlSchemaParserCtxtPtr;\n\ntypedef struct _xmlSchemaValidCtxt xmlSchemaValidCtxt;\ntypedef xmlSchemaValidCtxt *xmlSchemaValidCtxtPtr;\n\n/**\n * xmlSchemaValidityLocatorFunc:\n * @ctx: user provided context\n * @file: returned file information\n * @line: returned line information\n *\n * A schemas validation locator, a callback called by the validator.\n * This is used when file or node information are not available\n * to find out what file and line number are affected\n *\n * Returns: 0 in case of success and -1 in case of error\n */\n\ntypedef int (*xmlSchemaValidityLocatorFunc) (void *ctx,\n                           const char **file, unsigned long *line);\n\n/*\n * Interfaces for parsing.\n */\nXMLPUBFUN xmlSchemaParserCtxtPtr\n\t    xmlSchemaNewParserCtxt\t(const char *URL);\nXMLPUBFUN xmlSchemaParserCtxtPtr\n\t    xmlSchemaNewMemParserCtxt\t(const char *buffer,\n\t\t\t\t\t int size);\nXMLPUBFUN xmlSchemaParserCtxtPtr\n\t    xmlSchemaNewDocParserCtxt\t(xmlDocPtr doc);\nXMLPUBFUN void\n\t    xmlSchemaFreeParserCtxt\t(xmlSchemaParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t    xmlSchemaSetParserErrors\t(xmlSchemaParserCtxtPtr ctxt,\n\t\t\t\t\t xmlSchemaValidityErrorFunc err,\n\t\t\t\t\t xmlSchemaValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN void\n\t    xmlSchemaSetParserStructuredErrors(xmlSchemaParserCtxtPtr ctxt,\n\t\t\t\t\t xmlStructuredErrorFunc serror,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t\txmlSchemaGetParserErrors(xmlSchemaParserCtxtPtr ctxt,\n\t\t\t\t\txmlSchemaValidityErrorFunc * err,\n\t\t\t\t\txmlSchemaValidityWarningFunc * warn,\n\t\t\t\t\tvoid **ctx);\nXMLPUBFUN int\n\t\txmlSchemaIsValid\t(xmlSchemaValidCtxtPtr ctxt);\n\nXMLPUBFUN xmlSchemaPtr\n\t    xmlSchemaParse\t\t(xmlSchemaParserCtxtPtr ctxt);\nXMLPUBFUN void\n\t    xmlSchemaFree\t\t(xmlSchemaPtr schema);\n#ifdef LIBXML_OUTPUT_ENABLED\nXMLPUBFUN void\n\t    xmlSchemaDump\t\t(FILE *output,\n\t\t\t\t\t xmlSchemaPtr schema);\n#endif /* LIBXML_OUTPUT_ENABLED */\n/*\n * Interfaces for validating\n */\nXMLPUBFUN void\n\t    xmlSchemaSetValidErrors\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSchemaValidityErrorFunc err,\n\t\t\t\t\t xmlSchemaValidityWarningFunc warn,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN void\n\t    xmlSchemaSetValidStructuredErrors(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlStructuredErrorFunc serror,\n\t\t\t\t\t void *ctx);\nXMLPUBFUN int\n\t    xmlSchemaGetValidErrors\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSchemaValidityErrorFunc *err,\n\t\t\t\t\t xmlSchemaValidityWarningFunc *warn,\n\t\t\t\t\t void **ctx);\nXMLPUBFUN int\n\t    xmlSchemaSetValidOptions\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t int options);\nXMLPUBFUN void\n            xmlSchemaValidateSetFilename(xmlSchemaValidCtxtPtr vctxt,\n\t                                 const char *filename);\nXMLPUBFUN int\n\t    xmlSchemaValidCtxtGetOptions(xmlSchemaValidCtxtPtr ctxt);\n\nXMLPUBFUN xmlSchemaValidCtxtPtr\n\t    xmlSchemaNewValidCtxt\t(xmlSchemaPtr schema);\nXMLPUBFUN void\n\t    xmlSchemaFreeValidCtxt\t(xmlSchemaValidCtxtPtr ctxt);\nXMLPUBFUN int\n\t    xmlSchemaValidateDoc\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlDocPtr instance);\nXMLPUBFUN int\n            xmlSchemaValidateOneElement (xmlSchemaValidCtxtPtr ctxt,\n\t\t\t                 xmlNodePtr elem);\nXMLPUBFUN int\n\t    xmlSchemaValidateStream\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlParserInputBufferPtr input,\n\t\t\t\t\t xmlCharEncoding enc,\n\t\t\t\t\t xmlSAXHandlerPtr sax,\n\t\t\t\t\t void *user_data);\nXMLPUBFUN int\n\t    xmlSchemaValidateFile\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t const char * filename,\n\t\t\t\t\t int options);\n\nXMLPUBFUN xmlParserCtxtPtr\n\t    xmlSchemaValidCtxtGetParserCtxt(xmlSchemaValidCtxtPtr ctxt);\n\n/*\n * Interface to insert Schemas SAX validation in a SAX stream\n */\ntypedef struct _xmlSchemaSAXPlug xmlSchemaSAXPlugStruct;\ntypedef xmlSchemaSAXPlugStruct *xmlSchemaSAXPlugPtr;\n\nXMLPUBFUN xmlSchemaSAXPlugPtr\n            xmlSchemaSAXPlug\t\t(xmlSchemaValidCtxtPtr ctxt,\n\t\t\t\t\t xmlSAXHandlerPtr *sax,\n\t\t\t\t\t void **user_data);\nXMLPUBFUN int\n            xmlSchemaSAXUnplug\t\t(xmlSchemaSAXPlugPtr plug);\n\n\nXMLPUBFUN void\n            xmlSchemaValidateSetLocator\t(xmlSchemaValidCtxtPtr vctxt,\n\t\t\t\t\t xmlSchemaValidityLocatorFunc f,\n\t\t\t\t\t void *ctxt);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMAS_ENABLED */\n#endif /* __XML_SCHEMA_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlschemastypes.h",
    "content": "/*\n * Summary: implementation of XML Schema Datatypes\n * Description: module providing the XML Schema Datatypes implementation\n *              both definition and validity checking\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n\n#ifndef __XML_SCHEMA_TYPES_H__\n#define __XML_SCHEMA_TYPES_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_SCHEMAS_ENABLED\n\n#include <libxml/schemasInternals.h>\n#include <libxml/xmlschemas.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\ntypedef enum {\n    XML_SCHEMA_WHITESPACE_UNKNOWN = 0,\n    XML_SCHEMA_WHITESPACE_PRESERVE = 1,\n    XML_SCHEMA_WHITESPACE_REPLACE = 2,\n    XML_SCHEMA_WHITESPACE_COLLAPSE = 3\n} xmlSchemaWhitespaceValueType;\n\nXMLPUBFUN int\n\t\txmlSchemaInitTypes\t\t(void);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\txmlSchemaCleanupTypes\t\t(void);\nXMLPUBFUN xmlSchemaTypePtr\n\t\txmlSchemaGetPredefinedType\t(const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns);\nXMLPUBFUN int\n\t\txmlSchemaValidatePredefinedType\t(xmlSchemaTypePtr type,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr *val);\nXMLPUBFUN int\n\t\txmlSchemaValPredefTypeNode\t(xmlSchemaTypePtr type,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr *val,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN int\n\t\txmlSchemaValidateFacet\t\t(xmlSchemaTypePtr base,\n\t\t\t\t\t\t xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr val);\nXMLPUBFUN int\n\t\txmlSchemaValidateFacetWhtsp\t(xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType fws,\n\t\t\t\t\t\t xmlSchemaValType valType,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr val,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType ws);\nXMLPUBFUN void\n\t\txmlSchemaFreeValue\t\t(xmlSchemaValPtr val);\nXMLPUBFUN xmlSchemaFacetPtr\n\t\txmlSchemaNewFacet\t\t(void);\nXMLPUBFUN int\n\t\txmlSchemaCheckFacet\t\t(xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t xmlSchemaTypePtr typeDecl,\n\t\t\t\t\t\t xmlSchemaParserCtxtPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN void\n\t\txmlSchemaFreeFacet\t\t(xmlSchemaFacetPtr facet);\nXMLPUBFUN int\n\t\txmlSchemaCompareValues\t\t(xmlSchemaValPtr x,\n\t\t\t\t\t\t xmlSchemaValPtr y);\nXMLPUBFUN xmlSchemaTypePtr\n    xmlSchemaGetBuiltInListSimpleTypeItemType\t(xmlSchemaTypePtr type);\nXMLPUBFUN int\n    xmlSchemaValidateListSimpleTypeFacet\t(xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t unsigned long actualLen,\n\t\t\t\t\t\t unsigned long *expectedLen);\nXMLPUBFUN xmlSchemaTypePtr\n\t\txmlSchemaGetBuiltInType\t\t(xmlSchemaValType type);\nXMLPUBFUN int\n\t\txmlSchemaIsBuiltInTypeFacet\t(xmlSchemaTypePtr type,\n\t\t\t\t\t\t int facetType);\nXMLPUBFUN xmlChar *\n\t\txmlSchemaCollapseString\t\t(const xmlChar *value);\nXMLPUBFUN xmlChar *\n\t\txmlSchemaWhiteSpaceReplace\t(const xmlChar *value);\nXMLPUBFUN unsigned long \n\t\txmlSchemaGetFacetValueAsULong\t(xmlSchemaFacetPtr facet);\nXMLPUBFUN int\n\t\txmlSchemaValidateLengthFacet\t(xmlSchemaTypePtr type,\n\t\t\t\t\t\t xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr val,\n\t\t\t\t\t\t unsigned long *length);\nXMLPUBFUN int\n\t\txmlSchemaValidateLengthFacetWhtsp(xmlSchemaFacetPtr facet,\n\t\t\t\t\t\t  xmlSchemaValType valType,\n\t\t\t\t\t\t  const xmlChar *value,\n\t\t\t\t\t\t  xmlSchemaValPtr val,\n\t\t\t\t\t\t  unsigned long *length,\n\t\t\t\t\t\t  xmlSchemaWhitespaceValueType ws);\nXMLPUBFUN int\n\t\txmlSchemaValPredefTypeNodeNoNorm(xmlSchemaTypePtr type,\n\t\t\t\t\t\t const xmlChar *value,\n\t\t\t\t\t\t xmlSchemaValPtr *val,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN int\n\t\txmlSchemaGetCanonValue\t\t(xmlSchemaValPtr val,\n\t\t\t\t\t\t const xmlChar **retValue);\nXMLPUBFUN int\n\t\txmlSchemaGetCanonValueWhtsp\t(xmlSchemaValPtr val,\n\t\t\t\t\t\t const xmlChar **retValue,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType ws);\nXMLPUBFUN int\n\t\txmlSchemaValueAppend\t\t(xmlSchemaValPtr prev,\n\t\t\t\t\t\t xmlSchemaValPtr cur);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaValueGetNext\t\t(xmlSchemaValPtr cur);\nXMLPUBFUN const xmlChar *\n\t\txmlSchemaValueGetAsString\t(xmlSchemaValPtr val);\nXMLPUBFUN int\n\t\txmlSchemaValueGetAsBoolean\t(xmlSchemaValPtr val);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaNewStringValue\t\t(xmlSchemaValType type,\n\t\t\t\t\t\t const xmlChar *value);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaNewNOTATIONValue\t(const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaNewQNameValue\t\t(const xmlChar *namespaceName,\n\t\t\t\t\t\t const xmlChar *localName);\nXMLPUBFUN int\n\t\txmlSchemaCompareValuesWhtsp\t(xmlSchemaValPtr x,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType xws,\n\t\t\t\t\t\t xmlSchemaValPtr y,\n\t\t\t\t\t\t xmlSchemaWhitespaceValueType yws);\nXMLPUBFUN xmlSchemaValPtr\n\t\txmlSchemaCopyValue\t\t(xmlSchemaValPtr val);\nXMLPUBFUN xmlSchemaValType\n\t\txmlSchemaGetValType\t\t(xmlSchemaValPtr val);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_SCHEMAS_ENABLED */\n#endif /* __XML_SCHEMA_TYPES_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlstring.h",
    "content": "/*\n * Summary: set of routines to process strings\n * Description: type and interfaces needed for the internal string handling\n *              of the library, especially UTF8 processing.\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_STRING_H__\n#define __XML_STRING_H__\n\n#include <stdarg.h>\n#include <libxml/xmlversion.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/**\n * xmlChar:\n *\n * This is a basic byte in an UTF-8 encoded string.\n * It's unsigned allowing to pinpoint case where char * are assigned\n * to xmlChar * (possibly making serialization back impossible).\n */\ntypedef unsigned char xmlChar;\n\n/**\n * BAD_CAST:\n *\n * Macro to cast a string to an xmlChar * when one know its safe.\n */\n#define BAD_CAST (xmlChar *)\n\n/*\n * xmlChar handling\n */\nXMLPUBFUN xmlChar *\n                xmlStrdup                (const xmlChar *cur);\nXMLPUBFUN xmlChar *\n                xmlStrndup               (const xmlChar *cur,\n                                         int len);\nXMLPUBFUN xmlChar *\n                xmlCharStrndup           (const char *cur,\n                                         int len);\nXMLPUBFUN xmlChar *\n                xmlCharStrdup            (const char *cur);\nXMLPUBFUN xmlChar *\n                xmlStrsub                (const xmlChar *str,\n                                         int start,\n                                         int len);\nXMLPUBFUN const xmlChar *\n                xmlStrchr                (const xmlChar *str,\n                                         xmlChar val);\nXMLPUBFUN const xmlChar *\n                xmlStrstr                (const xmlChar *str,\n                                         const xmlChar *val);\nXMLPUBFUN const xmlChar *\n                xmlStrcasestr            (const xmlChar *str,\n                                         const xmlChar *val);\nXMLPUBFUN int\n                xmlStrcmp                (const xmlChar *str1,\n                                         const xmlChar *str2);\nXMLPUBFUN int\n                xmlStrncmp               (const xmlChar *str1,\n                                         const xmlChar *str2,\n                                         int len);\nXMLPUBFUN int\n                xmlStrcasecmp            (const xmlChar *str1,\n                                         const xmlChar *str2);\nXMLPUBFUN int\n                xmlStrncasecmp           (const xmlChar *str1,\n                                         const xmlChar *str2,\n                                         int len);\nXMLPUBFUN int\n                xmlStrEqual              (const xmlChar *str1,\n                                         const xmlChar *str2);\nXMLPUBFUN int\n                xmlStrQEqual             (const xmlChar *pref,\n                                         const xmlChar *name,\n                                         const xmlChar *str);\nXMLPUBFUN int\n                xmlStrlen                (const xmlChar *str);\nXMLPUBFUN xmlChar *\n                xmlStrcat                (xmlChar *cur,\n                                         const xmlChar *add);\nXMLPUBFUN xmlChar *\n                xmlStrncat               (xmlChar *cur,\n                                         const xmlChar *add,\n                                         int len);\nXMLPUBFUN xmlChar *\n                xmlStrncatNew            (const xmlChar *str1,\n                                         const xmlChar *str2,\n                                         int len);\nXMLPUBFUN int\n                xmlStrPrintf             (xmlChar *buf,\n                                         int len,\n                                         const char *msg,\n                                         ...) LIBXML_ATTR_FORMAT(3,4);\nXMLPUBFUN int\n                xmlStrVPrintf                (xmlChar *buf,\n                                         int len,\n                                         const char *msg,\n                                         va_list ap) LIBXML_ATTR_FORMAT(3,0);\n\nXMLPUBFUN int\n        xmlGetUTF8Char                   (const unsigned char *utf,\n                                         int *len);\nXMLPUBFUN int\n        xmlCheckUTF8                     (const unsigned char *utf);\nXMLPUBFUN int\n        xmlUTF8Strsize                   (const xmlChar *utf,\n                                         int len);\nXMLPUBFUN xmlChar *\n        xmlUTF8Strndup                   (const xmlChar *utf,\n                                         int len);\nXMLPUBFUN const xmlChar *\n        xmlUTF8Strpos                    (const xmlChar *utf,\n                                         int pos);\nXMLPUBFUN int\n        xmlUTF8Strloc                    (const xmlChar *utf,\n                                         const xmlChar *utfchar);\nXMLPUBFUN xmlChar *\n        xmlUTF8Strsub                    (const xmlChar *utf,\n                                         int start,\n                                         int len);\nXMLPUBFUN int\n        xmlUTF8Strlen                    (const xmlChar *utf);\nXMLPUBFUN int\n        xmlUTF8Size                      (const xmlChar *utf);\nXMLPUBFUN int\n        xmlUTF8Charcmp                   (const xmlChar *utf1,\n                                         const xmlChar *utf2);\n\n#ifdef __cplusplus\n}\n#endif\n#endif /* __XML_STRING_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlunicode.h",
    "content": "/*\n * Summary: Unicode character APIs\n * Description: API for the Unicode character APIs\n *\n * This file is automatically generated from the\n * UCS description files of the Unicode Character Database\n * http://www.unicode.org/Public/4.0-Update1/UCD-4.0.1.html\n * using the genUnicode.py Python script.\n *\n * Generation date: Mon Mar 27 11:09:52 2006\n * Sources: Blocks-4.0.1.txt UnicodeData-4.0.1.txt\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_UNICODE_H__\n#define __XML_UNICODE_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_UNICODE_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nXMLPUBFUN int xmlUCSIsAegeanNumbers\t(int code);\nXMLPUBFUN int xmlUCSIsAlphabeticPresentationForms\t(int code);\nXMLPUBFUN int xmlUCSIsArabic\t(int code);\nXMLPUBFUN int xmlUCSIsArabicPresentationFormsA\t(int code);\nXMLPUBFUN int xmlUCSIsArabicPresentationFormsB\t(int code);\nXMLPUBFUN int xmlUCSIsArmenian\t(int code);\nXMLPUBFUN int xmlUCSIsArrows\t(int code);\nXMLPUBFUN int xmlUCSIsBasicLatin\t(int code);\nXMLPUBFUN int xmlUCSIsBengali\t(int code);\nXMLPUBFUN int xmlUCSIsBlockElements\t(int code);\nXMLPUBFUN int xmlUCSIsBopomofo\t(int code);\nXMLPUBFUN int xmlUCSIsBopomofoExtended\t(int code);\nXMLPUBFUN int xmlUCSIsBoxDrawing\t(int code);\nXMLPUBFUN int xmlUCSIsBraillePatterns\t(int code);\nXMLPUBFUN int xmlUCSIsBuhid\t(int code);\nXMLPUBFUN int xmlUCSIsByzantineMusicalSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsCJKCompatibility\t(int code);\nXMLPUBFUN int xmlUCSIsCJKCompatibilityForms\t(int code);\nXMLPUBFUN int xmlUCSIsCJKCompatibilityIdeographs\t(int code);\nXMLPUBFUN int xmlUCSIsCJKCompatibilityIdeographsSupplement\t(int code);\nXMLPUBFUN int xmlUCSIsCJKRadicalsSupplement\t(int code);\nXMLPUBFUN int xmlUCSIsCJKSymbolsandPunctuation\t(int code);\nXMLPUBFUN int xmlUCSIsCJKUnifiedIdeographs\t(int code);\nXMLPUBFUN int xmlUCSIsCJKUnifiedIdeographsExtensionA\t(int code);\nXMLPUBFUN int xmlUCSIsCJKUnifiedIdeographsExtensionB\t(int code);\nXMLPUBFUN int xmlUCSIsCherokee\t(int code);\nXMLPUBFUN int xmlUCSIsCombiningDiacriticalMarks\t(int code);\nXMLPUBFUN int xmlUCSIsCombiningDiacriticalMarksforSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsCombiningHalfMarks\t(int code);\nXMLPUBFUN int xmlUCSIsCombiningMarksforSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsControlPictures\t(int code);\nXMLPUBFUN int xmlUCSIsCurrencySymbols\t(int code);\nXMLPUBFUN int xmlUCSIsCypriotSyllabary\t(int code);\nXMLPUBFUN int xmlUCSIsCyrillic\t(int code);\nXMLPUBFUN int xmlUCSIsCyrillicSupplement\t(int code);\nXMLPUBFUN int xmlUCSIsDeseret\t(int code);\nXMLPUBFUN int xmlUCSIsDevanagari\t(int code);\nXMLPUBFUN int xmlUCSIsDingbats\t(int code);\nXMLPUBFUN int xmlUCSIsEnclosedAlphanumerics\t(int code);\nXMLPUBFUN int xmlUCSIsEnclosedCJKLettersandMonths\t(int code);\nXMLPUBFUN int xmlUCSIsEthiopic\t(int code);\nXMLPUBFUN int xmlUCSIsGeneralPunctuation\t(int code);\nXMLPUBFUN int xmlUCSIsGeometricShapes\t(int code);\nXMLPUBFUN int xmlUCSIsGeorgian\t(int code);\nXMLPUBFUN int xmlUCSIsGothic\t(int code);\nXMLPUBFUN int xmlUCSIsGreek\t(int code);\nXMLPUBFUN int xmlUCSIsGreekExtended\t(int code);\nXMLPUBFUN int xmlUCSIsGreekandCoptic\t(int code);\nXMLPUBFUN int xmlUCSIsGujarati\t(int code);\nXMLPUBFUN int xmlUCSIsGurmukhi\t(int code);\nXMLPUBFUN int xmlUCSIsHalfwidthandFullwidthForms\t(int code);\nXMLPUBFUN int xmlUCSIsHangulCompatibilityJamo\t(int code);\nXMLPUBFUN int xmlUCSIsHangulJamo\t(int code);\nXMLPUBFUN int xmlUCSIsHangulSyllables\t(int code);\nXMLPUBFUN int xmlUCSIsHanunoo\t(int code);\nXMLPUBFUN int xmlUCSIsHebrew\t(int code);\nXMLPUBFUN int xmlUCSIsHighPrivateUseSurrogates\t(int code);\nXMLPUBFUN int xmlUCSIsHighSurrogates\t(int code);\nXMLPUBFUN int xmlUCSIsHiragana\t(int code);\nXMLPUBFUN int xmlUCSIsIPAExtensions\t(int code);\nXMLPUBFUN int xmlUCSIsIdeographicDescriptionCharacters\t(int code);\nXMLPUBFUN int xmlUCSIsKanbun\t(int code);\nXMLPUBFUN int xmlUCSIsKangxiRadicals\t(int code);\nXMLPUBFUN int xmlUCSIsKannada\t(int code);\nXMLPUBFUN int xmlUCSIsKatakana\t(int code);\nXMLPUBFUN int xmlUCSIsKatakanaPhoneticExtensions\t(int code);\nXMLPUBFUN int xmlUCSIsKhmer\t(int code);\nXMLPUBFUN int xmlUCSIsKhmerSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsLao\t(int code);\nXMLPUBFUN int xmlUCSIsLatin1Supplement\t(int code);\nXMLPUBFUN int xmlUCSIsLatinExtendedA\t(int code);\nXMLPUBFUN int xmlUCSIsLatinExtendedB\t(int code);\nXMLPUBFUN int xmlUCSIsLatinExtendedAdditional\t(int code);\nXMLPUBFUN int xmlUCSIsLetterlikeSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsLimbu\t(int code);\nXMLPUBFUN int xmlUCSIsLinearBIdeograms\t(int code);\nXMLPUBFUN int xmlUCSIsLinearBSyllabary\t(int code);\nXMLPUBFUN int xmlUCSIsLowSurrogates\t(int code);\nXMLPUBFUN int xmlUCSIsMalayalam\t(int code);\nXMLPUBFUN int xmlUCSIsMathematicalAlphanumericSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsMathematicalOperators\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousMathematicalSymbolsA\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousMathematicalSymbolsB\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousSymbolsandArrows\t(int code);\nXMLPUBFUN int xmlUCSIsMiscellaneousTechnical\t(int code);\nXMLPUBFUN int xmlUCSIsMongolian\t(int code);\nXMLPUBFUN int xmlUCSIsMusicalSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsMyanmar\t(int code);\nXMLPUBFUN int xmlUCSIsNumberForms\t(int code);\nXMLPUBFUN int xmlUCSIsOgham\t(int code);\nXMLPUBFUN int xmlUCSIsOldItalic\t(int code);\nXMLPUBFUN int xmlUCSIsOpticalCharacterRecognition\t(int code);\nXMLPUBFUN int xmlUCSIsOriya\t(int code);\nXMLPUBFUN int xmlUCSIsOsmanya\t(int code);\nXMLPUBFUN int xmlUCSIsPhoneticExtensions\t(int code);\nXMLPUBFUN int xmlUCSIsPrivateUse\t(int code);\nXMLPUBFUN int xmlUCSIsPrivateUseArea\t(int code);\nXMLPUBFUN int xmlUCSIsRunic\t(int code);\nXMLPUBFUN int xmlUCSIsShavian\t(int code);\nXMLPUBFUN int xmlUCSIsSinhala\t(int code);\nXMLPUBFUN int xmlUCSIsSmallFormVariants\t(int code);\nXMLPUBFUN int xmlUCSIsSpacingModifierLetters\t(int code);\nXMLPUBFUN int xmlUCSIsSpecials\t(int code);\nXMLPUBFUN int xmlUCSIsSuperscriptsandSubscripts\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementalArrowsA\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementalArrowsB\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementalMathematicalOperators\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementaryPrivateUseAreaA\t(int code);\nXMLPUBFUN int xmlUCSIsSupplementaryPrivateUseAreaB\t(int code);\nXMLPUBFUN int xmlUCSIsSyriac\t(int code);\nXMLPUBFUN int xmlUCSIsTagalog\t(int code);\nXMLPUBFUN int xmlUCSIsTagbanwa\t(int code);\nXMLPUBFUN int xmlUCSIsTags\t(int code);\nXMLPUBFUN int xmlUCSIsTaiLe\t(int code);\nXMLPUBFUN int xmlUCSIsTaiXuanJingSymbols\t(int code);\nXMLPUBFUN int xmlUCSIsTamil\t(int code);\nXMLPUBFUN int xmlUCSIsTelugu\t(int code);\nXMLPUBFUN int xmlUCSIsThaana\t(int code);\nXMLPUBFUN int xmlUCSIsThai\t(int code);\nXMLPUBFUN int xmlUCSIsTibetan\t(int code);\nXMLPUBFUN int xmlUCSIsUgaritic\t(int code);\nXMLPUBFUN int xmlUCSIsUnifiedCanadianAboriginalSyllabics\t(int code);\nXMLPUBFUN int xmlUCSIsVariationSelectors\t(int code);\nXMLPUBFUN int xmlUCSIsVariationSelectorsSupplement\t(int code);\nXMLPUBFUN int xmlUCSIsYiRadicals\t(int code);\nXMLPUBFUN int xmlUCSIsYiSyllables\t(int code);\nXMLPUBFUN int xmlUCSIsYijingHexagramSymbols\t(int code);\n\nXMLPUBFUN int xmlUCSIsBlock\t(int code, const char *block);\n\nXMLPUBFUN int xmlUCSIsCatC\t(int code);\nXMLPUBFUN int xmlUCSIsCatCc\t(int code);\nXMLPUBFUN int xmlUCSIsCatCf\t(int code);\nXMLPUBFUN int xmlUCSIsCatCo\t(int code);\nXMLPUBFUN int xmlUCSIsCatCs\t(int code);\nXMLPUBFUN int xmlUCSIsCatL\t(int code);\nXMLPUBFUN int xmlUCSIsCatLl\t(int code);\nXMLPUBFUN int xmlUCSIsCatLm\t(int code);\nXMLPUBFUN int xmlUCSIsCatLo\t(int code);\nXMLPUBFUN int xmlUCSIsCatLt\t(int code);\nXMLPUBFUN int xmlUCSIsCatLu\t(int code);\nXMLPUBFUN int xmlUCSIsCatM\t(int code);\nXMLPUBFUN int xmlUCSIsCatMc\t(int code);\nXMLPUBFUN int xmlUCSIsCatMe\t(int code);\nXMLPUBFUN int xmlUCSIsCatMn\t(int code);\nXMLPUBFUN int xmlUCSIsCatN\t(int code);\nXMLPUBFUN int xmlUCSIsCatNd\t(int code);\nXMLPUBFUN int xmlUCSIsCatNl\t(int code);\nXMLPUBFUN int xmlUCSIsCatNo\t(int code);\nXMLPUBFUN int xmlUCSIsCatP\t(int code);\nXMLPUBFUN int xmlUCSIsCatPc\t(int code);\nXMLPUBFUN int xmlUCSIsCatPd\t(int code);\nXMLPUBFUN int xmlUCSIsCatPe\t(int code);\nXMLPUBFUN int xmlUCSIsCatPf\t(int code);\nXMLPUBFUN int xmlUCSIsCatPi\t(int code);\nXMLPUBFUN int xmlUCSIsCatPo\t(int code);\nXMLPUBFUN int xmlUCSIsCatPs\t(int code);\nXMLPUBFUN int xmlUCSIsCatS\t(int code);\nXMLPUBFUN int xmlUCSIsCatSc\t(int code);\nXMLPUBFUN int xmlUCSIsCatSk\t(int code);\nXMLPUBFUN int xmlUCSIsCatSm\t(int code);\nXMLPUBFUN int xmlUCSIsCatSo\t(int code);\nXMLPUBFUN int xmlUCSIsCatZ\t(int code);\nXMLPUBFUN int xmlUCSIsCatZl\t(int code);\nXMLPUBFUN int xmlUCSIsCatZp\t(int code);\nXMLPUBFUN int xmlUCSIsCatZs\t(int code);\n\nXMLPUBFUN int xmlUCSIsCat\t(int code, const char *cat);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_UNICODE_ENABLED */\n\n#endif /* __XML_UNICODE_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlversion.h",
    "content": "/*\n * Summary: compile-time version information\n * Description: compile-time version information for the XML library\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_VERSION_H__\n#define __XML_VERSION_H__\n\n#include <libxml/xmlexports.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/*\n * use those to be sure nothing nasty will happen if\n * your library and includes mismatch\n */\n#ifndef LIBXML2_COMPILING_MSCCDEF\nXMLPUBFUN void xmlCheckVersion(int version);\n#endif /* LIBXML2_COMPILING_MSCCDEF */\n\n/**\n * LIBXML_DOTTED_VERSION:\n *\n * the version string like \"1.2.3\"\n */\n#define LIBXML_DOTTED_VERSION \"2.11.5\"\n\n/**\n * LIBXML_VERSION:\n *\n * the version number: 1.2.3 value is 10203\n */\n#define LIBXML_VERSION 21105\n\n/**\n * LIBXML_VERSION_STRING:\n *\n * the version number string, 1.2.3 value is \"10203\"\n */\n#define LIBXML_VERSION_STRING \"21105\"\n\n/**\n * LIBXML_VERSION_EXTRA:\n *\n * extra version information, used to show a git commit description\n */\n#define LIBXML_VERSION_EXTRA \"\"\n\n/**\n * LIBXML_TEST_VERSION:\n *\n * Macro to check that the libxml version in use is compatible with\n * the version the software has been compiled against\n */\n#define LIBXML_TEST_VERSION xmlCheckVersion(21105);\n\n#ifndef VMS\n#if 0\n/**\n * WITH_TRIO:\n *\n * defined if the trio support need to be configured in\n */\n#define WITH_TRIO\n#else\n/**\n * WITHOUT_TRIO:\n *\n * defined if the trio support should not be configured in\n */\n#define WITHOUT_TRIO\n#endif\n#else /* VMS */\n/**\n * WITH_TRIO:\n *\n * defined if the trio support need to be configured in\n */\n#define WITH_TRIO 1\n#endif /* VMS */\n\n/**\n * LIBXML_THREAD_ENABLED:\n *\n * Whether the thread support is configured in\n */\n#if 0\n#define LIBXML_THREAD_ENABLED\n#endif\n\n/**\n * LIBXML_THREAD_ALLOC_ENABLED:\n *\n * Whether the allocation hooks are per-thread\n */\n#if 0\n#define LIBXML_THREAD_ALLOC_ENABLED\n#endif\n\n/**\n * LIBXML_TREE_ENABLED:\n *\n * Whether the DOM like tree manipulation API support is configured in\n */\n#if 1\n#define LIBXML_TREE_ENABLED\n#endif\n\n/**\n * LIBXML_OUTPUT_ENABLED:\n *\n * Whether the serialization/saving support is configured in\n */\n#if 1\n#define LIBXML_OUTPUT_ENABLED\n#endif\n\n/**\n * LIBXML_PUSH_ENABLED:\n *\n * Whether the push parsing interfaces are configured in\n */\n#if 1\n#define LIBXML_PUSH_ENABLED\n#endif\n\n/**\n * LIBXML_READER_ENABLED:\n *\n * Whether the xmlReader parsing interface is configured in\n */\n#if 1\n#define LIBXML_READER_ENABLED\n#endif\n\n/**\n * LIBXML_PATTERN_ENABLED:\n *\n * Whether the xmlPattern node selection interface is configured in\n */\n#if 1\n#define LIBXML_PATTERN_ENABLED\n#endif\n\n/**\n * LIBXML_WRITER_ENABLED:\n *\n * Whether the xmlWriter saving interface is configured in\n */\n#if 1\n#define LIBXML_WRITER_ENABLED\n#endif\n\n/**\n * LIBXML_SAX1_ENABLED:\n *\n * Whether the older SAX1 interface is configured in\n */\n#if 1\n#define LIBXML_SAX1_ENABLED\n#endif\n\n/**\n * LIBXML_FTP_ENABLED:\n *\n * Whether the FTP support is configured in\n */\n#if 0\n#define LIBXML_FTP_ENABLED\n#endif\n\n/**\n * LIBXML_HTTP_ENABLED:\n *\n * Whether the HTTP support is configured in\n */\n#if 0\n#define LIBXML_HTTP_ENABLED\n#endif\n\n/**\n * LIBXML_VALID_ENABLED:\n *\n * Whether the DTD validation support is configured in\n */\n#if 1\n#define LIBXML_VALID_ENABLED\n#endif\n\n/**\n * LIBXML_HTML_ENABLED:\n *\n * Whether the HTML support is configured in\n */\n#if 1\n#define LIBXML_HTML_ENABLED\n#endif\n\n/**\n * LIBXML_LEGACY_ENABLED:\n *\n * Whether the deprecated APIs are compiled in for compatibility\n */\n#if 0\n#define LIBXML_LEGACY_ENABLED\n#endif\n\n/**\n * LIBXML_C14N_ENABLED:\n *\n * Whether the Canonicalization support is configured in\n */\n#if 1\n#define LIBXML_C14N_ENABLED\n#endif\n\n/**\n * LIBXML_CATALOG_ENABLED:\n *\n * Whether the Catalog support is configured in\n */\n#if 1\n#define LIBXML_CATALOG_ENABLED\n#endif\n\n/**\n * LIBXML_XPATH_ENABLED:\n *\n * Whether XPath is configured in\n */\n#if 1\n#define LIBXML_XPATH_ENABLED\n#endif\n\n/**\n * LIBXML_XPTR_ENABLED:\n *\n * Whether XPointer is configured in\n */\n#if 1\n#define LIBXML_XPTR_ENABLED\n#endif\n\n/**\n * LIBXML_XPTR_LOCS_ENABLED:\n *\n * Whether support for XPointer locations is configured in\n */\n#if 0\n#define LIBXML_XPTR_LOCS_ENABLED\n#endif\n\n/**\n * LIBXML_XINCLUDE_ENABLED:\n *\n * Whether XInclude is configured in\n */\n#if 1\n#define LIBXML_XINCLUDE_ENABLED\n#endif\n\n/**\n * LIBXML_ICONV_ENABLED:\n *\n * Whether iconv support is available\n */\n#if 0\n#define LIBXML_ICONV_ENABLED\n#endif\n\n/**\n * LIBXML_ICU_ENABLED:\n *\n * Whether icu support is available\n */\n#if 0\n#define LIBXML_ICU_ENABLED\n#endif\n\n/**\n * LIBXML_ISO8859X_ENABLED:\n *\n * Whether ISO-8859-* support is made available in case iconv is not\n */\n#if 1\n#define LIBXML_ISO8859X_ENABLED\n#endif\n\n/**\n * LIBXML_DEBUG_ENABLED:\n *\n * Whether Debugging module is configured in\n */\n#if 1\n#define LIBXML_DEBUG_ENABLED\n#endif\n\n/**\n * DEBUG_MEMORY_LOCATION:\n *\n * Whether the memory debugging is configured in\n */\n#if 0\n#define DEBUG_MEMORY_LOCATION\n#endif\n\n/**\n * LIBXML_DEBUG_RUNTIME:\n *\n * Removed\n */\n#if 0\n#define LIBXML_DEBUG_RUNTIME\n#endif\n\n/**\n * LIBXML_UNICODE_ENABLED:\n *\n * Whether the Unicode related interfaces are compiled in\n */\n#if 1\n#define LIBXML_UNICODE_ENABLED\n#endif\n\n/**\n * LIBXML_REGEXP_ENABLED:\n *\n * Whether the regular expressions interfaces are compiled in\n */\n#if 1\n#define LIBXML_REGEXP_ENABLED\n#endif\n\n/**\n * LIBXML_AUTOMATA_ENABLED:\n *\n * Whether the automata interfaces are compiled in\n */\n#if 1\n#define LIBXML_AUTOMATA_ENABLED\n#endif\n\n/**\n * LIBXML_EXPR_ENABLED:\n *\n * Whether the formal expressions interfaces are compiled in\n *\n * This code is unused and disabled unconditionally for now.\n */\n#if 0\n#define LIBXML_EXPR_ENABLED\n#endif\n\n/**\n * LIBXML_SCHEMAS_ENABLED:\n *\n * Whether the Schemas validation interfaces are compiled in\n */\n#if 1\n#define LIBXML_SCHEMAS_ENABLED\n#endif\n\n/**\n * LIBXML_SCHEMATRON_ENABLED:\n *\n * Whether the Schematron validation interfaces are compiled in\n */\n#if 1\n#define LIBXML_SCHEMATRON_ENABLED\n#endif\n\n/**\n * LIBXML_MODULES_ENABLED:\n *\n * Whether the module interfaces are compiled in\n */\n#if 1\n#define LIBXML_MODULES_ENABLED\n/**\n * LIBXML_MODULE_EXTENSION:\n *\n * the string suffix used by dynamic modules (usually shared libraries)\n */\n#define LIBXML_MODULE_EXTENSION \".dll\" \n#endif\n\n/**\n * LIBXML_ZLIB_ENABLED:\n *\n * Whether the Zlib support is compiled in\n */\n#if 1\n#define LIBXML_ZLIB_ENABLED\n#endif\n\n/**\n * LIBXML_LZMA_ENABLED:\n *\n * Whether the Lzma support is compiled in\n */\n#if 0\n#define LIBXML_LZMA_ENABLED\n#endif\n\n#ifdef __GNUC__\n/** DOC_DISABLE */\n\n#ifndef ATTRIBUTE_UNUSED\n# if ((__GNUC__ > 2) || ((__GNUC__ == 2) && (__GNUC_MINOR__ >= 7)))\n#  define ATTRIBUTE_UNUSED __attribute__((unused))\n# else\n#  define ATTRIBUTE_UNUSED\n# endif\n#endif\n\n#ifndef LIBXML_ATTR_ALLOC_SIZE\n# if (!defined(__clang__) && ((__GNUC__ > 4) || ((__GNUC__ == 4) && (__GNUC_MINOR__ >= 3))))\n#  define LIBXML_ATTR_ALLOC_SIZE(x) __attribute__((alloc_size(x)))\n# else\n#  define LIBXML_ATTR_ALLOC_SIZE(x)\n# endif\n#else\n# define LIBXML_ATTR_ALLOC_SIZE(x)\n#endif\n\n#ifndef LIBXML_ATTR_FORMAT\n# if ((__GNUC__ > 3) || ((__GNUC__ == 3) && (__GNUC_MINOR__ >= 3)))\n#  define LIBXML_ATTR_FORMAT(fmt,args) __attribute__((__format__(__printf__,fmt,args)))\n# else\n#  define LIBXML_ATTR_FORMAT(fmt,args)\n# endif\n#else\n# define LIBXML_ATTR_FORMAT(fmt,args)\n#endif\n\n#ifndef XML_DEPRECATED\n#  if defined (IN_LIBXML) || (__GNUC__ * 100 + __GNUC_MINOR__ < 301)\n#    define XML_DEPRECATED\n/* Available since at least GCC 3.1 */\n#  else\n#    define XML_DEPRECATED __attribute__((deprecated))\n#  endif\n#endif\n\n#if defined(__clang__) || (__GNUC__ * 100 + __GNUC_MINOR__ >= 406)\n#define XML_IGNORE_FPTR_CAST_WARNINGS \\\n    _Pragma(\"GCC diagnostic push\") \\\n    _Pragma(\"GCC diagnostic ignored \\\"-Wpedantic\\\"\") \\\n    _Pragma(\"GCC diagnostic ignored \\\"-Wcast-function-type\\\"\")\n#define XML_POP_WARNINGS \\\n    _Pragma(\"GCC diagnostic pop\")\n#else\n#define XML_IGNORE_FPTR_CAST_WARNINGS\n#define XML_POP_WARNINGS\n#endif\n\n/** DOC_ENABLE */\n#else /* ! __GNUC__ */\n/**\n * ATTRIBUTE_UNUSED:\n *\n * Macro used to signal to GCC unused function parameters\n */\n#define ATTRIBUTE_UNUSED\n/**\n * LIBXML_ATTR_ALLOC_SIZE:\n *\n * Macro used to indicate to GCC this is an allocator function\n */\n#define LIBXML_ATTR_ALLOC_SIZE(x)\n/**\n * LIBXML_ATTR_FORMAT:\n *\n * Macro used to indicate to GCC the parameter are printf like\n */\n#define LIBXML_ATTR_FORMAT(fmt,args)\n/**\n * XML_DEPRECATED:\n *\n * Macro used to indicate that a function, variable, type or struct member\n * is deprecated.\n */\n#ifndef XML_DEPRECATED\n#  if defined (IN_LIBXML) || !defined (_MSC_VER)\n#    define XML_DEPRECATED\n/* Available since Visual Studio 2005 */\n#  elif defined (_MSC_VER) && (_MSC_VER >= 1400)\n#    define XML_DEPRECATED __declspec(deprecated)\n#  endif\n#endif\n/**\n * LIBXML_IGNORE_FPTR_CAST_WARNINGS:\n *\n * Macro used to ignore pointer cast warnings that can't be worked around.\n */\n#if defined (_MSC_VER) && (_MSC_VER >= 1400)\n#  define XML_IGNORE_FPTR_CAST_WARNINGS __pragma(warning(push))\n#else\n#  define XML_IGNORE_FPTR_CAST_WARNINGS\n#endif\n/**\n * XML_POP_WARNINGS:\n *\n * Macro used to restore warnings state.\n */\n#ifndef XML_POP_WARNINGS\n#  if defined (_MSC_VER) && (_MSC_VER >= 1400)\n#    define XML_POP_WARNINGS __pragma(warning(pop))\n#  else\n#    define XML_POP_WARNINGS\n#  endif\n#endif\n#endif /* __GNUC__ */\n\n#ifdef __cplusplus\n}\n#endif /* __cplusplus */\n#endif\n\n\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xmlwriter.h",
    "content": "/*\n * Summary: text writing API for XML\n * Description: text writing API for XML\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Alfred Mickautsch <alfred@mickautsch.de>\n */\n\n#ifndef __XML_XMLWRITER_H__\n#define __XML_XMLWRITER_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_WRITER_ENABLED\n\n#include <stdarg.h>\n#include <libxml/xmlIO.h>\n#include <libxml/list.h>\n#include <libxml/xmlstring.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n    typedef struct _xmlTextWriter xmlTextWriter;\n    typedef xmlTextWriter *xmlTextWriterPtr;\n\n/*\n * Constructors & Destructor\n */\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriter(xmlOutputBufferPtr out);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterFilename(const char *uri, int compression);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterMemory(xmlBufferPtr buf, int compression);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterPushParser(xmlParserCtxtPtr ctxt, int compression);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterDoc(xmlDocPtr * doc, int compression);\n    XMLPUBFUN xmlTextWriterPtr\n        xmlNewTextWriterTree(xmlDocPtr doc, xmlNodePtr node,\n                             int compression);\n    XMLPUBFUN void xmlFreeTextWriter(xmlTextWriterPtr writer);\n\n/*\n * Functions\n */\n\n\n/*\n * Document\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDocument(xmlTextWriterPtr writer,\n                                   const char *version,\n                                   const char *encoding,\n                                   const char *standalone);\n    XMLPUBFUN int xmlTextWriterEndDocument(xmlTextWriterPtr\n                                                   writer);\n\n/*\n * Comments\n */\n    XMLPUBFUN int xmlTextWriterStartComment(xmlTextWriterPtr\n                                                    writer);\n    XMLPUBFUN int xmlTextWriterEndComment(xmlTextWriterPtr writer);\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatComment(xmlTextWriterPtr writer,\n                                        const char *format, ...)\n\t\t\t\t\tLIBXML_ATTR_FORMAT(2,3);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatComment(xmlTextWriterPtr writer,\n                                         const char *format,\n                                         va_list argptr)\n\t\t\t\t\t LIBXML_ATTR_FORMAT(2,0);\n    XMLPUBFUN int xmlTextWriterWriteComment(xmlTextWriterPtr\n                                                    writer,\n                                                    const xmlChar *\n                                                    content);\n\n/*\n * Elements\n */\n    XMLPUBFUN int\n        xmlTextWriterStartElement(xmlTextWriterPtr writer,\n                                  const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterStartElementNS(xmlTextWriterPtr\n                                                      writer,\n                                                      const xmlChar *\n                                                      prefix,\n                                                      const xmlChar * name,\n                                                      const xmlChar *\n                                                      namespaceURI);\n    XMLPUBFUN int xmlTextWriterEndElement(xmlTextWriterPtr writer);\n    XMLPUBFUN int xmlTextWriterFullEndElement(xmlTextWriterPtr\n                                                      writer);\n\n/*\n * Elements conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatElement(xmlTextWriterPtr writer,\n                                        const xmlChar * name,\n                                        const char *format, ...)\n\t\t\t\t\tLIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatElement(xmlTextWriterPtr writer,\n                                         const xmlChar * name,\n                                         const char *format,\n                                         va_list argptr)\n\t\t\t\t\t LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int xmlTextWriterWriteElement(xmlTextWriterPtr\n                                                    writer,\n                                                    const xmlChar * name,\n                                                    const xmlChar *\n                                                    content);\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatElementNS(xmlTextWriterPtr writer,\n                                          const xmlChar * prefix,\n                                          const xmlChar * name,\n                                          const xmlChar * namespaceURI,\n                                          const char *format, ...)\n\t\t\t\t\t  LIBXML_ATTR_FORMAT(5,6);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatElementNS(xmlTextWriterPtr writer,\n                                           const xmlChar * prefix,\n                                           const xmlChar * name,\n                                           const xmlChar * namespaceURI,\n                                           const char *format,\n                                           va_list argptr)\n\t\t\t\t\t   LIBXML_ATTR_FORMAT(5,0);\n    XMLPUBFUN int xmlTextWriterWriteElementNS(xmlTextWriterPtr\n                                                      writer,\n                                                      const xmlChar *\n                                                      prefix,\n                                                      const xmlChar * name,\n                                                      const xmlChar *\n                                                      namespaceURI,\n                                                      const xmlChar *\n                                                      content);\n\n/*\n * Text\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatRaw(xmlTextWriterPtr writer,\n                                    const char *format, ...)\n\t\t\t\t    LIBXML_ATTR_FORMAT(2,3);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatRaw(xmlTextWriterPtr writer,\n                                     const char *format, va_list argptr)\n\t\t\t\t     LIBXML_ATTR_FORMAT(2,0);\n    XMLPUBFUN int\n        xmlTextWriterWriteRawLen(xmlTextWriterPtr writer,\n                                 const xmlChar * content, int len);\n    XMLPUBFUN int\n        xmlTextWriterWriteRaw(xmlTextWriterPtr writer,\n                              const xmlChar * content);\n    XMLPUBFUN int xmlTextWriterWriteFormatString(xmlTextWriterPtr\n                                                         writer,\n                                                         const char\n                                                         *format, ...)\n\t\t\t\t\t\t\t LIBXML_ATTR_FORMAT(2,3);\n    XMLPUBFUN int xmlTextWriterWriteVFormatString(xmlTextWriterPtr\n                                                          writer,\n                                                          const char\n                                                          *format,\n                                                          va_list argptr)\n\t\t\t\t\t\t\t  LIBXML_ATTR_FORMAT(2,0);\n    XMLPUBFUN int xmlTextWriterWriteString(xmlTextWriterPtr writer,\n                                                   const xmlChar *\n                                                   content);\n    XMLPUBFUN int xmlTextWriterWriteBase64(xmlTextWriterPtr writer,\n                                                   const char *data,\n                                                   int start, int len);\n    XMLPUBFUN int xmlTextWriterWriteBinHex(xmlTextWriterPtr writer,\n                                                   const char *data,\n                                                   int start, int len);\n\n/*\n * Attributes\n */\n    XMLPUBFUN int\n        xmlTextWriterStartAttribute(xmlTextWriterPtr writer,\n                                    const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterStartAttributeNS(xmlTextWriterPtr\n                                                        writer,\n                                                        const xmlChar *\n                                                        prefix,\n                                                        const xmlChar *\n                                                        name,\n                                                        const xmlChar *\n                                                        namespaceURI);\n    XMLPUBFUN int xmlTextWriterEndAttribute(xmlTextWriterPtr\n                                                    writer);\n\n/*\n * Attributes conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatAttribute(xmlTextWriterPtr writer,\n                                          const xmlChar * name,\n                                          const char *format, ...)\n\t\t\t\t\t  LIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatAttribute(xmlTextWriterPtr writer,\n                                           const xmlChar * name,\n                                           const char *format,\n                                           va_list argptr)\n\t\t\t\t\t   LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int xmlTextWriterWriteAttribute(xmlTextWriterPtr\n                                                      writer,\n                                                      const xmlChar * name,\n                                                      const xmlChar *\n                                                      content);\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatAttributeNS(xmlTextWriterPtr writer,\n                                            const xmlChar * prefix,\n                                            const xmlChar * name,\n                                            const xmlChar * namespaceURI,\n                                            const char *format, ...)\n\t\t\t\t\t    LIBXML_ATTR_FORMAT(5,6);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatAttributeNS(xmlTextWriterPtr writer,\n                                             const xmlChar * prefix,\n                                             const xmlChar * name,\n                                             const xmlChar * namespaceURI,\n                                             const char *format,\n                                             va_list argptr)\n\t\t\t\t\t     LIBXML_ATTR_FORMAT(5,0);\n    XMLPUBFUN int xmlTextWriterWriteAttributeNS(xmlTextWriterPtr\n                                                        writer,\n                                                        const xmlChar *\n                                                        prefix,\n                                                        const xmlChar *\n                                                        name,\n                                                        const xmlChar *\n                                                        namespaceURI,\n                                                        const xmlChar *\n                                                        content);\n\n/*\n * PI's\n */\n    XMLPUBFUN int\n        xmlTextWriterStartPI(xmlTextWriterPtr writer,\n                             const xmlChar * target);\n    XMLPUBFUN int xmlTextWriterEndPI(xmlTextWriterPtr writer);\n\n/*\n * PI conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatPI(xmlTextWriterPtr writer,\n                                   const xmlChar * target,\n                                   const char *format, ...)\n\t\t\t\t   LIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatPI(xmlTextWriterPtr writer,\n                                    const xmlChar * target,\n                                    const char *format, va_list argptr)\n\t\t\t\t    LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int\n        xmlTextWriterWritePI(xmlTextWriterPtr writer,\n                             const xmlChar * target,\n                             const xmlChar * content);\n\n/**\n * xmlTextWriterWriteProcessingInstruction:\n *\n * This macro maps to xmlTextWriterWritePI\n */\n#define xmlTextWriterWriteProcessingInstruction xmlTextWriterWritePI\n\n/*\n * CDATA\n */\n    XMLPUBFUN int xmlTextWriterStartCDATA(xmlTextWriterPtr writer);\n    XMLPUBFUN int xmlTextWriterEndCDATA(xmlTextWriterPtr writer);\n\n/*\n * CDATA conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatCDATA(xmlTextWriterPtr writer,\n                                      const char *format, ...)\n\t\t\t\t      LIBXML_ATTR_FORMAT(2,3);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatCDATA(xmlTextWriterPtr writer,\n                                       const char *format, va_list argptr)\n\t\t\t\t       LIBXML_ATTR_FORMAT(2,0);\n    XMLPUBFUN int\n        xmlTextWriterWriteCDATA(xmlTextWriterPtr writer,\n                                const xmlChar * content);\n\n/*\n * DTD\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDTD(xmlTextWriterPtr writer,\n                              const xmlChar * name,\n                              const xmlChar * pubid,\n                              const xmlChar * sysid);\n    XMLPUBFUN int xmlTextWriterEndDTD(xmlTextWriterPtr writer);\n\n/*\n * DTD conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatDTD(xmlTextWriterPtr writer,\n                                    const xmlChar * name,\n                                    const xmlChar * pubid,\n                                    const xmlChar * sysid,\n                                    const char *format, ...)\n\t\t\t\t    LIBXML_ATTR_FORMAT(5,6);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatDTD(xmlTextWriterPtr writer,\n                                     const xmlChar * name,\n                                     const xmlChar * pubid,\n                                     const xmlChar * sysid,\n                                     const char *format, va_list argptr)\n\t\t\t\t     LIBXML_ATTR_FORMAT(5,0);\n    XMLPUBFUN int\n        xmlTextWriterWriteDTD(xmlTextWriterPtr writer,\n                              const xmlChar * name,\n                              const xmlChar * pubid,\n                              const xmlChar * sysid,\n                              const xmlChar * subset);\n\n/**\n * xmlTextWriterWriteDocType:\n *\n * this macro maps to xmlTextWriterWriteDTD\n */\n#define xmlTextWriterWriteDocType xmlTextWriterWriteDTD\n\n/*\n * DTD element definition\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDTDElement(xmlTextWriterPtr writer,\n                                     const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterEndDTDElement(xmlTextWriterPtr\n                                                     writer);\n\n/*\n * DTD element definition conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatDTDElement(xmlTextWriterPtr writer,\n                                           const xmlChar * name,\n                                           const char *format, ...)\n\t\t\t\t\t   LIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatDTDElement(xmlTextWriterPtr writer,\n                                            const xmlChar * name,\n                                            const char *format,\n                                            va_list argptr)\n\t\t\t\t\t    LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int xmlTextWriterWriteDTDElement(xmlTextWriterPtr\n                                                       writer,\n                                                       const xmlChar *\n                                                       name,\n                                                       const xmlChar *\n                                                       content);\n\n/*\n * DTD attribute list definition\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDTDAttlist(xmlTextWriterPtr writer,\n                                     const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterEndDTDAttlist(xmlTextWriterPtr\n                                                     writer);\n\n/*\n * DTD attribute list definition conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatDTDAttlist(xmlTextWriterPtr writer,\n                                           const xmlChar * name,\n                                           const char *format, ...)\n\t\t\t\t\t   LIBXML_ATTR_FORMAT(3,4);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatDTDAttlist(xmlTextWriterPtr writer,\n                                            const xmlChar * name,\n                                            const char *format,\n                                            va_list argptr)\n\t\t\t\t\t    LIBXML_ATTR_FORMAT(3,0);\n    XMLPUBFUN int xmlTextWriterWriteDTDAttlist(xmlTextWriterPtr\n                                                       writer,\n                                                       const xmlChar *\n                                                       name,\n                                                       const xmlChar *\n                                                       content);\n\n/*\n * DTD entity definition\n */\n    XMLPUBFUN int\n        xmlTextWriterStartDTDEntity(xmlTextWriterPtr writer,\n                                    int pe, const xmlChar * name);\n    XMLPUBFUN int xmlTextWriterEndDTDEntity(xmlTextWriterPtr\n                                                    writer);\n\n/*\n * DTD entity definition conveniency functions\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteFormatDTDInternalEntity(xmlTextWriterPtr writer,\n                                                  int pe,\n                                                  const xmlChar * name,\n                                                  const char *format, ...)\n\t\t\t\t\t\t  LIBXML_ATTR_FORMAT(4,5);\n    XMLPUBFUN int\n        xmlTextWriterWriteVFormatDTDInternalEntity(xmlTextWriterPtr writer,\n                                                   int pe,\n                                                   const xmlChar * name,\n                                                   const char *format,\n                                                   va_list argptr)\n\t\t\t\t\t\t   LIBXML_ATTR_FORMAT(4,0);\n    XMLPUBFUN int\n        xmlTextWriterWriteDTDInternalEntity(xmlTextWriterPtr writer,\n                                            int pe,\n                                            const xmlChar * name,\n                                            const xmlChar * content);\n    XMLPUBFUN int\n        xmlTextWriterWriteDTDExternalEntity(xmlTextWriterPtr writer,\n                                            int pe,\n                                            const xmlChar * name,\n                                            const xmlChar * pubid,\n                                            const xmlChar * sysid,\n                                            const xmlChar * ndataid);\n    XMLPUBFUN int\n        xmlTextWriterWriteDTDExternalEntityContents(xmlTextWriterPtr\n                                                    writer,\n                                                    const xmlChar * pubid,\n                                                    const xmlChar * sysid,\n                                                    const xmlChar *\n                                                    ndataid);\n    XMLPUBFUN int xmlTextWriterWriteDTDEntity(xmlTextWriterPtr\n                                                      writer, int pe,\n                                                      const xmlChar * name,\n                                                      const xmlChar *\n                                                      pubid,\n                                                      const xmlChar *\n                                                      sysid,\n                                                      const xmlChar *\n                                                      ndataid,\n                                                      const xmlChar *\n                                                      content);\n\n/*\n * DTD notation definition\n */\n    XMLPUBFUN int\n        xmlTextWriterWriteDTDNotation(xmlTextWriterPtr writer,\n                                      const xmlChar * name,\n                                      const xmlChar * pubid,\n                                      const xmlChar * sysid);\n\n/*\n * Indentation\n */\n    XMLPUBFUN int\n        xmlTextWriterSetIndent(xmlTextWriterPtr writer, int indent);\n    XMLPUBFUN int\n        xmlTextWriterSetIndentString(xmlTextWriterPtr writer,\n                                     const xmlChar * str);\n\n    XMLPUBFUN int\n        xmlTextWriterSetQuoteChar(xmlTextWriterPtr writer, xmlChar quotechar);\n\n\n/*\n * misc\n */\n    XMLPUBFUN int xmlTextWriterFlush(xmlTextWriterPtr writer);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_WRITER_ENABLED */\n\n#endif                          /* __XML_XMLWRITER_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xpath.h",
    "content": "/*\n * Summary: XML Path Language implementation\n * Description: API for the XML Path Language implementation\n *\n * XML Path Language implementation\n * XPath is a language for addressing parts of an XML document,\n * designed to be used by both XSLT and XPointer\n *     http://www.w3.org/TR/xpath\n *\n * Implements\n * W3C Recommendation 16 November 1999\n *     http://www.w3.org/TR/1999/REC-xpath-19991116\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XPATH_H__\n#define __XML_XPATH_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_XPATH_ENABLED\n\n#include <libxml/xmlerror.h>\n#include <libxml/tree.h>\n#include <libxml/hash.h>\n#endif /* LIBXML_XPATH_ENABLED */\n\n#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED */\n\n#ifdef LIBXML_XPATH_ENABLED\n\ntypedef struct _xmlXPathContext xmlXPathContext;\ntypedef xmlXPathContext *xmlXPathContextPtr;\ntypedef struct _xmlXPathParserContext xmlXPathParserContext;\ntypedef xmlXPathParserContext *xmlXPathParserContextPtr;\n\n/**\n * The set of XPath error codes.\n */\n\ntypedef enum {\n    XPATH_EXPRESSION_OK = 0,\n    XPATH_NUMBER_ERROR,\n    XPATH_UNFINISHED_LITERAL_ERROR,\n    XPATH_START_LITERAL_ERROR,\n    XPATH_VARIABLE_REF_ERROR,\n    XPATH_UNDEF_VARIABLE_ERROR,\n    XPATH_INVALID_PREDICATE_ERROR,\n    XPATH_EXPR_ERROR,\n    XPATH_UNCLOSED_ERROR,\n    XPATH_UNKNOWN_FUNC_ERROR,\n    XPATH_INVALID_OPERAND,\n    XPATH_INVALID_TYPE,\n    XPATH_INVALID_ARITY,\n    XPATH_INVALID_CTXT_SIZE,\n    XPATH_INVALID_CTXT_POSITION,\n    XPATH_MEMORY_ERROR,\n    XPTR_SYNTAX_ERROR,\n    XPTR_RESOURCE_ERROR,\n    XPTR_SUB_RESOURCE_ERROR,\n    XPATH_UNDEF_PREFIX_ERROR,\n    XPATH_ENCODING_ERROR,\n    XPATH_INVALID_CHAR_ERROR,\n    XPATH_INVALID_CTXT,\n    XPATH_STACK_ERROR,\n    XPATH_FORBID_VARIABLE_ERROR,\n    XPATH_OP_LIMIT_EXCEEDED,\n    XPATH_RECURSION_LIMIT_EXCEEDED\n} xmlXPathError;\n\n/*\n * A node-set (an unordered collection of nodes without duplicates).\n */\ntypedef struct _xmlNodeSet xmlNodeSet;\ntypedef xmlNodeSet *xmlNodeSetPtr;\nstruct _xmlNodeSet {\n    int nodeNr;\t\t\t/* number of nodes in the set */\n    int nodeMax;\t\t/* size of the array as allocated */\n    xmlNodePtr *nodeTab;\t/* array of nodes in no particular order */\n    /* @@ with_ns to check whether namespace nodes should be looked at @@ */\n};\n\n/*\n * An expression is evaluated to yield an object, which\n * has one of the following four basic types:\n *   - node-set\n *   - boolean\n *   - number\n *   - string\n *\n * @@ XPointer will add more types !\n */\n\ntypedef enum {\n    XPATH_UNDEFINED = 0,\n    XPATH_NODESET = 1,\n    XPATH_BOOLEAN = 2,\n    XPATH_NUMBER = 3,\n    XPATH_STRING = 4,\n#ifdef LIBXML_XPTR_LOCS_ENABLED\n    XPATH_POINT = 5,\n    XPATH_RANGE = 6,\n    XPATH_LOCATIONSET = 7,\n#endif\n    XPATH_USERS = 8,\n    XPATH_XSLT_TREE = 9  /* An XSLT value tree, non modifiable */\n} xmlXPathObjectType;\n\n#ifndef LIBXML_XPTR_LOCS_ENABLED\n/** DOC_DISABLE */\n#define XPATH_POINT 5\n#define XPATH_RANGE 6\n#define XPATH_LOCATIONSET 7\n/** DOC_ENABLE */\n#endif\n\ntypedef struct _xmlXPathObject xmlXPathObject;\ntypedef xmlXPathObject *xmlXPathObjectPtr;\nstruct _xmlXPathObject {\n    xmlXPathObjectType type;\n    xmlNodeSetPtr nodesetval;\n    int boolval;\n    double floatval;\n    xmlChar *stringval;\n    void *user;\n    int index;\n    void *user2;\n    int index2;\n};\n\n/**\n * xmlXPathConvertFunc:\n * @obj:  an XPath object\n * @type:  the number of the target type\n *\n * A conversion function is associated to a type and used to cast\n * the new type to primitive values.\n *\n * Returns -1 in case of error, 0 otherwise\n */\ntypedef int (*xmlXPathConvertFunc) (xmlXPathObjectPtr obj, int type);\n\n/*\n * Extra type: a name and a conversion function.\n */\n\ntypedef struct _xmlXPathType xmlXPathType;\ntypedef xmlXPathType *xmlXPathTypePtr;\nstruct _xmlXPathType {\n    const xmlChar         *name;\t\t/* the type name */\n    xmlXPathConvertFunc func;\t\t/* the conversion function */\n};\n\n/*\n * Extra variable: a name and a value.\n */\n\ntypedef struct _xmlXPathVariable xmlXPathVariable;\ntypedef xmlXPathVariable *xmlXPathVariablePtr;\nstruct _xmlXPathVariable {\n    const xmlChar       *name;\t\t/* the variable name */\n    xmlXPathObjectPtr value;\t\t/* the value */\n};\n\n/**\n * xmlXPathEvalFunc:\n * @ctxt: an XPath parser context\n * @nargs: the number of arguments passed to the function\n *\n * An XPath evaluation function, the parameters are on the XPath context stack.\n */\n\ntypedef void (*xmlXPathEvalFunc)(xmlXPathParserContextPtr ctxt,\n\t                         int nargs);\n\n/*\n * Extra function: a name and a evaluation function.\n */\n\ntypedef struct _xmlXPathFunct xmlXPathFunct;\ntypedef xmlXPathFunct *xmlXPathFuncPtr;\nstruct _xmlXPathFunct {\n    const xmlChar      *name;\t\t/* the function name */\n    xmlXPathEvalFunc func;\t\t/* the evaluation function */\n};\n\n/**\n * xmlXPathAxisFunc:\n * @ctxt:  the XPath interpreter context\n * @cur:  the previous node being explored on that axis\n *\n * An axis traversal function. To traverse an axis, the engine calls\n * the first time with cur == NULL and repeat until the function returns\n * NULL indicating the end of the axis traversal.\n *\n * Returns the next node in that axis or NULL if at the end of the axis.\n */\n\ntypedef xmlXPathObjectPtr (*xmlXPathAxisFunc) (xmlXPathParserContextPtr ctxt,\n\t\t\t\t xmlXPathObjectPtr cur);\n\n/*\n * Extra axis: a name and an axis function.\n */\n\ntypedef struct _xmlXPathAxis xmlXPathAxis;\ntypedef xmlXPathAxis *xmlXPathAxisPtr;\nstruct _xmlXPathAxis {\n    const xmlChar      *name;\t\t/* the axis name */\n    xmlXPathAxisFunc func;\t\t/* the search function */\n};\n\n/**\n * xmlXPathFunction:\n * @ctxt:  the XPath interprestation context\n * @nargs:  the number of arguments\n *\n * An XPath function.\n * The arguments (if any) are popped out from the context stack\n * and the result is pushed on the stack.\n */\n\ntypedef void (*xmlXPathFunction) (xmlXPathParserContextPtr ctxt, int nargs);\n\n/*\n * Function and Variable Lookup.\n */\n\n/**\n * xmlXPathVariableLookupFunc:\n * @ctxt:  an XPath context\n * @name:  name of the variable\n * @ns_uri:  the namespace name hosting this variable\n *\n * Prototype for callbacks used to plug variable lookup in the XPath\n * engine.\n *\n * Returns the XPath object value or NULL if not found.\n */\ntypedef xmlXPathObjectPtr (*xmlXPathVariableLookupFunc) (void *ctxt,\n                                         const xmlChar *name,\n                                         const xmlChar *ns_uri);\n\n/**\n * xmlXPathFuncLookupFunc:\n * @ctxt:  an XPath context\n * @name:  name of the function\n * @ns_uri:  the namespace name hosting this function\n *\n * Prototype for callbacks used to plug function lookup in the XPath\n * engine.\n *\n * Returns the XPath function or NULL if not found.\n */\ntypedef xmlXPathFunction (*xmlXPathFuncLookupFunc) (void *ctxt,\n\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t const xmlChar *ns_uri);\n\n/**\n * xmlXPathFlags:\n * Flags for XPath engine compilation and runtime\n */\n/**\n * XML_XPATH_CHECKNS:\n *\n * check namespaces at compilation\n */\n#define XML_XPATH_CHECKNS (1<<0)\n/**\n * XML_XPATH_NOVAR:\n *\n * forbid variables in expression\n */\n#define XML_XPATH_NOVAR\t  (1<<1)\n\n/**\n * xmlXPathContext:\n *\n * Expression evaluation occurs with respect to a context.\n * he context consists of:\n *    - a node (the context node)\n *    - a node list (the context node list)\n *    - a set of variable bindings\n *    - a function library\n *    - the set of namespace declarations in scope for the expression\n * Following the switch to hash tables, this need to be trimmed up at\n * the next binary incompatible release.\n * The node may be modified when the context is passed to libxml2\n * for an XPath evaluation so you may need to initialize it again\n * before the next call.\n */\n\nstruct _xmlXPathContext {\n    xmlDocPtr doc;\t\t\t/* The current document */\n    xmlNodePtr node;\t\t\t/* The current node */\n\n    int nb_variables_unused;\t\t/* unused (hash table) */\n    int max_variables_unused;\t\t/* unused (hash table) */\n    xmlHashTablePtr varHash;\t\t/* Hash table of defined variables */\n\n    int nb_types;\t\t\t/* number of defined types */\n    int max_types;\t\t\t/* max number of types */\n    xmlXPathTypePtr types;\t\t/* Array of defined types */\n\n    int nb_funcs_unused;\t\t/* unused (hash table) */\n    int max_funcs_unused;\t\t/* unused (hash table) */\n    xmlHashTablePtr funcHash;\t\t/* Hash table of defined funcs */\n\n    int nb_axis;\t\t\t/* number of defined axis */\n    int max_axis;\t\t\t/* max number of axis */\n    xmlXPathAxisPtr axis;\t\t/* Array of defined axis */\n\n    /* the namespace nodes of the context node */\n    xmlNsPtr *namespaces;\t\t/* Array of namespaces */\n    int nsNr;\t\t\t\t/* number of namespace in scope */\n    void *user;\t\t\t\t/* function to free */\n\n    /* extra variables */\n    int contextSize;\t\t\t/* the context size */\n    int proximityPosition;\t\t/* the proximity position */\n\n    /* extra stuff for XPointer */\n    int xptr;\t\t\t\t/* is this an XPointer context? */\n    xmlNodePtr here;\t\t\t/* for here() */\n    xmlNodePtr origin;\t\t\t/* for origin() */\n\n    /* the set of namespace declarations in scope for the expression */\n    xmlHashTablePtr nsHash;\t\t/* The namespaces hash table */\n    xmlXPathVariableLookupFunc varLookupFunc;/* variable lookup func */\n    void *varLookupData;\t\t/* variable lookup data */\n\n    /* Possibility to link in an extra item */\n    void *extra;                        /* needed for XSLT */\n\n    /* The function name and URI when calling a function */\n    const xmlChar *function;\n    const xmlChar *functionURI;\n\n    /* function lookup function and data */\n    xmlXPathFuncLookupFunc funcLookupFunc;/* function lookup func */\n    void *funcLookupData;\t\t/* function lookup data */\n\n    /* temporary namespace lists kept for walking the namespace axis */\n    xmlNsPtr *tmpNsList;\t\t/* Array of namespaces */\n    int tmpNsNr;\t\t\t/* number of namespaces in scope */\n\n    /* error reporting mechanism */\n    void *userData;                     /* user specific data block */\n    xmlStructuredErrorFunc error;       /* the callback in case of errors */\n    xmlError lastError;\t\t\t/* the last error */\n    xmlNodePtr debugNode;\t\t/* the source node XSLT */\n\n    /* dictionary */\n    xmlDictPtr dict;\t\t\t/* dictionary if any */\n\n    int flags;\t\t\t\t/* flags to control compilation */\n\n    /* Cache for reusal of XPath objects */\n    void *cache;\n\n    /* Resource limits */\n    unsigned long opLimit;\n    unsigned long opCount;\n    int depth;\n};\n\n/*\n * The structure of a compiled expression form is not public.\n */\n\ntypedef struct _xmlXPathCompExpr xmlXPathCompExpr;\ntypedef xmlXPathCompExpr *xmlXPathCompExprPtr;\n\n/**\n * xmlXPathParserContext:\n *\n * An XPath parser context. It contains pure parsing information,\n * an xmlXPathContext, and the stack of objects.\n */\nstruct _xmlXPathParserContext {\n    const xmlChar *cur;\t\t\t/* the current char being parsed */\n    const xmlChar *base;\t\t\t/* the full expression */\n\n    int error;\t\t\t\t/* error code */\n\n    xmlXPathContextPtr  context;\t/* the evaluation context */\n    xmlXPathObjectPtr     value;\t/* the current value */\n    int                 valueNr;\t/* number of values stacked */\n    int                valueMax;\t/* max number of values stacked */\n    xmlXPathObjectPtr *valueTab;\t/* stack of values */\n\n    xmlXPathCompExprPtr comp;\t\t/* the precompiled expression */\n    int xptr;\t\t\t\t/* it this an XPointer expression */\n    xmlNodePtr         ancestor;\t/* used for walking preceding axis */\n\n    int              valueFrame;        /* unused */\n};\n\n/************************************************************************\n *\t\t\t\t\t\t\t\t\t*\n *\t\t\tPublic API\t\t\t\t\t*\n *\t\t\t\t\t\t\t\t\t*\n ************************************************************************/\n\n/**\n * Objects and Nodesets handling\n */\n\nXMLPUBVAR double xmlXPathNAN;\nXMLPUBVAR double xmlXPathPINF;\nXMLPUBVAR double xmlXPathNINF;\n\n/* These macros may later turn into functions */\n/**\n * xmlXPathNodeSetGetLength:\n * @ns:  a node-set\n *\n * Implement a functionality similar to the DOM NodeList.length.\n *\n * Returns the number of nodes in the node-set.\n */\n#define xmlXPathNodeSetGetLength(ns) ((ns) ? (ns)->nodeNr : 0)\n/**\n * xmlXPathNodeSetItem:\n * @ns:  a node-set\n * @index:  index of a node in the set\n *\n * Implements a functionality similar to the DOM NodeList.item().\n *\n * Returns the xmlNodePtr at the given @index in @ns or NULL if\n *         @index is out of range (0 to length-1)\n */\n#define xmlXPathNodeSetItem(ns, index)\t\t\t\t\\\n\t\t((((ns) != NULL) &&\t\t\t\t\\\n\t\t  ((index) >= 0) && ((index) < (ns)->nodeNr)) ?\t\\\n\t\t (ns)->nodeTab[(index)]\t\t\t\t\\\n\t\t : NULL)\n/**\n * xmlXPathNodeSetIsEmpty:\n * @ns: a node-set\n *\n * Checks whether @ns is empty or not.\n *\n * Returns %TRUE if @ns is an empty node-set.\n */\n#define xmlXPathNodeSetIsEmpty(ns)                                      \\\n    (((ns) == NULL) || ((ns)->nodeNr == 0) || ((ns)->nodeTab == NULL))\n\n\nXMLPUBFUN void\n\t\t    xmlXPathFreeObject\t\t(xmlXPathObjectPtr obj);\nXMLPUBFUN xmlNodeSetPtr\n\t\t    xmlXPathNodeSetCreate\t(xmlNodePtr val);\nXMLPUBFUN void\n\t\t    xmlXPathFreeNodeSetList\t(xmlXPathObjectPtr obj);\nXMLPUBFUN void\n\t\t    xmlXPathFreeNodeSet\t\t(xmlNodeSetPtr obj);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathObjectCopy\t\t(xmlXPathObjectPtr val);\nXMLPUBFUN int\n\t\t    xmlXPathCmpNodes\t\t(xmlNodePtr node1,\n\t\t\t\t\t\t xmlNodePtr node2);\n/**\n * Conversion functions to basic types.\n */\nXMLPUBFUN int\n\t\t    xmlXPathCastNumberToBoolean\t(double val);\nXMLPUBFUN int\n\t\t    xmlXPathCastStringToBoolean\t(const xmlChar * val);\nXMLPUBFUN int\n\t\t    xmlXPathCastNodeSetToBoolean(xmlNodeSetPtr ns);\nXMLPUBFUN int\n\t\t    xmlXPathCastToBoolean\t(xmlXPathObjectPtr val);\n\nXMLPUBFUN double\n\t\t    xmlXPathCastBooleanToNumber\t(int val);\nXMLPUBFUN double\n\t\t    xmlXPathCastStringToNumber\t(const xmlChar * val);\nXMLPUBFUN double\n\t\t    xmlXPathCastNodeToNumber\t(xmlNodePtr node);\nXMLPUBFUN double\n\t\t    xmlXPathCastNodeSetToNumber\t(xmlNodeSetPtr ns);\nXMLPUBFUN double\n\t\t    xmlXPathCastToNumber\t(xmlXPathObjectPtr val);\n\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastBooleanToString\t(int val);\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastNumberToString\t(double val);\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastNodeToString\t(xmlNodePtr node);\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastNodeSetToString\t(xmlNodeSetPtr ns);\nXMLPUBFUN xmlChar *\n\t\t    xmlXPathCastToString\t(xmlXPathObjectPtr val);\n\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathConvertBoolean\t(xmlXPathObjectPtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathConvertNumber\t(xmlXPathObjectPtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathConvertString\t(xmlXPathObjectPtr val);\n\n/**\n * Context handling.\n */\nXMLPUBFUN xmlXPathContextPtr\n\t\t    xmlXPathNewContext\t\t(xmlDocPtr doc);\nXMLPUBFUN void\n\t\t    xmlXPathFreeContext\t\t(xmlXPathContextPtr ctxt);\nXMLPUBFUN int\n\t\t    xmlXPathContextSetCache(xmlXPathContextPtr ctxt,\n\t\t\t\t            int active,\n\t\t\t\t\t    int value,\n\t\t\t\t\t    int options);\n/**\n * Evaluation functions.\n */\nXMLPUBFUN long\n\t\t    xmlXPathOrderDocElems\t(xmlDocPtr doc);\nXMLPUBFUN int\n\t\t    xmlXPathSetContextNode\t(xmlNodePtr node,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathNodeEval\t\t(xmlNodePtr node,\n\t\t\t\t\t\t const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathEval\t\t(const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathEvalExpression\t(const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctxt);\nXMLPUBFUN int\n\t\t    xmlXPathEvalPredicate\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t xmlXPathObjectPtr res);\n/**\n * Separate compilation/evaluation entry points.\n */\nXMLPUBFUN xmlXPathCompExprPtr\n\t\t    xmlXPathCompile\t\t(const xmlChar *str);\nXMLPUBFUN xmlXPathCompExprPtr\n\t\t    xmlXPathCtxtCompile\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *str);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPathCompiledEval\t(xmlXPathCompExprPtr comp,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\nXMLPUBFUN int\n\t\t    xmlXPathCompiledEvalToBoolean(xmlXPathCompExprPtr comp,\n\t\t\t\t\t\t xmlXPathContextPtr ctxt);\nXMLPUBFUN void\n\t\t    xmlXPathFreeCompExpr\t(xmlXPathCompExprPtr comp);\n#endif /* LIBXML_XPATH_ENABLED */\n#if defined(LIBXML_XPATH_ENABLED) || defined(LIBXML_SCHEMAS_ENABLED)\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPathInit\t\t(void);\nXMLPUBFUN int\n\t\txmlXPathIsNaN\t(double val);\nXMLPUBFUN int\n\t\txmlXPathIsInf\t(double val);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XPATH_ENABLED or LIBXML_SCHEMAS_ENABLED*/\n#endif /* ! __XML_XPATH_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xpathInternals.h",
    "content": "/*\n * Summary: internal interfaces for XML Path Language implementation\n * Description: internal interfaces for XML Path Language implementation\n *              used to build new modules on top of XPath like XPointer and\n *              XSLT\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XPATH_INTERNALS_H__\n#define __XML_XPATH_INTERNALS_H__\n\n#include <libxml/xmlversion.h>\n#include <libxml/xpath.h>\n\n#ifdef LIBXML_XPATH_ENABLED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/************************************************************************\n *\t\t\t\t\t\t\t\t\t*\n *\t\t\tHelpers\t\t\t\t\t\t*\n *\t\t\t\t\t\t\t\t\t*\n ************************************************************************/\n\n/*\n * Many of these macros may later turn into functions. They\n * shouldn't be used in #ifdef's preprocessor instructions.\n */\n/**\n * xmlXPathSetError:\n * @ctxt:  an XPath parser context\n * @err:  an xmlXPathError code\n *\n * Raises an error.\n */\n#define xmlXPathSetError(ctxt, err)\t\t\t\t\t\\\n    { xmlXPatherror((ctxt), __FILE__, __LINE__, (err));\t\t\t\\\n      if ((ctxt) != NULL) (ctxt)->error = (err); }\n\n/**\n * xmlXPathSetArityError:\n * @ctxt:  an XPath parser context\n *\n * Raises an XPATH_INVALID_ARITY error.\n */\n#define xmlXPathSetArityError(ctxt)\t\t\t\t\t\\\n    xmlXPathSetError((ctxt), XPATH_INVALID_ARITY)\n\n/**\n * xmlXPathSetTypeError:\n * @ctxt:  an XPath parser context\n *\n * Raises an XPATH_INVALID_TYPE error.\n */\n#define xmlXPathSetTypeError(ctxt)\t\t\t\t\t\\\n    xmlXPathSetError((ctxt), XPATH_INVALID_TYPE)\n\n/**\n * xmlXPathGetError:\n * @ctxt:  an XPath parser context\n *\n * Get the error code of an XPath context.\n *\n * Returns the context error.\n */\n#define xmlXPathGetError(ctxt)\t  ((ctxt)->error)\n\n/**\n * xmlXPathCheckError:\n * @ctxt:  an XPath parser context\n *\n * Check if an XPath error was raised.\n *\n * Returns true if an error has been raised, false otherwise.\n */\n#define xmlXPathCheckError(ctxt)  ((ctxt)->error != XPATH_EXPRESSION_OK)\n\n/**\n * xmlXPathGetDocument:\n * @ctxt:  an XPath parser context\n *\n * Get the document of an XPath context.\n *\n * Returns the context document.\n */\n#define xmlXPathGetDocument(ctxt)\t((ctxt)->context->doc)\n\n/**\n * xmlXPathGetContextNode:\n * @ctxt: an XPath parser context\n *\n * Get the context node of an XPath context.\n *\n * Returns the context node.\n */\n#define xmlXPathGetContextNode(ctxt)\t((ctxt)->context->node)\n\nXMLPUBFUN int\n\t\txmlXPathPopBoolean\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN double\n\t\txmlXPathPopNumber\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN xmlChar *\n\t\txmlXPathPopString\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathPopNodeSet\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void *\n\t\txmlXPathPopExternal\t(xmlXPathParserContextPtr ctxt);\n\n/**\n * xmlXPathReturnBoolean:\n * @ctxt:  an XPath parser context\n * @val:  a boolean\n *\n * Pushes the boolean @val on the context stack.\n */\n#define xmlXPathReturnBoolean(ctxt, val)\t\t\t\t\\\n    valuePush((ctxt), xmlXPathNewBoolean(val))\n\n/**\n * xmlXPathReturnTrue:\n * @ctxt:  an XPath parser context\n *\n * Pushes true on the context stack.\n */\n#define xmlXPathReturnTrue(ctxt)   xmlXPathReturnBoolean((ctxt), 1)\n\n/**\n * xmlXPathReturnFalse:\n * @ctxt:  an XPath parser context\n *\n * Pushes false on the context stack.\n */\n#define xmlXPathReturnFalse(ctxt)  xmlXPathReturnBoolean((ctxt), 0)\n\n/**\n * xmlXPathReturnNumber:\n * @ctxt:  an XPath parser context\n * @val:  a double\n *\n * Pushes the double @val on the context stack.\n */\n#define xmlXPathReturnNumber(ctxt, val)\t\t\t\t\t\\\n    valuePush((ctxt), xmlXPathNewFloat(val))\n\n/**\n * xmlXPathReturnString:\n * @ctxt:  an XPath parser context\n * @str:  a string\n *\n * Pushes the string @str on the context stack.\n */\n#define xmlXPathReturnString(ctxt, str)\t\t\t\t\t\\\n    valuePush((ctxt), xmlXPathWrapString(str))\n\n/**\n * xmlXPathReturnEmptyString:\n * @ctxt:  an XPath parser context\n *\n * Pushes an empty string on the stack.\n */\n#define xmlXPathReturnEmptyString(ctxt)\t\t\t\t\t\\\n    valuePush((ctxt), xmlXPathNewCString(\"\"))\n\n/**\n * xmlXPathReturnNodeSet:\n * @ctxt:  an XPath parser context\n * @ns:  a node-set\n *\n * Pushes the node-set @ns on the context stack.\n */\n#define xmlXPathReturnNodeSet(ctxt, ns)\t\t\t\t\t\\\n    valuePush((ctxt), xmlXPathWrapNodeSet(ns))\n\n/**\n * xmlXPathReturnEmptyNodeSet:\n * @ctxt:  an XPath parser context\n *\n * Pushes an empty node-set on the context stack.\n */\n#define xmlXPathReturnEmptyNodeSet(ctxt)\t\t\t\t\\\n    valuePush((ctxt), xmlXPathNewNodeSet(NULL))\n\n/**\n * xmlXPathReturnExternal:\n * @ctxt:  an XPath parser context\n * @val:  user data\n *\n * Pushes user data on the context stack.\n */\n#define xmlXPathReturnExternal(ctxt, val)\t\t\t\t\\\n    valuePush((ctxt), xmlXPathWrapExternal(val))\n\n/**\n * xmlXPathStackIsNodeSet:\n * @ctxt: an XPath parser context\n *\n * Check if the current value on the XPath stack is a node set or\n * an XSLT value tree.\n *\n * Returns true if the current object on the stack is a node-set.\n */\n#define xmlXPathStackIsNodeSet(ctxt)\t\t\t\t\t\\\n    (((ctxt)->value != NULL)\t\t\t\t\t\t\\\n     && (((ctxt)->value->type == XPATH_NODESET)\t\t\t\t\\\n         || ((ctxt)->value->type == XPATH_XSLT_TREE)))\n\n/**\n * xmlXPathStackIsExternal:\n * @ctxt: an XPath parser context\n *\n * Checks if the current value on the XPath stack is an external\n * object.\n *\n * Returns true if the current object on the stack is an external\n * object.\n */\n#define xmlXPathStackIsExternal(ctxt)\t\t\t\t\t\\\n\t((ctxt->value != NULL) && (ctxt->value->type == XPATH_USERS))\n\n/**\n * xmlXPathEmptyNodeSet:\n * @ns:  a node-set\n *\n * Empties a node-set.\n */\n#define xmlXPathEmptyNodeSet(ns)\t\t\t\t\t\\\n    { while ((ns)->nodeNr > 0) (ns)->nodeTab[--(ns)->nodeNr] = NULL; }\n\n/**\n * CHECK_ERROR:\n *\n * Macro to return from the function if an XPath error was detected.\n */\n#define CHECK_ERROR\t\t\t\t\t\t\t\\\n    if (ctxt->error != XPATH_EXPRESSION_OK) return\n\n/**\n * CHECK_ERROR0:\n *\n * Macro to return 0 from the function if an XPath error was detected.\n */\n#define CHECK_ERROR0\t\t\t\t\t\t\t\\\n    if (ctxt->error != XPATH_EXPRESSION_OK) return(0)\n\n/**\n * XP_ERROR:\n * @X:  the error code\n *\n * Macro to raise an XPath error and return.\n */\n#define XP_ERROR(X)\t\t\t\t\t\t\t\\\n    { xmlXPathErr(ctxt, X); return; }\n\n/**\n * XP_ERROR0:\n * @X:  the error code\n *\n * Macro to raise an XPath error and return 0.\n */\n#define XP_ERROR0(X)\t\t\t\t\t\t\t\\\n    { xmlXPathErr(ctxt, X); return(0); }\n\n/**\n * CHECK_TYPE:\n * @typeval:  the XPath type\n *\n * Macro to check that the value on top of the XPath stack is of a given\n * type.\n */\n#define CHECK_TYPE(typeval)\t\t\t\t\t\t\\\n    if ((ctxt->value == NULL) || (ctxt->value->type != typeval))\t\\\n        XP_ERROR(XPATH_INVALID_TYPE)\n\n/**\n * CHECK_TYPE0:\n * @typeval:  the XPath type\n *\n * Macro to check that the value on top of the XPath stack is of a given\n * type. Return(0) in case of failure\n */\n#define CHECK_TYPE0(typeval)\t\t\t\t\t\t\\\n    if ((ctxt->value == NULL) || (ctxt->value->type != typeval))\t\\\n        XP_ERROR0(XPATH_INVALID_TYPE)\n\n/**\n * CHECK_ARITY:\n * @x:  the number of expected args\n *\n * Macro to check that the number of args passed to an XPath function matches.\n */\n#define CHECK_ARITY(x)\t\t\t\t\t\t\t\\\n    if (ctxt == NULL) return;\t\t\t\t\t\t\\\n    if (nargs != (x))\t\t\t\t\t\t\t\\\n        XP_ERROR(XPATH_INVALID_ARITY);\t\t\t\t\t\\\n    if (ctxt->valueNr < ctxt->valueFrame + (x))\t\t\t\t\\\n        XP_ERROR(XPATH_STACK_ERROR);\n\n/**\n * CAST_TO_STRING:\n *\n * Macro to try to cast the value on the top of the XPath stack to a string.\n */\n#define CAST_TO_STRING\t\t\t\t\t\t\t\\\n    if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_STRING))\t\\\n        xmlXPathStringFunction(ctxt, 1);\n\n/**\n * CAST_TO_NUMBER:\n *\n * Macro to try to cast the value on the top of the XPath stack to a number.\n */\n#define CAST_TO_NUMBER\t\t\t\t\t\t\t\\\n    if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_NUMBER))\t\\\n        xmlXPathNumberFunction(ctxt, 1);\n\n/**\n * CAST_TO_BOOLEAN:\n *\n * Macro to try to cast the value on the top of the XPath stack to a boolean.\n */\n#define CAST_TO_BOOLEAN\t\t\t\t\t\t\t\\\n    if ((ctxt->value != NULL) && (ctxt->value->type != XPATH_BOOLEAN))\t\\\n        xmlXPathBooleanFunction(ctxt, 1);\n\n/*\n * Variable Lookup forwarding.\n */\n\nXMLPUBFUN void\n\txmlXPathRegisterVariableLookup\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t xmlXPathVariableLookupFunc f,\n\t\t\t\t\t void *data);\n\n/*\n * Function Lookup forwarding.\n */\n\nXMLPUBFUN void\n\t    xmlXPathRegisterFuncLookup\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t xmlXPathFuncLookupFunc f,\n\t\t\t\t\t void *funcCtxt);\n\n/*\n * Error reporting.\n */\nXMLPUBFUN void\n\t\txmlXPatherror\t(xmlXPathParserContextPtr ctxt,\n\t\t\t\t const char *file,\n\t\t\t\t int line,\n\t\t\t\t int no);\n\nXMLPUBFUN void\n\t\txmlXPathErr\t(xmlXPathParserContextPtr ctxt,\n\t\t\t\t int error);\n\n#ifdef LIBXML_DEBUG_ENABLED\nXMLPUBFUN void\n\t\txmlXPathDebugDumpObject\t(FILE *output,\n\t\t\t\t\t xmlXPathObjectPtr cur,\n\t\t\t\t\t int depth);\nXMLPUBFUN void\n\t    xmlXPathDebugDumpCompExpr(FILE *output,\n\t\t\t\t\t xmlXPathCompExprPtr comp,\n\t\t\t\t\t int depth);\n#endif\n/**\n * NodeSet handling.\n */\nXMLPUBFUN int\n\t\txmlXPathNodeSetContains\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr val);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathDifference\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathIntersection\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\n\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathDistinctSorted\t\t(xmlNodeSetPtr nodes);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathDistinct\t\t(xmlNodeSetPtr nodes);\n\nXMLPUBFUN int\n\t\txmlXPathHasSameNodes\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\n\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeLeadingSorted\t(xmlNodeSetPtr nodes,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathLeadingSorted\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeLeading\t\t(xmlNodeSetPtr nodes,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathLeading\t\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\n\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeTrailingSorted\t(xmlNodeSetPtr nodes,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathTrailingSorted\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeTrailing\t\t(xmlNodeSetPtr nodes,\n\t\t\t\t\t\t xmlNodePtr node);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathTrailing\t\t(xmlNodeSetPtr nodes1,\n\t\t\t\t\t\t xmlNodeSetPtr nodes2);\n\n\n/**\n * Extending a context.\n */\n\nXMLPUBFUN int\n\t\txmlXPathRegisterNs\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *prefix,\n\t\t\t\t\t\t const xmlChar *ns_uri);\nXMLPUBFUN const xmlChar *\n\t\txmlXPathNsLookup\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *prefix);\nXMLPUBFUN void\n\t\txmlXPathRegisteredNsCleanup\t(xmlXPathContextPtr ctxt);\n\nXMLPUBFUN int\n\t\txmlXPathRegisterFunc\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t xmlXPathFunction f);\nXMLPUBFUN int\n\t\txmlXPathRegisterFuncNS\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns_uri,\n\t\t\t\t\t\t xmlXPathFunction f);\nXMLPUBFUN int\n\t\txmlXPathRegisterVariable\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t xmlXPathObjectPtr value);\nXMLPUBFUN int\n\t\txmlXPathRegisterVariableNS\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns_uri,\n\t\t\t\t\t\t xmlXPathObjectPtr value);\nXMLPUBFUN xmlXPathFunction\n\t\txmlXPathFunctionLookup\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlXPathFunction\n\t\txmlXPathFunctionLookupNS\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns_uri);\nXMLPUBFUN void\n\t\txmlXPathRegisteredFuncsCleanup\t(xmlXPathContextPtr ctxt);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathVariableLookup\t\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathVariableLookupNS\t(xmlXPathContextPtr ctxt,\n\t\t\t\t\t\t const xmlChar *name,\n\t\t\t\t\t\t const xmlChar *ns_uri);\nXMLPUBFUN void\n\t\txmlXPathRegisteredVariablesCleanup(xmlXPathContextPtr ctxt);\n\n/**\n * Utilities to extend XPath.\n */\nXMLPUBFUN xmlXPathParserContextPtr\n\t\t  xmlXPathNewParserContext\t(const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctxt);\nXMLPUBFUN void\n\t\txmlXPathFreeParserContext\t(xmlXPathParserContextPtr ctxt);\n\n/* TODO: remap to xmlXPathValuePop and Push. */\nXMLPUBFUN xmlXPathObjectPtr\n\t\tvaluePop\t\t\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN int\n\t\tvaluePush\t\t\t(xmlXPathParserContextPtr ctxt,\n\t\t\t\t\t\t xmlXPathObjectPtr value);\n\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewString\t\t(const xmlChar *val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewCString\t\t(const char *val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathWrapString\t\t(xmlChar *val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathWrapCString\t\t(char * val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewFloat\t\t(double val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewBoolean\t\t(int val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewNodeSet\t\t(xmlNodePtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewValueTree\t\t(xmlNodePtr val);\nXMLPUBFUN int\n\t\txmlXPathNodeSetAdd\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr val);\nXMLPUBFUN int\n\t\txmlXPathNodeSetAddUnique\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr val);\nXMLPUBFUN int\n\t\txmlXPathNodeSetAddNs\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr node,\n\t\t\t\t\t\t xmlNsPtr ns);\nXMLPUBFUN void\n\t\txmlXPathNodeSetSort\t\t(xmlNodeSetPtr set);\n\nXMLPUBFUN void\n\t\txmlXPathRoot\t\t\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void\n\t\txmlXPathEvalExpr\t\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN xmlChar *\n\t\txmlXPathParseName\t\t(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN xmlChar *\n\t\txmlXPathParseNCName\t\t(xmlXPathParserContextPtr ctxt);\n\n/*\n * Existing functions.\n */\nXMLPUBFUN double\n\t\txmlXPathStringEvalNumber\t(const xmlChar *str);\nXMLPUBFUN int\n\t\txmlXPathEvaluatePredicateResult (xmlXPathParserContextPtr ctxt,\n\t\t\t\t\t\t xmlXPathObjectPtr res);\nXMLPUBFUN void\n\t\txmlXPathRegisterAllFunctions\t(xmlXPathContextPtr ctxt);\nXMLPUBFUN xmlNodeSetPtr\n\t\txmlXPathNodeSetMerge\t\t(xmlNodeSetPtr val1,\n\t\t\t\t\t\t xmlNodeSetPtr val2);\nXMLPUBFUN void\n\t\txmlXPathNodeSetDel\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t xmlNodePtr val);\nXMLPUBFUN void\n\t\txmlXPathNodeSetRemove\t\t(xmlNodeSetPtr cur,\n\t\t\t\t\t\t int val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathNewNodeSetList\t\t(xmlNodeSetPtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathWrapNodeSet\t\t(xmlNodeSetPtr val);\nXMLPUBFUN xmlXPathObjectPtr\n\t\txmlXPathWrapExternal\t\t(void *val);\n\nXMLPUBFUN int xmlXPathEqualValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN int xmlXPathNotEqualValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN int xmlXPathCompareValues(xmlXPathParserContextPtr ctxt, int inf, int strict);\nXMLPUBFUN void xmlXPathValueFlipSign(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathAddValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathSubValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathMultValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathDivValues(xmlXPathParserContextPtr ctxt);\nXMLPUBFUN void xmlXPathModValues(xmlXPathParserContextPtr ctxt);\n\nXMLPUBFUN int xmlXPathIsNodeType(const xmlChar *name);\n\n/*\n * Some of the axis navigation routines.\n */\nXMLPUBFUN xmlNodePtr xmlXPathNextSelf(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextChild(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextDescendant(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextDescendantOrSelf(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextParent(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextAncestorOrSelf(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextFollowingSibling(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextFollowing(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextNamespace(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextAttribute(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextPreceding(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextAncestor(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\nXMLPUBFUN xmlNodePtr xmlXPathNextPrecedingSibling(xmlXPathParserContextPtr ctxt,\n\t\t\txmlNodePtr cur);\n/*\n * The official core of XPath functions.\n */\nXMLPUBFUN void xmlXPathLastFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathPositionFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathCountFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathIdFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathLocalNameFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathNamespaceURIFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathStringFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathStringLengthFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathConcatFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathContainsFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathStartsWithFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathSubstringFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathSubstringBeforeFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathSubstringAfterFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathNormalizeFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathTranslateFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathNotFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathTrueFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathFalseFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathLangFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathNumberFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathSumFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathFloorFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathCeilingFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathRoundFunction(xmlXPathParserContextPtr ctxt, int nargs);\nXMLPUBFUN void xmlXPathBooleanFunction(xmlXPathParserContextPtr ctxt, int nargs);\n\n/**\n * Really internal functions\n */\nXMLPUBFUN void xmlXPathNodeSetFreeNs(xmlNsPtr ns);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XPATH_ENABLED */\n#endif /* ! __XML_XPATH_INTERNALS_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/libxml2/libxml/xpointer.h",
    "content": "/*\n * Summary: API to handle XML Pointers\n * Description: API to handle XML Pointers\n * Base implementation was made accordingly to\n * W3C Candidate Recommendation 7 June 2000\n * http://www.w3.org/TR/2000/CR-xptr-20000607\n *\n * Added support for the element() scheme described in:\n * W3C Proposed Recommendation 13 November 2002\n * http://www.w3.org/TR/2002/PR-xptr-element-20021113/\n *\n * Copy: See Copyright for the status of this software.\n *\n * Author: Daniel Veillard\n */\n\n#ifndef __XML_XPTR_H__\n#define __XML_XPTR_H__\n\n#include <libxml/xmlversion.h>\n\n#ifdef LIBXML_XPTR_ENABLED\n\n#include <libxml/tree.h>\n#include <libxml/xpath.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifdef LIBXML_XPTR_LOCS_ENABLED\n/*\n * A Location Set\n */\ntypedef struct _xmlLocationSet xmlLocationSet;\ntypedef xmlLocationSet *xmlLocationSetPtr;\nstruct _xmlLocationSet {\n    int locNr;\t\t      /* number of locations in the set */\n    int locMax;\t\t      /* size of the array as allocated */\n    xmlXPathObjectPtr *locTab;/* array of locations */\n};\n\n/*\n * Handling of location sets.\n */\n\nXML_DEPRECATED\nXMLPUBFUN xmlLocationSetPtr\n\t\t    xmlXPtrLocationSetCreate\t(xmlXPathObjectPtr val);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrFreeLocationSet\t(xmlLocationSetPtr obj);\nXML_DEPRECATED\nXMLPUBFUN xmlLocationSetPtr\n\t\t    xmlXPtrLocationSetMerge\t(xmlLocationSetPtr val1,\n\t\t\t\t\t\t xmlLocationSetPtr val2);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRange\t\t(xmlNodePtr start,\n\t\t\t\t\t\t int startindex,\n\t\t\t\t\t\t xmlNodePtr end,\n\t\t\t\t\t\t int endindex);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangePoints\t(xmlXPathObjectPtr start,\n\t\t\t\t\t\t xmlXPathObjectPtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangeNodePoint\t(xmlNodePtr start,\n\t\t\t\t\t\t xmlXPathObjectPtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangePointNode\t(xmlXPathObjectPtr start,\n\t\t\t\t\t\t xmlNodePtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangeNodes\t(xmlNodePtr start,\n\t\t\t\t\t\t xmlNodePtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewLocationSetNodes\t(xmlNodePtr start,\n\t\t\t\t\t\t xmlNodePtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewLocationSetNodeSet(xmlNodeSetPtr set);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewRangeNodeObject\t(xmlNodePtr start,\n\t\t\t\t\t\t xmlXPathObjectPtr end);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrNewCollapsedRange\t(xmlNodePtr start);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrLocationSetAdd\t(xmlLocationSetPtr cur,\n\t\t\t\t\t\t xmlXPathObjectPtr val);\nXML_DEPRECATED\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrWrapLocationSet\t(xmlLocationSetPtr val);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrLocationSetDel\t(xmlLocationSetPtr cur,\n\t\t\t\t\t\t xmlXPathObjectPtr val);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrLocationSetRemove\t(xmlLocationSetPtr cur,\n\t\t\t\t\t\t int val);\n#endif /* LIBXML_XPTR_LOCS_ENABLED */\n\n/*\n * Functions.\n */\nXMLPUBFUN xmlXPathContextPtr\n\t\t    xmlXPtrNewContext\t\t(xmlDocPtr doc,\n\t\t\t\t\t\t xmlNodePtr here,\n\t\t\t\t\t\t xmlNodePtr origin);\nXMLPUBFUN xmlXPathObjectPtr\n\t\t    xmlXPtrEval\t\t\t(const xmlChar *str,\n\t\t\t\t\t\t xmlXPathContextPtr ctx);\n#ifdef LIBXML_XPTR_LOCS_ENABLED\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrRangeToFunction\t(xmlXPathParserContextPtr ctxt,\n\t\t\t\t\t\t int nargs);\nXML_DEPRECATED\nXMLPUBFUN xmlNodePtr\n\t\t    xmlXPtrBuildNodeList\t(xmlXPathObjectPtr obj);\nXML_DEPRECATED\nXMLPUBFUN void\n\t\t    xmlXPtrEvalRangePredicate\t(xmlXPathParserContextPtr ctxt);\n#endif /* LIBXML_XPTR_LOCS_ENABLED */\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* LIBXML_XPTR_ENABLED */\n#endif /* __XML_XPTR_H__ */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/aes.h",
    "content": "/* aes.h\n\n   The aes/rijndael block cipher.\n\n   Copyright (C) 2001, 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_AES_H_INCLUDED\n#define NETTLE_AES_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define aes_set_encrypt_key nettle_aes_set_encrypt_key\n#define aes_set_decrypt_key nettle_aes_set_decrypt_key\n#define aes_invert_key nettle_aes_invert_key\n#define aes_encrypt nettle_aes_encrypt\n#define aes_decrypt nettle_aes_decrypt\n#define aes128_set_encrypt_key nettle_aes128_set_encrypt_key\n#define aes128_set_decrypt_key nettle_aes128_set_decrypt_key\n#define aes128_invert_key nettle_aes128_invert_key\n#define aes128_encrypt nettle_aes128_encrypt\n#define aes128_decrypt nettle_aes128_decrypt\n#define aes192_set_encrypt_key nettle_aes192_set_encrypt_key\n#define aes192_set_decrypt_key nettle_aes192_set_decrypt_key\n#define aes192_invert_key nettle_aes192_invert_key\n#define aes192_encrypt nettle_aes192_encrypt\n#define aes192_decrypt nettle_aes192_decrypt\n#define aes256_set_encrypt_key nettle_aes256_set_encrypt_key\n#define aes256_set_decrypt_key nettle_aes256_set_decrypt_key\n#define aes256_invert_key nettle_aes256_invert_key\n#define aes256_encrypt nettle_aes256_encrypt\n#define aes256_decrypt nettle_aes256_decrypt\n\n#define AES_BLOCK_SIZE 16\n\n#define AES128_KEY_SIZE 16\n#define AES192_KEY_SIZE 24\n#define AES256_KEY_SIZE 32\n#define _AES128_ROUNDS 10\n#define _AES192_ROUNDS 12\n#define _AES256_ROUNDS 14\n\nstruct aes128_ctx\n{\n  uint32_t keys[4 * (_AES128_ROUNDS + 1)];\n};\n\nvoid\naes128_set_encrypt_key(struct aes128_ctx *ctx, const uint8_t *key);\nvoid\naes128_set_decrypt_key(struct aes128_ctx *ctx, const uint8_t *key);\nvoid\naes128_invert_key(struct aes128_ctx *dst,\n\t\t  const struct aes128_ctx *src);\nvoid\naes128_encrypt(const struct aes128_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\nvoid\naes128_decrypt(const struct aes128_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\n\nstruct aes192_ctx\n{\n  uint32_t keys[4 * (_AES192_ROUNDS + 1)];\n};\n\nvoid\naes192_set_encrypt_key(struct aes192_ctx *ctx, const uint8_t *key);\nvoid\naes192_set_decrypt_key(struct aes192_ctx *ctx, const uint8_t *key);\nvoid\naes192_invert_key(struct aes192_ctx *dst,\n\t\t  const struct aes192_ctx *src);\nvoid\naes192_encrypt(const struct aes192_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\nvoid\naes192_decrypt(const struct aes192_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\n\nstruct aes256_ctx\n{\n  uint32_t keys[4 * (_AES256_ROUNDS + 1)];\n};\n\nvoid\naes256_set_encrypt_key(struct aes256_ctx *ctx, const uint8_t *key);\nvoid\naes256_set_decrypt_key(struct aes256_ctx *ctx, const uint8_t *key);\nvoid\naes256_invert_key(struct aes256_ctx *dst,\n\t\t  const struct aes256_ctx *src);\nvoid\naes256_encrypt(const struct aes256_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\nvoid\naes256_decrypt(const struct aes256_ctx *ctx,\n\t       size_t length, uint8_t *dst,\n\t       const uint8_t *src);\n\n/* The older nettle-2.7 AES interface is deprecated, please migrate to\n   the newer interface where each algorithm has a fixed key size. */\n\n/* Variable key size between 128 and 256 bits. But the only valid\n * values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */\n#define AES_MIN_KEY_SIZE AES128_KEY_SIZE\n#define AES_MAX_KEY_SIZE AES256_KEY_SIZE\n\n#define AES_KEY_SIZE 32\n\nstruct aes_ctx\n{\n  unsigned key_size;  /* In octets */\n  union {\n    struct aes128_ctx ctx128;\n    struct aes192_ctx ctx192;\n    struct aes256_ctx ctx256;\n  } u;\n};\n\nvoid\naes_set_encrypt_key(struct aes_ctx *ctx,\n\t\t    size_t length, const uint8_t *key)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\naes_set_decrypt_key(struct aes_ctx *ctx,\n\t\t   size_t length, const uint8_t *key)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\naes_invert_key(struct aes_ctx *dst,\n\t       const struct aes_ctx *src)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\naes_encrypt(const struct aes_ctx *ctx,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src) _NETTLE_ATTRIBUTE_DEPRECATED;\nvoid\naes_decrypt(const struct aes_ctx *ctx,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src) _NETTLE_ATTRIBUTE_DEPRECATED;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_AES_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/arcfour.h",
    "content": "/* arcfour.h\n\n   The arcfour/rc4 stream cipher.\n\n   Copyright (C) 2001, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_ARCFOUR_H_INCLUDED\n#define NETTLE_ARCFOUR_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define arcfour128_set_key nettle_arcfour128_set_key\n#define arcfour_set_key nettle_arcfour_set_key\n#define arcfour_crypt nettle_arcfour_crypt\n\n/* Minimum and maximum keysizes, and a reasonable default. In\n * octets.*/\n#define ARCFOUR_MIN_KEY_SIZE 1\n#define ARCFOUR_MAX_KEY_SIZE 256\n#define ARCFOUR_KEY_SIZE 16\n#define ARCFOUR128_KEY_SIZE 16\n\nstruct arcfour_ctx\n{\n  uint8_t S[256];\n  uint8_t i;\n  uint8_t j;\n};\n\nvoid\narcfour_set_key(struct arcfour_ctx *ctx,\n\t\tsize_t length, const uint8_t *key);\n\nvoid\narcfour128_set_key(struct arcfour_ctx *ctx, const uint8_t *key);\n\nvoid\narcfour_crypt(struct arcfour_ctx *ctx,\n\t      size_t length, uint8_t *dst,\n\t      const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ARCFOUR_H_INCLUDED */\n\n"
  },
  {
    "path": "thirdparty/64/include/nettle/arctwo.h",
    "content": "/* arctwo.h\n\n   The arctwo/rfc2268 block cipher.\n\n   Copyright (C) 2004 Simon Josefsson\n   Copyright (C) 2002, 2004, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_ARCTWO_H_INCLUDED\n#define NETTLE_ARCTWO_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define arctwo_set_key nettle_arctwo_set_key\n#define arctwo_set_key_ekb nettle_arctwo_set_key_ekb\n#define arctwo_set_key_gutmann nettle_arctwo_set_key_gutmann\n#define arctwo40_set_key nettle_arctwo40_set_key\n#define arctwo64_set_key nettle_arctwo64_set_key\n#define arctwo128_set_key nettle_arctwo128_set_key\n#define arctwo128_set_key_gutmann nettle_arctwo128_set_key_gutmann\n#define arctwo_encrypt nettle_arctwo_encrypt\n#define arctwo_decrypt nettle_arctwo_decrypt\n\n#define ARCTWO_BLOCK_SIZE 8\n\n/* Variable key size from 1 byte to 128 bytes. */\n#define ARCTWO_MIN_KEY_SIZE 1\n#define ARCTWO_MAX_KEY_SIZE 128\n\n#define ARCTWO_KEY_SIZE 8\n\nstruct arctwo_ctx\n{\n  uint16_t S[64];\n};\n\n/* Key expansion function that takes the \"effective key bits\", 1-1024,\n   as an explicit argument. 0 means maximum key bits. */\nvoid\narctwo_set_key_ekb (struct arctwo_ctx *ctx,\n\t\t    size_t length, const uint8_t * key, unsigned ekb);\n\n/* Equvivalent to arctwo_set_key_ekb, with ekb = 8 * length */\nvoid\narctwo_set_key (struct arctwo_ctx *ctx, size_t length, const uint8_t *key);\nvoid\narctwo40_set_key (struct arctwo_ctx *ctx, const uint8_t *key);\nvoid\narctwo64_set_key (struct arctwo_ctx *ctx, const uint8_t *key);\nvoid\narctwo128_set_key (struct arctwo_ctx *ctx, const uint8_t *key);\n\n/* Equvivalent to arctwo_set_key_ekb, with ekb = 1024 */\nvoid\narctwo_set_key_gutmann (struct arctwo_ctx *ctx,\n\t\t\tsize_t length, const uint8_t *key);\nvoid\narctwo128_set_key_gutmann (struct arctwo_ctx *ctx,\n\t\t\t   const uint8_t *key);\n\nvoid\narctwo_encrypt (struct arctwo_ctx *ctx,\n\t\tsize_t length, uint8_t *dst, const uint8_t *src);\nvoid\narctwo_decrypt (struct arctwo_ctx *ctx,\n\t\tsize_t length, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ARCTWO_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/asn1.h",
    "content": "/* asn1.h\n\n   Limited support for ASN.1 DER decoding.\n\n   Copyright (C) 2005 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_ASN1_H_INCLUDED\n#define NETTLE_ASN1_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define asn1_der_iterator_first nettle_asn1_der_iterator_first\n#define asn1_der_iterator_next nettle_asn1_der_iterator_next\n#define asn1_der_decode_constructed nettle_asn1_der_decode_constructed\n#define asn1_der_decode_constructed_last nettle_asn1_der_decode_constructed_last\n#define asn1_der_decode_bitstring nettle_asn1_der_decode_bitstring\n#define asn1_der_decode_bitstring_last nettle_asn1_der_decode_bitstring_last\n#define asn1_der_get_uint32 nettle_asn1_der_get_uint32\n#define asn1_der_get_bignum nettle_asn1_der_get_bignum\n\n\n/* enum asn1_type keeps the class number and the constructive in bits\n   13-14, and the constructive flag in bit 12. The remaining 14 bits\n   are the tag (although currently, only tags in the range 0-30 are\n   supported). */\n\nenum\n  {\n    ASN1_TYPE_CONSTRUCTED = 1 << 12,\n\n    ASN1_CLASS_UNIVERSAL = 0,\n    ASN1_CLASS_APPLICATION = 1 << 13,\n    ASN1_CLASS_CONTEXT_SPECIFIC = 2 << 13,\n    ASN1_CLASS_PRIVATE = 3 << 13,\n\n    ASN1_CLASS_MASK = 3 << 13,\n    ASN1_CLASS_SHIFT = 13,\n  };\n\nenum asn1_type\n  {\n    ASN1_BOOLEAN = 1,\n    ASN1_INTEGER = 2,\n    ASN1_BITSTRING = 3,\n    ASN1_OCTETSTRING = 4,\n    ASN1_NULL = 5,\n    ASN1_IDENTIFIER = 6,\n    ASN1_REAL = 9,\n    ASN1_ENUMERATED = 10,\n    ASN1_UTF8STRING = 12,\n    ASN1_SEQUENCE = 16 | ASN1_TYPE_CONSTRUCTED,\n    ASN1_SET = 17 | ASN1_TYPE_CONSTRUCTED,\n    ASN1_PRINTABLESTRING = 19,\n    ASN1_TELETEXSTRING = 20,\n    ASN1_IA5STRING = 22,\n    ASN1_UTC = 23,\n    ASN1_UNIVERSALSTRING = 28,\n    ASN1_BMPSTRING = 30,\n  };\n\nenum asn1_iterator_result\n  {\n    ASN1_ITERATOR_ERROR,\n    ASN1_ITERATOR_PRIMITIVE,\n    ASN1_ITERATOR_CONSTRUCTED,\n    ASN1_ITERATOR_END,\n  };\n\n/* Parsing DER objects. */\nstruct asn1_der_iterator\n{\n  size_t buffer_length;\n  const uint8_t *buffer;\n\n  /* Next object to parse. */\n  size_t pos;\n\n  enum asn1_type type;\n\n  /* Pointer to the current object */\n  size_t length;\n  const uint8_t *data;\n};\n\n/* Initializes the iterator. */\nenum asn1_iterator_result\nasn1_der_iterator_first(struct asn1_der_iterator *iterator,\n\t\t\tsize_t length, const uint8_t *input);\n\nenum asn1_iterator_result\nasn1_der_iterator_next(struct asn1_der_iterator *iterator);\n\n/* Starts parsing of a constructed object. */\nenum asn1_iterator_result\nasn1_der_decode_constructed(struct asn1_der_iterator *i,\n\t\t\t    struct asn1_der_iterator *contents);\n\n/* For the common case that we have a sequence at the end of the\n   object. Checks that the current object is the final one, and then\n   reinitializes the iterator to parse its ontents. */\nenum asn1_iterator_result\nasn1_der_decode_constructed_last(struct asn1_der_iterator *i);\n\nenum asn1_iterator_result\nasn1_der_decode_bitstring(struct asn1_der_iterator *i,\n\t\t\t  struct asn1_der_iterator *contents);\n\nenum asn1_iterator_result\nasn1_der_decode_bitstring_last(struct asn1_der_iterator *i);\n\n/* All these functions return 1 on success, 0 on failure */\nint\nasn1_der_get_uint32(struct asn1_der_iterator *i,\n\t\t    uint32_t *x);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ASN1_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/balloon.h",
    "content": "/* balloon.h\n\n   Balloon password-hashing algorithm.\n\n   Copyright (C) 2022 Zoltan Fridrich\n   Copyright (C) 2022 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* For a description of the algorithm, see:\n * Boneh, D., Corrigan-Gibbs, H., Schechter, S. (2017, May 12). Balloon Hashing:\n * A Memory-Hard Function Providing Provable Protection Against Sequential Attacks.\n * Retrieved Sep 1, 2022, from https://eprint.iacr.org/2016/027.pdf\n */\n\n#ifndef NETTLE_BALLOON_H_INCLUDED\n#define NETTLE_BALLOON_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define balloon nettle_balloon\n#define balloon_itch nettle_balloon_itch\n#define balloon_sha1 nettle_balloon_sha1\n#define balloon_sha256 nettle_balloon_sha256\n#define balloon_sha384 nettle_balloon_sha384\n#define balloon_sha512 nettle_balloon_sha512\n\nvoid\nballoon(void *hash_ctx,\n        nettle_hash_update_func *update,\n        nettle_hash_digest_func *digest,\n        size_t digest_size, size_t s_cost, size_t t_cost,\n        size_t passwd_length, const uint8_t *passwd,\n        size_t salt_length, const uint8_t *salt,\n        uint8_t *scratch, uint8_t *dst);\n\nsize_t\nballoon_itch(size_t digest_size, size_t s_cost);\n\nvoid\nballoon_sha1(size_t s_cost, size_t t_cost,\n             size_t passwd_length, const uint8_t *passwd,\n             size_t salt_length, const uint8_t *salt,\n             uint8_t *scratch, uint8_t *dst);\n\nvoid\nballoon_sha256(size_t s_cost, size_t t_cost,\n               size_t passwd_length, const uint8_t *passwd,\n               size_t salt_length, const uint8_t *salt,\n               uint8_t *scratch, uint8_t *dst);\n\nvoid\nballoon_sha384(size_t s_cost, size_t t_cost,\n               size_t passwd_length, const uint8_t *passwd,\n               size_t salt_length, const uint8_t *salt,\n               uint8_t *scratch, uint8_t *dst);\n\nvoid\nballoon_sha512(size_t s_cost, size_t t_cost,\n               size_t passwd_length, const uint8_t *passwd,\n               size_t salt_length, const uint8_t *salt,\n               uint8_t *scratch, uint8_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BALLOON_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/base16.h",
    "content": "/* base16.h\n   \n   Hex encoding and decoding, following spki conventions (i.e.\n   allowing whitespace between digits).\n\n   Copyright (C) 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BASE16_H_INCLUDED\n#define NETTLE_BASE16_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define base16_encode_single nettle_base16_encode_single\n#define base16_encode_update nettle_base16_encode_update\n#define base16_decode_init nettle_base16_decode_init\n#define base16_decode_single nettle_base16_decode_single\n#define base16_decode_update nettle_base16_decode_update\n#define base16_decode_final nettle_base16_decode_final\n\n/* Base16 encoding */\n\n/* Maximum length of output for base16_encode_update. */\n#define BASE16_ENCODE_LENGTH(length) ((length) * 2)\n\n/* Encodes a single byte. Always stores two digits in dst[0] and dst[1]. */\nvoid\nbase16_encode_single(char *dst,\n\t\t     uint8_t src);\n\n/* Always stores BASE16_ENCODE_LENGTH(length) digits in dst. */\nvoid\nbase16_encode_update(char *dst,\n\t\t     size_t length,\n\t\t     const uint8_t *src);\n\n\n/* Base16 decoding */\n\n/* Maximum length of output for base16_decode_update. */\n/* We have at most 4 buffered bits, and a total of (length + 1) * 4 bits. */\n#define BASE16_DECODE_LENGTH(length) (((length) + 1) / 2)\n\nstruct base16_decode_ctx\n{\n  unsigned char word; /* Leftover bits */\n  unsigned char bits; /* Number buffered bits */\n};\n\nvoid\nbase16_decode_init(struct base16_decode_ctx *ctx);\n\n/* Decodes a single byte. Returns amount of output (0 or 1), or -1 on\n * errors. */\nint\nbase16_decode_single(struct base16_decode_ctx *ctx,\n\t\t     uint8_t *dst,\n\t\t     char src);\n\n/* Returns 1 on success, 0 on error. DST should point to an area of\n * size at least BASE16_DECODE_LENGTH(length). The amount of data\n * generated is returned in *DST_LENGTH. */\n\nint\nbase16_decode_update(struct base16_decode_ctx *ctx,\n\t\t     size_t *dst_length,\n\t\t     uint8_t *dst,\n\t\t     size_t src_length,\n\t\t     const char *src);\n\n/* Returns 1 on success. */\nint\nbase16_decode_final(struct base16_decode_ctx *ctx);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BASE16_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/base64.h",
    "content": "/* base64.h\n   \n   Base-64 encoding and decoding.\n\n   Copyright (C) 2002 Niels Möller, Dan Egnor\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BASE64_H_INCLUDED\n#define NETTLE_BASE64_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define base64_encode_init nettle_base64_encode_init\n#define base64url_encode_init nettle_base64url_encode_init\n#define base64_encode_single nettle_base64_encode_single\n#define base64_encode_update nettle_base64_encode_update\n#define base64_encode_final nettle_base64_encode_final\n#define base64_encode_raw nettle_base64_encode_raw\n#define base64_encode_group nettle_base64_encode_group\n#define base64_decode_init nettle_base64_decode_init\n#define base64url_decode_init nettle_base64url_decode_init\n#define base64_decode_single nettle_base64_decode_single\n#define base64_decode_update nettle_base64_decode_update\n#define base64_decode_final nettle_base64_decode_final\n\n#define BASE64_BINARY_BLOCK_SIZE 3\n#define BASE64_TEXT_BLOCK_SIZE 4\n\n/* Base64 encoding */\n\n/* Maximum length of output for base64_encode_update. NOTE: Doesn't\n * include any padding that base64_encode_final may add. */\n/* We have at most 4 buffered bits, and a total of (4 + length * 8) bits. */\n#define BASE64_ENCODE_LENGTH(length) (((length) * 8 + 4)/6)\n\n/* Maximum length of output generated by base64_encode_final. */\n#define BASE64_ENCODE_FINAL_LENGTH 3\n\n/* Exact length of output generated by base64_encode_raw, including\n * padding. */\n#define BASE64_ENCODE_RAW_LENGTH(length) ((((length) + 2)/3)*4)\n\nstruct base64_encode_ctx\n{\n  const char *alphabet;    /* Alphabet to use for encoding */\n  unsigned short word;     /* Leftover bits */\n  unsigned char bits;      /* Number of bits, always 0, 2, or 4. */\n};\n\n/* Initialize encoding context for base-64 */\nvoid\nbase64_encode_init(struct base64_encode_ctx *ctx);\n\n/* Initialize encoding context for URL safe alphabet, RFC 4648. */\nvoid\nbase64url_encode_init(struct base64_encode_ctx *ctx);\n\n/* Encodes a single byte. Returns amount of output (always 1 or 2). */\nsize_t\nbase64_encode_single(struct base64_encode_ctx *ctx,\n\t\t     char *dst,\n\t\t     uint8_t src);\n\n/* Returns the number of output characters. DST should point to an\n * area of size at least BASE64_ENCODE_LENGTH(length). */\nsize_t\nbase64_encode_update(struct base64_encode_ctx *ctx,\n\t\t     char *dst,\n\t\t     size_t length,\n\t\t     const uint8_t *src);\n\n/* DST should point to an area of size at least\n * BASE64_ENCODE_FINAL_LENGTH */\nsize_t\nbase64_encode_final(struct base64_encode_ctx *ctx,\n\t\t    char *dst);\n\n/* Lower level functions */\n\n/* Encodes a string in one go, including any padding at the end.\n * Generates exactly BASE64_ENCODE_RAW_LENGTH(length) bytes of output.\n * Supports overlapped operation, if src <= dst. FIXME: Use of overlap\n * is deprecated, if needed there should be a separate public fucntion\n * to do that.*/\nvoid\nbase64_encode_raw(char *dst, size_t length, const uint8_t *src);\n\nvoid\nbase64_encode_group(char *dst, uint32_t group);\n\n\n/* Base64 decoding */\n\n/* Maximum length of output for base64_decode_update. */\n/* We have at most 6 buffered bits, and a total of (length + 1) * 6 bits. */\n#define BASE64_DECODE_LENGTH(length) ((((length) + 1) * 6) / 8)\n\nstruct base64_decode_ctx\n{\n  const signed char *table; /* Decoding table */\n  unsigned short word;      /* Leftover bits */\n  unsigned char bits;       /* Number buffered bits */\n\n  /* Number of padding characters encountered */\n  unsigned char padding;\n};\n\n/* Initialize decoding context for base-64 */\nvoid\nbase64_decode_init(struct base64_decode_ctx *ctx);\n\n/* Initialize encoding context for URL safe alphabet, RFC 4648. */\nvoid\nbase64url_decode_init(struct base64_decode_ctx *ctx);\n\n/* Decodes a single byte. Returns amount of output (0 or 1), or -1 on\n * errors. */\nint\nbase64_decode_single(struct base64_decode_ctx *ctx,\n\t\t     uint8_t *dst,\n\t\t     char src);\n\n/* Returns 1 on success, 0 on error. DST should point to an area of\n * size at least BASE64_DECODE_LENGTH(length). The amount of data\n * generated is returned in *DST_LENGTH. */\nint\nbase64_decode_update(struct base64_decode_ctx *ctx,\n\t\t     size_t *dst_length,\n\t\t     uint8_t *dst,\n\t\t     size_t src_length,\n\t\t     const char *src);\n\n/* Returns 1 on success. */\nint\nbase64_decode_final(struct base64_decode_ctx *ctx);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BASE64_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/bignum.h",
    "content": "/* bignum.h\n\n   Bignum operations that are missing from gmp.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BIGNUM_H_INCLUDED\n#define NETTLE_BIGNUM_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n/* For NETTLE_USE_MINI_GMP */\n#include \"version.h\"\n\n#if NETTLE_USE_MINI_GMP\n# include \"mini-gmp.h\"\n\n# define GMP_NUMB_MASK (~(mp_limb_t) 0)\n\n/* Side-channel silent powm not available in mini-gmp. */\n# define mpz_powm_sec mpz_powm\n#else\n# include <gmp.h>\n#endif\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Size needed for signed encoding, including extra sign byte if\n * necessary. */\nsize_t\nnettle_mpz_sizeinbase_256_s(const mpz_t x);\n\n/* Size needed for unsigned encoding */\nsize_t\nnettle_mpz_sizeinbase_256_u(const mpz_t x);\n\n/* Writes an integer as length octets, using big endian byte order,\n * and two's complement for negative numbers. */\nvoid\nnettle_mpz_get_str_256(size_t length, uint8_t *s, const mpz_t x);\n\n/* Reads a big endian, two's complement, integer. */\nvoid\nnettle_mpz_set_str_256_s(mpz_t x,\n\t\t\t size_t length, const uint8_t *s);\n\nvoid\nnettle_mpz_init_set_str_256_s(mpz_t x,\n\t\t\t      size_t length, const uint8_t *s);\n\n/* Similar, but for unsigned format. These function don't interpret\n * the most significant bit as the sign. */\nvoid\nnettle_mpz_set_str_256_u(mpz_t x,\n\t\t\t size_t length, const uint8_t *s);\n\nvoid\nnettle_mpz_init_set_str_256_u(mpz_t x,\n\t\t\t      size_t length, const uint8_t *s);\n\n/* Returns a uniformly distributed random number 0 <= x < 2^n */\nvoid\nnettle_mpz_random_size(mpz_t x,\n\t\t       void *ctx, nettle_random_func *random,\n\t\t       unsigned bits);\n\n/* Returns a number x, almost uniformly random in the range\n * 0 <= x < n. */\nvoid\nnettle_mpz_random(mpz_t x, \n\t\t  void *ctx, nettle_random_func *random,\n\t\t  const mpz_t n);\n\nvoid\nnettle_random_prime(mpz_t p, unsigned bits, int top_bits_set,\n\t\t    void *ctx, nettle_random_func *random,\n\t\t    void *progress_ctx, nettle_progress_func *progress);\n\n  \n/* sexp parsing */\nstruct sexp_iterator;\n\n/* If LIMIT is non-zero, the number must be at most LIMIT bits.\n * Implies sexp_iterator_next. */\nint\nnettle_mpz_set_sexp(mpz_t x, unsigned limit, struct sexp_iterator *i);\n\n\n/* der parsing */\nstruct asn1_der_iterator;\n\nint\nnettle_asn1_der_get_bignum(struct asn1_der_iterator *iterator,\n\t\t\t   mpz_t x, unsigned max_bits);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BIGNUM_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/blowfish.h",
    "content": "/* blowfish.h\n\n   Blowfish block cipher.\n\n   Copyright (C) 2014 Niels Möller\n   Copyright (C) 1998, 2001 FSF, Ray Dassen, Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BLOWFISH_H_INCLUDED\n#define NETTLE_BLOWFISH_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define blowfish_set_key nettle_blowfish_set_key\n#define blowfish128_set_key nettle_blowfish128_set_key\n#define blowfish_encrypt nettle_blowfish_encrypt\n#define blowfish_decrypt nettle_blowfish_decrypt\n#define blowfish_bcrypt_hash nettle_blowfish_bcrypt_hash\n#define blowfish_bcrypt_verify nettle_blowfish_bcrypt_verify\n\n#define BLOWFISH_BLOCK_SIZE 8\n\n/* Variable key size between 64 and 448 bits. */\n#define BLOWFISH_MIN_KEY_SIZE 8\n#define BLOWFISH_MAX_KEY_SIZE 56\n\n/* Default to 128 bits */\n#define BLOWFISH_KEY_SIZE 16\n\n#define BLOWFISH128_KEY_SIZE 16\n\n#define _BLOWFISH_ROUNDS 16\n\n#define BLOWFISH_BCRYPT_HASH_SIZE (60 + 1) /* Including null-terminator */\n#define BLOWFISH_BCRYPT_BINSALT_SIZE 16    /* Binary string size */\n\nstruct blowfish_ctx\n{\n  uint32_t s[4][256];\n  uint32_t p[_BLOWFISH_ROUNDS+2];\n};\n\n/* Returns 0 for weak keys, otherwise 1. */\nint\nblowfish_set_key(struct blowfish_ctx *ctx,\n                 size_t length, const uint8_t *key);\nint\nblowfish128_set_key(struct blowfish_ctx *ctx, const uint8_t *key);\n\nvoid\nblowfish_encrypt(const struct blowfish_ctx *ctx,\n                 size_t length, uint8_t *dst,\n                 const uint8_t *src);\nvoid\nblowfish_decrypt(const struct blowfish_ctx *ctx,\n                 size_t length, uint8_t *dst,\n                 const uint8_t *src);\n\n/* dst parameter must point to a buffer of minimally\n * BLOWFISH_BCRYPT_HASH_SIZE bytes */\nint\nblowfish_bcrypt_hash(uint8_t *dst,\n                     size_t lenkey, const uint8_t *key,\n                     size_t lenscheme, const uint8_t *scheme,\n\t\t     int log2rounds,\n\t\t     const uint8_t *salt);\nint\nblowfish_bcrypt_verify(size_t lenkey, const uint8_t *key,\n                       size_t lenhashed, const uint8_t *hashed);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BLOWFISH_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/buffer.h",
    "content": "/* buffer.h\n\n   A bare-bones string stream.\n\n   Copyright (C) 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_BUFFER_H_INCLUDED\n#define NETTLE_BUFFER_H_INCLUDED\n\n#include \"realloc.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct nettle_buffer\n{\n  uint8_t *contents;\n  /* Allocated size */\n  size_t alloc;\n\n  void *realloc_ctx;\n  nettle_realloc_func *realloc;\n\n  /* Current size */\n  size_t size;\n};\n\n/* Initializes a buffer that uses plain realloc */\nvoid\nnettle_buffer_init(struct nettle_buffer *buffer);\n\nvoid\nnettle_buffer_init_realloc(struct nettle_buffer *buffer,\n\t\t\t   void *realloc_ctx,\n\t\t\t   nettle_realloc_func *realloc);\n\n/* Initializes a buffer of fix size */\nvoid\nnettle_buffer_init_size(struct nettle_buffer *buffer,\n\t\t\tsize_t length, uint8_t *space);\n\nvoid\nnettle_buffer_clear(struct nettle_buffer *buffer);\n\n/* Resets the buffer, without freeing the buffer space. */\nvoid\nnettle_buffer_reset(struct nettle_buffer *buffer);\n\nint\nnettle_buffer_grow(struct nettle_buffer *buffer,\n\t\t   size_t length);\n\n#define NETTLE_BUFFER_PUTC(buffer, c) \\\n( (((buffer)->size < (buffer)->alloc) || nettle_buffer_grow((buffer), 1)) \\\n  && ((buffer)->contents[(buffer)->size++] = (c), 1) )\n\nint\nnettle_buffer_write(struct nettle_buffer *buffer,\n\t\t    size_t length, const uint8_t *data);\n\n/* Like nettle_buffer_write, but instead of copying data to the\n * buffer, it returns a pointer to the area where the caller can copy\n * the data. The pointer is valid only until the next call that can\n * reallocate the buffer. */\nuint8_t *\nnettle_buffer_space(struct nettle_buffer *buffer,\n\t\t    size_t length);\n\n/* Copy the contents of SRC to the end of DST. */\nint\nnettle_buffer_copy(struct nettle_buffer *dst,\n\t\t   const struct nettle_buffer *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_BUFFER_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/camellia.h",
    "content": "/* camellia.h\n\n   Copyright (C) 2006,2007 NTT\n   (Nippon Telegraph and Telephone Corporation).\n\n   Copyright (C) 2010, 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CAMELLIA_H_INCLUDED\n#define NETTLE_CAMELLIA_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define camellia128_set_encrypt_key nettle_camellia128_set_encrypt_key\n#define camellia128_set_decrypt_key nettle_camellia_set_decrypt_key\n#define camellia128_invert_key nettle_camellia128_invert_key\n#define camellia128_crypt nettle_camellia128_crypt\n\n#define camellia192_set_encrypt_key nettle_camellia192_set_encrypt_key\n#define camellia192_set_decrypt_key nettle_camellia192_set_decrypt_key\n\n#define camellia256_set_encrypt_key nettle_camellia256_set_encrypt_key\n#define camellia256_set_decrypt_key nettle_camellia256_set_decrypt_key\n#define camellia256_invert_key nettle_camellia256_invert_key\n#define camellia256_crypt nettle_camellia256_crypt\n\n\n#define CAMELLIA_BLOCK_SIZE 16\n/* Valid key sizes are 128, 192 or 256 bits (16, 24 or 32 bytes) */\n#define CAMELLIA128_KEY_SIZE 16\n#define CAMELLIA192_KEY_SIZE 24\n#define CAMELLIA256_KEY_SIZE 32\n\n/* For 128-bit keys, there are 18 regular rounds, pre- and\n   post-whitening, and two FL and FLINV rounds, using a total of 26\n   subkeys, each of 64 bit. For 192- and 256-bit keys, there are 6\n   additional regular rounds and one additional FL and FLINV, using a\n   total of 34 subkeys. */\n/* The clever combination of subkeys imply one of the pre- and\n   post-whitening keys is folded with the round keys, so that subkey\n   #1 and the last one (#25 or #33) is not used. The result is that we\n   have only 24 or 32 subkeys at the end of key setup. */\n\n#define _CAMELLIA128_NKEYS 24\n#define _CAMELLIA256_NKEYS 32\n\nstruct camellia128_ctx\n{\n  uint64_t keys[_CAMELLIA128_NKEYS];\n};\n\nvoid\ncamellia128_set_encrypt_key(struct camellia128_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia128_set_decrypt_key(struct camellia128_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia128_invert_key(struct camellia128_ctx *dst,\n\t\t       const struct camellia128_ctx *src);\n\nvoid\ncamellia128_crypt(const struct camellia128_ctx *ctx,\n\t\t  size_t length, uint8_t *dst,\n\t\t  const uint8_t *src);\n\nstruct camellia256_ctx\n{\n  uint64_t keys[_CAMELLIA256_NKEYS];\n};\n\nvoid\ncamellia256_set_encrypt_key(struct camellia256_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia256_set_decrypt_key(struct camellia256_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia256_invert_key(struct camellia256_ctx *dst,\n\t\t       const struct camellia256_ctx *src);\n\nvoid\ncamellia256_crypt(const struct camellia256_ctx *ctx,\n\t\t  size_t length, uint8_t *dst,\n\t\t  const uint8_t *src);\n\n/* camellia192 is the same as camellia256, except for the key\n   schedule. */\n/* Slightly ugly with a #define on a struct tag, since it might cause\n   surprises if also used as a name of a variable. */\n#define camellia192_ctx camellia256_ctx\n\nvoid\ncamellia192_set_encrypt_key(struct camellia256_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\nvoid\ncamellia192_set_decrypt_key(struct camellia256_ctx *ctx,\n\t\t\t    const uint8_t *key);\n\n#define camellia192_invert_key camellia256_invert_key\n#define camellia192_crypt camellia256_crypt\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CAMELLIA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/cast128.h",
    "content": "/* cast128.h\n\n   The CAST-128 block cipher.\n\n   Copyright (C) 2001, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_CAST128_H_INCLUDED\n#define NETTLE_CAST128_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define cast5_set_key nettle_cast5_set_key\n#define cast128_set_key nettle_cast128_set_key\n#define cast128_encrypt nettle_cast128_encrypt\n#define cast128_decrypt nettle_cast128_decrypt\n\n#define CAST128_BLOCK_SIZE 8\n\n/* Variable key size between 40 and 128. */\n#define CAST5_MIN_KEY_SIZE 5\n#define CAST5_MAX_KEY_SIZE 16\n\n#define CAST128_KEY_SIZE 16\n\nstruct cast128_ctx\n{\n  unsigned rounds;  /* Number of rounds to use, 12 or 16 */\n  /* Expanded key, rotations (5 bits only) and 32-bit masks. */\n  unsigned char Kr[16];\n  uint32_t Km[16];\n};\n\n/* Using variable key size. */\nvoid\ncast5_set_key(struct cast128_ctx *ctx,\n\t      size_t length, const uint8_t *key);\n\nvoid\ncast128_set_key(struct cast128_ctx *ctx, const uint8_t *key);\n\nvoid\ncast128_encrypt(const struct cast128_ctx *ctx,\n\t\tsize_t length, uint8_t *dst,\n\t\tconst uint8_t *src);\nvoid\ncast128_decrypt(const struct cast128_ctx *ctx,\n\t\tsize_t length, uint8_t *dst,\n\t\tconst uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CAST128_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/cbc.h",
    "content": "/* cbc.h\n\n   Cipher block chaining mode.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CBC_H_INCLUDED\n#define NETTLE_CBC_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define cbc_encrypt nettle_cbc_encrypt\n#define cbc_decrypt nettle_cbc_decrypt\n#define cbc_aes128_encrypt nettle_cbc_aes128_encrypt\n#define cbc_aes192_encrypt nettle_cbc_aes192_encrypt\n#define cbc_aes256_encrypt nettle_cbc_aes256_encrypt\n\nvoid\ncbc_encrypt(const void *ctx, nettle_cipher_func *f,\n\t    size_t block_size, uint8_t *iv,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\nvoid\ncbc_decrypt(const void *ctx, nettle_cipher_func *f,\n\t    size_t block_size, uint8_t *iv,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\n#define CBC_CTX(type, size) \\\n{ type ctx; uint8_t iv[size]; }\n\n#define CBC_SET_IV(ctx, data) \\\nmemcpy((ctx)->iv, (data), sizeof((ctx)->iv))\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define CBC_ENCRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cbc_encrypt((void *) &(self)->ctx,\t\t\t\\\n\t\t (nettle_cipher_func *) (f),\t\t\\\n\t\t sizeof((self)->iv), (self)->iv,\t\\\n\t\t (length), (dst), (src)))\n\n#define CBC_DECRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cbc_decrypt((void *) &(self)->ctx,\t\t\t\\\n\t\t (nettle_cipher_func *) (f),\t\t\\\n\t\t sizeof((self)->iv), (self)->iv,\t\\\n\t\t (length), (dst), (src)))\n\nvoid\ncbc_aes128_encrypt(const struct aes128_ctx *ctx, uint8_t *iv,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ncbc_aes192_encrypt(const struct aes192_ctx *ctx, uint8_t *iv,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ncbc_aes256_encrypt(const struct aes256_ctx *ctx, uint8_t *iv,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CBC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/ccm.h",
    "content": "/* ccm.h\n\n   Counter with CBC-MAC mode, specified by NIST,\n   http://csrc.nist.gov/publications/nistpubs/800-38C/SP800-38C_updated-July20_2007.pdf\n\n   Copyright (C) 2014 Exegin Technologies Limited\n   Copyright (C) 2014 Owen Kirby\n\n   Contributed to GNU Nettle by Owen Kirby\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* NIST SP800-38C doesn't specify the particular formatting and\n * counter generation algorithm for CCM, but it does include an\n * example algorithm. This example has become the de-factor standard,\n * and has been adopted by both the IETF and IEEE across a wide\n * variety of protocols.\n */\n\n#ifndef NETTLE_CCM_H_INCLUDED\n#define NETTLE_CCM_H_INCLUDED\n\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ccm_set_nonce nettle_ccm_set_nonce\n#define ccm_update nettle_ccm_update\n#define ccm_encrypt nettle_ccm_encrypt\n#define ccm_decrypt nettle_ccm_decrypt\n#define ccm_digest nettle_ccm_digest\n#define ccm_encrypt_message nettle_ccm_encrypt_message\n#define ccm_decrypt_message nettle_ccm_decrypt_message\n\n#define ccm_aes128_set_key nettle_ccm_aes128_set_key\n#define ccm_aes128_set_nonce nettle_ccm_aes128_set_nonce\n#define ccm_aes128_update nettle_ccm_aes128_update\n#define ccm_aes128_encrypt nettle_ccm_aes128_encrypt\n#define ccm_aes128_decrypt nettle_ccm_aes128_decrypt\n#define ccm_aes128_digest nettle_ccm_aes128_digest\n#define ccm_aes128_encrypt_message nettle_ccm_aes128_encrypt_message\n#define ccm_aes128_decrypt_message nettle_ccm_aes128_decrypt_message\n\n#define ccm_aes192_set_key nettle_ccm_aes192_set_key\n#define ccm_aes192_set_nonce nettle_ccm_aes192_set_nonce\n#define ccm_aes192_update nettle_ccm_aes192_update\n#define ccm_aes192_encrypt nettle_ccm_aes192_encrypt\n#define ccm_aes192_decrypt nettle_ccm_aes192_decrypt\n#define ccm_aes192_digest nettle_ccm_aes192_digest\n#define ccm_aes192_encrypt_message nettle_ccm_aes192_encrypt_message\n#define ccm_aes192_decrypt_message nettle_ccm_aes192_decrypt_message\n\n#define ccm_aes256_set_key nettle_ccm_aes256_set_key\n#define ccm_aes256_set_nonce nettle_ccm_aes256_set_nonce\n#define ccm_aes256_update nettle_ccm_aes256_update\n#define ccm_aes256_encrypt nettle_ccm_aes256_encrypt\n#define ccm_aes256_decrypt nettle_ccm_aes256_decrypt\n#define ccm_aes256_digest nettle_ccm_aes256_digest\n#define ccm_aes256_encrypt_message nettle_ccm_aes256_encrypt_message\n#define ccm_aes256_decrypt_message nettle_ccm_aes256_decrypt_message\n\n/* For CCM, the block size of the block cipher shall be 128 bits. */\n#define CCM_BLOCK_SIZE  16\n#define CCM_DIGEST_SIZE 16\n#define CCM_MIN_NONCE_SIZE 7\n#define CCM_MAX_NONCE_SIZE 14\n\n/* Maximum cleartext message size, as a function of the nonce size N.\n   The length field is L octets, with L = 15 - N, and then the maximum\n   size M = 2^{8L} - 1. */\n#define CCM_MAX_MSG_SIZE(N)\t\t\t\\\n  ((sizeof(size_t) + (N) <= 15)\t\t\t\\\n   ? ~(size_t) 0\t\t\t\t\\\n   : ((size_t) 1 << (8*(15 - N))) - 1)\n\n/* Per-message state */\nstruct ccm_ctx {\n  union nettle_block16 ctr;     /* Counter for CTR encryption. */\n  union nettle_block16 tag;     /* CBC-MAC message tag. */\n  /* Length of data processed by the CBC-MAC modulus the block size */\n  unsigned int blength;\n};\n\n/*\n * CCM mode requires the adata and message lengths when building the IV, which\n * prevents streaming processing and it incompatible with the AEAD API.\n */\nvoid\nccm_set_nonce(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t      size_t noncelen, const uint8_t *nonce,\n\t      size_t authlen, size_t msglen, size_t taglen);\n\nvoid\nccm_update(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t    size_t length, const uint8_t *data);\n\nvoid\nccm_encrypt(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_decrypt(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_digest(struct ccm_ctx *ctx, const void *cipher, nettle_cipher_func *f,\n\t   size_t length, uint8_t *digest);\n\n/*\n * All-in-one encryption and decryption API:\n *  tlength = sizeof(digest)\n *  mlength = sizeof(cleartext)\n *  clength = sizeof(ciphertext) = mlength + tlength\n *\n * The ciphertext will contain the encrypted payload with the message digest\n * appended to the end.\n */\nvoid\nccm_encrypt_message(const void *cipher, nettle_cipher_func *f,\n\t\t    size_t nlength, const uint8_t *nonce,\n\t\t    size_t alength, const uint8_t *adata,\n\t\t    size_t tlength,\n\t\t    size_t clength, uint8_t *dst, const uint8_t *src);\n\n/*\n * The decryption function will write the plaintext to dst and parse the digest\n * from the final tlength bytes of the ciphertext. If the digest matched the\n * value computed during decryption then this will return 1, or it will return\n * 0 if the digest was invalid.\n */\nint\nccm_decrypt_message(const void *cipher, nettle_cipher_func *f,\n\t\t    size_t nlength, const uint8_t *nonce,\n\t\t    size_t alength, const uint8_t *adata,\n\t\t    size_t tlength,\n\t\t    size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* CCM Mode with AES-128 */\nstruct ccm_aes128_ctx {\n    struct ccm_ctx      ccm;\n    struct aes128_ctx   cipher;\n};\n\nvoid\nccm_aes128_set_key(struct ccm_aes128_ctx *ctx, const uint8_t *key);\n\nvoid\nccm_aes128_set_nonce(struct ccm_aes128_ctx *ctx,\n\t\t     size_t length, const uint8_t *nonce,\n\t\t     size_t authlen, size_t msglen, size_t taglen);\n\nvoid\nccm_aes128_update (struct ccm_aes128_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nccm_aes128_encrypt(struct ccm_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes128_decrypt(struct ccm_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes128_digest(struct ccm_aes128_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\n/* FIXME: For next API/ABI break: first argument should be const\n   struct aes128_ctx *, and similarly for other ccm_*_message\n   functions below. */\nvoid\nccm_aes128_encrypt_message(struct ccm_aes128_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nccm_aes128_decrypt_message(struct ccm_aes128_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t mlength, uint8_t *dst, const uint8_t *src);\n\nstruct ccm_aes192_ctx {\n    struct ccm_ctx      ccm;\n    struct aes192_ctx   cipher;\n};\n\n/* CCM Mode with AES-192 */\nvoid\nccm_aes192_set_key(struct ccm_aes192_ctx *ctx, const uint8_t *key);\n\nvoid\nccm_aes192_set_nonce(struct ccm_aes192_ctx *ctx,\n\t\t     size_t length, const uint8_t *nonce,\n\t\t     size_t authlen, size_t msglen, size_t taglen);\n\nvoid\nccm_aes192_update(struct ccm_aes192_ctx *ctx,\n\t\t  size_t length, const uint8_t *data);\n\nvoid\nccm_aes192_encrypt(struct ccm_aes192_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes192_decrypt(struct ccm_aes192_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes192_digest(struct ccm_aes192_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\nvoid\nccm_aes192_encrypt_message(struct ccm_aes192_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nccm_aes192_decrypt_message(struct ccm_aes192_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* CCM Mode with AES-256 */\nstruct ccm_aes256_ctx {\n    struct ccm_ctx      ccm;\n    struct aes256_ctx   cipher;\n};\n\nvoid\nccm_aes256_set_key(struct ccm_aes256_ctx *ctx, const uint8_t *key);\n\nvoid\nccm_aes256_set_nonce(struct ccm_aes256_ctx *ctx,\n\t\t     size_t length, const uint8_t *nonce,\n\t\t     size_t authlen, size_t msglen, size_t taglen);\n\nvoid\nccm_aes256_update(struct ccm_aes256_ctx *ctx,\n\t\t  size_t length, const uint8_t *data);\n\nvoid\nccm_aes256_encrypt(struct ccm_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes256_decrypt(struct ccm_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nccm_aes256_digest(struct ccm_aes256_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\nvoid\nccm_aes256_encrypt_message(struct ccm_aes256_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nccm_aes256_decrypt_message(struct ccm_aes256_ctx *ctx,\n\t\t\t   size_t nlength, const uint8_t *nonce,\n\t\t\t   size_t alength, const uint8_t *adata,\n\t\t\t   size_t tlength,\n\t\t\t   size_t mlength, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CCM_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/cfb.h",
    "content": "/* cfb.h\n\n   Cipher feedback mode.\n\n   Copyright (C) 2015, 2017 Dmitry Eremin-Solenikov\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CFB_H_INCLUDED\n#define NETTLE_CFB_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define cfb_encrypt nettle_cfb_encrypt\n#define cfb_decrypt nettle_cfb_decrypt\n\n#define cfb8_encrypt nettle_cfb8_encrypt\n#define cfb8_decrypt nettle_cfb8_decrypt\n\nvoid\ncfb_encrypt(const void *ctx, nettle_cipher_func *f,\n\t    size_t block_size, uint8_t *iv,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\nvoid\ncfb_decrypt(const void *ctx, nettle_cipher_func *f,\n\t    size_t block_size, uint8_t *iv,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\nvoid\ncfb8_encrypt(const void *ctx, nettle_cipher_func *f,\n\t     size_t block_size, uint8_t *iv,\n\t     size_t length, uint8_t *dst,\n\t     const uint8_t *src);\n\nvoid\ncfb8_decrypt(const void *ctx, nettle_cipher_func *f,\n\t     size_t block_size, uint8_t *iv,\n\t     size_t length, uint8_t *dst,\n\t     const uint8_t *src);\n\n\n#define CFB_CTX(type, size) \\\n{ type ctx; uint8_t iv[size]; }\n\n#define CFB_SET_IV(ctx, data) \\\nmemcpy((ctx)->iv, (data), sizeof((ctx)->iv))\n\n#define CFB8_CTX CFB_CTX\n#define CFB8_SET_IV CFB_SET_IV\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define CFB_ENCRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cfb_encrypt((void *) &(self)->ctx,\t\t\t\\\n\t\t (nettle_cipher_func *) (f),\t\t\\\n\t\t sizeof((self)->iv), (self)->iv,\t\\\n\t\t (length), (dst), (src)))\n\n#define CFB_DECRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cfb_decrypt((void *) &(self)->ctx,\t\t\t\\\n\t\t (nettle_cipher_func *) (f),\t\t\\\n\t\t sizeof((self)->iv), (self)->iv,\t\\\n\t\t (length), (dst), (src)))\n\n#define CFB8_ENCRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cfb8_encrypt((void *) &(self)->ctx,\t\t\\\n\t\t  (nettle_cipher_func *) (f),\t\t\\\n\t\t  sizeof((self)->iv), (self)->iv,\t\\\n\t\t  (length), (dst), (src)))\n\n#define CFB8_DECRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t    (uint8_t *) 0, (const uint8_t *) 0))\t\\\n   : cfb8_decrypt((void *) &(self)->ctx,\t\t\\\n\t\t  (nettle_cipher_func *) (f),\t\t\\\n\t\t  sizeof((self)->iv), (self)->iv,\t\\\n\t\t  (length), (dst), (src)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CFB_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/chacha-poly1305.h",
    "content": "/* chacha-poly1305.h\n\n   AEAD mechanism based on chacha and poly1305.\n   See draft-agl-tls-chacha20poly1305-04.\n\n   Copyright (C) 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CHACHA_POLY1305_H_INCLUDED\n#define NETTLE_CHACHA_POLY1305_H_INCLUDED\n\n#include \"chacha.h\"\n#include \"poly1305.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define chacha_poly1305_set_key nettle_chacha_poly1305_set_key\n#define chacha_poly1305_set_nonce nettle_chacha_poly1305_set_nonce\n#define chacha_poly1305_update nettle_chacha_poly1305_update\n#define chacha_poly1305_decrypt nettle_chacha_poly1305_decrypt\n#define chacha_poly1305_encrypt nettle_chacha_poly1305_encrypt\n#define chacha_poly1305_digest nettle_chacha_poly1305_digest\n\n#define CHACHA_POLY1305_BLOCK_SIZE 64\n/* FIXME: Any need for 128-bit variant? */\n#define CHACHA_POLY1305_KEY_SIZE 32\n#define CHACHA_POLY1305_NONCE_SIZE CHACHA_NONCE96_SIZE\n#define CHACHA_POLY1305_DIGEST_SIZE 16\n\nstruct chacha_poly1305_ctx\n{\n  struct chacha_ctx chacha;\n  struct poly1305_ctx poly1305;\n  union nettle_block16 s;\n  uint64_t auth_size;\n  uint64_t data_size;\n  /* poly1305 block */\n  uint8_t block[POLY1305_BLOCK_SIZE];\n  unsigned index;\n};\n\nvoid\nchacha_poly1305_set_key (struct chacha_poly1305_ctx *ctx,\n\t\t\t const uint8_t *key);\nvoid\nchacha_poly1305_set_nonce (struct chacha_poly1305_ctx *ctx,\n\t\t\t   const uint8_t *nonce);\n\nvoid\nchacha_poly1305_update (struct chacha_poly1305_ctx *ctx,\n\t\t\tsize_t length, const uint8_t *data);\n\nvoid\nchacha_poly1305_encrypt (struct chacha_poly1305_ctx *ctx,\n\t\t\t size_t length, uint8_t *dst, const uint8_t *src);\n\t\t\t \nvoid\nchacha_poly1305_decrypt (struct chacha_poly1305_ctx *ctx,\n\t\t\t size_t length, uint8_t *dst, const uint8_t *src);\n\t\t\t \nvoid\nchacha_poly1305_digest (struct chacha_poly1305_ctx *ctx,\n\t\t\tsize_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CHACHA_POLY1305_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/chacha.h",
    "content": "/* chacha.h\n\n   The ChaCha stream cipher.\n\n   Copyright (C) 2013 Joachim Strömbergson\n   Copyright (C) 2012 Simon Josefsson\n   Copyright (C) 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CHACHA_H_INCLUDED\n#define NETTLE_CHACHA_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define chacha_set_key nettle_chacha_set_key\n#define chacha_set_nonce nettle_chacha_set_nonce\n#define chacha_set_nonce96 nettle_chacha_set_nonce96\n#define chacha_set_counter nettle_chacha_set_counter\n#define chacha_set_counter32 nettle_chacha_set_counter32\n#define chacha_crypt nettle_chacha_crypt\n#define chacha_crypt32 nettle_chacha_crypt32\n\n/* Currently, only 256-bit keys are supported. */\n#define CHACHA_KEY_SIZE 32\n#define CHACHA_BLOCK_SIZE 64\n#define CHACHA_NONCE_SIZE 8\n#define CHACHA_NONCE96_SIZE 12\n#define CHACHA_COUNTER_SIZE 8\n#define CHACHA_COUNTER32_SIZE 4\n\n#define _CHACHA_STATE_LENGTH 16\n\nstruct chacha_ctx\n{\n  /* Indices 0-3 holds a constant (SIGMA or TAU).\n     Indices 4-11 holds the key.\n     Indices 12-13 holds the block counter.\n     Indices 14-15 holds the IV:\n\n     This creates the state matrix:\n     C C C C\n     K K K K\n     K K K K\n     B B I I\n  */\n  uint32_t state[_CHACHA_STATE_LENGTH];\n};\n\nvoid\nchacha_set_key(struct chacha_ctx *ctx, const uint8_t *key);\n\nvoid\nchacha_set_nonce(struct chacha_ctx *ctx, const uint8_t *nonce);\n\nvoid\nchacha_set_nonce96(struct chacha_ctx *ctx, const uint8_t *nonce);\n\nvoid\nchacha_set_counter(struct chacha_ctx *ctx, const uint8_t *counter);\n\nvoid\nchacha_set_counter32(struct chacha_ctx *ctx, const uint8_t *counter);\n\nvoid\nchacha_crypt(struct chacha_ctx *ctx, size_t length, \n             uint8_t *dst, const uint8_t *src);\n\nvoid\nchacha_crypt32(struct chacha_ctx *ctx, size_t length,\n\t       uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CHACHA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/cmac.h",
    "content": "/* cmac.h\n\n   CMAC mode, as specified in RFC4493\n\n   Copyright (C) 2017 Red Hat, Inc.\n\n   Contributed by Nikos Mavrogiannopoulos\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CMAC_H_INCLUDED\n#define NETTLE_CMAC_H_INCLUDED\n\n#include \"aes.h\"\n#include \"des.h\"\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define CMAC128_DIGEST_SIZE 16\n#define CMAC64_DIGEST_SIZE 8\n\n#define cmac128_set_key nettle_cmac128_set_key\n#define cmac128_init nettle_cmac128_init\n#define cmac128_update nettle_cmac128_update\n#define cmac128_digest nettle_cmac128_digest\n#define cmac_aes128_set_key nettle_cmac_aes128_set_key\n#define cmac_aes128_update nettle_cmac_aes128_update\n#define cmac_aes128_digest nettle_cmac_aes128_digest\n#define cmac_aes256_set_key nettle_cmac_aes256_set_key\n#define cmac_aes256_update nettle_cmac_aes256_update\n#define cmac_aes256_digest nettle_cmac_aes256_digest\n\n#define cmac64_set_key nettle_cmac64_set_key\n#define cmac64_init nettle_cmac64_init\n#define cmac64_update nettle_cmac64_update\n#define cmac64_digest nettle_cmac64_digest\n#define cmac_des3_set_key nettle_cmac_des3_set_key\n#define cmac_des3_update nettle_cmac_des3_update\n#define cmac_des3_digest nettle_cmac_des3_digest\n\nstruct cmac128_key\n{\n  union nettle_block16 K1;\n  union nettle_block16 K2;\n};\n\nstruct cmac128_ctx\n{\n  /* MAC state */\n  union nettle_block16 X;\n\n  /* Block buffer */\n  union nettle_block16 block;\n  size_t index;\n};\n\nstruct cmac64_key\n{\n  union nettle_block8 K1;\n  union nettle_block8 K2;\n};\n\nstruct cmac64_ctx\n{\n  /* MAC state */\n  union nettle_block8 X;\n\n  /* Block buffer */\n  union nettle_block8 block;\n  size_t index;\n};\n\nvoid\ncmac128_set_key(struct cmac128_key *key, const void *cipher,\n\t\tnettle_cipher_func *encrypt);\n\nvoid\ncmac128_init(struct cmac128_ctx *ctx);\n\nvoid\ncmac128_update(struct cmac128_ctx *ctx, const void *cipher,\n\t       nettle_cipher_func *encrypt,\n\t       size_t msg_len, const uint8_t *msg);\nvoid\ncmac128_digest(struct cmac128_ctx *ctx, const struct cmac128_key *key,\n\t       const void *cipher, nettle_cipher_func *encrypt,\n\t       unsigned length, uint8_t *digest);\n\n\n#define CMAC128_CTX(type) \\\n  { struct cmac128_key key; struct cmac128_ctx ctx; type cipher; }\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define CMAC128_SET_KEY(self, set_key, encrypt, cmac_key)\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    (set_key)(&(self)->cipher, (cmac_key));\t\t\t\\\n    if (0) (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\\\n\t\t     (uint8_t *) 0, (const uint8_t *) 0);\t\\\n    cmac128_set_key(&(self)->key, &(self)->cipher,\t\t\\\n\t\t    (nettle_cipher_func *) (encrypt));\t\t\\\n    cmac128_init(&(self)->ctx);\t\t\t\t\t\\\n  } while (0)\n\n#define CMAC128_UPDATE(self, encrypt, length, src)\t\t\\\n  (0 ? (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\\\n     : cmac128_update(&(self)->ctx, &(self)->cipher,\t\t\\\n\t\t      (nettle_cipher_func *)encrypt,\t\t\\\n\t\t      (length), (src)))\n\n#define CMAC128_DIGEST(self, encrypt, length, digest)\t\t\\\n  (0 ? (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\\\n     : cmac128_digest(&(self)->ctx, &(self)->key,\t\t\\\n\t\t      &(self)->cipher,\t\t\t\t\\\n\t\t      (nettle_cipher_func *) (encrypt),\t\t\\\n\t\t      (length), (digest)))\n\nvoid\ncmac64_set_key(struct cmac64_key *key, const void *cipher,\n\t\tnettle_cipher_func *encrypt);\n\nvoid\ncmac64_init(struct cmac64_ctx *ctx);\n\nvoid\ncmac64_update(struct cmac64_ctx *ctx, const void *cipher,\n\t       nettle_cipher_func *encrypt,\n\t       size_t msg_len, const uint8_t *msg);\n\nvoid\ncmac64_digest(struct cmac64_ctx *ctx, const struct cmac64_key *key,\n\t       const void *cipher, nettle_cipher_func *encrypt,\n\t       unsigned length, uint8_t *digest);\n\n\n#define CMAC64_CTX(type) \\\n  { struct cmac64_key key; struct cmac64_ctx ctx; type cipher; }\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define CMAC64_SET_KEY(self, set_key, encrypt, cmac_key)\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    (set_key)(&(self)->cipher, (cmac_key));\t\t\t\\\n    if (0) (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\\\n\t\t     (uint8_t *) 0, (const uint8_t *) 0);\t\\\n    cmac64_set_key(&(self)->key, &(self)->cipher,\t\t\\\n\t\t    (nettle_cipher_func *) (encrypt));\t\t\\\n    cmac64_init(&(self)->ctx);\t\t\t\t\t\\\n  } while (0)\n\n#define CMAC64_UPDATE(self, encrypt, length, src)\t\t\\\n  (0 ? (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\\\n     : cmac64_update(&(self)->ctx, &(self)->cipher,\t\t\\\n\t\t      (nettle_cipher_func *)encrypt,\t\t\\\n\t\t      (length), (src)))\n\n#define CMAC64_DIGEST(self, encrypt, length, digest)\t\t\\\n  (0 ? (encrypt)(&(self)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\\\n     : cmac64_digest(&(self)->ctx, &(self)->key,\t\t\\\n\t\t      &(self)->cipher,\t\t\t\t\\\n\t\t      (nettle_cipher_func *) (encrypt),\t\t\\\n\t\t      (length), (digest)))\n\nstruct cmac_aes128_ctx CMAC128_CTX(struct aes128_ctx);\n\nvoid\ncmac_aes128_set_key(struct cmac_aes128_ctx *ctx, const uint8_t *key);\n\nvoid\ncmac_aes128_update(struct cmac_aes128_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\ncmac_aes128_digest(struct cmac_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\nstruct cmac_aes256_ctx CMAC128_CTX(struct aes256_ctx);\n\nvoid\ncmac_aes256_set_key(struct cmac_aes256_ctx *ctx, const uint8_t *key);\n\nvoid\ncmac_aes256_update(struct cmac_aes256_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\ncmac_aes256_digest(struct cmac_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\nstruct cmac_des3_ctx CMAC64_CTX(struct des3_ctx);\n\nvoid\ncmac_des3_set_key(struct cmac_des3_ctx *ctx, const uint8_t *key);\n\nvoid\ncmac_des3_update(struct cmac_des3_ctx *ctx,\n\t\t size_t length, const uint8_t *data);\n\nvoid\ncmac_des3_digest(struct cmac_des3_ctx *ctx,\n\t\t size_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* CMAC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/ctr.h",
    "content": "/* ctr.h\n\n   Counter mode, using an network byte order incremented counter,\n   matching the testcases of NIST 800-38A.\n\n   Copyright (C) 2005 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CTR_H_INCLUDED\n#define NETTLE_CTR_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ctr_crypt nettle_ctr_crypt\n\nvoid\nctr_crypt(const void *ctx, nettle_cipher_func *f,\n\t  size_t block_size, uint8_t *ctr,\n\t  size_t length, uint8_t *dst,\n\t  const uint8_t *src);\n\n#define CTR_CTX(type, size) \\\n{ type ctx; uint8_t ctr[size]; }\n\n#define CTR_SET_COUNTER(ctx, data) \\\nmemcpy((ctx)->ctr, (data), sizeof((ctx)->ctr))\n\n#define CTR_CRYPT(self, f, length, dst, src)\t\t\\\n  (0 ? ((f)(&(self)->ctx, ~(size_t) 0,\t\t\t\\\n\t  (uint8_t *) 0, (const uint8_t *) 0))\t\t\\\n   : ctr_crypt((void *) &(self)->ctx,\t\t\t\\\n\t       (nettle_cipher_func *) (f),\t\t\\\n\t       sizeof((self)->ctr), (self)->ctr,\t\\\n\t       (length), (dst), (src)))\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CTR_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/curve25519.h",
    "content": "/* curve25519.h\n\n   Copyright (C) 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CURVE25519_H\n#define NETTLE_CURVE25519_H\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define curve25519_mul_g nettle_curve25519_mul_g\n#define curve25519_mul nettle_curve25519_mul\n\n#define CURVE25519_SIZE 32\n\n/* Indicates that curve25519_mul conforms to RFC 7748. */\n#define NETTLE_CURVE25519_RFC7748 1\n\nvoid\ncurve25519_mul_g (uint8_t *q, const uint8_t *n);\n\nvoid\ncurve25519_mul (uint8_t *q, const uint8_t *n, const uint8_t *p);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CURVE25519_H */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/curve448.h",
    "content": "/* curve448.h\n\n   Copyright (C) 2017 Daiki Ueno\n   Copyright (C) 2017 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_CURVE448_H\n#define NETTLE_CURVE448_H\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define curve448_mul_g nettle_curve448_mul_g\n#define curve448_mul nettle_curve448_mul\n\n#define CURVE448_SIZE 56\n\nvoid\ncurve448_mul_g (uint8_t *q, const uint8_t *n);\n\nvoid\ncurve448_mul (uint8_t *q, const uint8_t *n, const uint8_t *p);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_CURVE448_H */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/des.h",
    "content": "/* des.h\n\n   The des block cipher. And triple des.\n\n   Copyright (C) 1992 Dana L. How\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/*\n *\tdes - fast & portable DES encryption & decryption.\n *\tCopyright (C) 1992  Dana L. How\n *\tPlease see the file `../lib/descore.README' for the complete copyright\n *\tnotice.\n *\n * Slightly edited by Niels Möller, 1997\n */\n\n#ifndef NETTLE_DES_H_INCLUDED\n#define NETTLE_DES_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define des_set_key nettle_des_set_key\n#define des_encrypt nettle_des_encrypt\n#define des_decrypt nettle_des_decrypt\n#define des_check_parity nettle_des_check_parity\n#define des_fix_parity nettle_des_fix_parity\n#define des3_set_key nettle_des3_set_key\n#define des3_encrypt nettle_des3_encrypt\n#define des3_decrypt nettle_des3_decrypt\n\n#define DES_KEY_SIZE 8\n#define DES_BLOCK_SIZE 8\n\n/* Expanded key length */\n#define _DES_KEY_LENGTH 32\n\nstruct des_ctx\n{\n  uint32_t key[_DES_KEY_LENGTH];\n};\n\n/* Returns 1 for good keys and 0 for weak keys. */\nint\ndes_set_key(struct des_ctx *ctx, const uint8_t *key);\n\nvoid\ndes_encrypt(const struct des_ctx *ctx,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\nvoid\ndes_decrypt(const struct des_ctx *ctx,\n\t    size_t length, uint8_t *dst,\n\t    const uint8_t *src);\n\nint\ndes_check_parity(size_t length, const uint8_t *key);\n\nvoid\ndes_fix_parity(size_t length, uint8_t *dst,\n\t       const uint8_t *src);\n\n#define DES3_KEY_SIZE 24\n#define DES3_BLOCK_SIZE DES_BLOCK_SIZE\n\nstruct des3_ctx\n{\n  struct des_ctx des[3];\n};\n\n\n/* Returns 1 for good keys and 0 for weak keys. */\nint\ndes3_set_key(struct des3_ctx *ctx, const uint8_t *key);\n\nvoid\ndes3_encrypt(const struct des3_ctx *ctx,\n\t     size_t length, uint8_t *dst,\n\t     const uint8_t *src);\nvoid\ndes3_decrypt(const struct des3_ctx *ctx,\n\t     size_t length, uint8_t *dst,\n\t     const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_DES_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/dsa-compat.h",
    "content": "/* dsa-compat.h\n\n   Old DSA publickey interface.\n\n   Copyright (C) 2002, 2013, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_DSA_COMPAT_H_INCLUDED\n#define NETTLE_DSA_COMPAT_H_INCLUDED\n\n#include \"dsa.h\"\n\n#include \"sha1.h\"\n#include \"sha2.h\"\n\n/* Name mangling */\n#define dsa_public_key_init nettle_dsa_public_key_init\n#define dsa_public_key_clear nettle_dsa_public_key_clear\n#define dsa_private_key_init nettle_dsa_private_key_init\n#define dsa_private_key_clear nettle_dsa_private_key_clear\n#define dsa_sha1_sign nettle_dsa_sha1_sign\n#define dsa_sha1_verify nettle_dsa_sha1_verify\n#define dsa_sha256_sign nettle_dsa_sha256_sign\n#define dsa_sha256_verify nettle_dsa_sha256_verify\n#define dsa_sha1_sign_digest nettle_dsa_sha1_sign_digest\n#define dsa_sha1_verify_digest nettle_dsa_sha1_verify_digest\n#define dsa_sha256_sign_digest nettle_dsa_sha256_sign_digest\n#define dsa_sha256_verify_digest nettle_dsa_sha256_verify_digest\n#define dsa_compat_generate_keypair nettle_dsa_compat_generate_keypair\n\n/* Switch meaning of dsa_generate_keypair */\n#undef dsa_generate_keypair\n#define dsa_generate_keypair nettle_dsa_compat_generate_keypair\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct dsa_public_key\n{\n  /* Same as struct dsa_params, but can't use that struct here without\n     breaking backwards compatibility. Layout must be identical, since\n     this is cast to a struct dsa_param pointer for calling _dsa_sign\n     and _dsa_verify */\n  mpz_t p;\n  mpz_t q;\n  mpz_t g;\n\n  /* Public value */\n  mpz_t y;\n};\n\nstruct dsa_private_key\n{\n  /* Unlike an rsa public key, private key operations will need both\n   * the private and the public information. */\n  mpz_t x;\n};\n\n/* Signing a message works as follows:\n *\n * Store the private key in a dsa_private_key struct.\n *\n * Initialize a hashing context, by callling\n *   sha1_init\n *\n * Hash the message by calling\n *   sha1_update\n *\n * Create the signature by calling\n *   dsa_sha1_sign\n *\n * The signature is represented as a struct dsa_signature. This call also\n * resets the hashing context.\n *\n * When done with the key and signature, don't forget to call\n * dsa_signature_clear.\n */\n\n/* Calls mpz_init to initialize bignum storage. */\nvoid\ndsa_public_key_init(struct dsa_public_key *key);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\ndsa_public_key_clear(struct dsa_public_key *key);\n\n\n/* Calls mpz_init to initialize bignum storage. */\nvoid\ndsa_private_key_init(struct dsa_private_key *key);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\ndsa_private_key_clear(struct dsa_private_key *key);\n\nint\ndsa_sha1_sign(const struct dsa_public_key *pub,\n\t      const struct dsa_private_key *key,\n\t      void *random_ctx, nettle_random_func *random,\n\t      struct sha1_ctx *hash,\n\t      struct dsa_signature *signature);\n\nint\ndsa_sha256_sign(const struct dsa_public_key *pub,\n\t\tconst struct dsa_private_key *key,\n\t\tvoid *random_ctx, nettle_random_func *random,\n\t\tstruct sha256_ctx *hash,\n\t\tstruct dsa_signature *signature);\n\nint\ndsa_sha1_verify(const struct dsa_public_key *key,\n\t\tstruct sha1_ctx *hash,\n\t\tconst struct dsa_signature *signature);\n\nint\ndsa_sha256_verify(const struct dsa_public_key *key,\n\t\t  struct sha256_ctx *hash,\n\t\t  const struct dsa_signature *signature);\n\nint\ndsa_sha1_sign_digest(const struct dsa_public_key *pub,\n\t\t     const struct dsa_private_key *key,\n\t\t     void *random_ctx, nettle_random_func *random,\n\t\t     const uint8_t *digest,\n\t\t     struct dsa_signature *signature);\nint\ndsa_sha256_sign_digest(const struct dsa_public_key *pub,\n\t\t       const struct dsa_private_key *key,\n\t\t       void *random_ctx, nettle_random_func *random,\n\t\t       const uint8_t *digest,\n\t\t       struct dsa_signature *signature);\n\nint\ndsa_sha1_verify_digest(const struct dsa_public_key *key,\n\t\t       const uint8_t *digest,\n\t\t       const struct dsa_signature *signature);\n\nint\ndsa_sha256_verify_digest(const struct dsa_public_key *key,\n\t\t\t const uint8_t *digest,\n\t\t\t const struct dsa_signature *signature);\n\n/* Key generation */\nint\ndsa_generate_keypair(struct dsa_public_key *pub,\n\t\t     struct dsa_private_key *key,\n\n\t\t     void *random_ctx, nettle_random_func *random,\n\t\t     void *progress_ctx, nettle_progress_func *progress,\n\t\t     unsigned p_bits, unsigned q_bits);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_DSA_COMPAT_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/dsa.h",
    "content": "/* dsa.h\n\n   The DSA publickey algorithm.\n\n   Copyright (C) 2002, 2013, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_DSA_H_INCLUDED\n#define NETTLE_DSA_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define dsa_params_init nettle_dsa_params_init\n#define dsa_params_clear nettle_dsa_params_clear\n#define dsa_signature_init nettle_dsa_signature_init\n#define dsa_signature_clear nettle_dsa_signature_clear\n#define dsa_sign nettle_dsa_sign\n#define dsa_verify nettle_dsa_verify\n#define dsa_generate_params nettle_dsa_generate_params\n#define dsa_generate_keypair nettle_dsa_generate_keypair\n#define dsa_signature_from_sexp nettle_dsa_signature_from_sexp\n#define dsa_keypair_to_sexp nettle_dsa_keypair_to_sexp\n#define dsa_keypair_from_sexp_alist nettle_dsa_keypair_from_sexp_alist\n#define dsa_sha1_keypair_from_sexp nettle_dsa_sha1_keypair_from_sexp\n#define dsa_sha256_keypair_from_sexp nettle_dsa_sha256_keypair_from_sexp\n#define dsa_params_from_der_iterator nettle_dsa_params_from_der_iterator\n#define dsa_public_key_from_der_iterator nettle_dsa_public_key_from_der_iterator\n#define dsa_openssl_private_key_from_der_iterator nettle_dsa_openssl_private_key_from_der_iterator \n#define dsa_openssl_private_key_from_der nettle_openssl_provate_key_from_der\n\n/* For FIPS approved parameters */\n#define DSA_SHA1_MIN_P_BITS 512\n#define DSA_SHA1_Q_OCTETS 20\n#define DSA_SHA1_Q_BITS 160\n\n#define DSA_SHA256_MIN_P_BITS 1024\n#define DSA_SHA256_Q_OCTETS 32\n#define DSA_SHA256_Q_BITS 256\n\nstruct dsa_params\n{  \n  /* Modulo */\n  mpz_t p;\n\n  /* Group order */\n  mpz_t q;\n\n  /* Generator */\n  mpz_t g;\n};\n\nvoid\ndsa_params_init (struct dsa_params *params);\n\nvoid\ndsa_params_clear (struct dsa_params *params);\n\nstruct dsa_signature\n{\n  mpz_t r;\n  mpz_t s;\n};\n\n/* Calls mpz_init to initialize bignum storage. */\nvoid\ndsa_signature_init(struct dsa_signature *signature);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\ndsa_signature_clear(struct dsa_signature *signature);\n\nint\ndsa_sign(const struct dsa_params *params,\n\t const mpz_t x,\n\t void *random_ctx, nettle_random_func *random,\n\t size_t digest_size,\n\t const uint8_t *digest,\n\t struct dsa_signature *signature);\n\nint\ndsa_verify(const struct dsa_params *params,\n\t   const mpz_t y,\n\t   size_t digest_size,\n\t   const uint8_t *digest,\n\t   const struct dsa_signature *signature);\n\n\n/* Key generation */\n\nint\ndsa_generate_params(struct dsa_params *params,\n\t\t    void *random_ctx, nettle_random_func *random,\n\t\t    void *progress_ctx, nettle_progress_func *progress,\n\t\t    unsigned p_bits, unsigned q_bits);\n\nvoid\ndsa_generate_keypair (const struct dsa_params *params,\n\t\t      mpz_t pub, mpz_t key,\n\t\t      void *random_ctx, nettle_random_func *random);\n\n/* Keys in sexp form. */\n\nstruct nettle_buffer;\n\n/* Generates a public-key expression if PRIV is NULL .*/\nint\ndsa_keypair_to_sexp(struct nettle_buffer *buffer,\n\t\t    const char *algorithm_name, /* NULL means \"dsa\" */\n\t\t    const struct dsa_params *params,\n\t\t    const mpz_t pub,\n\t\t    const mpz_t priv);\n\nstruct sexp_iterator;\n\nint\ndsa_signature_from_sexp(struct dsa_signature *rs,\n\t\t\tstruct sexp_iterator *i,\n\t\t\tunsigned q_bits);\n\nint\ndsa_keypair_from_sexp_alist(struct dsa_params *params,\n\t\t\t    mpz_t pub,\n\t\t\t    mpz_t priv,\n\t\t\t    unsigned p_max_bits,\n\t\t\t    unsigned q_bits,\n\t\t\t    struct sexp_iterator *i);\n\n/* If PRIV is NULL, expect a public-key expression. If PUB is NULL,\n * expect a private key expression and ignore the parts not needed for\n * the public key. */\n/* Keys must be initialized before calling this function, as usual. */\nint\ndsa_sha1_keypair_from_sexp(struct dsa_params *params,\n\t\t\t   mpz_t pub,\n\t\t\t   mpz_t priv,\n\t\t\t   unsigned p_max_bits,\n\t\t\t   size_t length, const uint8_t *expr);\n\nint\ndsa_sha256_keypair_from_sexp(struct dsa_params *params,\n\t\t\t     mpz_t pub,\n\t\t\t     mpz_t priv,\n\t\t\t     unsigned p_max_bits,\n\t\t\t     size_t length, const uint8_t *expr);\n\n/* Keys in X.509 andd OpenSSL format. */\nstruct asn1_der_iterator;\n\nint\ndsa_params_from_der_iterator(struct dsa_params *params,\n\t\t\t     unsigned max_bits, unsigned q_bits,\n\t\t\t     struct asn1_der_iterator *i);\n\nint\ndsa_public_key_from_der_iterator(const struct dsa_params *params,\n\t\t\t\t mpz_t pub,\n\t\t\t\t struct asn1_der_iterator *i);\n\nint\ndsa_openssl_private_key_from_der_iterator(struct dsa_params *params,\n\t\t\t\t\t  mpz_t pub,\n\t\t\t\t\t  mpz_t priv,\n\t\t\t\t\t  unsigned p_max_bits,\n\t\t\t\t\t  struct asn1_der_iterator *i);\n\nint\ndsa_openssl_private_key_from_der(struct dsa_params *params,\n\t\t\t\t mpz_t pub,\n\t\t\t\t mpz_t priv,\n\t\t\t\t unsigned p_max_bits,\n\t\t\t\t size_t length, const uint8_t *data);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_DSA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/eax.h",
    "content": "/* eax.h\n\n   EAX mode, see http://www.cs.ucdavis.edu/~rogaway/papers/eax.pdf\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_EAX_H_INCLUDED\n#define NETTLE_EAX_H_INCLUDED\n\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define eax_set_key nettle_eax_set_key\n#define eax_set_nonce nettle_eax_set_nonce\n#define eax_update nettle_eax_update\n#define eax_encrypt nettle_eax_encrypt\n#define eax_decrypt nettle_eax_decrypt\n#define eax_digest nettle_eax_digest\n\n#define eax_aes128_set_key nettle_eax_aes128_set_key\n#define eax_aes128_set_nonce nettle_eax_aes128_set_nonce\n#define eax_aes128_update nettle_eax_aes128_update\n#define eax_aes128_encrypt nettle_eax_aes128_encrypt\n#define eax_aes128_decrypt nettle_eax_aes128_decrypt\n#define eax_aes128_digest nettle_eax_aes128_digest\n\n/* Restricted to block ciphers with 128 bit block size. FIXME: Reflect\n   this in naming? */\n\n#define EAX_BLOCK_SIZE 16\n#define EAX_DIGEST_SIZE 16\n/* FIXME: Reasonable default? */\n#define EAX_IV_SIZE 16\n\n/* Values independent of message and nonce */\nstruct eax_key\n{\n  union nettle_block16 pad_block;\n  union nettle_block16 pad_partial;\n};\n\nstruct eax_ctx\n{\n  union nettle_block16 omac_nonce;\n  union nettle_block16 omac_data;\n  union nettle_block16 omac_message;\n  union nettle_block16 ctr;\n};\n\nvoid\neax_set_key (struct eax_key *key, const void *cipher, nettle_cipher_func *f);\n\nvoid\neax_set_nonce (struct eax_ctx *eax, const struct eax_key *key,\n\t       const void *cipher, nettle_cipher_func *f,\n\t       size_t nonce_length, const uint8_t *nonce);\n\nvoid\neax_update (struct eax_ctx *eax, const struct eax_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t data_length, const uint8_t *data);\n\nvoid\neax_encrypt (struct eax_ctx *eax, const struct eax_key *key,\n\t     const void *cipher, nettle_cipher_func *f,\n\t     size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\neax_decrypt (struct eax_ctx *eax, const struct eax_key *key,\n\t     const void *cipher, nettle_cipher_func *f,\n\t     size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\neax_digest (struct eax_ctx *eax, const struct eax_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *digest);\n\n/* Put the cipher last, to get cipher-independent offsets for the EAX\n * state. */\n#define EAX_CTX(type) \\\n  { struct eax_key key; struct eax_ctx eax; type cipher; }\n\n#define EAX_SET_KEY(ctx, set_key, encrypt, data)\t\t\t\\\n  do {\t\t\t\t\t\t\t\t\t\\\n    (set_key)(&(ctx)->cipher, (data));\t\t\t\t\t\\\n    if (0) (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\\\n\t\t      (uint8_t *) 0, (const uint8_t *) 0);\t\t\\\n    eax_set_key (&(ctx)->key, &(ctx)->cipher, (nettle_cipher_func *) encrypt); \\\n  } while (0)\n\n#define EAX_SET_NONCE(ctx, encrypt, length, nonce)\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_set_nonce (&(ctx)->eax, &(ctx)->key,\t\t\t\\\n\t\t    &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t    (length), (nonce)))\n\n#define EAX_UPDATE(ctx, encrypt, length, data)\t\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_update (&(ctx)->eax, &(ctx)->key,\t\t\t\t\\\n\t\t &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t (length), (data)))\n\n#define EAX_ENCRYPT(ctx, encrypt, length, dst, src)\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_encrypt (&(ctx)->eax, &(ctx)->key,\t\t\t\t\\\n\t\t &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t  (length), (dst), (src)))\n\n#define EAX_DECRYPT(ctx, encrypt, length, dst, src)\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_decrypt (&(ctx)->eax, &(ctx)->key,\t\t\t\t\\\n\t\t &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t  (length), (dst), (src)))\n\n#define EAX_DIGEST(ctx, encrypt, length, digest)\t\t\t\\\n  (0 ? (encrypt) (&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t  (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n   : eax_digest (&(ctx)->eax, &(ctx)->key,\t\t\t\t\\\n\t\t &(ctx)->cipher, (nettle_cipher_func *) (encrypt),\t\\\n\t\t (length), (digest)))\n\nstruct eax_aes128_ctx EAX_CTX(struct aes128_ctx);\n\nvoid\neax_aes128_set_key(struct eax_aes128_ctx *ctx, const uint8_t *key);\n\nvoid\neax_aes128_set_nonce(struct eax_aes128_ctx *ctx,\n\t\t     size_t length, const uint8_t *iv);\n\nvoid\neax_aes128_update(struct eax_aes128_ctx *ctx,\n\t\t  size_t length, const uint8_t *data);\n\nvoid\neax_aes128_encrypt(struct eax_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\neax_aes128_decrypt(struct eax_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\neax_aes128_digest(struct eax_aes128_ctx *ctx, size_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_EAX_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/ecc-curve.h",
    "content": "/* ecc-curve.h\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */\n\n#ifndef NETTLE_ECC_CURVE_H_INCLUDED\n#define NETTLE_ECC_CURVE_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* The contents of this struct is internal. */\nstruct ecc_curve;\n\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_gost_gc256b(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_gost_gc512a(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_192r1(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_224r1(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_256r1(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_384r1(void);\nconst struct ecc_curve * _NETTLE_ATTRIBUTE_PURE nettle_get_secp_521r1(void);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ECC_CURVE_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/ecc.h",
    "content": "/* ecc.h\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */\n\n#ifndef NETTLE_ECC_H_INCLUDED\n#define NETTLE_ECC_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ecc_point_init nettle_ecc_point_init\n#define ecc_point_clear nettle_ecc_point_clear\n#define ecc_point_set nettle_ecc_point_set\n#define ecc_point_get nettle_ecc_point_get\n#define ecc_point_mul nettle_ecc_point_mul\n#define ecc_point_mul_g nettle_ecc_point_mul_g\n#define ecc_scalar_init nettle_ecc_scalar_init\n#define ecc_scalar_clear nettle_ecc_scalar_clear\n#define ecc_scalar_set nettle_ecc_scalar_set\n#define ecc_scalar_get nettle_ecc_scalar_get\n#define ecc_scalar_random nettle_ecc_scalar_random\n#define ecc_point_mul nettle_ecc_point_mul\n#define ecc_bit_size nettle_ecc_bit_size\n#define ecc_size nettle_ecc_size\n#define ecc_size_a nettle_ecc_size_a\n#define ecc_size_j nettle_ecc_size_j\n\nstruct ecc_curve;\n\n/* High level interface, for ECDSA, DH, etc */\n\n/* Represents a point on the ECC curve */\nstruct ecc_point\n{\n  const struct ecc_curve *ecc;\n  /* Allocated using the same allocation function as GMP. */\n  mp_limb_t *p;\n};\n\n/* Represents a non-zero scalar, an element of Z_q^*, where q is the\n   group order of the curve. */\nstruct ecc_scalar\n{\n  const struct ecc_curve *ecc;\n  /* Allocated using the same allocation function as GMP. */\n  mp_limb_t *p;\n};\n\nvoid\necc_point_init (struct ecc_point *p, const struct ecc_curve *ecc);\nvoid\necc_point_clear (struct ecc_point *p);\n\n/* Fails and returns zero if the point is not on the curve. */\nint\necc_point_set (struct ecc_point *p, const mpz_t x, const mpz_t y);\nvoid\necc_point_get (const struct ecc_point *p, mpz_t x, mpz_t y);\n\nvoid\necc_scalar_init (struct ecc_scalar *s, const struct ecc_curve *ecc);\nvoid\necc_scalar_clear (struct ecc_scalar *s);\n\n/* Fails and returns zero if the scalar is not in the proper range. */\nint\necc_scalar_set (struct ecc_scalar *s, const mpz_t z);\nvoid\necc_scalar_get (const struct ecc_scalar *s, mpz_t z);\n/* Generates a random scalar, suitable as an ECDSA private key or a\n   ECDH exponent. */\nvoid\necc_scalar_random (struct ecc_scalar *s,\n\t\t   void *random_ctx, nettle_random_func *random);\n\n/* Computes r = n p */\nvoid\necc_point_mul (struct ecc_point *r, const struct ecc_scalar *n,\n\t       const struct ecc_point *p);\n\n/* Computes r = n g */\nvoid\necc_point_mul_g (struct ecc_point *r, const struct ecc_scalar *n);\n\n\f\n/* Low-level interface */\n  \n/* Points on a curve are represented as arrays of mp_limb_t, with\n   curve-specific representation. For the secp curves, we use Jacobian\n   coordinates (possibly in Montgomery form for mod multiplication).\n   For curve25519 we use homogeneous coordinates on an equivalent\n   Edwards curve. The suffix \"_h\" denotes this internal\n   representation.\n   \n   Since we use additive notation for the groups, the infinity point\n   on the curve is denoted 0. The infinity point can be represented\n   with x = y = 0 in affine coordinates, and Z = 0 in Jacobian\n   coordinates. However, note that most of the ECC functions do *not*\n   support infinity as an input or output.\n*/\n\n/* Returns the bit size of a single coordinate (and of the prime p). */\nunsigned\necc_bit_size (const struct ecc_curve *ecc);\n\n/* Returns the size of a single coordinate. */\nmp_size_t\necc_size (const struct ecc_curve *ecc);\n\n/* Size of a point, using affine coordinates x, y. */\nmp_size_t\necc_size_a (const struct ecc_curve *ecc);\n\n/* Size of a point, using jacobian coordinates X, Y and Z. */\nmp_size_t\necc_size_j (const struct ecc_curve *ecc);\n\n/* FIXME: Define a generic ecc_dup, ecc_add, for any type of curve. Do\n   they need to handle infinity points? */\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ECC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/ecdsa.h",
    "content": "/* ecdsa.h\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Development of Nettle's ECC support was funded by the .SE Internet Fund. */\n\n#ifndef NETTLE_ECDSA_H_INCLUDED\n#define NETTLE_ECDSA_H_INCLUDED\n\n#include \"ecc.h\"\n#include \"dsa.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ecdsa_sign nettle_ecdsa_sign\n#define ecdsa_verify nettle_ecdsa_verify\n#define ecdsa_generate_keypair nettle_ecdsa_generate_keypair\n#define ecc_ecdsa_sign nettle_ecc_ecdsa_sign\n#define ecc_ecdsa_sign_itch nettle_ecc_ecdsa_sign_itch\n#define ecc_ecdsa_verify nettle_ecc_ecdsa_verify\n#define ecc_ecdsa_verify_itch nettle_ecc_ecdsa_verify_itch\n\n/* High level ECDSA functions.\n *\n * A public key is represented as a struct ecc_point, and a private\n * key as a struct ecc_scalar. */\nvoid\necdsa_sign (const struct ecc_scalar *key,\n\t    void *random_ctx, nettle_random_func *random,\n\t    size_t digest_length,\n\t    const uint8_t *digest,\n\t    struct dsa_signature *signature);\n\nint\necdsa_verify (const struct ecc_point *pub,\n\t      size_t length, const uint8_t *digest,\n\t      const struct dsa_signature *signature);\n\nvoid\necdsa_generate_keypair (struct ecc_point *pub,\n\t\t\tstruct ecc_scalar *key,\n\t\t\tvoid *random_ctx, nettle_random_func *random);\n\n/* Low-level ECDSA functions. */\nmp_size_t\necc_ecdsa_sign_itch (const struct ecc_curve *ecc);\n\nvoid\necc_ecdsa_sign (const struct ecc_curve *ecc,\n\t\tconst mp_limb_t *zp,\n\t\t/* Random nonce, must be invertible mod ecc group\n\t\t   order. */\n\t\tconst mp_limb_t *kp,\n\t\tsize_t length, const uint8_t *digest,\n\t\tmp_limb_t *rp, mp_limb_t *sp,\n\t\tmp_limb_t *scratch);\n\nmp_size_t\necc_ecdsa_verify_itch (const struct ecc_curve *ecc);\n\nint\necc_ecdsa_verify (const struct ecc_curve *ecc,\n\t\t  const mp_limb_t *pp, /* Public key */\n\t\t  size_t length, const uint8_t *digest,\n\t\t  const mp_limb_t *rp, const mp_limb_t *sp,\n\t\t  mp_limb_t *scratch);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_ECDSA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/eddsa.h",
    "content": "/* eddsa.h\n\n   Copyright (C) 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_EDDSA_H\n#define NETTLE_EDDSA_H\n\n#include \"nettle-types.h\"\n\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ed25519_sha512_set_private_key nettle_ed25519_sha512_set_private_key\n#define ed25519_sha512_public_key nettle_ed25519_sha512_public_key\n#define ed25519_sha512_sign nettle_ed25519_sha512_sign\n#define ed25519_sha512_verify nettle_ed25519_sha512_verify\n#define ed448_shake256_public_key nettle_ed448_shake256_public_key\n#define ed448_shake256_sign nettle_ed448_shake256_sign\n#define ed448_shake256_verify nettle_ed448_shake256_verify\n\n#define ED25519_KEY_SIZE 32\n#define ED25519_SIGNATURE_SIZE 64\n\nvoid\ned25519_sha512_public_key (uint8_t *pub, const uint8_t *priv);\n\nvoid\ned25519_sha512_sign (const uint8_t *pub,\n\t\t     const uint8_t *priv,\t\t     \n\t\t     size_t length, const uint8_t *msg,\n\t\t     uint8_t *signature);\n\nint\ned25519_sha512_verify (const uint8_t *pub,\n\t\t       size_t length, const uint8_t *msg,\n\t\t       const uint8_t *signature);\n\n#define ED448_KEY_SIZE 57\n#define ED448_SIGNATURE_SIZE 114\n\nvoid\ned448_shake256_public_key (uint8_t *pub, const uint8_t *priv);\n\nvoid\ned448_shake256_sign (const uint8_t *pub,\n\t\t     const uint8_t *priv,\n\t\t     size_t length, const uint8_t *msg,\n\t\t     uint8_t *signature);\n\nint\ned448_shake256_verify (const uint8_t *pub,\n\t\t       size_t length, const uint8_t *msg,\n\t\t       const uint8_t *signature);\n\t\t\t   \n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_EDDSA_H */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/gcm.h",
    "content": "/* gcm.h\n\n   Galois counter mode, specified by NIST,\n   http://csrc.nist.gov/publications/nistpubs/800-38D/SP-800-38D.pdf\n\n   Copyright (C) 2011 Katholieke Universiteit Leuven\n   Copyright (C) 2011, 2014 Niels Möller\n\n   Contributed by Nikos Mavrogiannopoulos\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_GCM_H_INCLUDED\n#define NETTLE_GCM_H_INCLUDED\n\n#include \"aes.h\"\n#include \"camellia.h\"\n#include \"sm4.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define gcm_set_key nettle_gcm_set_key\n#define gcm_set_iv nettle_gcm_set_iv\n#define gcm_update nettle_gcm_update\n#define gcm_encrypt nettle_gcm_encrypt\n#define gcm_decrypt nettle_gcm_decrypt\n#define gcm_digest nettle_gcm_digest\n\n#define gcm_aes128_set_key nettle_gcm_aes128_set_key\n#define gcm_aes128_set_iv nettle_gcm_aes128_set_iv\n#define gcm_aes128_update nettle_gcm_aes128_update\n#define gcm_aes128_encrypt nettle_gcm_aes128_encrypt\n#define gcm_aes128_decrypt nettle_gcm_aes128_decrypt\n#define gcm_aes128_digest nettle_gcm_aes128_digest\n\n#define gcm_aes192_set_key nettle_gcm_aes192_set_key\n#define gcm_aes192_set_iv nettle_gcm_aes192_set_iv\n#define gcm_aes192_update nettle_gcm_aes192_update\n#define gcm_aes192_encrypt nettle_gcm_aes192_encrypt\n#define gcm_aes192_decrypt nettle_gcm_aes192_decrypt\n#define gcm_aes192_digest nettle_gcm_aes192_digest\n\n#define gcm_aes256_set_key nettle_gcm_aes256_set_key\n#define gcm_aes256_set_iv nettle_gcm_aes256_set_iv\n#define gcm_aes256_update nettle_gcm_aes256_update\n#define gcm_aes256_encrypt nettle_gcm_aes256_encrypt\n#define gcm_aes256_decrypt nettle_gcm_aes256_decrypt\n#define gcm_aes256_digest nettle_gcm_aes256_digest\n\n#define gcm_aes_set_key nettle_gcm_aes_set_key\n#define gcm_aes_set_iv nettle_gcm_aes_set_iv\n#define gcm_aes_update nettle_gcm_aes_update\n#define gcm_aes_encrypt nettle_gcm_aes_encrypt\n#define gcm_aes_decrypt nettle_gcm_aes_decrypt\n#define gcm_aes_digest nettle_gcm_aes_digest\n\n#define gcm_camellia128_set_key nettle_gcm_camellia128_set_key\n#define gcm_camellia128_set_iv nettle_gcm_camellia128_set_iv\n#define gcm_camellia128_update nettle_gcm_camellia128_update\n#define gcm_camellia128_encrypt nettle_gcm_camellia128_encrypt\n#define gcm_camellia128_decrypt nettle_gcm_camellia128_decrypt\n#define gcm_camellia128_digest nettle_gcm_camellia128_digest\n\n#define gcm_camellia256_set_key nettle_gcm_camellia256_set_key\n#define gcm_camellia256_set_iv nettle_gcm_camellia256_set_iv\n#define gcm_camellia256_update nettle_gcm_camellia256_update\n#define gcm_camellia256_encrypt nettle_gcm_camellia256_encrypt\n#define gcm_camellia256_decrypt nettle_gcm_camellia256_decrypt\n#define gcm_camellia256_digest nettle_gcm_camellia256_digest\n\n#define gcm_sm4_set_key nettle_gcm_sm4_set_key\n#define gcm_sm4_set_iv nettle_gcm_sm4_set_iv\n#define gcm_sm4_update nettle_gcm_sm4_update\n#define gcm_sm4_encrypt nettle_gcm_sm4_encrypt\n#define gcm_sm4_decrypt nettle_gcm_sm4_decrypt\n#define gcm_sm4_digest nettle_gcm_sm4_digest\n\n#define GCM_BLOCK_SIZE 16\n#define GCM_IV_SIZE (GCM_BLOCK_SIZE - 4)\n#define GCM_DIGEST_SIZE 16\n#define GCM_TABLE_BITS 8\n\n/* Hashing subkey */\nstruct gcm_key\n{\n  union nettle_block16 h[1 << GCM_TABLE_BITS];\n};\n\n/* Per-message state, depending on the iv */\nstruct gcm_ctx {\n  /* Original counter block */\n  union nettle_block16 iv;\n  /* Updated for each block. */\n  union nettle_block16 ctr;\n  /* Hashing state */\n  union nettle_block16 x;\n  uint64_t auth_size;\n  uint64_t data_size;\n};\n\nvoid\ngcm_set_key(struct gcm_key *key,\n\t    const void *cipher, nettle_cipher_func *f);\n\nvoid\ngcm_set_iv(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t   size_t length, const uint8_t *iv);\n\nvoid\ngcm_update(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t   size_t length, const uint8_t *data);\n\nvoid\ngcm_encrypt(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_decrypt(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_digest(struct gcm_ctx *ctx, const struct gcm_key *key,\n\t   const void *cipher, nettle_cipher_func *f,\n\t   size_t length, uint8_t *digest);\n\n/* Convenience macrology (not sure how useful it is) */\n/* All-in-one context, with hash subkey, message state, and cipher. */\n#define GCM_CTX(type) \\\n  { struct gcm_key key; struct gcm_ctx gcm; type cipher; }\n\n/* NOTE: Avoid using NULL, as we don't include anything defining it. */\n#define GCM_SET_KEY(ctx, set_key, encrypt, gcm_key)\t\t\\\n  do {\t\t\t\t\t\t\t\t\\\n    (set_key)(&(ctx)->cipher, (gcm_key));\t\t\t\\\n    if (0) (encrypt)(&(ctx)->cipher, ~(size_t) 0,\t\t\\\n\t\t     (uint8_t *) 0, (const uint8_t *) 0);\t\\\n    gcm_set_key(&(ctx)->key, &(ctx)->cipher,\t\t\t\\\n\t\t(nettle_cipher_func *) (encrypt));\t\t\\\n  } while (0)\n\n#define GCM_SET_IV(ctx, length, data)\t\t\t\t\\\n  gcm_set_iv(&(ctx)->gcm, &(ctx)->key, (length), (data))\n\n#define GCM_UPDATE(ctx, length, data)\t\t\t\\\n  gcm_update(&(ctx)->gcm, &(ctx)->key, (length), (data))\n\n#define GCM_ENCRYPT(ctx, encrypt, length, dst, src)\t\t\t\\\n  (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n     : gcm_encrypt(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher,\t\t\\\n\t\t   (nettle_cipher_func *) (encrypt),\t\t\t\\\n\t\t   (length), (dst), (src)))\n\n#define GCM_DECRYPT(ctx, encrypt, length, dst, src)\t\t\t\\\n  (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n     : gcm_decrypt(&(ctx)->gcm,  &(ctx)->key, &(ctx)->cipher,\t\t\\\n\t\t   (nettle_cipher_func *) (encrypt),\t\t\t\\\n\t\t   (length), (dst), (src)))\n\n#define GCM_DIGEST(ctx, encrypt, length, digest)\t\t\t\\\n  (0 ? (encrypt)(&(ctx)->cipher, ~(size_t) 0,\t\t\t\t\\\n\t\t (uint8_t *) 0, (const uint8_t *) 0)\t\t\t\\\n     : gcm_digest(&(ctx)->gcm, &(ctx)->key, &(ctx)->cipher,\t\t\\\n\t\t  (nettle_cipher_func *) (encrypt),\t\t\t\\\n\t\t  (length), (digest)))\n\nstruct gcm_aes128_ctx GCM_CTX(struct aes128_ctx);\n\nvoid\ngcm_aes128_set_key(struct gcm_aes128_ctx *ctx, const uint8_t *key);\n\n/* FIXME: Define _update and _set_iv as some kind of aliaes,\n   there's nothing aes-specific. */\nvoid\ngcm_aes128_update (struct gcm_aes128_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\nvoid\ngcm_aes128_set_iv (struct gcm_aes128_ctx *ctx,\n\t\t   size_t length, const uint8_t *iv);\n\nvoid\ngcm_aes128_encrypt(struct gcm_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes128_decrypt(struct gcm_aes128_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes128_digest(struct gcm_aes128_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\nstruct gcm_aes192_ctx GCM_CTX(struct aes192_ctx);\n\nvoid\ngcm_aes192_set_key(struct gcm_aes192_ctx *ctx, const uint8_t *key);\n\nvoid\ngcm_aes192_update (struct gcm_aes192_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\nvoid\ngcm_aes192_set_iv (struct gcm_aes192_ctx *ctx,\n\t\t   size_t length, const uint8_t *iv);\n\nvoid\ngcm_aes192_encrypt(struct gcm_aes192_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes192_decrypt(struct gcm_aes192_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes192_digest(struct gcm_aes192_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\nstruct gcm_aes256_ctx GCM_CTX(struct aes256_ctx);\n\nvoid\ngcm_aes256_set_key(struct gcm_aes256_ctx *ctx, const uint8_t *key);\n\nvoid\ngcm_aes256_update (struct gcm_aes256_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\nvoid\ngcm_aes256_set_iv (struct gcm_aes256_ctx *ctx,\n\t\t   size_t length, const uint8_t *iv);\n\nvoid\ngcm_aes256_encrypt(struct gcm_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes256_decrypt(struct gcm_aes256_ctx *ctx,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\ngcm_aes256_digest(struct gcm_aes256_ctx *ctx,\n\t\t  size_t length, uint8_t *digest);\n\n/* Old deprecated aes interface, for backwards compatibility */\nstruct gcm_aes_ctx GCM_CTX(struct aes_ctx);\n\nvoid\ngcm_aes_set_key(struct gcm_aes_ctx *ctx,\n\t\tsize_t length, const uint8_t *key) _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_set_iv(struct gcm_aes_ctx *ctx,\n\t       size_t length, const uint8_t *iv) _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_update(struct gcm_aes_ctx *ctx,\n\t       size_t length, const uint8_t *data) _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_encrypt(struct gcm_aes_ctx *ctx,\n\t\tsize_t length, uint8_t *dst, const uint8_t *src)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_decrypt(struct gcm_aes_ctx *ctx,\n\t\tsize_t length, uint8_t *dst, const uint8_t *src)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\nvoid\ngcm_aes_digest(struct gcm_aes_ctx *ctx, size_t length, uint8_t *digest)\n  _NETTLE_ATTRIBUTE_DEPRECATED;\n\n\nstruct gcm_camellia128_ctx GCM_CTX(struct camellia128_ctx);\n\nvoid gcm_camellia128_set_key(struct gcm_camellia128_ctx *ctx,\n\t\t\t     const uint8_t *key);\nvoid gcm_camellia128_set_iv(struct gcm_camellia128_ctx *ctx,\n\t\t\t    size_t length, const uint8_t *iv);\nvoid gcm_camellia128_update(struct gcm_camellia128_ctx *ctx,\n\t\t\t    size_t length, const uint8_t *data);\nvoid gcm_camellia128_encrypt(struct gcm_camellia128_ctx *ctx,\n\t\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_camellia128_decrypt(struct gcm_camellia128_ctx *ctx,\n\t\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_camellia128_digest(struct gcm_camellia128_ctx *ctx,\n\t\t\t    size_t length, uint8_t *digest);\n\n\nstruct gcm_camellia256_ctx GCM_CTX(struct camellia256_ctx);\n\nvoid gcm_camellia256_set_key(struct gcm_camellia256_ctx *ctx,\n\t\t\t     const uint8_t *key);\nvoid gcm_camellia256_set_iv(struct gcm_camellia256_ctx *ctx,\n\t\t\t    size_t length, const uint8_t *iv);\nvoid gcm_camellia256_update(struct gcm_camellia256_ctx *ctx,\n\t\t\t    size_t length, const uint8_t *data);\nvoid gcm_camellia256_encrypt(struct gcm_camellia256_ctx *ctx,\n\t\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_camellia256_decrypt(struct gcm_camellia256_ctx *ctx,\n\t\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_camellia256_digest(struct gcm_camellia256_ctx *ctx,\n\t\t\t    size_t length, uint8_t *digest);\n\n\nstruct gcm_sm4_ctx GCM_CTX(struct sm4_ctx);\n\nvoid gcm_sm4_set_key(struct gcm_sm4_ctx *ctx, const uint8_t *key);\nvoid gcm_sm4_set_iv(struct gcm_sm4_ctx *ctx,\n\t\t    size_t length, const uint8_t *iv);\nvoid gcm_sm4_update(struct gcm_sm4_ctx *ctx,\n\t\t    size_t length, const uint8_t *data);\nvoid gcm_sm4_encrypt(struct gcm_sm4_ctx *ctx,\n\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_sm4_decrypt(struct gcm_sm4_ctx *ctx,\n\t\t     size_t length, uint8_t *dst, const uint8_t *src);\nvoid gcm_sm4_digest(struct gcm_sm4_ctx *ctx,\n\t\t    size_t length, uint8_t *digest);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_GCM_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/gostdsa.h",
    "content": "/* gostdsa.h\n\n   Copyright (C) 2015 Dmity Eremin-Solenikov\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_GOSTDSA_H_INCLUDED\n#define NETTLE_GOSTDSA_H_INCLUDED\n\n#include \"ecc.h\"\n#include \"dsa.h\"\n#include \"ecdsa.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define gostdsa_sign nettle_gostdsa_sign\n#define gostdsa_verify nettle_gostdsa_verify\n#define gostdsa_vko nettle_gostdsa_vko\n#define ecc_gostdsa_sign nettle_ecc_gostdsa_sign\n#define ecc_gostdsa_sign_itch nettle_ecc_gostdsa_sign_itch\n#define ecc_gostdsa_verify nettle_ecc_gostdsa_verify\n#define ecc_gostdsa_verify_itch nettle_ecc_gostdsa_verify_itch\n\n/* Just use ECDSA function for key generation */\n#define gostdsa_generate_keypair ecdsa_generate_keypair\n\n/* High level GOST DSA functions.\n *\n * A public key is represented as a struct ecc_point, and a private\n * key as a struct ecc_scalar. */\nvoid\ngostdsa_sign (const struct ecc_scalar *key,\n\t      void *random_ctx, nettle_random_func *random,\n\t      size_t digest_length,\n\t      const uint8_t *digest,\n\t      struct dsa_signature *signature);\n\nint\ngostdsa_verify (const struct ecc_point *pub,\n\t        size_t length, const uint8_t *digest,\n\t        const struct dsa_signature *signature);\n\nvoid\ngostdsa_vko (const struct ecc_scalar *key,\n\t     const struct ecc_point *pub,\n\t     size_t ukm_length, const uint8_t *ukm,\n\t     uint8_t *out);\n\n/* Low-level GOSTDSA functions. */\nmp_size_t\necc_gostdsa_sign_itch (const struct ecc_curve *ecc);\n\nvoid\necc_gostdsa_sign (const struct ecc_curve *ecc,\n\t\tconst mp_limb_t *zp,\n\t\t/* Random nonce, must be invertible mod ecc group\n\t\t   order. */\n\t\tconst mp_limb_t *kp,\n\t\tsize_t length, const uint8_t *digest,\n\t\tmp_limb_t *rp, mp_limb_t *sp,\n\t\tmp_limb_t *scratch);\n\nmp_size_t\necc_gostdsa_verify_itch (const struct ecc_curve *ecc);\n\nint\necc_gostdsa_verify (const struct ecc_curve *ecc,\n\t\t  const mp_limb_t *pp, /* Public key */\n\t\t  size_t length, const uint8_t *digest,\n\t\t  const mp_limb_t *rp, const mp_limb_t *sp,\n\t\t  mp_limb_t *scratch);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_GOSTDSA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/gosthash94.h",
    "content": "/* gosthash94.h\n\n   The GOST R 34.11-94 hash function, described in RFC 5831.\n\n   Copyright (C) 2012 Nikos Mavrogiannopoulos, Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Based on rhash gost.h. */\n\n/* Copyright: 2009-2012 Aleksey Kravchenko <rhash.admin@gmail.com>\n *\n * Permission is hereby granted, free of charge, to any person obtaining a\n * copy of this software and associated documentation files (the\n * \"Software\"), to deal in the Software without restriction, including\n * without limitation the rights to use, copy, modify, merge, publish,\n * distribute, sublicense, and/or sell copies of the Software, and to\n * permit persons to whom the Software is furnished to do so, subject to\n * the following conditions:\n *\n * The above copyright notice and this permission notice shall be included\n * in all copies or substantial portions of the Software.\n *\n * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS\n * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\n * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.\n * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY\n * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,\n * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE\n * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n */\n\n/*\n * Ported to nettle by Nikos Mavrogiannopoulos.\n */\n\n#ifndef NETTLE_GOSTHASH94_H_INCLUDED\n#define NETTLE_GOSTHASH94_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define gosthash94_init nettle_gosthash94_init\n#define gosthash94_update nettle_gosthash94_update\n#define gosthash94_digest nettle_gosthash94_digest\n\n#define gosthash94cp_update nettle_gosthash94cp_update\n#define gosthash94cp_digest nettle_gosthash94cp_digest\n\n#define GOSTHASH94_BLOCK_SIZE 32\n#define GOSTHASH94_DIGEST_SIZE 32\n/* For backwards compatibility */\n#define GOSTHASH94_DATA_SIZE GOSTHASH94_BLOCK_SIZE\n\n#define GOSTHASH94CP_BLOCK_SIZE GOSTHASH94_BLOCK_SIZE\n#define GOSTHASH94CP_DIGEST_SIZE GOSTHASH94_DIGEST_SIZE\n\nstruct gosthash94_ctx\n{\n  uint32_t hash[8]; /* algorithm 256-bit state */\n  uint32_t sum[8];  /* sum of processed message blocks */\n  uint64_t count;               /* Block count */\n  unsigned index;               /* Into buffer */\n  uint8_t block[GOSTHASH94_BLOCK_SIZE]; /* 256-bit buffer for leftovers */\n};\n#define gosthash94cp_ctx gosthash94_ctx\n\nvoid gosthash94_init(struct gosthash94_ctx *ctx);\nvoid gosthash94_update(struct gosthash94_ctx *ctx,\n\t\t       size_t length, const uint8_t *msg);\nvoid gosthash94_digest(struct gosthash94_ctx *ctx,\n\t\t       size_t length, uint8_t *result);\n\n#define gosthash94cp_init gosthash94_init\nvoid gosthash94cp_update(struct gosthash94_ctx *ctx,\n\t\t\t size_t length, const uint8_t *msg);\nvoid gosthash94cp_digest(struct gosthash94_ctx *ctx,\n\t\t\t size_t length, uint8_t *result);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_GOSTHASH94_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/hkdf.h",
    "content": "/* hkdf.h\n\n   TLS PRF code (RFC-5246, RFC-2246).\n\n   Copyright (C) 2017 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_HKDF_H_INCLUDED\n#define NETTLE_HKDF_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define hkdf_extract nettle_hkdf_extract\n#define hkdf_expand nettle_hkdf_expand\n\nvoid\nhkdf_extract(void *mac_ctx,\n\t     nettle_hash_update_func *update,\n\t     nettle_hash_digest_func *digest,\n\t     size_t digest_size,\n\t     size_t secret_size, const uint8_t *secret,\n\t     uint8_t *dst);\n\nvoid\nhkdf_expand(void *mac_ctx,\n\t    nettle_hash_update_func *update,\n\t    nettle_hash_digest_func *digest,\n\t    size_t digest_size,\n\t    size_t info_size, const uint8_t *info,\n\t    size_t length, uint8_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_HKDF_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/hmac.h",
    "content": "/* hmac.h\n\n   HMAC message authentication code (RFC-2104).\n\n   Copyright (C) 2001, 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_HMAC_H_INCLUDED\n#define NETTLE_HMAC_H_INCLUDED\n\n#include \"nettle-meta.h\"\n\n#include \"gosthash94.h\"\n#include \"md5.h\"\n#include \"ripemd160.h\"\n#include \"sha1.h\"\n#include \"sha2.h\"\n#include \"streebog.h\"\n#include \"sm3.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define hmac_set_key nettle_hmac_set_key\n#define hmac_update nettle_hmac_update\n#define hmac_digest nettle_hmac_digest\n#define hmac_md5_set_key nettle_hmac_md5_set_key\n#define hmac_md5_update nettle_hmac_md5_update\n#define hmac_md5_digest nettle_hmac_md5_digest\n#define hmac_ripemd160_set_key nettle_hmac_ripemd160_set_key\n#define hmac_ripemd160_update nettle_hmac_ripemd160_update\n#define hmac_ripemd160_digest nettle_hmac_ripemd160_digest\n#define hmac_sha1_set_key nettle_hmac_sha1_set_key\n#define hmac_sha1_update nettle_hmac_sha1_update\n#define hmac_sha1_digest nettle_hmac_sha1_digest\n#define hmac_sha224_set_key nettle_hmac_sha224_set_key\n#define hmac_sha224_digest nettle_hmac_sha224_digest\n#define hmac_sha256_set_key nettle_hmac_sha256_set_key\n#define hmac_sha256_update nettle_hmac_sha256_update\n#define hmac_sha256_digest nettle_hmac_sha256_digest\n#define hmac_sha384_set_key nettle_hmac_sha384_set_key\n#define hmac_sha384_digest nettle_hmac_sha384_digest\n#define hmac_sha512_set_key nettle_hmac_sha512_set_key\n#define hmac_sha512_update nettle_hmac_sha512_update\n#define hmac_sha512_digest nettle_hmac_sha512_digest\n#define hmac_gosthash94_set_key nettle_hmac_gosthash94_set_key\n#define hmac_gosthash94_update nettle_hmac_gosthash94_update\n#define hmac_gosthash94_digest nettle_hmac_gosthash94_digest\n#define hmac_gosthash94cp_set_key nettle_hmac_gosthash94cp_set_key\n#define hmac_gosthash94cp_update nettle_hmac_gosthash94cp_update\n#define hmac_gosthash94cp_digest nettle_hmac_gosthash94cp_digest\n#define hmac_streebog256_set_key nettle_hmac_streebog256_set_key\n#define hmac_streebog256_digest nettle_hmac_streebog256_digest\n#define hmac_streebog512_set_key nettle_hmac_streebog512_set_key\n#define hmac_streebog512_update nettle_hmac_streebog512_update\n#define hmac_streebog512_digest nettle_hmac_streebog512_digest\n#define hmac_sm3_set_key nettle_hmac_sm3_set_key\n#define hmac_sm3_update nettle_hmac_sm3_update\n#define hmac_sm3_digest nettle_hmac_sm3_digest\n\nvoid\nhmac_set_key(void *outer, void *inner, void *state,\n\t     const struct nettle_hash *hash,\n\t     size_t length, const uint8_t *key);\n\n/* This function is not strictly needed, it's s just the same as the\n * hash update function. */\nvoid\nhmac_update(void *state,\n\t    const struct nettle_hash *hash,\n\t    size_t length, const uint8_t *data);\n\nvoid\nhmac_digest(const void *outer, const void *inner, void *state,\n\t    const struct nettle_hash *hash,\n\t    size_t length, uint8_t *digest);\n\n\n#define HMAC_CTX(type) \\\n{ type outer; type inner; type state; }\n\n#define HMAC_SET_KEY(ctx, hash, length, key)\t\t\t\\\n  hmac_set_key( &(ctx)->outer, &(ctx)->inner, &(ctx)->state,\t\\\n                (hash), (length), (key) )\n\n#define HMAC_DIGEST(ctx, hash, length, digest)\t\t\t\\\n  hmac_digest( &(ctx)->outer, &(ctx)->inner, &(ctx)->state,\t\\\n               (hash), (length), (digest) )\n\n/* HMAC using specific hash functions */\n\n/* hmac-md5 */\nstruct hmac_md5_ctx HMAC_CTX(struct md5_ctx);\n\nvoid\nhmac_md5_set_key(struct hmac_md5_ctx *ctx,\n\t\t size_t key_length, const uint8_t *key);\n\nvoid\nhmac_md5_update(struct hmac_md5_ctx *ctx,\n\t\tsize_t length, const uint8_t *data);\n\nvoid\nhmac_md5_digest(struct hmac_md5_ctx *ctx,\n\t\tsize_t length, uint8_t *digest);\n\n\n/* hmac-ripemd160 */\nstruct hmac_ripemd160_ctx HMAC_CTX(struct ripemd160_ctx);\n\nvoid\nhmac_ripemd160_set_key(struct hmac_ripemd160_ctx *ctx,\n\t\t       size_t key_length, const uint8_t *key);\n\nvoid\nhmac_ripemd160_update(struct hmac_ripemd160_ctx *ctx,\n\t\t      size_t length, const uint8_t *data);\n\nvoid\nhmac_ripemd160_digest(struct hmac_ripemd160_ctx *ctx,\n\t\t      size_t length, uint8_t *digest);\n\n\n/* hmac-sha1 */\nstruct hmac_sha1_ctx HMAC_CTX(struct sha1_ctx);\n\nvoid\nhmac_sha1_set_key(struct hmac_sha1_ctx *ctx,\n\t\t  size_t key_length, const uint8_t *key);\n\nvoid\nhmac_sha1_update(struct hmac_sha1_ctx *ctx,\n\t\t size_t length, const uint8_t *data);\n\nvoid\nhmac_sha1_digest(struct hmac_sha1_ctx *ctx,\n\t\t size_t length, uint8_t *digest);\n\n/* hmac-sha256 */\nstruct hmac_sha256_ctx HMAC_CTX(struct sha256_ctx);\n\nvoid\nhmac_sha256_set_key(struct hmac_sha256_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\nvoid\nhmac_sha256_update(struct hmac_sha256_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nhmac_sha256_digest(struct hmac_sha256_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-sha224 */\n#define hmac_sha224_ctx hmac_sha256_ctx\n\nvoid\nhmac_sha224_set_key(struct hmac_sha224_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\n#define hmac_sha224_update nettle_hmac_sha256_update\n\nvoid\nhmac_sha224_digest(struct hmac_sha224_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-sha512 */\nstruct hmac_sha512_ctx HMAC_CTX(struct sha512_ctx);\n\nvoid\nhmac_sha512_set_key(struct hmac_sha512_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\nvoid\nhmac_sha512_update(struct hmac_sha512_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nhmac_sha512_digest(struct hmac_sha512_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-sha384 */\n#define hmac_sha384_ctx hmac_sha512_ctx\n\nvoid\nhmac_sha384_set_key(struct hmac_sha512_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\n#define hmac_sha384_update nettle_hmac_sha512_update\n\nvoid\nhmac_sha384_digest(struct hmac_sha512_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-gosthash94 */\nstruct hmac_gosthash94_ctx HMAC_CTX(struct gosthash94_ctx);\n\nvoid\nhmac_gosthash94_set_key(struct hmac_gosthash94_ctx *ctx,\n\t\t\tsize_t key_length, const uint8_t *key);\n\nvoid\nhmac_gosthash94_update(struct hmac_gosthash94_ctx *ctx,\n\t\t       size_t length, const uint8_t *data);\n\n  void\nhmac_gosthash94_digest(struct hmac_gosthash94_ctx *ctx,\n\t\t       size_t length, uint8_t *digest);\n\nstruct hmac_gosthash94cp_ctx HMAC_CTX(struct gosthash94cp_ctx);\n\nvoid\nhmac_gosthash94cp_set_key(struct hmac_gosthash94cp_ctx *ctx,\n\t\t\t  size_t key_length, const uint8_t *key);\n\nvoid\nhmac_gosthash94cp_update(struct hmac_gosthash94cp_ctx *ctx,\n\t\t\t size_t length, const uint8_t *data);\n\nvoid\nhmac_gosthash94cp_digest(struct hmac_gosthash94cp_ctx *ctx,\n\t\t\t size_t length, uint8_t *digest);\n\n\n/* hmac-streebog */\nstruct hmac_streebog512_ctx HMAC_CTX(struct streebog512_ctx);\n\nvoid\nhmac_streebog512_set_key(struct hmac_streebog512_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\nvoid\nhmac_streebog512_update(struct hmac_streebog512_ctx *ctx,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nhmac_streebog512_digest(struct hmac_streebog512_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n#define hmac_streebog256_ctx hmac_streebog512_ctx\n\nvoid\nhmac_streebog256_set_key(struct hmac_streebog256_ctx *ctx,\n\t\t    size_t key_length, const uint8_t *key);\n\n#define hmac_streebog256_update hmac_streebog512_update\n\nvoid\nhmac_streebog256_digest(struct hmac_streebog256_ctx *ctx,\n\t\t   size_t length, uint8_t *digest);\n\n/* hmac-sm3 */\nstruct hmac_sm3_ctx HMAC_CTX(struct sm3_ctx);\n\nvoid\nhmac_sm3_set_key(struct hmac_sm3_ctx *ctx,\n\t\t size_t key_length, const uint8_t *key);\n\nvoid\nhmac_sm3_update(struct hmac_sm3_ctx *ctx,\n\t\tsize_t length, const uint8_t *data);\n\nvoid\nhmac_sm3_digest(struct hmac_sm3_ctx *ctx,\n\t\tsize_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_HMAC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/knuth-lfib.h",
    "content": "/* knuth-lfib.h\n\n   The \"lagged fibonacci\" pseudorandomness generator, described in\n   Knuth, TAoCP, 3.6\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* NOTE: This generator is totally inappropriate for cryptographic\n * applications. It is useful for generating deterministic but\n * random-looking test data, and is used by the Nettle testsuite. */\n#ifndef NETTLE_KNUTH_LFIB_H_INCLUDED\n#define NETTLE_KNUTH_LFIB_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define knuth_lfib_init nettle_knuth_lfib_init\n#define knuth_lfib_get nettle_knuth_lfib_get\n#define knuth_lfib_get_array nettle_knuth_lfib_get_array\n#define knuth_lfib_random nettle_knuth_lfib_random\n\n#define _KNUTH_LFIB_KK 100\n\nstruct knuth_lfib_ctx\n{\n  uint32_t x[_KNUTH_LFIB_KK];\n  unsigned index;\n};\n\nvoid\nknuth_lfib_init(struct knuth_lfib_ctx *ctx, uint32_t seed);\n\n/* Get's a single number in the range 0 ... 2^30-1 */\nuint32_t\nknuth_lfib_get(struct knuth_lfib_ctx *ctx);\n\n/* Get an array of numbers */\nvoid\nknuth_lfib_get_array(struct knuth_lfib_ctx *ctx,\n\t\t     size_t n, uint32_t *a);\n\n/* Get an array of octets. */\nvoid\nknuth_lfib_random(struct knuth_lfib_ctx *ctx,\n\t\t  size_t n, uint8_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_KNUTH_LFIB_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/macros.h",
    "content": "/* macros.h\n\n   Copyright (C) 2001, 2010 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_MACROS_H_INCLUDED\n#define NETTLE_MACROS_H_INCLUDED\n\n/* Reads a 64-bit integer, in network, big-endian, byte order */\n#define READ_UINT64(p)\t\t\t\t\\\n(  (((uint64_t) (p)[0]) << 56)\t\t\t\\\n | (((uint64_t) (p)[1]) << 48)\t\t\t\\\n | (((uint64_t) (p)[2]) << 40)\t\t\t\\\n | (((uint64_t) (p)[3]) << 32)\t\t\t\\\n | (((uint64_t) (p)[4]) << 24)\t\t\t\\\n | (((uint64_t) (p)[5]) << 16)\t\t\t\\\n | (((uint64_t) (p)[6]) << 8)\t\t\t\\\n |  ((uint64_t) (p)[7]))\n\n#define WRITE_UINT64(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[0] = ((i) >> 56) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 48) & 0xff;\t\t\t\\\n  (p)[2] = ((i) >> 40) & 0xff;\t\t\t\\\n  (p)[3] = ((i) >> 32) & 0xff;\t\t\t\\\n  (p)[4] = ((i) >> 24) & 0xff;\t\t\t\\\n  (p)[5] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[6] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[7] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n/* Reads a 32-bit integer, in network, big-endian, byte order */\n#define READ_UINT32(p)\t\t\t\t\\\n(  (((uint32_t) (p)[0]) << 24)\t\t\t\\\n | (((uint32_t) (p)[1]) << 16)\t\t\t\\\n | (((uint32_t) (p)[2]) << 8)\t\t\t\\\n |  ((uint32_t) (p)[3]))\n\n#define WRITE_UINT32(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[0] = ((i) >> 24) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[2] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[3] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n/* Analogous macros, for 24 and 16 bit numbers */\n#define READ_UINT24(p)\t\t\t\t\\\n(  (((uint32_t) (p)[0]) << 16)\t\t\t\\\n | (((uint32_t) (p)[1]) << 8)\t\t\t\\\n |  ((uint32_t) (p)[2]))\n\n#define WRITE_UINT24(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[0] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[2] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n#define READ_UINT16(p)\t\t\t\t\\\n(  (((uint32_t) (p)[0]) << 8)\t\t\t\\\n |  ((uint32_t) (p)[1]))\n\n#define WRITE_UINT16(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[0] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[1] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n/* And the other, little-endian, byteorder */\n#define LE_READ_UINT64(p)\t\t\t\\\n(  (((uint64_t) (p)[7]) << 56)\t\t\t\\\n | (((uint64_t) (p)[6]) << 48)\t\t\t\\\n | (((uint64_t) (p)[5]) << 40)\t\t\t\\\n | (((uint64_t) (p)[4]) << 32)\t\t\t\\\n | (((uint64_t) (p)[3]) << 24)\t\t\t\\\n | (((uint64_t) (p)[2]) << 16)\t\t\t\\\n | (((uint64_t) (p)[1]) << 8)\t\t\t\\\n |  ((uint64_t) (p)[0]))\n\n#define LE_WRITE_UINT64(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[7] = ((i) >> 56) & 0xff;\t\t\t\\\n  (p)[6] = ((i) >> 48) & 0xff;\t\t\t\\\n  (p)[5] = ((i) >> 40) & 0xff;\t\t\t\\\n  (p)[4] = ((i) >> 32) & 0xff;\t\t\t\\\n  (p)[3] = ((i) >> 24) & 0xff;\t\t\t\\\n  (p)[2] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[0] = (i) & 0xff;\t\t\t\t\\\n} while (0)\n\n#define LE_READ_UINT32(p)\t\t\t\\\n(  (((uint32_t) (p)[3]) << 24)\t\t\t\\\n | (((uint32_t) (p)[2]) << 16)\t\t\t\\\n | (((uint32_t) (p)[1]) << 8)\t\t\t\\\n |  ((uint32_t) (p)[0]))\n\n#define LE_WRITE_UINT32(p, i)\t\t\t\\\ndo {\t\t\t\t\t\t\\\n  (p)[3] = ((i) >> 24) & 0xff;\t\t\t\\\n  (p)[2] = ((i) >> 16) & 0xff;\t\t\t\\\n  (p)[1] = ((i) >> 8) & 0xff;\t\t\t\\\n  (p)[0] = (i) & 0xff;\t\t\t\t\\\n} while(0)\n\n/* Analogous macros, for 16 bit numbers */\n#define LE_READ_UINT16(p)\t\t\t\\\n  (  (((uint32_t) (p)[1]) << 8)\t\t\t\\\n     |  ((uint32_t) (p)[0]))\n\n#define LE_WRITE_UINT16(p, i)\t\t\t\\\n  do {\t\t\t\t\t\t\\\n    (p)[1] = ((i) >> 8) & 0xff;\t\t\t\\\n    (p)[0] = (i) & 0xff;\t\t\t\\\n  } while(0)\n\n/* Macro to make it easier to loop over several blocks. */\n#define FOR_BLOCKS(length, dst, src, blocksize)\t\\\n  assert( !((length) % (blocksize)));           \\\n  for (; (length); ((length) -= (blocksize),\t\\\n\t\t  (dst) += (blocksize),\t\t\\\n\t\t  (src) += (blocksize)) )\n\n/* The masking of the right shift is needed to allow n == 0 (using\n   just 32 - n and 64 - n results in undefined behaviour). Most uses\n   of these macros use a constant and non-zero rotation count. */\n#define ROTL32(n,x) (((x)<<(n)) | ((x)>>((-(n)&31))))\n\n#define ROTL64(n,x) (((x)<<(n)) | ((x)>>((-(n))&63)))\n\n/* Requires that size > 0 */\n#define INCREMENT(size, ctr)\t\t\t\\\n  do {\t\t\t\t\t\t\\\n    unsigned increment_i = (size) - 1;\t\t\\\n    if (++(ctr)[increment_i] == 0)\t\t\\\n      while (increment_i > 0\t\t\t\\\n\t     && ++(ctr)[--increment_i] == 0 )\t\\\n\t;\t\t\t\t\t\\\n  } while (0)\n\n\n/* Helper macro for Merkle-Damgård hash functions. Assumes the context\n   structs includes the following fields:\n\n     uint8_t block[...];\t\t// Buffer holding one block\n     unsigned int index;\t\t// Index into block\n*/\n\n/* Currently used by sha512 (and sha384) only. */\n#define MD_INCR(ctx) ((ctx)->count_high += !++(ctx)->count_low)\n\n/* Takes the compression function f as argument. NOTE: also clobbers\n   length and data. */\n#define MD_UPDATE(ctx, length, data, f, incr)\t\t\t\t\\\n  do {\t\t\t\t\t\t\t\t\t\\\n    if ((ctx)->index)\t\t\t\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\t\\\n\t/* Try to fill partial block */\t\t\t\t\t\\\n\tunsigned __md_left = sizeof((ctx)->block) - (ctx)->index;\t\\\n\tif ((length) < __md_left)\t\t\t\t\t\\\n\t  {\t\t\t\t\t\t\t\t\\\n\t    memcpy((ctx)->block + (ctx)->index, (data), (length));\t\\\n\t    (ctx)->index += (length);\t\t\t\t\t\\\n\t    goto __md_done; /* Finished */\t\t\t\t\\\n\t  }\t\t\t\t\t\t\t\t\\\n\telse\t\t\t\t\t\t\t\t\\\n\t  {\t\t\t\t\t\t\t\t\\\n\t    memcpy((ctx)->block + (ctx)->index, (data), __md_left);\t\\\n\t\t\t\t\t\t\t\t\t\\\n\t    f((ctx), (ctx)->block);\t\t\t\t\t\\\n\t    (incr);\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n\t    (data) += __md_left;\t\t\t\t\t\\\n\t    (length) -= __md_left;\t\t\t\t\t\\\n\t  }\t\t\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\t\\\n    while ((length) >= sizeof((ctx)->block))\t\t\t\t\\\n      {\t\t\t\t\t\t\t\t\t\\\n\tf((ctx), (data));\t\t\t\t\t\t\\\n\t(incr);\t\t\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n\t(data) += sizeof((ctx)->block);\t\t\t\t\t\\\n\t(length) -= sizeof((ctx)->block);\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\t\\\n    memcpy ((ctx)->block, (data), (length));\t\t\t\t\\\n    (ctx)->index = (length);\t\t\t\t\t\t\\\n  __md_done:\t\t\t\t\t\t\t\t\\\n    ;\t\t\t\t\t\t\t\t\t\\\n  } while (0)\n\n/* Pads the block to a block boundary with the bit pattern 1 0*,\n   leaving size octets for the length field at the end. If needed,\n   compresses the block and starts a new one. */\n#define MD_PAD(ctx, size, f)\t\t\t\t\t\t\\\n  do {\t\t\t\t\t\t\t\t\t\\\n    unsigned __md_i;\t\t\t\t\t\t\t\\\n    __md_i = (ctx)->index;\t\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n    /* Set the first char of padding to 0x80. This is safe since there\t\\\n       is always at least one byte free */\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n    assert(__md_i < sizeof((ctx)->block));\t\t\t\t\\\n    (ctx)->block[__md_i++] = 0x80;\t\t\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n    if (__md_i > (sizeof((ctx)->block) - (size)))\t\t\t\\\n      { /* No room for length in this block. Process it and\t\t\\\n\t   pad with another one */\t\t\t\t\t\\\n\tmemset((ctx)->block + __md_i, 0, sizeof((ctx)->block) - __md_i); \\\n\t\t\t\t\t\t\t\t\t\\\n\tf((ctx), (ctx)->block);\t\t\t\t\t\t\\\n\t__md_i = 0;\t\t\t\t\t\t\t\\\n      }\t\t\t\t\t\t\t\t\t\\\n    memset((ctx)->block + __md_i, 0,\t\t\t\t\t\\\n\t   sizeof((ctx)->block) - (size) - __md_i);\t\t\t\\\n\t\t\t\t\t\t\t\t\t\\\n  } while (0)\n\n#endif /* NETTLE_MACROS_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/md2.h",
    "content": "/* md2.h\n\n   The MD2 hash function, described in RFC 1319.\n\n   Copyright (C) 2003 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_MD2_H_INCLUDED\n#define NETTLE_MD2_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define md2_init nettle_md2_init\n#define md2_update nettle_md2_update\n#define md2_digest nettle_md2_digest\n\n#define MD2_DIGEST_SIZE 16\n#define MD2_BLOCK_SIZE 16\n/* For backwards compatibility */\n#define MD2_DATA_SIZE MD2_BLOCK_SIZE\n\nstruct md2_ctx\n{\n  uint8_t C[MD2_BLOCK_SIZE];\n  uint8_t X[3 * MD2_BLOCK_SIZE];\n  unsigned index;               /* Into buffer */\n  uint8_t block[MD2_BLOCK_SIZE]; /* Block buffer */\n};\n\nvoid\nmd2_init(struct md2_ctx *ctx);\n\nvoid\nmd2_update(struct md2_ctx *ctx,\n\t   size_t length,\n\t   const uint8_t *data);\n\nvoid\nmd2_digest(struct md2_ctx *ctx,\n\t   size_t length,\n\t   uint8_t *digest);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MD2_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/md4.h",
    "content": "/* md4.h\n\n   The MD4 hash function, described in RFC 1320.\n\n   Copyright (C) 2003 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_MD4_H_INCLUDED\n#define NETTLE_MD4_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define md4_init nettle_md4_init\n#define md4_update nettle_md4_update\n#define md4_digest nettle_md4_digest\n\n#define MD4_DIGEST_SIZE 16\n#define MD4_BLOCK_SIZE 64\n/* For backwards compatibility */\n#define MD4_DATA_SIZE MD4_BLOCK_SIZE\n\n/* Digest is kept internally as 4 32-bit words. */\n#define _MD4_DIGEST_LENGTH 4\n\n/* FIXME: Identical to md5_ctx */\nstruct md4_ctx\n{\n  uint32_t state[_MD4_DIGEST_LENGTH];\n  uint64_t count;\t\t\t/* Block count */\n  unsigned index;\t\t\t/* Into buffer */\n  uint8_t block[MD4_BLOCK_SIZE];\t/* Block buffer */\n};\n\nvoid\nmd4_init(struct md4_ctx *ctx);\n\nvoid\nmd4_update(struct md4_ctx *ctx,\n\t   size_t length,\n\t   const uint8_t *data);\n\nvoid\nmd4_digest(struct md4_ctx *ctx,\n\t   size_t length,\n\t   uint8_t *digest);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MD4_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/md5-compat.h",
    "content": "/* md5-compat.h\n\n   The md5 hash function, RFC 1321-style interface.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_MD5_COMPAT_H_INCLUDED\n#define NETTLE_MD5_COMPAT_H_INCLUDED\n\n#include \"md5.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define MD5Init nettle_MD5Init\n#define MD5Update nettle_MD5Update\n#define MD5Final nettle_MD5Final\n\ntypedef struct md5_ctx MD5_CTX;\n\nvoid MD5Init(MD5_CTX *ctx);\nvoid MD5Update(MD5_CTX *ctx, const unsigned char *data, unsigned int length);\nvoid MD5Final(unsigned char *out, MD5_CTX *ctx);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MD5_COMPAT_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/md5.h",
    "content": "/* md5.h\n\n   The MD5 hash function, described in RFC 1321.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_MD5_H_INCLUDED\n#define NETTLE_MD5_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define md5_init nettle_md5_init\n#define md5_update nettle_md5_update\n#define md5_digest nettle_md5_digest\n#define md5_compress nettle_md5_compress\n\n#define MD5_DIGEST_SIZE 16\n#define MD5_BLOCK_SIZE 64\n/* For backwards compatibility */\n#define MD5_DATA_SIZE MD5_BLOCK_SIZE\n\n/* Digest is kept internally as 4 32-bit words. */\n#define _MD5_DIGEST_LENGTH 4\n\nstruct md5_ctx\n{\n  uint32_t state[_MD5_DIGEST_LENGTH];\n  uint64_t count;               /* Block count */\n  unsigned index;               /* Into buffer */\n  uint8_t block[MD5_BLOCK_SIZE]; /* Block buffer */\n};\n\nvoid\nmd5_init(struct md5_ctx *ctx);\n\nvoid\nmd5_update(struct md5_ctx *ctx,\n\t   size_t length,\n\t   const uint8_t *data);\n\nvoid\nmd5_digest(struct md5_ctx *ctx,\n\t   size_t length,\n\t   uint8_t *digest);\n\n/* MD5 compression function. STATE points to 4 uint32_t words,\n   and DATA points to 64 bytes of input data, possibly unaligned. */\nvoid\nmd5_compress(uint32_t *state, const uint8_t *data);\n\n/* Old name, for backwards compatibility. */\n#define _nettle_md5_compress nettle_md5_compress\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MD5_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/memops.h",
    "content": "/* memops.h\n\n   Copyright (C) 2016 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_MEMOPS_H_INCLUDED\n#define NETTLE_MEMOPS_H_INCLUDED\n\n#include \"memxor.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define cnd_memcpy nettle_cnd_memcpy\n#define memeql_sec nettle_memeql_sec\n\nint\nmemeql_sec (const void *a, const void *b, size_t n);\n\n/* Side-channel silent conditional memcpy. cnd must be 0 (nop) or 1\n   (copy). */\nvoid\ncnd_memcpy(int cnd, volatile void *dst, const volatile void *src, size_t n);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MEMOPS_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/memxor.h",
    "content": "/* memxor.h\n *\n */\n\n#ifndef NETTLE_MEMXOR_H_INCLUDED\n#define NETTLE_MEMXOR_H_INCLUDED\n\n#include <stdlib.h>\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define memxor nettle_memxor\n#define memxor3 nettle_memxor3\n\nvoid *memxor(void *dst, const void *src, size_t n);\nvoid *memxor3(void *dst, const void *a, const void *b, size_t n);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_MEMXOR_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/nettle-meta.h",
    "content": "/* nettle-meta.h\n\n   Information about algorithms.\n\n   Copyright (C) 2002, 2014, 2020 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_META_H_INCLUDED\n#define NETTLE_META_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n\nstruct nettle_cipher\n{\n  const char *name;\n  \n  unsigned context_size;\n  \n  /* Zero for stream ciphers */\n  unsigned block_size;\n\n  /* Suggested key size; other sizes are sometimes possible. */\n  unsigned key_size;\n\n  nettle_set_key_func *set_encrypt_key;\n  nettle_set_key_func *set_decrypt_key;\n\n  nettle_cipher_func *encrypt;\n  nettle_cipher_func *decrypt;\n};\n\n/* null-terminated list of ciphers implemented by this version of nettle */\nconst struct nettle_cipher * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_ciphers (void);\n\n#define nettle_ciphers (nettle_get_ciphers())\n\nextern const struct nettle_cipher nettle_aes128;\nextern const struct nettle_cipher nettle_aes192;\nextern const struct nettle_cipher nettle_aes256;\n\nextern const struct nettle_cipher nettle_camellia128;\nextern const struct nettle_cipher nettle_camellia192;\nextern const struct nettle_cipher nettle_camellia256;\n\nextern const struct nettle_cipher nettle_cast128;\n\nextern const struct nettle_cipher nettle_serpent128;\nextern const struct nettle_cipher nettle_serpent192;\nextern const struct nettle_cipher nettle_serpent256;\n\nextern const struct nettle_cipher nettle_twofish128;\nextern const struct nettle_cipher nettle_twofish192;\nextern const struct nettle_cipher nettle_twofish256;\n\nextern const struct nettle_cipher nettle_arctwo40;\nextern const struct nettle_cipher nettle_arctwo64;\nextern const struct nettle_cipher nettle_arctwo128;\nextern const struct nettle_cipher nettle_arctwo_gutmann128;\n\nextern const struct nettle_cipher nettle_sm4;\n\nstruct nettle_hash\n{\n  const char *name;\n\n  /* Size of the context struct */\n  unsigned context_size;\n\n  /* Size of digests */\n  unsigned digest_size;\n  \n  /* Internal block size */\n  unsigned block_size;\n\n  nettle_hash_init_func *init;\n  nettle_hash_update_func *update;\n  nettle_hash_digest_func *digest;\n};\n\n#define _NETTLE_HASH(name, NAME) {\t\t\\\n #name,\t\t\t\t\t\t\\\n sizeof(struct name##_ctx),\t\t\t\\\n NAME##_DIGEST_SIZE,\t\t\t\t\\\n NAME##_BLOCK_SIZE,\t\t\t\t\\\n (nettle_hash_init_func *) name##_init,\t\t\\\n (nettle_hash_update_func *) name##_update,\t\\\n (nettle_hash_digest_func *) name##_digest\t\\\n} \n\n/* null-terminated list of digests implemented by this version of nettle */\nconst struct nettle_hash * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_hashes (void);\n\n#define nettle_hashes (nettle_get_hashes())\n\nconst struct nettle_hash *\nnettle_lookup_hash (const char *name);\n\nextern const struct nettle_hash nettle_md2;\nextern const struct nettle_hash nettle_md4;\nextern const struct nettle_hash nettle_md5;\nextern const struct nettle_hash nettle_gosthash94;\nextern const struct nettle_hash nettle_gosthash94cp;\nextern const struct nettle_hash nettle_ripemd160;\nextern const struct nettle_hash nettle_sha1;\nextern const struct nettle_hash nettle_sha224;\nextern const struct nettle_hash nettle_sha256;\nextern const struct nettle_hash nettle_sha384;\nextern const struct nettle_hash nettle_sha512;\nextern const struct nettle_hash nettle_sha512_224;\nextern const struct nettle_hash nettle_sha512_256;\nextern const struct nettle_hash nettle_sha3_224;\nextern const struct nettle_hash nettle_sha3_256;\nextern const struct nettle_hash nettle_sha3_384;\nextern const struct nettle_hash nettle_sha3_512;\nextern const struct nettle_hash nettle_streebog256;\nextern const struct nettle_hash nettle_streebog512;\nextern const struct nettle_hash nettle_sm3;\n\nstruct nettle_mac\n{\n  const char *name;\n\n  /* Size of the context struct */\n  unsigned context_size;\n\n  /* Size of digests */\n  unsigned digest_size;\n\n  /* Key size */\n  unsigned key_size;\n\n  nettle_set_key_func *set_key;\n  nettle_hash_update_func *update;\n  nettle_hash_digest_func *digest;\n};\n\nstruct nettle_aead\n{\n  const char *name;\n  \n  unsigned context_size;\n  /* Block size for encrypt and decrypt. */\n  unsigned block_size;\n  unsigned key_size;\n  unsigned nonce_size;\n  unsigned digest_size;\n\n  nettle_set_key_func *set_encrypt_key;\n  nettle_set_key_func *set_decrypt_key;\n  nettle_set_key_func *set_nonce;\n  nettle_hash_update_func *update;\n  nettle_crypt_func *encrypt;\n  nettle_crypt_func *decrypt;\n  /* FIXME: Drop length argument? */\n  nettle_hash_digest_func *digest;\n};\n\n/* null-terminated list of aead constructions implemented by this\n   version of nettle */\nconst struct nettle_aead * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_aeads (void);\n\n#define nettle_aeads (nettle_get_aeads())\n\nextern const struct nettle_aead nettle_gcm_aes128;\nextern const struct nettle_aead nettle_gcm_aes192;\nextern const struct nettle_aead nettle_gcm_aes256;\nextern const struct nettle_aead nettle_gcm_camellia128;\nextern const struct nettle_aead nettle_gcm_camellia256;\nextern const struct nettle_aead nettle_gcm_sm4;\nextern const struct nettle_aead nettle_eax_aes128;\nextern const struct nettle_aead nettle_chacha_poly1305;\n\nstruct nettle_armor\n{\n  const char *name;\n  unsigned encode_context_size;\n  unsigned decode_context_size;\n\n  unsigned encode_final_length;\n\n  nettle_armor_init_func *encode_init;\n  nettle_armor_length_func *encode_length;\n  nettle_armor_encode_update_func *encode_update;\n  nettle_armor_encode_final_func *encode_final;\n  \n  nettle_armor_init_func *decode_init;\n  nettle_armor_length_func *decode_length;\n  nettle_armor_decode_update_func *decode_update;\n  nettle_armor_decode_final_func *decode_final;\n};\n\n#define _NETTLE_ARMOR(name, NAME) {\t\t\t\t\\\n  #name,\t\t\t\t\t\t\t\\\n  sizeof(struct name##_encode_ctx),\t\t\t\t\\\n  sizeof(struct name##_decode_ctx),\t\t\t\t\\\n  NAME##_ENCODE_FINAL_LENGTH,\t\t\t\t\t\\\n  (nettle_armor_init_func *) name##_encode_init,\t\t\\\n  (nettle_armor_length_func *) name##_encode_length,\t\t\\\n  (nettle_armor_encode_update_func *) name##_encode_update,\t\\\n  (nettle_armor_encode_final_func *) name##_encode_final,\t\\\n  (nettle_armor_init_func *) name##_decode_init,\t\t\\\n  (nettle_armor_length_func *) name##_decode_length,\t\t\\\n  (nettle_armor_decode_update_func *) name##_decode_update,\t\\\n  (nettle_armor_decode_final_func *) name##_decode_final,\t\\\n}\n\n#define _NETTLE_ARMOR_0(name, NAME) {\t\t\t\t\\\n  #name,\t\t\t\t\t\t\t\\\n  0,\t\t\t\t\t\t\t\t\\\n  sizeof(struct name##_decode_ctx),\t\t\t\t\\\n  NAME##_ENCODE_FINAL_LENGTH,\t\t\t\t\t\\\n  (nettle_armor_init_func *) name##_encode_init,\t\t\\\n  (nettle_armor_length_func *) name##_encode_length,\t\t\\\n  (nettle_armor_encode_update_func *) name##_encode_update,\t\\\n  (nettle_armor_encode_final_func *) name##_encode_final,\t\\\n  (nettle_armor_init_func *) name##_decode_init,\t\t\\\n  (nettle_armor_length_func *) name##_decode_length,\t\t\\\n  (nettle_armor_decode_update_func *) name##_decode_update,\t\\\n  (nettle_armor_decode_final_func *) name##_decode_final,\t\\\n}\n\n/* null-terminated list of armor schemes implemented by this version of nettle */\nconst struct nettle_armor * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_armors (void);\n\n#define nettle_armors (nettle_get_armors())\n\nextern const struct nettle_armor nettle_base64;\nextern const struct nettle_armor nettle_base64url;\nextern const struct nettle_armor nettle_base16;\n\n#define _NETTLE_HMAC(name, HASH) {\t\t\\\n  #name,\t\t\t\t\t\\\n  sizeof(struct name##_ctx),\t\t\t\\\n  HASH##_DIGEST_SIZE,\t\t\t\t\\\n  HASH##_DIGEST_SIZE,\t\t\t\t\\\n  name##_set_key_wrapper,\t\t\t\\\n  (nettle_hash_update_func *) name##_update,\t\\\n  (nettle_hash_digest_func *) name##_digest,\t\\\n}\n\n/* null-terminated list of macs implemented by this\n   version of nettle */\nconst struct nettle_mac * const * _NETTLE_ATTRIBUTE_PURE\nnettle_get_macs (void);\n\n#define nettle_macs (nettle_get_macs())\n\nextern const struct nettle_mac nettle_cmac_aes128;\nextern const struct nettle_mac nettle_cmac_aes256;\nextern const struct nettle_mac nettle_cmac_des3;\n\n/* HMAC variants with key size = digest size */\nextern const struct nettle_mac nettle_hmac_md5;\nextern const struct nettle_mac nettle_hmac_ripemd160;\nextern const struct nettle_mac nettle_hmac_sha1;\nextern const struct nettle_mac nettle_hmac_sha224;\nextern const struct nettle_mac nettle_hmac_sha256;\nextern const struct nettle_mac nettle_hmac_sha384;\nextern const struct nettle_mac nettle_hmac_sha512;\nextern const struct nettle_mac nettle_hmac_streebog256;\nextern const struct nettle_mac nettle_hmac_streebog512;\nextern const struct nettle_mac nettle_hmac_sm3;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_META_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/nettle-types.h",
    "content": "/* nettle-types.h\n\n   Copyright (C) 2005, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_TYPES_H\n#define NETTLE_TYPES_H\n\n/* For size_t */\n#include <stddef.h>\n#include <stdint.h>\n\n/* Attributes we want to use in installed header files, and hence\n   can't rely on config.h. */\n#ifdef __GNUC__\n\n#define _NETTLE_ATTRIBUTE_PURE __attribute__((pure))\n#ifndef _NETTLE_ATTRIBUTE_DEPRECATED\n/* Variant without message is supported since gcc-3.1 or so. */\n#define _NETTLE_ATTRIBUTE_DEPRECATED __attribute__((deprecated))\n#endif\n\n#else /* !__GNUC__ */\n\n#define _NETTLE_ATTRIBUTE_PURE\n#define _NETTLE_ATTRIBUTE_DEPRECATED\n\n#endif /* !__GNUC__ */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* An aligned 16-byte block. */\nunion nettle_block16\n{\n  uint8_t b[16];\n  unsigned long w[16 / sizeof(unsigned long)] _NETTLE_ATTRIBUTE_DEPRECATED;\n  uint64_t u64[2];\n};\n\nunion nettle_block8\n{\n  uint8_t b[8];\n  uint64_t u64;\n};\n\n/* Randomness. Used by key generation and dsa signature creation. */\ntypedef void nettle_random_func(void *ctx,\n\t\t\t\tsize_t length, uint8_t *dst);\n\n/* Progress report function, mainly for key generation. */\ntypedef void nettle_progress_func(void *ctx, int c);\n\n/* Realloc function, used by struct nettle_buffer. */\ntypedef void *nettle_realloc_func(void *ctx, void *p, size_t length);\n\n/* Ciphers */\ntypedef void nettle_set_key_func(void *ctx, const uint8_t *key);\n\n/* For block ciphers, const context. */\ntypedef void nettle_cipher_func(const void *ctx,\n\t\t\t\tsize_t length, uint8_t *dst,\n\t\t\t\tconst uint8_t *src);\n\n\n/* Uses a void * for cipher contexts. Used for crypt operations where\n   the internal state changes during the encryption. */\ntypedef void nettle_crypt_func(void *ctx,\n\t\t\t       size_t length, uint8_t *dst,\n\t\t\t       const uint8_t *src);\n\n/* Hash algorithms */\ntypedef void nettle_hash_init_func(void *ctx);\ntypedef void nettle_hash_update_func(void *ctx,\n\t\t\t\t     size_t length,\n\t\t\t\t     const uint8_t *src);\ntypedef void nettle_hash_digest_func(void *ctx,\n\t\t\t\t     size_t length, uint8_t *dst);\n\n/* ASCII armor codecs. NOTE: Experimental and subject to change. */\n\ntypedef size_t nettle_armor_length_func(size_t length);\ntypedef void nettle_armor_init_func(void *ctx);\n\ntypedef size_t nettle_armor_encode_update_func(void *ctx,\n\t\t\t\t\t       char *dst,\n\t\t\t\t\t       size_t src_length,\n\t\t\t\t\t       const uint8_t *src);\n\ntypedef size_t nettle_armor_encode_final_func(void *ctx, char *dst);\n\ntypedef int nettle_armor_decode_update_func(void *ctx,\n\t\t\t\t\t    size_t *dst_length,\n\t\t\t\t\t    uint8_t *dst,\n\t\t\t\t\t    size_t src_length,\n\t\t\t\t\t    const char *src);\n\ntypedef int nettle_armor_decode_final_func(void *ctx);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_TYPES_H */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/nist-keywrap.h",
    "content": "/* nist-keywrap.h\n\n   AES Key Wrap function.\n   implements RFC 3394\n   https://tools.ietf.org/html/rfc3394\n\n   Copyright (C) 2021 Nicolas Mora\n                 2021 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_NIST_KEYWRAP_H_INCLUDED\n#define NETTLE_NIST_KEYWRAP_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define nist_keywrap16 nettle_nist_keywrap16\n#define nist_keyunwrap16 nettle_nist_keyunwrap16\n#define aes128_keywrap nettle_aes128_keywrap\n#define aes192_keywrap nettle_aes192_keywrap\n#define aes256_keywrap nettle_aes256_keywrap\n#define aes128_keyunwrap nettle_aes128_keyunwrap\n#define aes192_keyunwrap nettle_aes192_keyunwrap\n#define aes256_keyunwrap nettle_aes256_keyunwrap\n\nvoid\nnist_keywrap16 (const void *ctx, nettle_cipher_func *encrypt,\n\t\tconst uint8_t *iv, size_t ciphertext_length,\n\t\tuint8_t *ciphertext, const uint8_t *cleartext);\n\nint\nnist_keyunwrap16 (const void *ctx, nettle_cipher_func *decrypt,\n        const uint8_t *iv, size_t cleartext_length,\n        uint8_t *cleartext, const uint8_t *ciphertext);\n\nvoid\naes128_keywrap (struct aes128_ctx *ctx,\n\t\tconst uint8_t *iv, size_t ciphertext_length,\n\t\tuint8_t *ciphertext, const uint8_t *cleartext);\n\nvoid\naes192_keywrap (struct aes192_ctx *ctx,\n\t\tconst uint8_t *iv, size_t ciphertext_length,\n\t\tuint8_t *ciphertext, const uint8_t *cleartext);\n\nvoid\naes256_keywrap (struct aes256_ctx *ctx,\n\t\tconst uint8_t *iv, size_t ciphertext_length,\n\t\tuint8_t *ciphertext, const uint8_t *cleartext);\n\nint\naes128_keyunwrap (struct aes128_ctx *ctx,\n\t\t  const uint8_t *iv, size_t cleartext_length,\n\t\t  uint8_t *cleartext, const uint8_t *ciphertext);\n\nint\naes192_keyunwrap (struct aes192_ctx *ctx,\n\t\t  const uint8_t *iv, size_t cleartext_length,\n\t\t  uint8_t *cleartext, const uint8_t *ciphertext);\n\nint\naes256_keyunwrap (struct aes256_ctx *ctx,\n\t\t  const uint8_t *iv, size_t cleartext_length,\n\t\t  uint8_t *cleartext, const uint8_t *ciphertext);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\t\t\t\t/* NETTLE_NIST_KEYWRAP_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/ocb.h",
    "content": "/* ocb.h\n\n   OCB AEAD mode, RFC 7253\n\n   Copyright (C) 2021 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_OCB_H_INCLUDED\n#define NETTLE_OCB_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define ocb_set_key nettle_ocb_set_key\n#define ocb_set_nonce nettle_ocb_set_nonce\n#define ocb_update nettle_ocb_update\n#define ocb_encrypt nettle_ocb_encrypt\n#define ocb_decrypt nettle_ocb_decrypt\n#define ocb_digest nettle_ocb_digest\n#define ocb_encrypt_message nettle_ocb_encrypt_message\n#define ocb_decrypt_message nettle_ocb_decrypt_message\n#define ocb_aes128_set_encrypt_key nettle_ocb_aes128_set_encrypt_key\n#define ocb_aes128_set_decrypt_key nettle_ocb_aes128_set_decrypt_key\n#define ocb_aes128_set_nonce nettle_ocb_aes128_set_nonce\n#define ocb_aes128_update nettle_ocb_aes128_update\n#define ocb_aes128_encrypt nettle_ocb_aes128_encrypt\n#define ocb_aes128_decrypt nettle_ocb_aes128_decrypt\n#define ocb_aes128_digest nettle_ocb_aes128_digest\n#define ocb_aes128_encrypt_message nettle_ocb_aes128_encrypt_message\n#define ocb_aes128_decrypt_message nettle_ocb_aes128_decrypt_message\n\n#define OCB_BLOCK_SIZE 16\n#define OCB_DIGEST_SIZE 16\n#define OCB_MAX_NONCE_SIZE 15\n\nstruct ocb_key {\n  /* L_*, L_$ and L_0, and one reserved entry */\n  union nettle_block16 L[4];\n};\n\nstruct ocb_ctx {\n  /* Initial offset, Offset_0 in the spec. */\n  union nettle_block16 initial;\n  /* Offset, updated per block. */\n  union nettle_block16 offset;\n  /* Authentication for the associated data */\n  union nettle_block16 sum;\n  /* Authentication for the message */\n  union nettle_block16 checksum;\n  /* Count of processed blocks. */\n  size_t data_count;\n  size_t message_count;\n};\n\nvoid\nocb_set_key (struct ocb_key *key, const void *cipher, nettle_cipher_func *f);\n\nvoid\nocb_set_nonce (struct ocb_ctx *ctx,\n\t       const void *cipher, nettle_cipher_func *f,\n\t       size_t tag_length, size_t nonce_length, const uint8_t *nonce);\n\nvoid\nocb_update (struct ocb_ctx *ctx, const struct ocb_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, const uint8_t *data);\n\nvoid\nocb_encrypt (struct ocb_ctx *ctx, const struct ocb_key *key,\n\t     const void *cipher, nettle_cipher_func *f,\n\t     size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nocb_decrypt (struct ocb_ctx *ctx, const struct ocb_key *key,\n\t     const void *encrypt_ctx, nettle_cipher_func *encrypt,\n\t     const void *decrypt_ctx, nettle_cipher_func *decrypt,\n\t     size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nocb_digest (const struct ocb_ctx *ctx, const struct ocb_key *key,\n\t    const void *cipher, nettle_cipher_func *f,\n\t    size_t length, uint8_t *digest);\n\n\nvoid\nocb_encrypt_message (const struct ocb_key *ocb_key,\n\t\t     const void *cipher, nettle_cipher_func *f,\n\t\t     size_t nlength, const uint8_t *nonce,\n\t\t     size_t alength, const uint8_t *adata,\n\t\t     size_t tlength,\n\t\t     size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nocb_decrypt_message (const struct ocb_key *ocb_key,\n\t\t     const void *encrypt_ctx, nettle_cipher_func *encrypt,\n\t\t     const void *decrypt_ctx, nettle_cipher_func *decrypt,\n\t\t     size_t nlength, const uint8_t *nonce,\n\t\t     size_t alength, const uint8_t *adata,\n\t\t     size_t tlength,\n\t\t     size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* OCB-AES */\n/* This struct represents an expanded key for ocb-aes encryption. For\n   decryption, a separate decryption context is needed as well. */\nstruct ocb_aes128_encrypt_key\n{\n  struct ocb_key ocb;\n  struct aes128_ctx encrypt;\n};\n\nvoid\nocb_aes128_set_encrypt_key (struct ocb_aes128_encrypt_key *ocb, const uint8_t *key);\n\nvoid\nocb_aes128_set_decrypt_key (struct ocb_aes128_encrypt_key *ocb, struct aes128_ctx *decrypt,\n\t\t\t    const uint8_t *key);\n\nvoid\nocb_aes128_set_nonce (struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t      size_t tag_length, size_t nonce_length, const uint8_t *nonce);\n\nvoid\nocb_aes128_update (struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t   size_t length, const uint8_t *data);\n\nvoid\nocb_aes128_encrypt(struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nocb_aes128_decrypt(struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t   const struct aes128_ctx *decrypt,\n\t\t   size_t length, uint8_t *dst, const uint8_t *src);\n\nvoid\nocb_aes128_digest(struct ocb_ctx *ctx, const struct ocb_aes128_encrypt_key *key,\n\t\t  size_t length, uint8_t *digest);\n\nvoid\nocb_aes128_encrypt_message (const struct ocb_aes128_encrypt_key *key,\n\t\t\t    size_t nlength, const uint8_t *nonce,\n\t\t\t    size_t alength, const uint8_t *adata,\n\t\t\t    size_t tlength,\n\t\t\t    size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nocb_aes128_decrypt_message (const struct ocb_aes128_encrypt_key *key,\n\t\t\t    const struct aes128_ctx *decrypt,\n\t\t\t    size_t nlength, const uint8_t *nonce,\n\t\t\t    size_t alength, const uint8_t *adata,\n\t\t\t    size_t tlength,\n\t\t\t    size_t mlength, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_OCB_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/pbkdf2.h",
    "content": "/* pbkdf2.h\n\n   PKCS #5 password-based key derivation function PBKDF2, see RFC 2898.\n\n   Copyright (C) 2012 Simon Josefsson\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PBKDF2_H_INCLUDED\n#define NETTLE_PBKDF2_H_INCLUDED\n\n#include \"nettle-meta.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/* Namespace mangling */\n#define pbkdf2 nettle_pbkdf2\n#define pbkdf2_hmac_sha1 nettle_pbkdf2_hmac_sha1\n#define pbkdf2_hmac_sha256 nettle_pbkdf2_hmac_sha256\n#define pbkdf2_hmac_sha384 nettle_pbkdf2_hmac_sha384\n#define pbkdf2_hmac_sha512 nettle_pbkdf2_hmac_sha512\n#define pbkdf2_hmac_gosthash94cp nettle_pbkdf2_hmac_gosthash94cp\n\nvoid\npbkdf2 (void *mac_ctx,\n\tnettle_hash_update_func *update,\n\tnettle_hash_digest_func *digest,\n\tsize_t digest_size, unsigned iterations,\n\tsize_t salt_length, const uint8_t *salt,\n\tsize_t length, uint8_t *dst);\n\n#define PBKDF2(ctx, update, digest, digest_size,\t\t\t\\\n\t       iterations, salt_length, salt, length, dst)\t\t\\\n  (0 ? ((update)((ctx), 0, (uint8_t *) 0),\t\t\t\t\\\n\t(digest)((ctx), 0, (uint8_t *) 0))\t\t\t\t\\\n   : pbkdf2 ((ctx),\t\t\t\t\t\t\t\\\n\t     (nettle_hash_update_func *)(update),\t\t\t\\\n\t     (nettle_hash_digest_func *)(digest),\t\t\t\\\n\t     (digest_size), (iterations),\t\t\t\t\\\n\t     (salt_length), (salt), (length), (dst)))\n\n/* PBKDF2 with specific PRFs. */\n\nvoid\npbkdf2_hmac_sha1 (size_t key_length, const uint8_t *key,\n\t\t  unsigned iterations,\n\t\t  size_t salt_length, const uint8_t *salt,\n\t\t  size_t length, uint8_t *dst);\n\nvoid\npbkdf2_hmac_sha256 (size_t key_length, const uint8_t *key,\n\t\t    unsigned iterations,\n\t\t    size_t salt_length, const uint8_t *salt,\n\t\t    size_t length, uint8_t *dst);\n\nvoid\npbkdf2_hmac_sha384 (size_t key_length, const uint8_t *key,\n\t\t    unsigned iterations,\n\t\t    size_t salt_length, const uint8_t *salt,\n\t\t    size_t length, uint8_t *dst);\n\nvoid\npbkdf2_hmac_sha512 (size_t key_length, const uint8_t *key,\n\t\t    unsigned iterations,\n\t\t    size_t salt_length, const uint8_t *salt,\n\t\t    size_t length, uint8_t *dst);\n\nvoid\npbkdf2_hmac_gosthash94cp (size_t key_length, const uint8_t *key,\n\t\t\t  unsigned iterations,\n\t\t\t  size_t salt_length, const uint8_t *salt,\n\t\t\t  size_t length, uint8_t *dst);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PBKDF2_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/pgp.h",
    "content": "/* pgp.h\n\n   PGP related functions.\n\n   Copyright (C) 2001, 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PGP_H_INCLUDED\n#define NETTLE_PGP_H_INCLUDED\n\n#include <time.h>\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define pgp_put_uint32 nettle_pgp_put_uint32\n#define pgp_put_uint16 nettle_pgp_put_uint16\n#define pgp_put_mpi nettle_pgp_put_mpi\n#define pgp_put_string nettle_pgp_put_string\n#define pgp_put_length nettle_pgp_put_length\n#define pgp_put_header nettle_pgp_put_header\n#define pgp_put_header_length nettle_pgp_put_header_length\n#define pgp_sub_packet_start nettle_pgp_sub_packet_start\n#define pgp_put_sub_packet nettle_pgp_put_sub_packet\n#define pgp_sub_packet_end nettle_pgp_sub_packet_end\n#define pgp_put_public_rsa_key nettle_pgp_put_public_rsa_key\n#define pgp_put_rsa_sha1_signature nettle_pgp_put_rsa_sha1_signature\n#define pgp_put_userid nettle_pgp_put_userid\n#define pgp_crc24 nettle_pgp_crc24\n#define pgp_armor nettle_pgp_armor\n\nstruct nettle_buffer;\nstruct rsa_public_key;\nstruct rsa_private_key;\nstruct sha1_ctx;\n\nint\npgp_put_uint32(struct nettle_buffer *buffer, uint32_t i);\n\nint\npgp_put_uint16(struct nettle_buffer *buffer, unsigned i);\n\nint\npgp_put_mpi(struct nettle_buffer *buffer, const mpz_t x);\n\nint\npgp_put_string(struct nettle_buffer *buffer,\n\t       unsigned length,\n\t       const uint8_t *s);\n\nint\npgp_put_length(struct nettle_buffer *buffer,\n\t       unsigned length);\n\nint\npgp_put_header(struct nettle_buffer *buffer,\n\t       unsigned tag, unsigned length);\n\nvoid\npgp_put_header_length(struct nettle_buffer *buffer,\n\t\t      /* start of the header */\n\t\t      unsigned start,\n\t\t      unsigned field_size);\n\nunsigned\npgp_sub_packet_start(struct nettle_buffer *buffer);\n\nint\npgp_put_sub_packet(struct nettle_buffer *buffer,\n\t\t   unsigned type,\n\t\t   unsigned length,\n\t\t   const uint8_t *data);\n\nvoid\npgp_sub_packet_end(struct nettle_buffer *buffer, unsigned start);\n\nint\npgp_put_public_rsa_key(struct nettle_buffer *,\n\t\t       const struct rsa_public_key *key,\n\t\t       time_t timestamp);\n\nint\npgp_put_rsa_sha1_signature(struct nettle_buffer *buffer,\n\t\t\t   const struct rsa_private_key *key,\n\t\t\t   const uint8_t *keyid,\n\t\t\t   unsigned type,\n\t\t\t   struct sha1_ctx *hash);\n\nint\npgp_put_userid(struct nettle_buffer *buffer,\n\t       unsigned length,\n\t       const uint8_t *name);\n\nuint32_t\npgp_crc24(unsigned length, const uint8_t *data);\n\nint\npgp_armor(struct nettle_buffer *buffer,\n\t  const char *tag,\n\t  unsigned length,\n\t  const uint8_t *data);\n\n/* Values that can be passed to pgp_put_header when the size of the\n * length field, but not the length itself, is known. Also the minimum length\n * for the given field size. */\nenum pgp_lengths\n  {\n    PGP_LENGTH_ONE_OCTET = 0,\n    PGP_LENGTH_TWO_OCTETS = 192,\n    PGP_LENGTH_FOUR_OCTETS = 8384,\n  };\n\nenum pgp_public_key_algorithm\n  {\n    PGP_RSA = 1,\n    PGP_RSA_ENCRYPT = 2,\n    PGP_RSA_SIGN = 3,\n    PGP_EL_GAMAL_ENCRYPT = 16,\n    PGP_DSA = 17,\n    PGP_EL_GAMAL = 20,\n  };\n\nenum pgp_symmetric_algorithm\n  {\n    PGP_PLAINTEXT = 0,\n    PGP_IDEA = 1,\n    PGP_3DES = 2,\n    PGP_CAST5 = 3,\n    PGP_BLOWFISH = 4,\n    PGP_SAFER_SK = 5,\n    PGP_AES128 = 7,\n    PGP_AES192 = 8,\n    PGP_AES256 = 9,\n  };\n\nenum pgp_compression_algorithm\n  {\n    PGP_UNCOMPRESSED = 0,\n    PGP_ZIP = 1,\n    PGP_ZLIB = 2,\n  };\n\nenum pgp_hash_algorithm\n  {\n    PGP_MD5 = 1,\n    PGP_SHA1 = 2,\n    PGP_RIPEMD = 3,\n    PGP_MD2 = 5,\n    PGP_TIGER192 = 6,\n    PGP_HAVAL = 7,\n  };\n\nenum pgp_tag\n  {\n    PGP_TAG_PUBLIC_SESSION_KEY = 1,\n    PGP_TAG_SIGNATURE = 2,\n    PGP_TAG_SYMMETRIC_SESSION_KEY = 3,\n    PGP_TAG_ONE_PASS_SIGNATURE = 4,\n    PGP_TAG_SECRET_KEY = 5,\n    PGP_TAG_PUBLIC_KEY = 6,\n    PGP_TAG_SECRET_SUBKEY = 7,\n    PGP_TAG_COMPRESSED = 8,\n    PGP_TAG_ENCRYPTED = 9,\n    PGP_TAG_MARKER = 10,\n    PGP_TAG_LITERAL = 11,\n    PGP_TAG_TRUST = 12,\n    PGP_TAG_USERID = 13,\n    PGP_TAG_PUBLIC_SUBKEY = 14,\n  };\n\nenum pgp_signature_type\n  {\n    PGP_SIGN_BINARY = 0,\n    PGP_SIGN_TEXT = 1,\n    PGP_SIGN_STANDALONE = 2,\n    PGP_SIGN_CERTIFICATION = 0x10,\n    PGP_SIGN_CERTIFICATION_PERSONA = 0x11,\n    PGP_SIGN_CERTIFICATION_CASUAL = 0x12,\n    PGP_SIGN_CERTIFICATION_POSITIVE = 0x13,\n    PGP_SIGN_SUBKEY = 0x18,\n    PGP_SIGN_KEY = 0x1f,\n    PGP_SIGN_REVOCATION = 0x20,\n    PGP_SIGN_REVOCATION_SUBKEY = 0x28,\n    PGP_SIGN_REVOCATION_CERTIFICATE = 0x30,\n    PGP_SIGN_TIMESTAMP = 0x40,\n  };\n\nenum pgp_subpacket_tag\n  {\n    PGP_SUBPACKET_CREATION_TIME = 2,\n    PGP_SUBPACKET_SIGNATURE_EXPIRATION_TIME = 3,\n    PGP_SUBPACKET_EXPORTABLE_CERTIFICATION = 4,\n    PGP_SUBPACKET_TRUST_SIGNATURE = 5,\n    PGP_SUBPACKET_REGULAR_EXPRESSION = 6,\n    PGP_SUBPACKET_REVOCABLE = 7,\n    PGP_SUBPACKET_KEY_EXPIRATION_TIME = 9,\n    PGP_SUBPACKET_PLACEHOLDER = 10 ,\n    PGP_SUBPACKET_PREFERRED_SYMMETRIC_ALGORITHMS = 11,\n    PGP_SUBPACKET_REVOCATION_KEY = 12,\n    PGP_SUBPACKET_ISSUER_KEY_ID = 16,\n    PGP_SUBPACKET_NOTATION_DATA = 20,\n    PGP_SUBPACKET_PREFERRED_HASH_ALGORITHMS = 21,\n    PGP_SUBPACKET_PREFERRED_COMPRESSION_ALGORITHMS = 22,\n    PGP_SUBPACKET_KEY_SERVER_PREFERENCES = 23,\n    PGP_SUBPACKET_PREFERRED_KEY_SERVER = 24,\n    PGP_SUBPACKET_PRIMARY_USER_ID = 25,\n    PGP_SUBPACKET_POLICY_URL = 26,\n    PGP_SUBPACKET_KEY_FLAGS = 27,\n    PGP_SUBPACKET_SIGNERS_USER_ID = 28,\n    PGP_SUBPACKET_REASON_FOR_REVOCATION = 29,\n  };\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PGP_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/pkcs1.h",
    "content": "/* pkcs1.h\n\n   PKCS1 embedding.\n\n   Copyright (C) 2003 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PKCS1_H_INCLUDED\n#define NETTLE_PKCS1_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define pkcs1_rsa_digest_encode nettle_pkcs1_rsa_digest_encode\n#define pkcs1_rsa_md5_encode nettle_pkcs1_rsa_md5_encode\n#define pkcs1_rsa_md5_encode_digest nettle_pkcs1_rsa_md5_encode_digest\n#define pkcs1_rsa_sha1_encode nettle_pkcs1_rsa_sha1_encode\n#define pkcs1_rsa_sha1_encode_digest nettle_pkcs1_rsa_sha1_encode_digest\n#define pkcs1_rsa_sha256_encode nettle_pkcs1_rsa_sha256_encode\n#define pkcs1_rsa_sha256_encode_digest nettle_pkcs1_rsa_sha256_encode_digest\n#define pkcs1_rsa_sha512_encode nettle_pkcs1_rsa_sha512_encode\n#define pkcs1_rsa_sha512_encode_digest nettle_pkcs1_rsa_sha512_encode_digest\n#define pkcs1_encrypt nettle_pkcs1_encrypt\n#define pkcs1_decrypt nettle_pkcs1_decrypt\n\nstruct md5_ctx;\nstruct sha1_ctx;\nstruct sha256_ctx;\nstruct sha512_ctx;\n\nint\npkcs1_encrypt (size_t key_size,\n\t       /* For padding */\n\t       void *random_ctx, nettle_random_func *random,\n\t       size_t length, const uint8_t *message,\n\t       mpz_t m);\n\nint\npkcs1_decrypt (size_t key_size,\n\t       const mpz_t m,\n\t       size_t *length, uint8_t *message);\n\nint\npkcs1_rsa_digest_encode(mpz_t m, size_t key_size,\n\t\t\tsize_t di_length, const uint8_t *digest_info);\n\nint\npkcs1_rsa_md5_encode(mpz_t m, size_t length, struct md5_ctx *hash);\n\nint\npkcs1_rsa_md5_encode_digest(mpz_t m, size_t length, const uint8_t *digest);\n\nint\npkcs1_rsa_sha1_encode(mpz_t m, size_t length, struct sha1_ctx *hash);\n\nint\npkcs1_rsa_sha1_encode_digest(mpz_t m, size_t length, const uint8_t *digest);\n\nint\npkcs1_rsa_sha256_encode(mpz_t m, size_t length, struct sha256_ctx *hash);\n\nint\npkcs1_rsa_sha256_encode_digest(mpz_t m, size_t length, const uint8_t *digest);\n\nint\npkcs1_rsa_sha512_encode(mpz_t m, size_t length, struct sha512_ctx *hash);\n\nint\npkcs1_rsa_sha512_encode_digest(mpz_t m, size_t length, const uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PKCS1_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/poly1305.h",
    "content": "/* poly1305.h\n\n   Poly1305 message authentication code.\n\n   Copyright (C) 2013 Nikos Mavrogiannopoulos\n   Copyright (C) 2013, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_POLY1305_H_INCLUDED\n#define NETTLE_POLY1305_H_INCLUDED\n\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define poly1305_aes_set_key nettle_poly1305_aes_set_key\n#define poly1305_aes_set_nonce nettle_poly1305_aes_set_nonce\n#define poly1305_aes_update nettle_poly1305_aes_update\n#define poly1305_aes_digest nettle_poly1305_aes_digest\n\n/* Low level functions/macros for the poly1305 construction. */\n\n#define POLY1305_BLOCK_SIZE 16\n\nstruct poly1305_ctx {\n  /* Key, 128-bit value and some cached multiples. */\n  union\n  {\n    uint32_t r32[6];\n    uint64_t r64[3];\n  } r;\n  uint32_t s32[3];\n  /* State, represented as words of 26, 32 or 64 bits, depending on\n     implementation. */\n  /* High bits first, to maintain alignment. */\n  uint32_t hh;\n  union\n  {\n    uint32_t h32[4];\n    uint64_t h64[2];\n  } h;\n};\n\n/* poly1305-aes */\n\n#define POLY1305_AES_KEY_SIZE 32\n#define POLY1305_AES_DIGEST_SIZE 16\n#define POLY1305_AES_NONCE_SIZE 16\n\nstruct poly1305_aes_ctx\n{\n  /* Keep aes context last, to make it possible to use a general\n     poly1305_update if other variants are added. */\n  struct poly1305_ctx pctx;\n  uint8_t block[POLY1305_BLOCK_SIZE];\n  unsigned index;\n  uint8_t nonce[POLY1305_BLOCK_SIZE];\n  struct aes128_ctx aes;\n};\n\n/* Also initialize the nonce to zero. */\nvoid\npoly1305_aes_set_key (struct poly1305_aes_ctx *ctx, const uint8_t *key);\n\n/* Optional, if not used, messages get incrementing nonces starting\n   from zero. */\nvoid\npoly1305_aes_set_nonce (struct poly1305_aes_ctx *ctx,\n\t\t        const uint8_t *nonce);\n\n/* Update is not aes-specific, but since this is the only implemented\n   variant, we need no more general poly1305_update. */\nvoid\npoly1305_aes_update (struct poly1305_aes_ctx *ctx, size_t length, const uint8_t *data);\n\n/* Also increments the nonce */\nvoid\npoly1305_aes_digest (struct poly1305_aes_ctx *ctx,\n\t       \t     size_t length, uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_POLY1305_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/pss-mgf1.h",
    "content": "/* pss-mgf1.h\n\n   PKCS#1 mask generation function 1, used in RSA-PSS (RFC-3447).\n\n   Copyright (C) 2017 Daiki Ueno\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PSS_MGF1_H_INCLUDED\n#define NETTLE_PSS_MGF1_H_INCLUDED\n\n#include \"nettle-meta.h\"\n\n#include \"sha1.h\"\n#include \"sha2.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/* Namespace mangling */\n#define pss_mgf1 nettle_pss_mgf1\n\nvoid\npss_mgf1(const void *seed, const struct nettle_hash *hash,\n\t size_t length, uint8_t *mask);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PSS_MGF1_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/pss.h",
    "content": "/* pss.h\n\n   PKCS#1 RSA-PSS (RFC-3447).\n\n   Copyright (C) 2017 Daiki Ueno\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_PSS_H_INCLUDED\n#define NETTLE_PSS_H_INCLUDED\n\n#include \"nettle-meta.h\"\n#include \"bignum.h\"\n\n#ifdef __cplusplus\nextern \"C\"\n{\n#endif\n\n/* Namespace mangling */\n#define pss_encode_mgf1 nettle_pss_encode_mgf1\n#define pss_verify_mgf1 nettle_pss_verify_mgf1\n\nint\npss_encode_mgf1(mpz_t m, size_t bits,\n\t\tconst struct nettle_hash *hash,\n\t\tsize_t salt_length, const uint8_t *salt,\n\t\tconst uint8_t *digest);\n\nint\npss_verify_mgf1(const mpz_t m, size_t bits,\n\t\tconst struct nettle_hash *hash,\n\t\tsize_t salt_length,\n\t\tconst uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_PSS_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/realloc.h",
    "content": "/* realloc.h\n\n   Copyright (C) 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_REALLOC_H_INCLUDED\n#define NETTLE_REALLOC_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nnettle_realloc_func nettle_realloc;\nnettle_realloc_func nettle_xrealloc;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_REALLOC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/ripemd160.h",
    "content": "/* ripemd160.h\n\n   RIPEMD-160 hash function.\n\n   Copyright (C) 2011 Andres Mejia\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_RIPEMD160_H_INCLUDED\n#define NETTLE_RIPEMD160_H_INCLUDED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include \"nettle-types.h\"\n\n/* Name mangling */\n#define ripemd160_init nettle_ripemd160_init\n#define ripemd160_update nettle_ripemd160_update\n#define ripemd160_digest nettle_ripemd160_digest\n\n/* RIPEMD160 */\n\n#define RIPEMD160_DIGEST_SIZE 20\n#define RIPEMD160_BLOCK_SIZE 64\n/* For backwards compatibility */\n#define RIPEMD160_DATA_SIZE RIPEMD160_BLOCK_SIZE\n\n/* Digest is kept internally as 5 32-bit words. */\n#define _RIPEMD160_DIGEST_LENGTH 5\n\nstruct ripemd160_ctx\n{\n  uint32_t state[_RIPEMD160_DIGEST_LENGTH];\n  uint64_t count;         /* 64-bit block count */\n  unsigned int index;\n  uint8_t block[RIPEMD160_BLOCK_SIZE];\n};\n\nvoid\nripemd160_init(struct ripemd160_ctx *ctx);\n\nvoid\nripemd160_update(struct ripemd160_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nripemd160_digest(struct ripemd160_ctx *ctx,\n\t\t size_t length,\n\t\t uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_RIPEMD160_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/rsa.h",
    "content": "/* rsa.h\n\n   The RSA publickey algorithm.\n\n   Copyright (C) 2001, 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_RSA_H_INCLUDED\n#define NETTLE_RSA_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"bignum.h\"\n\n#include \"md5.h\"\n#include \"sha1.h\"\n#include \"sha2.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define rsa_public_key_init nettle_rsa_public_key_init\n#define rsa_public_key_clear nettle_rsa_public_key_clear\n#define rsa_public_key_prepare nettle_rsa_public_key_prepare\n#define rsa_private_key_init nettle_rsa_private_key_init\n#define rsa_private_key_clear nettle_rsa_private_key_clear\n#define rsa_private_key_prepare nettle_rsa_private_key_prepare\n#define rsa_pkcs1_verify nettle_rsa_pkcs1_verify\n#define rsa_pkcs1_sign nettle_rsa_pkcs1_sign\n#define rsa_pkcs1_sign_tr nettle_rsa_pkcs1_sign_tr\n#define rsa_md5_sign nettle_rsa_md5_sign\n#define rsa_md5_sign_tr nettle_rsa_md5_sign_tr\n#define rsa_md5_verify nettle_rsa_md5_verify\n#define rsa_sha1_sign nettle_rsa_sha1_sign\n#define rsa_sha1_sign_tr nettle_rsa_sha1_sign_tr\n#define rsa_sha1_verify nettle_rsa_sha1_verify\n#define rsa_sha256_sign nettle_rsa_sha256_sign\n#define rsa_sha256_sign_tr nettle_rsa_sha256_sign_tr\n#define rsa_sha256_verify nettle_rsa_sha256_verify\n#define rsa_sha512_sign nettle_rsa_sha512_sign\n#define rsa_sha512_sign_tr nettle_rsa_sha512_sign_tr\n#define rsa_sha512_verify nettle_rsa_sha512_verify\n#define rsa_md5_sign_digest nettle_rsa_md5_sign_digest\n#define rsa_md5_sign_digest_tr nettle_rsa_md5_sign_digest_tr\n#define rsa_md5_verify_digest nettle_rsa_md5_verify_digest\n#define rsa_sha1_sign_digest nettle_rsa_sha1_sign_digest\n#define rsa_sha1_sign_digest_tr nettle_rsa_sha1_sign_digest_tr\n#define rsa_sha1_verify_digest nettle_rsa_sha1_verify_digest\n#define rsa_sha256_sign_digest nettle_rsa_sha256_sign_digest\n#define rsa_sha256_sign_digest_tr nettle_rsa_sha256_sign_digest_tr\n#define rsa_sha256_verify_digest nettle_rsa_sha256_verify_digest\n#define rsa_sha512_sign_digest nettle_rsa_sha512_sign_digest\n#define rsa_sha512_sign_digest_tr nettle_rsa_sha512_sign_digest_tr\n#define rsa_sha512_verify_digest nettle_rsa_sha512_verify_digest\n#define rsa_pss_sha256_sign_digest_tr nettle_rsa_pss_sha256_sign_digest_tr\n#define rsa_pss_sha256_verify_digest nettle_rsa_pss_sha256_verify_digest\n#define rsa_pss_sha384_sign_digest_tr nettle_rsa_pss_sha384_sign_digest_tr\n#define rsa_pss_sha384_verify_digest nettle_rsa_pss_sha384_verify_digest\n#define rsa_pss_sha512_sign_digest_tr nettle_rsa_pss_sha512_sign_digest_tr\n#define rsa_pss_sha512_verify_digest nettle_rsa_pss_sha512_verify_digest\n#define rsa_encrypt nettle_rsa_encrypt\n#define rsa_decrypt nettle_rsa_decrypt\n#define rsa_decrypt_tr nettle_rsa_decrypt_tr\n#define rsa_sec_decrypt nettle_rsa_sec_decrypt\n#define rsa_compute_root nettle_rsa_compute_root\n#define rsa_compute_root_tr nettle_rsa_compute_root_tr\n#define rsa_generate_keypair nettle_rsa_generate_keypair\n#define rsa_keypair_to_sexp nettle_rsa_keypair_to_sexp\n#define rsa_keypair_from_sexp_alist nettle_rsa_keypair_from_sexp_alist\n#define rsa_keypair_from_sexp nettle_rsa_keypair_from_sexp\n#define rsa_public_key_from_der_iterator nettle_rsa_public_key_from_der_iterator\n#define rsa_private_key_from_der_iterator nettle_rsa_private_key_from_der_iterator\n#define rsa_keypair_from_der nettle_rsa_keypair_from_der\n#define rsa_keypair_to_openpgp nettle_rsa_keypair_to_openpgp\n\n/* This limit is somewhat arbitrary. Technically, the smallest modulo\n   which makes sense at all is 15 = 3*5, phi(15) = 8, size 4 bits. But\n   for ridiculously small keys, not all odd e are possible (e.g., for\n   5 bits, the only possible modulo is 3*7 = 21, phi(21) = 12, and e =\n   3 don't work). The smallest size that makes sense with pkcs#1, and\n   which allows RSA encryption of one byte messages, is 12 octets, 89\n   bits. */\n\n#define RSA_MINIMUM_N_OCTETS 12\n#define RSA_MINIMUM_N_BITS (8*RSA_MINIMUM_N_OCTETS - 7)\n\nstruct rsa_public_key\n{\n  /* Size of the modulo, in octets. This is also the size of all\n   * signatures that are created or verified with this key. */\n  size_t size;\n  \n  /* Modulo */\n  mpz_t n;\n\n  /* Public exponent */\n  mpz_t e;\n};\n\nstruct rsa_private_key\n{\n  size_t size;\n\n  /* d is filled in by the key generation function; otherwise it's\n   * completely unused. */\n  mpz_t d;\n  \n  /* The two factors */\n  mpz_t p; mpz_t q;\n\n  /* d % (p-1), i.e. a e = 1 (mod (p-1)) */\n  mpz_t a;\n\n  /* d % (q-1), i.e. b e = 1 (mod (q-1)) */\n  mpz_t b;\n\n  /* modular inverse of q , i.e. c q = 1 (mod p) */\n  mpz_t c;\n};\n\n/* Signing a message works as follows:\n *\n * Store the private key in a rsa_private_key struct.\n *\n * Call rsa_private_key_prepare. This initializes the size attribute\n * to the length of a signature.\n *\n * Initialize a hashing context, by callling\n *   md5_init\n *\n * Hash the message by calling\n *   md5_update\n *\n * Create the signature by calling\n *   rsa_md5_sign\n *\n * The signature is represented as a mpz_t bignum. This call also\n * resets the hashing context.\n *\n * When done with the key and signature, don't forget to call\n * mpz_clear.\n */\n \n/* Calls mpz_init to initialize bignum storage. */\nvoid\nrsa_public_key_init(struct rsa_public_key *key);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\nrsa_public_key_clear(struct rsa_public_key *key);\n\nint\nrsa_public_key_prepare(struct rsa_public_key *key);\n\n/* Calls mpz_init to initialize bignum storage. */\nvoid\nrsa_private_key_init(struct rsa_private_key *key);\n\n/* Calls mpz_clear to deallocate bignum storage. */\nvoid\nrsa_private_key_clear(struct rsa_private_key *key);\n\nint\nrsa_private_key_prepare(struct rsa_private_key *key);\n\n\n/* PKCS#1 style signatures */\nint\nrsa_pkcs1_sign(const struct rsa_private_key *key,\n\t       size_t length, const uint8_t *digest_info,\n\t       mpz_t s);\n\nint\nrsa_pkcs1_sign_tr(const struct rsa_public_key *pub,\n  \t          const struct rsa_private_key *key,\n\t          void *random_ctx, nettle_random_func *random,\n\t          size_t length, const uint8_t *digest_info,\n   \t          mpz_t s);\nint\nrsa_pkcs1_verify(const struct rsa_public_key *key,\n\t\t size_t length, const uint8_t *digest_info,\n\t\t const mpz_t signature);\n\nint\nrsa_md5_sign(const struct rsa_private_key *key,\n             struct md5_ctx *hash,\n             mpz_t signature);\n\nint\nrsa_md5_sign_tr(const struct rsa_public_key *pub,\n\t\tconst struct rsa_private_key *key,\n\t\tvoid *random_ctx, nettle_random_func *random,\n\t\tstruct md5_ctx *hash, mpz_t s);\n\n\nint\nrsa_md5_verify(const struct rsa_public_key *key,\n               struct md5_ctx *hash,\n\t       const mpz_t signature);\n\nint\nrsa_sha1_sign(const struct rsa_private_key *key,\n              struct sha1_ctx *hash,\n              mpz_t signature);\n\nint\nrsa_sha1_sign_tr(const struct rsa_public_key *pub,\n\t\t const struct rsa_private_key *key,\n\t\t void *random_ctx, nettle_random_func *random,\n\t\t struct sha1_ctx *hash,\n\t\t mpz_t s);\n\nint\nrsa_sha1_verify(const struct rsa_public_key *key,\n                struct sha1_ctx *hash,\n\t\tconst mpz_t signature);\n\nint\nrsa_sha256_sign(const struct rsa_private_key *key,\n\t\tstruct sha256_ctx *hash,\n\t\tmpz_t signature);\n\nint\nrsa_sha256_sign_tr(const struct rsa_public_key *pub,\n\t\t   const struct rsa_private_key *key,\n\t\t   void *random_ctx, nettle_random_func *random,\n\t\t   struct sha256_ctx *hash,\n\t\t   mpz_t s);\n\nint\nrsa_sha256_verify(const struct rsa_public_key *key,\n\t\t  struct sha256_ctx *hash,\n\t\t  const mpz_t signature);\n\nint\nrsa_sha512_sign(const struct rsa_private_key *key,\n\t\tstruct sha512_ctx *hash,\n\t\tmpz_t signature);\n\nint\nrsa_sha512_sign_tr(const struct rsa_public_key *pub,\n\t\t   const struct rsa_private_key *key,\n\t\t   void *random_ctx, nettle_random_func *random,\n\t\t   struct sha512_ctx *hash,\n\t\t   mpz_t s);\n\nint\nrsa_sha512_verify(const struct rsa_public_key *key,\n\t\t  struct sha512_ctx *hash,\n\t\t  const mpz_t signature);\n\n/* Variants taking the digest as argument. */\nint\nrsa_md5_sign_digest(const struct rsa_private_key *key,\n\t\t    const uint8_t *digest,\n\t\t    mpz_t s);\n\nint\nrsa_md5_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t       const struct rsa_private_key *key,\n\t\t       void *random_ctx, nettle_random_func *random,\n\t\t       const uint8_t *digest, mpz_t s);\n\nint\nrsa_md5_verify_digest(const struct rsa_public_key *key,\n\t\t      const uint8_t *digest,\n\t\t      const mpz_t signature);\n\nint\nrsa_sha1_sign_digest(const struct rsa_private_key *key,\n\t\t     const uint8_t *digest,\n\t\t     mpz_t s);\n\nint\nrsa_sha1_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\tconst struct rsa_private_key *key,\n\t\t\tvoid *random_ctx, nettle_random_func *random,\n\t\t\tconst uint8_t *digest,\n\t\t\tmpz_t s);\n\nint\nrsa_sha1_verify_digest(const struct rsa_public_key *key,\n\t\t       const uint8_t *digest,\n\t\t       const mpz_t signature);\n\nint\nrsa_sha256_sign_digest(const struct rsa_private_key *key,\n\t\t       const uint8_t *digest,\n\t\t       mpz_t s);\n\nint\nrsa_sha256_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t  const struct rsa_private_key *key,\n\t\t\t  void *random_ctx, nettle_random_func *random,\n\t\t\t  const uint8_t *digest,\n\t\t\t  mpz_t s);\n\nint\nrsa_sha256_verify_digest(const struct rsa_public_key *key,\n\t\t\t const uint8_t *digest,\n\t\t\t const mpz_t signature);\n\nint\nrsa_sha512_sign_digest(const struct rsa_private_key *key,\n\t\t       const uint8_t *digest,\n\t\t       mpz_t s);\n\nint\nrsa_sha512_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t  const struct rsa_private_key *key,\n\t\t\t  void *random_ctx, nettle_random_func *random,\n\t\t\t  const uint8_t *digest,\n\t\t\t  mpz_t s);\n\nint\nrsa_sha512_verify_digest(const struct rsa_public_key *key,\n\t\t\t const uint8_t *digest,\n\t\t\t const mpz_t signature);\n\n/* PSS style signatures */\nint\nrsa_pss_sha256_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t      const struct rsa_private_key *key,\n\t\t\t      void *random_ctx, nettle_random_func *random,\n\t\t\t      size_t salt_length, const uint8_t *salt,\n\t\t\t      const uint8_t *digest,\n\t\t\t      mpz_t s);\n\nint\nrsa_pss_sha256_verify_digest(const struct rsa_public_key *key,\n\t\t\t     size_t salt_length,\n\t\t\t     const uint8_t *digest,\n\t\t\t     const mpz_t signature);\n\nint\nrsa_pss_sha384_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t      const struct rsa_private_key *key,\n\t\t\t      void *random_ctx, nettle_random_func *random,\n\t\t\t      size_t salt_length, const uint8_t *salt,\n\t\t\t      const uint8_t *digest,\n\t\t\t      mpz_t s);\n\nint\nrsa_pss_sha384_verify_digest(const struct rsa_public_key *key,\n\t\t\t     size_t salt_length,\n\t\t\t     const uint8_t *digest,\n\t\t\t     const mpz_t signature);\n\nint\nrsa_pss_sha512_sign_digest_tr(const struct rsa_public_key *pub,\n\t\t\t      const struct rsa_private_key *key,\n\t\t\t      void *random_ctx, nettle_random_func *random,\n\t\t\t      size_t salt_length, const uint8_t *salt,\n\t\t\t      const uint8_t *digest,\n\t\t\t      mpz_t s);\n\nint\nrsa_pss_sha512_verify_digest(const struct rsa_public_key *key,\n\t\t\t     size_t salt_length,\n\t\t\t     const uint8_t *digest,\n\t\t\t     const mpz_t signature);\n\n\n/* RSA encryption, using PKCS#1 */\n/* These functions uses the v1.5 padding. What should the v2 (OAEP)\n * functions be called? */\n\n/* Returns 1 on success, 0 on failure, which happens if the\n * message is too long for the key. */\nint\nrsa_encrypt(const struct rsa_public_key *key,\n\t    /* For padding */\n\t    void *random_ctx, nettle_random_func *random,\n\t    size_t length, const uint8_t *cleartext,\n\t    mpz_t cipher);\n\n/* Message must point to a buffer of size *LENGTH. KEY->size is enough\n * for all valid messages. On success, *LENGTH is updated to reflect\n * the actual length of the message. Returns 1 on success, 0 on\n * failure, which happens if decryption failed or if the message\n * didn't fit. */\nint\nrsa_decrypt(const struct rsa_private_key *key,\n\t    size_t *length, uint8_t *cleartext,\n\t    const mpz_t ciphertext);\n\n/* Timing-resistant version, using randomized RSA blinding. */\nint\nrsa_decrypt_tr(const struct rsa_public_key *pub,\n\t       const struct rsa_private_key *key,\n\t       void *random_ctx, nettle_random_func *random,\t       \n\t       size_t *length, uint8_t *message,\n\t       const mpz_t gibberish);\n\n/* like rsa_decrypt_tr but with additional side-channel resistance.\n * NOTE: the length of the final message must be known in advance. */\nint\nrsa_sec_decrypt(const struct rsa_public_key *pub,\n\t        const struct rsa_private_key *key,\n\t        void *random_ctx, nettle_random_func *random,\n\t        size_t length, uint8_t *message,\n\t        const mpz_t gibberish);\n\n/* Compute x, the e:th root of m. Calling it with x == m is allowed.\n   It is required that 0 <= m < n. */\nvoid\nrsa_compute_root(const struct rsa_private_key *key,\n\t\t mpz_t x, const mpz_t m);\n\n/* Safer variant, using RSA blinding, and checking the result after\n   CRT. It is required that 0 <= m < n. */\nint\nrsa_compute_root_tr(const struct rsa_public_key *pub,\n\t\t    const struct rsa_private_key *key,\n\t\t    void *random_ctx, nettle_random_func *random,\n\t\t    mpz_t x, const mpz_t m);\n\n/* Key generation */\n\n/* Note that the key structs must be initialized first. */\nint\nrsa_generate_keypair(struct rsa_public_key *pub,\n\t\t     struct rsa_private_key *key,\n\n\t\t     void *random_ctx, nettle_random_func *random,\n\t\t     void *progress_ctx, nettle_progress_func *progress,\n\n\t\t     /* Desired size of modulo, in bits */\n\t\t     unsigned n_size,\n\t\t     \n\t\t     /* Desired size of public exponent, in bits. If\n\t\t      * zero, the passed in value pub->e is used. */\n\t\t     unsigned e_size);\n\n\n#define RSA_SIGN(key, algorithm, ctx, length, data, signature) ( \\\n  algorithm##_update(ctx, length, data), \\\n  rsa_##algorithm##_sign(key, ctx, signature) \\\n)\n\n#define RSA_VERIFY(key, algorithm, ctx, length, data, signature) ( \\\n  algorithm##_update(ctx, length, data), \\\n  rsa_##algorithm##_verify(key, ctx, signature) \\\n)\n\n\f\n/* Keys in sexp form. */\n\nstruct nettle_buffer;\n\n/* Generates a public-key expression if PRIV is NULL .*/\nint\nrsa_keypair_to_sexp(struct nettle_buffer *buffer,\n\t\t    const char *algorithm_name, /* NULL means \"rsa\" */\n\t\t    const struct rsa_public_key *pub,\n\t\t    const struct rsa_private_key *priv);\n\nstruct sexp_iterator;\n\nint\nrsa_keypair_from_sexp_alist(struct rsa_public_key *pub,\n\t\t\t    struct rsa_private_key *priv,\n\t\t\t    unsigned limit,\n\t\t\t    struct sexp_iterator *i);\n\n/* If PRIV is NULL, expect a public-key expression. If PUB is NULL,\n * expect a private key expression and ignore the parts not needed for\n * the public key. */\n/* Keys must be initialized before calling this function, as usual. */\nint\nrsa_keypair_from_sexp(struct rsa_public_key *pub,\n\t\t      struct rsa_private_key *priv,\n\t\t      unsigned limit,\n\t\t      size_t length, const uint8_t *expr);\n\n\n/* Keys in PKCS#1 format. */\nstruct asn1_der_iterator;\n\nint\nrsa_public_key_from_der_iterator(struct rsa_public_key *pub,\n\t\t\t\t unsigned limit,\n\t\t\t\t struct asn1_der_iterator *i);\n\nint\nrsa_private_key_from_der_iterator(struct rsa_public_key *pub,\n\t\t\t\t  struct rsa_private_key *priv,\n\t\t\t\t  unsigned limit,\n\t\t\t\t  struct asn1_der_iterator *i);\n\n/* For public keys, use PRIV == NULL */ \nint\nrsa_keypair_from_der(struct rsa_public_key *pub,\n\t\t     struct rsa_private_key *priv,\n\t\t     unsigned limit, \n\t\t     size_t length, const uint8_t *data);\n\n/* OpenPGP format. Experimental interface, subject to change. */\nint\nrsa_keypair_to_openpgp(struct nettle_buffer *buffer,\n\t\t       const struct rsa_public_key *pub,\n\t\t       const struct rsa_private_key *priv,\n\t\t       /* A single user id. NUL-terminated utf8. */\n\t\t       const char *userid);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_RSA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/salsa20.h",
    "content": "/* salsa20.h\n\n   The Salsa20 stream cipher.\n\n   Copyright (C) 2012 Simon Josefsson\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SALSA20_H_INCLUDED\n#define NETTLE_SALSA20_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define salsa20_set_key nettle_salsa20_set_key\n#define salsa20_128_set_key nettle_salsa20_128_set_key\n#define salsa20_256_set_key nettle_salsa20_256_set_key\n#define salsa20_set_nonce nettle_salsa20_set_nonce\n#define salsa20_crypt nettle_salsa20_crypt\n\n#define salsa20r12_crypt nettle_salsa20r12_crypt\n\n/* Alias for backwards compatibility */\n#define salsa20_set_iv nettle_salsa20_set_nonce\n\n/* In octets.*/\n#define SALSA20_128_KEY_SIZE 16\n#define SALSA20_256_KEY_SIZE 32\n#define SALSA20_BLOCK_SIZE 64\n#define SALSA20_NONCE_SIZE 8\n#define SALSA20_IV_SIZE SALSA20_NONCE_SIZE\n\n/* Aliases */\n#define SALSA20_MIN_KEY_SIZE 16\n#define SALSA20_MAX_KEY_SIZE 32\n#define SALSA20_KEY_SIZE 32\n\n#define _SALSA20_INPUT_LENGTH 16\n\nstruct salsa20_ctx\n{\n  /* Indices 1-4 and 11-14 holds the key (two identical copies for the\n     shorter key size), indices 0, 5, 10, 15 are constant, indices 6, 7\n     are the IV, and indices 8, 9 are the block counter:\n\n     C K K K\n     K C I I\n     B B C K\n     K K K C\n  */\n  uint32_t input[_SALSA20_INPUT_LENGTH];\n};\n\nvoid\nsalsa20_128_set_key(struct salsa20_ctx *ctx, const uint8_t *key);\nvoid\nsalsa20_256_set_key(struct salsa20_ctx *ctx, const uint8_t *key);\n\nvoid\nsalsa20_set_key(struct salsa20_ctx *ctx,\n\t\tsize_t length, const uint8_t *key);\n\nvoid\nsalsa20_set_nonce(struct salsa20_ctx *ctx, const uint8_t *nonce);\n  \nvoid\nsalsa20_crypt(struct salsa20_ctx *ctx,\n\t      size_t length, uint8_t *dst,\n\t      const uint8_t *src);\n\nvoid\nsalsa20r12_crypt(struct salsa20_ctx *ctx,\n\t\t size_t length, uint8_t *dst,\n\t\t const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SALSA20_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/serpent.h",
    "content": "/* serpent.h\n\n   The serpent block cipher.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/* Serpent is a 128-bit block cipher that accepts a key size of 256\n * bits, designed by Ross Anderson, Eli Biham, and Lars Knudsen. See\n * http://www.cl.cam.ac.uk/~rja14/serpent.html for details.\n */\n\n#ifndef NETTLE_SERPENT_H_INCLUDED\n#define NETTLE_SERPENT_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define serpent_set_key nettle_serpent_set_key\n#define serpent128_set_key nettle_serpent128_set_key\n#define serpent192_set_key nettle_serpent192_set_key\n#define serpent256_set_key nettle_serpent256_set_key\n#define serpent_encrypt nettle_serpent_encrypt\n#define serpent_decrypt nettle_serpent_decrypt\n\n#define SERPENT_BLOCK_SIZE 16\n\n/* Other key lengths are possible, but the design of Serpent makes\n * smaller key lengths quite pointless; they cheated with the AES\n * requirements, using a 256-bit key length exclusively and just\n * padding it out if the desired key length was less, so there really\n * is no advantage to using key lengths less than 256 bits. */\n#define SERPENT_KEY_SIZE 32\n\n/* Allow keys of size 128 <= bits <= 256 */\n\n#define SERPENT_MIN_KEY_SIZE 16\n#define SERPENT_MAX_KEY_SIZE 32\n\n#define SERPENT128_KEY_SIZE 16\n#define SERPENT192_KEY_SIZE 24\n#define SERPENT256_KEY_SIZE 32\n\nstruct serpent_ctx\n{\n  uint32_t keys[33][4];  /* key schedule */\n};\n\nvoid\nserpent_set_key(struct serpent_ctx *ctx,\n                size_t length, const uint8_t *key);\nvoid\nserpent128_set_key(struct serpent_ctx *ctx, const uint8_t *key);\nvoid\nserpent192_set_key(struct serpent_ctx *ctx, const uint8_t *key);\nvoid\nserpent256_set_key(struct serpent_ctx *ctx, const uint8_t *key);\n\nvoid\nserpent_encrypt(const struct serpent_ctx *ctx,\n                size_t length, uint8_t *dst,\n                const uint8_t *src);\nvoid\nserpent_decrypt(const struct serpent_ctx *ctx,\n                size_t length, uint8_t *dst,\n                const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SERPENT_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/sexp.h",
    "content": "/* sexp.h\n\n   Parsing s-expressions.\n   Copyright (C) 2002 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_SEXP_H_INCLUDED\n#define NETTLE_SEXP_H_INCLUDED\n\n#include <stdarg.h>\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sexp_iterator_first nettle_sexp_iterator_first\n#define sexp_transport_iterator_first nettle_sexp_transport_iterator_first\n#define sexp_iterator_next nettle_sexp_iterator_next\n#define sexp_iterator_enter_list nettle_sexp_iterator_enter_list\n#define sexp_iterator_exit_list nettle_sexp_iterator_exit_list\n#define sexp_iterator_subexpr nettle_sexp_iterator_subexpr\n#define sexp_iterator_get_uint32 nettle_sexp_iterator_get_uint32\n#define sexp_iterator_check_type nettle_sexp_iterator_check_type\n#define sexp_iterator_check_types nettle_sexp_iterator_check_types\n#define sexp_iterator_assoc nettle_sexp_iterator_assoc\n#define sexp_format nettle_sexp_format\n#define sexp_vformat nettle_sexp_vformat\n#define sexp_transport_format nettle_sexp_transport_format\n#define sexp_transport_vformat nettle_sexp_transport_vformat\n#define sexp_token_chars nettle_sexp_token_chars\n\nenum sexp_type\n  { SEXP_ATOM, SEXP_LIST, SEXP_END };\n\nstruct sexp_iterator\n{\n  size_t length;\n  const uint8_t *buffer;\n\n  /* Points at the start of the current sub expression. */\n  size_t start;\n  /* If type is SEXP_LIST, pos points at the start of the current\n   * element. Otherwise, it points at the end. */\n  size_t pos;\n  unsigned level;\n\n  enum sexp_type type;\n  \n  size_t display_length;\n  const uint8_t *display;\n\n  size_t atom_length;\n  const uint8_t *atom;\n};\n\n\n/* All these functions return 1 on success, 0 on failure */\n\n/* Initializes the iterator. */\nint\nsexp_iterator_first(struct sexp_iterator *iterator,\n\t\t    size_t length, const uint8_t *input);\n\n/* NOTE: Decodes the input string in place */\nint\nsexp_transport_iterator_first(struct sexp_iterator *iterator,\n\t\t\t      size_t length, uint8_t *input);\n\nint\nsexp_iterator_next(struct sexp_iterator *iterator);\n\n/* Current element must be a list. */\nint\nsexp_iterator_enter_list(struct sexp_iterator *iterator);\n\n/* Skips the rest of the current list */\nint\nsexp_iterator_exit_list(struct sexp_iterator *iterator);\n\n#if 0\n/* Skips out of as many lists as necessary to get back to the given\n * level. */\nint\nsexp_iterator_exit_lists(struct sexp_iterator *iterator,\n\t\t\t unsigned level);\n#endif\n\n/* Gets start and length of the current subexpression. Implies\n * sexp_iterator_next. */\nconst uint8_t *\nsexp_iterator_subexpr(struct sexp_iterator *iterator,\n\t\t      size_t *length);\n\nint\nsexp_iterator_get_uint32(struct sexp_iterator *iterator,\n\t\t\t uint32_t *x);\n\n\f\n/* Checks the type of the current expression, which should be a list\n *\n *  (<type> ...)\n */\nint\nsexp_iterator_check_type(struct sexp_iterator *iterator,\n\t\t\t const char *type);\n\nconst char *\nsexp_iterator_check_types(struct sexp_iterator *iterator,\n\t\t\t  unsigned ntypes,\n\t\t\t  const char * const *types);\n\n/* Current element must be a list. Looks up element of type\n *\n *   (key rest...)\n *\n * For a matching key, the corresponding iterator is initialized\n * pointing at the start of REST.\n *\n * On success, exits the current list.\n */\nint\nsexp_iterator_assoc(struct sexp_iterator *iterator,\n\t\t    unsigned nkeys,\n\t\t    const char * const *keys,\n\t\t    struct sexp_iterator *values);\n\n\f\n/* Output functions. What is a reasonable API for this? It seems\n * ugly to have to reimplement string streams. */\n\n/* Declared for real in buffer.h */\nstruct nettle_buffer;\n\n/* Returns the number of output characters, or 0 on out of memory. If\n * buffer == NULL, just compute length.\n *\n * Format strings can contained matched parentheses, tokens (\"foo\" in\n * the format string is formatted as \"3:foo\"), whitespace (which\n * separates tokens but is otherwise ignored) and the following\n * formatting specifiers:\n *\n *   %s   String represented as size_t length, const uint8_t *data.\n *\n *   %t   Optional display type, represented as\n *        size_t display_length, const uint8_t *display,\n *        display == NULL means no display type.\n *\n *   %i   Non-negative small integer, uint32_t.\n *\n *   %b   Non-negative bignum, mpz_t.\n *\n *   %l   Literal string (no length added), typically a balanced\n *        subexpression. Represented as size_t length, const uint8_t\n *        *data.\n *\n *   %(, %)  Allows insertion of unbalanced parenthesis.\n *\n * Modifiers:\n *\n *   %0   For %s, %t and %l, says that there's no length argument,\n *        instead the string is NUL-terminated, and there's only one\n *        const uint8_t * argument.\n */\n \nsize_t\nsexp_format(struct nettle_buffer *buffer,\n\t    const char *format, ...);\n\nsize_t\nsexp_vformat(struct nettle_buffer *buffer,\n\t     const char *format, va_list args);\n\nsize_t\nsexp_transport_format(struct nettle_buffer *buffer,\n\t\t      const char *format, ...);\n\nsize_t\nsexp_transport_vformat(struct nettle_buffer *buffer,\n\t\t       const char *format, va_list args);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SEXP_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/sha.h",
    "content": "/* sha.h\n\n   This file is deprecated, and provided only for backwards\n   compatibility with earlier versions of Nettle. Please use sha1.h\n   and/or sha2.h instead.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SHA_H_INCLUDED\n#define NETTLE_SHA_H_INCLUDED\n\n#include \"sha1.h\"\n#include \"sha2.h\"\n\n#endif /* NETTLE_SHA_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/sha1.h",
    "content": "/* sha1.h\n\n   The sha1 hash function.\n\n   Copyright (C) 2001, 2012 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_SHA1_H_INCLUDED\n#define NETTLE_SHA1_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sha1_init nettle_sha1_init\n#define sha1_update nettle_sha1_update\n#define sha1_digest nettle_sha1_digest\n#define sha1_compress nettle_sha1_compress\n\n/* SHA1 */\n\n#define SHA1_DIGEST_SIZE 20\n#define SHA1_BLOCK_SIZE 64\n/* For backwards compatibility */\n#define SHA1_DATA_SIZE SHA1_BLOCK_SIZE\n\n/* Digest is kept internally as 5 32-bit words. */\n#define _SHA1_DIGEST_LENGTH 5\n\nstruct sha1_ctx\n{\n  uint32_t state[_SHA1_DIGEST_LENGTH];    /* State variables */\n  uint64_t count;                         /* 64-bit block count */\n  unsigned int index;                     /* index into buffer */\n  uint8_t block[SHA1_BLOCK_SIZE];         /* SHA1 data buffer */\n};\n\nvoid\nsha1_init(struct sha1_ctx *ctx);\n\nvoid\nsha1_update(struct sha1_ctx *ctx,\n\t    size_t length,\n\t    const uint8_t *data);\n\nvoid\nsha1_digest(struct sha1_ctx *ctx,\n\t    size_t length,\n\t    uint8_t *digest);\n\n/* SHA1 compression function. STATE points to 5 uint32_t words,\n   and DATA points to 64 bytes of input data, possibly unaligned. */\nvoid\nsha1_compress(uint32_t *state, const uint8_t *data);\n\n/* Old name, for backwards compatibility. */\n#define _nettle_sha1_compress nettle_sha1_compress\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SHA1_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/sha2.h",
    "content": "/* sha2.h\n\n   The sha2 family of hash functions.\n\n   Copyright (C) 2001, 2012 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_SHA2_H_INCLUDED\n#define NETTLE_SHA2_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sha224_init nettle_sha224_init\n#define sha224_digest nettle_sha224_digest\n#define sha256_init nettle_sha256_init\n#define sha256_update nettle_sha256_update\n#define sha256_digest nettle_sha256_digest\n#define sha256_compress nettle_sha256_compress\n#define sha384_init nettle_sha384_init\n#define sha384_digest nettle_sha384_digest\n#define sha512_init nettle_sha512_init\n#define sha512_update nettle_sha512_update\n#define sha512_digest nettle_sha512_digest\n#define sha512_compress nettle_sha512_compress\n#define sha512_224_init   nettle_sha512_224_init\n#define sha512_224_digest nettle_sha512_224_digest\n#define sha512_256_init   nettle_sha512_256_init\n#define sha512_256_digest nettle_sha512_256_digest\n\n/* For backwards compatibility */\n#define SHA224_DATA_SIZE SHA256_BLOCK_SIZE\n#define SHA256_DATA_SIZE SHA256_BLOCK_SIZE\n#define SHA512_DATA_SIZE SHA512_BLOCK_SIZE\n#define SHA384_DATA_SIZE SHA512_BLOCK_SIZE\n\n/* SHA256 */\n\n#define SHA256_DIGEST_SIZE 32\n#define SHA256_BLOCK_SIZE 64\n\n/* Digest is kept internally as 8 32-bit words. */\n#define _SHA256_DIGEST_LENGTH 8\n\nstruct sha256_ctx\n{\n  uint32_t state[_SHA256_DIGEST_LENGTH];    /* State variables */\n  uint64_t count;                           /* 64-bit block count */\n  unsigned int index;                       /* index into buffer */\n  uint8_t block[SHA256_BLOCK_SIZE];          /* SHA256 data buffer */\n};\n\nvoid\nsha256_init(struct sha256_ctx *ctx);\n\nvoid\nsha256_update(struct sha256_ctx *ctx,\n\t      size_t length,\n\t      const uint8_t *data);\n\nvoid\nsha256_digest(struct sha256_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\nvoid\nsha256_compress(uint32_t *state, const uint8_t *input);\n\n/* SHA224, a truncated SHA256 with different initial state. */\n\n#define SHA224_DIGEST_SIZE 28\n#define SHA224_BLOCK_SIZE SHA256_BLOCK_SIZE\n#define sha224_ctx sha256_ctx\n\nvoid\nsha224_init(struct sha256_ctx *ctx);\n\n#define sha224_update nettle_sha256_update\n\nvoid\nsha224_digest(struct sha256_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\n\n/* SHA512 */\n\n#define SHA512_DIGEST_SIZE 64\n#define SHA512_BLOCK_SIZE 128\n\n/* Digest is kept internally as 8 64-bit words. */\n#define _SHA512_DIGEST_LENGTH 8\n\nstruct sha512_ctx\n{\n  uint64_t state[_SHA512_DIGEST_LENGTH];    /* State variables */\n  uint64_t count_low, count_high;           /* 128-bit block count */\n  unsigned int index;                       /* index into buffer */\n  uint8_t block[SHA512_BLOCK_SIZE];          /* SHA512 data buffer */\n};\n\nvoid\nsha512_init(struct sha512_ctx *ctx);\n\nvoid\nsha512_update(struct sha512_ctx *ctx,\n\t      size_t length,\n\t      const uint8_t *data);\n\nvoid\nsha512_digest(struct sha512_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\nvoid\nsha512_compress(uint64_t *state, const uint8_t *input);\n\n/* SHA384, a truncated SHA512 with different initial state. */\n\n#define SHA384_DIGEST_SIZE 48\n#define SHA384_BLOCK_SIZE SHA512_BLOCK_SIZE\n#define sha384_ctx sha512_ctx\n\nvoid\nsha384_init(struct sha512_ctx *ctx);\n\n#define sha384_update nettle_sha512_update\n\nvoid\nsha384_digest(struct sha512_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\n\n/* SHA512_224 and SHA512_256, two truncated versions of SHA512 \n   with different initial states. */\n\n#define SHA512_224_DIGEST_SIZE 28\n#define SHA512_224_BLOCK_SIZE SHA512_BLOCK_SIZE\n#define sha512_224_ctx sha512_ctx\n\nvoid\nsha512_224_init(struct sha512_224_ctx *ctx);\n\n#define sha512_224_update nettle_sha512_update\n\nvoid\nsha512_224_digest(struct sha512_224_ctx *ctx,\n                  size_t length,\n                  uint8_t *digest);\n\n#define SHA512_256_DIGEST_SIZE 32\n#define SHA512_256_BLOCK_SIZE SHA512_BLOCK_SIZE\n#define sha512_256_ctx sha512_ctx\n\nvoid\nsha512_256_init(struct sha512_256_ctx *ctx);\n\n#define sha512_256_update nettle_sha512_update\n\nvoid\nsha512_256_digest(struct sha512_256_ctx *ctx,\n                  size_t length,\n                  uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SHA2_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/sha3.h",
    "content": "/* sha3.h\n\n   The sha3 hash function (aka Keccak).\n\n   Copyright (C) 2012 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_SHA3_H_INCLUDED\n#define NETTLE_SHA3_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sha3_permute nettle_sha3_permute\n#define sha3_224_init nettle_sha3_224_init\n#define sha3_224_update nettle_sha3_224_update\n#define sha3_224_digest nettle_sha3_224_digest\n#define sha3_256_init nettle_sha3_256_init\n#define sha3_256_update nettle_sha3_256_update\n#define sha3_256_digest nettle_sha3_256_digest\n#define sha3_256_shake nettle_sha3_256_shake\n#define sha3_384_init nettle_sha3_384_init\n#define sha3_384_update nettle_sha3_384_update\n#define sha3_384_digest nettle_sha3_384_digest\n#define sha3_512_init nettle_sha3_512_init\n#define sha3_512_update nettle_sha3_512_update\n#define sha3_512_digest nettle_sha3_512_digest\n\n/* Indicates that SHA3 is the NIST FIPS 202 version. */\n#define NETTLE_SHA3_FIPS202 1\n\n/* The sha3 state is a 5x5 matrix of 64-bit words. In the notation of\n   Keccak description, S[x,y] is element x + 5*y, so if x is\n   interpreted as the row index and y the column index, it is stored\n   in column-major order. */\n#define SHA3_STATE_LENGTH 25\n\n/* The \"width\" is 1600 bits or 200 octets */\nstruct sha3_state\n{\n  uint64_t a[SHA3_STATE_LENGTH];\n};\n\nvoid\nsha3_permute (struct sha3_state *state);\n\n/* The \"capacity\" is set to 2*(digest size), 512 bits or 64 octets.\n   The \"rate\" is the width - capacity, or width - 2 * (digest\n   size). */\n\n#define SHA3_224_DIGEST_SIZE 28\n#define SHA3_224_BLOCK_SIZE 144\n\n#define SHA3_256_DIGEST_SIZE 32\n#define SHA3_256_BLOCK_SIZE 136\n\n#define SHA3_384_DIGEST_SIZE 48\n#define SHA3_384_BLOCK_SIZE 104\n\n#define SHA3_512_DIGEST_SIZE 64\n#define SHA3_512_BLOCK_SIZE 72\n\n/* For backwards compatibility */\n#define SHA3_224_DATA_SIZE SHA3_224_BLOCK_SIZE\n#define SHA3_256_DATA_SIZE SHA3_256_BLOCK_SIZE\n#define SHA3_384_DATA_SIZE SHA3_384_BLOCK_SIZE\n#define SHA3_512_DATA_SIZE SHA3_512_BLOCK_SIZE\n\nstruct sha3_224_ctx\n{\n  struct sha3_state state;\n  unsigned index;\n  uint8_t block[SHA3_224_BLOCK_SIZE];\n};\n\nvoid\nsha3_224_init (struct sha3_224_ctx *ctx);\n\nvoid\nsha3_224_update (struct sha3_224_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nsha3_224_digest(struct sha3_224_ctx *ctx,\n\t\tsize_t length,\n\t\tuint8_t *digest);\n\nstruct sha3_256_ctx\n{\n  struct sha3_state state;\n  unsigned index;\n  uint8_t block[SHA3_256_BLOCK_SIZE];\n};\n\nvoid\nsha3_256_init (struct sha3_256_ctx *ctx);\n\nvoid\nsha3_256_update (struct sha3_256_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nsha3_256_digest(struct sha3_256_ctx *ctx,\n\t\tsize_t length,\n\t\tuint8_t *digest);\n\n/* Alternative digest function implementing shake256, with arbitrary\n   digest size */\nvoid\nsha3_256_shake(struct sha3_256_ctx *ctx,\n\t       size_t length,\n\t       uint8_t *digest);\n\nstruct sha3_384_ctx\n{\n  struct sha3_state state;\n  unsigned index;\n  uint8_t block[SHA3_384_BLOCK_SIZE];\n};\n\nvoid\nsha3_384_init (struct sha3_384_ctx *ctx);\n\nvoid\nsha3_384_update (struct sha3_384_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nsha3_384_digest(struct sha3_384_ctx *ctx,\n\t\tsize_t length,\n\t\tuint8_t *digest);\n\nstruct sha3_512_ctx\n{\n  struct sha3_state state;\n  unsigned index;\n  uint8_t block[SHA3_512_BLOCK_SIZE];\n};\n\nvoid\nsha3_512_init (struct sha3_512_ctx *ctx);\n\nvoid\nsha3_512_update (struct sha3_512_ctx *ctx,\n\t\t size_t length,\n\t\t const uint8_t *data);\n\nvoid\nsha3_512_digest(struct sha3_512_ctx *ctx,\n\t\tsize_t length,\n\t\tuint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SHA3_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/siv-cmac.h",
    "content": "/* siv-cmac.h\n\n   AES-SIV, RFC5297\n\n   Copyright (C) 2017 Nikos Mavrogiannopoulos\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SIV_H_INCLUDED\n#define NETTLE_SIV_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"nettle-meta.h\"\n#include \"cmac.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define siv_cmac_set_key nettle_siv_cmac_set_key\n#define siv_cmac_encrypt_message nettle_siv_cmac_encrypt_message\n#define siv_cmac_decrypt_message nettle_siv_cmac_decrypt_message\n#define siv_cmac_aes128_set_key nettle_siv_cmac_aes128_set_key\n#define siv_cmac_aes128_encrypt_message nettle_siv_cmac_aes128_encrypt_message\n#define siv_cmac_aes128_decrypt_message nettle_siv_cmac_aes128_decrypt_message\n#define siv_cmac_aes256_set_key nettle_siv_cmac_aes256_set_key\n#define siv_cmac_aes256_encrypt_message nettle_siv_cmac_aes256_encrypt_message\n#define siv_cmac_aes256_decrypt_message nettle_siv_cmac_aes256_decrypt_message\n\n/* For SIV, the block size of the underlying cipher shall be 128 bits. */\n#define SIV_BLOCK_SIZE  16\n#define SIV_DIGEST_SIZE 16\n#define SIV_MIN_NONCE_SIZE 1\n\nvoid\nsiv_cmac_set_key(struct cmac128_key *cmac_key, void *cmac_cipher, void *ctr_cipher,\n\t\t const struct nettle_cipher *nc,\n\t\t const uint8_t *key);\n\nvoid\nsiv_cmac_encrypt_message(const struct cmac128_key *cmac_key, const void *cmac_cipher_ctx,\n\t\t\t const struct nettle_cipher *nc,\n\t\t\t const void *ctr_ctx,\n\t\t\t size_t nlength, const uint8_t *nonce,\n\t\t\t size_t alength, const uint8_t *adata,\n\t\t\t size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_cmac_decrypt_message(const struct cmac128_key *cmac_key, const void *cmac_cipher,\n\t\t\t const struct nettle_cipher *nc,\n\t\t\t const void *ctr_cipher,\n\t\t\t size_t nlength, const uint8_t *nonce,\n\t\t\t size_t alength, const uint8_t *adata,\n\t\t\t size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/*\n * SIV mode requires the aad and plaintext when building the IV, which\n * prevents streaming processing and it incompatible with the AEAD API.\n */\n\n#define SIV_CMAC_CTX(type) { struct cmac128_key cmac_key; type cmac_cipher; type ctr_cipher; }\n\n/* SIV_CMAC_AES128 */\n#define SIV_CMAC_AES128_KEY_SIZE 32\n\nstruct siv_cmac_aes128_ctx SIV_CMAC_CTX(struct aes128_ctx);\n\nvoid\nsiv_cmac_aes128_set_key(struct siv_cmac_aes128_ctx *ctx, const uint8_t *key);\n\nvoid\nsiv_cmac_aes128_encrypt_message(const struct siv_cmac_aes128_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_cmac_aes128_decrypt_message(const struct siv_cmac_aes128_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* SIV_CMAC_AES256 */\n#define SIV_CMAC_AES256_KEY_SIZE 64\n\nstruct siv_cmac_aes256_ctx SIV_CMAC_CTX(struct aes256_ctx);\n\nvoid\nsiv_cmac_aes256_set_key(struct siv_cmac_aes256_ctx *ctx, const uint8_t *key);\n\nvoid\nsiv_cmac_aes256_encrypt_message(const struct siv_cmac_aes256_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_cmac_aes256_decrypt_message(const struct siv_cmac_aes256_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t mlength, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SIV_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/siv-gcm.h",
    "content": "/* siv-gcm.h\n\n   AES-GCM-SIV, RFC8452\n\n   Copyright (C) 2022 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SIV_GCM_H_INCLUDED\n#define NETTLE_SIV_GCM_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"nettle-meta.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define siv_gcm_encrypt_message nettle_siv_gcm_encrypt_message\n#define siv_gcm_decrypt_message nettle_siv_gcm_decrypt_message\n#define siv_gcm_aes128_encrypt_message nettle_siv_gcm_aes128_encrypt_message\n#define siv_gcm_aes128_decrypt_message nettle_siv_gcm_aes128_decrypt_message\n#define siv_gcm_aes256_encrypt_message nettle_siv_gcm_aes256_encrypt_message\n#define siv_gcm_aes256_decrypt_message nettle_siv_gcm_aes256_decrypt_message\n\n/* For AES-GCM-SIV, the block size of the underlying cipher shall be 128 bits. */\n#define SIV_GCM_BLOCK_SIZE 16\n#define SIV_GCM_DIGEST_SIZE 16\n#define SIV_GCM_NONCE_SIZE 12\n\n/* Generic interface.  NC must be a block cipher with 128-bit block\n   size, and keysize that is a multiple of 64 bits, such as AES-128 or\n   AES-256.  */\nvoid\nsiv_gcm_encrypt_message (const struct nettle_cipher *nc,\n\t\t\t const void *ctx,\n\t\t\t void *ctr_ctx,\n\t\t\t size_t nlength, const uint8_t *nonce,\n\t\t\t size_t alength, const uint8_t *adata,\n\t\t\t size_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_gcm_decrypt_message (const struct nettle_cipher *nc,\n\t\t\t const void *ctx,\n\t\t\t void *ctr_ctx,\n\t\t\t size_t nlength, const uint8_t *nonce,\n\t\t\t size_t alength, const uint8_t *adata,\n\t\t\t size_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* AEAD_AES_128_GCM_SIV */\nvoid\nsiv_gcm_aes128_encrypt_message (const struct aes128_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_gcm_aes128_decrypt_message (const struct aes128_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t mlength, uint8_t *dst, const uint8_t *src);\n\n/* AEAD_AES_256_GCM_SIV */\nvoid\nsiv_gcm_aes256_encrypt_message (const struct aes256_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t clength, uint8_t *dst, const uint8_t *src);\n\nint\nsiv_gcm_aes256_decrypt_message (const struct aes256_ctx *ctx,\n\t\t\t\tsize_t nlength, const uint8_t *nonce,\n\t\t\t\tsize_t alength, const uint8_t *adata,\n\t\t\t\tsize_t mlength, uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SIV_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/sm3.h",
    "content": "/* sm3.h\n\n   The SM3 hash function.\n\n   Copyright (C) 2017 Jia Zhang\n   Copyright (C) 2021 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SM3_H_INCLUDED\n#define NETTLE_SM3_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sm3_init nettle_sm3_init\n#define sm3_update nettle_sm3_update\n#define sm3_digest nettle_sm3_digest\n\n#define SM3_DIGEST_SIZE 32\n#define SM3_BLOCK_SIZE 64\n\n/* Digest is kept internally as 8 32-bit words. */\n#define _SM3_DIGEST_LENGTH 8\n\nstruct sm3_ctx\n{\n  uint32_t state[_SM3_DIGEST_LENGTH];\n  uint64_t count;               /* Block count */\n  unsigned index;               /* Into buffer */\n  uint8_t block[SM3_BLOCK_SIZE]; /* Block buffer */\n};\n\nvoid\nsm3_init(struct sm3_ctx *ctx);\n\nvoid\nsm3_update(struct sm3_ctx *ctx,\n\t   size_t length,\n\t   const uint8_t *data);\n\nvoid\nsm3_digest(struct sm3_ctx *ctx,\n\t   size_t length,\n\t   uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SM3_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/sm4.h",
    "content": "/* sm4.h\n\n   Copyright (C) 2022 Tianjia Zhang <tianjia.zhang@linux.alibaba.com>\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_SM4_H_INCLUDED\n#define NETTLE_SM4_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define sm4_set_encrypt_key nettle_sm4_set_encrypt_key\n#define sm4_set_decrypt_key nettle_sm4_set_decrypt_key\n#define sm4_crypt nettle_sm4_crypt\n\n#define SM4_BLOCK_SIZE 16\n#define SM4_KEY_SIZE 16\n\nstruct sm4_ctx\n{\n  uint32_t rkey[32];\n};\n\nvoid\nsm4_set_encrypt_key(struct sm4_ctx *ctx, const uint8_t *key);\n\nvoid\nsm4_set_decrypt_key(struct sm4_ctx *ctx, const uint8_t *key);\n\nvoid\nsm4_crypt(const struct sm4_ctx *context,\n\t  size_t length, uint8_t *dst,\n\t  const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_SM4_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/streebog.h",
    "content": "/* streebog.h\n\n   The Streebog family of hash functions.\n\n   Copyright (C) 2020 Dmitry Baryshkov\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_STREEBOG_H_INCLUDED\n#define NETTLE_STREEBOG_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define streebog256_init nettle_streebog256_init\n#define streebog256_digest nettle_streebog256_digest\n#define streebog512_init nettle_streebog512_init\n#define streebog512_update nettle_streebog512_update\n#define streebog512_digest nettle_streebog512_digest\n\n/* STREEBOG512 */\n\n#define STREEBOG512_DIGEST_SIZE 64\n#define STREEBOG512_BLOCK_SIZE 64\n\n/* Digest is kept internally as 8 64-bit words. */\n#define _STREEBOG512_DIGEST_LENGTH 8\n\nstruct streebog512_ctx\n{\n  uint64_t state[_STREEBOG512_DIGEST_LENGTH];    /* State variables */\n  uint64_t count[_STREEBOG512_DIGEST_LENGTH];\n  uint64_t sigma[_STREEBOG512_DIGEST_LENGTH];\n  unsigned int index;                       /* index into buffer */\n  uint8_t block[STREEBOG512_BLOCK_SIZE];          /* STREEBOG512 data buffer */\n};\n\nvoid\nstreebog512_init(struct streebog512_ctx *ctx);\n\nvoid\nstreebog512_update(struct streebog512_ctx *ctx,\n\t      size_t length,\n\t      const uint8_t *data);\n\nvoid\nstreebog512_digest(struct streebog512_ctx *ctx,\n\t      size_t length,\n\t      uint8_t *digest);\n\n\n#define STREEBOG256_DIGEST_SIZE 32\n#define STREEBOG256_BLOCK_SIZE STREEBOG512_BLOCK_SIZE\n#define streebog256_ctx streebog512_ctx\n\nvoid\nstreebog256_init(struct streebog256_ctx *ctx);\n\n#define streebog256_update nettle_streebog512_update\n\nvoid\nstreebog256_digest(struct streebog256_ctx *ctx,\n\t\t  size_t length,\n\t\t  uint8_t *digest);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_STREEBOG_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/twofish.h",
    "content": "/* twofish.h\n\n   The twofish block cipher.\n\n   Copyright (C) 2001, 2014 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n/*\n * Twofish is a 128-bit block cipher that accepts a variable-length\n * key up to 256 bits, designed by Bruce Schneier and others.  See\n * http://www.counterpane.com/twofish.html for details.\n */\n\n#ifndef NETTLE_TWOFISH_H_INCLUDED\n#define NETTLE_TWOFISH_H_INCLUDED\n\n#include \"nettle-types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define twofish_set_key nettle_twofish_set_key\n#define twofish128_set_key nettle_twofish128_set_key\n#define twofish192_set_key nettle_twofish192_set_key\n#define twofish256_set_key nettle_twofish256_set_key\n#define twofish_encrypt nettle_twofish_encrypt\n#define twofish_decrypt nettle_twofish_decrypt\n\n#define TWOFISH_BLOCK_SIZE 16\n\n/* Variable key size between 128 and 256 bits. But the only valid\n * values are 16 (128 bits), 24 (192 bits) and 32 (256 bits). */\n#define TWOFISH_MIN_KEY_SIZE 16\n#define TWOFISH_MAX_KEY_SIZE 32\n\n#define TWOFISH_KEY_SIZE 32\n#define TWOFISH128_KEY_SIZE 16\n#define TWOFISH192_KEY_SIZE 24\n#define TWOFISH256_KEY_SIZE 32\n\nstruct twofish_ctx\n{\n  uint32_t keys[40];\n  uint32_t s_box[4][256];\n};\n\nvoid\ntwofish_set_key(struct twofish_ctx *ctx,\n\t\tsize_t length, const uint8_t *key);\nvoid\ntwofish128_set_key(struct twofish_ctx *context, const uint8_t *key);\nvoid\ntwofish192_set_key(struct twofish_ctx *context, const uint8_t *key);\nvoid\ntwofish256_set_key(struct twofish_ctx *context, const uint8_t *key);\n\nvoid\ntwofish_encrypt(const struct twofish_ctx *ctx,\n\t\tsize_t length, uint8_t *dst,\n\t\tconst uint8_t *src);\nvoid\ntwofish_decrypt(const struct twofish_ctx *ctx,\n\t\tsize_t length, uint8_t *dst,\n\t\tconst uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_TWOFISH_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/umac.h",
    "content": "/* umac.h\n\n   UMAC message authentication code (RFC-4418).\n\n   Copyright (C) 2013 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_UMAC_H_INCLUDED\n#define NETTLE_UMAC_H_INCLUDED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Namespace mangling */\n#define umac32_set_key  nettle_umac32_set_key\n#define umac64_set_key  nettle_umac64_set_key\n#define umac96_set_key  nettle_umac96_set_key\n#define umac128_set_key nettle_umac128_set_key\n#define umac32_set_nonce  nettle_umac32_set_nonce\n#define umac64_set_nonce  nettle_umac64_set_nonce\n#define umac96_set_nonce  nettle_umac96_set_nonce\n#define umac128_set_nonce nettle_umac128_set_nonce\n#define umac32_update  nettle_umac32_update\n#define umac64_update  nettle_umac64_update\n#define umac96_update  nettle_umac96_update\n#define umac128_update nettle_umac128_update\n#define umac32_digest  nettle_umac32_digest\n#define umac64_digest  nettle_umac64_digest\n#define umac96_digest  nettle_umac96_digest\n#define umac128_digest nettle_umac128_digest\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#define UMAC_KEY_SIZE AES128_KEY_SIZE\n#define UMAC32_DIGEST_SIZE 4\n#define UMAC64_DIGEST_SIZE 8\n#define UMAC96_DIGEST_SIZE 12\n#define UMAC128_DIGEST_SIZE 16\n#define UMAC_BLOCK_SIZE 1024\n#define UMAC_MIN_NONCE_SIZE 1\n#define UMAC_MAX_NONCE_SIZE AES_BLOCK_SIZE\n/* For backwards compatibility */\n#define UMAC_DATA_SIZE UMAC_BLOCK_SIZE\n\n/* Subkeys and state for UMAC with tag size 32*n bits. */\n#define _UMAC_STATE(n)\t\t\t\t\t\\\n  uint32_t l1_key[UMAC_BLOCK_SIZE/4 + 4*((n)-1)];\t\\\n  /* Keys in 32-bit pieces, high first */\t\t\\\n  uint32_t l2_key[6*(n)];\t\t\t\t\\\n  uint64_t l3_key1[8*(n)];\t\t\t\t\\\n  uint32_t l3_key2[(n)];\t\t\t\t\\\n  /* AES cipher for encrypting the nonce */\t\t\\\n  struct aes128_ctx pdf_key;\t\t\t\t\\\n  /* The l2_state consists of 2*n uint64_t, for poly64\t\\\n     and poly128 hashing, followed by n additional\t\\\n     uint64_t used as an input buffer. */\t\t\\\n  uint64_t l2_state[3*(n)];\t\t\t\t\\\n  /* Input to the pdf_key, zero-padded and low bits\t\\\n     cleared if appropriate. */\t\t\t\t\\\n  uint8_t nonce[AES_BLOCK_SIZE];\t\t\t\\\n  unsigned short nonce_length /* For incrementing */\n\n  /* Buffering */ \n#define _UMAC_BUFFER\t\t\t\t\t\\\n  unsigned index;\t\t\t\t\t\\\n  /* Complete blocks processed */\t\t\t\\\n  uint64_t count;\t\t\t\t\t\\\n  uint8_t block[UMAC_BLOCK_SIZE]\n  \n#define _UMAC_NONCE_CACHED 0x80\n\nstruct umac32_ctx\n{\n  _UMAC_STATE(1);\n  /* Low bits and cache flag. */\n  unsigned short nonce_low;\n  /* Previous padding block */\n  uint32_t pad_cache[AES_BLOCK_SIZE / 4];\n  _UMAC_BUFFER;\n};\n\nstruct umac64_ctx\n{\n  _UMAC_STATE(2);\n  /* Low bit and cache flag. */\n  unsigned short nonce_low;\n  /* Previous padding block */\n  uint32_t pad_cache[AES_BLOCK_SIZE/4];\n  _UMAC_BUFFER;\n};\n\nstruct umac96_ctx\n{\n  _UMAC_STATE(3);\n  _UMAC_BUFFER;\n};\n\nstruct umac128_ctx\n{\n  _UMAC_STATE(4);\n  _UMAC_BUFFER;\n};\n\n/* The _set_key function initialize the nonce to zero. */\nvoid\numac32_set_key (struct umac32_ctx *ctx, const uint8_t *key);\nvoid\numac64_set_key (struct umac64_ctx *ctx, const uint8_t *key);\nvoid\numac96_set_key (struct umac96_ctx *ctx, const uint8_t *key);\nvoid\numac128_set_key (struct umac128_ctx *ctx, const uint8_t *key);\n\n/* Optional, if not used, messages get incrementing nonces starting from zero. */\nvoid\numac32_set_nonce (struct umac32_ctx *ctx,\n\t\t  size_t nonce_length, const uint8_t *nonce);\nvoid\numac64_set_nonce (struct umac64_ctx *ctx,\n\t\t  size_t nonce_length, const uint8_t *nonce);\nvoid\numac96_set_nonce (struct umac96_ctx *ctx,\n\t\t  size_t nonce_length, const uint8_t *nonce);\nvoid\numac128_set_nonce (struct umac128_ctx *ctx,\n\t\t   size_t nonce_length, const uint8_t *nonce);\n\nvoid\numac32_update (struct umac32_ctx *ctx,\n\t       size_t length, const uint8_t *data);\nvoid\numac64_update (struct umac64_ctx *ctx,\n\t       size_t length, const uint8_t *data);\nvoid\numac96_update (struct umac96_ctx *ctx,\n\t       size_t length, const uint8_t *data);\nvoid\numac128_update (struct umac128_ctx *ctx,\n\t\tsize_t length, const uint8_t *data);\n\n/* The _digest functions increment the nonce */\nvoid\numac32_digest (struct umac32_ctx *ctx,\n\t       size_t length, uint8_t *digest);\nvoid\numac64_digest (struct umac64_ctx *ctx,\n\t       size_t length, uint8_t *digest);\nvoid\numac96_digest (struct umac96_ctx *ctx,\n\t       size_t length, uint8_t *digest);\nvoid\numac128_digest (struct umac128_ctx *ctx,\n\t\tsize_t length, uint8_t *digest);\n\n\n/* Internal functions */\n#define UMAC_POLY64_BLOCKS 16384\n\n#define UMAC_P64_OFFSET 59\n#define UMAC_P64 (- (uint64_t) UMAC_P64_OFFSET)\n\n#define UMAC_P128_OFFSET 159\n#define UMAC_P128_HI (~(uint64_t) 0)\n#define UMAC_P128_LO (-(uint64_t) UMAC_P128_OFFSET)\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_UMAC_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/version.h",
    "content": "/* version.h\n\n   Information about library version.\n\n   Copyright (C) 2015 Red Hat, Inc.\n   Copyright (C) 2015 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n#ifndef NETTLE_VERSION_H_INCLUDED\n#define NETTLE_VERSION_H_INCLUDED\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Individual version numbers in decimal */\n#define NETTLE_VERSION_MAJOR 3\n#define NETTLE_VERSION_MINOR 9\n\n#define NETTLE_USE_MINI_GMP 0\n\n/* We need a preprocessor constant for GMP_NUMB_BITS, simply using\n   sizeof(mp_limb_t) * CHAR_BIT is not good enough. */\n#if NETTLE_USE_MINI_GMP\n# define GMP_NUMB_BITS n/a\n#endif\n\nint\nnettle_version_major (void);\n\nint\nnettle_version_minor (void);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_VERSION_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/xts.h",
    "content": "/* xts.h\n\n   XEX-based tweaked-codebook mode with ciphertext stealing (XTS)\n\n   Copyright (C) 2005 Niels Möller\n   Copyright (C) 2018 Red Hat, Inc.\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n\n\n#ifndef NETTLE_XTS_H_INCLUDED\n#define NETTLE_XTS_H_INCLUDED\n\n#include \"nettle-types.h\"\n#include \"aes.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define xts_encrypt_message nettle_xts_encrypt_message\n#define xts_decrypt_message nettle_xts_decrypt_message\n#define xts_aes128_set_encrypt_key nettle_xts_aes128_set_encrypt_key\n#define xts_aes128_set_decrypt_key nettle_xts_aes128_set_decrypt_key\n#define xts_aes128_encrypt_message nettle_xts_aes128_encrypt_message\n#define xts_aes128_decrypt_message nettle_xts_aes128_decrypt_message\n#define xts_aes256_set_encrypt_key nettle_xts_aes256_set_encrypt_key\n#define xts_aes256_set_decrypt_key nettle_xts_aes256_set_decrypt_key\n#define xts_aes256_encrypt_message nettle_xts_aes256_encrypt_message\n#define xts_aes256_decrypt_message nettle_xts_aes256_decrypt_message\n\n#define XTS_BLOCK_SIZE 16\n\nvoid\nxts_encrypt_message(const void *enc_ctx, const void *twk_ctx,\n                nettle_cipher_func *encf,\n                const uint8_t *tweak, size_t length,\n                uint8_t *dst, const uint8_t *src);\nvoid\nxts_decrypt_message(const void *dec_ctx, const void *twk_ctx,\n                    nettle_cipher_func *decf, nettle_cipher_func *encf,\n                    const uint8_t *tweak, size_t length,\n                    uint8_t *dst, const uint8_t *src);\n\n/* XTS Mode with AES-128 */\nstruct xts_aes128_key {\n    struct aes128_ctx cipher;\n    struct aes128_ctx tweak_cipher;\n};\n\nvoid\nxts_aes128_set_encrypt_key(struct xts_aes128_key *xts_key,\n                           const uint8_t *key);\n\nvoid\nxts_aes128_set_decrypt_key(struct xts_aes128_key *xts_key,\n                           const uint8_t *key);\n\nvoid\nxts_aes128_encrypt_message(const struct xts_aes128_key *xtskey,\n                           const uint8_t *tweak, size_t length,\n                           uint8_t *dst, const uint8_t *src);\n\nvoid\nxts_aes128_decrypt_message(const struct xts_aes128_key *xts_key,\n                           const uint8_t *tweak, size_t length,\n                           uint8_t *dst, const uint8_t *src);\n\n/* XTS Mode with AES-256 */\nstruct xts_aes256_key {\n    struct aes256_ctx cipher;\n    struct aes256_ctx tweak_cipher;\n};\n\nvoid\nxts_aes256_set_encrypt_key(struct xts_aes256_key *xts_key,\n                           const uint8_t *key);\n\nvoid\nxts_aes256_set_decrypt_key(struct xts_aes256_key *xts_key,\n                           const uint8_t *key);\n\nvoid\nxts_aes256_encrypt_message(const struct xts_aes256_key *xts_key,\n                           const uint8_t *tweak, size_t length,\n                           uint8_t *dst, const uint8_t *src);\n\nvoid\nxts_aes256_decrypt_message(const struct xts_aes256_key *xts_key,\n                           const uint8_t *tweak, size_t length,\n                           uint8_t *dst, const uint8_t *src);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_XTS_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/nettle/yarrow.h",
    "content": "/* yarrow.h\n\n   The yarrow pseudo-randomness generator.\n\n   Copyright (C) 2001 Niels Möller\n\n   This file is part of GNU Nettle.\n\n   GNU Nettle is free software: you can redistribute it and/or\n   modify it under the terms of either:\n\n     * the GNU Lesser General Public License as published by the Free\n       Software Foundation; either version 3 of the License, or (at your\n       option) any later version.\n\n   or\n\n     * the GNU General Public License as published by the Free\n       Software Foundation; either version 2 of the License, or (at your\n       option) any later version.\n\n   or both in parallel, as here.\n\n   GNU Nettle is distributed in the hope that it will be useful,\n   but WITHOUT ANY WARRANTY; without even the implied warranty of\n   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n   General Public License for more details.\n\n   You should have received copies of the GNU General Public License and\n   the GNU Lesser General Public License along with this program.  If\n   not, see http://www.gnu.org/licenses/.\n*/\n \n#ifndef NETTLE_YARROW_H_INCLUDED\n#define NETTLE_YARROW_H_INCLUDED\n\n#include \"aes.h\"\n#include \"sha2.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Name mangling */\n#define yarrow256_init nettle_yarrow256_init\n#define yarrow256_seed nettle_yarrow256_seed\n#define yarrow256_update nettle_yarrow256_update\n#define yarrow256_random nettle_yarrow256_random\n#define yarrow256_is_seeded nettle_yarrow256_is_seeded\n#define yarrow256_needed_sources nettle_yarrow256_needed_sources\n#define yarrow256_fast_reseed nettle_yarrow256_fast_reseed\n#define yarrow256_slow_reseed nettle_yarrow256_slow_reseed\n#define yarrow_key_event_init nettle_yarrow_key_event_init\n#define yarrow_key_event_estimate nettle_yarrow_key_event_estimate\n\n/* Obsolete alias for backwards compatibility. Will be deleted in some\n   later version. */\n#define yarrow256_force_reseed yarrow256_slow_reseed\n  \nenum yarrow_pool_id { YARROW_FAST = 0, YARROW_SLOW = 1 };\n\nstruct yarrow_source\n{\n  /* Indexed by yarrow_pool_id */\n  uint32_t estimate[2];\n  \n  /* The pool next sample should go to. */\n  enum yarrow_pool_id next;\n};\n\n\n#define YARROW256_SEED_FILE_SIZE (2 * AES_BLOCK_SIZE)\n\n/* Yarrow-256, based on SHA-256 and AES-256 */\nstruct yarrow256_ctx\n{\n  /* Indexed by yarrow_pool_id */\n  struct sha256_ctx pools[2];\n\n  int seeded;\n\n  /* The current key and counter block */\n  struct aes256_ctx key;\n  uint8_t counter[AES_BLOCK_SIZE];\n\n  /* The entropy sources */\n  unsigned nsources;\n  struct yarrow_source *sources;\n};\n\nvoid\nyarrow256_init(struct yarrow256_ctx *ctx,\n\t       unsigned nsources,\n\t       struct yarrow_source *sources);\n\nvoid\nyarrow256_seed(struct yarrow256_ctx *ctx,\n\t       size_t length,\n\t       const uint8_t *seed_file);\n\n/* Returns 1 on reseed */\nint\nyarrow256_update(struct yarrow256_ctx *ctx,\n\t\t unsigned source, unsigned entropy,\n\t\t size_t length, const uint8_t *data);\n\nvoid\nyarrow256_random(struct yarrow256_ctx *ctx, size_t length, uint8_t *dst);\n\nint\nyarrow256_is_seeded(struct yarrow256_ctx *ctx);\n\nunsigned\nyarrow256_needed_sources(struct yarrow256_ctx *ctx);\n\nvoid\nyarrow256_fast_reseed(struct yarrow256_ctx *ctx);\n\nvoid\nyarrow256_slow_reseed(struct yarrow256_ctx *ctx);\n\n\n/* Key event estimator */\n#define YARROW_KEY_EVENT_BUFFER 16\n\nstruct yarrow_key_event_ctx\n{\n  /* Counter for initial priming of the state */\n  unsigned index;\n  unsigned chars[YARROW_KEY_EVENT_BUFFER];\n  unsigned previous;\n};\n\nvoid\nyarrow_key_event_init(struct yarrow_key_event_ctx *ctx);\n\nunsigned\nyarrow_key_event_estimate(struct yarrow_key_event_ctx *ctx,\n\t\t\t  unsigned key, unsigned time);\n  \n#ifdef __cplusplus\n}\n#endif\n\n#endif /* NETTLE_YARROW_H_INCLUDED */\n"
  },
  {
    "path": "thirdparty/64/include/opencore-amrnb/interf_dec.h",
    "content": "/* ------------------------------------------------------------------\n * Copyright (C) 2009 Martin Storsjo\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n * -------------------------------------------------------------------\n */\n\n#ifndef OPENCORE_AMRNB_INTERF_DEC_H\n#define OPENCORE_AMRNB_INTERF_DEC_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nvoid* Decoder_Interface_init(void);\nvoid Decoder_Interface_exit(void* state);\nvoid Decoder_Interface_Decode(void* state, const unsigned char* in, short* out, int bfi);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/opencore-amrnb/interf_enc.h",
    "content": "/* ------------------------------------------------------------------\n * Copyright (C) 2009 Martin Storsjo\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n * -------------------------------------------------------------------\n */\n\n#ifndef OPENCORE_AMRNB_INTERF_ENC_H\n#define OPENCORE_AMRNB_INTERF_ENC_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#ifndef AMRNB_WRAPPER_INTERNAL\n/* Copied from enc/src/gsmamr_enc.h */\nenum Mode {\n\tMR475 = 0,/* 4.75 kbps */\n\tMR515,    /* 5.15 kbps */\n\tMR59,     /* 5.90 kbps */\n\tMR67,     /* 6.70 kbps */\n\tMR74,     /* 7.40 kbps */\n\tMR795,    /* 7.95 kbps */\n\tMR102,    /* 10.2 kbps */\n\tMR122,    /* 12.2 kbps */\n\tMRDTX,    /* DTX       */\n\tN_MODES   /* Not Used  */\n};\n#endif\n\nvoid* Encoder_Interface_init(int dtx);\nvoid Encoder_Interface_exit(void* state);\nint Encoder_Interface_Encode(void* state, enum Mode mode, const short* speech, unsigned char* out, int forceSpeech);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/opencore-amrwb/dec_if.h",
    "content": "/* ------------------------------------------------------------------\n * Copyright (C) 2009 Martin Storsjo\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n * -------------------------------------------------------------------\n */\n\n#ifndef OPENCORE_AMRWB_DEC_IF_H\n#define OPENCORE_AMRWB_DEC_IF_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#define _good_frame 0\n\nvoid* D_IF_init(void);\nvoid D_IF_decode(void* state, const unsigned char* bits, short* synth, int bfi);\nvoid D_IF_exit(void* state);\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/opencore-amrwb/if_rom.h",
    "content": "/* ------------------------------------------------------------------\n * Copyright (C) 2009 Martin Storsjo\n *\n * Licensed under the Apache License, Version 2.0 (the \"License\");\n * you may not use this file except in compliance with the License.\n * You may obtain a copy of the License at\n *\n *      http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either\n * express or implied.\n * See the License for the specific language governing permissions\n * and limitations under the License.\n * -------------------------------------------------------------------\n */\n\n#ifndef OPENCORE_AMRWB_IF_ROM_H\n#define OPENCORE_AMRWB_IF_ROM_H\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n#include <stdint.h>\ntypedef int16_t Word16;\n\n#ifdef __cplusplus\n}\n#endif\n\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/speex/speex.h",
    "content": "/* Copyright (C) 2002-2006 Jean-Marc Valin*/\n/**\n  @file speex.h\n  @brief Describes the different modes of the codec\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n#ifndef SPEEX_H\n#define SPEEX_H\n/** @defgroup Codec Speex encoder and decoder\n *  This is the Speex codec itself.\n *  @{\n */\n\n#include \"speex_types.h\"\n#include \"speex_bits.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/* Values allowed for *ctl() requests */\n\n/** Set enhancement on/off (decoder only) */\n#define SPEEX_SET_ENH 0\n/** Get enhancement state (decoder only) */\n#define SPEEX_GET_ENH 1\n\n/*Would be SPEEX_SET_FRAME_SIZE, but it's (currently) invalid*/\n/** Obtain frame size used by encoder/decoder */\n#define SPEEX_GET_FRAME_SIZE 3\n\n/** Set quality value */\n#define SPEEX_SET_QUALITY 4\n/** Get current quality setting */\n/* #define SPEEX_GET_QUALITY 5 -- Doesn't make much sense, does it? */\n\n/** Set sub-mode to use */\n#define SPEEX_SET_MODE 6\n/** Get current sub-mode in use */\n#define SPEEX_GET_MODE 7\n\n/** Set low-band sub-mode to use (wideband only)*/\n#define SPEEX_SET_LOW_MODE 8\n/** Get current low-band mode in use (wideband only)*/\n#define SPEEX_GET_LOW_MODE 9\n\n/** Set high-band sub-mode to use (wideband only)*/\n#define SPEEX_SET_HIGH_MODE 10\n/** Get current high-band mode in use (wideband only)*/\n#define SPEEX_GET_HIGH_MODE 11\n\n/** Set VBR on (1) or off (0) */\n#define SPEEX_SET_VBR 12\n/** Get VBR status (1 for on, 0 for off) */\n#define SPEEX_GET_VBR 13\n\n/** Set quality value for VBR encoding (0-10) */\n#define SPEEX_SET_VBR_QUALITY 14\n/** Get current quality value for VBR encoding (0-10) */\n#define SPEEX_GET_VBR_QUALITY 15\n\n/** Set complexity of the encoder (0-10) */\n#define SPEEX_SET_COMPLEXITY 16\n/** Get current complexity of the encoder (0-10) */\n#define SPEEX_GET_COMPLEXITY 17\n\n/** Set bit-rate used by the encoder (or lower) */\n#define SPEEX_SET_BITRATE 18\n/** Get current bit-rate used by the encoder or decoder */\n#define SPEEX_GET_BITRATE 19\n\n/** Define a handler function for in-band Speex request*/\n#define SPEEX_SET_HANDLER 20\n\n/** Define a handler function for in-band user-defined request*/\n#define SPEEX_SET_USER_HANDLER 22\n\n/** Set sampling rate used in bit-rate computation */\n#define SPEEX_SET_SAMPLING_RATE 24\n/** Get sampling rate used in bit-rate computation */\n#define SPEEX_GET_SAMPLING_RATE 25\n\n/** Reset the encoder/decoder memories to zero*/\n#define SPEEX_RESET_STATE 26\n\n/** Get VBR info (mostly used internally) */\n#define SPEEX_GET_RELATIVE_QUALITY 29\n\n/** Set VAD status (1 for on, 0 for off) */\n#define SPEEX_SET_VAD 30\n\n/** Get VAD status (1 for on, 0 for off) */\n#define SPEEX_GET_VAD 31\n\n/** Set Average Bit-Rate (ABR) to n bits per seconds */\n#define SPEEX_SET_ABR 32\n/** Get Average Bit-Rate (ABR) setting (in bps) */\n#define SPEEX_GET_ABR 33\n\n/** Set DTX status (1 for on, 0 for off) */\n#define SPEEX_SET_DTX 34\n/** Get DTX status (1 for on, 0 for off) */\n#define SPEEX_GET_DTX 35\n\n/** Set submode encoding in each frame (1 for yes, 0 for no, setting to no breaks the standard) */\n#define SPEEX_SET_SUBMODE_ENCODING 36\n/** Get submode encoding in each frame */\n#define SPEEX_GET_SUBMODE_ENCODING 37\n\n/*#define SPEEX_SET_LOOKAHEAD 38*/\n/** Returns the lookahead used by Speex separately for an encoder and a decoder.\n *  Sum encoder and decoder lookahead values to get the total codec lookahead. */\n#define SPEEX_GET_LOOKAHEAD 39\n\n/** Sets tuning for packet-loss concealment (expected loss rate) */\n#define SPEEX_SET_PLC_TUNING 40\n/** Gets tuning for PLC */\n#define SPEEX_GET_PLC_TUNING 41\n\n/** Sets the max bit-rate allowed in VBR mode */\n#define SPEEX_SET_VBR_MAX_BITRATE 42\n/** Gets the max bit-rate allowed in VBR mode */\n#define SPEEX_GET_VBR_MAX_BITRATE 43\n\n/** Turn on/off input/output high-pass filtering */\n#define SPEEX_SET_HIGHPASS 44\n/** Get status of input/output high-pass filtering */\n#define SPEEX_GET_HIGHPASS 45\n\n/** Get \"activity level\" of the last decoded frame, i.e.\n    how much damage we cause if we remove the frame */\n#define SPEEX_GET_ACTIVITY 47\n\n\n/* Preserving compatibility:*/\n/** Equivalent to SPEEX_SET_ENH */\n#define SPEEX_SET_PF 0\n/** Equivalent to SPEEX_GET_ENH */\n#define SPEEX_GET_PF 1\n\n\n\n\n/* Values allowed for mode queries */\n/** Query the frame size of a mode */\n#define SPEEX_MODE_FRAME_SIZE 0\n\n/** Query the size of an encoded frame for a particular sub-mode */\n#define SPEEX_SUBMODE_BITS_PER_FRAME 1\n\n\n\n/** Get major Speex version */\n#define SPEEX_LIB_GET_MAJOR_VERSION 1\n/** Get minor Speex version */\n#define SPEEX_LIB_GET_MINOR_VERSION 3\n/** Get micro Speex version */\n#define SPEEX_LIB_GET_MICRO_VERSION 5\n/** Get extra Speex version */\n#define SPEEX_LIB_GET_EXTRA_VERSION 7\n/** Get Speex version string */\n#define SPEEX_LIB_GET_VERSION_STRING 9\n\n/*#define SPEEX_LIB_SET_ALLOC_FUNC 10\n#define SPEEX_LIB_GET_ALLOC_FUNC 11\n#define SPEEX_LIB_SET_FREE_FUNC 12\n#define SPEEX_LIB_GET_FREE_FUNC 13\n\n#define SPEEX_LIB_SET_WARNING_FUNC 14\n#define SPEEX_LIB_GET_WARNING_FUNC 15\n#define SPEEX_LIB_SET_ERROR_FUNC 16\n#define SPEEX_LIB_GET_ERROR_FUNC 17\n*/\n\n/** Number of defined modes in Speex */\n#define SPEEX_NB_MODES 3\n\n/** modeID for the defined narrowband mode */\n#define SPEEX_MODEID_NB 0\n\n/** modeID for the defined wideband mode */\n#define SPEEX_MODEID_WB 1\n\n/** modeID for the defined ultra-wideband mode */\n#define SPEEX_MODEID_UWB 2\n\nstruct SpeexMode;\n\n\n/* Prototypes for mode function pointers */\n\n/** Encoder state initialization function */\ntypedef void *(*encoder_init_func)(const struct SpeexMode *mode);\n\n/** Encoder state destruction function */\ntypedef void (*encoder_destroy_func)(void *st);\n\n/** Main encoding function */\ntypedef int (*encode_func)(void *state, void *in, SpeexBits *bits);\n\n/** Function for controlling the encoder options */\ntypedef int (*encoder_ctl_func)(void *state, int request, void *ptr);\n\n/** Decoder state initialization function */\ntypedef void *(*decoder_init_func)(const struct SpeexMode *mode);\n\n/** Decoder state destruction function */\ntypedef void (*decoder_destroy_func)(void *st);\n\n/** Main decoding function */\ntypedef int  (*decode_func)(void *state, SpeexBits *bits, void *out);\n\n/** Function for controlling the decoder options */\ntypedef int (*decoder_ctl_func)(void *state, int request, void *ptr);\n\n\n/** Query function for a mode */\ntypedef int (*mode_query_func)(const void *mode, int request, void *ptr);\n\n/** Struct defining a Speex mode */\ntypedef struct SpeexMode {\n   /** Pointer to the low-level mode data */\n   const void *mode;\n\n   /** Pointer to the mode query function */\n   mode_query_func query;\n\n   /** The name of the mode (you should not rely on this to identify the mode)*/\n   const char *modeName;\n\n   /**ID of the mode*/\n   int modeID;\n\n   /**Version number of the bitstream (incremented every time we break\n    bitstream compatibility*/\n   int bitstream_version;\n\n   /** Pointer to encoder initialization function */\n   encoder_init_func enc_init;\n\n   /** Pointer to encoder destruction function */\n   encoder_destroy_func enc_destroy;\n\n   /** Pointer to frame encoding function */\n   encode_func enc;\n\n   /** Pointer to decoder initialization function */\n   decoder_init_func dec_init;\n\n   /** Pointer to decoder destruction function */\n   decoder_destroy_func dec_destroy;\n\n   /** Pointer to frame decoding function */\n   decode_func dec;\n\n   /** ioctl-like requests for encoder */\n   encoder_ctl_func enc_ctl;\n\n   /** ioctl-like requests for decoder */\n   decoder_ctl_func dec_ctl;\n\n} SpeexMode;\n\n/**\n * Returns a handle to a newly created Speex encoder state structure. For now,\n * the \"mode\" argument can be &nb_mode or &wb_mode . In the future, more modes\n * may be added. Note that for now if you have more than one channels to\n * encode, you need one state per channel.\n *\n * @param mode The mode to use (either speex_nb_mode or speex_wb.mode)\n * @return A newly created encoder state or NULL if state allocation fails\n */\nvoid *speex_encoder_init(const SpeexMode *mode);\n\n/** Frees all resources associated to an existing Speex encoder state.\n * @param state Encoder state to be destroyed */\nvoid speex_encoder_destroy(void *state);\n\n/** Uses an existing encoder state to encode one frame of speech pointed to by\n    \"in\". The encoded bit-stream is saved in \"bits\".\n @param state Encoder state\n @param in Frame that will be encoded with a +-2^15 range. This data MAY be\n        overwritten by the encoder and should be considered uninitialised\n        after the call.\n @param bits Bit-stream where the data will be written\n @return 0 if frame needs not be transmitted (DTX only), 1 otherwise\n */\nint speex_encode(void *state, float *in, SpeexBits *bits);\n\n/** Uses an existing encoder state to encode one frame of speech pointed to by\n    \"in\". The encoded bit-stream is saved in \"bits\".\n @param state Encoder state\n @param in Frame that will be encoded with a +-2^15 range\n @param bits Bit-stream where the data will be written\n @return 0 if frame needs not be transmitted (DTX only), 1 otherwise\n */\nint speex_encode_int(void *state, spx_int16_t *in, SpeexBits *bits);\n\n/** Used like the ioctl function to control the encoder parameters\n *\n * @param state Encoder state\n * @param request ioctl-type request (one of the SPEEX_* macros)\n * @param ptr Data exchanged to-from function\n * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter\n */\nint speex_encoder_ctl(void *state, int request, void *ptr);\n\n\n/** Returns a handle to a newly created decoder state structure. For now,\n * the mode argument can be &nb_mode or &wb_mode . In the future, more modes\n * may be added.  Note that for now if you have more than one channels to\n * decode, you need one state per channel.\n *\n * @param mode Speex mode (one of speex_nb_mode or speex_wb_mode)\n * @return A newly created decoder state or NULL if state allocation fails\n */\nvoid *speex_decoder_init(const SpeexMode *mode);\n\n/** Frees all resources associated to an existing decoder state.\n *\n * @param state State to be destroyed\n */\nvoid speex_decoder_destroy(void *state);\n\n/** Uses an existing decoder state to decode one frame of speech from\n * bit-stream bits. The output speech is saved written to out.\n *\n * @param state Decoder state\n * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost)\n * @param out Where to write the decoded frame\n * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream)\n */\nint speex_decode(void *state, SpeexBits *bits, float *out);\n\n/** Uses an existing decoder state to decode one frame of speech from\n * bit-stream bits. The output speech is saved written to out.\n *\n * @param state Decoder state\n * @param bits Bit-stream from which to decode the frame (NULL if the packet was lost)\n * @param out Where to write the decoded frame\n * @return return status (0 for no error, -1 for end of stream, -2 corrupt stream)\n */\nint speex_decode_int(void *state, SpeexBits *bits, spx_int16_t *out);\n\n/** Used like the ioctl function to control the encoder parameters\n *\n * @param state Decoder state\n * @param request ioctl-type request (one of the SPEEX_* macros)\n * @param ptr Data exchanged to-from function\n * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter\n */\nint speex_decoder_ctl(void *state, int request, void *ptr);\n\n\n/** Query function for mode information\n *\n * @param mode Speex mode\n * @param request ioctl-type request (one of the SPEEX_* macros)\n * @param ptr Data exchanged to-from function\n * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter\n */\nint speex_mode_query(const SpeexMode *mode, int request, void *ptr);\n\n/** Functions for controlling the behavior of libspeex\n * @param request ioctl-type request (one of the SPEEX_LIB_* macros)\n * @param ptr Data exchanged to-from function\n * @return 0 if no error, -1 if request in unknown, -2 for invalid parameter\n */\nint speex_lib_ctl(int request, void *ptr);\n\n/** Default narrowband mode */\nextern const SpeexMode speex_nb_mode;\n\n/** Default wideband mode */\nextern const SpeexMode speex_wb_mode;\n\n/** Default \"ultra-wideband\" mode */\nextern const SpeexMode speex_uwb_mode;\n\n/** List of all modes available */\nextern const SpeexMode * const speex_mode_list[SPEEX_NB_MODES];\n\n/** Obtain one of the modes available */\nconst SpeexMode * speex_lib_get_mode (int mode);\n\n#ifndef _WIN32\n/* We actually override the function in the narrowband case so that we can avoid linking in the wideband stuff */\n#define speex_lib_get_mode(mode) ((mode)==SPEEX_MODEID_NB ? &speex_nb_mode : speex_lib_get_mode (mode))\n#endif\n\n#ifdef __cplusplus\n}\n#endif\n\n/** @}*/\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/speex/speex_bits.h",
    "content": "/* Copyright (C) 2002 Jean-Marc Valin */\n/**\n   @file speex_bits.h\n   @brief Handles bit packing/unpacking\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n#ifndef BITS_H\n#define BITS_H\n/** @defgroup SpeexBits SpeexBits: Bit-stream manipulations\n *  This is the structure that holds the bit-stream when encoding or decoding\n * with Speex. It allows some manipulations as well.\n *  @{\n */\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/** Bit-packing data structure representing (part of) a bit-stream. */\ntypedef struct SpeexBits {\n   char *chars;   /**< \"raw\" data */\n   int   nbBits;  /**< Total number of bits stored in the stream*/\n   int   charPtr; /**< Position of the byte \"cursor\" */\n   int   bitPtr;  /**< Position of the bit \"cursor\" within the current char */\n   int   owner;   /**< Does the struct \"own\" the \"raw\" buffer (member \"chars\") */\n   int   overflow;/**< Set to one if we try to read past the valid data */\n   int   buf_size;/**< Allocated size for buffer */\n   int   reserved1; /**< Reserved for future use */\n   void *reserved2; /**< Reserved for future use */\n} SpeexBits;\n\n/** Initializes and allocates resources for a SpeexBits struct */\nvoid speex_bits_init(SpeexBits *bits);\n\n/** Initializes SpeexBits struct using a pre-allocated buffer*/\nvoid speex_bits_init_buffer(SpeexBits *bits, void *buff, int buf_size);\n\n/** Sets the bits in a SpeexBits struct to use data from an existing buffer (for decoding without copying data) */\nvoid speex_bits_set_bit_buffer(SpeexBits *bits, void *buff, int buf_size);\n\n/** Frees all resources associated to a SpeexBits struct. Right now this does nothing since no resources are allocated, but this could change in the future.*/\nvoid speex_bits_destroy(SpeexBits *bits);\n\n/** Resets bits to initial value (just after initialization, erasing content)*/\nvoid speex_bits_reset(SpeexBits *bits);\n\n/** Rewind the bit-stream to the beginning (ready for read) without erasing the content */\nvoid speex_bits_rewind(SpeexBits *bits);\n\n/** Initializes the bit-stream from the data in an area of memory */\nvoid speex_bits_read_from(SpeexBits *bits, const char *bytes, int len);\n\n/** Append bytes to the bit-stream\n *\n * @param bits Bit-stream to operate on\n * @param bytes pointer to the bytes what will be appended\n * @param len Number of bytes of append\n */\nvoid speex_bits_read_whole_bytes(SpeexBits *bits, const char *bytes, int len);\n\n/** Write the content of a bit-stream to an area of memory\n *\n * @param bits Bit-stream to operate on\n * @param bytes Memory location where to write the bits\n * @param max_len Maximum number of bytes to write (i.e. size of the \"bytes\" buffer)\n * @return Number of bytes written to the \"bytes\" buffer\n*/\nint speex_bits_write(SpeexBits *bits, char *bytes, int max_len);\n\n/** Like speex_bits_write, but writes only the complete bytes in the stream. Also removes the written bytes from the stream */\nint speex_bits_write_whole_bytes(SpeexBits *bits, char *bytes, int max_len);\n\n/** Append bits to the bit-stream\n * @param bits Bit-stream to operate on\n * @param data Value to append as integer\n * @param nbBits number of bits to consider in \"data\"\n */\nvoid speex_bits_pack(SpeexBits *bits, int data, int nbBits);\n\n/** Interpret the next bits in the bit-stream as a signed integer\n *\n * @param bits Bit-stream to operate on\n * @param nbBits Number of bits to interpret\n * @return A signed integer represented by the bits read\n */\nint speex_bits_unpack_signed(SpeexBits *bits, int nbBits);\n\n/** Interpret the next bits in the bit-stream as an unsigned integer\n *\n * @param bits Bit-stream to operate on\n * @param nbBits Number of bits to interpret\n * @return An unsigned integer represented by the bits read\n */\nunsigned int speex_bits_unpack_unsigned(SpeexBits *bits, int nbBits);\n\n/** Returns the number of bytes in the bit-stream, including the last one even if it is not \"full\"\n *\n * @param bits Bit-stream to operate on\n * @return Number of bytes in the stream\n */\nint speex_bits_nbytes(SpeexBits *bits);\n\n/** Same as speex_bits_unpack_unsigned, but without modifying the cursor position\n *\n * @param bits Bit-stream to operate on\n * @param nbBits Number of bits to look for\n * @return Value of the bits peeked, interpreted as unsigned\n */\nunsigned int speex_bits_peek_unsigned(SpeexBits *bits, int nbBits);\n\n/** Get the value of the next bit in the stream, without modifying the\n * \"cursor\" position\n *\n * @param bits Bit-stream to operate on\n * @return Value of the bit peeked (one bit only)\n */\nint speex_bits_peek(SpeexBits *bits);\n\n/** Advances the position of the \"bit cursor\" in the stream\n *\n * @param bits Bit-stream to operate on\n * @param n Number of bits to advance\n */\nvoid speex_bits_advance(SpeexBits *bits, int n);\n\n/** Returns the number of bits remaining to be read in a stream\n *\n * @param bits Bit-stream to operate on\n * @return Number of bits that can still be read from the stream\n */\nint speex_bits_remaining(SpeexBits *bits);\n\n/** Insert a terminator so that the data can be sent as a packet while auto-detecting\n * the number of frames in each packet\n *\n * @param bits Bit-stream to operate on\n */\nvoid speex_bits_insert_terminator(SpeexBits *bits);\n\n#ifdef __cplusplus\n}\n#endif\n\n/* @} */\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/speex/speex_callbacks.h",
    "content": "/* Copyright (C) 2002 Jean-Marc Valin*/\n/**\n  @file speex_callbacks.h\n  @brief Describes callback handling and in-band signalling\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n#ifndef SPEEX_CALLBACKS_H\n#define SPEEX_CALLBACKS_H\n/** @defgroup SpeexCallbacks Various definitions for Speex callbacks supported by the decoder.\n *  @{\n */\n\n#include \"speex.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/** Total number of callbacks */\n#define SPEEX_MAX_CALLBACKS 16\n\n/* Describes all the in-band requests */\n\n/*These are 1-bit requests*/\n/** Request for perceptual enhancement (1 for on, 0 for off) */\n#define SPEEX_INBAND_ENH_REQUEST         0\n/** Reserved */\n#define SPEEX_INBAND_RESERVED1           1\n\n/*These are 4-bit requests*/\n/** Request for a mode change */\n#define SPEEX_INBAND_MODE_REQUEST        2\n/** Request for a low mode change */\n#define SPEEX_INBAND_LOW_MODE_REQUEST    3\n/** Request for a high mode change */\n#define SPEEX_INBAND_HIGH_MODE_REQUEST   4\n/** Request for VBR (1 on, 0 off) */\n#define SPEEX_INBAND_VBR_QUALITY_REQUEST 5\n/** Request to be sent acknowledge */\n#define SPEEX_INBAND_ACKNOWLEDGE_REQUEST 6\n/** Request for VBR (1 for on, 0 for off) */\n#define SPEEX_INBAND_VBR_REQUEST         7\n\n/*These are 8-bit requests*/\n/** Send a character in-band */\n#define SPEEX_INBAND_CHAR                8\n/** Intensity stereo information */\n#define SPEEX_INBAND_STEREO              9\n\n/*These are 16-bit requests*/\n/** Transmit max bit-rate allowed */\n#define SPEEX_INBAND_MAX_BITRATE         10\n\n/*These are 32-bit requests*/\n/** Acknowledge packet reception */\n#define SPEEX_INBAND_ACKNOWLEDGE         12\n\n/** Callback function type */\ntypedef int (*speex_callback_func)(SpeexBits *bits, void *state, void *data);\n\n/** Callback information */\ntypedef struct SpeexCallback {\n   int callback_id;             /**< ID associated to the callback */\n   speex_callback_func func;    /**< Callback handler function */\n   void *data;                  /**< Data that will be sent to the handler */\n   void *reserved1;             /**< Reserved for future use */\n   int   reserved2;             /**< Reserved for future use */\n} SpeexCallback;\n\n/** Handle in-band request */\nint speex_inband_handler(SpeexBits *bits, SpeexCallback *callback_list, void *state);\n\n/** Standard handler for mode request (change mode, no questions asked) */\nint speex_std_mode_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for high mode request (change high mode, no questions asked) */\nint speex_std_high_mode_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for in-band characters (write to stderr) */\nint speex_std_char_handler(SpeexBits *bits, void *state, void *data);\n\n/** Default handler for user-defined requests: in this case, just ignore */\nint speex_default_user_handler(SpeexBits *bits, void *state, void *data);\n\n\n\n/** Standard handler for low mode request (change low mode, no questions asked) */\nint speex_std_low_mode_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for VBR request (Set VBR, no questions asked) */\nint speex_std_vbr_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for enhancer request (Turn enhancer on/off, no questions asked) */\nint speex_std_enh_request_handler(SpeexBits *bits, void *state, void *data);\n\n/** Standard handler for VBR quality request (Set VBR quality, no questions asked) */\nint speex_std_vbr_quality_request_handler(SpeexBits *bits, void *state, void *data);\n\n\n#ifdef __cplusplus\n}\n#endif\n\n/** @} */\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/speex/speex_config_types.h",
    "content": "#ifndef __SPEEX_TYPES_H__\n#define __SPEEX_TYPES_H__\n\n#include <stdint.h>\n\ntypedef int16_t spx_int16_t;\ntypedef uint16_t spx_uint16_t;\ntypedef int32_t spx_int32_t;\ntypedef uint32_t spx_uint32_t;\n\n#endif\n\n"
  },
  {
    "path": "thirdparty/64/include/speex/speex_header.h",
    "content": "/* Copyright (C) 2002 Jean-Marc Valin */\n/**\n   @file speex_header.h\n   @brief Describes the Speex header\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n*/\n\n\n#ifndef SPEEX_HEADER_H\n#define SPEEX_HEADER_H\n/** @defgroup SpeexHeader SpeexHeader: Makes it easy to write/parse an Ogg/Speex header\n *  This is the Speex header for the Ogg encapsulation. You don't need that if you just use RTP.\n *  @{\n */\n\n#include \"speex_types.h\"\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\nstruct SpeexMode;\n\n/** Length of the Speex header identifier */\n#define SPEEX_HEADER_STRING_LENGTH 8\n\n/** Maximum number of characters for encoding the Speex version number in the header */\n#define SPEEX_HEADER_VERSION_LENGTH 20\n\n/** Speex header info for file-based formats */\ntypedef struct SpeexHeader {\n   char speex_string[SPEEX_HEADER_STRING_LENGTH];   /**< Identifies a Speex bit-stream, always set to \"Speex   \" */\n   char speex_version[SPEEX_HEADER_VERSION_LENGTH]; /**< Speex version */\n   spx_int32_t speex_version_id;       /**< Version for Speex (for checking compatibility) */\n   spx_int32_t header_size;            /**< Total size of the header ( sizeof(SpeexHeader) ) */\n   spx_int32_t rate;                   /**< Sampling rate used */\n   spx_int32_t mode;                   /**< Mode used (0 for narrowband, 1 for wideband) */\n   spx_int32_t mode_bitstream_version; /**< Version ID of the bit-stream */\n   spx_int32_t nb_channels;            /**< Number of channels encoded */\n   spx_int32_t bitrate;                /**< Bit-rate used */\n   spx_int32_t frame_size;             /**< Size of frames */\n   spx_int32_t vbr;                    /**< 1 for a VBR encoding, 0 otherwise */\n   spx_int32_t frames_per_packet;      /**< Number of frames stored per Ogg packet */\n   spx_int32_t extra_headers;          /**< Number of additional headers after the comments */\n   spx_int32_t reserved1;              /**< Reserved for future use, must be zero */\n   spx_int32_t reserved2;              /**< Reserved for future use, must be zero */\n} SpeexHeader;\n\n/** Initializes a SpeexHeader using basic information */\nvoid speex_init_header(SpeexHeader *header, int rate, int nb_channels, const struct SpeexMode *m);\n\n/** Creates the header packet from the header itself (mostly involves endianness conversion) */\nchar *speex_header_to_packet(SpeexHeader *header, int *size);\n\n/** Creates a SpeexHeader from a packet */\nSpeexHeader *speex_packet_to_header(char *packet, int size);\n\n/** Frees the memory allocated by either speex_header_to_packet() or speex_packet_to_header() */\nvoid speex_header_free(void *ptr);\n\n#ifdef __cplusplus\n}\n#endif\n\n/** @} */\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/speex/speex_stereo.h",
    "content": "/* Copyright (C) 2002 Jean-Marc Valin*/\n/**\n   @file speex_stereo.h\n   @brief Describes the handling for intensity stereo\n*/\n/*\n   Redistribution and use in source and binary forms, with or without\n   modification, are permitted provided that the following conditions\n   are met:\n\n   - Redistributions of source code must retain the above copyright\n   notice, this list of conditions and the following disclaimer.\n\n   - Redistributions in binary form must reproduce the above copyright\n   notice, this list of conditions and the following disclaimer in the\n   documentation and/or other materials provided with the distribution.\n\n   - Neither the name of the Xiph.org Foundation nor the names of its\n   contributors may be used to endorse or promote products derived from\n   this software without specific prior written permission.\n\n   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS\n   ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT\n   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR\n   A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR\n   CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,\n   EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,\n   PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR\n   PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF\n   LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING\n   NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS\n   SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n*/\n\n#ifndef STEREO_H\n#define STEREO_H\n/** @defgroup SpeexStereoState SpeexStereoState: Handling Speex stereo files\n *  This describes the Speex intensity stereo encoding/decoding\n *  @{\n */\n\n#include \"speex_types.h\"\n#include \"speex_bits.h\"\n\n\n#ifdef __cplusplus\nextern \"C\" {\n#endif\n\n/** If you access any of these fields directly, I'll personally come and bite you */\ntypedef struct SpeexStereoState {\n   float balance;      /**< Left/right balance info */\n   float e_ratio;      /**< Ratio of energies: E(left+right)/[E(left)+E(right)]  */\n   float smooth_left;  /**< Smoothed left channel gain */\n   float smooth_right; /**< Smoothed right channel gain */\n   float reserved1;    /**< Reserved for future use */\n   float reserved2;    /**< Reserved for future use */\n} SpeexStereoState;\n\n/** Deprecated. Use speex_stereo_state_init() instead. */\n#define SPEEX_STEREO_STATE_INIT {1,.5,1,1,0,0}\n\n/** Initialise/create a stereo stereo state */\nSpeexStereoState *speex_stereo_state_init(void);\n\n/** Reset/re-initialise an already allocated stereo state */\nvoid speex_stereo_state_reset(SpeexStereoState *stereo);\n\n/** Destroy a stereo stereo state */\nvoid speex_stereo_state_destroy(SpeexStereoState *stereo);\n\n/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */\nvoid speex_encode_stereo(float *data, int frame_size, SpeexBits *bits);\n\n/** Transforms a stereo frame into a mono frame and stores intensity stereo info in 'bits' */\nvoid speex_encode_stereo_int(spx_int16_t *data, int frame_size, SpeexBits *bits);\n\n/** Transforms a mono frame into a stereo frame using intensity stereo info */\nvoid speex_decode_stereo(float *data, int frame_size, SpeexStereoState *stereo);\n\n/** Transforms a mono frame into a stereo frame using intensity stereo info */\nvoid speex_decode_stereo_int(spx_int16_t *data, int frame_size, SpeexStereoState *stereo);\n\n/** Callback handler for intensity stereo info */\nint speex_std_stereo_request_handler(SpeexBits *bits, void *state, void *data);\n\n#ifdef __cplusplus\n}\n#endif\n\n/** @} */\n#endif\n"
  },
  {
    "path": "thirdparty/64/include/speex/speex_types.h",
    "content": "/* speex_types.h taken from libogg */\n/********************************************************************\n *                                                                  *\n * THIS FILE IS PART OF THE OggVorbis SOFTWARE CODEC SOURCE CODE.   *\n * USE, DISTRIBUTION AND REPRODUCTION OF THIS LIBRARY SOURCE IS     *\n * GOVERNED BY A BSD-STYLE SOURCE LICENSE INCLUDED WITH THIS SOURCE *\n * IN 'COPYING'. PLEASE READ THESE TERMS BEFORE DISTRIBUTING.       *\n *                                                                  *\n * THE OggVorbis SOURCE CODE IS (C) COPYRIGHT 1994-2002             *\n * by the Xiph.Org Foundation http://www.xiph.org/                  *\n *                                                                  *\n ********************************************************************\n\n function: #ifdef jail to whip a few platforms into the UNIX ideal.\n last mod: $Id: os_types.h 7524 2004-08-11 04:20:36Z conrad $\n\n ********************************************************************/\n/**\n   @file speex_types.h\n   @brief Speex types\n*/\n#ifndef _SPEEX_TYPES_H\n#define _SPEEX_TYPES_H\n\n#if defined(_WIN32)\n\n#  if defined(__CYGWIN__)\n#    include <_G_config.h>\n     typedef _G_int32_t spx_int32_t;\n     typedef _G_uint32_t spx_uint32_t;\n     typedef _G_int16_t spx_int16_t;\n     typedef _G_uint16_t spx_uint16_t;\n#  elif defined(__MINGW32__)\n     typedef short spx_int16_t;\n     typedef unsigned short spx_uint16_t;\n     typedef int spx_int32_t;\n     typedef unsigned int spx_uint32_t;\n#  elif defined(__MWERKS__)\n     typedef int spx_int32_t;\n     typedef unsigned int spx_uint32_t;\n     typedef short spx_int16_t;\n     typedef unsigned short spx_uint16_t;\n#  else\n     /* MSVC/Borland */\n     typedef __int32 spx_int32_t;\n     typedef unsigned __int32 spx_uint32_t;\n     typedef __int16 spx_int16_t;\n     typedef unsigned __int16 spx_uint16_t;\n#  endif\n\n#elif defined(__MACOS__)\n\n#  include <sys/types.h>\n   typedef SInt16 spx_int16_t;\n   typedef UInt16 spx_uint16_t;\n   typedef SInt32 spx_int32_t;\n   typedef UInt32 spx_uint32_t;\n\n#elif (defined(__APPLE__) && defined(__MACH__)) /* MacOS X Framework build */\n\n#  include <sys/types.h>\n   typedef int16_t spx_int16_t;\n   typedef u_int16_t spx_uint16_t;\n   typedef int32_t spx_int32_t;\n   typedef u_int32_t spx_uint32_t;\n\n#elif defined(__BEOS__)\n\n   /* Be */\n#  include <inttypes.h>\n   typedef int16_t spx_int16_t;\n   typedef u_int16_t spx_uint16_t;\n   typedef int32_t spx_int32_t;\n   typedef u_int32_t spx_uint32_t;\n\n#elif defined (__EMX__)\n\n   /* OS/2 GCC */\n   typedef short spx_int16_t;\n   typedef unsigned short spx_uint16_t;\n   typedef int spx_int32_t;\n   typedef unsigned int spx_uint32_t;\n\n#elif defined (DJGPP)\n\n   /* DJGPP */\n   typedef short spx_int16_t;\n   typedef int spx_int32_t;\n   typedef unsigned int spx_uint32_t;\n\n#elif defined(R5900)\n\n   /* PS2 EE */\n   typedef int spx_int32_t;\n   typedef unsigned spx_uint32_t;\n   typedef short spx_int16_t;\n\n#elif defined(__SYMBIAN32__)\n\n   /* Symbian GCC */\n   typedef signed short spx_int16_t;\n   typedef unsigned short spx_uint16_t;\n   typedef signed int spx_int32_t;\n   typedef unsigned int spx_uint32_t;\n\n#elif defined(CONFIG_TI_C54X) || defined (CONFIG_TI_C55X)\n\n   typedef short spx_int16_t;\n   typedef unsigned short spx_uint16_t;\n   typedef long spx_int32_t;\n   typedef unsigned long spx_uint32_t;\n\n#elif defined(CONFIG_TI_C6X)\n\n   typedef short spx_int16_t;\n   typedef unsigned short spx_uint16_t;\n   typedef int spx_int32_t;\n   typedef unsigned int spx_uint32_t;\n\n#else\n\n#include \"speex_config_types.h\"\n\n#endif\n\n#endif  /* _SPEEX_TYPES_H */\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/dav1d.pc",
    "content": "prefix=.\nincludedir=${prefix}/include\nlibdir=${prefix}/lib\n\nName: libdav1d\nDescription: AV1 decoding library\nVersion: 1.5.1\nLibs: -L${libdir} -ldav1d\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/gmp.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nincludedir=${prefix}/include\nlibdir=${exec_prefix}/lib\n\nName: GNU MP\nDescription: GNU Multiple Precision Arithmetic Library\nURL: https://gmplib.org\nVersion: 6.3.0\nCflags: -I${includedir}\nLibs: -L${libdir} -lgmp\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/gnutls.pc",
    "content": "# Process this file with autoconf to produce a pkg-config metadata file.\n\n# Copyright (C) 2004-2012 Free Software Foundation, Inc.\n\n# Copying and distribution of this file, with or without modification,\n# are permitted in any medium without royalty provided the copyright\n# notice and this notice are preserved.  This file is offered as-is,\n# without any warranty.\n\n# Author: Simon Josefsson\n\nprefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: GnuTLS\nDescription: Transport Security Layer implementation for the GNU system\nURL: https://www.gnutls.org/\nVersion: 3.7.10\nLibs: -L${libdir} -lgnutls\nLibs.private: -lz -lws2_32 -L${libdir}  -latomic  -ladvapi32 -lcrypt32 -lncrypt -lbcrypt\nRequires.private: nettle, hogweed\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/hogweed.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\n# Uses Requires.private and Libs.private, under the assumption that\n# when using shared libraries, the ELF dependencies from libhogweed.so\n# to nettle and gmp work.\n\nName: Hogweed\nDescription: Nettle low-level cryptographic library (public-key algorithms)\nURL: http://www.lysator.liu.se/~nisse/nettle\nVersion: 3.9.1\nRequires:  nettle\nRequires.private: # nettle\nLibs: -L${libdir} -lhogweed  -lgmp -lnettle\nLibs.private: # -lgmp\nCflags: -I${includedir}\n\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/libxml-2.0.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\nmodules=1\n\nName: libXML\nVersion: 2.11.5\nDescription: libXML library version2.\nRequires:\nLibs: -L${libdir} -lxml2\nLibs.private: -lz     -lm\nCflags: -I${includedir}/libxml2  -DLIBXML_STATIC\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/nettle.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: Nettle\nDescription: Nettle low-level cryptographic library (symmetric algorithms)\nURL: http://www.lysator.liu.se/~nisse/nettle\nVersion: 3.9.1\nLibs: -L${libdir} -lnettle\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/opencore-amrnb.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: OpenCORE AMR-NB\nDescription: Adaptive Multi-Rate speech codec library\nVersion: 0.1.6\nLibs: -L${libdir} -lopencore-amrnb\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/opencore-amrwb.pc",
    "content": "prefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: OpenCORE AMR-WB\nDescription: Adaptive Multi-Rate Wideband speech codec library\nVersion: 0.1.6\nLibs: -L${libdir} -lopencore-amrwb\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/64/lib/pkgconfig/speex.pc",
    "content": "# libspeex pkg-config source file\n\nprefix=.\nexec_prefix=${prefix}\nlibdir=${exec_prefix}/lib\nincludedir=${prefix}/include\n\nName: speex\nDescription: Speex is an audio codec tuned for speech\nVersion: 1.2.1\nRequires:\nConflicts:\nLibs: -L${libdir} -lspeex\nLibs.private: -lm\nCflags: -I${includedir}\n"
  },
  {
    "path": "thirdparty/build instructions.txt",
    "content": "opencore-amr:\n\n32-bit:\n./configure --prefix=$PREFIX --enable-static --disable-shared --disable-amrnb-encoder\nmake\n\n64-bit:\n./configure --prefix=$PREFIX --host=x86_64-w64-mingw32 --enable-static --disable-shared --disable-amrnb-encoder\nmake\n\n----------------------------------------------\nSpeex:\n\n32-bit:\n./configure --prefix=$PREFIX --enable-sse --enable-static --disable-shared\nmake\n\n64-bit:\n./configure --prefix=$PREFIX --host=x86_64-w64-mingw32 --enable-sse --enable-static --disable-shared\n\n----------------------------------------------\ndav1d\n\n32-bit\nexport CC=gcc\nexport CXX=g++\nmeson setup build32 --prefix .. --buildtype release --default-library static && ninja -C build32\n\n64-bit\nmeson setup build64 --prefix .. --buildtype release --default-library static --cross-file x86_64-mingw64-cross.txt\n\n----------------------------------------------\ngnutls & deps\n\nPREFIX=/tmp/install\n\nGMP:\n32-bit\n./configure --prefix=$PREFIX --disable-shared --build=i686-w64-mingw32 --host=i686-w64-mingw32\n\n64-bit\n./configure --prefix=$PREFIX --disable-shared --build=i686-w64-mingw32 --host=x86_64-w64-mingw32\n\n\nNETTLE:\n32-bit\n./configure --prefix=$PREFIX --disable-shared --build=i686-w64-mingw32 --host=i686-w64-mingw32 --with-include-path=$PREFIX/include --with-lib-path=$PREFIX/lib\n\n64-bit\n./configure --prefix=$PREFIX --disable-shared --build=i686-w64-mingw32 --host=x86_64-w64-mingw32 --with-include-path=$PREFIX/include --with-lib-path=$PREFIX/lib\n\nGNUTLS:\n32-bit\nGMP_CFLAGS=\"-I$PREFIX/include\" GMP_LIBS=\"-L$PREFIX/lib\" PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig/ ./configure --prefix=$PREFIX --disable-shared --build=i686-w64-mingw32 --host=i686-w64-mingw32 --disable-cxx --with-included-libtasn1 --with-included-unistring --without-p11-kit\n\n64-bit\nGMP_CFLAGS=\"-I$PREFIX/include\" GMP_LIBS=\"-L$PREFIX/lib\" PKG_CONFIG_PATH=$PREFIX/lib/pkgconfig/ ./configure --prefix=$PREFIX --disable-shared --build=i686-w64-mingw32 --host=x86_64-w64-mingw32 --disable-cxx --with-included-libtasn1 --with-included-unistring --without-p11-kit\n\n----------------------------------------------\nlibxml2\n\nPREFIX=/tmp/install\n\n32-bit\n./configure --prefix=$PREFIX --disable-shared --build=i686-w64-mingw32 --host=i686-w64-mingw32 --without-threads --without-python --without-ftp --without-http\n\n64-bit\n./configure --prefix=$PREFIX --disable-shared -build=i686-w64-mingw32 --host=x86_64-w64-mingw32 --without-threads --without-python --without-ftp --without-http\n"
  },
  {
    "path": "thirdparty/versions.txt",
    "content": "DAV1D 1.5.1\n\nGMP 6.3.0\nNETTLE 3.9.1\nGNUTLS 3.7.10\n\nOPENCORE-AMR 0.1.6\nSPEEX 1.2.1\n\nLIBXML2 2.11.5\n"
  }
]